2 * FreeRTOS Kernel V10.2.0
\r
3 * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 * this software and associated documentation files (the "Software"), to deal in
\r
7 * the Software without restriction, including without limitation the rights to
\r
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 * subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
22 * http://www.FreeRTOS.org
\r
23 * http://aws.amazon.com/freertos
\r
25 * 1 tab == 4 spaces!
\r
28 /******************************************************************************
\r
29 * This project provides two demo applications:
\r
30 * - A simple blinky style demo application.
\r
31 * - A more comprehensive test and demo application.
\r
32 * The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY macro is used to select between the two.
\r
34 * The simply blinky demo is implemented and described in the file main_blinky.c.
\r
35 * The more comprehensive test and demo application is implemented and described
\r
36 * in the file main_full.c.
\r
38 * This file implements the code that is not demo specific, including the FreeRTOS
\r
41 *******************************************************************************
\r
44 /* Standard includes. */
\r
48 /* FreeRTOS kernel includes. */
\r
49 #include "FreeRTOS.h"
\r
53 * This project provides two demo applications:
\r
54 * - A simple blinky style demo application.
\r
55 * - A more comprehensive test and demo application.
\r
56 * The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY macro is used to select between the two.
\r
58 * If mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1 then the blinky demo will be
\r
59 * built. The blinky demo is implemented and described in main_blinky.c.
\r
61 * If mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0 then the comprehensive test
\r
62 * and demo application will be built. The comprehensive test and demo application
\r
63 * is implemented and described in main_full.c.
\r
65 #define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0
\r
66 /*-----------------------------------------------------------*/
\r
69 * The entry function for the blinky demo application.
\r
71 * This is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.
\r
73 extern void main_blinky( void );
\r
76 * The entry function for the comprehensive test and demo application.
\r
78 * This is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.
\r
80 extern void main_full( void );
\r
83 * Prototypes for the standard FreeRTOS application hook (callback) functions
\r
84 * implemented within this file.
\r
86 * @see http://www.freertos.org/a00016.html
\r
88 void vApplicationMallocFailedHook( void );
\r
89 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
\r
90 void vApplicationTickHook( void );
\r
93 * The function called from the tick hook.
\r
95 * @note Only the comprehensive demo uses application hook (callback) functions.
\r
97 * @see http://www.freertos.org/a00016.html
\r
99 void vFullDemoTickHookFunction( void );
\r
100 /*-----------------------------------------------------------*/
\r
104 /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
\r
106 #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )
\r
118 /*-----------------------------------------------------------*/
\r
120 void vApplicationMallocFailedHook( void )
\r
122 /* vApplicationMallocFailedHook() will only be called if
\r
123 * configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
\r
124 * function that will get called if a call to pvPortMalloc() fails.
\r
125 * pvPortMalloc() is called internally by the kernel whenever a task, queue,
\r
126 * timer or semaphore is created. It is also called by various parts of the
\r
127 * demo application. If heap_1.c, heap_2.c or heap_4.c is being used, then
\r
128 * the size of the heap available to pvPortMalloc() is defined by
\r
129 * configTOTAL_HEAP_SIZE in FreeRTOSConfig.h, and the xPortGetFreeHeapSize()
\r
130 * API function can be used to query the size of free heap space that remains
\r
131 * (although it does not provide information on how the remaining heap might be
\r
132 * fragmented). See http://www.freertos.org/a00111.html for more information.
\r
134 vAssertCalled( __LINE__, __FILE__ );
\r
136 /*-----------------------------------------------------------*/
\r
138 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
\r
140 ( void ) pcTaskName;
\r
143 /* Run time stack overflow checking is performed if
\r
144 * configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
\r
145 * function is called if a stack overflow is detected. */
\r
146 vAssertCalled( __LINE__, __FILE__ );
\r
148 /*-----------------------------------------------------------*/
\r
150 void vApplicationTickHook( void )
\r
152 /* This function will be called by each tick interrupt if
\r
153 * configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be
\r
154 * added here, but the tick hook is called from an interrupt context, so
\r
155 * code must not attempt to block, and only the interrupt safe FreeRTOS API
\r
156 * functions can be used (those that end in FromISR()). */
\r
157 #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY != 1 )
\r
159 vFullDemoTickHookFunction();
\r
161 #endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */
\r
163 /*-----------------------------------------------------------*/
\r
165 void vAssertCalled( unsigned long ulLine, const char * const pcFileName )
\r
167 static BaseType_t xPrinted = pdFALSE;
\r
168 volatile uint32_t ulSetToNonZeroInDebuggerToContinue = 0;
\r
170 /* Called if an assertion passed to configASSERT() fails. See
\r
171 * http://www.freertos.org/a00110.html#configASSERT for more information. */
\r
173 /* Parameters are not used. */
\r
175 ( void ) pcFileName;
\r
177 taskENTER_CRITICAL();
\r
179 /* You can step out of this function to debug the assertion by using
\r
180 * the debugger to set ulSetToNonZeroInDebuggerToContinue to a non-zero
\r
182 while( ulSetToNonZeroInDebuggerToContinue == 0 )
\r
184 __asm volatile( "NOP" );
\r
185 __asm volatile( "NOP" );
\r
188 taskEXIT_CRITICAL();
\r
190 /*-----------------------------------------------------------*/
\r