openpilot v0.9.6 release
date: 2024-02-21T23:02:42 master commit: 0b4d08fab8e35a264bc7383e878538f8083c33e5
This commit is contained in:
26
panda/board/drivers/simple_watchdog.h
Normal file
26
panda/board/drivers/simple_watchdog.h
Normal file
@@ -0,0 +1,26 @@
|
||||
typedef struct simple_watchdog_state_t {
|
||||
uint32_t fault;
|
||||
uint32_t last_ts;
|
||||
uint32_t threshold;
|
||||
} simple_watchdog_state_t;
|
||||
|
||||
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();
|
||||
}
|
||||
Reference in New Issue
Block a user