Mark3 Realtime Kernel
Mark3::Timer Class Reference

The Timer Class. This class provides kernel-managed timers, used to provide high-precision delays. Functionality is useful to both user-code, and is used extensively within the kernel and its blocking objects to implement round-robin scheduling, thread sleep, and timeouts. Provides one-shot and periodic timers for use by application code. This object relies on a target-defined hardware timer implementation, which is multiplexed by the kernel's timer scheduler. More...

#include <timer.h>

Inheritance diagram for Mark3::Timer:
Mark3::TypedLinkListNode< Timer > Mark3::LinkListNode

Public Member Functions

void * operator new (size_t sz, void *pv)
 
 ~Timer ()
 
 Timer ()
 Timer Default Constructor - Do nothing. Allow the init call to perform the necessary object initialization prior to use. More...
 
void Init ()
 Init Re-initialize the Timer to default values. More...
 
void Start (bool bRepeat_, uint32_t u32IntervalMs_, TimerCallback pfCallback_, void *pvData_)
 Start Start a timer using default ownership, using repeats as an option, and millisecond resolution. More...
 
void Start ()
 Start Start or restart a timer using parameters previously configured via calls to Start(<with args>), or via the a-la-carte parameter setter methods. This is especially useful for retriggering one-shot timers that have previously expired, using the timer's previous configuration. More...
 
void Stop ()
 Stop Stop a timer already in progress. Has no effect on timers that have already been stopped. More...
 

Private Member Functions

void SetInitialized ()
 SetInitialized. More...
 
bool IsInitialized (void)
 IsInitialized. More...
 

Static Private Member Functions

static uint32_t SecondsToTicks (uint32_t x)
 
static uint32_t MSecondsToTicks (uint32_t x)
 
static uint32_t USecondsToTicks (uint32_t x)
 

Private Attributes

uint8_t m_u8Initialized
 Cookie used to determine whether or not the timer is initialized. More...
 
uint8_t m_u8Flags
 Flags for the timer, defining if the timer is one-shot or repeated. More...
 
TimerCallback m_pfCallback
 Pointer to the callback function. More...
 
uint32_t m_u32Interval
 Interval of the timer in timer ticks. More...
 
uint32_t m_u32TimeLeft
 Time remaining on the timer. More...
 
Threadm_pclOwner
 Pointer to the owner thread. More...
 
void * m_pvData
 Pointer to the callback data. More...
 

Static Private Attributes

static constexpr auto m_uTimerInvalidCookie = uint8_t { 0x3C }
 
static constexpr auto m_uTimerInitCookie = uint8_t { 0xC3 }
 

Friends

class TimerList
 

Additional Inherited Members

Detailed Description

The Timer Class. This class provides kernel-managed timers, used to provide high-precision delays. Functionality is useful to both user-code, and is used extensively within the kernel and its blocking objects to implement round-robin scheduling, thread sleep, and timeouts. Provides one-shot and periodic timers for use by application code. This object relies on a target-defined hardware timer implementation, which is multiplexed by the kernel's timer scheduler.

Examples:
lab6_timers/main.cpp.

Definition at line 68 of file timer.h.

Constructor & Destructor Documentation

◆ ~Timer()

Mark3::Timer::~Timer ( )
inline

Definition at line 72 of file timer.h.

◆ Timer()

Mark3::Timer::Timer ( )

Timer Default Constructor - Do nothing. Allow the init call to perform the necessary object initialization prior to use.

Definition at line 29 of file timer.cpp.

Member Function Documentation

◆ Init()

void Mark3::Timer::Init ( void  )

Init Re-initialize the Timer to default values.

Definition at line 36 of file timer.cpp.

◆ IsInitialized()

bool Mark3::Timer::IsInitialized ( void  )
inlineprivate

IsInitialized.

Returns
true if initialized, false if not initialized.

Definition at line 127 of file timer.h.

◆ MSecondsToTicks()

static uint32_t Mark3::Timer::MSecondsToTicks ( uint32_t  x)
inlinestaticprivate

Definition at line 130 of file timer.h.

◆ operator new()

void* Mark3::Timer::operator new ( size_t  sz,
void *  pv 
)
inline

Definition at line 71 of file timer.h.

◆ SecondsToTicks()

static uint32_t Mark3::Timer::SecondsToTicks ( uint32_t  x)
inlinestaticprivate

Definition at line 129 of file timer.h.

◆ SetInitialized()

void Mark3::Timer::SetInitialized ( void  )
inlineprivate

SetInitialized.

Definition at line 121 of file timer.h.

◆ Start() [1/2]

void Mark3::Timer::Start ( bool  bRepeat_,
uint32_t  u32IntervalMs_,
TimerCallback  pfCallback_,
void *  pvData_ 
)

Start Start a timer using default ownership, using repeats as an option, and millisecond resolution.

Parameters
bRepeat_0 - timer is one-shot. 1 - timer is repeating.
u32IntervalMs_- Interval of the timer in miliseconds
pfCallback_- Function to call on timer expiry
pvData_- Data to pass into the callback function
Examples:
lab6_timers/main.cpp.

Definition at line 51 of file timer.cpp.

◆ Start() [2/2]

void Mark3::Timer::Start ( void  )

Start Start or restart a timer using parameters previously configured via calls to Start(<with args>), or via the a-la-carte parameter setter methods. This is especially useful for retriggering one-shot timers that have previously expired, using the timer's previous configuration.

Definition at line 73 of file timer.cpp.

◆ Stop()

void Mark3::Timer::Stop ( void  )

Stop Stop a timer already in progress. Has no effect on timers that have already been stopped.

Definition at line 86 of file timer.cpp.

◆ USecondsToTicks()

static uint32_t Mark3::Timer::USecondsToTicks ( uint32_t  x)
inlinestaticprivate

Definition at line 131 of file timer.h.

Friends And Related Function Documentation

◆ TimerList

friend class TimerList
friend

Definition at line 116 of file timer.h.

Member Data Documentation

◆ m_pclOwner

Thread* Mark3::Timer::m_pclOwner
private

Pointer to the owner thread.

Definition at line 152 of file timer.h.

◆ m_pfCallback

TimerCallback Mark3::Timer::m_pfCallback
private

Pointer to the callback function.

Definition at line 143 of file timer.h.

◆ m_pvData

void* Mark3::Timer::m_pvData
private

Pointer to the callback data.

Definition at line 155 of file timer.h.

◆ m_u32Interval

uint32_t Mark3::Timer::m_u32Interval
private

Interval of the timer in timer ticks.

Definition at line 146 of file timer.h.

◆ m_u32TimeLeft

uint32_t Mark3::Timer::m_u32TimeLeft
private

Time remaining on the timer.

Definition at line 149 of file timer.h.

◆ m_u8Flags

uint8_t Mark3::Timer::m_u8Flags
private

Flags for the timer, defining if the timer is one-shot or repeated.

Definition at line 140 of file timer.h.

◆ m_u8Initialized

uint8_t Mark3::Timer::m_u8Initialized
private

Cookie used to determine whether or not the timer is initialized.

Definition at line 137 of file timer.h.

◆ m_uTimerInitCookie

constexpr auto Mark3::Timer::m_uTimerInitCookie = uint8_t { 0xC3 }
staticprivate

Definition at line 134 of file timer.h.

◆ m_uTimerInvalidCookie

constexpr auto Mark3::Timer::m_uTimerInvalidCookie = uint8_t { 0x3C }
staticprivate

Definition at line 133 of file timer.h.


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