Fix spurious EP0 completion.

This commit is contained in:
HiFiPhile
2024-05-05 22:01:09 +02:00
parent 8765568282
commit 02ec486610

View File

@@ -1081,22 +1081,26 @@ static void handle_epout_irq(uint8_t rhport) {
} else if (doepint & DOEPINT_OTEPSPR) { } else if (doepint & DOEPINT_OTEPSPR) {
epout->doepint = DOEPINT_OTEPSPR; epout->doepint = DOEPINT_OTEPSPR;
} else { } else {
// EP0 can only handle one packet if ((doepint & DOEPINT_STPKTRX) && (dwc2->gsnpsid >= DWC2_CORE_REV_3_00a)) {
if ((n == 0) && ep0_pending[TUSB_DIR_OUT]) { epout->doepint = DOEPINT_STPKTRX;
// Schedule another packet to be received.
edpt_schedule_packets(rhport, n, TUSB_DIR_OUT, 1, ep0_pending[TUSB_DIR_OUT]);
} else { } else {
if(dma_enabled(rhport)) { // EP0 can only handle one packet
// Fix packet length if ((n == 0) && ep0_pending[TUSB_DIR_OUT]) {
uint16_t remain = (epout->doeptsiz & DOEPTSIZ_XFRSIZ_Msk) >> DOEPTSIZ_XFRSIZ_Pos; // Schedule another packet to be received.
xfer->total_len -= remain; edpt_schedule_packets(rhport, n, TUSB_DIR_OUT, 1, ep0_pending[TUSB_DIR_OUT]);
// this is ZLP, so prepare EP0 for next setup } else {
if(n == 0 && xfer->total_len == 0) { if(dma_enabled(rhport)) {
dma_stpkt_rx(rhport); // Fix packet length
uint16_t remain = (epout->doeptsiz & DOEPTSIZ_XFRSIZ_Msk) >> DOEPTSIZ_XFRSIZ_Pos;
xfer->total_len -= remain;
// this is ZLP, so prepare EP0 for next setup
if(n == 0 && xfer->total_len == 0) {
dma_stpkt_rx(rhport);
}
} }
}
dcd_event_xfer_complete(rhport, n, xfer->total_len, XFER_RESULT_SUCCESS, true); dcd_event_xfer_complete(rhport, n, xfer->total_len, XFER_RESULT_SUCCESS, true);
}
} }
} }
} }