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

Wrapper macros for FreeRTOS constructs (tasks, queues, semaphores) to simplify static memory allocation and initialization. More...

#include <stdint.h>

Go to the source code of this file.

Classes

struct  periodic_task_params_t
 

Macros

#define myIDENT(x)
 
#define myXSTR(x)
 
#define mySTR(x)
 
#define __FREERTOS_PATH(x, y)
 
#define _FREERTOS_PATH(y)
 
#define STACK_256   (256)
 
#define STACK_512   (512)
 
#define STACK_1024   (1024)
 
#define STACK_2048   (2048)
 
#define STACK_4096   (4096)
 
#define DEFINE_TASK(NAME, PERIOD_MS, PRIORITY, STACK_SIZE)
 Scaffolds the static memory for a FreeRTOS task.
 
#define START_TASK(NAME)
 Initializes and starts the defined task.
 
#define getTaskHandle(NAME)
 Retrieves the FreeRTOS task handle for the defined task.
 
#define DEFINE_QUEUE(NAME, ITEM, COUNT)
 Scaffolds the static memory for a FreeRTOS queue.
 
#define INIT_QUEUE(NAME, ITEM, COUNT)
 Initializes the defined static queue.
 
#define DEFINE_SEMAPHORE(NAME)
 Scaffolds the static memory for a semaphore (and related variants).
 
#define DEFINE_MUTEX(NAME)
 
#define DEFINE_COUNTING_SEMAPHORE(NAME)
 
#define DEFINE_BINARY_SEMAPHORE(NAME)
 
#define INIT_MUTEX(NAME)
 Initializes the defined mutex.
 
#define INIT_COUNTING_SEMAPHORE(NAME, MAX_COUNT)
 Initializes the defined static counting semaphore.
 
#define INIT_BINARY_SEMAPHORE(NAME)
 Initializes the defined static binary semaphore.
 
#define getTick()
 
#define getMS()
 
#define mDelay(ms)
 

Functions

void periodic_task_runner (void *arg)
 

Detailed Description

Wrapper macros for FreeRTOS constructs (tasks, queues, semaphores) to simplify static memory allocation and initialization.

Author
Irving Wang (irvin.nosp@m.gw@p.nosp@m.urdue.nosp@m..edu)
Eileen Yoon (eyn@p.nosp@m.urdu.nosp@m.e.edu)

Macro Definition Documentation

◆ __FREERTOS_PATH

#define __FREERTOS_PATH ( x,
y )
Value:
mySTR(myIDENT(x)y)

◆ _FREERTOS_PATH

#define _FREERTOS_PATH ( y)
Value:
__FREERTOS_PATH(_FREERTOS_DIR, y)

◆ DEFINE_BINARY_SEMAPHORE

#define DEFINE_BINARY_SEMAPHORE ( NAME)
Value:
#define DEFINE_SEMAPHORE(NAME)
Scaffolds the static memory for a semaphore (and related variants).
Definition freertos.h:113

◆ DEFINE_COUNTING_SEMAPHORE

#define DEFINE_COUNTING_SEMAPHORE ( NAME)
Value:

◆ DEFINE_MUTEX

#define DEFINE_MUTEX ( NAME)
Value:

◆ DEFINE_QUEUE

#define DEFINE_QUEUE ( NAME,
ITEM,
COUNT )
Value:
static_assert(COUNT > 0, "Queue count must be greater than 0"); \
QueueHandle_t NAME; \
static StaticQueue_t NAME##_cb; \
static uint8_t NAME##_data[sizeof(ITEM) * (COUNT)];

Scaffolds the static memory for a FreeRTOS queue.

◆ DEFINE_SEMAPHORE

#define DEFINE_SEMAPHORE ( NAME)
Value:
SemaphoreHandle_t NAME; \
static StaticSemaphore_t NAME##_cb;

Scaffolds the static memory for a semaphore (and related variants).

◆ DEFINE_TASK

#define DEFINE_TASK ( NAME,
PERIOD_MS,
PRIORITY,
STACK_SIZE )
Value:
static_assert( \
(STACK_SIZE) % sizeof(StackType_t) == 0, \
"Stack size must be a multiple of StackType_t" \
); \
static StaticTask_t NAME##_tcb; \
static StackType_t NAME##_stack[(STACK_SIZE) / sizeof(StackType_t)]; \
periodic_task_params_t NAME##_params = { \
.taskFunction = (void (*)(void))NAME, \
.period_ms = (PERIOD_MS), \
}; \
osThreadAttr_t NAME##_attrs = { \
.name = #NAME, \
.attr_bits = osThreadDetached, \
.cb_mem = &NAME##_tcb, \
.cb_size = sizeof(StaticTask_t), \
.stack_mem = NAME##_stack, \
.stack_size = sizeof(NAME##_stack), \
.priority = (osPriority_t)(PRIORITY), \
}; \
osThreadId_t NAME##_handle;
Definition freertos.h:46

Scaffolds the static memory for a FreeRTOS task.

Parameters
NAMEThe function name of the task.
PERIOD_MSTask period in milliseconds.
PRIORITYCMSIS-RTOS2 priority (e.g., osPriorityNormal).
STACK_SIZEStack size in bytes.

◆ getMS

#define getMS ( )
Value:
(getTick() * portTICK_PERIOD_MS)

◆ getTaskHandle

#define getTaskHandle ( NAME)
Value:
(NAME##_handle)

Retrieves the FreeRTOS task handle for the defined task.

◆ getTick

#define getTick ( )
Value:
xTaskGetTickCount()

◆ INIT_BINARY_SEMAPHORE

#define INIT_BINARY_SEMAPHORE ( NAME)
Value:
(NAME = xSemaphoreCreateBinaryStatic(&(NAME##_cb)))

Initializes the defined static binary semaphore.

◆ INIT_COUNTING_SEMAPHORE

#define INIT_COUNTING_SEMAPHORE ( NAME,
MAX_COUNT )
Value:
(NAME = xSemaphoreCreateCountingStatic((MAX_COUNT), (MAX_COUNT), &(NAME##_cb)))

Initializes the defined static counting semaphore.

Note
initial count is set to max count (full by default)

◆ INIT_MUTEX

#define INIT_MUTEX ( NAME)
Value:
(NAME = xSemaphoreCreateMutexStatic(&(NAME##_cb)))

Initializes the defined mutex.

◆ INIT_QUEUE

#define INIT_QUEUE ( NAME,
ITEM,
COUNT )
Value:
(NAME = xQueueCreateStatic((COUNT), sizeof(ITEM), NAME##_data, &NAME##_cb))

Initializes the defined static queue.

◆ mDelay

#define mDelay ( ms)
Value:
(osDelay(pdMS_TO_TICKS((ms))))

◆ myIDENT

#define myIDENT ( x)
Value:
x

◆ mySTR

#define mySTR ( x)
Value:
myXSTR(x)

◆ myXSTR

#define myXSTR ( x)
Value:
#x

◆ START_TASK

#define START_TASK ( NAME)
Value:
(NAME##_handle = osThreadNew(periodic_task_runner, &NAME##_params, &NAME##_attrs))

Initializes and starts the defined task.