Skip to content

Commit 92a1140

Browse files
trupplesdanieldegrasse
authored andcommitted
drivers: can: Add CAN support for max32662
Adapt MAX32690 driver to use Wrap_MXC_CAN_Init to handle differences in the MSDK API (see analogdevicesinc/msdk#1306) between the MAX32690 and MAX32662. can_driver_api.timing_min required phase_seg1 >= 3 and phase_seg2 >= 2 when configuring CAN bit timing. Both microcontrollers covered by this driver (MAX32662, MAX32690) support values down to 1 for both of these timing parameters. Refer to the docs for registers CAN_BUSTIM1, CANn_BUSTIM1. Add a can0 node to the MAX32662 dtsi. Signed-off-by: Ioan Dragomir <ioan.dragomir@analog.com>
1 parent 4eb7168 commit 92a1140

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

drivers/can/can_max32.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024 Analog Devices, Inc.
2+
* Copyright (c) 2024-2025 Analog Devices, Inc.
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -15,6 +15,7 @@
1515
#include <zephyr/logging/log.h>
1616

1717
#include <can.h>
18+
#include <wrap_max32_can.h>
1819

1920
LOG_MODULE_REGISTER(can_max32, CONFIG_CAN_LOG_LEVEL);
2021

@@ -639,10 +640,10 @@ static int can_max32_init(const struct device *dev)
639640

640641
dev_list[dev_cfg->can_id] = dev;
641642

642-
ret = MXC_CAN_Init(dev_cfg->can_id, MXC_CAN_OBJ_CFG_TXRX, unit_event_callback,
643-
object_event_callback);
643+
ret = Wrap_MXC_CAN_Init(dev_cfg->can_id, MXC_CAN_OBJ_CFG_TXRX, unit_event_callback,
644+
object_event_callback);
644645
if (ret < 0) {
645-
LOG_ERR("MXC_CAN_Init() failed:%d", ret);
646+
LOG_ERR("Wrap_MXC_CAN_Init() failed:%d", ret);
646647
return ret;
647648
}
648649

@@ -700,8 +701,8 @@ static const struct can_driver_api can_max32_api = {
700701
.timing_min = {
701702
.sjw = 1,
702703
.prop_seg = 0,
703-
.phase_seg1 = 3,
704-
.phase_seg2 = 2,
704+
.phase_seg1 = 1,
705+
.phase_seg2 = 1,
705706
.prescaler = 1,
706707
},
707708
.timing_max = {

dts/arm/adi/max32/max32662.dtsi

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024 Analog Devices, Inc.
2+
* Copyright (c) 2024-2025 Analog Devices, Inc.
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -127,5 +127,13 @@
127127
interrupts = <3 0>;
128128
status = "disabled";
129129
};
130+
131+
can0: can@40064000 {
132+
compatible = "adi,max32-can";
133+
reg = <0x40064000 0x1000>;
134+
clocks = <&gcr ADI_MAX32_CLOCK_BUS1 11>;
135+
interrupts = <107 0>;
136+
status = "disabled";
137+
};
130138
};
131139
};

0 commit comments

Comments
 (0)