]> git.sur5r.net Git - freertos/blob - Demo/WizNET_DEMO_TERN_186/main.c
Remove unnecessary use of portLONG, portCHAR and portSHORT.
[freertos] / Demo / WizNET_DEMO_TERN_186 / main.c
1 /*\r
2     FreeRTOS V6.0.0 - Copyright (C) 2009 Real Time Engineers Ltd.\r
3 \r
4     This file is part of the FreeRTOS distribution.\r
5 \r
6     FreeRTOS is free software; you can redistribute it and/or modify it    under\r
7     the terms of the GNU General Public License (version 2) as published by the\r
8     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 without being obliged to provide the\r
11     source code for proprietary components outside of the FreeRTOS kernel.\r
12     Alternative commercial license and support terms are also available upon\r
13     request.  See the licensing section of http://www.FreeRTOS.org for full\r
14     license details.\r
15 \r
16     FreeRTOS is distributed in the hope that it will be useful,    but WITHOUT\r
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
19     more details.\r
20 \r
21     You should have received a copy of the GNU General Public License along\r
22     with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59\r
23     Temple Place, Suite 330, Boston, MA  02111-1307  USA.\r
24 \r
25 \r
26     ***************************************************************************\r
27     *                                                                         *\r
28     * The FreeRTOS eBook and reference manual are available to purchase for a *\r
29     * small fee. Help yourself get started quickly while also helping the     *\r
30     * FreeRTOS project! See http://www.FreeRTOS.org/Documentation for details *\r
31     *                                                                         *\r
32     ***************************************************************************\r
33 \r
34     1 tab == 4 spaces!\r
35 \r
36     Please ensure to read the configuration and relevant port sections of the\r
37     online documentation.\r
38 \r
39     http://www.FreeRTOS.org - Documentation, latest information, license and\r
40     contact details.\r
41 \r
42     http://www.SafeRTOS.com - A version that is certified for use in safety\r
43     critical systems.\r
44 \r
45     http://www.OpenRTOS.com - Commercial support, development, porting,\r
46     licensing and training services.\r
47 */\r
48 \r
49 /*\r
50  * Creates all the demo application tasks then starts the scheduler.  In \r
51  * addition to the standard demo application tasks main() creates the \r
52  * HTTPServer task, and a "Check" task.  The Check task periodically inspects\r
53  * all the other tasks in the system to see if any errors have been reported.\r
54  * The error status is then displayed on the served WEB page.\r
55  */\r
56 \r
57 /* Tern includes. */\r
58 #include <ae.h>\r
59 #include <embedded.h>\r
60 \r
61 /* FreeRTOS.org includes. */\r
62 #include <FreeRTOS.h>\r
63 #include <task.h>\r
64 \r
65 /* Demo application includes. */\r
66 #include "HTTPTask.h"\r
67 #include "integer.h"\r
68 #include "PollQ.h"\r
69 #include "semtest.h"\r
70 #include "dynamic.h"\r
71 #include "BlockQ.h"\r
72 #include "death.h"\r
73 #include "serial.h"\r
74 #include "comtest.h"\r
75 \r
76 /* How often should the "check" task execute? */\r
77 #define mainCHECK_DELAY         ( 3000 / portTICK_RATE_MS )\r
78 \r
79 /* Priorities allocated to the various tasks. */\r
80 #define mainQUEUE_POLL_PRIORITY         ( tskIDLE_PRIORITY + 2 )\r
81 #define mainCHECK_TASK_PRIORITY         ( tskIDLE_PRIORITY + 4 )\r
82 #define mainSEM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 1 )\r
83 #define mainBLOCK_Q_PRIORITY            ( tskIDLE_PRIORITY + 2 )\r
84 #define mainHTTP_TASK_PRIORITY          ( tskIDLE_PRIORITY + 3 )\r
85 #define mainSUICIDE_TASKS_PRIORITY  ( tskIDLE_PRIORITY + 1 )\r
86 #define mainCOM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 2 )\r
87 \r
88 /* Used to indicate the error status.  A value of 0 means that an error has not\r
89 been detected in any task.  A non zero value indicates which group of demo \r
90 tasks has reported an error.  See prvCheckTask() for bit definitions. */\r
91 unsigned short usCheckStatus = 0;\r
92 \r
93 /*-----------------------------------------------------------*/\r
94 \r
95 /*\r
96  * Setup any hardware required by the demo - other than the RTOS tick which\r
97  * is configured when the scheduler is started.\r
98  */\r
99 static void prvSetupHardware( void );\r
100 \r
101 /*\r
102  * Periodically inspect all the other tasks, updating usCheckStatus should an\r
103  * error be discovered in any task.\r
104  */\r
105 static void prvCheckTask( void *pvParameters );\r
106 /*-----------------------------------------------------------*/\r
107 \r
108 void main(void)\r
109 {\r
110         prvSetupHardware();\r
111 \r
112     /* Start the HTTP server task. */\r
113         xTaskCreate( vHTTPTask, "WizNet", configMINIMAL_STACK_SIZE, NULL, mainHTTP_TASK_PRIORITY, NULL );\r
114 \r
115         /* Start the demo/test application tasks.  See the demo application \r
116         section of the FreeRTOS.org WEB site for more information. */\r
117         vStartIntegerMathTasks( tskIDLE_PRIORITY );\r
118         vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
119         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
120         vStartDynamicPriorityTasks();\r
121         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
122     vStartComTestTasks( mainCOM_TEST_PRIORITY, serCOM2, ser57600 );\r
123 \r
124         /* Start the task that checks the other demo tasks for errors. */\r
125     xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
126 \r
127         /* The suicide tasks must be created last as they monitor the number of\r
128         tasks in the system to ensure there are no more or fewer than expected\r
129         compared to the number that were executing when the task started. */\r
130         vCreateSuicidalTasks( mainSUICIDE_TASKS_PRIORITY );\r
131         \r
132         /* Finally start the scheduler. */\r
133     vTaskStartScheduler();\r
134 \r
135         /* Should not get here! */\r
136         for( ;; );\r
137 }\r
138 /*-----------------------------------------------------------*/\r
139 \r
140 static void prvSetupHardware( void )\r
141 {\r
142         ae_init();\r
143 }\r
144 /*-----------------------------------------------------------*/\r
145 \r
146 static void prvCheckTask( void *pvParameters )\r
147 {\r
148         ( void ) pvParameters;\r
149 \r
150         /* Check all the demo tasks to ensure that they are all still running, and\r
151     that none of them have detected     an error. */\r
152     for( ;; )\r
153     {\r
154                 /* Block until it is time to check again. */\r
155         vTaskDelay( mainCHECK_DELAY );\r
156         \r
157                 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
158                 {\r
159                         usCheckStatus |= 0x01;\r
160                 }\r
161 \r
162                 if( xArePollingQueuesStillRunning() != pdTRUE )\r
163                 {\r
164                         usCheckStatus |= 0x02;\r
165                 }\r
166 \r
167                 if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
168                 {\r
169                         usCheckStatus |= 0x04;\r
170                 }\r
171 \r
172                 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
173                 {\r
174                         usCheckStatus |= 0x08;\r
175                 }\r
176 \r
177                 if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
178                 {\r
179                         usCheckStatus |= 0x10;\r
180                 }\r
181 \r
182         if( xIsCreateTaskStillRunning() != pdTRUE )\r
183         {\r
184                 usCheckStatus |= 0x20;\r
185         }\r
186 \r
187         if( xAreComTestTasksStillRunning() != pdTRUE )\r
188         {\r
189                 usCheckStatus |= 0x40;\r
190         }\r
191         }\r
192 }\r
193 /*-----------------------------------------------------------*/\r
194 \r
195 /* This is included to prevent link errors - allowing the 'full' version of\r
196 the comtest tasks to be used.  It can be ignored. */\r
197 void vPrintDisplayMessage( const char * const * ppcMessageToSend )\r
198 {\r
199         ( void ) ppcMessageToSend;\r
200 }\r
201 \r
202 \r
203 \r
204 \r
205 \r
206 \r
207 \r
208 \r
209 \r
210 \r
211 \r
212 \r