diff options
Diffstat (limited to 'LUFA/Drivers/USB/LowLevel')
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/DevChapter9.c | 32 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/DevChapter9.h | 12 |
2 files changed, 43 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
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.h b/LUFA/Drivers/USB/LowLevel/DevChapter9.h index 68cb2c448..65fa0418c 100644 --- a/LUFA/Drivers/USB/LowLevel/DevChapter9.h +++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.h @@ -35,6 +35,9 @@ #include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
+ #include <avr/boot.h>
+ #include <stdlib.h>
+ #include <ctype.h>
#include "../HighLevel/StdDescriptors.h"
#include "../HighLevel/Events.h"
@@ -42,6 +45,15 @@ #include "../HighLevel/USBTask.h"
#include "LowLevel.h"
+ /* Preprocessor Checks: */
+ #if defined(USE_INTERNAL_SERIAL) && !(defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
+ #error USE_INTERNAL_SERIAL invalid, the selected AVR model does not contain unique serial bytes.
+ #endif
+
+ #if defined(USE_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL <= 1)
+ #error USE_INTERNAL_SERIAL must be defined to the string descriptor index chosen for the serial number descriptor.
+ #endif
+
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
extern "C" {
|