summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--software/first/first.c1
-rw-r--r--software/first/setup_timer_irq.S11
-rw-r--r--software/first/super_blink.h1
3 files changed, 13 insertions, 0 deletions
diff --git a/software/first/first.c b/software/first/first.c
index 889e05b..e04d501 100644
--- a/software/first/first.c
+++ b/software/first/first.c
@@ -16,5 +16,6 @@ int main() {
// for the first interrupt. In the interrupt
// routine, we set the next delay so all we need
// to do here is to loop endlessly
+ wait_for_irq();
}
}
diff --git a/software/first/setup_timer_irq.S b/software/first/setup_timer_irq.S
index c3e7513..bba356d 100644
--- a/software/first/setup_timer_irq.S
+++ b/software/first/setup_timer_irq.S
@@ -1,6 +1,7 @@
.section .text
.align 2
.global setup_timer_irq
+.global wait_for_irq
.include "gpio.inc"
.include "memory_map.inc"
@@ -97,3 +98,13 @@ exit:
lw a0, 4(sp) # restore first argument to function
addi sp, sp, 28 # deallocate stack frame
mret # exit IRQ handler
+
+
+wait_for_irq:
+ csrr t0, mip
+ csrr t1, mcause
+ csrr t2, mtvec
+ csrr t3, mstatus
+ csrr t4, mie
+ wfi
+ ret
diff --git a/software/first/super_blink.h b/software/first/super_blink.h
index b53d55d..b1ddf8e 100644
--- a/software/first/super_blink.h
+++ b/software/first/super_blink.h
@@ -10,4 +10,5 @@
void setup_GPIO();
int set_LED(int color, int state);
void setup_timer_irq();
+void wait_for_irq();
void delay(int milliseconds);