feat(port): implement usbd_ep_is_stalled api

This commit is contained in:
sakumisu
2024-07-08 21:50:00 +08:00
parent 4f3a3f496e
commit 7fab3c29f0
5 changed files with 83 additions and 8 deletions

View File

@@ -255,8 +255,20 @@ int usbd_ep_clear_stall(uint8_t busid, const uint8_t ep)
int usbd_ep_is_stalled(uint8_t busid, const uint8_t ep, uint8_t *stalled)
{
uint8_t ep_idx = USB_EP_GET_IDX(ep);
if (USB_EP_DIR_IS_OUT(ep)) {
if (PCD_GET_EP_RX_STATUS(USB, ep_idx) & USB_EP_RX_STALL) {
*stalled = 1;
} else {
*stalled = 0;
}
} else {
if (PCD_GET_EP_TX_STATUS(USB, ep_idx) & USB_EP_TX_STALL) {
*stalled = 1;
} else {
*stalled = 0;
}
}
return 0;
}