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;
while (true)
{
myTimer.set(MY_PERIOD);
...
myTimer.sleep();
}
myTimer.set(MY_TIMEOUT);
bool done = false;
do
{
...
} while (!done && !myTimer.expired());
unsiged int remaining;
myTimer.set(MAX_TIME);
...
myTimer.expired(&remaining);
myTimer.cancel();
printf("There were %1d ticks left (%1d elapsed)\r\n",
remaining, MAX_TIME-remaining);
}