mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-11 20:32:13 +08:00
33d5cfc393
date: 2025-12-18T23:23:16 master commit: 3cdee7b54718ee14bd85befd6c5bad3d699c5479
22 lines
540 B
C
22 lines
540 B
C
#include "simple_watchdog_declarations.h"
|
|
|
|
static simple_watchdog_state_t wd_state;
|
|
|
|
void simple_watchdog_kick(void) {
|
|
uint32_t ts = microsecond_timer_get();
|
|
|
|
uint32_t et = get_ts_elapsed(ts, wd_state.last_ts);
|
|
if (et > wd_state.threshold) {
|
|
print("WD timeout 0x"); puth(et); print("\n");
|
|
fault_occurred(wd_state.fault);
|
|
}
|
|
|
|
wd_state.last_ts = ts;
|
|
}
|
|
|
|
void simple_watchdog_init(uint32_t fault, uint32_t threshold) {
|
|
wd_state.fault = fault;
|
|
wd_state.threshold = threshold;
|
|
wd_state.last_ts = microsecond_timer_get();
|
|
}
|