diff options
Diffstat (limited to 'LUFA/Drivers/USB/LowLevel')
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/DevChapter9.c | 96 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/DevChapter9.h | 4 |
2 files changed, 55 insertions, 45 deletions
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c index f49f5b39b..231821646 100644 --- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c +++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c @@ -174,59 +174,65 @@ void USB_Device_GetConfiguration(void) Endpoint_ClearOUT();
}
-static void USB_Device_GetDescriptor(void)
+#if !defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
+static void USB_Device_GetInternalSerialDescriptor(void)
{
- void* DescriptorPointer;
- uint16_t DescriptorSize;
+ struct
+ {
+ USB_Descriptor_Header_t Header;
+ int16_t UnicodeString[12];
+ } SignatureDescriptor;
- #if !defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
- if (USB_ControlRequest.wValue == ((DTYPE_String << 8) | USE_INTERNAL_SERIAL))
+ uint8_t SigReadAddress = 0x0E;
+ bool OddNibbleRead = false;
+
+ #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)
+ SignatureDescriptor.Header.Size = sizeof(SignatureDescriptor);
+ SignatureDescriptor.Header.Type = DTYPE_String;
+ #else
+ SignatureDescriptor.Header.bLength = sizeof(SignatureDescriptor);
+ SignatureDescriptor.Header.bDescriptorType = DTYPE_String;
+ #endif
+
+ for (uint8_t SerialCharNum = 0; SerialCharNum < 12; SerialCharNum++)
{
- struct
- {
- USB_Descriptor_Header_t Header;
- int16_t UnicodeString[12];
- } SignatureDescriptor;
-
- #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)
- SignatureDescriptor.Header.Size = sizeof(SignatureDescriptor);
- SignatureDescriptor.Header.Type = DTYPE_String;
- #else
- SignatureDescriptor.Header.bLength = sizeof(SignatureDescriptor);
- SignatureDescriptor.Header.bDescriptorType = DTYPE_String;
- #endif
+ uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
- uint8_t SigReadAddress = 0x0E;
- bool OddRead = false;
-
- for (uint8_t SerialCharNum = 0; SerialCharNum < 12; SerialCharNum++)
+ if (OddNibbleRead)
{
- uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
-
- if (OddRead)
- {
- SerialByte >>= 4;
- SigReadAddress++;
- }
- else
- {
- SerialByte &= 0x0F;
- }
-
- OddRead = !(OddRead);
-
- if (SerialByte < 0x0A)
- SerialByte += '0';
- else
- SerialByte += ('A' - 0x0A);
-
- SignatureDescriptor.UnicodeString[SerialCharNum] = SerialByte;
+ SerialByte >>= 4;
+ SigReadAddress++;
+ }
+ else
+ {
+ SerialByte &= 0x0F;
}
- Endpoint_ClearSETUP();
- Endpoint_Write_Control_Stream_LE(&SignatureDescriptor, sizeof(SignatureDescriptor));
- Endpoint_ClearOUT();
+ OddNibbleRead = !(OddNibbleRead);
+
+ if (SerialByte < 0x0A)
+ SerialByte += '0';
+ else
+ SerialByte += ('A' - 0x0A);
+
+ SignatureDescriptor.UnicodeString[SerialCharNum] = SerialByte;
+ }
+
+ Endpoint_ClearSETUP();
+ Endpoint_Write_Control_Stream_LE(&SignatureDescriptor, sizeof(SignatureDescriptor));
+ Endpoint_ClearOUT();
+}
+#endif
+static void USB_Device_GetDescriptor(void)
+{
+ void* DescriptorPointer;
+ uint16_t DescriptorSize;
+
+ #if !defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
+ if (USB_ControlRequest.wValue == ((DTYPE_String << 8) | USE_INTERNAL_SERIAL))
+ {
+ USB_Device_GetInternalSerialDescriptor();
return;
}
#endif
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.h b/LUFA/Drivers/USB/LowLevel/DevChapter9.h index fdef72757..2640cbba1 100644 --- a/LUFA/Drivers/USB/LowLevel/DevChapter9.h +++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.h @@ -99,6 +99,10 @@ static void USB_Device_GetDescriptor(void);
static void USB_Device_GetStatus(void);
static void USB_Device_ClearSetFeature(void);
+
+ #if !defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
+ static void USB_Device_GetInternalSerialDescriptor(void);
+ #endif
#endif
#endif
|