diff options
| author | MiraculousConch <[email protected]> | 2017-11-28 03:02:48 +0800 |
|---|---|---|
| committer | MiraculousConch <[email protected]> | 2017-11-28 03:02:48 +0800 |
| commit | d40d5355b8d64097259be35fef8b91f0cbda713c (patch) | |
| tree | fc90c3dca9536e5a42f3e7cd3dcf7742e30e7d3c /components/drivers/usb | |
| parent | 3044461ba22dcd926a03d1088c4fe44ce18d38b0 (diff) | |
[Components][Drivers][USB]WinUSB And Core update
协议栈增加允许class在windows环境下枚举时向系统注册附加属性。并在winusb class中提供范例(注册GUID信息)
Diffstat (limited to 'components/drivers/usb')
| -rw-r--r-- | components/drivers/usb/usbdevice/class/winusb.c | 19 | ||||
| -rw-r--r-- | components/drivers/usb/usbdevice/class/winusb.h | 14 | ||||
| -rw-r--r-- | components/drivers/usb/usbdevice/core/core.c | 9 |
3 files changed, 27 insertions, 15 deletions
diff --git a/components/drivers/usb/usbdevice/class/winusb.c b/components/drivers/usb/usbdevice/class/winusb.c index 4da9333789..0ce0d88064 100644 --- a/components/drivers/usb/usbdevice/class/winusb.c +++ b/components/drivers/usb/usbdevice/class/winusb.c @@ -25,7 +25,7 @@ static struct udevice_descriptor dev_desc = USB_DESC_LENGTH_DEVICE, //bLength; USB_DESC_TYPE_DEVICE, //type; USB_BCD_VERSION, //bcdUSB; - 0x00, //bDeviceClass; + 0x00, //bDeviceClass; 0x00, //bDeviceSubClass; 0x00, //bDeviceProtocol; 0x40, //bMaxPacketSize0; @@ -100,6 +100,11 @@ const static char* _ustring[] = "Interface", USB_STRING_OS//must be }; +struct usb_os_proerty winusb_proerty[] = +{ + USB_OS_PROERTY_DESC(USB_OS_PROERTY_TYPE_REG_SZ,"DeviceInterfaceGUID","{6860DC3C-C05F-4807-8807-1CA861CC1D66}"), +}; + struct usb_os_function_comp_id_descriptor winusb_func_comp_id_desc = { .bFirstInterfaceNumber = USB_DYNAMIC, @@ -127,6 +132,18 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size) } static rt_err_t _interface_handler(ufunction_t func, ureq_t setup) { + switch(setup->bRequest) + { + case 'A': + switch(setup->wIndex) + { + case 0x05: + usbd_os_proerty_descriptor_send(func,setup,winusb_proerty,sizeof(winusb_proerty)/sizeof(winusb_proerty[0])); + break; + } + break; + } + return RT_EOK; } static rt_err_t _function_enable(ufunction_t func) diff --git a/components/drivers/usb/usbdevice/class/winusb.h b/components/drivers/usb/usbdevice/class/winusb.h index 514dd0a184..86aa7f413c 100644 --- a/components/drivers/usb/usbdevice/class/winusb.h +++ b/components/drivers/usb/usbdevice/class/winusb.h @@ -20,18 +20,4 @@ struct winusb_descriptor }; typedef struct winusb_descriptor* winusb_desc_t; - -struct winusb_os_header_properties_descriptor -{ - rt_uint32_t dwLength; - rt_uint16_t bcdVersion; - rt_uint16_t wIndex; - rt_uint16_t bCount; -}; -typedef struct winusb_os_header_properties_descriptor * winusb_os_header_prop_desc_t; - - - - - #endif diff --git a/components/drivers/usb/usbdevice/core/core.c b/components/drivers/usb/usbdevice/core/core.c index 4786d7db32..3c0d8f1e26 100644 --- a/components/drivers/usb/usbdevice/core/core.c +++ b/components/drivers/usb/usbdevice/core/core.c @@ -669,6 +669,8 @@ static rt_err_t _vendor_request(udevice_t device, ureq_t setup) static rt_uint8_t * usb_comp_id_desc = RT_NULL; static rt_uint32_t usb_comp_id_desc_size = 0; usb_os_func_comp_id_desc_t func_comp_id_desc; + uintf_t intf; + ufunction_t func; switch(setup->bRequest) { case 'A': @@ -704,6 +706,13 @@ static rt_err_t _vendor_request(udevice_t device, ureq_t setup) } rt_usbd_ep0_write(device, (void*)usb_comp_id_desc, setup->wLength); break; + case 0x05: + intf = rt_usbd_find_interface(device, setup->wValue & 0xFF, &func); + if(intf != RT_NULL) + { + intf->handler(func, setup); + } + break; } break; |
