12
12
* @defgroup ec_host_cmd_interface EC Host Command Interface
13
13
* @since 2.4
14
14
* @version 0.1.0
15
- * @ingroup io_interfaces
15
+ * @ingroup device_mgmt
16
16
* @{
17
17
*/
18
18
@@ -72,24 +72,54 @@ enum ec_host_cmd_status {
72
72
EC_HOST_CMD_MAX = UINT16_MAX /* Force enum to be 16 bits. */
73
73
} __packed ;
74
74
75
+ /**
76
+ * @brief Host command log levels
77
+ */
75
78
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 */
81
84
};
82
85
86
+ /**
87
+ * @brief Host command state
88
+ */
83
89
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 */
88
94
};
89
95
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
+ */
90
106
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
+ */
91
118
typedef enum ec_host_cmd_status (* ec_host_cmd_in_progress_cb_t )(void * user_data );
92
119
120
+ /**
121
+ * Host command context structure
122
+ */
93
123
struct ec_host_cmd {
94
124
struct ec_host_cmd_rx_ctx rx_ctx ;
95
125
struct ec_host_cmd_tx_buf tx ;
@@ -138,7 +168,18 @@ struct ec_host_cmd_handler_args {
138
168
uint16_t output_buf_size ;
139
169
};
140
170
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
+ */
141
181
typedef enum ec_host_cmd_status (* ec_host_cmd_handler_cb )(struct ec_host_cmd_handler_args * args );
182
+
142
183
/**
143
184
* @brief Structure use for statically registering host command handlers
144
185
*/
@@ -334,13 +375,15 @@ const struct ec_host_cmd *ec_host_cmd_get_hc(void);
334
375
FUNC_NORETURN void ec_host_cmd_task (void );
335
376
#endif
336
377
337
- #ifdef CONFIG_EC_HOST_CMD_IN_PROGRESS_STATUS
378
+ #if defined( CONFIG_EC_HOST_CMD_IN_PROGRESS_STATUS ) || defined( __DOXYGEN__ )
338
379
/**
339
380
* @brief Check if a Host Command that sent EC_HOST_CMD_IN_PROGRESS status has ended.
340
381
*
341
382
* A Host Command that sends EC_HOST_CMD_IN_PROGRESS status doesn't send a final result.
342
383
* The final result can be get with the ec_host_cmd_send_in_progress_status function.
343
384
*
385
+ * @kconfig_dep{CONFIG_EC_HOST_CMD_IN_PROGRESS_STATUS}
386
+ *
344
387
* @retval true if the Host Command endded
345
388
*/
346
389
bool ec_host_cmd_send_in_progress_ended (void );
@@ -354,6 +397,8 @@ bool ec_host_cmd_send_in_progress_ended(void);
354
397
*
355
398
* Saving status of Host Commands that send response data is not supported.
356
399
*
400
+ * @kconfig_dep{CONFIG_EC_HOST_CMD_IN_PROGRESS_STATUS}
401
+ *
357
402
* @retval The final status or EC_HOST_CMD_UNAVAILABLE if not available.
358
403
*/
359
404
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);
367
412
* ec_host_cmd_send_in_progress_status function. The ec_host_cmd_send_in_progress_ended function
368
413
* can be used to check if the callback has ended.
369
414
*
415
+ * @kconfig_dep{CONFIG_EC_HOST_CMD_IN_PROGRESS_STATUS}
416
+ *
370
417
* @param[in] cb A callback to be called after returning from a command handler.
371
418
* @param[in] user_data User data to be passed to the callback.
372
419
*
0 commit comments