The ConnectCore 8X system-on-module has three CAN ports, controlled by independent NXP {cpu-family} FlexCAN controllers, available for peripheral use. FlexCAN is a communications controller implementing 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 legacy features:

  • Version 2.0B

  • Standard data and remote frames

  • Extended data and remote frames

  • Zero to eight bytes payload length

  • Programmable bitrate up to 1 Mbps

  • Content-related addressing

  • Flexible mailboxes of eight bytes data length

The CAN driver is a network device driver.

Available CAN interfaces

  • CAN0:

    • Port lines are available at TTL level on the expansion header (multiplexed with LPUART0 CTS/RTS). An external CAN transceiver is required.

    • Interface is disabled in the default device tree due to conflicts with another interface.

  • CAN1:

    • Interface is enabled in the default device tree.

    • Port lines are available on the expansion header.

    • Port incorporates a CAN transceiver.

    • The transceiver 'standby' pin is handled automatically through CAN1_MODE signal. This is defined through the stby-gpios device tree entry:

      ConnectCore 8X SBC Pro device tree
      /* CAN1 on expansion header */
      &flexcan2 {
      	pinctrl-names = "default";
      	pinctrl-0 = <&pinctrl_flexcan2>;
      	xceiver-supply = <&reg_5v_display>;
      	stby-gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>;
      	status = "okay";
      };
  • CAN2:

    • Interface is enabled in the default device tree.

    • Port is multiplexed with LPUART3 and requires CAN/RS485# signal to select between the CAN and RS485 transceivers.

    • CAN lines are available on the expansion header.

    • The transceiver 'standby' pin is handled automatically through CAN2_MODE signal. This is defined through the stby-gpios entry in the device tree.

    • To select the CAN transceiver, CAN/RS485# signal needs to be driven high. This is handled automatically through the pinctrl-assert-gpios device tree entry:

      ConnectCore 8X SBC Pro device tree
      /*
       * CAN2 on expansion header.
       * Conflicts with LPUART3 RX/TX lines.
       * Requires signal CAN/RS485# (GPIO3_IO23) to be driven high
       */
      &flexcan3 {
      	pinctrl-names = "default";
      	pinctrl-0 = <&pinctrl_flexcan3>,
      		    <&pinctrl_flexcan3_lpuart3_gpios>;
      	xceiver-supply = <&reg_5v_display>;
      	stby-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
      	pinctrl-assert-gpios = <&gpio3 23 GPIO_ACTIVE_HIGH>;
      	status = "okay";
      };

Kernel configuration

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

  • CAN Bus support (CONFIG_CAN)

  • NXP FlexCAN support (CONFIG_CAN_FLEXCAN)

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

Kernel driver

File Description

drivers/net/can/flexcan.c

FlexCAN driver

CAN support on the ConnectCore 8X 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 {cpu-family} CAN interface device tree binding is documented at Documentation/devicetree/bindings/net/can/fsl-flexcan.txt

Example: CAN1 on the ConnectCore 8X SBC Pro

Definition of the device

{cpu-family} device tree
flexcan2: can@5a8e0000 {
	compatible = "fsl,imx8qxp-flexcan", "fsl,imx8qm-flexcan";
	reg = <0x0 0x5a8e0000 0x0 0x10000>;
	interrupts = <GIC_SPI 236 IRQ_TYPE_LEVEL_HIGH>;
	interrupt-parent = <&wu>;
	/* CAN0 clock and PD is shared among all CAN instances */
	clocks = <&clk IMX8QXP_CAN0_IPG_CLK>,
		 <&clk IMX8QXP_CAN0_CLK>;
	clock-names = "ipg", "per";
	assigned-clocks = <&clk IMX8QXP_CAN0_CLK>;
	assigned-clock-rates = <40000000>;
	power-domains = <&pd_dma_flexcan0>;
	status = "disabled";
};

IOMUX configuration

ConnectCore 8X SBC Pro device tree
pinctrl_flexcan2: flexcan1grp {
	fsl,pins = <
		SC_P_FLEXCAN1_TX_ADMA_FLEXCAN1_TX		0x21
		SC_P_FLEXCAN1_RX_ADMA_FLEXCAN1_RX		0x21
		/* CAN1 MODE */
		SC_P_SPI2_CS0_LSIO_GPIO1_IO00                   0x06000020
	>;
};

Bus enabling

ConnectCore 8X SBC Pro device tree
/* CAN1 on expansion header */
&flexcan2 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_flexcan2>;
	xceiver-supply = <&reg_5v_display>;
	stby-gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>;
	status = "okay";
};

Using the CAN interface

You can access CAN interfaces from your Android application. See CAN API for more information about the CAN APIx.

Sample application

The CAN Sample Application demonstrates the use of the CAN API. In this example, you can configure all the settings of the CAN interface, write, and read data from the port.

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