浏览代码

Use string literals for `SERIAL_NUMBER` (#13403)

Ryan 3 年之前
父节点
当前提交
7ed5ac4a60
共有 3 个文件被更改,包括 8 次插入4 次删除
  1. 2 2
      tmk_core/protocol/usb_descriptor.c
  2. 4 0
      tmk_core/protocol/usb_descriptor_common.h
  3. 2 2
      tmk_core/protocol/vusb/vusb.c

+ 2 - 2
tmk_core/protocol/usb_descriptor.c

@@ -953,10 +953,10 @@ const USB_Descriptor_String_t PROGMEM ProductString = {
 #if defined(SERIAL_NUMBER)
 #if defined(SERIAL_NUMBER)
 const USB_Descriptor_String_t PROGMEM SerialNumberString = {
 const USB_Descriptor_String_t PROGMEM SerialNumberString = {
     .Header = {
     .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
         .Type                   = DTYPE_String
     },
     },
-    .UnicodeString              = LSTR(SERIAL_NUMBER)
+    .UnicodeString              = USBSTR(SERIAL_NUMBER)
 };
 };
 #endif
 #endif
 
 

+ 4 - 0
tmk_core/protocol/usb_descriptor_common.h

@@ -16,6 +16,10 @@
 
 
 #pragma once
 #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
 // RAW Usage page and ID configuration
 
 

+ 2 - 2
tmk_core/protocol/vusb/vusb.c

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