Merge pull request #836 from hplp/master

demo with c++ HW example
This commit is contained in:
enjoy-digital 2021-03-02 09:13:10 +01:00 committed by GitHub
commit c23e8813fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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();
}