@@ -336,40 +336,46 @@ void dcd_int_handler(uint8_t rhport) {
336
336
uint8_t int_status = USBHSD -> INT_ST ;
337
337
338
338
if (int_flag & (USBHS_ISO_ACT_FLAG | USBHS_TRANSFER_FLAG )) {
339
- uint8_t const rx_token = int_status & MASK_UIS_TOKEN ;
340
- uint8_t const ep_num = int_status & MASK_UIS_ENDP ;
341
- tusb_dir_t const ep_dir = (rx_token == USBHS_TOKEN_PID_IN ) ? TUSB_DIR_IN : TUSB_DIR_OUT ;
342
- uint8_t const ep_addr = tu_edpt_addr (ep_num , ep_dir );
343
- xfer_ctl_t * xfer = XFER_CTL_BASE (ep_num , ep_dir );
344
-
345
- if (rx_token == USBHS_TOKEN_PID_OUT ) {
346
- uint16_t rx_len = USBHSD -> RX_LEN ;
339
+ uint8_t const token = int_status & MASK_UIS_TOKEN ;
340
+
341
+ if (token == USBHS_TOKEN_PID_SOF ) {
342
+ uint32_t frame_count = USBHSD -> FRAME_NO & USBHS_FRAME_NO_NUM_MASK ;
343
+ dcd_event_sof (rhport , frame_count , true);
344
+ }else {
345
+ uint8_t const ep_num = int_status & MASK_UIS_ENDP ;
346
+ tusb_dir_t const ep_dir = (token == USBHS_TOKEN_PID_IN ) ? TUSB_DIR_IN : TUSB_DIR_OUT ;
347
+ uint8_t const ep_addr = tu_edpt_addr (ep_num , ep_dir );
348
+ xfer_ctl_t * xfer = XFER_CTL_BASE (ep_num , ep_dir );
349
+
350
+ if (token == USBHS_TOKEN_PID_OUT ) {
351
+ uint16_t rx_len = USBHSD -> RX_LEN ;
352
+
353
+ if (ep_num == 0 ) {
354
+ memcpy (& xfer -> buffer [xfer -> queued_len ], ep0_buffer , rx_len );
355
+ }
347
356
348
- if (ep_num == 0 ) {
349
- memcpy (& xfer -> buffer [xfer -> queued_len ], ep0_buffer , rx_len );
357
+ xfer -> queued_len += rx_len ;
358
+ if (rx_len < xfer -> max_size ) {
359
+ xfer -> is_last_packet = true;
360
+ }
361
+ } else if (token == USBHS_TOKEN_PID_IN ) {
362
+ if (xfer -> is_iso && xfer -> is_last_packet ) {
363
+ /* Disable EP to avoid ISO_ACT interrupt generation */
364
+ USBHSD -> ENDP_CONFIG &= ~(USBHS_EP0_T_EN << ep_num );
365
+ } else {
366
+ // Do nothing, no need to update xfer->is_last_packet, it is already updated in xfer_data_packet
367
+ }
350
368
}
351
369
352
- xfer -> queued_len += rx_len ;
353
- if (rx_len < xfer -> max_size ) {
354
- xfer -> is_last_packet = true;
355
- }
356
- } else if (rx_token == USBHS_TOKEN_PID_IN ) {
357
- if (xfer -> is_iso && xfer -> is_last_packet ) {
358
- /* Disable EP to avoid ISO_ACT interrupt generation */
359
- USBHSD -> ENDP_CONFIG &= ~(USBHS_EP0_T_EN << ep_num );
360
- }else {
361
- // Do nothing, no need to update xfer->is_last_packet, it is already updated in xfer_data_packet
370
+ if (xfer -> is_last_packet == true) {
371
+ ep_set_response_and_toggle (ep_num , ep_dir , EP_RESPONSE_NAK );
372
+ dcd_event_xfer_complete (0 , ep_addr , xfer -> queued_len , XFER_RESULT_SUCCESS , true);
373
+ } else {
374
+ /* prepare next part of packet to xref */
375
+ xfer_data_packet (ep_num , ep_dir , xfer );
362
376
}
363
377
}
364
378
365
- if (xfer -> is_last_packet == true) {
366
- ep_set_response_and_toggle (ep_num , ep_dir , EP_RESPONSE_NAK );
367
- dcd_event_xfer_complete (0 , ep_addr , xfer -> queued_len , XFER_RESULT_SUCCESS , true);
368
- } else {
369
- /* prepare next part of packet to xref */
370
- xfer_data_packet (ep_num , ep_dir , xfer );
371
- }
372
-
373
379
USBHSD -> INT_FG = (int_flag & (USBHS_ISO_ACT_FLAG | USBHS_TRANSFER_FLAG )); /* Clear flag */
374
380
} else if (int_flag & USBHS_SETUP_FLAG ) {
375
381
ep_set_response_and_toggle (0 , TUSB_DIR_IN , EP_RESPONSE_NAK );
0 commit comments