Modify script to generate SDIO and I2S alternate functions
This commit is contained in:
parent
f42083c792
commit
95fd76f218
|
@ -178,20 +178,31 @@ class load_mcu:
|
||||||
if not pin.attrib['Type'] == 'I/O':
|
if not pin.attrib['Type'] == 'I/O':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
signals = pin.findall('stm:Signal', ns)
|
instance_signal_elements = pin.findall('stm:Signal', ns)
|
||||||
for signal_element in signals:
|
for instance_signal_element in instance_signal_elements:
|
||||||
signal = signal_element.attrib['Name']
|
instance_signal = instance_signal_element.attrib['Name']
|
||||||
if not signal.startswith('USART') \
|
|
||||||
and not signal.startswith('SPI') \
|
if not instance_signal.startswith('USART') \
|
||||||
and not signal.startswith('I2C') \
|
and not instance_signal.startswith('SPI') \
|
||||||
and not signal.startswith('TIM') \
|
and not instance_signal.startswith('I2C') \
|
||||||
and not signal.startswith('ADC1') \
|
and not instance_signal.startswith('TIM') \
|
||||||
and not signal.startswith('ADC_'):
|
and not instance_signal.startswith('ADC1') \
|
||||||
|
and not instance_signal.startswith('ADC_') \
|
||||||
|
and not instance_signal.startswith('I2S') \
|
||||||
|
and not instance_signal.startswith('SDIO') \
|
||||||
|
and not instance_signal.startswith('SDMMC'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
(instance, sig) = instance_signal.split('_', 1)
|
(instance, sig) = instance_signal.split('_', 1)
|
||||||
|
|
||||||
if instance[:-1].isdigit():
|
if instance == 'SDIO':
|
||||||
|
instance = 'SDIO1'
|
||||||
|
if instance == 'SDMMC1':
|
||||||
|
instance = 'SDIO1'
|
||||||
|
if instance == 'SDMMC2':
|
||||||
|
instance = 'SDIO2'
|
||||||
|
|
||||||
|
if instance[-1].isdigit():
|
||||||
periph = instance[:-1]
|
periph = instance[:-1]
|
||||||
else:
|
else:
|
||||||
periph = instance
|
periph = instance
|
||||||
|
@ -250,9 +261,22 @@ class load_mcu:
|
||||||
|
|
||||||
|
|
||||||
for periph in sorted(self.groups):
|
for periph in sorted(self.groups):
|
||||||
|
source_code += '\n'
|
||||||
|
source_code += '// --------------------' + periph + '--------------------'
|
||||||
|
source_code += '\n'
|
||||||
|
if 'SDIO' in periph:
|
||||||
|
source_code += '#define STM32_CHIP_HAS_SDIO'
|
||||||
|
source_code += '\n'
|
||||||
|
if 'I2S' in periph:
|
||||||
|
source_code += '#define STM32_CHIP_HAS_I2S'
|
||||||
|
source_code += '\n'
|
||||||
|
|
||||||
for sig in sorted(set(self.groups[periph])):
|
for sig in sorted(set(self.groups[periph])):
|
||||||
|
|
||||||
if 'SDIO' not in periph and sig not in ['SDA', 'SCL', 'TX', 'RX', 'MISO', 'MOSI', 'SCK']:
|
if 'SDIO' not in periph and 'I2S' not in periph and sig not in ['SDA', 'SCL', 'TX', 'RX', 'MISO', 'MOSI', 'SCK', 'NSS']:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if 'I2S' == periph and sig == 'CKIN':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
source_code += '\n'
|
source_code += '\n'
|
||||||
|
@ -270,6 +294,8 @@ class load_mcu:
|
||||||
split = signal.split('_')
|
split = signal.split('_')
|
||||||
p = split[0]
|
p = split[0]
|
||||||
|
|
||||||
|
p = p.replace('I2S', 'SPI');
|
||||||
|
|
||||||
source_code += ' { ' + p.ljust(6) + ', GPIO' + pin[1:2] + ', GPIO_PIN_' + pin[2:].ljust(3) + ', ' + remap.ljust(15) + '}, \n'
|
source_code += ' { ' + p.ljust(6) + ', GPIO' + pin[1:2] + ', GPIO_PIN_' + pin[2:].ljust(3) + ', ' + remap.ljust(15) + '}, \n'
|
||||||
|
|
||||||
source_code += '}; \n'
|
source_code += '}; \n'
|
||||||
|
@ -283,6 +309,9 @@ class load_mcu:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
(_, channel) = instance_signal.split('_', 1)
|
(_, channel) = instance_signal.split('_', 1)
|
||||||
|
if not channel[2:].isdigit():
|
||||||
|
continue
|
||||||
|
|
||||||
pin = self.defaultremaps[instance_signal]
|
pin = self.defaultremaps[instance_signal]
|
||||||
source_code += ' { GPIO' + pin[1:2] + ', GPIO_PIN_' + pin[2:].ljust(3) + ', ADC_CHANNEL_' + channel[2:].ljust(3) + '}, \n'
|
source_code += ' { GPIO' + pin[1:2] + ', GPIO_PIN_' + pin[2:].ljust(3) + ', ADC_CHANNEL_' + channel[2:].ljust(3) + '}, \n'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue