extended task management for freeRTOS
This commit is contained in:
parent
15c03863c0
commit
281da25bf9
@ -6,9 +6,10 @@ PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority,
|
|||||||
TaskStackSize setStack, TaskPeriod setPeriod,
|
TaskStackSize setStack, TaskPeriod setPeriod,
|
||||||
void (*setDeadlineMissedFunc)()) :
|
void (*setDeadlineMissedFunc)()) :
|
||||||
started(false), handle(NULL), period(setPeriod), deadlineMissedFunc(
|
started(false), handle(NULL), period(setPeriod), deadlineMissedFunc(
|
||||||
setDeadlineMissedFunc) {
|
setDeadlineMissedFunc)
|
||||||
|
{
|
||||||
BaseType_t status = xTaskCreate(taskEntryPoint, name, setStack, this, setPriority, &handle);
|
BaseType_t status = xTaskCreate(taskEntryPoint, name,
|
||||||
|
setStack, this, setPriority, &handle);
|
||||||
if(status != pdPASS){
|
if(status != pdPASS){
|
||||||
sif::debug << "PeriodicTask Insufficient heap memory remaining. Status: "
|
sif::debug << "PeriodicTask Insufficient heap memory remaining. Status: "
|
||||||
<< status << std::endl;
|
<< status << std::endl;
|
||||||
|
@ -13,11 +13,9 @@
|
|||||||
class ExecutableObjectIF;
|
class ExecutableObjectIF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class represents a specialized task for periodic activities of multiple objects.
|
* @brief This class represents a specialized task for
|
||||||
*
|
* periodic activities of multiple objects.
|
||||||
* @details MultiObjectTask is an extension to ObjectTask in the way that it is able to execute
|
* @details
|
||||||
* multiple objects that implement the ExecutableObjectIF interface. The objects must be
|
|
||||||
* added prior to starting the task.
|
|
||||||
*
|
*
|
||||||
* @ingroup task_handling
|
* @ingroup task_handling
|
||||||
*/
|
*/
|
||||||
@ -25,21 +23,22 @@ class PeriodicTask: public PeriodicTaskIF {
|
|||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Standard constructor of the class.
|
* @brief Standard constructor of the class.
|
||||||
* @details The class is initialized without allocated objects. These need to be added
|
* @details
|
||||||
* with #addObject.
|
* The class is initialized without allocated objects. These need to be added
|
||||||
* In the underlying TaskBase class, a new operating system task is created.
|
* with #addComponent. In the underlying TaskBase class, a new operating
|
||||||
* In addition to the TaskBase parameters, the period, the pointer to the
|
* system task is created. In addition to the TaskBase parameters,
|
||||||
* aforementioned initialization function and an optional "deadline-missed"
|
* the period, the pointer to the aforementioned initialization function and
|
||||||
* function pointer is passed.
|
* an optional "deadline-missed" function pointer is passed.
|
||||||
* @param priority Sets the priority of a task. Values range from a low 0 to a high 99.
|
* @param priority Sets the priority of a task. Values depend on
|
||||||
|
* freeRTOS configuration, high number means high priority.
|
||||||
* @param stack_size The stack size reserved by the operating system for the task.
|
* @param stack_size The stack size reserved by the operating system for the task.
|
||||||
* @param setPeriod The length of the period with which the task's functionality will be
|
* @param setPeriod The length of the period with which the task's
|
||||||
* executed. It is expressed in clock ticks.
|
* functionality will be executed. It is expressed in clock ticks.
|
||||||
* @param setDeadlineMissedFunc The function pointer to the deadline missed function
|
* @param setDeadlineMissedFunc
|
||||||
* that shall be assigned.
|
* The function pointer to the deadline missed function that shall be assigned.
|
||||||
*/
|
*/
|
||||||
PeriodicTask(const char *name, TaskPriority setPriority, TaskStackSize setStack, TaskPeriod setPeriod,
|
PeriodicTask(const char *name, TaskPriority setPriority, TaskStackSize setStack,
|
||||||
void (*setDeadlineMissedFunc)());
|
TaskPeriod setPeriod,void (*setDeadlineMissedFunc)());
|
||||||
/**
|
/**
|
||||||
* @brief Currently, the executed object's lifetime is not coupled with the task object's
|
* @brief Currently, the executed object's lifetime is not coupled with the task object's
|
||||||
* lifetime, so the destructor is empty.
|
* lifetime, so the destructor is empty.
|
||||||
|
@ -44,10 +44,6 @@ ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t TaskFactory::delayTask(uint32_t delayMs) {
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(delayMs));
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
TaskFactory::TaskFactory() {
|
TaskFactory::TaskFactory() {
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
#include <framework/osal/FreeRTOS/TaskManagement.h>
|
#include <framework/osal/FreeRTOS/TaskManagement.h>
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include "FreeRTOS.h"
|
|
||||||
#include "task.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskManagement::requestContextSwitchFromTask() {
|
void TaskManagement::requestContextSwitchFromTask() {
|
||||||
vTaskDelay(0);
|
vTaskDelay(0);
|
||||||
}
|
}
|
||||||
@ -18,5 +13,16 @@ void TaskManagement::requestContextSwitch(CallContext callContext = CallContext:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TaskHandle_t TaskManagement::getCurrentTaskHandle() {
|
||||||
|
return xTaskGetCurrentTaskHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
configSTACK_DEPTH_TYPE TaskManagement::getTaskStackHighWatermark() {
|
||||||
|
return uxTaskGetStackHighWaterMark(TaskManagement::getCurrentTaskHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t TaskManagement::delayTask(uint32_t delayMs) {
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(delayMs));
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
#ifndef FRAMEWORK_OSAL_FREERTOS_TASKMANAGEMENT_H_
|
#ifndef FRAMEWORK_OSAL_FREERTOS_TASKMANAGEMENT_H_
|
||||||
#define FRAMEWORK_OSAL_FREERTOS_TASKMANAGEMENT_H_
|
#define FRAMEWORK_OSAL_FREERTOS_TASKMANAGEMENT_H_
|
||||||
|
|
||||||
// maybe this can be part of the TaskFactory.cpp
|
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
}
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Architecture dependant portmacro.h function call.
|
* Architecture dependant portmacro.h function call.
|
||||||
* Should be implemented in bsp.
|
* Should be implemented in bsp.
|
||||||
@ -35,6 +42,29 @@ public:
|
|||||||
* can be requested manually by calling this function.
|
* can be requested manually by calling this function.
|
||||||
*/
|
*/
|
||||||
static void requestContextSwitchFromTask(void);
|
static void requestContextSwitchFromTask(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The current task handle
|
||||||
|
*/
|
||||||
|
static TaskHandle_t getCurrentTaskHandle();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get returns the minimum amount of remaining stack space in words
|
||||||
|
* that was a available to the task since the task started executing.
|
||||||
|
* Please note that the actual value in bytes depends
|
||||||
|
* on the stack depth type.
|
||||||
|
* E.g. on a 32 bit machine, a value of 200 means 800 bytes.
|
||||||
|
* @return Smallest value of stack remaining since the task was started in
|
||||||
|
* words.
|
||||||
|
*/
|
||||||
|
static configSTACK_DEPTH_TYPE getTaskStackHighWatermark();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to be called to delay current task
|
||||||
|
* @param delay The delay in milliseconds
|
||||||
|
* @return Success of deletion
|
||||||
|
*/
|
||||||
|
static ReturnValue_t delayTask(uint32_t delayMs);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FRAMEWORK_OSAL_FREERTOS_TASKMANAGEMENT_H_ */
|
#endif /* FRAMEWORK_OSAL_FREERTOS_TASKMANAGEMENT_H_ */
|
||||||
|
@ -60,13 +60,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
static ReturnValue_t deleteTask(PeriodicTaskIF* task = NULL);
|
static ReturnValue_t deleteTask(PeriodicTaskIF* task = NULL);
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to be called to delay current task
|
|
||||||
* @param delay The delay in milliseconds
|
|
||||||
* @return Success of deletion
|
|
||||||
*/
|
|
||||||
static ReturnValue_t delayTask(uint32_t delayMs);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* External instantiation is not allowed.
|
* External instantiation is not allowed.
|
||||||
|
Loading…
Reference in New Issue
Block a user