/************************************************************************ * NAME: fnet_cpu_timer_handler_top * * DESCRIPTION: Top interrupt handler. Increment fnet_current_time * and interrupt flag. *************************************************************************/ static void fnet_cpu_timer_handler_top( void ) { /* Clear timer event condition. */ FNET_MPC_PITRTI_TFLG(FNET_TIMER_NUMBER) = 0x1; /* Update RTC counter. */ fnet_timer_ticks_inc(); }
/************************************************************************ * DESCRIPTION: Top interrupt handler. Increment fnet_current_time * and interrupt flag. *************************************************************************/ static void fnet_cpu_timer_handler_top(fnet_uint32_t cookie ) { /* Clear the PIT timer flag. */ FNET_MK_PIT_TFLG(FNET_CFG_CPU_TIMER_NUMBER) |= FNET_MK_PIT_TFLG_TIF_MASK; /* Read the load value to restart the timer. */ (void)FNET_MK_PIT_LDVAL(FNET_CFG_CPU_TIMER_NUMBER); /* Update RTC counter. */ fnet_timer_ticks_inc(); }
static msg_t fnet_timer_thread(void *period_ms) { EventListener el0; chRegSetThreadName("FNET timer thread"); evtInit(&fnetEventTimer, MS2ST(period_ms) ); evtStart(&fnetEventTimer); chEvtRegisterMask(&fnetEventTimer.et_es, &el0, PERIODIC_TIMER_ID); chEvtAddEvents(PERIODIC_TIMER_ID); while (TRUE) { eventmask_t mask = chEvtWaitAny(ALL_EVENTS ); if (mask & PERIODIC_TIMER_ID) { fnet_timer_ticks_inc(); fnet_timer_handler_bottom(NULL ); } } return RDY_OK; }