Overview¶
This example demonstrates spawning multiple threads using
K_THREAD_DEFINE(). It spawns up to five threads.
Each thread is then defined at compile time using K_THREAD_DEFINE.
The first four threads control an LED using a custom driver named blink.
blink0()controlsblink0_ledand has a 100ms sleep cycleblink1()controlsblink1_ledand has a 200ms sleep cycleblink2()controlsblink2_ledand has a 300ms sleep cycleblink3()controlsblink3_ledand has a 400ms sleep cycle
Each thread relies on the use of Zephyr Semaphores for proper thread synichronization.
Note that a multi-threaded application does not strictly require a main() function.
The last thread controls a button using a custom driver named custom_button.
button()controlscustom_button_0
The button thread uses printk() to print a message when the button is pushed.
Button was pressed
Requirements¶
The IAR Zephyr application example was designed to run with the IAR STM32F429II-ACA board
using a custom Device Tree specification, hence the default board is named custom_aca.
Alternatively, a overlay can be created for supported Zephyr boards
under app/boards. The board must have two or more LEDs and
one button connected via GPIO pins.