From d916cf5f6326c798e400a9fe0db6ad776f9a861f Mon Sep 17 00:00:00 2001 From: David Connelly Date: Mon, 4 Mar 2019 10:50:41 -0500 Subject: coreplexip-welcome example updated using freedom metal --- README.md | 4 +- software/coreplexip-welcome/Makefile | 4 + software/coreplexip-welcome/README.md | 2 + software/coreplexip-welcome/coreplexip-welcome.c | 156 +++++++++++++++++++++++ 4 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 software/coreplexip-welcome/Makefile create mode 100644 software/coreplexip-welcome/README.md create mode 100644 software/coreplexip-welcome/coreplexip-welcome.c diff --git a/README.md b/README.md index 2484c5f..0feac4f 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,9 @@ of Freedom E SDK. - Demonstrates how to register a handler for and trigger a local interrupt - example-pmp - Demonstrates how to configure a Physical Memory Protection (PMP) region - + - coreplexip-welcome + - Prints the SiFive banner and blinks LEDs + #### (Deprecated) Legacy Freedom E SDK Library #### As we transition to supporting SiFive targets and examples with the new Freedom Metal diff --git a/software/coreplexip-welcome/Makefile b/software/coreplexip-welcome/Makefile new file mode 100644 index 0000000..f9c9ead --- /dev/null +++ b/software/coreplexip-welcome/Makefile @@ -0,0 +1,4 @@ +coreplexip-welcome: coreplexip-welcome.c + +clean: + rm -f coreplexip-welcome coreplexip-welcome.hex diff --git a/software/coreplexip-welcome/README.md b/software/coreplexip-welcome/README.md new file mode 100644 index 0000000..5ea36ef --- /dev/null +++ b/software/coreplexip-welcome/README.md @@ -0,0 +1,2 @@ +# coreplexip-welcome +A simple "CoreplexIP Welcome" example which prints SiFive banner and uses board LEDs. diff --git a/software/coreplexip-welcome/coreplexip-welcome.c b/software/coreplexip-welcome/coreplexip-welcome.c new file mode 100644 index 0000000..a975b1c --- /dev/null +++ b/software/coreplexip-welcome/coreplexip-welcome.c @@ -0,0 +1,156 @@ + +#include +#include +#include +#include +#include + +#define RTC_FREQ 32768 + +struct metal_cpu *cpu0; +struct metal_interrupt *cpu_intr, *tmr_intr; +int tmr_id; +volatile uint32_t timer_isr_flag; + +void display_banner (void) { + + printf("\n"); + printf("\n"); + printf(" SIFIVE, INC.\n"); + printf("\n"); + printf(" 5555555555555555555555555\n"); + printf(" 5555 5555\n"); + printf(" 5555 5555\n"); + printf(" 5555 5555\n"); + printf(" 5555 5555555555555555555555\n"); + printf(" 5555 555555555555555555555555\n"); + printf(" 5555 5555\n"); + printf(" 5555 5555\n"); + printf(" 5555 5555\n"); + printf(" 5555555555555555555555555555 55555\n"); + printf(" 55555 555555555 55555\n"); + printf(" 55555 55555 55555\n"); + printf(" 55555 5 55555\n"); + printf(" 55555 55555\n"); + printf(" 55555 55555\n"); + printf(" 55555 55555\n"); + printf(" 55555 55555\n"); + printf(" 55555 55555\n"); + printf(" 555555555\n"); + printf(" 55555\n"); + printf(" 5\n"); + printf("\n"); + + printf("\n"); + printf("Welcome to the E31/E51 Coreplex IP FPGA Evaluation Kit!\n"); + +} + +void timer_isr (int id, void *data) { + + // Disable Timer interrupt + metal_interrupt_disable(tmr_intr, tmr_id); + + // Flag showing we hit timer isr + timer_isr_flag = 1; +} + +void wait_for_timer(struct metal_led *which_led) { + + // clear global timer isr flag + timer_isr_flag = 0; + + // Turn on desired LED + metal_led_on(which_led); + + // Set timer + metal_cpu_set_mtimecmp(cpu0, metal_cpu_get_mtime(cpu0) + RTC_FREQ); + + // Enable Timer interrupt + metal_interrupt_enable(tmr_intr, tmr_id); + + // wait till timer triggers and isr is hit + while (timer_isr_flag == 0){}; + + timer_isr_flag = 0; + + // All Off + metal_led_off(which_led); +} + +int main (void) +{ + int rc, up_cnt, dn_cnt; + struct metal_led *led0_red, *led0_green, *led0_blue; + + // This demo will toggle LEDs colors so we define them here + led0_red = metal_led_get_rgb("LD0", "red"); + led0_green = metal_led_get_rgb("LD0", "green"); + led0_blue = metal_led_get_rgb("LD0", "blue"); + if ((led0_red == NULL) || (led0_green == NULL) || (led0_blue == NULL)) { + printf("At least one of LEDs is null.\n"); + return 1; + } + + // Enable each LED + metal_led_enable(led0_red); + metal_led_enable(led0_green); + metal_led_enable(led0_blue); + + // All Off + metal_led_off(led0_red); + metal_led_off(led0_green); + metal_led_off(led0_blue); + + // Lets get the CPU and and its interrupt + cpu0 = metal_cpu_get(0); + if (cpu0 == NULL) { + printf("CPU null.\n"); + return 2; + } + cpu_intr = metal_cpu_interrupt_controller(cpu0); + if (cpu_intr == NULL) { + printf("CPU interrupt controller is null.\n"); + return 3; + } + metal_interrupt_init(cpu_intr); + + // display welcome banner + display_banner(); + + // Setup Timer and its interrupt so we can toggle LEDs on 1s cadence + tmr_intr = metal_cpu_timer_interrupt_controller(cpu0); + if (tmr_intr == NULL) { + printf("TIMER interrupt controller is null.\n"); + return 4; + } + metal_interrupt_init(tmr_intr); + tmr_id = metal_cpu_timer_get_interrupt_id(cpu0); + rc = metal_interrupt_register_handler(tmr_intr, tmr_id, timer_isr, cpu0); + if (rc < 0) { + printf("TIMER interrupt handler registration failed\n"); + return (rc * -1); + } + + // Lastly CPU interrupt + if (metal_interrupt_enable(cpu_intr, 0) == -1) { + printf("CPU interrupt enable failed\n"); + return 6; + } + + // Red -> Green -> Blue, repeat + while (1) { + + // Turn on RED + wait_for_timer(led0_red); + + // Turn on Green + wait_for_timer(led0_green); + + // Turn on Blue + wait_for_timer(led0_blue); + } + + // return + return 0; +} -- cgit v1.2.3 From 590f34d5399dcd497d6bc1fa4f3722fe1741a5fb Mon Sep 17 00:00:00 2001 From: David Connelly Date: Mon, 4 Mar 2019 11:04:34 -0500 Subject: fix spacing, remove tabs --- software/coreplexip-welcome/coreplexip-welcome.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/software/coreplexip-welcome/coreplexip-welcome.c b/software/coreplexip-welcome/coreplexip-welcome.c index a975b1c..de6f92d 100644 --- a/software/coreplexip-welcome/coreplexip-welcome.c +++ b/software/coreplexip-welcome/coreplexip-welcome.c @@ -48,7 +48,7 @@ void display_banner (void) { void timer_isr (int id, void *data) { - // Disable Timer interrupt + // Disable Timer interrupt metal_interrupt_disable(tmr_intr, tmr_id); // Flag showing we hit timer isr @@ -57,22 +57,22 @@ void timer_isr (int id, void *data) { void wait_for_timer(struct metal_led *which_led) { - // clear global timer isr flag + // clear global timer isr flag timer_isr_flag = 0; - // Turn on desired LED - metal_led_on(which_led); + // Turn on desired LED + metal_led_on(which_led); // Set timer metal_cpu_set_mtimecmp(cpu0, metal_cpu_get_mtime(cpu0) + RTC_FREQ); - // Enable Timer interrupt - metal_interrupt_enable(tmr_intr, tmr_id); + // Enable Timer interrupt + metal_interrupt_enable(tmr_intr, tmr_id); - // wait till timer triggers and isr is hit - while (timer_isr_flag == 0){}; + // wait till timer triggers and isr is hit + while (timer_isr_flag == 0){}; - timer_isr_flag = 0; + timer_isr_flag = 0; // All Off metal_led_off(which_led); -- cgit v1.2.3 From 40516386bd96b3341bccc666012b4a1007338acd Mon Sep 17 00:00:00 2001 From: David Connelly Date: Tue, 5 Mar 2019 09:51:46 -0500 Subject: changed demo name to coreip-welcome to match bsp convention (was coreplexip-welcome) --- README.md | 2 +- software/coreip-welcome/Makefile | 6 + software/coreip-welcome/README.md | 2 + software/coreip-welcome/coreip-welcome.c | 156 +++++++++++++++++++++++ software/coreplexip-welcome/Makefile | 4 - software/coreplexip-welcome/README.md | 2 - software/coreplexip-welcome/coreplexip-welcome.c | 156 ----------------------- 7 files changed, 165 insertions(+), 163 deletions(-) create mode 100644 software/coreip-welcome/Makefile create mode 100644 software/coreip-welcome/README.md create mode 100644 software/coreip-welcome/coreip-welcome.c delete mode 100644 software/coreplexip-welcome/Makefile delete mode 100644 software/coreplexip-welcome/README.md delete mode 100644 software/coreplexip-welcome/coreplexip-welcome.c diff --git a/README.md b/README.md index 0feac4f..d2496df 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ of Freedom E SDK. - Demonstrates how to register a handler for and trigger a local interrupt - example-pmp - Demonstrates how to configure a Physical Memory Protection (PMP) region - - coreplexip-welcome + - coreip-welcome - Prints the SiFive banner and blinks LEDs #### (Deprecated) Legacy Freedom E SDK Library #### diff --git a/software/coreip-welcome/Makefile b/software/coreip-welcome/Makefile new file mode 100644 index 0000000..3198603 --- /dev/null +++ b/software/coreip-welcome/Makefile @@ -0,0 +1,6 @@ + +coreip-welcome: coreip-welcome.c + +clean: + rm -f coreip-welcome coreip-welcome.hex + diff --git a/software/coreip-welcome/README.md b/software/coreip-welcome/README.md new file mode 100644 index 0000000..a9a513b --- /dev/null +++ b/software/coreip-welcome/README.md @@ -0,0 +1,2 @@ +# coreip-welcome +A simple "CoreIP Welcome" example which prints SiFive banner and uses board LEDs. diff --git a/software/coreip-welcome/coreip-welcome.c b/software/coreip-welcome/coreip-welcome.c new file mode 100644 index 0000000..7147d83 --- /dev/null +++ b/software/coreip-welcome/coreip-welcome.c @@ -0,0 +1,156 @@ + +#include +#include +#include +#include +#include + +#define RTC_FREQ 32768 + +struct metal_cpu *cpu0; +struct metal_interrupt *cpu_intr, *tmr_intr; +int tmr_id; +volatile uint32_t timer_isr_flag; + +void display_banner (void) { + + printf("\n"); + printf("\n"); + printf(" SIFIVE, INC.\n"); + printf("\n"); + printf(" 5555555555555555555555555\n"); + printf(" 5555 5555\n"); + printf(" 5555 5555\n"); + printf(" 5555 5555\n"); + printf(" 5555 5555555555555555555555\n"); + printf(" 5555 555555555555555555555555\n"); + printf(" 5555 5555\n"); + printf(" 5555 5555\n"); + printf(" 5555 5555\n"); + printf(" 5555555555555555555555555555 55555\n"); + printf(" 55555 555555555 55555\n"); + printf(" 55555 55555 55555\n"); + printf(" 55555 5 55555\n"); + printf(" 55555 55555\n"); + printf(" 55555 55555\n"); + printf(" 55555 55555\n"); + printf(" 55555 55555\n"); + printf(" 55555 55555\n"); + printf(" 555555555\n"); + printf(" 55555\n"); + printf(" 5\n"); + printf("\n"); + + printf("\n"); + printf("Welcome to the E31/E51 Core IP FPGA Evaluation Kit!\n"); + +} + +void timer_isr (int id, void *data) { + + // Disable Timer interrupt + metal_interrupt_disable(tmr_intr, tmr_id); + + // Flag showing we hit timer isr + timer_isr_flag = 1; +} + +void wait_for_timer(struct metal_led *which_led) { + + // clear global timer isr flag + timer_isr_flag = 0; + + // Turn on desired LED + metal_led_on(which_led); + + // Set timer + metal_cpu_set_mtimecmp(cpu0, metal_cpu_get_mtime(cpu0) + RTC_FREQ); + + // Enable Timer interrupt + metal_interrupt_enable(tmr_intr, tmr_id); + + // wait till timer triggers and isr is hit + while (timer_isr_flag == 0){}; + + timer_isr_flag = 0; + + // All Off + metal_led_off(which_led); +} + +int main (void) +{ + int rc, up_cnt, dn_cnt; + struct metal_led *led0_red, *led0_green, *led0_blue; + + // This demo will toggle LEDs colors so we define them here + led0_red = metal_led_get_rgb("LD0", "red"); + led0_green = metal_led_get_rgb("LD0", "green"); + led0_blue = metal_led_get_rgb("LD0", "blue"); + if ((led0_red == NULL) || (led0_green == NULL) || (led0_blue == NULL)) { + printf("At least one of LEDs is null.\n"); + return 1; + } + + // Enable each LED + metal_led_enable(led0_red); + metal_led_enable(led0_green); + metal_led_enable(led0_blue); + + // All Off + metal_led_off(led0_red); + metal_led_off(led0_green); + metal_led_off(led0_blue); + + // Lets get the CPU and and its interrupt + cpu0 = metal_cpu_get(0); + if (cpu0 == NULL) { + printf("CPU null.\n"); + return 2; + } + cpu_intr = metal_cpu_interrupt_controller(cpu0); + if (cpu_intr == NULL) { + printf("CPU interrupt controller is null.\n"); + return 3; + } + metal_interrupt_init(cpu_intr); + + // display welcome banner + display_banner(); + + // Setup Timer and its interrupt so we can toggle LEDs on 1s cadence + tmr_intr = metal_cpu_timer_interrupt_controller(cpu0); + if (tmr_intr == NULL) { + printf("TIMER interrupt controller is null.\n"); + return 4; + } + metal_interrupt_init(tmr_intr); + tmr_id = metal_cpu_timer_get_interrupt_id(cpu0); + rc = metal_interrupt_register_handler(tmr_intr, tmr_id, timer_isr, cpu0); + if (rc < 0) { + printf("TIMER interrupt handler registration failed\n"); + return (rc * -1); + } + + // Lastly CPU interrupt + if (metal_interrupt_enable(cpu_intr, 0) == -1) { + printf("CPU interrupt enable failed\n"); + return 6; + } + + // Red -> Green -> Blue, repeat + while (1) { + + // Turn on RED + wait_for_timer(led0_red); + + // Turn on Green + wait_for_timer(led0_green); + + // Turn on Blue + wait_for_timer(led0_blue); + } + + // return + return 0; +} diff --git a/software/coreplexip-welcome/Makefile b/software/coreplexip-welcome/Makefile deleted file mode 100644 index f9c9ead..0000000 --- a/software/coreplexip-welcome/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -coreplexip-welcome: coreplexip-welcome.c - -clean: - rm -f coreplexip-welcome coreplexip-welcome.hex diff --git a/software/coreplexip-welcome/README.md b/software/coreplexip-welcome/README.md deleted file mode 100644 index 5ea36ef..0000000 --- a/software/coreplexip-welcome/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# coreplexip-welcome -A simple "CoreplexIP Welcome" example which prints SiFive banner and uses board LEDs. diff --git a/software/coreplexip-welcome/coreplexip-welcome.c b/software/coreplexip-welcome/coreplexip-welcome.c deleted file mode 100644 index de6f92d..0000000 --- a/software/coreplexip-welcome/coreplexip-welcome.c +++ /dev/null @@ -1,156 +0,0 @@ - -#include -#include -#include -#include -#include - -#define RTC_FREQ 32768 - -struct metal_cpu *cpu0; -struct metal_interrupt *cpu_intr, *tmr_intr; -int tmr_id; -volatile uint32_t timer_isr_flag; - -void display_banner (void) { - - printf("\n"); - printf("\n"); - printf(" SIFIVE, INC.\n"); - printf("\n"); - printf(" 5555555555555555555555555\n"); - printf(" 5555 5555\n"); - printf(" 5555 5555\n"); - printf(" 5555 5555\n"); - printf(" 5555 5555555555555555555555\n"); - printf(" 5555 555555555555555555555555\n"); - printf(" 5555 5555\n"); - printf(" 5555 5555\n"); - printf(" 5555 5555\n"); - printf(" 5555555555555555555555555555 55555\n"); - printf(" 55555 555555555 55555\n"); - printf(" 55555 55555 55555\n"); - printf(" 55555 5 55555\n"); - printf(" 55555 55555\n"); - printf(" 55555 55555\n"); - printf(" 55555 55555\n"); - printf(" 55555 55555\n"); - printf(" 55555 55555\n"); - printf(" 555555555\n"); - printf(" 55555\n"); - printf(" 5\n"); - printf("\n"); - - printf("\n"); - printf("Welcome to the E31/E51 Coreplex IP FPGA Evaluation Kit!\n"); - -} - -void timer_isr (int id, void *data) { - - // Disable Timer interrupt - metal_interrupt_disable(tmr_intr, tmr_id); - - // Flag showing we hit timer isr - timer_isr_flag = 1; -} - -void wait_for_timer(struct metal_led *which_led) { - - // clear global timer isr flag - timer_isr_flag = 0; - - // Turn on desired LED - metal_led_on(which_led); - - // Set timer - metal_cpu_set_mtimecmp(cpu0, metal_cpu_get_mtime(cpu0) + RTC_FREQ); - - // Enable Timer interrupt - metal_interrupt_enable(tmr_intr, tmr_id); - - // wait till timer triggers and isr is hit - while (timer_isr_flag == 0){}; - - timer_isr_flag = 0; - - // All Off - metal_led_off(which_led); -} - -int main (void) -{ - int rc, up_cnt, dn_cnt; - struct metal_led *led0_red, *led0_green, *led0_blue; - - // This demo will toggle LEDs colors so we define them here - led0_red = metal_led_get_rgb("LD0", "red"); - led0_green = metal_led_get_rgb("LD0", "green"); - led0_blue = metal_led_get_rgb("LD0", "blue"); - if ((led0_red == NULL) || (led0_green == NULL) || (led0_blue == NULL)) { - printf("At least one of LEDs is null.\n"); - return 1; - } - - // Enable each LED - metal_led_enable(led0_red); - metal_led_enable(led0_green); - metal_led_enable(led0_blue); - - // All Off - metal_led_off(led0_red); - metal_led_off(led0_green); - metal_led_off(led0_blue); - - // Lets get the CPU and and its interrupt - cpu0 = metal_cpu_get(0); - if (cpu0 == NULL) { - printf("CPU null.\n"); - return 2; - } - cpu_intr = metal_cpu_interrupt_controller(cpu0); - if (cpu_intr == NULL) { - printf("CPU interrupt controller is null.\n"); - return 3; - } - metal_interrupt_init(cpu_intr); - - // display welcome banner - display_banner(); - - // Setup Timer and its interrupt so we can toggle LEDs on 1s cadence - tmr_intr = metal_cpu_timer_interrupt_controller(cpu0); - if (tmr_intr == NULL) { - printf("TIMER interrupt controller is null.\n"); - return 4; - } - metal_interrupt_init(tmr_intr); - tmr_id = metal_cpu_timer_get_interrupt_id(cpu0); - rc = metal_interrupt_register_handler(tmr_intr, tmr_id, timer_isr, cpu0); - if (rc < 0) { - printf("TIMER interrupt handler registration failed\n"); - return (rc * -1); - } - - // Lastly CPU interrupt - if (metal_interrupt_enable(cpu_intr, 0) == -1) { - printf("CPU interrupt enable failed\n"); - return 6; - } - - // Red -> Green -> Blue, repeat - while (1) { - - // Turn on RED - wait_for_timer(led0_red); - - // Turn on Green - wait_for_timer(led0_green); - - // Turn on Blue - wait_for_timer(led0_blue); - } - - // return - return 0; -} -- cgit v1.2.3 From 8e886ab52c3621cc25f158ca86b452356c22b9a2 Mon Sep 17 00:00:00 2001 From: David Connelly Date: Tue, 5 Mar 2019 14:55:06 -0500 Subject: submodule name change --- software/example-coreip-welcome | 1 + 1 file changed, 1 insertion(+) create mode 160000 software/example-coreip-welcome diff --git a/software/example-coreip-welcome b/software/example-coreip-welcome new file mode 160000 index 0000000..b8e2d46 --- /dev/null +++ b/software/example-coreip-welcome @@ -0,0 +1 @@ +Subproject commit b8e2d46f3d589dab7b4ba4c38b87d3dec02e3b81 -- cgit v1.2.3 From 0f5acb16b51fe3a2b2f93f096f2c928c2a0a0a40 Mon Sep 17 00:00:00 2001 From: David Connelly Date: Tue, 5 Mar 2019 15:08:12 -0500 Subject: Updated to submodule --- .gitmodules | 3 + README.md | 2 +- software/coreip-welcome/Makefile | 6 -- software/coreip-welcome/README.md | 2 - software/coreip-welcome/coreip-welcome.c | 156 ------------------------------- software/example-coreip-welcome | 2 +- 6 files changed, 5 insertions(+), 166 deletions(-) delete mode 100644 software/coreip-welcome/Makefile delete mode 100644 software/coreip-welcome/README.md delete mode 100644 software/coreip-welcome/coreip-welcome.c diff --git a/.gitmodules b/.gitmodules index 068c7a1..28db658 100644 --- a/.gitmodules +++ b/.gitmodules @@ -37,3 +37,6 @@ [submodule "software/empty"] path = software/empty url = https://github.com/sifive/example-empty.git +[submodule "software/example-coreip-welcome"] + path = software/example-coreip-welcome + url = https://github.com/sifive/example-coreip-welcome diff --git a/README.md b/README.md index d2496df..56d3ddd 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ of Freedom E SDK. - Demonstrates how to register a handler for and trigger a local interrupt - example-pmp - Demonstrates how to configure a Physical Memory Protection (PMP) region - - coreip-welcome + - example-coreip-welcome - Prints the SiFive banner and blinks LEDs #### (Deprecated) Legacy Freedom E SDK Library #### diff --git a/software/coreip-welcome/Makefile b/software/coreip-welcome/Makefile deleted file mode 100644 index 3198603..0000000 --- a/software/coreip-welcome/Makefile +++ /dev/null @@ -1,6 +0,0 @@ - -coreip-welcome: coreip-welcome.c - -clean: - rm -f coreip-welcome coreip-welcome.hex - diff --git a/software/coreip-welcome/README.md b/software/coreip-welcome/README.md deleted file mode 100644 index a9a513b..0000000 --- a/software/coreip-welcome/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# coreip-welcome -A simple "CoreIP Welcome" example which prints SiFive banner and uses board LEDs. diff --git a/software/coreip-welcome/coreip-welcome.c b/software/coreip-welcome/coreip-welcome.c deleted file mode 100644 index 7147d83..0000000 --- a/software/coreip-welcome/coreip-welcome.c +++ /dev/null @@ -1,156 +0,0 @@ - -#include -#include -#include -#include -#include - -#define RTC_FREQ 32768 - -struct metal_cpu *cpu0; -struct metal_interrupt *cpu_intr, *tmr_intr; -int tmr_id; -volatile uint32_t timer_isr_flag; - -void display_banner (void) { - - printf("\n"); - printf("\n"); - printf(" SIFIVE, INC.\n"); - printf("\n"); - printf(" 5555555555555555555555555\n"); - printf(" 5555 5555\n"); - printf(" 5555 5555\n"); - printf(" 5555 5555\n"); - printf(" 5555 5555555555555555555555\n"); - printf(" 5555 555555555555555555555555\n"); - printf(" 5555 5555\n"); - printf(" 5555 5555\n"); - printf(" 5555 5555\n"); - printf(" 5555555555555555555555555555 55555\n"); - printf(" 55555 555555555 55555\n"); - printf(" 55555 55555 55555\n"); - printf(" 55555 5 55555\n"); - printf(" 55555 55555\n"); - printf(" 55555 55555\n"); - printf(" 55555 55555\n"); - printf(" 55555 55555\n"); - printf(" 55555 55555\n"); - printf(" 555555555\n"); - printf(" 55555\n"); - printf(" 5\n"); - printf("\n"); - - printf("\n"); - printf("Welcome to the E31/E51 Core IP FPGA Evaluation Kit!\n"); - -} - -void timer_isr (int id, void *data) { - - // Disable Timer interrupt - metal_interrupt_disable(tmr_intr, tmr_id); - - // Flag showing we hit timer isr - timer_isr_flag = 1; -} - -void wait_for_timer(struct metal_led *which_led) { - - // clear global timer isr flag - timer_isr_flag = 0; - - // Turn on desired LED - metal_led_on(which_led); - - // Set timer - metal_cpu_set_mtimecmp(cpu0, metal_cpu_get_mtime(cpu0) + RTC_FREQ); - - // Enable Timer interrupt - metal_interrupt_enable(tmr_intr, tmr_id); - - // wait till timer triggers and isr is hit - while (timer_isr_flag == 0){}; - - timer_isr_flag = 0; - - // All Off - metal_led_off(which_led); -} - -int main (void) -{ - int rc, up_cnt, dn_cnt; - struct metal_led *led0_red, *led0_green, *led0_blue; - - // This demo will toggle LEDs colors so we define them here - led0_red = metal_led_get_rgb("LD0", "red"); - led0_green = metal_led_get_rgb("LD0", "green"); - led0_blue = metal_led_get_rgb("LD0", "blue"); - if ((led0_red == NULL) || (led0_green == NULL) || (led0_blue == NULL)) { - printf("At least one of LEDs is null.\n"); - return 1; - } - - // Enable each LED - metal_led_enable(led0_red); - metal_led_enable(led0_green); - metal_led_enable(led0_blue); - - // All Off - metal_led_off(led0_red); - metal_led_off(led0_green); - metal_led_off(led0_blue); - - // Lets get the CPU and and its interrupt - cpu0 = metal_cpu_get(0); - if (cpu0 == NULL) { - printf("CPU null.\n"); - return 2; - } - cpu_intr = metal_cpu_interrupt_controller(cpu0); - if (cpu_intr == NULL) { - printf("CPU interrupt controller is null.\n"); - return 3; - } - metal_interrupt_init(cpu_intr); - - // display welcome banner - display_banner(); - - // Setup Timer and its interrupt so we can toggle LEDs on 1s cadence - tmr_intr = metal_cpu_timer_interrupt_controller(cpu0); - if (tmr_intr == NULL) { - printf("TIMER interrupt controller is null.\n"); - return 4; - } - metal_interrupt_init(tmr_intr); - tmr_id = metal_cpu_timer_get_interrupt_id(cpu0); - rc = metal_interrupt_register_handler(tmr_intr, tmr_id, timer_isr, cpu0); - if (rc < 0) { - printf("TIMER interrupt handler registration failed\n"); - return (rc * -1); - } - - // Lastly CPU interrupt - if (metal_interrupt_enable(cpu_intr, 0) == -1) { - printf("CPU interrupt enable failed\n"); - return 6; - } - - // Red -> Green -> Blue, repeat - while (1) { - - // Turn on RED - wait_for_timer(led0_red); - - // Turn on Green - wait_for_timer(led0_green); - - // Turn on Blue - wait_for_timer(led0_blue); - } - - // return - return 0; -} diff --git a/software/example-coreip-welcome b/software/example-coreip-welcome index b8e2d46..11309c6 160000 --- a/software/example-coreip-welcome +++ b/software/example-coreip-welcome @@ -1 +1 @@ -Subproject commit b8e2d46f3d589dab7b4ba4c38b87d3dec02e3b81 +Subproject commit 11309c62af2e373b989968ad32e28c651a95f866 -- cgit v1.2.3 From 33787f7ab3e84e5d2bd7cbfbbec08b7638348e5c Mon Sep 17 00:00:00 2001 From: David Connelly Date: Wed, 6 Mar 2019 10:33:38 -0500 Subject: submodule updated and banner message updated --- software/example-coreip-welcome | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/example-coreip-welcome b/software/example-coreip-welcome index 11309c6..cbcea37 160000 --- a/software/example-coreip-welcome +++ b/software/example-coreip-welcome @@ -1 +1 @@ -Subproject commit 11309c62af2e373b989968ad32e28c651a95f866 +Subproject commit cbcea378fcb4ab2310bc1d283b79a1539e621093 -- cgit v1.2.3