NTURT Zephyr v0.0.1
NTURT common library for Zephyr RTOS
Loading...
Searching...
No Matches
states.h File Reference

Control system state machine. More...

#include <stdbool.h>
#include <stdint.h>
#include <zephyr/sys/iterable_sections.h>
#include <zephyr/sys/util.h>
+ Include dependency graph for states.h:
+ This graph shows which files directly or indirectly include this file:

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_infostates_transition_info (enum states_trans_cmd cmd)
 Get the information of a state transition.
 

Detailed Description

Control system state machine.

Author
quantumspawner
Version
0.0.1
Date
2025-02-24