DESK-MX6UL-L/Peripherals/CAN

From DAVE Developer's Wiki
< DESK-MX6UL-L
Revision as of 09:51, 21 April 2021 by U0007 (talk | contribs) (Created page with "{{subst:Peripheral | nome-som=AXEL Lite | nome-peripheral = CAN}}")

(diff) ← Older revision | Approved revision (diff) | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
History
Version Issue Date Notes
X.Y.Z Month Year TBD
[TBD_link X.Y.Z] Month Year TBD
... ... ...


Peripheral CAN[edit | edit source]

TBD: sostituire tutti i dump con le informazioni sull'uso della periferica

Device tree configuration[edit | edit source]

Here below an example of device tree configuration used on standard DAVE's kit for the AXEL Lite SOM:

From carrier.dts:

&can1 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_flexcan1_axel>;
    status = "okay";
};

From carrier-common.dtsi:

    can1 {
        pinctrl_flexcan1_axel: flexcan1axelgrp-1 {
            fsl,pins = <
                MX6QDL_PAD_GPIO_7__FLEXCAN1_TX 0x80000000
                MX6QDL_PAD_GPIO_8__FLEXCAN1_RX 0x80000000
            >;
        };
    };

Accessing the peripheral[edit | edit source]

Linux messages at boot time[edit | edit source]

...
...
[    1.807495] flexcan 2090000.flexcan: 2090000.flexcan supply xceiver not found, using dummy regulator
[    1.817366] flexcan 2090000.flexcan: device registered (reg_base=c0a30000, irq=31)
...
...
[    3.952659] can: controller area network core (rev 20170425 abi 9)
[    3.963413] can: raw protocol (rev 20170425)
[    3.967717] can: broadcast manager protocol (rev 20170425 t)
[    3.973397] can: netlink gateway (rev 20170425) max_hops=1

Enable the interface and check status[edit | edit source]

root@imx6qxelk:~# ip link set can0 type can bitrate 500000
root@imx6qxelk:~# ifconfig can0 up
root@imx6qxelk:~# ifconfig can0
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:31

root@imx6qxelk:~#

Usage with can-utils[edit | edit source]

TBD: reference verso eventuali informazioni sul web

root@imx6qxelk:~# ip link set can0 type can bitrate 500000 triple-sampling on
root@imx6qxelk:~# ifconfig can0 up
root@imx6qxelk:~# cansend can0 128#1122334455667788
root@imx6qxelk:~# candump can0
  can0  128   [8]  11 22 33 44 55 66 77 88
root@imx6qxelk:~# 

Additional information[edit | edit source]

Each CAN port appears like a networking interface in the form canX where X is the port number.

Information about programming the CAN socket interface is given in the kernel tree under Documentation/networking/can.txt