ESPHome 2026.3.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
16 public:
18 bool is_created() const { return this->handle_ != nullptr; }
19
21 TaskHandle_t get_handle() const { return this->handle_; }
22
31 bool create(TaskFunction_t fn, const char *name, uint32_t stack_size, void *param, UBaseType_t priority,
32 bool use_psram);
33
35 void destroy();
36
38 void deallocate();
39
40 protected:
41 TaskHandle_t handle_{nullptr};
42 StaticTask_t tcb_;
43 StackType_t *stack_buffer_{nullptr};
45 bool use_psram_{false};
46};
47
48} // namespace esphome
49
50#endif // USE_ESP32
Helper for FreeRTOS static task management.
Definition static_task.h:15
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:18
TaskHandle_t get_handle() const
Get the FreeRTOS task handle.
Definition static_task.h:21
void deallocate()
Delete the task (if running) and free the stack buffer.
TaskHandle_t handle_
Definition static_task.h:41
void destroy()
Delete the task but keep the stack buffer allocated for reuse by a subsequent create() call.
StackType_t * stack_buffer_
Definition static_task.h:43
StaticTask_t tcb_
Definition static_task.h:42
uint8_t priority
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
static void uint32_t