Apps     Components     Interfaces     All Files     Source Tree     source: tos.interfaces.Timer.nc

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

Components providing this interface:
apps.Blink.SingleTimer
apps.BlinkTask.SingleTimer
tos.system.LogicalTime
tos.system.SimpleTime
tos.system.TimerC
tos.system.TimerM

Components requiring this interface:
apps.Blink.BlinkM
apps.BlinkTask.BlinkTaskM
apps.Bombilla.AMPromiscuous
apps.Ident.IdentC
apps.MicaHWVerify.MicaHWVerifyM
apps.Oscilloscope.OscilloscopeM
apps.OscilloscopeRF.OscilloscopeM
apps.Sense.SenseM
apps.SenseLightToLog.SenseLightToLogM
apps.SenseTask.SenseTaskM
apps.Surge.SurgeM
apps.TASKApp.Field
apps.TestTinyAlloc.TestTinyAllocM
apps.TestTinyViz.TestTinyVizM
apps.TestUart.TestUartM
tos.lib.Attributes.AttrMicM
tos.lib.Commands.CommandResetM
tos.lib.Commands.CommandSounderM
tos.lib.Counters.Counter
tos.lib.Counters.SenseToInt
tos.lib.Route.MultiHopLEPSM
tos.lib.TinyDB.SimpleTimeM
tos.lib.TinySec.AMStandardTinySec
tos.lib.Util.DebugC
tos.lib.Util.NoDebug
tos.lib.VM.components.BVirus
tos.lib.VM.components.BombillaEngineM
tos.lib.VM.contexts.ClockContextM
tos.system.AMPromiscuous
tos.system.AMStandard
tos.system.SimpleTimeM

Commands

Events

Commands - Details

start

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

result_t stop(void)

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.