zephyr/samples/subsys/sensing/simple
Tom Burdick e69ce68d40 sensing: Fix initializer compile-time constant
Initializers must be compile time constants (not expressions!) for clang
to be happy. Clang rightfully pointed out that the callback_list member
of sensing_connection was being initialized using an expression that was
not compile-time constant.

The macros passed along a pointer created by taking the address of a
global constant and then at initialization time attempting to
dereference it using the * operator. So in the end the compiler has
identifier its trying to first take the address of and then later
dereference in an initializer. Clang didn't appreciate this, though gcc
seemed to be just fine.

Actually clang 17 might work just fine with this as well, but clang 16
(the clang I tried) didn't like it at all.

Instead store the pointer to the callback list rather than copying the
struct. This could be done the other way and not passing a
pointer through the macros perhaps.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-01-24 10:32:10 +01:00
..
boards sensing: support multiple sensor types in one device 2024-01-24 10:32:10 +01:00
src sensing: Fix initializer compile-time constant 2024-01-24 10:32:10 +01:00
CMakeLists.txt
README.rst
app.overlay
prj.conf
sample.yaml

README.rst

.. zephyr:code-sample:: sensing
   :name: Sensing subsystem
   :relevant-api: sensing_api

   Get high-level sensor data in defined intervals.

Overview
********

A simple sample that shows how to use the sensors with sensing subsystem APIs. It defines
two sensors, with the underlying device bmi160 emulator, and gets the sensor
data in defined interval.

The program runs in the following sequence:

#. Define the sensor in the dts

#. Open the sensor

#. Register call back.

#. Set sample interval

#. Run forever and get the sensor data.

Building and Running
********************

This application can be built and executed on :ref:`native_sim <native_sim>` as follows:

.. zephyr-app-commands::
   :zephyr-app: samples/subsys/sensing/simple
   :host-os: unix
   :board: native_sim
   :goals: run
   :compact:

To build for another board, change "native_sim" above to that board's name.
At the current stage, it only support native sim.