feat: add lab-rv32i-freertos-scheduler-states card
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#ifndef FREERTOS_CPP_TASK_REF_HPP
|
||||
#define FREERTOS_CPP_TASK_REF_HPP
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
}
|
||||
|
||||
namespace freertos
|
||||
{
|
||||
|
||||
/* Non-owning view: it never deletes the task and must not outlive the handle. */
|
||||
class TaskRef final
|
||||
{
|
||||
public:
|
||||
explicit constexpr TaskRef( TaskHandle_t handle ) noexcept
|
||||
: handle_ { handle }
|
||||
{
|
||||
}
|
||||
|
||||
static TaskRef current() noexcept
|
||||
{
|
||||
return TaskRef { xTaskGetCurrentTaskHandle() };
|
||||
}
|
||||
|
||||
eTaskState state() const noexcept
|
||||
{
|
||||
return eTaskGetState( handle_ );
|
||||
}
|
||||
|
||||
UBaseType_t priority() const noexcept
|
||||
{
|
||||
return uxTaskPriorityGet( handle_ );
|
||||
}
|
||||
|
||||
void set_priority( UBaseType_t priority ) const noexcept
|
||||
{
|
||||
vTaskPrioritySet( handle_, priority );
|
||||
}
|
||||
|
||||
constexpr TaskHandle_t native_handle() const noexcept
|
||||
{
|
||||
return handle_;
|
||||
}
|
||||
|
||||
private:
|
||||
TaskHandle_t handle_;
|
||||
};
|
||||
|
||||
} // namespace freertos
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user