MityDSP Documentation Index
tcDspTimer

Introduction

The tcDspTimer class may be used to implement any number of simple timers. methods are provided to set, clear, and check the status of a timer. The sleep function is also provided to put the calling thread to sleep until the timer expires.

Timers are created in a disabled state, after construction the "set" method must be called on a timer to use it.

See also:
MityDSP::tcDspTimer Class Reference

Example

This is a simple example of tcDspTimer creation and usage:

{
tcDspTimer myTimer;
// some periodic operation
while (true)
{
myTimer.set(MY_PERIOD);
// perform periodic operation
...
myTimer.sleep();
}
// retry something
myTimer.set(MY_TIMEOUT);
bool done = false;
do
{
// check if it's done
...
} while (!done && !myTimer.expired());
// see how long "it" takes
unsiged int remaining;
myTimer.set(MAX_TIME);
// do "it"
...
myTimer.expired(&remaining);
myTimer.cancel();
printf("There were %1d ticks left (%1d elapsed)\r\n",
remaining, MAX_TIME-remaining);
}

  
Generated on Mon Apr 22 2013 11:33:02 for MityDSP Core by  Doxygen Version 1.8.1.1
Copyright © 2009, Critical Link LLC, All rights reserved.