Fixed possible invalid program execution when in host mode if corrupt descriptor...
[pub/lufa.git] / LUFA / Drivers / USB / Core / UC3 / Device_UC3.h
index ed74098..8bc8188 100644 (file)
                                 *  On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial\r
                                 *  number for the device.\r
                                 */\r
-                               #define USE_INTERNAL_SERIAL           0xDC\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
+                               #define INTERNAL_SERIAL_LENGTH_BITS     120\r
+\r
+                               /** Start address of the internal serial number, in the appropriate address space, if present on the selected microcontroller\r
+                                *  model.\r
+                                */\r
+                               #define INTERNAL_SERIAL_START_ADDRESS   0x80800204\r
                        #else\r
-                               #define USE_INTERNAL_SERIAL           NO_DESCRIPTOR\r
+                               #define USE_INTERNAL_SERIAL             NO_DESCRIPTOR\r
 \r
-                               #define INTERNAL_SERIAL_LENGTH_BITS   0\r
+                               #define INTERNAL_SERIAL_LENGTH_BITS     0\r
+                               #define INTERNAL_SERIAL_START_ADDRESS   0\r
                        #endif\r
-                       \r
+                                               \r
                /* Function Prototypes: */\r
                        /** Sends a Remote Wakeup request to the host. This signals to the host that the device should\r
                         *  be taken out of suspended mode, and communications should resume.\r
                                return AVR32_USBB.UDCON.adden;\r
                        }\r
 \r
-                       static inline void USB_Device_GetSerialString(uint16_t* UnicodeString)\r
+                       #if (USE_INTERNAL_SERIAL != NO_DESCRIPTOR)\r
+                       static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString)\r
                        {\r
                                uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();\r
                                GlobalInterruptDisable();\r
                                \r
-                               uint8_t* SigReadAddress = (uint8_t*)0x80800204;\r
+                               uint8_t* SigReadAddress = (uint8_t*)INTERNAL_SERIAL_START_ADDRESS;\r
 \r
                                for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++)\r
                                {\r
                                \r
                                SetGlobalInterruptMask(CurrentGlobalInt);\r
                        }\r
+                       #endif\r
+\r
        #endif\r
 \r
 #endif\r