diff options
author | Angus Gratton <angus@redyak.com.au> | 2023-08-09 11:53:03 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-08-23 11:58:11 +1000 |
commit | 2919a9fbf33b2e9c0cfeeb73e1a7240d70b5310d (patch) | |
tree | 62d32d92161fb52e2c59022a62c4fcf083e41f9d | |
parent | 02620c2236e948b1899d122359a1eb150e5a9ee0 (diff) | |
download | micropython-2919a9fbf33b2e9c0cfeeb73e1a7240d70b5310d.tar.gz micropython-2919a9fbf33b2e9c0cfeeb73e1a7240d70b5310d.zip |
stm32/modstm: Add MICROPY_PY_STM_CONST flag, clear it for STM32WL5.
MICROPY_PY_STM_CONST defaults to 1 if MICROPY_PY_STM is set. Overriding to
0 disables the named register peripheral constants being including in the
stm32 module.
This saves about 7.5KB of code size for the STM32WL55, which is significant
as this SoC doesn't have a lot of flash.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
-rw-r--r-- | ports/stm32/boards/NUCLEO_WL55/mpconfigboard.h | 3 | ||||
-rw-r--r-- | ports/stm32/make-stmconst.py | 4 | ||||
-rw-r--r-- | ports/stm32/modstm.c | 2 | ||||
-rw-r--r-- | ports/stm32/mpconfigboard_common.h | 7 |
4 files changed, 12 insertions, 4 deletions
diff --git a/ports/stm32/boards/NUCLEO_WL55/mpconfigboard.h b/ports/stm32/boards/NUCLEO_WL55/mpconfigboard.h index c87fcdea9b..843e855ce7 100644 --- a/ports/stm32/boards/NUCLEO_WL55/mpconfigboard.h +++ b/ports/stm32/boards/NUCLEO_WL55/mpconfigboard.h @@ -14,7 +14,8 @@ #define MICROPY_PY_SOCKET (0) #define MICROPY_PY_NETWORK (0) #define MICROPY_PY_ONEWIRE (0) -#define MICROPY_PY_STM (1) +#define MICROPY_PY_STM (1) // for subghz radio functions +#define MICROPY_PY_STM_CONST (0) // saves size, no named registers #define MICROPY_PY_PYB_LEGACY (0) #define MICROPY_PY_HEAPQ (0) diff --git a/ports/stm32/make-stmconst.py b/ports/stm32/make-stmconst.py index 49b5c1a17b..4e4f2d7155 100644 --- a/ports/stm32/make-stmconst.py +++ b/ports/stm32/make-stmconst.py @@ -319,10 +319,10 @@ def main(): print("") with open(args.qstr_filename, "wt") as qstr_file: - print("#if MICROPY_PY_STM", file=qstr_file) + print("#if MICROPY_PY_STM_CONST", file=qstr_file) for qstr in sorted(needed_qstrs): print("Q({})".format(qstr), file=qstr_file) - print("#endif // MICROPY_PY_STM", file=qstr_file) + print("#endif // MICROPY_PY_STM_CONST", 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 53bc0db79c..251360594a 100644 --- a/ports/stm32/modstm.c +++ b/ports/stm32/modstm.c @@ -45,7 +45,9 @@ STATIC const mp_rom_map_elem_t stm_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_mem16), MP_ROM_PTR(&machine_mem16_obj) }, { MP_ROM_QSTR(MP_QSTR_mem32), MP_ROM_PTR(&machine_mem32_obj) }, + #if MICROPY_PY_STM_CONST #include "genhdr/modstm_const.h" + #endif #if defined(STM32WB) { MP_ROM_QSTR(MP_QSTR_rfcore_status), MP_ROM_PTR(&rfcore_status_obj) }, diff --git a/ports/stm32/mpconfigboard_common.h b/ports/stm32/mpconfigboard_common.h index 3331b38400..611a08252d 100644 --- a/ports/stm32/mpconfigboard_common.h +++ b/ports/stm32/mpconfigboard_common.h @@ -32,11 +32,16 @@ /*****************************************************************************/ // Feature settings with defaults -// Whether to include the stm module, with peripheral register constants +// Whether to include the stm module #ifndef MICROPY_PY_STM #define MICROPY_PY_STM (1) #endif +// Whether to include named register constants in the stm module +#ifndef MICROPY_PY_STM_CONST +#define MICROPY_PY_STM_CONST (MICROPY_PY_STM) +#endif + // Whether to include the pyb module #ifndef MICROPY_PY_PYB #define MICROPY_PY_PYB (1) |