diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-06-20 11:43:26 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-06-20 11:43:26 +0000 |
commit | 00d0883507efdc17688abafa75e81bf62f83d777 (patch) | |
tree | efdf229555604f3c092557ac7ce638cf838dbdb2 /LUFA/Drivers/USB/LowLevel/DevChapter9.c | |
parent | 35bdada24b49c4dd1900a78a1595077b99814cf9 (diff) | |
download | lufa-00d0883507efdc17688abafa75e81bf62f83d777.tar.gz lufa-00d0883507efdc17688abafa75e81bf62f83d777.tar.bz2 lufa-00d0883507efdc17688abafa75e81bf62f83d777.zip |
Added USE_INTERNAL_SERIAL compile time option to automatically read out the internal unique serial number as the device's serial number descriptor on supported AVR models.
Diffstat (limited to 'LUFA/Drivers/USB/LowLevel/DevChapter9.c')
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/DevChapter9.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c index 829bd13e8..9acf30099 100644 --- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c +++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c @@ -179,6 +179,36 @@ static void USB_Device_GetDescriptor(void) void* DescriptorPointer;
uint16_t DescriptorSize;
+ #if defined(USE_INTERNAL_SERIAL)
+ if (USB_ControlRequest.wValue == ((DTYPE_String << 8) | USE_INTERNAL_SERIAL))
+ {
+ uint8_t SignatureDescriptor[2 + (sizeof(int16_t) * 20)];
+
+ SignatureDescriptor[0] = sizeof(SignatureDescriptor);
+ SignatureDescriptor[1] = DTYPE_String;
+
+ uint16_t* SigUnicodeChars = (uint16_t*)&SignatureDescriptor[2];
+
+ for (uint8_t SerialByteNum = 0; SerialByteNum < 10; SerialByteNum++)
+ {
+ char ConvSigString[3];
+
+ itoa(boot_signature_byte_get(0x0E + SerialByteNum), ConvSigString, 16);
+
+ SigUnicodeChars[0] = toupper(ConvSigString[0]);
+ SigUnicodeChars[1] = toupper(ConvSigString[1]);
+
+ SigUnicodeChars += 2;
+ }
+
+ Endpoint_ClearSETUP();
+ Endpoint_Write_Control_Stream_LE(SignatureDescriptor, sizeof(SignatureDescriptor));
+ Endpoint_ClearOUT();
+
+ return;
+ }
+ #endif
+
if ((DescriptorSize = CALLBACK_USB_GetDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex,
&DescriptorPointer)) == NO_DESCRIPTOR)
{
@@ -186,7 +216,7 @@ static void USB_Device_GetDescriptor(void) }
Endpoint_ClearSETUP();
-
+
#if defined(USE_RAM_DESCRIPTORS)
Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize);
#else
|