2020-05-27 19:46:56 +02:00
|
|
|
#ifndef FRAMEWORK_OSAL_FREERTOS_COUNTINGSEMAPHUSINGTASK_H_
|
|
|
|
#define FRAMEWORK_OSAL_FREERTOS_COUNTINGSEMAPHUSINGTASK_H_
|
|
|
|
|
|
|
|
#include <framework/osal/FreeRTOS/CountingSemaphUsingTask.h>
|
|
|
|
#include <framework/tasks/SemaphoreIF.h>
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <freertos/FreeRTOS.h>
|
|
|
|
#include <freertos/task.h>
|
|
|
|
}
|
|
|
|
|
|
|
|
class CountingSemaphoreUsingTask: public SemaphoreIF {
|
|
|
|
public:
|
2020-05-27 21:27:31 +02:00
|
|
|
CountingSemaphoreUsingTask(uint8_t maxCount, uint8_t initCount);
|
2020-05-27 19:46:56 +02:00
|
|
|
|
2020-05-27 19:56:02 +02:00
|
|
|
ReturnValue_t acquire(uint32_t timeoutMs) override;
|
|
|
|
ReturnValue_t release() override;
|
|
|
|
uint8_t getSemaphoreCounter() override;
|
2020-05-27 19:46:56 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
TaskHandle_t handle;
|
2020-05-27 21:27:31 +02:00
|
|
|
const uint8_t maxCount;
|
|
|
|
uint8_t currentCount = 0;
|
2020-05-27 19:46:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* FRAMEWORK_OSAL_FREERTOS_COUNTINGSEMAPHUSINGTASK_H_ */
|