#include #include namespace sta { RtosSignal::RtosSignal(osSemaphoreId_t semaphore) : semaphore_{semaphore} { STA_ASSERT(semaphore != NULL); } RtosSignal::RtosSignal(uint32_t max, uint32_t initial /* = 0 */) : semaphore_{osSemaphoreNew(max, initial, NULL)} { STA_ASSERT(semaphore_ != NULL); } void RtosSignal::notify() { osSemaphoreRelease(semaphore_); } bool RtosSignal::peek() { return (osSemaphoreGetCount(semaphore_) != 0); } bool RtosSignal::test() { return (osSemaphoreAcquire(semaphore_, 0) == osOK); } void RtosSignal::wait() { osSemaphoreAcquire(semaphore_, osWaitForever); } } // namespace sta