The ConnectCore 8M Mini system-on-module has no native CAN ports.
The ConnectCore 8M Mini Development Kit incorporates an external MCP2518FD CAN FD controller with SPI interface, available for peripheral use. This external CAN controller implements the CAN protocol according to the CAN-FD 3.0 protocol specification. It also supports legacy CAN 2.0B protocol specification. The controller can operate on both CAN-FD (flexible data rate) and legacy CAN modes.
CAN-FD protocol supports two different bitrates for the arbitration phase and the payload phase, and up to 64 Bytes of payload, achieving higher throughput than classical CAN protocol.
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
-
Payload length up to 64 bytes
-
-
CAN 2.0B controller mode
-
Arbitration and data bitrates up to 1 Mbps
-
Payload length up to eight bytes
-
The CAN driver is a network device driver.
Available CAN interfaces
-
CAN0:
-
Interface is enabled in the default device tree.
-
Port lines are available on the CAN connector J24.
-
Port incorporates a CAN transceiver.
-
Optional termination line resistor can be connected by placing a jumper on connector J23.
-
Kernel configuration
You can manage the CAN support through the kernel configuration options:
-
CAN Bus support (
CONFIG_CAN
) -
Microchip MCP251xFD SPI CAN controllers (
CONFIG_CAN_MCP251XFD
)
These options are enabled as built-in on the default ConnectCore 8M Mini kernel configuration file.
Kernel driver
File | Description |
---|---|
Microchip MCP251xFD driver |
CAN support on the ConnectCore 8M Mini 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 Microchip MCP251xFD CAN controller device tree binding is documented at Documentation/devicetree/bindings/net/can/microchip,mcp251xfd.yaml
Example: CAN0 on the ConnectCore 8M Mini Development Kit
/* fixed crystal dedicated to mcp2517fd */
mcp2517fd_osc: mcp2517fd_osc {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <40000000>;
};
[...]
&ecspi3 {
[...]
mcp2517fd: mcp2517fd@0 {
reg = <0>;
compatible = "microchip,mcp2517fd";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_mcp2517fd>;
spi-max-frequency = <20000000>;
interrupt-parent = <&gpio1>;
interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
clocks = <&mcp2517fd_osc>;
xceiver-supply = <®_5v_board>;
};
};
[...]
&iomuxc {
pinctrl_mcp2517fd: mcp2517fdgrp {
fsl,pins = <
MX8MM_IOMUXC_GPIO1_IO00_GPIO1_IO0 0x19
>;
};
};
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.
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 8M Mini 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.