aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-03-01 00:28:00 +0100
committerDario Nieuwenhuis <[email protected]>2021-03-01 00:36:30 +0100
commita30c705fd79e8f05177eaa690beac5e8c53296c1 (patch)
treeef7e317bcc4771acbe4f85102901edd29f66d19c
parent255bf1aa6a68193a1521ae57a841fe4a9928a1d1 (diff)
nrf/spim: support all chips
-rw-r--r--embassy-nrf/src/spim.rs24
1 files changed, 17 insertions, 7 deletions
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs
index ad37f0714..3c0f6e047 100644
--- a/embassy-nrf/src/spim.rs
+++ b/embassy-nrf/src/spim.rs
@@ -5,7 +5,6 @@ use core::task::Poll;
5use embassy::util::WakerRegistration; 5use embassy::util::WakerRegistration;
6use futures::future::poll_fn; 6use futures::future::poll_fn;
7 7
8use crate::fmt::*;
9use crate::hal::gpio::Port as GpioPort; 8use crate::hal::gpio::Port as GpioPort;
10use crate::interrupt::{self, Interrupt}; 9use crate::interrupt::{self, Interrupt};
11use crate::util::peripheral::{PeripheralMutex, PeripheralState}; 10use crate::util::peripheral::{PeripheralMutex, PeripheralState};
@@ -216,12 +215,6 @@ impl<U: Instance> PeripheralState for State<U> {
216 215
217mod sealed { 216mod sealed {
218 pub trait Instance {} 217 pub trait Instance {}
219
220 impl Instance for crate::pac::SPIM0 {}
221 impl Instance for crate::pac::SPIM1 {}
222 impl Instance for crate::pac::SPIM2 {}
223 impl Instance for crate::pac::SPIM3 {}
224 impl<T: Instance> Instance for &mut T {}
225} 218}
226 219
227pub trait Instance: sealed::Instance { 220pub trait Instance: sealed::Instance {
@@ -229,24 +222,40 @@ pub trait Instance: sealed::Instance {
229 fn regs(&mut self) -> &pac::spim0::RegisterBlock; 222 fn regs(&mut self) -> &pac::spim0::RegisterBlock;
230} 223}
231 224
225impl sealed::Instance for pac::SPIM0 {}
232impl Instance for pac::SPIM0 { 226impl Instance for pac::SPIM0 {
227 #[cfg(feature = "52810")]
228 type Interrupt = interrupt::SPIM0_SPIS0_SPI0;
229 #[cfg(not(feature = "52810"))]
233 type Interrupt = interrupt::SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0; 230 type Interrupt = interrupt::SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0;
234 fn regs(&mut self) -> &pac::spim0::RegisterBlock { 231 fn regs(&mut self) -> &pac::spim0::RegisterBlock {
235 self 232 self
236 } 233 }
237} 234}
235
236#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))]
237impl sealed::Instance for pac::SPIM1 {}
238#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))]
238impl Instance for pac::SPIM1 { 239impl Instance for pac::SPIM1 {
239 type Interrupt = interrupt::SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1; 240 type Interrupt = interrupt::SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1;
240 fn regs(&mut self) -> &pac::spim0::RegisterBlock { 241 fn regs(&mut self) -> &pac::spim0::RegisterBlock {
241 self 242 self
242 } 243 }
243} 244}
245
246#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))]
247impl sealed::Instance for pac::SPIM2 {}
248#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))]
244impl Instance for pac::SPIM2 { 249impl Instance for pac::SPIM2 {
245 type Interrupt = interrupt::SPIM2_SPIS2_SPI2; 250 type Interrupt = interrupt::SPIM2_SPIS2_SPI2;
246 fn regs(&mut self) -> &pac::spim0::RegisterBlock { 251 fn regs(&mut self) -> &pac::spim0::RegisterBlock {
247 self 252 self
248 } 253 }
249} 254}
255
256#[cfg(any(feature = "52833", feature = "52840"))]
257impl sealed::Instance for pac::SPIM3 {}
258#[cfg(any(feature = "52833", feature = "52840"))]
250impl Instance for pac::SPIM3 { 259impl Instance for pac::SPIM3 {
251 type Interrupt = interrupt::SPIM3; 260 type Interrupt = interrupt::SPIM3;
252 fn regs(&mut self) -> &pac::spim0::RegisterBlock { 261 fn regs(&mut self) -> &pac::spim0::RegisterBlock {
@@ -254,6 +263,7 @@ impl Instance for pac::SPIM3 {
254 } 263 }
255} 264}
256 265
266impl<T: sealed::Instance> sealed::Instance for &mut T {}
257impl<T: Instance> Instance for &mut T { 267impl<T: Instance> Instance for &mut T {
258 type Interrupt = T::Interrupt; 268 type Interrupt = T::Interrupt;
259 fn regs(&mut self) -> &pac::spim0::RegisterBlock { 269 fn regs(&mut self) -> &pac::spim0::RegisterBlock {