2 FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.
\r
5 ***************************************************************************
\r
7 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
8 * Complete, revised, and edited pdf reference manuals are also *
\r
11 * Purchasing FreeRTOS documentation will not only help you, by *
\r
12 * ensuring you get running as quickly as possible and with an *
\r
13 * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
14 * the FreeRTOS project to continue with its mission of providing *
\r
15 * professional grade, cross platform, de facto standard solutions *
\r
16 * for microcontrollers - completely free of charge! *
\r
18 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
20 * Thank you for using FreeRTOS, and thank you for your support! *
\r
22 ***************************************************************************
\r
25 This file is part of the FreeRTOS distribution.
\r
27 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
28 the terms of the GNU General Public License (version 2) as published by the
\r
29 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
30 >>>NOTE<<< The modification to the GPL is included to allow you to
\r
31 distribute a combined work that includes FreeRTOS without being obliged to
\r
32 provide the source code for proprietary components outside of the FreeRTOS
\r
33 kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
34 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
35 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
36 more details. You should have received a copy of the GNU General Public
\r
37 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
38 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
39 by writing to Richard Barry, contact details for whom are available on the
\r
44 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
47 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
50 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
51 licensing and training services.
\r
54 /* Environment includes. */
\r
55 #include <targets/LPC2368.h>
\r
57 /* Scheduler includes. */
\r
58 #include "FreeRTOS.h"
\r
63 /* Demo app includes. */
\r
66 #include "integer.h"
\r
67 #include "blocktim.h"
\r
68 #include "portlcd.h"
\r
70 #include "partest.h"
\r
71 #include "semtest.h"
\r
74 /* Demo application definitions. */
\r
75 #define mainQUEUE_SIZE ( 3 )
\r
76 #define mainCHECK_DELAY ( ( portTickType ) 5000 / portTICK_RATE_MS )
\r
77 #define mainBASIC_WEB_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 )
\r
79 /* Task priorities. */
\r
80 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
81 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
82 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
83 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
84 #define mainFLASH_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
85 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
86 #define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
90 * Checks the status of all the demo tasks then prints a message to the
\r
91 * CrossStudio terminal IO windows. The message will be either PASS or FAIL
\r
92 * depending on the status of the demo applications tasks. A FAIL status will
\r
95 * Messages are not written directly to the terminal, but passed to vPrintTask
\r
98 static void vCheckTask( void *pvParameters );
\r
101 * The task that handles the uIP stack. All TCP/IP processing is performed in
\r
104 extern void vuIP_Task( void *pvParameters );
\r
107 * The LCD is written two by more than one task so is controlled by a
\r
108 * 'gatekeeper' task. This is the only task that is actually permitted to
\r
109 * access the LCD directly. Other tasks wanting to display a message send
\r
110 * the message to the gatekeeper.
\r
112 static void vLCDTask( void *pvParameters );
\r
114 /* The queue used to send messages to the LCD task. */
\r
115 xQueueHandle xLCDQueue;
\r
117 /*-----------------------------------------------------------*/
\r
121 /* Setup the led's on the MCB2300 board */
\r
122 vParTestInitialise();
\r
124 /* Create the queue used by the LCD task. Messages for display on the LCD
\r
125 are received via this queue. */
\r
126 xLCDQueue = xQueueCreate( mainQUEUE_SIZE, sizeof( xLCDMessage ) );
\r
128 /* Create the lwIP task. This uses the lwIP RTOS abstraction layer.*/
\r
129 xTaskCreate( vuIP_Task, ( signed char * ) "uIP", mainBASIC_WEB_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
\r
131 /* Start the standard demo tasks - these serve no useful purpose other than
\r
132 to demonstrate the FreeRTOS API being used and to test the port. */
\r
133 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
134 vCreateBlockTimeTasks();
\r
135 vStartLEDFlashTasks( mainFLASH_PRIORITY );
\r
136 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
137 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
138 vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
\r
140 /* Start the tasks defined within this file/specific to this demo. */
\r
141 xTaskCreate( vCheckTask, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
142 xTaskCreate( vLCDTask, ( signed char * ) "LCD", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
\r
144 /* The suicide tasks must be created last as they need to know how many
\r
145 tasks were running prior to their creation in order to ascertain whether
\r
146 or not the correct/expected number of tasks are running at any given time. */
\r
147 vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
\r
149 /* Start the scheduler. */
\r
150 vTaskStartScheduler();
\r
152 /* Will only get here if there was insufficient memory to create the idle
\r
156 /*-----------------------------------------------------------*/
\r
158 static void vCheckTask( void *pvParameters )
\r
160 portBASE_TYPE xErrorOccurred = pdFALSE;
\r
161 portTickType xLastExecutionTime;
\r
162 unsigned portBASE_TYPE uxColumn = 0;
\r
163 xLCDMessage xMessage;
\r
165 xLastExecutionTime = xTaskGetTickCount();
\r
167 xMessage.xColumn = 0;
\r
168 xMessage.pcMessage = "PASS";
\r
172 /* Perform this check every mainCHECK_DELAY milliseconds. */
\r
173 vTaskDelayUntil( &xLastExecutionTime, mainCHECK_DELAY );
\r
175 /* Has an error been found in any task? */
\r
177 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
179 xErrorOccurred = pdTRUE;
\r
182 if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
184 xErrorOccurred = pdTRUE;
\r
187 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
189 xErrorOccurred = pdTRUE;
\r
192 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
194 xErrorOccurred = pdTRUE;
\r
197 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
199 xErrorOccurred = pdTRUE;
\r
202 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
204 xErrorOccurred = pdTRUE;
\r
208 xMessage.xColumn++;
\r
209 LCD_gotoxy( ( uxColumn & 0x07 ) + 1, ( uxColumn & 0x01 ) + 1 );
\r
211 if( xErrorOccurred == pdTRUE )
\r
213 xMessage.pcMessage = "FAIL";
\r
216 /* Send the message to the LCD gatekeeper for display. */
\r
217 xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY );
\r
220 /*-----------------------------------------------------------*/
\r
222 void vLCDTask( void *pvParameters )
\r
224 xLCDMessage xMessage;
\r
226 /* Initialise the LCD and display a startup message. */
\r
230 LCD_gotoxy( 1, 1 );
\r
231 LCD_puts( ( signed char * ) "www.FreeRTOS.org" );
\r
235 /* Wait for a message to arrive that requires displaying. */
\r
236 while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS );
\r
238 /* Display the message. Print each message to a different position. */
\r
240 LCD_gotoxy( ( xMessage.xColumn & 0x07 ) + 1, ( xMessage.xColumn & 0x01 ) + 1 );
\r
241 LCD_puts( xMessage.pcMessage );
\r
245 /*-----------------------------------------------------------*/
\r
247 /* Keep the compiler quiet. */
\r
249 int __putchar( int c )
\r