I have asked the question about using the timer with GPIO trigger in the old forum, but never got a solution, so I have to ask it again.
How to use timer with GPIO trigger in ZigBee SDK?
In BLE SDK I was doing this like below:
Init timer for gpio trigger function
timer2_gpio_init(GPIO_HALL, POL_RISING);
timer2_set_mode(TIMER_MODE_GPIO_TRIGGER, 0, 2);
irq_enable();
timer_start(TIMER2);
And irq function
_attribute_ram_code_ void irq_handler(void) {
if((reg_tmr_sta & FLD_TMR_STA_TMR2) == FLD_TMR_STA_TMR2) {
reg_tmr_sta |= FLD_TMR_STA_TMR2;
++hall_count;
}
irq_blt_sdk_handler();
}
After looking in timer.c functions in ZigBee SDK, to init timer I have to do it like this:
Init timer:
timer_gpio_init(TIMER0, GPIO_HALL, POL_RISING); // POL_FALLING);
timer_set_init_tick(TIMER0, 0);
timer_set_cap_tick(TIMER0, 3);
timer_set_mode(TIMER0, TIMER_MODE_GPIO_TRIGGER);
timer_irq_enable(TIMER0);
// hwTimerSet(TIMER0, 3);
// hwTimerInit(TIMER0, TIMER_MODE_GPIO_TRIGGER);
timer_start(TIMER0);
But how do I use/set up interrupt for this timer?
ZigBee is using void irq_handler(void) function in irq_handler.c
In this function there is the following:
if((src & FLD_IRQ_TMR1_EN)){
reg_irq_src = FLD_IRQ_TMR1_EN;
reg_tmr_sta = FLD_TMR_STA_TMR1;
T_DBG_irqTest[3]++;
drv_timer_irq1_handler();
}
Which calls drv_timer_irq1_handler() in drv_timer.c
void drv_timer_irq1_handler(void)
{
drv_hwTmr_irq_process(TIMER_IDX_1);
}
How do I create a callback function for this interrupt process function?
Is my code for setup the timer correct?
By the way, what happened with all the posts in the old Telink Forum? There was a lot of valuable information there and I made a lot of posts. Everything is gone!
|