diff options
author | Damien George <damien@micropython.org> | 2024-12-11 00:04:34 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-12-17 23:53:24 +1100 |
commit | 3203e950fc23b31f8a702babe4c220a248763804 (patch) | |
tree | 2505d9961be4070fe4814222ca77a39d074430e8 /tools/boardgen.py | |
parent | 1c2cdf9f6dc649280ecfcc114100b3c2443c9402 (diff) | |
download | micropython-3203e950fc23b31f8a702babe4c220a248763804.tar.gz micropython-3203e950fc23b31f8a702babe4c220a248763804.zip |
tools/boardgen.py: Provide macro defns for number of cpu/board pins.
So a port can use them if needed to exclude the Pin.cpu/Pin.board objects.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tools/boardgen.py')
-rw-r--r-- | tools/boardgen.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/boardgen.py b/tools/boardgen.py index 41a8e9f2e5..39bedf71cd 100644 --- a/tools/boardgen.py +++ b/tools/boardgen.py @@ -172,6 +172,8 @@ class PinGenerator: self._pins = [] self._pin_type = pin_type self._enable_af = enable_af + self._pin_cpu_num_entries = 0 + self._pin_board_num_entries = 0 # Allows a port to define a known cpu pin (without relying on it being in the # csv file). @@ -298,6 +300,9 @@ class PinGenerator: # Don't include hidden pins in Pins.board. continue + # Keep track of the total number of Pin.board entries. + self._pin_board_num_entries += 1 + # We don't use the enable macro for board pins, because they # shouldn't be referenced in pins.csv unless they're # available. @@ -322,6 +327,9 @@ class PinGenerator: file=out_source, ) for pin in self.available_pins(exclude_hidden=True): + # Keep track of the total number of Pin.cpu entries. + self._pin_cpu_num_entries += 1 + m = pin.enable_macro() if m: print(" #if {}".format(m), file=out_source) @@ -351,6 +359,20 @@ class PinGenerator: # Print the pin_CPUNAME and pin_BOARDNAME macros. def print_defines(self, out_header, cpu=True, board=True): + # Provide #defines for the number of cpu and board pins. + print( + "#define MICROPY_PY_MACHINE_PIN_CPU_NUM_ENTRIES ({})".format( + self._pin_cpu_num_entries + ), + file=out_header, + ) + print( + "#define MICROPY_PY_MACHINE_PIN_BOARD_NUM_ENTRIES ({})".format( + self._pin_board_num_entries + ), + file=out_header, + ) + # Provide #defines for each cpu pin. for pin in self.available_pins(): print(file=out_header) |