diff options
| author | Ryan <fauxpark@gmail.com> | 2020-12-05 21:14:19 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-05 21:14:19 +1100 |
| commit | 15faffacf49240ea95a0f0121511e6b2fb4c914c (patch) | |
| tree | dc207b03cd4d374d8e2d066b335774ab121aa8bd /tmk_core | |
| parent | e3888281f49d566cb9cf3efdebb105014f0957d2 (diff) | |
| download | qmk_firmware-15faffacf49240ea95a0f0121511e6b2fb4c914c.tar.gz qmk_firmware-15faffacf49240ea95a0f0121511e6b2fb4c914c.zip | |
Omit serial number if not defined (#11104)
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/protocol/usb_descriptor.c | 12 | ||||
| -rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 12 |
2 files changed, 16 insertions, 8 deletions
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index a0c0d4cdc..7ea4b2e37 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c | |||
| @@ -374,7 +374,11 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = { | |||
| 374 | .ReleaseNumber = DEVICE_VER, | 374 | .ReleaseNumber = DEVICE_VER, |
| 375 | .ManufacturerStrIndex = 0x01, | 375 | .ManufacturerStrIndex = 0x01, |
| 376 | .ProductStrIndex = 0x02, | 376 | .ProductStrIndex = 0x02, |
| 377 | #if defined(SERIAL_NUMBER) | ||
| 377 | .SerialNumStrIndex = 0x03, | 378 | .SerialNumStrIndex = 0x03, |
| 379 | #else | ||
| 380 | .SerialNumStrIndex = 0x00, | ||
| 381 | #endif | ||
| 378 | .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | 382 | .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS |
| 379 | }; | 383 | }; |
| 380 | 384 | ||
| @@ -950,10 +954,7 @@ const USB_Descriptor_String_t PROGMEM ProductString = { | |||
| 950 | .UnicodeString = LSTR(PRODUCT) | 954 | .UnicodeString = LSTR(PRODUCT) |
| 951 | }; | 955 | }; |
| 952 | 956 | ||
| 953 | #ifndef SERIAL_NUMBER | 957 | #if defined(SERIAL_NUMBER) |
| 954 | # define SERIAL_NUMBER 0 | ||
| 955 | #endif | ||
| 956 | |||
| 957 | const USB_Descriptor_String_t PROGMEM SerialNumberString = { | 958 | const USB_Descriptor_String_t PROGMEM SerialNumberString = { |
| 958 | .Header = { | 959 | .Header = { |
| 959 | .Size = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1), // Subtract 1 for null terminator | 960 | .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 = { | |||
| 961 | }, | 962 | }, |
| 962 | .UnicodeString = LSTR(SERIAL_NUMBER) | 963 | .UnicodeString = LSTR(SERIAL_NUMBER) |
| 963 | }; | 964 | }; |
| 965 | #endif | ||
| 964 | 966 | ||
| 965 | // clang-format on | 967 | // clang-format on |
| 966 | 968 | ||
| @@ -1005,11 +1007,13 @@ uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const | |||
| 1005 | Size = pgm_read_byte(&ProductString.Header.Size); | 1007 | Size = pgm_read_byte(&ProductString.Header.Size); |
| 1006 | 1008 | ||
| 1007 | break; | 1009 | break; |
| 1010 | #if defined(SERIAL_NUMBER) | ||
| 1008 | case 0x03: | 1011 | case 0x03: |
| 1009 | Address = &SerialNumberString; | 1012 | Address = &SerialNumberString; |
| 1010 | Size = pgm_read_byte(&SerialNumberString.Header.Size); | 1013 | Size = pgm_read_byte(&SerialNumberString.Header.Size); |
| 1011 | 1014 | ||
| 1012 | break; | 1015 | break; |
| 1016 | #endif | ||
| 1013 | } | 1017 | } |
| 1014 | 1018 | ||
| 1015 | break; | 1019 | break; |
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 77bbbd7bd..9b65ba9ac 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c | |||
| @@ -531,10 +531,6 @@ const PROGMEM uchar console_hid_report[] = { | |||
| 531 | }; | 531 | }; |
| 532 | #endif | 532 | #endif |
| 533 | 533 | ||
| 534 | #ifndef SERIAL_NUMBER | ||
| 535 | # define SERIAL_NUMBER 0 | ||
| 536 | #endif | ||
| 537 | |||
| 538 | #ifndef USB_MAX_POWER_CONSUMPTION | 534 | #ifndef USB_MAX_POWER_CONSUMPTION |
| 539 | # define USB_MAX_POWER_CONSUMPTION 500 | 535 | # define USB_MAX_POWER_CONSUMPTION 500 |
| 540 | #endif | 536 | #endif |
| @@ -569,6 +565,7 @@ const PROGMEM usbStringDescriptor_t usbStringDescriptorProduct = { | |||
| 569 | .bString = LSTR(PRODUCT) | 565 | .bString = LSTR(PRODUCT) |
| 570 | }; | 566 | }; |
| 571 | 567 | ||
| 568 | #if defined(SERIAL_NUMBER) | ||
| 572 | const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = { | 569 | const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = { |
| 573 | .header = { | 570 | .header = { |
| 574 | .bLength = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1), | 571 | .bLength = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1), |
| @@ -576,6 +573,7 @@ const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = { | |||
| 576 | }, | 573 | }, |
| 577 | .bString = LSTR(SERIAL_NUMBER) | 574 | .bString = LSTR(SERIAL_NUMBER) |
| 578 | }; | 575 | }; |
| 576 | #endif | ||
| 579 | 577 | ||
| 580 | /* | 578 | /* |
| 581 | * Device descriptor | 579 | * Device descriptor |
| @@ -595,7 +593,11 @@ const PROGMEM usbDeviceDescriptor_t usbDeviceDescriptor = { | |||
| 595 | .bcdDevice = DEVICE_VER, | 593 | .bcdDevice = DEVICE_VER, |
| 596 | .iManufacturer = 0x01, | 594 | .iManufacturer = 0x01, |
| 597 | .iProduct = 0x02, | 595 | .iProduct = 0x02, |
| 596 | #if defined(SERIAL_NUMBER) | ||
| 598 | .iSerialNumber = 0x03, | 597 | .iSerialNumber = 0x03, |
| 598 | #else | ||
| 599 | .iSerialNumber = 0x00, | ||
| 600 | #endif | ||
| 599 | .bNumConfigurations = 1 | 601 | .bNumConfigurations = 1 |
| 600 | }; | 602 | }; |
| 601 | 603 | ||
| @@ -821,10 +823,12 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) { | |||
| 821 | usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorProduct; | 823 | usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorProduct; |
| 822 | len = usbStringDescriptorProduct.header.bLength; | 824 | len = usbStringDescriptorProduct.header.bLength; |
| 823 | break; | 825 | break; |
| 826 | #if defined(SERIAL_NUMBER) | ||
| 824 | case 3: // iSerialNumber | 827 | case 3: // iSerialNumber |
| 825 | usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorSerial; | 828 | usbMsgPtr = (usbMsgPtr_t)&usbStringDescriptorSerial; |
| 826 | len = usbStringDescriptorSerial.header.bLength; | 829 | len = usbStringDescriptorSerial.header.bLength; |
| 827 | break; | 830 | break; |
| 831 | #endif | ||
| 828 | } | 832 | } |
| 829 | break; | 833 | break; |
| 830 | case USBDESCR_HID: | 834 | case USBDESCR_HID: |
