Add __VA_ARGS__ support to the LUFA supplied ISR macro. Add proper result typecasting...
authorDean Camera <dean@fourwalledcubicle.com>
Mon, 25 Apr 2011 07:28:36 +0000 (07:28 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Mon, 25 Apr 2011 07:28:36 +0000 (07:28 +0000)
Switch to using -1 on the UC3 target to obtain a register mask with all bits set (for clearing interrupts and status flags).

Fix incorrect USB controller mode on the UC3 when a fixed mode is specified as a compile time option due to AVR32_USBB.USBCON.uide being set by default.

Make USB_Descriptor_String_t use a uint16_t for Unicode strings on all targets except the AVR8 (retained for backwards compatibility).

LUFA/CodeTemplates/makefile_template.uc3
LUFA/Common/Common.h
LUFA/Common/Endianness.h
LUFA/Drivers/USB/Core/StdDescriptors.h
LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.c
LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c
LUFA/Drivers/USB/Core/UC3/USBController_UC3.c
LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.c

index 843d775..e56cb32 100644 (file)
@@ -236,9 +236,7 @@ ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-l
 #    -Map:      create map file\r
 #    --cref:    add cross reference to  map file\r
 LDFLAGS  = -Wl,-Map=$(TARGET).map,--cref\r
 #    -Map:      create map file\r
 #    --cref:    add cross reference to  map file\r
 LDFLAGS  = -Wl,-Map=$(TARGET).map,--cref\r
-LDFLAGS += -Wl,--relax \r
-LDFLAGS += -Wl,--gc-sections\r
-LDFLAGS += -Wl,--rodata-writable\r
+LDFLAGS += -Wl,--gc-sections --rodata-writable\r
 LDFLAGS += -Wl,--direct-data\r
 #LDFLAGS += -T linker_script.x\r
 \r
 LDFLAGS += -Wl,--direct-data\r
 #LDFLAGS += -T linker_script.x\r
 \r
index e349063..1fc47e0 100644 (file)
                                 *
                                 *  \param Name  Unique name of the interrupt service routine.
                                 */
                                 *
                                 *  \param Name  Unique name of the interrupt service routine.
                                 */
-                               #define ISR(Name, ...)                  void Name (void) __attribute__((__interrupt__)); void Name (void)
+                               #define ISR(Name, ...)                  void Name (void) __attribute__((__interrupt__)) __VA_ARGS__; void Name (void)
                        #endif
 
                /* Inline Functions: */
                        #endif
 
                /* Inline Functions: */
index ef8c1a7..115d054 100644 (file)
@@ -78,7 +78,7 @@
                         *\r
                         *  \return Input value with the byte ordering reversed.\r
                         */\r
                         *\r
                         *  \return Input value with the byte ordering reversed.\r
                         */\r
-                       #define SWAPENDIAN_16(x)          ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))\r
+                       #define SWAPENDIAN_16(x)            (uint16_t)((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))\r
 \r
                        /** Swaps the byte ordering of a 32-bit value at compile-time. Do not use this macro for swapping byte orderings\r
                         *  of dynamic values computed at runtime- use \ref SwapEndian_32() instead. The result of this macro can be used\r
 \r
                        /** Swaps the byte ordering of a 32-bit value at compile-time. Do not use this macro for swapping byte orderings\r
                         *  of dynamic values computed at runtime- use \ref SwapEndian_32() instead. The result of this macro can be used\r
@@ -91,8 +91,8 @@
                         *\r
                         *  \return Input value with the byte ordering reversed.\r
                         */\r
                         *\r
                         *  \return Input value with the byte ordering reversed.\r
                         */\r
-                       #define SWAPENDIAN_32(x)          ((((x) & 0xFF000000UL) >> 24UL) | (((x) & 0x00FF0000UL) >> 8UL) | \\r
-                                                          (((x) & 0x0000FF00UL) << 8UL)  | (((x) & 0x000000FFUL) << 24UL))\r
+                       #define SWAPENDIAN_32(x)            (uint32_t)((((x) & 0xFF000000UL) >> 24UL) | (((x) & 0x00FF0000UL) >> 8UL) | \\r
+                                                                      (((x) & 0x0000FF00UL) << 8UL)  | (((x) & 0x000000FFUL) << 24UL))\r
 \r
                        #if defined(ARCH_BIG_ENDIAN) && !defined(le16_to_cpu)\r
                                #define le16_to_cpu(x)           SwapEndian_16(x)\r
 \r
                        #if defined(ARCH_BIG_ENDIAN) && !defined(le16_to_cpu)\r
                                #define le16_to_cpu(x)           SwapEndian_16(x)\r
index 32777cc..7840bcb 100644 (file)
                        {
                                USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
 
                        {
                                USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
 
-                               wchar_t UnicodeString[]; /**< 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.
-                                                         */
+                               #if (ARCH == ARCH_AVR8)
+                               wchar_t  UnicodeString[];
+                               #else
+                               uint16_t UnicodeString[]; /**< 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.
+                                                          */
+                               #endif
                        } ATTR_PACKED USB_Descriptor_String_t;
 
                        /** \brief Standard USB String Descriptor (USB-IF naming conventions).
                        } ATTR_PACKED USB_Descriptor_String_t;
 
                        /** \brief Standard USB String Descriptor (USB-IF naming conventions).
index b978ec7..9c7d6b6 100644 (file)
@@ -61,7 +61,7 @@ void Endpoint_ClearEndpoints(void)
        {\r
                Endpoint_SelectEndpoint(EPNum);\r
                (&AVR32_USBB.uecfg0)[EPNum]    = 0;\r
        {\r
                Endpoint_SelectEndpoint(EPNum);\r
                (&AVR32_USBB.uecfg0)[EPNum]    = 0;\r
-               (&AVR32_USBB.uecon0clr)[EPNum] = 0xFFFFFFFF;\r
+               (&AVR32_USBB.uecon0clr)[EPNum] = -1;\r
                USB_EndpointFIFOPos[EPNum]     = &AVR32_USBB_SLAVE[EPNum * 0x10000];\r
                Endpoint_DisableEndpoint();\r
        }\r
                USB_EndpointFIFOPos[EPNum]     = &AVR32_USBB_SLAVE[EPNum * 0x10000];\r
                Endpoint_DisableEndpoint();\r
        }\r
index 86bed03..92589a8 100644 (file)
@@ -69,7 +69,7 @@ void Pipe_ClearPipes(void)
        {\r
                Pipe_SelectPipe(PNum);\r
                (&AVR32_USBB.upcfg0)[PNum]    = 0;\r
        {\r
                Pipe_SelectPipe(PNum);\r
                (&AVR32_USBB.upcfg0)[PNum]    = 0;\r
-               (&AVR32_USBB.upcon0clr)[PNum] = 0xFFFFFFFF;\r
+               (&AVR32_USBB.upcon0clr)[PNum] = -1;\r
                USB_PipeFIFOPos[PNum]         = &AVR32_USBB_SLAVE[PNum * 0x10000];\r
                Pipe_DisablePipe();\r
        }\r
                USB_PipeFIFOPos[PNum]         = &AVR32_USBB_SLAVE[PNum * 0x10000];\r
                Pipe_DisablePipe();\r
        }\r
index e3d97d6..0b0d04d 100644 (file)
@@ -72,6 +72,8 @@ void USB_Init(
                AVR32_USBB.USBCON.uide = false;\r
                USB_CurrentMode = Mode;\r
        }\r
                AVR32_USBB.USBCON.uide = false;\r
                USB_CurrentMode = Mode;\r
        }\r
+       #else\r
+       AVR32_USBB.USBCON.uide = false; \r
        #endif\r
 \r
        USB_IsInitialized = true;\r
        #endif\r
 \r
        USB_IsInitialized = true;\r
index 76f4ef0..5191ee6 100644 (file)
@@ -36,8 +36,8 @@ void USB_INT_DisableAllInterrupts(void)
        AVR32_USBB.USBCON.vbuste = false;\r
        AVR32_USBB.USBCON.idte   = false;\r
 \r
        AVR32_USBB.USBCON.vbuste = false;\r
        AVR32_USBB.USBCON.idte   = false;\r
 \r
-       AVR32_USBB.uhinteclr = 0xFFFFFFFF;\r
-       AVR32_USBB.udinteclr = 0xFFFFFFFF;\r
+       AVR32_USBB.uhinteclr     = -1;\r
+       AVR32_USBB.udinteclr     = -1;\r
 }\r
 \r
 void USB_INT_ClearAllInterrupts(void)\r
 }\r
 \r
 void USB_INT_ClearAllInterrupts(void)\r
@@ -45,8 +45,8 @@ void USB_INT_ClearAllInterrupts(void)
        AVR32_USBB.USBSTACLR.vbustic = true;\r
        AVR32_USBB.USBSTACLR.idtic   = true;\r
 \r
        AVR32_USBB.USBSTACLR.vbustic = true;\r
        AVR32_USBB.USBSTACLR.idtic   = true;\r
 \r
-       AVR32_USBB.uhintclr = 0xFFFFFFFF;\r
-       AVR32_USBB.udintclr = 0xFFFFFFFF;\r
+       AVR32_USBB.uhintclr      = -1;\r
+       AVR32_USBB.udintclr      = -1;\r
 }\r
 \r
 ISR(USB_GEN_vect)\r
 }\r
 \r
 ISR(USB_GEN_vect)\r