]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RX200_RX210-RSK_Renesas/RTOSDemo/main-full.c
Update version numbers in preparation for new release.
[freertos] / FreeRTOS / Demo / RX200_RX210-RSK_Renesas / RTOSDemo / main-full.c
1 /*\r
2     FreeRTOS V8.2.2 - Copyright (C) 2015 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     ***************************************************************************\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
19 \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
24 \r
25     ***************************************************************************\r
26      *                                                                       *\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
31      *                                                                       *\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
36      *                                                                       *\r
37     ***************************************************************************\r
38 \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
42 \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
46 \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
51 \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
55 \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
58 \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
62 \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
66 \r
67     1 tab == 4 spaces!\r
68 */\r
69 \r
70 /* ****************************************************************************\r
71  * This project includes a lot of tasks and tests and is therefore complex.\r
72  * If you would prefer a much simpler project to get started with then select\r
73  * the 'Blinky' build configuration within the HEW IDE.  The Blinky build\r
74  * configuration uses main-blinky.c instead of main-full.c.\r
75  * ****************************************************************************\r
76  *\r
77  * Creates all the demo application tasks, then starts the scheduler.  The web\r
78  * documentation provides more details of the standard demo application tasks,\r
79  * which provide no particular functionality but do provide a good example of\r
80  * how to use the FreeRTOS API.\r
81  *\r
82  * In addition to the standard demo tasks, the following tasks and tests are\r
83  * defined and/or created within this file:\r
84  *\r
85  * "Reg test" tasks - These fill the registers with known values, then \r
86  * repeatedly check that each register still contains its expected value for \r
87  * the lifetime of the tasks.  Each task uses different values.  The tasks run \r
88  * with very low priority so get preempted very frequently.  A check variable \r
89  * is incremented on each iteration of the test loop.  A register containing an \r
90  * unexpected value is indicative of an error in the context switching \r
91  * mechanism and will result in a branch to a null loop - which in turn will \r
92  * prevent the check variable from incrementing any further and allow the check \r
93  * timer (described below) to determine that an error has occurred.  The nature \r
94  * of the reg test tasks necessitates that they are written in assembly code.\r
95  *\r
96  * "Check Timer" and Callback Function - The check timer period is initially \r
97  * set to five seconds.  The check timer callback function checks that all the \r
98  * standard demo tasks are not only still executing, but are executing without \r
99  * reporting any errors.  If the check timer discovers that a task has either \r
100  * stalled, or reported an error, then it changes its own period from the \r
101  * initial five seconds, to just 200ms.  The check timer callback function \r
102  * also toggles LED 3 each time it is called.  This provides a visual \r
103  * indication of the system status:  If the LED toggles every five seconds, \r
104  * then no issues have been discovered.  If the LED toggles every 200ms, then \r
105  * an issue has been discovered with at least one task.\r
106  *\r
107  * "High frequency timer test" - A high frequency periodic interrupt is\r
108  * generated using a timer - the interrupt is assigned a priority above\r
109  * configMAX_SYSCALL_INTERRUPT_PRIORITY, so will not be effected by anything\r
110  * the kernel is doing.  The frequency and priority of the interrupt, in\r
111  * combination with other standard tests executed in this demo, will result\r
112  * in interrupts nesting at least 3 and probably 4 deep.  This test is only\r
113  * included in build configurations that have the optimiser switched on.\r
114  *\r
115  * "Button and LCD test" - This creates two tasks.  The first simply scrolls\r
116  * a message back and forth along the top line of the LCD display.  If no\r
117  * buttons are pushed, the second also scrolls a message back and forth, but\r
118  * along the bottom line of the display.  The automatic scrolling of the second\r
119  * line of the display can be started and stopped using button SW2.  Once \r
120  * stopped it can then be manually nudged left using button SW3, and manually\r
121  * nudged right using button SW1.  Button pushes generate an interrupt, and the\r
122  * interrupt communicates with the task using a queue.\r
123  *\r
124  * *NOTE 1* vApplicationSetupTimerInterrupt() is called by the kernel to let\r
125  * the application set up a timer to generate the tick interrupt.  In this\r
126  * example a compare match timer is used for this purpose.\r
127  *\r
128  * *NOTE 2* The CPU must be in Supervisor mode when the scheduler is started.\r
129  * The PowerON_Reset_PC() supplied in resetprg.c with this demo has\r
130  * Change_PSW_PM_to_UserMode() commented out to ensure this is the case.\r
131  *\r
132  * *NOTE 3* The IntQueue common demo tasks test interrupt nesting and make use\r
133  * of all the 8bit timers (as two cascaded 16bit units).\r
134 */\r
135 \r
136 /* Standard includes. */\r
137 #include <string.h>\r
138 \r
139 /* Hardware specific includes. */\r
140 #include "iodefine.h"\r
141 \r
142 /* Kernel includes. */\r
143 #include "FreeRTOS.h"\r
144 #include "task.h"\r
145 #include "timers.h"\r
146 #include "semphr.h"\r
147 \r
148 /* Standard demo includes. */\r
149 #include "partest.h"\r
150 #include "flash.h"\r
151 #include "IntQueue.h"\r
152 #include "BlockQ.h"\r
153 #include "death.h"\r
154 #include "integer.h"\r
155 #include "blocktim.h"\r
156 #include "semtest.h"\r
157 #include "PollQ.h"\r
158 #include "GenQTest.h"\r
159 #include "QPeek.h"\r
160 #include "recmutex.h"\r
161 \r
162 /* Demo specific tasks. */\r
163 #include "ButtonAndLCD.h"\r
164 \r
165 /* Peripheral includes. */\r
166 #include "lcd.h"\r
167 \r
168 /* Values that are passed into the reg test tasks using the task parameter.  \r
169 The tasks check that the values are passed in correctly. */\r
170 #define mainREG_TEST_1_PARAMETER        ( 0x12121212UL )\r
171 #define mainREG_TEST_2_PARAMETER        ( 0x12345678UL )\r
172 \r
173 /* Priorities at which the tasks are created. */\r
174 #define mainQUEUE_POLL_PRIORITY         ( tskIDLE_PRIORITY + 1 )\r
175 #define mainSEM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 1 )\r
176 #define mainBLOCK_Q_PRIORITY            ( tskIDLE_PRIORITY + 2 )\r
177 #define mainCREATOR_TASK_PRIORITY   ( tskIDLE_PRIORITY + 3 )\r
178 #define mainFLASH_TASK_PRIORITY         ( tskIDLE_PRIORITY + 1 )\r
179 #define mainINTEGER_TASK_PRIORITY   ( tskIDLE_PRIORITY )\r
180 #define mainGEN_QUEUE_TASK_PRIORITY     ( tskIDLE_PRIORITY )\r
181 #define mainFLOP_TASK_PRIORITY          ( tskIDLE_PRIORITY )\r
182 \r
183 /* The LED toggled by the check timer. */\r
184 #define mainCHECK_LED                           ( 3 )\r
185 \r
186 /* The period at which the check timer will expire, in ms, provided no errors\r
187 have been reported by any of the standard demo tasks.  ms are converted to the\r
188 equivalent in ticks using the portTICK_PERIOD_MS constant. */\r
189 #define mainCHECK_TIMER_PERIOD_MS                       ( 5000UL / portTICK_PERIOD_MS )\r
190 \r
191 /* The period at which the check timer will expire, in ms, if an error has been\r
192 reported in one of the standard demo tasks.  ms are converted to the equivalent\r
193 in ticks using the portTICK_PERIOD_MS constant. */\r
194 #define mainERROR_CHECK_TIMER_PERIOD_MS         ( 200UL / portTICK_PERIOD_MS )\r
195 \r
196 /* A block time of zero simple means "Don't Block". */\r
197 #define mainDONT_BLOCK                          ( 0UL )\r
198 \r
199 /*\r
200  * vApplicationMallocFailedHook() will only be called if\r
201  * configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook\r
202  * function that will execute if a call to pvPortMalloc() fails.\r
203  * pvPortMalloc() is called internally by the kernel whenever a task, queue or\r
204  * semaphore is created.  It is also called by various parts of the demo\r
205  * application.\r
206  */\r
207 void vApplicationMallocFailedHook( void );\r
208 \r
209 /*\r
210  * vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set to 1\r
211  * in FreeRTOSConfig.h.  It is a hook function that is called on each iteration\r
212  * of the idle task.  It is essential that code added to this hook function\r
213  * never attempts to block in any way (for example, call xQueueReceive() with\r
214  * a block time specified).  If the application makes use of the vTaskDelete()\r
215  * API function (as this demo application does) then it is also important that\r
216  * vApplicationIdleHook() is permitted to return to its calling function because\r
217  * it is the responsibility of the idle task to clean up memory allocated by the\r
218  * kernel to any task that has since been deleted.\r
219  */\r
220 void vApplicationIdleHook( void );\r
221 \r
222 /*\r
223  * vApplicationStackOverflowHook() will only be called if\r
224  * configCHECK_FOR_STACK_OVERFLOW is set to a non-zero value.  The handle and\r
225  * name of the offending task should be passed in the function parameters, but\r
226  * it is possible that the stack overflow will have corrupted these - in which\r
227  * case pxCurrentTCB can be inspected to find the same information.\r
228  */\r
229 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );\r
230 \r
231 /*\r
232  * The reg test tasks as described at the top of this file.\r
233  */\r
234 static void prvRegTest1Task( void *pvParameters );\r
235 static void prvRegTest2Task( void *pvParameters );\r
236 \r
237 /*\r
238  * The actual implementation of the reg test functionality, which, because of\r
239  * the direct register access, have to be in assembly.\r
240  */\r
241 static void prvRegTest1Implementation( void );\r
242 static void prvRegTest2Implementation( void );\r
243 \r
244 /*\r
245  * The check timer callback function, as described at the top of this file.\r
246  */\r
247 static void prvCheckTimerCallback( TimerHandle_t xTimer );\r
248 \r
249 \r
250 /*-----------------------------------------------------------*/\r
251 \r
252 /* Variables that are incremented on each iteration of the reg test tasks -\r
253 provided the tasks have not reported any errors.  The check timer inspects these\r
254 variables to ensure they are still incrementing as expected.  If a variable\r
255 stops incrementing then it is likely that its associate task has stalled. */\r
256 unsigned long ulRegTest1CycleCount = 0UL, ulRegTest2CycleCount = 0UL;\r
257 \r
258 /* The check timer.  This uses prvCheckTimerCallback() as its callback\r
259 function. */\r
260 static TimerHandle_t xCheckTimer = NULL;\r
261 \r
262 /*-----------------------------------------------------------*/\r
263 \r
264 void main(void)\r
265 {\r
266 extern void HardwareSetup( void );\r
267 \r
268         /* Renesas provided CPU configuration routine.  The clocks are configured in\r
269         here. */\r
270         HardwareSetup();        \r
271 \r
272         /* Turn all LEDs off. */\r
273         vParTestInitialise();\r
274 \r
275         /* Start the reg test tasks which test the context switching mechanism. */\r
276         xTaskCreate( prvRegTest1Task, "RegTst1", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_1_PARAMETER, tskIDLE_PRIORITY, NULL );\r
277         xTaskCreate( prvRegTest2Task, "RegTst2", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_2_PARAMETER, tskIDLE_PRIORITY, NULL );\r
278 \r
279         /* The button and LCD tasks, as described at the top of this file. */\r
280         vStartButtonAndLCDDemo();\r
281 \r
282         /* Create the standard demo tasks. */\r
283         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
284         vCreateBlockTimeTasks();\r
285         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
286         vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
287         vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );\r
288         vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );\r
289         vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );\r
290         vStartQueuePeekTasks();\r
291         vStartRecursiveMutexTasks();\r
292         vStartInterruptQueueTasks();\r
293 \r
294         /* The suicide tasks must be created last as they need to know how many\r
295         tasks were running prior to their creation in order to ascertain whether\r
296         or not the correct/expected number of tasks are running at any given time. */\r
297         vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
298 \r
299         /* Create the software timer that performs the 'check' functionality,\r
300         as described at the top of this file. */\r
301         xCheckTimer = xTimerCreate( "CheckTimer",/* A text name, purely to help debugging. */\r
302                                                                 ( mainCHECK_TIMER_PERIOD_MS ),          /* The timer period, in this case 5000ms (5s). */\r
303                                                                 pdTRUE,                                                         /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */\r
304                                                                 ( void * ) 0,                                           /* The ID is not used, so can be set to anything. */\r
305                                                                 prvCheckTimerCallback                           /* The callback function that inspects the status of all the other tasks. */\r
306                                                           );\r
307                                                           \r
308         configASSERT( xCheckTimer );\r
309         \r
310         /* Start the check timer.  It will actually start when the scheduler is\r
311         started. */\r
312         xTimerStart( xCheckTimer, mainDONT_BLOCK );\r
313 \r
314         /* Start the tasks running. */\r
315         vTaskStartScheduler();\r
316 \r
317         /* If all is well we will never reach here as the scheduler will now be\r
318         running.  If we do reach here then it is likely that there was insufficient\r
319         heap available for the idle task to be created. */\r
320         for( ;; );\r
321 }\r
322 /*-----------------------------------------------------------*/\r
323 \r
324 static void prvCheckTimerCallback( TimerHandle_t xTimer )\r
325 {\r
326 static long lChangedTimerPeriodAlready = pdFALSE, lErrorStatus = pdPASS;\r
327 static volatile unsigned long ulLastRegTest1CycleCount = 0UL, ulLastRegTest2CycleCount = 0UL;\r
328 \r
329         /* Check the standard demo tasks are running without error. */\r
330         if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
331         {\r
332                 lErrorStatus = pdFAIL;\r
333         }\r
334         else if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
335         {\r
336                 lErrorStatus = pdFAIL;\r
337         }\r
338         else if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
339         {\r
340                 lErrorStatus = pdFAIL;\r
341         }\r
342         else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
343         {\r
344                 lErrorStatus = pdFAIL;\r
345         }\r
346         else if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
347         {\r
348                 lErrorStatus = pdFAIL;\r
349         }\r
350         else if( xArePollingQueuesStillRunning() != pdTRUE )\r
351         {\r
352                 lErrorStatus = pdFAIL;\r
353         }\r
354         else if( xIsCreateTaskStillRunning() != pdTRUE )\r
355         {\r
356                 lErrorStatus = pdFAIL;\r
357         }\r
358         else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
359         {\r
360                 lErrorStatus = pdFAIL;\r
361         }\r
362         else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
363         {\r
364                 lErrorStatus = pdFAIL;\r
365         }\r
366         else if( xAreIntQueueTasksStillRunning() != pdPASS )\r
367         {\r
368                 lErrorStatus = pdFAIL;\r
369         }\r
370 \r
371         /* Check the reg test tasks are still cycling.  They will stop incrementing\r
372         their loop counters if they encounter an error. */\r
373         if( ulRegTest1CycleCount == ulLastRegTest1CycleCount )\r
374         {\r
375                 lErrorStatus = pdFAIL;\r
376         }\r
377 \r
378         if( ulRegTest2CycleCount == ulLastRegTest2CycleCount )\r
379         {\r
380                 lErrorStatus = pdFAIL;\r
381         }\r
382 \r
383         ulLastRegTest1CycleCount = ulRegTest1CycleCount;\r
384         ulLastRegTest2CycleCount = ulRegTest2CycleCount;\r
385 \r
386         /* Toggle the check LED to give an indication of the system status.  If\r
387         the LED toggles every 5 seconds then everything is ok.  A faster toggle\r
388         indicates an error. */\r
389         vParTestToggleLED( mainCHECK_LED );\r
390         \r
391         /* Was an error detected this time through the callback execution? */\r
392         if( lErrorStatus != pdPASS )\r
393         {\r
394                 if( lChangedTimerPeriodAlready == pdFALSE )\r
395                 {\r
396                         lChangedTimerPeriodAlready = pdTRUE;\r
397                         \r
398                         /* This call to xTimerChangePeriod() uses a zero block time.  \r
399                         Functions called from inside of a timer callback function must \r
400                         *never* attempt to block. */\r
401                         xTimerChangePeriod( xCheckTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK );\r
402                 }\r
403         }\r
404 }\r
405 /*-----------------------------------------------------------*/\r
406 \r
407 /* The RX port uses this callback function to configure its tick interrupt.\r
408 This allows the application to choose the tick interrupt source. */\r
409 void vApplicationSetupTimerInterrupt( void )\r
410 {\r
411         /* Enable compare match timer 0. */\r
412         MSTP( CMT0 ) = 0;\r
413 \r
414         /* Interrupt on compare match. */\r
415         CMT0.CMCR.BIT.CMIE = 1;\r
416 \r
417         /* Set the compare match value. */\r
418         CMT0.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ ) -1 ) / 8 );\r
419 \r
420         /* Divide the PCLK by 8. */\r
421         CMT0.CMCR.BIT.CKS = 0;\r
422 \r
423         /* Enable the interrupt... */\r
424         _IEN( _CMT0_CMI0 ) = 1;\r
425 \r
426         /* ...and set its priority to the application defined kernel priority. */\r
427         _IPR( _CMT0_CMI0 ) = configKERNEL_INTERRUPT_PRIORITY;\r
428 \r
429         /* Start the timer. */\r
430         CMT.CMSTR0.BIT.STR0 = 1;\r
431 }\r
432 /*-----------------------------------------------------------*/\r
433 \r
434 /* This function is explained by the comments above its prototype at the top\r
435 of this file. */\r
436 void vApplicationMallocFailedHook( void )\r
437 {\r
438         for( ;; );\r
439 }\r
440 /*-----------------------------------------------------------*/\r
441 \r
442 /* This function is explained by the comments above its prototype at the top\r
443 of this file. */\r
444 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )\r
445 {\r
446         for( ;; );\r
447 }\r
448 /*-----------------------------------------------------------*/\r
449 \r
450 /* This function is explained by the comments above its prototype at the top\r
451 of this file. */\r
452 void vApplicationIdleHook( void )\r
453 {\r
454         /* If this is being executed then the kernel has been started.  Start the high\r
455         frequency timer test as described at the top of this file.  This is only\r
456         included in the optimised build configuration - otherwise it takes up too much\r
457         CPU time and can disrupt other tests. */\r
458         #ifdef INCLUDE_HIGH_FREQUENCY_TIMER_TEST\r
459         static portBASE_TYPE xTimerTestStarted = pdFALSE;\r
460         extern void vSetupHighFrequencyTimer( void );\r
461                 if( xTimerTestStarted == pdFALSE )\r
462                 {\r
463                         vSetupHighFrequencyTimer();\r
464                         xTimerTestStarted = pdTRUE;\r
465                 }\r
466         #endif\r
467 }\r
468 /*-----------------------------------------------------------*/\r
469 \r
470 /* This function is explained in the comments at the top of this file. */\r
471 static void prvRegTest1Task( void *pvParameters )\r
472 {\r
473         if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_1_PARAMETER )\r
474         {\r
475                 /* The parameter did not contain the expected value. */\r
476                 for( ;; )\r
477                 {\r
478                         /* Stop the tick interrupt so its obvious something has gone wrong. */\r
479                         taskDISABLE_INTERRUPTS();\r
480                 }\r
481         }\r
482 \r
483         /* This is an inline asm function that never returns. */\r
484         prvRegTest1Implementation();\r
485 }\r
486 /*-----------------------------------------------------------*/\r
487 \r
488 /* This function is explained in the comments at the top of this file. */\r
489 static void prvRegTest2Task( void *pvParameters )\r
490 {\r
491         if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_2_PARAMETER )\r
492         {\r
493                 /* The parameter did not contain the expected value. */\r
494                 for( ;; )\r
495                 {\r
496                         /* Stop the tick interrupt so its obvious something has gone wrong. */\r
497                         taskDISABLE_INTERRUPTS();\r
498                 }\r
499         }\r
500 \r
501         /* This is an inline asm function that never returns. */\r
502         prvRegTest2Implementation();\r
503 }\r
504 /*-----------------------------------------------------------*/\r
505 \r
506 /* This function is explained in the comments at the top of this file. */\r
507 #pragma inline_asm prvRegTest1Implementation\r
508 static void prvRegTest1Implementation( void )\r
509 {\r
510         ; Put a known value in each register.\r
511         MOV.L   #1, R1\r
512         MOV.L   #2, R2\r
513         MOV.L   #3, R3\r
514         MOV.L   #4, R4\r
515         MOV.L   #5, R5\r
516         MOV.L   #6, R6\r
517         MOV.L   #7, R7\r
518         MOV.L   #8, R8\r
519         MOV.L   #9, R9\r
520         MOV.L   #10, R10\r
521         MOV.L   #11, R11\r
522         MOV.L   #12, R12\r
523         MOV.L   #13, R13\r
524         MOV.L   #14, R14\r
525         MOV.L   #15, R15\r
526 \r
527         ; Loop, checking each itteration that each register still contains the\r
528         ; expected value.\r
529 TestLoop1:\r
530 \r
531         ; Push the registers that are going to get clobbered.\r
532         PUSHM   R14-R15\r
533 \r
534         ; Increment the loop counter to show this task is still getting CPU time.\r
535         MOV.L   #_ulRegTest1CycleCount, R14\r
536         MOV.L   [ R14 ], R15\r
537         ADD             #1, R15\r
538         MOV.L   R15, [ R14 ]\r
539 \r
540         ; Yield to extend the text coverage.  Set the bit in the ITU SWINTR register.\r
541         MOV.L   #1, R14\r
542         MOV.L   #0872E0H, R15\r
543         MOV.B   R14, [R15]\r
544         NOP\r
545         NOP\r
546 \r
547         ; Restore the clobbered registers.\r
548         POPM    R14-R15\r
549 \r
550         ; Now compare each register to ensure it still contains the value that was\r
551         ; set before this loop was entered.\r
552         CMP             #1, R1\r
553         BNE             RegTest1Error\r
554         CMP             #2, R2\r
555         BNE             RegTest1Error\r
556         CMP             #3, R3\r
557         BNE             RegTest1Error\r
558         CMP             #4, R4\r
559         BNE             RegTest1Error\r
560         CMP             #5, R5\r
561         BNE             RegTest1Error\r
562         CMP             #6, R6\r
563         BNE             RegTest1Error\r
564         CMP             #7, R7\r
565         BNE             RegTest1Error\r
566         CMP             #8, R8\r
567         BNE             RegTest1Error\r
568         CMP             #9, R9\r
569         BNE             RegTest1Error\r
570         CMP             #10, R10\r
571         BNE             RegTest1Error\r
572         CMP             #11, R11\r
573         BNE             RegTest1Error\r
574         CMP             #12, R12\r
575         BNE             RegTest1Error\r
576         CMP             #13, R13\r
577         BNE             RegTest1Error\r
578         CMP             #14, R14\r
579         BNE             RegTest1Error\r
580         CMP             #15, R15\r
581         BNE             RegTest1Error\r
582 \r
583         ; All comparisons passed, start a new itteratio of this loop.\r
584         BRA             TestLoop1\r
585 \r
586 RegTest1Error:\r
587         ; A compare failed, just loop here so the loop counter stops incrementing\r
588         ; causing the check timer to indicate the error.\r
589         BRA RegTest1Error\r
590 }\r
591 /*-----------------------------------------------------------*/\r
592 \r
593 /* This function is explained in the comments at the top of this file. */\r
594 #pragma inline_asm prvRegTest2Implementation\r
595 static void prvRegTest2Implementation( void )\r
596 {\r
597         ; Put a known value in each register.\r
598         MOV.L   #10, R1\r
599         MOV.L   #20, R2\r
600         MOV.L   #30, R3\r
601         MOV.L   #40, R4\r
602         MOV.L   #50, R5\r
603         MOV.L   #60, R6\r
604         MOV.L   #70, R7\r
605         MOV.L   #80, R8\r
606         MOV.L   #90, R9\r
607         MOV.L   #100, R10\r
608         MOV.L   #110, R11\r
609         MOV.L   #120, R12\r
610         MOV.L   #130, R13\r
611         MOV.L   #140, R14\r
612         MOV.L   #150, R15\r
613 \r
614         ; Loop, checking on each itteration that each register still contains the\r
615         ; expected value.\r
616 TestLoop2:\r
617 \r
618         ; Push the registers that are going to get clobbered.\r
619         PUSHM   R14-R15\r
620 \r
621         ; Increment the loop counter to show this task is still getting CPU time.\r
622         MOV.L   #_ulRegTest2CycleCount, R14\r
623         MOV.L   [ R14 ], R15\r
624         ADD             #1, R15\r
625         MOV.L   R15, [ R14 ]\r
626 \r
627         ; Restore the clobbered registers.\r
628         POPM    R14-R15\r
629 \r
630         CMP             #10, R1\r
631         BNE             RegTest2Error\r
632         CMP             #20, R2\r
633         BNE             RegTest2Error\r
634         CMP             #30, R3\r
635         BNE             RegTest2Error\r
636         CMP             #40, R4\r
637         BNE             RegTest2Error\r
638         CMP             #50, R5\r
639         BNE             RegTest2Error\r
640         CMP             #60, R6\r
641         BNE             RegTest2Error\r
642         CMP             #70, R7\r
643         BNE             RegTest2Error\r
644         CMP             #80, R8\r
645         BNE             RegTest2Error\r
646         CMP             #90, R9\r
647         BNE             RegTest2Error\r
648         CMP             #100, R10\r
649         BNE             RegTest2Error\r
650         CMP             #110, R11\r
651         BNE             RegTest2Error\r
652         CMP             #120, R12\r
653         BNE             RegTest2Error\r
654         CMP             #130, R13\r
655         BNE             RegTest2Error\r
656         CMP             #140, R14\r
657         BNE             RegTest2Error\r
658         CMP             #150, R15\r
659         BNE             RegTest2Error\r
660 \r
661         ; All comparisons passed, start a new itteratio of this loop.\r
662         BRA             TestLoop2\r
663 \r
664 RegTest2Error:\r
665         ; A compare failed, just loop here so the loop counter stops incrementing\r
666         ; - causing the check timer to indicate the error.\r
667         BRA RegTest2Error\r
668 }\r
669 /*-----------------------------------------------------------*/\r
670 \r