最近刚接触安霸方案,很多不太明白
其中在SDK中发现两个这样的函数,不知道具体什么意思,没看明白,哪位群友指点一下app_timer_unregister(TIMER_2HZ,flash_led_timer_handler);
app_timer_register(TIMER_2HZ,flash_led_timer_handler); int app_timer_register(int tid, timer_handler hdlr)
{
int i = 0, found;
app_timer_t *cur;
DBGMSGc2(BLUE, " <app_timer_register> start: tid = %d / hdlr = 0x%X", tid, hdlr);
if (tid >= TIMER_NUM) {
// no such timer
DBGMSG(" No timer id %d", tid);
return -1;
}
if (hdlr == NULL) {
// NULL hdlr
DBGMSG(" Timer handler is NULL");
return -1;
}
cur = &(timers);
found = 0;
for (i=0; i<MAX_TIMER_HANDLER; i++) {
if (hdlr == cur->hdlr) {
// hdlr already exists
DBGMSG(" This timer handler has already been registered");
found = 1;
break;
}
}
if (!found) {
for (i=0; i<MAX_TIMER_HANDLER; i++) {
if (cur->hdlr == NULL) {
// Empty slot found. Insert hdlr
cur->hdlr = hdlr;
cur->hdlr_num++;
if (!cur->valid) {
DBGMSG(" Timer id %d is invalid. Create timer id %d", tid, tid);
timer_set_timer(tid);
}
break;
}
}
}
DBGMSGc2(BLUE, " <app_timer_register> end");
return 0;
} 你好
本公司长期备货安霸高清芯片
微信:szyushuokj
页:
[1]