2 FreeRTOS.org V5.1.2 - Copyright (C) 2003-2009 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 * Get the FreeRTOS eBook! See http://www.FreeRTOS.org/Documentation *
\r
31 * This is a concise, step by step, 'hands on' guide that describes both *
\r
32 * general multitasking concepts and FreeRTOS specifics. It presents and *
\r
33 * explains numerous examples that are written using the FreeRTOS API. *
\r
34 * Full source code for all the examples is provided in an accompanying *
\r
37 ***************************************************************************
\r
38 ***************************************************************************
\r
40 Please ensure to read the configuration and relevant port sections of the
\r
41 online documentation.
\r
43 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
46 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
49 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
50 licensing and training services.
\r
54 * Creates all the demo application tasks then starts the scheduler. In
\r
55 * addition to the standard demo application tasks main() creates the
\r
56 * HTTPServer task, and a "Check" task. The Check task periodically inspects
\r
57 * all the other tasks in the system to see if any errors have been reported.
\r
58 * The error status is then displayed on the served WEB page.
\r
61 /* Tern includes. */
\r
63 #include <embedded.h>
\r
65 /* FreeRTOS.org includes. */
\r
66 #include <FreeRTOS.h>
\r
69 /* Demo application includes. */
\r
70 #include "HTTPTask.h"
\r
71 #include "integer.h"
\r
73 #include "semtest.h"
\r
74 #include "dynamic.h"
\r
78 #include "comtest.h"
\r
80 /* How often should the "check" task execute? */
\r
81 #define mainCHECK_DELAY ( 3000 / portTICK_RATE_MS )
\r
83 /* Priorities allocated to the various tasks. */
\r
84 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
85 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
\r
86 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
87 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
88 #define mainHTTP_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
89 #define mainSUICIDE_TASKS_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
90 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
92 /* Used to indicate the error status. A value of 0 means that an error has not
\r
93 been detected in any task. A non zero value indicates which group of demo
\r
94 tasks has reported an error. See prvCheckTask() for bit definitions. */
\r
95 unsigned portSHORT usCheckStatus = 0;
\r
97 /*-----------------------------------------------------------*/
\r
100 * Setup any hardware required by the demo - other than the RTOS tick which
\r
101 * is configured when the scheduler is started.
\r
103 static void prvSetupHardware( void );
\r
106 * Periodically inspect all the other tasks, updating usCheckStatus should an
\r
107 * error be discovered in any task.
\r
109 static void prvCheckTask( void *pvParameters );
\r
110 /*-----------------------------------------------------------*/
\r
114 prvSetupHardware();
\r
116 /* Start the HTTP server task. */
\r
117 xTaskCreate( vHTTPTask, "WizNet", configMINIMAL_STACK_SIZE, NULL, mainHTTP_TASK_PRIORITY, NULL );
\r
119 /* Start the demo/test application tasks. See the demo application
\r
120 section of the FreeRTOS.org WEB site for more information. */
\r
121 vStartIntegerMathTasks( tskIDLE_PRIORITY );
\r
122 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
123 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
124 vStartDynamicPriorityTasks();
\r
125 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
126 vStartComTestTasks( mainCOM_TEST_PRIORITY, serCOM2, ser57600 );
\r
128 /* Start the task that checks the other demo tasks for errors. */
\r
129 xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
131 /* The suicide tasks must be created last as they monitor the number of
\r
132 tasks in the system to ensure there are no more or fewer than expected
\r
133 compared to the number that were executing when the task started. */
\r
134 vCreateSuicidalTasks( mainSUICIDE_TASKS_PRIORITY );
\r
136 /* Finally start the scheduler. */
\r
137 vTaskStartScheduler();
\r
139 /* Should not get here! */
\r
142 /*-----------------------------------------------------------*/
\r
144 static void prvSetupHardware( void )
\r
148 /*-----------------------------------------------------------*/
\r
150 static void prvCheckTask( void *pvParameters )
\r
152 ( void ) pvParameters;
\r
154 /* Check all the demo tasks to ensure that they are all still running, and
\r
155 that none of them have detected an error. */
\r
158 /* Block until it is time to check again. */
\r
159 vTaskDelay( mainCHECK_DELAY );
\r
161 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
163 usCheckStatus |= 0x01;
\r
166 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
168 usCheckStatus |= 0x02;
\r
171 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
173 usCheckStatus |= 0x04;
\r
176 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
\r
178 usCheckStatus |= 0x08;
\r
181 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
183 usCheckStatus |= 0x10;
\r
186 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
188 usCheckStatus |= 0x20;
\r
191 if( xAreComTestTasksStillRunning() != pdTRUE )
\r
193 usCheckStatus |= 0x40;
\r
197 /*-----------------------------------------------------------*/
\r
199 /* This is included to prevent link errors - allowing the 'full' version of
\r
200 the comtest tasks to be used. It can be ignored. */
\r
201 void vPrintDisplayMessage( const portCHAR * const * ppcMessageToSend )
\r
203 ( void ) ppcMessageToSend;
\r