From 3ea3c1f537171a9a790a2b18384b4d1ec1bf0523 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Wed, 18 Jul 2018 15:10:47 -0700 Subject: [PATCH] px4fmu-v5:Runtime Safety LED support. Safety Switch is HW version dependent on having an PX4IO So we init to a benign state with the _INIT definition and use the non _INIT verion in the driver if the run time decision is we do not have a PX4IO --- src/drivers/boards/px4fmu-v5/led.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/drivers/boards/px4fmu-v5/led.c b/src/drivers/boards/px4fmu-v5/led.c index 5b5019a151..3ded48f7d0 100644 --- a/src/drivers/boards/px4fmu-v5/led.c +++ b/src/drivers/boards/px4fmu-v5/led.c @@ -79,10 +79,10 @@ static uint32_t g_ledmap[] = { # define xlat(p) (p) static uint32_t g_ledmap[] = { - GPIO_nLED_BLUE, // Indexed by LED_BLUE - GPIO_nLED_RED, // Indexed by LED_RED, LED_AMBER - GPIO_nSAFETY_SWITCH_LED_OUT, // Indexed by LED_SAFETY - GPIO_nLED_GREEN, // Indexed by LED_GREEN + GPIO_nLED_BLUE, // Indexed by LED_BLUE + GPIO_nLED_RED, // Indexed by LED_RED, LED_AMBER + GPIO_nSAFETY_SWITCH_LED_OUT_INIT, // Indexed by LED_SAFETY (defaulted to an input) + GPIO_nLED_GREEN, // Indexed by LED_GREEN }; #endif @@ -90,6 +90,10 @@ static uint32_t g_ledmap[] = { __EXPORT void led_init(void) { /* Configure LED GPIOs for output */ + if (!PX4_MFT_HW_SUPPORTED(PX4_MFT_PX4IO)) { + g_ledmap[2] = GPIO_nSAFETY_SWITCH_LED_OUT; + } + for (size_t l = 0; l < (sizeof(g_ledmap) / sizeof(g_ledmap[0])); l++) { stm32_configgpio(g_ledmap[l]); }