示例#1
0
/**@brief Function for handling changes to the timer list.
 */
static void timer_list_handler(void)
{
    timer_node_t * p_restart_list_head = NULL;

    uint32_t       ticks_elapsed;
    uint32_t       ticks_previous;
    bool           ticks_have_elapsed;
    bool           compare_update;
    timer_node_t * p_timer_id_head_old;

#if APP_TIMER_WITH_PROFILER
    {
        uint8_t size = m_op_queue.size;
        uint8_t first = m_op_queue.first;
        uint8_t last = m_op_queue.last;
        uint8_t utilization = (first <= last) ? (last - first) : (size + 1 - first + last);

        if (utilization > m_max_user_op_queue_utilization)
        {
            m_max_user_op_queue_utilization = utilization;
        }
    }
#endif

    // Back up the previous known tick and previous list head
    ticks_previous    = m_ticks_latest;
    p_timer_id_head_old = mp_timer_id_head;

    // Get number of elapsed ticks
    ticks_have_elapsed = elapsed_ticks_acquire(&ticks_elapsed);

    // Handle list deletions
    compare_update = list_deletions_handler();

    // Handle expired timers
    if (ticks_have_elapsed)
    {
        expired_timers_handler(ticks_elapsed, ticks_previous, &p_restart_list_head);
        compare_update = true;
    }

    // Handle list insertions
    if (list_insertions_handler(p_restart_list_head))
    {
        compare_update = true;
    }

    // Update compare register if necessary
    if (compare_update)
    {
        compare_reg_update(p_timer_id_head_old);
    }
    m_rtc1_reset = false;
}
示例#2
0
/**@brief Function for handling changes to the timer list.
 */
static void timer_list_handler(void)
{
    timer_node_t * p_restart_list_head = NULL;

    uint32_t       ticks_elapsed;
    uint32_t       ticks_previous;
    bool           ticks_have_elapsed;
    bool           compare_update;
    timer_node_t * p_timer_id_head_old;
    
    // Back up the previous known tick and previous list head
    ticks_previous    = m_ticks_latest;
    p_timer_id_head_old = mp_timer_id_head;
    
    // Get number of elapsed ticks
    ticks_have_elapsed = elapsed_ticks_acquire(&ticks_elapsed);

    // Handle list deletions
    compare_update = list_deletions_handler();
    
    // Handle expired timers
    if (ticks_have_elapsed)
    {
        expired_timers_handler(ticks_elapsed, ticks_previous, &p_restart_list_head);
        compare_update = true;
    }
    
    // Handle list insertions
    if (list_insertions_handler(p_restart_list_head))
    {
        compare_update = true;
    }

    // Update compare register if necessary
    if (compare_update)
    {
        compare_reg_update(p_timer_id_head_old);
    }
    m_rtc1_reset = false;
}