]> git.sur5r.net Git - freertos/blob - Demo/ARM7_LPC2368_Rowley/main.c
Remove incorrect comment.
[freertos] / Demo / ARM7_LPC2368_Rowley / main.c
1 /*\r
2         FreeRTOS.org V4.7.0 - Copyright (C) 2003-2007 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\r
7         it under the terms of the GNU General Public License as published by\r
8         the Free Software Foundation; either version 2 of the License, or\r
9         (at your option) any later version.\r
10 \r
11         FreeRTOS.org is distributed in the hope that it will be useful,\r
12         but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14         GNU General Public License for more details.\r
15 \r
16         You should have received a copy of the GNU General Public License\r
17         along with FreeRTOS.org; if not, write to the Free Software\r
18         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
19 \r
20         A special exception to the GPL can be applied should you wish to distribute\r
21         a combined work that includes FreeRTOS.org, without being obliged to provide\r
22         the source code for any proprietary components.  See the licensing section \r
23         of http://www.FreeRTOS.org for full details of how and when the exception\r
24         can be applied.\r
25 \r
26         ***************************************************************************\r
27         See http://www.FreeRTOS.org for documentation, latest information, license \r
28         and contact details.  Please ensure to read the configuration and relevant \r
29         port sections of the online documentation.\r
30 \r
31         Also see http://www.SafeRTOS.com a version that has been certified for use\r
32         in safety critical systems, plus commercial licensing, development and\r
33         support options.\r
34         ***************************************************************************\r
35 */\r
36 \r
37 /* Environment includes. */\r
38 #include <targets/LPC2368.h>\r
39 \r
40 /* Scheduler includes. */\r
41 #include "FreeRTOS.h"\r
42 #include "Task.h"\r
43 #include "queue.h"\r
44 #include "semphr.h"\r
45 \r
46 /* Demo app includes. */\r
47 #include "BlockQ.h"\r
48 #include "death.h"\r
49 #include "integer.h"\r
50 #include "blocktim.h"\r
51 #include "portlcd.h"\r
52 #include "flash.h"\r
53 #include "partest.h"\r
54 #include "semtest.h"\r
55 #include "pollq.h"\r
56 \r
57 /* Demo application definitions. */\r
58 #define mainQUEUE_SIZE                                          ( 3 )\r
59 #define mainCHECK_DELAY                                         ( ( portTickType ) 5000 / portTICK_RATE_MS )\r
60 #define mainBASIC_WEB_STACK_SIZE            ( configMINIMAL_STACK_SIZE * 2 )\r
61 \r
62 /* Task priorities. */\r
63 #define mainQUEUE_POLL_PRIORITY                         ( tskIDLE_PRIORITY + 2 )\r
64 #define mainCHECK_TASK_PRIORITY                         ( tskIDLE_PRIORITY + 3 )\r
65 #define mainSEM_TEST_PRIORITY                           ( tskIDLE_PRIORITY + 1 )\r
66 #define mainBLOCK_Q_PRIORITY                            ( tskIDLE_PRIORITY + 2 )\r
67 #define mainFLASH_PRIORITY                  ( tskIDLE_PRIORITY + 2 )\r
68 #define mainCREATOR_TASK_PRIORITY           ( tskIDLE_PRIORITY + 3 )\r
69 #define mainINTEGER_TASK_PRIORITY           ( tskIDLE_PRIORITY )\r
70 \r
71 \r
72 /*\r
73  * Checks the status of all the demo tasks then prints a message to the\r
74  * CrossStudio terminal IO windows.  The message will be either PASS or FAIL\r
75  * depending on the status of the demo applications tasks.  A FAIL status will\r
76  * be latched.\r
77  *\r
78  * Messages are not written directly to the terminal, but passed to vPrintTask\r
79  * via a queue.\r
80  */\r
81 static void vCheckTask( void *pvParameters );\r
82 \r
83 /* \r
84  * The task that handles the uIP stack.  All TCP/IP processing is performed in\r
85  * this task.\r
86  */\r
87 extern void vuIP_Task( void *pvParameters );\r
88 \r
89 /*\r
90  * The LCD is written two by more than one task so is controlled by a \r
91  * 'gatekeeper' task.  This is the only task that is actually permitted to \r
92  * access the LCD directly.  Other tasks wanting to display a message send\r
93  * the message to the gatekeeper.\r
94  */\r
95 static void vLCDTask( void *pvParameters );\r
96 \r
97 /* The queue used to send messages to the LCD task. */\r
98 xQueueHandle xLCDQueue;\r
99 \r
100 /*-----------------------------------------------------------*/\r
101 \r
102 int main (void)\r
103 {\r
104         /* Setup the led's on the MCB2300 board */\r
105         vParTestInitialise();\r
106 \r
107         /* Create the queue used by the LCD task.  Messages for display on the LCD\r
108         are received via this queue. */\r
109         xLCDQueue = xQueueCreate( mainQUEUE_SIZE, sizeof( xLCDMessage ) );\r
110 \r
111         /* Create the lwIP task.  This uses the lwIP RTOS abstraction layer.*/\r
112     xTaskCreate( vuIP_Task, ( signed portCHAR * ) "uIP", mainBASIC_WEB_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );\r
113 \r
114         /* Start the standard demo tasks. */\r
115         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
116     vCreateBlockTimeTasks();\r
117     vStartLEDFlashTasks( mainFLASH_PRIORITY );\r
118     vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
119     vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
120     vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );\r
121 \r
122         /* Start the tasks defined within this file/specific to this demo. */\r
123     xTaskCreate( vCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
124         xTaskCreate( vLCDTask, ( signed portCHAR * ) "LCD", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );\r
125 \r
126         /* The suicide tasks must be created last as they need to know how many\r
127         tasks were running prior to their creation in order to ascertain whether\r
128         or not the correct/expected number of tasks are running at any given time. */\r
129     vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
130 \r
131         /* Start the scheduler. */\r
132         vTaskStartScheduler();\r
133 \r
134     /* Will only get here if there was insufficient memory to create the idle\r
135     task. */\r
136         return 0; \r
137 }\r
138 /*-----------------------------------------------------------*/\r
139 \r
140 static void vCheckTask( void *pvParameters )\r
141 {\r
142 portBASE_TYPE xErrorOccurred = pdFALSE;\r
143 portTickType xLastExecutionTime;\r
144 unsigned portBASE_TYPE uxColumn = 0;\r
145 xLCDMessage xMessage;\r
146 \r
147         xLastExecutionTime = xTaskGetTickCount();\r
148 \r
149         xMessage.xColumn = 0;\r
150         xMessage.pcMessage = "PASS";\r
151 \r
152     for( ;; )\r
153         {\r
154                 /* Perform this check every mainCHECK_DELAY milliseconds. */\r
155                 vTaskDelayUntil( &xLastExecutionTime, mainCHECK_DELAY );\r
156 \r
157                 /* Has an error been found in any task? */\r
158 \r
159         if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
160                 {\r
161                         xErrorOccurred = pdTRUE;\r
162                 }\r
163 \r
164                 if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
165                 {\r
166                         xErrorOccurred = pdTRUE;\r
167                 }\r
168 \r
169         if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
170         {\r
171             xErrorOccurred = pdTRUE;\r
172         }\r
173 \r
174         if( xArePollingQueuesStillRunning() != pdTRUE )\r
175         {\r
176             xErrorOccurred = pdTRUE;\r
177         }\r
178 \r
179         if( xIsCreateTaskStillRunning() != pdTRUE )\r
180         {\r
181             xErrorOccurred = pdTRUE;\r
182         }\r
183 \r
184         if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
185         {\r
186             xErrorOccurred = pdTRUE;\r
187         }\r
188 \r
189         LCD_cls();\r
190         xMessage.xColumn++;\r
191         LCD_gotoxy( ( uxColumn & 0x07 ) + 1, ( uxColumn & 0x01 ) + 1 );\r
192 \r
193         if( xErrorOccurred == pdTRUE )\r
194         {\r
195             xMessage.pcMessage = "FAIL";\r
196         }\r
197 \r
198                 /* Send the message to the LCD gatekeeper for display. */\r
199                 xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY );\r
200         }\r
201 }\r
202 /*-----------------------------------------------------------*/\r
203 \r
204 void vLCDTask( void *pvParameters )\r
205 {\r
206 xLCDMessage xMessage;\r
207 \r
208         /* Initialise the LCD and display a startup message. */\r
209         LCD_init();\r
210         LCD_cur_off();\r
211     LCD_cls();    \r
212     LCD_gotoxy( 1, 1 );\r
213     LCD_puts( ( signed portCHAR * ) "www.FreeRTOS.org" );\r
214 \r
215         for( ;; )\r
216         {\r
217                 /* Wait for a message to arrive that requires displaying. */\r
218                 while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS );\r
219                 \r
220                 /* Display the message.  Print each message to a different position. */\r
221                 LCD_cls();\r
222                 LCD_gotoxy( ( xMessage.xColumn & 0x07 ) + 1, ( xMessage.xColumn & 0x01 ) + 1 );\r
223                 LCD_puts( xMessage.pcMessage );\r
224         }\r
225 \r
226 }\r
227 /*-----------------------------------------------------------*/\r
228 \r
229 /* Keep the compiler quiet. */\r
230 #include <stdio.h>\r
231 int __putchar( int c )\r
232 {\r
233     return EOF;\r
234 }\r
235 \r
236 \r
237 \r
238 \r
239 \r