zephyr/samples/basic/threads
Sebastian Bøe 830b8bdc17 samples: threads: Rewrite misleading sample
The basic/threads sample is printing a log that looks like this:

Toggle USR0 LED: Counter = 0
Toggle USR1 LED: Counter = 0
Toggle USR0 LED: Counter = 1
Toggle USR0 LED: Counter = 2
Toggle USR0 LED: Counter = 3
Toggle USR0 LED: Counter = 4

From that log you would think that it was logging when leds were
blinking, but actually the led-threads might have crashed, and it
would just continue logging anyway. All it's doing is executing
printk's at roughly the same frequency as the LED's are blinking.

This patch rewrites the sample to use a FIFO so that the printk's only
trigger if the LEDs are actually blinking.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-08 14:25:11 -05:00
..
src samples: threads: Rewrite misleading sample 2018-01-08 14:25:11 -05:00
CMakeLists.txt Introduce cmake-based rewrite of KBuild 2017-11-08 20:00:22 -05:00
README.rst samples: threads: Rewrite misleading sample 2018-01-08 14:25:11 -05:00
prj.conf samples: threads: Rewrite misleading sample 2018-01-08 14:25:11 -05:00
sample.yaml samples: remove more build_only tags 2017-12-28 20:24:29 -05:00

README.rst

.. _96b_carbon_multi_thread_blinky:

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

Overview
********

This example demonstrates spawning of multiple threads using K_THREAD_DEFINE.

The example works by spawning three threads. The first two threads control a
separate LED. Both of these LEDs (USR1 and USR2) have their individual loop
control and timing logic defined by separate functions.

After either thread toggles its LED, it also pushes information into a
FIFO identifying which thread toggled its LED and how many times it
was done.

The third thread, ``uart_out()``, uses printk (over the UART) to
display the information that comes through the FIFO.

- blink1() controls the USR1 LED that has a 100ms sleep cycle
- blink2() controls the USR2 LED that has a 1000ms sleep cycle

Each thread is then defined at compile time using K_THREAD_DEFINE.

Building
********

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