STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
mode_core.h
Go to the documentation of this file.
1
#ifndef STAR_MODE_CORE_H
2
#define STAR_MODE_CORE_H
3
4
/*
5
* What runs in each flight state, and what a ground command does there.
6
* Portable: src/app/mode.c applies it on the board, the tests check it here.
7
*
8
* SELF_TEST bring-up checks; nothing sampling yet
9
* IDLE only the radio (Inez): IMU/high-g powered down, baro
10
* idle, GPS rail off (REG_3V6_EN feeds only the GPS,
11
* schematic p.10/p.12), W5500 held in reset; the Idle
12
* loop (PR #162) sleeps in Stop between heartbeats
13
* ARMED onwards everything on; the eMMC log records
14
* (flight_state_logs_to_emmc)
15
* ARMED means "record", never pyro: no pyro output is driven anywhere.
16
*/
17
18
#include <stdbool.h>
19
20
#include "
flight_state.h
"
21
22
#ifdef __cplusplus
23
extern
"C"
{
24
#endif
25
26
typedef
struct
{
27
bool
sensors
;
/* IMU, high-g, baro sampling */
28
bool
gps
;
/* GPS rail on, GNSS task running */
29
bool
ethernet
;
/* W5500 out of reset */
30
bool
idle_loop
;
/* heartbeats + Stop between them */
31
bool
radio_sniff
;
/* radio duty-cycles (SetRxDutyCycle) instead of
32
listening continuously; only in Idle */
33
}
mode_outputs_t
;
34
35
/* Idle sniff timing (SX1262 DS 13.1.7, p.71; Megan, #182): listen 33 ms,
36
* sleep 1 s. The ground must send Arm / Un-arm with a preamble longer than
37
* the sleep (>= 260 symbols, ~1.08 s at SF9/125 kHz) or it can be missed. */
38
#define MODE_SNIFF_RX_MS 33U
39
#define MODE_SNIFF_SLEEP_MS 1000U
40
41
mode_outputs_t
mode_outputs
(
flight_state_t
state
);
42
43
typedef
enum
{
MODE_CMD_ARM
= 1,
MODE_CMD_DISARM
}
mode_command_t
;
44
45
typedef
enum
{
46
MODE_TO_IDLE_LOOP
,
/* IDLE: the Idle loop decides (Arm -> ARM_REQUESTED) */
47
MODE_TRANSITION
,
/* go to *next now */
48
MODE_IGNORE
/* the state table does not move on it */
49
}
mode_route_t
;
50
51
/* Where a confirmed ground command goes in `state`. */
52
mode_route_t
mode_route_command
(
flight_state_t
state
,
mode_command_t
command,
53
flight_state_t
* next);
54
55
#ifdef __cplusplus
56
}
57
#endif
58
#endif
flight_state.h
flight_state_t
flight_state_t
Definition
flight_state.h:25
state
static ActuatorControllerState state
Definition
main.cpp:57
mode_route_command
mode_route_t mode_route_command(flight_state_t state, mode_command_t command, flight_state_t *next)
Definition
mode_core.c:23
mode_route_t
mode_route_t
Definition
mode_core.h:45
MODE_TRANSITION
@ MODE_TRANSITION
Definition
mode_core.h:47
MODE_TO_IDLE_LOOP
@ MODE_TO_IDLE_LOOP
Definition
mode_core.h:46
MODE_IGNORE
@ MODE_IGNORE
Definition
mode_core.h:48
mode_command_t
mode_command_t
Definition
mode_core.h:43
MODE_CMD_DISARM
@ MODE_CMD_DISARM
Definition
mode_core.h:43
MODE_CMD_ARM
@ MODE_CMD_ARM
Definition
mode_core.h:43
mode_outputs
mode_outputs_t mode_outputs(flight_state_t state)
Definition
mode_core.c:3
mode_outputs_t
Definition
mode_core.h:26
mode_outputs_t::idle_loop
bool idle_loop
Definition
mode_core.h:30
mode_outputs_t::gps
bool gps
Definition
mode_core.h:28
mode_outputs_t::sensors
bool sensors
Definition
mode_core.h:27
mode_outputs_t::radio_sniff
bool radio_sniff
Definition
mode_core.h:31
mode_outputs_t::ethernet
bool ethernet
Definition
mode_core.h:29
firmware
Flight_Computer
src
app
mode_core.h
Generated by
1.15.0