Skip to content

Commit 2126891

Browse files
committed
Use protocol version number for USB device version
Uses the protocol version number as the USB device version so that we don't have to find a way to embed the protocol version into the USB protocol itself.
1 parent 77ebf82 commit 2126891

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
******************************************************************************
4444
*/
4545
/* Includes ------------------------------------------------------------------*/
46+
#include "pbio/protocol.h"
4647
#include "usbd_core.h"
4748
#include "usbd_conf.h"
4849
#include "usbd_pybricks.h"
@@ -56,6 +57,9 @@
5657
#define USBD_PRODUCT_FS_STRING "Pybricks Hub"
5758
#define USBD_CONFIGURATION_FS_STRING "Pybricks Config"
5859
#define USBD_INTERFACE_FS_STRING "Pybricks Interface"
60+
#define USBD_VERSION_BCD ((PBIO_PROTOCOL_VERSION_MAJOR << 8) | \
61+
(PBIO_PROTOCOL_VERSION_MINOR << 4) | \
62+
(PBIO_PROTOCOL_VERSION_PATCH))
5963

6064
#define DEVICE_ID1 (0x1FFF7A10)
6165
#define DEVICE_ID2 (0x1FFF7A14)
@@ -83,8 +87,8 @@ __ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = {
8387
HIBYTE(USBD_VID), /* idVendor */
8488
LOBYTE(USBD_PID), /* idVendor */
8589
HIBYTE(USBD_PID), /* idVendor */
86-
0x00, /* bcdDevice rel. 2.00 */
87-
0x02,
90+
LOBYTE(USBD_VERSION_BCD), /* bcdDevice */
91+
HIBYTE(USBD_VERSION_BCD),
8892
USBD_IDX_MFC_STR, /* Index of manufacturer string */
8993
USBD_IDX_PRODUCT_STR, /* Index of product string */
9094
USBD_IDX_SERIAL_STR, /* Index of serial number string */

0 commit comments

Comments
 (0)