aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28>2009-07-24 01:44:01 +0000
committerDean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28>2009-07-24 01:44:01 +0000
commitc6b134fc58030cd850a0a0046fc19434862c6f5f (patch)
tree0aed41075af0b12258d1dee1c3946e61e9e4d0e0
parent0e4f9aed2acc0b21b6d9aed0b0189ffe2717540e (diff)
Added new LEDs_ToggleLEDs() function to the Board LEDs driver.
git-svn-id: http://lufa-lib.googlecode.com/svn/trunk@683 d5102386-fcda-11dd-9fdb-3debd5008f28
-rw-r--r--Demos/Host/LowLevel/KeyboardHost/KeyboardHost.c5
-rw-r--r--Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c5
-rw-r--r--LUFA/DriverStubs/LEDs.h21
-rw-r--r--LUFA/Drivers/Board/ATAVRUSBRF01/LEDs.h5
-rw-r--r--LUFA/Drivers/Board/LEDs.h6
-rw-r--r--LUFA/Drivers/Board/RZUSBSTICK/LEDs.h6
-rw-r--r--LUFA/Drivers/Board/STK525/LEDs.h21
-rw-r--r--LUFA/Drivers/Board/STK526/LEDs.h21
-rw-r--r--LUFA/Drivers/Board/USBKEY/LEDs.h21
-rw-r--r--LUFA/ManPages/ChangeLog.txt1
-rw-r--r--Projects/Benito/Benito.c2
-rw-r--r--Projects/MissileLauncher/MissileLauncher.c2
12 files changed, 74 insertions, 42 deletions
diff --git a/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.c b/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.c
index 273cd717..1a53526b 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 eee1755b..2cc08a13 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 993481d8..3f4cca00 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 9f808279..8487ee74 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 cd2b857a..cea947a8 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 24977ea5..ecaab1ed 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 a769f16d..73c03f75 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 6b17ab1c..5718f405 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 68df3172..2e61d2eb 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 b7c1e288..eb6c89eb 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 1afb74a7..2f0317da 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 1ae37044..50a8009b 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);