H7: reset CAN core on bus off state (#1615)

* init

* misra

* merge
This commit is contained in:
Igor Biletskyy 2023-09-06 09:50:13 -07:00 committed by GitHub
parent 39bc5a4886
commit 394b61cd16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 12 deletions

View File

@ -75,9 +75,11 @@ void update_can_health_pkt(uint8_t can_number, uint32_t ir_reg) {
if ((ir_reg & (FDCAN_IR_RF0L)) != 0) {
can_health[can_number].total_rx_lost_cnt += 1U;
}
// While multiplexing between buses 1 and 3 we are getting ACK errors that overwhelm CAN core
// By resseting CAN core when no ACK is detected for a while(until TEC counter reaches 127) it can recover faster
if (((can_health[can_number].last_error == CAN_ACK_ERROR) || (can_health[can_number].last_data_error == CAN_ACK_ERROR)) && (can_health[can_number].transmit_error_cnt > 127U)) {
// Cases:
// 1. while multiplexing between buses 1 and 3 we are getting ACK errors that overwhelm CAN core, by resetting it recovers faster
// 2. H7 gets stuck in bus off recovery state indefinitely
if ((((can_health[can_number].last_error == CAN_ACK_ERROR) || (can_health[can_number].last_data_error == CAN_ACK_ERROR)) && (can_health[can_number].transmit_error_cnt > 127U)) ||
((ir_reg & FDCAN_IR_BO) != 0)) {
can_health[can_number].can_core_reset_cnt += 1U;
can_health[can_number].total_tx_lost_cnt += (FDCAN_TX_FIFO_EL_CNT - (FDCANx->TXFQS & FDCAN_TXFQS_TFFL)); // TX FIFO msgs will be lost after reset
llcan_clear_send(FDCANx);

View File

@ -93,15 +93,6 @@ void tick_handler(void) {
}
#ifdef FINAL_PROVISIONING
// Reset CAN core if it got stuck in bus off state after shorted CANH/L
// Looks like an issue with H7 that it doesn't want to recover from bus off
// FIXME: this must be fixed on the driver level, temporary workaround
for (uint8_t i = 0U; i < 3U; i++) {
update_can_health_pkt(i, 0);
if (can_health[i].bus_off == 1U) {
can_init(i);
}
}
// Ignition blinking
uint8_t ignition_bitmask = 0U;
for (uint8_t i = 0U; i < 6U; i++) {