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 * ENSURE TO READ THE DOCUMENTATION PAGE FOR THIS PORT AND DEMO APPLICATION ON
78 * THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO
79 * APPLICATION, AND ITS ASSOCIATE FreeRTOS ARCHITECTURE PORT!
83 /* Standard includes. */
86 /* Scheduler include files. */
91 /* Standard demo includes. */
93 #include "TimerDemo.h"
94 #include "QueueOverwrite.h"
96 /* Xilinx includes. */
98 #include "xparameters.h"
99 #include "xscutimer.h"
101 #include "xil_exception.h"
103 /* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,
104 or 0 to run the more comprehensive test and demo application. */
105 #define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0
107 /*-----------------------------------------------------------*/
110 * Configure the hardware as necessary to run this demo.
112 static void prvSetupHardware( void );
115 * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.
116 * main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.
118 #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1
119 extern void main_blinky( void );
121 extern void main_full( void );
122 #endif /* #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 */
124 /* Prototypes for the standard FreeRTOS callback/hook functions implemented
126 void vApplicationMallocFailedHook( void );
127 void vApplicationIdleHook( void );
128 void vApplicationStackOverflowHook( xTaskHandle pxTask, char *pcTaskName );
129 void vApplicationTickHook( void );
131 /*-----------------------------------------------------------*/
135 /* Configure the hardware ready to run the demo. */
138 /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
140 #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1
152 /*-----------------------------------------------------------*/
154 static void prvSetupHardware( void )
157 XScuGic_Config *pxGICConfig;
158 XScuGic xInterruptController;
160 /* Ensure no interrupts execute while the scheduler is in an inconsistent
161 state. Interrupts are automatically enabled when the scheduler is
163 portDISABLE_INTERRUPTS();
165 /* Obtain the configuration of the GIC. */
166 pxGICConfig = XScuGic_LookupConfig( XPAR_SCUGIC_SINGLE_DEVICE_ID );
168 /* Sanity check the FreeRTOSConfig.h settings are correct for the
170 configASSERT( pxGICConfig );
171 configASSERT( pxGICConfig->CpuBaseAddress == ( configINTERRUPT_CONTROLLER_BASE_ADDRESS + configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET ) );
172 configASSERT( pxGICConfig->DistBaseAddress == configINTERRUPT_CONTROLLER_BASE_ADDRESS );
174 /* Install a default handler for each GIC interrupt. */
175 xStatus = XScuGic_CfgInitialize( &xInterruptController, pxGICConfig, pxGICConfig->CpuBaseAddress );
176 configASSERT( xStatus == XST_SUCCESS );
178 /* Initialise the LED port. */
179 vParTestInitialise();
181 /*-----------------------------------------------------------*/
183 void vApplicationMallocFailedHook( void )
185 /* Called if a call to pvPortMalloc() fails because there is insufficient
186 free memory available in the FreeRTOS heap. pvPortMalloc() is called
187 internally by FreeRTOS API functions that create tasks, queues, software
188 timers, and semaphores. The size of the FreeRTOS heap is set by the
189 configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
190 taskDISABLE_INTERRUPTS();
193 /*-----------------------------------------------------------*/
195 void vApplicationStackOverflowHook( xTaskHandle pxTask, char *pcTaskName )
200 /* Run time stack overflow checking is performed if
201 configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
202 function is called if a stack overflow is detected. */
203 taskDISABLE_INTERRUPTS();
206 /*-----------------------------------------------------------*/
208 void vApplicationIdleHook( void )
210 volatile size_t xFreeHeapSpace;
212 /* This is just a trivial example of an idle hook. It is called on each
213 cycle of the idle task. It must *NOT* attempt to block. In this case the
214 idle task just queries the amount of FreeRTOS heap that remains. See the
215 memory management section on the http://www.FreeRTOS.org web site for memory
216 management options. If there is a lot of heap memory free then the
217 configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up
219 xFreeHeapSpace = xPortGetFreeHeapSize();
221 /* Remove compiler warning about xFreeHeapSpace being set but never used. */
222 ( void ) xFreeHeapSpace;
224 /*-----------------------------------------------------------*/
226 void vAssertCalled( const char * pcFile, unsigned long ulLine )
228 volatile unsigned long ul = 0;
233 taskENTER_CRITICAL();
235 /* Set ul to a non-zero value using the debugger to step out of this
244 /*-----------------------------------------------------------*/
246 void vApplicationTickHook( void )
248 #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )
250 /* The full demo includes a software timer demo/test that requires
251 prodding periodically from the tick interrupt. */
252 vTimerPeriodicISRTests();
254 /* Call the periodic queue overwrite from ISR demo. */
255 vQueueOverwritePeriodicISRDemo();