Merge pull request 'Added Support for Timers and Events' (#4) from adding-events into main

Reviewed-on: https://git.intern.spaceteamaachen.de/ALPAKA/sta-core/pulls/4
Reviewed-by: dario <dario@noreply.git.intern.spaceteamaachen.de>
This commit is contained in:
carlwachter 2023-09-14 20:53:23 +00:00
commit 4dc625f6e9
2 changed files with 81 additions and 0 deletions

47
include/sta/event.hpp Normal file
View File

@ -0,0 +1,47 @@
/**
* @file
* @brief Event interface definition.
*/
#ifndef STA_CORE_EVENT_HPP
#define STA_CORE_EVENT_HPP
namespace sta
{
/**
* @brief Interface for event objects.
*
* @ingroup sta_core
*/
class Event
{
public:
/**
* @brief Set event flag.
*
* @param Flag nr. to set
*/
virtual void set(uint32_t flags) = 0;
/**
* @brief Clear event flag.
*
* @param Flag nr. to clear
*/
virtual void clear(uint32_t flags) = 0;
/**
* @brief Check event flag state w/o changing it.
*
* @return Value of event flag
*/
virtual uint32_t get() = 0;
/**
* @brief Wait until event flag is set. Timeout default to forever.
*
* @param Event flag nr. to wait for.
*/
virtual uint32_t wait(uint32_t flags, uint32_t timeout = osWaitForever) = 0;
};
} // namespace sta
#endif //STA_CORE_EVENT_HPP

34
include/sta/timer.hpp Normal file
View File

@ -0,0 +1,34 @@
/**
* @file
* @brief Timer interface definition.
*/
#ifndef STA_CORE_TIMER_HPP
#define STA_CORE_TIMER_HPP
namespace sta
{
/**
* @brief Interface for timer objects.
*
* @ingroup sta_core
*/
class Timer
{
public:
/**
* @brief Start Timer.
*
* @param time in milliseconds
*/
virtual void start(uint32_t millis) = 0;
/**
* @brief Stop Timer.
*
*/
virtual void stop() = 0;
};
} // namespace sta
#endif //STA_CORE_TIMER_HPP