update(port): add USB_ASSERT_MSG for ep num check

Signed-off-by: sakumisu <1203593632@qq.com>
This commit is contained in:
sakumisu
2025-05-09 21:44:51 +08:00
parent 8393ed986a
commit 5253d5aa6b
5 changed files with 27 additions and 49 deletions

View File

@@ -525,10 +525,7 @@ int usbd_ep_open(uint8_t busid, const struct usb_endpoint_descriptor *ep)
{
uint8_t ep_idx = USB_EP_GET_IDX(ep->bEndpointAddress);
/* Must not exceed max endpoint number */
if (ep_idx >= CONFIG_USBDEV_EP_NUM) {
return -1;
}
USB_ASSERT_MSG(ep_idx < CONFIG_USBDEV_EP_NUM, "Ep addr %02x overflow", ep->bEndpointAddress);
chipidea_edpt_open(busid, ep->bEndpointAddress, USB_GET_ENDPOINT_TYPE(ep->bmAttributes), ep->wMaxPacketSize);
@@ -666,17 +663,10 @@ void USBD_IRQHandler(uint8_t busid)
if (int_status & intr_usb) {
uint32_t const edpt_complete = USB_OTG_DEV->ENDPTCOMPLETE;
USB_OTG_DEV->ENDPTCOMPLETE = edpt_complete;
uint32_t edpt_setup_status = USB_OTG_DEV->ENDPTSETUPSTAT;
if (edpt_setup_status) {
/*------------- Set up Received -------------*/
USB_OTG_DEV->ENDPTSETUPSTAT = edpt_setup_status;
dcd_qhd_t *qhd0 = chipidea_qhd_get(busid, 0);
usbd_event_ep0_setup_complete_handler(busid, (uint8_t *)&qhd0->setup_request);
}
if (edpt_complete) {
USB_OTG_DEV->ENDPTCOMPLETE = edpt_complete;
for (uint8_t ep_idx = 0; ep_idx < (CONFIG_USBDEV_EP_NUM * 2); ep_idx++) {
if (edpt_complete & (1 << ep_idx2bit(ep_idx))) {
transfer_len = 0;
@@ -714,5 +704,12 @@ void USBD_IRQHandler(uint8_t busid)
}
}
}
if (edpt_setup_status) {
/*------------- Set up Received -------------*/
USB_OTG_DEV->ENDPTSETUPSTAT = edpt_setup_status;
dcd_qhd_t *qhd0 = chipidea_qhd_get(busid, 0);
usbd_event_ep0_setup_complete_handler(busid, (uint8_t *)&qhd0->setup_request);
}
}
}