Add ability for status LED to be inverted

This commit is contained in:
Doug Brown 2023-08-06 20:35:28 -07:00 committed by Doug Brown
parent df5c50ffee
commit b1ab4ece95

12
led.h
View File

@ -27,6 +27,8 @@
#include "hal/board.h" #include "hal/board.h"
#include "hal/gpio.h" #include "hal/gpio.h"
static inline void LED_Off(void);
/** Initializes the LED and turns it off /** Initializes the LED and turns it off
* *
*/ */
@ -34,7 +36,7 @@ static inline void LED_Init(void)
{ {
GPIOPin ledPin = Board_LEDPin(); GPIOPin ledPin = Board_LEDPin();
GPIO_SetDirection(ledPin, true); GPIO_SetDirection(ledPin, true);
GPIO_SetOff(ledPin); LED_Off();
} }
/** Turns the LED on /** Turns the LED on
@ -42,7 +44,11 @@ static inline void LED_Init(void)
*/ */
static inline void LED_On(void) static inline void LED_On(void)
{ {
#if BOARD_LED_INVERTED
GPIO_SetOff(Board_LEDPin());
#else
GPIO_SetOn(Board_LEDPin()); GPIO_SetOn(Board_LEDPin());
#endif
} }
/** Turns the LED off /** Turns the LED off
@ -50,7 +56,11 @@ static inline void LED_On(void)
*/ */
static inline void LED_Off(void) static inline void LED_Off(void)
{ {
#if BOARD_LED_INVERTED
GPIO_SetOn(Board_LEDPin());
#else
GPIO_SetOff(Board_LEDPin()); GPIO_SetOff(Board_LEDPin());
#endif
} }
/** Toggles the LED /** Toggles the LED