replaced some timeout values

This commit is contained in:
Robin Müller 2020-05-27 17:07:35 +02:00
parent 5b521e039b
commit 968d7fad81
2 changed files with 10 additions and 19 deletions

View File

@ -1,6 +1,5 @@
#include <framework/osal/FreeRTOS/BinarySemaphore.h> #include <framework/osal/FreeRTOS/BinarySemaphore.h>
#include <framework/osal/FreeRTOS/TaskManagement.h> #include <framework/osal/FreeRTOS/TaskManagement.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h> #include <framework/serviceinterface/ServiceInterfaceStream.h>
BinarySemaphore::BinarySemaphore() { BinarySemaphore::BinarySemaphore() {
@ -39,11 +38,11 @@ ReturnValue_t BinarySemaphore::takeBinarySemaphore(uint32_t timeoutMs) {
if(handle == nullptr) { if(handle == nullptr) {
return SEMAPHORE_NULLPOINTER; return SEMAPHORE_NULLPOINTER;
} }
TickType_t timeout = BinarySemaphore::NO_BLOCK_TICKS; TickType_t timeout = SemaphoreIF::NO_TIMEOUT;
if(timeoutMs == BinarySemaphore::BLOCK_TIMEOUT) { if(timeoutMs == SemaphoreIF::MAX_TIMEOUT) {
timeout = BinarySemaphore::BLOCK_TIMEOUT_TICKS; timeout = SemaphoreIF::MAX_TIMEOUT;
} }
else if(timeoutMs > BinarySemaphore::NO_BLOCK_TIMEOUT){ else if(timeoutMs > BinarySemaphore::NO_TIMEOUT){
timeout = pdMS_TO_TICKS(timeoutMs); timeout = pdMS_TO_TICKS(timeoutMs);
} }

View File

@ -3,13 +3,14 @@
#include <framework/returnvalues/HasReturnvaluesIF.h> #include <framework/returnvalues/HasReturnvaluesIF.h>
#include <framework/tasks/SemaphoreIF.h> #include <framework/tasks/SemaphoreIF.h>
extern "C" { extern "C" {
#include <freertos/FreeRTOS.h> #include <freertos/FreeRTOS.h>
#include <freertos/semphr.h> #include <freertos/semphr.h>
} }
// TODO: Counting semaphores and implement the new (better) // TODO: Implement the new (better) task notifications.
// task notifications. However, those use task notifications require // However, those task notifications require
// the task handle. Maybe it would be better to make a separate class // the task handle. Maybe it would be better to make a separate class
// and switch between the classes with #ifdefs. // and switch between the classes with #ifdefs.
// Task Notifications require FreeRTOS V8.2 something.. // Task Notifications require FreeRTOS V8.2 something..
@ -28,15 +29,6 @@ class BinarySemaphore: public SemaphoreIF,
public: public:
static const uint8_t INTERFACE_ID = CLASS_ID::SEMAPHORE_IF; static const uint8_t INTERFACE_ID = CLASS_ID::SEMAPHORE_IF;
//! No block time, poll the semaphore. Can also be used as tick type.
//! Can be passed as tick type and ms value.
static constexpr uint32_t NO_BLOCK_TIMEOUT = 0;
static constexpr TickType_t NO_BLOCK_TICKS = 0;
//! No block time, poll the semaphore.
//! Can be passed as tick type and ms value.
static constexpr TickType_t BLOCK_TIMEOUT_TICKS = portMAX_DELAY;
static constexpr uint32_t BLOCK_TIMEOUT = portMAX_DELAY;
//! @brief Default ctor //! @brief Default ctor
BinarySemaphore(); BinarySemaphore();
//! @brief Copy ctor, deleted explicitely. //! @brief Copy ctor, deleted explicitely.
@ -51,7 +43,7 @@ public:
virtual ~BinarySemaphore(); virtual ~BinarySemaphore();
ReturnValue_t acquire(uint32_t timeoutMs = ReturnValue_t acquire(uint32_t timeoutMs =
BinarySemaphore::NO_BLOCK_TIMEOUT) override; SemaphoreIF::NO_TIMEOUT) override;
ReturnValue_t release() override; ReturnValue_t release() override;
uint8_t getSemaphoreCounter() override; uint8_t getSemaphoreCounter() override;
@ -65,7 +57,7 @@ public:
* -@c RETURN_FAILED on failure * -@c RETURN_FAILED on failure
*/ */
ReturnValue_t takeBinarySemaphore(uint32_t timeoutMs = ReturnValue_t takeBinarySemaphore(uint32_t timeoutMs =
BinarySemaphore::NO_BLOCK_TIMEOUT); SemaphoreIF::NO_TIMEOUT);
/** /**
* Same as lockBinarySemaphore() with timeout in FreeRTOS ticks. * Same as lockBinarySemaphore() with timeout in FreeRTOS ticks.
@ -74,7 +66,7 @@ public:
* - @c RETURN_FAILED on failure * - @c RETURN_FAILED on failure
*/ */
ReturnValue_t takeBinarySemaphoreTickTimeout(TickType_t timeoutTicks = ReturnValue_t takeBinarySemaphoreTickTimeout(TickType_t timeoutTicks =
BinarySemaphore::NO_BLOCK_TICKS); BinarySemaphore::NO_TIMEOUT);
/** /**
* Give back the binary semaphore * Give back the binary semaphore