Ethernetwebsoc
Dependencies: C12832_lcd LM75B WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip
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 19:26:06 by 1.7.2