diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index ad37f071..3c0f6e04 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs @@ -5,7 +5,6 @@ use core::task::Poll; use embassy::util::WakerRegistration; use futures::future::poll_fn; -use crate::fmt::*; use crate::hal::gpio::Port as GpioPort; use crate::interrupt::{self, Interrupt}; use crate::util::peripheral::{PeripheralMutex, PeripheralState}; @@ -216,12 +215,6 @@ impl PeripheralState for State { mod sealed { pub trait Instance {} - - impl Instance for crate::pac::SPIM0 {} - impl Instance for crate::pac::SPIM1 {} - impl Instance for crate::pac::SPIM2 {} - impl Instance for crate::pac::SPIM3 {} - impl Instance for &mut T {} } pub trait Instance: sealed::Instance { @@ -229,24 +222,40 @@ pub trait Instance: sealed::Instance { fn regs(&mut self) -> &pac::spim0::RegisterBlock; } +impl sealed::Instance for pac::SPIM0 {} impl Instance for pac::SPIM0 { + #[cfg(feature = "52810")] + type Interrupt = interrupt::SPIM0_SPIS0_SPI0; + #[cfg(not(feature = "52810"))] type Interrupt = interrupt::SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0; fn regs(&mut self) -> &pac::spim0::RegisterBlock { self } } + +#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))] +impl sealed::Instance for pac::SPIM1 {} +#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))] impl Instance for pac::SPIM1 { type Interrupt = interrupt::SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1; fn regs(&mut self) -> &pac::spim0::RegisterBlock { self } } + +#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))] +impl sealed::Instance for pac::SPIM2 {} +#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))] impl Instance for pac::SPIM2 { type Interrupt = interrupt::SPIM2_SPIS2_SPI2; fn regs(&mut self) -> &pac::spim0::RegisterBlock { self } } + +#[cfg(any(feature = "52833", feature = "52840"))] +impl sealed::Instance for pac::SPIM3 {} +#[cfg(any(feature = "52833", feature = "52840"))] impl Instance for pac::SPIM3 { type Interrupt = interrupt::SPIM3; fn regs(&mut self) -> &pac::spim0::RegisterBlock { @@ -254,6 +263,7 @@ impl Instance for pac::SPIM3 { } } +impl sealed::Instance for &mut T {} impl Instance for &mut T { type Interrupt = T::Interrupt; fn regs(&mut self) -> &pac::spim0::RegisterBlock {