2 FreeRTOS V8.0.0:rc2 - Copyright (C) 2014 Real Time Engineers Ltd.
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
7 ***************************************************************************
9 * FreeRTOS provides completely free yet professionally developed, *
10 * robust, strictly quality controlled, supported, and cross *
11 * platform software that has become a de facto standard. *
13 * Help yourself get started quickly and support the FreeRTOS *
14 * project by purchasing a FreeRTOS tutorial book, reference *
15 * manual, or both from: http://www.FreeRTOS.org/Documentation *
19 ***************************************************************************
21 This file is part of the FreeRTOS distribution.
23 FreeRTOS is free software; you can redistribute it and/or modify it under
24 the terms of the GNU General Public License (version 2) as published by the
25 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
27 >>! NOTE: The modification to the GPL is included to allow you to distribute
28 >>! a combined work that includes FreeRTOS without being obliged to provide
29 >>! the source code for proprietary components outside of the FreeRTOS
32 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
33 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
34 FOR A PARTICULAR PURPOSE. Full license text is available from the following
35 link: http://www.freertos.org/a00114.html
39 ***************************************************************************
41 * Having a problem? Start by reading the FAQ "My application does *
42 * not run, what could be wrong?" *
44 * http://www.FreeRTOS.org/FAQHelp.html *
46 ***************************************************************************
48 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
49 license and Real Time Engineers Ltd. contact details.
51 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
52 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
53 compatible FAT file system, and our tiny thread aware UDP/IP stack.
55 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
56 Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
57 licenses offer ticketed support, indemnification and middleware.
59 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
60 engineered and independently SIL3 certified version for use in safety and
61 mission critical applications that require provable dependability.
66 /******************************************************************************
67 * This project provides two demo applications. A simple blinky style project,
68 * and a more comprehensive test and demo application. The
69 * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this file) is used to
70 * select between the two. The simply blinky demo is implemented and described
71 * in main_blinky.c. The more comprehensive test and demo application is
72 * implemented and described in main_full.c.
74 * This file implements the code that is not demo specific, including the
75 * hardware setup and FreeRTOS hook functions.
77 * NOTE: The full demo includes a test that checks the floating point context
78 * is maintained correctly across task switches. The standard GCC libraries can
79 * use floating point registers and made this test fail (unless the tasks that
80 * use the library are given a floating point context as described on the
81 * documentation page for this demo). printf-stdarg.c is included in this
82 * project to prevent the standard GCC libraries being linked into the project.
84 * ENSURE TO READ THE DOCUMENTATION PAGE FOR THIS PORT AND DEMO APPLICATION ON
85 * THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO
86 * APPLICATION, AND ITS ASSOCIATE FreeRTOS ARCHITECTURE PORT!
90 /* Standard includes. */
93 /* Scheduler include files. */
98 /* Standard demo includes. */
100 #include "TimerDemo.h"
101 #include "QueueOverwrite.h"
103 /* Xilinx includes. */
104 #include "platform.h"
105 #include "xparameters.h"
106 #include "xscutimer.h"
108 #include "xil_exception.h"
110 /* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,
111 or 0 to run the more comprehensive test and demo application. */
112 #define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0
114 /*-----------------------------------------------------------*/
117 * Configure the hardware as necessary to run this demo.
119 static void prvSetupHardware( void );
122 * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.
123 * main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.
125 #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1
126 extern void main_blinky( void );
128 extern void main_full( void );
129 #endif /* #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 */
131 /* Prototypes for the standard FreeRTOS callback/hook functions implemented
133 void vApplicationMallocFailedHook( void );
134 void vApplicationIdleHook( void );
135 void vApplicationStackOverflowHook( xTaskHandle pxTask, char *pcTaskName );
136 void vApplicationTickHook( void );
138 /*-----------------------------------------------------------*/
140 /* The interrupt controller is initialised in this file, and made available to
142 XScuGic xInterruptController;
144 /*-----------------------------------------------------------*/
148 /* Configure the hardware ready to run the demo. */
151 /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
153 #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1
163 /* Don't expect to reach here. */
166 /*-----------------------------------------------------------*/
168 static void prvSetupHardware( void )
171 XScuGic_Config *pxGICConfig;
173 /* Ensure no interrupts execute while the scheduler is in an inconsistent
174 state. Interrupts are automatically enabled when the scheduler is
176 portDISABLE_INTERRUPTS();
178 /* Obtain the configuration of the GIC. */
179 pxGICConfig = XScuGic_LookupConfig( XPAR_SCUGIC_SINGLE_DEVICE_ID );
181 /* Sanity check the FreeRTOSConfig.h settings are correct for the
183 configASSERT( pxGICConfig );
184 configASSERT( pxGICConfig->CpuBaseAddress == ( configINTERRUPT_CONTROLLER_BASE_ADDRESS + configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET ) );
185 configASSERT( pxGICConfig->DistBaseAddress == configINTERRUPT_CONTROLLER_BASE_ADDRESS );
187 /* Install a default handler for each GIC interrupt. */
188 xStatus = XScuGic_CfgInitialize( &xInterruptController, pxGICConfig, pxGICConfig->CpuBaseAddress );
189 configASSERT( xStatus == XST_SUCCESS );
191 /* Initialise the LED port. */
192 vParTestInitialise();
194 /*-----------------------------------------------------------*/
196 void vApplicationMallocFailedHook( void )
198 /* Called if a call to pvPortMalloc() fails because there is insufficient
199 free memory available in the FreeRTOS heap. pvPortMalloc() is called
200 internally by FreeRTOS API functions that create tasks, queues, software
201 timers, and semaphores. The size of the FreeRTOS heap is set by the
202 configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
203 taskDISABLE_INTERRUPTS();
206 /*-----------------------------------------------------------*/
208 void vApplicationStackOverflowHook( xTaskHandle pxTask, char *pcTaskName )
213 /* Run time stack overflow checking is performed if
214 configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
215 function is called if a stack overflow is detected. */
216 taskDISABLE_INTERRUPTS();
219 /*-----------------------------------------------------------*/
221 void vApplicationIdleHook( void )
223 volatile size_t xFreeHeapSpace;
225 /* This is just a trivial example of an idle hook. It is called on each
226 cycle of the idle task. It must *NOT* attempt to block. In this case the
227 idle task just queries the amount of FreeRTOS heap that remains. See the
228 memory management section on the http://www.FreeRTOS.org web site for memory
229 management options. If there is a lot of heap memory free then the
230 configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up
232 xFreeHeapSpace = xPortGetFreeHeapSize();
234 /* Remove compiler warning about xFreeHeapSpace being set but never used. */
235 ( void ) xFreeHeapSpace;
237 /*-----------------------------------------------------------*/
239 void vAssertCalled( const char * pcFile, unsigned long ulLine )
241 volatile unsigned long ul = 0;
246 taskENTER_CRITICAL();
248 /* Set ul to a non-zero value using the debugger to step out of this
257 /*-----------------------------------------------------------*/
259 void vApplicationTickHook( void )
261 #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )
263 /* The full demo includes a software timer demo/test that requires
264 prodding periodically from the tick interrupt. */
265 vTimerPeriodicISRTests();
267 /* Call the periodic queue overwrite from ISR demo. */
268 vQueueOverwritePeriodicISRDemo();