CPU usage depending on boards

This commit is contained in:
Terrence
2025-02-04 14:24:51 +08:00
parent a0adbfd774
commit 84c932da4a
9 changed files with 63 additions and 101 deletions

View File

@@ -5,27 +5,16 @@
#define TAG "BackgroundTask"
BackgroundTask::BackgroundTask(uint32_t stack_size) {
#if CONFIG_IDF_TARGET_ESP32S3
task_stack_ = (StackType_t*)heap_caps_malloc(stack_size, MALLOC_CAP_SPIRAM);
background_task_handle_ = xTaskCreateStatic([](void* arg) {
BackgroundTask* task = (BackgroundTask*)arg;
task->BackgroundTaskLoop();
}, "background_task", stack_size, this, 1, task_stack_, &task_buffer_);
#else
xTaskCreate([](void* arg) {
BackgroundTask* task = (BackgroundTask*)arg;
task->BackgroundTaskLoop();
}, "background_task", stack_size, this, 1, &background_task_handle_);
#endif
}
BackgroundTask::~BackgroundTask() {
if (background_task_handle_ != nullptr) {
vTaskDelete(background_task_handle_);
}
if (task_stack_ != nullptr) {
heap_caps_free(task_stack_);
}
}
void BackgroundTask::Schedule(std::function<void()> callback) {