Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
sensing.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022-2023 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_SENSING_H_
8#define ZEPHYR_INCLUDE_SENSING_H_
9
22#include <zephyr/device.h>
23
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34
50
55#define SENSING_SENSOR_VERSION(_major, _minor, _hotfix, _build) \
56 (FIELD_PREP(GENMASK(31, 24), _major) | \
57 FIELD_PREP(GENMASK(23, 16), _minor) | \
58 FIELD_PREP(GENMASK(15, 8), _hotfix) | \
59 FIELD_PREP(GENMASK(7, 0), _build))
60
61
68#define SENSING_SENSOR_FLAG_REPORT_ON_EVENT BIT(0)
69
77#define SENSING_SENSOR_FLAG_REPORT_ON_CHANGE BIT(1)
78
83#define SENSING_SENSITIVITY_INDEX_ALL -1
84
93
108
114
122typedef void (*sensing_data_event_t)(
124 const void *buf,
125 void *context);
126
134 const char *name;
135
137 const char *friendly_name;
138
140 const char *vendor;
141
143 const char *model;
144
147
150};
151
161
192
204int sensing_get_sensors(int *num_sensors, const struct sensing_sensor_info **info);
205
221 const struct sensing_sensor_info *info,
222 struct sensing_callback_list *cb_list,
224
240 const struct device *dev, struct sensing_callback_list *cb_list,
242
251
262 struct sensing_sensor_config *configs, int count);
263
274 struct sensing_sensor_config *configs, int count);
275
284
285#ifdef __cplusplus
286}
287#endif
288
293#endif /*ZEPHYR_INCLUDE_SENSING_H_*/
ZTEST_BMEM int count
Definition main.c:33
int sensing_open_sensor_by_dt(const struct device *dev, struct sensing_callback_list *cb_list, sensing_sensor_handle_t *handle)
Open sensor instance by device.
const struct sensing_sensor_info * sensing_get_sensor_info(sensing_sensor_handle_t handle)
Get sensor information from sensor instance handle.
int sensing_set_config(sensing_sensor_handle_t handle, struct sensing_sensor_config *configs, int count)
Set current config items to Sensing subsystem.
void(* sensing_data_event_t)(sensing_sensor_handle_t handle, const void *buf, void *context)
Sensor data event receive callback.
Definition sensing.h:122
sensing_sensor_attribute
Sensing subsystem sensor config attribute.
Definition sensing.h:98
int sensing_open_sensor(const struct sensing_sensor_info *info, struct sensing_callback_list *cb_list, sensing_sensor_handle_t *handle)
Open sensor instance by sensing sensor info.
int sensing_close_sensor(sensing_sensor_handle_t *handle)
Close sensor instance.
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_get_sensors(int *num_sensors, const struct sensing_sensor_info **info)
Get all supported sensor instances' information.
int sensing_get_config(sensing_sensor_handle_t handle, struct sensing_sensor_config *configs, int count)
Get current config items from Sensing subsystem.
@ SENSING_SENSOR_ATTRIBUTE_MAX
The maximum number of attributes that a sensor configuration can have.
Definition sensing.h:106
@ SENSING_SENSOR_ATTRIBUTE_LATENCY
The latency attribute of a sensor configuration.
Definition sensing.h:104
@ SENSING_SENSOR_ATTRIBUTE_INTERVAL
The interval attribute of a sensor configuration.
Definition sensing.h:100
@ SENSING_SENSOR_ATTRIBUTE_SENSITIVITY
The sensitivity attribute of a sensor configuration.
Definition sensing.h:102
@ SENSING_SENSOR_STATE_READY
The sensor is ready.
Definition sensing.h:90
@ SENSING_SENSOR_STATE_OFFLINE
The sensor is offline.
Definition sensing.h:91
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__INT32_TYPE__ int32_t
Definition stdint.h:74
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__INT8_TYPE__ int8_t
Definition stdint.h:72
Runtime device structure (in ROM) per driver instance.
Definition device.h:403
Sensing subsystem event callback list.
Definition sensing.h:157
void * context
Associated context with on_data_event.
Definition sensing.h:159
sensing_data_event_t on_data_event
Callback function for a sensor data event.
Definition sensing.h:158
Sensing subsystem sensor configure, including interval, sensitivity, latency.
Definition sensing.h:167
uint32_t interval
Interval between two sensor samples in microseconds (us).
Definition sensing.h:175
enum sensing_sensor_attribute attri
Attribute of the sensor configuration.
Definition sensing.h:168
int8_t data_field
SENSING_SENSITIVITY_INDEX_ALL
Definition sensing.h:171
uint32_t sensitivity
Sensitivity threshold for reporting new data.
Definition sensing.h:182
uint64_t latency
Maximum duration for batching sensor samples before reporting in microseconds (us).
Definition sensing.h:189
Sensor basic constant information.
Definition sensing.h:132
const char * vendor
Vendor name of the sensor instance.
Definition sensing.h:140
const uint32_t minimal_interval
Minimal report interval in micro seconds.
Definition sensing.h:149
const int32_t type
Sensor type.
Definition sensing.h:146
const char * friendly_name
Friendly name of the sensor instance.
Definition sensing.h:137
const char * name
Name of the sensor instance.
Definition sensing.h:134
const char * model
Model name of the sensor instance.
Definition sensing.h:143
Sensor Version.
Definition sensing.h:39
uint32_t value
The version represented as a 32-bit value.
Definition sensing.h:41
uint8_t hotfix
The hotfix version number.
Definition sensing.h:45
uint8_t build
The build version number.
Definition sensing.h:46
uint8_t minor
The minor version number.
Definition sensing.h:44
uint8_t major
The major version number.
Definition sensing.h:43