The ConnectCore 95 system-on-module has two native CAN ports. This CAN controller implements the CAN protocol according to the ISO11898-1, the CAN with Flexibe Data rate (CAN FD) protocol, and the CAN-FD 2.0B protocol specification.

The CAN port includes the following features:

  • Standard data and remote frames

  • Extended data and remote frames

  • Mixed controller mode (CAN FD and CAN 2.0B)

    • Arbitration bitrate up to 1 Mbps

    • Data bitrate up to 8 Mbps

The CAN driver is a network device driver.

Available CAN interfaces

On the ConnectCore 95 system-on-module:

  • CAN0 is available at the castellated and LGA pads

  • CAN1 is available at the castellated and LGA pads

On the ConnectCore 95 Development Kit:

  • CAN0 is available through a transceiver at connector J11. Optional termination line resistor can be connected by placing a jumper on connector J10.

  • CAN1 is available through a transceiver at connector J14. Optional termination line resistor can be connected by placing a jumper on connector J13.

Kernel configuration

You can manage the CAN support through the kernel configuration options:

  • CAN Bus support (CONFIG_CAN)

  • Support for Freescale FLEXCAN based chips (CONFIG_CAN_FLEXCAN)

These options are enabled as built-in on the default ConnectCore 95 kernel configuration file.

Kernel driver

File Description

drivers/net/can/flexcan.c

Freescale FLEXCAN driver

CAN support on the ConnectCore 95 Development Kit is based on the SocketCAN stack. For more information and source code about this project, see http://elinux.org/CAN_Bus and https://github.com/linux-can/.

Device tree bindings and customization

The Freescale FLEXCAN controller device tree binding is documented at Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml

Both CAN ports are enabled on the default ConnectCore 95 Development Kit device tree.

Example: CAN0 on the ConnectCore 95 Development Kit

ConnectCore 95 Development Kit device tree
&flexcan1 {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&pinctrl_flexcan1>;
	pinctrl-1 = <&pinctrl_flexcan1_sleep>;
	xceiver-supply = <&reg_can1_stby>;
	status = "okay";
};

[...]


/* CAN1 */
pinctrl_flexcan1: flexcan1grp {
	fsl,pins = <
		IMX95_PAD_PDM_CLK__AONMIX_TOP_CAN1_TX		0x39e
		IMX95_PAD_PDM_BIT_STREAM0__AONMIX_TOP_CAN1_RX	0x39e
	>;
};

pinctrl_flexcan1_sleep: flexcan1grpsleep {
	fsl,pins = <
		IMX95_PAD_PDM_CLK__AONMIX_TOP_GPIO1_IO_BIT8			0x200
		IMX95_PAD_PDM_BIT_STREAM0__AONMIX_TOP_GPIO1_IO_BIT9		0x200
	>;
};

[NOTE]
Flexcan1 (CAN0) belongs to the Always-ON (AON) domain and probed last, after flexcan2 (CAN1) port.
Therefore, the kernel names CAN0 as `can1` and CAN1 as `can0`.

CAN user space use examples

CAN device interface

The CAN driver is a network device driver from the PF_CAN protocol family. It exposes device data through the sysfs at /sys/class/net/canX/, where X is the port index, starting at zero.

Linux creates port indexes sequentially as enabled CAN entries are found in the device tree.

Configuring the interface

Before you can start the CAN network device, you must configure the bitrate at which it will communicate. In the following example, X is the index of the CAN node you want to configure:

# ip link set canX up type can bitrate 125000

Starting and stopping the CAN network device

Similar to other network interfaces, you can start or stop a CAN network device with the ifconfig command. In the following example, X is the index of the CAN node you want to bring up or down.

To start:

# ifconfig canX up

To stop:

# ifconfig canX down

For more information, see the Linux kernel documentation: Documentation/networking/can.rst

Sample application

Example applications called apix-can-send-example and apix-can-recv-example are included in the dey-examples-digiapix recipe (part of dey-examples package) of the meta-digi layer. These applications show how to send and receive packets through the CAN ports using Digi APIx library on the ConnectCore 95 platform.

Go to GitHub to see the application instructions and source code.

First bring the interface down in case it’s already configured and up:

# ifconfig canX down

To send an 8-bit CAN message to node can0 with ID 0x12 at a baudrate of 500 Kbit/s:

# apix-can-send-example -i can0 -I 0x12 -b 500000

To receive a similar message:

# apix-can-recv-example -i can0 -b 500000

See CAN API for more information about the CAN APIx.