8000 stm32/modstm: Add MICROPY_PY_STM_CONST flag, clear it for STM32WL5. · micropython/micropython@2919a9f · GitHub
[go: up one dir, main page]

Skip to content

Commit 2919a9f

Browse files
projectgusdpgeorge
authored andcommitted
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>
1 parent 02620c2 commit 2919a9f

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

ports/stm32/boards/NUCLEO_WL55/mpconfigboard.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
#define MICROPY_PY_SOCKET (0)
1515
#define MICROPY_PY_NETWORK (0)
1616
#define MICROPY_PY_ONEWIRE (0)
17-
#define MICROPY_PY_STM (1)
17+
#define MICROPY_PY_STM (1) // for subghz radio functions
18+
#define MICROPY_PY_STM_CONST (0) // saves size, no named registers
1819
#define MICROPY_PY_PYB_LEGACY (0)
1920
#define MICROPY_PY_HEAPQ (0)
2021

ports/stm32/make-stmconst.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,10 @@ def main():
319319
print("")
320320

321321
with open(args.qstr_filename, "wt") as qstr_file:
322-
print("#if MICROPY_PY_STM", file=qstr_file)
322+
print("#if MICROPY_PY_STM_CONST", file=qstr_file)
323323
for qstr in sorted(needed_qstrs):
324324
print("Q({})".format(qstr), file=qstr_file)
325-
print("#endif // MICROPY_PY_STM", file=qstr_file)
325+
print("#endif // MICROPY_PY_STM_CONST", file=qstr_file)
326326

327327
with open(args.mpz_filename, "wt") as mpz_file:
328328
for mpz in sorted(needed_mpzs):

ports/stm32/modstm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ STATIC const mp_rom_map_elem_t stm_module_globals_table[] = {
4545
{ MP_ROM_QSTR(MP_QSTR_mem16), MP_ROM_PTR(&machine_mem16_obj) },
4646
{ MP_ROM_QSTR(MP_QSTR_mem32), MP_ROM_PTR(&machine_mem32_obj) },
4747

48+
#if MICROPY_PY_STM_CONST
4849
#include "genhdr/modstm_const.h"
50+
#endif
4951

5052
#if defined(STM32WB)
5153
{ MP_ROM_QSTR(MP_QSTR_rfcore_status), MP_ROM_PTR(&rfcore_status_obj) },

ports/stm32/mpconfigboard_common.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,16 @@
3232
/*****************************************************************************/
3333
// Feature settings with defaults
3434

35-
// Whether to include the stm module, with peripheral register constants
35+
// Whether to include the stm module
3636
#ifndef MICROPY_PY_STM
3737
#define MICROPY_PY_STM (1)
3838
#endif
3939

40+
// Whether to include named register constants in the stm module
41+
#ifndef MICROPY_PY_STM_CONST
42+
#define MICROPY_PY_STM_CONST (MICROPY_PY_STM)
43+
#endif
44+
4045
// Whether to include the pyb module
4146
#ifndef MICROPY_PY_PYB
4247
#define MICROPY_PY_PYB (1)

0 commit comments

Comments
 (0)
0