sitara_depot/components/free_rtos/task/task.hpp

53 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* task.hpp
*
* Created on: 6 мар. 2023 г.
* Author: sychev
* Во FreeRtos есть два способа создать задачу:
* xTaskCreate - стэк выделяется динамически при создании задачи
* xTaskCreateStatic - стек выделяется статически
* Данный модуль реализован на основе xTaskCreate
*/
#ifndef FREE_RTOS_TASK_TASK_HPP_
#define FREE_RTOS_TASK_TASK_HPP_
#include <cstdint>
#include <string>
#include "FreeRTOS.h"
#include "task.h"
namespace free_rtos {
/**
* @brief  Класс обертка реализующий создание задачи во free_rtos.
*/
class Task {
public:
/**
* @brief Тип указателя на функцию задачи
*
*/
using TaskFunction = TaskFunction_t;
static const uint32_t TaskPriorityHiest = configMAX_PRIORITIES - 1; // 31
static const uint32_t TaskPriorityLowest = 0; // 0
bool Create(std::string name, uint32_t priority, TaskFunction task_fun,
void * taskArg, int32_t stack_size_bytes = -1);
~Task() {
vTaskDelete(taskHandle_);
}
private:
static const uint32_t defStackSize_ = 8192; /// Размер стека по-умолчанию
TaskHandle_t taskHandle_;
};
}
#endif /* FREE_RTOS_TASK_TASK_HPP_ */