2020-05-18 20:35:13 +02:00
|
|
|
#include <framework/osal/FreeRTOS/CountingSemaphore.h>
|
|
|
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
2020-05-27 19:46:56 +02:00
|
|
|
#include <framework/osal/FreeRTOS/TaskManagement.h>
|
2020-05-18 20:35:13 +02:00
|
|
|
|
2020-05-27 19:03:46 +02:00
|
|
|
extern "C" {
|
|
|
|
#include <freertos/semphr.h>
|
|
|
|
}
|
|
|
|
|
2020-05-19 22:45:48 +02:00
|
|
|
// Make sure #define configUSE_COUNTING_SEMAPHORES 1 is set in
|
|
|
|
// free FreeRTOSConfig.h file.
|
2020-05-27 22:12:52 +02:00
|
|
|
CountingSemaphore::CountingSemaphore(const uint8_t maxCount, uint8_t initCount):
|
|
|
|
maxCount(maxCount), initCount(initCount) {
|
|
|
|
handle = xSemaphoreCreateCounting(maxCount, initCount);
|
2020-05-18 20:35:13 +02:00
|
|
|
if(handle == nullptr) {
|
|
|
|
sif::error << "CountingSemaphore: Creation failure" << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-27 22:12:52 +02:00
|
|
|
CountingSemaphore::CountingSemaphore(CountingSemaphore&& other):
|
|
|
|
maxCount(other.maxCount), initCount(other.initCount) {
|
|
|
|
handle = xSemaphoreCreateCounting(other.maxCount, other.initCount);
|
2020-05-18 20:35:13 +02:00
|
|
|
if(handle == nullptr) {
|
|
|
|
sif::error << "CountingSemaphore: Creation failure" << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CountingSemaphore& CountingSemaphore::operator =(
|
|
|
|
CountingSemaphore&& other) {
|
2020-05-27 22:12:52 +02:00
|
|
|
handle = xSemaphoreCreateCounting(other.maxCount, other.initCount);
|
2020-05-18 20:35:13 +02:00
|
|
|
if(handle == nullptr) {
|
|
|
|
sif::error << "CountingSemaphore: Creation failure" << std::endl;
|
|
|
|
}
|
|
|
|
return * this;
|
|
|
|
}
|
2020-05-27 19:46:56 +02:00
|
|
|
|