Skip to content

Commit

Permalink
WCH569 triggers an OUT interrupt even if it NAKs the packet
Browse files Browse the repository at this point in the history
  • Loading branch information
kauwua committed Jun 9, 2024
1 parent 797f465 commit 25ea723
Showing 1 changed file with 12 additions and 0 deletions.
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

0 comments on commit 25ea723

Please sign in to comment.