Miosix  2.0alpha1
miosix::Timer Class Reference

#include <sync.h>

Public Member Functions

 Timer ()
 
void start ()
 
void stop ()
 
bool isRunning () const
 
int interval () const
 
void clear ()
 

Detailed Description

A timer that can be used to measure time intervals.
Its resolution equals the kernel tick.
Maximum interval is 2^31-1 ticks.

Constructor & Destructor Documentation

miosix::Timer::Timer ( )

Constructor. Timer is initialized in stopped status.

Member Function Documentation

void miosix::Timer::clear ( )

Clear the timer and set it to not running state.

int miosix::Timer::interval ( ) const

get the interval, in kernel ticks.

Returns
the number of tick between start and stop. Returns -1 if the timer was never started, if interval is called after start but before stop, or if it overflowed.

To read the vaue of a timer without stopping it, you can use its copy constructor to create another timer, and stop it while the first timer keeps running.

bool miosix::Timer::isRunning ( ) const
Returns
true if timer is running
void miosix::Timer::start ( )

Start the timer

void miosix::Timer::stop ( )

Stop the timer. After stop, Timer can be started and stopped again to count non-contiguous timer intervals.


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