Skip to content

Commit fb45d7b

Browse files
committed
Add OS 2.0 descriptor set
Adds an OS 2.0 descriptor set using a new, random GUID.
1 parent 7fe3999 commit fb45d7b

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed

lib/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
EndBSPDependencies */
5757

5858
/* Includes ------------------------------------------------------------------*/
59+
#include "usbd_bos.h"
5960
#include "usbd_cdc.h"
6061
#include "usbd_ctlreq.h"
6162

@@ -363,6 +364,22 @@ static uint8_t USBD_CDC_Setup(USBD_HandleTypeDef *pdev,
363364
}
364365
break;
365366

367+
case USB_REQ_TYPE_VENDOR:
368+
switch (req->bRequest)
369+
{
370+
case USB_MS_VENDOR_CODE:
371+
(void)USBD_CtlSendData(pdev,
372+
(uint8_t *)USBD_FS_OSDescSet,
373+
MIN(sizeof(USBD_FS_OSDescSet), req->wLength));
374+
break;
375+
376+
default:
377+
USBD_CtlError(pdev, req);
378+
ret = USBD_FAIL;
379+
break;
380+
}
381+
break;
382+
366383
case USB_REQ_TYPE_STANDARD:
367384
switch (req->bRequest)
368385
{

lib/pbio/drv/usb/stm32_usbd/usbd_bos.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33

44
// Header file for USB BOS descriptor.
55

6+
#include <stdint.h>
7+
68
#define USB_MS_VENDOR_CODE 0xCC
79
#define USB_SIZ_MS_OS_DSCRPTR_SET (10+20+130)
10+
11+
extern uint8_t USBD_FS_OSDescSet[USB_SIZ_MS_OS_DSCRPTR_SET];

lib/pbio/drv/usb/stm32_usbd/usbd_desc.c

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,98 @@ __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END =
127127
};
128128
#endif /* USBD_CLASS_BOS_ENABLED == 1 */
129129

130+
#if (USBD_CLASS_BOS_ENABLED == 1)
131+
#if defined ( __ICCARM__ ) /* IAR Compiler */
132+
#pragma data_alignment=4
133+
#endif /* defined ( __ICCARM__ ) */
134+
__ALIGN_BEGIN uint8_t USBD_FS_OSDescSet[USB_SIZ_MS_OS_DSCRPTR_SET] __ALIGN_END =
135+
{
136+
0x0A, 0x00, /* wLength = 10 */
137+
0x00, 0x00, /* wDescriptorType = MS_OS_20_SET_HEADER_DESCRIPTOR */
138+
0x00, 0x00, 0x03, 0x06, /* dwWindowsVersion = 0x06030000 for Windows 8.1 Build */
139+
LOBYTE(USB_SIZ_MS_OS_DSCRPTR_SET), /* wTotalLength */
140+
HIBYTE(USB_SIZ_MS_OS_DSCRPTR_SET), /* wTotalLength (cont.) */
141+
142+
0x14, 0x00, /* wLength = 20 */
143+
0x03, 0x00, /* wDescriptorType = MS_OS_20_FEATURE_COMPATBLE_ID */
144+
'W', 'I', 'N', 'U', 'S', 'B', /* CompatibleID */
145+
0x00, 0x00, /* CompatibleID (cont.) */
146+
0x00, 0x00, 0x00, 0x00, /* SubCompatibleID */
147+
0x00, 0x00, 0x00, 0x00, /* SubCompatibleID (cont.) */
148+
149+
0x82, 0x00, /* wLength = 130 */
150+
0x04, 0x00, /* wDescriptorType = MS_OS_20_FEATURE_REG_PROPERTY */
151+
0x07, 0x00, /* wStringType = REG_MULTI_SZ */
152+
/* wPropertyNameLength = 42 */
153+
0x2A, 0x00,
154+
/* PropertyName = DeviceInterfaceGUIDs */
155+
'D', '\0',
156+
'e', '\0',
157+
'v', '\0',
158+
'i', '\0',
159+
'c', '\0',
160+
'e', '\0',
161+
'I', '\0',
162+
'n', '\0',
163+
't', '\0',
164+
'e', '\0',
165+
'r', '\0',
166+
'f', '\0',
167+
'a', '\0',
168+
'c', '\0',
169+
'e', '\0',
170+
'G', '\0',
171+
'U', '\0',
172+
'I', '\0',
173+
'D', '\0',
174+
's', '\0',
175+
'\0', '\0',
176+
177+
/* wPropertyDataLength = 78 */
178+
0x4E, 0x00,
179+
/* PropertyData = {A5C44A4C-53D4-4389-9821-AE95051908A1} */
180+
'{', '\0',
181+
'A', '\0',
182+
'5', '\0',
183+
'C', '\0',
184+
'4', '\0',
185+
'4', '\0',
186+
'A', '\0',
187+
'4', '\0',
188+
'C', '\0',
189+
'-', '\0',
190+
'5', '\0',
191+
'3', '\0',
192+
'D', '\0',
193+
'4', '\0',
194+
'-', '\0',
195+
'4', '\0',
196+
'3', '\0',
197+
'8', '\0',
198+
'9', '\0',
199+
'-', '\0',
200+
'9', '\0',
201+
'8', '\0',
202+
'2', '\0',
203+
'1', '\0',
204+
'-', '\0',
205+
'A', '\0',
206+
'E', '\0',
207+
'9', '\0',
208+
'5', '\0',
209+
'0', '\0',
210+
'5', '\0',
211+
'1', '\0',
212+
'9', '\0',
213+
'0', '\0',
214+
'8', '\0',
215+
'A', '\0',
216+
'1', '\0',
217+
'}', '\0',
218+
'\0', '\0'
219+
};
220+
#endif /* USBD_CLASS_BOS_ENABLED == 1 */
221+
130222
/* USB Standard Device Descriptor */
131223
__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = {
132224
USB_LEN_LANGID_STR_DESC,

0 commit comments

Comments
 (0)