diff --git a/demo.sh b/demo.sh index 5166656..e95aab4 100755 --- a/demo.sh +++ b/demo.sh @@ -1,6 +1,6 @@ #!/bin/bash set -e -rm -f demo/*.o demo/*.d demo/demo.bin demo/demo.elf demo/demo.elf.map python3 demo/demo.py --build-path build/gsd_orangecrab/ --with-cxx +rm -f demo/*.o demo/*.d demo/demo.bin demo/demo.elf demo/demo.elf.map && echo "Cleaned up build artifacts" rm -f /mnt/c/Users/suple/Desktop/dfu-util-0.9-win64/gsd.bin && echo "Deleted old Win11 BIN" mv demo.bin /mnt/c/Users/suple/Desktop/dfu-util-0.9-win64/gsd.bin && echo "Moved new BIN to Win11 Desktop" diff --git a/demo/Makefile b/demo/Makefile index a30071a..1326373 100644 --- a/demo/Makefile +++ b/demo/Makefile @@ -5,7 +5,7 @@ include $(SOC_DIRECTORY)/software/common.mak OBJECTS = donut.o helloc.o crt0.o main.o ifdef WITH_CXX - OBJECTS += hellocpp.o + OBJECTS += hellocpp.o leds.o CFLAGS += -DWITH_CXX endif diff --git a/demo/leds.cpp b/demo/leds.cpp new file mode 100644 index 0000000..072ea2d --- /dev/null +++ b/demo/leds.cpp @@ -0,0 +1,7 @@ +#include +#include + +extern "C" void leds(int); +void leds(int v) { + leds_out_write(v); +} \ No newline at end of file diff --git a/demo/main.c b/demo/main.c index 38c451f..5e9f1fb 100644 --- a/demo/main.c +++ b/demo/main.c @@ -5,28 +5,27 @@ #include #include -#include -#include -#include #include +#include +#include +#include /*-----------------------------------------------------------------------*/ /* Uart */ /*-----------------------------------------------------------------------*/ -static char *readstr(void) -{ +static char *readstr(void) { char c[2]; static char s[64]; static int ptr = 0; - if(readchar_nonblock()) { + if (readchar_nonblock()) { c[0] = getchar(); c[1] = 0; - switch(c[0]) { + switch (c[0]) { case 0x7f: case 0x08: - if(ptr > 0) { + if (ptr > 0) { ptr--; fputs("\x08 \x08", stdout); } @@ -40,7 +39,7 @@ static char *readstr(void) ptr = 0; return s; default: - if(ptr >= (sizeof(s) - 1)) + if (ptr >= (sizeof(s) - 1)) break; fputs(c, stdout); s[ptr] = c[0]; @@ -52,34 +51,33 @@ static char *readstr(void) return NULL; } -static char *get_token(char **str) -{ +static char *get_token(char **str) { char *c, *d; c = (char *)strchr(*str, ' '); - if(c == NULL) { + if (c == NULL) { d = *str; - *str = *str+strlen(*str); + *str = *str + strlen(*str); return d; } *c = 0; d = *str; - *str = c+1; + *str = c + 1; return d; } -static void prompt(void) -{ - printf("\e[92;1mlitex-demo-app\e[0m> "); +static void prompt(void) { + printf("\e[92;1mStackSynth\e[0m> "); } /*-----------------------------------------------------------------------*/ /* Help */ /*-----------------------------------------------------------------------*/ -static void help(void) -{ - puts("\nLiteX minimal demo app built "__DATE__" "__TIME__"\n"); +static void help(void) { + puts("\nLiteX custom demo app built "__DATE__ + " "__TIME__ + "\n"); puts("Available commands:"); puts("help - Show this command"); puts("reboot - Reboot CPU"); @@ -90,6 +88,9 @@ static void help(void) puts("helloc - Hello C"); #ifdef WITH_CXX puts("hellocpp - Hello C++"); +#ifdef CSR_LEDS_BASE + puts("leds - Led set demo"); +#endif #endif } @@ -97,35 +98,38 @@ static void help(void) /* Commands */ /*-----------------------------------------------------------------------*/ -static void reboot_cmd(void) -{ +static void reboot_cmd(void) { ctrl_reset_write(1); } #ifdef CSR_LEDS_BASE -static void led_cmd(void) -{ +static void led_cmd(void) { int i; + int j; printf("Led demo...\n"); printf("Counter mode...\n"); - for(i=0; i<32; i++) { + for (i = 0; i < 128; i++) { leds_out_write(i); busy_wait(100); } printf("Shift mode...\n"); - for(i=0; i<4; i++) { - leds_out_write(1<