; *********************************************************************** ; * * ; * Interrupt Handler for Push-button Program, First Version * ; * * ; *********************************************************************** ; Author: John Zaitseff ; Date: 28th May, 2003 ; Version: 1.2 ; This file contains the interrupt handler routine for the first version ; of the IRQ-enabled Push-button Program (pb-irq-v1.elf). The Interrupt ; exception vector at address 0x18 contains a branch to "irq_handler", ; found below. ; ----------------------------------------------------------------------- ; The following code will be placed into the ".ospage" section, NOT into ; the ".text" section. The GNU Linker will place the ".ospage" section at ; address 0x1000. .section .ospage, "awx" ; For "operating system" code .include "header-v3.s" ; Include definitions needed for this program ; ----------------------------------------------------------------------- ; Interrupt handler ; This interrupt handler (running in the Interrupt processor mode) checks ; the status of the push-button switches S2 and S3. These switches have ; been programmed (in the initialisation code in boot-pbirq-v1.s) to ; generate an interrupt every time they are pressed. If one of these ; switches caused the interrupt, the relevant LEDs are turned on and the ; other LEDs are turned off. .global irq_handler ; Make this label visible to other modules irq_handler: ; This code runs in Interrupt mode ; IRQ handler initialisation ldr r3, =iobase ; R3 = base of Microcontroller I/O space ldrb r0, [r3, #irq_status] ; Read the IRQ Status register into R0 ; Check for push-button switch S2 tst r0, #irq_pbs2 ; Check if push-button S2 generated the IRQ, ; ie, is currently being pressed movne r1, #left_leds ; If it is, prepare to turn on the left LEDs strneb r1, [r3, #portA] ; Now actually do so ; Check for push-button switch S3 tst r0, #irq_pbs3 ; Check if push-button S3 generated the IRQ movne r1, #right_leds ; If it did, prepare to turn on the right LEDs strneb r1, [r3, #portA] ; Now actually do so ; Acknowledge interrupts bic r1, r0, #(irq_pbs2 | irq_pbs3) ; Clear the IRQs for S2 and S3 strb r1, [r3, #irq_status] ; Acknowledge the interrupts subs pc, lr, #4 ; Return to whatever the processor was doing ; at the time of the interrupt .end