stm32/boards/make-pins.py: Add cmdline options to support use by mboot.
This commit is contained in:
parent
bc4f8b438b
commit
7b2dc96251
|
@ -573,7 +573,11 @@ main.c: $(GEN_CDCINF_HEADER)
|
|||
# both pins_$(BOARD).c and pins.h
|
||||
$(BUILD)/%_$(BOARD).c $(HEADER_BUILD)/%.h $(HEADER_BUILD)/%_af_const.h $(HEADER_BUILD)/%_af_defs.h $(BUILD)/%_qstr.h: $(BOARD_DIR)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD)
|
||||
$(ECHO) "GEN $@"
|
||||
$(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) --qstr $(GEN_PINS_QSTR) --af-const $(GEN_PINS_AF_CONST) --af-defs $(GEN_PINS_AF_DEFS) --af-py $(GEN_PINS_AF_PY) > $(GEN_PINS_SRC)
|
||||
$(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) \
|
||||
--prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) --hdr-obj-decls \
|
||||
--qstr $(GEN_PINS_QSTR) --af-const $(GEN_PINS_AF_CONST) \
|
||||
--af-defs $(GEN_PINS_AF_DEFS) --af-defs-cmp-strings \
|
||||
--af-py $(GEN_PINS_AF_PY) > $(GEN_PINS_SRC)
|
||||
|
||||
$(BUILD)/pins_$(BOARD).o: $(BUILD)/pins_$(BOARD).c
|
||||
$(call compile_c)
|
||||
|
|
|
@ -341,15 +341,16 @@ class Pins(object):
|
|||
print('};')
|
||||
|
||||
|
||||
def print_header(self, hdr_filename):
|
||||
def print_header(self, hdr_filename, obj_decls):
|
||||
with open(hdr_filename, 'wt') as hdr_file:
|
||||
for named_pin in self.cpu_pins:
|
||||
pin = named_pin.pin()
|
||||
if pin.is_board_pin():
|
||||
pin.print_header(hdr_file)
|
||||
hdr_file.write('extern const pin_obj_t * const pin_adc1[];\n')
|
||||
hdr_file.write('extern const pin_obj_t * const pin_adc2[];\n')
|
||||
hdr_file.write('extern const pin_obj_t * const pin_adc3[];\n')
|
||||
if obj_decls:
|
||||
for named_pin in self.cpu_pins:
|
||||
pin = named_pin.pin()
|
||||
if pin.is_board_pin():
|
||||
pin.print_header(hdr_file)
|
||||
hdr_file.write('extern const pin_obj_t * const pin_adc1[];\n')
|
||||
hdr_file.write('extern const pin_obj_t * const pin_adc2[];\n')
|
||||
hdr_file.write('extern const pin_obj_t * const pin_adc3[];\n')
|
||||
# provide #define's mapping board to cpu name
|
||||
for named_pin in self.board_pins:
|
||||
hdr_file.write("#define pyb_pin_{:s} pin_{:s}\n".format(named_pin.name(), named_pin.pin().cpu_pin_name()))
|
||||
|
@ -396,7 +397,7 @@ class Pins(object):
|
|||
file=af_const_file)
|
||||
print_conditional_endif(cond_var, file=af_const_file)
|
||||
|
||||
def print_af_defs(self, af_defs_filename):
|
||||
def print_af_defs(self, af_defs_filename, cmp_strings):
|
||||
with open(af_defs_filename, 'wt') as af_defs_file:
|
||||
|
||||
STATIC_AF_TOKENS = {}
|
||||
|
@ -407,11 +408,17 @@ class Pins(object):
|
|||
tok = "#define STATIC_AF_%s_%s(pin_obj) ( \\" % (func, pin_type)
|
||||
if tok not in STATIC_AF_TOKENS:
|
||||
STATIC_AF_TOKENS[tok] = []
|
||||
STATIC_AF_TOKENS[tok].append(
|
||||
' ((strcmp( #pin_obj , "(&pin_%s_obj)") & strcmp( #pin_obj , "((&pin_%s_obj))")) == 0) ? (%d) : \\' % (
|
||||
named_pin.pin().cpu_pin_name(), named_pin.pin().cpu_pin_name(), af.idx
|
||||
if cmp_strings:
|
||||
pin_name = named_pin.pin().cpu_pin_name()
|
||||
cmp_str = ' ((strcmp( #pin_obj , "(&pin_%s_obj)") ' \
|
||||
' & strcmp( #pin_obj , "((&pin_%s_obj))")) == 0) ? (%d) : \\' % (
|
||||
pin_name, pin_name, af.idx
|
||||
)
|
||||
)
|
||||
else:
|
||||
cmp_str = ' ((pin_obj) == (pin_%s)) ? (%d) : \\' % (
|
||||
named_pin.pin().cpu_pin_name(), af.idx
|
||||
)
|
||||
STATIC_AF_TOKENS[tok].append(cmp_str)
|
||||
|
||||
for tok, pins in STATIC_AF_TOKENS.items():
|
||||
print(tok, file=af_defs_file)
|
||||
|
@ -460,6 +467,12 @@ def main():
|
|||
help="Specifies the filename for the alternate function defines.",
|
||||
default="build/pins_af_defs.h"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--af-defs-cmp-strings",
|
||||
dest="af_defs_cmp_strings",
|
||||
help="Whether to compare pin name strings for the alternate function defines instead of object values",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-b", "--board",
|
||||
dest="board_filename",
|
||||
|
@ -483,6 +496,12 @@ def main():
|
|||
help="Specifies name of generated pin header file",
|
||||
default="build/pins.h"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--hdr-obj-decls",
|
||||
dest="hdr_obj_decls",
|
||||
help="Whether to include declarations for pin objects in pin header file",
|
||||
action="store_true"
|
||||
)
|
||||
args = parser.parse_args(sys.argv[1:])
|
||||
|
||||
pins = Pins()
|
||||
|
@ -506,11 +525,11 @@ def main():
|
|||
pins.print_adc(1)
|
||||
pins.print_adc(2)
|
||||
pins.print_adc(3)
|
||||
pins.print_header(args.hdr_filename)
|
||||
pins.print_header(args.hdr_filename, args.hdr_obj_decls)
|
||||
pins.print_qstr(args.qstr_filename)
|
||||
pins.print_af_hdr(args.af_const_filename)
|
||||
pins.print_af_py(args.af_py_filename)
|
||||
pins.print_af_defs(args.af_defs_filename)
|
||||
pins.print_af_defs(args.af_defs_filename, args.af_defs_cmp_strings)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in New Issue