2 FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.
\r
4 FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT
\r
5 http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 ***************************************************************************
\r
9 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
10 * Complete, revised, and edited pdf reference manuals are also *
\r
13 * Purchasing FreeRTOS documentation will not only help you, by *
\r
14 * ensuring you get running as quickly as possible and with an *
\r
15 * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
16 * the FreeRTOS project to continue with its mission of providing *
\r
17 * professional grade, cross platform, de facto standard solutions *
\r
18 * for microcontrollers - completely free of charge! *
\r
20 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
22 * Thank you for using FreeRTOS, and thank you for your support! *
\r
24 ***************************************************************************
\r
27 This file is part of the FreeRTOS distribution.
\r
29 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
30 the terms of the GNU General Public License (version 2) as published by the
\r
31 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
32 >>>NOTE<<< The modification to the GPL is included to allow you to
\r
33 distribute a combined work that includes FreeRTOS without being obliged to
\r
34 provide the source code for proprietary components outside of the FreeRTOS
\r
35 kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
36 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
37 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
38 more details. You should have received a copy of the GNU General Public
\r
39 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
40 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
41 by writing to Richard Barry, contact details for whom are available on the
\r
46 ***************************************************************************
\r
48 * Having a problem? Start by reading the FAQ "My application does *
\r
49 * not run, what could be wrong?" *
\r
51 * http://www.FreeRTOS.org/FAQHelp.html *
\r
53 ***************************************************************************
\r
56 http://www.FreeRTOS.org - Documentation, training, latest versions, license
\r
57 and contact details.
\r
59 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
60 including FreeRTOS+Trace - an indispensable productivity tool.
\r
62 Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
\r
63 the code with commercial support, indemnification, and middleware, under
\r
64 the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
\r
65 provide a safety engineered and independently SIL3 certified version under
\r
66 the SafeRTOS brand: http://www.SafeRTOS.com.
\r
70 *******************************************************************************
\r
71 * -NOTE- The Win32 port is a simulation (or is that emulation?) only! Do not
\r
72 * expect to get real time behaviour from the Win32 port or this demo
\r
73 * application. It is provided as a convenient development and demonstration
\r
74 * test bed only. This was tested using Windows XP on a dual core laptop.
\r
76 * - READ THE WEB DOCUMENTATION FOR THIS PORT FOR MORE INFORMATION ON USING IT -
\r
77 *******************************************************************************
\r
79 * main() creates all the demo application tasks, then starts the scheduler.
\r
80 * The web documentation provides more details of the standard demo application
\r
81 * tasks, which provide no particular functionality but do provide a good
\r
82 * example of how to use the FreeRTOS API.
\r
84 * In addition to the standard demo tasks, the following tasks and tests are
\r
85 * defined and/or created within this file:
\r
87 * "Check" task - This only executes every five seconds but has a high priority
\r
88 * to ensure it gets processor time. Its main function is to check that all the
\r
89 * standard demo tasks are still operational. While no errors have been
\r
90 * discovered the check task will print out "OK" and the current simulated tick
\r
91 * time. If an error is discovered in the execution of a task then the check
\r
92 * task will print out an appropriate error message.
\r
97 /* Standard includes. */
\r
100 /* Kernel includes. */
\r
101 #include <FreeRTOS.h>
\r
105 /* Standard demo includes. */
\r
106 #include "BlockQ.h"
\r
107 #include "integer.h"
\r
108 #include "semtest.h"
\r
110 #include "GenQTest.h"
\r
112 #include "recmutex.h"
\r
115 /* Priorities at which the tasks are created. */
\r
116 #define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
\r
117 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
118 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
119 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
120 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
121 #define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
122 #define mainuIP_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
123 #define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
124 #define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
125 #define mainFLOP_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
127 /* Task function prototypes. */
\r
128 static void prvCheckTask( void *pvParameters );
\r
130 /*-----------------------------------------------------------*/
\r
134 /* Start the check task as described at the top of this file. */
\r
135 xTaskCreate( prvCheckTask, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
137 /* Create the standard demo tasks. */
\r
138 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
139 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
140 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
141 vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
\r
142 vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
\r
143 vStartQueuePeekTasks();
\r
144 vStartMathTasks( mainFLOP_TASK_PRIORITY );
\r
145 vStartRecursiveMutexTasks();
\r
147 /* Start the scheduler itself. */
\r
148 vTaskStartScheduler();
\r
150 /* Should never get here unless there was not enough heap space to create
\r
151 the idle and other system tasks. */
\r
154 /*-----------------------------------------------------------*/
\r
156 static void prvCheckTask( void *pvParameters )
\r
158 portTickType xNextWakeTime;
\r
159 const portTickType xCycleFrequency = 5000 / portTICK_RATE_MS;
\r
160 char *pcStatusMessage = "OK";
\r
162 /* Just to remove compiler warning. */
\r
163 ( void ) pvParameters;
\r
165 /* Initialise xNextWakeTime - this only needs to be done once. */
\r
166 xNextWakeTime = xTaskGetTickCount();
\r
170 /* Place this task in the blocked state until it is time to run again. */
\r
171 vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );
\r
173 /* Check the standard demo tasks are running without error. */
\r
174 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
176 pcStatusMessage = "Error: IntMath";
\r
178 else if( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
180 pcStatusMessage = "Error: GenQueue";
\r
182 else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
\r
184 pcStatusMessage = "Error: QueuePeek";
\r
186 else if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
188 pcStatusMessage = "Error: BlockQueue";
\r
190 else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
192 pcStatusMessage = "Error: SemTest";
\r
194 else if( xArePollingQueuesStillRunning() != pdTRUE )
\r
196 pcStatusMessage = "Error: PollQueue";
\r
198 else if( xAreMathsTaskStillRunning() != pdPASS )
\r
200 pcStatusMessage = "Error: Flop";
\r
202 else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
\r
204 pcStatusMessage = "Error: RecMutex";
\r
207 /* This is the only task that uses stdout so its ok to call printf()
\r
209 printf( "%s - %d\r\n", pcStatusMessage, ( int ) xTaskGetTickCount() );
\r
210 fflush( stdout ); /* Required by Eclipse console. */
\r
213 /*-----------------------------------------------------------*/
\r
215 void vApplicationIdleHook( void )
\r
217 const unsigned long ulMSToSleep = 5;
\r
219 /* Sleep to reduce CPU load, but don't sleep indefinitely in case there are
\r
220 tasks waiting to be terminated by the idle task. */
\r
221 Sleep( ulMSToSleep );
\r
223 /*-----------------------------------------------------------*/
\r
225 void vApplicationMallocFailedHook( void )
\r
227 /* Can be implemented if required, but probably not required in this
\r
228 environment and running this demo. */
\r
230 /*-----------------------------------------------------------*/
\r
232 void vApplicationStackOverflowHook( void )
\r
234 /* Can be implemented if required, but not required in this
\r
235 environment and running this demo. */
\r