@@ -38,16 +38,20 @@ extern "C" {
3838 */
3939struct sensing_sensor_version {
4040 union {
41- uint32_t value ;
41+ uint32_t value ; /**< The version represented as a 32-bit value. */
4242 struct {
43- uint8_t major ;
44- uint8_t minor ;
45- uint8_t hotfix ;
46- uint8_t build ;
43+ uint8_t major ; /**< The major version number. */
44+ uint8_t minor ; /**< The minor version number. */
45+ uint8_t hotfix ; /**< The hotfix version number. */
46+ uint8_t build ; /**< The build version number. */
4747 };
4848 };
4949};
5050
51+ /**
52+ * @brief Macro to create a sensor version value.
53+ *
54+ */
5155#define SENSING_SENSOR_VERSION (_major , _minor , _hotfix , _build ) \
5256 (FIELD_PREP(GENMASK(31, 24), _major) | \
5357 FIELD_PREP(GENMASK(23, 16), _minor) | \
@@ -83,36 +87,36 @@ struct sensing_sensor_version {
8387 *
8488 */
8589enum sensing_sensor_state {
86- SENSING_SENSOR_STATE_READY = 0 ,
87- SENSING_SENSOR_STATE_OFFLINE = 1 ,
90+ SENSING_SENSOR_STATE_READY = 0 , /**< The sensor is ready. */
91+ SENSING_SENSOR_STATE_OFFLINE = 1 , /**< The sensor is offline. */
8892};
8993
9094/**
9195 * @brief Sensing subsystem sensor config attribute
9296 *
9397 */
9498enum sensing_sensor_attribute {
99+ /** The interval attribute of a sensor configuration. */
95100 SENSING_SENSOR_ATTRIBUTE_INTERVAL = 0 ,
101+ /** The sensitivity attribute of a sensor configuration. */
96102 SENSING_SENSOR_ATTRIBUTE_SENSITIVITY = 1 ,
103+ /** The latency attribute of a sensor configuration. */
97104 SENSING_SENSOR_ATTRIBUTE_LATENCY = 2 ,
105+ /** The maximum number of attributes that a sensor configuration can have. */
98106 SENSING_SENSOR_ATTRIBUTE_MAX ,
99107};
100108
101-
102109/**
103110 * @brief Define Sensing subsystem sensor handle
104111 *
105112 */
106113typedef void * sensing_sensor_handle_t ;
107114
108-
109115/**
110116 * @brief Sensor data event receive callback.
111117 *
112118 * @param handle The sensor instance handle.
113- *
114119 * @param buf The data buffer with sensor data.
115- *
116120 * @param context User provided context pointer.
117121 */
118122typedef void (* sensing_data_event_t )(
@@ -151,41 +155,52 @@ struct sensing_sensor_info {
151155 *
152156 */
153157struct sensing_callback_list {
154- sensing_data_event_t on_data_event ;
155- void * context ;
158+ sensing_data_event_t on_data_event ; /**< Callback function for a sensor data event. */
159+ void * context ; /**< Associated context with on_data_event */
156160};
161+
157162/**
158163 * @struct sensing_sensor_config
159164 * @brief Sensing subsystem sensor configure, including interval, sensitivity, latency
160165 *
161166 */
162167struct sensing_sensor_config {
163- enum sensing_sensor_attribute attri ;
168+ enum sensing_sensor_attribute attri ; /**< Attribute of the sensor configuration. */
164169
165170 /** \ref SENSING_SENSITIVITY_INDEX_ALL */
166- int8_t data_field ;
171+ int8_t data_field ; /**< Data field of the sensor configuration. */
167172
168173 union {
174+ /** Interval between two sensor samples in microseconds (us). */
169175 uint32_t interval ;
176+
177+ /**
178+ * Sensitivity threshold for reporting new data. A new sensor sample is reported
179+ * only if the difference between it and the previous sample exceeds this
180+ * sensitivity value.
181+ */
170182 uint32_t sensitivity ;
183+
184+ /**
185+ * Maximum duration for batching sensor samples before reporting in
186+ * microseconds (us). This defines how long sensor samples can be
187+ * accumulated before they must be reported.
188+ */
171189 uint64_t latency ;
172190 };
173191};
174192
175-
176- /**
177- * @brief Get all supported sensor instances' information.
178- *
179- * This API just returns read only information of sensor instances, pointer info will
180- * directly point to internal buffer, no need for caller to allocate buffer,
181- * no side effect to sensor instances.
182- *
183- * @param num_sensors Get number of sensor instances.
184- *
185- * @param info For receiving sensor instances' information array pointer.
186- *
187- * @return 0 on success or negative error value on failure.
188- */
193+ /**
194+ * @brief Get all supported sensor instances' information.
195+ *
196+ * This API just returns read only information of sensor instances, pointer info will
197+ * directly point to internal buffer, no need for caller to allocate buffer,
198+ * no side effect to sensor instances.
199+ *
200+ * @param num_sensors Get number of sensor instances.
201+ * @param info For receiving sensor instances' information array pointer.
202+ * @return 0 on success or negative error value on failure.
203+ */
189204int sensing_get_sensors (int * num_sensors , const struct sensing_sensor_info * * info );
190205
191206/**
@@ -197,12 +212,9 @@ int sensing_get_sensors(int *num_sensors, const struct sensing_sensor_info **inf
197212 * meanwhile, also register sensing callback list
198213 *
199214 * @param info The sensor info got from \ref sensing_get_sensors
200- *
201215 * @param cb_list callback list to be registered to sensing, must have a static
202216 * lifetime.
203- *
204217 * @param handle The opened instance handle, if failed will be set to NULL.
205- *
206218 * @return 0 on success or negative error value on failure.
207219 */
208220int sensing_open_sensor (
@@ -219,12 +231,9 @@ int sensing_open_sensor(
219231 * meanwhile, also register sensing callback list.
220232 *
221233 * @param dev pointer device get from device tree.
222- *
223234 * @param cb_list callback list to be registered to sensing, must have a static
224235 * lifetime.
225- *
226236 * @param handle The opened instance handle, if failed will be set to NULL.
227- *
228237 * @return 0 on success or negative error value on failure.
229238 */
230239int sensing_open_sensor_by_dt (
@@ -235,7 +244,6 @@ int sensing_open_sensor_by_dt(
235244 * @brief Close sensor instance.
236245 *
237246 * @param handle The sensor instance handle need to close.
238- *
239247 * @return 0 on success or negative error value on failure.
240248 */
241249int sensing_close_sensor (
@@ -245,11 +253,8 @@ int sensing_close_sensor(
245253 * @brief Set current config items to Sensing subsystem.
246254 *
247255 * @param handle The sensor instance handle.
248- *
249256 * @param configs The configs to be set according to config attribute.
250- *
251257 * @param count count of configs.
252- *
253258 * @return 0 on success or negative error value on failure, not support etc.
254259 */
255260int sensing_set_config (
@@ -260,11 +265,8 @@ int sensing_set_config(
260265 * @brief Get current config items from Sensing subsystem.
261266 *
262267 * @param handle The sensor instance handle.
263- *
264268 * @param configs The configs to be get according to config attribute.
265- *
266269 * @param count count of configs.
267- *
268270 * @return 0 on success or negative error value on failure, not support etc.
269271 */
270272int sensing_get_config (
@@ -275,7 +277,6 @@ int sensing_get_config(
275277 * @brief Get sensor information from sensor instance handle.
276278 *
277279 * @param handle The sensor instance handle.
278- *
279280 * @return a const pointer to \ref sensing_sensor_info on success or NULL on failure.
280281 */
281282const struct sensing_sensor_info * sensing_get_sensor_info (
@@ -289,5 +290,4 @@ const struct sensing_sensor_info *sensing_get_sensor_info(
289290 * @}
290291 */
291292
292-
293293#endif /*ZEPHYR_INCLUDE_SENSING_H_*/
0 commit comments