summaryrefslogtreecommitdiff
path: root/ports/stm32/make-stmconst.py
diff options
context:
space:
mode:
Diffstat (limited to 'ports/stm32/make-stmconst.py')
-rw-r--r--ports/stm32/make-stmconst.py30
1 files changed, 6 insertions, 24 deletions
diff --git a/ports/stm32/make-stmconst.py b/ports/stm32/make-stmconst.py
index 4e4f2d715..6d64fe3cf 100644
--- a/ports/stm32/make-stmconst.py
+++ b/ports/stm32/make-stmconst.py
@@ -183,22 +183,20 @@ def print_int_obj(val, needed_mpzs):
needed_mpzs.add(val)
-def print_periph(periph_name, periph_val, needed_qstrs, needed_mpzs):
+def print_periph(periph_name, periph_val, needed_mpzs):
qstr = periph_name.upper()
print("{ MP_ROM_QSTR(MP_QSTR_%s), " % qstr, end="")
print_int_obj(periph_val, needed_mpzs)
print(" },")
- needed_qstrs.add(qstr)
-def print_regs(reg_name, reg_defs, needed_qstrs, needed_mpzs):
+def print_regs(reg_name, reg_defs, needed_mpzs):
reg_name = reg_name.upper()
for r in reg_defs:
qstr = reg_name + "_" + r[0]
print("{ MP_ROM_QSTR(MP_QSTR_%s), " % qstr, end="")
print_int_obj(r[1], needed_mpzs)
print(" }, // %s-bits, %s" % (r[2], r[3]))
- needed_qstrs.add(qstr)
# This version of print regs groups registers together into submodules (eg GPIO submodule).
@@ -208,7 +206,7 @@ def print_regs(reg_name, reg_defs, needed_qstrs, needed_mpzs):
# As such, we don't use this version.
# And for the number of constants we have, this function seems to use about the same amount
# of ROM as print_regs.
-def print_regs_as_submodules(reg_name, reg_defs, modules, needed_qstrs):
+def print_regs_as_submodules(reg_name, reg_defs, modules):
mod_name_lower = reg_name.lower() + "_"
mod_name_upper = mod_name_lower.upper()
modules.append((mod_name_lower, mod_name_upper))
@@ -220,14 +218,12 @@ STATIC const mp_rom_map_elem_t stm_%s_globals_table[] = {
"""
% (mod_name_lower, mod_name_upper)
)
- needed_qstrs.add(mod_name_upper)
for r in reg_defs:
print(
" { MP_ROM_QSTR(MP_QSTR_%s), MP_ROM_INT(%#x) }, // %s-bits, %s"
% (r[0], r[1], r[2], r[3])
)
- needed_qstrs.add(r[0])
print(
"""};
@@ -248,13 +244,6 @@ def main():
cmd_parser = argparse.ArgumentParser(description="Extract ST constants from a C header file.")
cmd_parser.add_argument("file", nargs=1, help="input file")
cmd_parser.add_argument(
- "-q",
- "--qstr",
- dest="qstr_filename",
- default="build/stmconst_qstr.h",
- help="Specified the name of the generated qstr header file",
- )
- cmd_parser.add_argument(
"--mpz",
dest="mpz_filename",
default="build/stmconst_mpz.h",
@@ -269,14 +258,13 @@ def main():
reg_defs["GPIO"].append(["BSRRL", 0x18, 16, "legacy register"])
reg_defs["GPIO"].append(["BSRRH", 0x1A, 16, "legacy register"])
- needed_qstrs = set()
needed_mpzs = set()
print("// Automatically generated from %s by make-stmconst.py" % args.file[0])
print("")
for periph_name, periph_val in periphs:
- print_periph(periph_name, periph_val, needed_qstrs, needed_mpzs)
+ print_periph(periph_name, periph_val, needed_mpzs)
for reg in (
"ADC",
@@ -309,8 +297,8 @@ def main():
"IPCC",
):
if reg in reg_defs:
- print_regs(reg, reg_defs[reg], needed_qstrs, needed_mpzs)
- # print_regs_as_submodules(reg, reg_defs[reg], modules, needed_qstrs)
+ print_regs(reg, reg_defs[reg], needed_mpzs)
+ # print_regs_as_submodules(reg, reg_defs[reg], modules)
# print("#define MOD_STM_CONST_MODULES \\")
# for mod_lower, mod_upper in modules:
@@ -318,12 +306,6 @@ def main():
print("")
- with open(args.qstr_filename, "wt") as 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_CONST", file=qstr_file)
-
with open(args.mpz_filename, "wt") as mpz_file:
for mpz in sorted(needed_mpzs):
assert 0 <= mpz <= 0xFFFFFFFF