diff options
| author | Grant Miller <[email protected]> | 2021-12-06 14:02:21 -0600 |
|---|---|---|
| committer | Grant Miller <[email protected]> | 2021-12-06 14:02:21 -0600 |
| commit | d426caefbfdc7ea4395df9007d786d3efc37eb88 (patch) | |
| tree | 72ce415b9efc9f708939be1dd85a7b2fc564bdbb | |
| parent | 8b4a247af2b54bd4deb8416b6181791e381c5aa3 (diff) | |
Move NoPin impls from v1 to mod
| -rw-r--r-- | embassy-stm32/src/spi/mod.rs | 22 | ||||
| -rw-r--r-- | embassy-stm32/src/spi/v1.rs | 22 |
2 files changed, 22 insertions, 22 deletions
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index e881a5235..8668f6344 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs | |||
| @@ -8,7 +8,7 @@ mod _version; | |||
| 8 | use crate::{dma, peripherals, rcc::RccPeripheral}; | 8 | use crate::{dma, peripherals, rcc::RccPeripheral}; |
| 9 | pub use _version::*; | 9 | pub use _version::*; |
| 10 | 10 | ||
| 11 | use crate::gpio::OptionalPin; | 11 | use crate::gpio::{NoPin, OptionalPin}; |
| 12 | 12 | ||
| 13 | #[derive(Debug)] | 13 | #[derive(Debug)] |
| 14 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 14 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| @@ -135,6 +135,26 @@ crate::pac::peripheral_pins!( | |||
| 135 | }; | 135 | }; |
| 136 | ); | 136 | ); |
| 137 | 137 | ||
| 138 | macro_rules! impl_nopin { | ||
| 139 | ($inst:ident, $signal:ident) => { | ||
| 140 | impl $signal<peripherals::$inst> for NoPin {} | ||
| 141 | |||
| 142 | impl sealed::$signal<peripherals::$inst> for NoPin { | ||
| 143 | fn af_num(&self) -> u8 { | ||
| 144 | 0 | ||
| 145 | } | ||
| 146 | } | ||
| 147 | }; | ||
| 148 | } | ||
| 149 | |||
| 150 | crate::pac::peripherals!( | ||
| 151 | (spi, $inst:ident) => { | ||
| 152 | impl_nopin!($inst, SckPin); | ||
| 153 | impl_nopin!($inst, MosiPin); | ||
| 154 | impl_nopin!($inst, MisoPin); | ||
| 155 | }; | ||
| 156 | ); | ||
| 157 | |||
| 138 | macro_rules! impl_dma { | 158 | macro_rules! impl_dma { |
| 139 | ($inst:ident, {dmamux: $dmamux:ident}, $signal:ident, $request:expr) => { | 159 | ($inst:ident, {dmamux: $dmamux:ident}, $signal:ident, $request:expr) => { |
| 140 | impl<T> sealed::$signal<peripherals::$inst> for T | 160 | impl<T> sealed::$signal<peripherals::$inst> for T |
diff --git a/embassy-stm32/src/spi/v1.rs b/embassy-stm32/src/spi/v1.rs index b727f2008..9ad9397a4 100644 --- a/embassy-stm32/src/spi/v1.rs +++ b/embassy-stm32/src/spi/v1.rs | |||
| @@ -3,9 +3,8 @@ | |||
| 3 | use crate::dma::NoDma; | 3 | use crate::dma::NoDma; |
| 4 | use crate::gpio::sealed::AFType; | 4 | use crate::gpio::sealed::AFType; |
| 5 | use crate::gpio::sealed::Pin; | 5 | use crate::gpio::sealed::Pin; |
| 6 | use crate::gpio::{AnyPin, NoPin}; | 6 | use crate::gpio::AnyPin; |
| 7 | use crate::pac::spi; | 7 | use crate::pac::spi; |
| 8 | use crate::peripherals; | ||
| 9 | use crate::spi::{ | 8 | use crate::spi::{ |
| 10 | ByteOrder, Config, Error, Instance, MisoPin, MosiPin, RxDmaChannel, SckPin, TxDmaChannel, | 9 | ByteOrder, Config, Error, Instance, MisoPin, MosiPin, RxDmaChannel, SckPin, TxDmaChannel, |
| 11 | WordSize, | 10 | WordSize, |
| @@ -30,25 +29,6 @@ impl WordSize { | |||
| 30 | } | 29 | } |
| 31 | } | 30 | } |
| 32 | 31 | ||
| 33 | macro_rules! impl_nopin { | ||
| 34 | ($inst:ident, $signal:ident) => { | ||
| 35 | impl $signal<peripherals::$inst> for NoPin {} | ||
| 36 | |||
| 37 | impl super::sealed::$signal<peripherals::$inst> for NoPin { | ||
| 38 | fn af_num(&self) -> u8 { | ||
| 39 | 0 | ||
| 40 | } | ||
| 41 | } | ||
| 42 | }; | ||
| 43 | } | ||
| 44 | crate::pac::peripherals!( | ||
| 45 | (spi, $inst:ident) => { | ||
| 46 | impl_nopin!($inst, SckPin); | ||
| 47 | impl_nopin!($inst, MosiPin); | ||
| 48 | impl_nopin!($inst, MisoPin); | ||
| 49 | }; | ||
| 50 | ); | ||
| 51 | |||
| 52 | pub struct Spi<'d, T: Instance, Tx, Rx> { | 32 | pub struct Spi<'d, T: Instance, Tx, Rx> { |
| 53 | sck: Option<AnyPin>, | 33 | sck: Option<AnyPin>, |
| 54 | mosi: Option<AnyPin>, | 34 | mosi: Option<AnyPin>, |
