diff options
| author | Dillon Min <[email protected]> | 2021-03-11 17:29:41 +0800 |
|---|---|---|
| committer | Dillon Min <[email protected]> | 2021-03-11 17:29:41 +0800 |
| commit | effcee25b7cbb2bb42d4134d37dc8a9ec4635130 (patch) | |
| tree | a9d124ef0ee38641b48f12d33de65ff3c4b3f482 /components/drivers/usb/usbdevice/core | |
| parent | 0beaeeef456e5e12dd8c7d76ebd8aea2e83973d3 (diff) | |
component: driver: usb: Add usb interface string(iInterface) setting
To make compositive usb device string more reansonable, not all devices
just show same "RTT Composite Device" on windows device manager.
add a interface rt_usbd_device_set_interface_string to set respective
interface string.
Signed-off-by: Dillon Min <[email protected]>
v1 -> v2: remove all tabs to space, to match rt-thread coding style
Diffstat (limited to 'components/drivers/usb/usbdevice/core')
| -rw-r--r-- | components/drivers/usb/usbdevice/core/usbdevice_core.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/components/drivers/usb/usbdevice/core/usbdevice_core.c b/components/drivers/usb/usbdevice/core/usbdevice_core.c index ef569d7bf2..063d5781bc 100644 --- a/components/drivers/usb/usbdevice/core/usbdevice_core.c +++ b/components/drivers/usb/usbdevice/core/usbdevice_core.c @@ -123,12 +123,18 @@ static rt_err_t _get_string_descriptor(struct udevice* device, ureq_t setup) } else { - len = rt_strlen(device->str[index]); + if(index < 5) + len = rt_strlen(device->str[index]); + else + len = rt_strlen(device->str_intf[index]); str_desc.bLength = len*2 + 2; for(i=0; i<len; i++) { - str_desc.String[i*2] = device->str[index][i]; + if(index < 5) + str_desc.String[i*2] = device->str[index][i]; + else + str_desc.String[i*2] = device->str_intf[index][i]; str_desc.String[i*2 + 1] = 0; } } @@ -1044,6 +1050,28 @@ rt_err_t rt_usbd_device_set_string(udevice_t device, const char** ustring) return RT_EOK; } +/** + * This function will set usb device interface string description. + * + * @param device the usb device object. + * @param index of interface string + * @param string pointer to interface string description. + * + * @return RT_EOK. + */ +rt_err_t rt_usbd_device_set_interface_string(udevice_t device, int index, const char* string) +{ + /* parameter check */ + RT_ASSERT(device != RT_NULL); + RT_ASSERT(string != RT_NULL); + RT_ASSERT(index < MAX_INTF_STR); + + /* set string descriptor array to the device object */ + device->str_intf[index] = string; + + return RT_EOK; +} + rt_err_t rt_usbd_device_set_os_comp_id_desc(udevice_t device, usb_os_comp_id_desc_t os_comp_id_desc) { /* parameter check */ |
