8
8
#define ZEPHYR_INCLUDE_SENSING_H_
9
9
10
10
/**
11
- * @defgroup sensing Sensing
12
- * @defgroup sensing_api Sensing Subsystem API
13
- * @ingroup sensing
14
- * @defgroup sensing_sensor_types Sensor Types
15
- * @ingroup sensing
16
- * @defgroup sensing_datatypes Data Types
17
- * @ingroup sensing
11
+ * @defgroup sensing_api Sensing
12
+ * @brief High-level sensor framework.
13
+ * @ingroup os_services
14
+ *
15
+ * The Sensing subsystem provides a high-level API for applications to discover sensors, open sensor
16
+ * instances, configure reporting behavior, and receive sampled data via callbacks.
17
+ * For low-level sensor access, see @ref sensor_interface.
18
+ *
19
+ * @{
18
20
*/
19
21
20
22
#include <zephyr/sensing/sensing_datatypes.h>
21
23
#include <zephyr/sensing/sensing_sensor_types.h>
22
24
#include <zephyr/device.h>
23
25
24
- /**
25
- * @brief Sensing Subsystem API
26
- * @addtogroup sensing_api
27
- * @{
28
- */
29
-
30
26
#ifdef __cplusplus
31
27
extern "C" {
32
28
#endif
33
29
34
-
35
30
/**
36
- * @struct sensing_sensor_version
37
31
* @brief Sensor Version
38
32
*/
39
33
struct sensing_sensor_version {
@@ -49,85 +43,119 @@ struct sensing_sensor_version {
49
43
};
50
44
51
45
/**
52
- * @brief Macro to create a sensor version value.
46
+ * @brief Build a packed @ref sensing_sensor_version value.
53
47
*
48
+ * @param _major Major version.
49
+ * @param _minor Minor version.
50
+ * @param _hotfix Hotfix version.
51
+ * @param _build Build number.
52
+ * @return 32-bit packed version value
54
53
*/
55
54
#define SENSING_SENSOR_VERSION (_major , _minor , _hotfix , _build ) \
56
55
(FIELD_PREP(GENMASK(31, 24), _major) | \
57
56
FIELD_PREP(GENMASK(23, 16), _minor) | \
58
57
FIELD_PREP(GENMASK(15, 8), _hotfix) | \
59
58
FIELD_PREP(GENMASK(7, 0), _build))
60
59
60
+ /**
61
+ * @name Sensor reporting flags
62
+ * @{
63
+ */
61
64
62
65
/**
63
- * @brief Sensor flag indicating if this sensor is on event reporting data.
66
+ * @brief Sensor flag indicating if this sensor is reporting data on event .
64
67
*
65
68
* Reporting sensor data when the sensor event occurs, such as a motion detect sensor reporting
66
69
* a motion or motionless detected event.
70
+ *
71
+ * @note Mutually exclusive with \ref SENSING_SENSOR_FLAG_REPORT_ON_CHANGE
67
72
*/
68
73
#define SENSING_SENSOR_FLAG_REPORT_ON_EVENT BIT(0)
69
74
70
75
/**
71
- * @brief Sensor flag indicating if this sensor is on change reporting data.
76
+ * @brief Sensor flag indicating if this sensor is reporting data on change .
72
77
*
73
78
* Reporting sensor data when the sensor data changes.
74
79
*
75
- * Exclusive with \ref SENSING_SENSOR_FLAG_REPORT_ON_EVENT
80
+ * @note Mutually exclusive with \ref SENSING_SENSOR_FLAG_REPORT_ON_EVENT
76
81
*/
77
82
#define SENSING_SENSOR_FLAG_REPORT_ON_CHANGE BIT(1)
78
83
84
+ /** @} */
85
+
79
86
/**
80
- * @brief SENSING_SENSITIVITY_INDEX_ALL indicating sensitivity of each data field should be set
87
+ * @brief Sentinel index meaning "apply to all data fields".
81
88
*
89
+ * Used with sensitivity configuration where a sensor provides multiple fields in a single sample.
82
90
*/
83
91
#define SENSING_SENSITIVITY_INDEX_ALL -1
84
92
85
93
/**
86
- * @brief Sensing subsystem sensor state.
94
+ * @brief Sensor state.
87
95
*
96
+ * This enumeration defines the possible states of a sensor.
88
97
*/
89
98
enum sensing_sensor_state {
90
99
SENSING_SENSOR_STATE_READY = 0 , /**< The sensor is ready. */
91
100
SENSING_SENSOR_STATE_OFFLINE = 1 , /**< The sensor is offline. */
92
101
};
93
102
94
103
/**
95
- * @brief Sensing subsystem sensor config attribute
104
+ * @brief Sensor configuration attribute.
96
105
*
106
+ * This enumeration defines the possible attributes of a sensor configuration.
97
107
*/
98
108
enum sensing_sensor_attribute {
99
- /** The interval attribute of a sensor configuration. */
109
+ /**
110
+ * Reporting interval between samples, in microseconds (us).
111
+ *
112
+ * See @ref sensing_sensor_config::interval.
113
+ */
100
114
SENSING_SENSOR_ATTRIBUTE_INTERVAL = 0 ,
101
- /** The sensitivity attribute of a sensor configuration. */
115
+
116
+ /**
117
+ * Per-field sensitivity threshold.
118
+ *
119
+ * See @ref sensing_sensor_config::sensitivity.
120
+ */
102
121
SENSING_SENSOR_ATTRIBUTE_SENSITIVITY = 1 ,
103
- /** The latency attribute of a sensor configuration. */
122
+
123
+ /**
124
+ * Maximum batching latency, in microseconds (us).
125
+ *
126
+ * See @ref sensing_sensor_config::latency.
127
+ */
104
128
SENSING_SENSOR_ATTRIBUTE_LATENCY = 2 ,
105
- /** The maximum number of attributes that a sensor configuration can have. */
129
+
130
+ /** Number of supported attributes. */
106
131
SENSING_SENSOR_ATTRIBUTE_MAX ,
107
132
};
108
133
109
134
/**
110
- * @brief Define Sensing subsystem sensor handle
135
+ * @brief Opaque handle to an opened sensor instance.
111
136
*
137
+ * A valid handle is obtained from @ref sensing_open_sensor or @ref sensing_open_sensor_by_dt and
138
+ * must be closed with @ref sensing_close_sensor when no longer needed.
112
139
*/
113
140
typedef void * sensing_sensor_handle_t ;
114
141
115
142
/**
116
- * @brief Sensor data event receive callback.
143
+ * @brief Data event callback signature .
117
144
*
118
- * @param handle The sensor instance handle.
119
- * @param buf The data buffer with sensor data.
120
- * @param context User provided context pointer.
145
+ * The Sensing subsystem invokes this callback to deliver buffered samples for the opened sensor.
146
+ *
147
+ * @param handle Sensor instance handle passed to @ref sensing_open_sensor.
148
+ * @param buf Pointer to a sensor-type-specific sample buffer; see @ref sensing_datatypes and
149
+ * @ref sensing_sensor_types.
150
+ * @param context User context pointer as provided in @ref sensing_callback_list::context.
121
151
*/
122
152
typedef void (* sensing_data_event_t )(
123
153
sensing_sensor_handle_t handle ,
124
154
const void * buf ,
125
155
void * context );
126
156
127
157
/**
128
- * @struct sensing_sensor_info
129
- * @brief Sensor basic constant information
130
- *
158
+ * @brief Read-only description of a sensor instance.
131
159
*/
132
160
struct sensing_sensor_info {
133
161
/** Name of the sensor instance */
@@ -154,9 +182,13 @@ struct sensing_sensor_info {
154
182
* @brief Sensing subsystem event callback list
155
183
*
156
184
*/
185
+
186
+ /**
187
+ * @brief Callback registration for a sensor instance.
188
+ */
157
189
struct sensing_callback_list {
158
190
sensing_data_event_t on_data_event ; /**< Callback function for a sensor data event. */
159
- void * context ; /**< Associated context with on_data_event */
191
+ void * context ; /**< Context that will be passed to the callback. */
160
192
};
161
193
162
194
/**
0 commit comments