/* * Play with interrupts */ #include #include #include #include #include #include /* * Direct trap on coldfire */ extern void myirc(int irq, void *dev_id, struct pt_regs *regs); void myirq_wrapper( void) { __asm__(" .global myirc myirc: rte sub.l #20, %sp movem.l %d0-%d2/%a0-%a1, %sp@ /* Save registers */ /* switch led state */ move.l #(0x80000000+0x4),%a0 move.l %a0@,%d0 eor.l #0x0800,%d0 move.l %d0,%a0@ /* clear interrupts for GPIO7 */ move.l #(0x80000000+0xc0),%a0 move.l #0x080,%a0@ movem.l %sp@, %d0-%d2/%a0-%a1 /* Restore registers */ add.l #20, %sp rte "); } /* * Set up trap on irq 7 ( the button on the board ) */ int main() { int i; unsigned long j, k; j = 1<<11 ; k = *((volatile unsigned long *)(MCF_MBAR2 + MCFSIM2_GPIOFUNC)); printf(" func = %x",k); *((volatile unsigned long *)(MCF_MBAR2 + MCFSIM2_GPIOFUNC)) = k|j; k = *((volatile unsigned long *)(MCF_MBAR2 + MCFSIM2_GPIOFUNC)); printf(" func = %x\n",k); k = *((volatile unsigned long *)(MCF_MBAR2 + MCFSIM2_GPIOENABLE)); printf(" enable = %x",k); *((volatile unsigned long *)(MCF_MBAR2 + MCFSIM2_GPIOENABLE)) = k|j; k = *((volatile unsigned long *)(MCF_MBAR2 + MCFSIM2_GPIOENABLE)); printf(" enable = %x\n",k); k = *((volatile unsigned long *)(MCF_MBAR2 + MCFSIM2_GPIOINTSTAT )); printf("\n gpio interupt status = %x",k); k = *((volatile unsigned long *)(MCF_MBAR2 + MCFSIM2_GPIOINTENABLE )); printf("\n gpio interupt enable = %x\n",k); /* Save interrupt handler in k */ k = *((unsigned long *) (4*0xa7)); /* reconfigure interrupt */ *((unsigned long *) (4*0xa7)) = (unsigned long) myirc; sleep( 120 ); /* restore interrupt handler */ *((unsigned long *) (4*0xa7)) = k; return 0; }