mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-08-06 11:07:34 +00:00
Added barrier pattern, thread yield and updated event API
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
#include <cmsis_os2.h>
|
||||
#include <sta/event.hpp>
|
||||
|
||||
|
||||
#define STA_EVENT_FLAGS_ALL 0xFFFFFFFFU
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
/**
|
||||
@@ -25,12 +29,12 @@ namespace sta
|
||||
/**
|
||||
* @brief Set given flags for the event.
|
||||
*/
|
||||
void set(uint32_t flags) override;
|
||||
void set(uint32_t flags = STA_EVENT_FLAGS_ALL) override;
|
||||
|
||||
/**
|
||||
* @brief Clear given flags for the event.
|
||||
*/
|
||||
void clear(uint32_t flags) override;
|
||||
void clear(uint32_t flags = STA_EVENT_FLAGS_ALL) override;
|
||||
|
||||
/**
|
||||
* @brief Get current flags for the event.
|
||||
@@ -46,11 +50,11 @@ namespace sta
|
||||
* @param timeout Timeout in milliseconds.
|
||||
* @return Event flags before clearing or error code if highest bit set.
|
||||
*/
|
||||
uint32_t wait(uint32_t flags, uint32_t timeout = osWaitForever) override;
|
||||
uint32_t wait(uint32_t flags = STA_EVENT_FLAGS_ALL, uint32_t timeout = osWaitForever) override;
|
||||
|
||||
private:
|
||||
osEventFlagsId_t event_id; /**< CMSIS RTOS2 Event Flag */
|
||||
};
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_RTOS_EVENT_HPP
|
||||
#endif // STA_RTOS_EVENT_HPP
|
||||
|
31
include/sta/rtos/patterns/barrier.hpp
Normal file
31
include/sta/rtos/patterns/barrier.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* barrier.hpp
|
||||
*
|
||||
* Created on: Mar 16, 2024
|
||||
* Author: Dario
|
||||
*/
|
||||
|
||||
#ifndef RTOS2_UTILS_STA_PATTERNS_BARRIER_HPP
|
||||
#define RTOS2_UTILS_STA_PATTERNS_BARRIER_HPP
|
||||
|
||||
#include <sta/rtos/mutex.hpp>
|
||||
#include <sta/rtos/event.hpp>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
class Barrier {
|
||||
public:
|
||||
Barrier(const char* name, uint8_t n_threads);
|
||||
|
||||
void wait();
|
||||
private:
|
||||
RtosMutex mutex_;
|
||||
RtosEvent flag_;
|
||||
const uint8_t n_threads_;
|
||||
uint8_t n_entered_;
|
||||
uint8_t n_left_;
|
||||
};
|
||||
} // namespace sta
|
||||
|
||||
#endif /* RTOS2_UTILS_STA_PATTERNS_BARRIER_HPP_ */
|
@@ -107,6 +107,12 @@ namespace sta
|
||||
*/
|
||||
void sleep(uint32_t ticks);
|
||||
|
||||
/**
|
||||
* @brief Makes the currently running thread pass control to the next thread.
|
||||
*
|
||||
*/
|
||||
void yield();
|
||||
|
||||
/**
|
||||
* @brief Send user notification flags to thread.
|
||||
*
|
||||
|
Reference in New Issue
Block a user