void mm_timer_schedule(int dummy) { struct mm_timer_tag *timer; for(;;) { ke_evt_clear(KE_EVT_MM_TIMER); // check the next timer timer = (struct mm_timer_tag *)co_list_pick(&mm_timer_env.prog); if (!timer) { // no more timers, disable HW irq and leave mm_timer_hw_set(NULL); break; } if (!hal_machw_time_past(timer->time - 50)) { // timer will expire in more than 32us, configure the HW mm_timer_hw_set(timer); // in most case, we will break here. However, if the timer expiration // time has just passed, may be the HW was set too late (due to an IRQ) // so we do not exit the loop to process it. if (!hal_machw_time_past(timer->time)) { break; } } // at this point, the next timer in the queue has expired or is about to -> pop it co_list_pop_front(&mm_timer_env.prog); // Sanity check ASSERT_ERR(timer->cb); // notify the caller - It has to be done after popping the timer from the queue // as the callback may set it again timer->cb(timer->env); } }
时间: 2023-04-11 13:00:27 浏览: 198
这是一个关于程序代码的问题,我可以回答。这段代码是一个定时器调度函数,它会循环遍历定时器列表,检查是否有定时器到期,如果有则触发相应的事件。其中,co_list_pick()函数用于从定时器列表中选择下一个定时器,ke_evt_clear()函数用于清除事件标志。
阅读全文