From 41c0624459cbb22ca47f105eb113617e2d7bafa4 Mon Sep 17 00:00:00 2001 From: Robert Fisk Date: Mon, 24 Oct 2016 12:20:32 +1300 Subject: [PATCH] Startup LED flash is now asynchronous. Not only a faster startup process, but also catches some HID devices that only work if initialised within 500ms of powerup. --- Downstream/Src/led.c | 15 +++++++++++---- Upstream/Src/led.c | 15 +++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Downstream/Src/led.c b/Downstream/Src/led.c index d38f4bc..89ad590 100644 --- a/Downstream/Src/led.c +++ b/Downstream/Src/led.c @@ -18,15 +18,13 @@ uint16_t FaultLedBlinkRate = 0; uint16_t FaultLedBlinkCounter = 0; uint8_t FaultLedState = 0; +uint8_t StartupBlinkActive; void LED_Init(void) { - //RUN_LED_ON; FAULT_LED_ON; - HAL_Delay(STARTUP_FLASH_DELAY); - //RUN_LED_OFF; - FAULT_LED_OFF; + StartupBlinkActive = 1; } @@ -43,6 +41,15 @@ void LED_Fault_SetBlinkRate(uint16_t newBlinkRate) void LED_DoBlinks(void) { + if (StartupBlinkActive) + { + if (HAL_GetTick() >= STARTUP_FLASH_DELAY) + { + FAULT_LED_OFF; + StartupBlinkActive = 0; + } + } + if (FaultLedBlinkRate > 0) { FaultLedBlinkCounter++; diff --git a/Upstream/Src/led.c b/Upstream/Src/led.c index d38f4bc..89ad590 100644 --- a/Upstream/Src/led.c +++ b/Upstream/Src/led.c @@ -18,15 +18,13 @@ uint16_t FaultLedBlinkRate = 0; uint16_t FaultLedBlinkCounter = 0; uint8_t FaultLedState = 0; +uint8_t StartupBlinkActive; void LED_Init(void) { - //RUN_LED_ON; FAULT_LED_ON; - HAL_Delay(STARTUP_FLASH_DELAY); - //RUN_LED_OFF; - FAULT_LED_OFF; + StartupBlinkActive = 1; } @@ -43,6 +41,15 @@ void LED_Fault_SetBlinkRate(uint16_t newBlinkRate) void LED_DoBlinks(void) { + if (StartupBlinkActive) + { + if (HAL_GetTick() >= STARTUP_FLASH_DELAY) + { + FAULT_LED_OFF; + StartupBlinkActive = 0; + } + } + if (FaultLedBlinkRate > 0) { FaultLedBlinkCounter++;