Base class for FreeRTOS-aware tasks in the framework. More...
#include <FrameworkTask.h>
Inheritance diagram for FrameworkTask:
Collaboration diagram for FrameworkTask:Public Member Functions | |
| FrameworkTask (const char *name, uint16_t stackSize=1024, UBaseType_t priority=1) | |
| Constructor. | |
| virtual | ~FrameworkTask () |
| Destructor. | |
| virtual void | onEvent (const Event &event) |
| Called when the task receives an event. | |
| bool | start () |
| Starts the task via FreeRTOS. | |
| void | suspend () |
Suspends the task using vTaskSuspend(). | |
| void | resume () |
Resumes the task using vTaskResume(). | |
| TaskHandle_t | getHandle () const |
| Returns the FreeRTOS task handle. | |
| const char * | getName () const |
| Returns the task name. | |
| void | notify (uint8_t index, uint32_t value=1) |
| Sends a notification to this task using an index. | |
| void | notify (Notification n, uint32_t value=1) |
| Sends a notification using a framework-defined enum. | |
| void | notifyFromISR (uint8_t index, uint32_t value=1, BaseType_t *pxHigherPriorityTaskWoken=nullptr) |
| Sends a notification from an ISR (by index). | |
| void | notifyFromISR (Notification n, uint32_t value=1, BaseType_t *pxHigherPriorityTaskWoken=nullptr) |
| Sends a notification from ISR using enum identifier. | |
| bool | waitFor (uint8_t index, TickType_t timeout=portMAX_DELAY) |
| Waits for a notification (by index). | |
| bool | waitFor (Notification n, TickType_t timeout=portMAX_DELAY) |
| Waits for a notification (by enum identifier). | |
| Notification | waitForAny (uint8_t index, uint32_t mask, TickType_t timeout=portMAX_DELAY) |
| waits for any notification matching the given mask. | |
Protected Member Functions | |
| virtual void | run ()=0 |
| Main task loop. | |
| uint32_t | waitFor (TickType_t timeout=portMAX_DELAY) |
| Wait for any notification (default index). | |
| bool | createQueue (size_t itemSize, size_t length) |
| Creates an internal FreeRTOS queue. | |
| bool | sendToQueue (const void *item, TickType_t timeout=0) |
| Sends an item to the internal queue. | |
| bool | receiveFromQueue (void *item, TickType_t timeout=portMAX_DELAY) |
| Receives an item from the internal queue. | |
Protected Attributes | |
| const char * | _name |
| uint16_t | _stackSize |
| UBaseType_t | _priority |
| TaskHandle_t | _handle = nullptr |
| QueueHandle_t | _queue = nullptr |
Static Private Member Functions | |
| static void | taskEntry (void *pvParams) |
Subclass this to define application or system-level tasks.
run() to define the main task loop.onEvent() to receive posted events.Supports:
Definition at line 41 of file FrameworkTask.h.
| FrameworkTask::FrameworkTask | ( | const char * | name, |
| uint16_t | stackSize = 1024, |
||
| UBaseType_t | priority = 1 |
||
| ) |
Constructor.
| name | Task name (used by FreeRTOS). |
| stackSize | Stack size in words. |
| priority | Task priority. |
| name | Task name (used by FreeRTOS). |
| stackSize | Stack size in words. |
| priority | Task priority. |
Definition at line 18 of file FrameworkTask.cpp.
|
virtual |
Destructor.
Frees the task and its queue (if allocated).
Frees the task and its queue (if allocated).
Definition at line 22 of file FrameworkTask.cpp.
|
protected |
Creates an internal FreeRTOS queue.
| itemSize | Size of each message item. |
| length | Number of slots in the queue. |
| itemSize | Size of each message item. |
| length | Number of slots in the queue. |
Definition at line 141 of file FrameworkTask.cpp.
References _queue.
| TaskHandle_t FrameworkTask::getHandle | ( | ) | const |
Returns the FreeRTOS task handle.
Definition at line 62 of file FrameworkTask.cpp.
References _handle.
|
inline |
Definition at line 93 of file FrameworkTask.h.
References _name.
Referenced by FrameworkController::getName().
Here is the caller graph for this function:| void FrameworkTask::notify | ( | Notification | n, |
| uint32_t | value = 1 |
||
| ) |
Sends a notification to this task using an index.
| index | Notification slot index (0–7). |
| value | Value to send (default is 1). |
Definition at line 74 of file FrameworkTask.cpp.
References Notification::code(), and notify().
Here is the call graph for this function:| void FrameworkTask::notify | ( | uint8_t | index, |
| uint32_t | value = 1 |
||
| ) |
Sends a notification to this task using an index.
| index | Notification slot index (0–7). |
| value | Value to send (default is 1). |
| index | Notification slot index (0–7). |
| value | Value to send (default is 1). |
Definition at line 68 of file FrameworkTask.cpp.
References _handle.
Referenced by notify().
Here is the caller graph for this function:| void FrameworkTask::notifyFromISR | ( | Notification | n, |
| uint32_t | value = 1, |
||
| BaseType_t * | pxHigherPriorityTaskWoken = nullptr |
||
| ) |
Sends a notification from an ISR (by index).
Definition at line 86 of file FrameworkTask.cpp.
References Notification::code(), and notifyFromISR().
Here is the call graph for this function:| void FrameworkTask::notifyFromISR | ( | uint8_t | index, |
| uint32_t | value = 1, |
||
| BaseType_t * | pxHigherPriorityTaskWoken = nullptr |
||
| ) |
Sends a notification from an ISR (by index).
Definition at line 80 of file FrameworkTask.cpp.
References _handle.
Referenced by notifyFromISR().
Here is the caller graph for this function:
|
inlinevirtual |
Override to react to framework events. This is called by the event manager. Default implementation does nothing.
Reimplemented in App, FrameworkController, and FrameworkManager.
Definition at line 64 of file FrameworkTask.h.
|
protected |
Receives an item from the internal queue.
Definition at line 154 of file FrameworkTask.cpp.
References _queue.
| void FrameworkTask::resume | ( | ) |
Resumes the task using vTaskResume().
Definition at line 55 of file FrameworkTask.cpp.
References _handle.
|
protectedpure virtual |
Must be implemented by subclasses.
Implemented in FrameworkController.
Referenced by taskEntry().
Here is the caller graph for this function:
|
protected |
Sends an item to the internal queue.
Definition at line 148 of file FrameworkTask.cpp.
References _queue.
| bool FrameworkTask::start | ( | ) |
Starts the task via FreeRTOS.
Internally calls xTaskCreate(). The task runs run() when scheduled.
Internally calls xTaskCreate(). The task runs run() when scheduled.
Definition at line 35 of file FrameworkTask.cpp.
References _handle, _name, _priority, _stackSize, and taskEntry().
Referenced by FrameworkApp::FrameworkApp(), App::onStart(), and FrameworkApp::start().
Here is the call graph for this function:
Here is the caller graph for this function:| void FrameworkTask::suspend | ( | ) |
Suspends the task using vTaskSuspend().
Definition at line 48 of file FrameworkTask.cpp.
References _handle.
|
staticprivate |
Definition at line 41 of file FrameworkTask.cpp.
References run().
Referenced by start().
Here is the call graph for this function:
Here is the caller graph for this function:| bool FrameworkTask::waitFor | ( | Notification | n, |
| TickType_t | timeout = portMAX_DELAY |
||
| ) |
Waits for a notification (by index).
| index | Notification index to wait for. |
| timeout | Timeout in ticks. |
Definition at line 99 of file FrameworkTask.cpp.
References Notification::code(), and waitFor().
Here is the call graph for this function:
|
protected |
Waits for a notification (by index).
| index | Notification index to wait for. |
| timeout | Timeout in ticks. |
Definition at line 105 of file FrameworkTask.cpp.
| bool FrameworkTask::waitFor | ( | uint8_t | index, |
| TickType_t | timeout = portMAX_DELAY |
||
| ) |
Waits for a notification (by index).
| index | Notification index to wait for. |
| timeout | Timeout in ticks. |
| index | Notification index to wait for. |
| timeout | Timeout in ticks. |
Definition at line 92 of file FrameworkTask.cpp.
Referenced by waitFor().
Here is the caller graph for this function:| Notification FrameworkTask::waitForAny | ( | uint8_t | index, |
| uint32_t | mask, | ||
| TickType_t | timeout = portMAX_DELAY |
||
| ) |
This is useful for waiting on multiple notification types.
| index | Notification index to wait for. |
Definition at line 113 of file FrameworkTask.cpp.
References Notification::kind, System, Notification::system, and WaitForTimeout.
|
protected |
Definition at line 179 of file FrameworkTask.h.
Referenced by getHandle(), notify(), notifyFromISR(), resume(), start(), suspend(), and ~FrameworkTask().
|
protected |
Definition at line 176 of file FrameworkTask.h.
|
protected |
Definition at line 178 of file FrameworkTask.h.
Referenced by start().
|
protected |
Definition at line 180 of file FrameworkTask.h.
Referenced by createQueue(), receiveFromQueue(), sendToQueue(), and ~FrameworkTask().
|
protected |
Definition at line 177 of file FrameworkTask.h.
Referenced by start().