Add software support for sawtooth block

This commit is contained in:
Aadi Desai 2023-03-11 18:06:19 +00:00
parent 2b18d82358
commit 3a13ec3433
No known key found for this signature in database
3 changed files with 26 additions and 3 deletions

View file

@ -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

7
demo/audio.cpp Normal file
View file

@ -0,0 +1,7 @@
#include <generated/csr.h>
#include <stdio.h>
extern "C" void audio(int);
void audio(int v) {
audio_targ_write(v);
}

View file

@ -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();
}