diff --git a/lib/pbio/drv/usb/stm32_usbd/usbd_desc.c b/lib/pbio/drv/usb/stm32_usbd/usbd_desc.c index 86532dd00..2fff4bfb4 100644 --- a/lib/pbio/drv/usb/stm32_usbd/usbd_desc.c +++ b/lib/pbio/drv/usb/stm32_usbd/usbd_desc.c @@ -47,6 +47,13 @@ #include "usbd_conf.h" #include "usbd_pybricks.h" +#include "pbio/protocol.h" +#include "pbio/version.h" +#include "pbsys/app.h" +#include "pbsys/program_load.h" +#include "pbdrvconfig.h" +#include "sys/config.h" + /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define USBD_VID 0x0483 @@ -62,7 +69,7 @@ #define DEVICE_ID3 (0x1FFF7A18) #define USB_SIZ_STRING_SERIAL 0x1A -#define USB_SIZ_BOS_DESC 33 +#define USB_SIZ_BOS_DESC (5 + 28 + 34) /* USB Standard Device Descriptor */ __ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = { @@ -98,12 +105,14 @@ __ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = { #endif /* defined ( __ICCARM__ ) */ __ALIGN_BEGIN uint8_t USBD_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = { + /* --- BOS Decriptor --- */ 5, /* bLength */ USB_DESC_TYPE_BOS, /* bDescriptorType = BOS */ LOBYTE(USB_SIZ_BOS_DESC), /* wTotalLength */ HIBYTE(USB_SIZ_BOS_DESC), /* wTotalLength */ - 0x01, /* bNumDeviceCaps = 1 */ + 0x02, /* bNumDeviceCaps = 2 */ + /* --- Platform Capability --- */ 28, /* bLength */ USB_DEVICE_CAPABITY_TYPE, /* bDescriptorType = Device Capability */ 0x05, /* bDevCapabilityType = Platform */ @@ -124,7 +133,44 @@ __ALIGN_BEGIN uint8_t USBD_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = LOBYTE(USB_SIZ_MS_OS_DSCRPTR_SET), /* wMSOSDescriptorSetTotalLength */ HIBYTE(USB_SIZ_MS_OS_DSCRPTR_SET), /* wMSOSDescriptorSetTotalLength */ USB_MS_VENDOR_CODE, /* bMS_VendorCode */ - 0x00 /* bAltEnumCode = Does not support alternate enumeration */ + 0x00, /* bAltEnumCode = Does not support alternate enumeration */ + + /* --- Platform Capability --- */ + 34, /* bLength */ + USB_DEVICE_CAPABITY_TYPE, /* bDescriptorType = Device Capability */ + 0x05, /* bDevCapabilityType = Platform */ + 0x00, /* bReserved */ + + /* + * PlatformCapabilityUUID + * Pybricks + * A5C44A4C-53D4-4389-9821-AE95051908A1 + */ + 0x4C, 0x4A, 0xC4, 0xA5, + 0xD4, 0x53, + 0x89, 0x43, + 0x98, 0x21, + 0xAE, 0x95, 0x05, 0x19, 0x08, 0xA1, + + PBIO_VERSION_MAJOR, /* Firmware version (major) */ + PBIO_VERSION_MINOR, /* Firmware version (minor) */ + PBIO_VERSION_MICRO, /* Firmware version (micro) */ + + PBIO_PROTOCOL_VERSION_MAJOR, /* Protocol version (major) */ + PBIO_PROTOCOL_VERSION_MINOR, /* Protocol version (minor) */ + PBIO_PROTOCOL_VERSION_PATCH, /* Protocol version (patch) */ + + /* Hub feature flags */ + (PBSYS_APP_HUB_FEATURE_FLAGS) & 0xFF, + (PBSYS_APP_HUB_FEATURE_FLAGS >> 8) & 0xFF, + (PBSYS_APP_HUB_FEATURE_FLAGS >> 16) & 0xFF, + (PBSYS_APP_HUB_FEATURE_FLAGS >> 24) & 0xFF, + + /* Program size */ + (PBSYS_PROGRAM_LOAD_MAX_PROGRAM_SIZE) & 0xFF, + (PBSYS_PROGRAM_LOAD_MAX_PROGRAM_SIZE >> 8) & 0xFF, + (PBSYS_PROGRAM_LOAD_MAX_PROGRAM_SIZE >> 16) & 0xFF, + (PBSYS_PROGRAM_LOAD_MAX_PROGRAM_SIZE >> 24) & 0xFF, }; #endif /* (USBD_LPM_ENABLED == 1) || (USBD_CLASS_BOS_ENABLED == 1) */