Ejemplo n.º 1
0
/**
 * @brief This function is generic interrupt handler
 *
 * @param[in] p_reg    pointer to timer registers
 * @param[in] timer_id specifies the timer id
 *
 * @return    NRF_SUCCESS on success, otherwise an error code.
 */
static void nrf_drv_timer_interrupt_handle(NRF_TIMER_Type * p_reg, uint32_t timer_id)
{
    uint32_t i;

    for(i=0; i<TIMER_CHANNEL_NUMBER; i++)
    {
        nrf_timer_events_t event = (nrf_timer_events_t)((uint32_t)NRF_TIMER_EVENTS_COMPARE0 + (i*sizeof(uint32_t)));

        if (nrf_timer_event_check(p_reg, event) && nrf_timer_int_enable_check(p_reg, (nrf_timer_int_mask_t)((uint32_t)NRF_TIMER_INT_COMPARE0_MASK << i)))
        {
            nrf_timer_event_clear(p_reg, event);
            (m_timer_event_handlers[timer_id])(event);
        }
    }
}
Ejemplo n.º 2
0
static void irq_handler(NRF_TIMER_Type * p_reg,
                        timer_control_block_t * p_cb,
                        uint8_t channel_count)
{
    uint8_t i;
    for (i = 0; i < channel_count; ++i)
    {
        nrf_timer_event_t event = nrf_timer_compare_event_get(i);
        nrf_timer_int_mask_t int_mask = nrf_timer_compare_int_get(i);

        if (nrf_timer_event_check(p_reg, event) &&
            nrf_timer_int_enable_check(p_reg, int_mask))
        {
            nrf_timer_event_clear(p_reg, event);
            p_cb->handler(event, p_cb->context);
        }
    }
}