@@ -292,6 +292,26 @@ pub struct Driver<'d, T: Instance> {
292292}
293293
294294impl < ' d , T : Instance > Driver < ' d , T > {
295+ /// Create a new USB driver with start-of-frame (SOF) output.
296+ pub fn new_with_sof (
297+ _usb : impl Peripheral < P = T > + ' d ,
298+ _irq : impl interrupt:: typelevel:: Binding < T :: Interrupt , InterruptHandler < T > > + ' d ,
299+ dp : impl Peripheral < P = impl DpPin < T > > + ' d ,
300+ dm : impl Peripheral < P = impl DmPin < T > > + ' d ,
301+ sof : impl Peripheral < P = impl SofPin < T > > + ' d ,
302+ ) -> Self {
303+ into_ref ! ( sof) ;
304+ #[ cfg( not( stm32l1) ) ]
305+ {
306+ use crate :: gpio:: { AfType , OutputType , Speed } ;
307+ sof. set_as_af ( sof. af_num ( ) , AfType :: output ( OutputType :: PushPull , Speed :: VeryHigh ) ) ;
308+ }
309+ #[ cfg( stm32l1) ]
310+ let _ = sof; // suppress "unused" warning.
311+
312+ Self :: new ( _usb, _irq, dp, dm)
313+ }
314+
295315 /// Create a new USB driver.
296316 pub fn new (
297317 _usb : impl Peripheral < P = T > + ' d ,
@@ -1221,6 +1241,7 @@ pub trait Instance: SealedInstance + RccPeripheral + 'static {
12211241// Internal PHY pins
12221242pin_trait ! ( DpPin , Instance ) ;
12231243pin_trait ! ( DmPin , Instance ) ;
1244+ pin_trait ! ( SofPin , Instance ) ;
12241245
12251246foreach_interrupt ! (
12261247 ( $inst: ident, usb, $block: ident, LP , $irq: ident) => {
0 commit comments