extend demo with basic C and C++ examples

This commit is contained in:
Sergiu Mosanu 2021-03-02 01:28:21 -05:00
parent 737ed9d658
commit 769f36d468
4 changed files with 40 additions and 1 deletions

View File

@ -3,7 +3,7 @@ BUILD_DIR?=../build/
include $(BUILD_DIR)/software/include/generated/variables.mak
include $(SOC_DIRECTORY)/software/common.mak
OBJECTS=isr.o donut.o main.o
OBJECTS=isr.o donut.o helloc.o hellocpp.o main.o
all: demo.bin
@ -30,6 +30,12 @@ main.o: main.c
donut.o: CFLAGS += -w
helloc.o: CFLAGS += -w
hellocpp.o: CXXFLAGS += -w
%.o: %.cpp
$(compilexx)
%.o: %.c
$(compile)

View File

@ -0,0 +1,5 @@
#include <stdio.h>
void helloc(void) {
printf("C: Hello, world!\n");
}

View File

@ -0,0 +1,7 @@
#include <stdio.h>
extern "C" void hellocpp(void);
void hellocpp(void)
{
printf("C++: Hello, world!\n");
}

View File

@ -87,6 +87,8 @@ static void help(void)
puts("led - Led demo");
#endif
puts("donut - Spinning Donut demo");
puts("helloc - Hello C");
puts("hellocpp - Hello C++");
}
/*-----------------------------------------------------------------------*/
@ -138,6 +140,21 @@ static void donut_cmd(void)
donut();
}
extern void helloc(void);
static void helloc_cmd(void)
{
printf("Hello C demo...\n");
helloc();
}
extern void hellocpp(void);
static void hellocpp_cmd(void)
{
printf("Hello C++ demo...\n");
hellocpp();
}
/*-----------------------------------------------------------------------*/
/* Console service / Main */
/*-----------------------------------------------------------------------*/
@ -160,6 +177,10 @@ 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();
prompt();
}