diff options
| author | sakumisu <[email protected]> | 2026-06-30 21:23:08 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2026-06-30 21:23:08 +0800 |
| commit | bec3b36fb8bce1f282964bfd4580a788f3571088 (patch) | |
| tree | a1236624d72e0bdcb670cbf603adf57a50b0838e | |
| parent | 35f4514b8b4139db725a5cf9ab82a62a0d8ca50a (diff) | |
fix(port/chipidea): using sutw semaphore by isr handler for setup
Signed-off-by: sakumisu <[email protected]>
| -rw-r--r-- | port/chipidea/usb_dc_chipidea.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/port/chipidea/usb_dc_chipidea.c b/port/chipidea/usb_dc_chipidea.c index d8122ece..06b9a3d8 100644 --- a/port/chipidea/usb_dc_chipidea.c +++ b/port/chipidea/usb_dc_chipidea.c @@ -133,6 +133,8 @@ static dcd_data_t *g_dcd_data[CONFIG_USBDEV_MAX_BUS] = { #endif }; +static uint8_t _setup_data[8]; + /* Index to bit position in register */ static inline uint8_t ep_idx2bit(uint8_t ep_idx) { @@ -660,6 +662,7 @@ void USBD_IRQHandler(uint8_t busid) memset(g_chipidea_udc[busid].out_ep, 0, sizeof(struct chipidea_ep_state) * CONFIG_USBDEV_EP_NUM); usbd_event_reset_handler(busid); chipidea_bus_reset(busid, g_chipidea_udc[busid].in_ep[0].ep_mps); + return; } if (int_status & intr_suspend) { @@ -734,7 +737,12 @@ void USBD_IRQHandler(uint8_t busid) /*------------- 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); + do { + USB_OTG_DEV->USBCMD |= USB_USBCMD_SUTW_MASK; + memcpy(_setup_data, (uint8_t *)(&qhd0->setup_request), 8); + } while (!USB_USBCMD_SUTW_GET(USB_OTG_DEV->USBCMD)); + USB_OTG_DEV->USBCMD &= ~USB_USBCMD_SUTW_MASK; + usbd_event_ep0_setup_complete_handler(busid, _setup_data); } } }
\ No newline at end of file |
