Skip to content

Commit 35a5611

Browse files
committed
include: sensing: doc: documentation improvements
- 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 afc739e commit 35a5611

File tree

2 files changed

+57
-22
lines changed

2 files changed

+57
-22
lines changed

include/zephyr/sensing/sensing.h

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ extern "C" {
3232
#endif
3333

3434
/**
35-
* @struct sensing_sensor_version
3635
* @brief Sensor Version
3736
*/
3837
struct sensing_sensor_version {
@@ -48,85 +47,117 @@ struct sensing_sensor_version {
4847
};
4948

5049
/**
51-
* @brief Macro to create a sensor version value.
50+
* @brief Build a packed @ref sensing_sensor_version value.
5251
*
52+
* @param _major Major version.
53+
* @param _minor Minor version.
54+
* @param _hotfix Hotfix version.
55+
* @param _build Build number.
56+
* @return 32-bit packed version value
5357
*/
5458
#define SENSING_SENSOR_VERSION(_major, _minor, _hotfix, _build) \
5559
(FIELD_PREP(GENMASK(31, 24), _major) | \
5660
FIELD_PREP(GENMASK(23, 16), _minor) | \
5761
FIELD_PREP(GENMASK(15, 8), _hotfix) | \
5862
FIELD_PREP(GENMASK(7, 0), _build))
5963

64+
/**
65+
* @name Sensor reporting flags
66+
* @{
67+
*/
6068

6169
/**
62-
* @brief Sensor flag indicating if this sensor is on event reporting data.
70+
* @brief Sensor flag indicating if this sensor is reporting data on event.
6371
*
6472
* Reporting sensor data when the sensor event occurs, such as a motion detect sensor reporting
6573
* a motion or motionless detected event.
6674
*/
6775
#define SENSING_SENSOR_FLAG_REPORT_ON_EVENT BIT(0)
6876

6977
/**
70-
* @brief Sensor flag indicating if this sensor is on change reporting data.
78+
* @brief Sensor flag indicating if this sensor is reporting data on change.
7179
*
7280
* Reporting sensor data when the sensor data changes.
7381
*
74-
* Exclusive with \ref SENSING_SENSOR_FLAG_REPORT_ON_EVENT
82+
* @note Mutually exclusive with \ref SENSING_SENSOR_FLAG_REPORT_ON_EVENT
7583
*/
7684
#define SENSING_SENSOR_FLAG_REPORT_ON_CHANGE BIT(1)
7785

86+
/** @} */
87+
7888
/**
79-
* @brief SENSING_SENSITIVITY_INDEX_ALL indicating sensitivity of each data field should be set
89+
* @brief Sentinel index meaning "apply to all data fields".
8090
*
91+
* Used with sensitivity configuration where a sensor provides multiple fields in a single sample.
8192
*/
8293
#define SENSING_SENSITIVITY_INDEX_ALL -1
8394

8495
/**
85-
* @brief Sensing subsystem sensor state.
96+
* @brief Sensor state.
8697
*
98+
* This enumeration defines the possible states of a sensor.
8799
*/
88100
enum sensing_sensor_state {
89101
SENSING_SENSOR_STATE_READY = 0, /**< The sensor is ready. */
90102
SENSING_SENSOR_STATE_OFFLINE = 1, /**< The sensor is offline. */
91103
};
92104

93105
/**
94-
* @brief Sensing subsystem sensor config attribute
106+
* @brief Sensor configuration attribute.
95107
*
108+
* This enumeration defines the possible attributes of a sensor configuration.
96109
*/
97110
enum sensing_sensor_attribute {
98-
/** The interval attribute of a sensor configuration. */
111+
/**
112+
* Reporting interval between samples, in microseconds (us).
113+
*
114+
* See @ref sensing_sensor_config::interval.
115+
*/
99116
SENSING_SENSOR_ATTRIBUTE_INTERVAL = 0,
100-
/** The sensitivity attribute of a sensor configuration. */
117+
118+
/**
119+
* Per-field sensitivity threshold.
120+
*
121+
* See @ref sensing_sensor_config::sensitivity.
122+
*/
101123
SENSING_SENSOR_ATTRIBUTE_SENSITIVITY = 1,
102-
/** The latency attribute of a sensor configuration. */
124+
125+
/**
126+
* Maximum batching latency, in microseconds (us).
127+
*
128+
* See @ref sensing_sensor_config::latency.
129+
*/
103130
SENSING_SENSOR_ATTRIBUTE_LATENCY = 2,
104-
/** The maximum number of attributes that a sensor configuration can have. */
131+
132+
/** Number of supported attributes. */
105133
SENSING_SENSOR_ATTRIBUTE_MAX,
106134
};
107135

108136
/**
109-
* @brief Define Sensing subsystem sensor handle
137+
* @brief Opaque handle to an opened sensor instance.
110138
*
139+
* A valid handle is obtained from @ref sensing_open_sensor or @ref sensing_open_sensor_by_dt and
140+
* must be closed with @ref sensing_close_sensor when no longer needed.
111141
*/
112142
typedef void *sensing_sensor_handle_t;
113143

114144
/**
115-
* @brief Sensor data event receive callback.
145+
* @brief Data event callback signature.
116146
*
117-
* @param handle The sensor instance handle.
118-
* @param buf The data buffer with sensor data.
119-
* @param context User provided context pointer.
147+
* The Sensing subsystem invokes this callback to deliver buffered samples for the opened sensor.
148+
*
149+
* @param handle Sensor instance handle passed to @ref sensing_open_sensor.
150+
* @param buf Pointer to a sensor-type-specific sample buffer; see @ref sensing_datatypes and
151+
* @ref sensing_sensor_types.
152+
* @param context User context pointer as provided in @ref sensing_callback_list::context.
120153
*/
121154
typedef void (*sensing_data_event_t)(
122155
sensing_sensor_handle_t handle,
123156
const void *buf,
124157
void *context);
125158

126159
/**
127-
* @struct sensing_sensor_info
128-
* @brief Sensor basic constant information
129-
*
160+
* @brief Read-only description of a sensor instance.
130161
*/
131162
struct sensing_sensor_info {
132163
/** Name of the sensor instance */
@@ -153,9 +184,13 @@ struct sensing_sensor_info {
153184
* @brief Sensing subsystem event callback list
154185
*
155186
*/
187+
188+
/**
189+
* @brief Callback registration for a sensor instance.
190+
*/
156191
struct sensing_callback_list {
157192
sensing_data_event_t on_data_event; /**< Callback function for a sensor data event. */
158-
void *context; /**< Associated context with on_data_event */
193+
void *context; /**< Context that will be passed to the callback. */
159194
};
160195

161196
/**

include/zephyr/sensing/sensing_sensor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ extern const struct rtio_iodev_api __sensing_iodev_api;
384384
SENSING_SENSORS_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
385385

386386
/**
387-
* @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.
388388
*
389389
* @param dev The sensor instance device structure.
390390
* @param type The given type, \ref SENSING_SENSOR_TYPE_ALL to get reporters

0 commit comments

Comments
 (0)