diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-07-22 22:00:12 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-07-23 01:33:22 +0200 |
| commit | be6408e202765bd735b56d81b77b94559fe67a57 (patch) | |
| tree | 652d7cca8b795d778ac29d4c081051f4bf16d07f | |
| parent | f9f2de3dfb131d71c4948405452e9529aea3c539 (diff) | |
Rename unsafe_impl_unborrow to impl_unborrow
| -rw-r--r-- | embassy-hal-common/src/macros.rs | 4 | ||||
| -rw-r--r-- | embassy-macros/src/macros/cortex_m_interrupt_declare.rs | 2 | ||||
| -rw-r--r-- | embassy-nrf/src/gpio.rs | 4 | ||||
| -rw-r--r-- | embassy-nrf/src/gpiote.rs | 4 | ||||
| -rw-r--r-- | embassy-nrf/src/ppi/mod.rs | 8 | ||||
| -rw-r--r-- | embassy-nrf/src/saadc.rs | 13 | ||||
| -rw-r--r-- | embassy-rp/src/gpio.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/dma/mod.rs | 14 | ||||
| -rw-r--r-- | embassy-stm32/src/exti.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/gpio.rs | 4 |
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] |
| 83 | macro_rules! unsafe_impl_unborrow { | 83 | macro_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; | |||
| 4 | use core::hint::unreachable_unchecked; | 4 | use core::hint::unreachable_unchecked; |
| 5 | 5 | ||
| 6 | use cfg_if::cfg_if; | 6 | use cfg_if::cfg_if; |
| 7 | use embassy_hal_common::{unborrow, unsafe_impl_unborrow, Unborrowed}; | 7 | use embassy_hal_common::{impl_unborrow, unborrow, Unborrowed}; |
| 8 | 8 | ||
| 9 | use self::sealed::Pin as _; | 9 | use self::sealed::Pin as _; |
| 10 | use crate::pac::p0 as gpio; | 10 | use crate::pac::p0 as gpio; |
| @@ -432,7 +432,7 @@ macro_rules! unborrow_and_degrade { | |||
| 432 | }; | 432 | }; |
| 433 | } | 433 | } |
| 434 | 434 | ||
| 435 | unsafe_impl_unborrow!(AnyPin); | 435 | impl_unborrow!(AnyPin); |
| 436 | impl Pin for AnyPin {} | 436 | impl Pin for AnyPin {} |
| 437 | impl sealed::Pin for AnyPin { | 437 | impl 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; | |||
| 4 | use core::task::{Context, Poll}; | 4 | use core::task::{Context, Poll}; |
| 5 | 5 | ||
| 6 | use embassy::waitqueue::AtomicWaker; | 6 | use embassy::waitqueue::AtomicWaker; |
| 7 | use embassy_hal_common::unsafe_impl_unborrow; | 7 | use embassy_hal_common::impl_unborrow; |
| 8 | use futures::future::poll_fn; | 8 | use futures::future::poll_fn; |
| 9 | 9 | ||
| 10 | use crate::gpio::sealed::Pin as _; | 10 | use crate::gpio::sealed::Pin as _; |
| @@ -414,7 +414,7 @@ pub trait Channel: sealed::Channel + Sized { | |||
| 414 | pub struct AnyChannel { | 414 | pub struct AnyChannel { |
| 415 | number: u8, | 415 | number: u8, |
| 416 | } | 416 | } |
| 417 | unsafe_impl_unborrow!(AnyChannel); | 417 | impl_unborrow!(AnyChannel); |
| 418 | impl sealed::Channel for AnyChannel {} | 418 | impl sealed::Channel for AnyChannel {} |
| 419 | impl Channel for AnyChannel { | 419 | impl 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 | ||
| 18 | use core::ptr::NonNull; | 18 | use core::ptr::NonNull; |
| 19 | 19 | ||
| 20 | use embassy_hal_common::{unsafe_impl_unborrow, Unborrowed}; | 20 | use embassy_hal_common::{impl_unborrow, Unborrowed}; |
| 21 | 21 | ||
| 22 | use crate::{peripherals, Unborrow}; | 22 | use crate::{peripherals, Unborrow}; |
| 23 | 23 | ||
| @@ -117,7 +117,7 @@ pub trait Group: sealed::Group + Sized { | |||
| 117 | pub struct AnyStaticChannel { | 117 | pub struct AnyStaticChannel { |
| 118 | pub(crate) number: u8, | 118 | pub(crate) number: u8, |
| 119 | } | 119 | } |
| 120 | unsafe_impl_unborrow!(AnyStaticChannel); | 120 | impl_unborrow!(AnyStaticChannel); |
| 121 | impl sealed::Channel for AnyStaticChannel {} | 121 | impl sealed::Channel for AnyStaticChannel {} |
| 122 | impl Channel for AnyStaticChannel { | 122 | impl Channel for AnyStaticChannel { |
| 123 | fn number(&self) -> usize { | 123 | fn number(&self) -> usize { |
| @@ -135,7 +135,7 @@ impl StaticChannel for AnyStaticChannel { | |||
| 135 | pub struct AnyConfigurableChannel { | 135 | pub struct AnyConfigurableChannel { |
| 136 | pub(crate) number: u8, | 136 | pub(crate) number: u8, |
| 137 | } | 137 | } |
| 138 | unsafe_impl_unborrow!(AnyConfigurableChannel); | 138 | impl_unborrow!(AnyConfigurableChannel); |
| 139 | impl sealed::Channel for AnyConfigurableChannel {} | 139 | impl sealed::Channel for AnyConfigurableChannel {} |
| 140 | impl Channel for AnyConfigurableChannel { | 140 | impl Channel for AnyConfigurableChannel { |
| 141 | fn number(&self) -> usize { | 141 | fn number(&self) -> usize { |
| @@ -187,7 +187,7 @@ macro_rules! impl_ppi_channel { | |||
| 187 | pub struct AnyGroup { | 187 | pub struct AnyGroup { |
| 188 | number: u8, | 188 | number: u8, |
| 189 | } | 189 | } |
| 190 | unsafe_impl_unborrow!(AnyGroup); | 190 | impl_unborrow!(AnyGroup); |
| 191 | impl sealed::Group for AnyGroup {} | 191 | impl sealed::Group for AnyGroup {} |
| 192 | impl Group for AnyGroup { | 192 | impl 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}; | |||
| 5 | use core::task::Poll; | 5 | use core::task::Poll; |
| 6 | 6 | ||
| 7 | use embassy::waitqueue::AtomicWaker; | 7 | use embassy::waitqueue::AtomicWaker; |
| 8 | use embassy_hal_common::{unborrow, unsafe_impl_unborrow}; | 8 | use embassy_hal_common::{impl_unborrow, unborrow}; |
| 9 | use futures::future::poll_fn; | 9 | use futures::future::poll_fn; |
| 10 | use pac::{saadc, SAADC}; | 10 | use pac::{saadc, SAADC}; |
| 11 | use saadc::ch::config::{GAIN_A, REFSEL_A, RESP_A, TACQ_A}; | 11 | use 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. |
| 78 | pub struct VddInput; | 78 | pub struct VddInput; |
| 79 | 79 | ||
| 80 | unsafe_impl_unborrow!(VddInput); | 80 | impl_unborrow!(VddInput); |
| 81 | 81 | ||
| 82 | impl sealed::Input for VddInput { | 82 | impl sealed::Input for VddInput { |
| 83 | #[cfg(not(feature = "_nrf9160"))] | 83 | #[cfg(not(feature = "_nrf9160"))] |
| @@ -97,7 +97,7 @@ impl Input for VddInput {} | |||
| 97 | pub struct VddhDiv5Input; | 97 | pub struct VddhDiv5Input; |
| 98 | 98 | ||
| 99 | #[cfg(any(feature = "_nrf5340-app", feature = "nrf52833", feature = "nrf52840"))] | 99 | #[cfg(any(feature = "_nrf5340-app", feature = "nrf52833", feature = "nrf52840"))] |
| 100 | unsafe_impl_unborrow!(VddhDiv5Input); | 100 | impl_unborrow!(VddhDiv5Input); |
| 101 | 101 | ||
| 102 | #[cfg(any(feature = "_nrf5340-app", feature = "nrf52833", feature = "nrf52840"))] | 102 | #[cfg(any(feature = "_nrf5340-app", feature = "nrf52833", feature = "nrf52840"))] |
| 103 | impl sealed::Input for VddhDiv5Input { | 103 | impl sealed::Input for VddhDiv5Input { |
| @@ -113,12 +113,7 @@ pub struct AnyInput { | |||
| 113 | channel: InputChannel, | 113 | channel: InputChannel, |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | unsafe impl Unborrow for AnyInput { | 116 | impl_unborrow!(AnyInput); |
| 117 | type Target = AnyInput; | ||
| 118 | unsafe fn unborrow(self) -> Self::Target { | ||
| 119 | self | ||
| 120 | } | ||
| 121 | } | ||
| 122 | 117 | ||
| 123 | impl sealed::Input for AnyInput { | 118 | impl 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 | ||
| 6 | use embassy::waitqueue::AtomicWaker; | 6 | use embassy::waitqueue::AtomicWaker; |
| 7 | use embassy_cortex_m::interrupt::{Interrupt, InterruptExt}; | 7 | use embassy_cortex_m::interrupt::{Interrupt, InterruptExt}; |
| 8 | use embassy_hal_common::{unborrow, unsafe_impl_unborrow, Unborrowed}; | 8 | use embassy_hal_common::{impl_unborrow, unborrow, Unborrowed}; |
| 9 | 9 | ||
| 10 | use crate::pac::common::{Reg, RW}; | 10 | use crate::pac::common::{Reg, RW}; |
| 11 | use crate::pac::SIO; | 11 | use crate::pac::SIO; |
| @@ -676,7 +676,7 @@ macro_rules! unborrow_and_degrade { | |||
| 676 | }; | 676 | }; |
| 677 | } | 677 | } |
| 678 | 678 | ||
| 679 | unsafe_impl_unborrow!(AnyPin); | 679 | impl_unborrow!(AnyPin); |
| 680 | 680 | ||
| 681 | impl Pin for AnyPin {} | 681 | impl Pin for AnyPin {} |
| 682 | impl sealed::Pin for AnyPin { | 682 | impl 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; | |||
| 13 | use core::pin::Pin; | 13 | use core::pin::Pin; |
| 14 | use core::task::{Context, Poll, Waker}; | 14 | use core::task::{Context, Poll, Waker}; |
| 15 | 15 | ||
| 16 | #[cfg(dmamux)] | 16 | use embassy_hal_common::{impl_unborrow, unborrow}; |
| 17 | pub use dmamux::*; | ||
| 18 | use embassy_hal_common::unborrow; | ||
| 19 | 17 | ||
| 18 | #[cfg(dmamux)] | ||
| 19 | pub use self::dmamux::*; | ||
| 20 | use crate::Unborrow; | 20 | use 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 | ||
| 295 | pub struct NoDma; | 295 | pub struct NoDma; |
| 296 | 296 | ||
| 297 | unsafe impl Unborrow for NoDma { | 297 | impl_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 |
| 306 | pub(crate) unsafe fn init() { | 300 | pub(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; | |||
| 4 | use core::task::{Context, Poll}; | 4 | use core::task::{Context, Poll}; |
| 5 | 5 | ||
| 6 | use embassy::waitqueue::AtomicWaker; | 6 | use embassy::waitqueue::AtomicWaker; |
| 7 | use embassy_hal_common::unsafe_impl_unborrow; | 7 | use embassy_hal_common::impl_unborrow; |
| 8 | 8 | ||
| 9 | use crate::gpio::{AnyPin, Input, Pin as GpioPin}; | 9 | use crate::gpio::{AnyPin, Input, Pin as GpioPin}; |
| 10 | use crate::pac::exti::regs::Lines; | 10 | use crate::pac::exti::regs::Lines; |
| @@ -320,7 +320,7 @@ pub trait Channel: sealed::Channel + Sized { | |||
| 320 | pub struct AnyChannel { | 320 | pub struct AnyChannel { |
| 321 | number: u8, | 321 | number: u8, |
| 322 | } | 322 | } |
| 323 | unsafe_impl_unborrow!(AnyChannel); | 323 | impl_unborrow!(AnyChannel); |
| 324 | impl sealed::Channel for AnyChannel {} | 324 | impl sealed::Channel for AnyChannel {} |
| 325 | impl Channel for AnyChannel { | 325 | impl 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 @@ | |||
| 2 | use core::convert::Infallible; | 2 | use core::convert::Infallible; |
| 3 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 4 | 4 | ||
| 5 | use embassy_hal_common::{unborrow, unsafe_impl_unborrow}; | 5 | use embassy_hal_common::{impl_unborrow, unborrow}; |
| 6 | 6 | ||
| 7 | use crate::pac::gpio::{self, vals}; | 7 | use crate::pac::gpio::{self, vals}; |
| 8 | use crate::{pac, peripherals, Unborrow}; | 8 | use crate::{pac, peripherals, Unborrow}; |
| @@ -673,7 +673,7 @@ impl AnyPin { | |||
| 673 | } | 673 | } |
| 674 | } | 674 | } |
| 675 | 675 | ||
| 676 | unsafe_impl_unborrow!(AnyPin); | 676 | impl_unborrow!(AnyPin); |
| 677 | impl Pin for AnyPin { | 677 | impl Pin for AnyPin { |
| 678 | #[cfg(feature = "exti")] | 678 | #[cfg(feature = "exti")] |
| 679 | type ExtiChannel = crate::exti::AnyChannel; | 679 | type ExtiChannel = crate::exti::AnyChannel; |
