diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2011-03-13 22:42:08 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2011-03-13 22:42:08 +0000 |
commit | a7eca42996418a7fd87b3411deb368e41615f9a1 (patch) | |
tree | 1cace684d438f8667138ddd01fa9414d893dd7de /LUFA | |
parent | 81fd8d4004247f169987acb2b5b4225bae651baf (diff) | |
download | lufa-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')
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h | 12 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/DeviceStandardReq.c | 6 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/StdDescriptors.h | 18 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/UC3/Device_UC3.h | 57 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/UC3/USBController_UC3.h | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/USBMode.h | 6 | ||||
-rw-r--r-- | LUFA/ManPages/DeviceSupport.txt | 6 |
7 files changed, 78 insertions, 29 deletions
diff --git a/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h index dbbe884ff..dc8630257 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h @@ -87,9 +87,9 @@ //@} #if (!defined(NO_INTERNAL_SERIAL) && \ - (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) || \ - defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || \ - defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__))) + (defined(USB_SERIES_7_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_4_AVR) || \ + (defined(USB_SERIES_2_AVR) && (!defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__))) || \ + 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 @@ -190,7 +190,7 @@ return (UDADDR & (1 << ADDEN)); } - static inline uint8_t USB_Device_GetSerialString(wchar_t* UnicodeString, const uint8_t MaxLen) + static inline uint8_t USB_Device_GetSerialString(uint16_t* UnicodeString, const uint8_t MaxLen) { uint8_t SerialCharNum = 0; @@ -213,8 +213,8 @@ SerialByte &= 0x0F; - UnicodeString[SerialCharNum] = (SerialByte >= 10) ? - (('A' - 10) + SerialByte) : ('0' + SerialByte); + UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ? + (('A' - 10) + SerialByte) : ('0' + SerialByte)); } } diff --git a/LUFA/Drivers/USB/Core/DeviceStandardReq.c b/LUFA/Drivers/USB/Core/DeviceStandardReq.c index 4ee2fce06..a2270f4d2 100644 --- a/LUFA/Drivers/USB/Core/DeviceStandardReq.c +++ b/LUFA/Drivers/USB/Core/DeviceStandardReq.c @@ -204,12 +204,12 @@ static void USB_Device_GetInternalSerialDescriptor(void) struct { USB_Descriptor_Header_t Header; - wchar_t UnicodeString[20]; + uint16_t UnicodeString[20]; } SignatureDescriptor; SignatureDescriptor.Header.Type = DTYPE_String; - SignatureDescriptor.Header.Size = USB_Device_GetSerialString(SignatureDescriptor.UnicodeString, - sizeof(SignatureDescriptor.UnicodeString)); + SignatureDescriptor.Header.Size = USB_STRING_LEN(USB_Device_GetSerialString(SignatureDescriptor.UnicodeString, + sizeof(SignatureDescriptor.UnicodeString) / sizeof(SignatureDescriptor.UnicodeString[0]))); Endpoint_ClearSETUP(); diff --git a/LUFA/Drivers/USB/Core/StdDescriptors.h b/LUFA/Drivers/USB/Core/StdDescriptors.h index 908f27bcd..32777cc0f 100644 --- a/LUFA/Drivers/USB/Core/StdDescriptors.h +++ b/LUFA/Drivers/USB/Core/StdDescriptors.h @@ -645,15 +645,15 @@ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t * or a value given by the specific class. */ - int16_t bString[]; /**< String data, as unicode characters (alternatively, string language IDs). - * If normal ASCII characters are to be used, they must be added as an array - * of characters rather than a normal C string so that they are widened to - * Unicode size. - * - * Under GCC, strings prefixed with the "L" character (before the opening string - * quotation mark) are considered to be Unicode strings, and may be used instead - * of an explicit array of ASCII characters. - */ + uint16_t bString[]; /**< String data, as unicode characters (alternatively, string language IDs). + * If normal ASCII characters are to be used, they must be added as an array + * of characters rather than a normal C string so that they are widened to + * Unicode size. + * + * Under GCC, strings prefixed with the "L" character (before the opening string + * quotation mark) are considered to be Unicode strings, and may be used instead + * of an explicit array of ASCII characters. + */ } ATTR_PACKED USB_StdDescriptor_String_t; /* Private Interface - For use in library only: */ 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
diff --git a/LUFA/Drivers/USB/Core/USBMode.h b/LUFA/Drivers/USB/Core/USBMode.h index e563e5669..4fb65be38 100644 --- a/LUFA/Drivers/USB/Core/USBMode.h +++ b/LUFA/Drivers/USB/Core/USBMode.h @@ -153,6 +153,12 @@ #define USB_SERIES_UC3A3_AVR #define USB_CAN_BE_DEVICE #define USB_CAN_BE_HOST + #elif (defined(__AVR32_UC3A4256__) || defined(__AVR32_UC3A4256S__) || \ + defined(__AVR32_UC3A4128__) || defined(__AVR32_UC3A4128S__) || \ + defined(__AVR32_UC3A464__) || defined(__AVR32_UC3A464S__)) + #define USB_SERIES_UC3A4_AVR + #define USB_CAN_BE_DEVICE + #define USB_CAN_BE_HOST #elif (defined(__AVR32_UC3B0512__) || defined(__AVR32_UC3B0256__) || \ defined(__AVR32_UC3B0128__) || defined(__AVR32_UC3B064__)) #define USB_SERIES_UC3B0_AVR diff --git a/LUFA/ManPages/DeviceSupport.txt b/LUFA/ManPages/DeviceSupport.txt index f93dbb277..2381d2a9e 100644 --- a/LUFA/ManPages/DeviceSupport.txt +++ b/LUFA/ManPages/DeviceSupport.txt @@ -15,18 +15,24 @@ * - AT32UC3A164 (USB Host and Device) * - AT32UC3A364 (USB Host and Device) * - AT32UC3A364S (USB Host and Device) + * - AT32UC3A464 (USB Host and Device) + * - AT32UC3A464S (USB Host and Device) * - AT32UC3B064 (USB Host and Device) * - AT32UC3B164 (USB Host and Device) * - AT32UC3A0128 (USB Host and Device) * - AT32UC3A1128 (USB Host and Device) * - AT32UC3A3128 (USB Host and Device) * - AT32UC3A3128S (USB Host and Device) + * - AT32UC3A4128 (USB Host and Device) + * - AT32UC3A4128S (USB Host and Device) * - AT32UC3B0128 (USB Host and Device) * - AT32UC3B1128 (USB Host and Device) * - AT32UC3A0256 (USB Host and Device) * - AT32UC3A1256 (USB Host and Device) * - AT32UC3A3256 (USB Host and Device) * - AT32UC3A3256S (USB Host and Device) + * - AT32UC3A4256 (USB Host and Device) + * - AT32UC3A4256S (USB Host and Device) * - AT32UC3B0256 (USB Host and Device) * - AT32UC3B1256 (USB Host and Device) * - AT32UC3A0512 (USB Host and Device) |