2 FreeRTOS.org V5.0.3 - Copyright (C) 2003-2008 Richard Barry.
\r
4 This file is part of the FreeRTOS.org distribution.
\r
6 FreeRTOS.org is free software; you can redistribute it and/or modify
\r
7 it under the terms of the GNU General Public License as published by
\r
8 the Free Software Foundation; either version 2 of the License, or
\r
9 (at your option) any later version.
\r
11 FreeRTOS.org is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 GNU General Public License for more details.
\r
16 You should have received a copy of the GNU General Public License
\r
17 along with FreeRTOS.org; if not, write to the Free Software
\r
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
20 A special exception to the GPL can be applied should you wish to distribute
\r
21 a combined work that includes FreeRTOS.org, without being obliged to provide
\r
22 the source code for any proprietary components. See the licensing section
\r
23 of http://www.FreeRTOS.org for full details of how and when the exception
\r
26 ***************************************************************************
\r
27 ***************************************************************************
\r
29 * SAVE TIME AND MONEY! We can port FreeRTOS.org to your own hardware, *
\r
30 * and even write all or part of your application on your behalf. *
\r
31 * See http://www.OpenRTOS.com for details of the services we provide to *
\r
32 * expedite your project. *
\r
34 ***************************************************************************
\r
35 ***************************************************************************
\r
37 Please ensure to read the configuration and relevant port sections of the
\r
38 online documentation.
\r
40 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
43 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
46 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
47 licensing and training services.
\r
52 * Creates all the demo application tasks, then starts the scheduler. The WEB
\r
53 * documentation provides more details of the standard demo application tasks.
\r
54 * In addition to the standard demo tasks, the following tasks and tests are
\r
55 * defined and/or created within this file:
\r
57 * "Check" task - This only executes every five seconds but has a high priority
\r
58 * to ensure it gets processor time. Its main function is to check that all the
\r
59 * standard demo tasks are still operational. While no errors have been
\r
60 * discovered the check task will toggle an LED every 5 seconds - the toggle
\r
61 * rate increasing to 500ms then being a visual indication that at least one
\r
62 * task has reported unexpected behaviour.
\r
66 /* Standard includes. */
\r
69 /* Scheduler includes. */
\r
70 #include "FreeRTOS.h"
\r
75 /* Demo app includes. */
\r
78 #include "integer.h"
\r
79 #include "blocktim.h"
\r
81 #include "partest.h"
\r
82 #include "semtest.h"
\r
84 #include "GenQTest.h"
\r
86 #include "recmutex.h"
\r
87 #include "IntQueue.h"
\r
89 /*-----------------------------------------------------------*/
\r
91 /* The time between cycles of the 'check' functionality (defined within the
\r
93 #define mainNO_ERROR_PERIOD ( ( portTickType ) 5000 / portTICK_RATE_MS )
\r
95 /* The rate at which the LED controlled by the 'check' task will flash when an
\r
96 error has been detected. */
\r
97 #define mainERROR_PERIOD ( 500 )
\r
99 /* The LED controlled by the 'check' task. */
\r
100 #define mainCHECK_LED ( 3 )
\r
102 /* Task priorities. */
\r
103 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
104 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
105 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
106 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
107 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
108 #define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
109 #define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
113 * Configure the hardware for the demo.
\r
115 static void prvSetupHardware( void );
\r
118 * Implements the 'check' task functionality as described at the top of this
\r
121 static void prvCheckTask( void *pvParameters );
\r
124 /*-----------------------------------------------------------*/
\r
128 prvSetupHardware();
\r
130 /* Start the standard demo tasks. */
\r
131 vStartLEDFlashTasks( tskIDLE_PRIORITY );
\r
132 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
133 vCreateBlockTimeTasks();
\r
134 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
135 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
136 vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
\r
137 vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
\r
138 vStartQueuePeekTasks();
\r
139 vStartRecursiveMutexTasks();
\r
141 /* Create the check task. */
\r
142 xTaskCreate( prvCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
144 /* The suicide tasks must be created last as they need to know how many
\r
145 tasks were running prior to their creation in order to ascertain whether
\r
146 or not the correct/expected number of tasks are running at any given time. */
\r
147 vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
\r
149 /* Start the scheduler. */
\r
150 vTaskStartScheduler();
\r
152 /* Will only get here if there was insufficient memory to create the idle
\r
156 /*-----------------------------------------------------------*/
\r
158 static void prvCheckTask( void *pvParameters )
\r
160 unsigned ulTicksToWait = mainNO_ERROR_PERIOD;
\r
161 portTickType xLastExecutionTime;
\r
163 ( void ) pvParameters;
\r
165 /* Initialise the variable used to control our iteration rate prior to
\r
167 xLastExecutionTime = xTaskGetTickCount();
\r
171 /* Wait until it is time to run the tests again. */
\r
172 vTaskDelayUntil( &xLastExecutionTime, ulTicksToWait );
\r
174 /* Has an error been found in any task? */
\r
175 if( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
177 ulTicksToWait = mainERROR_PERIOD;
\r
179 else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
\r
181 ulTicksToWait = mainERROR_PERIOD;
\r
183 else if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
185 ulTicksToWait = mainERROR_PERIOD;
\r
187 else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
189 ulTicksToWait = mainERROR_PERIOD;
\r
191 else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
193 ulTicksToWait = mainERROR_PERIOD;
\r
195 else if( xArePollingQueuesStillRunning() != pdTRUE )
\r
197 ulTicksToWait = mainERROR_PERIOD;
\r
199 else if( xIsCreateTaskStillRunning() != pdTRUE )
\r
201 ulTicksToWait = mainERROR_PERIOD;
\r
203 else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
205 ulTicksToWait = mainERROR_PERIOD;
\r
207 else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
\r
209 ulTicksToWait = mainERROR_PERIOD;
\r
212 vParTestToggleLED( mainCHECK_LED );
\r
215 /*-----------------------------------------------------------*/
\r
217 void prvSetupHardware( void )
\r
219 vParTestInitialise();
\r
221 /*-----------------------------------------------------------*/
\r
223 void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed portCHAR *pcTaskName )
\r
226 ( void ) pcTaskName;
\r