mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-06-10 01:55:59 +00:00
40 lines
691 B
C++
40 lines
691 B
C++
#include <sta/rtos/signal.hpp>
|
|
|
|
#include <sta/debug/assert.hpp>
|
|
|
|
|
|
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
|