sitara_depot/components/free_rtos/task/task.cpp

42 lines
950 B
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.cpp
*
* Created on: 6 мар. 2023 г.
* Author: sychev
*/
#include "free_rtos/task/task.hpp"
bool free_rtos::Task::Create(std::string name, uint32_t priority, TaskFunction task_fun,
void * taskArg, int32_t stack_size_bytes)
{
if ( (priority > TaskPriorityHiest) || (task_fun == nullptr) ) {
return false;
}
if (stack_size_bytes < 0)
{
stack_size_bytes = defStackSize_;
}
/// Стек должен быть выровнен по границе 32 байта
if (stack_size_bytes % 32) {
return false;
}
auto ret = xTaskCreate(task_fun,
name.c_str(),
stack_size_bytes / sizeof(configSTACK_DEPTH_TYPE),
taskArg,
priority,
&taskHandle_);
if (pdPASS != ret) {
return false;
}
return true;
}