TLE8888 watchdog #917

window watchdog progress
This commit is contained in:
rusEfi 2020-02-10 13:24:09 -05:00
parent 223fe8ab70
commit ce54ae9497
4 changed files with 30 additions and 2 deletions

View File

@ -396,11 +396,14 @@ void setTle8888TestConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
/**
* This configuration is used for MRE board Quality Assurance validation
* set engine_type 30
* MRE_BOARD_TEST
*/
void mreBoardTest(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
#if (BOARD_TLE8888_COUNT > 0)
engineConfiguration->directSelfStimulation = true; // this engine type is used for board validation
engineConfiguration->debugMode = DBG_TLE8888;
engineConfiguration->triggerSimulatorFrequency = 60;
// set cranking_rpm 500
engineConfiguration->cranking.rpm = 100;

View File

@ -905,6 +905,8 @@ static void enableOrDisable(const char *param, bool isEnabled) {
engineConfiguration->isFastAdcEnabled = isEnabled;
} else if (strEqualCaseInsensitive(param, CMD_TRIGGER_HW_INPUT)) {
engine->hwTriggerInputEnabled = isEnabled;
} else if (strEqualCaseInsensitive(param, "useTLE8888_cranking_hack")) {
CONFIG(useTLE8888_cranking_hack) = isEnabled;
} else if (strEqualCaseInsensitive(param, "etb_auto")) {
engine->etbAutoTune = isEnabled;
} else if (strEqualCaseInsensitive(param, "cranking_constant_dwell")) {

View File

@ -108,6 +108,19 @@ typedef enum {
SEMAPHORE_DECL(tle8888_wake, 10 /* or BOARD_TLE8888_COUNT ? */);
static THD_WORKING_AREA(tle8888_thread_1_wa, 256);
// todo: much of state is currently global while technically it should be per-chip. but we
// are lazy and in reality it's usually one chip per board
/**
* For the timing check the microcontroller has to send periodically the window watchdog service command
* WWDServiceCmd. The window watchdog is triggered correctly if the command is received inside the open
* window of the window watchdog sequence.
*/
static efitick_t lastWindowWatchdogTimeNt = 0;
//static_assert(TLE8888_POLL_INTERVAL_MS < Window_watchdog_open_window_time_ms)
static bool needInitialSpi = true;
int resetCounter = 0;
float vBattForTle8888 = 14;
@ -372,6 +385,15 @@ static THD_FUNCTION(tle8888_driver_thread, p) {
}
}
efitick_t nowNt = getTimeNowNt();
if (nowNt - lastWindowWatchdogTimeNt > MS2NT(Window_watchdog_close_window_time_ms)) {
// todo: super-lazy implementation!
struct tle8888_priv *chip = &chips[0];
tle8888_spi_rw(chip, CMD_WWDServiceCmd, NULL);
lastWindowWatchdogTimeNt = nowNt;
}
for (int i = 0; i < BOARD_TLE8888_COUNT; i++) {
struct tle8888_priv *chip = &chips[i];
if ((chip->cfg == NULL) ||

View File

@ -23,10 +23,11 @@
#define Window_watchdog_close_window_time_ms 100.8
// unchangeable value for TLE8888QK
#define Window_watchdog_open_window_time_ms 12.8
// unused for now
//#define Window_watchdog_open_window_time_ms 12.8
/* DOTO: add irq support */
#define TLE8888_POLL_INTERVAL_MS 100
#define TLE8888_POLL_INTERVAL_MS 7
/* note that spi transfer should be LSB first */
struct tle8888_config {