Basic Thread Example¶
This example demonstrates spawning multiple threads using
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,
loop control and timing logic controlled by separate functions.
led0and has a 100ms sleep cycle
led1and has a 1000ms sleep cycle
When either of these threads toggles its LED, it also pushes information into a FIFO identifying the thread/LED and how many times it has been toggled.
The third thread uses
printk() to print the information added to the
FIFO to the device console.
The board must have two LEDs connected via GPIO pins. These are called “User
LEDs” on many of Zephyr’s Supported Boards. The LEDs must be configured using the
led1 devicetree aliases, usually in the
You will see one of these errors if you try to build this sample for an unsupported board:
Unsupported board: led0 devicetree alias is not defined
Unsupported board: led1 devicetree alias is not defined