diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-04-14 19:59:52 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-04-14 19:59:52 +0200 |
| commit | 97ca54fa6639371e5a871bd1e87562c126d92a16 (patch) | |
| tree | 2cd2a7cf890817da28831af608473852c9df15e9 | |
| parent | bac53e3e55e84fc2f3c1b4be8cf20d0e5f25ca22 (diff) | |
Rename PeripheralBorrow to Unborrow
| -rw-r--r-- | embassy-extras/src/macros.rs | 8 | ||||
| -rw-r--r-- | embassy-macros/src/lib.rs | 4 | ||||
| -rw-r--r-- | embassy-nrf/src/buffered_uarte.rs | 20 | ||||
| -rw-r--r-- | embassy-nrf/src/gpio.rs | 6 | ||||
| -rw-r--r-- | embassy-nrf/src/ppi.rs | 4 | ||||
| -rw-r--r-- | embassy-nrf/src/qspi.rs | 18 | ||||
| -rw-r--r-- | embassy-nrf/src/saadc.rs | 15 | ||||
| -rw-r--r-- | embassy-nrf/src/spim.rs | 12 | ||||
| -rw-r--r-- | embassy-nrf/src/uarte.rs | 14 | ||||
| -rw-r--r-- | embassy-rp/src/gpio.rs | 6 | ||||
| -rw-r--r-- | embassy-rp/src/uart.rs | 12 | ||||
| -rw-r--r-- | embassy/src/util/mod.rs | 6 |
12 files changed, 61 insertions, 64 deletions
diff --git a/embassy-extras/src/macros.rs b/embassy-extras/src/macros.rs index 832e76d68..d85439358 100644 --- a/embassy-extras/src/macros.rs +++ b/embassy-extras/src/macros.rs | |||
| @@ -16,7 +16,7 @@ macro_rules! peripherals { | |||
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | $(#[$cfg])? | 18 | $(#[$cfg])? |
| 19 | impl embassy::util::PeripheralBorrow for $name { | 19 | impl embassy::util::Unborrow for $name { |
| 20 | type Target = $name; | 20 | type Target = $name; |
| 21 | #[inline] | 21 | #[inline] |
| 22 | unsafe fn unborrow(self) -> $name { | 22 | unsafe fn unborrow(self) -> $name { |
| @@ -25,7 +25,7 @@ macro_rules! peripherals { | |||
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | $(#[$cfg])? | 27 | $(#[$cfg])? |
| 28 | impl embassy::util::PeripheralBorrow for &mut $name { | 28 | impl embassy::util::Unborrow for &mut $name { |
| 29 | type Target = $name; | 29 | type Target = $name; |
| 30 | #[inline] | 30 | #[inline] |
| 31 | unsafe fn unborrow(self) -> $name { | 31 | unsafe fn unborrow(self) -> $name { |
| @@ -89,7 +89,7 @@ macro_rules! unborrow { | |||
| 89 | #[macro_export] | 89 | #[macro_export] |
| 90 | macro_rules! impl_unborrow { | 90 | macro_rules! impl_unborrow { |
| 91 | ($type:ident) => { | 91 | ($type:ident) => { |
| 92 | impl ::embassy::util::PeripheralBorrow for $type { | 92 | impl ::embassy::util::Unborrow for $type { |
| 93 | type Target = $type; | 93 | type Target = $type; |
| 94 | #[inline] | 94 | #[inline] |
| 95 | unsafe fn unborrow(self) -> Self::Target { | 95 | unsafe fn unborrow(self) -> Self::Target { |
| @@ -97,7 +97,7 @@ macro_rules! impl_unborrow { | |||
| 97 | } | 97 | } |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | impl<'a> ::embassy::util::PeripheralBorrow for &'a mut $type { | 100 | impl<'a> ::embassy::util::Unborrow for &'a mut $type { |
| 101 | type Target = $type; | 101 | type Target = $type; |
| 102 | #[inline] | 102 | #[inline] |
| 103 | unsafe fn unborrow(self) -> Self::Target { | 103 | unsafe fn unborrow(self) -> Self::Target { |
diff --git a/embassy-macros/src/lib.rs b/embassy-macros/src/lib.rs index 402f0e08a..cca6c8a56 100644 --- a/embassy-macros/src/lib.rs +++ b/embassy-macros/src/lib.rs | |||
| @@ -147,14 +147,14 @@ pub fn interrupt_declare(item: TokenStream) -> TokenStream { | |||
| 147 | } | 147 | } |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | impl ::embassy::util::PeripheralBorrow for #name_interrupt { | 150 | impl ::embassy::util::Unborrow for #name_interrupt { |
| 151 | type Target = #name_interrupt; | 151 | type Target = #name_interrupt; |
| 152 | unsafe fn unborrow(self) -> #name_interrupt { | 152 | unsafe fn unborrow(self) -> #name_interrupt { |
| 153 | self | 153 | self |
| 154 | } | 154 | } |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | impl ::embassy::util::PeripheralBorrow for &mut #name_interrupt { | 157 | impl ::embassy::util::Unborrow for &mut #name_interrupt { |
| 158 | type Target = #name_interrupt; | 158 | type Target = #name_interrupt; |
| 159 | unsafe fn unborrow(self) -> #name_interrupt { | 159 | unsafe fn unborrow(self) -> #name_interrupt { |
| 160 | ::core::ptr::read(self) | 160 | ::core::ptr::read(self) |
diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs index 9e67aaef6..49e8dd2b6 100644 --- a/embassy-nrf/src/buffered_uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs | |||
| @@ -5,7 +5,7 @@ use core::sync::atomic::{compiler_fence, Ordering}; | |||
| 5 | use core::task::{Context, Poll}; | 5 | use core::task::{Context, Poll}; |
| 6 | use embassy::interrupt::InterruptExt; | 6 | use embassy::interrupt::InterruptExt; |
| 7 | use embassy::io::{AsyncBufRead, AsyncWrite, Result}; | 7 | use embassy::io::{AsyncBufRead, AsyncWrite, Result}; |
| 8 | use embassy::util::{PeripheralBorrow, WakerRegistration}; | 8 | use embassy::util::{Unborrow, WakerRegistration}; |
| 9 | use embassy_extras::peripheral::{PeripheralMutex, PeripheralState}; | 9 | use embassy_extras::peripheral::{PeripheralMutex, PeripheralState}; |
| 10 | use embassy_extras::ring_buffer::RingBuffer; | 10 | use embassy_extras::ring_buffer::RingBuffer; |
| 11 | use embassy_extras::{low_power_wait_until, unborrow}; | 11 | use embassy_extras::{low_power_wait_until, unborrow}; |
| @@ -63,15 +63,15 @@ pub struct BufferedUarte<'d, U: UarteInstance, T: TimerInstance> { | |||
| 63 | impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { | 63 | impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { |
| 64 | /// unsafe: may not leak self or futures | 64 | /// unsafe: may not leak self or futures |
| 65 | pub unsafe fn new( | 65 | pub unsafe fn new( |
| 66 | uarte: impl PeripheralBorrow<Target = U> + 'd, | 66 | uarte: impl Unborrow<Target = U> + 'd, |
| 67 | timer: impl PeripheralBorrow<Target = T> + 'd, | 67 | timer: impl Unborrow<Target = T> + 'd, |
| 68 | ppi_ch1: impl PeripheralBorrow<Target = impl ConfigurableChannel> + 'd, | 68 | ppi_ch1: impl Unborrow<Target = impl ConfigurableChannel> + 'd, |
| 69 | ppi_ch2: impl PeripheralBorrow<Target = impl ConfigurableChannel> + 'd, | 69 | ppi_ch2: impl Unborrow<Target = impl ConfigurableChannel> + 'd, |
| 70 | irq: impl PeripheralBorrow<Target = U::Interrupt> + 'd, | 70 | irq: impl Unborrow<Target = U::Interrupt> + 'd, |
| 71 | rxd: impl PeripheralBorrow<Target = impl GpioPin> + 'd, | 71 | rxd: impl Unborrow<Target = impl GpioPin> + 'd, |
| 72 | txd: impl PeripheralBorrow<Target = impl GpioPin> + 'd, | 72 | txd: impl Unborrow<Target = impl GpioPin> + 'd, |
| 73 | cts: impl PeripheralBorrow<Target = impl GpioOptionalPin> + 'd, | 73 | cts: impl Unborrow<Target = impl GpioOptionalPin> + 'd, |
| 74 | rts: impl PeripheralBorrow<Target = impl GpioOptionalPin> + 'd, | 74 | rts: impl Unborrow<Target = impl GpioOptionalPin> + 'd, |
| 75 | config: Config, | 75 | config: Config, |
| 76 | rx_buffer: &'d mut [u8], | 76 | rx_buffer: &'d mut [u8], |
| 77 | tx_buffer: &'d mut [u8], | 77 | tx_buffer: &'d mut [u8], |
diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs index 5a5f7b8da..a06ee6053 100644 --- a/embassy-nrf/src/gpio.rs +++ b/embassy-nrf/src/gpio.rs | |||
| @@ -2,7 +2,7 @@ use core::convert::Infallible; | |||
| 2 | use core::hint::unreachable_unchecked; | 2 | use core::hint::unreachable_unchecked; |
| 3 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 4 | 4 | ||
| 5 | use embassy::util::PeripheralBorrow; | 5 | use embassy::util::Unborrow; |
| 6 | use embassy_extras::{impl_unborrow, unborrow}; | 6 | use embassy_extras::{impl_unborrow, unborrow}; |
| 7 | use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin}; | 7 | use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin}; |
| 8 | use gpio::pin_cnf::DRIVE_A; | 8 | use gpio::pin_cnf::DRIVE_A; |
| @@ -38,7 +38,7 @@ pub struct Input<'d, T: Pin> { | |||
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | impl<'d, T: Pin> Input<'d, T> { | 40 | impl<'d, T: Pin> Input<'d, T> { |
| 41 | pub fn new(pin: impl PeripheralBorrow<Target = T> + 'd, pull: Pull) -> Self { | 41 | pub fn new(pin: impl Unborrow<Target = T> + 'd, pull: Pull) -> Self { |
| 42 | unborrow!(pin); | 42 | unborrow!(pin); |
| 43 | 43 | ||
| 44 | pin.conf().write(|w| { | 44 | pin.conf().write(|w| { |
| @@ -123,7 +123,7 @@ pub struct Output<'d, T: Pin> { | |||
| 123 | 123 | ||
| 124 | impl<'d, T: Pin> Output<'d, T> { | 124 | impl<'d, T: Pin> Output<'d, T> { |
| 125 | pub fn new( | 125 | pub fn new( |
| 126 | pin: impl PeripheralBorrow<Target = T> + 'd, | 126 | pin: impl Unborrow<Target = T> + 'd, |
| 127 | initial_output: Level, | 127 | initial_output: Level, |
| 128 | drive: OutputDrive, | 128 | drive: OutputDrive, |
| 129 | ) -> Self { | 129 | ) -> Self { |
diff --git a/embassy-nrf/src/ppi.rs b/embassy-nrf/src/ppi.rs index 6487267da..e8bcbd603 100644 --- a/embassy-nrf/src/ppi.rs +++ b/embassy-nrf/src/ppi.rs | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | use core::marker::PhantomData; | 12 | use core::marker::PhantomData; |
| 13 | use core::ptr::NonNull; | 13 | use core::ptr::NonNull; |
| 14 | use embassy::util::PeripheralBorrow; | 14 | use embassy::util::Unborrow; |
| 15 | use embassy_extras::{impl_unborrow, unborrow}; | 15 | use embassy_extras::{impl_unborrow, unborrow}; |
| 16 | 16 | ||
| 17 | use crate::{pac, peripherals}; | 17 | use crate::{pac, peripherals}; |
| @@ -25,7 +25,7 @@ pub struct Ppi<'d, C: Channel> { | |||
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | impl<'d, C: Channel> Ppi<'d, C> { | 27 | impl<'d, C: Channel> Ppi<'d, C> { |
| 28 | pub fn new(ch: impl PeripheralBorrow<Target = C> + 'd) -> Self { | 28 | pub fn new(ch: impl Unborrow<Target = C> + 'd) -> Self { |
| 29 | unborrow!(ch); | 29 | unborrow!(ch); |
| 30 | let mut this = Self { | 30 | let mut this = Self { |
| 31 | ch, | 31 | ch, |
diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs index d682c1b8c..f683138d6 100644 --- a/embassy-nrf/src/qspi.rs +++ b/embassy-nrf/src/qspi.rs | |||
| @@ -3,7 +3,7 @@ use core::marker::PhantomData; | |||
| 3 | use core::task::Poll; | 3 | use core::task::Poll; |
| 4 | use embassy::interrupt::{Interrupt, InterruptExt}; | 4 | use embassy::interrupt::{Interrupt, InterruptExt}; |
| 5 | use embassy::traits::flash::{Error, Flash}; | 5 | use embassy::traits::flash::{Error, Flash}; |
| 6 | use embassy::util::{AtomicWaker, DropBomb, PeripheralBorrow}; | 6 | use embassy::util::{AtomicWaker, DropBomb, Unborrow}; |
| 7 | use embassy_extras::unborrow; | 7 | use embassy_extras::unborrow; |
| 8 | use futures::future::poll_fn; | 8 | use futures::future::poll_fn; |
| 9 | 9 | ||
| @@ -61,14 +61,14 @@ pub struct Qspi<'d, T: Instance> { | |||
| 61 | 61 | ||
| 62 | impl<'d, T: Instance> Qspi<'d, T> { | 62 | impl<'d, T: Instance> Qspi<'d, T> { |
| 63 | pub fn new( | 63 | pub fn new( |
| 64 | qspi: impl PeripheralBorrow<Target = T> + 'd, | 64 | qspi: impl Unborrow<Target = T> + 'd, |
| 65 | irq: impl PeripheralBorrow<Target = T::Interrupt> + 'd, | 65 | irq: impl Unborrow<Target = T::Interrupt> + 'd, |
| 66 | sck: impl PeripheralBorrow<Target = impl GpioPin> + 'd, | 66 | sck: impl Unborrow<Target = impl GpioPin> + 'd, |
| 67 | csn: impl PeripheralBorrow<Target = impl GpioPin> + 'd, | 67 | csn: impl Unborrow<Target = impl GpioPin> + 'd, |
| 68 | io0: impl PeripheralBorrow<Target = impl GpioPin> + 'd, | 68 | io0: impl Unborrow<Target = impl GpioPin> + 'd, |
| 69 | io1: impl PeripheralBorrow<Target = impl GpioPin> + 'd, | 69 | io1: impl Unborrow<Target = impl GpioPin> + 'd, |
| 70 | io2: impl PeripheralBorrow<Target = impl GpioPin> + 'd, | 70 | io2: impl Unborrow<Target = impl GpioPin> + 'd, |
| 71 | io3: impl PeripheralBorrow<Target = impl GpioPin> + 'd, | 71 | io3: impl Unborrow<Target = impl GpioPin> + 'd, |
| 72 | config: Config, | 72 | config: Config, |
| 73 | ) -> Self { | 73 | ) -> Self { |
| 74 | unborrow!(qspi, irq, sck, csn, io0, io1, io2, io3); | 74 | unborrow!(qspi, irq, sck, csn, io0, io1, io2, io3); |
diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs index b854ce780..448d0334c 100644 --- a/embassy-nrf/src/saadc.rs +++ b/embassy-nrf/src/saadc.rs | |||
| @@ -3,15 +3,12 @@ use core::marker::PhantomData; | |||
| 3 | use core::pin::Pin; | 3 | use core::pin::Pin; |
| 4 | use core::sync::atomic::{compiler_fence, Ordering}; | 4 | use core::sync::atomic::{compiler_fence, Ordering}; |
| 5 | use core::task::Poll; | 5 | use core::task::Poll; |
| 6 | use embassy::traits; | 6 | use embassy::util::{wake_on_interrupt, Unborrow}; |
| 7 | use embassy::util::{wake_on_interrupt, PeripheralBorrow}; | ||
| 8 | use embassy_extras::unborrow; | 7 | use embassy_extras::unborrow; |
| 9 | use futures::future::poll_fn; | 8 | use futures::future::poll_fn; |
| 10 | use traits::spi::FullDuplex; | ||
| 11 | 9 | ||
| 12 | use crate::gpio::Pin as GpioPin; | 10 | use crate::interrupt; |
| 13 | use crate::interrupt::{self, Interrupt}; | 11 | use crate::{pac, peripherals}; |
| 14 | use crate::{pac, peripherals, slice_in_ram_or}; | ||
| 15 | 12 | ||
| 16 | #[cfg(feature = "9160")] | 13 | #[cfg(feature = "9160")] |
| 17 | use pac::{saadc_ns as saadc, SAADC_NS as SAADC}; | 14 | use pac::{saadc_ns as saadc, SAADC_NS as SAADC}; |
| @@ -74,9 +71,9 @@ impl Default for Config { | |||
| 74 | 71 | ||
| 75 | impl<'d, T: PositivePin> OneShot<'d, T> { | 72 | impl<'d, T: PositivePin> OneShot<'d, T> { |
| 76 | pub fn new( | 73 | pub fn new( |
| 77 | saadc: impl PeripheralBorrow<Target = peripherals::SAADC> + 'd, | 74 | saadc: impl Unborrow<Target = peripherals::SAADC> + 'd, |
| 78 | irq: impl PeripheralBorrow<Target = interrupt::SAADC> + 'd, | 75 | irq: impl Unborrow<Target = interrupt::SAADC> + 'd, |
| 79 | positive_pin: impl PeripheralBorrow<Target = T> + 'd, | 76 | positive_pin: impl Unborrow<Target = T> + 'd, |
| 80 | config: Config, | 77 | config: Config, |
| 81 | ) -> Self { | 78 | ) -> Self { |
| 82 | unborrow!(saadc, irq, positive_pin); | 79 | unborrow!(saadc, irq, positive_pin); |
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index bbe1eedf9..d6b9ee8d8 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs | |||
| @@ -4,7 +4,7 @@ use core::sync::atomic::{compiler_fence, Ordering}; | |||
| 4 | use core::task::Poll; | 4 | use core::task::Poll; |
| 5 | use embassy::interrupt::InterruptExt; | 5 | use embassy::interrupt::InterruptExt; |
| 6 | use embassy::traits; | 6 | use embassy::traits; |
| 7 | use embassy::util::{AtomicWaker, PeripheralBorrow}; | 7 | use embassy::util::{AtomicWaker, Unborrow}; |
| 8 | use embassy_extras::unborrow; | 8 | use embassy_extras::unborrow; |
| 9 | use futures::future::poll_fn; | 9 | use futures::future::poll_fn; |
| 10 | use traits::spi::FullDuplex; | 10 | use traits::spi::FullDuplex; |
| @@ -41,11 +41,11 @@ pub struct Config { | |||
| 41 | 41 | ||
| 42 | impl<'d, T: Instance> Spim<'d, T> { | 42 | impl<'d, T: Instance> Spim<'d, T> { |
| 43 | pub fn new( | 43 | pub fn new( |
| 44 | spim: impl PeripheralBorrow<Target = T> + 'd, | 44 | spim: impl Unborrow<Target = T> + 'd, |
| 45 | irq: impl PeripheralBorrow<Target = T::Interrupt> + 'd, | 45 | irq: impl Unborrow<Target = T::Interrupt> + 'd, |
| 46 | sck: impl PeripheralBorrow<Target = impl GpioPin> + 'd, | 46 | sck: impl Unborrow<Target = impl GpioPin> + 'd, |
| 47 | miso: impl PeripheralBorrow<Target = impl OptionalPin> + 'd, | 47 | miso: impl Unborrow<Target = impl OptionalPin> + 'd, |
| 48 | mosi: impl PeripheralBorrow<Target = impl OptionalPin> + 'd, | 48 | mosi: impl Unborrow<Target = impl OptionalPin> + 'd, |
| 49 | config: Config, | 49 | config: Config, |
| 50 | ) -> Self { | 50 | ) -> Self { |
| 51 | unborrow!(spim, irq, sck, miso, mosi); | 51 | unborrow!(spim, irq, sck, miso, mosi); |
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index 9e485907c..a02f7c347 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs | |||
| @@ -6,7 +6,7 @@ use core::sync::atomic::{compiler_fence, Ordering}; | |||
| 6 | use core::task::Poll; | 6 | use core::task::Poll; |
| 7 | use embassy::interrupt::InterruptExt; | 7 | use embassy::interrupt::InterruptExt; |
| 8 | use embassy::traits::uart::{Error, Read, Write}; | 8 | use embassy::traits::uart::{Error, Read, Write}; |
| 9 | use embassy::util::{AtomicWaker, OnDrop, PeripheralBorrow}; | 9 | use embassy::util::{AtomicWaker, OnDrop, Unborrow}; |
| 10 | use embassy_extras::unborrow; | 10 | use embassy_extras::unborrow; |
| 11 | use futures::future::poll_fn; | 11 | use futures::future::poll_fn; |
| 12 | 12 | ||
| @@ -54,12 +54,12 @@ impl<'d, T: Instance> Uarte<'d, T> { | |||
| 54 | /// or [`receive`](Uarte::receive). | 54 | /// or [`receive`](Uarte::receive). |
| 55 | #[allow(unused_unsafe)] | 55 | #[allow(unused_unsafe)] |
| 56 | pub unsafe fn new( | 56 | pub unsafe fn new( |
| 57 | uarte: impl PeripheralBorrow<Target = T> + 'd, | 57 | uarte: impl Unborrow<Target = T> + 'd, |
| 58 | irq: impl PeripheralBorrow<Target = T::Interrupt> + 'd, | 58 | irq: impl Unborrow<Target = T::Interrupt> + 'd, |
| 59 | rxd: impl PeripheralBorrow<Target = impl GpioPin> + 'd, | 59 | rxd: impl Unborrow<Target = impl GpioPin> + 'd, |
| 60 | txd: impl PeripheralBorrow<Target = impl GpioPin> + 'd, | 60 | txd: impl Unborrow<Target = impl GpioPin> + 'd, |
| 61 | cts: impl PeripheralBorrow<Target = impl GpioOptionalPin> + 'd, | 61 | cts: impl Unborrow<Target = impl GpioOptionalPin> + 'd, |
| 62 | rts: impl PeripheralBorrow<Target = impl GpioOptionalPin> + 'd, | 62 | rts: impl Unborrow<Target = impl GpioOptionalPin> + 'd, |
| 63 | config: Config, | 63 | config: Config, |
| 64 | ) -> Self { | 64 | ) -> Self { |
| 65 | unborrow!(uarte, irq, rxd, txd, cts, rts); | 65 | unborrow!(uarte, irq, rxd, txd, cts, rts); |
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs index 46a7b5a15..ecfad1878 100644 --- a/embassy-rp/src/gpio.rs +++ b/embassy-rp/src/gpio.rs | |||
| @@ -5,7 +5,7 @@ use crate::pac::generic::{Reg, RW}; | |||
| 5 | use crate::pac::SIO; | 5 | use crate::pac::SIO; |
| 6 | use crate::peripherals; | 6 | use crate::peripherals; |
| 7 | 7 | ||
| 8 | use embassy::util::PeripheralBorrow; | 8 | use embassy::util::Unborrow; |
| 9 | use embassy_extras::{impl_unborrow, unborrow}; | 9 | use embassy_extras::{impl_unborrow, unborrow}; |
| 10 | use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin}; | 10 | use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin}; |
| 11 | 11 | ||
| @@ -37,7 +37,7 @@ pub struct Input<'d, T: Pin> { | |||
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | impl<'d, T: Pin> Input<'d, T> { | 39 | impl<'d, T: Pin> Input<'d, T> { |
| 40 | pub fn new(pin: impl PeripheralBorrow<Target = T> + 'd, pull: Pull) -> Self { | 40 | pub fn new(pin: impl Unborrow<Target = T> + 'd, pull: Pull) -> Self { |
| 41 | unborrow!(pin); | 41 | unborrow!(pin); |
| 42 | 42 | ||
| 43 | unsafe { | 43 | unsafe { |
| @@ -91,7 +91,7 @@ pub struct Output<'d, T: Pin> { | |||
| 91 | 91 | ||
| 92 | impl<'d, T: Pin> Output<'d, T> { | 92 | impl<'d, T: Pin> Output<'d, T> { |
| 93 | // TODO opendrain | 93 | // TODO opendrain |
| 94 | pub fn new(pin: impl PeripheralBorrow<Target = T> + 'd, initial_output: Level) -> Self { | 94 | pub fn new(pin: impl Unborrow<Target = T> + 'd, initial_output: Level) -> Self { |
| 95 | unborrow!(pin); | 95 | unborrow!(pin); |
| 96 | 96 | ||
| 97 | unsafe { | 97 | unsafe { |
diff --git a/embassy-rp/src/uart.rs b/embassy-rp/src/uart.rs index 3eb768a7d..2c8986302 100644 --- a/embassy-rp/src/uart.rs +++ b/embassy-rp/src/uart.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | use core::marker::PhantomData; | 1 | use core::marker::PhantomData; |
| 2 | 2 | ||
| 3 | use embassy::util::PeripheralBorrow; | 3 | use embassy::util::Unborrow; |
| 4 | use embassy_extras::unborrow; | 4 | use embassy_extras::unborrow; |
| 5 | use gpio::Pin; | 5 | use gpio::Pin; |
| 6 | 6 | ||
| @@ -30,11 +30,11 @@ pub struct Uart<'d, T: Instance> { | |||
| 30 | 30 | ||
| 31 | impl<'d, T: Instance> Uart<'d, T> { | 31 | impl<'d, T: Instance> Uart<'d, T> { |
| 32 | pub fn new( | 32 | pub fn new( |
| 33 | inner: impl PeripheralBorrow<Target = T>, | 33 | inner: impl Unborrow<Target = T>, |
| 34 | tx: impl PeripheralBorrow<Target = impl TxPin<T>>, | 34 | tx: impl Unborrow<Target = impl TxPin<T>>, |
| 35 | rx: impl PeripheralBorrow<Target = impl RxPin<T>>, | 35 | rx: impl Unborrow<Target = impl RxPin<T>>, |
| 36 | cts: impl PeripheralBorrow<Target = impl CtsPin<T>>, | 36 | cts: impl Unborrow<Target = impl CtsPin<T>>, |
| 37 | rts: impl PeripheralBorrow<Target = impl RtsPin<T>>, | 37 | rts: impl Unborrow<Target = impl RtsPin<T>>, |
| 38 | config: Config, | 38 | config: Config, |
| 39 | ) -> Self { | 39 | ) -> Self { |
| 40 | unborrow!(inner, tx, rx, cts, rts); | 40 | unborrow!(inner, tx, rx, cts, rts); |
diff --git a/embassy/src/util/mod.rs b/embassy/src/util/mod.rs index 25b570cc6..cace0d190 100644 --- a/embassy/src/util/mod.rs +++ b/embassy/src/util/mod.rs | |||
| @@ -1,15 +1,16 @@ | |||
| 1 | //! Async utilities | 1 | //! Async utilities |
| 2 | mod critical_section; | ||
| 2 | mod drop_bomb; | 3 | mod drop_bomb; |
| 3 | mod forever; | 4 | mod forever; |
| 4 | mod mutex; | 5 | mod mutex; |
| 5 | mod on_drop; | 6 | mod on_drop; |
| 6 | mod portal; | 7 | mod portal; |
| 7 | mod signal; | 8 | mod signal; |
| 8 | mod critical_section; | ||
| 9 | 9 | ||
| 10 | #[cfg_attr(feature = "executor-agnostic", path = "waker_agnostic.rs")] | 10 | #[cfg_attr(feature = "executor-agnostic", path = "waker_agnostic.rs")] |
| 11 | mod waker; | 11 | mod waker; |
| 12 | 12 | ||
| 13 | pub use critical_section::*; | ||
| 13 | pub use drop_bomb::*; | 14 | pub use drop_bomb::*; |
| 14 | pub use forever::*; | 15 | pub use forever::*; |
| 15 | pub use mutex::*; | 16 | pub use mutex::*; |
| @@ -17,9 +18,8 @@ pub use on_drop::*; | |||
| 17 | pub use portal::*; | 18 | pub use portal::*; |
| 18 | pub use signal::*; | 19 | pub use signal::*; |
| 19 | pub use waker::*; | 20 | pub use waker::*; |
| 20 | pub use critical_section::*; | ||
| 21 | 21 | ||
| 22 | pub trait PeripheralBorrow { | 22 | pub trait Unborrow { |
| 23 | type Target; | 23 | type Target; |
| 24 | unsafe fn unborrow(self) -> Self::Target; | 24 | unsafe fn unborrow(self) -> Self::Target; |
| 25 | } | 25 | } |
