task management function taken over from master
This commit is contained in:
parent
aacda3afc2
commit
073f168b95
@ -1,23 +1,24 @@
|
|||||||
#include <framework/osal/FreeRTOS/TaskManagement.h>
|
#include "../../osal/FreeRTOS/TaskManagement.h"
|
||||||
|
|
||||||
void TaskManagement::requestContextSwitchFromTask() {
|
void TaskManagement::vRequestContextSwitchFromTask() {
|
||||||
vTaskDelay(0);
|
vTaskDelay(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskManagement::requestContextSwitch(
|
void TaskManagement::requestContextSwitch(
|
||||||
CallContext callContext = CallContext::TASK) {
|
CallContext callContext = CallContext::TASK) {
|
||||||
if(callContext == CallContext::ISR) {
|
if(callContext == CallContext::ISR) {
|
||||||
// This function depends on the partmacro.h definition for the specific device
|
// This function depends on the partmacro.h definition for the specific device
|
||||||
requestContextSwitchFromISR();
|
vRequestContextSwitchFromISR();
|
||||||
} else {
|
} else {
|
||||||
requestContextSwitchFromTask();
|
vRequestContextSwitchFromTask();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskHandle_t TaskManagement::getCurrentTaskHandle() {
|
TaskHandle_t TaskManagement::getCurrentTaskHandle() {
|
||||||
return xTaskGetCurrentTaskHandle();
|
return xTaskGetCurrentTaskHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
configSTACK_DEPTH_TYPE TaskManagement::getTaskStackHighWatermark() {
|
size_t TaskManagement::getTaskStackHighWatermark(
|
||||||
return uxTaskGetStackHighWaterMark(TaskManagement::getCurrentTaskHandle());
|
TaskHandle_t task) {
|
||||||
}
|
return uxTaskGetStackHighWaterMark(task) * sizeof(StackType_t);
|
||||||
|
}
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
#ifndef FRAMEWORK_OSAL_FREERTOS_TASKMANAGEMENT_H_
|
#ifndef FRAMEWORK_OSAL_FREERTOS_TASKMANAGEMENT_H_
|
||||||
#define FRAMEWORK_OSAL_FREERTOS_TASKMANAGEMENT_H_
|
#define FRAMEWORK_OSAL_FREERTOS_TASKMANAGEMENT_H_
|
||||||
|
|
||||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
#include "../../returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <freertos/FreeRTOS.h>
|
#include <freertos/FreeRTOS.h>
|
||||||
#include <freertos/task.h>
|
#include <freertos/task.h>
|
||||||
}
|
}
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Architecture dependant portmacro.h function call.
|
* Architecture dependant portmacro.h function call.
|
||||||
* Should be implemented in bsp.
|
* Should be implemented in bsp.
|
||||||
*/
|
*/
|
||||||
extern "C" void requestContextSwitchFromISR();
|
extern void vRequestContextSwitchFromISR();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Used by functions to tell if they are being called from
|
* Used by functions to tell if they are being called from
|
||||||
* within an ISR or from a regular task. This is required because FreeRTOS
|
* within an ISR or from a regular task. This is required because FreeRTOS
|
||||||
* has different functions for handling semaphores and messages from within
|
* has different functions for handling semaphores and messages from within
|
||||||
* an ISR and task.
|
* an ISR and task.
|
||||||
*/
|
*/
|
||||||
enum class CallContext {
|
enum class CallContext {
|
||||||
TASK = 0x00,//!< task_context
|
TASK = 0x00,//!< task_context
|
||||||
@ -29,19 +29,19 @@ enum class CallContext {
|
|||||||
|
|
||||||
class TaskManagement {
|
class TaskManagement {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief In this function, a function dependant on the portmacro.h header
|
* @brief In this function, a function dependant on the portmacro.h header
|
||||||
* function calls to request a context switch can be specified.
|
* function calls to request a context switch can be specified.
|
||||||
* This can be used if sending to the queue from an ISR caused a task
|
* This can be used if sending to the queue from an ISR caused a task
|
||||||
* to unblock and a context switch is required.
|
* to unblock and a context switch is required.
|
||||||
*/
|
*/
|
||||||
static void requestContextSwitch(CallContext callContext);
|
static void requestContextSwitch(CallContext callContext);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If task preemption in FreeRTOS is disabled, a context switch
|
* If task preemption in FreeRTOS is disabled, a context switch
|
||||||
* can be requested manually by calling this function.
|
* can be requested manually by calling this function.
|
||||||
*/
|
*/
|
||||||
static void requestContextSwitchFromTask(void);
|
static void vRequestContextSwitchFromTask(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The current task handle
|
* @return The current task handle
|
||||||
@ -56,8 +56,9 @@ public:
|
|||||||
* E.g. on a 32 bit machine, a value of 200 means 800 bytes.
|
* E.g. on a 32 bit machine, a value of 200 means 800 bytes.
|
||||||
* @return Smallest value of stack remaining since the task was started in
|
* @return Smallest value of stack remaining since the task was started in
|
||||||
* words.
|
* words.
|
||||||
*/
|
*/
|
||||||
static configSTACK_DEPTH_TYPE getTaskStackHighWatermark();
|
static size_t getTaskStackHighWatermark(
|
||||||
|
TaskHandle_t task = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FRAMEWORK_OSAL_FREERTOS_TASKMANAGEMENT_H_ */
|
#endif /* FRAMEWORK_OSAL_FREERTOS_TASKMANAGEMENT_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user