diff --git a/firmware/controllers/algo/auto_generated_enums.cpp b/firmware/controllers/algo/auto_generated_enums.cpp index 413c86fe76..ce51a2b3c3 100644 --- a/firmware/controllers/algo/auto_generated_enums.cpp +++ b/firmware/controllers/algo/auto_generated_enums.cpp @@ -1,6 +1,6 @@ #include "global.h" #include "rusefi_hw_enums.h" -// was generated automatically by rusEFI tool from rusefi_hw_enums.h // by enum2string.jar tool on Mon Jul 12 21:09:56 EDT 2021 +// was generated automatically by rusEFI tool from rusefi_hw_enums.h // by enum2string.jar tool on Mon Jan 03 20:26:28 EST 2022 // see also gen_config_and_enums.bat @@ -50,6 +50,8 @@ case EFI_ADC_NONE: } const char *getBrain_pin_diag_e(brain_pin_diag_e value){ switch(value) { +case PIN_DRIVER_OFF: + return "PIN_DRIVER_OFF"; case PIN_DRIVER_OVERTEMP: return "PIN_DRIVER_OVERTEMP"; case PIN_INVALID: diff --git a/firmware/controllers/algo/rusefi_hw_enums.h b/firmware/controllers/algo/rusefi_hw_enums.h index e193e1bbaa..bd4978a57e 100644 --- a/firmware/controllers/algo/rusefi_hw_enums.h +++ b/firmware/controllers/algo/rusefi_hw_enums.h @@ -252,6 +252,7 @@ typedef enum __attribute__ ((__packed__)) PIN_SHORT_TO_BAT = 0x04, PIN_OVERLOAD = 0x08, PIN_DRIVER_OVERTEMP = 0x10, + PIN_DRIVER_OFF = 0x20, PIN_INVALID = 0x80 } brain_pin_diag_e; diff --git a/firmware/hw_layer/drivers/gpio/tle8888.cpp b/firmware/hw_layer/drivers/gpio/tle8888.cpp index 6a100f2927..b65a54b5ef 100644 --- a/firmware/hw_layer/drivers/gpio/tle8888.cpp +++ b/firmware/hw_layer/drivers/gpio/tle8888.cpp @@ -40,6 +40,8 @@ #include "gpio/gpio_ext.h" #include "os_util.h" +static Timer diagResponse; + /* * TODO list: */ @@ -889,6 +891,8 @@ static THD_FUNCTION(tle8888_driver_thread, p) { ret = chip->update_status_and_diag(); if (ret) { /* set state to TLE8888_FAILED or force reinit? */ + } else { + diagResponse.reset(); } /* TODO: * Procedure to switch on after failure condition occurred: @@ -989,8 +993,11 @@ int Tle8888::readPad(size_t pin) { return -1; } -brain_pin_diag_e Tle8888::getOutputDiag(size_t pin) -{ +brain_pin_diag_e Tle8888::getOutputDiag(size_t pin) { + if (diagResponse.hasElapsedMs(500)) { + // has been to long since we've recieved diagnostics + return PIN_DRIVER_OFF; + } /* OUT1..OUT4, indexes 0..3 */ if (pin < 4) return tle8888_2b_to_diag_with_temp((OutDiag[0] >> ((pin - 0) * 2)) & 0x03); diff --git a/firmware/hw_layer/pin_repository.cpp b/firmware/hw_layer/pin_repository.cpp index 6005d23fef..f44d4c3c07 100644 --- a/firmware/hw_layer/pin_repository.cpp +++ b/firmware/hw_layer/pin_repository.cpp @@ -117,7 +117,8 @@ void pinDiag2string(char *buffer, size_t size, brain_pin_diag_e pin_diag) { if (pin_diag == PIN_OK) { chsnprintf(buffer, size, "Ok"); } else if (pin_diag != PIN_INVALID) { - chsnprintf(buffer, size, "%s%s%s%s%s", + chsnprintf(buffer, size, "%s%s%s%s%s%s", + pin_diag & PIN_DRIVER_OFF ? "driver_off " : "", pin_diag & PIN_OPEN ? "open_load " : "", pin_diag & PIN_SHORT_TO_GND ? "short_to_gnd " : "", pin_diag & PIN_SHORT_TO_BAT ? "short_to_bat " : "",