Skip to content

Commit 0109ffb

Browse files
committed
fix abort transfer does not release endpoint, also reset state if it is control transfer
1 parent b3c7fe1 commit 0109ffb

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/host/usbh.c

+15-7
Original file line numberDiff line numberDiff line change
@@ -738,19 +738,27 @@ bool tuh_edpt_abort_xfer(uint8_t daddr, uint8_t ep_addr) {
738738
usbh_device_t* dev = get_device(daddr);
739739
TU_VERIFY(dev);
740740

741+
TU_LOG_USBH("[%u] Aborted transfer on EP %02X\r\n", daddr, ep_addr);
742+
741743
uint8_t const epnum = tu_edpt_number(ep_addr);
742744
uint8_t const dir = tu_edpt_dir(ep_addr);
743745

744-
// skip if not busy
745-
TU_VERIFY(dev->ep_status[epnum][dir].busy);
746-
747-
bool const ret = hcd_edpt_abort_xfer(dev->rhport, daddr, ep_addr);
748-
if (ret) {
749-
// mark as ready if transfer is aborted
746+
if ( epnum == 0 ) {
747+
// control transfer: only 1 control at a time, check if we are aborting the current one
748+
TU_VERIFY(daddr == _ctrl_xfer.daddr && _ctrl_xfer.stage != CONTROL_STAGE_IDLE);
749+
TU_VERIFY(hcd_edpt_abort_xfer(dev->rhport, daddr, ep_addr));
750+
// reset control transfer state to idle
751+
_set_control_xfer_stage(CONTROL_STAGE_IDLE);
752+
} else {
753+
// non-control skip if not busy
754+
TU_VERIFY(dev->ep_status[epnum][dir].busy);
755+
TU_VERIFY(hcd_edpt_abort_xfer(dev->rhport, daddr, ep_addr));
756+
// mark as ready and release endpoint if transfer is aborted
750757
dev->ep_status[epnum][dir].busy = false;
758+
usbh_edpt_release(daddr, ep_addr);
751759
}
752760

753-
return ret;
761+
return true;
754762
}
755763

756764
//--------------------------------------------------------------------+

0 commit comments

Comments
 (0)