summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/stm32/make-stmconst.py2
-rw-r--r--ports/stm32/modstm.c7
-rw-r--r--ports/stm32/mpconfigboard_common.h5
-rw-r--r--ports/stm32/mpconfigport.h10
4 files changed, 21 insertions, 3 deletions
diff --git a/ports/stm32/make-stmconst.py b/ports/stm32/make-stmconst.py
index 3a8e22b38..d509d00c1 100644
--- a/ports/stm32/make-stmconst.py
+++ b/ports/stm32/make-stmconst.py
@@ -244,8 +244,10 @@ def main():
print("")
with open(args.qstr_filename, 'wt') as qstr_file:
+ print('#if MICROPY_PY_STM', file=qstr_file)
for qstr in sorted(needed_qstrs):
print('Q({})'.format(qstr), file=qstr_file)
+ print('#endif // MICROPY_PY_STM', file=qstr_file)
with open(args.mpz_filename, 'wt') as mpz_file:
for mpz in sorted(needed_mpzs):
diff --git a/ports/stm32/modstm.c b/ports/stm32/modstm.c
index 2084c0aa0..3fae3a57c 100644
--- a/ports/stm32/modstm.c
+++ b/ports/stm32/modstm.c
@@ -30,9 +30,12 @@
#include "py/obj.h"
#include "py/objint.h"
#include "extmod/machine_mem.h"
-#include "genhdr/modstm_mpz.h"
#include "portmodules.h"
+#if MICROPY_PY_STM
+
+#include "genhdr/modstm_mpz.h"
+
STATIC const mp_rom_map_elem_t stm_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_stm) },
@@ -49,3 +52,5 @@ const mp_obj_module_t stm_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&stm_module_globals,
};
+
+#endif // MICROPY_PY_STM
diff --git a/ports/stm32/mpconfigboard_common.h b/ports/stm32/mpconfigboard_common.h
index 97c21d022..2ed8609e7 100644
--- a/ports/stm32/mpconfigboard_common.h
+++ b/ports/stm32/mpconfigboard_common.h
@@ -32,6 +32,11 @@
/*****************************************************************************/
// Feature settings with defaults
+// Whether to include the stm module, with peripheral register constants
+#ifndef MICROPY_PY_STM
+#define MICROPY_PY_STM (1)
+#endif
+
// Whether to enable storage on the internal flash of the MCU
#ifndef MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (1)
diff --git a/ports/stm32/mpconfigport.h b/ports/stm32/mpconfigport.h
index a0a67e95f..72744f04b 100644
--- a/ports/stm32/mpconfigport.h
+++ b/ports/stm32/mpconfigport.h
@@ -186,6 +186,12 @@ 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_STM
+#define STM_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_stm), MP_ROM_PTR(&stm_module) },
+#else
+#define STM_BUILTIN_MODULE
+#endif
+
#if MICROPY_PY_USOCKET
#define SOCKET_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_usocket) },
#define SOCKET_BUILTIN_MODULE_WEAK_LINKS { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&mp_module_usocket) },
@@ -203,7 +209,7 @@ extern const struct _mp_obj_module_t mp_module_onewire;
#define MICROPY_PORT_BUILTIN_MODULES \
{ MP_ROM_QSTR(MP_QSTR_umachine), MP_ROM_PTR(&machine_module) }, \
{ MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) }, \
- { MP_ROM_QSTR(MP_QSTR_stm), MP_ROM_PTR(&stm_module) }, \
+ STM_BUILTIN_MODULE \
{ MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&mp_module_uos) }, \
{ MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_utime) }, \
SOCKET_BUILTIN_MODULE \
@@ -233,7 +239,7 @@ extern const struct _mp_obj_module_t mp_module_onewire;
{ MP_ROM_QSTR(MP_QSTR_umachine), MP_ROM_PTR(&machine_module) }, \
{ MP_ROM_QSTR(MP_QSTR_machine), MP_ROM_PTR(&machine_module) }, \
{ MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) }, \
- { MP_ROM_QSTR(MP_QSTR_stm), MP_ROM_PTR(&stm_module) }, \
+ STM_BUILTIN_MODULE \
#define MP_STATE_PORT MP_STATE_VM