2 * FreeRTOS Kernel V10.0.1
3 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * http://www.FreeRTOS.org
23 * http://aws.amazon.com/freertos
28 /******************************************************************************
29 * This project provides two demo applications. A simple blinky style project,
30 * and a more comprehensive test and demo application. The
31 * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is used to select between the two.
32 * The simply blinky demo is implemented and described in main_blinky.c. The
33 * more comprehensive test and demo application is implemented and described in
36 * This file implements the code that is not demo specific, including the
37 * hardware setup and FreeRTOS hook functions.
39 *******************************************************************************
42 /* Standard includes. */
46 /* FreeRTOS kernel includes. */
50 /* This project provides two demo applications. A simple blinky style demo
51 application, and a more comprehensive test and demo application. The
52 mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is used to select between the two.
54 If mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is 1 then the blinky demo will be built.
55 The blinky demo is implemented and described in main_blinky.c.
57 If mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is not 1 then the comprehensive test and
58 demo application will be built. The comprehensive test and demo application is
59 implemented and described in main_full.c. */
60 #define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0
62 /*-----------------------------------------------------------*/
65 * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.
66 * main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.
68 extern void main_blinky( void );
69 extern void main_full( void );
72 * Prototypes for the standard FreeRTOS application hook (callback) functions
73 * implemented within this file. See http://www.freertos.org/a00016.html .
75 void vApplicationMallocFailedHook( void );
76 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
77 void vApplicationTickHook( void );
80 * Only the comprehensive demo uses application hook (callback) functions. See
81 * http://www.freertos.org/a00016.html for more information.
83 void vFullDemoTickHookFunction( void );
86 /*-----------------------------------------------------------*/
90 /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
92 #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )
104 /*-----------------------------------------------------------*/
106 void vApplicationMallocFailedHook( void )
108 /* vApplicationMallocFailedHook() will only be called if
109 configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
110 function that will get called if a call to pvPortMalloc() fails.
111 pvPortMalloc() is called internally by the kernel whenever a task, queue,
112 timer or semaphore is created. It is also called by various parts of the
113 demo application. If heap_1.c, heap_2.c or heap_4.c is being used, then the
114 size of the heap available to pvPortMalloc() is defined by
115 configTOTAL_HEAP_SIZE in FreeRTOSConfig.h, and the xPortGetFreeHeapSize()
116 API function can be used to query the size of free heap space that remains
117 (although it does not provide information on how the remaining heap might be
118 fragmented). See http://www.freertos.org/a00111.html for more
120 vAssertCalled( __LINE__, __FILE__ );
122 /*-----------------------------------------------------------*/
124 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
129 /* Run time stack overflow checking is performed if
130 configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
131 function is called if a stack overflow is detected. This function is
132 provided as an example only as stack overflow checking does not function
133 when running the FreeRTOS Windows port. */
134 vAssertCalled( __LINE__, __FILE__ );
136 /*-----------------------------------------------------------*/
138 void vApplicationTickHook( void )
140 /* This function will be called by each tick interrupt if
141 configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be
142 added here, but the tick hook is called from an interrupt context, so
143 code must not attempt to block, and only the interrupt safe FreeRTOS API
144 functions can be used (those that end in FromISR()). */
146 #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY != 1 )
148 vFullDemoTickHookFunction();
150 #endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */
152 /*-----------------------------------------------------------*/
154 void vAssertCalled( unsigned long ulLine, const char * const pcFileName )
156 static BaseType_t xPrinted = pdFALSE;
157 volatile uint32_t ulSetToNonZeroInDebuggerToContinue = 0;
159 /* Called if an assertion passed to configASSERT() fails. See
160 http://www.freertos.org/a00110.html#configASSERT for more information. */
162 /* Parameters are not used. */
166 printf( "ASSERT! Line %ld, file %s\r\n", ulLine, pcFileName );
168 taskENTER_CRITICAL();
170 /* You can step out of this function to debug the assertion by using
171 the debugger to set ulSetToNonZeroInDebuggerToContinue to a non-zero
173 while( ulSetToNonZeroInDebuggerToContinue == 0 )
175 __asm volatile( "NOP" );
176 __asm volatile( "NOP" );
181 /*-----------------------------------------------------------*/