summaryrefslogtreecommitdiff
path: root/components/drivers/include
diff options
context:
space:
mode:
authorMiraculousConch <[email protected]>2017-11-28 03:02:48 +0800
committerMiraculousConch <[email protected]>2017-11-28 03:02:48 +0800
commitd40d5355b8d64097259be35fef8b91f0cbda713c (patch)
treefc90c3dca9536e5a42f3e7cd3dcf7742e30e7d3c /components/drivers/include
parent3044461ba22dcd926a03d1088c4fe44ce18d38b0 (diff)
[Components][Drivers][USB]WinUSB And Core update
协议栈增加允许class在windows环境下枚举时向系统注册附加属性。并在winusb class中提供范例(注册GUID信息)
Diffstat (limited to 'components/drivers/include')
-rw-r--r--components/drivers/include/drivers/usb_common.h47
-rw-r--r--components/drivers/include/drivers/usb_device.h46
2 files changed, 92 insertions, 1 deletions
diff --git a/components/drivers/include/drivers/usb_common.h b/components/drivers/include/drivers/usb_common.h
index ff332e8f7a..91afb252d9 100644
--- a/components/drivers/include/drivers/usb_common.h
+++ b/components/drivers/include/drivers/usb_common.h
@@ -422,6 +422,53 @@ struct usb_os_comp_id_descriptor
};
typedef struct usb_os_comp_id_descriptor * usb_os_comp_id_desc_t;
+struct usb_os_property_header
+{
+ rt_uint32_t dwLength;
+ rt_uint16_t bcdVersion;
+ rt_uint16_t wIndex;
+ rt_uint16_t wCount;
+};
+typedef struct usb_os_property_header * usb_os_property_header_t;
+struct usb_os_proerty
+{
+ rt_uint32_t dwSize;
+ rt_uint32_t dwPropertyDataType;
+ rt_uint16_t wPropertyNameLength;
+ const char * bPropertyName;
+ rt_uint32_t dwPropertyDataLength;
+ const char * bPropertyData;
+};
+typedef struct usb_os_proerty * usb_os_proerty_t;
+
+// Value Description
+// 1 A NULL-terminated Unicode String (REG_SZ)
+// 2 A NULL-terminated Unicode String that includes environment variables (REG_EXPAND_SZ)
+// 3 Free-form binary (REG_BINARY)
+// 4 A little-endian 32-bit integer (REG_DWORD_LITTLE_ENDIAN)
+// 5 A big-endian 32-bit integer (REG_DWORD_BIG_ENDIAN)
+// 6 A NULL-terminated Unicode string that contains a symbolic link (REG_LINK)
+// 7 Multiple NULL-terminated Unicode strings (REG_MULTI_SZ)
+#define USB_OS_PROERTY_TYPE_REG_SZ 0x01UL
+#define USB_OS_PROERTY_TYPE_REG_EXPAND_SZ 0x02UL
+#define USB_OS_PROERTY_TYPE_REG_BINARY 0x03UL
+#define USB_OS_PROERTY_TYPE_REG_DWORD_LITTLE_ENDIAN 0x04UL
+#define USB_OS_PROERTY_TYPE_REG_DWORD_BIG_ENDIAN 0x05UL
+#define USB_OS_PROERTY_TYPE_REG_LINK 0x06UL
+#define USB_OS_PROERTY_TYPE_REG_MULTI_SZ 0x07UL
+
+#define USB_OS_PROERTY_DESC(PropertyDataType,PropertyName,PropertyData) \
+{\
+ .dwSize = sizeof(struct usb_os_proerty)-sizeof(const char *)*2\
+ +sizeof(PropertyName)*2+sizeof(PropertyData)*2,\
+ .dwPropertyDataType = PropertyDataType,\
+ .wPropertyNameLength = sizeof(PropertyName)*2,\
+ .bPropertyName = PropertyName,\
+ .dwPropertyDataLength = sizeof(PropertyData)*2,\
+ .bPropertyData = PropertyData\
+}
+
+
#ifndef HID_SUB_DESCRIPTOR_MAX
#define HID_SUB_DESCRIPTOR_MAX 1
#endif
diff --git a/components/drivers/include/drivers/usb_device.h b/components/drivers/include/drivers/usb_device.h
index 11ae608582..8f2c1d1116 100644
--- a/components/drivers/include/drivers/usb_device.h
+++ b/components/drivers/include/drivers/usb_device.h
@@ -410,5 +410,49 @@ rt_inline rt_err_t dcd_ep_clear_stall(udcd_t dcd, rt_uint8_t address)
return dcd->ops->ep_clear_stall(address);
}
-
+rt_inline void usbd_os_proerty_descriptor_send(ufunction_t func, ureq_t setup, usb_os_proerty_t usb_os_proerty, rt_uint8_t number_of_proerty)
+{
+ struct usb_os_property_header header;
+ static rt_uint8_t * data;
+ rt_uint8_t * pdata;
+ rt_uint8_t index,i;
+ if(data == RT_NULL)
+ {
+ header.dwLength = sizeof(struct usb_os_property_header);
+ header.bcdVersion = 0x0100;
+ header.wIndex = 0x05;
+ header.wCount = number_of_proerty;
+ for(index = 0;index < number_of_proerty;index++)
+ {
+ header.dwLength += usb_os_proerty[index].dwSize;
+ }
+ data = (rt_uint8_t *)rt_malloc(header.dwLength);
+ RT_ASSERT(data != RT_NULL);
+ pdata = data;
+ rt_memcpy((void *)pdata,(void *)&header,sizeof(struct usb_os_property_header));
+ pdata += sizeof(struct usb_os_property_header);
+ for(index = 0;index < number_of_proerty;index++)
+ {
+ rt_memcpy((void *)pdata,(void *)&usb_os_proerty[index],10);
+ pdata += 10;
+ for(i = 0;i < usb_os_proerty[index].wPropertyNameLength;i++)
+ {
+ *pdata = usb_os_proerty[index].bPropertyName[i];
+ pdata++;
+ *pdata = 0;
+ pdata++;
+ }
+ *((rt_uint32_t *)pdata) = usb_os_proerty[index].dwPropertyDataLength;
+ pdata += 4;
+ for(i = 0;i < usb_os_proerty[index].dwPropertyDataLength;i++)
+ {
+ *pdata = usb_os_proerty[index].bPropertyData[i];
+ pdata++;
+ *pdata = 0;
+ pdata++;
+ }
+ }
+ }
+ rt_usbd_ep0_write(func->device, data, setup->wLength);
+}
#endif