25 #include "LLWATCHDOG_TIMER_configuration.h" 26 #include "LLWATCHDOG_TIMER_impl.h" 42 #if WATCHDOG_TIMER_FREERTOS_CONFIGURATION_VERSION != 1 43 #error "Version of the configuration file watchdog_timer_freertos_configuration.h is not compatible with this implementation." 48 static xTimerHandle wtd_rtos_timer = NULL;
53 static volatile int32_t checkpoint_id_rtos_scheduler = WATCHDOG_TIMER_ERROR;
62 static void watchdog_timer_freertos_check_callback(xTimerHandle pxTimer);
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");
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;
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");
159 static void watchdog_timer_freertos_check_callback(xTimerHandle pxTimer){
160 LLWATCHDOG_TIMER_DEBUG_TRACE(
"Watchdog FreeRTOS SW timer callback: attest the FreeRTOS scheduler activity with the checkpoint ID %d", checkpoint_id_rtos_scheduler);
161 if(WATCHDOG_TIMER_ERROR == LLWATCHDOG_TIMER_IMPL_checkpoint(checkpoint_id_rtos_scheduler)){
162 LLWATCHDOG_TIMER_DEBUG_TRACE(
"Watchdog FreeRTOS fail to attest the scheduler activity\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 CCO header file.
int32_t watchdog_timer_freertos_scheduler_checkpoint_stop(void)
Stops the FreeRTOS scheduler checkpoint.
void watchdog_timer_freertos_print_tasks_state(void)
Prints the current FreeRTOS tasks state.
int32_t watchdog_timer_freertos_scheduler_checkpoint_start(void)
Starts the FreeRTOS scheduler checkpoint.
WATCHDOG TIMER FreeRTOS CCO configuration file.