diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-07-23 14:00:19 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-07-23 14:00:19 +0200 |
| commit | 4901c34d9c4cd326ab9bca02dd099a663da2567f (patch) | |
| tree | 8225afebb595fb10c1d67148c0d19b7b732853da /embassy-nrf/src/timer.rs | |
| parent | 8a9d2f59af004902d3978a2922843833b98bcce0 (diff) | |
Rename Unborrowed -> PeripheralRef, Unborrow -> Peripheral
Diffstat (limited to 'embassy-nrf/src/timer.rs')
| -rw-r--r-- | embassy-nrf/src/timer.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs index c8c36dfae..d7a7c4d70 100644 --- a/embassy-nrf/src/timer.rs +++ b/embassy-nrf/src/timer.rs | |||
| @@ -5,12 +5,12 @@ use core::task::Poll; | |||
| 5 | 5 | ||
| 6 | use embassy::waitqueue::AtomicWaker; | 6 | use embassy::waitqueue::AtomicWaker; |
| 7 | use embassy_hal_common::drop::OnDrop; | 7 | use embassy_hal_common::drop::OnDrop; |
| 8 | use embassy_hal_common::unborrow; | 8 | use embassy_hal_common::into_ref; |
| 9 | use futures::future::poll_fn; | 9 | use futures::future::poll_fn; |
| 10 | 10 | ||
| 11 | use crate::interrupt::{Interrupt, InterruptExt}; | 11 | use crate::interrupt::{Interrupt, InterruptExt}; |
| 12 | use crate::ppi::{Event, Task}; | 12 | use crate::ppi::{Event, Task}; |
| 13 | use crate::{pac, Unborrow}; | 13 | use crate::{pac, Peripheral}; |
| 14 | 14 | ||
| 15 | pub(crate) mod sealed { | 15 | pub(crate) mod sealed { |
| 16 | 16 | ||
| @@ -28,7 +28,7 @@ pub(crate) mod sealed { | |||
| 28 | pub trait TimerType {} | 28 | pub trait TimerType {} |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static + Send { | 31 | pub trait Instance: Peripheral<P = Self> + sealed::Instance + 'static + Send { |
| 32 | type Interrupt: Interrupt; | 32 | type Interrupt: Interrupt; |
| 33 | } | 33 | } |
| 34 | pub trait ExtendedInstance: Instance + sealed::ExtendedInstance {} | 34 | pub trait ExtendedInstance: Instance + sealed::ExtendedInstance {} |
| @@ -99,11 +99,8 @@ pub struct Timer<'d, T: Instance, I: TimerType = NotAwaitable> { | |||
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | impl<'d, T: Instance> Timer<'d, T, Awaitable> { | 101 | impl<'d, T: Instance> Timer<'d, T, Awaitable> { |
| 102 | pub fn new_awaitable( | 102 | pub fn new_awaitable(timer: impl Peripheral<P = T> + 'd, irq: impl Peripheral<P = T::Interrupt> + 'd) -> Self { |
| 103 | timer: impl Unborrow<Target = T> + 'd, | 103 | into_ref!(irq); |
| 104 | irq: impl Unborrow<Target = T::Interrupt> + 'd, | ||
| 105 | ) -> Self { | ||
| 106 | unborrow!(irq); | ||
| 107 | 104 | ||
| 108 | irq.set_handler(Self::on_interrupt); | 105 | irq.set_handler(Self::on_interrupt); |
| 109 | irq.unpend(); | 106 | irq.unpend(); |
| @@ -117,7 +114,7 @@ impl<'d, T: Instance> Timer<'d, T, NotAwaitable> { | |||
| 117 | /// | 114 | /// |
| 118 | /// This can be useful for triggering tasks via PPI | 115 | /// This can be useful for triggering tasks via PPI |
| 119 | /// `Uarte` uses this internally. | 116 | /// `Uarte` uses this internally. |
| 120 | pub fn new(timer: impl Unborrow<Target = T> + 'd) -> Self { | 117 | pub fn new(timer: impl Peripheral<P = T> + 'd) -> Self { |
| 121 | Self::new_irqless(timer) | 118 | Self::new_irqless(timer) |
| 122 | } | 119 | } |
| 123 | } | 120 | } |
| @@ -126,7 +123,7 @@ impl<'d, T: Instance, I: TimerType> Timer<'d, T, I> { | |||
| 126 | /// Create a `Timer` without an interrupt, meaning `Cc::wait` won't work. | 123 | /// Create a `Timer` without an interrupt, meaning `Cc::wait` won't work. |
| 127 | /// | 124 | /// |
| 128 | /// This is used by the public constructors. | 125 | /// This is used by the public constructors. |
| 129 | fn new_irqless(_timer: impl Unborrow<Target = T> + 'd) -> Self { | 126 | fn new_irqless(_timer: impl Peripheral<P = T> + 'd) -> Self { |
| 130 | let regs = T::regs(); | 127 | let regs = T::regs(); |
| 131 | 128 | ||
| 132 | let mut this = Self { phantom: PhantomData }; | 129 | let mut this = Self { phantom: PhantomData }; |
