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-rp/src/clocks.rs | |
| parent | 9edf5b7f049f95742b60b041e4443967d8a6b708 (diff) | |
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-rp/src/clocks.rs')
| -rw-r--r-- | embassy-rp/src/clocks.rs | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/embassy-rp/src/clocks.rs b/embassy-rp/src/clocks.rs index 705dde62a..67aa5e540 100644 --- a/embassy-rp/src/clocks.rs +++ b/embassy-rp/src/clocks.rs | |||
| @@ -7,13 +7,12 @@ use core::marker::PhantomData; | |||
| 7 | use core::sync::atomic::AtomicU16; | 7 | use core::sync::atomic::AtomicU16; |
| 8 | use core::sync::atomic::{AtomicU32, Ordering}; | 8 | use core::sync::atomic::{AtomicU32, Ordering}; |
| 9 | 9 | ||
| 10 | use embassy_hal_internal::{into_ref, PeripheralRef}; | ||
| 11 | use pac::clocks::vals::*; | 10 | use pac::clocks::vals::*; |
| 12 | 11 | ||
| 13 | use crate::gpio::{AnyPin, SealedPin}; | 12 | use crate::gpio::{AnyPin, SealedPin}; |
| 14 | #[cfg(feature = "rp2040")] | 13 | #[cfg(feature = "rp2040")] |
| 15 | use crate::pac::common::{Reg, RW}; | 14 | use crate::pac::common::{Reg, RW}; |
| 16 | use crate::{pac, reset, Peripheral}; | 15 | use crate::{pac, reset, Peri}; |
| 17 | 16 | ||
| 18 | // NOTE: all gpin handling is commented out for future reference. | 17 | // NOTE: all gpin handling is commented out for future reference. |
| 19 | // gpin is not usually safe to use during the boot init() call, so it won't | 18 | // gpin is not usually safe to use during the boot init() call, so it won't |
| @@ -200,8 +199,8 @@ impl ClockConfig { | |||
| 200 | 199 | ||
| 201 | // pub fn bind_gpin<P: GpinPin>(&mut self, gpin: Gpin<'static, P>, hz: u32) { | 200 | // pub fn bind_gpin<P: GpinPin>(&mut self, gpin: Gpin<'static, P>, hz: u32) { |
| 202 | // match P::NR { | 201 | // match P::NR { |
| 203 | // 0 => self.gpin0 = Some((hz, gpin.map_into())), | 202 | // 0 => self.gpin0 = Some((hz, gpin.into())), |
| 204 | // 1 => self.gpin1 = Some((hz, gpin.map_into())), | 203 | // 1 => self.gpin1 = Some((hz, gpin.into())), |
| 205 | // _ => unreachable!(), | 204 | // _ => unreachable!(), |
| 206 | // } | 205 | // } |
| 207 | // // pin is now provisionally bound. if the config is applied it must be forgotten, | 206 | // // pin is now provisionally bound. if the config is applied it must be forgotten, |
| @@ -845,15 +844,13 @@ impl_gpinpin!(PIN_22, 22, 1); | |||
| 845 | 844 | ||
| 846 | /// General purpose clock input driver. | 845 | /// General purpose clock input driver. |
| 847 | pub struct Gpin<'d, T: GpinPin> { | 846 | pub struct Gpin<'d, T: GpinPin> { |
| 848 | gpin: PeripheralRef<'d, AnyPin>, | 847 | gpin: Peri<'d, AnyPin>, |
| 849 | _phantom: PhantomData<T>, | 848 | _phantom: PhantomData<T>, |
| 850 | } | 849 | } |
| 851 | 850 | ||
| 852 | impl<'d, T: GpinPin> Gpin<'d, T> { | 851 | impl<'d, T: GpinPin> Gpin<'d, T> { |
| 853 | /// Create new gpin driver. | 852 | /// Create new gpin driver. |
| 854 | pub fn new(gpin: impl Peripheral<P = T> + 'd) -> Self { | 853 | pub fn new(gpin: Peri<'d, T>) -> Self { |
| 855 | into_ref!(gpin); | ||
| 856 | |||
| 857 | #[cfg(feature = "rp2040")] | 854 | #[cfg(feature = "rp2040")] |
| 858 | gpin.gpio().ctrl().write(|w| w.set_funcsel(0x08)); | 855 | gpin.gpio().ctrl().write(|w| w.set_funcsel(0x08)); |
| 859 | 856 | ||
| @@ -867,14 +864,10 @@ impl<'d, T: GpinPin> Gpin<'d, T> { | |||
| 867 | }); | 864 | }); |
| 868 | 865 | ||
| 869 | Gpin { | 866 | Gpin { |
| 870 | gpin: gpin.map_into(), | 867 | gpin: gpin.into(), |
| 871 | _phantom: PhantomData, | 868 | _phantom: PhantomData, |
| 872 | } | 869 | } |
| 873 | } | 870 | } |
| 874 | |||
| 875 | // fn map_into(self) -> Gpin<'d, AnyPin> { | ||
| 876 | // unsafe { core::mem::transmute(self) } | ||
| 877 | // } | ||
| 878 | } | 871 | } |
| 879 | 872 | ||
| 880 | impl<'d, T: GpinPin> Drop for Gpin<'d, T> { | 873 | impl<'d, T: GpinPin> Drop for Gpin<'d, T> { |
| @@ -936,14 +929,12 @@ pub enum GpoutSrc { | |||
| 936 | 929 | ||
| 937 | /// General purpose clock output driver. | 930 | /// General purpose clock output driver. |
| 938 | pub struct Gpout<'d, T: GpoutPin> { | 931 | pub struct Gpout<'d, T: GpoutPin> { |
| 939 | gpout: PeripheralRef<'d, T>, | 932 | gpout: Peri<'d, T>, |
| 940 | } | 933 | } |
| 941 | 934 | ||
| 942 | impl<'d, T: GpoutPin> Gpout<'d, T> { | 935 | impl<'d, T: GpoutPin> Gpout<'d, T> { |
| 943 | /// Create new general purpose clock output. | 936 | /// Create new general purpose clock output. |
| 944 | pub fn new(gpout: impl Peripheral<P = T> + 'd) -> Self { | 937 | pub fn new(gpout: Peri<'d, T>) -> Self { |
| 945 | into_ref!(gpout); | ||
| 946 | |||
| 947 | #[cfg(feature = "rp2040")] | 938 | #[cfg(feature = "rp2040")] |
| 948 | gpout.gpio().ctrl().write(|w| w.set_funcsel(0x08)); | 939 | gpout.gpio().ctrl().write(|w| w.set_funcsel(0x08)); |
| 949 | 940 | ||
