19 : _name(name), _stackSize(stackSize), _priority(priority) {}
70 xTaskNotifyIndexed(
_handle, index, value, eSetValueWithOverwrite);
82 xTaskNotifyIndexedFromISR(
_handle, index, value, eSetValueWithOverwrite, pxHigherPriorityTaskWoken);
95 return xTaskNotifyWaitIndexed(index, 0, UINT32_MAX, &value, timeout) == pdTRUE;
108 xTaskNotifyWaitIndexed(0, 0, UINT32_MAX, &value, timeout);
116 if (xTaskNotifyWaitIndexed(index, 0, mask, &value, timeout) == pdTRUE && (value & mask))
122 for (uint8_t i = 0; i < 32; ++i)
124 if (value & (1u << i))
143 _queue = xQueueCreate(length, itemSize);
150 return xQueueSend(
_queue, item, timeout) == pdTRUE;
156 return xQueueReceive(
_queue, item, timeout) == pdTRUE;
FreeRTOS-aware task abstraction with built-in notification and queue support.
SystemNotification
System-defined notification types reserved by the framework.
Base class for FreeRTOS-aware tasks in the framework.
void notifyFromISR(uint8_t index, uint32_t value=1, BaseType_t *pxHigherPriorityTaskWoken=nullptr)
Sends a notification from an ISR (by index).
virtual ~FrameworkTask()
Destructor.
TaskHandle_t getHandle() const
Returns the FreeRTOS task handle.
void resume()
Resumes the task using vTaskResume().
void notify(uint8_t index, uint32_t value=1)
Sends a notification to this task using an index.
void suspend()
Suspends the task using vTaskSuspend().
bool waitFor(uint8_t index, TickType_t timeout=portMAX_DELAY)
Waits for a notification (by index).
bool createQueue(size_t itemSize, size_t length)
Creates an internal FreeRTOS queue.
static void taskEntry(void *pvParams)
Notification waitForAny(uint8_t index, uint32_t mask, TickType_t timeout=portMAX_DELAY)
waits for any notification matching the given mask.
bool start()
Starts the task via FreeRTOS.
virtual void run()=0
Main task loop.
bool receiveFromQueue(void *item, TickType_t timeout=portMAX_DELAY)
Receives an item from the internal queue.
FrameworkTask(const char *name, uint16_t stackSize=1024, UBaseType_t priority=1)
Constructor.
bool sendToQueue(const void *item, TickType_t timeout=0)
Sends an item to the internal queue.
A tagged union representing either a system or user-defined notification.
SystemNotification system
uint8_t code() const
Get the notification code.