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
23extern "C" {
24#endif
25
26typedef 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 */
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
42
44
45typedef 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 */
50
51/* Where a confirmed ground command goes in `state`. */
53 flight_state_t* next);
54
55#ifdef __cplusplus
56}
57#endif
58#endif
flight_state_t
static ActuatorControllerState state
Definition main.cpp:57
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
Definition mode_core.h:45
@ MODE_TRANSITION
Definition mode_core.h:47
@ MODE_TO_IDLE_LOOP
Definition mode_core.h:46
@ MODE_IGNORE
Definition mode_core.h:48
mode_command_t
Definition mode_core.h:43
@ MODE_CMD_DISARM
Definition mode_core.h:43
@ MODE_CMD_ARM
Definition mode_core.h:43
mode_outputs_t mode_outputs(flight_state_t state)
Definition mode_core.c:3