summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew Barbier <dbarbi1@gmail.com>2018-07-02 22:48:21 -0500
committerDrew Barbier <dbarbi1@gmail.com>2018-07-02 22:48:21 -0500
commit9d58b2120c5a9b9dbc95c0ea90b16280e36dc9ca (patch)
treec63c3acf5d7cad4b0b2b79b9c80f8282f03c0acf
parent835b33318a3b350051ef153d382a5980efe19ed6 (diff)
short msi handler
-rw-r--r--bsp/env/coreip-e2-arty/platform.h2
-rw-r--r--software/clic_vectored/clic_vectored.c26
2 files changed, 24 insertions, 4 deletions
diff --git a/bsp/env/coreip-e2-arty/platform.h b/bsp/env/coreip-e2-arty/platform.h
index 6bf2121..305726d 100644
--- a/bsp/env/coreip-e2-arty/platform.h
+++ b/bsp/env/coreip-e2-arty/platform.h
@@ -32,7 +32,7 @@
// Memory map
#define CLINT_CTRL_ADDR _AC(0x02000000,UL)
-#define CLIC_HART0_ADDR _AC(0x02800000, UL)
+#define CLIC_HART0_ADDR _AC(0x02800000,UL)
#define GPIO_CTRL_ADDR _AC(0x20002000,UL)
#define PWM0_CTRL_ADDR _AC(0x20005000,UL)
#define RAM_MEM_ADDR _AC(0x80000000,UL)
diff --git a/software/clic_vectored/clic_vectored.c b/software/clic_vectored/clic_vectored.c
index a20b1f2..cbc104e 100644
--- a/software/clic_vectored/clic_vectored.c
+++ b/software/clic_vectored/clic_vectored.c
@@ -98,6 +98,21 @@ void button_2_setup(void) {
clic_enable_interrupt(&clic, (LOCALINTIDBASE + LOCAL_INT_BTN_2));
}
+/*Entry Point for Machine Software Interrupt Handler*/
+uint32_t COUNT;
+void msi_isr()__attribute((interrupt));
+void msi_isr() {
+ //clear the SW interrupt
+ CLINT_REG(CLINT_MSIP) = 0;
+ COUNT++;
+}
+
+void msi_setup(void) {
+ clic_install_handler(&clic, MSIPID, msi_isr);
+ clic_set_intcfg(&clic, MSIPID, 1<<4);
+ clic_enable_interrupt(&clic, MSIPID);
+}
+
void config_gpio() {
// Configure LEDs as outputs.
GPIO_REG(GPIO_INPUT_EN) &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;
@@ -127,13 +142,18 @@ int main(int argc, char **argv)
button_0_setup();
button_1_setup();
button_2_setup();
+ msi_setup();
// Enable all global interrupts
set_csr(mstatus, MSTATUS_MIE);
-
-
print_instructions();
- while(1);
+
+ while(1) {
+ wait_ms(10000);
+ printf("Count=%d\n", COUNT);
+ //Trigger a SW interrupt
+ CLINT_REG(CLINT_MSIP) = 1;
+ }
return 0;