diff --git a/demo/Makefile b/demo/Makefile index c525d44..fbe946d 100644 --- a/demo/Makefile +++ b/demo/Makefile @@ -3,8 +3,7 @@ BUILD_DIR?=../build/ include $(BUILD_DIR)/software/include/generated/variables.mak include $(SOC_DIRECTORY)/software/common.mak -OBJECTS = donut.o helloc.o crt0.o main.o -OBJECTS += hellocpp.o leds.o audio.o +OBJECTS = crt0.o donut.o led.o main.o CFLAGS += -DWITH_CXX diff --git a/demo/audio.cpp b/demo/audio.cpp deleted file mode 100644 index 81eaabf..0000000 --- a/demo/audio.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -void audio(int v) { - audio_targ_write(v); -} \ No newline at end of file diff --git a/demo/helloc.cpp b/demo/helloc.cpp deleted file mode 100644 index 4591772..0000000 --- a/demo/helloc.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -void helloc(void) { - printf("C: Hello, world!\n"); -} \ No newline at end of file diff --git a/demo/hellocpp.cpp b/demo/hellocpp.cpp deleted file mode 100644 index 775f205..0000000 --- a/demo/hellocpp.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -void hellocpp(void) { - printf("C++: Hello, world!\n"); -} \ No newline at end of file diff --git a/demo/led.cpp b/demo/led.cpp new file mode 100644 index 0000000..172c4d6 --- /dev/null +++ b/demo/led.cpp @@ -0,0 +1,40 @@ +#include +#include + +void led(void) { + int i; + int j; + int k; + printf("Led demo...\n"); + + printf("Counter mode...\n"); + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + for (k = 0; k < 4; k++) { + leds_out_write(0x3F0000 * i + 0x003F00 * j + 0x00003F * k); + busy_wait(100); + } + } + } + + printf("Shift mode...\n"); + for (i = 0; i < 24; i++) { + leds_out_write(1 << i); + busy_wait(100); + } + for (i = 0; i < 24; i++) { + leds_out_write(1 << (23 - i)); + busy_wait(100); + } + + printf("Dance mode...\n"); + for (i = 0; i < 16; i++) { + leds_out_write(0x000055); + busy_wait(200); + leds_out_write(0xAAAA00); + busy_wait(200); + } + + printf("Clearing led...\n"); + leds_out_write(0); +} diff --git a/demo/leds.cpp b/demo/leds.cpp deleted file mode 100644 index 7a3d97d..0000000 --- a/demo/leds.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -void leds(int v) { - leds_out_write(v); -} \ No newline at end of file diff --git a/demo/main.cpp b/demo/main.cpp index 597b849..8b57b45 100644 --- a/demo/main.cpp +++ b/demo/main.cpp @@ -73,7 +73,7 @@ static void prompt(void) { /*-----------------------------------------------------------------------*/ /* Help */ /*-----------------------------------------------------------------------*/ -// void audio_targ_write(uint32_t v) + static void help(void) { puts("\nLiteX custom demo app built " __DATE__ " " __TIME__ @@ -85,13 +85,11 @@ static void help(void) { puts("led - Led demo"); #endif puts("donut - Spinning Donut demo"); - puts("helloc - Hello C"); - puts("hellocpp - Hello C++"); #ifdef CSR_LEDS_BASE puts("leds - Led set demo"); #endif #ifdef CSR_AUDIO_BASE - puts("audio - Sawtooth Audio demo"); + puts("saw - Sawtooth Audio demo"); #endif } @@ -104,61 +102,25 @@ static void reboot_cmd(void) { } #ifdef CSR_LEDS_BASE +void led(void); + static void led_cmd(void) { - int i; - int j; - int k; - printf("Led demo...\n"); - - printf("Counter mode...\n"); - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - for (k = 0; k < 4; k++) { - leds_out_write(0x3F0000 * i + 0x003F00 * j + 0x00003F * k); - busy_wait(100); - } - } - } - - printf("Shift mode...\n"); - for (i = 0; i < 24; i++) { - leds_out_write(1 << i); - busy_wait(100); - } - for (i = 0; i < 24; i++) { - leds_out_write(1 << (23 - i)); - busy_wait(100); - } - - printf("Dance mode...\n"); - for (i = 0; i < 16; i++) { - leds_out_write(0x000055); - busy_wait(200); - leds_out_write(0xAAAA00); - busy_wait(200); - } - - printf("Clearing led...\n"); - leds_out_write(0); + led(); } #endif #ifdef CSR_LEDS_BASE -void leds(int); - static void leds_cmd(char **val) { int value = (int)strtol(get_token(val), NULL, 0); printf("Setting LED to %6x\n", value); - leds(value); + leds_out_write(value); } #endif #ifdef CSR_AUDIO_BASE -void audio(int); - -static void audio_cmd(char **val) { +static void saw_cmd(char **val) { int value = (int)strtol(get_token(val), NULL, 0); printf("Setting Sawtooth to %dHz\n", value); - audio(value); + audio_targ_write(value); } #endif @@ -169,20 +131,6 @@ static void donut_cmd(void) { donut(); } -void helloc(void); - -static void helloc_cmd(void) { - printf("Hello C demo...\n"); - helloc(); -} - -void hellocpp(void); - -static void hellocpp_cmd(void) { - printf("Hello C++ demo...\n"); - hellocpp(); -} - /*-----------------------------------------------------------------------*/ /* Console service / Main */ /*-----------------------------------------------------------------------*/ @@ -205,17 +153,13 @@ static void console_service(void) { #endif else if (strcmp(token, "donut") == 0) donut_cmd(); - else if (strcmp(token, "helloc") == 0) - helloc_cmd(); - else if (strcmp(token, "hellocpp") == 0) - hellocpp_cmd(); #ifdef CSR_LEDS_BASE else if (strcmp(token, "leds") == 0) leds_cmd(&str); #endif #ifdef CSR_AUDIO_BASE - else if (strcmp(token, "audio") == 0) - audio_cmd(&str); + else if (strcmp(token, "saw") == 0) + saw_cmd(&str); #endif prompt(); }