![]() |
NTURT Zephyr v0.0.1
NTURT common library for Zephyr RTOS
|
Control system state machine. More...
Data Structures | |
struct | states_trans_cmd_info |
State transition command information. More... | |
struct | states_callback |
State transition callback. More... | |
Macros | |
#define | STATES_CALLBACK_DEFINE_NAMED(_name, _states, _handler, _user_data) |
Same as STATES_CALLBACK_DEFINE, but with a custom name for the callback. | |
#define | STATES_CALLBACK_DEFINE(states, handler, user_data) |
Define a callback for state transition. | |
Typedefs | |
typedef uint32_t | states_t |
State machine states type, where each bit represents a state defined in states_state. | |
typedef void(* | states_handler_t) (enum states_state state, bool is_entry, void *user_data) |
State transition handler type. | |
Enumerations | |
enum | states_state { STATE_INVALID = 0 , STATE_ERR_FREE = BIT(0) , STATE_READY = BIT(1) , STATE_RTD_BLINK = BIT(2) , STATE_RTD_STEADY = BIT(3) , STATE_RTD_READY = BIT(4) , STATE_RTD_SOUND = BIT(5) , STATE_RUNNING = BIT(6) , STATE_ERR = BIT(7) , STATE_ALL = UINT32_MAX , NUM_STATE = 8 } |
State machine states. More... | |
enum | states_trans_cmd { TRANS_CMD_INVALID = 0 , TRANS_CMD_ERR , TRANS_CMD_ERR_CLEAR , TRANS_CMD_PEDAL , TRANS_CMD_PEDAL_CLEAR , TRANS_CMD_RTD , TRANS_CMD_RTD_FINISH , TRANS_CMD_DISABLE , NUM_TRANS_CMD } |
State transition commands. More... | |
Functions | |
states_t | states_get () |
Get the current states. | |
bool | states_valid_transition (enum states_trans_cmd cmd) |
Test if a state transition command is valid. | |
void | states_transition (enum states_trans_cmd cmd) |
Execute a state transition command to transition to a new state. | |
const char * | states_state_str (enum states_state state) |
Get the string representation of a state. | |
int | states_states_str (char *buf, size_t size, states_t states) |
Get the string representation of states separated by commas in the same semantic as snprintf. | |
const struct states_trans_cmd_info * | states_transition_info (enum states_trans_cmd cmd) |
Get the information of a state transition. | |
Control system state machine.
#define STATES_CALLBACK_DEFINE | ( | states, | |
handler, | |||
user_data ) |
#include <vcu/ctrl/states.h>
Define a callback for state transition.
[in] | states | When transition from/to what states to call the callback. Multiple states_state can be specified using bitwise OR operator (|). |
[in] | handler | Handler of the state transition. |
[in] | user_data | Pointer to custom data for the callback. |
handler
, if the same handler is used for multiple callbacks, STATES_CALLBACK_DEFINE_NAMED can be used instead to prevent linker errors. #define STATES_CALLBACK_DEFINE_NAMED | ( | _name, | |
_states, | |||
_handler, | |||
_user_data ) |
#include <vcu/ctrl/states.h>
Same as STATES_CALLBACK_DEFINE, but with a custom name for the callback.
typedef void(* states_handler_t) (enum states_state state, bool is_entry, void *user_data) |
#include <vcu/ctrl/states.h>
State transition handler type.
[in] | state | to transition from/to. |
[in] | is_entry | True when transitioning to the state. False when transition from. |
[in,out] | user_data | Pointer to custom data for the callback provided by STATES_CALLBACK_DEFINE. |
typedef uint32_t states_t |
#include <vcu/ctrl/states.h>
State machine states type, where each bit represents a state defined in states_state.
enum states_state |
#include <vcu/ctrl/states.h>
State machine states.
Enumerator | |
---|---|
STATE_INVALID | |
STATE_ERR_FREE | |
STATE_READY | |
STATE_RTD_BLINK | |
STATE_RTD_STEADY | |
STATE_RTD_READY | |
STATE_RTD_SOUND | |
STATE_RUNNING | |
STATE_ERR | |
STATE_ALL | |
NUM_STATE |
enum states_trans_cmd |
#include <vcu/ctrl/states.h>
State transition commands.
Enumerator | |
---|---|
TRANS_CMD_INVALID | |
TRANS_CMD_ERR | |
TRANS_CMD_ERR_CLEAR | |
TRANS_CMD_PEDAL | |
TRANS_CMD_PEDAL_CLEAR | |
TRANS_CMD_RTD | |
TRANS_CMD_RTD_FINISH | |
TRANS_CMD_DISABLE | |
NUM_TRANS_CMD |
states_t states_get | ( | ) |
const char * states_state_str | ( | enum states_state | state | ) |
#include <vcu/ctrl/states.h>
Get the string representation of a state.
[in] | state | State. |
int states_states_str | ( | char * | buf, |
size_t | size, | ||
states_t | states ) |
#include <vcu/ctrl/states.h>
Get the string representation of states separated by commas in the same semantic as snprintf.
[out] | buf | Buffer to store the string representation. |
[in] | size | Size of the buffer. |
[in] | states | States. |
void states_transition | ( | enum states_trans_cmd | cmd | ) |
#include <vcu/ctrl/states.h>
Execute a state transition command to transition to a new state.
[in] | cmd | State transition command. |
const struct states_trans_cmd_info * states_transition_info | ( | enum states_trans_cmd | cmd | ) |
#include <vcu/ctrl/states.h>
Get the information of a state transition.
[in] | cmd | State transition command. |
bool states_valid_transition | ( | enum states_trans_cmd | cmd | ) |
#include <vcu/ctrl/states.h>
Test if a state transition command is valid.
[in] | cmd | State transition command. |
true | If the command can be executed. |
false | If the command cannot be executed. |