integrated interface into bin semaphore
This commit is contained in:
parent
9ba21b1e28
commit
4dd6594845
@ -132,6 +132,17 @@ void BinarySemaphore::resetSemaphore() {
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t BinarySemaphore::acquire(uint32_t timeoutMs) {
|
||||
return takeBinarySemaphore(timeoutMs);
|
||||
}
|
||||
|
||||
ReturnValue_t BinarySemaphore::release() {
|
||||
return giveBinarySemaphore();
|
||||
}
|
||||
|
||||
uint8_t BinarySemaphore::getSemaphoreCounter() {
|
||||
return uxSemaphoreGetCount(handle);
|
||||
}
|
||||
|
||||
// Be careful with the stack size here. This is called from an ISR!
|
||||
ReturnValue_t BinarySemaphore::giveBinarySemaphoreFromISR(SemaphoreHandle_t semaphore,
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define FRAMEWORK_OSAL_FREERTOS_BINARYSEMPAHORE_H_
|
||||
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
|
||||
#include <framework/tasks/SemaphoreIF.h>
|
||||
extern "C" {
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/semphr.h>
|
||||
@ -21,7 +21,8 @@ extern "C" {
|
||||
* @author R. Mueller
|
||||
* @ingroup osal
|
||||
*/
|
||||
class BinarySemaphore: public HasReturnvaluesIF {
|
||||
class BinarySemaphore: public SemaphoreIF,
|
||||
public HasReturnvaluesIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::SEMAPHORE_IF;
|
||||
|
||||
@ -67,6 +68,12 @@ public:
|
||||
*/
|
||||
virtual ~BinarySemaphore();
|
||||
|
||||
ReturnValue_t acquire(uint32_t timeoutMs =
|
||||
BinarySemaphore::NO_BLOCK_TIMEOUT) override;
|
||||
ReturnValue_t release() override;
|
||||
|
||||
uint8_t getSemaphoreCounter() override;
|
||||
|
||||
/**
|
||||
* Take the binary semaphore.
|
||||
* If the semaphore has already been taken, the task will be blocked
|
||||
|
@ -9,10 +9,11 @@
|
||||
* task synchronization.
|
||||
*/
|
||||
class SemaphoreIF {
|
||||
public:
|
||||
virtual~ SemaphoreIF() {};
|
||||
//!< Needs to be defined in implementation.
|
||||
static const uint32_t NO_TIMEOUT;
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::SEMAPHORE_IF;
|
||||
|
||||
//! Semaphore timeout
|
||||
static constexpr ReturnValue_t SEMAPHORE_TIMEOUT = MAKE_RETURN_CODE(1);
|
||||
//! The current semaphore can not be given, because it is not owned
|
||||
@ -26,24 +27,23 @@ class SemaphoreIF {
|
||||
* for a maximum of timeoutMs while trying to acquire the semaphore.
|
||||
* This can be used to achieve task synchrnization.
|
||||
* @param timeoutMs
|
||||
* @return
|
||||
* @return - c RETURN_OK for successfull acquisition
|
||||
*/
|
||||
ReturnValue_t acquire(uint32_t timeoutMs) = 0;
|
||||
virtual ReturnValue_t acquire(uint32_t timeoutMs) = 0;
|
||||
|
||||
/**
|
||||
* Corrensponding call to release a semaphore.
|
||||
* @return
|
||||
* @return -@c RETURN_OK for successfull release
|
||||
*/
|
||||
ReturnValue_t release() = 0;
|
||||
virtual ReturnValue_t release() = 0;
|
||||
|
||||
/**
|
||||
* If the semaphore is a counting semaphore then the semaphores current
|
||||
* count value is returned. If the semaphore is a binary semaphore then 1
|
||||
* is returned if the semaphore is available, and 0 is returned if the
|
||||
* semaphore is not available.
|
||||
* @return
|
||||
*/
|
||||
uint8_t getSemaphoreCounter() = 0;
|
||||
virtual uint8_t getSemaphoreCounter() = 0;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_TASKS_SEMAPHOREIF_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user