GPIO Programming:
Now with Interrupts!
Computing Machinery II Tutorial:
Week of March 25th
"sysreg.h" for enableIRQ();
"irq.h" for IRQ_ENABLE_IRQS_2
*GPREN0 = (0x1 << 17);
*IRQ_ENABLE_IRQS_2 = (0x1 << 20);
sharedValue++
int light_next(current LED) {
busy_loop();
clear_GPIO(current LED);
set_GPIO(previous LED);
return next LED
}....
if (*IQR_PENDING_2 == 0x00100000) {
if (interrupt pin is 23) {current_state set to 2}
else if (interrupt pin is 24) {current_state set to 1}
write GPEDS0 value back to itself to indicate the interrupt has been serviced
}
....while (true) {
if (current state is 1) {
current LED = light_next(state parameters, current LED)
}
else if (current state is 2) {
current LED = light_next(state parameters, current LED)
}
}