2 FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 This file is part of the FreeRTOS distribution.
\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
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
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
25 ***************************************************************************
\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
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
37 ***************************************************************************
\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
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
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
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
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
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
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
70 /* Environment includes. */
\r
71 #include <targets/LPC2368.h>
\r
73 /* Scheduler includes. */
\r
74 #include "FreeRTOS.h"
\r
79 /* Demo app includes. */
\r
82 #include "integer.h"
\r
83 #include "blocktim.h"
\r
84 #include "portlcd.h"
\r
86 #include "partest.h"
\r
87 #include "semtest.h"
\r
90 /* Demo application definitions. */
\r
91 #define mainQUEUE_SIZE ( 3 )
\r
92 #define mainCHECK_DELAY ( ( TickType_t ) 5000 / portTICK_PERIOD_MS )
\r
93 #define mainBASIC_WEB_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 )
\r
95 /* Task priorities. */
\r
96 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
97 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
98 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
99 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
100 #define mainFLASH_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
101 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
102 #define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
106 * Checks the status of all the demo tasks then prints a message to the
\r
107 * CrossStudio terminal IO windows. The message will be either PASS or FAIL
\r
108 * depending on the status of the demo applications tasks. A FAIL status will
\r
111 * Messages are not written directly to the terminal, but passed to vPrintTask
\r
114 static void vCheckTask( void *pvParameters );
\r
117 * The task that handles the uIP stack. All TCP/IP processing is performed in
\r
120 extern void vuIP_Task( void *pvParameters );
\r
123 * The LCD is written two by more than one task so is controlled by a
\r
124 * 'gatekeeper' task. This is the only task that is actually permitted to
\r
125 * access the LCD directly. Other tasks wanting to display a message send
\r
126 * the message to the gatekeeper.
\r
128 static void vLCDTask( void *pvParameters );
\r
130 /* The queue used to send messages to the LCD task. */
\r
131 QueueHandle_t xLCDQueue;
\r
133 /*-----------------------------------------------------------*/
\r
137 /* Setup the led's on the MCB2300 board */
\r
138 vParTestInitialise();
\r
140 /* Create the queue used by the LCD task. Messages for display on the LCD
\r
141 are received via this queue. */
\r
142 xLCDQueue = xQueueCreate( mainQUEUE_SIZE, sizeof( xLCDMessage ) );
\r
144 /* Create the lwIP task. This uses the lwIP RTOS abstraction layer.*/
\r
145 xTaskCreate( vuIP_Task, "uIP", mainBASIC_WEB_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
\r
147 /* Start the standard demo tasks - these serve no useful purpose other than
\r
148 to demonstrate the FreeRTOS API being used and to test the port. */
\r
149 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
150 vCreateBlockTimeTasks();
\r
151 vStartLEDFlashTasks( mainFLASH_PRIORITY );
\r
152 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
153 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
154 vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
\r
156 /* Start the tasks defined within this file/specific to this demo. */
\r
157 xTaskCreate( vCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
158 xTaskCreate( vLCDTask, "LCD", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
\r
160 /* The suicide tasks must be created last as they need to know how many
\r
161 tasks were running prior to their creation in order to ascertain whether
\r
162 or not the correct/expected number of tasks are running at any given time. */
\r
163 vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
\r
165 /* Start the scheduler. */
\r
166 vTaskStartScheduler();
\r
168 /* Will only get here if there was insufficient memory to create the idle
\r
172 /*-----------------------------------------------------------*/
\r
174 static void vCheckTask( void *pvParameters )
\r
176 portBASE_TYPE xErrorOccurred = pdFALSE;
\r
177 TickType_t xLastExecutionTime;
\r
178 unsigned portBASE_TYPE uxColumn = 0;
\r
179 xLCDMessage xMessage;
\r
181 xLastExecutionTime = xTaskGetTickCount();
\r
183 xMessage.xColumn = 0;
\r
184 xMessage.pcMessage = "PASS";
\r
188 /* Perform this check every mainCHECK_DELAY milliseconds. */
\r
189 vTaskDelayUntil( &xLastExecutionTime, mainCHECK_DELAY );
\r
191 /* Has an error been found in any task? */
\r
193 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
195 xErrorOccurred = pdTRUE;
\r
198 if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
200 xErrorOccurred = pdTRUE;
\r
203 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
205 xErrorOccurred = pdTRUE;
\r
208 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
210 xErrorOccurred = pdTRUE;
\r
213 if( xIsCreateTaskStillRunning() != pdTRUE )
\r
215 xErrorOccurred = pdTRUE;
\r
218 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
220 xErrorOccurred = pdTRUE;
\r
224 xMessage.xColumn++;
\r
225 LCD_gotoxy( ( uxColumn & 0x07 ) + 1, ( uxColumn & 0x01 ) + 1 );
\r
227 if( xErrorOccurred == pdTRUE )
\r
229 xMessage.pcMessage = "FAIL";
\r
232 /* Send the message to the LCD gatekeeper for display. */
\r
233 xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY );
\r
236 /*-----------------------------------------------------------*/
\r
238 void vLCDTask( void *pvParameters )
\r
240 xLCDMessage xMessage;
\r
242 /* Initialise the LCD and display a startup message. */
\r
246 LCD_gotoxy( 1, 1 );
\r
247 LCD_puts( ( signed char * ) "www.FreeRTOS.org" );
\r
251 /* Wait for a message to arrive that requires displaying. */
\r
252 while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS );
\r
254 /* Display the message. Print each message to a different position. */
\r
256 LCD_gotoxy( ( xMessage.xColumn & 0x07 ) + 1, ( xMessage.xColumn & 0x01 ) + 1 );
\r
257 LCD_puts( xMessage.pcMessage );
\r
261 /*-----------------------------------------------------------*/
\r
263 /* Keep the compiler quiet. */
\r
265 int __putchar( int c )
\r