STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
flight_state.h
Go to the documentation of this file.
1
#ifndef STAR_FLIGHT_STATE_H
2
#define STAR_FLIGHT_STATE_H
3
4
/*
5
* The flight computer's top-level states, as drawn in Flight_computer.drawio:
6
*
7
* power on -> SELF_TEST -(done)-> IDLE -(Arm)-> ARMED -(launch)-> LAUNCHED
8
* ^ | |
9
* +--(Un-arm)---+ (apogee)
10
* v
11
* RECOVERY
12
*
13
* This file is only the transition table: which event moves which state
14
* where. It does no I/O and owns no timers, so it runs unchanged on a laptop
15
* (tests/emmc) and on the board. Launch and apogee detection do not exist
16
* yet; nothing raises those events today.
17
*/
18
19
#include <stdbool.h>
20
21
#ifdef __cplusplus
22
extern
"C"
{
23
#endif
24
25
typedef
enum
{
26
FLIGHT_SELF_TEST
= 0,
27
FLIGHT_IDLE
,
28
FLIGHT_ARMED
,
29
FLIGHT_LAUNCHED
,
30
FLIGHT_RECOVERY
,
31
FLIGHT_STATE_COUNT
32
}
flight_state_t
;
33
34
typedef
enum
{
35
FLIGHT_EV_SELF_TEST_DONE
= 0,
36
FLIGHT_EV_ARM
,
37
FLIGHT_EV_UNARM
,
38
FLIGHT_EV_LAUNCH_DETECTED
,
39
FLIGHT_EV_APOGEE_DETECTED
,
40
FLIGHT_EVENT_COUNT
41
}
flight_event_t
;
42
43
/*
44
* The state after `event` arrives in `state`. An event the diagram does not
45
* draw from that state leaves it unchanged: Un-arm after launch is ignored,
46
* Arm while armed is ignored. An out-of-range state or event also returns
47
* `state` unchanged.
48
*/
49
flight_state_t
flight_state_next
(
flight_state_t
state
,
flight_event_t
event);
50
51
/*
52
* Whether the eMMC flight log records in this state. At this stage it starts
53
* at ARMED, not LAUNCHED, because launch detection is not implemented: a log
54
* that waited for "launch detected" would never start. ARMED, LAUNCHED and
55
* RECOVERY record; SELF_TEST and IDLE leave the eMMC untouched.
56
*/
57
bool
flight_state_logs_to_emmc
(
flight_state_t
state
);
58
59
/* Upper-case name for logs and the ground station ("ARMED"); "?" if bad. */
60
const
char
*
flight_state_name
(
flight_state_t
state
);
61
62
#ifdef __cplusplus
63
}
64
#endif
65
#endif
flight_state_next
flight_state_t flight_state_next(flight_state_t state, flight_event_t event)
Definition
flight_state.c:3
flight_state_name
const char * flight_state_name(flight_state_t state)
Definition
flight_state.c:27
flight_state_t
flight_state_t
Definition
flight_state.h:25
FLIGHT_RECOVERY
@ FLIGHT_RECOVERY
Definition
flight_state.h:30
FLIGHT_SELF_TEST
@ FLIGHT_SELF_TEST
Definition
flight_state.h:26
FLIGHT_ARMED
@ FLIGHT_ARMED
Definition
flight_state.h:28
FLIGHT_IDLE
@ FLIGHT_IDLE
Definition
flight_state.h:27
FLIGHT_LAUNCHED
@ FLIGHT_LAUNCHED
Definition
flight_state.h:29
FLIGHT_STATE_COUNT
@ FLIGHT_STATE_COUNT
Definition
flight_state.h:31
flight_event_t
flight_event_t
Definition
flight_state.h:34
FLIGHT_EV_LAUNCH_DETECTED
@ FLIGHT_EV_LAUNCH_DETECTED
Definition
flight_state.h:38
FLIGHT_EV_ARM
@ FLIGHT_EV_ARM
Definition
flight_state.h:36
FLIGHT_EV_UNARM
@ FLIGHT_EV_UNARM
Definition
flight_state.h:37
FLIGHT_EV_APOGEE_DETECTED
@ FLIGHT_EV_APOGEE_DETECTED
Definition
flight_state.h:39
FLIGHT_EV_SELF_TEST_DONE
@ FLIGHT_EV_SELF_TEST_DONE
Definition
flight_state.h:35
FLIGHT_EVENT_COUNT
@ FLIGHT_EVENT_COUNT
Definition
flight_state.h:40
flight_state_logs_to_emmc
bool flight_state_logs_to_emmc(flight_state_t state)
Definition
flight_state.c:22
state
static ActuatorControllerState state
Definition
main.cpp:57
firmware
Flight_Computer
src
app
flight_state.h
Generated by
1.15.0