Rename unsafe_impl_unborrow to impl_unborrow

This commit is contained in:
Dario Nieuwenhuis 2022-07-22 22:00:12 +02:00
parent f9f2de3dfb
commit be6408e202
10 changed files with 25 additions and 36 deletions

View file

@ -21,7 +21,7 @@ macro_rules! peripherals {
}
$(#[$cfg])?
$crate::unsafe_impl_unborrow!($name);
$crate::impl_unborrow!($name);
)*
}
@ -80,7 +80,7 @@ macro_rules! unborrow {
}
#[macro_export]
macro_rules! unsafe_impl_unborrow {
macro_rules! impl_unborrow {
($type:ident) => {
impl $crate::Unborrow for $type {
type Target = $type;

View file

@ -25,7 +25,7 @@ pub fn run(name: syn::Ident) -> Result<TokenStream, TokenStream> {
}
}
::embassy_hal_common::unsafe_impl_unborrow!(#name_interrupt);
::embassy_hal_common::impl_unborrow!(#name_interrupt);
};
Ok(result)
}

View file

@ -4,7 +4,7 @@ use core::convert::Infallible;
use core::hint::unreachable_unchecked;
use cfg_if::cfg_if;
use embassy_hal_common::{unborrow, unsafe_impl_unborrow, Unborrowed};
use embassy_hal_common::{impl_unborrow, unborrow, Unborrowed};
use self::sealed::Pin as _;
use crate::pac::p0 as gpio;
@ -432,7 +432,7 @@ macro_rules! unborrow_and_degrade {
};
}
unsafe_impl_unborrow!(AnyPin);
impl_unborrow!(AnyPin);
impl Pin for AnyPin {}
impl sealed::Pin for AnyPin {
#[inline]

View file

@ -4,7 +4,7 @@ use core::marker::PhantomData;
use core::task::{Context, Poll};
use embassy::waitqueue::AtomicWaker;
use embassy_hal_common::unsafe_impl_unborrow;
use embassy_hal_common::impl_unborrow;
use futures::future::poll_fn;
use crate::gpio::sealed::Pin as _;
@ -414,7 +414,7 @@ pub trait Channel: sealed::Channel + Sized {
pub struct AnyChannel {
number: u8,
}
unsafe_impl_unborrow!(AnyChannel);
impl_unborrow!(AnyChannel);
impl sealed::Channel for AnyChannel {}
impl Channel for AnyChannel {
fn number(&self) -> usize {

View file

@ -17,7 +17,7 @@
use core::ptr::NonNull;
use embassy_hal_common::{unsafe_impl_unborrow, Unborrowed};
use embassy_hal_common::{impl_unborrow, Unborrowed};
use crate::{peripherals, Unborrow};
@ -117,7 +117,7 @@ pub trait Group: sealed::Group + Sized {
pub struct AnyStaticChannel {
pub(crate) number: u8,
}
unsafe_impl_unborrow!(AnyStaticChannel);
impl_unborrow!(AnyStaticChannel);
impl sealed::Channel for AnyStaticChannel {}
impl Channel for AnyStaticChannel {
fn number(&self) -> usize {
@ -135,7 +135,7 @@ impl StaticChannel for AnyStaticChannel {
pub struct AnyConfigurableChannel {
pub(crate) number: u8,
}
unsafe_impl_unborrow!(AnyConfigurableChannel);
impl_unborrow!(AnyConfigurableChannel);
impl sealed::Channel for AnyConfigurableChannel {}
impl Channel for AnyConfigurableChannel {
fn number(&self) -> usize {
@ -187,7 +187,7 @@ macro_rules! impl_ppi_channel {
pub struct AnyGroup {
number: u8,
}
unsafe_impl_unborrow!(AnyGroup);
impl_unborrow!(AnyGroup);
impl sealed::Group for AnyGroup {}
impl Group for AnyGroup {
fn number(&self) -> usize {

View file

@ -5,7 +5,7 @@ use core::sync::atomic::{compiler_fence, Ordering};
use core::task::Poll;
use embassy::waitqueue::AtomicWaker;
use embassy_hal_common::{unborrow, unsafe_impl_unborrow};
use embassy_hal_common::{impl_unborrow, unborrow};
use futures::future::poll_fn;
use pac::{saadc, SAADC};
use saadc::ch::config::{GAIN_A, REFSEL_A, RESP_A, TACQ_A};
@ -77,7 +77,7 @@ pub struct ChannelConfig<'d> {
/// internal voltage.
pub struct VddInput;
unsafe_impl_unborrow!(VddInput);
impl_unborrow!(VddInput);
impl sealed::Input for VddInput {
#[cfg(not(feature = "_nrf9160"))]
@ -97,7 +97,7 @@ impl Input for VddInput {}
pub struct VddhDiv5Input;
#[cfg(any(feature = "_nrf5340-app", feature = "nrf52833", feature = "nrf52840"))]
unsafe_impl_unborrow!(VddhDiv5Input);
impl_unborrow!(VddhDiv5Input);
#[cfg(any(feature = "_nrf5340-app", feature = "nrf52833", feature = "nrf52840"))]
impl sealed::Input for VddhDiv5Input {
@ -113,12 +113,7 @@ pub struct AnyInput {
channel: InputChannel,
}
unsafe impl Unborrow for AnyInput {
type Target = AnyInput;
unsafe fn unborrow(self) -> Self::Target {
self
}
}
impl_unborrow!(AnyInput);
impl sealed::Input for AnyInput {
fn channel(&self) -> InputChannel {

View file

@ -5,7 +5,7 @@ use core::task::{Context, Poll};
use embassy::waitqueue::AtomicWaker;
use embassy_cortex_m::interrupt::{Interrupt, InterruptExt};
use embassy_hal_common::{unborrow, unsafe_impl_unborrow, Unborrowed};
use embassy_hal_common::{impl_unborrow, unborrow, Unborrowed};
use crate::pac::common::{Reg, RW};
use crate::pac::SIO;
@ -676,7 +676,7 @@ macro_rules! unborrow_and_degrade {
};
}
unsafe_impl_unborrow!(AnyPin);
impl_unborrow!(AnyPin);
impl Pin for AnyPin {}
impl sealed::Pin for AnyPin {

View file

@ -13,10 +13,10 @@ use core::mem;
use core::pin::Pin;
use core::task::{Context, Poll, Waker};
#[cfg(dmamux)]
pub use dmamux::*;
use embassy_hal_common::unborrow;
use embassy_hal_common::{impl_unborrow, unborrow};
#[cfg(dmamux)]
pub use self::dmamux::*;
use crate::Unborrow;
#[cfg(feature = "unstable-pac")]
@ -294,13 +294,7 @@ pub trait Channel: sealed::Channel + Unborrow<Target = Self> + 'static {}
pub struct NoDma;
unsafe impl Unborrow for NoDma {
type Target = NoDma;
unsafe fn unborrow(self) -> Self::Target {
self
}
}
impl_unborrow!(NoDma);
// safety: must be called only once at startup
pub(crate) unsafe fn init() {

View file

@ -4,7 +4,7 @@ use core::pin::Pin;
use core::task::{Context, Poll};
use embassy::waitqueue::AtomicWaker;
use embassy_hal_common::unsafe_impl_unborrow;
use embassy_hal_common::impl_unborrow;
use crate::gpio::{AnyPin, Input, Pin as GpioPin};
use crate::pac::exti::regs::Lines;
@ -320,7 +320,7 @@ pub trait Channel: sealed::Channel + Sized {
pub struct AnyChannel {
number: u8,
}
unsafe_impl_unborrow!(AnyChannel);
impl_unborrow!(AnyChannel);
impl sealed::Channel for AnyChannel {}
impl Channel for AnyChannel {
fn number(&self) -> usize {

View file

@ -2,7 +2,7 @@
use core::convert::Infallible;
use core::marker::PhantomData;
use embassy_hal_common::{unborrow, unsafe_impl_unborrow};
use embassy_hal_common::{impl_unborrow, unborrow};
use crate::pac::gpio::{self, vals};
use crate::{pac, peripherals, Unborrow};
@ -673,7 +673,7 @@ impl AnyPin {
}
}
unsafe_impl_unborrow!(AnyPin);
impl_unborrow!(AnyPin);
impl Pin for AnyPin {
#[cfg(feature = "exti")]
type ExtiChannel = crate::exti::AnyChannel;