Skip to content

Commit

Permalink
stm32/boards/make-pins.py: Generate empty ADC table if needed.
Browse files Browse the repository at this point in the history
If ADCx pins are hidden, print an empty table to prevent linker errors.
  • Loading branch information
iabdalkader authored and dpgeorge committed Dec 19, 2021
1 parent 1dc5320 commit bedd9c5
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions ports/stm32/boards/make-pins.py
Expand Up @@ -426,16 +426,19 @@ def print_adc(self, adc_num):
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:
Expand Down

0 comments on commit bedd9c5

Please sign in to comment.