mirror of
https://github.com/silenty4ng/uv-k5-firmware-chinese-lts
synced 2025-01-30 06:04:20 +00:00
24 lines
513 B
C++
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);
|
|
}
|
|
|
|
}
|