• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

boards/11-Mar-2024-1612

src/11-Mar-2024-302250

CMakeLists.txtD11-Mar-2024187 105

KconfigD11-Mar-2024359 1611

README.rstD11-Mar-20241.6 KiB6546

prj.confD11-Mar-2024227 1512

sample.yamlD11-Mar-2024361 1514

README.rst

1.. zephyr:code-sample:: can-counter
2   :name: Controller Area Network (CAN) counter
3   :relevant-api: can_interface
4
5   Send and receive CAN messages.
6
7Overview
8********
9
10This sample demonstrates how to use the Controller Area Network (CAN) API.
11Messages with standard and extended identifiers are sent over the bus.
12Messages are received using message-queues and work-queues.
13Reception is indicated by blinking the LED (if present) and output of
14received counter values to the console.
15
16Building and Running
17********************
18
19In loopback mode, the board receives its own messages. This could be used for
20standalone testing.
21
22The LED output pin is defined in the board's devicetree.
23
24The sample can be built and executed for boards with a SoC that have an
25integrated CAN controller or for boards with a SoC that has been augmented
26with a stand alone CAN controller.
27
28Integrated CAN controller
29=========================
30
31For the NXP TWR-KE18F board:
32
33.. zephyr-app-commands::
34   :zephyr-app: samples/drivers/can/counter
35   :board: twr_ke18f
36   :goals: build flash
37
38Stand alone CAN controller
39==========================
40
41For the nrf52dk_nrf52832 board combined with the DFRobot CAN bus V2.0 shield that
42provides the MCP2515 CAN controller:
43
44.. zephyr-app-commands::
45   :zephyr-app: samples/drivers/can/counter
46   :board: nrf52dk_nrf52832
47   :shield: dfrobot_can_bus_v2_0
48   :goals: build flash
49
50Sample output
51=============
52
53.. code-block:: console
54
55   Change LED filter ID: 0
56   Finished init.
57   Counter filter id: 4
58
59   uart:~$ Counter received: 0
60   Counter received: 1
61   Counter received: 2
62   Counter received: 3
63
64.. note:: The values shown above might differ.
65