diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-03-16 21:10:27 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-03-16 21:10:27 +0000 |
| commit | 86572bf009c341ea7dc64f478b970175ea6dbb2f (patch) | |
| tree | be19aac2f3974a150a46715c78041f7c195d3bae /embassy-stm32/src/usb | |
| parent | 2e004ccf9ee68d09a70c04c8c62c0558252af575 (diff) | |
| parent | 63f7a5da09b150de5077c02c5b1394af4d012676 (diff) | |
Merge pull request #3964 from elagil/sof_out_usb
Add optional USB driver SOF output
Diffstat (limited to 'embassy-stm32/src/usb')
| -rw-r--r-- | embassy-stm32/src/usb/usb.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/embassy-stm32/src/usb/usb.rs b/embassy-stm32/src/usb/usb.rs index 8dabfc78f..24983cf3c 100644 --- a/embassy-stm32/src/usb/usb.rs +++ b/embassy-stm32/src/usb/usb.rs | |||
| @@ -287,6 +287,24 @@ pub struct Driver<'d, T: Instance> { | |||
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | impl<'d, T: Instance> Driver<'d, T> { | 289 | impl<'d, T: Instance> Driver<'d, T> { |
| 290 | /// Create a new USB driver with start-of-frame (SOF) output. | ||
| 291 | #[cfg(not(stm32l1))] | ||
| 292 | pub fn new_with_sof( | ||
| 293 | _usb: impl Peripheral<P = T> + 'd, | ||
| 294 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | ||
| 295 | dp: impl Peripheral<P = impl DpPin<T>> + 'd, | ||
| 296 | dm: impl Peripheral<P = impl DmPin<T>> + 'd, | ||
| 297 | sof: impl Peripheral<P = impl SofPin<T>> + 'd, | ||
| 298 | ) -> Self { | ||
| 299 | into_ref!(sof); | ||
| 300 | { | ||
| 301 | use crate::gpio::{AfType, OutputType, Speed}; | ||
| 302 | sof.set_as_af(sof.af_num(), AfType::output(OutputType::PushPull, Speed::VeryHigh)); | ||
| 303 | } | ||
| 304 | |||
| 305 | Self::new(_usb, _irq, dp, dm) | ||
| 306 | } | ||
| 307 | |||
| 290 | /// Create a new USB driver. | 308 | /// Create a new USB driver. |
| 291 | pub fn new( | 309 | pub fn new( |
| 292 | _usb: impl Peripheral<P = T> + 'd, | 310 | _usb: impl Peripheral<P = T> + 'd, |
| @@ -1216,6 +1234,7 @@ pub trait Instance: SealedInstance + RccPeripheral + 'static { | |||
| 1216 | // Internal PHY pins | 1234 | // Internal PHY pins |
| 1217 | pin_trait!(DpPin, Instance); | 1235 | pin_trait!(DpPin, Instance); |
| 1218 | pin_trait!(DmPin, Instance); | 1236 | pin_trait!(DmPin, Instance); |
| 1237 | pin_trait!(SofPin, Instance); | ||
| 1219 | 1238 | ||
| 1220 | foreach_interrupt!( | 1239 | foreach_interrupt!( |
| 1221 | ($inst:ident, usb, $block:ident, LP, $irq:ident) => { | 1240 | ($inst:ident, usb, $block:ident, LP, $irq:ident) => { |
