From 40755d4fde2e7b88341d91f61e6f053144c02986 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 12 Aug 2012 17:25:39 +0000 Subject: Fixed inverted LED driving code for the Arduino Leonardo board. Fixed inverted LEDs_GetLEDs() function implementation for the Benito, Minimus and Arduino UNO boards. --- LUFA/Drivers/Board/AVR8/BENITO/LEDs.h | 2 +- LUFA/Drivers/Board/AVR8/LEONARDO/LEDs.h | 44 ++++++++++++++++----------------- LUFA/Drivers/Board/AVR8/MINIMUS/LEDs.h | 2 +- LUFA/Drivers/Board/AVR8/UNO/LEDs.h | 2 +- LUFA/Drivers/Board/AVR8/USBKEY/LEDs.h | 8 +++--- 5 files changed, 29 insertions(+), 29 deletions(-) (limited to 'LUFA/Drivers/Board/AVR8') diff --git a/LUFA/Drivers/Board/AVR8/BENITO/LEDs.h b/LUFA/Drivers/Board/AVR8/BENITO/LEDs.h index 875130fbf..8e586c431 100644 --- a/LUFA/Drivers/Board/AVR8/BENITO/LEDs.h +++ b/LUFA/Drivers/Board/AVR8/BENITO/LEDs.h @@ -124,7 +124,7 @@ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; static inline uint8_t LEDs_GetLEDs(void) { - return (PORTC & LEDS_ALL_LEDS); + return (~PORTC & LEDS_ALL_LEDS); } #endif diff --git a/LUFA/Drivers/Board/AVR8/LEONARDO/LEDs.h b/LUFA/Drivers/Board/AVR8/LEONARDO/LEDs.h index 0a3c9fcb9..e8e9c4993 100644 --- a/LUFA/Drivers/Board/AVR8/LEONARDO/LEDs.h +++ b/LUFA/Drivers/Board/AVR8/LEONARDO/LEDs.h @@ -73,7 +73,7 @@ /* Macros: */ #define LEDS_PORTB_LEDS (LEDS_LED1) #define LEDS_PORTD_LEDS (LEDS_LED2) - #define LEDS_PORTE_LEDS (LEDS_LED3) + #define LEDS_PORTC_LEDS (LEDS_LED3) #endif /* Public Interface - May be used in end-application: */ @@ -85,7 +85,7 @@ #define LEDS_LED2 (1 << 0) /** LED mask for the third LED on the board. */ - #define LEDS_LED3 (1 << 6) + #define LEDS_LED3 (1 << 7) /** LED mask for all the LEDs on the board. */ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3) @@ -98,11 +98,11 @@ static inline void LEDs_Init(void) { DDRB |= LEDS_PORTB_LEDS; - PORTB &= ~LEDS_PORTB_LEDS; + PORTB |= LEDS_PORTB_LEDS; DDRD |= LEDS_PORTD_LEDS; - PORTD &= ~LEDS_PORTD_LEDS; - DDRE |= LEDS_PORTE_LEDS; - PORTE &= ~LEDS_PORTE_LEDS; + PORTD |= LEDS_PORTD_LEDS; + DDRC |= LEDS_PORTC_LEDS; + PORTC &= ~LEDS_PORTC_LEDS; } static inline void LEDs_Disable(void) @@ -111,50 +111,50 @@ PORTB &= ~LEDS_PORTB_LEDS; DDRD &= ~LEDS_PORTD_LEDS; PORTD &= ~LEDS_PORTD_LEDS; - DDRE &= ~LEDS_PORTE_LEDS; - PORTE &= ~LEDS_PORTE_LEDS; + DDRC &= ~LEDS_PORTC_LEDS; + PORTC &= ~LEDS_PORTC_LEDS; } static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) { - PORTB |= (LEDMask & LEDS_PORTB_LEDS); - PORTD |= (LEDMask & LEDS_PORTD_LEDS); - PORTE |= (LEDMask & LEDS_PORTE_LEDS); + PORTB &= ~(LEDMask & LEDS_PORTB_LEDS); + PORTD &= ~(LEDMask & LEDS_PORTD_LEDS); + PORTC |= (LEDMask & LEDS_PORTC_LEDS); } static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) { - PORTB &= ~(LEDMask & LEDS_PORTB_LEDS); - PORTD &= ~(LEDMask & LEDS_PORTD_LEDS); - PORTE &= ~(LEDMask & LEDS_PORTE_LEDS); + PORTB |= (LEDMask & LEDS_PORTB_LEDS); + PORTD |= (LEDMask & LEDS_PORTD_LEDS); + PORTC &= ~(LEDMask & LEDS_PORTC_LEDS); } static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) { - PORTB = ((PORTB & ~LEDS_PORTB_LEDS) | (LEDMask & LEDS_PORTB_LEDS)); - PORTD = ((PORTD & ~LEDS_PORTD_LEDS) | (LEDMask & LEDS_PORTD_LEDS)); - PORTE = ((PORTE & ~LEDS_PORTE_LEDS) | (LEDMask & LEDS_PORTE_LEDS)); + PORTB = ((PORTB & ~LEDS_PORTB_LEDS) | (LEDMask & LEDS_PORTB_LEDS)); + PORTD = ((PORTD & ~LEDS_PORTD_LEDS) | (LEDMask & LEDS_PORTD_LEDS)); + PORTC = ((PORTC | LEDS_PORTC_LEDS) & ~(LEDMask & LEDS_PORTC_LEDS)); } static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) { - PORTB = ((PORTB & ~(LEDMask & LEDS_PORTB_LEDS)) | (ActiveMask & LEDS_PORTB_LEDS)); - PORTD = ((PORTD & ~(LEDMask & LEDS_PORTD_LEDS)) | (ActiveMask & LEDS_PORTD_LEDS)); - PORTE = ((PORTE & ~(LEDMask & LEDS_PORTE_LEDS)) | (ActiveMask & LEDS_PORTE_LEDS)); + PORTB = ((PORTB & ~(LEDMask & LEDS_PORTB_LEDS)) | (ActiveMask & LEDS_PORTB_LEDS)); + PORTD = ((PORTD & ~(LEDMask & LEDS_PORTD_LEDS)) | (ActiveMask & LEDS_PORTD_LEDS)); + PORTC = ((PORTC | (LEDMask & LEDS_PORTC_LEDS)) | ~(ActiveMask & LEDS_PORTC_LEDS)); } static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) { PINB = (LEDMask & LEDS_PORTB_LEDS); PIND = (LEDMask & LEDS_PORTD_LEDS); - PINE = (LEDMask & LEDS_PORTE_LEDS); + PINC = (LEDMask & LEDS_PORTC_LEDS); } static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; static inline uint8_t LEDs_GetLEDs(void) { - return ((PORTB & LEDS_PORTB_LEDS) | (PORTD & LEDS_PORTD_LEDS) | (PORTE & LEDS_PORTE_LEDS)); + return ((PORTB & LEDS_PORTB_LEDS) | (PORTD & LEDS_PORTD_LEDS) | (~PORTC & LEDS_PORTC_LEDS)); } #endif diff --git a/LUFA/Drivers/Board/AVR8/MINIMUS/LEDs.h b/LUFA/Drivers/Board/AVR8/MINIMUS/LEDs.h index f23317d1c..74c6d1648 100644 --- a/LUFA/Drivers/Board/AVR8/MINIMUS/LEDs.h +++ b/LUFA/Drivers/Board/AVR8/MINIMUS/LEDs.h @@ -128,7 +128,7 @@ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; static inline uint8_t LEDs_GetLEDs(void) { - return (PORTD & LEDS_ALL_LEDS); + return (~PORTD & LEDS_ALL_LEDS); } #endif diff --git a/LUFA/Drivers/Board/AVR8/UNO/LEDs.h b/LUFA/Drivers/Board/AVR8/UNO/LEDs.h index 2a6178caa..9c01c6133 100644 --- a/LUFA/Drivers/Board/AVR8/UNO/LEDs.h +++ b/LUFA/Drivers/Board/AVR8/UNO/LEDs.h @@ -124,7 +124,7 @@ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; static inline uint8_t LEDs_GetLEDs(void) { - return (PORTD & LEDS_ALL_LEDS); + return (~PORTD & LEDS_ALL_LEDS); } #endif diff --git a/LUFA/Drivers/Board/AVR8/USBKEY/LEDs.h b/LUFA/Drivers/Board/AVR8/USBKEY/LEDs.h index 25a90a74e..fef8c06bb 100644 --- a/LUFA/Drivers/Board/AVR8/USBKEY/LEDs.h +++ b/LUFA/Drivers/Board/AVR8/USBKEY/LEDs.h @@ -44,10 +44,10 @@ * * * - * - * - * - * + * + * + * + * *
NameColorInfoActive LevelPort Pin
LEDS_LED1RedBicolor Indicator 1LowPORTD.4
LEDS_LED2GreenBicolor Indicator 1LowPORTD.5
LEDS_LED3RedBicolor Indicator 2LowPORTD.6
LEDS_LED4GreenBicolor Indicator 2LowPORTD.7
LEDS_LED1RedBicolor Indicator 1HighPORTD.4
LEDS_LED2GreenBicolor Indicator 1HighPORTD.5
LEDS_LED3RedBicolor Indicator 2HighPORTD.6
LEDS_LED4GreenBicolor Indicator 2HighPORTD.7
* * @{ -- cgit v1.2.3