From effcee25b7cbb2bb42d4134d37dc8a9ec4635130 Mon Sep 17 00:00:00 2001 From: Dillon Min Date: Thu, 11 Mar 2021 17:29:41 +0800 Subject: 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 v1 -> v2: remove all tabs to space, to match rt-thread coding style --- components/drivers/usb/usbdevice/class/hid.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'components/drivers/usb/usbdevice/class/hid.c') diff --git a/components/drivers/usb/usbdevice/class/hid.c b/components/drivers/usb/usbdevice/class/hid.c index 52e50296a4..7dc344365d 100644 --- a/components/drivers/usb/usbdevice/class/hid.c +++ b/components/drivers/usb/usbdevice/class/hid.c @@ -17,7 +17,7 @@ #include "hid.h" #ifdef RT_USB_DEVICE_HID - +#define HID_INTF_STR_INDEX 7 struct hid_s { struct rt_device parent; @@ -318,8 +318,12 @@ const static struct uhid_comm_descriptor _hid_comm_desc = #else USB_HID_PROTOCOL_MOUSE, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */ #endif - 0, /* iInterface: Index of string descriptor */ - }, +#ifdef RT_USB_DEVICE_COMPOSITE + HID_INTF_STR_INDEX, /* iInterface: Index of string descriptor */ +#else + 0, +#endif + }, /* HID Descriptor */ { @@ -685,8 +689,11 @@ ufunction_t rt_usbd_function_hid_create(udevice_t device) RT_ASSERT(device != RT_NULL); /* set usb device string description */ +#ifdef RT_USB_DEVICE_COMPOSITE + rt_usbd_device_set_interface_string(device, HID_INTF_STR_INDEX, _ustring[2]); +#else rt_usbd_device_set_string(device, _ustring); - +#endif /* create a cdc function */ func = rt_usbd_function_new(device, &_dev_desc, &ops); -- cgit v1.3.1