]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/WizNET_DEMO_TERN_186/main.c
Update version number ready for version 9 release candidate 1.
[freertos] / FreeRTOS / Demo / WizNET_DEMO_TERN_186 / main.c
1 /*\r
2     FreeRTOS V9.0.0rc1 - Copyright (C) 2016 Real Time Engineers Ltd.\r
3     All rights reserved\r
4 \r
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     This file is part of the FreeRTOS distribution.\r
8 \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
12 \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
19 \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
24 \r
25     ***************************************************************************\r
26      *                                                                       *\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
31      *                                                                       *\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
36      *                                                                       *\r
37     ***************************************************************************\r
38 \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
42 \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
46 \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
51 \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
55 \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
58 \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
62 \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
66 \r
67     1 tab == 4 spaces!\r
68 */\r
69 \r
70 /*\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
76  */\r
77 \r
78 /* Tern includes. */\r
79 #include <ae.h>\r
80 #include <embedded.h>\r
81 \r
82 /* FreeRTOS.org includes. */\r
83 #include <FreeRTOS.h>\r
84 #include <task.h>\r
85 \r
86 /* Demo application includes. */\r
87 #include "HTTPTask.h"\r
88 #include "integer.h"\r
89 #include "PollQ.h"\r
90 #include "semtest.h"\r
91 #include "dynamic.h"\r
92 #include "BlockQ.h"\r
93 #include "death.h"\r
94 #include "serial.h"\r
95 #include "comtest.h"\r
96 \r
97 /* How often should the "check" task execute? */\r
98 #define mainCHECK_DELAY         ( 3000 / portTICK_PERIOD_MS )\r
99 \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
108 \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
113 \r
114 /*-----------------------------------------------------------*/\r
115 \r
116 /*\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
119  */\r
120 static void prvSetupHardware( void );\r
121 \r
122 /*\r
123  * Periodically inspect all the other tasks, updating usCheckStatus should an\r
124  * error be discovered in any task.\r
125  */\r
126 static void prvCheckTask( void *pvParameters );\r
127 /*-----------------------------------------------------------*/\r
128 \r
129 void main(void)\r
130 {\r
131         prvSetupHardware();\r
132 \r
133     /* Start the HTTP server task. */\r
134         xTaskCreate( vHTTPTask, "WizNet", configMINIMAL_STACK_SIZE, NULL, mainHTTP_TASK_PRIORITY, NULL );\r
135 \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
144 \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
147 \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
152         \r
153         /* Finally start the scheduler. */\r
154     vTaskStartScheduler();\r
155 \r
156         /* Should not get here! */\r
157         for( ;; );\r
158 }\r
159 /*-----------------------------------------------------------*/\r
160 \r
161 static void prvSetupHardware( void )\r
162 {\r
163         ae_init();\r
164 }\r
165 /*-----------------------------------------------------------*/\r
166 \r
167 static void prvCheckTask( void *pvParameters )\r
168 {\r
169         ( void ) pvParameters;\r
170 \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
173     for( ;; )\r
174     {\r
175                 /* Block until it is time to check again. */\r
176         vTaskDelay( mainCHECK_DELAY );\r
177         \r
178                 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
179                 {\r
180                         usCheckStatus |= 0x01;\r
181                 }\r
182 \r
183                 if( xArePollingQueuesStillRunning() != pdTRUE )\r
184                 {\r
185                         usCheckStatus |= 0x02;\r
186                 }\r
187 \r
188                 if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
189                 {\r
190                         usCheckStatus |= 0x04;\r
191                 }\r
192 \r
193                 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
194                 {\r
195                         usCheckStatus |= 0x08;\r
196                 }\r
197 \r
198                 if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
199                 {\r
200                         usCheckStatus |= 0x10;\r
201                 }\r
202 \r
203         if( xIsCreateTaskStillRunning() != pdTRUE )\r
204         {\r
205                 usCheckStatus |= 0x20;\r
206         }\r
207 \r
208         if( xAreComTestTasksStillRunning() != pdTRUE )\r
209         {\r
210                 usCheckStatus |= 0x40;\r
211         }\r
212         }\r
213 }\r
214 /*-----------------------------------------------------------*/\r
215 \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
219 {\r
220         ( void ) ppcMessageToSend;\r
221 }\r
222 \r
223 \r
224 \r
225 \r
226 \r
227 \r
228 \r
229 \r
230 \r
231 \r
232 \r
233 \r