Add experimental support for the UC3A0, UC3A1 and UC3A3 series AVR32 microcontrollers.
authorDean Camera <dean@fourwalledcubicle.com>
Sun, 13 Mar 2011 21:25:05 +0000 (21:25 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Sun, 13 Mar 2011 21:25:05 +0000 (21:25 +0000)
LUFA/Common/Common.h
LUFA/Drivers/USB/Core/StdDescriptors.h
LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.c
LUFA/Drivers/USB/Core/UC3B/USBController_UC3B.h
LUFA/Drivers/USB/Core/USBMode.h

index c2eeead..80bafce 100644 (file)
                         */
                        #define GCC_FORCE_POINTER_ACCESS(StructPtr) __asm__ __volatile__("" : "=b" (StructPtr) : "0" (StructPtr))
 
+                       /** Forces GCC to create a memory barrier, ensuring that memory accesses are not reordered past the barrier point.
+                        *  This can be used before ordering-critical operations, to ensure that the compiler does not re-order the resulting
+                        *  assembly output in an unexpected manner on sections of code that are ordering-specific.
+                        */
+                       #define GCC_MEMORY_BARRIER()                __asm__ __volatile__("" ::: "memory");
+
                /* Inline Functions: */
                        /** Function to reverse the individual bits in a byte - i.e. bit 7 is moved to bit 0, bit 6 to bit 1,
                         *  etc.
index 1ad1497..908f27b 100644 (file)
                         */
                        #define NO_DESCRIPTOR                     0
 
-                       /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes. */
+                       /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes.
+                        *
+                        *  \param[in] mA  Maximum number of milliamps the device consumes when the given configuration is selected.
+                        */
                        #define USB_CONFIG_POWER_MA(mA)           ((mA) >> 1)
 
                        /** Macro to calculate the Unicode length of a string with a given number of Unicode characters.
                         *  Should be used in string descriptor's headers for giving the string descriptor's byte length.
+                        *
+                        *  \param[in] UnicodeChars  Number of Unicode characters in the string text.
                         */
-                       #define USB_STRING_LEN(str)               (sizeof(USB_Descriptor_Header_t) + ((str) << 1))
+                       #define USB_STRING_LEN(UnicodeChars)      (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1))
 
                        /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded
                         *  Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the
                         *  standard device descriptor.
+                        *
+                        *  \param[in]  x  Version number to encode as a 16-bit little-endian number, as a floating point number.
                         */
                        #define VERSION_BCD(x)                    CPU_TO_LE16((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \
                                                                  ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x)))
index 8241e0b..40ac381 100644 (file)
@@ -104,11 +104,11 @@ void USB_ResetInterface(void)
        bool UIDModeSelectEnabled = AVR32_USBB.USBCON.uide;\r
        #endif\r
 \r
-       AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].pllsel = !(USB_Options & USB_OPT_GCLK_SRC_OSC);\r
-       AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].oscsel = !(USB_Options & USB_OPT_GCLK_CHANNEL_0);\r
-       AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].diven  = (F_CLOCK != 48000000UL);\r
-       AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].div    = (F_CLOCK == 48000000UL) ? 0 : (uint32_t)(((F_CLOCK / 48000000UL) - 1) / 2);\r
-       AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].cen    = true;\r
+       AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].pllsel = !(USB_Options & USB_OPT_GCLK_SRC_OSC);\r
+       AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].oscsel = !(USB_Options & USB_OPT_GCLK_CHANNEL_0);\r
+       AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].diven  = (F_CLOCK != USB_CLOCK_REQUIRED_FREQ);\r
+       AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].div    = (F_CLOCK == USB_CLOCK_REQUIRED_FREQ) ? 0 : (uint32_t)(((F_CLOCK / USB_CLOCK_REQUIRED_FREQ) - 1) / 2);\r
+       AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].cen    = true;\r
 \r
        USB_INT_DisableAllInterrupts();\r
        USB_INT_ClearAllInterrupts();\r
index 5bfcb5b..dde6f23 100644 (file)
 \r
        /* Private Interface - For use in library only: */\r
        #if !defined(__DOXYGEN__)\r
-               /* Macros: */\r
-                       #define USB_GCLK_USBB_INDEX          3\r
+               /* Macros: */                   \r
+                       #if defined(USB_SERIES_UC3A3_AVR)\r
+                               #define USB_CLOCK_REQUIRED_FREQ  12000000UL\r
+                       #else\r
+                               #define USB_CLOCK_REQUIRED_FREQ  48000000UL\r
+                       #endif\r
        \r
                /* Function Prototypes: */\r
                        #if defined(__INCLUDE_FROM_USB_CONTROLLER_C)\r
index 4acfda2..e563e56 100644 (file)
 
        /* Public Interface - May be used in end-application: */
        #if defined(__DOXYGEN__)
-               /** Indicates that the target AVR microcontroller belongs to the Series 2 USB controller
+               /** Indicates that the target AVR microcontroller belongs to the Series 2 AVR8 USB controller
                 *  (i.e. AT90USBxxx2 or ATMEGAxxU2) when defined.
                 */
                #define USB_SERIES_2_AVR
 
-               /** Indicates that the target AVR microcontroller belongs to the Series 4 USB controller
+               /** Indicates that the target AVR microcontroller belongs to the Series 4 AVR8 USB controller
                 *  (i.e. ATMEGAxxU4) when defined.
                 */
                #define USB_SERIES_4_AVR
 
-               /** Indicates that the target AVR microcontroller belongs to the Series 6 USB controller
+               /** Indicates that the target AVR microcontroller belongs to the Series 6 AVR8 USB controller
                 *  (i.e. AT90USBxxx6) when defined.
                 */
                #define USB_SERIES_6_AVR
 
-               /** Indicates that the target AVR microcontroller belongs to the Series 7 USB controller
+               /** Indicates that the target AVR microcontroller belongs to the Series 7 AVR8 USB controller
                 *  (i.e. AT90USBxxx7) when defined.
                 */
                #define USB_SERIES_7_AVR
 
-               /** Indicates that the target AVR microcontroller belongs to the UC3B Series USB controller
-                *  (i.e. AT32UC3B*) when defined.
+               /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A0 Series USB controller
+                *  (i.e. AT32UC3A0*) when defined.
                 */
-               #define USB_SERIES_UC3B_AVR
+               #define USB_SERIES_UC3A0_AVR
+               
+               /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A1 Series USB controller
+                *  (i.e. AT32UC3A1*) when defined.
+                */
+               #define USB_SERIES_UC3A1_AVR
+
+               /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A3 Series USB controller
+                *  (i.e. AT32UC3A3*) when defined.
+                */
+               #define USB_SERIES_UC3A3_AVR
+
+               /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3B0 Series USB controller
+                *  (i.e. AT32UC3B0*) when defined.
+                */
+               #define USB_SERIES_UC3B0_AVR
+
+               /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3B1 Series USB controller
+                *  (i.e. AT32UC3B1*) when defined.
+                */
+               #define USB_SERIES_UC3B1_AVR
 
                /** Indicates that the target microcontroller and compilation settings allow for the
                 *  target to be configured in USB Device mode when defined.
                                #define USB_SERIES_7_AVR
                                #define USB_CAN_BE_DEVICE
                                #define USB_CAN_BE_HOST
-                       #elif (defined(__AVR32_UC3B0512__) || defined(__AVR32_UC3B1512__) || \
-                              defined(__AVR32_UC3B0256__) || defined(__AVR32_UC3B1256__) || \
-                              defined(__AVR32_UC3B0128__) || defined(__AVR32_UC3B1128__) || \
-                              defined(__AVR32_UC3B064__) || defined(__AVR32_UC3B164__))
-                               #define USB_SERIES_UC3B_AVR
+                       #elif (defined(__AVR32_UC3A0512__) || defined(__AVR32_UC3A0256__) || \
+                              defined(__AVR32_UC3A0128__) || defined(__AVR32_UC3A064__))
+                               #define USB_SERIES_UC3A0_AVR
+                               #define USB_CAN_BE_DEVICE
+                               #define USB_CAN_BE_HOST
+                       #elif (defined(__AVR32_UC3A1512__) || defined(__AVR32_UC3A1256__) || \
+                              defined(__AVR32_UC3A1128__) || defined(__AVR32_UC3A164__))
+                               #define USB_SERIES_UC3A1_AVR
+                               #define USB_CAN_BE_DEVICE
+                               #define USB_CAN_BE_HOST
+                       #elif (defined(__AVR32_UC3A3256__) || defined(__AVR32_UC3A3256S__) || \
+                              defined(__AVR32_UC3A3128__) || defined(__AVR32_UC3A3128S__) || \
+                              defined(__AVR32_UC3A364__)  || defined(__AVR32_UC3A364S__))
+                               #define USB_SERIES_UC3A3_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
+                               #define USB_CAN_BE_DEVICE
+                               #define USB_CAN_BE_HOST
+                       #elif (defined(__AVR32_UC3B1512__) || defined(__AVR32_UC3B1256__) || \
+                              defined(__AVR32_UC3B1128__) || defined(__AVR32_UC3B164__))
+                               #define USB_SERIES_UC3B1_AVR
                                #define USB_CAN_BE_DEVICE
                                #define USB_CAN_BE_HOST
                        #endif
                        #endif
 
                        #if (!defined(USB_CAN_BE_DEVICE) && !defined(USB_CAN_BE_HOST))
-                               #error The currently selected architecture is not supported under the USB component of the library.
+                               #error The currently selected device or architecture is not supported under the USB component of the library.
                        #endif
        #endif