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>
This commit is contained in:
@@ -172,6 +172,8 @@ class PinGenerator:
|
|||||||
self._pins = []
|
self._pins = []
|
||||||
self._pin_type = pin_type
|
self._pin_type = pin_type
|
||||||
self._enable_af = enable_af
|
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
|
# Allows a port to define a known cpu pin (without relying on it being in the
|
||||||
# csv file).
|
# csv file).
|
||||||
@@ -298,6 +300,9 @@ class PinGenerator:
|
|||||||
# Don't include hidden pins in Pins.board.
|
# Don't include hidden pins in Pins.board.
|
||||||
continue
|
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
|
# We don't use the enable macro for board pins, because they
|
||||||
# shouldn't be referenced in pins.csv unless they're
|
# shouldn't be referenced in pins.csv unless they're
|
||||||
# available.
|
# available.
|
||||||
@@ -322,6 +327,9 @@ class PinGenerator:
|
|||||||
file=out_source,
|
file=out_source,
|
||||||
)
|
)
|
||||||
for pin in self.available_pins(exclude_hidden=True):
|
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()
|
m = pin.enable_macro()
|
||||||
if m:
|
if m:
|
||||||
print(" #if {}".format(m), file=out_source)
|
print(" #if {}".format(m), file=out_source)
|
||||||
@@ -351,6 +359,20 @@ class PinGenerator:
|
|||||||
|
|
||||||
# Print the pin_CPUNAME and pin_BOARDNAME macros.
|
# Print the pin_CPUNAME and pin_BOARDNAME macros.
|
||||||
def print_defines(self, out_header, cpu=True, board=True):
|
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.
|
# Provide #defines for each cpu pin.
|
||||||
for pin in self.available_pins():
|
for pin in self.available_pins():
|
||||||
print(file=out_header)
|
print(file=out_header)
|
||||||
|
|||||||
Reference in New Issue
Block a user