move ep0 active into hub event

This commit is contained in:
sakumisu
2023-02-23 17:53:42 +08:00
parent 043c594cd8
commit 5e406f41c1
2 changed files with 8 additions and 10 deletions

View File

@@ -509,18 +509,22 @@ static void usbh_hub_events(struct usbh_hub *hub)
child->connected = true;
child->port = port + 1;
child->speed = speed;
USB_LOG_INFO("New %s device on Hub %u, Port %u connected\r\n", speed_table[speed], hub->index, port + 1);
/* Configure EP0 with the default maximum packet size */
usbh_hport_activate_ep0(child);
if (usbh_enumerate(child) < 0) {
/** release child sources */
usbh_hubport_release(child);
USB_LOG_ERR("Port %u enumerate fail\r\n", port + 1);
}
} else {
USB_LOG_ERR("Failed to enable port %u\r\n", port + 1);
child = &hub->child[port];
/** release child sources */
usbh_hubport_release(child);
USB_LOG_ERR("Failed to enable port %u\r\n", port + 1);
continue;
}
@@ -528,6 +532,7 @@ static void usbh_hub_events(struct usbh_hub *hub)
child = &hub->child[port];
/** release child sources */
usbh_hubport_release(child);
USB_LOG_INFO("Device on Hub %u, Port %u disconnected\r\n", hub->index, port + 1);
}
}
}

View File

@@ -419,9 +419,6 @@ int usbh_enumerate(struct usbh_hubport *hport)
hport->setup = &g_setup[hport->parent->index - 1][hport->port - 1];
setup = hport->setup;
/* Configure EP0 with the default maximum packet size */
usbh_hport_activate_ep0(hport);
/* Read the first 8 bytes of the device descriptor */
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_STANDARD | USB_REQUEST_RECIPIENT_DEVICE;
setup->bRequest = USB_REQUEST_GET_DESCRIPTOR;
@@ -629,10 +626,6 @@ int usbh_enumerate(struct usbh_hubport *hport)
}
errout:
if (ret < 0) {
hport->config.config_desc.bNumInterfaces = 0;
usbh_hport_deactivate_ep0(hport);
}
if (hport->raw_config_desc) {
usb_free(hport->raw_config_desc);
hport->raw_config_desc = NULL;