FreeRTOS Addons
Loading...
Searching...
No Matches
task.hpp
1
2#pragma once
3#include "freertos-config.h"
4#include "thread.hpp"
5
6namespace cpp_freertos {
12class Task : public Thread {
13public:
14 Task(const char *Name, uint16_t StackDepth, UBaseType_t Priority,
15 void (*fn)(), size_t numberOfLoops=0)
16 : Thread(Name, StackDepth, Priority) {
17 task = fn;
18 count = numberOfLoops;
19 }
20
25 virtual void Run() {
26 if (count==0){
27 while (true) {
28 task();
29 }
30 } else {
31 for (size_t j=0;j<count;j++){
32 task();
33 }
34 }
35 }
36
37protected:
38 void (*task)() = nullptr;
39 size_t count=0;
40};
41
42} // namespace cpp_freertos
A Thread which has the Run method implemented as loop which is executing the function that is passed ...
Definition: task.hpp:12
virtual void Run()
Custom Implementation which is executing the provided method in a loop.
Definition: task.hpp:25
Definition: thread.hpp:79
Definition: condition_variable.hpp:57