Simplify the internal serial extraction routines for each architecture.
[pub/USBasp.git] / LUFA / Drivers / USB / Core / UC3 / Device_UC3.h
index 59897a7..8389d62 100644 (file)
                                 *  number for the device.\r
                                 */\r
                                #define USE_INTERNAL_SERIAL           0xDC\r
+                               \r
+                               /** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller\r
+                                *  model.\r
+                                */\r
+                               #define INTERNAL_SERIAL_LENGTH_BITS   120\r
                        #else\r
                                #define USE_INTERNAL_SERIAL           NO_DESCRIPTOR\r
-                       #endif  \r
+\r
+                               #define INTERNAL_SERIAL_LENGTH_BITS   0\r
+                       #endif\r
                        \r
                /* Function Prototypes: */\r
                        /** Sends a Remote Wakeup request to the host. This signals to the host that the device should\r
                                return AVR32_USBB.UDCON.adden;\r
                        }\r
 \r
-                       static inline uint8_t USB_Device_GetSerialString(uint16_t* UnicodeString, const uint8_t MaxLen)\r
+                       static inline void USB_Device_GetSerialString(uint16_t* UnicodeString)\r
                        {\r
-                               uint8_t SerialCharNum = 0;\r
-\r
                                ATOMIC_BLOCK(ATOMIC_RESTORESTATE)\r
                                {\r
-                                       uint32_t* SigReadAddress = 0x80800204;\r
+                                       uint8_t* SigReadAddress = (uint8_t*)0x80800204;\r
 \r
-                                       for (SerialCharNum = 0; SerialCharNum < MIN(MaxLen, 30); SerialCharNum++)\r
+                                       for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++)\r
                                        {\r
-                                               if (SerialCharNum == MaxLen)\r
-                                                 break;\r
-\r
                                                uint8_t SerialByte = *SigReadAddress;\r
 \r
                                                if (SerialCharNum & 0x01)\r
                                                                                           (('A' - 10) + SerialByte) : ('0' + SerialByte));\r
                                        }\r
                                }\r
-                               \r
-                               return SerialCharNum;\r
                        }\r
        #endif\r
 \r