]> git.sur5r.net Git - freertos/blob - Demo/WizNET_DEMO_TERN_186/main.c
Update version number.
[freertos] / Demo / WizNET_DEMO_TERN_186 / main.c
1 /*\r
2         FreeRTOS.org V5.4.0 - Copyright (C) 2003-2009 Richard Barry.\r
3 \r
4         This file is part of the FreeRTOS.org distribution.\r
5 \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
14 \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
18         more details.\r
19 \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
23 \r
24 \r
25         ***************************************************************************\r
26         *                                                                         *\r
27         * Get the FreeRTOS eBook!  See http://www.FreeRTOS.org/Documentation      *\r
28         *                                                                         *\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
33         * .zip file.                                                              *\r
34         *                                                                         *\r
35         ***************************************************************************\r
36 \r
37         1 tab == 4 spaces!\r
38 \r
39         Please ensure to read the configuration and relevant port sections of the\r
40         online documentation.\r
41 \r
42         http://www.FreeRTOS.org - Documentation, latest information, license and\r
43         contact details.\r
44 \r
45         http://www.SafeRTOS.com - A version that is certified for use in safety\r
46         critical systems.\r
47 \r
48         http://www.OpenRTOS.com - Commercial support, development, porting,\r
49         licensing and training services.\r
50 */\r
51 \r
52 /*\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
58  */\r
59 \r
60 /* Tern includes. */\r
61 #include <ae.h>\r
62 #include <embedded.h>\r
63 \r
64 /* FreeRTOS.org includes. */\r
65 #include <FreeRTOS.h>\r
66 #include <task.h>\r
67 \r
68 /* Demo application includes. */\r
69 #include "HTTPTask.h"\r
70 #include "integer.h"\r
71 #include "PollQ.h"\r
72 #include "semtest.h"\r
73 #include "dynamic.h"\r
74 #include "BlockQ.h"\r
75 #include "death.h"\r
76 #include "serial.h"\r
77 #include "comtest.h"\r
78 \r
79 /* How often should the "check" task execute? */\r
80 #define mainCHECK_DELAY         ( 3000 / portTICK_RATE_MS )\r
81 \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
90 \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
95 \r
96 /*-----------------------------------------------------------*/\r
97 \r
98 /*\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
101  */\r
102 static void prvSetupHardware( void );\r
103 \r
104 /*\r
105  * Periodically inspect all the other tasks, updating usCheckStatus should an\r
106  * error be discovered in any task.\r
107  */\r
108 static void prvCheckTask( void *pvParameters );\r
109 /*-----------------------------------------------------------*/\r
110 \r
111 void main(void)\r
112 {\r
113         prvSetupHardware();\r
114 \r
115     /* Start the HTTP server task. */\r
116         xTaskCreate( vHTTPTask, "WizNet", configMINIMAL_STACK_SIZE, NULL, mainHTTP_TASK_PRIORITY, NULL );\r
117 \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
126 \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
129 \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
134         \r
135         /* Finally start the scheduler. */\r
136     vTaskStartScheduler();\r
137 \r
138         /* Should not get here! */\r
139         for( ;; );\r
140 }\r
141 /*-----------------------------------------------------------*/\r
142 \r
143 static void prvSetupHardware( void )\r
144 {\r
145         ae_init();\r
146 }\r
147 /*-----------------------------------------------------------*/\r
148 \r
149 static void prvCheckTask( void *pvParameters )\r
150 {\r
151         ( void ) pvParameters;\r
152 \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
155     for( ;; )\r
156     {\r
157                 /* Block until it is time to check again. */\r
158         vTaskDelay( mainCHECK_DELAY );\r
159         \r
160                 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
161                 {\r
162                         usCheckStatus |= 0x01;\r
163                 }\r
164 \r
165                 if( xArePollingQueuesStillRunning() != pdTRUE )\r
166                 {\r
167                         usCheckStatus |= 0x02;\r
168                 }\r
169 \r
170                 if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
171                 {\r
172                         usCheckStatus |= 0x04;\r
173                 }\r
174 \r
175                 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
176                 {\r
177                         usCheckStatus |= 0x08;\r
178                 }\r
179 \r
180                 if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
181                 {\r
182                         usCheckStatus |= 0x10;\r
183                 }\r
184 \r
185         if( xIsCreateTaskStillRunning() != pdTRUE )\r
186         {\r
187                 usCheckStatus |= 0x20;\r
188         }\r
189 \r
190         if( xAreComTestTasksStillRunning() != pdTRUE )\r
191         {\r
192                 usCheckStatus |= 0x40;\r
193         }\r
194         }\r
195 }\r
196 /*-----------------------------------------------------------*/\r
197 \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
201 {\r
202         ( void ) ppcMessageToSend;\r
203 }\r
204 \r
205 \r
206 \r
207 \r
208 \r
209 \r
210 \r
211 \r
212 \r
213 \r
214 \r
215 \r