diff options
| author | HiFiPhile <[email protected]> | 2026-05-22 18:04:44 +0200 |
|---|---|---|
| committer | HiFiPhile <[email protected]> | 2026-05-22 18:04:44 +0200 |
| commit | 66c5f6d45dc90f947261e2e4e62918c2ceb0ce11 (patch) | |
| tree | 2f6e52dd2429211c50dd954dec17a9373c22141c | |
| parent | d202477ebe0f8805bf88fcee4c0d5968d146dfbd (diff) | |
dcd/ch32fs: only enable EP0 ACK if no data stage, reduce race
Signed-off-by: HiFiPhile <[email protected]>
| -rw-r--r-- | src/portable/wch/dcd_ch32_usbfs.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/portable/wch/dcd_ch32_usbfs.c b/src/portable/wch/dcd_ch32_usbfs.c index 0727664c9..e4abbd824 100644 --- a/src/portable/wch/dcd_ch32_usbfs.c +++ b/src/portable/wch/dcd_ch32_usbfs.c @@ -186,9 +186,12 @@ void dcd_int_handler(uint8_t rhport) { case PID_SETUP: // setup clears stall EP_TX_CTRL(0) = USBFS_EP_T_RES_NAK; - EP_RX_CTRL(0) = USBFS_EP_R_RES_ACK; - data.ep0_tog = true; + + tusb_control_request_t const* setup = + (tusb_control_request_t const*) &data.buffer[0][TUSB_DIR_OUT][0]; + EP_RX_CTRL(0) = (setup->wLength == 0) ? USBFS_EP_R_RES_ACK : USBFS_EP_R_RES_NAK; + dcd_event_setup_received(rhport, &data.buffer[0][TUSB_DIR_OUT][0], true); break; } |
