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/usb/usb.rs | |
| parent | 9edf5b7f049f95742b60b041e4443967d8a6b708 (diff) | |
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-stm32/src/usb/usb.rs')
| -rw-r--r-- | embassy-stm32/src/usb/usb.rs | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/embassy-stm32/src/usb/usb.rs b/embassy-stm32/src/usb/usb.rs index 6682374d3..0b878915a 100644 --- a/embassy-stm32/src/usb/usb.rs +++ b/embassy-stm32/src/usb/usb.rs | |||
| @@ -5,7 +5,7 @@ use core::marker::PhantomData; | |||
| 5 | use core::sync::atomic::{AtomicBool, Ordering}; | 5 | use core::sync::atomic::{AtomicBool, Ordering}; |
| 6 | use core::task::Poll; | 6 | use core::task::Poll; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::into_ref; | 8 | use embassy_hal_internal::PeripheralType; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | use embassy_usb_driver as driver; | 10 | use embassy_usb_driver as driver; |
| 11 | use embassy_usb_driver::{ | 11 | use embassy_usb_driver::{ |
| @@ -16,7 +16,7 @@ use crate::pac::usb::regs; | |||
| 16 | use crate::pac::usb::vals::{EpType, Stat}; | 16 | use crate::pac::usb::vals::{EpType, Stat}; |
| 17 | use crate::pac::USBRAM; | 17 | use crate::pac::USBRAM; |
| 18 | use crate::rcc::RccPeripheral; | 18 | use crate::rcc::RccPeripheral; |
| 19 | use crate::{interrupt, Peripheral}; | 19 | use crate::{interrupt, Peri}; |
| 20 | 20 | ||
| 21 | /// Interrupt handler. | 21 | /// Interrupt handler. |
| 22 | pub struct InterruptHandler<T: Instance> { | 22 | pub struct InterruptHandler<T: Instance> { |
| @@ -290,13 +290,12 @@ impl<'d, T: Instance> Driver<'d, T> { | |||
| 290 | /// Create a new USB driver with start-of-frame (SOF) output. | 290 | /// Create a new USB driver with start-of-frame (SOF) output. |
| 291 | #[cfg(not(stm32l1))] | 291 | #[cfg(not(stm32l1))] |
| 292 | pub fn new_with_sof( | 292 | pub fn new_with_sof( |
| 293 | _usb: impl Peripheral<P = T> + 'd, | 293 | _usb: Peri<'d, T>, |
| 294 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 294 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 295 | dp: impl Peripheral<P = impl DpPin<T>> + 'd, | 295 | dp: Peri<'d, impl DpPin<T>>, |
| 296 | dm: impl Peripheral<P = impl DmPin<T>> + 'd, | 296 | dm: Peri<'d, impl DmPin<T>>, |
| 297 | sof: impl Peripheral<P = impl SofPin<T>> + 'd, | 297 | sof: Peri<'d, impl SofPin<T>>, |
| 298 | ) -> Self { | 298 | ) -> Self { |
| 299 | into_ref!(sof); | ||
| 300 | { | 299 | { |
| 301 | use crate::gpio::{AfType, OutputType, Speed}; | 300 | use crate::gpio::{AfType, OutputType, Speed}; |
| 302 | sof.set_as_af(sof.af_num(), AfType::output(OutputType::PushPull, Speed::VeryHigh)); | 301 | sof.set_as_af(sof.af_num(), AfType::output(OutputType::PushPull, Speed::VeryHigh)); |
| @@ -307,13 +306,11 @@ impl<'d, T: Instance> Driver<'d, T> { | |||
| 307 | 306 | ||
| 308 | /// Create a new USB driver. | 307 | /// Create a new USB driver. |
| 309 | pub fn new( | 308 | pub fn new( |
| 310 | _usb: impl Peripheral<P = T> + 'd, | 309 | _usb: Peri<'d, T>, |
| 311 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 310 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 312 | dp: impl Peripheral<P = impl DpPin<T>> + 'd, | 311 | dp: Peri<'d, impl DpPin<T>>, |
| 313 | dm: impl Peripheral<P = impl DmPin<T>> + 'd, | 312 | dm: Peri<'d, impl DmPin<T>>, |
| 314 | ) -> Self { | 313 | ) -> Self { |
| 315 | into_ref!(dp, dm); | ||
| 316 | |||
| 317 | super::common_init::<T>(); | 314 | super::common_init::<T>(); |
| 318 | 315 | ||
| 319 | let regs = T::regs(); | 316 | let regs = T::regs(); |
| @@ -1236,7 +1233,7 @@ trait SealedInstance { | |||
| 1236 | 1233 | ||
| 1237 | /// USB instance trait. | 1234 | /// USB instance trait. |
| 1238 | #[allow(private_bounds)] | 1235 | #[allow(private_bounds)] |
| 1239 | pub trait Instance: SealedInstance + RccPeripheral + 'static { | 1236 | pub trait Instance: SealedInstance + PeripheralType + RccPeripheral + 'static { |
| 1240 | /// Interrupt for this USB instance. | 1237 | /// Interrupt for this USB instance. |
| 1241 | type Interrupt: interrupt::typelevel::Interrupt; | 1238 | type Interrupt: interrupt::typelevel::Interrupt; |
| 1242 | } | 1239 | } |
