From ff3a78a64798c8cce7f2a10256a26a3e91c0351c Mon Sep 17 00:00:00 2001 From: Drew Barbier Date: Mon, 2 Jul 2018 15:23:10 -0500 Subject: add busy wait and extra buttons/irq --- software/clic_vectored/clic_vectored.c | 68 ++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 16 deletions(-) (limited to 'software') diff --git a/software/clic_vectored/clic_vectored.c b/software/clic_vectored/clic_vectored.c index db2435d..38a564e 100644 --- a/software/clic_vectored/clic_vectored.c +++ b/software/clic_vectored/clic_vectored.c @@ -1,5 +1,4 @@ // See LICENSE for license details. - #include #include #include "platform.h" @@ -8,6 +7,7 @@ #include #include "sifive/devices/clic.h" #include "clic/clic_driver.h" +#include "sifive/devices/clint.h" #ifndef _SIFIVE_COREPLEXIP_ARTY_H #error 'local_interrupts' demo only supported for Core IP Eval Kits @@ -27,31 +27,34 @@ clic_instance_t clic; const char * instructions_msg = " \ \n\ - SiFive, Inc\n\ - E21 Core IP Eval Kit 'clic_interrupts' demo.\n\ + SiFive, Inc\n\ + E21 Core IP Eval Kit 'clic_vectored' demo.\n\ + This demo uses buttons 0, 1, and 2 on the\n\ + Arty board to trigger vectored clic interrupts.\n\ \n\ -The Buttons 0-3 and Switch 3 are enabled as local\n\ -interrupts sources. A .5 s 'debounce' timer is used \n\ -between these interrupts. Software interrupts are\n\ -used to print a message while debouncing.\n\ -Note the priority of the interrupts sources.\n\ \n"; void print_instructions() { + write (STDERR_FILENO, instructions_msg, strlen(instructions_msg)); +} - //write (STDERR_FILENO, instructions_msg, strlen(instructions_msg)); - printf(instructions_msg); +//busy wait for the specified time +void wait_ms(uint64_t ms) { + static const uint64_t ms_tick = RTC_FREQ/1000; + volatile uint64_t * mtime = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIME); + uint64_t then = (ms_tick * ms) + *mtime; + while(*mtime