Zephyr Project API 3.6.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Sensing Sensor API

Sensing Sensor API. More...

Modules

 Sensor Callbacks
 

Data Structures

struct  sensing_sensor_register_info
 Sensor registration information. More...
 
struct  sensing_connection
 Connection between a source and sink of sensor data. More...
 
struct  sensing_sensor
 Internal sensor instance data structure. More...
 
struct  sensing_submit_config
 

Macros

#define SENSING_SENSOR_INFO_NAME(node, idx)    _CONCAT(_CONCAT(__sensing_sensor_info_, idx), DEVICE_DT_NAME_GET(node))
 
#define SENSING_SENSOR_INFO_DEFINE(node, idx)
 
#define SENSING_CONNECTIONS_NAME(node)    _CONCAT(__sensing_connections_, DEVICE_DT_NAME_GET(node))
 
#define SENSING_SENSOR_SOURCE_NAME(idx, node)
 
#define SENSING_SENSOR_SOURCE_EXTERN(idx, node)   extern struct sensing_sensor SENSING_SENSOR_SOURCE_NAME(idx, node); \
 
#define SENSING_CONNECTION_INITIALIZER(source_name, cb_list_ptr)
 
#define SENSING_CONNECTION_DEFINE(idx, node, cb_list_ptr)
 
#define SENSING_CONNECTIONS_DEFINE(node, num, cb_list_ptr)
 
#define SENSING_SUBMIT_CFG_NAME(node, idx)    _CONCAT(_CONCAT(__sensing_submit_cfg_, idx), DEVICE_DT_NAME_GET(node))
 
#define SENSING_SENSOR_IODEV_NAME(node, idx)    _CONCAT(_CONCAT(__sensing_iodev_, idx), DEVICE_DT_NAME_GET(node))
 
#define SENSING_SENSOR_IODEV_DEFINE(node, idx)
 
#define SENSING_SENSOR_NAME(node, idx)    _CONCAT(_CONCAT(__sensing_sensor_, idx), DEVICE_DT_NAME_GET(node))
 
#define SENSING_SENSOR_DEFINE(node, prop, idx, reg_ptr, cb_list_ptr)
 
#define SENSING_SENSORS_DEFINE(node, reg_ptr, cb_list_ptr)
 
#define SENSING_SENSORS_DT_DEFINE(node, reg_ptr, cb_list_ptr, init_fn, pm_device, data_ptr, cfg_ptr, level, prio, api_ptr, ...)
 Like SENSOR_DEVICE_DT_DEFINE() with sensing specifics.
 
#define SENSING_SENSORS_DT_INST_DEFINE(inst, ...)    SENSING_SENSORS_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
 Like SENSING_SENSORS_DT_DEFINE() for an instance of a DT_DRV_COMPAT compatible.
 

Enumerations

enum  { EVENT_CONFIG_READY }
 
enum  { SENSOR_LATER_CFG_BIT }
 

Functions

int sensing_sensor_get_reporters (const struct device *dev, int type, sensing_sensor_handle_t *reporter_handles, int max_handles)
 Get reporter handles of a given sensor instance by sensor type.
 
int sensing_sensor_get_reporters_count (const struct device *dev, int type)
 Get reporters count of a given sensor instance by sensor type.
 
int sensing_sensor_get_state (const struct device *dev, enum sensing_sensor_state *state)
 Get this sensor's state.
 

Detailed Description

Sensing Sensor API.

Macro Definition Documentation

◆ SENSING_CONNECTION_DEFINE

#define SENSING_CONNECTION_DEFINE (   idx,
  node,
  cb_list_ptr 
)

#include <include/zephyr/sensing/sensing_sensor.h>

Value:
cb_list_ptr)
#define SENSING_CONNECTION_INITIALIZER(source_name, cb_list_ptr)
Definition sensing_sensor.h:137
#define SENSING_SENSOR_SOURCE_NAME(idx, node)
Definition sensing_sensor.h:130

◆ SENSING_CONNECTION_INITIALIZER

#define SENSING_CONNECTION_INITIALIZER (   source_name,
  cb_list_ptr 
)

#include <include/zephyr/sensing/sensing_sensor.h>

Value:
{ \
.callback_list = cb_list_ptr, \
.source = &source_name, \
}

◆ SENSING_CONNECTIONS_DEFINE

#define SENSING_CONNECTIONS_DEFINE (   node,
  num,
  cb_list_ptr 
)

#include <include/zephyr/sensing/sensing_sensor.h>

Value:
(), node) \
static struct sensing_connection \
SENSING_CONNECTIONS_NAME(node)[(num)] = { \
LISTIFY(num, SENSING_CONNECTION_DEFINE, \
(,), node, cb_list_ptr) \
};
#define SENSING_CONNECTIONS_NAME(node)
Definition sensing_sensor.h:127
#define SENSING_SENSOR_SOURCE_EXTERN(idx, node)
Definition sensing_sensor.h:134
#define SENSING_CONNECTION_DEFINE(idx, node, cb_list_ptr)
Definition sensing_sensor.h:143
#define LISTIFY(LEN, F, sep,...)
Generates a sequence of code with configurable separator.
Definition util_macro.h:442
Connection between a source and sink of sensor data.
Definition sensing_sensor.h:71

◆ SENSING_CONNECTIONS_NAME

#define SENSING_CONNECTIONS_NAME (   node)     _CONCAT(__sensing_connections_, DEVICE_DT_NAME_GET(node))

◆ SENSING_SENSOR_DEFINE

#define SENSING_SENSOR_DEFINE (   node,
  prop,
  idx,
  reg_ptr,
  cb_list_ptr 
)

#include <include/zephyr/sensing/sensing_sensor.h>

Value:
SENSING_SENSOR_IODEV_DEFINE(node, idx) \
STRUCT_SECTION_ITERABLE(sensing_sensor, \
SENSING_SENSOR_NAME(node, idx)) = { \
.dev = DEVICE_DT_GET(node), \
.info = &SENSING_SENSOR_INFO_NAME(node, idx), \
.register_info = reg_ptr, \
.reporter_num = DT_PROP_LEN_OR(node, reporters, 0), \
.conns = SENSING_CONNECTIONS_NAME(node), \
.iodev = &SENSING_SENSOR_IODEV_NAME(node, idx), \
};
#define DEVICE_DT_GET(node_id)
Get a device reference from a devicetree node identifier.
Definition device.h:233
#define DT_PROP_LEN_OR(node_id, prop, default_value)
Like DT_PROP_LEN(), but with a fallback to default_value.
Definition devicetree.h:665
#define SENSING_SENSOR_INFO_DEFINE(node, idx)
Definition sensing_sensor.h:116
#define SENSING_SENSOR_INFO_NAME(node, idx)
Definition sensing_sensor.h:113
#define SENSING_SENSOR_NAME(node, idx)
Definition sensing_sensor.h:179
#define SENSING_SENSOR_IODEV_NAME(node, idx)
Definition sensing_sensor.h:167
Internal sensor instance data structure.
Definition sensing_sensor.h:95

◆ SENSING_SENSOR_INFO_DEFINE

#define SENSING_SENSOR_INFO_DEFINE (   node,
  idx 
)

#include <include/zephyr/sensing/sensing_sensor.h>

Value:
SENSING_SENSOR_INFO_NAME(node, idx)) = { \
.type = DT_PROP_BY_IDX(node, sensor_types, idx), \
.name = DT_NODE_FULL_NAME(node), \
.friendly_name = DT_PROP(node, friendly_name), \
.vendor = DT_NODE_VENDOR_OR(node, NULL), \
.model = DT_NODE_MODEL_OR(node, NULL), \
.minimal_interval = DT_PROP(node, minimal_interval),\
};
#define DT_NODE_FULL_NAME(node_id)
Get a devicetree node's name with unit-address as a string literal.
Definition devicetree.h:522
#define DT_PROP_BY_IDX(node_id, prop, idx)
Get the value at index idx in an array type property.
Definition devicetree.h:761
#define DT_PROP(node_id, prop)
Get a devicetree property value.
Definition devicetree.h:615
#define DT_NODE_MODEL_OR(node_id, default_value)
Get the node's (only) model as a string literal.
Definition devicetree.h:2148
#define DT_NODE_VENDOR_OR(node_id, default_value)
Get the node's (only) vendor as a string literal.
Definition devicetree.h:2072
#define STRUCT_SECTION_ITERABLE(struct_type, varname)
Defines a new element for an iterable section.
Definition iterable_sections.h:216
Sensor basic constant information.
Definition sensing.h:126

◆ SENSING_SENSOR_INFO_NAME

#define SENSING_SENSOR_INFO_NAME (   node,
  idx 
)     _CONCAT(_CONCAT(__sensing_sensor_info_, idx), DEVICE_DT_NAME_GET(node))

◆ SENSING_SENSOR_IODEV_DEFINE

#define SENSING_SENSOR_IODEV_DEFINE (   node,
  idx 
)

#include <include/zephyr/sensing/sensing_sensor.h>

Value:
static struct sensing_submit_config SENSING_SUBMIT_CFG_NAME(node, idx) = { \
.is_streaming = DT_PROP(node, stream_mode), \
.info_index = idx, \
}; \
RTIO_IODEV_DEFINE(SENSING_SENSOR_IODEV_NAME(node, idx), \
&__sensing_iodev_api, \
#define SENSING_SUBMIT_CFG_NAME(node, idx)
Definition sensing_sensor.h:164
Definition sensing_sensor.h:156
const bool is_streaming
Definition sensing_sensor.h:159

◆ SENSING_SENSOR_IODEV_NAME

#define SENSING_SENSOR_IODEV_NAME (   node,
  idx 
)     _CONCAT(_CONCAT(__sensing_iodev_, idx), DEVICE_DT_NAME_GET(node))

◆ SENSING_SENSOR_NAME

#define SENSING_SENSOR_NAME (   node,
  idx 
)     _CONCAT(_CONCAT(__sensing_sensor_, idx), DEVICE_DT_NAME_GET(node))

◆ SENSING_SENSOR_SOURCE_EXTERN

#define SENSING_SENSOR_SOURCE_EXTERN (   idx,
  node 
)    extern struct sensing_sensor SENSING_SENSOR_SOURCE_NAME(idx, node); \

◆ SENSING_SENSOR_SOURCE_NAME

#define SENSING_SENSOR_SOURCE_NAME (   idx,
  node 
)

#include <include/zephyr/sensing/sensing_sensor.h>

Value:
SENSING_SENSOR_NAME(DT_PHANDLE_BY_IDX(node, reporters, idx), \
DT_PROP_BY_IDX(node, reporters_index, idx))
#define DT_PHANDLE_BY_IDX(node_id, prop, idx)
Get a node identifier for a phandle in a property.
Definition devicetree.h:1580

◆ SENSING_SENSORS_DEFINE

#define SENSING_SENSORS_DEFINE (   node,
  reg_ptr,
  cb_list_ptr 
)

#include <include/zephyr/sensing/sensing_sensor.h>

Value:
DT_FOREACH_PROP_ELEM_VARGS(node, sensor_types, \
SENSING_SENSOR_DEFINE, reg_ptr, cb_list_ptr)
#define DT_FOREACH_PROP_ELEM_VARGS(node_id, prop, fn,...)
Invokes fn for each element in the value of property prop with multiple arguments.
Definition devicetree.h:3013
#define SENSING_SENSOR_DEFINE(node, prop, idx, reg_ptr, cb_list_ptr)
Definition sensing_sensor.h:182

◆ SENSING_SENSORS_DT_DEFINE

#define SENSING_SENSORS_DT_DEFINE (   node,
  reg_ptr,
  cb_list_ptr,
  init_fn,
  pm_device,
  data_ptr,
  cfg_ptr,
  level,
  prio,
  api_ptr,
  ... 
)

#include <include/zephyr/sensing/sensing_sensor.h>

Value:
data_ptr, cfg_ptr, level, prio, \
api_ptr, __VA_ARGS__); \
SENSING_CONNECTIONS_DEFINE(node, \
DT_PROP_LEN_OR(node, reporters, 0), \
cb_list_ptr); \
SENSING_SENSORS_DEFINE(node, reg_ptr, cb_list_ptr);
static int init_fn(void)
Definition main.c:249
#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.
Definition sensor.h:1313
Runtime PM info for device with generic PM.
Definition device.h:165

Like SENSOR_DEVICE_DT_DEFINE() with sensing specifics.

Defines a sensor which implements the sensor API. May define an element in the sensing sensor iterable section used to enumerate all sensing sensors.

Parameters
nodeThe devicetree node identifier.
reg_ptrPointer to the device's sensing_sensor_register_info.
cb_list_ptrPointer to devices callback list.
init_fnName of the init function of the driver.
pm_devicePM device resources reference (NULL if device does not use PM).
data_ptrPointer to the device's private data.
cfg_ptrThe address to the structure containing the configuration information for this instance of the driver.
levelThe initialization level. See SYS_INIT() for details.
prioPriority within the selected initialization level. See SYS_INIT() for details.
api_ptrProvides an initial pointer to the API function struct used by the driver. Can be NULL.

◆ SENSING_SENSORS_DT_INST_DEFINE

#define SENSING_SENSORS_DT_INST_DEFINE (   inst,
  ... 
)     SENSING_SENSORS_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)

#include <include/zephyr/sensing/sensing_sensor.h>

Like SENSING_SENSORS_DT_DEFINE() for an instance of a DT_DRV_COMPAT compatible.

Parameters
instinstance number. This is replaced by DT_DRV_COMPAT(inst) in the call to SENSING_SENSORS_DT_DEFINE().
...other parameters as expected by SENSING_SENSORS_DT_DEFINE().

◆ SENSING_SUBMIT_CFG_NAME

#define SENSING_SUBMIT_CFG_NAME (   node,
  idx 
)     _CONCAT(_CONCAT(__sensing_submit_cfg_, idx), DEVICE_DT_NAME_GET(node))

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

#include <include/zephyr/sensing/sensing_sensor.h>

Enumerator
EVENT_CONFIG_READY 

◆ anonymous enum

anonymous enum

#include <include/zephyr/sensing/sensing_sensor.h>

Enumerator
SENSOR_LATER_CFG_BIT 

Function Documentation

◆ sensing_sensor_get_reporters()

int sensing_sensor_get_reporters ( const struct device dev,
int  type,
sensing_sensor_handle_t reporter_handles,
int  max_handles 
)

#include <include/zephyr/sensing/sensing_sensor.h>

Get reporter handles of a given sensor instance by sensor type.

Parameters
devThe sensor instance device structure.
typeThe given type, SENSING_SENSOR_TYPE_ALL to get reporters with all types.
max_handlesThe max count of the reporter_handles array input. Can get real count number via sensing_sensor_get_reporters_count
reporter_handlesInput handles array for receiving found reporter sensor instances
Returns
number of reporters found, 0 returned if not found.

◆ sensing_sensor_get_reporters_count()

int sensing_sensor_get_reporters_count ( const struct device dev,
int  type 
)

#include <include/zephyr/sensing/sensing_sensor.h>

Get reporters count of a given sensor instance by sensor type.

Parameters
devThe sensor instance device structure.
typeThe sensor type for checking, SENSING_SENSOR_TYPE_ALL
Returns
Count of reporters by type, 0 returned if no reporters by type.

◆ sensing_sensor_get_state()

int sensing_sensor_get_state ( const struct device dev,
enum sensing_sensor_state state 
)

#include <include/zephyr/sensing/sensing_sensor.h>

Get this sensor's state.

Parameters
devThe sensor instance device structure.
stateReturned sensor state value
Returns
0 on success or negative error value on failure.