TLE8888 watchdog #917

This commit is contained in:
rusEfi 2020-02-10 14:37:52 -05:00
parent 59eb424ba0
commit 0b8c1e69dc
2 changed files with 22 additions and 0 deletions

View File

@ -119,6 +119,10 @@ static THD_WORKING_AREA(tle8888_thread_1_wa, 256);
*/
static efitick_t lastWindowWatchdogTimeNt = 0;
static efitick_t lastFunctionWatchdogTimeNt = 0;
static uint16_t functionWDrx = 0;
//static_assert(TLE8888_POLL_INTERVAL_MS < Window_watchdog_open_window_time_ms)
static bool needInitialSpi = true;
@ -177,6 +181,7 @@ void tle8888PostState(TsDebugChannels *debugChannels) {
debugChannels->debugFloatField3 = chips[0].OpStat[1];
debugChannels->debugFloatField4 = resetCounter;
debugChannels->debugFloatField5 = functionWDrx;
}
#endif /* EFI_TUNER_STUDIO */
@ -270,6 +275,7 @@ static int tle8888_update_status(struct tle8888_priv *chip)
/* TODO: lock? */
// todo: extract helper method?
/* the address and content of the selected register is transmitted with the
* next SPI transmission (for not existing addresses or wrong access mode
* the data is always '0' */
@ -393,6 +399,19 @@ static THD_FUNCTION(tle8888_driver_thread, p) {
lastWindowWatchdogTimeNt = nowNt;
}
if (nowNt - lastFunctionWatchdogTimeNt > MS2NT(Functional_Watchdog_PERIOD_MS)) {
// todo: super-lazy implementation!
struct tle8888_priv *chip = &chips[0];
// todo: extract helper method?
/* the address and content of the selected register is transmitted with the
* next SPI transmission (for not existing addresses or wrong access mode
* the data is always '0' */
tle8888_spi_rw(chip, CMD_FWDStat1, NULL);
tle8888_spi_rw(chip, CMD_FWDStat1, &functionWDrx);
lastFunctionWatchdogTimeNt = nowNt;
}
for (int i = 0; i < BOARD_TLE8888_COUNT; i++) {
struct tle8888_priv *chip = &chips[i];

View File

@ -19,6 +19,9 @@
* 4 INJ channels - OUT1..4 - IN5..8 */
#define TLE8888_DIRECT_OUTPUTS (4 + 4 + TLE8888_DIRECT_MISC)
// Looks like reset value is 113.6ms? 1.6ms * 0x47
#define Functional_Watchdog_PERIOD_MS 90
// we can change this value on TLE8888QK but we probably do not have a reason to change
#define Window_watchdog_close_window_time_ms 100.8