Browse Source

Fix receiving of short packet data (ep out)

Jan Dümpelmann 5 years ago
parent
commit
9e35ef73f7
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/portable/st/synopsys/dcd_synopsys.c

+ 6 - 0
src/portable/st/synopsys/dcd_synopsys.c

@@ -576,6 +576,12 @@ static void handle_rxflvl_ints(USB_OTG_OUTEndpointTypeDef * out_ep) {
 
         // Increment pointer to xfer data
         xfer->buffer += bcnt;
+
+        // Truncate transfer length in case of short packet
+        if(bcnt < xfer->max_size){
+          xfer->total_len -= (out_ep[epnum].DOEPTSIZ & USB_OTG_DOEPTSIZ_XFRSIZ_Msk) >> USB_OTG_DOEPTSIZ_XFRSIZ_Pos;
+          if(epnum == 0) xfer->total_len -= ep0_pending[TUSB_DIR_OUT];
+        }
       }
       break;
     case 0x03: // Out packet done (Interrupt)