2 FreeRTOS.org V5.1.1 - 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
50 /* FreeRTOS includes. */
\r
51 #include "FreeRTOS.h"
\r
54 /* Standard demo includes. */
\r
56 #include "blocktim.h"
\r
57 #include "countsem.h"
\r
59 #include "dynamic.h"
\r
61 #include "GenQTest.h"
\r
62 #include "integer.h"
\r
65 #include "recmutex.h"
\r
66 #include "semtest.h"
\r
67 #include "ParTest.h"
\r
69 /* Standard includes. */
\r
72 /* Priorities for the demo application tasks. */
\r
73 #define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
74 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
75 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 0 )
\r
76 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
\r
77 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 0 )
\r
78 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
79 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
80 #define mainGENERIC_QUEUE_PRIORITY ( tskIDLE_PRIORITY )
\r
82 /* The period of the check task both in and out of the presense of an error. */
\r
83 #define mainNO_ERROR_PERIOD ( 5000 / portTICK_RATE_MS )
\r
84 #define mainERROR_PERIOD ( 500 / portTICK_RATE_MS );
\r
85 /*-----------------------------------------------------------*/
\r
87 /* Simple hardware setup required by the demo. */
\r
88 static void prvSetupHardware( void );
\r
90 /* The check task as described at the top of this file. */
\r
91 static void prvCheckTask( void *pvParameters );
\r
93 /*-----------------------------------------------------------*/
\r
98 /* Start the standard demo tasks. */
\r
99 vStartIntegerMathTasks( tskIDLE_PRIORITY );
\r
100 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
101 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
102 vStartDynamicPriorityTasks();
\r
103 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
104 vCreateBlockTimeTasks();
\r
105 vStartCountingSemaphoreTasks();
\r
106 vStartGenericQueueTasks( tskIDLE_PRIORITY );
\r
107 vStartQueuePeekTasks();
\r
108 vStartRecursiveMutexTasks();
\r
110 /* Create the check task - this is the task that checks all the other tasks
\r
111 are executing as expected and without reporting any errors. */
\r
112 xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL );
\r
114 /* The death demo tasks must be started last as the sanity checks performed
\r
115 require knowledge of the number of other tasks in the system. */
\r
116 vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
\r
118 /* Start the scheduler. From this point on the execution will be under
\r
119 the control of the kernel. */
\r
120 vTaskStartScheduler();
\r
122 /* Will only get here if there was insufficient heap availale for the
\r
123 idle task to be created. */
\r
126 /*-----------------------------------------------------------*/
\r
128 static void prvCheckTask( void * pvParameters )
\r
130 portTickType xNextWakeTime, xPeriod = mainNO_ERROR_PERIOD;
\r
131 static volatile unsigned portLONG ulErrorCode = 0UL;
\r
133 /* Just to remove the compiler warning. */
\r
134 ( void ) pvParameters;
\r
136 /* Initialise xNextWakeTime prior to its first use. From this point on
\r
137 the value of the variable is handled automatically by the kernel. */
\r
138 xNextWakeTime = xTaskGetTickCount();
\r
142 vTaskDelayUntil( &xNextWakeTime, xPeriod );
\r
144 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
146 ulErrorCode |= 0x01UL;
\r
149 if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
151 ulErrorCode |= 0x02UL;
\r
154 if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )
\r
156 ulErrorCode |= 0x04UL;
\r
159 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
161 ulErrorCode |= 0x08UL;
\r
164 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
\r
166 ulErrorCode |= 0x10UL;
\r
169 if( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
171 ulErrorCode |= 0x20UL;
\r
174 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
176 ulErrorCode |= 0x40UL;
\r
179 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
181 ulErrorCode |= 0x80UL;
\r
184 if( xAreQueuePeekTasksStillRunning() != pdTRUE )
\r
186 ulErrorCode |= 0x100UL;
\r
189 if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
\r
191 ulErrorCode |= 0x200UL;
\r
194 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
196 ulErrorCode |= 0x400UL;
\r
199 if( ulErrorCode != 0x00 )
\r
201 xPeriod = mainERROR_PERIOD;
\r
204 vParTestToggleLED( LED_DS1 );
\r
207 /*-----------------------------------------------------------*/
\r
209 static void prvSetupHardware( void )
\r
211 vParTestInitialise();
\r