MCU
Loading...
Searching...
No Matches
SafetySystem.cpp
Go to the documentation of this file.
1#include "SafetySystem.h"
2
3/*
4 Initialize SafetySystem
5 write software_ok high, write wd_input high, set software ok state true
6*/
8 // Initialize interface output
11 // Initial state is ok
12 software_is_ok = true;
13}
14
15/* Monitor AMS heartbeat and kick watchdog */
16void SafetySystem::software_shutdown(const SysTick_s &tick) {
17 software_is_ok = true;
18
19 // If AMS heartbeat is not received within reasonable interval
20 // Set software is not ok
21 if (!ams_->heartbeat_received(tick.millis)) {
22 // Serial.println("heartbeat not received");
23 software_is_ok = false;
24 }
25 if (software_is_ok) {
27 }
28 else {
29 ams_->set_state_ok_high(false);
30 }
31
32 // Kick watchdog every software cycle
33 wd_->kick_watchdog(tick.millis);
34}
35
36/* Return software ok */
38 return software_is_ok;
39}
bool heartbeat_received(unsigned long curr_millis)
void set_state_ok_high(bool ok_high)
void set_start_state()
WatchdogInterface * wd_
Definition: SafetySystem.h:29
void software_shutdown(const SysTick_s &tick)
AMSInterface * ams_
Definition: SafetySystem.h:28
bool get_software_is_ok()
bool software_is_ok
Definition: SafetySystem.h:32
void kick_watchdog(unsigned long curr_millis)