zephyr/samples/drivers/can
Henrik Brix Andersen 2aed5a1237 drivers: can: remove CAN_BUS_UNKNOWN CAN controller state
The CAN_BUS_UNKNOWN CAN controller state is only used to indicate that
the current CAN controller state could not be read.

Remove it and change the signature of the can_get_state() API function
to return an integer indicating success or failure.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-28 10:05:29 +01:00
..
boards samples: can: devicetree cleanups 2021-05-05 20:46:43 +02:00
src drivers: can: remove CAN_BUS_UNKNOWN CAN controller state 2022-01-28 10:05:29 +01:00
CMakeLists.txt cmake: increase minimal required version to 3.20.0 2021-08-20 09:47:34 +02:00
Kconfig samples: drivers: can: Rename directory for consistency 2020-05-02 09:54:06 -04:00
prj.conf samples: drivers: can: convert from can_attach_workq() to triggered work 2021-12-22 18:04:02 +01:00
README.rst doc: can: fix build commands 2021-05-25 09:40:27 -04:00
sample.yaml samples: drivers: can: Rename directory for consistency 2020-05-02 09:54:06 -04:00

.. _can-sample:

Controller Area Network
#######################

Overview
********

This sample demonstrates how to use the Controller Area Network (CAN) API.
Messages with standard and extended identifiers are sent over the bus.
Messages are received using message-queues and work-queues.
Reception is indicated by blinking the LED (if present) and output to the console.

Building and Running
********************

In loopback mode, the board receives its own messages. This could be used for
standalone testing.

The LED output pin is defined in the board's devicetree.

The sample can be built and executed for boards with a SoC that have an
integrated CAN controller or for boards with a SoC that has been augmented
with a stand alone CAN controller.

Integrated CAN controller
=========================

For the NXP TWR-KE18F board:

.. zephyr-app-commands::
   :zephyr-app: samples/drivers/can
   :board: twr_ke18f
   :goals: build flash

Stand alone CAN controller
==========================

For the nrf52dk_nrf52832 board combined with the DFRobot CAN bus V2.0 shield that
provides the MCP2515 CAN controller:

.. zephyr-app-commands::
   :zephyr-app: samples/drivers/can
   :board: nrf52dk_nrf52832
   :shield: dfrobot_can_bus_v2_0
   :goals: build flash

Sample output
=============

.. code-block:: console

   Change LED filter ID: 0
   Finished init.
   Counter filter id: 4

   uart:~$ Counter received: 0
   Counter received: 1
   Counter received: 2
   Counter received: 3

.. note:: The values shown above might differ.