diff --git a/class/hub/usbh_hub.c b/class/hub/usbh_hub.c index c112e9cf..d91b9090 100644 --- a/class/hub/usbh_hub.c +++ b/class/hub/usbh_hub.c @@ -252,6 +252,16 @@ static void usbh_hub_thread_wakeup(struct usbh_hub *hub) usb_osal_sem_give(hub_event_wait); } +static void hub_int_complete_callback(void *arg, int nbytes) +{ + struct usbh_hub *hub = (struct usbh_hub *)arg; + + if (nbytes > 0) { + usbh_hub_thread_wakeup(hub); + usbh_submit_urb(&hub->inturb); + } +} + static int usbh_hub_connect(struct usbh_hubport *hport, uint8_t intf) { struct usbh_endpoint_cfg ep_cfg = { 0 }; @@ -316,10 +326,13 @@ static int usbh_hub_connect(struct usbh_hubport *hport, uint8_t intf) } } + hub->connected = true; snprintf(hport->config.intf[intf].devname, CONFIG_USBHOST_DEV_NAMELEN, DEV_FORMAT, hub->index); usbh_hub_register(hub); USB_LOG_INFO("Register HUB Class:%s\r\n", hport->config.intf[intf].devname); + usbh_int_urb_fill(&hub->inturb, hub->intin, hub->int_buffer, 1, 0, hub_int_complete_callback, hub); + usbh_submit_urb(&hub->inturb); return 0; } diff --git a/core/usbh_core.h b/core/usbh_core.h index 7271bda5..65856b0c 100644 --- a/core/usbh_core.h +++ b/core/usbh_core.h @@ -153,6 +153,7 @@ struct usbh_hub { uint8_t hub_addr; usbh_pipe_t intin; USB_MEM_ALIGNX uint8_t int_buffer[1]; + struct usbh_urb inturb; struct usb_hub_descriptor hub_desc; struct usbh_hubport child[CONFIG_USBHOST_EHPORTS]; struct usbh_hubport *parent;