This commit is contained in:
hamza
2024-07-08 18:52:09 +03:00
parent 17e8cee0ac
commit 1a6728f7c0
8 changed files with 165 additions and 13 deletions

View File

@ -65,12 +65,12 @@ void can_handle_send_status() {
sm_check_battery_temperature(&id_highest_temp, &highest_temp);
data[0] = ((state.current_state << 4) | (powerground_status >> 4)); // 1 bit emptyy | 3 bit state | 4 bit powerground
data[1] = ((powerground_status << 4) | (state.error_source >> 4)); // 4 bit powerground | 4 bit error
data[1] = ((powerground_status << 4) | (state.error_source >> 4)); // 4 bit powerground | 4 bit error
data[2] = ((state.error_source << 4) | (0)); // 4 bit error | 4 bit state of charge
data[3] = ((RELAY_BAT_SIDE_VOLTAGE >> 8)); // 4 bit state of charge | 4 bit battery voltage
data[3] = ((RELAY_BAT_SIDE_VOLTAGE >> 8)); // 8 bit battery voltage
data[4] = ((RELAY_BAT_SIDE_VOLTAGE >> 0));
data[5] = ((CURRENT_MEASUREMENT >> 8));
data[6] = ((CURRENT_MEASUREMENT & 0x000F) | (highest_temp >> 12));
data[5] = ((CURRENT_MEASUREMENT) / 1000);
data[6] = (/*(CURRENT_MEASUREMENT & 0x000F) |*/ (highest_temp >> 12));
data[7] = ((highest_temp) >> 4);
//data[7] = state.error_source;
ftcan_transmit(CAN_ID_OUT, data, sizeof(data));
@ -144,6 +144,12 @@ void can_handle_recieve_command(const uint8_t *data){
sm_handle_ams_in(data);
} else if (data[0] == 0x02 && data[1] <= 100) {
sm_handle_ams_in(data);
} else if (data[0] == 0xF0 && data[1] == 0x00) {
sm_handle_ams_in(data);
} else if (data[0] == 0xF1 && data[1] == 0) {
sm_handle_ams_in(data);
} else if (data[0] == 0xFF && data[1] == 0) {
sm_handle_ams_in(data);
}
}