mirror of
https://github.com/supleed2/EIE4-FYP.git
synced 2024-11-09 20:05:49 +00:00
Add software support for sawtooth block
This commit is contained in:
parent
2b18d82358
commit
3a13ec3433
|
@ -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
7
demo/audio.cpp
Normal 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);
|
||||
}
|
20
demo/main.c
20
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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue