ESPHome 2026.3.0
Loading...
Searching...
No Matches
esphome::StaticTask Class Reference

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.
 
void destroy ()
 Delete the task but keep the stack buffer allocated for reuse by a subsequent create() call.
 
void deallocate ()
 Delete the task (if running) 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}
 

Detailed Description

Helper for FreeRTOS static task management.

Bundles TaskHandle_t, StaticTask_t, and the stack buffer into one object with create/destroy methods.

Definition at line 15 of file static_task.h.

Member Function Documentation

◆ create()

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.

Parameters
fnTask function
nameTask name (for debug)
stack_sizeStack size in StackType_t words
paramParameter passed to task function
priorityFreeRTOS task priority
use_psramIf true, allocate stack in PSRAM; otherwise internal RAM
Returns
true on success

Definition at line 9 of file static_task.cpp.

◆ deallocate()

void esphome::StaticTask::deallocate ( )

Delete the task (if running) and free the stack buffer.

Definition at line 51 of file static_task.cpp.

◆ destroy()

void esphome::StaticTask::destroy ( )

Delete the task but keep the stack buffer allocated for reuse by a subsequent create() call.

Definition at line 43 of file static_task.cpp.

◆ get_handle()

TaskHandle_t esphome::StaticTask::get_handle ( ) const
inline

Get the FreeRTOS task handle.

Definition at line 21 of file static_task.h.

◆ is_created()

bool esphome::StaticTask::is_created ( ) const
inline

Check if the task has been created and not yet destroyed.

Definition at line 18 of file static_task.h.

Field Documentation

◆ handle_

TaskHandle_t esphome::StaticTask::handle_ {nullptr}
protected

Definition at line 41 of file static_task.h.

◆ stack_buffer_

StackType_t* esphome::StaticTask::stack_buffer_ {nullptr}
protected

Definition at line 43 of file static_task.h.

◆ stack_size_

uint32_t esphome::StaticTask::stack_size_ {0}
protected

Definition at line 44 of file static_task.h.

◆ tcb_

StaticTask_t esphome::StaticTask::tcb_
protected

Definition at line 42 of file static_task.h.

◆ use_psram_

bool esphome::StaticTask::use_psram_ {false}
protected

Definition at line 45 of file static_task.h.


The documentation for this class was generated from the following files: