PER Firmware
Loading...
Searching...
No Matches
heartbeat.h File Reference

Shared heartbeat task implementation for status LEDs. More...

#include "common/rtos/rtos.h"
Include dependency graph for heartbeat.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  status_leds_t
 

Macros

#define DEFINE_HEARTBEAT_TASK(PREFLIGHT_CALLBACK)
 Macro to define a heartbeat task with predefined behavior for status LEDs.
 
#define START_HEARTBEAT_TASK()
 

Enumerations

enum  heartbeat_state_t : uint8_t { HEARTBEAT_STATE_PREFLIGHT , HEARTBEAT_STATE_NORMAL }
 

Functions

void heartbeat_task (status_leds_t *leds)
 

Variables

static constexpr uint32_t PREFLIGHT_DURATION_MS = 1500
 
static constexpr uint32_t HEARTBEAT_PERIOD_MS = 100
 
static constexpr uint32_t CONN_LED_TIMEOUT_MS = 1000
 

Detailed Description

Shared heartbeat task implementation for status LEDs.

Author
Irving Wang (irvin.nosp@m.gw@p.nosp@m.urdue.nosp@m..edu)

Macro Definition Documentation

◆ DEFINE_HEARTBEAT_TASK

#define DEFINE_HEARTBEAT_TASK ( PREFLIGHT_CALLBACK)
Value:
.heartbeat_port = HEARTBEAT_LED_PORT, \
.heartbeat_pin = HEARTBEAT_LED_PIN, \
.connection_port = CONNECTION_LED_PORT, \
.connection_pin = CONNECTION_LED_PIN, \
.error_port = ERROR_LED_PORT, \
.error_pin = ERROR_LED_PIN, \
.preflight_callback = (PREFLIGHT_CALLBACK), \
}; \
void heartbeat_wrapper(void) { heartbeat_task(&status_leds); }; \
RTOS_DEFINE_TASK(heartbeat_wrapper, HEARTBEAT_PERIOD_MS, TASK_PRIORITY_LOW, STACK_512)
#define ERROR_LED_PIN
Definition main.h:20
#define HEARTBEAT_LED_PIN
Definition main.h:18
#define ERROR_LED_PORT
Definition main.h:19
#define CONNECTION_LED_PIN
Definition main.h:22
#define HEARTBEAT_LED_PORT
Definition main.h:17
#define CONNECTION_LED_PORT
Definition main.h:21
status_leds_t status_leds
@ HEARTBEAT_STATE_PREFLIGHT
Definition heartbeat.h:25
void heartbeat_task(status_leds_t *leds)
Definition heartbeat.c:35
static constexpr uint32_t HEARTBEAT_PERIOD_MS
Definition heartbeat.h:21
@ TASK_PRIORITY_LOW
Definition rtos.h:34
@ STACK_512
Definition rtos.h:26
Definition heartbeat.h:29

Macro to define a heartbeat task with predefined behavior for status LEDs.

Usage:

  1. Ensure that the macros HEARTBEAT_LED_PORT, HEARTBEAT_LED_PIN, CONNECTION_LED_PORT, CONNECTION_LED_PIN, ERROR_LED_PORT, and ERROR_LED_PIN are defined
  2. Init the GPIOS for the LEDs as outputs.
  3. Call DEFINE_HEARTBEAT_TASK() in your source file to define the task.
  4. Call START_HEARTBEAT_TASK() in your main function after initializing the kernel to start the task.
Parameters
PREFLIGHT_CALLBACKoptional callback function periodically called during the preflight state.

◆ START_HEARTBEAT_TASK

#define START_HEARTBEAT_TASK ( )
Value:
RTOS_START_TASK(heartbeat_wrapper)
#define RTOS_START_TASK(NAME)
Creates and starts a previously defined task.
Definition rtos.h:109

Enumeration Type Documentation

◆ heartbeat_state_t

enum heartbeat_state_t : uint8_t
Enumerator
HEARTBEAT_STATE_PREFLIGHT 
HEARTBEAT_STATE_NORMAL 

Function Documentation

◆ heartbeat_task()

void heartbeat_task ( status_leds_t * leds)
extern
Here is the call graph for this function:

Variable Documentation

◆ CONN_LED_TIMEOUT_MS

uint32_t CONN_LED_TIMEOUT_MS = 1000
staticconstexpr

◆ HEARTBEAT_PERIOD_MS

uint32_t HEARTBEAT_PERIOD_MS = 100
staticconstexpr

◆ PREFLIGHT_DURATION_MS

uint32_t PREFLIGHT_DURATION_MS = 1500
staticconstexpr