fix(usb): report correct version number (#4904)

This commit is contained in:
ThomasKuehne
2024-05-03 13:31:33 +10:00
committed by GitHub
parent f1e74a90f9
commit faa74267c8
+12 -7
View File
@@ -26,6 +26,7 @@
/* USER CODE BEGIN INCLUDE */
#include "hal/usb_driver.h"
#include "usb_descriptor.h"
#include "stamp.h"
/* USER CODE END INCLUDE */
/* Private typedef -----------------------------------------------------------*/
@@ -295,12 +296,16 @@ uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
pid = 0;
}
/* version has to be bcd coded */
uint8_t version_minor = ((VERSION_MINOR / 10) << 4) | (VERSION_MINOR % 10);
uint8_t version_major = ((VERSION_MAJOR / 10) << 4) | (VERSION_MAJOR % 10);
/* USB Standard Device Descriptor */
__ALIGN_BEGIN const uint8_t USBD_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END =
{
USB_LEN_DEV_DESC, /*bLength */
USB_LEN_DEV_DESC, /*bLength */
USB_DESC_TYPE_DEVICE, /*bDescriptorType*/
0x00, /*bcdUSB */
0x00, /*bcdUSB USB specification release number in binary-coded decimal*/
0x02,
0x00, /*bDeviceClass*/
0x00, /*bDeviceSubClass*/
@@ -308,11 +313,11 @@ uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
USB_MAX_EP0_SIZE, /*bMaxPacketSize*/
LOBYTE(vid), /*idVendor*/
HIBYTE(vid), /*idVendor*/
LOBYTE(pid), /*idVendor*/
HIBYTE(pid), /*idVendor*/
0x00, /*bcdDevice rel. 2.00*/
0x02,
USBD_IDX_MFC_STR, /*Index of manufacturer string*/
LOBYTE(pid), /*idProduct*/
HIBYTE(pid), /*idProduct*/
version_minor, /*bcdDevice device release number in binary-coded decimal*/
version_major,
USBD_IDX_MFC_STR, /*Index of manufacturer string*/
USBD_IDX_PRODUCT_STR, /*Index of product string*/
USBD_IDX_SERIAL_STR, /*Index of serial number string*/
USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/