diff options
| author | Zixun LI <[email protected]> | 2026-07-29 14:27:59 +0200 |
|---|---|---|
| committer | Zixun LI <[email protected]> | 2026-07-29 15:56:12 +0200 |
| commit | 8f287a9e8ea6073f1970a4bf6993ade3a9db620d (patch) | |
| tree | 7404b73c6002d752333a76bb24ccdb47988877b9 /src/device/usbd.c | |
| parent | 529fd0532ae6eeb13b1ac8dc87381c6560e3a995 (diff) | |
raw_gadget: fix MSC recovery after endpoint haltraw_gadget_review
Allow opt-in DCDs to queue transfers behind a halted endpoint without changing hardware DCD behavior.
Retry dummy_hcd's transient EP_SET_HALT failure, queue MSC BOT status and recovery requests behind the halt, and clean up Raw Gadget endpoint workers across bus reset.
Signed-off-by: Zixun LI <[email protected]>
Diffstat (limited to 'src/device/usbd.c')
| -rw-r--r-- | src/device/usbd.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c index 5471e132d..5b123bbb4 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -1654,7 +1654,12 @@ void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr) { // only stalled if currently cleared TU_LOG_USBD(" Stall EP %02X\r\n", ep_addr); dcd_edpt_stall(rhport, ep_addr); + #if CFG_TUD_ENDPOINT_XFER_BEHIND_HALT + _usbd_dev.ep_status[epnum][dir] &= (uint8_t) ~(TU_EDPT_STATE_BUSY | TU_EDPT_STATE_CLAIMED); + _usbd_dev.ep_status[epnum][dir] |= TU_EDPT_STATE_STALLED; + #else _usbd_dev.ep_status[epnum][dir] |= (TU_EDPT_STATE_STALLED | TU_EDPT_STATE_BUSY); + #endif } void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) { @@ -1664,6 +1669,10 @@ void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) { uint8_t const dir = tu_edpt_dir(ep_addr); TU_LOG_USBD(" Clear Stall EP %02X\r\n", ep_addr); + #if CFG_TUD_ENDPOINT_XFER_BEHIND_HALT + dcd_edpt_clear_stall(rhport, ep_addr); + _usbd_dev.ep_status[epnum][dir] &= (uint8_t) ~TU_EDPT_STATE_STALLED; + #else const bool was_stalled = (_usbd_dev.ep_status[epnum][dir] & TU_EDPT_STATE_STALLED) != 0; dcd_edpt_clear_stall(rhport, ep_addr); // Clear STALLED|BUSY unconditionally (long-standing behavior; some classes, e.g. audio's @@ -1678,6 +1687,7 @@ void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) { clear_mask |= TU_EDPT_STATE_CLAIMED; } _usbd_dev.ep_status[epnum][dir] &= (uint8_t) ~clear_mask; + #endif } bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr) { |
