diff options
-rw-r--r-- | Demos/Host/LowLevel/KeyboardHost/KeyboardHost.c | 5 | ||||
-rw-r--r-- | Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c | 5 | ||||
-rw-r--r-- | LUFA/DriverStubs/LEDs.h | 21 | ||||
-rw-r--r-- | LUFA/Drivers/Board/ATAVRUSBRF01/LEDs.h | 5 | ||||
-rw-r--r-- | LUFA/Drivers/Board/LEDs.h | 6 | ||||
-rw-r--r-- | LUFA/Drivers/Board/RZUSBSTICK/LEDs.h | 6 | ||||
-rw-r--r-- | LUFA/Drivers/Board/STK525/LEDs.h | 21 | ||||
-rw-r--r-- | LUFA/Drivers/Board/STK526/LEDs.h | 21 | ||||
-rw-r--r-- | LUFA/Drivers/Board/USBKEY/LEDs.h | 21 | ||||
-rw-r--r-- | LUFA/ManPages/ChangeLog.txt | 1 | ||||
-rw-r--r-- | Projects/Benito/Benito.c | 2 | ||||
-rw-r--r-- | Projects/MissileLauncher/MissileLauncher.c | 2 |
12 files changed, 74 insertions, 42 deletions
diff --git a/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.c b/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.c index 273cd7175..1a53526ba 100644 --- a/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.c +++ b/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.c @@ -156,10 +156,7 @@ void ReadNextReport(void) if (KeyboardReport.KeyCode)
{
/* Toggle status LED to indicate keypress */
- if (LEDs_GetLEDs() & LEDS_LED2)
- LEDs_TurnOffLEDs(LEDS_LED2);
- else
- LEDs_TurnOnLEDs(LEDS_LED2);
+ LEDs_ToggleLEDs(LEDS_LED2);
char PressedKey = 0;
diff --git a/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c b/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c index eee1755bf..2cc08a13d 100644 --- a/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c +++ b/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c @@ -250,10 +250,7 @@ void ProcessKeyboardReport(uint8_t* KeyboardReport) if (KeyCode)
{
/* Toggle status LED to indicate keypress */
- if (LEDs_GetLEDs() & LEDS_LED2)
- LEDs_TurnOffLEDs(LEDS_LED2);
- else
- LEDs_TurnOnLEDs(LEDS_LED2);
+ LEDs_ToggleLEDs(LEDS_LED2);
char PressedKey = 0;
diff --git a/LUFA/DriverStubs/LEDs.h b/LUFA/DriverStubs/LEDs.h index 993481d8b..3f4cca006 100644 --- a/LUFA/DriverStubs/LEDs.h +++ b/LUFA/DriverStubs/LEDs.h @@ -86,24 +86,29 @@ // TODO: Add code to initialize LED port pins as outputs here
}
- static inline void LEDs_TurnOnLEDs(const uint8_t LedMask)
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
{
- // TODO: Add code to turn on LEDs given in the LedMask mask here, leave others as-is
+ // TODO: Add code to turn on LEDs given in the LEDMask mask here, leave others as-is
}
- static inline void LEDs_TurnOffLEDs(const uint8_t LedMask)
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
{
- // TODO: Add code to turn off LEDs given in the LedMask mask here, leave others as-is
+ // TODO: Add code to turn off LEDs given in the LEDMask mask here, leave others as-is
}
- static inline void LEDs_SetAllLEDs(const uint8_t LedMask)
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
{
- // TODO: Add code to turn on only LEDs given in the LedMask mask here, all others off
+ // TODO: Add code to turn on only LEDs given in the LEDMask mask here, all others off
}
- static inline void LEDs_ChangeLEDs(const uint8_t LedMask, const uint8_t ActiveMask)
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)
{
- // TODO: Add code to set the Leds in the given LedMask to the status given in ActiveMask here
+ // TODO: Add code to set the Leds in the given LEDMask to the status given in ActiveMask here
+ }
+
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
+ {
+ // TODO: Add code to toggle the Leds in the given LEDMask, ignoring all others
}
static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
diff --git a/LUFA/Drivers/Board/ATAVRUSBRF01/LEDs.h b/LUFA/Drivers/Board/ATAVRUSBRF01/LEDs.h index 9f808279a..8487ee74e 100644 --- a/LUFA/Drivers/Board/ATAVRUSBRF01/LEDs.h +++ b/LUFA/Drivers/Board/ATAVRUSBRF01/LEDs.h @@ -110,6 +110,11 @@ {
PORTD = ((PORTD & ~(LEDMask & LEDS_ALL_LEDS)) | (ActiveMask & LEDS_ALL_LEDS));
}
+
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
+ {
+ PORTD = (PORTD ^ (LEDMask & LEDS_ALL_LEDS));
+ }
static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
static inline uint8_t LEDs_GetLEDs(void)
diff --git a/LUFA/Drivers/Board/LEDs.h b/LUFA/Drivers/Board/LEDs.h index cd2b857a4..cea947a85 100644 --- a/LUFA/Drivers/Board/LEDs.h +++ b/LUFA/Drivers/Board/LEDs.h @@ -142,6 +142,12 @@ * \param[in] ActiveMask Mask of whether the LEDs in the LED mask should be turned on or off
*/
static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask);
+
+ /** Toggles all LEDs in the LED mask, leaving all others in their current states.
+ *
+ * \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file)
+ */
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask);
/** Returns the status of all the board LEDs; set LED masks in the return value indicate that the
* corresponding LED is on.
diff --git a/LUFA/Drivers/Board/RZUSBSTICK/LEDs.h b/LUFA/Drivers/Board/RZUSBSTICK/LEDs.h index 24977ea5e..ecaab1edf 100644 --- a/LUFA/Drivers/Board/RZUSBSTICK/LEDs.h +++ b/LUFA/Drivers/Board/RZUSBSTICK/LEDs.h @@ -131,6 +131,12 @@ ~((ActiveMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT));
}
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
+ {
+ PORTD = (PORTD ^ (LEDMask & LEDS_PORTD_LEDS));
+ PORTE = (PORTE ^ ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT));
+ }
+
static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
static inline uint8_t LEDs_GetLEDs(void)
{
diff --git a/LUFA/Drivers/Board/STK525/LEDs.h b/LUFA/Drivers/Board/STK525/LEDs.h index a769f16d0..73c03f75a 100644 --- a/LUFA/Drivers/Board/STK525/LEDs.h +++ b/LUFA/Drivers/Board/STK525/LEDs.h @@ -88,26 +88,31 @@ PORTD &= ~LEDS_ALL_LEDS;
}
- static inline void LEDs_TurnOnLEDs(const uint8_t LedMask)
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
{
- PORTD |= LedMask;
+ PORTD |= LEDMask;
}
- static inline void LEDs_TurnOffLEDs(const uint8_t LedMask)
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
{
- PORTD &= ~LedMask;
+ PORTD &= ~LEDMask;
}
- static inline void LEDs_SetAllLEDs(const uint8_t LedMask)
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
{
- PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LedMask);
+ PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);
}
- static inline void LEDs_ChangeLEDs(const uint8_t LedMask, const uint8_t ActiveMask)
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)
{
- PORTD = ((PORTD & ~LedMask) | ActiveMask);
+ PORTD = ((PORTD & ~LEDMask) | ActiveMask);
}
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
+ {
+ PORTD = (PORTD ^ (LEDMask & LEDS_ALL_LEDS));
+ }
+
static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
static inline uint8_t LEDs_GetLEDs(void)
{
diff --git a/LUFA/Drivers/Board/STK526/LEDs.h b/LUFA/Drivers/Board/STK526/LEDs.h index 6b17ab1c8..5718f405d 100644 --- a/LUFA/Drivers/Board/STK526/LEDs.h +++ b/LUFA/Drivers/Board/STK526/LEDs.h @@ -88,24 +88,29 @@ PORTD &= ~LEDS_ALL_LEDS;
}
- static inline void LEDs_TurnOnLEDs(const uint8_t LedMask)
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
{
- PORTD |= LedMask;
+ PORTD |= LEDMask;
}
- static inline void LEDs_TurnOffLEDs(const uint8_t LedMask)
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
{
- PORTD &= ~LedMask;
+ PORTD &= ~LEDMask;
}
- static inline void LEDs_SetAllLEDs(const uint8_t LedMask)
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
{
- PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LedMask);
+ PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);
}
- static inline void LEDs_ChangeLEDs(const uint8_t LedMask, const uint8_t ActiveMask)
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)
{
- PORTD = ((PORTD & ~LedMask) | ActiveMask);
+ PORTD = ((PORTD & ~(LEDMask & LEDS_ALL_LEDS)) | (ActiveMask & LEDS_ALL_LEDS));
+ }
+
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
+ {
+ PORTD = (PORTD ^ (LEDMask & LEDS_ALL_LEDS));
}
static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
diff --git a/LUFA/Drivers/Board/USBKEY/LEDs.h b/LUFA/Drivers/Board/USBKEY/LEDs.h index 68df3172f..2e61d2eb2 100644 --- a/LUFA/Drivers/Board/USBKEY/LEDs.h +++ b/LUFA/Drivers/Board/USBKEY/LEDs.h @@ -88,24 +88,29 @@ PORTD &= ~LEDS_ALL_LEDS;
}
- static inline void LEDs_TurnOnLEDs(const uint8_t LedMask)
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
{
- PORTD |= LedMask;
+ PORTD |= LEDMask;
}
- static inline void LEDs_TurnOffLEDs(const uint8_t LedMask)
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
{
- PORTD &= ~LedMask;
+ PORTD &= ~LEDMask;
}
- static inline void LEDs_SetAllLEDs(const uint8_t LedMask)
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
{
- PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LedMask);
+ PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);
}
- static inline void LEDs_ChangeLEDs(const uint8_t LedMask, const uint8_t ActiveMask)
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)
{
- PORTD = ((PORTD & ~LedMask) | ActiveMask);
+ PORTD = ((PORTD & ~LEDMask) | ActiveMask);
+ }
+
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
+ {
+ PORTD = (PORTD ^ (LEDMask & LEDS_ALL_LEDS));
}
static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index b7c1e288d..eb6c89ebf 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -32,6 +32,7 @@ * - Added new USB_DeviceState variable to keep track of the current Device mode USB state
* - Added new Endpoint_ClearStatusStage() convenience function to assist with the status stages of control transfers
* - Added new Benito Arduino Programmer project
+ * - Added new LEDs_ToggleLEDs() function to the LEDs driver
*
* <b>Changed:</b>
* - Deprecated psuedo-scheduler and removed dynamic memory allocator from the library (first no longer needed and second unused)
diff --git a/Projects/Benito/Benito.c b/Projects/Benito/Benito.c index 1afb74a72..2f0317daa 100644 --- a/Projects/Benito/Benito.c +++ b/Projects/Benito/Benito.c @@ -107,7 +107,7 @@ int main(void) /* Check if the LEDs should be ping-ponging (during enumeration) */
if (PingPongMSRemaining && !(--PingPongMSRemaining))
{
- LEDs_ChangeLEDs(LEDMASK_BUSY, (~LEDs_GetLEDs() & LEDMASK_BUSY));
+ LEDs_ToggleLEDs(LEDMASK_BUSY);
PingPongMSRemaining = PING_PONG_LED_PULSE_MS;
}
diff --git a/Projects/MissileLauncher/MissileLauncher.c b/Projects/MissileLauncher/MissileLauncher.c index 1ae37044f..50a8009bb 100644 --- a/Projects/MissileLauncher/MissileLauncher.c +++ b/Projects/MissileLauncher/MissileLauncher.c @@ -173,7 +173,7 @@ void Send_Command(uint8_t* Command) if ((CmdState == CMD_STOP && Command != CMD_STOP) ||
(CmdState != CMD_STOP && Command == CMD_STOP))
{
- LEDs_ChangeLEDs(LEDS_LED4, ~LEDs_GetLEDs() & LEDS_LED4);
+ LEDs_ToggleLEDs(LEDS_LED4);
Send_Command_Report(CMD_INITA, 8);
Send_Command_Report(CMD_INITB, 8);
|