diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-10-12 09:02:19 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-10-12 09:02:19 +1100 |
| commit | f0d3a27dd997f0746ed48da967771cee7dbebb48 (patch) | |
| tree | 8e833056a94fe1a0ea28d3c9222033dc2327d4b5 /src/tasks/tasks.hpp | |
| parent | ddcaa967fd6cc32c25a3a9294bd5cfff19c3036d (diff) | |
| download | tangara-fw-f0d3a27dd997f0746ed48da967771cee7dbebb48.tar.gz | |
Ensure StaticTask_t allocs are internal
Diffstat (limited to 'src/tasks/tasks.hpp')
| -rw-r--r-- | src/tasks/tasks.hpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/tasks/tasks.hpp b/src/tasks/tasks.hpp index 1b6a108f..2f008120 100644 --- a/src/tasks/tasks.hpp +++ b/src/tasks/tasks.hpp @@ -12,6 +12,7 @@ #include <memory> #include <string> +#include "esp_heap_caps.h" #include "freertos/FreeRTOS.h" #include "freertos/portmacro.h" #include "freertos/projdefs.h" @@ -54,7 +55,8 @@ auto PersistentMain(void* fn) -> void; template <Type t> auto StartPersistent(const std::function<void(void)>& fn) -> void { - StaticTask_t* task_buffer = new StaticTask_t; + StaticTask_t* task_buffer = static_cast<StaticTask_t*>(heap_caps_malloc( + sizeof(StaticTask_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)); cpp::span<StackType_t> stack = AllocateStack<t>(); xTaskCreateStatic(&PersistentMain, Name<t>().c_str(), stack.size(), new std::function<void(void)>(fn), Priority<t>(), @@ -64,7 +66,8 @@ auto StartPersistent(const std::function<void(void)>& fn) -> void { template <Type t> auto StartPersistent(BaseType_t core, const std::function<void(void)>& fn) -> void { - StaticTask_t* task_buffer = new StaticTask_t; + StaticTask_t* task_buffer = static_cast<StaticTask_t*>(heap_caps_malloc( + sizeof(StaticTask_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)); cpp::span<StackType_t> stack = AllocateStack<t>(); xTaskCreateStaticPinnedToCore(&PersistentMain, Name<t>().c_str(), stack.size(), new std::function<void(void)>(fn), @@ -81,7 +84,7 @@ class Worker { StackType_t* stack_; QueueHandle_t queue_; std::atomic<bool> is_task_running_; - StaticTask_t task_buffer_; + StaticTask_t *task_buffer_; TaskHandle_t task_; struct WorkItem { |
