Omit serial number if not defined (#11104)
This commit is contained in:
parent
e3888281f4
commit
15faffacf4
2 changed files with 16 additions and 8 deletions
|
|
@ -374,7 +374,11 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = {
|
|||
.ReleaseNumber = DEVICE_VER,
|
||||
.ManufacturerStrIndex = 0x01,
|
||||
.ProductStrIndex = 0x02,
|
||||
#if defined(SERIAL_NUMBER)
|
||||
.SerialNumStrIndex = 0x03,
|
||||
#else
|
||||
.SerialNumStrIndex = 0x00,
|
||||
#endif
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
|
|
@ -950,10 +954,7 @@ const USB_Descriptor_String_t PROGMEM ProductString = {
|
|||
.UnicodeString = LSTR(PRODUCT)
|
||||
};
|
||||
|
||||
#ifndef SERIAL_NUMBER
|
||||
# define SERIAL_NUMBER 0
|
||||
#endif
|
||||
|
||||
#if defined(SERIAL_NUMBER)
|
||||
const USB_Descriptor_String_t PROGMEM SerialNumberString = {
|
||||
.Header = {
|
||||
.Size = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1), // Subtract 1 for null terminator
|
||||
|
|
@ -961,6 +962,7 @@ const USB_Descriptor_String_t PROGMEM SerialNumberString = {
|
|||
},
|
||||
.UnicodeString = LSTR(SERIAL_NUMBER)
|
||||
};
|
||||
#endif
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
|
@ -1005,11 +1007,13 @@ uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const
|
|||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
|
||||
break;
|
||||
#if defined(SERIAL_NUMBER)
|
||||
case 0x03:
|
||||
Address = &SerialNumberString;
|
||||
Size = pgm_read_byte(&SerialNumberString.Header.Size);
|
||||
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue