Skip to content

Commit

Permalink
NAK instead of ACK when clearing stall
Browse files Browse the repository at this point in the history
When clearing an endpoint halt condition, set endpoint status to NAK
instead of VALID.

When Windows receives more data than expected from an interrupt
endpoint, it resets the device and attempts to clear the endpoint halt
condition on that endpoint. On an IN endpoint, setting the status to
VALID will cause a retransmission of the offending packet, resulting in
a loop of attempted recovery operations.
  • Loading branch information
tlyu committed Nov 23, 2022
1 parent 4a3d515 commit ac14728
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,15 @@ static void usbd_ep_stall_clear (usb_dev *udev, uint8_t ep_addr)
udev->transc_in[ep_num].ep_stall = 0U;

/* clear endpoint stall status */
USBD_EP_TX_STAT_SET(ep_num, EPTX_VALID);
USBD_EP_TX_STAT_SET(ep_num, EPTX_NAK);
} else {
/* clear endpoint data toggle bit */
USBD_RX_DTG_CLEAR(ep_num);

udev->transc_out[ep_num].ep_stall = 0U;

/* clear endpoint stall status */
USBD_EP_RX_STAT_SET(ep_num, EPRX_VALID);
USBD_EP_RX_STAT_SET(ep_num, EPRX_NAK);
}
}

Expand Down

0 comments on commit ac14728

Please sign in to comment.