4747#include "usbd_conf.h"
4848#include "usbd_pybricks.h"
4949
50+ #include "pbio/protocol.h"
51+ #include "pbio/version.h"
52+ #include "pbsys/app.h"
53+ #include "pbsys/program_load.h"
54+ #include "pbdrvconfig.h"
55+ #include "sys/config.h"
56+
5057/* Private typedef -----------------------------------------------------------*/
5158/* Private define ------------------------------------------------------------*/
5259#define USBD_VID 0x0483
6269#define DEVICE_ID3 (0x1FFF7A18)
6370
6471#define USB_SIZ_STRING_SERIAL 0x1A
65- #define USB_SIZ_BOS_DESC 33
72+ #define USB_SIZ_BOS_DESC (5 + 28 + 34)
6673
6774/* USB Standard Device Descriptor */
6875__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 = {
98105#endif /* defined ( __ICCARM__ ) */
99106__ALIGN_BEGIN uint8_t USBD_BOSDesc [USB_SIZ_BOS_DESC ] __ALIGN_END =
100107{
108+ /* --- BOS Decriptor --- */
101109 5 , /* bLength */
102110 USB_DESC_TYPE_BOS , /* bDescriptorType = BOS */
103111 LOBYTE (USB_SIZ_BOS_DESC ), /* wTotalLength */
104112 HIBYTE (USB_SIZ_BOS_DESC ), /* wTotalLength */
105- 0x01 , /* bNumDeviceCaps = 1 */
113+ 0x02 , /* bNumDeviceCaps = 2 */
106114
115+ /* --- Platform Capability --- */
107116 28 , /* bLength */
108117 USB_DEVICE_CAPABITY_TYPE , /* bDescriptorType = Device Capability */
109118 0x05 , /* bDevCapabilityType = Platform */
@@ -124,7 +133,44 @@ __ALIGN_BEGIN uint8_t USBD_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END =
124133 LOBYTE (USB_SIZ_MS_OS_DSCRPTR_SET ), /* wMSOSDescriptorSetTotalLength */
125134 HIBYTE (USB_SIZ_MS_OS_DSCRPTR_SET ), /* wMSOSDescriptorSetTotalLength */
126135 USB_MS_VENDOR_CODE , /* bMS_VendorCode */
127- 0x00 /* bAltEnumCode = Does not support alternate enumeration */
136+ 0x00 , /* bAltEnumCode = Does not support alternate enumeration */
137+
138+ /* --- Platform Capability --- */
139+ 34 , /* bLength */
140+ USB_DEVICE_CAPABITY_TYPE , /* bDescriptorType = Device Capability */
141+ 0x05 , /* bDevCapabilityType = Platform */
142+ 0x00 , /* bReserved */
143+
144+ /*
145+ * PlatformCapabilityUUID
146+ * Pybricks
147+ * A5C44A4C-53D4-4389-9821-AE95051908A1
148+ */
149+ 0x4C , 0x4A , 0xC4 , 0xA5 ,
150+ 0xD4 , 0x53 ,
151+ 0x89 , 0x43 ,
152+ 0x98 , 0x21 ,
153+ 0xAE , 0x95 , 0x05 , 0x19 , 0x08 , 0xA1 ,
154+
155+ PBIO_VERSION_MAJOR , /* Firmware version (major) */
156+ PBIO_VERSION_MINOR , /* Firmware version (minor) */
157+ PBIO_VERSION_MICRO , /* Firmware version (micro) */
158+
159+ PBIO_PROTOCOL_VERSION_MAJOR , /* Protocol version (major) */
160+ PBIO_PROTOCOL_VERSION_MINOR , /* Protocol version (minor) */
161+ PBIO_PROTOCOL_VERSION_PATCH , /* Protocol version (patch) */
162+
163+ /* Hub feature flags */
164+ (PBSYS_APP_HUB_FEATURE_FLAGS ) & 0xFF ,
165+ (PBSYS_APP_HUB_FEATURE_FLAGS >> 8 ) & 0xFF ,
166+ (PBSYS_APP_HUB_FEATURE_FLAGS >> 16 ) & 0xFF ,
167+ (PBSYS_APP_HUB_FEATURE_FLAGS >> 24 ) & 0xFF ,
168+
169+ /* Program size */
170+ (PBSYS_PROGRAM_LOAD_MAX_PROGRAM_SIZE ) & 0xFF ,
171+ (PBSYS_PROGRAM_LOAD_MAX_PROGRAM_SIZE >> 8 ) & 0xFF ,
172+ (PBSYS_PROGRAM_LOAD_MAX_PROGRAM_SIZE >> 16 ) & 0xFF ,
173+ (PBSYS_PROGRAM_LOAD_MAX_PROGRAM_SIZE >> 24 ) & 0xFF ,
128174};
129175#endif /* (USBD_LPM_ENABLED == 1) || (USBD_CLASS_BOS_ENABLED == 1) */
130176
0 commit comments