1
0
forked from fsfw/fsfw

implemented counting semaph for linux

This commit is contained in:
2020-05-29 01:41:16 +02:00
parent 56498e5bc1
commit 671f298935
7 changed files with 155 additions and 20 deletions

View File

@ -10,6 +10,12 @@ extern "C" {
// free FreeRTOSConfig.h file.
CountingSemaphore::CountingSemaphore(const uint8_t maxCount, uint8_t initCount):
maxCount(maxCount), initCount(initCount) {
if(initCount > maxCount) {
sif::error << "CountingSemaphoreUsingTask: Max count bigger than "
"intial cout. Setting initial count to max count." << std::endl;
initCount = maxCount;
}
handle = xSemaphoreCreateCounting(maxCount, initCount);
if(handle == nullptr) {
sif::error << "CountingSemaphore: Creation failure" << std::endl;
@ -33,3 +39,7 @@ CountingSemaphore& CountingSemaphore::operator =(
return * this;
}
uint8_t CountingSemaphore::getMaxCount() const {
return maxCount;
}