Add AMS Error popup
This commit is contained in:
@ -55,6 +55,23 @@ typedef enum {
|
||||
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 fl;
|
||||
float fr;
|
||||
@ -89,6 +106,15 @@ typedef struct {
|
||||
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;
|
||||
|
||||
@ -11,7 +11,9 @@
|
||||
#include "stm32h7xx_hal_gpio.h"
|
||||
#include "tx_api.h"
|
||||
|
||||
#define CAN_ID_AMS_SLAVE_PANIC 0x9
|
||||
#define CAN_ID_AMS_STATUS 0xA
|
||||
#define CAN_ID_AMS_ERROR 0xC
|
||||
#define CAN_ID_MISSION_SELECTED 0x400
|
||||
#define CAN_ID_STW_BUTTONS 0x401
|
||||
#define CAN_ID_STW_PARAM_SET 0x402
|
||||
@ -27,7 +29,9 @@ VehicleState vehicle_state = {0};
|
||||
|
||||
void vehicle_thread_entry(ULONG hfdcan_addr) {
|
||||
ftcan_init((void *)hfdcan_addr);
|
||||
ftcan_add_filter(CAN_ID_AMS_SLAVE_PANIC, 0x7FF);
|
||||
ftcan_add_filter(CAN_ID_AMS_STATUS, 0x7FF);
|
||||
ftcan_add_filter(CAN_ID_AMS_ERROR, 0x7FF);
|
||||
ftcan_add_filter(CAN_ID_AS_MISSION_FB, 0x7FF);
|
||||
ftcan_add_filter(CAN_ID_STW_STATUS, 0x7FF);
|
||||
ftcan_add_filter(CAN_ID_SHUNT_CURRENT, 0x7FF);
|
||||
@ -59,16 +63,27 @@ void vehicle_broadcast_buttons(GPIO_PinState *button_states) {
|
||||
}
|
||||
|
||||
void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data) {
|
||||
const uint8_t *ptr;
|
||||
switch (id) {
|
||||
case CAN_ID_AMS_SLAVE_PANIC:
|
||||
vehicle_state.last_ams_slave_panic.id = data[0];
|
||||
vehicle_state.last_ams_slave_panic.kind = data[1];
|
||||
ptr = &data[2];
|
||||
vehicle_state.last_ams_slave_panic.arg = ftcan_unmarshal_unsigned(&ptr, 4);
|
||||
break;
|
||||
case CAN_ID_AMS_STATUS:
|
||||
vehicle_state.ts_state = data[0] & 0x7F;
|
||||
vehicle_state.soc = data[1];
|
||||
const uint8_t *ptr = &data[2];
|
||||
ptr = &data[2];
|
||||
vehicle_state.min_cell_volt =
|
||||
ftcan_unmarshal_unsigned(&ptr, 2) * CAN_AMS_STATUS_VOLTAGE_FACTOR;
|
||||
vehicle_state.max_cell_temp =
|
||||
ftcan_unmarshal_signed(&ptr, 2) * CAN_AMS_STATUS_TEMP_FACTOR;
|
||||
break;
|
||||
case CAN_ID_AMS_ERROR:
|
||||
vehicle_state.last_ams_error.kind = data[0];
|
||||
vehicle_state.last_ams_error.arg = data[1];
|
||||
break;
|
||||
case CAN_ID_AS_MISSION_FB:
|
||||
vehicle_state.active_mission = data[0] & 0b111;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user