mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-08-02 18:11:53 +00:00
Add system events handling
This commit is contained in:
commit
dde9b83a29
45
include/sta/system_event.hpp
Normal file
45
include/sta/system_event.hpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#ifndef STA_SYSTEM_EVENT_HPP
|
||||||
|
#define STA_SYSTEM_EVENT_HPP
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
// System event flags
|
||||||
|
//
|
||||||
|
|
||||||
|
#define STA_SYSTEM_EVENT_STARTUP 0x00100000U
|
||||||
|
|
||||||
|
|
||||||
|
namespace sta
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief Signal system events
|
||||||
|
*
|
||||||
|
* @param flags System event flags
|
||||||
|
*/
|
||||||
|
void signalSystemEvents(uint32_t flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Wait for system event.
|
||||||
|
*
|
||||||
|
* @param flags System event flags
|
||||||
|
* @param options osFlagsWaitAll or osFlagsWaitAny (osFlagsNoClear always set)
|
||||||
|
* @param timeout Wait timeout (0 = instant, osWaitForever = infinite)
|
||||||
|
*/
|
||||||
|
void waitForSystemEvents(uint32_t flags, uint32_t options, uint32_t timeout);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Signal startup system event
|
||||||
|
*/
|
||||||
|
void signalStartupCompleted();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Wait for startup system event.
|
||||||
|
*
|
||||||
|
* Blocking while waiting
|
||||||
|
*/
|
||||||
|
void waitForStartup();
|
||||||
|
} // namespace sta
|
||||||
|
|
||||||
|
|
||||||
|
#endif // STA_SYSTEM_EVENT_HPP
|
32
src/system_event.cpp
Normal file
32
src/system_event.cpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include <sta/system_event.hpp>
|
||||||
|
|
||||||
|
#include <cmsis_os2.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern osEventFlagsId_t systemEventHandle;
|
||||||
|
|
||||||
|
|
||||||
|
namespace sta
|
||||||
|
{
|
||||||
|
void signalSystemEvents(uint32_t flags)
|
||||||
|
{
|
||||||
|
osEventFlagsSet(systemEventHandle, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void waitForSystemEvents(uint32_t flags, uint32_t options, uint32_t timeout)
|
||||||
|
{
|
||||||
|
osEventFlagsWait(systemEventHandle, flags, options | osFlagsNoClear, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void signalStartupCompleted()
|
||||||
|
{
|
||||||
|
signalSystemEvents(STA_SYSTEM_EVENT_STARTUP);
|
||||||
|
}
|
||||||
|
|
||||||
|
void waitForStartup()
|
||||||
|
{
|
||||||
|
waitForSystemEvents(STA_SYSTEM_EVENT_STARTUP, osFlagsWaitAll, osWaitForever);
|
||||||
|
}
|
||||||
|
} // namespace sta
|
Loading…
x
Reference in New Issue
Block a user