Skip to content

Commit

Permalink
cpu/esp32/freertos/semphr.c::xSemaphoreTake() return value fix
Browse files Browse the repository at this point in the history
xSemaphoreTake() 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 xSemaphoreTake() was successful in obtaining the semaphore"
"pdFAIL Returned if the call to xSemaphoreTake() did not successfully obtain the semaphore."
Fixed it to return the correct value.
  • Loading branch information
JulianHolzwarth committed Mar 27, 2019
1 parent 0a7a86d commit 1b42d3f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 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) == 0) ? pdTRUE : pdFALSE;
return (mutex_trylock(mutex) == 1) ? pdTRUE : pdFALSE;
}
else {
mutex_lock(mutex);
Expand Down

0 comments on commit 1b42d3f

Please sign in to comment.