implementing new task notifications
This commit is contained in:
@ -6,7 +6,11 @@
|
||||
|
||||
extern "C" {
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#if ( configUSE_OLD_SEMAPHORES == 1 )
|
||||
#include <freertos/semphr.h>
|
||||
#else
|
||||
#include <freertos/task.h>
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO: Implement the new (better) task notifications.
|
||||
@ -24,11 +28,13 @@ extern "C" {
|
||||
* @author R. Mueller
|
||||
* @ingroup osal
|
||||
*/
|
||||
#if ( configUSE_OLD_SEMAPHORES == 1 )
|
||||
|
||||
class BinarySemaphore: public SemaphoreIF,
|
||||
public HasReturnvaluesIF {
|
||||
public HasReturnvaluesIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::SEMAPHORE_IF;
|
||||
|
||||
|
||||
//! @brief Default ctor
|
||||
BinarySemaphore();
|
||||
//! @brief Copy ctor, deleted explicitely.
|
||||
@ -46,7 +52,7 @@ public:
|
||||
SemaphoreIF::NO_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
|
||||
@ -81,11 +87,6 @@ public:
|
||||
*/
|
||||
SemaphoreHandle_t getSemaphore();
|
||||
|
||||
/**
|
||||
* Reset the semaphore.
|
||||
*/
|
||||
void resetSemaphore();
|
||||
|
||||
/**
|
||||
* Wrapper function to give back semaphore from handle
|
||||
* @param semaphore
|
||||
@ -104,9 +105,83 @@ public:
|
||||
*/
|
||||
static ReturnValue_t giveBinarySemaphoreFromISR(SemaphoreHandle_t semaphore,
|
||||
BaseType_t * higherPriorityTaskWoken);
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
SemaphoreHandle_t handle;
|
||||
};
|
||||
|
||||
|
||||
#else
|
||||
|
||||
class BinarySemaphore: public SemaphoreIF,
|
||||
public HasReturnvaluesIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::SEMAPHORE_IF;
|
||||
|
||||
//! @brief Default ctor
|
||||
BinarySemaphore();
|
||||
|
||||
ReturnValue_t acquire(uint32_t timeoutMs =
|
||||
SemaphoreIF::NO_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
|
||||
* for a maximum of #timeoutMs or until the semaphore is given back,
|
||||
* for example by an ISR or another task.
|
||||
* @param timeoutMs
|
||||
* @return -@c RETURN_OK on success
|
||||
* -@c RETURN_FAILED on failure
|
||||
*/
|
||||
ReturnValue_t takeBinarySemaphore(uint32_t timeoutMs =
|
||||
SemaphoreIF::NO_TIMEOUT);
|
||||
|
||||
/**
|
||||
* Same as lockBinarySemaphore() with timeout in FreeRTOS ticks.
|
||||
* @param timeoutTicks
|
||||
* @return - @c RETURN_OK on success
|
||||
* - @c RETURN_FAILED on failure
|
||||
*/
|
||||
ReturnValue_t takeBinarySemaphoreTickTimeout(TickType_t timeoutTicks =
|
||||
BinarySemaphore::NO_TIMEOUT);
|
||||
|
||||
/**
|
||||
* Give back the binary semaphore
|
||||
* @return - @c RETURN_OK on success
|
||||
* - @c RETURN_FAILED on failure
|
||||
*/
|
||||
ReturnValue_t giveBinarySemaphore();
|
||||
|
||||
/**
|
||||
* Get Handle to the semaphore.
|
||||
* @return
|
||||
*/
|
||||
TaskHandle_t getTaskHandle();
|
||||
|
||||
/**
|
||||
* Wrapper function to give back semaphore from handle
|
||||
* @param semaphore
|
||||
* @return - @c RETURN_OK on success
|
||||
* - @c RETURN_FAILED on failure
|
||||
*/
|
||||
static ReturnValue_t giveBinarySemaphore(TaskHandle_t taskToNotify);
|
||||
|
||||
/**
|
||||
* Wrapper function to give back semaphore from handle when called from an ISR
|
||||
* @param semaphore
|
||||
* @param higherPriorityTaskWoken This will be set to pdPASS if a task with a higher priority
|
||||
* was unblocked
|
||||
* @return - @c RETURN_OK on success
|
||||
* - @c RETURN_FAILED on failure
|
||||
*/
|
||||
static ReturnValue_t giveBinarySemaphoreFromISR(TaskHandle_t taskToNotify,
|
||||
BaseType_t * higherPriorityTaskWoken);
|
||||
|
||||
protected:
|
||||
TaskHandle_t handle;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* FRAMEWORK_OSAL_FREERTOS_BINARYSEMPAHORE_H_ */
|
||||
|
Reference in New Issue
Block a user