Skip to content

Commit 1c50ef6

Browse files
alexanderwachtergalak
authored andcommitted
drivers: can: Implement Bosch M_CAN driver
Implementation of the Bosch M_CAN IP driver. This driver is just the base for a specific SoC implementation. Signed-off-by: Alexander Wachter <[email protected]>
1 parent 2ccbfd6 commit 1c50ef6

File tree

12 files changed

+2846
-2
lines changed

12 files changed

+2846
-2
lines changed

drivers/can/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ zephyr_sources_ifdef(CONFIG_CAN can_common.c)
44
zephyr_sources_ifdef(CONFIG_CAN_LOOPBACK can_loopback.c)
55
zephyr_sources_ifdef(CONFIG_CAN_MCP2515 can_mcp2515.c)
66
zephyr_sources_ifdef(CONFIG_CAN_STM32 can_stm32.c)
7+
zephyr_sources_ifdef(CONFIG_CAN_STM32FD can_stm32fd.c)
8+
zephyr_sources_ifdef(CONFIG_CAN_MCAN can_mcan.c)
79
zephyr_sources_ifdef(CONFIG_CAN_MCUX_FLEXCAN can_mcux_flexcan.c)
810

911
zephyr_sources_ifdef(CONFIG_USERSPACE can_handlers.c)

drivers/can/Kconfig

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@ config CAN_SHELL
2424
help
2525
Enable CAN Shell for testing.
2626

27-
config CAN_FD_MODE
27+
config CAN_HAS_CANFD
2828
bool
29+
help
30+
driver supports CAN-FD
31+
32+
config CAN_FD_MODE
33+
bool "CAN-FD"
34+
default y
35+
depends on CAN_HAS_CANFD
2936
help
3037
Enable CAN-FD compatible API
3138

@@ -59,7 +66,7 @@ config CAN_WORKQ_FRAMES_BUF_CNT
5966

6067
config CAN_RX_TIMESTAMP
6168
bool "Enable receiving timestamps"
62-
depends on CAN_STM32 || CAN_MCUX_FLEXCAN
69+
depends on CAN_STM32 || CAN_MCUX_FLEXCAN || CAN_STM32FD
6370
help
6471
This option enables a timestamp value of the CAN free running timer.
6572
The value is incremented every bit time and starts when the controller
@@ -75,8 +82,10 @@ config CAN_AUTO_BUS_OFF_RECOVERY
7582
available.
7683

7784
source "drivers/can/Kconfig.stm32"
85+
source "drivers/can/Kconfig.stm32fd"
7886
source "drivers/can/Kconfig.mcux"
7987
source "drivers/can/Kconfig.mcp2515"
88+
source "drivers/can/Kconfig.mcan"
8089
source "drivers/can/Kconfig.loopback"
8190
source "drivers/can/Kconfig.net"
8291

drivers/can/Kconfig.mcan

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Bosch m_can configuration options
2+
3+
# Copyright (c) 2020 Alexander Wachter
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
config CAN_MCAN
7+
bool
8+
select CAN_HAS_CANFD
9+
help
10+
Enable Bosch m_can driver.
11+
This driver supports the Bosch m_can IP. This IP is built into the
12+
STM32G4, STM32G0 and the Microchip SAM controllers with CAN-FD.
13+
14+
if CAN_MCAN
15+
16+
config CAN_DELAY_COMP
17+
bool "Enable transceiver delay compensation"
18+
default y
19+
help
20+
Enable the automatic transceiver delay compensation.
21+
22+
endif #CAN_MCAN

drivers/can/Kconfig.stm32fd

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# STM32 CAN configuration options
2+
if CAN_MCAN && SOC_SERIES_STM32G4X
3+
4+
config CAN_STM32FD
5+
bool
6+
default y
7+
8+
config CAN_MAX_STD_ID_FILTER
9+
int "Maximum number of std ID filters"
10+
default 28
11+
range 0 28
12+
help
13+
Defines the maximum number of filters with standard ID (11-bit)
14+
that can be attached.
15+
16+
config CAN_MAX_EXT_ID_FILTER
17+
int "Maximum number of ext ID filters"
18+
default 8
19+
range 0 8
20+
help
21+
Defines the maximum number of filters with extended ID (29-bit)
22+
that can be attached.
23+
24+
config CAN_CKDIV
25+
int "CKDIV register value"
26+
range 0 15
27+
default 0
28+
help
29+
This value is written to the CKDIV register.
30+
The APB clock is divided according to this value before it is feed to
31+
CAN core. Note that the the divider affects all CAN controllers.
32+
The values of the register are multiplied by two and zero corresponds
33+
to one. The value six, for example results in a clock divided by 12.
34+
35+
endif #CAN_MCAN

0 commit comments

Comments
 (0)