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

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

#include "common/phal/gpio.h"
#include "common/freertos/freertos.h"

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)
 

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:
status_leds_t status_leds = { \
.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), \
.state = HEARTBEAT_STATE_PREFLIGHT \
}; \
void heartbeat_wrapper(void) { heartbeat_task(&status_leds); }; \
DEFINE_TASK(heartbeat_wrapper, HEARTBEAT_PERIOD_MS, osPriorityLow, STACK_512)
Definition heartbeat.h:23

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:
START_TASK(heartbeat_wrapper)
#define START_TASK(NAME)
Initializes and starts the defined task.
Definition freertos.h:87