summaryrefslogtreecommitdiff
path: root/src/host
diff options
context:
space:
mode:
authorhathach <[email protected]>2023-07-21 19:06:36 +0700
committerhathach <[email protected]>2023-07-21 19:06:36 +0700
commitc122e9df73331fa60d1713c7cc4cf46251b0cd76 (patch)
tree00f4a6245e6357672cb42ab4ba0cf33c2892418e /src/host
parent14c98dd863a9cab55fc2981fb826f63eceed4b2d (diff)
implement hcd_edpt_abort_xfer() for EHCI, also move thing around a bit
Diffstat (limited to 'src/host')
-rw-r--r--src/host/hcd.h1
-rw-r--r--src/host/usbh.c10
-rw-r--r--src/host/usbh.h1
3 files changed, 10 insertions, 2 deletions
diff --git a/src/host/hcd.h b/src/host/hcd.h
index cbfffb349..90bfd79db 100644
--- a/src/host/hcd.h
+++ b/src/host/hcd.h
@@ -172,6 +172,7 @@ bool hcd_edpt_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_endpoint_t const
bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t * buffer, uint16_t buflen);
// Abort a queued transfer. Note: it can only abort transfer that has not been started
+// Return true if a queued transfer is aborted, false if there is no transfer to abort
bool hcd_edpt_abort_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr);
// Submit a special transfer to send 8-byte Setup Packet, when complete hcd_event_xfer_complete() must be invoked
diff --git a/src/host/usbh.c b/src/host/usbh.c
index bbf333d5f..15c48be47 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -718,9 +718,15 @@ bool tuh_edpt_abort_xfer(uint8_t daddr, uint8_t ep_addr) {
uint8_t const dir = tu_edpt_dir(ep_addr);
// skip if not busy
- if (!dev->ep_status[epnum][dir].busy) return true;
+ TU_VERIFY(dev->ep_status[epnum][dir].busy);
- return hcd_edpt_abort_xfer(dev->rhport, daddr, ep_addr);
+ bool const ret = hcd_edpt_abort_xfer(dev->rhport, daddr, ep_addr);
+ if (ret) {
+ // mark as ready if transfer is aborted
+ dev->ep_status[epnum][dir].busy = false;
+ }
+
+ return ret;
}
//--------------------------------------------------------------------+
diff --git a/src/host/usbh.h b/src/host/usbh.h
index d765f6744..0d56f40c9 100644
--- a/src/host/usbh.h
+++ b/src/host/usbh.h
@@ -176,6 +176,7 @@ bool tuh_edpt_xfer(tuh_xfer_t* xfer);
bool tuh_edpt_open(uint8_t daddr, tusb_desc_endpoint_t const * desc_ep);
// Abort a queued transfer. Note: it can only abort transfer that has not been started
+// Return true if a queued transfer is aborted, false if there is no transfer to abort
bool tuh_edpt_abort_xfer(uint8_t daddr, uint8_t ep_addr);
// Set Configuration (control transfer)