2 FreeRTOS V7.2.0 - Copyright (C) 2012 Real Time Engineers Ltd.
\r
5 ***************************************************************************
\r
7 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
8 * Complete, revised, and edited pdf reference manuals are also *
\r
11 * Purchasing FreeRTOS documentation will not only help you, by *
\r
12 * ensuring you get running as quickly as possible and with an *
\r
13 * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
14 * the FreeRTOS project to continue with its mission of providing *
\r
15 * professional grade, cross platform, de facto standard solutions *
\r
16 * for microcontrollers - completely free of charge! *
\r
18 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
20 * Thank you for using FreeRTOS, and thank you for your support! *
\r
22 ***************************************************************************
\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 modification to the GPL is included to allow you to
\r
31 distribute a combined work that includes FreeRTOS without being obliged to
\r
32 provide the source code for proprietary components outside of the FreeRTOS
\r
33 kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
34 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
35 or 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 ***************************************************************************
\r
46 * Having a problem? Start by reading the FAQ "My application does *
\r
47 * not run, what could be wrong? *
\r
49 * http://www.FreeRTOS.org/FAQHelp.html *
\r
51 ***************************************************************************
\r
54 http://www.FreeRTOS.org - Documentation, training, latest information,
\r
55 license and contact details.
\r
57 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
58 including FreeRTOS+Trace - an indispensable productivity tool.
\r
60 Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
\r
61 the code with commercial support, indemnification, and middleware, under
\r
62 the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
\r
63 provide a safety engineered and independently SIL3 certified version under
\r
64 the SafeRTOS brand: http://www.SafeRTOS.com.
\r
68 * Creates all the demo application tasks then starts the scheduler. In
\r
69 * addition to the standard demo application tasks main() creates the
\r
70 * HTTPServer task, and a "Check" task. The Check task periodically inspects
\r
71 * all the other tasks in the system to see if any errors have been reported.
\r
72 * The error status is then displayed on the served WEB page.
\r
75 /* Tern includes. */
\r
77 #include <embedded.h>
\r
79 /* FreeRTOS.org includes. */
\r
80 #include <FreeRTOS.h>
\r
83 /* Demo application includes. */
\r
84 #include "HTTPTask.h"
\r
85 #include "integer.h"
\r
87 #include "semtest.h"
\r
88 #include "dynamic.h"
\r
92 #include "comtest.h"
\r
94 /* How often should the "check" task execute? */
\r
95 #define mainCHECK_DELAY ( 3000 / portTICK_RATE_MS )
\r
97 /* Priorities allocated to the various tasks. */
\r
98 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
99 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
\r
100 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
101 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
102 #define mainHTTP_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
103 #define mainSUICIDE_TASKS_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
104 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
106 /* Used to indicate the error status. A value of 0 means that an error has not
\r
107 been detected in any task. A non zero value indicates which group of demo
\r
108 tasks has reported an error. See prvCheckTask() for bit definitions. */
\r
109 unsigned short usCheckStatus = 0;
\r
111 /*-----------------------------------------------------------*/
\r
114 * Setup any hardware required by the demo - other than the RTOS tick which
\r
115 * is configured when the scheduler is started.
\r
117 static void prvSetupHardware( void );
\r
120 * Periodically inspect all the other tasks, updating usCheckStatus should an
\r
121 * error be discovered in any task.
\r
123 static void prvCheckTask( void *pvParameters );
\r
124 /*-----------------------------------------------------------*/
\r
128 prvSetupHardware();
\r
130 /* Start the HTTP server task. */
\r
131 xTaskCreate( vHTTPTask, "WizNet", configMINIMAL_STACK_SIZE, NULL, mainHTTP_TASK_PRIORITY, NULL );
\r
133 /* Start the demo/test application tasks. See the demo application
\r
134 section of the FreeRTOS.org WEB site for more information. */
\r
135 vStartIntegerMathTasks( tskIDLE_PRIORITY );
\r
136 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
137 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
138 vStartDynamicPriorityTasks();
\r
139 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
140 vStartComTestTasks( mainCOM_TEST_PRIORITY, serCOM2, ser57600 );
\r
142 /* Start the task that checks the other demo tasks for errors. */
\r
143 xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
145 /* The suicide tasks must be created last as they monitor the number of
\r
146 tasks in the system to ensure there are no more or fewer than expected
\r
147 compared to the number that were executing when the task started. */
\r
148 vCreateSuicidalTasks( mainSUICIDE_TASKS_PRIORITY );
\r
150 /* Finally start the scheduler. */
\r
151 vTaskStartScheduler();
\r
153 /* Should not get here! */
\r
156 /*-----------------------------------------------------------*/
\r
158 static void prvSetupHardware( void )
\r
162 /*-----------------------------------------------------------*/
\r
164 static void prvCheckTask( void *pvParameters )
\r
166 ( void ) pvParameters;
\r
168 /* Check all the demo tasks to ensure that they are all still running, and
\r
169 that none of them have detected an error. */
\r
172 /* Block until it is time to check again. */
\r
173 vTaskDelay( mainCHECK_DELAY );
\r
175 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
177 usCheckStatus |= 0x01;
\r
180 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
182 usCheckStatus |= 0x02;
\r
185 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
187 usCheckStatus |= 0x04;
\r
190 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
\r
192 usCheckStatus |= 0x08;
\r
195 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
197 usCheckStatus |= 0x10;
\r
200 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
202 usCheckStatus |= 0x20;
\r
205 if( xAreComTestTasksStillRunning() != pdTRUE )
\r
207 usCheckStatus |= 0x40;
\r
211 /*-----------------------------------------------------------*/
\r
213 /* This is included to prevent link errors - allowing the 'full' version of
\r
214 the comtest tasks to be used. It can be ignored. */
\r
215 void vPrintDisplayMessage( const char * const * ppcMessageToSend )
\r
217 ( void ) ppcMessageToSend;
\r