36 lines
763 B
C++
36 lines
763 B
C++
/*
|
|
* task.h
|
|
*
|
|
* Created on: Oct 29, 2021
|
|
* Author: compi
|
|
*/
|
|
|
|
#ifndef FSL_TASK_H_
|
|
#define FSL_TASK_H_
|
|
|
|
#include <FreeRTOS.h>
|
|
#include <task.h> // FreeRTOS
|
|
#include <semphr.h> // FreeRTOS
|
|
|
|
namespace fsl {
|
|
|
|
template<typename T, uint32_t stackSize> class Task {
|
|
public:
|
|
Task(UBaseType_t priority) : m_priority(priority) {}
|
|
void Start(SemaphoreHandle_t doneSem = nullptr, bool waitForInit = false) {
|
|
m_handle = xTaskCreateStatic(T::TaskFn, getName(), sizeof(m_stack)/sizeof(m_stack[0]),
|
|
this, m_priority, m_stack, &m_tcb);
|
|
}
|
|
virtual ~Task() {};
|
|
virtual char const * getName() = 0;
|
|
|
|
private:
|
|
TaskHandle_t m_handle;
|
|
UBaseType_t m_priority;
|
|
StaticTask_t m_tcb;
|
|
StackType_t m_stack[stackSize];
|
|
};
|
|
|
|
} /* namespace fsl */
|
|
|
|
#endif /* FSL_TASK_H_ */
|