nrf/spim: support all chips

This commit is contained in:
Dario Nieuwenhuis 2021-03-01 00:28:00 +01:00
parent 255bf1aa6a
commit a30c705fd7

View file

@ -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<U: Instance> PeripheralState for State<U> {
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<T: Instance> 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<T: sealed::Instance> sealed::Instance for &mut T {}
impl<T: Instance> Instance for &mut T {
type Interrupt = T::Interrupt;
fn regs(&mut self) -> &pac::spim0::RegisterBlock {