aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-05-20 04:14:38 +0200
committerGitHub <[email protected]>2021-05-20 04:14:38 +0200
commitb5cdd296dd875c42974e85671473efeaadd70345 (patch)
treef97cc2fdcc44058d1f0c1a53d94522dd802e0de8 /embassy-nrf/src
parent63cceb2a53502e2b503c897e690b6c619ab14795 (diff)
parent1c0ad538410b61f8011c7d8facd136a85138be61 (diff)
Merge pull request #195 from embassy-rs/unborrow-mk2
Unborrow fixes
Diffstat (limited to 'embassy-nrf/src')
-rw-r--r--embassy-nrf/src/gpio.rs8
-rw-r--r--embassy-nrf/src/gpiote.rs4
-rw-r--r--embassy-nrf/src/ppi.rs8
-rw-r--r--embassy-nrf/src/saadc.rs2
4 files changed, 11 insertions, 11 deletions
diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs
index 223247d60..3ae160ca8 100644
--- a/embassy-nrf/src/gpio.rs
+++ b/embassy-nrf/src/gpio.rs
@@ -5,7 +5,7 @@ use core::hint::unreachable_unchecked;
5use core::marker::PhantomData; 5use core::marker::PhantomData;
6 6
7use embassy::util::Unborrow; 7use embassy::util::Unborrow;
8use embassy_extras::{impl_unborrow, unborrow}; 8use embassy_extras::{unborrow, unsafe_impl_unborrow};
9use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin}; 9use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin};
10use gpio::pin_cnf::DRIVE_A; 10use gpio::pin_cnf::DRIVE_A;
11 11
@@ -330,7 +330,7 @@ pub(crate) mod sealed {
330 pub trait OptionalPin {} 330 pub trait OptionalPin {}
331} 331}
332 332
333pub trait Pin: Unborrow<Target = Self> + sealed::Pin + Sized { 333pub trait Pin: Unborrow<Target = Self> + sealed::Pin + Sized + 'static {
334 /// Number of the pin within the port (0..31) 334 /// Number of the pin within the port (0..31)
335 #[inline] 335 #[inline]
336 fn pin(&self) -> u8 { 336 fn pin(&self) -> u8 {
@@ -374,7 +374,7 @@ impl AnyPin {
374 } 374 }
375} 375}
376 376
377impl_unborrow!(AnyPin); 377unsafe_impl_unborrow!(AnyPin);
378impl Pin for AnyPin {} 378impl Pin for AnyPin {}
379impl sealed::Pin for AnyPin { 379impl sealed::Pin for AnyPin {
380 #[inline] 380 #[inline]
@@ -469,7 +469,7 @@ impl<T: Pin> OptionalPin for T {
469 469
470#[derive(Clone, Copy, Debug)] 470#[derive(Clone, Copy, Debug)]
471pub struct NoPin; 471pub struct NoPin;
472impl_unborrow!(NoPin); 472unsafe_impl_unborrow!(NoPin);
473impl sealed::OptionalPin for NoPin {} 473impl sealed::OptionalPin for NoPin {}
474impl OptionalPin for NoPin { 474impl OptionalPin for NoPin {
475 type Pin = AnyPin; 475 type Pin = AnyPin;
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs
index 7e0220e79..2ef26e36a 100644
--- a/embassy-nrf/src/gpiote.rs
+++ b/embassy-nrf/src/gpiote.rs
@@ -5,7 +5,7 @@ use core::task::{Context, Poll};
5use embassy::interrupt::{Interrupt, InterruptExt}; 5use embassy::interrupt::{Interrupt, InterruptExt};
6use embassy::traits::gpio::{WaitForAnyEdge, WaitForHigh, WaitForLow}; 6use embassy::traits::gpio::{WaitForAnyEdge, WaitForHigh, WaitForLow};
7use embassy::util::AtomicWaker; 7use embassy::util::AtomicWaker;
8use embassy_extras::impl_unborrow; 8use embassy_extras::unsafe_impl_unborrow;
9use embedded_hal::digital::v2::{InputPin, StatefulOutputPin}; 9use embedded_hal::digital::v2::{InputPin, StatefulOutputPin};
10use futures::future::poll_fn; 10use futures::future::poll_fn;
11 11
@@ -382,7 +382,7 @@ pub trait Channel: sealed::Channel + Sized {
382pub struct AnyChannel { 382pub struct AnyChannel {
383 number: u8, 383 number: u8,
384} 384}
385impl_unborrow!(AnyChannel); 385unsafe_impl_unborrow!(AnyChannel);
386impl sealed::Channel for AnyChannel {} 386impl sealed::Channel for AnyChannel {}
387impl Channel for AnyChannel { 387impl Channel for AnyChannel {
388 fn number(&self) -> usize { 388 fn number(&self) -> usize {
diff --git a/embassy-nrf/src/ppi.rs b/embassy-nrf/src/ppi.rs
index e8bcbd603..c91a69c10 100644
--- a/embassy-nrf/src/ppi.rs
+++ b/embassy-nrf/src/ppi.rs
@@ -12,7 +12,7 @@
12use core::marker::PhantomData; 12use core::marker::PhantomData;
13use core::ptr::NonNull; 13use core::ptr::NonNull;
14use embassy::util::Unborrow; 14use embassy::util::Unborrow;
15use embassy_extras::{impl_unborrow, unborrow}; 15use embassy_extras::{unborrow, unsafe_impl_unborrow};
16 16
17use crate::{pac, peripherals}; 17use crate::{pac, peripherals};
18 18
@@ -146,7 +146,7 @@ pub trait Group: sealed::Group + Sized {
146pub struct AnyChannel { 146pub struct AnyChannel {
147 number: u8, 147 number: u8,
148} 148}
149impl_unborrow!(AnyChannel); 149unsafe_impl_unborrow!(AnyChannel);
150impl sealed::Channel for AnyChannel {} 150impl sealed::Channel for AnyChannel {}
151impl Channel for AnyChannel { 151impl Channel for AnyChannel {
152 fn number(&self) -> usize { 152 fn number(&self) -> usize {
@@ -157,7 +157,7 @@ impl Channel for AnyChannel {
157pub struct AnyConfigurableChannel { 157pub struct AnyConfigurableChannel {
158 number: u8, 158 number: u8,
159} 159}
160impl_unborrow!(AnyConfigurableChannel); 160unsafe_impl_unborrow!(AnyConfigurableChannel);
161impl sealed::Channel for AnyConfigurableChannel {} 161impl sealed::Channel for AnyConfigurableChannel {}
162impl sealed::ConfigurableChannel for AnyConfigurableChannel {} 162impl sealed::ConfigurableChannel for AnyConfigurableChannel {}
163impl ConfigurableChannel for AnyConfigurableChannel {} 163impl ConfigurableChannel for AnyConfigurableChannel {}
@@ -226,7 +226,7 @@ impl_channel!(PPI_CH31, 31);
226pub struct AnyGroup { 226pub struct AnyGroup {
227 number: u8, 227 number: u8,
228} 228}
229impl_unborrow!(AnyGroup); 229unsafe_impl_unborrow!(AnyGroup);
230impl sealed::Group for AnyGroup {} 230impl sealed::Group for AnyGroup {}
231impl Group for AnyGroup { 231impl Group for AnyGroup {
232 fn number(&self) -> usize { 232 fn number(&self) -> usize {
diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs
index 65276a309..c1afd00de 100644
--- a/embassy-nrf/src/saadc.rs
+++ b/embassy-nrf/src/saadc.rs
@@ -190,7 +190,7 @@ impl<'d, T: PositivePin> Sample for OneShot<'d, T> {
190/// A pin that can be used as the positive end of a ADC differential in the SAADC periperhal. 190/// A pin that can be used as the positive end of a ADC differential in the SAADC periperhal.
191/// 191///
192/// Currently negative is always shorted to ground (0V). 192/// Currently negative is always shorted to ground (0V).
193pub trait PositivePin { 193pub trait PositivePin: Unborrow<Target = Self> {
194 fn channel(&self) -> PositiveChannel; 194 fn channel(&self) -> PositiveChannel;
195} 195}
196 196