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

@ -28,7 +28,8 @@ uint8_t packetChecksumFails = 0;
uint8_t deviceSleeps = 0;
#define MAX_DEVICE_SLEEP 3 //TODO: change to correct value
#define MAX_CELL_VOLTAGE 4100 //change to 4200
#define MIN_CELL_VOLTAGE 3100 //change to 3100
amsState currentAMSState = AMSDEACTIVE;
amsState lastAMSState = AMSDEACTIVE;
@ -136,13 +137,13 @@ uint8_t AMS_Idle_Loop() {
int any_voltage_error = 0;
for (size_t i = 0; i < numberofCells; i++) {
if (module.cellVoltages[i] < 3200) {
if (module.cellVoltages[i] < MIN_CELL_VOLTAGE) {
any_voltage_error = 1;
error_data.data_kind = SEK_UNDERVOLT;
error_data.data[0] = i;
uint8_t* ptr = &error_data.data[1];
ptr = ftcan_marshal_unsigned(ptr, module.cellVoltages[i], 2);
} else if (module.cellVoltages[i] > 4200) {
} else if (module.cellVoltages[i] > MAX_CELL_VOLTAGE) {
any_voltage_error = 1;
error_data.data_kind = SEK_OVERVOLT;
error_data.data[0] = i;