Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Sensor emulator backend API

Sensor emulator backend API . More...

Functions

static bool emul_sensor_backend_is_supported (const struct emul *target)
 Check if a given sensor emulator supports the backend API.
 
static int emul_sensor_backend_set_channel (const struct emul *target, struct sensor_chan_spec ch, const q31_t *value, int8_t shift)
 Set an expected value for a given channel on a given sensor emulator.
 
static int emul_sensor_backend_get_sample_range (const struct emul *target, struct sensor_chan_spec ch, q31_t *lower, q31_t *upper, q31_t *epsilon, int8_t *shift)
 Query an emulator for a channel's supported sample value range and tolerance.
 
static int emul_sensor_backend_set_attribute (const struct emul *target, struct sensor_chan_spec ch, enum sensor_attribute attribute, const void *value)
 Set the emulator's attribute values.
 
static int emul_sensor_backend_get_attribute_metadata (const struct emul *target, struct sensor_chan_spec ch, enum sensor_attribute attribute, q31_t *min, q31_t *max, q31_t *increment, int8_t *shift)
 Get metadata about an attribute.
 

Detailed Description

Sensor emulator backend API .

Function Documentation

◆ emul_sensor_backend_get_attribute_metadata()

static int emul_sensor_backend_get_attribute_metadata ( const struct emul * target,
struct sensor_chan_spec ch,
enum sensor_attribute attribute,
q31_t * min,
q31_t * max,
q31_t * increment,
int8_t * shift )
inlinestatic

#include <zephyr/drivers/emul_sensor.h>

Get metadata about an attribute.

Information provided by this function includes the minimum/maximum values of the attribute as well as the increment (value per LSB) which can be used as an epsilon when comparing results.

Parameters
[in]targetPointer to emulator instance to operate on
[in]chThe channel to request info for. If ch is unsupported, return '-ENOTSUP'
[in]attributeThe attribute to request info for. If attribute is unsupported, return '-ENOTSUP'
[out]minThe minimum value the attribute can be set to
[out]maxThe maximum value the attribute can be set to
[out]incrementThe value that the attribute increases by for every LSB
[out]shiftThe shift for min, max, and increment
Returns
0 on SUCCESS
< 0 on error

◆ emul_sensor_backend_get_sample_range()

static int emul_sensor_backend_get_sample_range ( const struct emul * target,
struct sensor_chan_spec ch,
q31_t * lower,
q31_t * upper,
q31_t * epsilon,
int8_t * shift )
inlinestatic

#include <zephyr/drivers/emul_sensor.h>

Query an emulator for a channel's supported sample value range and tolerance.

Parameters
targetPointer to emulator instance to operate on
chThe channel to request info for. If ch is unsupported, return -ENOTSUP
[out]lowerMinimum supported sample value in SI units, fixed-point format
[out]upperMaximum supported sample value in SI units, fixed-point format
[out]epsilonTolerance to use comparing expected and actual values to account for rounding and sensor precision issues. This can usually be set to the minimum sample value step size. Uses SI units and fixed-point format.
[out]shiftThe shift value (scaling factor) associated with lower, upper, and epsilon.
Returns
0 if successful
-ENOTSUP if no backend API or if channel not supported by emul

◆ emul_sensor_backend_is_supported()

static bool emul_sensor_backend_is_supported ( const struct emul * target)
inlinestatic

#include <zephyr/drivers/emul_sensor.h>

Check if a given sensor emulator supports the backend API.

Parameters
targetPointer to emulator instance to query
Returns
True if supported, false if unsupported or if target is NULL.

◆ emul_sensor_backend_set_attribute()

static int emul_sensor_backend_set_attribute ( const struct emul * target,
struct sensor_chan_spec ch,
enum sensor_attribute attribute,
const void * value )
inlinestatic

#include <zephyr/drivers/emul_sensor.h>

Set the emulator's attribute values.

Parameters
[in]targetPointer to emulator instance to operate on
[in]chThe channel to request info for. If ch is unsupported, return -ENOTSUP
[in]attributeThe attribute to set
[in]valuethe value to use (cast according to the channel/attribute pair)
Returns
0 is successful
< 0 on error

◆ emul_sensor_backend_set_channel()

static int emul_sensor_backend_set_channel ( const struct emul * target,
struct sensor_chan_spec ch,
const q31_t * value,
int8_t shift )
inlinestatic

#include <zephyr/drivers/emul_sensor.h>

Set an expected value for a given channel on a given sensor emulator.

Parameters
targetPointer to emulator instance to operate on
chSensor channel to set expected value for
valueExpected value in fixed-point format using standard SI unit for sensor type
shiftShift value (scaling factor) applied to value
Returns
0 if successful
-ENOTSUP if no backend API or if channel not supported by emul
-ERANGE if provided value is not in the sensor's supported range