1
0
forked from fsfw/fsfw

renormalized line endings

This commit is contained in:
2020-08-28 18:33:29 +02:00
parent 9abd796e6f
commit 1b9c8446b7
381 changed files with 38723 additions and 38723 deletions

View File

@ -1,51 +1,51 @@
#include "../../osal/FreeRTOS/Mutex.h"
#include "../../serviceinterface/ServiceInterfaceStream.h"
Mutex::Mutex() {
handle = xSemaphoreCreateMutex();
if(handle == nullptr) {
sif::error << "Mutex::Mutex(FreeRTOS): Creation failure" << std::endl;
}
}
Mutex::~Mutex() {
if (handle != nullptr) {
vSemaphoreDelete(handle);
}
}
ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType,
uint32_t timeoutMs) {
if (handle == nullptr) {
return MutexIF::MUTEX_NOT_FOUND;
}
// If the timeout type is BLOCKING, this will be the correct value.
uint32_t timeout = portMAX_DELAY;
if(timeoutType == TimeoutType::POLLING) {
timeout = 0;
}
else if(timeoutType == TimeoutType::WAITING){
timeout = pdMS_TO_TICKS(timeoutMs);
}
BaseType_t returncode = xSemaphoreTake(handle, timeout);
if (returncode == pdPASS) {
return HasReturnvaluesIF::RETURN_OK;
} else {
return MutexIF::MUTEX_TIMEOUT;
}
}
ReturnValue_t Mutex::unlockMutex() {
if (handle == nullptr) {
return MutexIF::MUTEX_NOT_FOUND;
}
BaseType_t returncode = xSemaphoreGive(handle);
if (returncode == pdPASS) {
return HasReturnvaluesIF::RETURN_OK;
} else {
return MutexIF::CURR_THREAD_DOES_NOT_OWN_MUTEX;
}
}
#include "../../osal/FreeRTOS/Mutex.h"
#include "../../serviceinterface/ServiceInterfaceStream.h"
Mutex::Mutex() {
handle = xSemaphoreCreateMutex();
if(handle == nullptr) {
sif::error << "Mutex::Mutex(FreeRTOS): Creation failure" << std::endl;
}
}
Mutex::~Mutex() {
if (handle != nullptr) {
vSemaphoreDelete(handle);
}
}
ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType,
uint32_t timeoutMs) {
if (handle == nullptr) {
return MutexIF::MUTEX_NOT_FOUND;
}
// If the timeout type is BLOCKING, this will be the correct value.
uint32_t timeout = portMAX_DELAY;
if(timeoutType == TimeoutType::POLLING) {
timeout = 0;
}
else if(timeoutType == TimeoutType::WAITING){
timeout = pdMS_TO_TICKS(timeoutMs);
}
BaseType_t returncode = xSemaphoreTake(handle, timeout);
if (returncode == pdPASS) {
return HasReturnvaluesIF::RETURN_OK;
} else {
return MutexIF::MUTEX_TIMEOUT;
}
}
ReturnValue_t Mutex::unlockMutex() {
if (handle == nullptr) {
return MutexIF::MUTEX_NOT_FOUND;
}
BaseType_t returncode = xSemaphoreGive(handle);
if (returncode == pdPASS) {
return HasReturnvaluesIF::RETURN_OK;
} else {
return MutexIF::CURR_THREAD_DOES_NOT_OWN_MUTEX;
}
}