2 FreeRTOS.org V5.4.0 - 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 it
\r
7 under the terms of the GNU General Public License (version 2) as published
\r
8 by the 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.org without being obliged to provide
\r
11 the source code for any proprietary components. Alternative commercial
\r
12 license and support terms are also available upon request. See the
\r
13 licensing section of http://www.FreeRTOS.org for full details.
\r
15 FreeRTOS.org is distributed in the hope that it will be useful, but WITHOUT
\r
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
\r
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
20 You should have received a copy of the GNU General Public License along
\r
21 with FreeRTOS.org; if not, write to the Free Software Foundation, Inc., 59
\r
22 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
\r
25 ***************************************************************************
\r
27 * Get the FreeRTOS eBook! See http://www.FreeRTOS.org/Documentation *
\r
29 * This is a concise, step by step, 'hands on' guide that describes both *
\r
30 * general multitasking concepts and FreeRTOS specifics. It presents and *
\r
31 * explains numerous examples that are written using the FreeRTOS API. *
\r
32 * Full source code for all the examples is provided in an accompanying *
\r
35 ***************************************************************************
\r
39 Please ensure to read the configuration and relevant port sections of the
\r
40 online documentation.
\r
42 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
45 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
48 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
49 licensing and training services.
\r
53 * Creates all the demo application tasks then starts the scheduler. In
\r
54 * addition to the standard demo application tasks main() creates the
\r
55 * HTTPServer task, and a "Check" task. The Check task periodically inspects
\r
56 * all the other tasks in the system to see if any errors have been reported.
\r
57 * The error status is then displayed on the served WEB page.
\r
60 /* Tern includes. */
\r
62 #include <embedded.h>
\r
64 /* FreeRTOS.org includes. */
\r
65 #include <FreeRTOS.h>
\r
68 /* Demo application includes. */
\r
69 #include "HTTPTask.h"
\r
70 #include "integer.h"
\r
72 #include "semtest.h"
\r
73 #include "dynamic.h"
\r
77 #include "comtest.h"
\r
79 /* How often should the "check" task execute? */
\r
80 #define mainCHECK_DELAY ( 3000 / portTICK_RATE_MS )
\r
82 /* Priorities allocated to the various tasks. */
\r
83 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
84 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
\r
85 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
86 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
87 #define mainHTTP_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
88 #define mainSUICIDE_TASKS_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
89 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
91 /* Used to indicate the error status. A value of 0 means that an error has not
\r
92 been detected in any task. A non zero value indicates which group of demo
\r
93 tasks has reported an error. See prvCheckTask() for bit definitions. */
\r
94 unsigned portSHORT usCheckStatus = 0;
\r
96 /*-----------------------------------------------------------*/
\r
99 * Setup any hardware required by the demo - other than the RTOS tick which
\r
100 * is configured when the scheduler is started.
\r
102 static void prvSetupHardware( void );
\r
105 * Periodically inspect all the other tasks, updating usCheckStatus should an
\r
106 * error be discovered in any task.
\r
108 static void prvCheckTask( void *pvParameters );
\r
109 /*-----------------------------------------------------------*/
\r
113 prvSetupHardware();
\r
115 /* Start the HTTP server task. */
\r
116 xTaskCreate( vHTTPTask, "WizNet", configMINIMAL_STACK_SIZE, NULL, mainHTTP_TASK_PRIORITY, NULL );
\r
118 /* Start the demo/test application tasks. See the demo application
\r
119 section of the FreeRTOS.org WEB site for more information. */
\r
120 vStartIntegerMathTasks( tskIDLE_PRIORITY );
\r
121 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
122 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
123 vStartDynamicPriorityTasks();
\r
124 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
125 vStartComTestTasks( mainCOM_TEST_PRIORITY, serCOM2, ser57600 );
\r
127 /* Start the task that checks the other demo tasks for errors. */
\r
128 xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
130 /* The suicide tasks must be created last as they monitor the number of
\r
131 tasks in the system to ensure there are no more or fewer than expected
\r
132 compared to the number that were executing when the task started. */
\r
133 vCreateSuicidalTasks( mainSUICIDE_TASKS_PRIORITY );
\r
135 /* Finally start the scheduler. */
\r
136 vTaskStartScheduler();
\r
138 /* Should not get here! */
\r
141 /*-----------------------------------------------------------*/
\r
143 static void prvSetupHardware( void )
\r
147 /*-----------------------------------------------------------*/
\r
149 static void prvCheckTask( void *pvParameters )
\r
151 ( void ) pvParameters;
\r
153 /* Check all the demo tasks to ensure that they are all still running, and
\r
154 that none of them have detected an error. */
\r
157 /* Block until it is time to check again. */
\r
158 vTaskDelay( mainCHECK_DELAY );
\r
160 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
162 usCheckStatus |= 0x01;
\r
165 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
167 usCheckStatus |= 0x02;
\r
170 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
172 usCheckStatus |= 0x04;
\r
175 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
\r
177 usCheckStatus |= 0x08;
\r
180 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
182 usCheckStatus |= 0x10;
\r
185 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
187 usCheckStatus |= 0x20;
\r
190 if( xAreComTestTasksStillRunning() != pdTRUE )
\r
192 usCheckStatus |= 0x40;
\r
196 /*-----------------------------------------------------------*/
\r
198 /* This is included to prevent link errors - allowing the 'full' version of
\r
199 the comtest tasks to be used. It can be ignored. */
\r
200 void vPrintDisplayMessage( const portCHAR * const * ppcMessageToSend )
\r
202 ( void ) ppcMessageToSend;
\r