diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index e881a523..8668f634 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs @@ -8,7 +8,7 @@ mod _version; use crate::{dma, peripherals, rcc::RccPeripheral}; pub use _version::*; -use crate::gpio::OptionalPin; +use crate::gpio::{NoPin, OptionalPin}; #[derive(Debug)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] @@ -135,6 +135,26 @@ crate::pac::peripheral_pins!( }; ); +macro_rules! impl_nopin { + ($inst:ident, $signal:ident) => { + impl $signal for NoPin {} + + impl sealed::$signal for NoPin { + fn af_num(&self) -> u8 { + 0 + } + } + }; +} + +crate::pac::peripherals!( + (spi, $inst:ident) => { + impl_nopin!($inst, SckPin); + impl_nopin!($inst, MosiPin); + impl_nopin!($inst, MisoPin); + }; +); + macro_rules! impl_dma { ($inst:ident, {dmamux: $dmamux:ident}, $signal:ident, $request:expr) => { impl sealed::$signal for T diff --git a/embassy-stm32/src/spi/v1.rs b/embassy-stm32/src/spi/v1.rs index b727f200..9ad9397a 100644 --- a/embassy-stm32/src/spi/v1.rs +++ b/embassy-stm32/src/spi/v1.rs @@ -3,9 +3,8 @@ use crate::dma::NoDma; use crate::gpio::sealed::AFType; use crate::gpio::sealed::Pin; -use crate::gpio::{AnyPin, NoPin}; +use crate::gpio::AnyPin; use crate::pac::spi; -use crate::peripherals; use crate::spi::{ ByteOrder, Config, Error, Instance, MisoPin, MosiPin, RxDmaChannel, SckPin, TxDmaChannel, WordSize, @@ -30,25 +29,6 @@ impl WordSize { } } -macro_rules! impl_nopin { - ($inst:ident, $signal:ident) => { - impl $signal for NoPin {} - - impl super::sealed::$signal for NoPin { - fn af_num(&self) -> u8 { - 0 - } - } - }; -} -crate::pac::peripherals!( - (spi, $inst:ident) => { - impl_nopin!($inst, SckPin); - impl_nopin!($inst, MosiPin); - impl_nopin!($inst, MisoPin); - }; -); - pub struct Spi<'d, T: Instance, Tx, Rx> { sck: Option, mosi: Option,