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/radio | |
| parent | 9edf5b7f049f95742b60b041e4443967d8a6b708 (diff) | |
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-nrf/src/radio')
| -rw-r--r-- | embassy-nrf/src/radio/ble.rs | 8 | ||||
| -rw-r--r-- | embassy-nrf/src/radio/ieee802154.rs | 9 | ||||
| -rw-r--r-- | embassy-nrf/src/radio/mod.rs | 5 |
3 files changed, 9 insertions, 13 deletions
diff --git a/embassy-nrf/src/radio/ble.rs b/embassy-nrf/src/radio/ble.rs index 682ca1c79..d42bbe5f6 100644 --- a/embassy-nrf/src/radio/ble.rs +++ b/embassy-nrf/src/radio/ble.rs | |||
| @@ -5,7 +5,6 @@ use core::sync::atomic::{compiler_fence, Ordering}; | |||
| 5 | use core::task::Poll; | 5 | use core::task::Poll; |
| 6 | 6 | ||
| 7 | use embassy_hal_internal::drop::OnDrop; | 7 | use embassy_hal_internal::drop::OnDrop; |
| 8 | use embassy_hal_internal::{into_ref, PeripheralRef}; | ||
| 9 | pub use pac::radio::vals::Mode; | 8 | pub use pac::radio::vals::Mode; |
| 10 | #[cfg(not(feature = "_nrf51"))] | 9 | #[cfg(not(feature = "_nrf51"))] |
| 11 | use pac::radio::vals::Plen as PreambleLength; | 10 | use pac::radio::vals::Plen as PreambleLength; |
| @@ -15,20 +14,19 @@ use crate::pac::radio::vals; | |||
| 15 | use crate::radio::*; | 14 | use crate::radio::*; |
| 16 | pub use crate::radio::{Error, TxPower}; | 15 | pub use crate::radio::{Error, TxPower}; |
| 17 | use crate::util::slice_in_ram_or; | 16 | use crate::util::slice_in_ram_or; |
| 17 | use crate::Peri; | ||
| 18 | 18 | ||
| 19 | /// Radio driver. | 19 | /// Radio driver. |
| 20 | pub struct Radio<'d, T: Instance> { | 20 | pub struct Radio<'d, T: Instance> { |
| 21 | _p: PeripheralRef<'d, T>, | 21 | _p: Peri<'d, T>, |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | impl<'d, T: Instance> Radio<'d, T> { | 24 | impl<'d, T: Instance> Radio<'d, T> { |
| 25 | /// Create a new radio driver. | 25 | /// Create a new radio driver. |
| 26 | pub fn new( | 26 | pub fn new( |
| 27 | radio: impl Peripheral<P = T> + 'd, | 27 | radio: Peri<'d, T>, |
| 28 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 28 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 29 | ) -> Self { | 29 | ) -> Self { |
| 30 | into_ref!(radio); | ||
| 31 | |||
| 32 | let r = T::regs(); | 30 | let r = T::regs(); |
| 33 | 31 | ||
| 34 | r.pcnf1().write(|w| { | 32 | r.pcnf1().write(|w| { |
diff --git a/embassy-nrf/src/radio/ieee802154.rs b/embassy-nrf/src/radio/ieee802154.rs index 083842f4a..2f0bcbe04 100644 --- a/embassy-nrf/src/radio/ieee802154.rs +++ b/embassy-nrf/src/radio/ieee802154.rs | |||
| @@ -4,13 +4,12 @@ use core::sync::atomic::{compiler_fence, Ordering}; | |||
| 4 | use core::task::Poll; | 4 | use core::task::Poll; |
| 5 | 5 | ||
| 6 | use embassy_hal_internal::drop::OnDrop; | 6 | use embassy_hal_internal::drop::OnDrop; |
| 7 | use embassy_hal_internal::{into_ref, PeripheralRef}; | ||
| 8 | 7 | ||
| 9 | use super::{state, Error, Instance, InterruptHandler, RadioState, TxPower}; | 8 | use super::{state, Error, Instance, InterruptHandler, RadioState, TxPower}; |
| 10 | use crate::interrupt::typelevel::Interrupt; | 9 | use crate::interrupt::typelevel::Interrupt; |
| 11 | use crate::interrupt::{self}; | 10 | use crate::interrupt::{self}; |
| 12 | use crate::pac::radio::vals; | 11 | use crate::pac::radio::vals; |
| 13 | use crate::Peripheral; | 12 | use crate::Peri; |
| 14 | 13 | ||
| 15 | /// Default (IEEE compliant) Start of Frame Delimiter | 14 | /// Default (IEEE compliant) Start of Frame Delimiter |
| 16 | pub const DEFAULT_SFD: u8 = 0xA7; | 15 | pub const DEFAULT_SFD: u8 = 0xA7; |
| @@ -33,18 +32,16 @@ pub enum Cca { | |||
| 33 | 32 | ||
| 34 | /// IEEE 802.15.4 radio driver. | 33 | /// IEEE 802.15.4 radio driver. |
| 35 | pub struct Radio<'d, T: Instance> { | 34 | pub struct Radio<'d, T: Instance> { |
| 36 | _p: PeripheralRef<'d, T>, | 35 | _p: Peri<'d, T>, |
| 37 | needs_enable: bool, | 36 | needs_enable: bool, |
| 38 | } | 37 | } |
| 39 | 38 | ||
| 40 | impl<'d, T: Instance> Radio<'d, T> { | 39 | impl<'d, T: Instance> Radio<'d, T> { |
| 41 | /// Create a new IEEE 802.15.4 radio driver. | 40 | /// Create a new IEEE 802.15.4 radio driver. |
| 42 | pub fn new( | 41 | pub fn new( |
| 43 | radio: impl Peripheral<P = T> + 'd, | 42 | radio: Peri<'d, T>, |
| 44 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 43 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 45 | ) -> Self { | 44 | ) -> Self { |
| 46 | into_ref!(radio); | ||
| 47 | |||
| 48 | let r = T::regs(); | 45 | let r = T::regs(); |
| 49 | 46 | ||
| 50 | // Disable and enable to reset peripheral | 47 | // Disable and enable to reset peripheral |
diff --git a/embassy-nrf/src/radio/mod.rs b/embassy-nrf/src/radio/mod.rs index 251f37d3d..982436266 100644 --- a/embassy-nrf/src/radio/mod.rs +++ b/embassy-nrf/src/radio/mod.rs | |||
| @@ -19,11 +19,12 @@ pub mod ieee802154; | |||
| 19 | 19 | ||
| 20 | use core::marker::PhantomData; | 20 | use core::marker::PhantomData; |
| 21 | 21 | ||
| 22 | use embassy_hal_internal::PeripheralType; | ||
| 22 | use embassy_sync::waitqueue::AtomicWaker; | 23 | use embassy_sync::waitqueue::AtomicWaker; |
| 23 | use pac::radio::vals::State as RadioState; | 24 | use pac::radio::vals::State as RadioState; |
| 24 | pub use pac::radio::vals::Txpower as TxPower; | 25 | pub use pac::radio::vals::Txpower as TxPower; |
| 25 | 26 | ||
| 26 | use crate::{interrupt, pac, Peripheral}; | 27 | use crate::{interrupt, pac}; |
| 27 | 28 | ||
| 28 | /// RADIO error. | 29 | /// RADIO error. |
| 29 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 30 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| @@ -94,7 +95,7 @@ macro_rules! impl_radio { | |||
| 94 | 95 | ||
| 95 | /// Radio peripheral instance. | 96 | /// Radio peripheral instance. |
| 96 | #[allow(private_bounds)] | 97 | #[allow(private_bounds)] |
| 97 | pub trait Instance: Peripheral<P = Self> + SealedInstance + 'static + Send { | 98 | pub trait Instance: SealedInstance + PeripheralType + 'static + Send { |
| 98 | /// Interrupt for this peripheral. | 99 | /// Interrupt for this peripheral. |
| 99 | type Interrupt: interrupt::typelevel::Interrupt; | 100 | type Interrupt: interrupt::typelevel::Interrupt; |
| 100 | } | 101 | } |
