157 lines
2.8 KiB
C
157 lines
2.8 KiB
C
#ifndef __INC_VEHICLE_STATE_H
|
|
#define __INC_VEHICLE_STATE_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "stw_defines.h"
|
|
#include <stdint.h>
|
|
|
|
typedef enum {
|
|
TS_INACTIVE = 0,
|
|
TS_ACTIVE = 1,
|
|
TS_PRECHARGE = 2,
|
|
TS_DISCHARGE = 3,
|
|
TS_ERROR = 4,
|
|
TS_CHARGING_CHECK = 5,
|
|
TS_CHARGING = 6
|
|
} TSState;
|
|
|
|
typedef enum {
|
|
AS_OFF = 0,
|
|
AS_MANUAL = 1,
|
|
AS_READY = 2,
|
|
AS_DRIVING = 3,
|
|
AS_FINISHED = 4,
|
|
AS_EMERGENCY = 5
|
|
} ASState;
|
|
|
|
typedef enum {
|
|
R2D_NONE = 0,
|
|
R2D_TSMS = 1,
|
|
R2D_TSACTIVE = 2,
|
|
R2D_RESETTING_NODES = 3,
|
|
R2D_RESETTING_COMMS = 4,
|
|
R2D_WAITING_INIT = 5,
|
|
R2D_INIT_STAGE1 = 6,
|
|
R2D_INIT_STAGE2 = 7,
|
|
R2D_INIT_SUCCESS = 0xF
|
|
} R2DProgress;
|
|
|
|
typedef enum {
|
|
INICHK_START = 0,
|
|
INICHK_WD_CHECK = 1,
|
|
INICHK_WD_OK = 2,
|
|
INICHK_ASB_CHECK_1 = 3,
|
|
INICHK_ASB_CHECK_2 = 4,
|
|
INICHK_WAIT_TS = 5,
|
|
INICHK_EBS_CHECK_A = 6,
|
|
INICHK_EBS_CHECK_B = 7,
|
|
INICHK_DONE = 8,
|
|
INICHK_ERROR = 9
|
|
} IniChkState;
|
|
|
|
typedef enum {
|
|
AMS_ERROR_NONE = 0x00,
|
|
AMS_ERROR_SLAVE_TIMEOUT = 0x01,
|
|
AMS_ERROR_SLAVE_PANIC = 0x02,
|
|
AMS_ERROR_SHUNT_TIMEOUT = 0x03,
|
|
AMS_ERROR_SHUNT_OVERCURRENT = 0x04,
|
|
AMS_ERROR_SHUNT_OVERTEMP = 0x05
|
|
} AMSErrorKind;
|
|
typedef enum {
|
|
AMS_SLAVEPANIC_OVERTEMP = 0x00,
|
|
AMS_SLAVEPANIC_UNDERTEMP = 0x01,
|
|
AMS_SLAVEPANIC_OVERVOLTAGE = 0x02,
|
|
AMS_SLAVEPANIC_UNDERVOLTAGE = 0x03,
|
|
AMS_SLAVEPANIC_TOO_FEW_TEMP = 0x04,
|
|
AMS_SLAVEPANIC_OPENWIRE = 0x05
|
|
} AMSSlavePanicKind;
|
|
|
|
typedef struct {
|
|
float tire_fl;
|
|
float tire_fr;
|
|
float tire_rl;
|
|
float tire_rr;
|
|
|
|
float brake_fl;
|
|
float brake_fr;
|
|
float brake_rl;
|
|
float brake_rr;
|
|
|
|
float inv_l;
|
|
float inv_r;
|
|
float mot_l;
|
|
float mot_r;
|
|
float bat_l;
|
|
float bat_r;
|
|
} Temperatures;
|
|
|
|
typedef struct {
|
|
TSState ts_state;
|
|
ASState as_state;
|
|
Mission active_mission;
|
|
|
|
int sdc_closed;
|
|
|
|
R2DProgress r2d_progress;
|
|
struct {
|
|
int invl_ready : 1;
|
|
int invr_ready : 1;
|
|
int sdc_bfl : 1;
|
|
int sdc_brl : 1;
|
|
int sdc_acc : 1;
|
|
int sdc_hvb : 1;
|
|
int err_sdc : 1;
|
|
int err_ams : 1;
|
|
int err_pdu : 1;
|
|
int err_ini_chk : 1;
|
|
int err_con_mon : 1;
|
|
int err_scs : 1;
|
|
int err_sbspd : 1;
|
|
int err_appsp : 1;
|
|
int err_as : 1;
|
|
int err_ros : 1;
|
|
int err_res : 1;
|
|
int err_invl : 1;
|
|
int err_invr : 1;
|
|
} errors;
|
|
struct {
|
|
AMSErrorKind kind;
|
|
uint8_t arg;
|
|
} last_ams_error;
|
|
struct {
|
|
uint8_t id;
|
|
AMSSlavePanicKind kind;
|
|
uint32_t arg;
|
|
} last_ams_slave_panic;
|
|
IniChkState ini_chk_state;
|
|
|
|
unsigned lap_count;
|
|
Temperatures temps;
|
|
|
|
float min_cell_volt;
|
|
float max_cell_temp;
|
|
int soc;
|
|
|
|
float ts_current;
|
|
float ts_voltage_bat;
|
|
float ts_voltage_veh;
|
|
|
|
float speed;
|
|
|
|
float brake_press_f;
|
|
float brake_press_r;
|
|
|
|
float distance_total;
|
|
} VehicleState;
|
|
|
|
extern VehicleState vehicle_state;
|
|
|
|
#ifdef __cplusplus
|
|
} // extern "C"
|
|
#endif
|
|
|
|
#endif // __INC_VEHICLE_STATE_H
|