Skip to content

Commit

Permalink
Add OS 2.0 descriptor set
Browse files Browse the repository at this point in the history
Adds an OS 2.0 descriptor set using a new, random GUID.
  • Loading branch information
nkarstens committed Oct 26, 2023
1 parent 7fe3999 commit fb45d7b
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
EndBSPDependencies */

/* Includes ------------------------------------------------------------------*/
#include "usbd_bos.h"
#include "usbd_cdc.h"
#include "usbd_ctlreq.h"

Expand Down Expand Up @@ -363,6 +364,22 @@ static uint8_t USBD_CDC_Setup(USBD_HandleTypeDef *pdev,
}
break;

case USB_REQ_TYPE_VENDOR:
switch (req->bRequest)
{
case USB_MS_VENDOR_CODE:
(void)USBD_CtlSendData(pdev,
(uint8_t *)USBD_FS_OSDescSet,
MIN(sizeof(USBD_FS_OSDescSet), req->wLength));
break;

default:
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
break;
}
break;

case USB_REQ_TYPE_STANDARD:
switch (req->bRequest)
{
Expand Down
4 changes: 4 additions & 0 deletions lib/pbio/drv/usb/stm32_usbd/usbd_bos.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@

// Header file for USB BOS descriptor.

#include <stdint.h>

#define USB_MS_VENDOR_CODE 0xCC
#define USB_SIZ_MS_OS_DSCRPTR_SET (10+20+130)

extern uint8_t USBD_FS_OSDescSet[USB_SIZ_MS_OS_DSCRPTR_SET];
92 changes: 92 additions & 0 deletions lib/pbio/drv/usb/stm32_usbd/usbd_desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,98 @@ __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END =
};
#endif /* USBD_CLASS_BOS_ENABLED == 1 */

#if (USBD_CLASS_BOS_ENABLED == 1)
#if defined ( __ICCARM__ ) /* IAR Compiler */
#pragma data_alignment=4
#endif /* defined ( __ICCARM__ ) */
__ALIGN_BEGIN uint8_t USBD_FS_OSDescSet[USB_SIZ_MS_OS_DSCRPTR_SET] __ALIGN_END =
{
0x0A, 0x00, /* wLength = 10 */
0x00, 0x00, /* wDescriptorType = MS_OS_20_SET_HEADER_DESCRIPTOR */
0x00, 0x00, 0x03, 0x06, /* dwWindowsVersion = 0x06030000 for Windows 8.1 Build */
LOBYTE(USB_SIZ_MS_OS_DSCRPTR_SET), /* wTotalLength */
HIBYTE(USB_SIZ_MS_OS_DSCRPTR_SET), /* wTotalLength (cont.) */

0x14, 0x00, /* wLength = 20 */
0x03, 0x00, /* wDescriptorType = MS_OS_20_FEATURE_COMPATBLE_ID */
'W', 'I', 'N', 'U', 'S', 'B', /* CompatibleID */
0x00, 0x00, /* CompatibleID (cont.) */
0x00, 0x00, 0x00, 0x00, /* SubCompatibleID */
0x00, 0x00, 0x00, 0x00, /* SubCompatibleID (cont.) */

0x82, 0x00, /* wLength = 130 */
0x04, 0x00, /* wDescriptorType = MS_OS_20_FEATURE_REG_PROPERTY */
0x07, 0x00, /* wStringType = REG_MULTI_SZ */
/* wPropertyNameLength = 42 */
0x2A, 0x00,
/* PropertyName = DeviceInterfaceGUIDs */
'D', '\0',
'e', '\0',
'v', '\0',
'i', '\0',
'c', '\0',
'e', '\0',
'I', '\0',
'n', '\0',
't', '\0',
'e', '\0',
'r', '\0',
'f', '\0',
'a', '\0',
'c', '\0',
'e', '\0',
'G', '\0',
'U', '\0',
'I', '\0',
'D', '\0',
's', '\0',
'\0', '\0',

/* wPropertyDataLength = 78 */
0x4E, 0x00,
/* PropertyData = {A5C44A4C-53D4-4389-9821-AE95051908A1} */
'{', '\0',
'A', '\0',
'5', '\0',
'C', '\0',
'4', '\0',
'4', '\0',
'A', '\0',
'4', '\0',
'C', '\0',
'-', '\0',
'5', '\0',
'3', '\0',
'D', '\0',
'4', '\0',
'-', '\0',
'4', '\0',
'3', '\0',
'8', '\0',
'9', '\0',
'-', '\0',
'9', '\0',
'8', '\0',
'2', '\0',
'1', '\0',
'-', '\0',
'A', '\0',
'E', '\0',
'9', '\0',
'5', '\0',
'0', '\0',
'5', '\0',
'1', '\0',
'9', '\0',
'0', '\0',
'8', '\0',
'A', '\0',
'1', '\0',
'}', '\0',
'\0', '\0'
};
#endif /* USBD_CLASS_BOS_ENABLED == 1 */

/* USB Standard Device Descriptor */
__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = {
USB_LEN_LANGID_STR_DESC,
Expand Down

0 comments on commit fb45d7b

Please sign in to comment.