diff options
| author | Jeff Epler <jepler@gmail.com> | 2020-10-06 10:31:01 -0500 |
|---|---|---|
| committer | Jeff Epler <jepler@gmail.com> | 2020-10-06 20:12:06 -0500 |
| commit | abe0405d6e643614557edd65995b61c04c656c44 (patch) | |
| tree | e9907f516d4d901521cd7acb2072d3472f74e07e | |
| parent | e5a0af9216a6d868fad9105a4eb44e0889f54e29 (diff) | |
stm32: canio: Fix canio.CAN.restart()
| -rw-r--r-- | ports/stm/common-hal/canio/CAN.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ports/stm/common-hal/canio/CAN.c b/ports/stm/common-hal/canio/CAN.c index 8ff91aaca..62c4e9935 100644 --- a/ports/stm/common-hal/canio/CAN.c +++ b/ports/stm/common-hal/canio/CAN.c @@ -197,7 +197,15 @@ canio_bus_state_t common_hal_canio_can_state_get(canio_can_obj_t *self) { void common_hal_canio_can_restart(canio_can_obj_t *self) { if (!common_hal_canio_can_auto_restart_get(self)) { - HAL_CAN_Start(&self->handle); + // "If ABOM is cleared, the software must initiate the recovering + // sequence by requesting bxCAN to enter and to leave initialization + // mode." + self->handle.Instance->MCR |= CAN_MCR_INRQ; + while ((self->handle.Instance->MSR & CAN_MSR_INAK) == 0) { + } + self->handle.Instance->MCR &= ~CAN_MCR_INRQ; + while ((self->handle.Instance->MSR & CAN_MSR_INAK)) { + } } } |
