Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Mutex.cpp
00001 #include "Mutex.h" 00002 00003 #include <string.h> 00004 #include "error.h" 00005 00006 namespace rtos { 00007 00008 Mutex::Mutex () { 00009 #ifdef CMSIS_OS_RTX 00010 memset(_mutex_data, 0, sizeof(_mutex_data)); 00011 _osMutexDef.mutex = _mutex_data; 00012 #endif 00013 _osMutexId = osMutexCreate(&_osMutexDef); 00014 if (_osMutexId == NULL) { 00015 error("Error initializing the mutex object\n"); 00016 } 00017 } 00018 00019 osStatus Mutex::lock (uint32_t millisec) { 00020 return osMutexWait(_osMutexId, millisec); 00021 } 00022 00023 bool Mutex::trylock () { 00024 return (osMutexWait(_osMutexId, 0) == osOK); 00025 } 00026 00027 osStatus Mutex::unlock () { 00028 return osMutexRelease(_osMutexId); 00029 } 00030 00031 Mutex::~Mutex() { 00032 osMutexDelete(_osMutexId); 00033 } 00034 00035 }
Generated on Tue Jul 12 2022 12:34:50 by
1.7.2