STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
app.c
Go to the documentation of this file.
1#include "app.h"
2
3#include "cmsis_os2.h"
4#include "emmc_stm32.h"
5#include "gnss_task.h"
6#include "idle_task.h"
7#include "mode.h"
8#include "radio_task.h"
9#include "sensors_task.h"
10#ifdef STAR_BENCH
11#include "bench_task.h"
12#endif
13
14static bool start_emmc(void) {
15 static const osThreadAttr_t attr = {
16 .name = "emmc",
17 .stack_size = 1024, /* emmc_stm32_writer_task: ~1 KB */
18 .priority = osPriorityLow,
19 };
20 if (emmc_stm32_init() != EMMC_OK) {
21 return false;
22 }
24}
25
29
30bool app_start(void) {
31 bool ok = start_emmc();
33 ok = gnss_task_start() && ok;
34 ok = radio_task_start() && ok;
35 ok = idle_task_start() && ok;
37#ifdef STAR_BENCH
38 /* Bench build (pio run -e bench): stay awake in SELF_TEST with the
39 * sensors and GPS running, so their readings can be watched over SWD.
40 * Not Idle, not ARMED: no sleep, no eMMC recording, no pyro. Never
41 * flown. */
44 ok = bench_task_start() && ok;
45#else
46 /* Every task starts stopped; the state decides what runs (mode_core). */
48#endif
49 return ok;
50}
@ FLIGHT_IDLE
static bool start_emmc(void)
Definition app.c:14
static void on_radio_command(radio_command_t command)
Definition app.c:26
bool app_start(void)
Definition app.c:30
bool bench_task_start(void)
osThreadId_t osThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr_t *attr)
Create a thread and add it to Active Threads.
Definition cmsis_os2.c:577
@ osPriorityLow
Priority: low.
Definition cmsis_os2.h:107
@ EMMC_OK
Definition emmc_port.h:23
void emmc_stm32_writer_task(void *argument)
Definition emmc_stm32.c:260
emmc_status_t emmc_stm32_init(void)
Definition emmc_stm32.c:235
static bool ok
Definition flight_e2e.c:435
void gnss_task_set_active(bool on)
Definition gnss_task.c:99
bool gnss_task_start(void)
Definition gnss_task.c:89
#define NULL
Definition usbd_def.h:44
bool idle_task_start(void)
Definition idle_task.c:113
void app_command(mode_command_t command)
Definition mode.c:52
void app_set_state(flight_state_t to)
Definition mode.c:22
@ MODE_CMD_DISARM
Definition mode_core.h:43
@ MODE_CMD_ARM
Definition mode_core.h:43
bool radio_task_start(void)
void radio_task_on_command(void(*callback)(radio_command_t))
radio_command_t
Definition radio_task.h:32
@ RADIO_CMD_ARM
Definition radio_task.h:32
bool sensors_task_start(void)
void sensors_task_set_active(bool on)
Attributes structure for thread.
Definition cmsis_os2.h:240