Adds sitara_depot/free_rtos Original one is on server_gorbunov/SmartForce4.0/sitara_depot
36 lines
629 B
C++
36 lines
629 B
C++
/*
|
|
* mutex.cpp
|
|
*
|
|
* Created on: 26 ñåíò. 2022 ã.
|
|
* Author: sychev
|
|
*/
|
|
#include "mutex/mutex.hpp"
|
|
#include <kernel/dpl/DebugP.h>
|
|
|
|
free_rtos::Mutex::Mutex() {
|
|
handle_ = xSemaphoreCreateMutex();
|
|
DebugP_assert(nullptr != handle_);
|
|
}
|
|
|
|
BaseType_t free_rtos::Mutex::lock(TickType_t wait) {
|
|
return xSemaphoreTake( handle_, wait );
|
|
}
|
|
|
|
void free_rtos::Mutex::unlock(void) {
|
|
xSemaphoreGive(handle_);
|
|
}
|
|
|
|
free_rtos::Mutex::~Mutex() {
|
|
vSemaphoreDelete(handle_);
|
|
}
|
|
|
|
free_rtos::LockGuard::LockGuard(Mutex& mutex) : mutex_{mutex} {
|
|
mutex_.lock();
|
|
}
|
|
|
|
free_rtos::LockGuard::~LockGuard() {
|
|
mutex_.unlock();
|
|
}
|
|
|
|
|