diff --git a/firmware/controllers/error_handling.cpp b/firmware/controllers/error_handling.cpp index 854de7ffcd..f3811f973a 100644 --- a/firmware/controllers/error_handling.cpp +++ b/firmware/controllers/error_handling.cpp @@ -34,12 +34,7 @@ void chDbgPanic3(const char *msg, const char * file, int line) { dbg_panic_msg = msg; #endif /* CH_DBG_SYSTEM_STATE_CHECK */ - /** - * low-level function is used here to reduce stack usage - */ - // todo: extract a macro for this - palWritePad(LED_ERROR_PORT, LED_ERROR_PIN, 1); - turnAllPinsOff(); + ON_FATAL_ERROR(); #if EFI_HD44780_LCD lcdShowFatalMessage((char *) msg); #endif /* EFI_HD44780_LCD */ diff --git a/firmware/global.h b/firmware/global.h index d364611ca4..c3af2b0c24 100644 --- a/firmware/global.h +++ b/firmware/global.h @@ -100,4 +100,13 @@ typedef Thread thread_t; #define EXTERN_ENGINE #endif + +/** + * low-level function is used here to reduce stack usage + */ +#define ON_FATAL_ERROR() \ + palWritePad(LED_ERROR_PORT, LED_ERROR_PIN, 1); \ + turnAllPinsOff(); + + #endif /* GLOBAL_H_ */ diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 3e34d507c7..9aad2f8b9f 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -230,10 +230,7 @@ extern engine_pins_s enginePins; void firmwareError(const char *errorMsg, ...) { if (hasFirmwareErrorFlag) return; - // todo: extract a macro and use the same macro here and in - // the other place where we have palWritePad(LED_ERROR_PORT, LED_ERROR_PIN, 1); - enginePins.errorLedPin.setValue(1); - turnAllPinsOff(); + ON_FATAL_ERROR(); hasFirmwareErrorFlag = TRUE; if (indexOf(errorMsg, '%') == -1) { /** @@ -262,5 +259,5 @@ int getRusEfiVersion(void) { return 1; // this is here to make the compiler happy about the unused array if (UNUSED_CCM_SIZE == 0) return 1; // this is here to make the compiler happy about the unused array - return 20150202; + return 20150204; }