2 FreeRTOS.org V4.8.0 - Copyright (C) 2003-2008 Richard Barry.
\r
4 This file is part of the FreeRTOS.org distribution.
\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
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
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
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
26 ***************************************************************************
\r
27 ***************************************************************************
\r
29 * SAVE TIME AND MONEY! Why not get us to quote to get FreeRTOS.org *
\r
30 * running on your hardware - or even write all or part of your application*
\r
31 * for you? See http://www.OpenRTOS.com for details. *
\r
33 ***************************************************************************
\r
34 ***************************************************************************
\r
36 Please ensure to read the configuration and relevant port sections of the
\r
37 online documentation.
\r
39 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
42 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
45 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
46 licensing and training services.
\r
49 /* Environment includes. */
\r
50 #include <targets/LPC2368.h>
\r
52 /* Scheduler includes. */
\r
53 #include "FreeRTOS.h"
\r
58 /* Demo app includes. */
\r
61 #include "integer.h"
\r
62 #include "blocktim.h"
\r
63 #include "portlcd.h"
\r
65 #include "partest.h"
\r
66 #include "semtest.h"
\r
69 /* Demo application definitions. */
\r
70 #define mainQUEUE_SIZE ( 3 )
\r
71 #define mainCHECK_DELAY ( ( portTickType ) 5000 / portTICK_RATE_MS )
\r
72 #define mainBASIC_WEB_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 )
\r
74 /* Task priorities. */
\r
75 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
76 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
77 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
78 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
79 #define mainFLASH_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
80 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
81 #define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
85 * Checks the status of all the demo tasks then prints a message to the
\r
86 * CrossStudio terminal IO windows. The message will be either PASS or FAIL
\r
87 * depending on the status of the demo applications tasks. A FAIL status will
\r
90 * Messages are not written directly to the terminal, but passed to vPrintTask
\r
93 static void vCheckTask( void *pvParameters );
\r
96 * The task that handles the uIP stack. All TCP/IP processing is performed in
\r
99 extern void vuIP_Task( void *pvParameters );
\r
102 * The LCD is written two by more than one task so is controlled by a
\r
103 * 'gatekeeper' task. This is the only task that is actually permitted to
\r
104 * access the LCD directly. Other tasks wanting to display a message send
\r
105 * the message to the gatekeeper.
\r
107 static void vLCDTask( void *pvParameters );
\r
109 /* The queue used to send messages to the LCD task. */
\r
110 xQueueHandle xLCDQueue;
\r
112 /*-----------------------------------------------------------*/
\r
116 /* Setup the led's on the MCB2300 board */
\r
117 vParTestInitialise();
\r
119 /* Create the queue used by the LCD task. Messages for display on the LCD
\r
120 are received via this queue. */
\r
121 xLCDQueue = xQueueCreate( mainQUEUE_SIZE, sizeof( xLCDMessage ) );
\r
123 /* Create the lwIP task. This uses the lwIP RTOS abstraction layer.*/
\r
124 xTaskCreate( vuIP_Task, ( signed portCHAR * ) "uIP", mainBASIC_WEB_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
\r
126 /* Start the standard demo tasks. */
\r
127 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
128 vCreateBlockTimeTasks();
\r
129 vStartLEDFlashTasks( mainFLASH_PRIORITY );
\r
130 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
131 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
132 vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
\r
134 /* Start the tasks defined within this file/specific to this demo. */
\r
135 xTaskCreate( vCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
136 xTaskCreate( vLCDTask, ( signed portCHAR * ) "LCD", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
\r
138 /* The suicide tasks must be created last as they need to know how many
\r
139 tasks were running prior to their creation in order to ascertain whether
\r
140 or not the correct/expected number of tasks are running at any given time. */
\r
141 vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
\r
143 /* Start the scheduler. */
\r
144 vTaskStartScheduler();
\r
146 /* Will only get here if there was insufficient memory to create the idle
\r
150 /*-----------------------------------------------------------*/
\r
152 static void vCheckTask( void *pvParameters )
\r
154 portBASE_TYPE xErrorOccurred = pdFALSE;
\r
155 portTickType xLastExecutionTime;
\r
156 unsigned portBASE_TYPE uxColumn = 0;
\r
157 xLCDMessage xMessage;
\r
159 xLastExecutionTime = xTaskGetTickCount();
\r
161 xMessage.xColumn = 0;
\r
162 xMessage.pcMessage = "PASS";
\r
166 /* Perform this check every mainCHECK_DELAY milliseconds. */
\r
167 vTaskDelayUntil( &xLastExecutionTime, mainCHECK_DELAY );
\r
169 /* Has an error been found in any task? */
\r
171 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
173 xErrorOccurred = pdTRUE;
\r
176 if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
178 xErrorOccurred = pdTRUE;
\r
181 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
183 xErrorOccurred = pdTRUE;
\r
186 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
188 xErrorOccurred = pdTRUE;
\r
191 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
193 xErrorOccurred = pdTRUE;
\r
196 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
198 xErrorOccurred = pdTRUE;
\r
202 xMessage.xColumn++;
\r
203 LCD_gotoxy( ( uxColumn & 0x07 ) + 1, ( uxColumn & 0x01 ) + 1 );
\r
205 if( xErrorOccurred == pdTRUE )
\r
207 xMessage.pcMessage = "FAIL";
\r
210 /* Send the message to the LCD gatekeeper for display. */
\r
211 xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY );
\r
214 /*-----------------------------------------------------------*/
\r
216 void vLCDTask( void *pvParameters )
\r
218 xLCDMessage xMessage;
\r
220 /* Initialise the LCD and display a startup message. */
\r
224 LCD_gotoxy( 1, 1 );
\r
225 LCD_puts( ( signed portCHAR * ) "www.FreeRTOS.org" );
\r
229 /* Wait for a message to arrive that requires displaying. */
\r
230 while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS );
\r
232 /* Display the message. Print each message to a different position. */
\r
234 LCD_gotoxy( ( xMessage.xColumn & 0x07 ) + 1, ( xMessage.xColumn & 0x01 ) + 1 );
\r
235 LCD_puts( xMessage.pcMessage );
\r
239 /*-----------------------------------------------------------*/
\r
241 /* Keep the compiler quiet. */
\r
243 int __putchar( int c )
\r