Skip to content

Commit e56a140

Browse files
committed
stm32: canio: Fix canio.CAN.restart()
1 parent 5f0ae73 commit e56a140

File tree

1 file changed

+9
-1
lines changed
  • ports/stm/common-hal/canio

1 file changed

+9
-1
lines changed

ports/stm/common-hal/canio/CAN.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,15 @@ canio_bus_state_t common_hal_canio_can_state_get(canio_can_obj_t *self) {
197197

198198
void common_hal_canio_can_restart(canio_can_obj_t *self) {
199199
if (!common_hal_canio_can_auto_restart_get(self)) {
200-
HAL_CAN_Start(&self->handle);
200+
// "If ABOM is cleared, the software must initiate the recovering
201+
// sequence by requesting bxCAN to enter and to leave initialization
202+
// mode."
203+
self->handle.Instance->MCR |= CAN_MCR_INRQ;
204+
while ((self->handle.Instance->MSR & CAN_MSR_INAK) == 0) {
205+
}
206+
self->handle.Instance->MCR &= ~CAN_MCR_INRQ;
207+
while ((self->handle.Instance->MSR & CAN_MSR_INAK)) {
208+
}
201209
}
202210
}
203211

0 commit comments

Comments
 (0)