diff options
author | Silvan Jegen <s.jegen@gmail.com> | 2019-08-24 16:43:44 +0200 |
---|---|---|
committer | Silvan Jegen <s.jegen@gmail.com> | 2019-08-24 16:43:44 +0200 |
commit | 3c1be20f6c13ec70083dfad1dcb007f9c2ffef78 (patch) | |
tree | 35079f9b5a9c7d489f0a97f22a33c2cdf3e4364c /software/first | |
parent | 55d4dc6e990516e2a97539d8b4d4a7c10f51daeb (diff) |
setup_timer_irq: check that we handle the correct IRQ
Diffstat (limited to 'software/first')
-rw-r--r-- | software/first/setup_timer_irq.S | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/software/first/setup_timer_irq.S b/software/first/setup_timer_irq.S index 6c75d67..8ca0370 100644 --- a/software/first/setup_timer_irq.S +++ b/software/first/setup_timer_irq.S @@ -60,6 +60,11 @@ irq_handler: sw t3, 8(sp) # save temporary sw a0, 4(sp) # save first argument to function + li t0, 0x80000007 # irqcause + 7 (machine timer interrupt) + csrr t1, mcause # load cause CSR + and t1, t1, t0 # check if it's a timer interrupt + bne t1, t0, exit + li t0, GPIO_CTRL_ADDR # load base GPIO address lw t1, GPIO_OUTPUT_VAL(t0) # load state @@ -74,22 +79,23 @@ irq_handler: switchOnRed: li t2, GPIO_RED_LED # load value indicating red LED - j exit + j setAndexit switchOnBlue: li t2, GPIO_BLUE_LED # load value indicating blue LED - j exit + j setAndexit switchOnGreen: li t2, GPIO_GREEN_LED # load value indicating green LED - j exit + j setAndexit -exit: +setAndexit: sw t2, GPIO_OUTPUT_VAL(t0) # write new LED values to the right address li a0, 200 # load the desired delay value (in ms) as the first arg to the function jal delay # call delay function to set new delay +exit: lw ra, 24(sp) # load return address lw t0, 20(sp) # restore temporary lw t1, 16(sp) # restore temporary |