aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-05-15 00:05:32 +0200
committerDario Nieuwenhuis <[email protected]>2021-05-17 01:01:31 +0200
commita5ad79927ecaa9d6cd7bd96e015b66afa9201d84 (patch)
treede9f18e1f858e62b03c0c465135bea3f57d926ac
parent8394603ea6c76b29d1cb14f706e048eebbd933c3 (diff)
nrf: add `Unborrow<Target = Self>` bound to all instance traits
-rw-r--r--embassy-nrf/src/gpio.rs4
-rw-r--r--embassy-nrf/src/pwm.rs2
-rw-r--r--embassy-nrf/src/qspi.rs2
-rw-r--r--embassy-nrf/src/rtc.rs4
-rw-r--r--embassy-nrf/src/spim.rs2
-rw-r--r--embassy-nrf/src/timer.rs3
-rw-r--r--embassy-nrf/src/twim.rs2
-rw-r--r--embassy-nrf/src/uarte.rs2
8 files changed, 11 insertions, 10 deletions
diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs
index 2cdb685d3..fed1ae049 100644
--- a/embassy-nrf/src/gpio.rs
+++ b/embassy-nrf/src/gpio.rs
@@ -331,7 +331,7 @@ pub(crate) mod sealed {
331 pub trait OptionalPin {} 331 pub trait OptionalPin {}
332} 332}
333 333
334pub trait Pin: sealed::Pin + Sized { 334pub trait Pin: Unborrow<Target = Self> + sealed::Pin + Sized {
335 /// Number of the pin within the port (0..31) 335 /// Number of the pin within the port (0..31)
336 #[inline] 336 #[inline]
337 fn pin(&self) -> u8 { 337 fn pin(&self) -> u8 {
@@ -435,7 +435,7 @@ fn init_output<T: Pin>(pin: &T, drive: OutputDrive) {
435 435
436// ==================== 436// ====================
437 437
438pub trait OptionalPin: sealed::OptionalPin + Sized { 438pub trait OptionalPin: Unborrow<Target = Self> + sealed::OptionalPin + Sized {
439 type Pin: Pin; 439 type Pin: Pin;
440 fn pin(&self) -> Option<&Self::Pin>; 440 fn pin(&self) -> Option<&Self::Pin>;
441 fn pin_mut(&mut self) -> Option<&mut Self::Pin>; 441 fn pin_mut(&mut self) -> Option<&mut Self::Pin>;
diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs
index 4f500d722..34c31e3bb 100644
--- a/embassy-nrf/src/pwm.rs
+++ b/embassy-nrf/src/pwm.rs
@@ -211,7 +211,7 @@ pub(crate) mod sealed {
211 } 211 }
212} 212}
213 213
214pub trait Instance: sealed::Instance + 'static { 214pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static {
215 type Interrupt: Interrupt; 215 type Interrupt: Interrupt;
216} 216}
217 217
diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs
index d75070220..db6b653e7 100644
--- a/embassy-nrf/src/qspi.rs
+++ b/embassy-nrf/src/qspi.rs
@@ -383,7 +383,7 @@ pub(crate) mod sealed {
383 } 383 }
384} 384}
385 385
386pub trait Instance: sealed::Instance + 'static { 386pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static {
387 type Interrupt: Interrupt; 387 type Interrupt: Interrupt;
388} 388}
389 389
diff --git a/embassy-nrf/src/rtc.rs b/embassy-nrf/src/rtc.rs
index dc0e3ceb6..99b6c099d 100644
--- a/embassy-nrf/src/rtc.rs
+++ b/embassy-nrf/src/rtc.rs
@@ -3,7 +3,7 @@ use core::sync::atomic::{compiler_fence, AtomicU32, Ordering};
3use critical_section::CriticalSection; 3use critical_section::CriticalSection;
4use embassy::interrupt::InterruptExt; 4use embassy::interrupt::InterruptExt;
5use embassy::time::Clock; 5use embassy::time::Clock;
6use embassy::util::CriticalSectionMutex as Mutex; 6use embassy::util::{CriticalSectionMutex as Mutex, Unborrow};
7 7
8use crate::interrupt::Interrupt; 8use crate::interrupt::Interrupt;
9use crate::pac; 9use crate::pac;
@@ -283,7 +283,7 @@ macro_rules! impl_instance {
283} 283}
284 284
285/// Implemented by all RTC instances. 285/// Implemented by all RTC instances.
286pub trait Instance: sealed::Instance + 'static { 286pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static {
287 /// The interrupt associated with this RTC instance. 287 /// The interrupt associated with this RTC instance.
288 type Interrupt: Interrupt; 288 type Interrupt: Interrupt;
289} 289}
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs
index 1fb3d441b..0703836b9 100644
--- a/embassy-nrf/src/spim.rs
+++ b/embassy-nrf/src/spim.rs
@@ -349,7 +349,7 @@ pub(crate) mod sealed {
349 } 349 }
350} 350}
351 351
352pub trait Instance: sealed::Instance + 'static { 352pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static {
353 type Interrupt: Interrupt; 353 type Interrupt: Interrupt;
354} 354}
355 355
diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs
index 69d620b48..2490bfd93 100644
--- a/embassy-nrf/src/timer.rs
+++ b/embassy-nrf/src/timer.rs
@@ -1,6 +1,7 @@
1#![macro_use] 1#![macro_use]
2 2
3use embassy::interrupt::Interrupt; 3use embassy::interrupt::Interrupt;
4use embassy::util::Unborrow;
4 5
5use crate::pac; 6use crate::pac;
6 7
@@ -13,7 +14,7 @@ pub(crate) mod sealed {
13 pub trait ExtendedInstance {} 14 pub trait ExtendedInstance {}
14} 15}
15 16
16pub trait Instance: sealed::Instance + 'static { 17pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static {
17 type Interrupt: Interrupt; 18 type Interrupt: Interrupt;
18} 19}
19pub trait ExtendedInstance: Instance + sealed::ExtendedInstance {} 20pub trait ExtendedInstance: Instance + sealed::ExtendedInstance {}
diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs
index cbaf97dff..3e0fbc3d0 100644
--- a/embassy-nrf/src/twim.rs
+++ b/embassy-nrf/src/twim.rs
@@ -509,7 +509,7 @@ pub(crate) mod sealed {
509 } 509 }
510} 510}
511 511
512pub trait Instance: sealed::Instance + 'static { 512pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static {
513 type Interrupt: Interrupt; 513 type Interrupt: Interrupt;
514} 514}
515 515
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs
index 7581f7a8b..494110bee 100644
--- a/embassy-nrf/src/uarte.rs
+++ b/embassy-nrf/src/uarte.rs
@@ -469,7 +469,7 @@ pub(crate) mod sealed {
469 } 469 }
470} 470}
471 471
472pub trait Instance: sealed::Instance + 'static { 472pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static {
473 type Interrupt: Interrupt; 473 type Interrupt: Interrupt;
474} 474}
475 475