WIP: somethings wrong.. #19
@ -114,4 +114,3 @@ ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) {
|
||||
vTaskDelay(pdMS_TO_TICKS(ms));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
ReturnValue_t checkSequence() const;
|
||||
|
||||
ReturnValue_t sleepFor(uint32_t ms);
|
||||
|
||||
protected:
|
||||
bool started;
|
||||
TaskHandle_t handle;
|
||||
|
@ -23,12 +23,6 @@ void MessageQueue::switchSystemContext(SystemContext callContext) {
|
||||
this->callContext = callContext;
|
||||
}
|
||||
|
||||
void MessageQueue::requestContextSwitch(SystemContext callContext) {
|
||||
if(callContext == SystemContext::isr_context) {
|
||||
portYIELD_FROM_ISR();
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t MessageQueue::sendMessage(MessageQueueId_t sendTo,
|
||||
MessageQueueMessage* message, bool ignoreFault) {
|
||||
return sendMessageFrom(sendTo, message, this->getId(), ignoreFault);
|
||||
|
@ -4,11 +4,11 @@
|
||||
#include <framework/internalError/InternalErrorReporterIF.h>
|
||||
#include <framework/ipc/MessageQueueIF.h>
|
||||
#include <framework/ipc/MessageQueueMessage.h>
|
||||
#include <framework/osal/FreeRTOS/TaskManagement.h>
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include "queue.h"
|
||||
#include "portmacro.h"
|
||||
#include "task.h"
|
||||
|
||||
|
||||
//TODO this class assumes that MessageQueueId_t is the same size as void* (the FreeRTOS handle type), compiler will catch this but it might be nice to have something checking or even an always working solution
|
||||
// https://scaryreasoner.wordpress.com/2009/02/28/checking-sizeof-at-compile-time/
|
||||
@ -58,16 +58,6 @@ public:
|
||||
*/
|
||||
virtual ~MessageQueue();
|
||||
|
||||
/*!
|
||||
* Used by calling function to tell the callbacks if they are being called from
|
||||
* within an ISR or from a regular task. This is required because FreeRTOS
|
||||
* has different functions for handling semaphores from within an ISR and task.
|
||||
*/
|
||||
typedef enum _SystemContext {
|
||||
task_context = 0x00,//!< task_context
|
||||
isr_context = 0xFF //!< isr_context
|
||||
} SystemContext;
|
||||
|
||||
/**
|
||||
* This function is used to specify whether a message queue operation is called
|
||||
* from within an ISR or a task. FreeRTOS offers different functions for this task.
|
||||
@ -187,13 +177,7 @@ protected:
|
||||
|
||||
static ReturnValue_t handleSendResult(BaseType_t result, bool ignoreFault);
|
||||
|
||||
/**
|
||||
* In this function, a function dependant on the portmacro.h header 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 to unblock
|
||||
* and a context switch is required.
|
||||
*/
|
||||
static void requestContextSwitch(SystemContext callContext);
|
||||
|
||||
private:
|
||||
QueueHandle_t handle;
|
||||
MessageQueueId_t defaultDestination;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef MULTIOBJECTTASK_H_
|
||||
#define MULTIOBJECTTASK_H_
|
||||
#ifndef PERIODICTASK_H_
|
||||
#define PERIODICTASK_H_
|
||||
|
||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||
#include <framework/tasks/PeriodicTaskIF.h>
|
||||
@ -107,4 +107,4 @@ protected:
|
||||
void taskFunctionality(void);
|
||||
};
|
||||
|
||||
#endif /* MULTIOBJECTTASK_H_ */
|
||||
#endif /* PERIODICTASK_H_ */
|
||||
|
24
osal/FreeRTOS/TaskManagement.cpp
Normal file
24
osal/FreeRTOS/TaskManagement.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @file TaskManagement.cpp
|
||||
*
|
||||
* @date 26.02.2020
|
||||
*
|
||||
*/
|
||||
#include <framework/osal/FreeRTOS/TaskManagement.h>
|
||||
#include <FreeRTOS.h>
|
||||
#include "portmacro.h"
|
||||
#include "task.h"
|
||||
|
||||
void requestContextSwitchFromTask() {
|
||||
vTaskDelay(0);
|
||||
}
|
||||
|
||||
void requestContextSwitch(SystemContext callContext) {
|
||||
if(callContext == SystemContext::isr_context) {
|
||||
// This function depends on the partmacro.h definition for the specific device
|
||||
portYIELD_FROM_ISR();
|
||||
} else {
|
||||
requestContextSwitchFromTask();
|
||||
}
|
||||
}
|
||||
|
35
osal/FreeRTOS/TaskManagement.h
Normal file
35
osal/FreeRTOS/TaskManagement.h
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @file TaskManagement.h
|
||||
*
|
||||
* @date 26.02.2020
|
||||
*/
|
||||
|
||||
#ifndef FRAMEWORK_OSAL_FREERTOS_TASKMANAGEMENT_H_
|
||||
#define FRAMEWORK_OSAL_FREERTOS_TASKMANAGEMENT_H_
|
||||
|
||||
/*!
|
||||
* Used by functions to tell if they are being called from
|
||||
* within an ISR or from a regular task. This is required because FreeRTOS
|
||||
* has different functions for handling semaphores and messages from within an ISR and task.
|
||||
*/
|
||||
typedef enum _SystemContext {
|
||||
task_context = 0x00,//!< task_context
|
||||
isr_context = 0xFF //!< isr_context
|
||||
} SystemContext;
|
||||
|
||||
/**
|
||||
* In this function, a function dependant on the portmacro.h header 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 to unblock
|
||||
* and a context switch is required.
|
||||
*/
|
||||
void requestContextSwitch(SystemContext callContext);
|
||||
|
||||
/**
|
||||
* If task preemption in FreeRTOS is disabled, a context switch
|
||||
* can be requested manually by calling this function.
|
||||
*/
|
||||
void requestContextSwitch(void);
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_OSAL_FREERTOS_TASKMANAGEMENT_H_ */
|
Loading…
Reference in New Issue
Block a user