projects
/
pub
/
USBasp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cleanup and optimization of the internal serial retrieval routines.
[pub/USBasp.git]
/
LUFA
/
Drivers
/
USB
/
LowLevel
/
DevChapter9.c
diff --git
a/LUFA/Drivers/USB/LowLevel/DevChapter9.c
b/LUFA/Drivers/USB/LowLevel/DevChapter9.c
index
7fecd1f
..
f9c52e6
100644
(file)
--- a/
LUFA/Drivers/USB/LowLevel/DevChapter9.c
+++ b/
LUFA/Drivers/USB/LowLevel/DevChapter9.c
@@
-227,6
+227,12
@@
void USB_Device_GetConfiguration(void)
}
\r
\r
#if !defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
\r
}
\r
\r
#if !defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
\r
+static char USB_Device_NibbleToASCII(uint8_t Nibble)
\r
+{
\r
+ Nibble = ((Nibble & 0x0F) + '0');
\r
+ return (Nibble > '9') ? (Nibble + ('A' - '9' - 1)) : Nibble;
\r
+}
\r
+
\r
static void USB_Device_GetInternalSerialDescriptor(void)
\r
{
\r
struct
\r
static void USB_Device_GetInternalSerialDescriptor(void)
\r
{
\r
struct
\r
@@
-234,9
+240,6
@@
static void USB_Device_GetInternalSerialDescriptor(void)
USB_Descriptor_Header_t Header;
\r
int16_t UnicodeString[20];
\r
} SignatureDescriptor;
\r
USB_Descriptor_Header_t Header;
\r
int16_t UnicodeString[20];
\r
} SignatureDescriptor;
\r
-
\r
- uint8_t SigReadAddress = 0x0E;
\r
- bool OddNibbleRead = false;
\r
\r
#if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)
\r
SignatureDescriptor.Header.Size = sizeof(SignatureDescriptor);
\r
\r
#if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)
\r
SignatureDescriptor.Header.Size = sizeof(SignatureDescriptor);
\r
@@
-246,28
+249,19
@@
static void USB_Device_GetInternalSerialDescriptor(void)
SignatureDescriptor.Header.bDescriptorType = DTYPE_String;
\r
#endif
\r
\r
SignatureDescriptor.Header.bDescriptorType = DTYPE_String;
\r
#endif
\r
\r
+ uint8_t SigReadAddress = 0x0E;
\r
+
\r
for (uint8_t SerialCharNum = 0; SerialCharNum < 20; SerialCharNum++)
\r
{
\r
uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
\r
\r
for (uint8_t SerialCharNum = 0; SerialCharNum < 20; SerialCharNum++)
\r
{
\r
uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
\r
\r
- if (
OddNibbleRead
)
\r
+ if (
SerialCharNum & 0x01
)
\r
{
\r
SerialByte >>= 4;
\r
SigReadAddress++;
\r
}
\r
{
\r
SerialByte >>= 4;
\r
SigReadAddress++;
\r
}
\r
- else
\r
- {
\r
- SerialByte &= 0x0F;
\r
- }
\r
\r
\r
- OddNibbleRead = !(OddNibbleRead);
\r
-
\r
- if (SerialByte < 0x0A)
\r
- SerialByte += '0';
\r
- else
\r
- SerialByte += ('A' - 0x0A);
\r
-
\r
- SignatureDescriptor.UnicodeString[SerialCharNum] = SerialByte;
\r
+ SignatureDescriptor.UnicodeString[SerialCharNum] = USB_Device_NibbleToASCII(SerialByte);
\r
}
\r
\r
Endpoint_ClearSETUP();
\r
}
\r
\r
Endpoint_ClearSETUP();
\r