@@ -30,7 +30,14 @@ pub unsafe fn on_interrupt<const MAX_EP_COUNT: usize>(r: Otg, state: &State<MAX_
3030 trace ! ( "irq" ) ;
3131
3232 let ints = r. gintsts ( ) . read ( ) ;
33- if ints. wkupint ( ) || ints. usbsusp ( ) || ints. usbrst ( ) || ints. enumdne ( ) || ints. otgint ( ) || ints. srqint ( ) {
33+ if ints. wkupint ( )
34+ || ints. usbsusp ( )
35+ || ints. usbrst ( )
36+ || ints. enumdne ( )
37+ || ints. otgint ( )
38+ || ints. srqint ( )
39+ || ints. sof ( )
40+ {
3441 // Mask interrupts and notify `Bus` to process them
3542 r. gintmsk ( ) . write ( |w| {
3643 w. set_iepint ( true ) ;
@@ -479,7 +486,7 @@ impl<'d, const MAX_EP_COUNT: usize> embassy_usb_driver::Driver<'d> for Driver<'d
479486 self . alloc_endpoint ( ep_type, ep_addr, max_packet_size, interval_ms)
480487 }
481488
482- fn start ( mut self , control_max_packet_size : u16 , _enable_sof_interrupts : bool ) -> ( Self :: Bus , Self :: ControlPipe ) {
489+ fn start ( mut self , control_max_packet_size : u16 , enable_sof_interrupts : bool ) -> ( Self :: Bus , Self :: ControlPipe ) {
483490 let ep_out = self
484491 . alloc_endpoint ( EndpointType :: Control , None , control_max_packet_size, 0 )
485492 . unwrap ( ) ;
@@ -500,6 +507,7 @@ impl<'d, const MAX_EP_COUNT: usize> embassy_usb_driver::Driver<'d> for Driver<'d
500507 ep_out : self . ep_out ,
501508 inited : false ,
502509 instance : self . instance ,
510+ enable_sof_interrupts : enable_sof_interrupts,
503511 } ,
504512 ControlPipe {
505513 max_packet_size : control_max_packet_size,
@@ -519,6 +527,7 @@ pub struct Bus<'d, const MAX_EP_COUNT: usize> {
519527 ep_out : [ Option < EndpointData > ; MAX_EP_COUNT ] ,
520528 instance : OtgInstance < ' d , MAX_EP_COUNT > ,
521529 inited : bool ,
530+ enable_sof_interrupts : bool ,
522531}
523532
524533impl < ' d , const MAX_EP_COUNT : usize > Bus < ' d , MAX_EP_COUNT > {
@@ -533,6 +542,7 @@ impl<'d, const MAX_EP_COUNT: usize> Bus<'d, MAX_EP_COUNT> {
533542 w. set_rxflvlm ( true ) ;
534543 w. set_srqim ( true ) ;
535544 w. set_otgint ( true ) ;
545+ w. set_sofm ( self . enable_sof_interrupts ) ;
536546 } ) ;
537547 }
538548
@@ -868,6 +878,13 @@ impl<'d, const MAX_EP_COUNT: usize> embassy_usb_driver::Bus for Bus<'d, MAX_EP_C
868878 return Poll :: Ready ( Event :: Resume ) ;
869879 }
870880
881+ if ints. sof ( ) {
882+ trace ! ( "sof" ) ;
883+ regs. gintsts ( ) . write ( |w| w. set_sof ( true ) ) ; // clear
884+ self . restore_irqs ( ) ;
885+ return Poll :: Ready ( Event :: SOF ) ;
886+ }
887+
871888 Poll :: Pending
872889 } )
873890 . await
0 commit comments