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.
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); }