ZigBee Timer functions

The functions are listed below.

Function page

  1. ZTIMER_eInit

  2. ZTIMER_eOpen

  3. ZTIMER_eClose

  4. ZTIMER_eStart

  5. ZTIMER_eStop

  6. ZTIMER_eGetState

To use the software timers, the while loop of your application must include a call to the following function:

void ZTIMER\_vTask\(void\);
This allows the stack software to automatically update the ZTIMER\_tsTimer structure for each timer as the timer runs.

Parent topic:ZigBee Timer functions

ZTIMER_eInit

ZTIMER_teStatus ZTIMER_eInit(ZTIMER_tsTimer *psTimers,
                            uint8 u8NumTimers);

Description

This function initializes a set of software timers for use by the application. A list of timers is provided in an array, in which each array element is a structure containing information on one timer (see Section 10.2.2.1). The index of an array element is used as a reference for the corresponding timer.

In order to use one of the initialized timers, it must first be opened using ZTIMER_eOpen().

Parent topic:ZTIMER_eInit

Parameters

  • psTimers: Pointer to an array of structures, where each array element contains information for one timer (see Section 10.2.2.1)

  • u8NumTimers: Number of timers in the above array

Parent topic:ZTIMER_eInit

Returns

  • E_ZTIMER_OK (timers successfully initialized)

  • E_ZTIMER_FAIL (timers not initialized)

Parent topic:ZTIMER_eInit

Parent topic:ZigBee Timer functions

ZTIMER_eOpen

ZTIMER_teStatus ZTIMER_eOpen(
                    uint8 *pu8TimerIndex,
                    ZTIMER_tpfCallback pfCallback,
                    void *pvParams,
                    uint8 u8Flags);

Description

This function is used to open the specified software timer. A list of parameter values for the timer must be provided as well as a user-defined callback function that will be used to perform any operations required on expiration of the timer.

The callback function has the following prototype:

typedef void (*ZTIMER_tpfCallback)(void * pvParam );

where pvParam is a pointer to the timer parameters.

The function also includes a parameter u8Flags, which specifies whether the timer should allow or prevent sleep. When activity checks are made to decide whether the device can enter sleep mode, the value of this flag determines if the (running) timer will stop the device from going to sleep.

Before a timer is opened, it must have been initialized in a call to ZTIMER_eInit().

Parent topic:ZTIMER_eOpen

Parameters

  • pu8TimerIndex Pointer to location containing the index number of the timer in the list of timers initialized using ZTIMER_eInit()

  • pfCallback Pointer to the user-defined callback function for the timer

  • pvParams Pointer to a list of parameter values for the timer u8Flags Flag indicating whether the timer should allow or prevent sleep, one of:

    • ZTIMER_FLAG_ALLOW_SLEEP

    • ZTIMER_FLAG_PREVENT_SLEEP

Parent topic:ZTIMER_eOpen

Returns

  • E_ZTIMER_OK (timer successfully opened)

  • E_ZTIMER_FAIL (timer not opened)

Parent topic:ZTIMER_eOpen

Parent topic:ZigBee Timer functions

ZTIMER_eClose

ZTIMER_teStatus ZTIMER_eClose(uint8 u8TimerIndex);

Description

This function is used to close the specified software timer when it is no longer needed. The timer must have been previously opened using ZTIMER_eOpen().

Parent topic:ZTIMER_eClose

Parameters

u8TimerIndex: Index number of the timer in the list of timers initialized using ZTIMER_eInit().

Parent topic:ZTIMER_eClose

Returns

  • E_ZTIMER_OK (timer successfully closed)

  • E_ZTIMER_FAIL (timer not closed - may be running or already closed)

Parent topic:ZTIMER_eClose

Parent topic:ZigBee Timer functions

ZTIMER_eStart

ZTIMER_teStatus ZTIMER_eStart(uint8 u8TimerIndex,
                              uint32 u32Time);

Description

This function is used to start the specified software timer. The length of time for which the timer will run must be specified in milliseconds.

Before a timer is started, it must have been opened using ZTIMER_eOpen(). Once started, the timer can be stopped (before it expires) using ZTIMER_eStop().

Parent topic:ZTIMER_eStart

Parameters

  • pu8TimerIndex: Index number of the timer in the list of timers initialized using ZTIMER_eInit().

  • u32Time: The time, in milliseconds, for which the timer should run.

Parent topic:ZTIMER_eStart

Returns

  • E_ZTIMER_OK (timer successfully started)

  • E_ZTIMER_FAIL (timer not started)

Parent topic:ZTIMER_eStart

Parent topic:ZigBee Timer functions

ZTIMER_eStop

ZTIMER_teStatus ZTIMER_eStop(uint8 u8TimerIndex);

Description

This function is used to stop the specified software timer (before it expires). The timer must have been previously started using ZTIMER_eStart().

Parent topic:ZTIMER_eStop

Parameters

pu8TimerIndex: Index number of the timer in the list of timers initialized using ZTIMER_eInit().

Parent topic:ZTIMER_eStop

Returns

  • E_ZTIMER_OK (timer successfully stopped)

  • E_ZTIMER_FAIL (timer not stopped - may be already stopped or expired)

Parent topic:ZTIMER_eStop

Parent topic:ZigBee Timer functions

ZTIMER_eGetState

ZTIMER_teStatus ZTIMER_eGetState(uint8 u8TimerIndex);

Description

This function is used to obtain the current state of the specified software timer. The possible reported states are:

  • Running

  • Stopped

  • Expired

  • Closed

Parent topic:ZTIMER_eGetState

Parameters

pu8TimerIndex Index number of the timer in the list of timers initialized using ZTIMER_eInit().

Parent topic:ZTIMER_eGetState

Parent topic:ZigBee Timer functions

Parent topic:ZigBee Timer resources