HAL_ChibiOS: show ADC1 channels in hwdef.h

This commit is contained in:
Andrew Tridgell 2018-01-08 13:09:13 +11:00
parent 5a7e2f75d1
commit aa2175ec0c
1 changed files with 21 additions and 2 deletions

View File

@ -51,10 +51,26 @@ def get_alt_function(mcu, pin, function):
sys.exit(1) sys.exit(1)
return alt_map[s] return alt_map[s]
return None return None
def get_ADC1_chan(mcu, pin):
'''return ADC1 channel for an analog pin'''
import importlib
try:
lib = importlib.import_module(mcu)
ADC1_map = lib.ADC1_map
except ImportError:
print("Unable to find ADC1_Map for MCU %s" % mcu)
sys.exit(1)
if not pin in ADC1_map:
print("Unable to find ADC1 channel for pin %s" % pin)
sys.exit(1)
return ADC1_map[pin]
class generic_pin(object): class generic_pin(object):
'''class to hold pin definition''' '''class to hold pin definition'''
def __init__(self, port, pin, label, type, extra): def __init__(self, port, pin, label, type, extra):
self.portpin = "P%s%u" % (port, pin)
self.port = port self.port = port
self.pin = pin self.pin = pin
self.label = label self.label = label
@ -145,9 +161,12 @@ class generic_pin(object):
def __str__(self): def __str__(self):
afstr = '' afstr = ''
adcstr = ''
if self.af is not None: if self.af is not None:
afstr = " AF%u" % self.af afstr = " AF%u" % self.af
return "P%s%u %s %s%s" % (self.port, self.pin, self.label, self.type, afstr) if self.type.startswith('ADC1'):
adcstr = " ADC1_IN%u" % get_ADC1_chan(mcu_type, self.portpin)
return "P%s%u %s %s%s%s" % (self.port, self.pin, self.label, self.type, afstr, adcstr)
# setup default as input pins # setup default as input pins
for port in ports: for port in ports: