Solaris Software
Loading...
Searching...
No Matches
fsm.h
Go to the documentation of this file.
1/**
2 * @file fsm.h
3 * @brief Finite State Machine (FSM) module for the SPP core.
4 */
5
6#ifndef SPP_CORE_FSM_H
7#define SPP_CORE_FSM_H
8
10#include "spp/core/types.h"
11
12/* ----------------------------------------------------------------
13* DEFINES
14* ---------------------------------------------------------------- */
15#define K_FSM_TIMEOUT_MS 10000U // Only executed once, np with stops
16#define K_FSM_MAX_TABLE_SIZE 10U /*<Only allow 10 rows on the FSM table */
17
18
19/* ----------------------------------------------------------------
20* STRUCTS
21* ---------------------------------------------------------------- */
22
23/**
24 * @brief Top-level FSM states.
25 */
33
34/**
35 * @brief FSM sub-states. Use FSM_SUBSTATE_NONE for states with no sub-state.
36 */
44
45/**
46 * @brief A single row in the FSM transition table.
47 */
58
59/**
60 * @brief FSM handle — holds the current and previous state of the machine.
61 */
69
70/* ----------------------------------------------------------------
71 * PUBLIC FUNCTIONS
72 * ---------------------------------------------------------------- */
73/**
74* @brief Get the pointer to the FSM errors bit.
75* @return Pointer to the FSM errors bit.
76*/
78/**
79* @brief Initialize the FSM.
80* @param p_halPorts Pointer to the HAL ports.
81* @param p_transitiontable Pointer to the FSM table for operation.
82* @param tableSize Size of the table.
83*/
84SPP_RetVal_t FSM_init(const FSM_Transition_t *p_transitionTable, const spp_uint8_t tableSize);
85/**
86 * @brief Evaluate the transition table and advance the FSM if a guard passes.
87 * Call this once per superloop tick.
88 */
89void FSM_tick(void);
90
91
92#endif /* SPP_CORE_FSM_H */
SPP_RetVal_t FSM_init(const FSM_Transition_t *p_transitionTable, const spp_uint8_t tableSize)
Initialize the FSM.
Definition fsm.c:38
spp_uint16_t * SPP_CORE_FSM_getErrorsBit(void)
Get the pointer to the FSM errors bit.
Definition fsm.c:33
void FSM_tick(void)
Evaluate the transition table and advance the FSM if a guard passes. Call this once per superloop tic...
Definition fsm.c:58
FSM_State_t
Top-level FSM states.
Definition fsm.h:27
@ FSM_STATE_LANDED
Definition fsm.h:31
@ FSM_STATE_FLIGHT
Definition fsm.h:30
@ FSM_STATE_READY
Definition fsm.h:29
@ FSM_STATE_INIT
Definition fsm.h:28
FSM_SubState_t
FSM sub-states. Use FSM_SUBSTATE_NONE for states with no sub-state.
Definition fsm.h:38
@ FSM_SUBSTATE_FLIGHT_ASCENDING
Definition fsm.h:40
@ FSM_SUBSTATE_FLIGHT_PARACHUTE_DEPLOYED
Definition fsm.h:42
@ FSM_SUBSTATE_NONE
Definition fsm.h:39
@ FSM_SUBSTATE_FLIGHT_DESCENDING
Definition fsm.h:41
Standard return-value type used across all SPP modules.
SPP_RetVal_t
Unified return type for all SPP API functions.
Definition returnTypes.h:24
FSM handle — holds the current and previous state of the machine.
Definition fsm.h:63
FSM_SubState_t prevSubState
Definition fsm.h:67
FSM_State_t prevState
Definition fsm.h:66
FSM_State_t state
Definition fsm.h:64
FSM_SubState_t subState
Definition fsm.h:65
A single row in the FSM transition table.
Definition fsm.h:49
FSM_SubState_t fromSubState
Definition fsm.h:51
spp_bool_t(*) guard(void)
Definition fsm.h:54
void(*) stateFunction(void)
Definition fsm.h:56
FSM_State_t fromState
Definition fsm.h:50
FSM_State_t toState
Definition fsm.h:52
void(*) action(void)
Definition fsm.h:55
FSM_SubState_t toSubState
Definition fsm.h:53
Portable integer types and SPI/storage configuration types for SPP.
uint16_t spp_uint16_t
Definition types.h:29
uint8_t spp_uint8_t
Definition types.h:27
bool spp_bool_t
Definition types.h:36