Use string literals for SERIAL_NUMBER (#13403)

This commit is contained in:
Ryan 2021-07-16 19:43:18 +10:00 committed by GitHub
parent f0198ad15e
commit 7ed5ac4a60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -953,10 +953,10 @@ const USB_Descriptor_String_t PROGMEM ProductString = {
#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
.Size = USB_STRING_LEN(sizeof(SERIAL_NUMBER) - 1), // Subtract 1 for null terminator
.Type = DTYPE_String
},
.UnicodeString = LSTR(SERIAL_NUMBER)
.UnicodeString = USBSTR(SERIAL_NUMBER)
};
#endif

View File

@ -16,6 +16,10 @@
#pragma once
// Prefix string literal with L for descriptors
#define USBCONCAT(a, b) a##b
#define USBSTR(s) USBCONCAT(L, s)
/////////////////////
// RAW Usage page and ID configuration

View File

@ -599,10 +599,10 @@ const PROGMEM usbStringDescriptor_t usbStringDescriptorProduct = {
#if defined(SERIAL_NUMBER)
const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = {
.header = {
.bLength = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1),
.bLength = USB_STRING_LEN(sizeof(SERIAL_NUMBER) - 1),
.bDescriptorType = USBDESCR_STRING
},
.bString = LSTR(SERIAL_NUMBER)
.bString = USBSTR(SERIAL_NUMBER)
};
#endif