diff options
| author | Torin Cooper-Bennun <[email protected]> | 2024-04-17 14:58:08 +0100 |
|---|---|---|
| committer | Torin Cooper-Bennun <[email protected]> | 2024-04-17 14:58:08 +0100 |
| commit | 80b3db4ea6b5b85ab87ec002c2029b868515f8ef (patch) | |
| tree | 514cb8e5de68d2c90d4a96fad724f6b220e885d2 /embassy-stm32/src | |
| parent | 901bdfc7b8d8e1dc5d04b28a69feb50b99d0be57 (diff) | |
stm32: can: fd: implement bus-off recovery
as per RM0492 and other relevant RMs, bus-off recovery is not automatic.
CCCR.INIT is set by the device upon bus-off; the CPU must reset
CCCR.INIT to initiate the recovery.
Diffstat (limited to 'embassy-stm32/src')
| -rw-r--r-- | embassy-stm32/src/can/fd/peripheral.rs | 1 | ||||
| -rw-r--r-- | embassy-stm32/src/can/fdcan.rs | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/embassy-stm32/src/can/fd/peripheral.rs b/embassy-stm32/src/can/fd/peripheral.rs index e32f19d91..e5cfee528 100644 --- a/embassy-stm32/src/can/fd/peripheral.rs +++ b/embassy-stm32/src/can/fd/peripheral.rs | |||
| @@ -368,6 +368,7 @@ impl Registers { | |||
| 368 | w.set_rfne(0, true); // Rx Fifo 0 New Msg | 368 | w.set_rfne(0, true); // Rx Fifo 0 New Msg |
| 369 | w.set_rfne(1, true); // Rx Fifo 1 New Msg | 369 | w.set_rfne(1, true); // Rx Fifo 1 New Msg |
| 370 | w.set_tce(true); // Tx Complete | 370 | w.set_tce(true); // Tx Complete |
| 371 | w.set_boe(true); // Bus-Off Status Changed | ||
| 371 | }); | 372 | }); |
| 372 | self.regs.ile().modify(|w| { | 373 | self.regs.ile().modify(|w| { |
| 373 | w.set_eint0(true); // Interrupt Line 0 | 374 | w.set_eint0(true); // Interrupt Line 0 |
diff --git a/embassy-stm32/src/can/fdcan.rs b/embassy-stm32/src/can/fdcan.rs index 23a35168b..563f542d4 100644 --- a/embassy-stm32/src/can/fdcan.rs +++ b/embassy-stm32/src/can/fdcan.rs | |||
| @@ -81,6 +81,14 @@ impl<T: Instance> interrupt::typelevel::Handler<T::IT0Interrupt> for IT0Interrup | |||
| 81 | if ir.rfn(1) { | 81 | if ir.rfn(1) { |
| 82 | T::state().rx_mode.on_interrupt::<T>(1); | 82 | T::state().rx_mode.on_interrupt::<T>(1); |
| 83 | } | 83 | } |
| 84 | |||
| 85 | if ir.bo() { | ||
| 86 | regs.ir().write(|w| w.set_bo(true)); | ||
| 87 | if regs.psr().read().bo() { | ||
| 88 | // Initiate bus-off recovery sequence by resetting CCCR.INIT | ||
| 89 | regs.cccr().modify(|w| w.set_init(false)); | ||
| 90 | } | ||
| 91 | } | ||
| 84 | } | 92 | } |
| 85 | } | 93 | } |
| 86 | 94 | ||
