mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-08-06 11:07:34 +00:00
Updated id handling for mutex and signal, sleep() for thread.
This commit is contained in:
@@ -1,19 +1,29 @@
|
||||
#include <sta/rtos/mutex.hpp>
|
||||
|
||||
#include <sta/debug/assert.hpp>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
RtosMutex::RtosMutex(osMutexId_t * handle)
|
||||
RtosMutex::RtosMutex(osMutexId_t handle)
|
||||
: handle_{handle}
|
||||
{}
|
||||
|
||||
RtosMutex::RtosMutex(const char* name)
|
||||
{
|
||||
osMutexAttr_t attribs = { .name = "uartMutex"};
|
||||
handle_ = osMutexNew(&attribs);
|
||||
|
||||
STA_ASSERT(handle_ != NULL);
|
||||
}
|
||||
|
||||
void RtosMutex::acquire()
|
||||
{
|
||||
osMutexAcquire(*handle_, osWaitForever);
|
||||
osMutexAcquire(handle_, osWaitForever);
|
||||
}
|
||||
|
||||
void RtosMutex::release()
|
||||
{
|
||||
osMutexRelease(*handle_);
|
||||
osMutexRelease(handle_);
|
||||
}
|
||||
} // namespace sta
|
||||
|
@@ -3,27 +3,27 @@
|
||||
|
||||
namespace sta
|
||||
{
|
||||
RtosSignal::RtosSignal(osSemaphoreId_t * semaphore)
|
||||
RtosSignal::RtosSignal(osSemaphoreId_t semaphore)
|
||||
: semaphore_{semaphore}
|
||||
{}
|
||||
|
||||
void RtosSignal::notify()
|
||||
{
|
||||
osSemaphoreRelease(*semaphore_);
|
||||
osSemaphoreRelease(semaphore_);
|
||||
}
|
||||
|
||||
bool RtosSignal::peek()
|
||||
{
|
||||
return (osSemaphoreGetCount(*semaphore_) != 0);
|
||||
return (osSemaphoreGetCount(semaphore_) != 0);
|
||||
}
|
||||
|
||||
bool RtosSignal::test()
|
||||
{
|
||||
return (osSemaphoreAcquire(*semaphore_, 0) == osOK);
|
||||
return (osSemaphoreAcquire(semaphore_, 0) == osOK);
|
||||
}
|
||||
|
||||
void RtosSignal::wait()
|
||||
{
|
||||
osSemaphoreAcquire(*semaphore_, osWaitForever);
|
||||
osSemaphoreAcquire(semaphore_, osWaitForever);
|
||||
}
|
||||
} // namespace sta
|
||||
|
@@ -17,6 +17,10 @@ namespace sta
|
||||
terminate_{false}
|
||||
{}
|
||||
|
||||
void RtosThread::sleep(uint32_t ticks)
|
||||
{
|
||||
osDelay(ticks);
|
||||
}
|
||||
|
||||
void RtosThread::notify(uint32_t flags)
|
||||
{
|
||||
|
Reference in New Issue
Block a user