mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-06-12 02:36:00 +00:00
Added Events wrapper
This commit is contained in:
parent
7a86cfeaaa
commit
7ea8bb839e
35
include/sta/rtos/event.hpp
Normal file
35
include/sta/rtos/event.hpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* @brief RTOS event implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef STA_RTOS_EVENT_HPP
|
||||||
|
#define STA_RTOS_EVENT_HPP
|
||||||
|
|
||||||
|
#include <cmsis_os2.h>
|
||||||
|
#include <sta/event.hpp>
|
||||||
|
|
||||||
|
namespace sta
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief Implementation of Event using CMSIS RTOS2.
|
||||||
|
*
|
||||||
|
* @ingroup STA_RTOS_API
|
||||||
|
*/
|
||||||
|
class RtosEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RtosEvent();
|
||||||
|
~RtosEvent();
|
||||||
|
|
||||||
|
void set(uint32_t flags) override;
|
||||||
|
void clear(uint32_t flags) override;
|
||||||
|
uint32_t get() override;
|
||||||
|
uint32_t wait(uint32_t flags, uint32_t timeout = osWaitForever) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
osEventFlagsId_t event_id; /**< CMSIS RTOS2 Event Flag */
|
||||||
|
};
|
||||||
|
} // namespace sta
|
||||||
|
|
||||||
|
#endif // STA_RTOS_EVENT_HPP
|
29
src/event.cpp
Normal file
29
src/event.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include <sta/rtos/event.hpp>
|
||||||
|
|
||||||
|
namespace sta {
|
||||||
|
RtosEvent::RtosEvent() {
|
||||||
|
osEventFlagsAttr_t attr = { 0 };
|
||||||
|
event_id = osEventFlagsNew(&attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
RtosEvent::~RtosEvent() {
|
||||||
|
osEventFlagsDelete(event_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RtosEvent::set(uint32_t flags) {
|
||||||
|
osEventFlagsSet(event_id, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RtosEvent::clear(uint32_t flags) {
|
||||||
|
osEventFlagsClear(event_id, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t RtosEvent::get() {
|
||||||
|
return osEventFlagsGet(event_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t RtosEvent::wait(uint32_t flags, uint32_t timeout) {
|
||||||
|
return osEventFlagsWait(event_id, flags, osFlagsWaitAny, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace sta
|
Loading…
x
Reference in New Issue
Block a user