| 
    Zephyr Project API
    3.4.0
    
   A Scalable Open Source RTOS 
   | 
 
Public APIs for the sensor driver. More...
#include <errno.h>#include <stdlib.h>#include <zephyr/device.h>#include <zephyr/dsp/types.h>#include <zephyr/rtio/rtio.h>#include <zephyr/sys/iterable_sections.h>#include <zephyr/types.h>#include <syscalls/sensor.h>Go to the source code of this file.
Data Structures | |
| struct | sensor_value | 
| Representation of a sensor readout value.  More... | |
| struct | sensor_trigger | 
| Sensor trigger spec.  More... | |
| struct | sensor_decoder_api | 
| Decodes a single raw data buffer.  More... | |
| struct | sensor_read_config | 
| struct | sensor_driver_api | 
| struct | sensor_data_generic_header | 
Macros | |
| #define | SENSOR_DT_READ_IODEV(name, dt_node, ...) | 
| Define a reading instance of a sensor.  More... | |
| #define | SENSOR_CHANNEL_3_AXIS(chan) | 
| checks if a given channel is a 3-axis channel  More... | |
| #define | SENSOR_G 9806650LL | 
| The value of gravitational constant in micro m/s^2.  More... | |
| #define | SENSOR_PI 3141592LL | 
| The value of constant PI in micros.  More... | |
| #define | SENSOR_INFO_DEFINE(name, ...) | 
| #define | SENSOR_INFO_DT_DEFINE(node_id) | 
| #define | SENSOR_DEVICE_DT_DEFINE(node_id, init_fn, pm_device, data_ptr, cfg_ptr, level, prio, api_ptr, ...) | 
| Like DEVICE_DT_DEFINE() with sensor specifics.  More... | |
| #define | SENSOR_DEVICE_DT_INST_DEFINE(inst, ...) SENSOR_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__) | 
| Like SENSOR_DEVICE_DT_DEFINE() for an instance of a DT_DRV_COMPAT compatible.  More... | |
| #define | SENSOR_DECODER_NAME() UTIL_CAT(DT_DRV_COMPAT, __decoder_api) | 
| Get the decoder name for the current driver.  More... | |
| #define | SENSOR_DECODER_DT_GET(node_id) &UTIL_CAT(DT_STRING_TOKEN_BY_IDX(node_id, compatible, 0), __decoder_api) | 
| Statically get the decoder for a given node.  More... | |
| #define | SENSOR_DECODER_API_DT_DEFINE() | 
| Define a decoder API.  More... | |
Typedefs | |
| typedef void(* | sensor_trigger_handler_t) (const struct device *dev, const struct sensor_trigger *trigger) | 
| Callback API upon firing of a trigger.  More... | |
| typedef int(* | sensor_attr_set_t) (const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) | 
| Callback API upon setting a sensor's attributes.  More... | |
| typedef int(* | sensor_attr_get_t) (const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, struct sensor_value *val) | 
| Callback API upon getting a sensor's attributes.  More... | |
| typedef int(* | sensor_trigger_set_t) (const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) | 
| Callback API for setting a sensor's trigger and handler.  More... | |
| typedef int(* | sensor_sample_fetch_t) (const struct device *dev, enum sensor_channel chan) | 
| Callback API for fetching data from a sensor.  More... | |
| typedef int(* | sensor_channel_get_t) (const struct device *dev, enum sensor_channel chan, struct sensor_value *val) | 
| Callback API for getting a reading from a sensor.  More... | |
| typedef uint32_t | sensor_frame_iterator_t | 
Used for iterating over the data frames via the :c:struct:sensor_decoder_api  More... | |
| typedef uint32_t | sensor_channel_iterator_t | 
Used for iterating over data channels in the same frame via :c:struct:sensor_decoder_api  More... | |
| typedef int(* | sensor_get_decoder_t) (const struct device *dev, const struct sensor_decoder_api **api) | 
| Get the decoder associate with the given device.  More... | |
| typedef int(* | sensor_submit_t) (const struct device *sensor, struct rtio_iodev_sqe *sqe) | 
| typedef void(* | sensor_processing_callback_t) (int result, uint8_t *buf, uint32_t buf_len, void *userdata) | 
| Callback function used with the helper processing function.  More... | |
Functions | |
| int | sensor_attr_set (const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) | 
| Set an attribute for a sensor.  More... | |
| int | sensor_attr_get (const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, struct sensor_value *val) | 
| Get an attribute for a sensor.  More... | |
| static int | sensor_trigger_set (const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) | 
| Activate a sensor's trigger and set the trigger handler.  More... | |
| int | sensor_sample_fetch (const struct device *dev) | 
| Fetch a sample from the sensor and store it in an internal driver buffer.  More... | |
| int | sensor_sample_fetch_chan (const struct device *dev, enum sensor_channel type) | 
| Fetch a sample from the sensor and store it in an internal driver buffer.  More... | |
| int | sensor_channel_get (const struct device *dev, enum sensor_channel chan, struct sensor_value *val) | 
| Get a reading from a sensor device.  More... | |
| int | sensor_get_decoder (const struct device *dev, const struct sensor_decoder_api **decoder) | 
| Get the sensor's decoder API.  More... | |
| int | sensor_reconfigure_read_iodev (struct rtio_iodev *iodev, const struct device *sensor, const enum sensor_channel *channels, size_t num_channels) | 
| Reconfigure a reading iodev.  More... | |
| static int | sensor_read (struct rtio_iodev *iodev, struct rtio *ctx, void *userdata) | 
| Read data from a sensor.  More... | |
| void | sensor_processing_with_callback (struct rtio *ctx, sensor_processing_callback_t cb) | 
| Helper function for common processing of sensor data.  More... | |
| static int32_t | sensor_ms2_to_g (const struct sensor_value *ms2) | 
| Helper function to convert acceleration from m/s^2 to Gs.  More... | |
| static void | sensor_g_to_ms2 (int32_t g, struct sensor_value *ms2) | 
| Helper function to convert acceleration from Gs to m/s^2.  More... | |
| static int32_t | sensor_ms2_to_ug (const struct sensor_value *ms2) | 
| Helper function to convert acceleration from m/s^2 to micro Gs.  More... | |
| static void | sensor_ug_to_ms2 (int32_t ug, struct sensor_value *ms2) | 
| Helper function to convert acceleration from micro Gs to m/s^2.  More... | |
| static int32_t | sensor_rad_to_degrees (const struct sensor_value *rad) | 
| Helper function for converting radians to degrees.  More... | |
| static void | sensor_degrees_to_rad (int32_t d, struct sensor_value *rad) | 
| Helper function for converting degrees to radians.  More... | |
| static int32_t | sensor_rad_to_10udegrees (const struct sensor_value *rad) | 
| Helper function for converting radians to 10 micro degrees.  More... | |
| static void | sensor_10udegrees_to_rad (int32_t d, struct sensor_value *rad) | 
| Helper function for converting 10 micro degrees to radians.  More... | |
| static double | sensor_value_to_double (const struct sensor_value *val) | 
| Helper function for converting struct sensor_value to double.  More... | |
| static float | sensor_value_to_float (const struct sensor_value *val) | 
| Helper function for converting struct sensor_value to float.  More... | |
| static int | sensor_value_from_double (struct sensor_value *val, double inp) | 
| Helper function for converting double to struct sensor_value.  More... | |
| static int | sensor_value_from_float (struct sensor_value *val, float inp) | 
| Helper function for converting float to struct sensor_value.  More... | |
| static int64_t | sensor_value_to_milli (struct sensor_value *val) | 
| Helper function for converting struct sensor_value to integer milli units.  More... | |
| static int64_t | sensor_value_to_micro (struct sensor_value *val) | 
| Helper function for converting struct sensor_value to integer micro units.  More... | |
Public APIs for the sensor driver.
| #define SENSOR_DECODER_API_DT_DEFINE | ( | ) | 
Define a decoder API.
This macro should be created once per compatible string of a sensor and will create a statically referenceable decoder API.
| #define SENSOR_DECODER_DT_GET | ( | node_id | ) | &UTIL_CAT(DT_STRING_TOKEN_BY_IDX(node_id, compatible, 0), __decoder_api) | 
Statically get the decoder for a given node.
| #define SENSOR_DECODER_NAME | ( | ) | UTIL_CAT(DT_DRV_COMPAT, __decoder_api) | 
Get the decoder name for the current driver.
This function depends on DT_DRV_COMPAT being defined.