Commit 40755d4f authored by Dean Camera's avatar Dean Camera
Browse files

Fixed inverted LED driving code for the Arduino Leonardo board. Fixed inverted...

Fixed inverted LED driving code for the Arduino Leonardo board. Fixed inverted LEDs_GetLEDs() function implementation for the Benito, Minimus and Arduino UNO boards.
parent 6fb6c628
......@@ -22,7 +22,7 @@
*
* <b>Fixed:</b>
* - Core:
* - <i>None</i>
* - Fixed inverted LEDs_GetLEDs() function implementation for the Benito, Minimus and Arduino UNO boards
* - Library Applications:
* - Fixed broken RESET_TOGGLES_LIBUSB_COMPAT compile time option in the AVRISP-MKII project
*
......
......@@ -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
......
......@@ -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,29 +111,29 @@
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));
PORTC = ((PORTC | LEDS_PORTC_LEDS) & ~(LEDMask & LEDS_PORTC_LEDS));
}
static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,
......@@ -141,20 +141,20 @@
{
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));
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
......
......@@ -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
......
......@@ -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
......
......@@ -44,10 +44,10 @@
*
* <table>
* <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
* <tr><td>LEDS_LED1</td><td>Red</td><td>Bicolor Indicator 1</td><td>Low</td><td>PORTD.4</td></tr>
* <tr><td>LEDS_LED2</td><td>Green</td><td>Bicolor Indicator 1</td><td>Low</td><td>PORTD.5</td></tr>
* <tr><td>LEDS_LED3</td><td>Red</td><td>Bicolor Indicator 2</td><td>Low</td><td>PORTD.6</td></tr>
* <tr><td>LEDS_LED4</td><td>Green</td><td>Bicolor Indicator 2</td><td>Low</td><td>PORTD.7</td></tr>
* <tr><td>LEDS_LED1</td><td>Red</td><td>Bicolor Indicator 1</td><td>High</td><td>PORTD.4</td></tr>
* <tr><td>LEDS_LED2</td><td>Green</td><td>Bicolor Indicator 1</td><td>High</td><td>PORTD.5</td></tr>
* <tr><td>LEDS_LED3</td><td>Red</td><td>Bicolor Indicator 2</td><td>High</td><td>PORTD.6</td></tr>
* <tr><td>LEDS_LED4</td><td>Green</td><td>Bicolor Indicator 2</td><td>High</td><td>PORTD.7</td></tr>
* </table>
*
* @{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment