mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-20 15:08:37 +03:00
Initial commit
This commit is contained in:
31
external/CMSIS_5/CMSIS/RTOS/Template/CPP/Mutex.cpp
vendored
Normal file
31
external/CMSIS_5/CMSIS/RTOS/Template/CPP/Mutex.cpp
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
#include "Mutex.h"
|
||||
|
||||
#include <string.h>
|
||||
//#include "error.h"
|
||||
|
||||
namespace rtos {
|
||||
|
||||
Mutex::Mutex() {
|
||||
#ifdef CMSIS_OS_RTX
|
||||
memset(_mutex_data, 0, sizeof(_mutex_data));
|
||||
_osMutexDef.mutex = _mutex_data;
|
||||
#endif
|
||||
_osMutexId = osMutexCreate(&_osMutexDef);
|
||||
if (_osMutexId == NULL) {
|
||||
// error("Error initializing the mutex object\n");
|
||||
}
|
||||
}
|
||||
|
||||
osStatus Mutex::lock(uint32_t millisec) {
|
||||
return osMutexWait(_osMutexId, millisec);
|
||||
}
|
||||
|
||||
bool Mutex::trylock() {
|
||||
return (osMutexWait(_osMutexId, 0) == osOK);
|
||||
}
|
||||
|
||||
osStatus Mutex::unlock() {
|
||||
return osMutexRelease(_osMutexId);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user