Go to the documentation of this file.
18#ifndef __VSF_USBD_WINUSB_H__
19#define __VSF_USBD_WINUSB_H__
25#if VSF_USE_USB_DEVICE == ENABLED
33#define USB_BOS_CAP_WINUSB_LEN \
34 USB_DESC_BOS_CAPABILITY_LEN(8)
36#define MSOS20_FEATURE_WINUSB_SIZE \
37 ( USB_DT_MSOS20_SUBSET_HEADER_CONFIGURATION_SIZE + \
38 USB_DT_MSOS20_FEATURE_COMPATIBLE_ID_SIZE + \
39 USB_DESC_MSOS20_FEATURE_REG_PROPERTY_LEN( \
40 MSOS20_REG_PROPERTY_NAME_LEN___DEVICE_INTERFACE_GUIDS___, \
41 MSOS20_REG_PROPERTY_DATA_LEN___DEVICE_INTERFACE_GUIDS___ \
45#define MSOS20_REQ_DISCRIPTOR_INDEX 7
46#define MSOS20_REQ_SET_ALT_ENUMERATION 8
48#define USB_DT_MSOS20_SET_HEADER_SIZE 10
49#define USB_DT_MSOS20_SUBSET_HEADER_CONFIGURATION_SIZE 8
50#define USB_DT_MSOS20_FEATURE_COMPATIBLE_ID_SIZE 20
52#define MSOS20_REG_PROPERTY_NAME_LEN___DEVICE_INTERFACE_GUIDS___ 42
53#define MSOS20_REG_PROPERTY_DATA_LEN___DEVICE_INTERFACE_GUIDS___ 80
54#define MSOS20_REG_PROPERTY_NAME___DEVICE_INTERFACE_GUIDS___ \
55 'D',0,'e',0,'v',0,'i',0,'c',0,'e',0, \
56 'I',0,'n',0,'t',0,'e',0,'r',0,'f',0,'a',0,'c',0,'e',0, \
57 'G',0,'U',0,'I',0,'D',0,'s',0,0,0,
59#define MSOS20_REG_PROPERTY_TYPE_REG_MULTI_SZ 7
61#define USB_DT_MSOS20_SET_HEADER 0x00
62#define USB_DT_MSOS20_SUBSET_HEADER_CONFIGURATION 0x01
63#define USB_DT_MSOS20_SUBSET_HEADER_FUNCTION 0x02
64#define USB_DT_MSOS20_FEATURE_COMPATIBLE_ID 0x03
65#define USB_DT_MSOS20_FEATURE_REG_PROPERTY 0x04
66#define USB_DT_MSOS20_FEATURE_MIN_RESUME_TIME 0x05
67#define USB_DT_MSOS20_FEATURE_MODEL_ID 0x06
68#define USB_DT_MSOS20_FEATURE_CCGP_DEVICE 0x07
69#define USB_DT_MSOS20_FEATURE_VENDOR_REVISION 0x08
73#define USB_DESC_MSOS20_SET_HEADER(__TOTAL_LEN) \
74 USB_DESC_WORD(USB_DT_MSOS20_SET_HEADER_SIZE), \
75 USB_DESC_WORD(USB_DT_MSOS20_SET_HEADER), \
76 0x00, 0x00, 0x03, 0x06, \
77 USB_DESC_WORD(__TOTAL_LEN),
79#define USB_DESC_MSOS20_SUBSET_FUNCTION(__FIRST_IFS, __LEN, ...) \
80 USB_DESC_WORD(USB_DT_MSOS20_SUBSET_HEADER_CONFIGURATION_SIZE), \
81 USB_DESC_WORD(USB_DT_MSOS20_SUBSET_HEADER_FUNCTION), \
84 USB_DESC_WORD(USB_DT_MSOS20_SUBSET_HEADER_CONFIGURATION_SIZE + (__LEN)),\
87#define USB_DESC_MSOS20_FEATURE_COMPATIBLE_ID(...) \
88 USB_DESC_WORD(USB_DT_MSOS20_FEATURE_COMPATIBLE_ID_SIZE), \
89 USB_DESC_WORD(USB_DT_MSOS20_FEATURE_COMPATIBLE_ID), \
92#define USB_DESC_MSOS20_FEATURE_REG_PROPERTY_LEN(__NAME_LEN, __DATA_LEN) \
93 (10 + (__NAME_LEN) + (__DATA_LEN))
94#define USB_DESC_MSOS20_FEATURE_REG_PROPERTY(__NAME_LEN, __NAME, __DATA_LEN, ...)\
95 USB_DESC_WORD(USB_DESC_MSOS20_FEATURE_REG_PROPERTY_LEN((__NAME_LEN), (__DATA_LEN))),\
96 USB_DESC_WORD(USB_DT_MSOS20_FEATURE_REG_PROPERTY), \
97 USB_DESC_WORD(MSOS20_REG_PROPERTY_TYPE_REG_MULTI_SZ), \
98 USB_DESC_WORD(__NAME_LEN), \
100 USB_DESC_WORD(__DATA_LEN), \
103#define USB_DESC_BOS_CAPABILITY_MSOS20(__len) \
104 USB_DESC_BOS_CAPABILITY_HEADER(4 + (__len), 5, \
105 0xDF, 0x60, 0xDD, 0xD8, \
106 0x89, 0x45, 0xC7, 0x4C, \
107 0x9C, 0xD2, 0x65, 0x9D, \
108 0x9E, 0x64, 0x8A, 0x9F, \
110 0x00, 0x00, 0x03, 0x06,
112#define __usbd_msos20_desc(__name, __desc_size, ...) \
114 __##__name##_msos20_desc_len = USB_DT_MSOS20_SET_HEADER_SIZE + (__desc_size),\
116 const uint8_t __##__name##_msos20_desc[__##__name##_msos20_desc_len] = {\
117 USB_DESC_MSOS20_SET_HEADER(__##__name##_msos20_desc_len) \
121#define usbd_msos20_desc(__name, __desc_size, ...) \
122 __usbd_msos20_desc(__name, __desc_size, __VA_ARGS__)
124#define __usbd_msos20_desc_buffer(__name) __##__name##_msos20_desc
125#define __usbd_msos20_desc_len(__name) __##__name##_msos20_desc_len
126#define usbd_msos20_desc_buffer(__name) __usbd_msos20_desc_buffer(__name)
127#define usbd_msos20_desc_len(__name) __usbd_msos20_desc_len(__name)
129#define __msos20_feature_winusb(__first_ifs, ...) \
130 USB_DESC_MSOS20_SUBSET_FUNCTION(__first_ifs, \
131 USB_DT_MSOS20_FEATURE_COMPATIBLE_ID_SIZE + \
132 USB_DESC_MSOS20_FEATURE_REG_PROPERTY_LEN( \
133 MSOS20_REG_PROPERTY_NAME_LEN___DEVICE_INTERFACE_GUIDS___,\
134 MSOS20_REG_PROPERTY_DATA_LEN___DEVICE_INTERFACE_GUIDS___\
136 USB_DESC_MSOS20_FEATURE_COMPATIBLE_ID( \
137 'W', 'I', 'N', 'U', 'S', 'B', 0, 0, \
138 0, 0, 0, 0, 0, 0, 0, 0, \
140 USB_DESC_MSOS20_FEATURE_REG_PROPERTY( \
141 MSOS20_REG_PROPERTY_NAME_LEN___DEVICE_INTERFACE_GUIDS___, \
142 MSOS20_REG_PROPERTY_NAME___DEVICE_INTERFACE_GUIDS___, \
143 MSOS20_REG_PROPERTY_DATA_LEN___DEVICE_INTERFACE_GUIDS___, \
150#define msos20_feature_winusb(__first_ifs, ...) \
151 __msos20_feature_winusb((__first_ifs), __VA_ARGS__)
153#define __bos_desc_winusb(__vendor_code, __alt_enum_code, __desc_len) \
154 USB_DESC_BOS_CAPABILITY_MSOS20(4) \
155 USB_DESC_WORD(__desc_len), \
159#define bos_desc_winusb(__vendor_code, __alt_enum_code, __desc_len) \
160 __bos_desc_winusb((__vendor_code), (__alt_enum_code), (__desc_len))