Compare commits
2 Commits
b9c34c9f49
...
a88f663afc
Author | SHA1 | Date | |
---|---|---|---|
a88f663afc | |||
2ca3f72de8 |
@ -31,7 +31,9 @@ HAL_StatusTypeDef amsReset() {
|
||||
amsWakeUp();
|
||||
readCMD(SRST, CMD_EMPTY_BUFFER, 0);
|
||||
|
||||
/* uint8_t sidbuffer[CMD_BUFFER_SIZE(SID_GROUP_SIZE)] = {};
|
||||
amsWakeUp();
|
||||
|
||||
uint8_t sidbuffer[CMD_BUFFER_SIZE(SID_GROUP_SIZE)] = {};
|
||||
if (readCMD(RDSID, sidbuffer, SID_GROUP_SIZE) != HAL_OK) {
|
||||
bool nonzero = false;
|
||||
for (size_t i = 0; i < N_BMS; i++) {
|
||||
@ -61,7 +63,7 @@ HAL_StatusTypeDef amsReset() {
|
||||
}
|
||||
debug_log_cont(LOG_LEVEL_INFO, "0x%lx%lx ", (uint32_t)(id >> 32), (uint32_t)(id & 0xFFFFFFFF)); //newlib does not support %llu
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
mcuDelay(10);
|
||||
amsWakeUp();
|
||||
|
@ -114,14 +114,22 @@ int main(void)
|
||||
/* Infinite loop */
|
||||
/* USER CODE BEGIN WHILE */
|
||||
int count = 0;
|
||||
int error_count = 0;
|
||||
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();
|
||||
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);
|
||||
HAL_Delay(2000);
|
||||
AMS_Init(&hspi1);
|
||||
continue;
|
||||
error_count++;
|
||||
}
|
||||
if (count % 4 == 0) {
|
||||
for (size_t i = 0; i < N_BMS; i++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user