Update XMEGA board drivers to use the port inversion feature of the XMEGA architectur...
[pub/lufa.git] / LUFA / Drivers / Board / XMEGA / B1_XPLAINED / LEDs.h
index b8c14d5..ee8a277 100644 (file)
                #if !defined(__DOXYGEN__)\r
                        static inline void LEDs_Init(void)\r
                        {\r
-                               PORTB_DIRSET = LEDS_PORTB_LEDS;\r
-                               PORTB_OUTSET = LEDS_PORTB_LEDS;\r
+                               PORTB.DIRSET    = LEDS_PORTB_LEDS;\r
+                               PORTB.OUTCLR    = LEDS_PORTB_LEDS;\r
 \r
-                               PORTE_DIRSET = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
-                               PORTE_OUTCLR = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
+                               PORTCFG.MPCMASK = LEDS_PORTB_LEDS;\r
+                               PORTB.PIN0CTRL  = PORT_INVEN_bm;\r
+\r
+                               PORTE.DIRSET    = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
+                               PORTE.OUTCLR    = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
                        }\r
 \r
                        static inline void LEDs_Disable(void)\r
                        {\r
-                               PORTB_DIRCLR = LEDS_PORTB_LEDS;\r
-                               PORTB_OUTCLR = LEDS_PORTB_LEDS;\r
-\r
-                               PORTE_DIRCLR = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
-                               PORTE_OUTCLR = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
+                               PORTB.DIRCLR    = LEDS_PORTB_LEDS;\r
+                               PORTB.OUTCLR    = LEDS_PORTB_LEDS;\r
+                               \r
+                               PORTCFG.MPCMASK = 0;\r
+                               PORTB.PIN0CTRL  = LEDS_PORTB_LEDS;\r
+\r
+                               PORTE.DIRCLR    = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
+                               PORTE.OUTCLR    = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
                        }\r
 \r
                        static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
                        {\r
-                               PORTB_OUTCLR = (LEDMask & LEDS_PORTB_LEDS);\r
+                               PORTB_OUTSET = (LEDMask & LEDS_PORTB_LEDS);\r
                                PORTE_OUTSET = ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);\r
                        }\r
 \r
                        static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
                        {\r
-                               PORTB_OUTSET = (LEDMask & LEDS_PORTB_LEDS);\r
+                               PORTB_OUTCLR = (LEDMask & LEDS_PORTB_LEDS);\r
                                PORTE_OUTCLR = ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);\r
                        }\r
 \r
                        static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
                        {\r
-                               PORTB_OUTSET = LEDS_PORTB_LEDS;\r
+                               PORTB_OUTCLR = LEDS_PORTB_LEDS;\r
                                PORTE_OUTCLR = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
 \r
-                               PORTB_OUTCLR = (LEDMask & LEDS_PORTB_LEDS);\r
+                               PORTB_OUTSET = (LEDMask & LEDS_PORTB_LEDS);\r
                                PORTE_OUTSET = ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);\r
                        }\r
 \r
                        static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)\r
                        {\r
-                               PORTB_OUT = (PORTB.OUT & (~LEDMask & LEDS_PORTB_LEDS)) | (ActiveMask & LEDS_PORTB_LEDS);\r
-                               PORTE_OUT = (PORTB.OUT & (((~LEDMask & LEDS_PORTB_LEDS)) << LEDS_PORTE_MASK_SHIFT) &\r
-                                            ~((ActiveMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT));\r
+                               PORTB_OUTCLR =  (LEDMask & LEDS_PORTB_LEDS);\r
+                               PORTE_OUTCLR = ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);\r
+                       \r
+                               PORTB_OUTSET =  (ActiveMask & LEDS_PORTB_LEDS);\r
+                               PORTE_OUTSET = ((ActiveMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);\r
                        }\r
 \r
                        static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
                        static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
                        static inline uint8_t LEDs_GetLEDs(void)\r
                        {\r
-                               return ((~PORTB_OUT & LEDS_PORTB_LEDS) | (PORTE_OUT & (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT)));\r
+                               return ((PORTB_OUT & LEDS_PORTB_LEDS) | (PORTE_OUT & (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT)));\r
                        }\r
                #endif\r
 \r