From b8f4d8690bec206be73a4e819ae71685177ae3e9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Dec 2020 23:38:06 +0100 Subject: [PATCH] determination of freeRTOS features from version --- osal/FreeRTOS/BinSemaphUsingTask.h | 3 --- osal/FreeRTOS/PeriodicTask.cpp | 18 +++++++++++------- osal/FreeRTOS/PeriodicTask.h | 1 + 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/osal/FreeRTOS/BinSemaphUsingTask.h b/osal/FreeRTOS/BinSemaphUsingTask.h index 0061c252..8a413d5a 100644 --- a/osal/FreeRTOS/BinSemaphUsingTask.h +++ b/osal/FreeRTOS/BinSemaphUsingTask.h @@ -10,9 +10,6 @@ #if (tskKERNEL_VERSION_MAJOR == 8 && tskKERNEL_VERSION_MINOR > 2) || \ tskKERNEL_VERSION_MAJOR > 8 -// todo: does not work for older FreeRTOS version, so we should -// actually check whether tskKERNEL_VERSION_MAJOR is larger than.. 7 or 8 ? - /** * @brief Binary Semaphore implementation using the task notification value. * The notification value should therefore not be used diff --git a/osal/FreeRTOS/PeriodicTask.cpp b/osal/FreeRTOS/PeriodicTask.cpp index 04c588d2..96389187 100644 --- a/osal/FreeRTOS/PeriodicTask.cpp +++ b/osal/FreeRTOS/PeriodicTask.cpp @@ -80,10 +80,16 @@ void PeriodicTask::taskFunctionality() { object->performOperation(); } - checkMissedDeadline(xLastWakeTime, xPeriod); - - vTaskDelayUntil(&xLastWakeTime, xPeriod); - +#if (tskKERNEL_VERSION_MAJOR == 10 && tskKERNEL_VERSION_MINOR >= 4) || \ + tskKERNEL_VERSION_MAJOR > 10 + BaseType_t wasDelayed = xTaskDelayUntil(&xLastWakeTime, xPeriod); + if(wasDelayed == pdFALSE) { + handleMissedDeadline(); + } +#else + checkMissedDeadline(xLastWakeTime, xPeriod); + vTaskDelayUntil(&xLastWakeTime, xPeriod); +#endif } } @@ -112,8 +118,6 @@ void PeriodicTask::checkMissedDeadline(const TickType_t xLastWakeTime, * it. */ TickType_t currentTickCount = xTaskGetTickCount(); TickType_t timeToWake = xLastWakeTime + interval; -#if tskKERNEL_VERSION_MAJOR >= 10 && tskKERNEL_VERSION_MINOR > 4) -#else // Time to wake has not overflown. if(timeToWake > xLastWakeTime) { /* If the current time has overflown exclusively or the current @@ -128,7 +132,7 @@ void PeriodicTask::checkMissedDeadline(const TickType_t xLastWakeTime, else if((timeToWake < xLastWakeTime) and (currentTickCount > timeToWake)) { handleMissedDeadline(); } -#endif + } TaskHandle_t PeriodicTask::getTaskHandle() { diff --git a/osal/FreeRTOS/PeriodicTask.h b/osal/FreeRTOS/PeriodicTask.h index 87b8b6d2..80d00bf1 100644 --- a/osal/FreeRTOS/PeriodicTask.h +++ b/osal/FreeRTOS/PeriodicTask.h @@ -71,6 +71,7 @@ public: TaskHandle_t getTaskHandle() override; protected: + bool started; TaskHandle_t handle;