switch errorkind to bitfield

This commit is contained in:
Kilian Bracher 2024-05-23 18:27:51 +02:00
parent d2478b5ff8
commit d701266509
1 changed files with 11 additions and 12 deletions

View File

@ -26,17 +26,16 @@ typedef enum { // valid transitions: (all could transition to error)
ERROR, // ERROR -> INACTIVE, DISCHARGE, ERROR
} State;
typedef enum {
ERRORKIND_NONE = 0x0,
ERRORKIND_BMS_TIMEOUT = 0x1,
ERRORKIND_OVERTEMPTURE = 0x2,
ERRORKIND_OVERCURRENT = 0x3,
ERRORKIND_OVERVOLTAGE = 0x4,
ERRORKIND_MISSING_CURRENT_READING = 0x5,
ERRORKIND_MISSING_VOLTAGE_READING = 0x6,
ERRORKIND_MISSING_TEMP_READING = 0x7,
ERRORKIND_PRECHARGE_FAIL = 0x8,
ERRORKIND_POWERGROUND_FAIL = 0x9
typedef struct {
uint16_t bms_timeout : 1;
uint16_t overtemp : 1;
uint16_t overcurrent : 1;
uint16_t overvoltage : 1;
uint16_t missing_current_reading : 1;
uint16_t missing_voltage_reading : 1;
uint16_t missing_temp_reading : 1;
uint16_t precharge_fail : 1;
uint16_t powerground_fail : 1;
} ErrorKind;
//typedef enum {} WarningKind;
@ -45,7 +44,7 @@ typedef struct {
State current_state;
State target_state;
uint16_t error_source; // TSErrorSource (bitmask)
uint16_t error_type; // TSErrorKind
ErrorKind error_type; // TSErrorKind
} StateHandle;
extern StateHandle state;