Interface: tos.interfaces.Timer

interface Timer

This interface provides a generic timer that can be used to generate events at regular intervals.

Author:
Su Ping
Sam Madden
David Gay
Modified:
7/16/02

Commands
command result_t start(char type, uint32_t interval) Start the timer.
command result_t stop() Stop the timer, preventing it from firing again.

Events
event result_t fired() The signal generated by the timer when it fires.

Commands - Details

start

command result_t start(char type, uint32_t interval)

Start the timer.

Parameters:
type - The type of timer to start. Valid values include 'TIMER_REPEAT' for a timer that fires repeatedly, or 'TIMER_ONE_SHOT' for a timer that fires once.
interval - The timer interval in binary milliseconds (1/1024 second). Note that the timer cannot support an arbitrary range of intervals. (Unfortunately this interface does not specify the valid range of timer intervals, which are specific to a platform.)
Returns:
Returns SUCCESS if the timer could be started with the given type and interval. Returns FAIL if the type is not one of TIMER_REPEAT or TIMER_ONE_SHOT, if the timer rate is too high, or if there are too many timers currently active.

stop

command result_t stop()

Stop the timer, preventing it from firing again. If this is a TIMER_ONE_SHOT timer and it has not fired yet, prevents it from firing.

Returns:
SUCCESS if the timer could be stopped, or FAIL if the timer is not running or the timer ID is out of range.

Events - Details

fired

event result_t fired()

The signal generated by the timer when it fires.