diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000000..3234cce49f --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,80 @@ +{ + "configurations": [ + { + "name": "Mac", + "includePath": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "defines": [], + "intelliSenseMode": "clang-x64", + "browse": { + "path": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + }, + "macFrameworkPath": [ + "/System/Library/Frameworks", + "/Library/Frameworks" + ] + }, + { + "name": "Linux", + "includePath": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "defines": [], + "intelliSenseMode": "clang-x64", + "browse": { + "path": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + }, + { + "name": "Win32", + "includePath": [ + "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/include/*", + "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/atlmfc/include/*", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/um", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/ucrt", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/winrt", + "${workspaceRoot}", + "${workspaceRoot}/include", + "${workspaceRoot}/components/drivers/include" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "intelliSenseMode": "msvc-x64", + "browse": { + "path": [ + "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/include/*", + "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/atlmfc/include/*", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/um", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/ucrt", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/winrt", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + } + ], + "version": 3 +} \ No newline at end of file diff --git a/components/drivers/include/drivers/usb_device.h b/components/drivers/include/drivers/usb_device.h index 48f407cc3d..caa171079b 100644 --- a/components/drivers/include/drivers/usb_device.h +++ b/components/drivers/include/drivers/usb_device.h @@ -140,6 +140,7 @@ struct udcd struct uendpoint ep0; uep0_stage_t stage; struct ep_id* ep_pool; + rt_uint8_t device_is_hs; }; typedef struct udcd* udcd_t; diff --git a/components/drivers/usb/usbdevice/class/winusb.c b/components/drivers/usb/usbdevice/class/winusb.c index 93a3a08e8b..82ac602c85 100644 --- a/components/drivers/usb/usbdevice/class/winusb.c +++ b/components/drivers/usb/usbdevice/class/winusb.c @@ -43,13 +43,14 @@ static struct udevice_descriptor dev_desc = //FS and HS needed static struct usb_qualifier_descriptor dev_qualifier = { - sizeof(dev_qualifier), - USB_DESC_TYPE_DEVICEQUALIFIER, - 0x0200, - 0x00, - 0x00, - 64, - 0x01, + sizeof(dev_qualifier), //bLength + USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType + 0x0200, //bcdUSB + 0xFF, //bDeviceClass + 0x00, //bDeviceSubClass + 0x00, //bDeviceProtocol + 64, //bMaxPacketSize0 + 0x01, //bNumConfigurations 0, }; @@ -81,14 +82,14 @@ struct winusb_descriptor _winusb_desc = USB_DESC_TYPE_ENDPOINT, USB_DYNAMIC | USB_DIR_OUT, USB_EP_ATTR_BULK, - 0x40, + USB_DYNAMIC, 0x00, /*endpoint descriptor*/ USB_DESC_LENGTH_ENDPOINT, USB_DESC_TYPE_ENDPOINT, USB_DYNAMIC | USB_DIR_IN, USB_EP_ATTR_BULK, - 0x40, + USB_DYNAMIC, 0x00, }; @@ -197,11 +198,13 @@ static struct ufunction_ops ops = RT_NULL, }; -static rt_err_t _winusb_descriptor_config(winusb_desc_t winusb, rt_uint8_t cintf_nr) +static rt_err_t _winusb_descriptor_config(winusb_desc_t winusb, rt_uint8_t cintf_nr, rt_uint8_t device_is_hs) { #ifdef RT_USB_DEVICE_COMPOSITE winusb->iad_desc.bFirstInterface = cintf_nr; #endif + winusb->ep_out_desc.wMaxPacketSize = device_is_hs ? 512 : 64; + winusb->ep_in_desc.wMaxPacketSize = device_is_hs ? 512 : 64; winusb_func_comp_id_desc.bFirstInterfaceNumber = cintf_nr; return RT_EOK; } @@ -293,7 +296,7 @@ ufunction_t rt_usbd_function_winusb_create(udevice_t device) rt_usbd_altsetting_config_descriptor(winusb_setting, &_winusb_desc, (rt_off_t)&((winusb_desc_t)0)->intf_desc); /* configure the hid interface descriptor */ - _winusb_descriptor_config(winusb_setting->desc, winusb_intf->intf_num); + _winusb_descriptor_config(winusb_setting->desc, winusb_intf->intf_num, device->dcd->device_is_hs); /* create endpoint */ winusb_desc = (winusb_desc_t)winusb_setting->desc; diff --git a/components/drivers/usb/usbdevice/core/core.c b/components/drivers/usb/usbdevice/core/core.c index 57111b6f4a..c8cd362bef 100644 --- a/components/drivers/usb/usbdevice/core/core.c +++ b/components/drivers/usb/usbdevice/core/core.c @@ -166,7 +166,7 @@ static rt_err_t _get_qualifier_descriptor(struct udevice* device, ureq_t setup) RT_ASSERT(device != RT_NULL); RT_ASSERT(setup != RT_NULL); - if(device->dev_qualifier) + if(device->dev_qualifier && device->dcd->device_is_hs) { /* send device qualifier descriptor to endpoint 0 */ rt_usbd_ep0_write(device, (rt_uint8_t*)device->dev_qualifier, @@ -210,6 +210,9 @@ static rt_err_t _get_descriptor(struct udevice* device, ureq_t setup) case USB_DESC_TYPE_DEVICEQUALIFIER: _get_qualifier_descriptor(device, setup); break; + case USB_DESC_TYPE_OTHERSPEED: + _get_config_descriptor(device, setup); + break; default: rt_kprintf("unsupported descriptor request\n"); rt_usbd_ep0_set_stall(device);