stm32/boards/make-pins.py: Generate empty ADC table if needed.

If ADCx pins are hidden, print an empty table to prevent linker errors.
This commit is contained in:
iabdalkader 2021-12-18 22:18:33 +02:00 committed by Damien George
parent 1dc532019b
commit bedd9c5463
1 changed files with 13 additions and 10 deletions

View File

@ -426,16 +426,19 @@ class Pins(object):
adc_pins[pin.adc_channel] = pin
if adc_pins:
table_size = max(adc_pins) + 1
self.adc_table_size[adc_num] = table_size
print("")
print("const pin_obj_t * const pin_adc{:d}[{:d}] = {{".format(adc_num, table_size))
for channel in range(table_size):
if channel in adc_pins:
obj = "&pin_{:s}_obj".format(adc_pins[channel].cpu_pin_name())
else:
obj = "NULL"
print(" [{:d}] = {},".format(channel, obj))
print("};")
else:
# If ADCx pins are hidden, print an empty table to prevent linker errors.
table_size = 0
self.adc_table_size[adc_num] = table_size
print("")
print("const pin_obj_t * const pin_adc{:d}[{:d}] = {{".format(adc_num, table_size))
for channel in range(table_size):
if channel in adc_pins:
obj = "&pin_{:s}_obj".format(adc_pins[channel].cpu_pin_name())
else:
obj = "NULL"
print(" [{:d}] = {},".format(channel, obj))
print("};")
def print_header(self, hdr_filename, obj_decls):
with open(hdr_filename, "wt") as hdr_file: