Difference between revisions of "CAN"
Jump to navigation
Jump to search
m (Minor formatting) |
m (Zephyr CAN default bitrate symbol) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 18: | Line 18: | ||
* https://www.politesi.polimi.it/retrieve/a81cb05d-af9c-616b-e053-1605fe0a889a/Implementation_of_CAN_driver_based_on_STM32H753I_EVAL_Board%20%283%29.pdf | * https://www.politesi.polimi.it/retrieve/a81cb05d-af9c-616b-e053-1605fe0a889a/Implementation_of_CAN_driver_based_on_STM32H753I_EVAL_Board%20%283%29.pdf | ||
+ | |||
+ | == Supported Boards == | ||
Zephyr 3.7.0 supported STMicro boards with CAN controllers: | Zephyr 3.7.0 supported STMicro boards with CAN controllers: | ||
Line 111: | Line 113: | ||
./stm32h7b3i_dk/stm32h7b3i_dk.dts:24: zephyr,canbus = &fdcan1; | ./stm32h7b3i_dk/stm32h7b3i_dk.dts:24: zephyr,canbus = &fdcan1; | ||
</pre> | </pre> | ||
+ | |||
+ | CAN default bit rate from Zephyr 3.7.0 menuconfig: | ||
+ | |||
+ | <pre> | ||
+ | Name: CAN_DEFAULT_BITRATE | ||
+ | Prompt: Default CAN bitrate | ||
+ | Type: int | ||
+ | Value: 125000 | ||
+ | |||
+ | Help: | ||
+ | |||
+ | Default initial CAN bitrate in bits/s. This can be overridden per CAN controller using the | ||
+ | "bitrate" devicetree property. | ||
+ | |||
+ | Direct dependencies (=y): | ||
+ | CAN(=y) | ||
+ | |||
+ | Default: | ||
+ | - 125000 | ||
+ | |||
+ | Kconfig definition, with parent deps. propagated to 'depends on' | ||
+ | ================================================================ | ||
+ | |||
+ | At drivers/can/Kconfig:26 | ||
+ | Included via /home/ted/projects/zephyr-project/psas-ers-board-bringup/samples/can/counter/Kconfig:15 -> Kconfig.zephyr:48 -> drivers/Kconfig:15 | ||
+ | Menu path: (Top) -> Device Drivers -> Controller Area Network (CAN) drivers | ||
+ | |||
+ | config CAN_DEFAULT_BITRATE | ||
+ | int "Default CAN bitrate" | ||
+ | default 125000 | ||
+ | depends on CAN(=y) | ||
+ | help | ||
+ | Default initial CAN bitrate in bits/s. This can be overridden per CAN controller using the | ||
+ | "bitrate" devicetree property. | ||
+ | </pre> | ||
+ | |||
+ | == Example Projects and Code == | ||
+ | |||
+ | * https://github.com/zephyrproject-rtos/zephyr/discussions/69073 | ||
+ | |||
+ | == Vulcan Boards == | ||
+ | |||
+ | * https://shop.copperforge.cc/products/ac41 - VulCAN USB-CANbus Adapter - Copperforge – Copperforge, LLC | ||
+ | |||
+ | Getting started sending and receiving bytes using Vulcan USB adapter and Python script: | ||
+ | |||
+ | * https://copperforge.cc/docs/hardware/AC41_vulcan/#sending-your-first-bytes-and-receiving-them-too |
Latest revision as of 13:39, 19 September 2025
Controller Area Network (CAN) developed and first released by Bosch in 1973.
2025-09-09
Basic CAN frames versus Canopennode frames . . .
2025-09-14
Masters thesis by William Fornaciari . . .
Supported Boards
Zephyr 3.7.0 supported STMicro boards with CAN controllers:
ted@localhost:~/projects/zephyr-project/zephyr/boards/st$ grep -nr can ./* | grep '&' | grep can grep: ./nucleo_f030r8/doc/img/nucleo_f030r8.jpg: binary file matches grep: ./nucleo_f070rb/doc/img/nucleo_f070rb.jpg: binary file matches grep: ./nucleo_f091rc/doc/img/nucleo_f091rc.jpg: binary file matches grep: ./nucleo_f103rb/doc/img/nucleo_f103rb.jpg: binary file matches grep: ./nucleo_f207zg/doc/img/nucleo_f207zg_zio_left.jpg: binary file matches ./nucleo_f091rc/nucleo_f091rc.dts:23: zephyr,canbus = &can1; ./nucleo_f091rc/nucleo_f091rc.dts:116:&can1 { ./nucleo_f091rc/nucleo_f091rc.dts:117: pinctrl-0 = <&can_rx_pa11 &can_tx_pa12>; ./nucleo_f303re/nucleo_f303re.dts:23: zephyr,canbus = &can1; ./nucleo_f303re/nucleo_f303re.dts:96:&can1 { ./nucleo_f303re/nucleo_f303re.dts:97: pinctrl-0 = <&can_rx_pb8 &can_tx_pb9>; ./nucleo_f446re/nucleo_f446re.dts:23: zephyr,canbus = &can2; ./nucleo_f446re/nucleo_f446re.dts:146:&can1 { ./nucleo_f446re/nucleo_f446re.dts:148: pinctrl-0 = <&can1_rx_pb8 &can1_tx_pb9>; ./nucleo_f446re/nucleo_f446re.dts:153:&can2 { ./nucleo_f446re/nucleo_f446re.dts:154: pinctrl-0 = <&can2_rx_pb12 &can2_tx_pb13>; ./nucleo_f446ze/nucleo_f446ze.dts:22: zephyr,canbus = &can1; ./nucleo_f446ze/nucleo_f446ze.dts:180:&can1 { ./nucleo_f446ze/nucleo_f446ze.dts:181: pinctrl-0 = <&can1_rx_pd0 &can1_tx_pd1>; ./nucleo_f722ze/nucleo_f722ze.dts:24: zephyr,canbus = &can1; ./nucleo_f722ze/nucleo_f722ze.dts:123:&can1 { ./nucleo_f722ze/nucleo_f722ze.dts:124: pinctrl-0 = <&can1_rx_pd0 &can1_tx_pd1>; ./nucleo_f746zg/nucleo_f746zg.dts:30: zephyr,canbus = &can1; ./nucleo_f746zg/nucleo_f746zg.dts:166:&can1 { ./nucleo_f746zg/nucleo_f746zg.dts:167: pinctrl-0 = <&can1_rx_pd0 &can1_tx_pd1>; ./nucleo_f767zi/nucleo_f767zi.dts:31: zephyr,canbus = &can1; ./nucleo_f767zi/nucleo_f767zi.dts:165:&can1 { ./nucleo_f767zi/nucleo_f767zi.dts:166: pinctrl-0 = <&can1_rx_pd0 &can1_tx_pd1>; ./nucleo_g0b1re/nucleo_g0b1re.dts:25: zephyr,canbus = &fdcan1; ./nucleo_g0Zephyr 3.7.0 supported STMicro boards with CAN controllersb1re/nucleo_g0b1re.dts:181:&fdcan1 { ./nucleo_g0b1re/nucleo_g0b1re.dts:184: pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>; ./nucleo_g0b1re/nucleo_g0b1re.dts:189:&fdcan2 { ./nucleo_g0b1re/nucleo_g0b1re.dts:192: pinctrl-0 = <&fdcan2_rx_pb0 &fdcan2_tx_pb1>; ./nucleo_g474re/nucleo_g474re.dts:22: zephyr,canbus = &fdcan1; ./nucleo_g474re/nucleo_g474re.dts:221:&fdcan1 { ./nucleo_g474re/nucleo_g474re.dts:224: pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>; ./nucleo_h563zi/nucleo_h563zi-common.dtsi:155:&fdcan1 { ./nucleo_h563zi/nucleo_h563zi-common.dtsi:156: pinctrl-0 = <&fdcan1_rx_pd0 &fdcan1_tx_pd1>; ./nucleo_h563zi/nucleo_h563zi.dts:25: zephyr,canbus = &fdcan1; ./nucleo_h743zi/nucleo_h743zi.dts:24: zephyr,canbus = &fdcan1; ./nucleo_h743zi/nucleo_h743zi.dts:180:&fdcan1 { ./nucleo_h743zi/nucleo_h743zi.dts:181: pinctrl-0 = <&fdcan1_rx_pd0 &fdcan1_tx_pd1>; ./nucleo_h753zi/nucleo_h753zi.dts:24: zephyr,canbus = &fdcan1; ./nucleo_h753zi/nucleo_h753zi.dts:159:&fdcan1 { ./nucleo_h753zi/nucleo_h753zi.dts:162: pinctrl-0 = <&fdcan1_rx_pd0 &fdcan1_tx_pd1>; ./nucleo_l432kc/nucleo_l432kc.dts:20: zephyr,canbus = &can1; ./nucleo_l432kc/nucleo_l432kc.dts:99:&can1 { ./nucleo_l432kc/nucleo_l432kc.dts:100: pinctrl-0 = <&can1_rx_pa11 &can1_tx_pa12>; ./nucleo_l433rc_p/nucleo_l433rc_p.dts:22: zephyr,canbus = &can1; ./nucleo_l433rc_p/nucleo_l433rc_p.dts:118:&can1 { ./nucleo_l433rc_p/nucleo_l433rc_p.dts:119: pinctrl-0 = <&can1_rx_pa11 &can1_tx_pa12>; ./nucleo_l452re/nucleo_l452re_common.dtsi:22: zephyr,canbus = &can1; ./nucleo_l452re/nucleo_l452re_common.dtsi:102:&can1 { ./nucleo_l452re/nucleo_l452re_common.dtsi:103: pinctrl-0 = <&can1_rx_pa11 &can1_tx_pa12>; ./nucleo_u575zi_q/nucleo_u575zi_q.dts:22: zephyr,canbus = &fdcan1; ./nucleo_u575zi_q/nucleo_u575zi_q-common.dtsi:181:&fdcan1 { ./nucleo_u575zi_q/nucleo_u575zi_q-common.dtsi:184: pinctrl-0 = <&fdcan1_rx_pd0 &fdcan1_tx_pd1>; ./nucleo_u5a5zj_q/nucleo_u5a5zj_q-common.dtsi:173:&fdcan1 { ./nucleo_u5a5zj_q/nucleo_u5a5zj_q-common.dtsi:176: pinctrl-0 = <&fdcan1_rx_pd0 &fdcan1_tx_pd1>; ./nucleo_u5a5zj_q/nucleo_u5a5zj_q.dts:22: zephyr,canbus = &fdcan1; ./stm32f072b_disco/stm32f072b_disco.dts:21: zephyr,canbus = &can1; ./stm32f072b_disco/stm32f072b_disco.dts:118:&can1 { ./stm32f072b_disco/stm32f072b_disco.dts:119: pinctrl-0 = <&can_rx_pb8 &can_tx_pb9>; ./stm32f3_disco/stm32f3_disco.dts:21: zephyr,canbus = &can1; ./stm32f3_disco/stm32f3_disco.dts:184:&can1 { ./stm32f3_disco/stm32f3_disco.dts:185: pinctrl-0 = <&can_rx_pd0 &can_tx_pd1>; ./stm32f4_disco/stm32f4_disco.dts:22: zephyr,canbus = &can2; ./stm32f4_disco/stm32f4_disco.dts:129:&can1 { ./stm32f4_disco/stm32f4_disco.dts:130: pinctrl-0 = <&can1_rx_pb8 &can1_tx_pb9>; ./stm32f4_disco/stm32f4_disco.dts:135:&can2 { ./stm32f4_disco/stm32f4_disco.dts:136: pinctrl-0 = <&can2_rx_pb5 &can2_tx_pb13>; ./stm32h573i_dk/stm32h573i_dk.dts:24: zephyr,canbus = &fdcan1; ./stm32h573i_dk/stm32h573i_dk.dts:253:&fdcan1 { ./stm32h573i_dk/stm32h573i_dk.dts:256: pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>; ./stm32h735g_disco/stm32h735g_disco.dts:22: zephyr,canbus = &fdcan1; ./stm32h735g_disco/stm32h735g_disco.dts:213:&fdcan1 { ./stm32h735g_disco/stm32h735g_disco.dts:214: pinctrl-0 = <&fdcan1_rx_ph14 &fdcan1_tx_ph13>; ./stm32h735g_disco/stm32h735g_disco.dts:225:&fdcan2 { ./stm32h735g_disco/stm32h735g_disco.dts:226: pinctrl-0 = <&fdcan2_rx_pb5 &fdcan2_tx_pb6>; ./stm32h735g_disco/stm32h735g_disco.dts:237:&fdcan3 { ./stm32h735g_disco/stm32h735g_disco.dts:238: pinctrl-0 = <&fdcan3_rx_pf6 &fdcan3_tx_pf7>; ./stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts:24: zephyr,canbus = &fdcan1; ./stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts:220:&fdcan1 { ./stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts:222: pinctrl-0 = <&fdcan1_tx_ph13 &fdcan1_rx_ph14>; ./stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts:234:&fdcan2 { ./stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts:236: pinctrl-0 = <&fdcan2_tx_pb13 &fdcan2_rx_pb5>; ./stm32h7b3i_dk/stm32h7b3i_dk.dts:24: zephyr,canbus = &fdcan1;
CAN default bit rate from Zephyr 3.7.0 menuconfig:
Name: CAN_DEFAULT_BITRATE Prompt: Default CAN bitrate Type: int Value: 125000 Help: Default initial CAN bitrate in bits/s. This can be overridden per CAN controller using the "bitrate" devicetree property. Direct dependencies (=y): CAN(=y) Default: - 125000 Kconfig definition, with parent deps. propagated to 'depends on' ================================================================ At drivers/can/Kconfig:26 Included via /home/ted/projects/zephyr-project/psas-ers-board-bringup/samples/can/counter/Kconfig:15 -> Kconfig.zephyr:48 -> drivers/Kconfig:15 Menu path: (Top) -> Device Drivers -> Controller Area Network (CAN) drivers config CAN_DEFAULT_BITRATE int "Default CAN bitrate" default 125000 depends on CAN(=y) help Default initial CAN bitrate in bits/s. This can be overridden per CAN controller using the "bitrate" devicetree property.
Example Projects and Code
Vulcan Boards
- https://shop.copperforge.cc/products/ac41 - VulCAN USB-CANbus Adapter - Copperforge – Copperforge, LLC
Getting started sending and receiving bytes using Vulcan USB adapter and Python script: