zephyr/samples/basic/threads
Martí Bolívar 51f55b437f twister: replace dt_compat_enabled_with_alias filter
Originally added in 7733b94224.

This filter is not well-formed. It's meant to match nodes like
/leds/led_0 in this DTS:

/ {
	aliases {
		led0 = &led0;
	};

	leds {
		compatible = "gpio-leds";
		led0: led_0 {
			gpios = <...>;
			label = "LED 0";
		};
	};
};

Uses look like this:

    filter: dt_compat_enabled_with_alias("gpio-leds", "led0")

But notice how the led_0 node doesn't have compatible "gpio-leds";
it's actually the *parent* node that has that compatible.

Replace this with a new filter, dt_enabled_alias_with_parent_compat(),
which is used like this:

    filter: dt_enabled_alias_with_parent_compat("led0", "gpio-leds")

This has a name and argument order that makes the meaning of the
filter clearer.

Replace in-tree users with the new filter.

Deprecate the old filter and warn about its use using the standard
logging module.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-03-10 15:09:09 -05:00
..
src device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
CMakeLists.txt samples: make find_package(Zephyr...) REQUIRED 2020-05-29 10:47:25 +02:00
README.rst
prj.conf
sample.yaml twister: replace dt_compat_enabled_with_alias filter 2021-03-10 15:09:09 -05:00

README.rst

.. _96b_carbon_multi_thread_blinky:

Basic Thread Example
####################

Overview
********

This example demonstrates spawning multiple threads using
:c:func:`K_THREAD_DEFINE`. It spawns three threads. Each thread is then defined
at compile time using K_THREAD_DEFINE.

The first two each control an LED. These LEDs, ``led0`` and ``led1``, have
loop control and timing logic controlled by separate functions.

- ``blink0()`` controls ``led0`` and has a 100ms sleep cycle
- ``blink1()`` controls ``led1`` and has a 1000ms sleep cycle

When either of these threads toggles its LED, it also pushes information into a
:ref:`FIFO <fifos_v2>` identifying the thread/LED and how many times it has
been toggled.

The third thread uses :c:func:`printk` to print the information added to the
FIFO to the device console.

Requirements
************

The board must have two LEDs connected via GPIO pins. These are called "User
LEDs" on many of Zephyr's :ref:`boards`. The LEDs must be configured using the
``led0`` and ``led1`` :ref:`devicetree <dt-guide>` aliases, usually in the
:ref:`BOARD.dts file <devicetree-in-out-files>`.

You will see one of these errors if you try to build this sample for an
unsupported board:

.. code-block:: none

   Unsupported board: led0 devicetree alias is not defined
   Unsupported board: led1 devicetree alias is not defined

Building
********

For example, to build this sample for :ref:`96b_carbon_board`:

.. zephyr-app-commands::
   :zephyr-app: samples/basic/threads
   :board: 96b_carbon
   :goals: build flash
   :compact:

Change ``96b_carbon`` appropriately for other supported boards.