Added new LEDs_ToggleLEDs() function to the Board LEDs driver.
authorDean Camera <dean@fourwalledcubicle.com>
Fri, 24 Jul 2009 01:44:01 +0000 (01:44 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Fri, 24 Jul 2009 01:44:01 +0000 (01:44 +0000)
12 files changed:
Demos/Host/LowLevel/KeyboardHost/KeyboardHost.c
Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c
LUFA/DriverStubs/LEDs.h
LUFA/Drivers/Board/ATAVRUSBRF01/LEDs.h
LUFA/Drivers/Board/LEDs.h
LUFA/Drivers/Board/RZUSBSTICK/LEDs.h
LUFA/Drivers/Board/STK525/LEDs.h
LUFA/Drivers/Board/STK526/LEDs.h
LUFA/Drivers/Board/USBKEY/LEDs.h
LUFA/ManPages/ChangeLog.txt
Projects/Benito/Benito.c
Projects/MissileLauncher/MissileLauncher.c

index 273cd71..1a53526 100644 (file)
@@ -156,10 +156,7 @@ void ReadNextReport(void)
                if (KeyboardReport.KeyCode)\r
                {\r
                        /* Toggle status LED to indicate keypress */\r
                if (KeyboardReport.KeyCode)\r
                {\r
                        /* Toggle status LED to indicate keypress */\r
-                       if (LEDs_GetLEDs() & LEDS_LED2)\r
-                         LEDs_TurnOffLEDs(LEDS_LED2);\r
-                       else\r
-                         LEDs_TurnOnLEDs(LEDS_LED2);\r
+                       LEDs_ToggleLEDs(LEDS_LED2);\r
                                  \r
                        char PressedKey = 0;\r
 \r
                                  \r
                        char PressedKey = 0;\r
 \r
index eee1755..2cc08a1 100644 (file)
@@ -250,10 +250,7 @@ void ProcessKeyboardReport(uint8_t* KeyboardReport)
                        if (KeyCode)\r
                        {\r
                                /* Toggle status LED to indicate keypress */\r
                        if (KeyCode)\r
                        {\r
                                /* Toggle status LED to indicate keypress */\r
-                               if (LEDs_GetLEDs() & LEDS_LED2)\r
-                                 LEDs_TurnOffLEDs(LEDS_LED2);\r
-                               else\r
-                                 LEDs_TurnOnLEDs(LEDS_LED2);\r
+                               LEDs_ToggleLEDs(LEDS_LED2);\r
 \r
                                char PressedKey = 0;\r
 \r
 \r
                                char PressedKey = 0;\r
 \r
index 993481d..3f4cca0 100644 (file)
                                // TODO: Add code to initialize LED port pins as outputs here\r
                        }\r
                        \r
                                // TODO: Add code to initialize LED port pins as outputs here\r
                        }\r
                        \r
-                       static inline void LEDs_TurnOnLEDs(const uint8_t LedMask)\r
+                       static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
                        {\r
                        {\r
-                               // TODO: Add code to turn on LEDs given in the LedMask mask here, leave others as-is\r
+                               // TODO: Add code to turn on LEDs given in the LEDMask mask here, leave others as-is\r
                        }\r
 \r
                        }\r
 \r
-                       static inline void LEDs_TurnOffLEDs(const uint8_t LedMask)\r
+                       static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
                        {\r
                        {\r
-                               // TODO: Add code to turn off LEDs given in the LedMask mask here, leave others as-is\r
+                               // TODO: Add code to turn off LEDs given in the LEDMask mask here, leave others as-is\r
                        }\r
 \r
                        }\r
 \r
-                       static inline void LEDs_SetAllLEDs(const uint8_t LedMask)\r
+                       static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
                        {\r
                        {\r
-                               // TODO: Add code to turn on only LEDs given in the LedMask mask here, all others off\r
+                               // TODO: Add code to turn on only LEDs given in the LEDMask mask here, all others off\r
                        }\r
                        \r
                        }\r
                        \r
-                       static inline void LEDs_ChangeLEDs(const uint8_t LedMask, const uint8_t ActiveMask)\r
+                       static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)\r
                        {\r
                        {\r
-                               // TODO: Add code to set the Leds in the given LedMask to the status given in ActiveMask here\r
+                               // TODO: Add code to set the Leds in the given LEDMask to the status given in ActiveMask here\r
+                       }\r
+\r
+                       static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+                       {\r
+                               // TODO: Add code to toggle the Leds in the given LEDMask, ignoring all others\r
                        }\r
                        \r
                        static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
                        }\r
                        \r
                        static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
index 9f80827..8487ee7 100644 (file)
                        {\r
                                PORTD = ((PORTD & ~(LEDMask & LEDS_ALL_LEDS)) | (ActiveMask & LEDS_ALL_LEDS));\r
                        }\r
                        {\r
                                PORTD = ((PORTD & ~(LEDMask & LEDS_ALL_LEDS)) | (ActiveMask & LEDS_ALL_LEDS));\r
                        }\r
+\r
+                       static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+                       {\r
+                               PORTD = (PORTD ^ (LEDMask & LEDS_ALL_LEDS));\r
+                       }\r
                        \r
                        static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
                        static inline uint8_t LEDs_GetLEDs(void)\r
                        \r
                        static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
                        static inline uint8_t LEDs_GetLEDs(void)\r
index cd2b857..cea947a 100644 (file)
                 *  \param[in] ActiveMask  Mask of whether the LEDs in the LED mask should be turned on or off\r
                 */\r
                static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask);\r
                 *  \param[in] ActiveMask  Mask of whether the LEDs in the LED mask should be turned on or off\r
                 */\r
                static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask);\r
+               \r
+               /** Toggles all LEDs in the LED mask, leaving all others in their current states.\r
+                *\r
+                *  \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file)\r
+                */\r
+               static inline void LEDs_ToggleLEDs(const uint8_t LEDMask);\r
 \r
                /** Returns the status of all the board LEDs; set LED masks in the return value indicate that the\r
                 *  corresponding LED is on.\r
 \r
                /** Returns the status of all the board LEDs; set LED masks in the return value indicate that the\r
                 *  corresponding LED is on.\r
index 24977ea..ecaab1e 100644 (file)
                                        ~((ActiveMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT));\r
                        }\r
                        \r
                                        ~((ActiveMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT));\r
                        }\r
                        \r
+                       static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+                       {\r
+                               PORTD = (PORTD ^ (LEDMask & LEDS_PORTD_LEDS));\r
+                               PORTE = (PORTE ^ ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT));\r
+                       }\r
+\r
                        static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
                        static inline uint8_t LEDs_GetLEDs(void)\r
                        {\r
                        static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
                        static inline uint8_t LEDs_GetLEDs(void)\r
                        {\r
index a769f16..73c03f7 100644 (file)
                                PORTD &= ~LEDS_ALL_LEDS;\r
                        }\r
                        \r
                                PORTD &= ~LEDS_ALL_LEDS;\r
                        }\r
                        \r
-                       static inline void LEDs_TurnOnLEDs(const uint8_t LedMask)\r
+                       static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
                        {\r
                        {\r
-                               PORTD |= LedMask;\r
+                               PORTD |= LEDMask;\r
                        }\r
 \r
                        }\r
 \r
-                       static inline void LEDs_TurnOffLEDs(const uint8_t LedMask)\r
+                       static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
                        {\r
                        {\r
-                               PORTD &= ~LedMask;\r
+                               PORTD &= ~LEDMask;\r
                        }\r
 \r
                        }\r
 \r
-                       static inline void LEDs_SetAllLEDs(const uint8_t LedMask)\r
+                       static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
                        {\r
                        {\r
-                               PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LedMask);\r
+                               PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);\r
                        }\r
                        \r
                        }\r
                        \r
-                       static inline void LEDs_ChangeLEDs(const uint8_t LedMask, const uint8_t ActiveMask)\r
+                       static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)\r
                        {\r
                        {\r
-                               PORTD = ((PORTD & ~LedMask) | ActiveMask);\r
+                               PORTD = ((PORTD & ~LEDMask) | ActiveMask);\r
                        }\r
                        \r
                        }\r
                        \r
+                       static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+                       {\r
+                               PORTD = (PORTD ^ (LEDMask & LEDS_ALL_LEDS));\r
+                       }\r
+\r
                        static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
                        static inline uint8_t LEDs_GetLEDs(void)\r
                        {\r
                        static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
                        static inline uint8_t LEDs_GetLEDs(void)\r
                        {\r
index 6b17ab1..5718f40 100644 (file)
                                PORTD &= ~LEDS_ALL_LEDS;\r
                        }\r
                        \r
                                PORTD &= ~LEDS_ALL_LEDS;\r
                        }\r
                        \r
-                       static inline void LEDs_TurnOnLEDs(const uint8_t LedMask)\r
+                       static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
                        {\r
                        {\r
-                               PORTD |= LedMask;\r
+                               PORTD |= LEDMask;\r
                        }\r
 \r
                        }\r
 \r
-                       static inline void LEDs_TurnOffLEDs(const uint8_t LedMask)\r
+                       static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
                        {\r
                        {\r
-                               PORTD &= ~LedMask;\r
+                               PORTD &= ~LEDMask;\r
                        }\r
 \r
                        }\r
 \r
-                       static inline void LEDs_SetAllLEDs(const uint8_t LedMask)\r
+                       static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
                        {\r
                        {\r
-                               PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LedMask);\r
+                               PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);\r
                        }\r
                        \r
                        }\r
                        \r
-                       static inline void LEDs_ChangeLEDs(const uint8_t LedMask, const uint8_t ActiveMask)\r
+                       static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)\r
                        {\r
                        {\r
-                               PORTD = ((PORTD & ~LedMask) | ActiveMask);\r
+                               PORTD = ((PORTD & ~(LEDMask & LEDS_ALL_LEDS)) | (ActiveMask & LEDS_ALL_LEDS));\r
+                       }\r
+                       \r
+                       static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+                       {\r
+                               PORTD = (PORTD ^ (LEDMask & LEDS_ALL_LEDS));\r
                        }\r
                        \r
                        static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
                        }\r
                        \r
                        static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
index 68df317..2e61d2e 100644 (file)
                                PORTD &= ~LEDS_ALL_LEDS;\r
                        }\r
                        \r
                                PORTD &= ~LEDS_ALL_LEDS;\r
                        }\r
                        \r
-                       static inline void LEDs_TurnOnLEDs(const uint8_t LedMask)\r
+                       static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
                        {\r
                        {\r
-                               PORTD |= LedMask;\r
+                               PORTD |= LEDMask;\r
                        }\r
 \r
                        }\r
 \r
-                       static inline void LEDs_TurnOffLEDs(const uint8_t LedMask)\r
+                       static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
                        {\r
                        {\r
-                               PORTD &= ~LedMask;\r
+                               PORTD &= ~LEDMask;\r
                        }\r
 \r
                        }\r
 \r
-                       static inline void LEDs_SetAllLEDs(const uint8_t LedMask)\r
+                       static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
                        {\r
                        {\r
-                               PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LedMask);\r
+                               PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);\r
                        }\r
                        \r
                        }\r
                        \r
-                       static inline void LEDs_ChangeLEDs(const uint8_t LedMask, const uint8_t ActiveMask)\r
+                       static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)\r
                        {\r
                        {\r
-                               PORTD = ((PORTD & ~LedMask) | ActiveMask);\r
+                               PORTD = ((PORTD & ~LEDMask) | ActiveMask);\r
+                       }\r
+                       \r
+                       static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+                       {\r
+                               PORTD = (PORTD ^ (LEDMask & LEDS_ALL_LEDS));\r
                        }\r
                        \r
                        static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
                        }\r
                        \r
                        static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
index b7c1e28..eb6c89e 100644 (file)
@@ -32,6 +32,7 @@
   *  - Added new USB_DeviceState variable to keep track of the current Device mode USB state\r
   *  - Added new Endpoint_ClearStatusStage() convenience function to assist with the status stages of control transfers\r
   *  - Added new Benito Arduino Programmer project\r
   *  - Added new USB_DeviceState variable to keep track of the current Device mode USB state\r
   *  - Added new Endpoint_ClearStatusStage() convenience function to assist with the status stages of control transfers\r
   *  - Added new Benito Arduino Programmer project\r
+  *  - Added new LEDs_ToggleLEDs() function to the LEDs driver\r
   *  \r
   *  <b>Changed:</b>\r
   *  - Deprecated psuedo-scheduler and removed dynamic memory allocator from the library (first no longer needed and second unused)\r
   *  \r
   *  <b>Changed:</b>\r
   *  - Deprecated psuedo-scheduler and removed dynamic memory allocator from the library (first no longer needed and second unused)\r
index 1afb74a..2f0317d 100644 (file)
@@ -107,7 +107,7 @@ int main(void)
                        /* Check if the LEDs should be ping-ponging (during enumeration) */\r
                        if (PingPongMSRemaining && !(--PingPongMSRemaining))\r
                        {\r
                        /* Check if the LEDs should be ping-ponging (during enumeration) */\r
                        if (PingPongMSRemaining && !(--PingPongMSRemaining))\r
                        {\r
-                               LEDs_ChangeLEDs(LEDMASK_BUSY, (~LEDs_GetLEDs() & LEDMASK_BUSY));\r
+                               LEDs_ToggleLEDs(LEDMASK_BUSY);\r
                                PingPongMSRemaining = PING_PONG_LED_PULSE_MS;\r
                        }\r
                \r
                                PingPongMSRemaining = PING_PONG_LED_PULSE_MS;\r
                        }\r
                \r
index 1ae3704..50a8009 100644 (file)
@@ -173,7 +173,7 @@ void Send_Command(uint8_t* Command)
        if ((CmdState == CMD_STOP && Command != CMD_STOP) ||\r
                (CmdState != CMD_STOP && Command == CMD_STOP))\r
        {\r
        if ((CmdState == CMD_STOP && Command != CMD_STOP) ||\r
                (CmdState != CMD_STOP && Command == CMD_STOP))\r
        {\r
-               LEDs_ChangeLEDs(LEDS_LED4, ~LEDs_GetLEDs() & LEDS_LED4);\r
+               LEDs_ToggleLEDs(LEDS_LED4);\r
 \r
                Send_Command_Report(CMD_INITA, 8);\r
                Send_Command_Report(CMD_INITB, 8);\r
 \r
                Send_Command_Report(CMD_INITA, 8);\r
                Send_Command_Report(CMD_INITB, 8);\r