From 98394afcc7a81fb6d5c44b82f61eb2227a005640 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Wed, 26 Sep 2018 08:12:56 -0700 Subject: [PATCH] board common:Define default CONTROL_STATUS LED mapping This commit is the groundwork to fix the power LED blinking on V5 Background: ---------- Early boards only had an AMBER LED that was used to indicate a High Load condition. This change defines the new logical inteface the LED_ should not be used in application code moving forward, only the minipulator macros should be used. Logical usage Legacy default ------------------------+------------- BOARD_OVERLOAD_LED | LED_RED Later boards defined BOARD_HAS_CONTROL_STATUS_LEDS and added the use of a BLUE and GREEN LED that were used as follows: Logical usage Legacy default ------------------------+------------- BOARD_ARMED_LED | LED_BLUE BOARD_ARMED_STATE_LED | LED_GREEN With this PR a board may now define _only_ a subset the leds and map them at the board level to the color LED it wants to use. Logical usage Legacy default ------------------------+------------- BOARD_OVERLOAD_LED | LED_RED when BOARD_HAS_CONTROL_STATUS_LEDS is defined BOARD_ARMED_LED | LED_BLUE BOARD_ARMED_STATE_LED | LED_GREEN If any of the BOARD_{OVERLOAD|ARMED|ARMED_STATE}_LED are not defined. The code output generates a null action for that LED. --- src/drivers/boards/common/board_common.h | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/drivers/boards/common/board_common.h b/src/drivers/boards/common/board_common.h index fcf54bc535..12bcf0b294 100644 --- a/src/drivers/boards/common/board_common.h +++ b/src/drivers/boards/common/board_common.h @@ -291,6 +291,39 @@ # define BOARD_HAS_VERSIONING 1 #endif +/* Default LED logical to color mapping */ + +#if defined(BOARD_OVERLOAD_LED) +# define BOARD_OVERLOAD_LED_TOGGLE() led_toggle(BOARD_OVERLOAD_LED) +# define BOARD_OVERLOAD_LED_OFF() led_off(BOARD_OVERLOAD_LED) +#else +# define BOARD_OVERLOAD_LED_TOGGLE() +# define BOARD_OVERLOAD_LED_OFF() +#endif + +#if defined(BOARD_HAS_CONTROL_STATUS_LEDS) + +# if defined(BOARD_ARMED_LED) +# define BOARD_ARMED_LED_TOGGLE() led_toggle(BOARD_ARMED_LED) +# define BOARD_ARMED_LED_OFF() led_off(BOARD_ARMED_LED) +# define BOARD_ARMED_LED_ON() led_on(BOARD_ARMED_LED) +# else +# define BOARD_ARMED_LED_TOGGLE() +# define BOARD_ARMED_LED_OFF() +# define BOARD_ARMED_LED_ON() +# endif + +# if defined(BOARD_ARMED_STATE_LED) +# define BOARD_ARMED_STATE_LED_TOGGLE() led_toggle(BOARD_ARMED_STATE_LED) +# define BOARD_ARMED_STATE_LED_OFF() led_off(BOARD_ARMED_STATE_LED) +# define BOARD_ARMED_STATE_LED_ON() led_on(BOARD_ARMED_STATE_LED) +# else +# define BOARD_ARMED_STATE_LED_TOGGLE() +# define BOARD_ARMED_STATE_LED_OFF() +# define BOARD_ARMED_STATE_LED_ON() +# endif +#endif // + /************************************************************************************ * Public Data ************************************************************************************/