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 1
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 */
132 * The Xilinx projects use a BSP that do not allow the start up code to be
133 * altered easily. Therefore the vector table used by FreeRTOS is defined in
134 * FreeRTOS_asm_vectors.S, which is part of this project. Switch to use the
135 * FreeRTOS vector table.
137 extern void vPortInstallFreeRTOSVectorTable( void );
139 /* Prototypes for the standard FreeRTOS callback/hook functions implemented
141 void vApplicationMallocFailedHook( void );
142 void vApplicationIdleHook( void );
143 void vApplicationStackOverflowHook( xTaskHandle pxTask, char *pcTaskName );
144 void vApplicationTickHook( void );
146 /*-----------------------------------------------------------*/
148 /* The interrupt controller is initialised in this file, and made available to
150 XScuGic xInterruptController;
152 /*-----------------------------------------------------------*/
156 /* Configure the hardware ready to run the demo. */
159 /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
161 #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1
171 /* Don't expect to reach here. */
174 /*-----------------------------------------------------------*/
176 static void prvSetupHardware( void )
179 XScuGic_Config *pxGICConfig;
181 /* Ensure no interrupts execute while the scheduler is in an inconsistent
182 state. Interrupts are automatically enabled when the scheduler is
184 portDISABLE_INTERRUPTS();
186 /* Obtain the configuration of the GIC. */
187 pxGICConfig = XScuGic_LookupConfig( XPAR_SCUGIC_SINGLE_DEVICE_ID );
189 /* Sanity check the FreeRTOSConfig.h settings are correct for the
191 configASSERT( pxGICConfig );
192 configASSERT( pxGICConfig->CpuBaseAddress == ( configINTERRUPT_CONTROLLER_BASE_ADDRESS + configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET ) );
193 configASSERT( pxGICConfig->DistBaseAddress == configINTERRUPT_CONTROLLER_BASE_ADDRESS );
195 /* Install a default handler for each GIC interrupt. */
196 xStatus = XScuGic_CfgInitialize( &xInterruptController, pxGICConfig, pxGICConfig->CpuBaseAddress );
197 configASSERT( xStatus == XST_SUCCESS );
198 ( void ) xStatus; /* Remove compiler warning if configASSERT() is not defined. */
200 /* Initialise the LED port. */
201 vParTestInitialise();
203 /* The Xilinx projects use a BSP that do not allow the start up code to be
204 altered easily. Therefore the vector table used by FreeRTOS is defined in
205 FreeRTOS_asm_vectors.S, which is part of this project. Switch to use the
206 FreeRTOS vector table. */
207 vPortInstallFreeRTOSVectorTable();
209 /*-----------------------------------------------------------*/
211 void vApplicationMallocFailedHook( void )
213 /* Called if a call to pvPortMalloc() fails because there is insufficient
214 free memory available in the FreeRTOS heap. pvPortMalloc() is called
215 internally by FreeRTOS API functions that create tasks, queues, software
216 timers, and semaphores. The size of the FreeRTOS heap is set by the
217 configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
218 taskDISABLE_INTERRUPTS();
221 /*-----------------------------------------------------------*/
223 void vApplicationStackOverflowHook( xTaskHandle pxTask, char *pcTaskName )
228 /* Run time stack overflow checking is performed if
229 configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
230 function is called if a stack overflow is detected. */
231 taskDISABLE_INTERRUPTS();
234 /*-----------------------------------------------------------*/
236 void vApplicationIdleHook( void )
238 volatile size_t xFreeHeapSpace;
240 /* This is just a trivial example of an idle hook. It is called on each
241 cycle of the idle task. It must *NOT* attempt to block. In this case the
242 idle task just queries the amount of FreeRTOS heap that remains. See the
243 memory management section on the http://www.FreeRTOS.org web site for memory
244 management options. If there is a lot of heap memory free then the
245 configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up
247 xFreeHeapSpace = xPortGetFreeHeapSize();
249 /* Remove compiler warning about xFreeHeapSpace being set but never used. */
250 ( void ) xFreeHeapSpace;
252 /*-----------------------------------------------------------*/
254 void vAssertCalled( const char * pcFile, unsigned long ulLine )
256 volatile unsigned long ul = 0;
261 taskENTER_CRITICAL();
263 /* Set ul to a non-zero value using the debugger to step out of this
272 /*-----------------------------------------------------------*/
274 void vApplicationTickHook( void )
276 #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )
278 /* The full demo includes a software timer demo/test that requires
279 prodding periodically from the tick interrupt. */
280 vTimerPeriodicISRTests();
282 /* Call the periodic queue overwrite from ISR demo. */
283 vQueueOverwritePeriodicISRDemo();