4#include "freertos/FreeRTOS.h"
5#include "freertos/task.h"
6#elif defined(__linux__
)
13namespace tinyrobotics {
16
17
18
19
20
24 Task(
const char* name,
int stackSize,
int priority = 1,
int core = -1) {
32 bool create(
const char* name,
int stackSize,
int priority = 1,
34 if (xHandle != 0)
return false;
37 xTaskCreatePinnedToCore(task_loop, name, stackSize,
this, priority,
40 xTaskCreate(task_loop, name, stackSize,
this, priority, &xHandle);
42 xTaskCreate(task_loop, name, stackSize,
this, priority, &xHandle);
50 if (xHandle !=
nullptr) {
57 bool begin(std::function<
void(
void* ref)> process) {
65 void end() { suspend(); }
67 void suspend() { vTaskSuspend(xHandle); }
69 void resume() { vTaskResume(xHandle); }
71 TaskHandle_t &getTaskHandle() {
75 void setReference(
void *r){
90 TaskHandle_t xHandle =
nullptr;
91 std::function<
void(
void* ref)> loop_code =
nop;
94 static void nop(
void*) { delay(100); }
96 static void task_loop(
void* arg) {
FreeRTOS task.
Definition: Task.h:21
bool create(const char *name, int stackSize, int priority=1, int core=-1)
If you used the empty constructor, you need to call create!
Definition: Task.h:32
void remove()
deletes the FreeRTOS task
Definition: Task.h:49
Task(const char *name, int stackSize, int priority=1, int core=-1)
Defines and creates a FreeRTOS task.
Definition: Task.h:24
void end()
suspends the task
Definition: Task.h:65