WATCHDOG TIMER FreeRTOS CCO implementation file.
More...
#include <stdio.h>
#include <watchdog_timer_freertos.h>
#include <watchdog_timer_freertos_configuration.h>
#include "FreeRTOS.h"
#include "timers.h"
#include "LLWATCHDOG_TIMER_configuration.h"
#include "LLWATCHDOG_TIMER_impl.h"
Go to the source code of this file.
WATCHDOG TIMER FreeRTOS CCO implementation file.
- Author
- MicroEJ Developer Team
- Version
- 2.1.0
- Date
- 29 April 2022
Definition in file watchdog_timer_checkpoint_freertos.c.
§ watchdog_timer_freertos_print_tasks_state()
void watchdog_timer_freertos_print_tasks_state |
( |
void |
| ) |
|
Prints the current FreeRTOS tasks state.
- Note
- The macros
configUSE_TRACE_FACILITY
and configUSE_STATS_FORMATTING_FUNCTIONS
need to be defined and set to 1 in FreeRTOSConfig.h otherwise no task state will be printed.
Definition at line 131 of file watchdog_timer_checkpoint_freertos.c.
132 #if (configUSE_TRACE_FACILITY == 1) && (configUSE_STATS_FORMATTING_FUNCTIONS == 1) 133 char* tasks_log_buffer;
134 uint16_t number_of_tasks = 0;
137 number_of_tasks = uxTaskGetNumberOfTasks();
139 if(0 < number_of_tasks){
141 tasks_log_buffer = pvPortMalloc(number_of_tasks * 50 *
sizeof(
char));
142 vTaskList(tasks_log_buffer);
143 printf(
"******************************************\n");
144 printf(
"Task \t State Prio Stack Num\n");
145 printf(
"******************************************\n");
146 printf(
"%s \n", tasks_log_buffer);
147 printf(
"******************************************\n");
148 printf(
"X-runnning, B–Blocked, R–Ready, D–Deleted, S–Suspended\n");
150 vPortFree(tasks_log_buffer);
152 LLWATCHDOG_TIMER_DEBUG_TRACE(
"No tasks retrieved with uxTaskGetNumberOfTasks()\n");
§ watchdog_timer_freertos_scheduler_checkpoint_start()
int32_t watchdog_timer_freertos_scheduler_checkpoint_start |
( |
void |
| ) |
|
Starts the FreeRTOS scheduler checkpoint.
This function creates a FreeRTOS software timer and registers a watchdog checkpoint for the FreeRTOS scheduler activity. Each time the timer expires, it calls LLWATCHDOG_TIMER_IMPL_checkpoint(unt32_t checkpointId)
with the recorded ID to attest the FreeRTOS scheduler activity.
- Returns
- CHECKPOINT_FREERTOS_OK on success.
- CHECKPOINT_FREERTOS_ERROR if an error occurs.
- Note
- This function does nothing if the checkpoint is already started.
Definition at line 67 of file watchdog_timer_checkpoint_freertos.c.
68 if (NULL != wtd_rtos_timer && WATCHDOG_TIMER_ERROR != checkpoint_id_rtos_scheduler) {
69 LLWATCHDOG_TIMER_DEBUG_TRACE(
"Watchdog FreeRTOS scheduler checkpoint already started.\n");
73 if (NULL == wtd_rtos_timer && WATCHDOG_TIMER_ERROR == checkpoint_id_rtos_scheduler){
74 wtd_rtos_timer = xTimerCreate(
75 "watchdog_timer_rtos_check",
79 watchdog_timer_freertos_check_callback);
81 if (NULL == wtd_rtos_timer) {
82 LLWATCHDOG_TIMER_DEBUG_TRACE(
"Watchdog FreeRTOS SW timer creation failed\n");
86 if(pdFAIL == xTimerStart( wtd_rtos_timer, 0 )){
87 LLWATCHDOG_TIMER_DEBUG_TRACE(
"Fail to start Watchdog FreeRTOS SW timer\n");
88 xTimerDelete( wtd_rtos_timer, 0 );
89 wtd_rtos_timer = NULL;
92 checkpoint_id_rtos_scheduler = LLWATCHDOG_TIMER_IMPL_registerCheckpoint();
93 if(WATCHDOG_TIMER_ERROR == checkpoint_id_rtos_scheduler){
94 LLWATCHDOG_TIMER_DEBUG_TRACE(
"Fail to register a checkpoint for Watchdog FreeRTOS scheduler activity\n");
95 xTimerDelete( wtd_rtos_timer, 0 );
96 wtd_rtos_timer = NULL;
106 LLWATCHDOG_TIMER_DEBUG_TRACE(
"Cannot restart the scheduler checkpoint when it was not correctly stopped.\n");
#define CHECKPOINT_FREERTOS_OK
Error codes constants.
#define CHECKPOINT_FREERTOS_ERROR
#define FREERTOS_TIMER_PERIOD_MS
Period (in milliseconds) of the FreeRTOS timer that will attest the FreeRTOS scheduler activity...
§ watchdog_timer_freertos_scheduler_checkpoint_stop()
int32_t watchdog_timer_freertos_scheduler_checkpoint_stop |
( |
void |
| ) |
|
Stops the FreeRTOS scheduler checkpoint.
This function stops the software timer and then unregisters the FreeRTOS scheduler checkpoint created in watchdog_timer_freertos_scheduler_checkpoint_start(void)
.
- Returns
- CHECKPOINT_FREERTOS_OK on success.
- CHECKPOINT_FREERTOS_ERROR if an error occurs.
- Note
- If this function fails when attempting to unregister the checkpoint ID, the software timer that has been stopped can no longer attest the scheduler activity and this may trigger the watchdog.
Definition at line 110 of file watchdog_timer_checkpoint_freertos.c.
111 if(NULL != wtd_rtos_timer){
112 if(pdFAIL == xTimerStop( wtd_rtos_timer, 0 )){
113 LLWATCHDOG_TIMER_DEBUG_TRACE(
"Watchdog FreeRTOS fails to stop the SW timer\n");
116 xTimerDelete( wtd_rtos_timer, 0 );
117 wtd_rtos_timer = NULL;
120 if(WATCHDOG_TIMER_ERROR != checkpoint_id_rtos_scheduler){
121 if(WATCHDOG_TIMER_ERROR == LLWATCHDOG_TIMER_IMPL_unregisterCheckpoint(checkpoint_id_rtos_scheduler)){
122 LLWATCHDOG_TIMER_DEBUG_TRACE(
"Fail to unregister the FreeRTOS scheduler checkpoint!\n");
125 checkpoint_id_rtos_scheduler = WATCHDOG_TIMER_ERROR;
#define CHECKPOINT_FREERTOS_OK
Error codes constants.
#define CHECKPOINT_FREERTOS_ERROR