FreeRTOS-Cpp
|
Class that encapsulates the functionality of a FreeRTOS task. More...
#include <Task.hpp>
Public Member Functions | |
Task (const Task &)=delete | |
Task & | operator= (const Task &)=delete |
bool | isValid () const |
Function that checks the return value of the call to xTaskCreate in the constructor. This function should be called to ensure the task was created successfully before starting the scheduler. More... | |
![]() | |
TaskBase (const TaskBase &)=delete | |
TaskBase & | operator= (const TaskBase &)=delete |
virtual void | taskEntry () final |
Function that acts as the entry point of the task instance. This function initializes the previous wake time of the task and calls the user implemented taskFunction(). More... | |
UBaseType_t | getPriority () const |
Function that calls UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask ) More... | |
void | setPriority (const UBaseType_t newPriority) const |
Function that calls void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) More... | |
void | suspend () const |
Function that calls void vTaskSuspend( TaskHandle_t xTaskToSuspend ) More... | |
void | resume () const |
Function that calls void vTaskResume( TaskHandle_t xTaskToResume ) More... | |
bool | resumeFromISR () const |
Function that calls BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) More... | |
bool | abortDelay () const |
Function that calls BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) More... | |
UBaseType_t | getStackHighWaterMark () const |
Function that calls UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) More... | |
configSTACK_DEPTH_TYPE | getStackHighWaterMark2 () const |
Function that calls UBaseType_t uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) More... | |
State | getState () const |
Function that calls UBaseType_t uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) More... | |
const char * | getName () const |
Function that calls char *pcTaskGetName( TaskHandle_t xTaskToQuery ) More... | |
void | notifyGive (const UBaseType_t index=0) const |
Function that calls BaseType_t xTaskNotifyGiveIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify ) More... | |
void | notifyGiveFromISR (bool &higherPriorityTaskWoken, const UBaseType_t index=0) const |
Function that calls void vTaskNotifyGiveIndexedFromISR( TaskHandle_t xTaskHandle, UBaseType_t uxIndexToNotify, BaseType_t *pxHigherPriorityTaskWoken ) More... | |
void | notifyGiveFromISR (const UBaseType_t index=0) const |
Function that calls void vTaskNotifyGiveIndexedFromISR( TaskHandle_t xTaskHandle, UBaseType_t uxIndexToNotify, BaseType_t *pxHigherPriorityTaskWoken ) More... | |
bool | notify (const NotifyAction action, const NotificationBits value=0, const UBaseType_t index=0) const |
Function that calls BaseType_t xTaskNotifyIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction ) More... | |
std::pair< bool, NotificationBits > | notifyAndQuery (const NotifyAction action, const NotificationBits value=0, const UBaseType_t index=0) const |
Function that calls BaseType_t xTaskNotifyAndQueryIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue ) More... | |
std::pair< bool, NotificationBits > | notifyAndQueryFromISR (bool &higherPriorityTaskWoken, const NotifyAction action, const NotificationBits value=0, const UBaseType_t index=0) const |
Function that calls BaseType_t xTaskNotifyAndQueryIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue, BaseType_t *pxHigherPriorityTaskWoken ) More... | |
std::pair< bool, NotificationBits > | notifyAndQueryFromISR (const NotifyAction action, const NotificationBits value=0, const UBaseType_t index=0) const |
Function that calls BaseType_t xTaskNotifyAndQueryIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue, BaseType_t *pxHigherPriorityTaskWoken ) More... | |
bool | notifyFromISR (bool &higherPriorityTaskWoken, const NotifyAction action, const NotificationBits value=0, const UBaseType_t index=0) const |
Function that calls BaseType_t xTaskNotifyIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken ) More... | |
bool | notifyFromISR (const NotifyAction action, const NotificationBits value=0, const UBaseType_t index=0) const |
Function that calls BaseType_t xTaskNotifyIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken ) More... | |
bool | notifyStateClear (const UBaseType_t index=0) const |
Function that calls BaseType_t xTaskNotifyStateClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToClear ) More... | |
NotificationBits | notifyValueClear (const NotificationBits bitsToClear=0, const UBaseType_t index=0) const |
Function that calls uint32_t ulTaskNotifyValueClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToClear, uint32_t ulBitsToClear ) More... | |
Protected Member Functions | |
Task (const UBaseType_t priority=tskIDLE_PRIORITY, const configSTACK_DEPTH_TYPE stackDepth=configMINIMAL_STACK_SIZE, const char *name="") | |
Construct a new Task object by calling BaseType_t xTaskCreate( TaskFunction_t pvTaskCode, const char * const pcName, configSTACK_DEPTH_TYPE usStackDepth, void *pvParameters, BaseType_t uxPriority, TaskHandle_t *pxCreatedTask ) More... | |
Task (Task &&) noexcept=default | |
Task & | operator= (Task &&) noexcept=default |
![]() | |
virtual void | taskFunction ()=0 |
Abstraction function that acts as the entry point of the task for the user. More... | |
bool | delayUntil (const TickType_t timeIncrement=0) |
Function that calls BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement ) More... | |
Private Attributes | |
bool | taskCreatedSuccessfully = false |
Additional Inherited Members | |
![]() | |
enum class | State { Running = eRunning , Ready = eReady , Blocked = eBlocked , Suspended = eSuspended , Deleted = eDeleted , Invalid = eInvalid } |
enum class | NotifyAction { NoAction = eNoAction , SetBits = eSetBits , Increment = eIncrement , SetValueWithOverwrite = eSetValueWithOverwrite , SetValueWithoutOverwrite = eSetValueWithoutOverwrite } |
using | NotificationBits = std::bitset< 32 > |
![]() | |
static void * | operator new (size_t, void *ptr) |
static void * | operator new[] (size_t, void *ptr) |
static void * | operator new (size_t)=delete |
static void * | operator new[] (size_t)=delete |
static TaskHandle_t | getIdleHandle () |
Function that calls TaskHandle_t xTaskGetIdleTaskHandle( void ) More... | |
static TaskHandle_t | getHandle (const char *name) |
Function that calls TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ) More... | |
static std::pair< bool, NotificationBits > | notifyWait (const TickType_t ticksToWait=portMAX_DELAY, const NotificationBits bitsToClearOnEntry=0, const NotificationBits bitsToClearOnExit=0, const UBaseType_t index=0) |
Function that calls BaseType_t xTaskNotifyWaitIndexed( UBaseType_t uxIndexToWaitOn, uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) More... | |
![]() | |
static void | delay (const TickType_t ticksToDelay=0) |
Function that calls void vTaskDelay( const TickType_t xTicksToDelay ) More... | |
static NotificationBits | notifyTake (const TickType_t ticksToWait=portMAX_DELAY, const bool clearCountOnExit=true, const UBaseType_t index=0) |
Function that calls uint32_t ulTaskNotifyTakeIndexed( UBaseType_t uxIndexToWaitOn, BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) More... | |
Class that encapsulates the functionality of a FreeRTOS task.
Task Task.hpp <FreeRTOS/Task.hpp>
Each task requires RAM that is used to hold the task state, and used by the task as its stack. If a task is created using this class then the required RAM is automatically allocated from the FreeRTOS heap. If a task is created using FreeRTOS::StaticTask() then the RAM is included in the object, so it can be statically allocated at compile time. See the Static Vs Dynamic allocation page for more information.
|
inlineexplicitprotected |
Construct a new Task object by calling BaseType_t xTaskCreate( TaskFunction_t pvTaskCode, const char * const pcName, configSTACK_DEPTH_TYPE usStackDepth, void *pvParameters, BaseType_t uxPriority, TaskHandle_t *pxCreatedTask )
xTaskCreate
the constructor passes the this
pointer as the task function argument. This pointer is used so that the interface function callTaskFunction() can invoke taskEntry() for this instance of the class.priority | The priority at which the created task will execute. Priorities are asserted to be less than configMAX_PRIORITIES. If configASSERT is undefined, priorities are silently capped at (configMAX_PRIORITIES - 1). |
stackDepth | The number of words (not bytes!) to allocate for use as the task's stack. For example, if the stack is 16-bits wide and stackDepth is 100, then 200 bytes will be allocated for use as the task's stack. As another example, if the stack is 32-bits wide and stackDepth is 400 then 1600 bytes will be allocated for use as the task's stack. The stack depth multiplied by the stack width must not exceed the maximum value that can be contained in a variable of type size_t. |
name | A descriptive name for the task. This is mainly used to facilitate debugging, but can also be used to obtain a task handle. The maximum length of a task's name is defined by configMAX_TASK_NAME_LEN in FreeRTOSConfig.h. |
Example Usage
|
inline |
Function that checks the return value of the call to xTaskCreate in the constructor. This function should be called to ensure the task was created successfully before starting the scheduler.