ESPHome 2026.9.0
Loading...
Searching...
No Matches
static_task.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef USE_ESP32
4
5#include <freertos/FreeRTOS.h>
6#include <freertos/task.h>
7
8#include <cstdint>
9
10namespace esphome {
11
17 public:
19 bool is_created() const { return this->handle_ != nullptr; }
20
22 TaskHandle_t get_handle() const { return this->handle_; }
23
32 bool create(TaskFunction_t fn, const char *name, uint32_t stack_size, void *param, UBaseType_t priority,
33 bool use_psram);
34
40 bool destroy();
41
45 bool deallocate();
46
47 protected:
48 TaskHandle_t handle_{nullptr};
49 StaticTask_t tcb_;
50 StackType_t *stack_buffer_{nullptr};
52 bool use_psram_{false};
53};
54
55} // namespace esphome
56
57#endif // USE_ESP32
Helper for FreeRTOS static task management.
Definition static_task.h:16
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 is_created() const
Check if the task has been created and not yet destroyed.
Definition static_task.h:19
bool destroy()
Delete the task, keeping the stack buffer allocated for reuse by a subsequent create() call.
TaskHandle_t get_handle() const
Get the FreeRTOS task handle.
Definition static_task.h:22
bool deallocate()
Delete the task (if created) and free the stack buffer.
TaskHandle_t handle_
Definition static_task.h:48
StackType_t * stack_buffer_
Definition static_task.h:50
StaticTask_t tcb_
Definition static_task.h:49
uint8_t priority
static void uint32_t