summaryrefslogtreecommitdiff
path: root/bsp/env/coreplexip-e31-arty
diff options
context:
space:
mode:
authorDrew Barbier <dbarbi1@gmail.com>2017-07-25 16:58:47 -0500
committerDrew Barbier <dbarbi1@gmail.com>2017-07-25 16:58:47 -0500
commit64115be98dda5eae8840e373c85b0c615f196dbb (patch)
treee763daaad52014791d7ad624ced43703bb918707 /bsp/env/coreplexip-e31-arty
parent261668c5dc1ba680a55acc0ebcab2ef63110b880 (diff)
added vectored interrupt example
Diffstat (limited to 'bsp/env/coreplexip-e31-arty')
-rw-r--r--bsp/env/coreplexip-e31-arty/init.c13
-rw-r--r--bsp/env/coreplexip-e31-arty/platform.h5
2 files changed, 16 insertions, 2 deletions
diff --git a/bsp/env/coreplexip-e31-arty/init.c b/bsp/env/coreplexip-e31-arty/init.c
index 84ae09e..888f04f 100644
--- a/bsp/env/coreplexip-e31-arty/init.c
+++ b/bsp/env/coreplexip-e31-arty/init.c
@@ -10,8 +10,14 @@
#define XSTR(x) #x
#define STR(x) XSTR(x)
+#ifndef VECT_IRQ
+ #define TRAP_ENTRY trap_entry
+#else
+ #define TRAP_ENTRY vtrap_entry
+#endif
+
extern int main(int argc, char** argv);
-extern void trap_entry();
+extern void TRAP_ENTRY();
static unsigned long get_cpu_freq()
{
@@ -57,6 +63,7 @@ typedef void (*my_interrupt_function_ptr_t) (void);
extern my_interrupt_function_ptr_t localISR[];
#endif
+#ifndef VECT_IRQ
uintptr_t handle_trap(uintptr_t mcause, uintptr_t epc)
{
if (0){
@@ -81,6 +88,7 @@ uintptr_t handle_trap(uintptr_t mcause, uintptr_t epc)
}
return epc;
}
+#endif
void _init()
{
@@ -89,7 +97,8 @@ void _init()
puts("core freq at " STR(CPU_FREQ) " Hz\n");
- write_csr(mtvec, &trap_entry);
+ write_csr(mtvec, ((unsigned long)&TRAP_ENTRY | MTVEC_VECTORED));
+
#endif
}
diff --git a/bsp/env/coreplexip-e31-arty/platform.h b/bsp/env/coreplexip-e31-arty/platform.h
index 42c8887..307a0c6 100644
--- a/bsp/env/coreplexip-e31-arty/platform.h
+++ b/bsp/env/coreplexip-e31-arty/platform.h
@@ -13,6 +13,11 @@
#define MCAUSE_CAUSE 0x7FFFFFFFFFFFFFFFUL
#endif
+#ifdef VECT_IRQ
+ #define MTVEC_VECTORED 0x01
+#else
+ #define MTVEC_VECTORED 0x00
+#endif
#define IRQ_M_LOCAL 16
#define MIP_MLIP(x) (1 << (IRQ_M_LOCAL + x))