summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2022-04-20 17:18:35 +1000
committerJim Mussared <jim.mussared@gmail.com>2022-05-18 20:56:30 +1000
commit0a92469c10542d57ef0ea6b6cf2ed0cae9491dbe (patch)
tree049c75b5a27e837148c5f58fb40e78e3a2452bde
parentbb794f05b7fef75696118ea1eb03a769a9fac40d (diff)
stm32: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
-rw-r--r--ports/stm32/modpyb.c2
-rw-r--r--ports/stm32/modstm.c2
-rw-r--r--ports/stm32/modutime.c2
-rw-r--r--ports/stm32/mpconfigport.h41
4 files changed, 16 insertions, 31 deletions
diff --git a/ports/stm32/modpyb.c b/ports/stm32/modpyb.c
index a44465488..d23065e4b 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 3f4f33979..185ec1a2f 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 1a22c34b6..d8ac156de 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 4bb1fcee3..484dd842c 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