update(port/dwc2): add mode check

Signed-off-by: sakumisu <1203593632@qq.com>
This commit is contained in:
sakumisu
2025-08-05 21:45:54 +08:00
parent 8cf12c1958
commit 2081360f2c
2 changed files with 12 additions and 2 deletions

View File

@@ -172,7 +172,12 @@ static inline void dwc2_set_mode(uint8_t busid, uint8_t mode)
USB_OTG_GLB->GUSBCFG |= USB_OTG_GUSBCFG_FDMOD;
}
usbd_dwc2_delay_ms(50);
while (1) {
if ((USB_OTG_GLB->GINTSTS & 0x1U) == USB_OTG_MODE_DEVICE) {
break;
}
usbd_dwc2_delay_ms(10);
}
}
static inline int dwc2_flush_rxfifo(uint8_t busid)

View File

@@ -135,7 +135,12 @@ static inline void dwc2_set_mode(struct usbh_bus *bus, uint8_t mode)
USB_OTG_GLB->GUSBCFG |= USB_OTG_GUSBCFG_FDMOD;
}
usb_osal_msleep(50);
while (1) {
if ((USB_OTG_GLB->GINTSTS & 0x1U) == USB_OTG_MODE_HOST) {
break;
}
usb_osal_msleep(10);
}
}
static inline int dwc2_flush_rxfifo(struct usbh_bus *bus)