nxp zigbee软件定时器使用方法

1. 初始化定时器:
ZTIMER_teStatus ZTIMER_eInit(ZTIMER_tsTimer *psTimers,uint8 u8NumTimers);
psTimers Pointer to an array of structures, where each array element contains information for
one timer
u8NumTimers Number of timers in the above array

–>eg: ZTIMER_eInit(asTimers, sizeof(asTimers) / sizeof(ZTIMER_tsTimer));
– PRIVATE ZTIMER_tsTimer asTimers[APP_ZTIMER_STORAGE +BDB_ZTIMER_STORAGE];

2. 打开定时器:
ZTIMER_teStatus ZTIMER_eOpen(
uint8 *pu8TimerIndex,
ZTIMER_tpfCallback pfCallback,
void *pvParams,
uint8 u8Flags);

pu8TimerIndex Pointer to location containing the index number of the timer in the list of timers
initialised 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

–>eg: ZTIMER_eOpen(&u8TimerButtonScan, APP_cbTimerButtonScan, NULL,
ZTIMER_FLAG_PREVENT_SLEEP);
– PUBLIC uint8 u8TimerButtonScan;
– PUBLIC void APP_cbTimerButtonScan(void *pvParam){};

–>eg: ZTIMER_eOpen(&u8TimerZCL, APP_cbTimerZclTick, NULL,
ZTIMER_FLAG_PREVENT_SLEEP);
– PUBLIC uint8 u8TimerZCL;
– PUBLIC void APP_cbTimerZclTick(void *pvParam){};

3.开始定时器:
//Before a timer is started, it must have been opened using ZTIMER_eOpen()
ZTIMER_teStatus ZTIMER_eStart(uint8 u8TimerIndex,uint32 u32Time);

pu8TimerIndex Index number of the timer in the list of timers initialised using ZTIMER_eInit()
u32Time The time, in milliseconds, for which the timer should run

–> eg: ZTIMER_eStart(u8TimerButtonScan, ZTIMER_TIME_MSEC(10));
#define ZTIMER_TIME_SEC(v) ((uint32)(v) * 1000UL)
#define ZTIMER_TIME_MSEC(v) ((uint32)(v) * 1UL)

4. 停止定时器:
//The timer must have been previously started using ZTIMER_eStart()
ZTIMER_teStatus ZTIMER_eStop(uint8 u8TimerIndex);
pu8TimerIndex Index number of the timer in the list of timers initialised using ZTIMER_eInit()

–>eg: ZTIMER_eStop(u8TimerButtonScan);

5.关定时器:
//The timer must have been previously opened using ZTIMER_eOpen()
ZTIMER_teStatus ZTIMER_eClose(uint8 u8TimerIndex);

–>eg: ZTIMER_eClose(u8TimerButtonScan);

6.获取定时器状态:
ZTIMER_teState ZTIMER_eGetState(uint8 u8TimerIndex);
The possible reported states are:
 Running Stopped Expired Closed

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值