STM32 RTC Scheduler
RTC-based scheduler for ultra-low power applications
main.c File Reference

This file contains the main application implementation, including the RTOS task implementations, RTOS hooks and scheduler callback implementations. More...

#include "main.h"
#include "FreeRTOS.h"
#include "core_stop.h"
#include "error_handler.h"
#include "hardware.h"
#include "rtc.h"
#include "scheduler.h"
#include "task.h"
#include "timers.h"

Go to the source code of this file.

Functions

void TaskLedBlink (void *arg)
 This function implements the blinking LED RTOS task. More...
 
void TaskLedSteady (void *arg)
 This function implements the steady LED RTOS task. More...
 
void JobShortPeriodCallback (void)
 The callback function for the short period job. More...
 
void JobLongPeriodCallback (void)
 The callback function for the long period job. More...
 
TickType_t GetExpectedIdleTime (void)
 Get the expected idle time from RTOS kernel. More...
 
UBaseType_t IsDelayedTaskListEmpty (void)
 Check whether the delayed task list of RTOS is empty. More...
 
int main (void)
 The main function of the application. More...
 
void vApplicationDaemonTaskStartupHook (void)
 RTOS daemon startup callback. More...
 
void vApplicationIdleHook (void)
 RTOS idle task hook. More...
 
void vApplicationStackOverflowHook (TaskHandle_t xTask, char *pcTaskName)
 RTOS task stack overflow hook. More...
 
void vApplicationMallocFailedHook (void)
 RTOS malloc failed hook. More...
 

Variables

TaskHandle_t taskHandleLedBlink = NULL
 
TaskHandle_t taskHandleLedSteady = NULL
 

Detailed Description

This file contains the main application implementation, including the RTOS task implementations, RTOS hooks and scheduler callback implementations.

STM32 RTC Scheduler

Author
Akos Pasztor
See also
Please refer to README for detailed information.

Definition in file main.c.

Function Documentation

◆ GetExpectedIdleTime()

TickType_t GetExpectedIdleTime ( void  )

Get the expected idle time from RTOS kernel.

Returns
The expected idle time in RTOS ticks.

Definition at line 27 of file freertos_tasks_c_additions.h.

◆ IsDelayedTaskListEmpty()

UBaseType_t IsDelayedTaskListEmpty ( void  )

Check whether the delayed task list of RTOS is empty.

Return values
pdTRUEif the delayed task list is empty.
pdFALSEif there is a task waiting in the delayed task list.

Definition at line 90 of file freertos_tasks_c_additions.h.

◆ JobLongPeriodCallback()

void JobLongPeriodCallback ( void  )

The callback function for the long period job.

This function is called when the job with long period is pending. The function unblocks the steady LED RTOS task.

Warning
The function is executed within an interrupt context. Therefore, this function must not block, furthermore only interrupt-safe RTOS API calls are allowed.

Definition at line 119 of file main.c.

◆ JobShortPeriodCallback()

void JobShortPeriodCallback ( void  )

The callback function for the short period job.

This function is called when the job with short period is pending. The function unblocks the blinking LED RTOS task.

Warning
The function is executed within an interrupt context. Therefore, this function must not block, furthermore only interrupt-safe RTOS API calls are allowed.

Definition at line 99 of file main.c.

◆ main()

int main ( void  )

The main function of the application.

Returns
The termination value of the application. This function must never return.

Definition at line 51 of file main.c.

◆ TaskLedBlink()

void TaskLedBlink ( void *  arg)

This function implements the blinking LED RTOS task.

This task waits for an RTOS task notification to unblock. The notification is given in the callback function of the short period job. The task blinks the LD3 LED twice, then waits until the task is unblocked again.

Parameters
argThe RTOS task argument.

Definition at line 138 of file main.c.

◆ TaskLedSteady()

void TaskLedSteady ( void *  arg)

This function implements the steady LED RTOS task.

This task waits for an RTOS task notification to unblock. The notification is given in the callback function of the long period job. The task turns on the LD2 LED, waits 1 second, turns off the LD2 LED, then waits until the task is unblocked again.

Parameters
argThe RTOS task argument.

Definition at line 167 of file main.c.

◆ vApplicationDaemonTaskStartupHook()

void vApplicationDaemonTaskStartupHook ( void  )

RTOS daemon startup callback.

This function is called only once after starting the kernel. The function runs in the context of the built-in RTOS timer/daemon task.

Definition at line 190 of file main.c.

◆ vApplicationIdleHook()

void vApplicationIdleHook ( void  )

RTOS idle task hook.

This function is called once per idle task execution. During each function call, the function asks the RTOS kernel what is the expected idle time and whether the delayed task list is empty. If the expected idle time is greater than a specified duration and the delayed task list is empty, the function enters into STOP2 mode.

Definition at line 204 of file main.c.

◆ vApplicationMallocFailedHook()

void vApplicationMallocFailedHook ( void  )

RTOS malloc failed hook.

This callback function is called upon memory allocation failure.

Definition at line 238 of file main.c.

◆ vApplicationStackOverflowHook()

void vApplicationStackOverflowHook ( TaskHandle_t  xTask,
char *  pcTaskName 
)

RTOS task stack overflow hook.

This callback is function is called upon detecting a stack overflow during task execution.

Parameters
xTaskHandle to the task where stack overflow is detected.
pcTaskNameName of task where stack overflow is detected.

Definition at line 225 of file main.c.

Variable Documentation

◆ taskHandleLedBlink

TaskHandle_t taskHandleLedBlink = NULL

RTOS task handle for the blinking LED task

Definition at line 29 of file main.c.

◆ taskHandleLedSteady

TaskHandle_t taskHandleLedSteady = NULL

RTOS task handle for the steady LED task

Definition at line 32 of file main.c.