Finally worked out how to use the GPIO interrupts on the AT91SAM7X, which is the brain of the makecontroller. A couple of “gotchas” along the way, especially for a newby to these beasts like me, which as usual, after I’ve finally worked it out I look back see how simple it was lol.
The three main “gotchas” were:
- The ISR needs to be in its own .c file and the filename appended to the ARM_SRC section in the makefile. Reason: All IRQ need to be compiled in ARM mode
- In the ISR I needed to Read the Interrupt Status register, PIOB_ISR, I was not dodin gthis and so it would process the IRQ once and never again. By reading the ISR it clears it and allows interrupts on the PIO to re-occur.
- The very last thing in the ISR is to renable the AIC so that interrupts will be processed upon exit
Here is the code: