From b5567e8aae90e5f87e6d94b45b9c51889387bb41 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 9 Jun 2020 13:26:27 +0200 Subject: [PATCH] rtems mutex update --- osal/rtems/Mutex.cpp | 17 +++++++++++++++-- osal/rtems/Mutex.h | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/osal/rtems/Mutex.cpp b/osal/rtems/Mutex.cpp index 0c1675b1..5487a503 100644 --- a/osal/rtems/Mutex.cpp +++ b/osal/rtems/Mutex.cpp @@ -1,7 +1,7 @@ #include "Mutex.h" #include -const uint32_t MutexIF::BLOCKING = RTEMS_NO_TIMEOUT; +const uint32_t MutexIF::BLOCKING = RTEMS_WAIT; const uint32_t MutexIF::POLLING = RTEMS_NO_WAIT; uint8_t Mutex::count = 0; @@ -26,7 +26,20 @@ Mutex::~Mutex() { } ReturnValue_t Mutex::lockMutex(uint32_t timeoutMs) { - rtems_status_code status = rtems_semaphore_obtain(mutexId, RTEMS_WAIT, timeoutMs); + if(timeoutMs == MutexIF::BLOCKING) { + rtems_status_code status = rtems_semaphore_obtain(mutexId, + RTEMS_WAIT, timeoutMs); + } + else if(timeoutMs == MutexIF::POLLING) { + timeoutMs = RTEMS_NO_TIMEOUT; + rtems_status_code status = rtems_semaphore_obtain(mutexId, + RTEMS_NO_WAIT, timeoutMs); + } + else { + rtems_status_code status = rtems_semaphore_obtain(mutexId, + RTEMS_NO_WAIT, timeoutMs); + } + switch(status){ case RTEMS_SUCCESSFUL: //semaphore obtained successfully diff --git a/osal/rtems/Mutex.h b/osal/rtems/Mutex.h index 486055ba..4aa25e40 100644 --- a/osal/rtems/Mutex.h +++ b/osal/rtems/Mutex.h @@ -8,7 +8,7 @@ class Mutex : public MutexIF { public: Mutex(); ~Mutex(); - ReturnValue_t lockMutex(uint32_t timeoutMs); + ReturnValue_t lockMutex(uint32_t timeoutMs = MutexIF::BLOCKING); ReturnValue_t unlockMutex(); private: rtems_id mutexId;