diff --git a/ports/stm32/modpyb.c b/ports/stm32/modpyb.c index a444654888..d23065e4bb 100644 --- a/ports/stm32/modpyb.c +++ b/ports/stm32/modpyb.c @@ -265,3 +265,5 @@ const mp_obj_module_t pyb_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&pyb_module_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_pyb, pyb_module, MICROPY_PY_PYB); diff --git a/ports/stm32/modstm.c b/ports/stm32/modstm.c index 3f4f33979a..185ec1a2fe 100644 --- a/ports/stm32/modstm.c +++ b/ports/stm32/modstm.c @@ -60,4 +60,6 @@ const mp_obj_module_t stm_module = { .globals = (mp_obj_dict_t *)&stm_module_globals, }; +MP_REGISTER_MODULE(MP_QSTR_stm, stm_module, MICROPY_PY_STM); + #endif // MICROPY_PY_STM diff --git a/ports/stm32/modutime.c b/ports/stm32/modutime.c index 1a22c34b6b..d8ac156de6 100644 --- a/ports/stm32/modutime.c +++ b/ports/stm32/modutime.c @@ -153,3 +153,5 @@ const mp_obj_module_t mp_module_utime = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&time_module_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime, MICROPY_PY_UTIME); diff --git a/ports/stm32/mpconfigport.h b/ports/stm32/mpconfigport.h index 4bb1fcee39..484dd842c4 100644 --- a/ports/stm32/mpconfigport.h +++ b/ports/stm32/mpconfigport.h @@ -172,30 +172,20 @@ #define MICROPY_PORT_BUILTINS \ { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) }, -// extra built in modules to add to the list of known ones -extern const struct _mp_obj_module_t pyb_module; -extern const struct _mp_obj_module_t stm_module; -extern const struct _mp_obj_module_t mp_module_ubinascii; -extern const struct _mp_obj_module_t mp_module_ure; -extern const struct _mp_obj_module_t mp_module_uzlib; -extern const struct _mp_obj_module_t mp_module_ujson; -extern const struct _mp_obj_module_t mp_module_uheapq; -extern const struct _mp_obj_module_t mp_module_uhashlib; -extern const struct _mp_obj_module_t mp_module_utime; -extern const struct _mp_obj_module_t mp_module_usocket; -extern const struct _mp_obj_module_t mp_module_network; -extern const struct _mp_obj_module_t mp_module_onewire; - #if MICROPY_PY_PYB -#define PYB_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) }, +extern const struct _mp_obj_module_t pyb_module; +#define PYB_BUILTIN_MODULE_CONSTANTS \ + { MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) }, #else -#define PYB_BUILTIN_MODULE +#define PYB_BUILTIN_MODULE_CONSTANTS #endif #if MICROPY_PY_STM -#define STM_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_stm), MP_ROM_PTR(&stm_module) }, +extern const struct _mp_obj_module_t stm_module; +#define STM_BUILTIN_MODULE_CONSTANTS \ + { MP_ROM_QSTR(MP_QSTR_stm), MP_ROM_PTR(&stm_module) }, #else -#define STM_BUILTIN_MODULE +#define STM_BUILTIN_MODULE_CONSTANTS #endif #if MICROPY_PY_MACHINE @@ -206,12 +196,6 @@ extern const struct _mp_obj_module_t mp_module_onewire; #define MACHINE_BUILTIN_MODULE_CONSTANTS #endif -#if MICROPY_PY_UTIME -#define UTIME_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_utime) }, -#else -#define UTIME_BUILTIN_MODULE -#endif - #if defined(MICROPY_HW_ETH_MDC) extern const struct _mp_obj_type_t network_lan_type; #define MICROPY_HW_NIC_ETH { MP_ROM_QSTR(MP_QSTR_LAN), MP_ROM_PTR(&network_lan_type) }, @@ -244,16 +228,11 @@ extern const struct _mod_network_nic_type_t mod_network_nic_type_cc3k; #define MICROPY_HW_NIC_CC3K #endif -#define MICROPY_PORT_BUILTIN_MODULES \ - PYB_BUILTIN_MODULE \ - STM_BUILTIN_MODULE \ - UTIME_BUILTIN_MODULE \ - // extra constants #define MICROPY_PORT_CONSTANTS \ MACHINE_BUILTIN_MODULE_CONSTANTS \ - PYB_BUILTIN_MODULE \ - STM_BUILTIN_MODULE \ + PYB_BUILTIN_MODULE_CONSTANTS \ + STM_BUILTIN_MODULE_CONSTANTS \ #ifndef MICROPY_BOARD_NETWORK_INTERFACES #define MICROPY_BOARD_NETWORK_INTERFACES