1
0
forked from fsfw/fsfw

counting semaph implementation finished

This commit is contained in:
2020-05-27 22:12:52 +02:00
parent 95bf5c1071
commit 63dbf99592
8 changed files with 154 additions and 87 deletions

View File

@ -43,21 +43,13 @@ ReturnValue_t BinarySemaphore::acquire(uint32_t timeoutMs) {
if(timeoutMs == SemaphoreIF::MAX_TIMEOUT) {
timeout = SemaphoreIF::MAX_TIMEOUT;
}
else if(timeoutMs > BinarySemaphore::NO_TIMEOUT){
else if(timeoutMs > SemaphoreIF::NO_TIMEOUT){
timeout = pdMS_TO_TICKS(timeoutMs);
}
BaseType_t returncode = xSemaphoreTake(handle, timeout);
if (returncode == pdPASS) {
return HasReturnvaluesIF::RETURN_OK;
}
else {
return SemaphoreIF::SEMAPHORE_TIMEOUT;
}
return acquireWithTickTimeout(timeout);
}
ReturnValue_t BinarySemaphore::acquireWithTickTimeout(
TickType_t timeoutTicks) {
ReturnValue_t BinarySemaphore::acquireWithTickTimeout(TickType_t timeoutTicks) {
if(handle == nullptr) {
return SemaphoreIF::SEMAPHORE_NULLPOINTER;
}
@ -65,20 +57,22 @@ ReturnValue_t BinarySemaphore::acquireWithTickTimeout(
BaseType_t returncode = xSemaphoreTake(handle, timeoutTicks);
if (returncode == pdPASS) {
return HasReturnvaluesIF::RETURN_OK;
} else {
}
else {
return SemaphoreIF::SEMAPHORE_TIMEOUT;
}
}
ReturnValue_t BinarySemaphore::release() {
if (handle == nullptr) {
return SEMAPHORE_NULLPOINTER;
return SemaphoreIF::SEMAPHORE_NULLPOINTER;
}
BaseType_t returncode = xSemaphoreGive(handle);
if (returncode == pdPASS) {
return HasReturnvaluesIF::RETURN_OK;
} else {
return SEMAPHORE_NOT_OWNED;
}
else {
return SemaphoreIF::SEMAPHORE_NOT_OWNED;
}
}