From b63a9af07d09da665e96014bba432724c5b37d74 Mon Sep 17 00:00:00 2001 From: Kamil Serwus Date: Thu, 18 May 2023 12:22:37 +0200 Subject: [PATCH] can: mcan: fix setup configuration ram SAM0 required can module was in init state before configure pointers to ram which handle can frames. Signed-off-by: Kamil Serwus --- drivers/can/can_mcan.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/can/can_mcan.c b/drivers/can/can_mcan.c index f8091b3224..ca252e914e 100644 --- a/drivers/can/can_mcan.c +++ b/drivers/can/can_mcan.c @@ -1207,6 +1207,18 @@ int can_mcan_configure_message_ram(const struct device *dev, uintptr_t mrba) uint32_t reg; int err; + err = can_mcan_exit_sleep_mode(dev); + if (err != 0) { + LOG_ERR("Failed to exit sleep mode"); + return -EIO; + } + + err = can_mcan_enter_init_mode(dev, K_MSEC(CAN_INIT_TIMEOUT_MS)); + if (err != 0) { + LOG_ERR("Failed to enter init mode"); + return -EIO; + } + can_mcan_enable_configuration_change(dev); reg = ((POINTER_TO_UINT(msg_ram->std_filt) - mrba) & CAN_MCAN_SIDFC_FLSSA) |