2 FreeRTOS V5.4.1 - Copyright (C) 2009 Real Time Engineers Ltd.
\r
4 This file is part of the FreeRTOS distribution.
\r
6 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
7 the terms of the GNU General Public License (version 2) as published by the
\r
8 Free Software Foundation and modified by the FreeRTOS exception.
\r
9 **NOTE** The exception to the GPL is included to allow you to distribute a
\r
10 combined work that includes FreeRTOS without being obliged to provide the
\r
11 source code for proprietary components outside of the FreeRTOS kernel.
\r
12 Alternative commercial license and support terms are also available upon
\r
13 request. See the licensing section of http://www.FreeRTOS.org for full
\r
16 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
\r
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
\r
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
21 You should have received a copy of the GNU General Public License along
\r
22 with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59
\r
23 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
\r
26 ***************************************************************************
\r
28 * Looking for a quick start? Then check out the FreeRTOS eBook! *
\r
29 * See http://www.FreeRTOS.org/Documentation for details *
\r
31 ***************************************************************************
\r
35 Please ensure to read the configuration and relevant port sections of the
\r
36 online documentation.
\r
38 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
41 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
44 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
45 licensing and training services.
\r
49 * Creates all the demo application tasks then starts the scheduler. In
\r
50 * addition to the standard demo application tasks main() creates the
\r
51 * HTTPServer task, and a "Check" task. The Check task periodically inspects
\r
52 * all the other tasks in the system to see if any errors have been reported.
\r
53 * The error status is then displayed on the served WEB page.
\r
56 /* Tern includes. */
\r
58 #include <embedded.h>
\r
60 /* FreeRTOS.org includes. */
\r
61 #include <FreeRTOS.h>
\r
64 /* Demo application includes. */
\r
65 #include "HTTPTask.h"
\r
66 #include "integer.h"
\r
68 #include "semtest.h"
\r
69 #include "dynamic.h"
\r
73 #include "comtest.h"
\r
75 /* How often should the "check" task execute? */
\r
76 #define mainCHECK_DELAY ( 3000 / portTICK_RATE_MS )
\r
78 /* Priorities allocated to the various tasks. */
\r
79 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
80 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
\r
81 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
82 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
83 #define mainHTTP_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
84 #define mainSUICIDE_TASKS_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
85 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
87 /* Used to indicate the error status. A value of 0 means that an error has not
\r
88 been detected in any task. A non zero value indicates which group of demo
\r
89 tasks has reported an error. See prvCheckTask() for bit definitions. */
\r
90 unsigned portSHORT usCheckStatus = 0;
\r
92 /*-----------------------------------------------------------*/
\r
95 * Setup any hardware required by the demo - other than the RTOS tick which
\r
96 * is configured when the scheduler is started.
\r
98 static void prvSetupHardware( void );
\r
101 * Periodically inspect all the other tasks, updating usCheckStatus should an
\r
102 * error be discovered in any task.
\r
104 static void prvCheckTask( void *pvParameters );
\r
105 /*-----------------------------------------------------------*/
\r
109 prvSetupHardware();
\r
111 /* Start the HTTP server task. */
\r
112 xTaskCreate( vHTTPTask, "WizNet", configMINIMAL_STACK_SIZE, NULL, mainHTTP_TASK_PRIORITY, NULL );
\r
114 /* Start the demo/test application tasks. See the demo application
\r
115 section of the FreeRTOS.org WEB site for more information. */
\r
116 vStartIntegerMathTasks( tskIDLE_PRIORITY );
\r
117 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
118 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
119 vStartDynamicPriorityTasks();
\r
120 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
121 vStartComTestTasks( mainCOM_TEST_PRIORITY, serCOM2, ser57600 );
\r
123 /* Start the task that checks the other demo tasks for errors. */
\r
124 xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
126 /* The suicide tasks must be created last as they monitor the number of
\r
127 tasks in the system to ensure there are no more or fewer than expected
\r
128 compared to the number that were executing when the task started. */
\r
129 vCreateSuicidalTasks( mainSUICIDE_TASKS_PRIORITY );
\r
131 /* Finally start the scheduler. */
\r
132 vTaskStartScheduler();
\r
134 /* Should not get here! */
\r
137 /*-----------------------------------------------------------*/
\r
139 static void prvSetupHardware( void )
\r
143 /*-----------------------------------------------------------*/
\r
145 static void prvCheckTask( void *pvParameters )
\r
147 ( void ) pvParameters;
\r
149 /* Check all the demo tasks to ensure that they are all still running, and
\r
150 that none of them have detected an error. */
\r
153 /* Block until it is time to check again. */
\r
154 vTaskDelay( mainCHECK_DELAY );
\r
156 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
158 usCheckStatus |= 0x01;
\r
161 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
163 usCheckStatus |= 0x02;
\r
166 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
168 usCheckStatus |= 0x04;
\r
171 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
\r
173 usCheckStatus |= 0x08;
\r
176 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
178 usCheckStatus |= 0x10;
\r
181 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
183 usCheckStatus |= 0x20;
\r
186 if( xAreComTestTasksStillRunning() != pdTRUE )
\r
188 usCheckStatus |= 0x40;
\r
192 /*-----------------------------------------------------------*/
\r
194 /* This is included to prevent link errors - allowing the 'full' version of
\r
195 the comtest tasks to be used. It can be ignored. */
\r
196 void vPrintDisplayMessage( const portCHAR * const * ppcMessageToSend )
\r
198 ( void ) ppcMessageToSend;
\r