PER Firmware
Loading...
Searching...
No Matches
heartbeat.h
Go to the documentation of this file.
1#ifndef HEARTBEAT_H
2#define HEARTBEAT_H
3
11#if defined(STM32F407xx)
13#elif defined(STM32G474xx)
15#else
16#error "Unsupported heartbeat target"
17#endif
18#include "common/rtos/rtos.h"
19
20static constexpr uint32_t PREFLIGHT_DURATION_MS = 1500;
21static constexpr uint32_t HEARTBEAT_PERIOD_MS = 100;
22static constexpr uint32_t CONN_LED_TIMEOUT_MS = 1000;
23
28
29typedef struct {
30 GPIO_TypeDef *heartbeat_port;
31 uint32_t heartbeat_pin;
32 GPIO_TypeDef *connection_port;
34 GPIO_TypeDef *error_port;
35 uint32_t error_pin;
36 void (*preflight_callback)(void);
39
40extern void heartbeat_task(status_leds_t *leds);
41
53#define DEFINE_HEARTBEAT_TASK(PREFLIGHT_CALLBACK) \
54 status_leds_t status_leds = { \
55 .heartbeat_port = HEARTBEAT_LED_PORT, \
56 .heartbeat_pin = HEARTBEAT_LED_PIN, \
57 .connection_port = CONNECTION_LED_PORT, \
58 .connection_pin = CONNECTION_LED_PIN, \
59 .error_port = ERROR_LED_PORT, \
60 .error_pin = ERROR_LED_PIN, \
61 .preflight_callback = (PREFLIGHT_CALLBACK), \
62 .state = HEARTBEAT_STATE_PREFLIGHT \
63 }; \
64 void heartbeat_wrapper(void) { heartbeat_task(&status_leds); }; \
65 RTOS_DEFINE_TASK(heartbeat_wrapper, HEARTBEAT_PERIOD_MS, TASK_PRIORITY_LOW, STACK_512)
66
67#define START_HEARTBEAT_TASK() RTOS_START_TASK(heartbeat_wrapper)
68
69#endif // HEARTBEAT_H
heartbeat_state_t
Definition heartbeat.h:24
@ HEARTBEAT_STATE_PREFLIGHT
Definition heartbeat.h:25
@ HEARTBEAT_STATE_NORMAL
Definition heartbeat.h:26
static constexpr uint32_t CONN_LED_TIMEOUT_MS
Definition heartbeat.h:22
void heartbeat_task(status_leds_t *leds)
Definition heartbeat.c:35
static constexpr uint32_t HEARTBEAT_PERIOD_MS
Definition heartbeat.h:21
static constexpr uint32_t PREFLIGHT_DURATION_MS
Definition heartbeat.h:20
GPIO Driver for STM32F4 Devices.
G4 GPIO public API.
Wrapper macros for FreeRTOS constructs (tasks, queues, semaphores) to simplify static memory allocati...
Definition heartbeat.h:29
heartbeat_state_t state
Definition heartbeat.h:37
uint32_t error_pin
Definition heartbeat.h:35
uint32_t heartbeat_pin
Definition heartbeat.h:31
uint32_t connection_pin
Definition heartbeat.h:33
GPIO_TypeDef * connection_port
Definition heartbeat.h:32
GPIO_TypeDef * error_port
Definition heartbeat.h:34
GPIO_TypeDef * heartbeat_port
Definition heartbeat.h:30