diff options
| author | Bob McWhirter <[email protected]> | 2021-06-03 11:31:03 -0400 |
|---|---|---|
| committer | Bob McWhirter <[email protected]> | 2021-06-03 13:12:38 -0400 |
| commit | c00a85f9a9e1506c23650b27d8db5a1c5b046aa5 (patch) | |
| tree | 1fb955e2e29bf23ddd3266932e33c891681e6b19 | |
| parent | 3dd497c1e63bdf03c064ca58ef15cda51eb17146 (diff) | |
Refactor SPI signal pin macro.
| -rw-r--r-- | embassy-stm32/src/spi/mod.rs | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index a888622de..730169ec0 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs | |||
| @@ -84,34 +84,28 @@ crate::pac::peripherals!( | |||
| 84 | }; | 84 | }; |
| 85 | ); | 85 | ); |
| 86 | 86 | ||
| 87 | crate::pac::peripheral_pins!( | 87 | macro_rules! impl_pin { |
| 88 | ($inst:ident, spi, SPI, $pin:ident, SCK, $af:expr) => { | 88 | ($inst:ident, $pin:ident, $signal:ident, $af:expr) => { |
| 89 | impl SckPin<peripherals::$inst> for peripherals::$pin {} | 89 | impl $signal<peripherals::$inst> for peripherals::$pin {} |
| 90 | 90 | ||
| 91 | impl sealed::SckPin<peripherals::$inst> for peripherals::$pin { | 91 | impl sealed::$signal<peripherals::$inst> for peripherals::$pin { |
| 92 | fn af_num(&self) -> u8 { | 92 | fn af_num(&self) -> u8 { |
| 93 | $af | 93 | $af |
| 94 | } | 94 | } |
| 95 | } | 95 | } |
| 96 | }; | 96 | }; |
| 97 | } | ||
| 97 | 98 | ||
| 98 | ($inst:ident, spi, SPI, $pin:ident, MOSI, $af:expr) => { | 99 | crate::pac::peripheral_pins!( |
| 99 | impl MosiPin<peripherals::$inst> for peripherals::$pin {} | 100 | ($inst:ident, spi, SPI, $pin:ident, SCK, $af:expr) => { |
| 101 | impl_pin!($inst, $pin, SckPin, $af); | ||
| 102 | }; | ||
| 100 | 103 | ||
| 101 | impl sealed::MosiPin<peripherals::$inst> for peripherals::$pin { | 104 | ($inst:ident, spi, SPI, $pin:ident, MOSI, $af:expr) => { |
| 102 | fn af_num(&self) -> u8 { | 105 | impl_pin!($inst, $pin, MosiPin, $af); |
| 103 | $af | ||
| 104 | } | ||
| 105 | } | ||
| 106 | }; | 106 | }; |
| 107 | 107 | ||
| 108 | ($inst:ident, spi, SPI, $pin:ident, MISO, $af:expr) => { | 108 | ($inst:ident, spi, SPI, $pin:ident, MISO, $af:expr) => { |
| 109 | impl MisoPin<peripherals::$inst> for peripherals::$pin {} | 109 | impl_pin!($inst, $pin, MisoPin, $af); |
| 110 | |||
| 111 | impl sealed::MisoPin<peripherals::$inst> for peripherals::$pin { | ||
| 112 | fn af_num(&self) -> u8 { | ||
| 113 | $af | ||
| 114 | } | ||
| 115 | } | ||
| 116 | }; | 110 | }; |
| 117 | ); | 111 | ); |
