2019-09-18 01:08:06 -04:00
|
|
|
// Options to control how MicroPython is built for this port,
|
|
|
|
// overriding defaults in py/mpconfig.h.
|
|
|
|
|
|
|
|
// Board-specific definitions
|
|
|
|
#include "mpconfigboard.h"
|
2014-11-27 15:30:33 -05:00
|
|
|
|
2019-09-18 01:08:06 -04:00
|
|
|
#include <stdint.h>
|
2014-11-27 15:30:33 -05:00
|
|
|
|
2015-12-18 16:07:58 -05:00
|
|
|
#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_C)
|
2018-12-04 02:32:10 -05:00
|
|
|
#define MICROPY_GC_STACK_ENTRY_TYPE uint16_t
|
2014-11-27 15:30:33 -05:00
|
|
|
#define MICROPY_ALLOC_PATH_MAX (128)
|
2016-05-10 08:34:30 -04:00
|
|
|
#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)
|
2014-11-27 15:30:33 -05:00
|
|
|
#define MICROPY_MEM_STATS (0)
|
2018-08-02 00:04:44 -04:00
|
|
|
#define MICROPY_DEBUG_PRINTER (&mp_debug_print)
|
2014-11-27 15:30:33 -05:00
|
|
|
#define MICROPY_ENABLE_GC (1)
|
2017-06-23 13:10:52 -04:00
|
|
|
#define MICROPY_ENABLE_FINALISER (1)
|
2016-02-13 08:44:53 -05:00
|
|
|
#define MICROPY_STACK_CHECK (1)
|
2016-10-13 10:27:53 -04:00
|
|
|
#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1)
|
2016-12-14 23:52:47 -05:00
|
|
|
#define MICROPY_KBD_EXCEPTION (1)
|
2016-04-01 07:22:28 -04:00
|
|
|
#define MICROPY_REPL_EVENT_DRIVEN (0)
|
2016-01-30 13:05:57 -05:00
|
|
|
#define MICROPY_REPL_AUTO_INDENT (1)
|
2014-11-27 15:30:33 -05:00
|
|
|
#define MICROPY_HELPER_REPL (1)
|
|
|
|
#define MICROPY_HELPER_LEXER_UNIX (0)
|
|
|
|
#define MICROPY_ENABLE_SOURCE_LINE (1)
|
2015-05-12 19:18:41 -04:00
|
|
|
#define MICROPY_MODULE_WEAK_LINKS (1)
|
2016-02-12 18:36:26 -05:00
|
|
|
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
|
2016-05-12 07:49:36 -04:00
|
|
|
#define MICROPY_USE_INTERNAL_ERRNO (1)
|
2017-02-15 01:45:36 -05:00
|
|
|
#define MICROPY_ENABLE_SCHEDULER (1)
|
2018-06-07 22:23:08 -04:00
|
|
|
#define MICROPY_PY_DESCRIPTORS (1)
|
2015-12-18 16:07:58 -05:00
|
|
|
#define MICROPY_PY_BUILTINS_COMPLEX (0)
|
2014-11-27 15:30:33 -05:00
|
|
|
#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)
|
|
|
|
#define MICROPY_PY_BUILTINS_PROPERTY (1)
|
2018-05-22 00:15:20 -04:00
|
|
|
#define MICROPY_PY_BUILTINS_ROUND_INT (1)
|
2017-06-01 01:43:20 -04:00
|
|
|
#define MICROPY_PY_BUILTINS_INPUT (1)
|
2017-01-21 07:22:44 -05:00
|
|
|
#define MICROPY_PY_BUILTINS_HELP (1)
|
|
|
|
#define MICROPY_PY_BUILTINS_HELP_TEXT esp_help_text
|
2017-02-24 02:26:51 -05:00
|
|
|
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
|
2014-11-27 15:30:33 -05:00
|
|
|
#define MICROPY_PY___FILE__ (0)
|
|
|
|
#define MICROPY_PY_GC (1)
|
|
|
|
#define MICROPY_PY_ARRAY (1)
|
2016-02-12 18:36:26 -05:00
|
|
|
#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1)
|
2014-11-27 15:30:33 -05:00
|
|
|
#define MICROPY_PY_COLLECTIONS (1)
|
2018-02-21 06:55:13 -05:00
|
|
|
#define MICROPY_PY_COLLECTIONS_DEQUE (1)
|
2016-05-21 19:57:05 -04:00
|
|
|
#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1)
|
2015-12-18 16:43:01 -05:00
|
|
|
#define MICROPY_PY_MATH (1)
|
2014-11-27 15:30:33 -05:00
|
|
|
#define MICROPY_PY_CMATH (0)
|
|
|
|
#define MICROPY_PY_IO (1)
|
2018-06-04 02:04:28 -04:00
|
|
|
#define MICROPY_PY_IO_IOBASE (1)
|
2014-11-27 15:30:33 -05:00
|
|
|
#define MICROPY_PY_STRUCT (1)
|
|
|
|
#define MICROPY_PY_SYS (1)
|
2016-02-12 18:36:26 -05:00
|
|
|
#define MICROPY_PY_SYS_MAXSIZE (1)
|
2014-11-27 15:30:33 -05:00
|
|
|
#define MICROPY_PY_SYS_EXIT (1)
|
|
|
|
#define MICROPY_PY_SYS_STDFILES (1)
|
2016-05-10 18:27:29 -04:00
|
|
|
#define MICROPY_PY_UERRNO (1)
|
2015-12-25 15:04:24 -05:00
|
|
|
#define MICROPY_PY_UBINASCII (1)
|
|
|
|
#define MICROPY_PY_UCTYPES (1)
|
2015-12-31 09:09:00 -05:00
|
|
|
#define MICROPY_PY_UHASHLIB (1)
|
2016-10-05 21:28:28 -04:00
|
|
|
#define MICROPY_PY_UHASHLIB_SHA1 (MICROPY_PY_USSL && MICROPY_SSL_AXTLS)
|
2016-02-13 05:41:10 -05:00
|
|
|
#define MICROPY_PY_UHEAPQ (1)
|
2016-12-23 06:49:13 -05:00
|
|
|
#define MICROPY_PY_UTIMEQ (1)
|
2015-12-25 15:04:24 -05:00
|
|
|
#define MICROPY_PY_UJSON (1)
|
2016-01-24 18:08:24 -05:00
|
|
|
#define MICROPY_PY_URANDOM (1)
|
2016-02-13 05:41:10 -05:00
|
|
|
#define MICROPY_PY_URE (1)
|
2016-12-02 00:44:31 -05:00
|
|
|
#define MICROPY_PY_USELECT (1)
|
2016-10-14 13:13:02 -04:00
|
|
|
#define MICROPY_PY_UTIME_MP_HAL (1)
|
2016-02-13 05:41:10 -05:00
|
|
|
#define MICROPY_PY_UZLIB (1)
|
2015-12-28 05:23:30 -05:00
|
|
|
#define MICROPY_PY_LWIP (1)
|
2019-07-30 08:58:54 -04:00
|
|
|
#define MICROPY_PY_LWIP_SOCK_RAW (1)
|
2015-12-30 17:52:01 -05:00
|
|
|
#define MICROPY_PY_MACHINE (1)
|
2017-04-10 17:12:20 -04:00
|
|
|
#define MICROPY_PY_MACHINE_PIN_MAKE_NEW mp_pin_make_new
|
2016-05-31 09:25:19 -04:00
|
|
|
#define MICROPY_PY_MACHINE_PULSE (1)
|
2016-04-12 08:55:20 -04:00
|
|
|
#define MICROPY_PY_MACHINE_I2C (1)
|
2016-09-01 01:10:27 -04:00
|
|
|
#define MICROPY_PY_MACHINE_SPI (1)
|
2016-12-07 22:41:58 -05:00
|
|
|
#define MICROPY_PY_MACHINE_SPI_MAKE_NEW machine_hspi_make_new
|
2019-02-10 15:35:18 -05:00
|
|
|
#define MICROPY_PY_UWEBSOCKET (1)
|
2016-04-29 12:38:21 -04:00
|
|
|
#define MICROPY_PY_WEBREPL (1)
|
2016-04-29 12:15:26 -04:00
|
|
|
#define MICROPY_PY_WEBREPL_DELAY (20)
|
2019-07-02 22:55:57 -04:00
|
|
|
#define MICROPY_PY_WEBREPL_STATIC_FILEBUF (1)
|
2015-12-26 09:30:37 -05:00
|
|
|
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
|
2018-05-15 01:13:58 -04:00
|
|
|
#define MICROPY_PY_OS_DUPTERM (2)
|
2016-02-12 18:36:26 -05:00
|
|
|
#define MICROPY_CPYTHON_COMPAT (1)
|
2015-12-17 17:15:04 -05:00
|
|
|
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
|
2015-12-18 16:07:58 -05:00
|
|
|
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
|
2016-07-21 17:57:55 -04:00
|
|
|
#define MICROPY_WARNINGS (1)
|
|
|
|
#define MICROPY_PY_STR_BYTES_CMP_WARN (1)
|
2016-01-03 00:19:04 -05:00
|
|
|
#define MICROPY_STREAMS_NON_BLOCK (1)
|
2016-07-30 13:05:56 -04:00
|
|
|
#define MICROPY_STREAMS_POSIX_API (1)
|
2016-01-31 17:24:16 -05:00
|
|
|
#define MICROPY_MODULE_FROZEN_STR (1)
|
2016-05-11 11:57:29 -04:00
|
|
|
#define MICROPY_MODULE_FROZEN_MPY (1)
|
2016-03-17 11:06:47 -04:00
|
|
|
#define MICROPY_MODULE_FROZEN_LEXER mp_lexer_new_from_str32
|
2016-05-11 11:57:29 -04:00
|
|
|
#define MICROPY_QSTR_EXTRA_POOL mp_qstr_frozen_const_pool
|
2014-11-27 15:30:33 -05:00
|
|
|
|
2016-03-27 10:13:47 -04:00
|
|
|
#define MICROPY_FATFS_ENABLE_LFN (1)
|
|
|
|
#define MICROPY_FATFS_RPATH (2)
|
|
|
|
#define MICROPY_FATFS_MAX_SS (4096)
|
2019-02-25 07:46:17 -05:00
|
|
|
#define MICROPY_FATFS_LFN_CODE_PAGE 437 /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
|
2016-07-31 17:03:55 -04:00
|
|
|
#define MICROPY_ESP8266_APA102 (1)
|
2016-10-08 17:56:46 -04:00
|
|
|
#define MICROPY_ESP8266_NEOPIXEL (1)
|
2016-03-27 10:13:47 -04:00
|
|
|
|
2016-03-10 22:41:10 -05:00
|
|
|
#define MICROPY_EVENT_POLL_HOOK {ets_event_poll();}
|
2016-04-01 18:32:55 -04:00
|
|
|
#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
|
2016-03-10 22:41:10 -05:00
|
|
|
|
2014-11-27 15:30:33 -05:00
|
|
|
// type definitions for the specific machine
|
|
|
|
|
|
|
|
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p)))
|
|
|
|
|
2016-02-12 18:36:26 -05:00
|
|
|
#define MP_SSIZE_MAX (0x7fffffff)
|
|
|
|
|
2014-11-27 15:30:33 -05:00
|
|
|
#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;
|
2015-12-28 05:23:30 -05:00
|
|
|
typedef uint32_t sys_prot_t; // for modlwip
|
2016-07-30 10:46:36 -04:00
|
|
|
// ssize_t, off_t as required by POSIX-signatured functions in stream.h
|
|
|
|
#include <sys/types.h>
|
2014-11-27 15:30:33 -05:00
|
|
|
|
2015-04-09 18:56:15 -04:00
|
|
|
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
|
2016-12-09 00:47:47 -05:00
|
|
|
void *esp_native_code_commit(void*, size_t);
|
|
|
|
#define MP_PLAT_COMMIT_EXEC(buf, len) esp_native_code_commit(buf, len)
|
2015-04-09 18:56:15 -04:00
|
|
|
|
2018-08-02 00:04:44 -04:00
|
|
|
// printer for debugging output, goes to UART only
|
|
|
|
extern const struct _mp_print_t mp_debug_print;
|
|
|
|
|
2018-06-05 22:00:23 -04:00
|
|
|
#define mp_type_fileio mp_type_vfs_fat_fileio
|
|
|
|
#define mp_type_textio mp_type_vfs_fat_textio
|
2016-05-31 14:46:02 -04:00
|
|
|
|
2017-01-26 23:16:08 -05:00
|
|
|
// 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
|
|
|
|
|
2014-11-27 15:30:33 -05:00
|
|
|
// extra built in names to add to the global namespace
|
|
|
|
#define MICROPY_PORT_BUILTINS \
|
2017-08-21 07:34:23 -04:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) },
|
2014-11-27 15:30:33 -05:00
|
|
|
|
|
|
|
// extra built in modules to add to the list of known ones
|
2015-01-22 17:34:16 -05:00
|
|
|
extern const struct _mp_obj_module_t esp_module;
|
2015-06-12 10:16:52 -04:00
|
|
|
extern const struct _mp_obj_module_t network_module;
|
2015-05-11 15:11:37 -04:00
|
|
|
extern const struct _mp_obj_module_t utime_module;
|
2015-05-18 12:35:25 -04:00
|
|
|
extern const struct _mp_obj_module_t uos_module;
|
2015-12-28 05:23:30 -05:00
|
|
|
extern const struct _mp_obj_module_t mp_module_lwip;
|
2015-12-30 17:52:01 -05:00
|
|
|
extern const struct _mp_obj_module_t mp_module_machine;
|
2017-06-22 02:17:46 -04:00
|
|
|
extern const struct _mp_obj_module_t mp_module_onewire;
|
2014-11-27 15:30:33 -05:00
|
|
|
|
|
|
|
#define MICROPY_PORT_BUILTIN_MODULES \
|
2017-08-21 07:34:23 -04:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_esp), MP_ROM_PTR(&esp_module) }, \
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_lwip) }, \
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_network), MP_ROM_PTR(&network_module) }, \
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&utime_module) }, \
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&uos_module) }, \
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_machine), MP_ROM_PTR(&mp_module_machine) }, \
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR__onewire), MP_ROM_PTR(&mp_module_onewire) }, \
|
2014-11-27 15:30:33 -05:00
|
|
|
|
2015-05-12 19:18:41 -04:00
|
|
|
#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
|
2018-05-16 23:27:18 -04:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_binascii), MP_ROM_PTR(&mp_module_ubinascii) }, \
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_collections), MP_ROM_PTR(&mp_module_collections) }, \
|
2017-08-21 07:34:23 -04:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, \
|
2018-05-16 23:27:18 -04:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_hashlib), MP_ROM_PTR(&mp_module_uhashlib) }, \
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_io), MP_ROM_PTR(&mp_module_io) }, \
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_json), MP_ROM_PTR(&mp_module_ujson) }, \
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_os), MP_ROM_PTR(&uos_module) }, \
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_random), MP_ROM_PTR(&mp_module_urandom) }, \
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_re), MP_ROM_PTR(&mp_module_ure) }, \
|
2017-08-21 07:34:23 -04:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_select), MP_ROM_PTR(&mp_module_uselect) }, \
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&mp_module_lwip) }, \
|
2018-05-16 23:27:18 -04:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_ssl), MP_ROM_PTR(&mp_module_ussl) }, \
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_struct), MP_ROM_PTR(&mp_module_ustruct) }, \
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&utime_module) }, \
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_zlib), MP_ROM_PTR(&mp_module_uzlib) }, \
|
2015-05-12 19:18:41 -04:00
|
|
|
|
2015-01-07 18:38:50 -05:00
|
|
|
#define MP_STATE_PORT MP_STATE_VM
|
|
|
|
|
|
|
|
#define MICROPY_PORT_ROOT_POINTERS \
|
2015-05-02 15:24:25 -04:00
|
|
|
const char *readline_hist[8]; \
|
2016-04-14 06:15:43 -04:00
|
|
|
mp_obj_t pin_irq_handler[16]; \
|
2018-12-05 07:31:24 -05:00
|
|
|
byte *uart0_rxbuf; \
|
2015-01-07 18:38:50 -05:00
|
|
|
|
2014-11-27 15:30:33 -05:00
|
|
|
// We need to provide a declaration/definition of alloca()
|
|
|
|
#include <alloca.h>
|
|
|
|
|
|
|
|
// board specifics
|
|
|
|
|
2015-10-30 19:03:58 -04:00
|
|
|
#define MICROPY_MPHALPORT_H "esp_mphal.h"
|
2016-05-02 13:54:46 -04:00
|
|
|
#define MICROPY_PY_SYS_PLATFORM "esp8266"
|
2015-12-29 13:44:55 -05:00
|
|
|
|
2016-10-18 17:20:10 -04:00
|
|
|
#define MP_FASTCODE(n) __attribute__((section(".iram0.text." #n))) n
|
|
|
|
|
2015-12-29 13:44:55 -05:00
|
|
|
#define _assert(expr) ((expr) ? (void)0 : __assert_func(__FILE__, __LINE__, __func__, #expr))
|