Skip to content

Commit

Permalink
cpu/esp32/freertos/semphr.c::xSemaphoreTakeRecursive() return value fix
Browse files Browse the repository at this point in the history
xSemaphoreTakeRecursive() returned before the fix: pdFALSE(equal to pdFAIL) when the call was successful in obtaining the semaphore
and pdTRUE(equal to pdPASS) when the call did not successfully obtain the semaphore.
According to freertos documentation:
"pdPASS Returned only if the call to xSemaphoreTakeRecursive() was successful in obtaining the semaphore"
"pdFAIL Returned if the call to xSemaphoreTakeRecursive() did not successfully obtain the semaphore."
Fixed it to return the correct value.
  • Loading branch information
JulianHolzwarth committed Mar 27, 2019
1 parent 800f758 commit 04cbb4f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cpu/esp32/freertos/semphr.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ BaseType_t xSemaphoreTake (SemaphoreHandle_t xSemaphore,
case queueQUEUE_TYPE_MUTEX:
{
if (xTicksToWait == 0) {
return (mutex_trylock(mutex) == 1) ? pdTRUE : pdFALSE;
return (mutex_trylock(mutex) == 1) ? pdPASS : pdFAIL;
}
else {
mutex_lock(mutex);
Expand Down Expand Up @@ -147,7 +147,7 @@ BaseType_t xSemaphoreTakeRecursive (SemaphoreHandle_t xSemaphore,
rmutex_t* rmutex = &((_rmutex_t*)xSemaphore)->rmutex;

if (xTicksToWait == 0) {
ret = (rmutex_trylock(rmutex) == 0) ? pdTRUE : pdFALSE;
ret = (rmutex_trylock(rmutex) == 1) ? pdPASS : pdFAIL;
}
else {
rmutex_lock(&((_rmutex_t*)xSemaphore)->rmutex);
Expand Down

0 comments on commit 04cbb4f

Please sign in to comment.