aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-08-03 07:10:54 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-08-03 07:10:54 +0000
commit840d386deb6736169085ec86ac9cb4d204072281 (patch)
tree3cecbeb7c3c4840a926a380c8160d449bafa7996
parentab2ae13d81427ddddbd24e8ba6bdfbd2f05ff958 (diff)
downloadlufa-840d386deb6736169085ec86ac9cb4d204072281.tar.gz
lufa-840d386deb6736169085ec86ac9cb4d204072281.tar.bz2
lufa-840d386deb6736169085ec86ac9cb4d204072281.zip
Cleanup and optimization of the internal serial retrieval routines.
Renamed ATTR_NOINLINE to ATTR_NO_INLINE to fit with the rest of the library function attribute names.
-rw-r--r--LUFA/Common/FunctionAttributes.h2
-rw-r--r--LUFA/Drivers/USB/LowLevel/DevChapter9.c26
-rw-r--r--LUFA/Drivers/USB/LowLevel/DevChapter9.h1
3 files changed, 12 insertions, 17 deletions
diff --git a/LUFA/Common/FunctionAttributes.h b/LUFA/Common/FunctionAttributes.h
index 9efa440e5..9a293b619 100644
--- a/LUFA/Common/FunctionAttributes.h
+++ b/LUFA/Common/FunctionAttributes.h
@@ -87,7 +87,7 @@
/** Prevents the compiler from considering a specified function for inlining. When applied, the given
* function will not be inlined under any circumstances.
*/
- #define ATTR_NOINLINE __attribute__ ((noinline))
+ #define ATTR_NO_INLINE __attribute__ ((noinline))
/** Forces the compiler to inline the specified function. When applied, the given function will be
* inlined under all circumstances.
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c
index 7fecd1f54..f9c52e666 100644
--- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c
+++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c
@@ -227,6 +227,12 @@ void USB_Device_GetConfiguration(void)
}
#if !defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
+static char USB_Device_NibbleToASCII(uint8_t Nibble)
+{
+ Nibble = ((Nibble & 0x0F) + '0');
+ return (Nibble > '9') ? (Nibble + ('A' - '9' - 1)) : Nibble;
+}
+
static void USB_Device_GetInternalSerialDescriptor(void)
{
struct
@@ -234,9 +240,6 @@ static void USB_Device_GetInternalSerialDescriptor(void)
USB_Descriptor_Header_t Header;
int16_t UnicodeString[20];
} SignatureDescriptor;
-
- uint8_t SigReadAddress = 0x0E;
- bool OddNibbleRead = false;
#if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)
SignatureDescriptor.Header.Size = sizeof(SignatureDescriptor);
@@ -246,28 +249,19 @@ static void USB_Device_GetInternalSerialDescriptor(void)
SignatureDescriptor.Header.bDescriptorType = DTYPE_String;
#endif
+ uint8_t SigReadAddress = 0x0E;
+
for (uint8_t SerialCharNum = 0; SerialCharNum < 20; SerialCharNum++)
{
uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
- if (OddNibbleRead)
+ if (SerialCharNum & 0x01)
{
SerialByte >>= 4;
SigReadAddress++;
}
- else
- {
- SerialByte &= 0x0F;
- }
- OddNibbleRead = !(OddNibbleRead);
-
- if (SerialByte < 0x0A)
- SerialByte += '0';
- else
- SerialByte += ('A' - 0x0A);
-
- SignatureDescriptor.UnicodeString[SerialCharNum] = SerialByte;
+ SignatureDescriptor.UnicodeString[SerialCharNum] = USB_Device_NibbleToASCII(SerialByte);
}
Endpoint_ClearSETUP();
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.h b/LUFA/Drivers/USB/LowLevel/DevChapter9.h
index a856dede4..a70dd066e 100644
--- a/LUFA/Drivers/USB/LowLevel/DevChapter9.h
+++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.h
@@ -124,6 +124,7 @@
static void USB_Device_ClearSetFeature(void);
#if !defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
+ static char USB_Device_NibbleToASCII(uint8_t Nibble) ATTR_ALWAYS_INLINE;
static void USB_Device_GetInternalSerialDescriptor(void);
#endif
#endif