mpconfigport.h 7.96 KB
Newer Older
1
2
3
4
#include <stdint.h>

// options to control how Micro Python is built

5
#define MICROPY_OBJ_REPR            (MICROPY_OBJ_REPR_C)
6
#define MICROPY_ALLOC_PATH_MAX      (128)
7
8
9
10
11
#define MICROPY_ALLOC_LEXER_INDENT_INIT (8)
#define MICROPY_ALLOC_PARSE_RULE_INIT   (48)
#define MICROPY_ALLOC_PARSE_RULE_INC    (8)
#define MICROPY_ALLOC_PARSE_RESULT_INC  (8)
#define MICROPY_ALLOC_PARSE_CHUNK_INIT  (64)
12
#define MICROPY_PERSISTENT_CODE_LOAD (1)
13
#define MICROPY_EMIT_XTENSA         (1)
14
#define MICROPY_EMIT_INLINE_XTENSA  (1)
15
#define MICROPY_MEM_STATS           (0)
16
#define MICROPY_DEBUG_PRINTERS      (1)
17
#define MICROPY_DEBUG_PRINTER_DEST  mp_debug_print
18
#define MICROPY_READER_VFS          (MICROPY_VFS)
19
#define MICROPY_ENABLE_GC           (1)
20
#define MICROPY_STACK_CHECK         (1)
21
#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1)
22
#define MICROPY_KBD_EXCEPTION       (1)
23
#define MICROPY_REPL_EVENT_DRIVEN   (0)
24
#define MICROPY_REPL_AUTO_INDENT    (1)
25
26
27
#define MICROPY_HELPER_REPL         (1)
#define MICROPY_HELPER_LEXER_UNIX   (0)
#define MICROPY_ENABLE_SOURCE_LINE  (1)
28
#define MICROPY_MODULE_WEAK_LINKS   (1)
29
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
30
#define MICROPY_USE_INTERNAL_ERRNO  (1)
31
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
32
#define MICROPY_PY_BUILTINS_COMPLEX (0)
33
34
35
36
37
38
#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
#define MICROPY_PY_BUILTINS_BYTEARRAY (1)
#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
#define MICROPY_PY_BUILTINS_FROZENSET (1)
#define MICROPY_PY_BUILTINS_SET     (1)
#define MICROPY_PY_BUILTINS_SLICE   (1)
39
#define MICROPY_PY_BUILTINS_SLICE_ATTRS (1)
40
#define MICROPY_PY_BUILTINS_PROPERTY (1)
41
42
#define MICROPY_PY_BUILTINS_HELP    (1)
#define MICROPY_PY_BUILTINS_HELP_TEXT esp_help_text
43
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
44
45
46
#define MICROPY_PY___FILE__         (0)
#define MICROPY_PY_GC               (1)
#define MICROPY_PY_ARRAY            (1)
47
#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1)
48
#define MICROPY_PY_COLLECTIONS      (1)
49
#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1)
Damien George's avatar
Damien George committed
50
#define MICROPY_PY_MATH             (1)
51
52
#define MICROPY_PY_CMATH            (0)
#define MICROPY_PY_IO               (1)
53
#define MICROPY_PY_IO_FILEIO        (1)
54
55
#define MICROPY_PY_STRUCT           (1)
#define MICROPY_PY_SYS              (1)
56
#define MICROPY_PY_SYS_MAXSIZE      (1)
57
58
#define MICROPY_PY_SYS_EXIT         (1)
#define MICROPY_PY_SYS_STDFILES     (1)
59
#define MICROPY_PY_SYS_STDIO_BUFFER (1)
60
#define MICROPY_PY_UERRNO           (1)
61
62
#define MICROPY_PY_UBINASCII        (1)
#define MICROPY_PY_UCTYPES          (1)
63
#define MICROPY_PY_UHASHLIB         (1)
64
#define MICROPY_PY_UHASHLIB_SHA1    (MICROPY_PY_USSL && MICROPY_SSL_AXTLS)
65
#define MICROPY_PY_UHEAPQ           (1)
66
#define MICROPY_PY_UTIMEQ           (1)
67
#define MICROPY_PY_UJSON            (1)
68
#define MICROPY_PY_URANDOM          (1)
69
#define MICROPY_PY_URE              (1)
70
#define MICROPY_PY_USELECT          (1)
71
#define MICROPY_PY_UTIME_MP_HAL     (1)
72
#define MICROPY_PY_UZLIB            (1)
Damien George's avatar
Damien George committed
73
#define MICROPY_PY_LWIP             (1)
Paul Sokolovsky's avatar
Paul Sokolovsky committed
74
#define MICROPY_PY_MACHINE          (1)
75
#define MICROPY_PY_MACHINE_PULSE    (1)
76
#define MICROPY_PY_MACHINE_I2C      (1)
77
#define MICROPY_PY_MACHINE_SPI      (1)
78
#define MICROPY_PY_MACHINE_SPI_MAKE_NEW machine_hspi_make_new
79
#define MICROPY_PY_WEBSOCKET        (1)
80
#define MICROPY_PY_WEBREPL          (1)
81
#define MICROPY_PY_WEBREPL_DELAY    (20)
82
#define MICROPY_PY_FRAMEBUF         (1)
83
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
84
#define MICROPY_PY_OS_DUPTERM       (1)
85
#define MICROPY_CPYTHON_COMPAT      (1)
86
#define MICROPY_LONGINT_IMPL        (MICROPY_LONGINT_IMPL_MPZ)
87
#define MICROPY_FLOAT_IMPL          (MICROPY_FLOAT_IMPL_FLOAT)
88
#define MICROPY_ERROR_REPORTING     (MICROPY_ERROR_REPORTING_NORMAL)
89
90
#define MICROPY_WARNINGS            (1)
#define MICROPY_PY_STR_BYTES_CMP_WARN (1)
91
#define MICROPY_STREAMS_NON_BLOCK   (1)
92
#define MICROPY_STREAMS_POSIX_API   (1)
93
#define MICROPY_MODULE_FROZEN_STR   (1)
94
#define MICROPY_MODULE_FROZEN_MPY   (1)
95
#define MICROPY_MODULE_FROZEN_LEXER mp_lexer_new_from_str32
96
#define MICROPY_QSTR_EXTRA_POOL     mp_qstr_frozen_const_pool
97

98
#define MICROPY_VFS                    (1)
99
100
101
102
103
#define MICROPY_FATFS_ENABLE_LFN       (1)
#define MICROPY_FATFS_RPATH            (2)
#define MICROPY_FATFS_MAX_SS           (4096)
#define MICROPY_FATFS_LFN_CODE_PAGE    (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
#define MICROPY_VFS_FAT                (1)
104
#define MICROPY_ESP8266_APA102         (1)
105
#define MICROPY_ESP8266_NEOPIXEL       (1)
106

107
#define MICROPY_EVENT_POLL_HOOK {ets_event_poll();}
108
109
110
111
112
113
114
115
116
#define MICROPY_VM_HOOK_COUNT (10)
#define MICROPY_VM_HOOK_INIT static uint vm_hook_divisor = MICROPY_VM_HOOK_COUNT;
#define MICROPY_VM_HOOK_POLL if (--vm_hook_divisor == 0) { \
        vm_hook_divisor = MICROPY_VM_HOOK_COUNT; \
        extern void ets_loop_iter(void); \
        ets_loop_iter(); \
    }
#define MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_POLL
#define MICROPY_VM_HOOK_RETURN MICROPY_VM_HOOK_POLL
117

118
119
120
121
122
123
// type definitions for the specific machine

#define BYTES_PER_WORD (4)

#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p)))

124
125
#define MP_SSIZE_MAX (0x7fffffff)

126
127
128
129
130
131
#define UINT_FMT "%u"
#define INT_FMT "%d"

typedef int32_t mp_int_t; // must be pointer size
typedef uint32_t mp_uint_t; // must be pointer size
typedef long mp_off_t;
Damien George's avatar
Damien George committed
132
typedef uint32_t sys_prot_t; // for modlwip
133
134
// ssize_t, off_t as required by POSIX-signatured functions in stream.h
#include <sys/types.h>
135

136
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
137
138
void *esp_native_code_commit(void*, size_t);
#define MP_PLAT_COMMIT_EXEC(buf, len) esp_native_code_commit(buf, len)
139

140
141
142
#define mp_type_fileio fatfs_type_fileio
#define mp_type_textio fatfs_type_textio

143
144
145
146
147
// use vfs's functions for import stat and builtin open
#define mp_import_stat mp_vfs_import_stat
#define mp_builtin_open mp_vfs_open
#define mp_builtin_open_obj mp_vfs_open_obj

148
149
// extra built in names to add to the global namespace
#define MICROPY_PORT_BUILTINS \
150
    { MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
151
152
153
    { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },

// extra built in modules to add to the list of known ones
154
extern const struct _mp_obj_module_t esp_module;
155
extern const struct _mp_obj_module_t network_module;
156
extern const struct _mp_obj_module_t utime_module;
Josef Gajdusek's avatar
Josef Gajdusek committed
157
extern const struct _mp_obj_module_t uos_module;
Damien George's avatar
Damien George committed
158
extern const struct _mp_obj_module_t mp_module_lwip;
Paul Sokolovsky's avatar
Paul Sokolovsky committed
159
extern const struct _mp_obj_module_t mp_module_machine;
160
extern const struct _mp_obj_module_t onewire_module;
161
162

#define MICROPY_PORT_BUILTIN_MODULES \
163
    { MP_OBJ_NEW_QSTR(MP_QSTR_esp), (mp_obj_t)&esp_module }, \
Damien George's avatar
Damien George committed
164
    { MP_OBJ_NEW_QSTR(MP_QSTR_lwip), (mp_obj_t)&mp_module_lwip }, \
165
166
    { MP_OBJ_NEW_QSTR(MP_QSTR_socket), (mp_obj_t)&mp_module_lwip }, \
    { MP_OBJ_NEW_QSTR(MP_QSTR_usocket), (mp_obj_t)&mp_module_lwip }, \
167
    { MP_OBJ_NEW_QSTR(MP_QSTR_network), (mp_obj_t)&network_module }, \
168
    { MP_OBJ_NEW_QSTR(MP_QSTR_utime), (mp_obj_t)&utime_module }, \
Josef Gajdusek's avatar
Josef Gajdusek committed
169
    { MP_OBJ_NEW_QSTR(MP_QSTR_uos), (mp_obj_t)&uos_module }, \
Paul Sokolovsky's avatar
Paul Sokolovsky committed
170
    { MP_OBJ_NEW_QSTR(MP_QSTR_machine), (mp_obj_t)&mp_module_machine }, \
171
    { MP_OBJ_NEW_QSTR(MP_QSTR__onewire), (mp_obj_t)&onewire_module }, \
172

173
174
#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
    { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&utime_module }, \
Josef Gajdusek's avatar
Josef Gajdusek committed
175
    { MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&uos_module }, \
176
    { MP_OBJ_NEW_QSTR(MP_QSTR_json), (mp_obj_t)&mp_module_ujson }, \
177
    { MP_OBJ_NEW_QSTR(MP_QSTR_errno), (mp_obj_t)&mp_module_uerrno }, \
178
    { MP_OBJ_NEW_QSTR(MP_QSTR_select), (mp_obj_t)&mp_module_uselect }, \
179

180
181
182
#define MP_STATE_PORT MP_STATE_VM

#define MICROPY_PORT_ROOT_POINTERS \
183
    const char *readline_hist[8]; \
184
    vstr_t *repl_line; \
185
    mp_obj_t pin_irq_handler[16]; \
186

187
188
189
190
191
// We need to provide a declaration/definition of alloca()
#include <alloca.h>

// board specifics

192
#define MICROPY_MPHALPORT_H "esp_mphal.h"
193
194
#define MICROPY_HW_BOARD_NAME "ESP module"
#define MICROPY_HW_MCU_NAME "ESP8266"
195
#define MICROPY_PY_SYS_PLATFORM "esp8266"
196

197
198
#define MP_FASTCODE(n) __attribute__((section(".iram0.text." #n))) n

199
#define _assert(expr) ((expr) ? (void)0 : __assert_func(__FILE__, __LINE__, __func__, #expr))