2 FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 ***************************************************************************
\r
9 * FreeRTOS provides completely free yet professionally developed, *
\r
10 * robust, strictly quality controlled, supported, and cross *
\r
11 * platform software that has become a de facto standard. *
\r
13 * Help yourself get started quickly and support the FreeRTOS *
\r
14 * project by purchasing a FreeRTOS tutorial book, reference *
\r
15 * manual, or both from: http://www.FreeRTOS.org/Documentation *
\r
19 ***************************************************************************
\r
21 This file is part of the FreeRTOS distribution.
\r
23 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
24 the terms of the GNU General Public License (version 2) as published by the
\r
25 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
\r
27 >>! NOTE: The modification to the GPL is included to allow you to distribute
\r
28 >>! a combined work that includes FreeRTOS without being obliged to provide
\r
29 >>! the source code for proprietary components outside of the FreeRTOS
\r
32 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
33 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
34 FOR A PARTICULAR PURPOSE. Full license text is available from the following
\r
35 link: http://www.freertos.org/a00114.html
\r
39 ***************************************************************************
\r
41 * Having a problem? Start by reading the FAQ "My application does *
\r
42 * not run, what could be wrong?" *
\r
44 * http://www.FreeRTOS.org/FAQHelp.html *
\r
46 ***************************************************************************
\r
48 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
\r
49 license and Real Time Engineers Ltd. contact details.
\r
51 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
52 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
53 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
55 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
\r
56 Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
57 licenses offer ticketed support, indemnification and middleware.
\r
59 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
60 engineered and independently SIL3 certified version for use in safety and
\r
61 mission critical applications that require provable dependability.
\r
67 *******************************************************************************
\r
68 * -NOTE- The Win32 port is a simulation (or is that emulation?) only! Do not
\r
69 * expect to get real time behaviour from the Win32 port or this demo
\r
70 * application. It is provided as a convenient development and demonstration
\r
71 * test bed only. This was tested using Windows XP on a dual core laptop.
\r
73 * - READ THE WEB DOCUMENTATION FOR THIS PORT FOR MORE INFORMATION ON USING IT -
\r
74 *******************************************************************************
\r
76 * main() creates all the demo application tasks, then starts the scheduler.
\r
77 * The web documentation provides more details of the standard demo application
\r
78 * tasks, which provide no particular functionality but do provide a good
\r
79 * example of how to use the FreeRTOS API.
\r
81 * In addition to the standard demo tasks, the following tasks and tests are
\r
82 * defined and/or created within this file:
\r
84 * "Check" task - This only executes every five seconds but has a high priority
\r
85 * to ensure it gets processor time. Its main function is to check that all the
\r
86 * standard demo tasks are still operational. While no errors have been
\r
87 * discovered the check task will print out "OK" and the current simulated tick
\r
88 * time. If an error is discovered in the execution of a task then the check
\r
89 * task will print out an appropriate error message.
\r
94 /* Standard includes. */
\r
97 /* Kernel includes. */
\r
98 #include <FreeRTOS.h>
\r
102 /* Standard demo includes. */
\r
103 #include "BlockQ.h"
\r
104 #include "integer.h"
\r
105 #include "semtest.h"
\r
107 #include "GenQTest.h"
\r
109 #include "recmutex.h"
\r
112 /* Priorities at which the tasks are created. */
\r
113 #define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
\r
114 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
115 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
116 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
117 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
118 #define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
119 #define mainuIP_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
120 #define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
121 #define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
122 #define mainFLOP_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
124 /* Task function prototypes. */
\r
125 static void prvCheckTask( void *pvParameters );
\r
127 /*-----------------------------------------------------------*/
\r
131 /* Start the check task as described at the top of this file. */
\r
132 xTaskCreate( prvCheckTask, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
134 /* Create the standard demo tasks. */
\r
135 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
136 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
137 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
138 vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
\r
139 vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
\r
140 vStartQueuePeekTasks();
\r
141 vStartMathTasks( mainFLOP_TASK_PRIORITY );
\r
142 vStartRecursiveMutexTasks();
\r
144 /* Start the scheduler itself. */
\r
145 vTaskStartScheduler();
\r
147 /* Should never get here unless there was not enough heap space to create
\r
148 the idle and other system tasks. */
\r
151 /*-----------------------------------------------------------*/
\r
153 static void prvCheckTask( void *pvParameters )
\r
155 portTickType xNextWakeTime;
\r
156 const portTickType xCycleFrequency = 2500 / portTICK_RATE_MS;
\r
157 char *pcStatusMessage = "OK";
\r
159 /* Just to remove compiler warning. */
\r
160 ( void ) pvParameters;
\r
162 /* Initialise xNextWakeTime - this only needs to be done once. */
\r
163 xNextWakeTime = xTaskGetTickCount();
\r
167 /* Place this task in the blocked state until it is time to run again. */
\r
168 vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );
\r
170 /* Check the standard demo tasks are running without error. */
\r
171 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
173 pcStatusMessage = "Error: IntMath";
\r
175 else if( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
177 pcStatusMessage = "Error: GenQueue";
\r
179 else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
\r
181 pcStatusMessage = "Error: QueuePeek";
\r
183 else if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
185 pcStatusMessage = "Error: BlockQueue";
\r
187 else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
189 pcStatusMessage = "Error: SemTest";
\r
191 else if( xArePollingQueuesStillRunning() != pdTRUE )
\r
193 pcStatusMessage = "Error: PollQueue";
\r
195 else if( xAreMathsTaskStillRunning() != pdPASS )
\r
197 pcStatusMessage = "Error: Flop";
\r
199 else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
\r
201 pcStatusMessage = "Error: RecMutex";
\r
204 /* This is the only task that uses stdout so its ok to call printf()
\r
206 printf( "%s - %d\r\n", pcStatusMessage, ( int ) xTaskGetTickCount() );
\r
207 fflush( stdout ); /* Required by Eclipse console. */
\r
210 /*-----------------------------------------------------------*/
\r
212 void vApplicationIdleHook( void )
\r
214 const unsigned long ulMSToSleep = 5;
\r
216 /* Sleep to reduce CPU load, but don't sleep indefinitely in case there are
\r
217 tasks waiting to be terminated by the idle task. */
\r
218 Sleep( ulMSToSleep );
\r
220 /*-----------------------------------------------------------*/
\r
222 void vApplicationMallocFailedHook( void )
\r
224 /* Can be implemented if required, but probably not required in this
\r
225 environment and running this demo. */
\r
227 /*-----------------------------------------------------------*/
\r
229 void vApplicationStackOverflowHook( void )
\r
231 /* Can be implemented if required, but not required in this
\r
232 environment and running this demo. */
\r