/* This routine configures device-specific details about interrupts */ void enableBalloonIRQ( int interval_cycles, ptr_to_function newISR ) { registerISR( IRQ_COUNTER, newISR ); /* specify which ISR to call with COUNTER interrupts */ *pCOUNTER = -interval_cycles; /* initial counter value */ *pCOUNTER_RELOAD = -interval_cycles; /* on overflow, start with this value */ *pCOUNTER_STATUS = 1; /* Device: send interrupts, clear existing interrupt */ enableInterrupt( IRQ_COUNTER ); /* CPU: allow it to receive COUNTER interrupts */ }
void enableKeyIRQ( int keys_to_watch, ptr_to_function newISR ) { registerISR( IRQ_KEY, newISR ); /* specify which ISR to call with KEY interrupts */ *pKEY_IRQENABLE = keys_to_watch; /* Device: to send interrupts for KEY3,KEY2 */ enableInterrupt( IRQ_KEY ); /* CPU: allow it to receive KEY interrupts */ }
void initTimer(void) { registerISR(8, timerISR); /* register ISR i vector table */ setClock(50,40); /* set clock to 200ms */ startClock(); /* start clock */ }