From 3a13ec3433077176840fb19e93c0be806dd47350 Mon Sep 17 00:00:00 2001 From: Aadi Desai <21363892+supleed2@users.noreply.github.com> Date: Sat, 11 Mar 2023 18:06:19 +0000 Subject: [PATCH] Add software support for sawtooth block --- demo/Makefile | 2 +- demo/audio.cpp | 7 +++++++ demo/main.c | 20 ++++++++++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 demo/audio.cpp diff --git a/demo/Makefile b/demo/Makefile index 1326373..ed274d7 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 leds.o + OBJECTS += hellocpp.o leds.o audio.o CFLAGS += -DWITH_CXX endif diff --git a/demo/audio.cpp b/demo/audio.cpp new file mode 100644 index 0000000..088c718 --- /dev/null +++ b/demo/audio.cpp @@ -0,0 +1,7 @@ +#include +#include + +extern "C" void audio(int); +void audio(int v) { + audio_targ_write(v); +} \ No newline at end of file diff --git a/demo/main.c b/demo/main.c index 3408d82..1126800 100644 --- a/demo/main.c +++ b/demo/main.c @@ -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__ @@ -91,6 +91,9 @@ static void help(void) { #ifdef CSR_LEDS_BASE puts("leds - Led set demo"); #endif +#ifdef CSR_AUDIO_BASE + puts("audio - Sawtooth Audio demo"); +#endif #endif } @@ -152,6 +155,15 @@ static void leds_cmd(char **val) { leds(value); } #endif +#ifdef CSR_AUDIO_BASE +extern void audio(int); + +static void audio_cmd(char **val) { + int value = (int)strtol(get_token(val), NULL, 0); + printf("Setting Sawtooth to %dHz\n", value); + audio(value); +} +#endif #endif extern void donut(void); @@ -202,12 +214,16 @@ static void console_service(void) { else if (strcmp(token, "helloc") == 0) helloc_cmd(); #ifdef WITH_CXX -#ifdef CSR_LEDS_BASE 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); +#endif #endif prompt(); }