diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-06-03 21:38:59 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-06-03 21:38:59 +0200 |
| commit | ebd3be74253dc72b35072475f6f9c2c1830f318e (patch) | |
| tree | 4fe9829d6807dee273e11f776f03bee0d07802d7 | |
| parent | 31feed53d5b4b1d6cb12e8e49997b762b7fddd4f (diff) | |
| parent | b4dca64e206dfc01fde98b6b4cc2b0a05245bc0d (diff) | |
Merge pull request #219 from bobmcwhirter/peripheral_pins
Create the new peripheral_pins! macro table.
| -rw-r--r-- | embassy-stm32/gen.py | 93 | ||||
| -rw-r--r-- | embassy-stm32/src/clock.rs | 14 | ||||
| -rw-r--r-- | embassy-stm32/src/dac/mod.rs | 28 | ||||
| -rw-r--r-- | embassy-stm32/src/dma/mod.rs | 29 | ||||
| -rw-r--r-- | embassy-stm32/src/exti.rs | 76 | ||||
| -rw-r--r-- | embassy-stm32/src/i2c/mod.rs | 30 | ||||
| -rw-r--r-- | embassy-stm32/src/lib.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/rng.rs | 37 | ||||
| -rw-r--r-- | embassy-stm32/src/sdmmc/mod.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/sdmmc/v2.rs | 61 | ||||
| -rw-r--r-- | embassy-stm32/src/spi/mod.rs | 33 | ||||
| -rw-r--r-- | embassy-stm32/src/usart/mod.rs | 43 | ||||
| m--------- | stm32-data | 0 | ||||
| -rw-r--r-- | stm32-metapac/build.rs | 39 |
14 files changed, 310 insertions, 177 deletions
diff --git a/embassy-stm32/gen.py b/embassy-stm32/gen.py index bfb791945..2736cd69d 100644 --- a/embassy-stm32/gen.py +++ b/embassy-stm32/gen.py | |||
| @@ -48,48 +48,6 @@ with open(output_file, 'w') as f: | |||
| 48 | 48 | ||
| 49 | custom_singletons = False | 49 | custom_singletons = False |
| 50 | 50 | ||
| 51 | if block_mod == 'usart': | ||
| 52 | f.write(f'impl_usart!({name});') | ||
| 53 | for pin, funcs in af.items(): | ||
| 54 | if pin in pins: | ||
| 55 | if (func := funcs.get(f'{name}_RX')) != None: | ||
| 56 | f.write(f'impl_usart_pin!({name}, RxPin, {pin}, {func});') | ||
| 57 | if (func := funcs.get(f'{name}_TX')) != None: | ||
| 58 | f.write(f'impl_usart_pin!({name}, TxPin, {pin}, {func});') | ||
| 59 | if (func := funcs.get(f'{name}_CTS')) != None: | ||
| 60 | f.write(f'impl_usart_pin!({name}, CtsPin, {pin}, {func});') | ||
| 61 | if (func := funcs.get(f'{name}_RTS')) != None: | ||
| 62 | f.write(f'impl_usart_pin!({name}, RtsPin, {pin}, {func});') | ||
| 63 | if (func := funcs.get(f'{name}_CK')) != None: | ||
| 64 | f.write(f'impl_usart_pin!({name}, CkPin, {pin}, {func});') | ||
| 65 | |||
| 66 | if block_mod == 'rng': | ||
| 67 | for irq in chip['interrupts']: | ||
| 68 | if re.search('RNG', irq): | ||
| 69 | f.write(f'impl_rng!({name}, {irq});') | ||
| 70 | |||
| 71 | if block_mod == 'spi': | ||
| 72 | if 'clock' in peri: | ||
| 73 | clock = peri['clock'] | ||
| 74 | f.write(f'impl_spi!({name}, {clock});') | ||
| 75 | for pin, funcs in af.items(): | ||
| 76 | if pin in pins: | ||
| 77 | if (func := funcs.get(f'{name}_SCK')) != None: | ||
| 78 | f.write(f'impl_spi_pin!({name}, SckPin, {pin}, {func});') | ||
| 79 | if (func := funcs.get(f'{name}_MOSI')) != None: | ||
| 80 | f.write(f'impl_spi_pin!({name}, MosiPin, {pin}, {func});') | ||
| 81 | if (func := funcs.get(f'{name}_MISO')) != None: | ||
| 82 | f.write(f'impl_spi_pin!({name}, MisoPin, {pin}, {func});') | ||
| 83 | |||
| 84 | if block_mod == 'i2c': | ||
| 85 | f.write(f'impl_i2c!({name});') | ||
| 86 | for pin, funcs in af.items(): | ||
| 87 | if pin in pins: | ||
| 88 | if func := funcs.get(f'{name}_SCL'): | ||
| 89 | f.write(f'impl_i2c_pin!({name}, SclPin, {pin}, {func});') | ||
| 90 | if func := funcs.get(f'{name}_SDA'): | ||
| 91 | f.write(f'impl_i2c_pin!({name}, SdaPin, {pin}, {func});') | ||
| 92 | |||
| 93 | if block_mod == 'gpio': | 51 | if block_mod == 'gpio': |
| 94 | custom_singletons = True | 52 | custom_singletons = True |
| 95 | port = name[4:] | 53 | port = name[4:] |
| @@ -102,62 +60,11 @@ with open(output_file, 'w') as f: | |||
| 102 | 60 | ||
| 103 | if block_mod == 'dma': | 61 | if block_mod == 'dma': |
| 104 | custom_singletons = True | 62 | custom_singletons = True |
| 105 | num_dmas += 1 | ||
| 106 | dma_num = int(name[3:])-1 # substract 1 because we want DMA1=0, DMA2=1 | ||
| 107 | |||
| 108 | for ch_num in range(8): | 63 | for ch_num in range(8): |
| 109 | channel = f'{name}_CH{ch_num}' | 64 | channel = f'{name}_CH{ch_num}' |
| 110 | singletons.append(channel) | 65 | singletons.append(channel) |
| 111 | 66 | ||
| 112 | f.write(f'impl_dma_channel!({channel}, {dma_num}, {ch_num});') | ||
| 113 | |||
| 114 | if peri['block'] == 'sdmmc_v2/SDMMC': | ||
| 115 | f.write(f'impl_sdmmc!({name});') | ||
| 116 | for pin, funcs in af.items(): | ||
| 117 | if pin in pins: | ||
| 118 | if (func := funcs.get(f'{name}_CK')) != None: | ||
| 119 | f.write(f'impl_sdmmc_pin!({name}, CkPin, {pin}, {func});') | ||
| 120 | if (func := funcs.get(f'{name}_CMD')) != None: | ||
| 121 | f.write(f'impl_sdmmc_pin!({name}, CmdPin, {pin}, {func});') | ||
| 122 | if (func := funcs.get(f'{name}_D0')) != None: | ||
| 123 | f.write(f'impl_sdmmc_pin!({name}, D0Pin, {pin}, {func});') | ||
| 124 | if (func := funcs.get(f'{name}_D1')) != None: | ||
| 125 | f.write(f'impl_sdmmc_pin!({name}, D1Pin, {pin}, {func});') | ||
| 126 | if (func := funcs.get(f'{name}_D2')) != None: | ||
| 127 | f.write(f'impl_sdmmc_pin!({name}, D2Pin, {pin}, {func});') | ||
| 128 | if (func := funcs.get(f'{name}_D3')) != None: | ||
| 129 | f.write(f'impl_sdmmc_pin!({name}, D3Pin, {pin}, {func});') | ||
| 130 | if (func := funcs.get(f'{name}_D4')) != None: | ||
| 131 | f.write(f'impl_sdmmc_pin!({name}, D4Pin, {pin}, {func});') | ||
| 132 | if (func := funcs.get(f'{name}_D5')) != None: | ||
| 133 | f.write(f'impl_sdmmc_pin!({name}, D5Pin, {pin}, {func});') | ||
| 134 | if (func := funcs.get(f'{name}_D6')) != None: | ||
| 135 | f.write(f'impl_sdmmc_pin!({name}, D6Pin, {pin}, {func});') | ||
| 136 | if (func := funcs.get(f'{name}_D7')) != None: | ||
| 137 | f.write(f'impl_sdmmc_pin!({name}, D7Pin, {pin}, {func});') | ||
| 138 | |||
| 139 | if block_name == 'TimGp16': | ||
| 140 | if re.match('TIM[2345]$', name): | ||
| 141 | f.write(f'impl_timer!({name});') | ||
| 142 | |||
| 143 | if block_mod == 'exti': | ||
| 144 | for irq in chip['interrupts']: | ||
| 145 | if re.match('EXTI', irq): | ||
| 146 | exti_interrupts.append(irq) | ||
| 147 | |||
| 148 | if block_mod == 'dac': | ||
| 149 | f.write(f'impl_dac!({name});') | ||
| 150 | if 'dac_out1' in peri: | ||
| 151 | pin = peri['dac_out1'] | ||
| 152 | f.write(f'impl_dac_pin!({name}, 1, {pin});') | ||
| 153 | if 'dac_out2' in peri: | ||
| 154 | pin = peri['dac_out2'] | ||
| 155 | f.write(f'impl_dac_pin!({name}, 2, {pin});') | ||
| 156 | |||
| 157 | if not custom_singletons: | 67 | if not custom_singletons: |
| 158 | singletons.append(name) | 68 | singletons.append(name) |
| 159 | 69 | ||
| 160 | f.write(f"embassy_extras::peripherals!({','.join(singletons)});") | 70 | f.write(f"embassy_extras::peripherals!({','.join(singletons)});") |
| 161 | |||
| 162 | # ========= exti interrupts | ||
| 163 | f.write(f"impl_exti_irq!({','.join(exti_interrupts)});") | ||
diff --git a/embassy-stm32/src/clock.rs b/embassy-stm32/src/clock.rs index aa83c5b45..694ca666d 100644 --- a/embassy-stm32/src/clock.rs +++ b/embassy-stm32/src/clock.rs | |||
| @@ -10,6 +10,7 @@ use embassy::time::{Clock as EmbassyClock, TICKS_PER_SECOND}; | |||
| 10 | 10 | ||
| 11 | use crate::interrupt::{CriticalSection, Interrupt, Mutex}; | 11 | use crate::interrupt::{CriticalSection, Interrupt, Mutex}; |
| 12 | use crate::pac::timer::TimGp16; | 12 | use crate::pac::timer::TimGp16; |
| 13 | use crate::peripherals; | ||
| 13 | use crate::time::Hertz; | 14 | use crate::time::Hertz; |
| 14 | 15 | ||
| 15 | // Clock timekeeping works with something we call "periods", which are time intervals | 16 | // Clock timekeeping works with something we call "periods", which are time intervals |
| @@ -362,15 +363,22 @@ pub trait Instance: sealed::Instance + Sized + 'static {} | |||
| 362 | 363 | ||
| 363 | macro_rules! impl_timer { | 364 | macro_rules! impl_timer { |
| 364 | ($inst:ident) => { | 365 | ($inst:ident) => { |
| 365 | impl crate::clock::sealed::Instance for peripherals::$inst { | 366 | impl sealed::Instance for peripherals::$inst { |
| 366 | type Interrupt = crate::interrupt::$inst; | 367 | type Interrupt = crate::interrupt::$inst; |
| 367 | 368 | ||
| 368 | fn inner() -> crate::clock::TimerInner { | 369 | fn inner() -> crate::clock::TimerInner { |
| 369 | const INNER: crate::clock::TimerInner = crate::clock::TimerInner(crate::pac::$inst); | 370 | const INNER: TimerInner = TimerInner(crate::pac::$inst); |
| 370 | INNER | 371 | INNER |
| 371 | } | 372 | } |
| 372 | } | 373 | } |
| 373 | 374 | ||
| 374 | impl crate::clock::Instance for peripherals::$inst {} | 375 | impl Instance for peripherals::$inst {} |
| 375 | }; | 376 | }; |
| 376 | } | 377 | } |
| 378 | |||
| 379 | crate::pac::peripherals!( | ||
| 380 | (timer, TIM2) => { impl_timer!(TIM2); }; | ||
| 381 | (timer, TIM3) => { impl_timer!(TIM3); }; | ||
| 382 | (timer, TIM4) => { impl_timer!(TIM4); }; | ||
| 383 | (timer, TIM5) => { impl_timer!(TIM5); }; | ||
| 384 | ); | ||
diff --git a/embassy-stm32/src/dac/mod.rs b/embassy-stm32/src/dac/mod.rs index e1a603d40..46c485b35 100644 --- a/embassy-stm32/src/dac/mod.rs +++ b/embassy-stm32/src/dac/mod.rs | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #[cfg_attr(dac_v2, path = "v2.rs")] | 3 | #[cfg_attr(dac_v2, path = "v2.rs")] |
| 4 | mod _version; | 4 | mod _version; |
| 5 | use crate::gpio::NoPin; | 5 | use crate::gpio::NoPin; |
| 6 | use crate::peripherals; | ||
| 6 | pub use _version::*; | 7 | pub use _version::*; |
| 7 | 8 | ||
| 8 | pub(crate) mod sealed { | 9 | pub(crate) mod sealed { |
| @@ -23,8 +24,8 @@ pub trait DacPin<T: Instance, const C: u8>: sealed::DacPin<T, C> + 'static {} | |||
| 23 | impl<T: Instance, const C: u8> DacPin<T, C> for NoPin {} | 24 | impl<T: Instance, const C: u8> DacPin<T, C> for NoPin {} |
| 24 | impl<T: Instance, const C: u8> sealed::DacPin<T, C> for NoPin {} | 25 | impl<T: Instance, const C: u8> sealed::DacPin<T, C> for NoPin {} |
| 25 | 26 | ||
| 26 | macro_rules! impl_dac { | 27 | crate::pac::peripherals!( |
| 27 | ($inst:ident) => { | 28 | (dac, $inst:ident) => { |
| 28 | impl crate::dac::sealed::Instance for peripherals::$inst { | 29 | impl crate::dac::sealed::Instance for peripherals::$inst { |
| 29 | fn regs() -> &'static crate::pac::dac::Dac { | 30 | fn regs() -> &'static crate::pac::dac::Dac { |
| 30 | &crate::pac::$inst | 31 | &crate::pac::$inst |
| @@ -33,16 +34,21 @@ macro_rules! impl_dac { | |||
| 33 | 34 | ||
| 34 | impl crate::dac::Instance for peripherals::$inst {} | 35 | impl crate::dac::Instance for peripherals::$inst {} |
| 35 | }; | 36 | }; |
| 36 | } | 37 | ); |
| 37 | 38 | ||
| 38 | macro_rules! impl_dac_pin { | 39 | crate::pac::peripheral_pins!( |
| 39 | ($inst:ident, $channel:expr, $pin:ident ) => { | 40 | ($inst:ident, dac, DAC, $pin:ident, OUT1) => { |
| 40 | impl crate::dac::DacPin<peripherals::$inst, $channel> for peripherals::$pin {} | 41 | impl DacPin<peripherals::$inst, 1> for peripherals::$pin {} |
| 41 | 42 | ||
| 42 | impl crate::dac::sealed::DacPin<peripherals::$inst, $channel> for peripherals::$pin { | 43 | impl sealed::DacPin<peripherals::$inst, 1> for peripherals::$pin { |
| 43 | //fn af_num(&self) -> u8 { | ||
| 44 | //$af | ||
| 45 | //} | ||
| 46 | } | 44 | } |
| 45 | |||
| 47 | }; | 46 | }; |
| 48 | } | 47 | |
| 48 | ($inst:ident, dac, DAC, $pin:ident, OUT2) => { | ||
| 49 | impl DacPin<peripherals::$inst, 2> for peripherals::$pin {} | ||
| 50 | |||
| 51 | impl sealed::DacPin<peripherals::$inst, 2> for peripherals::$pin { | ||
| 52 | } | ||
| 53 | }; | ||
| 54 | ); | ||
diff --git a/embassy-stm32/src/dma/mod.rs b/embassy-stm32/src/dma/mod.rs index aef31ce74..773cdc8b8 100644 --- a/embassy-stm32/src/dma/mod.rs +++ b/embassy-stm32/src/dma/mod.rs | |||
| @@ -8,6 +8,7 @@ mod _version; | |||
| 8 | pub use _version::*; | 8 | pub use _version::*; |
| 9 | 9 | ||
| 10 | use crate::pac; | 10 | use crate::pac; |
| 11 | use crate::peripherals; | ||
| 11 | 12 | ||
| 12 | pub(crate) mod sealed { | 13 | pub(crate) mod sealed { |
| 13 | use super::*; | 14 | use super::*; |
| @@ -31,8 +32,8 @@ pub trait Channel: sealed::Channel + Sized {} | |||
| 31 | 32 | ||
| 32 | macro_rules! impl_dma_channel { | 33 | macro_rules! impl_dma_channel { |
| 33 | ($type:ident, $dma_num:expr, $ch_num:expr) => { | 34 | ($type:ident, $dma_num:expr, $ch_num:expr) => { |
| 34 | impl crate::dma::Channel for peripherals::$type {} | 35 | impl Channel for peripherals::$type {} |
| 35 | impl crate::dma::sealed::Channel for peripherals::$type { | 36 | impl sealed::Channel for peripherals::$type { |
| 36 | #[inline] | 37 | #[inline] |
| 37 | fn num(&self) -> u8 { | 38 | fn num(&self) -> u8 { |
| 38 | $dma_num * 8 + $ch_num | 39 | $dma_num * 8 + $ch_num |
| @@ -40,3 +41,27 @@ macro_rules! impl_dma_channel { | |||
| 40 | } | 41 | } |
| 41 | }; | 42 | }; |
| 42 | } | 43 | } |
| 44 | |||
| 45 | crate::pac::peripherals!( | ||
| 46 | (dma,DMA1) => { | ||
| 47 | impl_dma_channel!(DMA1_CH0, 0, 0); | ||
| 48 | impl_dma_channel!(DMA1_CH1, 0, 1); | ||
| 49 | impl_dma_channel!(DMA1_CH2, 0, 2); | ||
| 50 | impl_dma_channel!(DMA1_CH3, 0, 3); | ||
| 51 | impl_dma_channel!(DMA1_CH4, 0, 4); | ||
| 52 | impl_dma_channel!(DMA1_CH5, 0, 5); | ||
| 53 | impl_dma_channel!(DMA1_CH6, 0, 6); | ||
| 54 | impl_dma_channel!(DMA1_CH7, 0, 7); | ||
| 55 | }; | ||
| 56 | |||
| 57 | (dma,DMA2) => { | ||
| 58 | impl_dma_channel!(DMA2_CH0, 1, 0); | ||
| 59 | impl_dma_channel!(DMA2_CH1, 1, 1); | ||
| 60 | impl_dma_channel!(DMA2_CH2, 1, 2); | ||
| 61 | impl_dma_channel!(DMA2_CH3, 1, 3); | ||
| 62 | impl_dma_channel!(DMA2_CH4, 1, 4); | ||
| 63 | impl_dma_channel!(DMA2_CH5, 1, 5); | ||
| 64 | impl_dma_channel!(DMA2_CH6, 1, 6); | ||
| 65 | impl_dma_channel!(DMA2_CH7, 1, 7); | ||
| 66 | }; | ||
| 67 | ); | ||
diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index 61c28aa7e..90d4afd56 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs | |||
| @@ -212,25 +212,63 @@ impl_exti!(EXTI13, 13); | |||
| 212 | impl_exti!(EXTI14, 14); | 212 | impl_exti!(EXTI14, 14); |
| 213 | impl_exti!(EXTI15, 15); | 213 | impl_exti!(EXTI15, 15); |
| 214 | 214 | ||
| 215 | pub(crate) unsafe fn init() {} | 215 | macro_rules! foreach_exti_irq { |
| 216 | 216 | ($action:ident) => { | |
| 217 | macro_rules! impl_exti_irq { | 217 | crate::pac::interrupts!( |
| 218 | ($($e:ident),+) => { | 218 | (EXTI0) => { $action!(EXTI0); }; |
| 219 | /// safety: must be called only once | 219 | (EXTI1) => { $action!(EXTI1); }; |
| 220 | pub(crate) unsafe fn init_exti() { | 220 | (EXTI2) => { $action!(EXTI2); }; |
| 221 | use embassy::interrupt::Interrupt; | 221 | (EXTI3) => { $action!(EXTI3); }; |
| 222 | use embassy::interrupt::InterruptExt; | 222 | (EXTI4) => { $action!(EXTI4); }; |
| 223 | 223 | (EXTI5) => { $action!(EXTI5); }; | |
| 224 | $( | 224 | (EXTI6) => { $action!(EXTI6); }; |
| 225 | crate::interrupt::$e::steal().enable(); | 225 | (EXTI7) => { $action!(EXTI7); }; |
| 226 | )+ | 226 | (EXTI8) => { $action!(EXTI8); }; |
| 227 | } | 227 | (EXTI9) => { $action!(EXTI9); }; |
| 228 | (EXTI10) => { $action!(EXTI10); }; | ||
| 229 | (EXTI11) => { $action!(EXTI11); }; | ||
| 230 | (EXTI12) => { $action!(EXTI12); }; | ||
| 231 | (EXTI13) => { $action!(EXTI13); }; | ||
| 232 | (EXTI14) => { $action!(EXTI14); }; | ||
| 233 | (EXTI15) => { $action!(EXTI15); }; | ||
| 234 | |||
| 235 | // plus the weird ones | ||
| 236 | (EXTI0_1) => { $action!( EXTI0_1 ); }; | ||
| 237 | (EXTI15_10) => { $action!(EXTI15_10); }; | ||
| 238 | (EXTI15_4) => { $action!(EXTI15_4); }; | ||
| 239 | (EXTI1_0) => { $action!(EXTI1_0); }; | ||
| 240 | (EXTI2_3) => { $action!(EXTI2_3); }; | ||
| 241 | (EXTI2_TSC) => { $action!(EXTI2_TSC); }; | ||
| 242 | (EXTI3_2) => { $action!(EXTI3_2); }; | ||
| 243 | (EXTI4_15) => { $action!(EXTI4_15); }; | ||
| 244 | (EXTI9_5) => { $action!(EXTI9_5); }; | ||
| 245 | ); | ||
| 246 | }; | ||
| 247 | } | ||
| 228 | 248 | ||
| 229 | $( | 249 | macro_rules! enable_irq { |
| 230 | #[crate::interrupt] | 250 | ($e:ident) => { |
| 231 | unsafe fn $e() { | 251 | crate::interrupt::$e::steal().enable(); |
| 232 | crate::exti::on_irq() | ||
| 233 | } | ||
| 234 | )+ | ||
| 235 | }; | 252 | }; |
| 236 | } | 253 | } |
| 254 | |||
| 255 | /// safety: must be called only once | ||
| 256 | pub(crate) unsafe fn init() { | ||
| 257 | use embassy::interrupt::Interrupt; | ||
| 258 | use embassy::interrupt::InterruptExt; | ||
| 259 | |||
| 260 | foreach_exti_irq!(enable_irq); | ||
| 261 | } | ||
| 262 | |||
| 263 | use crate::interrupt; | ||
| 264 | |||
| 265 | macro_rules! impl_irq { | ||
| 266 | ($e:ident) => { | ||
| 267 | #[interrupt] | ||
| 268 | unsafe fn $e() { | ||
| 269 | on_irq() | ||
| 270 | } | ||
| 271 | }; | ||
| 272 | } | ||
| 273 | |||
| 274 | foreach_exti_irq!(impl_irq); | ||
diff --git a/embassy-stm32/src/i2c/mod.rs b/embassy-stm32/src/i2c/mod.rs index 7b0dd8160..0f9414c53 100644 --- a/embassy-stm32/src/i2c/mod.rs +++ b/embassy-stm32/src/i2c/mod.rs | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #[cfg_attr(i2c_v1, path = "v1.rs")] | 3 | #[cfg_attr(i2c_v1, path = "v1.rs")] |
| 4 | #[cfg_attr(i2c_v2, path = "v2.rs")] | 4 | #[cfg_attr(i2c_v2, path = "v2.rs")] |
| 5 | mod _version; | 5 | mod _version; |
| 6 | use crate::peripherals; | ||
| 6 | pub use _version::*; | 7 | pub use _version::*; |
| 7 | 8 | ||
| 8 | pub enum Error { | 9 | pub enum Error { |
| @@ -37,26 +38,37 @@ pub trait SclPin<T: Instance>: sealed::SclPin<T> + 'static {} | |||
| 37 | 38 | ||
| 38 | pub trait SdaPin<T: Instance>: sealed::SdaPin<T> + 'static {} | 39 | pub trait SdaPin<T: Instance>: sealed::SdaPin<T> + 'static {} |
| 39 | 40 | ||
| 40 | macro_rules! impl_i2c { | 41 | crate::pac::peripherals!( |
| 41 | ($inst:ident) => { | 42 | (i2c, $inst:ident) => { |
| 42 | impl crate::i2c::sealed::Instance for peripherals::$inst { | 43 | impl sealed::Instance for peripherals::$inst { |
| 43 | fn regs() -> &'static crate::pac::i2c::I2c { | 44 | fn regs() -> &'static crate::pac::i2c::I2c { |
| 44 | &crate::pac::$inst | 45 | &crate::pac::$inst |
| 45 | } | 46 | } |
| 46 | } | 47 | } |
| 47 | 48 | ||
| 48 | impl crate::i2c::Instance for peripherals::$inst {} | 49 | impl Instance for peripherals::$inst {} |
| 50 | |||
| 49 | }; | 51 | }; |
| 50 | } | 52 | ); |
| 51 | 53 | ||
| 52 | macro_rules! impl_i2c_pin { | 54 | macro_rules! impl_pin { |
| 53 | ($inst:ident, $pin_func:ident, $pin:ident, $af:expr) => { | 55 | ($inst:ident, $pin:ident, $signal:ident, $af:expr) => { |
| 54 | impl crate::i2c::$pin_func<peripherals::$inst> for peripherals::$pin {} | 56 | impl $signal<peripherals::$inst> for peripherals::$pin {} |
| 55 | 57 | ||
| 56 | impl crate::i2c::sealed::$pin_func<peripherals::$inst> for peripherals::$pin { | 58 | impl sealed::$signal<peripherals::$inst> for peripherals::$pin { |
| 57 | fn af_num(&self) -> u8 { | 59 | fn af_num(&self) -> u8 { |
| 58 | $af | 60 | $af |
| 59 | } | 61 | } |
| 60 | } | 62 | } |
| 61 | }; | 63 | }; |
| 62 | } | 64 | } |
| 65 | |||
| 66 | crate::pac::peripheral_pins!( | ||
| 67 | ($inst:ident, i2c, I2C, $pin:ident, SDA, $af:expr) => { | ||
| 68 | impl_pin!($inst, $pin, SdaPin, $af); | ||
| 69 | }; | ||
| 70 | |||
| 71 | ($inst:ident, i2c, I2C, $pin:ident, SCL, $af:expr) => { | ||
| 72 | impl_pin!($inst, $pin, SclPin, $af); | ||
| 73 | }; | ||
| 74 | ); | ||
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index c51f93eb5..c205bc49d 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -83,7 +83,7 @@ pub fn init(config: Config) -> Peripherals { | |||
| 83 | 83 | ||
| 84 | #[cfg(dma)] | 84 | #[cfg(dma)] |
| 85 | dma::init(); | 85 | dma::init(); |
| 86 | generated::init_exti(); | 86 | exti::init(); |
| 87 | rcc::init(config.rcc); | 87 | rcc::init(config.rcc); |
| 88 | } | 88 | } |
| 89 | 89 | ||
diff --git a/embassy-stm32/src/rng.rs b/embassy-stm32/src/rng.rs index 694ad4a1c..704f1a97b 100644 --- a/embassy-stm32/src/rng.rs +++ b/embassy-stm32/src/rng.rs | |||
| @@ -9,6 +9,7 @@ use futures::future::poll_fn; | |||
| 9 | use rand_core::{CryptoRng, RngCore}; | 9 | use rand_core::{CryptoRng, RngCore}; |
| 10 | 10 | ||
| 11 | use crate::pac; | 11 | use crate::pac; |
| 12 | use crate::peripherals; | ||
| 12 | 13 | ||
| 13 | pub(crate) static RNG_WAKER: AtomicWaker = AtomicWaker::new(); | 14 | pub(crate) static RNG_WAKER: AtomicWaker = AtomicWaker::new(); |
| 14 | 15 | ||
| @@ -134,16 +135,20 @@ pub(crate) mod sealed { | |||
| 134 | 135 | ||
| 135 | pub trait Instance: sealed::Instance {} | 136 | pub trait Instance: sealed::Instance {} |
| 136 | 137 | ||
| 137 | macro_rules! impl_rng { | 138 | crate::pac::peripherals!( |
| 138 | ($inst:ident, $irq:ident) => { | 139 | (rng, $inst:ident) => { |
| 139 | impl crate::rng::sealed::Instance for peripherals::RNG { | 140 | impl Instance for peripherals::$inst {} |
| 141 | |||
| 142 | impl sealed::Instance for peripherals::$inst { | ||
| 140 | fn regs() -> crate::pac::rng::Rng { | 143 | fn regs() -> crate::pac::rng::Rng { |
| 141 | crate::pac::RNG | 144 | crate::pac::RNG |
| 142 | } | 145 | } |
| 143 | } | 146 | } |
| 147 | }; | ||
| 148 | ); | ||
| 144 | 149 | ||
| 145 | impl crate::rng::Instance for peripherals::RNG {} | 150 | macro_rules! irq { |
| 146 | 151 | ($irq:ident) => { | |
| 147 | mod rng_irq { | 152 | mod rng_irq { |
| 148 | use crate::interrupt; | 153 | use crate::interrupt; |
| 149 | 154 | ||
| @@ -158,3 +163,25 @@ macro_rules! impl_rng { | |||
| 158 | } | 163 | } |
| 159 | }; | 164 | }; |
| 160 | } | 165 | } |
| 166 | |||
| 167 | crate::pac::interrupts!( | ||
| 168 | (RNG) => { | ||
| 169 | irq!(RNG); | ||
| 170 | }; | ||
| 171 | |||
| 172 | (RNG_LPUART1) => { | ||
| 173 | irq!(RNG_LPUART1); | ||
| 174 | }; | ||
| 175 | |||
| 176 | (AES_RNG_LPUART1) => { | ||
| 177 | irq!(AES_RNG_LPUART1); | ||
| 178 | }; | ||
| 179 | |||
| 180 | (AES_RNG) => { | ||
| 181 | irq!(AES_RNG); | ||
| 182 | }; | ||
| 183 | |||
| 184 | (HASH_RNG) => { | ||
| 185 | irq!(HASH_RNG); | ||
| 186 | }; | ||
| 187 | ); | ||
diff --git a/embassy-stm32/src/sdmmc/mod.rs b/embassy-stm32/src/sdmmc/mod.rs index 087cb4c40..9244c22a6 100644 --- a/embassy-stm32/src/sdmmc/mod.rs +++ b/embassy-stm32/src/sdmmc/mod.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | 2 | ||
| 3 | #[cfg_attr(sdmmc_v1, path = "v1.rs")] | 3 | //#[cfg_attr(sdmmc_v1, path = "v1.rs")] |
| 4 | #[cfg_attr(sdmmc_v2, path = "v2.rs")] | 4 | #[cfg_attr(sdmmc_v2, path = "v2.rs")] |
| 5 | mod _version; | 5 | mod _version; |
| 6 | 6 | ||
diff --git a/embassy-stm32/src/sdmmc/v2.rs b/embassy-stm32/src/sdmmc/v2.rs index e432ca9a3..2c7f8ac00 100644 --- a/embassy-stm32/src/sdmmc/v2.rs +++ b/embassy-stm32/src/sdmmc/v2.rs | |||
| @@ -15,6 +15,7 @@ use crate::interrupt::Interrupt; | |||
| 15 | use crate::pac; | 15 | use crate::pac; |
| 16 | use crate::pac::gpio::Gpio; | 16 | use crate::pac::gpio::Gpio; |
| 17 | use crate::pac::sdmmc::Sdmmc as RegBlock; | 17 | use crate::pac::sdmmc::Sdmmc as RegBlock; |
| 18 | use crate::peripherals; | ||
| 18 | use crate::time::Hertz; | 19 | use crate::time::Hertz; |
| 19 | 20 | ||
| 20 | /// The signalling scheme used on the SDMMC bus | 21 | /// The signalling scheme used on the SDMMC bus |
| @@ -1469,13 +1470,13 @@ where | |||
| 1469 | } | 1470 | } |
| 1470 | } | 1471 | } |
| 1471 | 1472 | ||
| 1472 | macro_rules! impl_sdmmc { | 1473 | crate::pac::peripherals!( |
| 1473 | ($inst:ident) => { | 1474 | (sdmmc, $inst:ident) => { |
| 1474 | impl crate::sdmmc::sealed::Instance for peripherals::$inst { | 1475 | impl sealed::Instance for peripherals::$inst { |
| 1475 | type Interrupt = crate::interrupt::$inst; | 1476 | type Interrupt = crate::interrupt::$inst; |
| 1476 | 1477 | ||
| 1477 | fn inner() -> crate::sdmmc::SdmmcInner { | 1478 | fn inner() -> SdmmcInner { |
| 1478 | const INNER: crate::sdmmc::SdmmcInner = crate::sdmmc::SdmmcInner(crate::pac::$inst); | 1479 | const INNER: SdmmcInner = SdmmcInner(crate::pac::$inst); |
| 1479 | INNER | 1480 | INNER |
| 1480 | } | 1481 | } |
| 1481 | 1482 | ||
| @@ -1485,20 +1486,56 @@ macro_rules! impl_sdmmc { | |||
| 1485 | } | 1486 | } |
| 1486 | } | 1487 | } |
| 1487 | 1488 | ||
| 1488 | impl crate::sdmmc::Instance for peripherals::$inst {} | 1489 | impl Instance for peripherals::$inst {} |
| 1489 | }; | 1490 | }; |
| 1490 | } | 1491 | ); |
| 1491 | 1492 | ||
| 1492 | macro_rules! impl_sdmmc_pin { | 1493 | macro_rules! impl_pin { |
| 1493 | ($inst:ident, $func:ident, $pin:ident, $num:expr) => { | 1494 | ($inst:ident, $pin:ident, $signal:ident, $af:expr) => { |
| 1494 | impl crate::sdmmc::sealed::$func<peripherals::$inst> for peripherals::$pin { | 1495 | impl sealed::$signal<peripherals::$inst> for peripherals::$pin { |
| 1495 | const AF_NUM: u8 = $num; | 1496 | const AF_NUM: u8 = $af; |
| 1496 | } | 1497 | } |
| 1497 | 1498 | ||
| 1498 | impl crate::sdmmc::$func<peripherals::$inst> for peripherals::$pin {} | 1499 | impl $signal<peripherals::$inst> for peripherals::$pin {} |
| 1499 | }; | 1500 | }; |
| 1500 | } | 1501 | } |
| 1501 | 1502 | ||
| 1503 | crate::pac::peripheral_pins!( | ||
| 1504 | ($inst:ident, sdmmc, SDMMC, $pin:ident, CK, $af:expr) => { | ||
| 1505 | impl_pin!($inst, $pin, CkPin, $af); | ||
| 1506 | }; | ||
| 1507 | ($inst:ident, sdmmc, SDMMC, $pin:ident, CMD, $af:expr) => { | ||
| 1508 | impl_pin!($inst, $pin, CmdPin, $af); | ||
| 1509 | }; | ||
| 1510 | ($inst:ident, sdmmc, SDMMC, $pin:ident, D0, $af:expr) => { | ||
| 1511 | impl_pin!($inst, $pin, D0Pin, $af); | ||
| 1512 | }; | ||
| 1513 | ($inst:ident, sdmmc, SDMMC, $pin:ident, D1, $af:expr) => { | ||
| 1514 | impl_pin!($inst, $pin, D1Pin, $af); | ||
| 1515 | }; | ||
| 1516 | ($inst:ident, sdmmc, SDMMC, $pin:ident, D2, $af:expr) => { | ||
| 1517 | impl_pin!($inst, $pin, D2Pin, $af); | ||
| 1518 | }; | ||
| 1519 | ($inst:ident, sdmmc, SDMMC, $pin:ident, D3, $af:expr) => { | ||
| 1520 | impl_pin!($inst, $pin, D3Pin, $af); | ||
| 1521 | }; | ||
| 1522 | ($inst:ident, sdmmc, SDMMC, $pin:ident, D4, $af:expr) => { | ||
| 1523 | impl_pin!($inst, $pin, D4Pin, $af); | ||
| 1524 | }; | ||
| 1525 | ($inst:ident, sdmmc, SDMMC, $pin:ident, D5, $af:expr) => { | ||
| 1526 | impl_pin!($inst, $pin, D5Pin, $af); | ||
| 1527 | }; | ||
| 1528 | ($inst:ident, sdmmc, SDMMC, $pin:ident, D6, $af:expr) => { | ||
| 1529 | impl_pin!($inst, $pin, D6Pin, $af); | ||
| 1530 | }; | ||
| 1531 | ($inst:ident, sdmmc, SDMMC, $pin:ident, D6, $af:expr) => { | ||
| 1532 | impl_pin!($inst, $pin, D7Pin, $af); | ||
| 1533 | }; | ||
| 1534 | ($inst:ident, sdmmc, SDMMC, $pin:ident, D8, $af:expr) => { | ||
| 1535 | impl_pin!($inst, $pin, D8Pin, $af); | ||
| 1536 | }; | ||
| 1537 | ); | ||
| 1538 | |||
| 1502 | #[cfg(feature = "sdmmc-rs")] | 1539 | #[cfg(feature = "sdmmc-rs")] |
| 1503 | mod sdmmc_rs { | 1540 | mod sdmmc_rs { |
| 1504 | use super::*; | 1541 | use super::*; |
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index d8bd66d9c..730169ec0 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #[cfg_attr(spi_v2, path = "v2.rs")] | 4 | #[cfg_attr(spi_v2, path = "v2.rs")] |
| 5 | #[cfg_attr(spi_v3, path = "v3.rs")] | 5 | #[cfg_attr(spi_v3, path = "v3.rs")] |
| 6 | mod _version; | 6 | mod _version; |
| 7 | use crate::peripherals; | ||
| 7 | pub use _version::*; | 8 | pub use _version::*; |
| 8 | 9 | ||
| 9 | use crate::gpio::Pin; | 10 | use crate::gpio::Pin; |
| @@ -71,26 +72,40 @@ pub trait MosiPin<T: Instance>: sealed::MosiPin<T> + 'static {} | |||
| 71 | 72 | ||
| 72 | pub trait MisoPin<T: Instance>: sealed::MisoPin<T> + 'static {} | 73 | pub trait MisoPin<T: Instance>: sealed::MisoPin<T> + 'static {} |
| 73 | 74 | ||
| 74 | macro_rules! impl_spi { | 75 | crate::pac::peripherals!( |
| 75 | ($inst:ident, $clk:ident) => { | 76 | (spi, $inst:ident) => { |
| 76 | impl crate::spi::sealed::Instance for peripherals::$inst { | 77 | impl sealed::Instance for peripherals::$inst { |
| 77 | fn regs() -> &'static crate::pac::spi::Spi { | 78 | fn regs() -> &'static crate::pac::spi::Spi { |
| 78 | &crate::pac::$inst | 79 | &crate::pac::$inst |
| 79 | } | 80 | } |
| 80 | } | 81 | } |
| 81 | 82 | ||
| 82 | impl crate::spi::Instance for peripherals::$inst {} | 83 | impl Instance for peripherals::$inst {} |
| 83 | }; | 84 | }; |
| 84 | } | 85 | ); |
| 85 | 86 | ||
| 86 | macro_rules! impl_spi_pin { | 87 | macro_rules! impl_pin { |
| 87 | ($inst:ident, $pin_func:ident, $pin:ident, $af:expr) => { | 88 | ($inst:ident, $pin:ident, $signal:ident, $af:expr) => { |
| 88 | impl crate::spi::$pin_func<peripherals::$inst> for peripherals::$pin {} | 89 | impl $signal<peripherals::$inst> for peripherals::$pin {} |
| 89 | 90 | ||
| 90 | impl crate::spi::sealed::$pin_func<peripherals::$inst> for peripherals::$pin { | 91 | impl sealed::$signal<peripherals::$inst> for peripherals::$pin { |
| 91 | fn af_num(&self) -> u8 { | 92 | fn af_num(&self) -> u8 { |
| 92 | $af | 93 | $af |
| 93 | } | 94 | } |
| 94 | } | 95 | } |
| 95 | }; | 96 | }; |
| 96 | } | 97 | } |
| 98 | |||
| 99 | crate::pac::peripheral_pins!( | ||
| 100 | ($inst:ident, spi, SPI, $pin:ident, SCK, $af:expr) => { | ||
| 101 | impl_pin!($inst, $pin, SckPin, $af); | ||
| 102 | }; | ||
| 103 | |||
| 104 | ($inst:ident, spi, SPI, $pin:ident, MOSI, $af:expr) => { | ||
| 105 | impl_pin!($inst, $pin, MosiPin, $af); | ||
| 106 | }; | ||
| 107 | |||
| 108 | ($inst:ident, spi, SPI, $pin:ident, MISO, $af:expr) => { | ||
| 109 | impl_pin!($inst, $pin, MisoPin, $af); | ||
| 110 | }; | ||
| 111 | ); | ||
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index 77b217c3a..adf48c326 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #[cfg_attr(usart_v1, path = "v1.rs")] | 3 | #[cfg_attr(usart_v1, path = "v1.rs")] |
| 4 | #[cfg_attr(usart_v2, path = "v2.rs")] | 4 | #[cfg_attr(usart_v2, path = "v2.rs")] |
| 5 | mod _version; | 5 | mod _version; |
| 6 | use crate::peripherals; | ||
| 6 | pub use _version::*; | 7 | pub use _version::*; |
| 7 | 8 | ||
| 8 | use crate::gpio::Pin; | 9 | use crate::gpio::Pin; |
| @@ -51,24 +52,48 @@ pub trait CtsPin<T: Instance>: sealed::CtsPin<T> {} | |||
| 51 | pub trait RtsPin<T: Instance>: sealed::RtsPin<T> {} | 52 | pub trait RtsPin<T: Instance>: sealed::RtsPin<T> {} |
| 52 | pub trait CkPin<T: Instance>: sealed::CkPin<T> {} | 53 | pub trait CkPin<T: Instance>: sealed::CkPin<T> {} |
| 53 | 54 | ||
| 54 | macro_rules! impl_usart { | 55 | crate::pac::peripherals!( |
| 55 | ($inst:ident) => { | 56 | (usart, $inst:ident) => { |
| 56 | impl crate::usart::sealed::Instance for peripherals::$inst { | 57 | impl sealed::Instance for peripherals::$inst { |
| 57 | fn regs(&self) -> crate::pac::usart::Usart { | 58 | fn regs(&self) -> crate::pac::usart::Usart { |
| 58 | crate::pac::$inst | 59 | crate::pac::$inst |
| 59 | } | 60 | } |
| 60 | } | 61 | } |
| 61 | impl crate::usart::Instance for peripherals::$inst {} | 62 | |
| 63 | impl Instance for peripherals::$inst {} | ||
| 62 | }; | 64 | }; |
| 63 | } | 65 | ); |
| 64 | 66 | ||
| 65 | macro_rules! impl_usart_pin { | 67 | macro_rules! impl_pin { |
| 66 | ($inst:ident, $func:ident, $pin:ident, $af:expr) => { | 68 | ($inst:ident, $pin:ident, $signal:ident, $af:expr) => { |
| 67 | impl crate::usart::sealed::$func<peripherals::$inst> for peripherals::$pin { | 69 | impl sealed::$signal<peripherals::$inst> for peripherals::$pin { |
| 68 | fn af_num(&self) -> u8 { | 70 | fn af_num(&self) -> u8 { |
| 69 | $af | 71 | $af |
| 70 | } | 72 | } |
| 71 | } | 73 | } |
| 72 | impl crate::usart::$func<peripherals::$inst> for peripherals::$pin {} | 74 | |
| 75 | impl $signal<peripherals::$inst> for peripherals::$pin {} | ||
| 73 | }; | 76 | }; |
| 74 | } | 77 | } |
| 78 | |||
| 79 | crate::pac::peripheral_pins!( | ||
| 80 | ($inst:ident, usart, USART, $pin:ident, TX, $af:expr) => { | ||
| 81 | impl_pin!($inst, $pin, TxPin, $af); | ||
| 82 | }; | ||
| 83 | |||
| 84 | ($inst:ident, usart, USART, $pin:ident, RX, $af:expr) => { | ||
| 85 | impl_pin!($inst, $pin, RxPin, $af); | ||
| 86 | }; | ||
| 87 | |||
| 88 | ($inst:ident, usart, USART, $pin:ident, CTS, $af:expr) => { | ||
| 89 | impl_pin!($inst, $pin, CtsPin, $af); | ||
| 90 | }; | ||
| 91 | |||
| 92 | ($inst:ident, usart, USART, $pin:ident, RTS, $af:expr) => { | ||
| 93 | impl_pin!($inst, $pin, RtsPin, $af); | ||
| 94 | }; | ||
| 95 | |||
| 96 | ($inst:ident, usart, USART, $pin:ident, CK, $af:expr) => { | ||
| 97 | impl_pin!($inst, $pin, CkPin, $af); | ||
| 98 | }; | ||
| 99 | ); | ||
diff --git a/stm32-data b/stm32-data | |||
| Subproject dfc67fe255e1e70101e9f1e3fb8b4fd8bb37362 | Subproject 33dfa674865b1b5f0bfb86f3217055a6a057a6f | ||
diff --git a/stm32-metapac/build.rs b/stm32-metapac/build.rs index 49ca76201..ef95f3313 100644 --- a/stm32-metapac/build.rs +++ b/stm32-metapac/build.rs | |||
| @@ -40,12 +40,24 @@ pub struct Peripheral { | |||
| 40 | pub block: Option<String>, | 40 | pub block: Option<String>, |
| 41 | #[serde(default)] | 41 | #[serde(default)] |
| 42 | pub clock: Option<String>, | 42 | pub clock: Option<String>, |
| 43 | #[serde(default)] | ||
| 44 | pub pins: Vec<Pin>, | ||
| 45 | } | ||
| 46 | |||
| 47 | #[derive(Debug, Eq, PartialEq, Clone, Deserialize)] | ||
| 48 | pub struct Pin { | ||
| 49 | pub pin: String, | ||
| 50 | pub signal: String, | ||
| 51 | pub af: Option<String>, | ||
| 43 | } | 52 | } |
| 44 | 53 | ||
| 45 | struct BlockInfo { | 54 | struct BlockInfo { |
| 46 | module: String, // usart_v1/USART -> usart | 55 | /// usart_v1/USART -> usart |
| 47 | version: String, // usart_v1/USART -> v1 | 56 | module: String, |
| 48 | block: String, // usart_v1/USART -> USART | 57 | /// usart_v1/USART -> v1 |
| 58 | version: String, | ||
| 59 | /// usart_v1/USART -> USART | ||
| 60 | block: String, | ||
| 49 | } | 61 | } |
| 50 | 62 | ||
| 51 | impl BlockInfo { | 63 | impl BlockInfo { |
| @@ -123,6 +135,8 @@ fn main() { | |||
| 123 | let mut cfgs: HashSet<String> = HashSet::new(); | 135 | let mut cfgs: HashSet<String> = HashSet::new(); |
| 124 | let mut pin_table: Vec<Vec<String>> = Vec::new(); | 136 | let mut pin_table: Vec<Vec<String>> = Vec::new(); |
| 125 | let mut interrupt_table: Vec<Vec<String>> = Vec::new(); | 137 | let mut interrupt_table: Vec<Vec<String>> = Vec::new(); |
| 138 | let mut peripherals_table: Vec<Vec<String>> = Vec::new(); | ||
| 139 | let mut peripheral_pins_table: Vec<Vec<String>> = Vec::new(); | ||
| 126 | 140 | ||
| 127 | let dma_base = chip | 141 | let dma_base = chip |
| 128 | .peripherals | 142 | .peripherals |
| @@ -149,8 +163,25 @@ fn main() { | |||
| 149 | if let Some(block) = &p.block { | 163 | if let Some(block) = &p.block { |
| 150 | let bi = BlockInfo::parse(block); | 164 | let bi = BlockInfo::parse(block); |
| 151 | 165 | ||
| 166 | for pin in &p.pins { | ||
| 167 | let mut row = Vec::new(); | ||
| 168 | row.push(name.clone()); | ||
| 169 | row.push(bi.module.clone()); | ||
| 170 | row.push(bi.block.clone()); | ||
| 171 | row.push(pin.pin.clone()); | ||
| 172 | row.push(pin.signal.clone()); | ||
| 173 | if let Some(ref af) = pin.af { | ||
| 174 | row.push(af.clone()); | ||
| 175 | } | ||
| 176 | peripheral_pins_table.push(row); | ||
| 177 | } | ||
| 178 | |||
| 152 | cfgs.insert(bi.module.clone()); | 179 | cfgs.insert(bi.module.clone()); |
| 153 | cfgs.insert(format!("{}_{}", bi.module, bi.version)); | 180 | cfgs.insert(format!("{}_{}", bi.module, bi.version)); |
| 181 | let mut peripheral_row = Vec::new(); | ||
| 182 | peripheral_row.push(bi.module.clone()); | ||
| 183 | peripheral_row.push(name.clone()); | ||
| 184 | peripherals_table.push(peripheral_row); | ||
| 154 | 185 | ||
| 155 | if let Some(old_version) = | 186 | if let Some(old_version) = |
| 156 | peripheral_versions.insert(bi.module.clone(), bi.version.clone()) | 187 | peripheral_versions.insert(bi.module.clone(), bi.version.clone()) |
| @@ -226,7 +257,9 @@ fn main() { | |||
| 226 | 257 | ||
| 227 | make_table(&mut extra, "pins", &pin_table); | 258 | make_table(&mut extra, "pins", &pin_table); |
| 228 | make_table(&mut extra, "interrupts", &interrupt_table); | 259 | make_table(&mut extra, "interrupts", &interrupt_table); |
| 260 | make_table(&mut extra, "peripherals", &peripherals_table); | ||
| 229 | make_table(&mut extra, "peripheral_versions", &peripheral_version_table); | 261 | make_table(&mut extra, "peripheral_versions", &peripheral_version_table); |
| 262 | make_table(&mut extra, "peripheral_pins", &peripheral_pins_table); | ||
| 230 | 263 | ||
| 231 | for (module, version) in peripheral_versions { | 264 | for (module, version) in peripheral_versions { |
| 232 | println!("loading {} {}", module, version); | 265 | println!("loading {} {}", module, version); |
