Skip to content

Commit

Permalink
F4 CAN: fix SCE IRQ double fire (commaai#1149)
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
briskspirit authored Nov 11, 2022
1 parent 72fd777 commit eae58b3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions board/drivers/bxcan.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ void update_can_health_pkt(uint8_t can_number, bool error_irq) {
CAN_TypeDef *CAN = CANIF_FROM_CAN_NUM(can_number);
uint32_t esr_reg = CAN->ESR;

if (error_irq) {
can_health[can_number].total_error_cnt += 1U;
CAN->MSR = CAN_MSR_ERRI;
llcan_clear_send(CAN);
}

can_health[can_number].bus_off = ((esr_reg & CAN_ESR_BOFF) >> CAN_ESR_BOFF_Pos);
can_health[can_number].bus_off_cnt += can_health[can_number].bus_off;
can_health[can_number].error_warning = ((esr_reg & CAN_ESR_EWGF) >> CAN_ESR_EWGF_Pos);
Expand All @@ -84,11 +90,6 @@ void update_can_health_pkt(uint8_t can_number, bool error_irq) {

can_health[can_number].receive_error_cnt = ((esr_reg & CAN_ESR_REC) >> CAN_ESR_REC_Pos);
can_health[can_number].transmit_error_cnt = ((esr_reg & CAN_ESR_TEC) >> CAN_ESR_TEC_Pos);

if (error_irq) {
can_health[can_number].total_error_cnt += 1U;
llcan_clear_send(CAN);
}
}

// CAN error
Expand Down

0 comments on commit eae58b3

Please sign in to comment.