Merge pull request #209 from lulf/handle-pin-0

Handle case where pin value could be 0
This commit is contained in:
Dario Nieuwenhuis 2021-05-27 13:29:16 +02:00 committed by GitHub
commit 1d3e685821
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -108,15 +108,15 @@ for chip in chips.values():
f.write(f'impl_usart!({name});') f.write(f'impl_usart!({name});')
for pin, funcs in af.items(): for pin, funcs in af.items():
if pin in pins: if pin in pins:
if func := funcs.get(f'{name}_RX'): if (func := funcs.get(f'{name}_RX')) != None:
f.write(f'impl_usart_pin!({name}, RxPin, {pin}, {func});') f.write(f'impl_usart_pin!({name}, RxPin, {pin}, {func});')
if func := funcs.get(f'{name}_TX'): if (func := funcs.get(f'{name}_TX')) != None:
f.write(f'impl_usart_pin!({name}, TxPin, {pin}, {func});') f.write(f'impl_usart_pin!({name}, TxPin, {pin}, {func});')
if func := funcs.get(f'{name}_CTS'): if (func := funcs.get(f'{name}_CTS')) != None:
f.write(f'impl_usart_pin!({name}, CtsPin, {pin}, {func});') f.write(f'impl_usart_pin!({name}, CtsPin, {pin}, {func});')
if func := funcs.get(f'{name}_RTS'): if (func := funcs.get(f'{name}_RTS')) != None:
f.write(f'impl_usart_pin!({name}, RtsPin, {pin}, {func});') f.write(f'impl_usart_pin!({name}, RtsPin, {pin}, {func});')
if func := funcs.get(f'{name}_CK'): if (func := funcs.get(f'{name}_CK')) != None:
f.write(f'impl_usart_pin!({name}, CkPin, {pin}, {func});') f.write(f'impl_usart_pin!({name}, CkPin, {pin}, {func});')
if block_mod == 'rng': if block_mod == 'rng':
@ -130,11 +130,11 @@ for chip in chips.values():
f.write(f'impl_spi!({name}, {clock});') f.write(f'impl_spi!({name}, {clock});')
for pin, funcs in af.items(): for pin, funcs in af.items():
if pin in pins: if pin in pins:
if func := funcs.get(f'{name}_SCK'): if (func := funcs.get(f'{name}_SCK')) != None:
f.write(f'impl_spi_pin!({name}, SckPin, {pin}, {func});') f.write(f'impl_spi_pin!({name}, SckPin, {pin}, {func});')
if func := funcs.get(f'{name}_MOSI'): if (func := funcs.get(f'{name}_MOSI')) != None:
f.write(f'impl_spi_pin!({name}, MosiPin, {pin}, {func});') f.write(f'impl_spi_pin!({name}, MosiPin, {pin}, {func});')
if func := funcs.get(f'{name}_MISO'): if (func := funcs.get(f'{name}_MISO')) != None:
f.write(f'impl_spi_pin!({name}, MisoPin, {pin}, {func});') f.write(f'impl_spi_pin!({name}, MisoPin, {pin}, {func});')
if block_mod == 'i2c': if block_mod == 'i2c':
@ -174,25 +174,25 @@ for chip in chips.values():
f.write(f'impl_sdmmc!({name});') f.write(f'impl_sdmmc!({name});')
for pin, funcs in af.items(): for pin, funcs in af.items():
if pin in pins: if pin in pins:
if func := funcs.get(f'{name}_CK'): if (func := funcs.get(f'{name}_CK')) != None:
f.write(f'impl_sdmmc_pin!({name}, CkPin, {pin}, {func});') f.write(f'impl_sdmmc_pin!({name}, CkPin, {pin}, {func});')
if func := funcs.get(f'{name}_CMD'): if (func := funcs.get(f'{name}_CMD')) != None:
f.write(f'impl_sdmmc_pin!({name}, CmdPin, {pin}, {func});') f.write(f'impl_sdmmc_pin!({name}, CmdPin, {pin}, {func});')
if func := funcs.get(f'{name}_D0'): if (func := funcs.get(f'{name}_D0')) != None:
f.write(f'impl_sdmmc_pin!({name}, D0Pin, {pin}, {func});') f.write(f'impl_sdmmc_pin!({name}, D0Pin, {pin}, {func});')
if func := funcs.get(f'{name}_D1'): if (func := funcs.get(f'{name}_D1')) != None:
f.write(f'impl_sdmmc_pin!({name}, D1Pin, {pin}, {func});') f.write(f'impl_sdmmc_pin!({name}, D1Pin, {pin}, {func});')
if func := funcs.get(f'{name}_D2'): if (func := funcs.get(f'{name}_D2')) != None:
f.write(f'impl_sdmmc_pin!({name}, D2Pin, {pin}, {func});') f.write(f'impl_sdmmc_pin!({name}, D2Pin, {pin}, {func});')
if func := funcs.get(f'{name}_D3'): if (func := funcs.get(f'{name}_D3')) != None:
f.write(f'impl_sdmmc_pin!({name}, D3Pin, {pin}, {func});') f.write(f'impl_sdmmc_pin!({name}, D3Pin, {pin}, {func});')
if func := funcs.get(f'{name}_D4'): if (func := funcs.get(f'{name}_D4')) != None:
f.write(f'impl_sdmmc_pin!({name}, D4Pin, {pin}, {func});') f.write(f'impl_sdmmc_pin!({name}, D4Pin, {pin}, {func});')
if func := funcs.get(f'{name}_D5'): if (func := funcs.get(f'{name}_D5')) != None:
f.write(f'impl_sdmmc_pin!({name}, D5Pin, {pin}, {func});') f.write(f'impl_sdmmc_pin!({name}, D5Pin, {pin}, {func});')
if func := funcs.get(f'{name}_D6'): if (func := funcs.get(f'{name}_D6')) != None:
f.write(f'impl_sdmmc_pin!({name}, D6Pin, {pin}, {func});') f.write(f'impl_sdmmc_pin!({name}, D6Pin, {pin}, {func});')
if func := funcs.get(f'{name}_D7'): if (func := funcs.get(f'{name}_D7')) != None:
f.write(f'impl_sdmmc_pin!({name}, D7Pin, {pin}, {func});') f.write(f'impl_sdmmc_pin!({name}, D7Pin, {pin}, {func});')
if block_name == 'TimGp16': if block_name == 'TimGp16':