*
* Board specific LED driver header for the Arduino Micro board (https://www.sparkfun.com/products/12640).
*
- * <table>
+ * <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>Yellow</td><td>RX</td><td>High</td><td>PORTB.0</td></tr>
- * <tr><td>LEDS_LED2</td><td>Green</td><td>TX</td><td>High</td><td>PORTD.5</td></tr>
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>TX</td><td>High</td><td>PORTD.5</td></tr>
+ * <tr><td>LEDS_LED2</td><td>Yellow</td><td>RX</td><td>High</td><td>PORTB.0</td></tr>
* </table>
*
+ * LEDS_LED2 is not used, and just programmed to be an input. So the application can use this MCU pin as
+ * a SPI slave select signal without the risk that two ouputs be drive the same pin.
+ *
* @{
*/
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
- #define LEDS_PORTB_LEDS (LEDS_LED1)
- #define LEDS_PORTD_LEDS (LEDS_LED2)
+ #define LEDS_PORTD_LEDS (LEDS_LED1)
+ #define LEDS_PORTB_LEDS (LEDS_LED2)
#endif
/* Public Interface - May be used in end-application: */
/* Macros: */
/** LED mask for the first LED on the board. */
- #define LEDS_LED1 (1 << 0)
+ #define LEDS_LED1 (1 << 5)
/** LED mask for the second LED on the board. */
- #define LEDS_LED2 (1 << 5)
+ #define LEDS_LED2 (1 << 0)
/** LED mask for all the LEDs on the board. */
- #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2)
+ #define LEDS_ALL_LEDS (LEDS_LED1)
/** LED mask for none of the board LEDs. */
#define LEDS_NO_LEDS 0
#if !defined(__DOXYGEN__)
static inline void LEDs_Init(void)
{
- DDRB |= LEDS_PORTB_LEDS;
- PORTB &= ~LEDS_PORTB_LEDS;
DDRD |= LEDS_PORTD_LEDS;
PORTD &= ~LEDS_PORTD_LEDS;
}
static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
{
- PORTB |= (LEDMask & LEDS_PORTB_LEDS);
PORTD |= (LEDMask & LEDS_PORTD_LEDS);
}
static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
{
- PORTB &= ~(LEDMask & LEDS_PORTB_LEDS);
PORTD &= ~(LEDMask & LEDS_PORTD_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));
}
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));
}
static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
{
- PORTB ^= (LEDMask & LEDS_PORTB_LEDS);
PORTD ^= (LEDMask & LEDS_PORTD_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));
+ return (PORTD & LEDS_PORTD_LEDS);
}
#endif