Display inverter & motor temperatures
This commit is contained in:
@ -14,6 +14,7 @@
|
||||
#define CAN_ID_AMS_SLAVE_PANIC 0x9
|
||||
#define CAN_ID_AMS_STATUS 0xA
|
||||
#define CAN_ID_AMS_ERROR 0xC
|
||||
#define CAN_ID_CS_INTERNAL 0x108
|
||||
#define CAN_ID_MISSION_SELECTED 0x400
|
||||
#define CAN_ID_STW_BUTTONS 0x401
|
||||
#define CAN_ID_STW_PARAM_SET 0x402
|
||||
@ -24,6 +25,7 @@
|
||||
#define CAN_ID_SHUNT_VOLTAGE2 0x523
|
||||
#define CAN_AMS_STATUS_VOLTAGE_FACTOR 1e-4
|
||||
#define CAN_AMS_STATUS_TEMP_FACTOR 0.0625
|
||||
#define CAN_CS_INTERNAL_TEMP_FACTOR 0.01
|
||||
|
||||
VehicleState vehicle_state = {0};
|
||||
|
||||
@ -32,6 +34,7 @@ void vehicle_thread_entry(ULONG 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_CS_INTERNAL, 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);
|
||||
@ -84,6 +87,17 @@ void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data) {
|
||||
vehicle_state.last_ams_error.kind = data[0];
|
||||
vehicle_state.last_ams_error.arg = data[1];
|
||||
break;
|
||||
case CAN_ID_CS_INTERNAL:
|
||||
vehicle_state.temps.inv_l =
|
||||
(data[0] | (data[1] << 8)) * CAN_CS_INTERNAL_TEMP_FACTOR;
|
||||
vehicle_state.temps.inv_r =
|
||||
(data[2] | (data[3] << 8)) * CAN_CS_INTERNAL_TEMP_FACTOR;
|
||||
vehicle_state.temps.mot_l =
|
||||
(data[4] | (data[5] << 8)) * CAN_CS_INTERNAL_TEMP_FACTOR;
|
||||
// TODO: uncomment when we have a right motor
|
||||
// vehicle_state.temps.mot_r =
|
||||
// (data[6] | (data[7] << 8)) * CAN_CS_INTERNAL_TEMP_FACTOR;
|
||||
break;
|
||||
case CAN_ID_AS_MISSION_FB:
|
||||
vehicle_state.active_mission = data[0] & 0b111;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user