diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-03-26 16:01:37 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-03-27 15:18:06 +0100 |
| commit | d41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch) | |
| tree | 678b6fc732216e529dc38e6f65b72a309917ac32 /embassy-nrf/src/timer.rs | |
| parent | 9edf5b7f049f95742b60b041e4443967d8a6b708 (diff) | |
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-nrf/src/timer.rs')
| -rw-r--r-- | embassy-nrf/src/timer.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs index a9aeb40fa..5b58b0a50 100644 --- a/embassy-nrf/src/timer.rs +++ b/embassy-nrf/src/timer.rs | |||
| @@ -6,11 +6,11 @@ | |||
| 6 | 6 | ||
| 7 | #![macro_use] | 7 | #![macro_use] |
| 8 | 8 | ||
| 9 | use embassy_hal_internal::{into_ref, PeripheralRef}; | 9 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 10 | 10 | ||
| 11 | use crate::pac; | ||
| 11 | use crate::pac::timer::vals; | 12 | use crate::pac::timer::vals; |
| 12 | use crate::ppi::{Event, Task}; | 13 | use crate::ppi::{Event, Task}; |
| 13 | use crate::{pac, Peripheral}; | ||
| 14 | 14 | ||
| 15 | pub(crate) trait SealedInstance { | 15 | pub(crate) trait SealedInstance { |
| 16 | /// The number of CC registers this instance has. | 16 | /// The number of CC registers this instance has. |
| @@ -20,7 +20,7 @@ pub(crate) trait SealedInstance { | |||
| 20 | 20 | ||
| 21 | /// Basic Timer instance. | 21 | /// Basic Timer instance. |
| 22 | #[allow(private_bounds)] | 22 | #[allow(private_bounds)] |
| 23 | pub trait Instance: Peripheral<P = Self> + SealedInstance + 'static + Send { | 23 | pub trait Instance: SealedInstance + PeripheralType + 'static + Send { |
| 24 | /// Interrupt for this peripheral. | 24 | /// Interrupt for this peripheral. |
| 25 | type Interrupt: crate::interrupt::typelevel::Interrupt; | 25 | type Interrupt: crate::interrupt::typelevel::Interrupt; |
| 26 | } | 26 | } |
| @@ -84,7 +84,7 @@ pub enum Frequency { | |||
| 84 | 84 | ||
| 85 | /// Timer driver. | 85 | /// Timer driver. |
| 86 | pub struct Timer<'d, T: Instance> { | 86 | pub struct Timer<'d, T: Instance> { |
| 87 | _p: PeripheralRef<'d, T>, | 87 | _p: Peri<'d, T>, |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | impl<'d, T: Instance> Timer<'d, T> { | 90 | impl<'d, T: Instance> Timer<'d, T> { |
| @@ -92,7 +92,7 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 92 | /// | 92 | /// |
| 93 | /// This can be useful for triggering tasks via PPI | 93 | /// This can be useful for triggering tasks via PPI |
| 94 | /// `Uarte` uses this internally. | 94 | /// `Uarte` uses this internally. |
| 95 | pub fn new(timer: impl Peripheral<P = T> + 'd) -> Self { | 95 | pub fn new(timer: Peri<'d, T>) -> Self { |
| 96 | Self::new_inner(timer, false) | 96 | Self::new_inner(timer, false) |
| 97 | } | 97 | } |
| 98 | 98 | ||
| @@ -100,13 +100,11 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 100 | /// | 100 | /// |
| 101 | /// This can be useful for triggering tasks via PPI | 101 | /// This can be useful for triggering tasks via PPI |
| 102 | /// `Uarte` uses this internally. | 102 | /// `Uarte` uses this internally. |
| 103 | pub fn new_counter(timer: impl Peripheral<P = T> + 'd) -> Self { | 103 | pub fn new_counter(timer: Peri<'d, T>) -> Self { |
| 104 | Self::new_inner(timer, true) | 104 | Self::new_inner(timer, true) |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | fn new_inner(timer: impl Peripheral<P = T> + 'd, _is_counter: bool) -> Self { | 107 | fn new_inner(timer: Peri<'d, T>, _is_counter: bool) -> Self { |
| 108 | into_ref!(timer); | ||
| 109 | |||
| 110 | let regs = T::regs(); | 108 | let regs = T::regs(); |
| 111 | 109 | ||
| 112 | let this = Self { _p: timer }; | 110 | let this = Self { _p: timer }; |
| @@ -229,7 +227,7 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 229 | /// When the register's CAPTURE task is triggered, the timer will store the current value of its counter in the register | 227 | /// When the register's CAPTURE task is triggered, the timer will store the current value of its counter in the register |
| 230 | pub struct Cc<'d, T: Instance> { | 228 | pub struct Cc<'d, T: Instance> { |
| 231 | n: usize, | 229 | n: usize, |
| 232 | _p: PeripheralRef<'d, T>, | 230 | _p: Peri<'d, T>, |
| 233 | } | 231 | } |
| 234 | 232 | ||
| 235 | impl<'d, T: Instance> Cc<'d, T> { | 233 | impl<'d, T: Instance> Cc<'d, T> { |
