RTOS Wrapper
API reference
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
PeriodicTimer Class Reference

Simple RAII wrapper around OS timers. More...

#include <PeriodicTimer.h>

Public Member Functions

 PeriodicTimer () noexcept
 
 ~PeriodicTimer ()
 
bool Create (const char *name, void(*callback)(uint32_t), uint32_t arg, uint32_t periodMs, bool autoStart=false) noexcept
 Create a periodic timer.
 
bool Start () noexcept
 
bool Stop () noexcept
 
bool Destroy () noexcept
 
bool IsValid () const noexcept
 

Private Attributes

OS_Timer timer
 
bool created
 

Detailed Description

Simple RAII wrapper around OS timers.

Constructor & Destructor Documentation

◆ PeriodicTimer()

PeriodicTimer::PeriodicTimer ( )
inlinenoexcept

Construct an empty timer.

◆ ~PeriodicTimer()

PeriodicTimer::~PeriodicTimer ( )
inline

Delete timer on destruction.

Member Function Documentation

◆ Create()

bool PeriodicTimer::Create ( const char *  name,
void(*)(uint32_t)  callback,
uint32_t  arg,
uint32_t  periodMs,
bool  autoStart = false 
)
inlinenoexcept

Create a periodic timer.

Parameters
nameTimer name used for debugging.
callbackFunction called on each expiration.
argValue passed to the callback.
periodMsPeriod in milliseconds.
autoStartWhether to start immediately after creation.
Returns
true on success.

◆ Destroy()

bool PeriodicTimer::Destroy ( )
inlinenoexcept

Delete the timer.

◆ IsValid()

bool PeriodicTimer::IsValid ( ) const
inlinenoexcept

Check if the timer was successfully created.

◆ Start()

bool PeriodicTimer::Start ( )
inlinenoexcept

Start the timer.

◆ Stop()

bool PeriodicTimer::Stop ( )
inlinenoexcept

Stop the timer.

Member Data Documentation

◆ created

bool PeriodicTimer::created
private

◆ timer

OS_Timer PeriodicTimer::timer
private

The documentation for this class was generated from the following file: