aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/Core/UC3
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2011-03-13 22:42:08 +0000
committerDean Camera <dean@fourwalledcubicle.com>2011-03-13 22:42:08 +0000
commita7eca42996418a7fd87b3411deb368e41615f9a1 (patch)
tree1cace684d438f8667138ddd01fa9414d893dd7de /LUFA/Drivers/USB/Core/UC3
parent81fd8d4004247f169987acb2b5b4225bae651baf (diff)
downloadlufa-a7eca42996418a7fd87b3411deb368e41615f9a1.tar.gz
lufa-a7eca42996418a7fd87b3411deb368e41615f9a1.tar.bz2
lufa-a7eca42996418a7fd87b3411deb368e41615f9a1.zip
Add experimental support for the AVR32 UC3A4 microcontrollers.
Add support for the inbuilt unique serial numbers in the UC3A3 and UC3A4 models.
Diffstat (limited to 'LUFA/Drivers/USB/Core/UC3')
-rw-r--r--LUFA/Drivers/USB/Core/UC3/Device_UC3.h57
-rw-r--r--LUFA/Drivers/USB/Core/UC3/USBController_UC3.h2
2 files changed, 48 insertions, 11 deletions
diff --git a/LUFA/Drivers/USB/Core/UC3/Device_UC3.h b/LUFA/Drivers/USB/Core/UC3/Device_UC3.h
index 653044f38..59897a769 100644
--- a/LUFA/Drivers/USB/Core/UC3/Device_UC3.h
+++ b/LUFA/Drivers/USB/Core/UC3/Device_UC3.h
@@ -77,16 +77,22 @@
#define USB_DEVICE_OPT_FULLSPEED (0 << 0)
//@}
- /** String descriptor index for the device's unique serial number string descriptor within the device.
- * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port
- * number allocations) to a device regardless of the port it is plugged in to on the host. Some microcontrollers contain
- * a unique serial number internally, and setting the device descriptors serial number string index to this value
- * will cause it to use the internal serial number.
- *
- * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial
- * number for the device.
- */
- #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
+ #if (!defined(NO_INTERNAL_SERIAL) && \
+ (defined(USB_SERIES_UC3A3_AVR) || defined(USB_SERIES_UC3A4_AVR) || \
+ defined(__DOXYGEN__)))
+ /** String descriptor index for the device's unique serial number string descriptor within the device.
+ * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port
+ * number allocations) to a device regardless of the port it is plugged in to on the host. Some microcontrollers contain
+ * a unique serial number internally, and setting the device descriptors serial number string index to this value
+ * will cause it to use the internal serial number.
+ *
+ * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial
+ * number for the device.
+ */
+ #define USE_INTERNAL_SERIAL 0xDC
+ #else
+ #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
+ #endif
/* Function Prototypes: */
/** Sends a Remote Wakeup request to the host. This signals to the host that the device should
@@ -171,6 +177,37 @@
{
return AVR32_USBB.UDCON.adden;
}
+
+ static inline uint8_t USB_Device_GetSerialString(uint16_t* UnicodeString, const uint8_t MaxLen)
+ {
+ uint8_t SerialCharNum = 0;
+
+ ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
+ {
+ uint32_t* SigReadAddress = 0x80800204;
+
+ for (SerialCharNum = 0; SerialCharNum < MIN(MaxLen, 30); SerialCharNum++)
+ {
+ if (SerialCharNum == MaxLen)
+ break;
+
+ uint8_t SerialByte = *SigReadAddress;
+
+ if (SerialCharNum & 0x01)
+ {
+ SerialByte >>= 4;
+ SigReadAddress++;
+ }
+
+ SerialByte &= 0x0F;
+
+ UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ?
+ (('A' - 10) + SerialByte) : ('0' + SerialByte));
+ }
+ }
+
+ return SerialCharNum;
+ }
#endif
#endif
diff --git a/LUFA/Drivers/USB/Core/UC3/USBController_UC3.h b/LUFA/Drivers/USB/Core/UC3/USBController_UC3.h
index c975bb3e9..8b29628ed 100644
--- a/LUFA/Drivers/USB/Core/UC3/USBController_UC3.h
+++ b/LUFA/Drivers/USB/Core/UC3/USBController_UC3.h
@@ -294,7 +294,7 @@
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
- #if defined(USB_SERIES_UC3A3_AVR)
+ #if (defined(USB_SERIES_UC3A3_AVR) || defined(USB_SERIES_UC3A4_AVR))
#define USB_CLOCK_REQUIRED_FREQ 12000000UL
#else
#define USB_CLOCK_REQUIRED_FREQ 48000000UL