2 FreeRTOS V6.0.4 - Copyright (C) 2010 Real Time Engineers Ltd.
\r
4 ***************************************************************************
\r
8 * + New to FreeRTOS, *
\r
9 * + Wanting to learn FreeRTOS or multitasking in general quickly *
\r
10 * + Looking for basic training, *
\r
11 * + Wanting to improve your FreeRTOS skills and productivity *
\r
13 * then take a look at the FreeRTOS eBook *
\r
15 * "Using the FreeRTOS Real Time Kernel - a Practical Guide" *
\r
16 * http://www.FreeRTOS.org/Documentation *
\r
18 * A pdf reference manual is also available. Both are usually delivered *
\r
19 * to your inbox within 20 minutes to two hours when purchased between 8am *
\r
20 * and 8pm GMT (although please allow up to 24 hours in case of *
\r
21 * exceptional circumstances). Thank you for your support! *
\r
23 ***************************************************************************
\r
25 This file is part of the FreeRTOS distribution.
\r
27 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
28 the terms of the GNU General Public License (version 2) as published by the
\r
29 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
30 ***NOTE*** The exception to the GPL is included to allow you to distribute
\r
31 a combined work that includes FreeRTOS without being obliged to provide the
\r
32 source code for proprietary components outside of the FreeRTOS kernel.
\r
33 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
\r
34 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
\r
35 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
36 more details. You should have received a copy of the GNU General Public
\r
37 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
38 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
39 by writing to Richard Barry, contact details for whom are available on the
\r
44 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
47 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
50 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
51 licensing and training services.
\r
55 * Creates all the demo application tasks then starts the scheduler. In
\r
56 * addition to the standard demo application tasks main() creates the
\r
57 * HTTPServer task, and a "Check" task. The Check task periodically inspects
\r
58 * all the other tasks in the system to see if any errors have been reported.
\r
59 * The error status is then displayed on the served WEB page.
\r
62 /* Tern includes. */
\r
64 #include <embedded.h>
\r
66 /* FreeRTOS.org includes. */
\r
67 #include <FreeRTOS.h>
\r
70 /* Demo application includes. */
\r
71 #include "HTTPTask.h"
\r
72 #include "integer.h"
\r
74 #include "semtest.h"
\r
75 #include "dynamic.h"
\r
79 #include "comtest.h"
\r
81 /* How often should the "check" task execute? */
\r
82 #define mainCHECK_DELAY ( 3000 / portTICK_RATE_MS )
\r
84 /* Priorities allocated to the various tasks. */
\r
85 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
86 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
\r
87 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
88 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
89 #define mainHTTP_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
90 #define mainSUICIDE_TASKS_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
91 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
93 /* Used to indicate the error status. A value of 0 means that an error has not
\r
94 been detected in any task. A non zero value indicates which group of demo
\r
95 tasks has reported an error. See prvCheckTask() for bit definitions. */
\r
96 unsigned short usCheckStatus = 0;
\r
98 /*-----------------------------------------------------------*/
\r
101 * Setup any hardware required by the demo - other than the RTOS tick which
\r
102 * is configured when the scheduler is started.
\r
104 static void prvSetupHardware( void );
\r
107 * Periodically inspect all the other tasks, updating usCheckStatus should an
\r
108 * error be discovered in any task.
\r
110 static void prvCheckTask( void *pvParameters );
\r
111 /*-----------------------------------------------------------*/
\r
115 prvSetupHardware();
\r
117 /* Start the HTTP server task. */
\r
118 xTaskCreate( vHTTPTask, "WizNet", configMINIMAL_STACK_SIZE, NULL, mainHTTP_TASK_PRIORITY, NULL );
\r
120 /* Start the demo/test application tasks. See the demo application
\r
121 section of the FreeRTOS.org WEB site for more information. */
\r
122 vStartIntegerMathTasks( tskIDLE_PRIORITY );
\r
123 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
124 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
125 vStartDynamicPriorityTasks();
\r
126 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
127 vStartComTestTasks( mainCOM_TEST_PRIORITY, serCOM2, ser57600 );
\r
129 /* Start the task that checks the other demo tasks for errors. */
\r
130 xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
132 /* The suicide tasks must be created last as they monitor the number of
\r
133 tasks in the system to ensure there are no more or fewer than expected
\r
134 compared to the number that were executing when the task started. */
\r
135 vCreateSuicidalTasks( mainSUICIDE_TASKS_PRIORITY );
\r
137 /* Finally start the scheduler. */
\r
138 vTaskStartScheduler();
\r
140 /* Should not get here! */
\r
143 /*-----------------------------------------------------------*/
\r
145 static void prvSetupHardware( void )
\r
149 /*-----------------------------------------------------------*/
\r
151 static void prvCheckTask( void *pvParameters )
\r
153 ( void ) pvParameters;
\r
155 /* Check all the demo tasks to ensure that they are all still running, and
\r
156 that none of them have detected an error. */
\r
159 /* Block until it is time to check again. */
\r
160 vTaskDelay( mainCHECK_DELAY );
\r
162 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
164 usCheckStatus |= 0x01;
\r
167 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
169 usCheckStatus |= 0x02;
\r
172 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
174 usCheckStatus |= 0x04;
\r
177 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
\r
179 usCheckStatus |= 0x08;
\r
182 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
184 usCheckStatus |= 0x10;
\r
187 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
189 usCheckStatus |= 0x20;
\r
192 if( xAreComTestTasksStillRunning() != pdTRUE )
\r
194 usCheckStatus |= 0x40;
\r
198 /*-----------------------------------------------------------*/
\r
200 /* This is included to prevent link errors - allowing the 'full' version of
\r
201 the comtest tasks to be used. It can be ignored. */
\r
202 void vPrintDisplayMessage( const char * const * ppcMessageToSend )
\r
204 ( void ) ppcMessageToSend;
\r