Skip to content

Commit

Permalink
Automatically recover from bus-off in bootloader
Browse files Browse the repository at this point in the history
This is the parallel to 5d76760 but
for the bootloader
  • Loading branch information
jpieper committed Jun 22, 2023
1 parent 03c1711 commit 9d0856b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions fw/can_bootloader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,15 @@ class BootloaderServer {
CanFrame result;

// Wait until there is a CAN frame available.
while ((fdcan_->RXF0S & FDCAN_RXF0S_F0FL) == 0) {
// Nothing in the FIFO yet.
while (true) {
// Do we have a frame?
if ((fdcan_->RXF0S & FDCAN_RXF0S_F0FL) != 0) { break; }

if (fdcan_->PSR & FDCAN_PSR_BO) {
// We went bus off. Attempt to recover.
fdcan_->CCCR &= ~FDCAN_CCCR_INIT;
timer_.wait_us(10);
}
}

const auto get_index = (fdcan_->RXF0S & FDCAN_RXF0S_F0GI) >> FDCAN_RXF0S_F0GI_Pos;
Expand Down

0 comments on commit 9d0856b

Please sign in to comment.