// ********************************************************************** // ********************************************************************** // simulate asynchronous interrupts by polling events during idle loop // void pollInterrupts(void) { // check for task monopoly pollClock = clock(); assert("Timeout" && ((pollClock - lastPollClock) < MAX_CYCLES)); lastPollClock = pollClock; // check for keyboard interrupt if ((inChar = GET_CHAR) > 0) { keyboard_isr(); } // timer interrupt timer_isr(); return; } // end pollInterrupts
uint32_t us_ticker_read() { if (!us_ticker_inited) us_ticker_init(); uint32_t retval; __disable_irq(); retval = (timer_ldval - PIT_TIMER.CVAL) / clk_mhz; //Hardware bits retval |= msb_counter << __CLZ(clk_mhz); //Software bits if (PIT_TIMER.TFLG == 1) { //If overflow bit is set, force it to be handled timer_isr(); //Handle IRQ, read again to make sure software/hardware bits are synced NVIC_ClearPendingIRQ(PIT_TIMER_IRQ); return us_ticker_read(); } __enable_irq(); return retval; }
// ********************************************************************** // ********************************************************************** // simulate asynchronous interrupts by polling events during idle loop // static void pollInterrupts(void) { // check for task monopoly pollClock = clock(); assert("Timeout" && ((pollClock - lastPollClock) < MAX_CYCLES)); lastPollClock = pollClock; // check for keyboard interrupt int inCharInt = 0; if ((inCharInt = GET_CHAR) > 0) { if(inCharInt == 224){ arrowKey = TRUE; inChar = GET_CHAR; } else inChar = (char)inCharInt; keyboard_isr(); } // timer interrupt timer_isr(); return; } // end pollInterrupts
void low_priority_isr(void) { adc_isr(); timer_isr(); }
void interrupts(void) { if (is_timer_isr()) timer_isr(); if (is_adc_isr()) adc_isr(); if (is_usart_isr()) usart_isr(); }