summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfred Gedeon <alfred2g@hotmail.com>2021-05-28 15:23:03 -0700
committeralfred gedeon <28123637+alfred2g@users.noreply.github.com>2021-06-02 11:00:10 -0700
commitb0e693e88b3ee621f98e0ed5aadf8656ea502c79 (patch)
tree75374b6c5cd1bd6de7f757c032d6fc5d6f450d79
parente84fc19966c05ccd2d77d7dddc7d5645f10db4d5 (diff)
downloadfreertos-git-b0e693e88b3ee621f98e0ed5aadf8656ea502c79.tar.gz
Demo: exit 1 on error exit 2 on Ctrl_C
-rw-r--r--FreeRTOS/Demo/Posix_GCC/Makefile17
-rw-r--r--FreeRTOS/Demo/Posix_GCC/main.c30
2 files changed, 32 insertions, 15 deletions
diff --git a/FreeRTOS/Demo/Posix_GCC/Makefile b/FreeRTOS/Demo/Posix_GCC/Makefile
index b3d4db686..f67ffcba2 100644
--- a/FreeRTOS/Demo/Posix_GCC/Makefile
+++ b/FreeRTOS/Demo/Posix_GCC/Makefile
@@ -75,11 +75,22 @@ endif
ifdef SANITIZE_ADDRESS
CFLAGS += -fsanitize=address -fsanitize=alignment
- LDFLAGS += -fsanitize=address -fsanitize=alignment
+ LDFLAGS += -fsanitize=address -fsanitize=alignment
endif
ifdef SANITIZE_LEAK
- LDFLAGS += -fsanitize=leak
+ LDFLAGS += -fsanitize=leak
+endif
+
+ $(info 'checking demo type')
+ifeq ($(USER_DEMO),BLINKY_DEMO)
+ $(info 'blinky demo selected')
+ CPPFLAGS += -DUSER_DEMO=0
+endif
+
+ifeq ($(USER_DEMO),FULL_DEMO)
+ $(info 'full demo selected')
+ CPPFLAGS += -DUSER_DEMO=1
endif
@@ -97,7 +108,7 @@ ${BUILD_DIR}/${BIN} : ${OBJ_FILES}
${BUILD_DIR}/%.o : %.c Makefile
-mkdir -p $(@D)
- $(CC) $(CFLAGS) ${INCLUDE_DIRS} -DUSER_DEMO= -MMD -c $< -o $@
+ $(CC) $(CPPFLAGS) $(CFLAGS) -MMD -c $< -o $@
.PHONY: clean
diff --git a/FreeRTOS/Demo/Posix_GCC/main.c b/FreeRTOS/Demo/Posix_GCC/main.c
index 3f82c3df6..a9c0b80a6 100644
--- a/FreeRTOS/Demo/Posix_GCC/main.c
+++ b/FreeRTOS/Demo/Posix_GCC/main.c
@@ -65,17 +65,20 @@
/* Local includes. */
#include "console.h"
+#define BLINKY_DEMO 0
+#define FULL_DEMO 1
+
#ifdef BUILD_DIR
- #define BUILD BUILD_DIR
+ #define BUILD BUILD_DIR
#else
- #define BUILD "./"
+ #define BUILD "./"
#endif
+
+/* Demo type is passed as an argument */
#ifdef USER_DEMO
-#define mainSELECTED_APPLICATION USER_DEMO
-#else
- #define BLINKY_DEMO 0
- #define FULL_DEMO 1
- #define mainSELECTED_APPLICATION FULL_DEMO
+ #define mainSELECTED_APPLICATION USER_DEMO
+#else /* Default Setting */
+ #define mainSELECTED_APPLICATION BLINKY_DEMO
#endif
/* This demo uses heap_3.c (the libc provided malloc() and free()). */
@@ -237,10 +240,10 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask,
void vApplicationTickHook( void )
{
/* This function will be called by each tick interrupt if
- * configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be
- * added here, but the tick hook is called from an interrupt context, so
- * code must not attempt to block, and only the interrupt safe FreeRTOS API
- * functions can be used (those that end in FromISR()). */
+ * configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be
+ * added here, but the tick hook is called from an interrupt context, so
+ * code must not attempt to block, and only the interrupt safe FreeRTOS API
+ * functions can be used (those that end in FromISR()). */
#if ( mainSELECTED_APPLICATION == FULL_DEMO )
{
@@ -413,10 +416,13 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
void handle_sigint( int signal )
{
int xReturn;
+
xReturn = chdir( BUILD ); /* changing dir to place gmon.out inside build */
+
if( xReturn == -1 )
{
- printf( "chdir into %s error is %d\n", BUILD, errno );
+ printf( "chdir into %s error is %d\n", BUILD, errno );
}
+
exit( 2 );
}