Solaris Software
Loading...
Searching...
No Matches
fsm.h File Reference

Finite State Machine (FSM) module for the SPP core. More...

Include dependency graph for fsm.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  FSM_Transition_t
 A single row in the FSM transition table. More...
struct  FSM_Handle_t
 FSM handle — holds the current and previous state of the machine. More...

Macros

#define K_FSM_TIMEOUT_MS   10000U
#define K_FSM_MAX_TABLE_SIZE   10U
#define K_FSM_MAX_TABLES   4U

Enumerations

enum  FSM_State_t { FSM_STATE_INIT = 0 , FSM_STATE_READY , FSM_STATE_FLIGHT , FSM_STATE_LANDED }
 Top-level FSM states. More...
enum  FSM_SubState_t { FSM_SUBSTATE_NONE = 0 , FSM_SUBSTATE_FLIGHT_ASCENDING , FSM_SUBSTATE_FLIGHT_DESCENDING , FSM_SUBSTATE_FLIGHT_PARACHUTE_DEPLOYED }
 FSM sub-states. Use FSM_SUBSTATE_NONE for states with no sub-state. More...

Functions

spp_uint16_t * SPP_CORE_FSM_getErrorsBit (void)
 Get the pointer to the FSM errors bit.
SPP_RetVal_t FSM_init (void)
 Initialise the FSM with the internal service table. The service table runs the PUBSUB produce/consume cycle in the active states. Use FSM_addTable to append application rows.
SPP_RetVal_t FSM_addTable (const FSM_Transition_t *p_transitionTable, const spp_uint8_t tableSize)
 Append a transition table to the FSM.
void FSM_tick (void)
 Evaluate the transition table and advance the FSM if a guard passes. Call this once per superloop tick.

Detailed Description

Finite State Machine (FSM) module for the SPP core.

Definition in file fsm.h.

Macro Definition Documentation

◆ K_FSM_TIMEOUT_MS

#define K_FSM_TIMEOUT_MS   10000U

Definition at line 15 of file fsm.h.

◆ K_FSM_MAX_TABLE_SIZE

#define K_FSM_MAX_TABLE_SIZE   10U

Definition at line 16 of file fsm.h.

Referenced by FSM_addTable().

◆ K_FSM_MAX_TABLES

#define K_FSM_MAX_TABLES   4U

Definition at line 17 of file fsm.h.

Referenced by FSM_addTable().

Enumeration Type Documentation

◆ FSM_State_t

Top-level FSM states.

Enumerator
FSM_STATE_INIT 
FSM_STATE_READY 
FSM_STATE_FLIGHT 
FSM_STATE_LANDED 

Definition at line 27 of file fsm.h.

◆ FSM_SubState_t

FSM sub-states. Use FSM_SUBSTATE_NONE for states with no sub-state.

Enumerator
FSM_SUBSTATE_NONE 
FSM_SUBSTATE_FLIGHT_ASCENDING 
FSM_SUBSTATE_FLIGHT_DESCENDING 
FSM_SUBSTATE_FLIGHT_PARACHUTE_DEPLOYED 

Definition at line 38 of file fsm.h.

Function Documentation

◆ SPP_CORE_FSM_getErrorsBit()

spp_uint16_t * SPP_CORE_FSM_getErrorsBit ( void )

Get the pointer to the FSM errors bit.

Returns
Pointer to the FSM errors bit.

Definition at line 117 of file fsm.c.

References s_fsmErrors, and SPP_CORE_FSM_getErrorsBit().

Referenced by SPP_CORE_FSM_getErrorsBit(), and SPP_SERVICES_M10M_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FSM_init()

SPP_RetVal_t FSM_init ( void )

Initialise the FSM with the internal service table. The service table runs the PUBSUB produce/consume cycle in the active states. Use FSM_addTable to append application rows.

Returns
K_SPP_OK on success.

Definition at line 122 of file fsm.c.

References FSM_addTable(), FSM_init(), FSM_STATE_INIT, FSM_SUBSTATE_NONE, FSM_Handle_t::prevState, FSM_Handle_t::prevSubState, s_fsmBaseTable, s_fsmHandle, s_tableCount, FSM_Handle_t::state, and FSM_Handle_t::subState.

Referenced by APP_initFsm(), and FSM_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FSM_addTable()

SPP_RetVal_t FSM_addTable ( const FSM_Transition_t * p_transitionTable,
const spp_uint8_t tableSize )

Append a transition table to the FSM.

Parameters
p_transitionTablePointer to the table to append.
tableSizeNumber of rows in the table.
Returns
K_SPP_OK on success.

Definition at line 135 of file fsm.c.

References FSM_addTable(), K_FSM_MAX_TABLE_SIZE, K_FSM_MAX_TABLES, K_SPP_ERROR_INVALID_PARAMETER, K_SPP_ERROR_NULL_POINTER, K_SPP_ERROR_REGISTRY_FULL, K_SPP_OK, FSM_Table_t::p_table, s_tableCount, s_tables, and FSM_Table_t::size.

Referenced by APP_initFsm(), FSM_addTable(), and FSM_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FSM_tick()

void FSM_tick ( void )

Evaluate the transition table and advance the FSM if a guard passes. Call this once per superloop tick.

Definition at line 159 of file fsm.c.

References FSM_Transition_t::action, FSM_Transition_t::fromState, FSM_Transition_t::fromSubState, FSM_tick(), FSM_Transition_t::guard, FSM_Table_t::p_table, FSM_Handle_t::prevState, FSM_Handle_t::prevSubState, s_fsmHandle, s_tableCount, s_tables, FSM_Table_t::size, FSM_Handle_t::state, FSM_Transition_t::stateFunction, FSM_Handle_t::subState, FSM_Transition_t::toState, and FSM_Transition_t::toSubState.

Referenced by APP_fsmLoop(), and FSM_tick().

Here is the call graph for this function:
Here is the caller graph for this function: