Skip to content

Commit

Permalink
Update FreeRTOS.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
h2zero committed May 1, 2019
1 parent a6bbf24 commit e7e2653
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cpp_utils/FreeRTOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,22 @@ uint32_t FreeRTOS::getTimeSinceStart() {
*/
uint32_t FreeRTOS::Semaphore::wait(std::string owner) {
ESP_LOGV(LOG_TAG, ">> wait: Semaphore waiting: %s for %s", toString().c_str(), owner.c_str());

m_owner = owner;

if (m_usePthreads) {
pthread_mutex_lock(&m_pthread_mutex);
} else {
xSemaphoreTake(m_semaphore, portMAX_DELAY);
}

m_owner = owner;

if (m_usePthreads) {
pthread_mutex_unlock(&m_pthread_mutex);
} else {
xSemaphoreGive(m_semaphore);
}

ESP_LOGV(LOG_TAG, "<< wait: Semaphore released: %s", toString().c_str());
m_owner = std::string("<N/A>");
return m_value;
} // wait

Expand All @@ -93,7 +92,8 @@ FreeRTOS::Semaphore::Semaphore(std::string name) {
if (m_usePthreads) {
pthread_mutex_init(&m_pthread_mutex, nullptr);
} else {
m_semaphore = xSemaphoreCreateMutex();
m_semaphore = xSemaphoreCreateBinary();
xSemaphoreGive(m_semaphore);
}

m_name = name;
Expand Down

0 comments on commit e7e2653

Please sign in to comment.