give bms time to settle before erroring immediately
This commit is contained in:
parent
2ca3f72de8
commit
a88f663afc
@ -114,14 +114,22 @@ int main(void)
|
|||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
/* USER CODE BEGIN WHILE */
|
/* USER CODE BEGIN WHILE */
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
int error_count = 0;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
if (error_count > 10) {
|
||||||
|
debug_log(LOG_LEVEL_ERROR, "Too many errors, restarting BMS...");
|
||||||
|
status = AMS_Init(&hspi1);
|
||||||
|
if (status.status != ADBMS_NO_ERROR) {
|
||||||
|
debug_log(LOG_LEVEL_ERROR, "Failed to initialize BMS, AMS_Init returned %u (%s) on BMS %d", status.status, ADBMS_Status_ToString(status.status), status.bms_id);
|
||||||
|
HAL_Delay(2000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
status = AMS_Idle_Loop();
|
status = AMS_Idle_Loop();
|
||||||
if (status.status != ADBMS_NO_ERROR) {
|
if (status.status != ADBMS_NO_ERROR) {
|
||||||
debug_log(LOG_LEVEL_ERROR, "AMS_Idle_Loop returned %u (%s) on BMS %d", status.status, ADBMS_Status_ToString(status.status), status.bms_id);
|
debug_log(LOG_LEVEL_ERROR, "AMS_Idle_Loop returned %u (%s) on BMS %d", status.status, ADBMS_Status_ToString(status.status), status.bms_id);
|
||||||
HAL_Delay(2000);
|
error_count++;
|
||||||
AMS_Init(&hspi1);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if (count % 4 == 0) {
|
if (count % 4 == 0) {
|
||||||
for (size_t i = 0; i < N_BMS; i++) {
|
for (size_t i = 0; i < N_BMS; i++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user