1
0
forked from fsfw/fsfw

interface adapted

This commit is contained in:
2020-08-27 16:26:00 +02:00
parent a9c8bea857
commit aacda3afc2
10 changed files with 616 additions and 606 deletions

View File

@ -1,11 +1,11 @@
#include <framework/osal/FreeRTOS/BinarySemaphore.h>
#include <framework/osal/FreeRTOS/TaskManagement.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include "../../osal/FreeRTOS/BinarySemaphore.h"
#include "../../osal/FreeRTOS/TaskManagement.h"
#include "../../serviceinterface/ServiceInterfaceStream.h"
BinarySemaphore::BinarySemaphore() {
handle = xSemaphoreCreateBinary();
if(handle == nullptr) {
sif::error << "Semaphore: Binary semaph creation failure" << std::endl;
if(handle == nullptr) {
sif::error << "Semaphore: Binary semaph creation failure" << std::endl;
}
// Initiated semaphore must be given before it can be taken.
xSemaphoreGive(handle);
@ -35,18 +35,23 @@ BinarySemaphore& BinarySemaphore::operator =(
return *this;
}
ReturnValue_t BinarySemaphore::acquire(uint32_t timeoutMs) {
TickType_t timeout = SemaphoreIF::POLLING;
if(timeoutMs == SemaphoreIF::BLOCKING) {
timeout = SemaphoreIF::BLOCKING;
ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType,
uint32_t timeoutMs) {
TickType_t timeout = 0;
if(timeoutType == TimeoutType::POLLING) {
timeout = 0;
}
else if(timeoutMs > SemaphoreIF::POLLING){
else if(timeoutType == TimeoutType::WAITING){
timeout = pdMS_TO_TICKS(timeoutMs);
}
return acquireWithTickTimeout(timeout);
else {
timeout = portMAX_DELAY;
}
return acquireWithTickTimeout(timeoutType, timeout);
}
ReturnValue_t BinarySemaphore::acquireWithTickTimeout(TickType_t timeoutTicks) {
ReturnValue_t BinarySemaphore::acquireWithTickTimeout(TimeoutType timeoutType,
TickType_t timeoutTicks) {
if(handle == nullptr) {
return SemaphoreIF::SEMAPHORE_INVALID;
}
@ -84,7 +89,7 @@ uint8_t BinarySemaphore::getSemaphoreCounter() const {
SemaphoreHandle_t BinarySemaphore::getSemaphore() {
return handle;
}
// Be careful with the stack size here. This is called from an ISR!
ReturnValue_t BinarySemaphore::releaseFromISR(
@ -100,4 +105,4 @@ ReturnValue_t BinarySemaphore::releaseFromISR(
else {
return SemaphoreIF::SEMAPHORE_NOT_OWNED;
}
}
}