7#ifndef ZEPHYR_INCLUDE_SENSING_SENSOR_H_
8#define ZEPHYR_INCLUDE_SENSING_SENSOR_H_
83struct sensing_connection {
85 struct sensing_sensor *source;
86 struct sensing_sensor *sink;
89 int sensitivity[CONFIG_SENSING_MAX_SENSITIVITY_COUNT];
105struct sensing_sensor {
115 int sensitivity[CONFIG_SENSING_MAX_SENSITIVITY_COUNT];
118 struct k_timer timer;
121 struct sensing_connection *conns;
132#define SENSING_SENSOR_INFO_NAME(node, idx) \
133 _CONCAT(_CONCAT(__sensing_sensor_info_, idx), DEVICE_DT_NAME_GET(node))
145#define SENSING_SENSOR_INFO_DEFINE(node, idx) \
146 const static STRUCT_SECTION_ITERABLE(sensing_sensor_info, \
147 SENSING_SENSOR_INFO_NAME(node, idx)) = { \
148 .type = DT_PROP_BY_IDX(node, sensor_types, idx), \
149 .name = DT_NODE_FULL_NAME(node), \
150 .friendly_name = DT_PROP(node, friendly_name), \
151 .vendor = DT_NODE_VENDOR_OR(node, NULL), \
152 .model = DT_NODE_MODEL_OR(node, NULL), \
153 .minimal_interval = DT_PROP(node, minimal_interval), \
163#define SENSING_CONNECTIONS_NAME(node) \
164 _CONCAT(__sensing_connections_, DEVICE_DT_NAME_GET(node))
174#define SENSING_SENSOR_SOURCE_NAME(idx, node) \
175 SENSING_SENSOR_NAME(DT_PHANDLE_BY_IDX(node, reporters, idx), \
176 DT_PROP_BY_IDX(node, reporters_index, idx))
186#define SENSING_SENSOR_SOURCE_EXTERN(idx, node) \
187extern struct sensing_sensor SENSING_SENSOR_SOURCE_NAME(idx, node);
197#define SENSING_CONNECTION_INITIALIZER(source_name, cb_list_ptr) \
199 .callback_list = cb_list_ptr, \
200 .source = &source_name, \
212#define SENSING_CONNECTION_DEFINE(idx, node, cb_list_ptr) \
213 SENSING_CONNECTION_INITIALIZER(SENSING_SENSOR_SOURCE_NAME(idx, node), \
226#define SENSING_CONNECTIONS_DEFINE(node, num, cb_list_ptr) \
227 LISTIFY(num, SENSING_SENSOR_SOURCE_EXTERN, \
229 static struct sensing_connection \
230 SENSING_CONNECTIONS_NAME(node)[(num)] = { \
231 LISTIFY(num, SENSING_CONNECTION_DEFINE, \
232 (,), node, cb_list_ptr) \
241struct sensing_submit_config {
243 const int info_index;
244 const bool is_streaming;
262#define SENSING_SUBMIT_CFG_NAME(node, idx) \
263 _CONCAT(_CONCAT(__sensing_submit_cfg_, idx), DEVICE_DT_NAME_GET(node))
273#define SENSING_SENSOR_IODEV_NAME(node, idx) \
274 _CONCAT(_CONCAT(__sensing_iodev_, idx), DEVICE_DT_NAME_GET(node))
285#define SENSING_SENSOR_IODEV_DEFINE(node, idx) \
286 static struct sensing_submit_config SENSING_SUBMIT_CFG_NAME(node, idx) = { \
287 .is_streaming = DT_PROP(node, stream_mode), \
290 RTIO_IODEV_DEFINE(SENSING_SENSOR_IODEV_NAME(node, idx), \
291 &__sensing_iodev_api, \
292 &SENSING_SUBMIT_CFG_NAME(node, idx));
302#define SENSING_SENSOR_NAME(node, idx) \
303 _CONCAT(_CONCAT(__sensing_sensor_, idx), DEVICE_DT_NAME_GET(node))
318#define SENSING_SENSOR_DEFINE(node, prop, idx, reg_ptr, cb_list_ptr) \
319 SENSING_SENSOR_INFO_DEFINE(node, idx) \
320 SENSING_SENSOR_IODEV_DEFINE(node, idx) \
321 STRUCT_SECTION_ITERABLE(sensing_sensor, \
322 SENSING_SENSOR_NAME(node, idx)) = { \
323 .dev = DEVICE_DT_GET(node), \
324 .info = &SENSING_SENSOR_INFO_NAME(node, idx), \
325 .register_info = reg_ptr, \
326 .reporter_num = DT_PROP_LEN_OR(node, reporters, 0), \
327 .conns = SENSING_CONNECTIONS_NAME(node), \
328 .iodev = &SENSING_SENSOR_IODEV_NAME(node, idx), \
341#define SENSING_SENSORS_DEFINE(node, reg_ptr, cb_list_ptr) \
342 DT_FOREACH_PROP_ELEM_VARGS(node, sensor_types, \
343 SENSING_SENSOR_DEFINE, reg_ptr, cb_list_ptr)
369#define SENSING_SENSORS_DT_DEFINE(node, reg_ptr, cb_list_ptr, \
370 init_fn, pm_device, \
371 data_ptr, cfg_ptr, level, prio, \
373 SENSOR_DEVICE_DT_DEFINE(node, init_fn, pm_device, \
374 data_ptr, cfg_ptr, level, prio, \
375 api_ptr, __VA_ARGS__); \
376 SENSING_CONNECTIONS_DEFINE(node, \
377 DT_PROP_LEN_OR(node, reporters, 0), \
379 SENSING_SENSORS_DEFINE(node, reg_ptr, cb_list_ptr);
389#define SENSING_SENSORS_DT_INST_DEFINE(inst, ...) \
390 SENSING_SENSORS_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
405 const struct device *dev,
int type,
416 const struct device *dev,
int type);
long atomic_t
Definition: atomic_types.h:15
sensing_sensor_state
Sensing subsystem sensor state.
Definition: sensing.h:89
void * sensing_sensor_handle_t
Define Sensing subsystem sensor handle.
Definition: sensing.h:113
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_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_state(const struct device *dev, enum sensing_sensor_state *state)
Get this sensor's state.
sensor_channel
Sensor channels.
Definition: sensor.h:61
struct _slist sys_slist_t
Single-linked list structure.
Definition: slist.h:49
struct _snode sys_snode_t
Single-linked list node structure.
Definition: slist.h:39
state
Definition: parser_state.h:29
Public APIs for the sensor driver.
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT64_TYPE__ uint64_t
Definition: stdint.h:91
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition: device.h:403
API that an RTIO IO device should implement.
Definition: rtio.h:433
An IO device with a function table for submitting requests.
Definition: rtio.h:448
A submission queue event.
Definition: rtio.h:232
Sensing subsystem event callback list.
Definition: sensing.h:157
Sensor basic constant information.
Definition: sensing.h:132
Sensor registration information.
Definition: sensing_sensor.h:36
uint16_t sample_size
Sample size in bytes for a single sample of the registered sensor.
Definition: sensing_sensor.h:46
uint16_t flags
Sensor flags.
Definition: sensing_sensor.h:40
uint8_t sensitivity_count
The number of sensor sensitivities.
Definition: sensing_sensor.h:51
struct sensing_sensor_version version
Sensor version.
Definition: sensing_sensor.h:57
Sensor Version.
Definition: sensing.h:39