Solaris Software
Toggle main menu visibility
Loading...
Searching...
No Matches
app.c
Go to the documentation of this file.
1
/**
2
* @file app.c
3
* @brief Solaris application initialization and execution.
4
*
5
* Initializes the hardware abstraction layer and the FSM,
6
* registers application-specific transitions, and runs the
7
* main execution loop. Handles fatal boot errors.
8
*/
9
10
/* ----------------------------------------------------------------
11
* INCLUDES
12
* ---------------------------------------------------------------- */
13
#include "
app.h
"
14
#include "
spp/services/fsm/fsm.h
"
15
#include "
spp/ports/hal/esp32/halEsp32.h
"
16
#include "
custom.h
"
17
18
#include <stdio.h>
19
20
/* ----------------------------------------------------------------
21
* STATIC FUNCTIONS
22
* ---------------------------------------------------------------- */
23
/**
24
* @brief Boot error handler.
25
*/
26
static
inline
void
BootError
();
27
28
/* ----------------------------------------------------------------
29
* PUBLIC FUNCTIONS
30
* ---------------------------------------------------------------- */
31
void
APP_initHal
(
void
)
32
{
33
// Get HAL port
34
const
SPP_HalPort_t
*p_halPorts =
SPP_PORTS_ESP32S3_getHalPorts
();
35
36
// HAL init
37
SPP_RetVal_t
ret =
SPP_HAL_init
((
void
*)p_halPorts);
38
if
(ret !=
K_SPP_OK
)
39
{
40
printf(
"BOOT FAIL: HAL ret=%d\n"
, (
int
)ret);
41
BootError
();
42
}
43
}
44
45
void
APP_initFsm
(
void
)
46
{
47
// Get the custom FSM table
48
const
FSM_Transition_t
*p_fsmTable =
CUSTOM_getFsmTable
();
49
50
// Init the FSM with the internal service table
51
SPP_RetVal_t
ret =
FSM_init
();
52
if
(ret !=
K_SPP_OK
)
53
{
54
printf(
"BOOT FAIL: FSM init ret=%d\n"
, (
int
)ret);
55
BootError
();
56
}
57
58
// Add the application transition table
59
ret =
FSM_addTable
(p_fsmTable,
K_CUSTOM_FSM_TABLE_SIZE
);
60
if
(ret !=
K_SPP_OK
)
61
{
62
printf(
"BOOT FAIL: FSM addTable ret=%d\n"
, (
int
)ret);
63
BootError
();
64
}
65
}
66
67
void
APP_fsmLoop
(
void
)
68
{
69
// FSM loop
70
while
(1)
71
{
72
FSM_tick
();
73
}
74
}
75
76
/* ----------------------------------------------------------------
77
* STATIC FUNCTIONS IMPLEMENTATIONS
78
* ---------------------------------------------------------------- */
79
static
inline
void
BootError
()
80
{
81
while
(1)
82
{
83
// Update Watchdog (future expansion)
84
// Send error bit to ground station (future expansion)
85
}
86
}
APP_fsmLoop
void APP_fsmLoop(void)
Main loop for the FSM (executes the state machine indefinitely).
Definition
app.c:67
BootError
static void BootError()
Boot error handler.
Definition
app.c:79
APP_initFsm
void APP_initFsm(void)
Initialize the FSM (Finite State Machine).
Definition
app.c:45
APP_initHal
void APP_initHal(void)
Initialize the HAL (Hardware Abstraction Layer).
Definition
app.c:31
app.h
CUSTOM_getFsmTable
const FSM_Transition_t * CUSTOM_getFsmTable(void)
Returns the application-specific FSM transition table.
Definition
custom.c:53
custom.h
Application-specific FSM configuration and error tracking.
K_CUSTOM_FSM_TABLE_SIZE
#define K_CUSTOM_FSM_TABLE_SIZE
Definition
custom.h:17
FSM_init
SPP_RetVal_t FSM_init(void)
Initialise the FSM with the internal service table. The service table runs the PUBSUB produce/consume...
Definition
fsm.c:122
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.
Definition
fsm.c:135
FSM_tick
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:159
fsm.h
Finite State Machine (FSM) module for the SPP core.
SPP_PORTS_ESP32S3_getHalPorts
const SPP_HalPort_t * SPP_PORTS_ESP32S3_getHalPorts(void)
Returns a pointer to the ESP32-S3 HAL port descriptor.
Definition
halEsp32.c:74
halEsp32.h
ESP32-S3 HAL port descriptor for SPP.
SPP_HAL_init
SPP_RetVal_t SPP_HAL_init(void *p_halPorts)
This functions initializes the ports struct and initializes all the peripherals.
Definition
hal.c:26
SPP_RetVal_t
SPP_RetVal_t
Unified return type for all SPP API functions.
Definition
returnTypes.h:24
K_SPP_OK
@ K_SPP_OK
Definition
returnTypes.h:25
FSM_Transition_t
A single row in the FSM transition table.
Definition
fsm.h:50
SPP_HalPort_t
Ports struct that contains all the pointers to the Ports functions.
Definition
hal.h:234
solaris-v2
main
app.c
Generated by
1.18.0