The ConnectCore 93 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 93 system-on-module:

  • CAN0 is available at the castellated and LGA pads

  • CAN1 is available at the castellated and LGA pads

On the {pfm-name-dvk}:

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

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

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 93 kernel configuration file.

Kernel driver

File Description

drivers/net/can/flexcan.c

Freescale FLEXCAN driver

CAN support on the ConnectCore 93 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 93 Development Kit device tree.

Example: CAN0 on the ConnectCore 93 Development Kit

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

[...]

/* CAN1 */
pinctrl_flexcan1: flexcan1grp {
	fsl,pins = <
		MX93_PAD_PDM_CLK__CAN1_TX			0x139e
		MX93_PAD_PDM_BIT_STREAM0__CAN1_RX		0x139e
	>;
};

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.

The CAN network device driver interface provides a generic interface to set up, configure, and monitor CAN network devices. For example, you can configure the CAN device via the netlink interface using the program ip from the iproute2 utility suite.

Configure 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

Start and stop 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 93 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.