Added flags clear for thread and new constructor for queue.

This commit is contained in:
dario 2023-11-07 12:40:50 +01:00
parent 0e96b2ec29
commit c609dc81cc
4 changed files with 28 additions and 0 deletions

View File

@ -34,6 +34,11 @@ namespace sta
*/
RtosQueue(osMessageQueueId_t handle);
/**
* @param length The maximum number of elements to be stored in the queue.
*/
RtosQueue(uint32_t length);
/**
* @brief Place message in queue.
*

View File

@ -21,6 +21,13 @@ namespace sta
{
STA_ASSERT(handle != nullptr);
}
template <typename T>
RtosQueue<T>::RtosQueue(uint32_t length)
: handle_{osMessageQueueNew(length, sizeof(Message), NULL)}
{
STA_ASSERT(handle_ != NULL);
}
template <typename T>
bool RtosQueue<T>::put(const Message & msg, uint32_t timeout /* = osWaitForever */)

View File

@ -98,6 +98,13 @@ namespace sta
*/
uint32_t wait(uint32_t flags);
/**
* @brief Clears the thread flags set for this thread.
*
* @return Returns the thread flags that set before clearing.
*/
uint32_t clear(uint32_t flags);
/**
* @brief Send termination request to thread.
*/

View File

@ -41,6 +41,15 @@ namespace sta
return osThreadFlagsWait(flags, osFlagsWaitAny, osWaitForever);
}
uint32_t RtosThread::clear(uint32_t flags)
{
uint32_t setFlags = osThreadFlagsClear(flags);
STA_ASSERT(setFlags != (uint32_t)osError);
return setFlags;
}
uint32_t RtosThread::getFlags()
{
STA_ASSERT(handle_.get() != nullptr);