|
ESPHome 2026.9.0
|
Helper for FreeRTOS static task management. More...
#include <static_task.h>
Public Member Functions | |
| bool | is_created () const |
| Check if the task has been created and not yet destroyed. | |
| TaskHandle_t | get_handle () const |
| Get the FreeRTOS task handle. | |
| bool | create (TaskFunction_t fn, const char *name, uint32_t stack_size, void *param, UBaseType_t priority, bool use_psram) |
| Allocate stack and create task. | |
| bool | destroy () |
| Delete the task, keeping the stack buffer allocated for reuse by a subsequent create() call. | |
| bool | deallocate () |
| Delete the task (if created) and free the stack buffer. | |
Protected Attributes | |
| TaskHandle_t | handle_ {nullptr} |
| StaticTask_t | tcb_ |
| StackType_t * | stack_buffer_ {nullptr} |
| uint32_t | stack_size_ {0} |
| bool | use_psram_ {false} |
Helper for FreeRTOS static task management.
Bundles TaskHandle_t, StaticTask_t, and the stack buffer into one object with create/destroy methods. Call destroy() and deallocate() from another task: a task cannot free the stack it is still running on.
Definition at line 16 of file static_task.h.
| bool esphome::StaticTask::create | ( | TaskFunction_t | fn, |
| const char * | name, | ||
| uint32_t | stack_size, | ||
| void * | param, | ||
| UBaseType_t | priority, | ||
| bool | use_psram ) |
Allocate stack and create task.
| fn | Task function |
| name | Task name (for debug) |
| stack_size | Stack size in bytes (StackType_t is a byte on ESP-IDF) |
| param | Parameter passed to task function |
| priority | FreeRTOS task priority |
| use_psram | If true, allocate stack in PSRAM; otherwise internal RAM |
Definition at line 9 of file static_task.cpp.
| bool esphome::StaticTask::deallocate | ( | ) |
Delete the task (if created) and free the stack buffer.
Definition at line 64 of file static_task.cpp.
| bool esphome::StaticTask::destroy | ( | ) |
Delete the task, keeping the stack buffer allocated for reuse by a subsequent create() call.
The task must have finished its work and parked itself, either suspended or blocked indefinitely: it is suspended here so that it cannot be scheduled again, and it is given no chance to clean up.
Definition at line 43 of file static_task.cpp.
|
inline |
Get the FreeRTOS task handle.
Definition at line 22 of file static_task.h.
|
inline |
Check if the task has been created and not yet destroyed.
Definition at line 19 of file static_task.h.
|
protected |
Definition at line 48 of file static_task.h.
|
protected |
Definition at line 50 of file static_task.h.
|
protected |
Definition at line 51 of file static_task.h.
|
protected |
Definition at line 49 of file static_task.h.
|
protected |
Definition at line 52 of file static_task.h.