Skip to content

Commit aade89e

Browse files
committed
include: sensing: doc: documentation improvements
- Move sensing documentation in the "OS Services" group and clean up group declarations - Add missing documentation for the Sensing Subsystem API and complete existing docs when it was too terse - Other grammar/cosmetic improvements Signed-off-by: Benjamin Cabé <[email protected]>
1 parent e4e6926 commit aade89e

File tree

5 files changed

+80
-55
lines changed

5 files changed

+80
-55
lines changed

doc/services/sensing/index.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,4 @@ See the example :zephyr_file:`samples/subsys/sensing/simple/boards/native_sim.ov
246246
API Reference
247247
*************
248248

249-
.. doxygengroup:: sensing_sensor_types
250-
.. doxygengroup:: sensing_datatypes
251249
.. doxygengroup:: sensing_api
252-
.. doxygengroup:: sensing_sensor

include/zephyr/sensing/sensing.h

Lines changed: 67 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,26 @@
88
#define ZEPHYR_INCLUDE_SENSING_H_
99

1010
/**
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+
* @{
1820
*/
1921

2022
#include <zephyr/sensing/sensing_datatypes.h>
2123
#include <zephyr/sensing/sensing_sensor_types.h>
2224
#include <zephyr/device.h>
2325

24-
/**
25-
* @brief Sensing Subsystem API
26-
* @addtogroup sensing_api
27-
* @{
28-
*/
29-
3026
#ifdef __cplusplus
3127
extern "C" {
3228
#endif
3329

34-
3530
/**
36-
* @struct sensing_sensor_version
3731
* @brief Sensor Version
3832
*/
3933
struct sensing_sensor_version {
@@ -49,85 +43,119 @@ struct sensing_sensor_version {
4943
};
5044

5145
/**
52-
* @brief Macro to create a sensor version value.
46+
* @brief Build a packed @ref sensing_sensor_version value.
5347
*
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
5453
*/
5554
#define SENSING_SENSOR_VERSION(_major, _minor, _hotfix, _build) \
5655
(FIELD_PREP(GENMASK(31, 24), _major) | \
5756
FIELD_PREP(GENMASK(23, 16), _minor) | \
5857
FIELD_PREP(GENMASK(15, 8), _hotfix) | \
5958
FIELD_PREP(GENMASK(7, 0), _build))
6059

60+
/**
61+
* @name Sensor reporting flags
62+
* @{
63+
*/
6164

6265
/**
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.
6467
*
6568
* Reporting sensor data when the sensor event occurs, such as a motion detect sensor reporting
6669
* a motion or motionless detected event.
70+
*
71+
* @note Mutually exclusive with \ref SENSING_SENSOR_FLAG_REPORT_ON_CHANGE
6772
*/
6873
#define SENSING_SENSOR_FLAG_REPORT_ON_EVENT BIT(0)
6974

7075
/**
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.
7277
*
7378
* Reporting sensor data when the sensor data changes.
7479
*
75-
* Exclusive with \ref SENSING_SENSOR_FLAG_REPORT_ON_EVENT
80+
* @note Mutually exclusive with \ref SENSING_SENSOR_FLAG_REPORT_ON_EVENT
7681
*/
7782
#define SENSING_SENSOR_FLAG_REPORT_ON_CHANGE BIT(1)
7883

84+
/** @} */
85+
7986
/**
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".
8188
*
89+
* Used with sensitivity configuration where a sensor provides multiple fields in a single sample.
8290
*/
8391
#define SENSING_SENSITIVITY_INDEX_ALL -1
8492

8593
/**
86-
* @brief Sensing subsystem sensor state.
94+
* @brief Sensor state.
8795
*
96+
* This enumeration defines the possible states of a sensor.
8897
*/
8998
enum sensing_sensor_state {
9099
SENSING_SENSOR_STATE_READY = 0, /**< The sensor is ready. */
91100
SENSING_SENSOR_STATE_OFFLINE = 1, /**< The sensor is offline. */
92101
};
93102

94103
/**
95-
* @brief Sensing subsystem sensor config attribute
104+
* @brief Sensor configuration attribute.
96105
*
106+
* This enumeration defines the possible attributes of a sensor configuration.
97107
*/
98108
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+
*/
100114
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+
*/
102121
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+
*/
104128
SENSING_SENSOR_ATTRIBUTE_LATENCY = 2,
105-
/** The maximum number of attributes that a sensor configuration can have. */
129+
130+
/** Number of supported attributes. */
106131
SENSING_SENSOR_ATTRIBUTE_MAX,
107132
};
108133

109134
/**
110-
* @brief Define Sensing subsystem sensor handle
135+
* @brief Opaque handle to an opened sensor instance.
111136
*
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.
112139
*/
113140
typedef void *sensing_sensor_handle_t;
114141

115142
/**
116-
* @brief Sensor data event receive callback.
143+
* @brief Data event callback signature.
117144
*
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.
121151
*/
122152
typedef void (*sensing_data_event_t)(
123153
sensing_sensor_handle_t handle,
124154
const void *buf,
125155
void *context);
126156

127157
/**
128-
* @struct sensing_sensor_info
129-
* @brief Sensor basic constant information
130-
*
158+
* @brief Read-only description of a sensor instance.
131159
*/
132160
struct sensing_sensor_info {
133161
/** Name of the sensor instance */
@@ -154,9 +182,13 @@ struct sensing_sensor_info {
154182
* @brief Sensing subsystem event callback list
155183
*
156184
*/
185+
186+
/**
187+
* @brief Callback registration for a sensor instance.
188+
*/
157189
struct sensing_callback_list {
158190
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. */
160192
};
161193

162194
/**

include/zephyr/sensing/sensing_datatypes.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
#include <zephyr/dsp/types.h>
1212

1313
/**
14-
* @brief Data Types
15-
* @addtogroup sensing_datatypes
14+
* @defgroup sensing_datatypes Data Types
15+
* @ingroup sensing_api
16+
* @brief Sensor data structures used by the sensing subsystem
17+
*
1618
* @{
1719
*/
1820

1921
/**
20-
* @struct sensing_sensor_value_header
21-
* @brief sensor value header
22+
* @brief Common header for all sensor value payloads.
2223
*
2324
* Each sensor value data structure should have this header
2425
*

include/zephyr/sensing/sensing_sensor.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,9 @@
1313
#include <zephyr/sensing/sensing.h>
1414

1515
/**
16-
* @defgroup sensing_sensor Sensing Sensor API
17-
* @ingroup sensing
18-
* @defgroup sensing_sensor_callbacks Sensor Callbacks
19-
* @ingroup sensing_sensor
20-
*/
21-
22-
/**
23-
* @brief Sensing Sensor API
24-
* @addtogroup sensing_sensor
16+
* @brief Interfaces to manipulate sensors in the sensing subsystem
17+
* @defgroup sensing_sensor Sensors (Sensing)
18+
* @ingroup sensing_api
2519
* @{
2620
*/
2721

@@ -390,7 +384,7 @@ extern const struct rtio_iodev_api __sensing_iodev_api;
390384
SENSING_SENSORS_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
391385

392386
/**
393-
* @brief Get reporter handles of a given sensor instance by sensor type.
387+
* @brief Get reporter handles of a given sensor instance by sensor type.
394388
*
395389
* @param dev The sensor instance device structure.
396390
* @param type The given type, \ref SENSING_SENSOR_TYPE_ALL to get reporters

include/zephyr/sensing/sensing_sensor_types.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
#define ZEPHYR_INCLUDE_SENSING_SENSOR_TYPES_H_
99

1010
/**
11-
* @brief Sensor Types Definition
11+
* @defgroup sensing_sensor_types Sensor Types (Sensing)
12+
* @ingroup sensing_api
13+
*
14+
* @brief Sensor type identifiers used by the sensing subsystem.
1215
*
1316
* Sensor types definition followed HID standard.
1417
* https://usb.org/sites/default/files/hutrr39b_0.pdf
1518
*
1619
* TODO: will add more types
17-
*
18-
* @addtogroup sensing_sensor_types
1920
* @{
2021
*/
2122

0 commit comments

Comments
 (0)