aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2017-11-17 11:53:46 -0500
committerGitHub <noreply@github.com>2017-11-17 11:53:46 -0500
commitf5a9758cea0cf65e4c4270aa55738e423213b82c (patch)
tree97a65d36de7418a15bc2dc8de196defce80fc099
parentf07e2cdd9df32fc26495bff37369cf5f6c13e23f (diff)
downloadqmk_firmware-f5a9758cea0cf65e4c4270aa55738e423213b82c.tar.gz
qmk_firmware-f5a9758cea0cf65e4c4270aa55738e423213b82c.zip
Adds serial number string to USB descriptors (#1996)
* add serial number string to usb descriptors * better name for serial number
-rw-r--r--tmk_core/protocol/lufa/descriptor.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/tmk_core/protocol/lufa/descriptor.c b/tmk_core/protocol/lufa/descriptor.c
index 357954368..e9f7f8730 100644
--- a/tmk_core/protocol/lufa/descriptor.c
+++ b/tmk_core/protocol/lufa/descriptor.c
@@ -275,7 +275,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
275 275
276 .ManufacturerStrIndex = 0x01, 276 .ManufacturerStrIndex = 0x01,
277 .ProductStrIndex = 0x02, 277 .ProductStrIndex = 0x02,
278 .SerialNumStrIndex = NO_DESCRIPTOR, 278 .SerialNumStrIndex = 0x03,
279 279
280 .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS 280 .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
281}; 281};
@@ -860,6 +860,18 @@ const USB_Descriptor_String_t PROGMEM ProductString =
860 .UnicodeString = LSTR(PRODUCT) 860 .UnicodeString = LSTR(PRODUCT)
861}; 861};
862 862
863#ifndef SERIAL_NUMBER
864 #define SERIAL_NUMBER 0
865#endif
866
867const USB_Descriptor_String_t PROGMEM SerialNumberString =
868{
869 /* subtract 1 for null terminator */
870 .Header = {.Size = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER))-1), .Type = DTYPE_String},
871
872 .UnicodeString = LSTR(SERIAL_NUMBER)
873};
874
863 875
864/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" 876/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
865 * documentation) by the application code so that the address and size of a requested descriptor can be given 877 * documentation) by the application code so that the address and size of a requested descriptor can be given
@@ -902,6 +914,10 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
902 Address = &ProductString; 914 Address = &ProductString;
903 Size = pgm_read_byte(&ProductString.Header.Size); 915 Size = pgm_read_byte(&ProductString.Header.Size);
904 break; 916 break;
917 case 0x03:
918 Address = &SerialNumberString;
919 Size = pgm_read_byte(&SerialNumberString.Header.Size);
920 break;
905 } 921 }
906 break; 922 break;
907 case HID_DTYPE_HID: 923 case HID_DTYPE_HID: