8000 stm32: Make port-specific modules use MP_REGISTER_MODULE. · larsks/micropython@0a92469 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a92469

Browse files
committed
stm32: Make port-specific modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
1 parent bb794f0 commit 0a92469

File tree

4 files changed

+16
-31
lines changed

4 files changed

+16
-31
lines changed

ports/stm32/modpyb.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,5 @@ const mp_obj_module_t pyb_module = {
265265
.base = { &mp_type_module },
266266
.globals = (mp_obj_dict_t *)&pyb_module_globals,
267267
};
268+
269+
MP_REGISTER_MODULE(MP_QSTR_pyb, pyb_module, MICROPY_PY_PYB);

ports/stm32/modstm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,6 @@ const mp_obj_module_t stm_module = {
6060
.globals = (mp_obj_dict_t *)&stm_module_globals,
6161
};
6262

63+
MP_REGISTER_MODULE(MP_QSTR_stm, stm_module, MICROPY_PY_STM);
64+
6365
#endif // MICROPY_PY_STM

ports/stm32/modutime.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,5 @@ const mp_obj_module_t mp_module_utime = {
153153
.base = { &mp_type_module },
154154
.globals = (mp_obj_dict_t *)&time_module_globals,
155155
};
156+
157+
MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime, MICROPY_PY_UTIME);

ports/stm32/mpconfigport.h

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -172,30 +172,20 @@
172172
#define MICROPY_PORT_BUILTINS \
173173
{ MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) },
174174

175-
// extra built in modules to add to the list of known ones
176-
extern const struct _mp_obj_module_t pyb_module;
177-
extern const struct _mp_obj_module_t stm_module;
178-
extern const struct _mp_obj_module_t mp_module_ubinascii;
179-
extern const struct _mp_obj_module_t mp_module_ure;
180-
extern const struct _mp_obj_module_t mp_module_uzlib;
181-
extern const struct _mp_obj_module_t mp_module_ujson;
182-
extern const struct _mp_obj_module_t mp_module_uheapq;
183-
extern const struct _mp_obj_module_t mp_module_uhashlib;
184-
extern const struct _mp_obj_module_t mp_module_utime;
185-
extern const struct _mp_obj_module_t mp_module_usocket;
186-
extern const struct _mp_obj_module_t mp_module_network;
187-
extern const struct _mp_obj_module_t mp_module_onewire;
188-
189175
#if MICROPY_PY_PYB
190-
#define PYB_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) },
176+
extern const struct _mp_obj_module_t pyb_module;
177+
#define PYB_BUILTIN_MODULE_CONSTANTS \
178+
{ MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) },
191179
#else
192-
#define PYB_BUILTIN_MODULE
180+
#define PYB_BUILTIN_MODULE_CONSTANTS
193181
#endif
194182

195183
#if MICROPY_PY_STM
196-
#define STM_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_stm), MP_ROM_PTR(&stm_module) },
184+
extern const struct _mp_obj_module_t stm_module;
185+
#define STM_BUILTIN_MODULE_CONSTANTS \
186+
{ MP_ROM_QSTR(MP_QSTR_stm), MP_ROM_PTR(&stm_module) },
197187
#else
198-
#define STM_BUILTIN_MODULE
188+
#define STM_BUILTIN_MODULE_CONSTANTS
199189
#endif
200190

201191
#if MICROPY_PY_MACHINE
@@ -206,12 +196,6 @@ extern const struct _mp_obj_module_t mp_module_onewire;
206196
#define MACHINE_BUILTIN_MODULE_CONSTANTS
207197
#endif
208198

209-
#if MICROPY_PY_UTIME
210-
#define UTIME_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_utime) },
211-
#else
212-
#define UTIME_BUILTIN_MODULE
213-
#endif
214-
215199
#if defined(MICROPY_HW_ETH_MDC)
216200
extern const struct _mp_obj_type_t network_lan_type;
217201
#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;
244228
#define MICROPY_HW_NIC_CC3K
245229
#endif
246230

247-
#define MICROPY_PORT_BUILTIN_MODULES \
248-
PYB_BUILTIN_MODULE \
249-
STM_BUILTIN_MODULE \
250-
UTIME_BUILTIN_MODULE \
251-
252231
// extra constants
253232
#define MICROPY_PORT_CONSTANTS \
254233
MACHINE_BUILTIN_MODULE_CONSTANTS \
255-
PYB_BUILTIN_MODULE \
256-
STM_BUILTIN_MODULE \
234+
PYB_BUILTIN_MODULE_CONSTANTS \
235+
STM_BUILTIN_MODULE_CONSTANTS \
257236

258237
#ifndef MICROPY_BOARD_NETWORK_INTERFACES
259238
#define MICROPY_BOARD_NETWORK_INTERFACES

0 commit comments

Comments
 (0)
0