#define USB_DEVICE_OPT_FULLSPEED (0 << 0)\r
//@}\r
\r
- /** String descriptor index for the device's unique serial number string descriptor within the device.\r
- * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port\r
- * number allocations) to a device regardless of the port it is plugged in to on the host. Some microcontrollers contain\r
- * a unique serial number internally, and setting the device descriptors serial number string index to this value\r
- * will cause it to use the internal serial number.\r
- *\r
- * 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 NO_DESCRIPTOR\r
+ #if (!defined(NO_INTERNAL_SERIAL) && \\r
+ (defined(USB_SERIES_UC3A3_AVR) || defined(USB_SERIES_UC3A4_AVR) || \\r
+ defined(__DOXYGEN__)))\r
+ /** String descriptor index for the device's unique serial number string descriptor within the device.\r
+ * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port\r
+ * number allocations) to a device regardless of the port it is plugged in to on the host. Some microcontrollers contain\r
+ * a unique serial number internally, and setting the device descriptors serial number string index to this value\r
+ * will cause it to use the internal serial number.\r
+ *\r
+ * 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
+ #else\r
+ #define USE_INTERNAL_SERIAL NO_DESCRIPTOR\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
{\r
return AVR32_USBB.UDCON.adden;\r
}\r
+\r
+ static inline uint8_t USB_Device_GetSerialString(uint16_t* UnicodeString, const uint8_t MaxLen)\r
+ {\r
+ uint8_t SerialCharNum = 0;\r
+\r
+ ATOMIC_BLOCK(ATOMIC_RESTORESTATE)\r
+ {\r
+ uint32_t* SigReadAddress = 0x80800204;\r
+\r
+ for (SerialCharNum = 0; SerialCharNum < MIN(MaxLen, 30); SerialCharNum++)\r
+ {\r
+ if (SerialCharNum == MaxLen)\r
+ break;\r
+\r
+ uint8_t SerialByte = *SigReadAddress;\r
+\r
+ if (SerialCharNum & 0x01)\r
+ {\r
+ SerialByte >>= 4;\r
+ SigReadAddress++;\r
+ }\r
+\r
+ SerialByte &= 0x0F;\r
+\r
+ UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ?\r
+ (('A' - 10) + SerialByte) : ('0' + SerialByte));\r
+ }\r
+ }\r
+ \r
+ return SerialCharNum;\r
+ }\r
#endif\r
\r
#endif\r