Using on-board timers

The ADI service supports one on-board timer per context on a board. This on-board timer has 10 ms resolution. The timer generates periodic events. You specify both the period and number of events when invoking adiStartTimer.

Starting the timer

To start the timer, call adiStartTimer and pass a context, a timeout value, and an event count value. A DONE event is generated when the timer expires.

If the count value is greater than one, a tick event is generated for each expiration of the timeout with a DONE event for the final expiration.

The timer can be reset or restarted with an additional call to adiStartTimer. When restarted, previous timer definitions are discarded and the timer begins with the new parameters.

Note: Unlike most Natural Access asynchronous functions, the timer is not automatically stopped when a call is released.

Start timer events

The following table lists the start timer events:

Event

Description

ADIEVN_TIMER_DONE

Once the timer has completed (expired), the ADI service generates a DONE event with the value field set to CTA_REASON_FINISHED. A DONE event is received with an error in the value field only if the board has an error. If the timer is stopped by calling adiStopTimer, the value field is CTA_REASON_STOPPED.

ADIEVN_TIMER_TICK

If count is greater than 1, the ADI service generates a tick event for the first count-1 expirations.

Stopping the timer

adiStopTimer stops the timer started with adiStartTimer. Once the timer has stopped, a DONE event is generated.

Stop timer event

The following table lists the stop timer event:

Event

Description

ADIEVN_TIMER_DONE

When the timer is stopped, a DONE event is generated with the value field set to CTA_REASON_STOPPED.