diff options
| author | sakumisu <[email protected]> | 2024-04-07 13:40:37 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2024-04-07 16:53:53 +0800 |
| commit | 1eef5f3e35f420a1cb3b1d6b67e67502d7e84f22 (patch) | |
| tree | b23521374996b1a8640572152174021cf5dd03ac | |
| parent | 1dd45e3e5ab6a25c3cf5c86487eca18d1fc60e40 (diff) | |
add config index to select multi configs
| -rw-r--r-- | core/usbh_core.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/usbh_core.c b/core/usbh_core.c index b8ed028d..e328953d 100644 --- a/core/usbh_core.c +++ b/core/usbh_core.c @@ -394,6 +394,7 @@ int usbh_enumerate(struct usbh_hubport *hport) int dev_addr; uint16_t ep_mps; uint8_t config_value; + uint8_t config_index; int ret; hport->setup = &g_setup_buffer[hport->bus->busid][hport->parent->index - 1][hport->port - 1]; @@ -497,10 +498,15 @@ int usbh_enumerate(struct usbh_hubport *hport) ((struct usb_device_descriptor *)ep0_request_buffer[hport->bus->busid])->idProduct, ((struct usb_device_descriptor *)ep0_request_buffer[hport->bus->busid])->bcdDevice); + USB_LOG_INFO("The device has %d bNumConfigurations\r\n", ((struct usb_device_descriptor *)ep0_request_buffer[hport->bus->busid])->bNumConfigurations); + + config_index = 0; + USB_LOG_INFO("The device selects config %d\r\n", config_index); + /* Read the first 9 bytes of the config descriptor */ setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_STANDARD | USB_REQUEST_RECIPIENT_DEVICE; setup->bRequest = USB_REQUEST_GET_DESCRIPTOR; - setup->wValue = (uint16_t)((USB_DESCRIPTOR_TYPE_CONFIGURATION << 8) | 0); + setup->wValue = (uint16_t)((USB_DESCRIPTOR_TYPE_CONFIGURATION << 8) | config_index); setup->wIndex = 0; setup->wLength = USB_SIZEOF_CONFIG_DESC; @@ -523,7 +529,7 @@ int usbh_enumerate(struct usbh_hubport *hport) setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_STANDARD | USB_REQUEST_RECIPIENT_DEVICE; setup->bRequest = USB_REQUEST_GET_DESCRIPTOR; - setup->wValue = (uint16_t)((USB_DESCRIPTOR_TYPE_CONFIGURATION << 8) | 0); + setup->wValue = (uint16_t)((USB_DESCRIPTOR_TYPE_CONFIGURATION << 8) | config_index); setup->wIndex = 0; setup->wLength = wTotalLength; |
