diff --git a/lib/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c b/lib/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c index 877b159d1..9d8730d47 100644 --- a/lib/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c +++ b/lib/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c @@ -56,6 +56,7 @@ EndBSPDependencies */ /* Includes ------------------------------------------------------------------*/ +#include "usbd_bos.h" #include "usbd_cdc.h" #include "usbd_ctlreq.h" @@ -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) { diff --git a/lib/pbio/drv/usb/stm32_usbd/usbd_bos.h b/lib/pbio/drv/usb/stm32_usbd/usbd_bos.h index 7ee1e12da..485bd1376 100644 --- a/lib/pbio/drv/usb/stm32_usbd/usbd_bos.h +++ b/lib/pbio/drv/usb/stm32_usbd/usbd_bos.h @@ -3,5 +3,9 @@ // Header file for USB BOS descriptor. +#include + #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]; diff --git a/lib/pbio/drv/usb/stm32_usbd/usbd_desc.c b/lib/pbio/drv/usb/stm32_usbd/usbd_desc.c index ffb562344..9008fde15 100644 --- a/lib/pbio/drv/usb/stm32_usbd/usbd_desc.c +++ b/lib/pbio/drv/usb/stm32_usbd/usbd_desc.c @@ -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,