Przeglądaj źródła

feat(core/usbh_core): support custom config index

Signed-off-by: sakumisu <1203593632@qq.com>
sakumisu 1 miesiąc temu
rodzic
commit
e10b44f64e
2 zmienionych plików z 7 dodań i 1 usunięć
  1. 6 1
      core/usbh_core.c
  2. 1 0
      core/usbh_core.h

+ 6 - 1
core/usbh_core.c

@@ -418,7 +418,7 @@ int usbh_enumerate(struct usbh_hubport *hport)
 
 
     USB_LOG_INFO("The device has %d bNumConfigurations\r\n", ((struct usb_device_descriptor *)ep0_request_buffer[hport->bus->busid])->bNumConfigurations);
     USB_LOG_INFO("The device has %d bNumConfigurations\r\n", ((struct usb_device_descriptor *)ep0_request_buffer[hport->bus->busid])->bNumConfigurations);
 
 
-    config_index = 0;
+    config_index = usbh_get_hport_active_config_index(hport);
     USB_LOG_DBG("The device selects config %d\r\n", config_index);
     USB_LOG_DBG("The device selects config %d\r\n", config_index);
 
 
     /* Read the first 9 bytes of the config descriptor */
     /* Read the first 9 bytes of the config descriptor */
@@ -1208,3 +1208,8 @@ int lsusb(int argc, char **argv)
 
 
     return 0;
     return 0;
 }
 }
+
+__WEAK uint8_t usbh_get_hport_active_config_index(struct usbh_hubport *hport)
+{
+    return 0; // Default to configuration index 0
+}

+ 1 - 0
core/usbh_core.h

@@ -313,6 +313,7 @@ int usbh_initialize(uint8_t busid, uintptr_t reg_base, usbh_event_handler_t even
 int usbh_deinitialize(uint8_t busid);
 int usbh_deinitialize(uint8_t busid);
 void *usbh_find_class_instance(const char *devname);
 void *usbh_find_class_instance(const char *devname);
 struct usbh_hubport *usbh_find_hubport(uint8_t busid, uint8_t hub_index, uint8_t hub_port);
 struct usbh_hubport *usbh_find_hubport(uint8_t busid, uint8_t hub_index, uint8_t hub_port);
+uint8_t usbh_get_hport_active_config_index(struct usbh_hubport *hport);
 
 
 int lsusb(int argc, char **argv);
 int lsusb(int argc, char **argv);