aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-07-22 22:00:12 +0200
committerDario Nieuwenhuis <[email protected]>2022-07-23 01:33:22 +0200
commitbe6408e202765bd735b56d81b77b94559fe67a57 (patch)
tree652d7cca8b795d778ac29d4c081051f4bf16d07f
parentf9f2de3dfb131d71c4948405452e9529aea3c539 (diff)
Rename unsafe_impl_unborrow to impl_unborrow
-rw-r--r--embassy-hal-common/src/macros.rs4
-rw-r--r--embassy-macros/src/macros/cortex_m_interrupt_declare.rs2
-rw-r--r--embassy-nrf/src/gpio.rs4
-rw-r--r--embassy-nrf/src/gpiote.rs4
-rw-r--r--embassy-nrf/src/ppi/mod.rs8
-rw-r--r--embassy-nrf/src/saadc.rs13
-rw-r--r--embassy-rp/src/gpio.rs4
-rw-r--r--embassy-stm32/src/dma/mod.rs14
-rw-r--r--embassy-stm32/src/exti.rs4
-rw-r--r--embassy-stm32/src/gpio.rs4
10 files changed, 25 insertions, 36 deletions
diff --git a/embassy-hal-common/src/macros.rs b/embassy-hal-common/src/macros.rs
index 7aa197908..d8e2a06e7 100644
--- a/embassy-hal-common/src/macros.rs
+++ b/embassy-hal-common/src/macros.rs
@@ -21,7 +21,7 @@ macro_rules! peripherals {
21 } 21 }
22 22
23 $(#[$cfg])? 23 $(#[$cfg])?
24 $crate::unsafe_impl_unborrow!($name); 24 $crate::impl_unborrow!($name);
25 )* 25 )*
26 } 26 }
27 27
@@ -80,7 +80,7 @@ macro_rules! unborrow {
80} 80}
81 81
82#[macro_export] 82#[macro_export]
83macro_rules! unsafe_impl_unborrow { 83macro_rules! impl_unborrow {
84 ($type:ident) => { 84 ($type:ident) => {
85 impl $crate::Unborrow for $type { 85 impl $crate::Unborrow for $type {
86 type Target = $type; 86 type Target = $type;
diff --git a/embassy-macros/src/macros/cortex_m_interrupt_declare.rs b/embassy-macros/src/macros/cortex_m_interrupt_declare.rs
index 7eaaf6097..13150634b 100644
--- a/embassy-macros/src/macros/cortex_m_interrupt_declare.rs
+++ b/embassy-macros/src/macros/cortex_m_interrupt_declare.rs
@@ -25,7 +25,7 @@ pub fn run(name: syn::Ident) -> Result<TokenStream, TokenStream> {
25 } 25 }
26 } 26 }
27 27
28 ::embassy_hal_common::unsafe_impl_unborrow!(#name_interrupt); 28 ::embassy_hal_common::impl_unborrow!(#name_interrupt);
29 }; 29 };
30 Ok(result) 30 Ok(result)
31} 31}
diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs
index 53ca15d3d..f6320b8ee 100644
--- a/embassy-nrf/src/gpio.rs
+++ b/embassy-nrf/src/gpio.rs
@@ -4,7 +4,7 @@ use core::convert::Infallible;
4use core::hint::unreachable_unchecked; 4use core::hint::unreachable_unchecked;
5 5
6use cfg_if::cfg_if; 6use cfg_if::cfg_if;
7use embassy_hal_common::{unborrow, unsafe_impl_unborrow, Unborrowed}; 7use embassy_hal_common::{impl_unborrow, unborrow, Unborrowed};
8 8
9use self::sealed::Pin as _; 9use self::sealed::Pin as _;
10use crate::pac::p0 as gpio; 10use crate::pac::p0 as gpio;
@@ -432,7 +432,7 @@ macro_rules! unborrow_and_degrade {
432 }; 432 };
433} 433}
434 434
435unsafe_impl_unborrow!(AnyPin); 435impl_unborrow!(AnyPin);
436impl Pin for AnyPin {} 436impl Pin for AnyPin {}
437impl sealed::Pin for AnyPin { 437impl sealed::Pin for AnyPin {
438 #[inline] 438 #[inline]
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs
index d4e1cb35c..d59c2e34d 100644
--- a/embassy-nrf/src/gpiote.rs
+++ b/embassy-nrf/src/gpiote.rs
@@ -4,7 +4,7 @@ use core::marker::PhantomData;
4use core::task::{Context, Poll}; 4use core::task::{Context, Poll};
5 5
6use embassy::waitqueue::AtomicWaker; 6use embassy::waitqueue::AtomicWaker;
7use embassy_hal_common::unsafe_impl_unborrow; 7use embassy_hal_common::impl_unborrow;
8use futures::future::poll_fn; 8use futures::future::poll_fn;
9 9
10use crate::gpio::sealed::Pin as _; 10use crate::gpio::sealed::Pin as _;
@@ -414,7 +414,7 @@ pub trait Channel: sealed::Channel + Sized {
414pub struct AnyChannel { 414pub struct AnyChannel {
415 number: u8, 415 number: u8,
416} 416}
417unsafe_impl_unborrow!(AnyChannel); 417impl_unborrow!(AnyChannel);
418impl sealed::Channel for AnyChannel {} 418impl sealed::Channel for AnyChannel {}
419impl Channel for AnyChannel { 419impl Channel for AnyChannel {
420 fn number(&self) -> usize { 420 fn number(&self) -> usize {
diff --git a/embassy-nrf/src/ppi/mod.rs b/embassy-nrf/src/ppi/mod.rs
index fd5bb5f77..fd1d0cf8c 100644
--- a/embassy-nrf/src/ppi/mod.rs
+++ b/embassy-nrf/src/ppi/mod.rs
@@ -17,7 +17,7 @@
17 17
18use core::ptr::NonNull; 18use core::ptr::NonNull;
19 19
20use embassy_hal_common::{unsafe_impl_unborrow, Unborrowed}; 20use embassy_hal_common::{impl_unborrow, Unborrowed};
21 21
22use crate::{peripherals, Unborrow}; 22use crate::{peripherals, Unborrow};
23 23
@@ -117,7 +117,7 @@ pub trait Group: sealed::Group + Sized {
117pub struct AnyStaticChannel { 117pub struct AnyStaticChannel {
118 pub(crate) number: u8, 118 pub(crate) number: u8,
119} 119}
120unsafe_impl_unborrow!(AnyStaticChannel); 120impl_unborrow!(AnyStaticChannel);
121impl sealed::Channel for AnyStaticChannel {} 121impl sealed::Channel for AnyStaticChannel {}
122impl Channel for AnyStaticChannel { 122impl Channel for AnyStaticChannel {
123 fn number(&self) -> usize { 123 fn number(&self) -> usize {
@@ -135,7 +135,7 @@ impl StaticChannel for AnyStaticChannel {
135pub struct AnyConfigurableChannel { 135pub struct AnyConfigurableChannel {
136 pub(crate) number: u8, 136 pub(crate) number: u8,
137} 137}
138unsafe_impl_unborrow!(AnyConfigurableChannel); 138impl_unborrow!(AnyConfigurableChannel);
139impl sealed::Channel for AnyConfigurableChannel {} 139impl sealed::Channel for AnyConfigurableChannel {}
140impl Channel for AnyConfigurableChannel { 140impl Channel for AnyConfigurableChannel {
141 fn number(&self) -> usize { 141 fn number(&self) -> usize {
@@ -187,7 +187,7 @@ macro_rules! impl_ppi_channel {
187pub struct AnyGroup { 187pub struct AnyGroup {
188 number: u8, 188 number: u8,
189} 189}
190unsafe_impl_unborrow!(AnyGroup); 190impl_unborrow!(AnyGroup);
191impl sealed::Group for AnyGroup {} 191impl sealed::Group for AnyGroup {}
192impl Group for AnyGroup { 192impl Group for AnyGroup {
193 fn number(&self) -> usize { 193 fn number(&self) -> usize {
diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs
index d7d59b629..9c7207c84 100644
--- a/embassy-nrf/src/saadc.rs
+++ b/embassy-nrf/src/saadc.rs
@@ -5,7 +5,7 @@ use core::sync::atomic::{compiler_fence, Ordering};
5use core::task::Poll; 5use core::task::Poll;
6 6
7use embassy::waitqueue::AtomicWaker; 7use embassy::waitqueue::AtomicWaker;
8use embassy_hal_common::{unborrow, unsafe_impl_unborrow}; 8use embassy_hal_common::{impl_unborrow, unborrow};
9use futures::future::poll_fn; 9use futures::future::poll_fn;
10use pac::{saadc, SAADC}; 10use pac::{saadc, SAADC};
11use saadc::ch::config::{GAIN_A, REFSEL_A, RESP_A, TACQ_A}; 11use saadc::ch::config::{GAIN_A, REFSEL_A, RESP_A, TACQ_A};
@@ -77,7 +77,7 @@ pub struct ChannelConfig<'d> {
77/// internal voltage. 77/// internal voltage.
78pub struct VddInput; 78pub struct VddInput;
79 79
80unsafe_impl_unborrow!(VddInput); 80impl_unborrow!(VddInput);
81 81
82impl sealed::Input for VddInput { 82impl sealed::Input for VddInput {
83 #[cfg(not(feature = "_nrf9160"))] 83 #[cfg(not(feature = "_nrf9160"))]
@@ -97,7 +97,7 @@ impl Input for VddInput {}
97pub struct VddhDiv5Input; 97pub struct VddhDiv5Input;
98 98
99#[cfg(any(feature = "_nrf5340-app", feature = "nrf52833", feature = "nrf52840"))] 99#[cfg(any(feature = "_nrf5340-app", feature = "nrf52833", feature = "nrf52840"))]
100unsafe_impl_unborrow!(VddhDiv5Input); 100impl_unborrow!(VddhDiv5Input);
101 101
102#[cfg(any(feature = "_nrf5340-app", feature = "nrf52833", feature = "nrf52840"))] 102#[cfg(any(feature = "_nrf5340-app", feature = "nrf52833", feature = "nrf52840"))]
103impl sealed::Input for VddhDiv5Input { 103impl sealed::Input for VddhDiv5Input {
@@ -113,12 +113,7 @@ pub struct AnyInput {
113 channel: InputChannel, 113 channel: InputChannel,
114} 114}
115 115
116unsafe impl Unborrow for AnyInput { 116impl_unborrow!(AnyInput);
117 type Target = AnyInput;
118 unsafe fn unborrow(self) -> Self::Target {
119 self
120 }
121}
122 117
123impl sealed::Input for AnyInput { 118impl sealed::Input for AnyInput {
124 fn channel(&self) -> InputChannel { 119 fn channel(&self) -> InputChannel {
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs
index 94d0f25c7..08a731f40 100644
--- a/embassy-rp/src/gpio.rs
+++ b/embassy-rp/src/gpio.rs
@@ -5,7 +5,7 @@ use core::task::{Context, Poll};
5 5
6use embassy::waitqueue::AtomicWaker; 6use embassy::waitqueue::AtomicWaker;
7use embassy_cortex_m::interrupt::{Interrupt, InterruptExt}; 7use embassy_cortex_m::interrupt::{Interrupt, InterruptExt};
8use embassy_hal_common::{unborrow, unsafe_impl_unborrow, Unborrowed}; 8use embassy_hal_common::{impl_unborrow, unborrow, Unborrowed};
9 9
10use crate::pac::common::{Reg, RW}; 10use crate::pac::common::{Reg, RW};
11use crate::pac::SIO; 11use crate::pac::SIO;
@@ -676,7 +676,7 @@ macro_rules! unborrow_and_degrade {
676 }; 676 };
677} 677}
678 678
679unsafe_impl_unborrow!(AnyPin); 679impl_unborrow!(AnyPin);
680 680
681impl Pin for AnyPin {} 681impl Pin for AnyPin {}
682impl sealed::Pin for AnyPin { 682impl sealed::Pin for AnyPin {
diff --git a/embassy-stm32/src/dma/mod.rs b/embassy-stm32/src/dma/mod.rs
index 87ac38ba8..02d6ca0f3 100644
--- a/embassy-stm32/src/dma/mod.rs
+++ b/embassy-stm32/src/dma/mod.rs
@@ -13,10 +13,10 @@ use core::mem;
13use core::pin::Pin; 13use core::pin::Pin;
14use core::task::{Context, Poll, Waker}; 14use core::task::{Context, Poll, Waker};
15 15
16#[cfg(dmamux)] 16use embassy_hal_common::{impl_unborrow, unborrow};
17pub use dmamux::*;
18use embassy_hal_common::unborrow;
19 17
18#[cfg(dmamux)]
19pub use self::dmamux::*;
20use crate::Unborrow; 20use crate::Unborrow;
21 21
22#[cfg(feature = "unstable-pac")] 22#[cfg(feature = "unstable-pac")]
@@ -294,13 +294,7 @@ pub trait Channel: sealed::Channel + Unborrow<Target = Self> + 'static {}
294 294
295pub struct NoDma; 295pub struct NoDma;
296 296
297unsafe impl Unborrow for NoDma { 297impl_unborrow!(NoDma);
298 type Target = NoDma;
299
300 unsafe fn unborrow(self) -> Self::Target {
301 self
302 }
303}
304 298
305// safety: must be called only once at startup 299// safety: must be called only once at startup
306pub(crate) unsafe fn init() { 300pub(crate) unsafe fn init() {
diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs
index 94e0e941d..5076de2e4 100644
--- a/embassy-stm32/src/exti.rs
+++ b/embassy-stm32/src/exti.rs
@@ -4,7 +4,7 @@ use core::pin::Pin;
4use core::task::{Context, Poll}; 4use core::task::{Context, Poll};
5 5
6use embassy::waitqueue::AtomicWaker; 6use embassy::waitqueue::AtomicWaker;
7use embassy_hal_common::unsafe_impl_unborrow; 7use embassy_hal_common::impl_unborrow;
8 8
9use crate::gpio::{AnyPin, Input, Pin as GpioPin}; 9use crate::gpio::{AnyPin, Input, Pin as GpioPin};
10use crate::pac::exti::regs::Lines; 10use crate::pac::exti::regs::Lines;
@@ -320,7 +320,7 @@ pub trait Channel: sealed::Channel + Sized {
320pub struct AnyChannel { 320pub struct AnyChannel {
321 number: u8, 321 number: u8,
322} 322}
323unsafe_impl_unborrow!(AnyChannel); 323impl_unborrow!(AnyChannel);
324impl sealed::Channel for AnyChannel {} 324impl sealed::Channel for AnyChannel {}
325impl Channel for AnyChannel { 325impl Channel for AnyChannel {
326 fn number(&self) -> usize { 326 fn number(&self) -> usize {
diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs
index 1059ebf86..3bdaccce6 100644
--- a/embassy-stm32/src/gpio.rs
+++ b/embassy-stm32/src/gpio.rs
@@ -2,7 +2,7 @@
2use core::convert::Infallible; 2use core::convert::Infallible;
3use core::marker::PhantomData; 3use core::marker::PhantomData;
4 4
5use embassy_hal_common::{unborrow, unsafe_impl_unborrow}; 5use embassy_hal_common::{impl_unborrow, unborrow};
6 6
7use crate::pac::gpio::{self, vals}; 7use crate::pac::gpio::{self, vals};
8use crate::{pac, peripherals, Unborrow}; 8use crate::{pac, peripherals, Unborrow};
@@ -673,7 +673,7 @@ impl AnyPin {
673 } 673 }
674} 674}
675 675
676unsafe_impl_unborrow!(AnyPin); 676impl_unborrow!(AnyPin);
677impl Pin for AnyPin { 677impl Pin for AnyPin {
678 #[cfg(feature = "exti")] 678 #[cfg(feature = "exti")]
679 type ExtiChannel = crate::exti::AnyChannel; 679 type ExtiChannel = crate::exti::AnyChannel;