BETWEEN INTERRUPTS
FIELD NOTES / ZEPHYR RTOS

Make room for the next sample.

A Zephyr notebook about sensor acquisition, deferred work, and keeping concurrent code understandable.

Fetch first, read second

The sensor fetch API obtains a sample and stores it in the driver. A channel-get call then reads a value from that stored sample. Fetching blocks the calling thread, so account for acquisition time when planning the rest of the application.

Read the Zephyr documentation ↗

Keep shared work moving

Workqueue handlers run on a workqueue thread. A handler that blocks also delays later work on that queue. Keep shared handlers short, and think carefully about whether long operations need a separate execution context.

Read the Zephyr documentation ↗

Give each sample an owner

For a sensor shared across threads, decide who controls the fetch-and-read sequence. Concurrent fetch/get calls generally need external locking. A single acquisition thread can make ownership easier to reason about.

Read the Zephyr documentation ↗

About this notebook

A small collection of embedded-systems study notes. These examples are starting points for exploration; check the documentation for your Zephyr release and board.