2 FreeRTOS.org V5.1.0 - Copyright (C) 2003-2008 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 ***************************************************************************
\r
29 * SAVE TIME AND MONEY! We can port FreeRTOS.org to your own hardware, *
\r
30 * and even write all or part of your application on your behalf. *
\r
31 * See http://www.OpenRTOS.com for details of the services we provide to *
\r
32 * expedite your project. *
\r
34 ***************************************************************************
\r
35 ***************************************************************************
\r
37 Please ensure to read the configuration and relevant port sections of the
\r
38 online documentation.
\r
40 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
43 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
46 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
47 licensing and training services.
\r
51 unsigned char *uip_buf;
\r
55 * Creates all the demo application tasks, then starts the scheduler. The WEB
\r
56 * documentation provides more details of the standard demo application tasks.
\r
57 * In addition to the standard demo tasks, the following tasks and tests are
\r
58 * defined and/or created within this file:
\r
60 * "Check" task - This only executes every five seconds but has a high priority
\r
61 * to ensure it gets processor time. Its main function is to check that all the
\r
62 * standard demo tasks are still operational. While no errors have been
\r
63 * discovered the check task will toggle an LED every 5 seconds - the toggle
\r
64 * rate increasing to 500ms being a visual indication that at least one task has
\r
65 * reported unexpected behaviour.
\r
67 * "Reg test" tasks - These fill the registers with known values, then check
\r
68 * that each register still contains its expected value. Each task uses
\r
69 * different values. The tasks run with very low priority so get preempted very
\r
70 * frequently. A register containing an unexpected value is indicative of an
\r
71 * error in the context switching mechanism.
\r
75 /* Standard includes. */
\r
78 /* Scheduler includes. */
\r
79 #include "FreeRTOS.h"
\r
84 /* Demo app includes. */
\r
88 #include "partest.h"
\r
89 #include "semtest.h"
\r
91 #include "GenQTest.h"
\r
93 #include "IntQueue.h"
\r
94 #include "comtest2.h"
\r
96 /*-----------------------------------------------------------*/
\r
98 /* The time between cycles of the 'check' functionality - as described at the
\r
99 top of this file. */
\r
100 #define mainNO_ERROR_PERIOD ( ( portTickType ) 5000 / portTICK_RATE_MS )
\r
102 /* The rate at which the LED controlled by the 'check' task will flash should an
\r
103 error have been detected. */
\r
104 #define mainERROR_PERIOD ( ( portTickType ) 500 / portTICK_RATE_MS )
\r
106 /* The LED controlled by the 'check' task. */
\r
107 #define mainCHECK_LED ( 3 )
\r
109 /* ComTest constants - there is no free LED for the comtest tasks. */
\r
110 #define mainCOM_TEST_BAUD_RATE ( ( unsigned portLONG ) 19200 )
\r
111 #define mainCOM_TEST_LED ( 5 )
\r
113 /* Task priorities. */
\r
114 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
115 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
116 #define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
117 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
118 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
119 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
120 #define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
122 /* The WEB server task uses more stack than most other tasks because of its
\r
123 reliance on using sprintf(). */
124 #define mainBASIC_WEB_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 )
\r
127 * Configure the hardware for the demo.
\r
129 static void prvSetupHardware( void );
\r
132 * Implements the 'check' task functionality as described at the top of this
\r
135 static void prvCheckTask( void *pvParameters );
\r
138 * The task that implements the WEB server.
140 extern void vuIP_Task( void *pvParameters );
\r
142 /*-----------------------------------------------------------*/
\r
146 /* Setup the hardware ready for this demo. */
\r
147 prvSetupHardware();
\r
149 /* Create the WEB server task. */
\r
150 xTaskCreate( vuIP_Task, ( signed portCHAR * ) "uIP", mainBASIC_WEB_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
\r
152 /* Start the standard demo tasks. */
\r
153 vStartLEDFlashTasks( tskIDLE_PRIORITY );
\r
154 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
155 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
156 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
157 vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
\r
158 vStartQueuePeekTasks();
\r
160 /* Create the check task. */
\r
161 xTaskCreate( prvCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
163 /* Start the scheduler. */
\r
164 vTaskStartScheduler();
\r
166 /* Will only get here if there was insufficient memory to create the idle
\r
170 /*-----------------------------------------------------------*/
\r
172 static void prvCheckTask( void *pvParameters )
\r
174 unsigned ulTicksToWait = mainNO_ERROR_PERIOD, ulError = 0;
\r
175 portTickType xLastExecutionTime;
\r
177 ( void ) pvParameters;
\r
179 /* Initialise the variable used to control our iteration rate prior to
\r
181 xLastExecutionTime = xTaskGetTickCount();
\r
185 /* Wait until it is time to run the tests again. */
\r
186 vTaskDelayUntil( &xLastExecutionTime, ulTicksToWait );
\r
188 /* Has an error been found in any task? */
\r
189 if( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
194 if( xAreQueuePeekTasksStillRunning() != pdTRUE )
\r
199 if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
204 if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
209 if( xArePollingQueuesStillRunning() != pdTRUE )
\r
214 /* If an error has been found then increase our cycle rate, and in so
\r
215 going increase the rate at which the check task LED toggles. */
\r
218 ulTicksToWait = mainERROR_PERIOD;
\r
221 /* Toggle the LED each itteration. */
\r
222 vParTestToggleLED( mainCHECK_LED );
\r
225 /*-----------------------------------------------------------*/
\r
227 void prvSetupHardware( void )
\r
229 __attribute__ ((section(".cfmconfig")))
\r
230 static const unsigned long _cfm[6] = {
\r
231 0, /* KEY_UPPER 0x00000400 */
\r
232 0, /* KEY_LOWER 0x00000404 */
\r
233 0, /* CFMPROT 0x00000408 */
\r
234 0, /* CFMSACC 0x0000040C */
\r
235 0, /* CFMDACC 0x00000410 */
\r
236 0, /* CFMSEC 0x00000414 */
\r
239 /* Just to stop compiler warnings. */
\r
242 /* Ensure the watchdog is disabled. */
\r
245 /* Initialize IPSBAR (0x40000000). */
\r
247 "move.l #0x40000000,%d0 \n"
\r
248 "andi.l #0xC0000000,%d0 \n"
\r
249 "add.l #0x1,%d0 \n"
\r
250 "move.l %d0,0x40000000 "
\r
253 /* Initialize FLASHBAR (0x00) */
\r
255 "move.l #0x00,%d0 \n"
\r
256 "andi.l #0xFFF80000,%d0 \n"
\r
257 "add.l #0x41,%d0 \n"
\r
258 "movec %d0,%FLASHBAR "
\r
261 portDISABLE_INTERRUPTS();
\r
264 MCF_SCM_RAMBAR = MCF_SCM_RAMBAR_BA( RAMBAR_ADDRESS ) | MCF_SCM_RAMBAR_BDE;
\r
266 /* Multiply 25MHz crystal by 12 to get 60MHz clock. */
\r
267 MCF_CLOCK_SYNCR = MCF_CLOCK_SYNCR_MFD(4) | MCF_CLOCK_SYNCR_CLKSRC| MCF_CLOCK_SYNCR_PLLMODE | MCF_CLOCK_SYNCR_PLLEN ;
\r
268 while (!(MCF_CLOCK_SYNSR & MCF_CLOCK_SYNSR_LOCK))
\r
272 /* Setup the port used to toggle LEDs. */
\r
273 vParTestInitialise();
\r
275 /*-----------------------------------------------------------*/
\r
277 void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed portCHAR *pcTaskName )
\r
279 /* This will get called if a stack overflow is detected during the context
\r
280 switch. Set configCHECK_FOR_STACK_OVERFLOWS to 2 to also check for stack
\r
281 problems within nested interrupts, but only do this for debug purposes as
\r
282 it will increase the context switch time. */
\r
285 ( void ) pcTaskName;
\r
289 /*-----------------------------------------------------------*/
\r