mirror of
https://github.com/sakumisu/CherryUSB.git
synced 2025-10-16 06:07:16 +08:00
add reset port timeout check for dwc2
This commit is contained in:
@@ -369,6 +369,7 @@ static void dwc2_halt(struct usbh_bus *bus, uint8_t ch_num)
|
||||
static int usbh_reset_port(struct usbh_bus *bus, const uint8_t port)
|
||||
{
|
||||
__IO uint32_t hprt0 = 0U;
|
||||
volatile uint32_t timeout = 0;
|
||||
|
||||
hprt0 = USB_OTG_HPRT;
|
||||
|
||||
@@ -384,6 +385,11 @@ static int usbh_reset_port(struct usbh_bus *bus, const uint8_t port)
|
||||
if (!(USB_OTG_HPRT & USB_OTG_HPRT_PCSTS)) {
|
||||
return -USB_ERR_NOTCONN; /* Port not connected */
|
||||
}
|
||||
timeout++;
|
||||
if (timeout > 10) {
|
||||
USB_LOG_ERR("Reset port timeout\r\n");
|
||||
return -USB_ERR_TIMEOUT;
|
||||
}
|
||||
usb_osal_msleep(10U);
|
||||
}
|
||||
return 0;
|
||||
@@ -907,7 +913,7 @@ int usbh_roothub_control(struct usbh_bus *bus, struct usb_setup_packet *setup, u
|
||||
dwc2_drivebus(bus, 1);
|
||||
break;
|
||||
case HUB_PORT_FEATURE_RESET:
|
||||
usbh_reset_port(bus, port);
|
||||
return usbh_reset_port(bus, port);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -1119,7 +1119,7 @@ int usbh_roothub_control(struct usbh_bus *bus, struct usb_setup_packet *setup, u
|
||||
EHCI_HCOR->portsc[port - 1] |= EHCI_PORTSC_PP;
|
||||
break;
|
||||
case HUB_PORT_FEATURE_RESET:
|
||||
usbh_reset_port(bus, port);
|
||||
return usbh_reset_port(bus, port);
|
||||
#ifdef CONFIG_USB_EHCI_WITH_OHCI
|
||||
if (!(EHCI_HCOR->portsc[port - 1] & EHCI_PORTSC_PE)) {
|
||||
EHCI_HCOR->portsc[port - 1] |= EHCI_PORTSC_OWNER;
|
||||
|
Reference in New Issue
Block a user