NTURT Zephyr v0.0.1
NTURT common library for Zephyr RTOS
Loading...
Searching...
No Matches
Command

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.
 

Detailed Description

Command support.

Macro Definition Documentation

◆ CMD_DEFINE

#define CMD_DEFINE ( opcode,
immed,
deffered,
user_data )

#include <nturt/cmd.h>

Value:
_CMD_DEFINE(__cmd_##opcode, opcode, immed, deffered, user_data)

Define a command.

Parameters
[in]opcodeCommand opcode.
[in]immedImmediate handler of type cmd_immed_handler_t, or CMD_NO_HANDLER if not required.
[in]defferedDeffered handler of type cmd_deffered_handler_t, or CMD_NO_HANDLER if not required.
[in]user_dataPointer to custom data of the command.
Note
Since the name of the command is automatically generated using 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.

◆ cmd_invoke_auto

#define cmd_invoke_auto ( opcode,
operand )

#include <nturt/cmd.h>

Value:
cmd_invoke(opcode, &operand, sizeof(operand))
int cmd_invoke(uint32_t opcode, void *operand, size_t operand_size)
Invoke a command.

Invoke a command with operand type inferred from operand .

Parameters
[in]opcodeCommand opcode.
[in]operandOperand for the command.
Returns
Same as cmd_invoke.

◆ cmd_invoke_typed

#define cmd_invoke_typed ( _opcode,
_operand,
_operand_type )

#include <nturt/cmd.h>

Value:
__extension__({ \
_operand_type operand = _operand; \
cmd_invoke(_opcode, &operand, sizeof(_operand_type)); \
})

Invoke a command with specific operand type.

Parameters
[in]_opcodeCommand opcode.
[in]_operandOperand for the command.
[in]_operand_typeType of the operand.
Returns
Same as cmd_invoke.

◆ CMD_NO_HANDLER

#define CMD_NO_HANDLER   0

#include <nturt/cmd.h>

Indicate that the command has no handler of this type.

Typedef Documentation

◆ cmd_deffered_handler_t

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.

Parameters
[in]opcodeCommand opcode.
[in]operandOperand for the command.
[in]user_dataCustom data of the command.

◆ cmd_immed_handler_t

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.

Parameters
[in]opcodeCommand opcode.
[in]operandOperand for the command.
[in]user_dataCustom data of the command.
Return values
0For success.
-EINVALIf the operand is invalid.
othersNegative error number.

Function Documentation

◆ cmd_invoke()

int cmd_invoke ( uint32_t opcode,
void * operand,
size_t operand_size )

#include <nturt/cmd.h>

Invoke a command.

Parameters
[in]opcodeCommand opcode.
[in]operandOperand for the command.
[in]operand_sizeSize of the operand.
Return values
0For success.
-ENOENTIf the opcode does not exist.
-EINVALIf the operand is invalid.
-ENOMEMIf the buffer for deffered handler is full.
othersNegative error number returned by immediate handler.

◆ cmd_invoke_void()

static int cmd_invoke_void ( uint32_t opcode)
inlinestatic

#include <nturt/cmd.h>

Invoke a command without operand.

Parameters
[in]opcodeCommand opcode.
Returns
Same as cmd_invoke.