]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/TriCore_TC1782_TriBoard_GCC/RTOSDemo/main.c
Update version numbers in preparation for V8.2.0 release candidate 1.
[freertos] / FreeRTOS / Demo / TriCore_TC1782_TriBoard_GCC / RTOSDemo / main.c
1 /*\r
2     FreeRTOS V8.2.0rc1 - Copyright (C) 2014 Real Time Engineers Ltd.\r
3     All rights reserved\r
4 \r
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     This file is part of the FreeRTOS distribution.\r
8 \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
12 \r
13     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
14     >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
15     >>!   obliged to provide the source code for proprietary components     !<<\r
16     >>!   outside of the FreeRTOS kernel.                                   !<<\r
17 \r
18     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
19     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
20     FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
21     link: http://www.freertos.org/a00114.html\r
22 \r
23     1 tab == 4 spaces!\r
24 \r
25     ***************************************************************************\r
26      *                                                                       *\r
27      *    Having a problem?  Start by reading the FAQ "My application does   *\r
28      *    not run, what could be wrong?".  Have you defined configASSERT()?  *\r
29      *                                                                       *\r
30      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
31      *                                                                       *\r
32     ***************************************************************************\r
33 \r
34     ***************************************************************************\r
35      *                                                                       *\r
36      *    FreeRTOS provides completely free yet professionally developed,    *\r
37      *    robust, strictly quality controlled, supported, and cross          *\r
38      *    platform software that is more than just the market leader, it     *\r
39      *    is the industry's de facto standard.                               *\r
40      *                                                                       *\r
41      *    Help yourself get started quickly while simultaneously helping     *\r
42      *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
43      *    tutorial book, reference manual, or both:                          *\r
44      *    http://www.FreeRTOS.org/Documentation                              *\r
45      *                                                                       *\r
46     ***************************************************************************\r
47 \r
48     ***************************************************************************\r
49      *                                                                       *\r
50      *   Investing in training allows your team to be as productive as       *\r
51      *   possible as early as possible, lowering your overall development    *\r
52      *   cost, and enabling you to bring a more robust product to market     *\r
53      *   earlier than would otherwise be possible.  Richard Barry is both    *\r
54      *   the architect and key author of FreeRTOS, and so also the world's   *\r
55      *   leading authority on what is the world's most popular real time     *\r
56      *   kernel for deeply embedded MCU designs.  Obtaining your training    *\r
57      *   from Richard ensures your team will gain directly from his in-depth *\r
58      *   product knowledge and years of usage experience.  Contact Real Time *\r
59      *   Engineers Ltd to enquire about the FreeRTOS Masterclass, presented  *\r
60      *   by Richard Barry:  http://www.FreeRTOS.org/contact\r
61      *                                                                       *\r
62     ***************************************************************************\r
63 \r
64     ***************************************************************************\r
65      *                                                                       *\r
66      *    You are receiving this top quality software for free.  Please play *\r
67      *    fair and reciprocate by reporting any suspected issues and         *\r
68      *    participating in the community forum:                              *\r
69      *    http://www.FreeRTOS.org/support                                    *\r
70      *                                                                       *\r
71      *    Thank you!                                                         *\r
72      *                                                                       *\r
73     ***************************************************************************\r
74 \r
75     http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
76     license and Real Time Engineers Ltd. contact details.\r
77 \r
78     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
79     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
80     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
81 \r
82     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
83     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
84 \r
85     http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
86     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
87     licenses offer ticketed support, indemnification and commercial middleware.\r
88 \r
89     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
90     engineered and independently SIL3 certified version for use in safety and\r
91     mission critical applications that require provable dependability.\r
92 \r
93     1 tab == 4 spaces!\r
94 */\r
95 \r
96 /******************************************************************************\r
97  * >>>>>> NOTE: <<<<<<\r
98  *\r
99  * main() can be configured to create either a very simple LED flasher demo, or\r
100  * a more comprehensive test/demo application.\r
101  *\r
102  * To create a very simple LED flasher example, set the\r
103  * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY constant (defined below) to 1.  When\r
104  * this is done, only the standard demo flash tasks are created.  The standard\r
105  * demo flash example creates three tasks, each toggle an LED at a fixed but\r
106  * different frequency.\r
107  *\r
108  * To create a more comprehensive test and demo application, set\r
109  * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 0.\r
110  *\r
111  * Two build configurations are provided, one that executes from RAM and one\r
112  * that executes from Flash.  The RAM build uses size optimisation, the Flash\r
113  * build has optimisation completely turned off.  The documentation page for\r
114  * this port on the FreeRTOS.org web site provides full information.\r
115  ******************************************************************************\r
116  *\r
117  * main() creates all the demo application tasks and timers, then starts the\r
118  * scheduler.  The web documentation provides more details of the standard demo\r
119  * application tasks, which provide no particular functionality, but do provide\r
120  * a good example of how to use the FreeRTOS API.\r
121  *\r
122  * In addition to the standard demo tasks, the following tasks and tests are\r
123  * defined and/or created within this file:\r
124  *\r
125  * "Reg test" tasks - These fill the registers with known values, then check\r
126  * that each register maintains its expected value for the lifetime of the\r
127  * task.  Each task uses a different set of values.  The reg test tasks execute\r
128  * with a very low priority, so get preempted very frequently.  A register\r
129  * containing an unexpected value is indicative of an error in the context\r
130  * switching mechanism.\r
131  *\r
132  * "Check" task - The check task period is initially set to five seconds.\r
133  * Each time it executes, the check task checks that all the standard demo\r
134  * tasks, and the register check tasks, are not only still executing, but are\r
135  * executing without reporting any errors.  If the check task discovers that a\r
136  * task has either stalled, or reported an error, then it changes its own\r
137  * execution period from the initial five seconds, to just 500ms.  The check\r
138  * task  also toggles an LED each time it is called.  This provides a visual\r
139  * indication of the system status:  If the LED toggles every five seconds,\r
140  * then no issues have been discovered.  If the LED toggles every 500ms, then\r
141  * an issue has been discovered with at least one task.\r
142  *\r
143  * ***NOTE*** This demo uses the standard comtest tasks, which has special\r
144  * hardware requirements as a loopback connector, or UART echo server are\r
145  * required.  See the documentation page for this demo on the FreeRTOS.org web\r
146  * site for more information.  Note that the comtest tasks were tested by\r
147  * placing the UART into loopback mode directly in the serial initialisation\r
148  * sequence, and as such, the baud rate used has not been verified as actually\r
149  * being correct.\r
150  */\r
151 \r
152 /* Standard includes. */\r
153 #include <stdlib.h>\r
154 #include <string.h>\r
155 \r
156 /* Scheduler includes. */\r
157 #include "FreeRTOS.h"\r
158 #include "task.h"\r
159 #include "croutine.h"\r
160 \r
161 /* Demo application includes. */\r
162 #include "partest.h"\r
163 #include "flash.h"\r
164 #include "integer.h"\r
165 #include "PollQ.h"\r
166 #include "comtest2.h"\r
167 #include "semtest.h"\r
168 #include "dynamic.h"\r
169 #include "BlockQ.h"\r
170 #include "blocktim.h"\r
171 #include "countsem.h"\r
172 #include "GenQTest.h"\r
173 #include "recmutex.h"\r
174 #include "serial.h"\r
175 #include "death.h"\r
176 #include "TimerDemo.h"\r
177 #include "InterruptNestTest.h"\r
178 \r
179 /*-----------------------------------------------------------*/\r
180 \r
181 /* Constants for the ComTest tasks. */\r
182 #define mainCOM_TEST_BAUD_RATE          ( ( unsigned long ) 200000 )\r
183 \r
184 #define mainCOM_TEST_LED                        ( 5 )\r
185 \r
186 /* Priorities for the demo application tasks. */\r
187 #define mainLED_TASK_PRIORITY           ( tskIDLE_PRIORITY + 1 )\r
188 #define mainCOM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 2 )\r
189 #define mainQUEUE_POLL_PRIORITY         ( tskIDLE_PRIORITY + 2 )\r
190 #define mainCHECK_TASK_PRIORITY         ( tskIDLE_PRIORITY + 4 )\r
191 #define mainSEM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 1 )\r
192 #define mainBLOCK_Q_PRIORITY            ( tskIDLE_PRIORITY + 2 )\r
193 #define mainCREATOR_TASK_PRIORITY       ( tskIDLE_PRIORITY + 3 )\r
194 \r
195 /* The rate at which the on board LED will toggle when there is/is not an\r
196 error. */\r
197 #define mainNO_ERROR_FLASH_PERIOD_MS    ( ( TickType_t ) 5000 / portTICK_PERIOD_MS      )\r
198 #define mainERROR_FLASH_PERIOD_MS               ( ( TickType_t ) 500 / portTICK_PERIOD_MS  )\r
199 #define mainON_BOARD_LED_BIT                    ( ( unsigned long ) 7 )\r
200 \r
201 /* Constant used by the standard timer test functions.  The timers created by\r
202 the timer test functions will all have a period that is a multiple of this\r
203 value. */\r
204 #define mainTIMER_TEST_PERIOD           ( 200 )\r
205 \r
206 /* Set mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 1 to create a simple demo.\r
207 Set mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY to 0 to create a much more\r
208 comprehensive test application.  See the comments at the top of this file, and\r
209 the documentation page on the http://www.FreeRTOS.org web site for more\r
210 information. */\r
211 #define mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY         0\r
212 \r
213 /*-----------------------------------------------------------*/\r
214 \r
215 /*\r
216  * Checks that all the demo application tasks are still executing without error\r
217  * - as described at the top of the file.\r
218  */\r
219 static long prvCheckOtherTasksAreStillRunning( void );\r
220 \r
221 /*\r
222  * The task that executes at the highest priority and calls\r
223  * prvCheckOtherTasksAreStillRunning().  See the description at the top\r
224  * of the file.\r
225  */\r
226 static void prvCheckTask( void *pvParameters );\r
227 \r
228 /*\r
229  * Configure the processor ready to run this demo.\r
230  */\r
231 static void prvSetupHardware( void );\r
232 \r
233 /*\r
234  * Writes to and checks the value of each register that is used in the context\r
235  * of a task.  See the comments at the top of this file.\r
236  */\r
237 static void prvRegisterCheckTask1( void *pvParameters );\r
238 static void prvRegisterCheckTask2( void *pvParameters );\r
239 \r
240 /*\r
241  * Specific check to see if the register test functions are still operating\r
242  * correctly.\r
243  */\r
244 static portBASE_TYPE prvAreRegTestTasksStillRunning( void );\r
245 \r
246 /*\r
247  * This file can be used to create either a simple LED flasher example, or a\r
248  * comprehensive test/demo application - depending on the setting of the\r
249  * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY constant defined above.  If\r
250  * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 1, then the following\r
251  * function will create a lot of additional tasks and timers.  If\r
252  * mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 0, then the following\r
253  * function will do nothing.\r
254  */\r
255 static void prvOptionallyCreateComprehensveTestApplication( void );\r
256 \r
257 /*-----------------------------------------------------------*/\r
258 \r
259 /* Used by the register test tasks to indicated liveness. */\r
260 static unsigned long ulRegisterTest1Count = 0;\r
261 static unsigned long ulRegisterTest2Count = 0;\r
262 \r
263 /*-----------------------------------------------------------*/\r
264 \r
265 /*\r
266  * Starts all the tasks, then starts the scheduler.\r
267  */\r
268 int main( void )\r
269 {\r
270         /* Setup the hardware for use with the TriCore evaluation board. */\r
271         prvSetupHardware();\r
272 \r
273         /* Start standard demo/test application flash tasks.  See the comments at\r
274         the top of this file.  The LED flash tasks are always created.  The other\r
275         tasks are only created if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to\r
276         0 (at the top of this file).  See the comments at the top of this file for\r
277         more information. */\r
278         vStartLEDFlashTasks( mainLED_TASK_PRIORITY );\r
279 \r
280         /* The following function will only create more tasks and timers if\r
281         mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY is set to 0 (at the top of this\r
282         file).  See the comments at the top of this file for more information. */\r
283         prvOptionallyCreateComprehensveTestApplication();\r
284 \r
285         /* Now all the tasks have been started - start the scheduler. */\r
286         vTaskStartScheduler();\r
287 \r
288         /* If all is well then the following line will never be reached.  If\r
289         execution does reach here, then it is highly probably that the heap size\r
290         is too small for the idle and/or timer tasks to be created within\r
291         vTaskStartScheduler(). */\r
292         for( ;; );\r
293 }\r
294 /*-----------------------------------------------------------*/\r
295 \r
296 static void prvCheckTask( void *pvParameters )\r
297 {\r
298 TickType_t xDelayPeriod = mainNO_ERROR_FLASH_PERIOD_MS;\r
299 TickType_t xLastExecutionTime;\r
300 \r
301         /* Just to stop compiler warnings. */\r
302         ( void ) pvParameters;\r
303 \r
304         /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()\r
305         works correctly. */\r
306         xLastExecutionTime = xTaskGetTickCount();\r
307 \r
308         /* Cycle for ever, delaying then checking all the other tasks are still\r
309         operating without error.  If an error is detected then the delay period\r
310         is decreased from mainNO_ERROR_FLASH_PERIOD_MS to mainERROR_FLASH_PERIOD_MS so\r
311         the on board LED flash rate will increase.  NOTE:  This task could easily\r
312         be replaced by a software timer callback to remove the overhead of having\r
313         an extra task. */\r
314 \r
315         for( ;; )\r
316         {\r
317                 /* Delay until it is time to execute again. */\r
318                 vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );\r
319 \r
320                 /* Check all the standard demo application tasks are executing without\r
321                 error.  */\r
322                 if( prvCheckOtherTasksAreStillRunning() != pdPASS )\r
323                 {\r
324                         /* An error has been detected in one of the tasks - flash the LED\r
325                         at a higher frequency to give visible feedback that something has\r
326                         gone wrong (it might just be that the loop back connector required\r
327                         by the comtest tasks has not been fitted). */\r
328                         xDelayPeriod = mainERROR_FLASH_PERIOD_MS;\r
329                 }\r
330 \r
331                 /* The toggle rate of the LED depends on how long this task delays for.\r
332                 An error reduces the delay period and so increases the toggle rate. */\r
333                 vParTestToggleLED( mainON_BOARD_LED_BIT );\r
334         }\r
335 }\r
336 /*-----------------------------------------------------------*/\r
337 \r
338 static long prvCheckOtherTasksAreStillRunning( void )\r
339 {\r
340 long lReturn = pdPASS;\r
341 unsigned long ulHighFrequencyTimerTaskIterations, ulExpectedIncFrequency_ms;\r
342 \r
343         /* Check all the demo tasks (other than the flash tasks) to ensure\r
344         that they are all still running, and that none have detected an error. */\r
345 \r
346         if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
347         {\r
348                 lReturn = pdFAIL;\r
349         }\r
350 \r
351         if( xAreComTestTasksStillRunning() != pdTRUE )\r
352         {\r
353                 lReturn = pdFAIL;\r
354         }\r
355 \r
356         if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
357         {\r
358                 lReturn = pdFAIL;\r
359         }\r
360 \r
361         if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
362         {\r
363                 lReturn = pdFAIL;\r
364         }\r
365 \r
366         if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
367         {\r
368                 lReturn = pdFAIL;\r
369         }\r
370 \r
371         if ( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
372         {\r
373                 lReturn = pdFAIL;\r
374         }\r
375 \r
376         if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
377         {\r
378                 lReturn = pdFAIL;\r
379         }\r
380 \r
381         if( prvAreRegTestTasksStillRunning() != pdTRUE )\r
382         {\r
383                 lReturn = pdFAIL;\r
384         }\r
385 \r
386         if( xIsCreateTaskStillRunning() != pdTRUE )\r
387         {\r
388                 lReturn = pdFAIL;\r
389         }\r
390 \r
391         if( xAreTimerDemoTasksStillRunning( mainNO_ERROR_FLASH_PERIOD_MS ) != pdTRUE )\r
392         {\r
393                 lReturn = pdFAIL;\r
394         }\r
395 \r
396         if( xArePollingQueuesStillRunning() != pdTRUE )\r
397         {\r
398                 lReturn = pdFAIL;\r
399         }\r
400 \r
401         if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
402         {\r
403                 lReturn = pdFAIL;\r
404         }\r
405 \r
406         /* Obtain the number of times the task associated with the high frequency\r
407         (interrupt nesting) timer test has increment since the check task last\r
408         executed, and the frequency at which it is expected to execute in ms. */\r
409         ulHighFrequencyTimerTaskIterations = ulInterruptNestingTestGetIterationCount( &ulExpectedIncFrequency_ms );\r
410         if( ( ulHighFrequencyTimerTaskIterations < ( ( mainNO_ERROR_FLASH_PERIOD_MS / ulExpectedIncFrequency_ms ) - 1 ) )\r
411                 ||\r
412                 ( ulHighFrequencyTimerTaskIterations > ( ( mainNO_ERROR_FLASH_PERIOD_MS / ulExpectedIncFrequency_ms ) +5 ) )\r
413           )\r
414         {\r
415                 /* Would have expected the high frequency timer task to have\r
416                 incremented its execution count more times that reported. */\r
417                 lReturn = pdFAIL;\r
418         }\r
419 \r
420         return lReturn;\r
421 }\r
422 /*-----------------------------------------------------------*/\r
423 \r
424 static void prvSetupHardware( void )\r
425 {\r
426 extern void set_cpu_frequency(void);\r
427 \r
428         /* Set-up the PLL. */\r
429         set_cpu_frequency();\r
430 \r
431         /* Initialise LED outputs. */\r
432         vParTestInitialise();\r
433 }\r
434 /*-----------------------------------------------------------*/\r
435 \r
436 void vApplicationMallocFailedHook( void )\r
437 {\r
438         /* vApplicationMallocFailedHook() will only be called if\r
439         configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook\r
440         function that will get called if a call to pvPortMalloc() fails.\r
441         pvPortMalloc() is called internally by the kernel whenever a task, queue,\r
442         timer or semaphore is created.  It is also called by various parts of the\r
443         demo application.  If heap_1.c or heap_2.c are used, then the size of the\r
444         heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in\r
445         FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used\r
446         to query the size of free heap space that remains (although it does not\r
447         provide information on how the remaining heap might be fragmented). */\r
448         taskDISABLE_INTERRUPTS();\r
449         for( ;; );\r
450 }\r
451 /*-----------------------------------------------------------*/\r
452 \r
453 void vApplicationTickHook( void )\r
454 {\r
455         #if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY != 1\r
456         {\r
457                 /* vApplicationTickHook() will only be called if configUSE_TICK_HOOK is set\r
458                 to 1 in FreeRTOSConfig.h.  It is a hook function that will get called during\r
459                 each FreeRTOS tick interrupt.  Note that vApplicationTickHook() is called\r
460                 from an interrupt context. */\r
461 \r
462                 /* Call the periodic timer test, which tests the timer API functions that\r
463                 can be called from an ISR. */\r
464                 vTimerPeriodicISRTests();\r
465         }\r
466         #endif /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */\r
467 }\r
468 /*-----------------------------------------------------------*/\r
469 \r
470 void vApplicationIdleHook( void )\r
471 {\r
472         /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set\r
473         to 1 in FreeRTOSConfig.h.  It will be called on each iteration of the idle\r
474         task.  It is essential that code added to this hook function never attempts\r
475         to block in any way (for example, call xQueueReceive() with a block time\r
476         specified, or call vTaskDelay()).  If the application makes use of the\r
477         vTaskDelete() API function (as this demo application does) then it is also\r
478         important that vApplicationIdleHook() is permitted to return to its calling\r
479         function, because it is the responsibility of the idle task to clean up\r
480         memory allocated by the kernel to any task that has since been deleted. */\r
481 }\r
482 /*-----------------------------------------------------------*/\r
483 \r
484 static portBASE_TYPE prvAreRegTestTasksStillRunning( void )\r
485 {\r
486 static unsigned long ulPreviousRegisterTest1Count = 0;\r
487 static unsigned long ulPreviousRegisterTest2Count = 0;\r
488 portBASE_TYPE xReturn = pdPASS;\r
489 \r
490         /* Check to see if the Counts have changed since the last check. */\r
491         if( ulRegisterTest1Count == ulPreviousRegisterTest1Count )\r
492         {\r
493                 xReturn = pdFAIL;\r
494         }\r
495 \r
496         if( ulRegisterTest2Count == ulPreviousRegisterTest2Count )\r
497         {\r
498                 xReturn = pdFAIL;\r
499         }\r
500 \r
501         /* Remember the current count for the next time this function is called. */\r
502         ulPreviousRegisterTest1Count = ulRegisterTest1Count;\r
503         ulPreviousRegisterTest2Count = ulRegisterTest2Count;\r
504 \r
505         return xReturn;\r
506 }\r
507 /*-----------------------------------------------------------*/\r
508 \r
509 static void prvOptionallyCreateComprehensveTestApplication( void )\r
510 {\r
511         #if mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY == 0\r
512         {\r
513                 vStartIntegerMathTasks( tskIDLE_PRIORITY );\r
514                 vStartDynamicPriorityTasks();\r
515                 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
516                 vCreateBlockTimeTasks();\r
517                 vStartCountingSemaphoreTasks();\r
518                 vStartGenericQueueTasks( tskIDLE_PRIORITY );\r
519                 vStartRecursiveMutexTasks();\r
520                 vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );\r
521                 vSetupInterruptNestingTest();\r
522                 vStartTimerDemoTask( mainTIMER_TEST_PERIOD );\r
523                 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
524                 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
525 \r
526                 /* Create the register test tasks, as described at the top of this file. */\r
527                 xTaskCreate( prvRegisterCheckTask1, "Reg 1", configMINIMAL_STACK_SIZE, &ulRegisterTest1Count, tskIDLE_PRIORITY, NULL );\r
528                 xTaskCreate( prvRegisterCheckTask2, "Reg 2", configMINIMAL_STACK_SIZE, &ulRegisterTest2Count, tskIDLE_PRIORITY, NULL );\r
529 \r
530                 /* Start the check task - which is defined in this file. */\r
531                 xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
532 \r
533                 /* This task has to be created last as it keeps account of the number of tasks\r
534                 it expects to see running. */\r
535                 vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
536         }\r
537         #else /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */\r
538         {\r
539                 /* Just to prevent compiler warnings when the configuration options are\r
540                 set such that these static functions are not used. */\r
541                 ( void ) prvCheckTask;\r
542                 ( void ) prvRegisterCheckTask1;\r
543                 ( void ) prvRegisterCheckTask2;\r
544         }\r
545         #endif /* mainCREATE_SIMPLE_LED_FLASHER_DEMO_ONLY */\r
546 }\r
547 /*-----------------------------------------------------------*/\r
548 \r
549 static void prvRegisterCheckTask1( void *pvParameters )\r
550 {\r
551         /* Make space on the stack for the parameter and a counter. */\r
552         __asm volatile( " sub.a %sp, 4                  \n"\r
553                                         " st.a [%sp], %a4               \n"\r
554                                         " mov %d15, 0                   \n"\r
555                                         " st.w [%sp]4, %d15             \n" );\r
556 \r
557         /* Change all of the Context sensitive registers (except SP and RA). */\r
558         __asm volatile(\r
559                         " mov %d0, 0            \n"\r
560                         " mov %d1, 1            \n"\r
561                         " mov %d2, 2            \n"\r
562                         " mov %d3, 3            \n"\r
563                         " mov %d4, 4            \n"\r
564                         " mov %d5, 5            \n"\r
565                         " mov %d6, 6            \n"\r
566                         " mov %d7, 7            \n"\r
567                         " mov %d8, 8            \n"\r
568                         " mov %d9, 9            \n"\r
569                         " mov %d10, 10          \n"\r
570                         " mov %d11, 11          \n"\r
571                         " mov %d12, 12          \n"\r
572                         " mov %d13, 13          \n"\r
573                         " mov %d14, 14          \n"\r
574                         " mov %d15, 15          \n"\r
575                         " mov.a %a2, 2          \n"\r
576                         " mov.a %a3, 3          \n"\r
577                         " mov.a %a4, 4          \n"\r
578                         " mov.a %a5, 5          \n"\r
579                         " mov.a %a6, 6          \n"\r
580                         " mov.a %a7, 7          \n"\r
581                         " mov.a %a12, 12        \n"\r
582                         " mov.a %a13, 13        \n"\r
583                         " mov.a %a14, 14        \n" );\r
584 \r
585         /* Check the values of the registers. */\r
586         __asm(  " _task1_loop:                                                  \n" \\r
587                         " eq %d1, %d0, 0                                                \n" \\r
588                         " jne %d1, 1, _task1_error_loop                 \n" \\r
589                         " eq %d1, %d1, 1                                                \n" \\r
590                         " jne %d1, 1, _task1_error_loop                 \n" \\r
591                         " eq %d1, %d2, 2                                                \n" \\r
592                         " jne %d1, 1, _task1_error_loop                 \n" \\r
593                         " eq %d1, %d3, 3                                                \n" \\r
594                         " jne %d1, 1, _task1_error_loop                 \n" \\r
595                         " eq %d1, %d4, 4                                                \n" \\r
596                         " jne %d1, 1, _task1_error_loop                 \n" \\r
597                         " eq %d1, %d5, 5                                                \n" \\r
598                         " jne %d1, 1, _task1_error_loop                 \n" \\r
599                         " eq %d1, %d6, 6                                                \n" \\r
600                         " jne %d1, 1, _task1_error_loop                 \n" \\r
601                         " eq %d1, %d7, 7                                                \n" \\r
602                         " jne %d1, 1, _task1_error_loop                 \n" \\r
603                         " eq %d1, %d8, 8                                                \n" \\r
604                         " jne %d1, 1, _task1_error_loop                 \n" \\r
605                         " eq %d1, %d9, 9                                                \n" \\r
606                         " jne %d1, 1, _task1_error_loop                 \n" \\r
607                         " eq %d1, %d10, 10                                              \n" \\r
608                         " jne %d1, 1, _task1_error_loop                 \n" \\r
609                         " eq %d1, %d11, 11                                              \n" \\r
610                         " jne %d1, 1, _task1_error_loop                 \n" \\r
611                         " eq %d1, %d12, 12                                              \n" \\r
612                         " jne %d1, 1, _task1_error_loop                 \n" \\r
613                         " eq %d1, %d13, 13                                              \n" \\r
614                         " jne %d1, 1, _task1_error_loop                 \n" \\r
615                         " eq %d1, %d14, 14                                              \n" \\r
616                         " jne %d1, 1, _task1_error_loop                 \n" \\r
617                         " eq %d1, %d15, 15                                              \n" \\r
618                         " jne %d1, 1, _task1_error_loop                 \n" \\r
619                         " mov.a %a15, 2                                                 \n" \\r
620                         " jne.a %a15, %a2, _task1_error_loop    \n" \\r
621                         " mov.a %a15, 3                                                 \n" \\r
622                         " jne.a %a15, %a3, _task1_error_loop    \n" \\r
623                         " mov.a %a15, 4                                                 \n" \\r
624                         " jne.a %a15, %a4, _task1_error_loop    \n" \\r
625                         " mov.a %a15, 5                                                 \n" \\r
626                         " jne.a %a15, %a5, _task1_error_loop    \n" \\r
627                         " mov.a %a15, 6                                                 \n" \\r
628                         " jne.a %a15, %a6, _task1_error_loop    \n" \\r
629                         " mov.a %a15, 7                                                 \n" \\r
630                         " jne.a %a15, %a7, _task1_error_loop    \n" \\r
631                         " mov.a %a15, 12                                                \n" \\r
632                         " jne.a %a15, %a12, _task1_error_loop   \n" \\r
633                         " mov.a %a15, 13                                                \n" \\r
634                         " jne.a %a15, %a13, _task1_error_loop   \n" \\r
635                         " mov.a %a15, 14                                                \n" \\r
636                         " jne.a %a15, %a14, _task1_error_loop   \n" \\r
637                         " j _task1_skip_error_loop                              \n"     \\r
638                         "_task1_error_loop:                                             \n"     /* Hitting this error loop will stop the counter incrementing, allowing the check task to recognise an error. */ \\r
639                         "       debug                                                           \n"     \\r
640                         " j _task1_error_loop                                   \n"     \\r
641                         "_task1_skip_error_loop:                                \n" );\r
642 \r
643         /* Load the parameter address from the stack and modify the value. */\r
644         __asm volatile(                                                                 \\r
645                         " ld.w %d1, [%sp]4                                              \n"     \\r
646                         " add %d1, 1                                                    \n"     \\r
647                         " st.w [%sp]4, %d1                                              \n"     \\r
648                         " ld.a %a15, [%sp]                                              \n"     \\r
649                         " st.w [%a15], %d1                                              \n"     \\r
650                         " j _task1_loop                                                 \n" );\r
651 \r
652         /* The parameter is used but in the assembly. */\r
653         (void)pvParameters;\r
654 }\r
655 /*-----------------------------------------------------------*/\r
656 \r
657 static void prvRegisterCheckTask2( void *pvParameters )\r
658 {\r
659         /* Make space on the stack for the parameter and a counter. */\r
660         __asm volatile( " sub.a %sp, 4          \n" \\r
661                                         " st.a [%sp], %a4       \n" \\r
662                                         " mov %d15, 0           \n" \\r
663                                         " st.w [%sp]4, %d15     \n" );\r
664 \r
665         /* Change all of the Context sensitive registers (except SP and RA). */\r
666         __asm volatile( " mov %d0, 7            \n" \\r
667                                         " mov %d1, 1            \n" \\r
668                                         " mov %d2, 5            \n" \\r
669                                         " mov %d3, 4            \n" \\r
670                                         " mov %d4, 3            \n" \\r
671                                         " mov %d5, 2            \n" \\r
672                                         " mov %d6, 1            \n" \\r
673                                         " mov %d7, 0            \n" \\r
674                                         " mov %d8, 15           \n" \\r
675                                         " mov %d9, 14           \n" \\r
676                                         " mov %d10, 13          \n" \\r
677                                         " mov %d11, 12          \n" \\r
678                                         " mov %d12, 11          \n" \\r
679                                         " mov %d13, 10          \n" \\r
680                                         " mov %d14, 9           \n" \\r
681                                         " mov %d15, 8           \n" \\r
682                                         " mov.a %a2, 14         \n" \\r
683                                         " mov.a %a3, 13         \n" \\r
684                                         " mov.a %a4, 12         \n" \\r
685                                         " mov.a %a5, 7          \n" \\r
686                                         " mov.a %a6, 6          \n" \\r
687                                         " mov.a %a7, 5          \n" \\r
688                                         " mov.a %a12, 4         \n" \\r
689                                         " mov.a %a13, 3         \n" \\r
690                                         " mov.a %a14, 2         \n" );\r
691 \r
692         /* Check the values of the registers. */\r
693         __asm volatile( " _task2_loop:                                                  \n" \\r
694                                         " syscall 0                                                             \n" \\r
695                                         " eq %d1, %d0, 7                                                \n" \\r
696                                         " jne %d1, 1, _task2_error_loop                 \n" \\r
697                                         " eq %d1, %d1, 1                                                \n" \\r
698                                         " jne %d1, 1, _task2_error_loop                 \n" \\r
699                                         " eq %d1, %d2, 5                                                \n" \\r
700                                         " jne %d1, 1, _task2_error_loop                 \n" \\r
701                                         " eq %d1, %d3, 4                                                \n" \\r
702                                         " jne %d1, 1, _task2_error_loop                 \n" \\r
703                                         " eq %d1, %d4, 3                                                \n" \\r
704                                         " jne %d1, 1, _task2_error_loop                 \n" \\r
705                                         " eq %d1, %d5, 2                                                \n" \\r
706                                         " jne %d1, 1, _task2_error_loop                 \n" \\r
707                                         " eq %d1, %d6, 1                                                \n" \\r
708                                         " jne %d1, 1, _task2_error_loop                 \n" \\r
709                                         " eq %d1, %d7, 0                                                \n" \\r
710                                         " jne %d1, 1, _task2_error_loop                 \n" \\r
711                                         " eq %d1, %d8, 15                                               \n" \\r
712                                         " jne %d1, 1, _task2_error_loop                 \n" \\r
713                                         " eq %d1, %d9, 14                                               \n" \\r
714                                         " jne %d1, 1, _task2_error_loop                 \n" \\r
715                                         " eq %d1, %d10, 13                                              \n" \\r
716                                         " jne %d1, 1, _task2_error_loop                 \n" \\r
717                                         " eq %d1, %d11, 12                                              \n" \\r
718                                         " jne %d1, 1, _task2_error_loop                 \n" \\r
719                                         " eq %d1, %d12, 11                                              \n" \\r
720                                         " jne %d1, 1, _task2_error_loop                 \n" \\r
721                                         " eq %d1, %d13, 10                                              \n" \\r
722                                         " jne %d1, 1, _task2_error_loop                 \n" \\r
723                                         " eq %d1, %d14, 9                                               \n" \\r
724                                         " jne %d1, 1, _task2_error_loop                 \n" \\r
725                                         " eq %d1, %d15, 8                                               \n" \\r
726                                         " jne %d1, 1, _task2_error_loop                 \n" \\r
727                                         " mov.a %a15, 14                                                \n" \\r
728                                         " jne.a %a15, %a2, _task2_error_loop    \n" \\r
729                                         " mov.a %a15, 13                                                \n" \\r
730                                         " jne.a %a15, %a3, _task2_error_loop    \n" \\r
731                                         " mov.a %a15, 12                                                \n" \\r
732                                         " jne.a %a15, %a4, _task2_error_loop    \n" \\r
733                                         " mov.a %a15, 7                                                 \n" \\r
734                                         " jne.a %a15, %a5, _task2_error_loop    \n" \\r
735                                         " mov.a %a15, 6                                                 \n" \\r
736                                         " jne.a %a15, %a6, _task2_error_loop    \n" \\r
737                                         " mov.a %a15, 5                                                 \n" \\r
738                                         " jne.a %a15, %a7, _task2_error_loop    \n" \\r
739                                         " mov.a %a15, 4                                                 \n" \\r
740                                         " jne.a %a15, %a12, _task2_error_loop   \n" \\r
741                                         " mov.a %a15, 3                                                 \n" \\r
742                                         " jne.a %a15, %a13, _task2_error_loop   \n" \\r
743                                         " mov.a %a15, 2                                                 \n" \\r
744                                         " jne.a %a15, %a14, _task2_error_loop   \n" \\r
745                                         " j _task2_skip_error_loop                              \n"     \\r
746                                         "_task2_error_loop:                                             \n"     /* Hitting this error loop will stop the counter incrementing, allowing the check task to recognise an error. */ \\r
747                                         " debug                                                                 \n" \\r
748                                         " j _task2_error_loop                                   \n"     \\r
749                                         "_task2_skip_error_loop:                                \n"     );\r
750 \r
751         /* Load the parameter address from the stack and modify the value. */\r
752         __asm volatile( " ld.w %d1, [%sp]4                                              \n"     \\r
753                                         " add %d1, %d1, 1                                               \n"     \\r
754                                         " st.w [%sp]4, %d1                                              \n"     \\r
755                                         " ld.a %a15, [%sp]                                              \n"     \\r
756                                         " st.w [%a15], %d1                                              \n"     \\r
757                                         " j _task2_loop                                 \n"  );\r
758 \r
759         /* The parameter is used but in the assembly. */\r
760         (void)pvParameters;\r
761 }\r
762 \r
763 /*-----------------------------------------------------------*/\r
764 \r