Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WCH569 triggers an OUT interrupt even if it NAKs the packet #13

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/wch-ch56x-lib/USBDevice/usb20.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,12 @@ __attribute__((interrupt("WCH-Interrupt-fast"))) void USBHS_IRQHandler(void)
{
if (ep0_passthrough_enabled)
{
// WCH569 will trigger an interrupt for a DATA packet, even if RX_CTRL was set to NAK
// discard this packet, as even though data has been received it shouldn't be taken into account
if (R8_UEP0_RX_CTRL & (UEP_R_RES_NAK | UEP_R_RES_STALL))
{
break;
}
usb2_out_transfer_handler(usb_dev_endp);
}
else
Expand All @@ -832,6 +838,12 @@ __attribute__((interrupt("WCH-Interrupt-fast"))) void USBHS_IRQHandler(void)
}
else if (usb_pid == PID_OUT)
{
// WCH569 will trigger an interrupt for a DATA packet, even if RX_CTRL was set to NAK
// discard this packet, as even though data has been received it shouldn't be taken into account
if (*usb2_get_rx_endpoint_ctrl_reg(usb_dev_endp) & (UEP_R_RES_NAK | UEP_R_RES_STALL))
{
break;
}
usb2_out_transfer_handler(usb_dev_endp);
}
break;
Expand Down
Loading