Watchdog for simulator refactor

This commit is contained in:
andreika-git 2023-11-29 15:34:34 +02:00 committed by rusefillc
parent f534d11f9e
commit b683a4f04c
2 changed files with 32 additions and 3 deletions

View File

@ -8,6 +8,5 @@ static bool isValidCanRxPin(brain_pin_e) { return true; }
static bool allowFlashWhileRunning() { return true; }
static void causeHardFault() { }
static void startWatchdog(int = 300) { }
static void setWatchdogResetPeriod(int) { }
static void tryResetWatchdog() { }
#include "sim_watchdog.h"

View File

@ -0,0 +1,30 @@
/**
* @file sim_watchdog.h
* @brief Simulator of Independent Watchdog (IWDG) high-level API
*
* @date Nov 28, 2023
* @author Andrey Belomutskiy, (c) 2012-2023
* @author andreika <prometheus.pcb@gmail.com>
*/
#pragma once
#include "engine_controller.h"
// 100 ms is our empiric choice based on 2 * SLOW_CALLBACK_PERIOD_MS
#define WATCHDOG_RESET_MS (2 * SLOW_CALLBACK_PERIOD_MS)
// 300 ms is our default timeout
#define WATCHDOG_TIMEOUT_MS (3 * WATCHDOG_RESET_MS)
// 5 secs should be enough to wait until
#define WATCHDOG_FLASH_TIMEOUT_MS 5000
// we use 'int' for compatibility with addConsoleActionI()
// can be called multiple times to change the timeout
void startWatchdog(int = WATCHDOG_TIMEOUT_MS) { }
// Can be called for debug reasons to test the watchdog
void setWatchdogResetPeriod(int resetMs) { }
// A reset is done only if enough time has passed since the last reset.
void tryResetWatchdog() { }