Skip to content

Commit b99bad9

Browse files
committed
include: ec_host_cmd: doxygen improvements
- add some missing docs - make sure API guarded by Kconfig is showing up in the docs - show EC Host Command docs in the Device Management group - re-arrange groups for backends and simulator API Signed-off-by: Benjamin Cabé <[email protected]>
1 parent 8ca31f3 commit b99bad9

File tree

3 files changed

+87
-24
lines changed

3 files changed

+87
-24
lines changed

include/zephyr/mgmt/ec_host_cmd/backend.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@
77
/**
88
* @file
99
* @brief Public APIs for Host Command backends that respond to host commands
10+
* @ingroup ec_host_cmd_backend
1011
*/
1112

1213
#ifndef ZEPHYR_INCLUDE_MGMT_EC_HOST_CMD_BACKEND_H_
1314
#define ZEPHYR_INCLUDE_MGMT_EC_HOST_CMD_BACKEND_H_
1415

16+
/**
17+
* @brief Interface to EC Host Command backends
18+
* @defgroup ec_host_cmd_backend Backends
19+
* @ingroup ec_host_cmd_interface
20+
* @{
21+
*/
22+
1523
#include <zephyr/sys/__assert.h>
1624
#include <zephyr/device.h>
1725
#include <zephyr/drivers/gpio.h>
@@ -22,20 +30,16 @@
2230
extern "C" {
2331
#endif
2432

33+
/**
34+
* @brief EC Host Command Backend
35+
*/
2536
struct ec_host_cmd_backend {
26-
/** API provided by the backed. */
37+
/** API provided by the backend. */
2738
const struct ec_host_cmd_backend_api *api;
28-
/** Context for the backed. */
39+
/** Context for the backend. */
2940
void *ctx;
3041
};
3142

32-
/**
33-
* @brief EC Host Command Interface
34-
* @defgroup ec_host_cmd_interface EC Host Command Interface
35-
* @ingroup io_interfaces
36-
* @{
37-
*/
38-
3943
/**
4044
* @brief Context for host command backend and handler to pass rx data.
4145
*/
@@ -58,7 +62,7 @@ struct ec_host_cmd_rx_ctx {
5862
*/
5963
struct ec_host_cmd_tx_buf {
6064
/**
61-
* Data to write to the host The buffer is provided by the handler if
65+
* Data to write to the host. The buffer is provided by the handler if
6266
* CONFIG_EC_HOST_CMD_HANDLER_TX_BUFFER_SIZE > 0. Otherwise, the backend should provide
6367
* the buffer on its own and overwrites @a buf pointer and @a len_max
6468
* in the init function.

include/zephyr/mgmt/ec_host_cmd/ec_host_cmd.h

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* @defgroup ec_host_cmd_interface EC Host Command Interface
1313
* @since 2.4
1414
* @version 0.1.0
15-
* @ingroup io_interfaces
15+
* @ingroup device_mgmt
1616
* @{
1717
*/
1818

@@ -72,24 +72,54 @@ enum ec_host_cmd_status {
7272
EC_HOST_CMD_MAX = UINT16_MAX /* Force enum to be 16 bits. */
7373
} __packed;
7474

75+
/**
76+
* @brief Host command log levels
77+
*/
7578
enum ec_host_cmd_log_level {
76-
EC_HOST_CMD_DEBUG_OFF, /* No Host Command debug output */
77-
EC_HOST_CMD_DEBUG_NORMAL, /* Normal output mode; skips repeated commands */
78-
EC_HOST_CMD_DEBUG_EVERY, /* Print every command */
79-
EC_HOST_CMD_DEBUG_PARAMS, /* ... and print params for request/response */
80-
EC_HOST_CMD_DEBUG_MODES /* Number of host command debug modes */
79+
EC_HOST_CMD_DEBUG_OFF, /**< No Host Command debug output */
80+
EC_HOST_CMD_DEBUG_NORMAL, /**< Normal output mode; skips repeated commands */
81+
EC_HOST_CMD_DEBUG_EVERY, /**< Print every command */
82+
EC_HOST_CMD_DEBUG_PARAMS, /**< ... and print params for request/response */
83+
EC_HOST_CMD_DEBUG_MODES /**< Number of host command debug modes */
8184
};
8285

86+
/**
87+
* @brief Host command state
88+
*/
8389
enum ec_host_cmd_state {
84-
EC_HOST_CMD_STATE_DISABLED = 0,
85-
EC_HOST_CMD_STATE_RECEIVING,
86-
EC_HOST_CMD_STATE_PROCESSING,
87-
EC_HOST_CMD_STATE_SENDING,
90+
EC_HOST_CMD_STATE_DISABLED = 0, /**< Host command subsystem is disabled */
91+
EC_HOST_CMD_STATE_RECEIVING, /**< Receiving command data from host */
92+
EC_HOST_CMD_STATE_PROCESSING, /**< Processing received command */
93+
EC_HOST_CMD_STATE_SENDING, /**< Sending response to host */
8894
};
8995

96+
/**
97+
* @brief User callback function type for host command reception
98+
*
99+
* This callback is invoked after a host command is received and validated
100+
* but before command processing begins. It allows user code to perform
101+
* custom actions based on the received command.
102+
*
103+
* @param rx_ctx Pointer to the receive context containing command data
104+
* @param user_data User-defined data pointer passed during callback registration
105+
*/
90106
typedef void (*ec_host_cmd_user_cb_t)(const struct ec_host_cmd_rx_ctx *rx_ctx, void *user_data);
107+
108+
/**
109+
* @brief In-progress callback function type
110+
*
111+
* This callback is executed asynchronously for commands that return
112+
* EC_HOST_CMD_IN_PROGRESS status. It allows long-running operations
113+
* to complete in the background.
114+
*
115+
* @param user_data User-provided data passed to the callback
116+
* @return Final status code for the command
117+
*/
91118
typedef enum ec_host_cmd_status (*ec_host_cmd_in_progress_cb_t)(void *user_data);
92119

120+
/**
121+
* Host command context structure
122+
*/
93123
struct ec_host_cmd {
94124
struct ec_host_cmd_rx_ctx rx_ctx;
95125
struct ec_host_cmd_tx_buf tx;
@@ -138,7 +168,18 @@ struct ec_host_cmd_handler_args {
138168
uint16_t output_buf_size;
139169
};
140170

171+
/**
172+
* @brief Host command handler callback function type
173+
*
174+
* This callback is invoked to process a host command that matches the handler's
175+
* command ID and version. The handler processes the incoming command data and
176+
* generates a response.
177+
*
178+
* @param args Pointer to the handler arguments containing command data and buffers
179+
* @return Status code indicating the result of command processing
180+
*/
141181
typedef enum ec_host_cmd_status (*ec_host_cmd_handler_cb)(struct ec_host_cmd_handler_args *args);
182+
142183
/**
143184
* @brief Structure use for statically registering host command handlers
144185
*/
@@ -334,13 +375,15 @@ const struct ec_host_cmd *ec_host_cmd_get_hc(void);
334375
FUNC_NORETURN void ec_host_cmd_task(void);
335376
#endif
336377

337-
#ifdef CONFIG_EC_HOST_CMD_IN_PROGRESS_STATUS
378+
#if defined(CONFIG_EC_HOST_CMD_IN_PROGRESS_STATUS) || defined(__DOXYGEN__)
338379
/**
339380
* @brief Check if a Host Command that sent EC_HOST_CMD_IN_PROGRESS status has ended.
340381
*
341382
* A Host Command that sends EC_HOST_CMD_IN_PROGRESS status doesn't send a final result.
342383
* The final result can be get with the ec_host_cmd_send_in_progress_status function.
343384
*
385+
* @kconfig_dep{CONFIG_EC_HOST_CMD_IN_PROGRESS_STATUS}
386+
*
344387
* @retval true if the Host Command endded
345388
*/
346389
bool ec_host_cmd_send_in_progress_ended(void);
@@ -354,6 +397,8 @@ bool ec_host_cmd_send_in_progress_ended(void);
354397
*
355398
* Saving status of Host Commands that send response data is not supported.
356399
*
400+
* @kconfig_dep{CONFIG_EC_HOST_CMD_IN_PROGRESS_STATUS}
401+
*
357402
* @retval The final status or EC_HOST_CMD_UNAVAILABLE if not available.
358403
*/
359404
enum ec_host_cmd_status ec_host_cmd_send_in_progress_status(void);
@@ -367,6 +412,8 @@ enum ec_host_cmd_status ec_host_cmd_send_in_progress_status(void);
367412
* ec_host_cmd_send_in_progress_status function. The ec_host_cmd_send_in_progress_ended function
368413
* can be used to check if the callback has ended.
369414
*
415+
* @kconfig_dep{CONFIG_EC_HOST_CMD_IN_PROGRESS_STATUS}
416+
*
370417
* @param[in] cb A callback to be called after returning from a command handler.
371418
* @param[in] user_data User data to be passed to the callback.
372419
*

include/zephyr/mgmt/ec_host_cmd/simulator.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,21 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#ifndef ZEPHYR_INCLUDE_MGMT_EC_HOST_CMD_SIMULATOR_H_
8-
#define ZEPHYR_INCLUDE_MGMT_EC_HOST_CMD_SIMULATOR_H_
9-
107
/**
118
* @file
129
* @brief Header for commands to interact with the simulator outside of normal
1310
* device interface.
11+
* @ingroup ec_host_cmd_simulator
12+
*/
13+
14+
#ifndef ZEPHYR_INCLUDE_MGMT_EC_HOST_CMD_SIMULATOR_H_
15+
#define ZEPHYR_INCLUDE_MGMT_EC_HOST_CMD_SIMULATOR_H_
16+
17+
/**
18+
* @brief Interface to EC Host Command Simulator
19+
* @defgroup ec_host_cmd_simulator Simulator
20+
* @ingroup ec_host_cmd_interface
21+
* @{
1422
*/
1523

1624
/* For ec_host_cmd_backend_api_send function pointer type */
@@ -45,4 +53,8 @@ void ec_host_cmd_backend_sim_install_send_cb(ec_host_cmd_backend_api_send cb,
4553
*/
4654
int ec_host_cmd_backend_sim_data_received(const uint8_t *buffer, size_t len);
4755

56+
/**
57+
* @}
58+
*/
59+
4860
#endif /* ZEPHYR_INCLUDE_MGMT_EC_HOST_CMD_SIMULATOR_H_ */

0 commit comments

Comments
 (0)