PER Firmware
Loading...
Searching...
No Matches
faults_common.h
Go to the documentation of this file.
1#ifndef FAULTS_COMMON_H
2#define FAULTS_COMMON_H
3
11#include <stdint.h>
12#include "common/can_library/generated/can_types.h"
13
14typedef enum : uint8_t {
15 FAULT_PRIO_WARNING,
16 FAULT_PRIO_ERROR,
17 FAULT_PRIO_FATAL,
18 NUM_FAULT_PRIOS
19} fault_priority_t;
20
21typedef enum : uint8_t {
22 FAULT_STATE_CLEAR = 0,
23 FAULT_STATE_PENDING = 1,
24 FAULT_STATE_LATCHED = 2,
25 FAULT_STATE_RECOVERING = 3
26} fault_state_t;
27
28typedef struct {
29 uint32_t start_time_ms;
30 uint16_t max_value;
31 uint16_t min_value;
32 uint16_t latch_time_ms;
33 uint16_t unlatch_time_ms;
34 fault_state_t state;
35 fault_priority_t priority;
36 // 2 byte padding
37} fault_t;
38
39// API
40void update_fault(fault_id_t fault_id, uint16_t value);
41bool is_latched(fault_id_t fault_id);
42bool is_clear(fault_id_t fault_id);
43void fault_library_periodic();
44
45bool is_warning_latched();
46bool is_error_latched();
47bool is_fatal_latched();
48bool is_curr_mcu_latched();
49bool is_other_mcus_latched();
50bool is_any_latched();
51
52#ifdef HAS_FAULT_STRINGS
53const char* get_fault_string(fault_id_t fault_id);
54#endif
55
56#endif // FAULTS_COMMON_H
Definition faults_common.h:28