Skip to content

Commit e043d46

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 e043d46

File tree

2 files changed

+59
-22
lines changed

2 files changed

+59
-22
lines changed

include/zephyr/sensing/sensing.h

Lines changed: 58 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,119 @@ 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.
74+
*
75+
* @note Mutually exclusive with \ref SENSING_SENSOR_FLAG_REPORT_ON_CHANGE
6676
*/
6777
#define SENSING_SENSOR_FLAG_REPORT_ON_EVENT BIT(0)
6878

6979
/**
70-
* @brief Sensor flag indicating if this sensor is on change reporting data.
80+
* @brief Sensor flag indicating if this sensor is reporting data on change.
7181
*
7282
* Reporting sensor data when the sensor data changes.
7383
*
74-
* Exclusive with \ref SENSING_SENSOR_FLAG_REPORT_ON_EVENT
84+
* @note Mutually exclusive with \ref SENSING_SENSOR_FLAG_REPORT_ON_EVENT
7585
*/
7686
#define SENSING_SENSOR_FLAG_REPORT_ON_CHANGE BIT(1)
7787

88+
/** @} */
89+
7890
/**
79-
* @brief SENSING_SENSITIVITY_INDEX_ALL indicating sensitivity of each data field should be set
91+
* @brief Sentinel index meaning "apply to all data fields".
8092
*
93+
* Used with sensitivity configuration where a sensor provides multiple fields in a single sample.
8194
*/
8295
#define SENSING_SENSITIVITY_INDEX_ALL -1
8396

8497
/**
85-
* @brief Sensing subsystem sensor state.
98+
* @brief Sensor state.
8699
*
100+
* This enumeration defines the possible states of a sensor.
87101
*/
88102
enum sensing_sensor_state {
89103
SENSING_SENSOR_STATE_READY = 0, /**< The sensor is ready. */
90104
SENSING_SENSOR_STATE_OFFLINE = 1, /**< The sensor is offline. */
91105
};
92106

93107
/**
94-
* @brief Sensing subsystem sensor config attribute
108+
* @brief Sensor configuration attribute.
95109
*
110+
* This enumeration defines the possible attributes of a sensor configuration.
96111
*/
97112
enum sensing_sensor_attribute {
98-
/** The interval attribute of a sensor configuration. */
113+
/**
114+
* Reporting interval between samples, in microseconds (us).
115+
*
116+
* See @ref sensing_sensor_config::interval.
117+
*/
99118
SENSING_SENSOR_ATTRIBUTE_INTERVAL = 0,
100-
/** The sensitivity attribute of a sensor configuration. */
119+
120+
/**
121+
* Per-field sensitivity threshold.
122+
*
123+
* See @ref sensing_sensor_config::sensitivity.
124+
*/
101125
SENSING_SENSOR_ATTRIBUTE_SENSITIVITY = 1,
102-
/** The latency attribute of a sensor configuration. */
126+
127+
/**
128+
* Maximum batching latency, in microseconds (us).
129+
*
130+
* See @ref sensing_sensor_config::latency.
131+
*/
103132
SENSING_SENSOR_ATTRIBUTE_LATENCY = 2,
104-
/** The maximum number of attributes that a sensor configuration can have. */
133+
134+
/** Number of supported attributes. */
105135
SENSING_SENSOR_ATTRIBUTE_MAX,
106136
};
107137

108138
/**
109-
* @brief Define Sensing subsystem sensor handle
139+
* @brief Opaque handle to an opened sensor instance.
110140
*
141+
* A valid handle is obtained from @ref sensing_open_sensor or @ref sensing_open_sensor_by_dt and
142+
* must be closed with @ref sensing_close_sensor when no longer needed.
111143
*/
112144
typedef void *sensing_sensor_handle_t;
113145

114146
/**
115-
* @brief Sensor data event receive callback.
147+
* @brief Data event callback signature.
116148
*
117-
* @param handle The sensor instance handle.
118-
* @param buf The data buffer with sensor data.
119-
* @param context User provided context pointer.
149+
* The Sensing subsystem invokes this callback to deliver buffered samples for the opened sensor.
150+
*
151+
* @param handle Sensor instance handle passed to @ref sensing_open_sensor.
152+
* @param buf Pointer to a sensor-type-specific sample buffer; see @ref sensing_datatypes and
153+
* @ref sensing_sensor_types.
154+
* @param context User context pointer as provided in @ref sensing_callback_list::context.
120155
*/
121156
typedef void (*sensing_data_event_t)(
122157
sensing_sensor_handle_t handle,
123158
const void *buf,
124159
void *context);
125160

126161
/**
127-
* @struct sensing_sensor_info
128-
* @brief Sensor basic constant information
129-
*
162+
* @brief Read-only description of a sensor instance.
130163
*/
131164
struct sensing_sensor_info {
132165
/** Name of the sensor instance */
@@ -153,9 +186,13 @@ struct sensing_sensor_info {
153186
* @brief Sensing subsystem event callback list
154187
*
155188
*/
189+
190+
/**
191+
* @brief Callback registration for a sensor instance.
192+
*/
156193
struct sensing_callback_list {
157194
sensing_data_event_t on_data_event; /**< Callback function for a sensor data event. */
158-
void *context; /**< Associated context with on_data_event */
195+
void *context; /**< Context that will be passed to the callback. */
159196
};
160197

161198
/**

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)