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-stm32/src/ucpd.rs | |
| parent | 9edf5b7f049f95742b60b041e4443967d8a6b708 (diff) | |
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-stm32/src/ucpd.rs')
| -rw-r--r-- | embassy-stm32/src/ucpd.rs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/embassy-stm32/src/ucpd.rs b/embassy-stm32/src/ucpd.rs index c40ee8ad0..87693f148 100644 --- a/embassy-stm32/src/ucpd.rs +++ b/embassy-stm32/src/ucpd.rs | |||
| @@ -20,15 +20,15 @@ use core::sync::atomic::{AtomicBool, Ordering}; | |||
| 20 | use core::task::Poll; | 20 | use core::task::Poll; |
| 21 | 21 | ||
| 22 | use embassy_hal_internal::drop::OnDrop; | 22 | use embassy_hal_internal::drop::OnDrop; |
| 23 | use embassy_hal_internal::{into_ref, Peripheral}; | 23 | use embassy_hal_internal::PeripheralType; |
| 24 | use embassy_sync::waitqueue::AtomicWaker; | 24 | use embassy_sync::waitqueue::AtomicWaker; |
| 25 | 25 | ||
| 26 | use crate::dma::{ChannelAndRequest, TransferOptions}; | 26 | use crate::dma::{ChannelAndRequest, TransferOptions}; |
| 27 | use crate::interrupt; | ||
| 28 | use crate::interrupt::typelevel::Interrupt; | 27 | use crate::interrupt::typelevel::Interrupt; |
| 29 | use crate::pac::ucpd::vals::{Anamode, Ccenable, PscUsbpdclk, Txmode}; | 28 | use crate::pac::ucpd::vals::{Anamode, Ccenable, PscUsbpdclk, Txmode}; |
| 30 | pub use crate::pac::ucpd::vals::{Phyccsel as CcSel, Rxordset, TypecVstateCc as CcVState}; | 29 | pub use crate::pac::ucpd::vals::{Phyccsel as CcSel, Rxordset, TypecVstateCc as CcVState}; |
| 31 | use crate::rcc::{self, RccPeripheral}; | 30 | use crate::rcc::{self, RccPeripheral}; |
| 31 | use crate::{interrupt, Peri}; | ||
| 32 | 32 | ||
| 33 | pub(crate) fn init( | 33 | pub(crate) fn init( |
| 34 | _cs: critical_section::CriticalSection, | 34 | _cs: critical_section::CriticalSection, |
| @@ -122,13 +122,12 @@ pub struct Ucpd<'d, T: Instance> { | |||
| 122 | impl<'d, T: Instance> Ucpd<'d, T> { | 122 | impl<'d, T: Instance> Ucpd<'d, T> { |
| 123 | /// Creates a new UCPD driver instance. | 123 | /// Creates a new UCPD driver instance. |
| 124 | pub fn new( | 124 | pub fn new( |
| 125 | _peri: impl Peripheral<P = T> + 'd, | 125 | _peri: Peri<'d, T>, |
| 126 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 126 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 127 | cc1: impl Peripheral<P = impl Cc1Pin<T>> + 'd, | 127 | cc1: Peri<'d, impl Cc1Pin<T>>, |
| 128 | cc2: impl Peripheral<P = impl Cc2Pin<T>> + 'd, | 128 | cc2: Peri<'d, impl Cc2Pin<T>>, |
| 129 | config: Config, | 129 | config: Config, |
| 130 | ) -> Self { | 130 | ) -> Self { |
| 131 | into_ref!(cc1, cc2); | ||
| 132 | cc1.set_as_analog(); | 131 | cc1.set_as_analog(); |
| 133 | cc2.set_as_analog(); | 132 | cc2.set_as_analog(); |
| 134 | 133 | ||
| @@ -208,8 +207,8 @@ impl<'d, T: Instance> Ucpd<'d, T> { | |||
| 208 | /// and a Power Delivery (PD) PHY with receiver and transmitter. | 207 | /// and a Power Delivery (PD) PHY with receiver and transmitter. |
| 209 | pub fn split_pd_phy( | 208 | pub fn split_pd_phy( |
| 210 | self, | 209 | self, |
| 211 | rx_dma: impl Peripheral<P = impl RxDma<T>> + 'd, | 210 | rx_dma: Peri<'d, impl RxDma<T>>, |
| 212 | tx_dma: impl Peripheral<P = impl TxDma<T>> + 'd, | 211 | tx_dma: Peri<'d, impl TxDma<T>>, |
| 213 | cc_sel: CcSel, | 212 | cc_sel: CcSel, |
| 214 | ) -> (CcPhy<'d, T>, PdPhy<'d, T>) { | 213 | ) -> (CcPhy<'d, T>, PdPhy<'d, T>) { |
| 215 | let r = T::REGS; | 214 | let r = T::REGS; |
| @@ -229,7 +228,6 @@ impl<'d, T: Instance> Ucpd<'d, T> { | |||
| 229 | // Both parts must be dropped before the peripheral can be disabled. | 228 | // Both parts must be dropped before the peripheral can be disabled. |
| 230 | T::state().drop_not_ready.store(true, Ordering::Relaxed); | 229 | T::state().drop_not_ready.store(true, Ordering::Relaxed); |
| 231 | 230 | ||
| 232 | into_ref!(rx_dma, tx_dma); | ||
| 233 | let rx_dma_req = rx_dma.request(); | 231 | let rx_dma_req = rx_dma.request(); |
| 234 | let tx_dma_req = tx_dma.request(); | 232 | let tx_dma_req = tx_dma.request(); |
| 235 | ( | 233 | ( |
| @@ -237,11 +235,11 @@ impl<'d, T: Instance> Ucpd<'d, T> { | |||
| 237 | PdPhy { | 235 | PdPhy { |
| 238 | _lifetime: PhantomData, | 236 | _lifetime: PhantomData, |
| 239 | rx_dma: ChannelAndRequest { | 237 | rx_dma: ChannelAndRequest { |
| 240 | channel: rx_dma.map_into(), | 238 | channel: rx_dma.into(), |
| 241 | request: rx_dma_req, | 239 | request: rx_dma_req, |
| 242 | }, | 240 | }, |
| 243 | tx_dma: ChannelAndRequest { | 241 | tx_dma: ChannelAndRequest { |
| 244 | channel: tx_dma.map_into(), | 242 | channel: tx_dma.into(), |
| 245 | request: tx_dma_req, | 243 | request: tx_dma_req, |
| 246 | }, | 244 | }, |
| 247 | }, | 245 | }, |
| @@ -689,7 +687,7 @@ trait SealedInstance { | |||
| 689 | 687 | ||
| 690 | /// UCPD instance trait. | 688 | /// UCPD instance trait. |
| 691 | #[allow(private_bounds)] | 689 | #[allow(private_bounds)] |
| 692 | pub trait Instance: SealedInstance + RccPeripheral { | 690 | pub trait Instance: SealedInstance + PeripheralType + RccPeripheral { |
| 693 | /// Interrupt for this instance. | 691 | /// Interrupt for this instance. |
| 694 | type Interrupt: crate::interrupt::typelevel::Interrupt; | 692 | type Interrupt: crate::interrupt::typelevel::Interrupt; |
| 695 | } | 693 | } |
