예제 #1
0
/**
 * \brief callback for tmr interrupt
 */
void tc_callback(void)
{
    uint32_t ul_status;
    /* Read TC0 Status. */
    ul_status = tc_get_status(TIMER, TIMER_CHANNEL_ID);
    ul_status &= tc_get_interrupt_mask(TIMER, TIMER_CHANNEL_ID);
#if SAM4E
    if (TC_SR_CPAS == (ul_status & TC_SR_CPAS)) {
        tmr_cca_callback();
    }

    if (TC_SR_CPCS == (ul_status & TC_SR_CPCS)) {
        tmr_ovf_callback();
    }

#else
    if (TC_SR_CPCS == (ul_status & TC_SR_CPCS)) {
        tmr_cca_callback();
    }

    /* Overflow */
    if (TC_SR_COVFS == (ul_status & TC_SR_COVFS)) {
        tmr_ovf_callback();
    }
#endif
}
예제 #2
0
void TICKER_COUNTER_Handlr2(void)
{
    uint32_t status=tc_get_status(TICKER_COUNTER_lp, TICKER_COUNTER_CHANNEL2);
    uint32_t interrupmask=tc_get_interrupt_mask(TICKER_COUNTER_lp, TICKER_COUNTER_CHANNEL2);

    if (((status & interrupmask)  & TC_IER_CPCS)) {
        if(lp_ticker_interrupt_counter) {
            lp_ticker_interrupt_counter--;
        } else {
            if(lp_ticker_interrupt_offset) {
                tc_stop(TICKER_COUNTER_lp, TICKER_COUNTER_CHANNEL2);
                tc_write_rc(TICKER_COUNTER_lp, TICKER_COUNTER_CHANNEL2, (uint32_t)lp_ticker_interrupt_offset);
                tc_start(TICKER_COUNTER_lp, TICKER_COUNTER_CHANNEL2);
                lp_ticker_interrupt_offset=0;
            } else {
                lp_ticker_irq_handler();
            }
        }
    }
}