Merge pull request #3964 from elagil/sof_out_usb

Add optional USB driver SOF output
This commit is contained in:
Dario Nieuwenhuis 2025-03-16 21:10:27 +00:00 committed by GitHub
commit 86572bf009
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View File

@ -876,6 +876,7 @@ fn main() {
(("ltdc", "B7"), quote!(crate::ltdc::B7Pin)),
(("usb", "DP"), quote!(crate::usb::DpPin)),
(("usb", "DM"), quote!(crate::usb::DmPin)),
(("usb", "SOF"), quote!(crate::usb::SofPin)),
(("otg", "DP"), quote!(crate::usb::DpPin)),
(("otg", "DM"), quote!(crate::usb::DmPin)),
(("otg", "ULPI_CK"), quote!(crate::usb::UlpiClkPin)),

View File

@ -287,6 +287,24 @@ pub struct Driver<'d, T: Instance> {
}
impl<'d, T: Instance> Driver<'d, T> {
/// Create a new USB driver with start-of-frame (SOF) output.
#[cfg(not(stm32l1))]
pub fn new_with_sof(
_usb: impl Peripheral<P = T> + 'd,
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
dp: impl Peripheral<P = impl DpPin<T>> + 'd,
dm: impl Peripheral<P = impl DmPin<T>> + 'd,
sof: impl Peripheral<P = impl SofPin<T>> + 'd,
) -> Self {
into_ref!(sof);
{
use crate::gpio::{AfType, OutputType, Speed};
sof.set_as_af(sof.af_num(), AfType::output(OutputType::PushPull, Speed::VeryHigh));
}
Self::new(_usb, _irq, dp, dm)
}
/// Create a new USB driver.
pub fn new(
_usb: impl Peripheral<P = T> + 'd,
@ -1216,6 +1234,7 @@ pub trait Instance: SealedInstance + RccPeripheral + 'static {
// Internal PHY pins
pin_trait!(DpPin, Instance);
pin_trait!(DmPin, Instance);
pin_trait!(SofPin, Instance);
foreach_interrupt!(
($inst:ident, usb, $block:ident, LP, $irq:ident) => {