![]() |
NTURT Zephyr v0.0.1
NTURT common library for Zephyr RTOS
|
Command support. More...
Data Structures | |
struct | cmd |
Command. More... | |
Macros | |
#define | CMD_NO_HANDLER 0 |
Indicate that the command has no handler of this type. | |
#define | CMD_DEFINE(opcode, immed, deffered, user_data) |
Define a command. | |
#define | cmd_invoke_typed(_opcode, _operand, _operand_type) |
Invoke a command with specific operand type. | |
#define | cmd_invoke_auto(opcode, operand) |
Invoke a command with operand type inferred from operand . | |
Typedefs | |
typedef int(* | cmd_immed_handler_t) (uint32_t opcode, const void *operand, size_t operand_size, void *user_data) |
Immediate handler of a command. | |
typedef void(* | cmd_deffered_handler_t) (uint32_t opcode, const void *operand, size_t operand_size, void *user_data) |
Deffered handler of a command. | |
Functions | |
int | cmd_invoke (uint32_t opcode, void *operand, size_t operand_size) |
Invoke a command. | |
static int | cmd_invoke_void (uint32_t opcode) |
Invoke a command without operand. | |
Command support.
#define CMD_DEFINE | ( | opcode, | |
immed, | |||
deffered, | |||
user_data ) |
#include <nturt/cmd.h>
Define a command.
[in] | opcode | Command opcode. |
[in] | immed | Immediate handler of type cmd_immed_handler_t, or CMD_NO_HANDLER if not required. |
[in] | deffered | Deffered handler of type cmd_deffered_handler_t, or CMD_NO_HANDLER if not required. |
[in] | user_data | Pointer to custom data of the command. |
opcode
, the name would be illegal if opcode
contains characters other than alphanumericals or underscores. To avoid this, _CMD_DEFINE can be used directly by providing a unique name. #define cmd_invoke_auto | ( | opcode, | |
operand ) |
#include <nturt/cmd.h>
Invoke a command with operand type inferred from operand
.
[in] | opcode | Command opcode. |
[in] | operand | Operand for the command. |
#define cmd_invoke_typed | ( | _opcode, | |
_operand, | |||
_operand_type ) |
#include <nturt/cmd.h>
Invoke a command with specific operand type.
[in] | _opcode | Command opcode. |
[in] | _operand | Operand for the command. |
[in] | _operand_type | Type of the operand. |
#define CMD_NO_HANDLER 0 |
#include <nturt/cmd.h>
Indicate that the command has no handler of this type.
typedef void(* cmd_deffered_handler_t) (uint32_t opcode, const void *operand, size_t operand_size, void *user_data) |
#include <nturt/cmd.h>
Deffered handler of a command.
[in] | opcode | Command opcode. |
[in] | operand | Operand for the command. |
[in] | user_data | Custom data of the command. |
typedef int(* cmd_immed_handler_t) (uint32_t opcode, const void *operand, size_t operand_size, void *user_data) |
#include <nturt/cmd.h>
Immediate handler of a command.
[in] | opcode | Command opcode. |
[in] | operand | Operand for the command. |
[in] | user_data | Custom data of the command. |
0 | For success. |
-EINVAL | If the operand is invalid. |
others | Negative error number. |
int cmd_invoke | ( | uint32_t | opcode, |
void * | operand, | ||
size_t | operand_size ) |
#include <nturt/cmd.h>
Invoke a command.
[in] | opcode | Command opcode. |
[in] | operand | Operand for the command. |
[in] | operand_size | Size of the operand. |
0 | For success. |
-ENOENT | If the opcode does not exist. |
-EINVAL | If the operand is invalid. |
-ENOMEM | If the buffer for deffered handler is full. |
others | Negative error number returned by immediate handler. |
|
inlinestatic |
#include <nturt/cmd.h>
Invoke a command without operand.
[in] | opcode | Command opcode. |