2 FreeRTOS.org V4.6.0 - Copyright (C) 2003-2007 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 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
33 /* Environment includes. */
\r
34 #include <targets/LPC2368.h>
\r
36 /* Scheduler includes. */
\r
37 #include "FreeRTOS.h"
\r
42 /* Demo app includes. */
\r
45 #include "integer.h"
\r
46 #include "blocktim.h"
\r
47 #include "portlcd.h"
\r
49 #include "partest.h"
\r
50 #include "semtest.h"
\r
53 /* Demo application definitions. */
\r
54 #define mainQUEUE_SIZE ( 3 )
\r
55 #define mainCHECK_DELAY ( ( portTickType ) 5000 / portTICK_RATE_MS )
\r
56 #define mainBASIC_WEB_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 )
\r
58 /* Task priorities. */
\r
59 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
60 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
61 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
62 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
63 #define mainFLASH_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
64 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
65 #define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
69 * Checks the status of all the demo tasks then prints a message to the
\r
70 * CrossStudio terminal IO windows. The message will be either PASS or FAIL
\r
71 * depending on the status of the demo applications tasks. A FAIL status will
\r
74 * Messages are not written directly to the terminal, but passed to vPrintTask
\r
77 static void vCheckTask( void *pvParameters );
\r
80 * The task that handles the uIP stack. All TCP/IP processing is performed in
\r
83 extern void vuIP_Task( void *pvParameters );
\r
86 * The LCD is written two by more than one task so is controlled by a
\r
87 * 'gatekeeper' task. This is the only task that is actually permitted to
\r
88 * access the LCD directly. Other tasks wanting to display a message send
\r
89 * the message to the gatekeeper.
\r
91 static void vLCDTask( void *pvParameters );
\r
93 /* The queue used to send messages to the LCD task. */
\r
94 xQueueHandle xLCDQueue;
\r
96 /*-----------------------------------------------------------*/
\r
100 /* Setup the led's on the MCB2300 board */
\r
101 vParTestInitialise();
\r
103 /* Create the queue used by the LCD task. Messages for display on the LCD
\r
104 are received via this queue. */
\r
105 xLCDQueue = xQueueCreate( mainQUEUE_SIZE, sizeof( xLCDMessage ) );
\r
107 /* Create the lwIP task. This uses the lwIP RTOS abstraction layer.*/
\r
108 xTaskCreate( vuIP_Task, ( signed portCHAR * ) "uIP", mainBASIC_WEB_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
\r
110 /* Start the standard demo tasks. */
\r
111 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
112 vCreateBlockTimeTasks();
\r
113 vStartLEDFlashTasks( mainFLASH_PRIORITY );
\r
114 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
115 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
116 vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
\r
118 /* Start the tasks defined within this file/specific to this demo. */
\r
119 xTaskCreate( vCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
120 xTaskCreate( vLCDTask, ( signed portCHAR * ) "LCD", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
\r
122 /* The suicide tasks must be created last as they need to know how many
\r
123 tasks were running prior to their creation in order to ascertain whether
\r
124 or not the correct/expected number of tasks are running at any given time. */
\r
125 vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
\r
127 /* Start the scheduler. */
\r
128 vTaskStartScheduler();
\r
130 /* Will only get here if there was insufficient memory to create the idle
\r
134 /*-----------------------------------------------------------*/
\r
136 static void vCheckTask( void *pvParameters )
\r
138 portBASE_TYPE xErrorOccurred = pdFALSE;
\r
139 portTickType xLastExecutionTime;
\r
140 unsigned portBASE_TYPE uxColumn = 0;
\r
141 xLCDMessage xMessage;
\r
143 xLastExecutionTime = xTaskGetTickCount();
\r
145 xMessage.xColumn = 0;
\r
146 xMessage.pcMessage = "PASS";
\r
150 /* Perform this check every mainCHECK_DELAY milliseconds. */
\r
151 vTaskDelayUntil( &xLastExecutionTime, mainCHECK_DELAY );
\r
153 /* Has an error been found in any task? */
\r
155 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
157 xErrorOccurred = pdTRUE;
\r
160 if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
162 xErrorOccurred = pdTRUE;
\r
165 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
167 xErrorOccurred = pdTRUE;
\r
170 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
172 xErrorOccurred = pdTRUE;
\r
175 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
177 xErrorOccurred = pdTRUE;
\r
180 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
182 xErrorOccurred = pdTRUE;
\r
186 xMessage.xColumn++;
\r
187 LCD_gotoxy( ( uxColumn & 0x07 ) + 1, ( uxColumn & 0x01 ) + 1 );
\r
189 if( xErrorOccurred == pdTRUE )
\r
191 xMessage.pcMessage = "FAIL";
\r
194 /* Send the message to the LCD gatekeeper for display. */
\r
195 xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY );
\r
198 /*-----------------------------------------------------------*/
\r
200 void vLCDTask( void *pvParameters )
\r
202 xLCDMessage xMessage;
\r
204 /* Initialise the LCD and display a startup message. */
\r
208 LCD_gotoxy( 1, 1 );
\r
209 LCD_puts( ( signed portCHAR * ) "www.FreeRTOS.org" );
\r
213 /* Wait for a message to arrive that requires displaying. */
\r
214 while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS );
\r
216 /* Display the message. Print each message to a different position. */
\r
218 LCD_gotoxy( ( xMessage.xColumn & 0x07 ) + 1, ( xMessage.xColumn & 0x01 ) + 1 );
\r
219 LCD_puts( xMessage.pcMessage );
\r
223 /*-----------------------------------------------------------*/
\r
225 /* Keep the compiler quiet. */
\r
227 int __putchar( int c )
\r