better blinking logic in case of software fatal error

This commit is contained in:
rusefi 2019-02-05 21:29:55 -05:00
parent 8dad472933
commit 01045db270
1 changed files with 14 additions and 7 deletions

View File

@ -616,19 +616,26 @@ static void blinkingThread(void *arg) {
initialLedsBlink(); initialLedsBlink();
while (true) { while (true) {
int delayMs = is_usb_serial_ready() ? 3 * blinkingPeriodMs : blinkingPeriodMs; int onTimeMs = is_usb_serial_ready() ? 3 * blinkingPeriodMs : blinkingPeriodMs;
#if EFI_INTERNAL_FLASH || defined(__DOXYGEN__) #if EFI_INTERNAL_FLASH || defined(__DOXYGEN__)
if (getNeedToWriteConfiguration()) { if (getNeedToWriteConfiguration()) {
delayMs = 2 * delayMs; onTimeMs = 2 * onTimeMs;
} }
#endif #endif
int offTimeMs = onTimeMs;
if (!hasFirmwareError()) { if (hasFirmwareError()) {
enginePins.communicationLedPin.setValue(0); // special behavior in case of fatal error - not equal on/off time
// this special behaviour helps to notice that something is not right, also
// differentiates software firmware error from fatal interrupt error with CPU halt.
offTimeMs = 50;
onTimeMs = 450;
} }
enginePins.communicationLedPin.setValue(0);
enginePins.warningLedPin.setValue(0); enginePins.warningLedPin.setValue(0);
chThdSleepMilliseconds(delayMs); chThdSleepMilliseconds(offTimeMs);
enginePins.communicationLedPin.setValue(1); enginePins.communicationLedPin.setValue(1);
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__) #if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
@ -636,8 +643,8 @@ static void blinkingThread(void *arg) {
consoleByteArrived = false; consoleByteArrived = false;
enginePins.warningLedPin.setValue(1); enginePins.warningLedPin.setValue(1);
} }
#endif #endif /* EFI_ENGINE_CONTROL */
chThdSleepMilliseconds(delayMs); chThdSleepMilliseconds(onTimeMs);
} }
} }