2 FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 This file is part of the FreeRTOS distribution.
\r
9 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
10 the terms of the GNU General Public License (version 2) as published by the
\r
11 Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
\r
13 ***************************************************************************
\r
14 >>! NOTE: The modification to the GPL is included to allow you to !<<
\r
15 >>! distribute a combined work that includes FreeRTOS without being !<<
\r
16 >>! obliged to provide the source code for proprietary components !<<
\r
17 >>! outside of the FreeRTOS kernel. !<<
\r
18 ***************************************************************************
\r
20 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
21 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
22 FOR A PARTICULAR PURPOSE. Full license text is available on the following
\r
23 link: http://www.freertos.org/a00114.html
\r
25 ***************************************************************************
\r
27 * FreeRTOS provides completely free yet professionally developed, *
\r
28 * robust, strictly quality controlled, supported, and cross *
\r
29 * platform software that is more than just the market leader, it *
\r
30 * is the industry's de facto standard. *
\r
32 * Help yourself get started quickly while simultaneously helping *
\r
33 * to support the FreeRTOS project by purchasing a FreeRTOS *
\r
34 * tutorial book, reference manual, or both: *
\r
35 * http://www.FreeRTOS.org/Documentation *
\r
37 ***************************************************************************
\r
39 http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
\r
40 the FAQ page "My application does not run, what could be wrong?". Have you
\r
41 defined configASSERT()?
\r
43 http://www.FreeRTOS.org/support - In return for receiving this top quality
\r
44 embedded software for free we request you assist our global community by
\r
45 participating in the support forum.
\r
47 http://www.FreeRTOS.org/training - Investing in training allows your team to
\r
48 be as productive as possible as early as possible. Now you can receive
\r
49 FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
\r
50 Ltd, and the world's leading authority on the world's leading RTOS.
\r
52 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
53 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
54 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
56 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
\r
57 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
\r
59 http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
\r
60 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
61 licenses offer ticketed support, indemnification and commercial middleware.
\r
63 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
64 engineered and independently SIL3 certified version for use in safety and
\r
65 mission critical applications that require provable dependability.
\r
71 * Creates all the demo application tasks then starts the scheduler. In
\r
72 * addition to the standard demo application tasks main() creates the
\r
73 * HTTPServer task, and a "Check" task. The Check task periodically inspects
\r
74 * all the other tasks in the system to see if any errors have been reported.
\r
75 * The error status is then displayed on the served WEB page.
\r
78 /* Tern includes. */
\r
80 #include <embedded.h>
\r
82 /* FreeRTOS.org includes. */
\r
83 #include <FreeRTOS.h>
\r
86 /* Demo application includes. */
\r
87 #include "HTTPTask.h"
\r
88 #include "integer.h"
\r
90 #include "semtest.h"
\r
91 #include "dynamic.h"
\r
95 #include "comtest.h"
\r
97 /* How often should the "check" task execute? */
\r
98 #define mainCHECK_DELAY ( 3000 / portTICK_PERIOD_MS )
\r
100 /* Priorities allocated to the various tasks. */
\r
101 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
102 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )
\r
103 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
104 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
105 #define mainHTTP_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
106 #define mainSUICIDE_TASKS_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
107 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
109 /* Used to indicate the error status. A value of 0 means that an error has not
\r
110 been detected in any task. A non zero value indicates which group of demo
\r
111 tasks has reported an error. See prvCheckTask() for bit definitions. */
\r
112 unsigned short usCheckStatus = 0;
\r
114 /*-----------------------------------------------------------*/
\r
117 * Setup any hardware required by the demo - other than the RTOS tick which
\r
118 * is configured when the scheduler is started.
\r
120 static void prvSetupHardware( void );
\r
123 * Periodically inspect all the other tasks, updating usCheckStatus should an
\r
124 * error be discovered in any task.
\r
126 static void prvCheckTask( void *pvParameters );
\r
127 /*-----------------------------------------------------------*/
\r
131 prvSetupHardware();
\r
133 /* Start the HTTP server task. */
\r
134 xTaskCreate( vHTTPTask, "WizNet", configMINIMAL_STACK_SIZE, NULL, mainHTTP_TASK_PRIORITY, NULL );
\r
136 /* Start the demo/test application tasks. See the demo application
\r
137 section of the FreeRTOS.org WEB site for more information. */
\r
138 vStartIntegerMathTasks( tskIDLE_PRIORITY );
\r
139 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
140 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
141 vStartDynamicPriorityTasks();
\r
142 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
143 vStartComTestTasks( mainCOM_TEST_PRIORITY, serCOM2, ser57600 );
\r
145 /* Start the task that checks the other demo tasks for errors. */
\r
146 xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
148 /* The suicide tasks must be created last as they monitor the number of
\r
149 tasks in the system to ensure there are no more or fewer than expected
\r
150 compared to the number that were executing when the task started. */
\r
151 vCreateSuicidalTasks( mainSUICIDE_TASKS_PRIORITY );
\r
153 /* Finally start the scheduler. */
\r
154 vTaskStartScheduler();
\r
156 /* Should not get here! */
\r
159 /*-----------------------------------------------------------*/
\r
161 static void prvSetupHardware( void )
\r
165 /*-----------------------------------------------------------*/
\r
167 static void prvCheckTask( void *pvParameters )
\r
169 ( void ) pvParameters;
\r
171 /* Check all the demo tasks to ensure that they are all still running, and
\r
172 that none of them have detected an error. */
\r
175 /* Block until it is time to check again. */
\r
176 vTaskDelay( mainCHECK_DELAY );
\r
178 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
180 usCheckStatus |= 0x01;
\r
183 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
185 usCheckStatus |= 0x02;
\r
188 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
190 usCheckStatus |= 0x04;
\r
193 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
\r
195 usCheckStatus |= 0x08;
\r
198 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
200 usCheckStatus |= 0x10;
\r
203 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
205 usCheckStatus |= 0x20;
\r
208 if( xAreComTestTasksStillRunning() != pdTRUE )
\r
210 usCheckStatus |= 0x40;
\r
214 /*-----------------------------------------------------------*/
\r
216 /* This is included to prevent link errors - allowing the 'full' version of
\r
217 the comtest tasks to be used. It can be ignored. */
\r
218 void vPrintDisplayMessage( const char * const * ppcMessageToSend )
\r
220 ( void ) ppcMessageToSend;
\r