MCU
Loading...
Searching...
No Matches
lib
systems
src
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
*/
7
void
SafetySystem::init
() {
8
// Initialize interface output
9
ams_
->
set_start_state
();
10
wd_
->
set_start_state
();
11
// Initial state is ok
12
software_is_ok
=
true
;
13
}
14
15
/* Monitor AMS heartbeat and kick watchdog */
16
void
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
) {
26
ams_
->
set_state_ok_high
(
true
);
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 */
37
bool
SafetySystem::get_software_is_ok
() {
38
return
software_is_ok
;
39
}
SafetySystem.h
AMSInterface::heartbeat_received
bool heartbeat_received(unsigned long curr_millis)
Definition:
AMSInterface.cpp:50
AMSInterface::set_state_ok_high
void set_state_ok_high(bool ok_high)
Definition:
AMSInterface.cpp:39
AMSInterface::set_start_state
void set_start_state()
Definition:
AMSInterface.cpp:32
SafetySystem::wd_
WatchdogInterface * wd_
Definition:
SafetySystem.h:29
SafetySystem::software_shutdown
void software_shutdown(const SysTick_s &tick)
Definition:
SafetySystem.cpp:16
SafetySystem::init
void init()
Definition:
SafetySystem.cpp:7
SafetySystem::ams_
AMSInterface * ams_
Definition:
SafetySystem.h:28
SafetySystem::get_software_is_ok
bool get_software_is_ok()
Definition:
SafetySystem.cpp:37
SafetySystem::software_is_ok
bool software_is_ok
Definition:
SafetySystem.h:32
WatchdogInterface::set_start_state
void set_start_state()
Definition:
WatchdogInterface.cpp:14
WatchdogInterface::kick_watchdog
void kick_watchdog(unsigned long curr_millis)
Definition:
WatchdogInterface.cpp:21
Generated by
1.9.5