uv-k5-firmware-chinese-lts/external/CMSIS_5/CMSIS/RTOS/Template/CPP/Semaphore.cpp
2023-11-30 14:38:27 +08:00

24 lines
513 B
C++

#include "Semaphore.h"
#include <string.h>
//#include "error.h"
namespace rtos {
Semaphore::Semaphore(int32_t count) {
#ifdef CMSIS_OS_RTX
memset(_semaphore_data, 0, sizeof(_semaphore_data));
_osSemaphoreDef.semaphore = _semaphore_data;
#endif
_osSemaphoreId = osSemaphoreCreate(&_osSemaphoreDef, count);
}
int32_t Semaphore::wait(uint32_t millisec) {
return osSemaphoreWait(_osSemaphoreId, millisec);
}
osStatus Semaphore::release(void) {
return osSemaphoreRelease(_osSemaphoreId);
}
}