]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RX100_RX113-RSK_Renesas_e2studio/src/Full_Demo/main_full.c
8c520765f59ed6c6a0a3ac4a271c3bf4c6217de8
[freertos] / FreeRTOS / Demo / RX100_RX113-RSK_Renesas_e2studio / src / Full_Demo / main_full.c
1 /*\r
2  * FreeRTOS Kernel V10.2.1\r
3  * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28 /******************************************************************************\r
29  * NOTE 1:  This project provides two demo applications.  A simple blinky\r
30  * style project, and a more comprehensive test and demo application.  The\r
31  * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to\r
32  * select between the two.  See the notes on using\r
33  * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY in main.c.  This file implements the\r
34  * comprehensive version.\r
35  *\r
36  * NOTE 2:  This file only contains the source code that is specific to the\r
37  * full demo.  Generic functions, such FreeRTOS hook functions, and functions\r
38  * required to configure the hardware, are defined in main.c.\r
39  *\r
40  ******************************************************************************\r
41  *\r
42  * main_full() creates a set of demo application tasks and software timers, then\r
43  * starts the scheduler.  The web documentation provides more details of the\r
44  * standard demo application tasks, which provide no particular functionality,\r
45  * but do provide a good example of how to use the FreeRTOS API.\r
46  *\r
47  * In addition to the standard demo tasks, the following tasks and tests are\r
48  * defined and/or created within this file:\r
49  *\r
50  * "FreeRTOS+CLI command console" -  The command console uses SCI1 for its\r
51  * input and output.  The baud rate is set to 19200.  Type "help" to see a list\r
52  * of registered commands.  The FreeRTOS+CLI license is different to the\r
53  * FreeRTOS license, see http://www.FreeRTOS.org/cli for license and usage\r
54  * details.\r
55  *\r
56  * "Reg test" tasks - These fill both the core and floating point registers with\r
57  * known values, then check that each register maintains its expected value for\r
58  * the lifetime of the task.  Each task uses a different set of values.  The reg\r
59  * test tasks execute with a very low priority, so get preempted very\r
60  * frequently.  A register containing an unexpected value is indicative of an\r
61  * error in the context switching mechanism.\r
62  *\r
63  * "Check" task - The check task period is initially set to three seconds.  The\r
64  * task checks that all the standard demo tasks are not only still executing,\r
65  * but are executing without reporting any errors.  If the check task discovers\r
66  * that a task has either stalled, or reported an error, then it changes its own\r
67  * execution period from the initial three seconds, to just 200ms.  The check\r
68  * task also toggles an LED on each iteration of its loop.  This provides a\r
69  * visual indication of the system status:  If the LED toggles every three\r
70  * seconds, then no issues have been discovered.  If the LED toggles every\r
71  * 200ms, then an issue has been discovered with at least one task.\r
72  */\r
73 \r
74 /* Standard includes. */\r
75 #include <stdio.h>\r
76 \r
77 /* Kernel includes. */\r
78 #include "FreeRTOS.h"\r
79 #include "task.h"\r
80 #include "timers.h"\r
81 #include "semphr.h"\r
82 \r
83 /* Standard demo application includes. */\r
84 #include "semtest.h"\r
85 #include "dynamic.h"\r
86 #include "BlockQ.h"\r
87 #include "blocktim.h"\r
88 #include "countsem.h"\r
89 #include "GenQTest.h"\r
90 #include "recmutex.h"\r
91 #include "death.h"\r
92 #include "partest.h"\r
93 #include "comtest2.h"\r
94 #include "serial.h"\r
95 #include "QueueOverwrite.h"\r
96 #include "IntQueue.h"\r
97 #include "EventGroupsDemo.h"\r
98 #include "TaskNotify.h"\r
99 #include "IntSemTest.h"\r
100 \r
101 /* Renesas includes. */\r
102 #include <rskrx113def.h>\r
103 #include "r_cg_macrodriver.h"\r
104 #include "r_cg_userdefine.h"\r
105 \r
106 /* Priorities for the demo application tasks. */\r
107 #define mainSEM_TEST_PRIORITY                           ( tskIDLE_PRIORITY + 1UL )\r
108 #define mainBLOCK_Q_PRIORITY                            ( tskIDLE_PRIORITY + 2UL )\r
109 #define mainCREATOR_TASK_PRIORITY                       ( tskIDLE_PRIORITY + 3UL )\r
110 #define mainUART_COMMAND_CONSOLE_STACK_SIZE     ( configMINIMAL_STACK_SIZE * 3UL )\r
111 #define mainCHECK_TASK_PRIORITY                         ( configMAX_PRIORITIES - 1 )\r
112 #define mainQUEUE_OVERWRITE_PRIORITY            ( tskIDLE_PRIORITY )\r
113 \r
114 /* The priority used by the UART command console task. */\r
115 #define mainUART_COMMAND_CONSOLE_TASK_PRIORITY  ( tskIDLE_PRIORITY + 1 )\r
116 \r
117 /* The period of the check task, in ms, provided no errors have been reported by\r
118 any of the standard demo tasks.  ms are converted to the equivalent in ticks\r
119 using the portTICK_PERIOD_MS constant. */\r
120 #define mainNO_ERROR_CHECK_TASK_PERIOD          pdMS_TO_TICKS( 3000UL )\r
121 \r
122 /* The period of the check task, in ms, if an error has been reported in one of\r
123 the standard demo tasks.  ms are converted to the equivalent in ticks using the\r
124 portTICK_PERIOD_MS constant. */\r
125 #define mainERROR_CHECK_TASK_PERIOD             pdMS_TO_TICKS( 200UL )\r
126 \r
127 /* Parameters that are passed into the register check tasks solely for the\r
128 purpose of ensuring parameters are passed into tasks correctly. */\r
129 #define mainREG_TEST_1_PARAMETER                        ( ( void * ) 0x12121212UL )\r
130 #define mainREG_TEST_2_PARAMETER                        ( ( void * ) 0x12345678UL )\r
131 \r
132 /* The base period used by the timer test tasks. */\r
133 #define mainTIMER_TEST_PERIOD                           ( 50 )\r
134 \r
135 /*-----------------------------------------------------------*/\r
136 \r
137 /*\r
138  * Entry point for the comprehensive demo (as opposed to the simple blinky\r
139  * demo).\r
140  */\r
141 void main_full( void );\r
142 \r
143 /*\r
144  * The full demo includes some functionality called from the tick hook.\r
145  */\r
146 void vFullDemoTickHook( void );\r
147 \r
148  /*\r
149  * The check task, as described at the top of this file.\r
150  */\r
151 static void prvCheckTask( void *pvParameters );\r
152 \r
153 /*\r
154  * Register check tasks, and the tasks used to write over and check the contents\r
155  * of the registers, as described at the top of this file.  The nature of these\r
156  * files necessitates that they are written in assembly, but the entry points\r
157  * are kept in the C file for the convenience of checking the task parameter.\r
158  */\r
159 static void prvRegTest1Task( void *pvParameters );\r
160 static void prvRegTest2Task( void *pvParameters );\r
161 static void prvRegTest1Implementation( void );\r
162 static void prvRegTest2Implementation( void );\r
163 \r
164 /*\r
165  * A high priority task that does nothing other than execute at a pseudo random\r
166  * time to ensure the other test tasks don't just execute in a repeating\r
167  * pattern.\r
168  */\r
169 static void prvPseudoRandomiser( void *pvParameters );\r
170 \r
171 /*\r
172  * Register commands that can be used with FreeRTOS+CLI.  The commands are\r
173  * defined in CLI-Commands.c and File-Related-CLI-Command.c respectively.\r
174  */\r
175 extern void vRegisterSampleCLICommands( void );\r
176 \r
177 /*\r
178  * The task that manages the FreeRTOS+CLI input and output.\r
179  */\r
180 extern void vUARTCommandConsoleStart( uint16_t usStackSize, UBaseType_t uxPriority );\r
181 \r
182 /*-----------------------------------------------------------*/\r
183 \r
184 /* The following two variables are used to communicate the status of the\r
185 register check tasks to the check task.  If the variables keep incrementing,\r
186 then the register check tasks have not discovered any errors.  If a variable\r
187 stops incrementing, then an error has been found. */\r
188 volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL;\r
189 \r
190 /*-----------------------------------------------------------*/\r
191 \r
192 void main_full( void )\r
193 {\r
194         /* Start all the other standard demo/test tasks.  They have no particular\r
195         functionality, but do demonstrate how to use the FreeRTOS API and test the\r
196         kernel port. */\r
197         vStartInterruptQueueTasks();\r
198         vStartDynamicPriorityTasks();\r
199         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
200         vCreateBlockTimeTasks();\r
201         vStartCountingSemaphoreTasks();\r
202         vStartGenericQueueTasks( tskIDLE_PRIORITY );\r
203         vStartRecursiveMutexTasks();\r
204         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
205         vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );\r
206         vStartEventGroupTasks();\r
207         vStartTaskNotifyTask();\r
208         vStartInterruptSemaphoreTasks();\r
209 \r
210         /* Create the register check tasks, as described at the top of this     file */\r
211         xTaskCreate( prvRegTest1Task, "RegTst1", configMINIMAL_STACK_SIZE, mainREG_TEST_1_PARAMETER, tskIDLE_PRIORITY, NULL );\r
212         xTaskCreate( prvRegTest2Task, "RegTst2", configMINIMAL_STACK_SIZE, mainREG_TEST_2_PARAMETER, tskIDLE_PRIORITY, NULL );\r
213 \r
214         /* Create the task that just adds a little random behaviour. */\r
215         xTaskCreate( prvPseudoRandomiser, "Rnd", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL );\r
216 \r
217         /* Start the tasks that implements the command console on the UART, as\r
218         described above. */\r
219         vUARTCommandConsoleStart( mainUART_COMMAND_CONSOLE_STACK_SIZE, mainUART_COMMAND_CONSOLE_TASK_PRIORITY );\r
220 \r
221         /* Register the standard CLI commands. */\r
222         vRegisterSampleCLICommands();\r
223 \r
224         /* Create the task that performs the 'check' functionality,     as described at\r
225         the top of this file. */\r
226         xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
227 \r
228         /* The set of tasks created by the following function call have to be\r
229         created last as they keep account of the number of tasks they expect to see\r
230         running. */\r
231         vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
232 \r
233         /* Start the scheduler. */\r
234         vTaskStartScheduler();\r
235 \r
236         /* If all is well, the scheduler will now be running, and the following\r
237         line will never be reached.  If the following line does execute, then\r
238         there was insufficient FreeRTOS heap memory available for the Idle and/or\r
239         timer tasks to be created.  See the memory management section on the\r
240         FreeRTOS web site for more details on the FreeRTOS heap\r
241         http://www.freertos.org/a00111.html. */\r
242         for( ;; );\r
243 }\r
244 /*-----------------------------------------------------------*/\r
245 \r
246 static void prvCheckTask( void *pvParameters )\r
247 {\r
248 TickType_t xDelayPeriod = mainNO_ERROR_CHECK_TASK_PERIOD;\r
249 TickType_t xLastExecutionTime;\r
250 static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;\r
251 unsigned long ulErrorFound = pdFALSE;\r
252 \r
253         /* Just to stop compiler warnings. */\r
254         ( void ) pvParameters;\r
255 \r
256         /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()\r
257         works correctly. */\r
258         xLastExecutionTime = xTaskGetTickCount();\r
259 \r
260         /* Cycle for ever, delaying then checking all the other tasks are still\r
261         operating without error.  The onboard LED is toggled on each iteration.\r
262         If an error is detected then the delay period is decreased from\r
263         mainNO_ERROR_CHECK_TASK_PERIOD to mainERROR_CHECK_TASK_PERIOD.  This has the\r
264         effect of increasing the rate at which the onboard LED toggles, and in so\r
265         doing gives visual feedback of the system status. */\r
266         for( ;; )\r
267         {\r
268                 /* Delay until it is time to execute again. */\r
269                 vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );\r
270 \r
271                 /* Check all the demo tasks (other than the flash tasks) to ensure\r
272                 that they are all still running, and that none have detected an error. */\r
273                 if( xAreIntQueueTasksStillRunning() != pdTRUE )\r
274                 {\r
275                         ulErrorFound |= 1UL << 0UL;\r
276                 }\r
277 \r
278                 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
279                 {\r
280                         ulErrorFound |= 1UL << 2UL;\r
281                 }\r
282 \r
283                 if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
284                 {\r
285                         ulErrorFound |= 1UL << 3UL;\r
286                 }\r
287 \r
288                 if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
289                 {\r
290                         ulErrorFound |= 1UL << 4UL;\r
291                 }\r
292 \r
293                 if ( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
294                 {\r
295                         ulErrorFound |= 1UL << 5UL;\r
296                 }\r
297 \r
298                 if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
299                 {\r
300                         ulErrorFound |= 1UL << 6UL;\r
301                 }\r
302 \r
303                 if( xIsCreateTaskStillRunning() != pdTRUE )\r
304                 {\r
305                         ulErrorFound |= 1UL << 7UL;\r
306                 }\r
307 \r
308                 if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
309                 {\r
310                         ulErrorFound |= 1UL << 8UL;\r
311                 }\r
312 \r
313                 if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )\r
314                 {\r
315                         ulErrorFound |= 1UL << 10UL;\r
316                 }\r
317 \r
318                 if( xIsQueueOverwriteTaskStillRunning() != pdPASS )\r
319                 {\r
320                         ulErrorFound |= 1UL << 11UL;\r
321                 }\r
322 \r
323                 if( xAreEventGroupTasksStillRunning() != pdPASS )\r
324                 {\r
325                         ulErrorFound |= 1UL << 12UL;\r
326                 }\r
327 \r
328                 if( xAreTaskNotificationTasksStillRunning() != pdTRUE )\r
329                 {\r
330                         ulErrorFound |= 1UL << 13UL;\r
331                 }\r
332 \r
333                 if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )\r
334                 {\r
335                         ulErrorFound |= 1UL << 14UL;\r
336                 }\r
337 \r
338                 /* Check that the register test 1 task is still running. */\r
339                 if( ulLastRegTest1Value == ulRegTest1LoopCounter )\r
340                 {\r
341                         ulErrorFound |= 1UL << 15UL;\r
342                 }\r
343                 ulLastRegTest1Value = ulRegTest1LoopCounter;\r
344 \r
345                 /* Check that the register test 2 task is still running. */\r
346                 if( ulLastRegTest2Value == ulRegTest2LoopCounter )\r
347                 {\r
348                         ulErrorFound |= 1UL << 16UL;\r
349                 }\r
350                 ulLastRegTest2Value = ulRegTest2LoopCounter;\r
351 \r
352                 /* Toggle the check LED to give an indication of the system status.  If\r
353                 the LED toggles every mainNO_ERROR_CHECK_TASK_PERIOD milliseconds then\r
354                 everything is ok.  A faster toggle indicates an error. */\r
355                 LED0 = !LED0;\r
356 \r
357                 if( ulErrorFound != pdFALSE )\r
358                 {\r
359                         /* An error has been detected in one of the tasks - flash the LED\r
360                         at a higher frequency to give visible feedback that something has\r
361                         gone wrong (it might just be that the loop back connector required\r
362                         by the comtest tasks has not been fitted). */\r
363                         xDelayPeriod = mainERROR_CHECK_TASK_PERIOD;\r
364                 }\r
365         }\r
366 }\r
367 /*-----------------------------------------------------------*/\r
368 \r
369 static void prvPseudoRandomiser( void *pvParameters )\r
370 {\r
371 const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL, ulMinDelay = ( 35 / portTICK_PERIOD_MS );\r
372 volatile uint32_t ulNextRand = ( uint32_t ) &pvParameters, ulValue;\r
373 \r
374         /* This task does nothing other than ensure there is a little bit of\r
375         disruption in the scheduling pattern of the other tasks.  Normally this is\r
376         done by generating interrupts at pseudo random times. */\r
377         for( ;; )\r
378         {\r
379                 ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;\r
380                 ulValue = ( ulNextRand >> 16UL ) & 0xffUL;\r
381 \r
382                 if( ulValue < ulMinDelay )\r
383                 {\r
384                         ulValue = ulMinDelay;\r
385                 }\r
386 \r
387                 vTaskDelay( ulValue );\r
388 \r
389                 while( ulValue > 0 )\r
390                 {\r
391                         nop();\r
392                         nop();\r
393                         nop();\r
394                         nop();\r
395                         nop();\r
396                         nop();\r
397                         nop();\r
398                         nop();\r
399 \r
400                         ulValue--;\r
401                 }\r
402         }\r
403 }\r
404 /*-----------------------------------------------------------*/\r
405 \r
406 void vFullDemoTickHook( void )\r
407 {\r
408         /* Call the periodic queue overwrite from ISR demo. */\r
409         vQueueOverwritePeriodicISRDemo();\r
410 \r
411         /* Call the periodic event group from ISR demo. */\r
412         vPeriodicEventGroupsProcessing();\r
413 \r
414         /* Use task notifications from an interrupt. */\r
415         xNotifyTaskFromISR();\r
416 \r
417         /* Use mutexes from interrupts. */\r
418         vInterruptSemaphorePeriodicTest();\r
419 }\r
420 /*-----------------------------------------------------------*/\r
421 \r
422 /* This function is explained in the comments at the top of this file. */\r
423 static void prvRegTest1Task( void *pvParameters )\r
424 {\r
425         if( pvParameters != mainREG_TEST_1_PARAMETER )\r
426         {\r
427                 /* The parameter did not contain the expected value. */\r
428                 for( ;; )\r
429                 {\r
430                         /* Stop the tick interrupt so its obvious something has gone wrong. */\r
431                         taskDISABLE_INTERRUPTS();\r
432                 }\r
433         }\r
434 \r
435         /* This is an inline asm function that never returns. */\r
436         prvRegTest1Implementation();\r
437 }\r
438 /*-----------------------------------------------------------*/\r
439 \r
440 /* This function is explained in the comments at the top of this file. */\r
441 static void prvRegTest2Task( void *pvParameters )\r
442 {\r
443         if( pvParameters != mainREG_TEST_2_PARAMETER )\r
444         {\r
445                 /* The parameter did not contain the expected value. */\r
446                 for( ;; )\r
447                 {\r
448                         /* Stop the tick interrupt so its obvious something has gone wrong. */\r
449                         taskDISABLE_INTERRUPTS();\r
450                 }\r
451         }\r
452 \r
453         /* This is an inline asm function that never returns. */\r
454         prvRegTest2Implementation();\r
455 }\r
456 /*-----------------------------------------------------------*/\r
457 \r
458 /* This function is explained in the comments at the top of this file. */\r
459 #pragma inline_asm prvRegTest1Implementation\r
460 static void prvRegTest1Implementation( void )\r
461 {\r
462         ; Put a known value in each register.\r
463         MOV.L   #1, R1\r
464         MOV.L   #2, R2\r
465         MOV.L   #3, R3\r
466         MOV.L   #4, R4\r
467         MOV.L   #5, R5\r
468         MOV.L   #6, R6\r
469         MOV.L   #7, R7\r
470         MOV.L   #8, R8\r
471         MOV.L   #9, R9\r
472         MOV.L   #10, R10\r
473         MOV.L   #11, R11\r
474         MOV.L   #12, R12\r
475         MOV.L   #13, R13\r
476         MOV.L   #14, R14\r
477         MOV.L   #15, R15\r
478 \r
479         ; Loop, checking each iteration that each register still contains the\r
480         ; expected value.\r
481 TestLoop1:\r
482 \r
483         ; Push the registers that are going to get clobbered.\r
484         PUSHM   R14-R15\r
485 \r
486         ; Increment the loop counter to show this task is still getting CPU time.\r
487         MOV.L   #_ulRegTest1LoopCounter, R14\r
488         MOV.L   [ R14 ], R15\r
489         ADD             #1, R15\r
490         MOV.L   R15, [ R14 ]\r
491 \r
492         ; Yield to extend the text coverage.  Set the bit in the ITU SWINTR register.\r
493         MOV.L   #1, R14\r
494         MOV.L   #0872E0H, R15\r
495         MOV.B   R14, [R15]\r
496         NOP\r
497         NOP\r
498 \r
499         ; Restore the clobbered registers.\r
500         POPM    R14-R15\r
501 \r
502         ; Now compare each register to ensure it still contains the value that was\r
503         ; set before this loop was entered.\r
504         CMP             #1, R1\r
505         BNE             RegTest1Error\r
506         CMP             #2, R2\r
507         BNE             RegTest1Error\r
508         CMP             #3, R3\r
509         BNE             RegTest1Error\r
510         CMP             #4, R4\r
511         BNE             RegTest1Error\r
512         CMP             #5, R5\r
513         BNE             RegTest1Error\r
514         CMP             #6, R6\r
515         BNE             RegTest1Error\r
516         CMP             #7, R7\r
517         BNE             RegTest1Error\r
518         CMP             #8, R8\r
519         BNE             RegTest1Error\r
520         CMP             #9, R9\r
521         BNE             RegTest1Error\r
522         CMP             #10, R10\r
523         BNE             RegTest1Error\r
524         CMP             #11, R11\r
525         BNE             RegTest1Error\r
526         CMP             #12, R12\r
527         BNE             RegTest1Error\r
528         CMP             #13, R13\r
529         BNE             RegTest1Error\r
530         CMP             #14, R14\r
531         BNE             RegTest1Error\r
532         CMP             #15, R15\r
533         BNE             RegTest1Error\r
534 \r
535         ; All comparisons passed, start a new itteratio of this loop.\r
536         BRA             TestLoop1\r
537 \r
538 RegTest1Error:\r
539         ; A compare failed, just loop here so the loop counter stops incrementing\r
540         ; causing the check task to indicate the error.\r
541         BRA RegTest1Error\r
542 }\r
543 /*-----------------------------------------------------------*/\r
544 \r
545 /* This function is explained in the comments at the top of this file. */\r
546 #pragma inline_asm prvRegTest2Implementation\r
547 static void prvRegTest2Implementation( void )\r
548 {\r
549         ; Put a known value in each register.\r
550         MOV.L   #10, R1\r
551         MOV.L   #20, R2\r
552         MOV.L   #30, R3\r
553         MOV.L   #40, R4\r
554         MOV.L   #50, R5\r
555         MOV.L   #60, R6\r
556         MOV.L   #70, R7\r
557         MOV.L   #80, R8\r
558         MOV.L   #90, R9\r
559         MOV.L   #100, R10\r
560         MOV.L   #110, R11\r
561         MOV.L   #120, R12\r
562         MOV.L   #130, R13\r
563         MOV.L   #140, R14\r
564         MOV.L   #150, R15\r
565 \r
566         ; Loop, checking on each iteration that each register still contains the\r
567         ; expected value.\r
568 TestLoop2:\r
569 \r
570         ; Push the registers that are going to get clobbered.\r
571         PUSHM   R14-R15\r
572 \r
573         ; Increment the loop counter to show this task is still getting CPU time.\r
574         MOV.L   #_ulRegTest2LoopCounter, R14\r
575         MOV.L   [ R14 ], R15\r
576         ADD             #1, R15\r
577         MOV.L   R15, [ R14 ]\r
578 \r
579         ; Restore the clobbered registers.\r
580         POPM    R14-R15\r
581 \r
582         CMP             #10, R1\r
583         BNE             RegTest2Error\r
584         CMP             #20, R2\r
585         BNE             RegTest2Error\r
586         CMP             #30, R3\r
587         BNE             RegTest2Error\r
588         CMP             #40, R4\r
589         BNE             RegTest2Error\r
590         CMP             #50, R5\r
591         BNE             RegTest2Error\r
592         CMP             #60, R6\r
593         BNE             RegTest2Error\r
594         CMP             #70, R7\r
595         BNE             RegTest2Error\r
596         CMP             #80, R8\r
597         BNE             RegTest2Error\r
598         CMP             #90, R9\r
599         BNE             RegTest2Error\r
600         CMP             #100, R10\r
601         BNE             RegTest2Error\r
602         CMP             #110, R11\r
603         BNE             RegTest2Error\r
604         CMP             #120, R12\r
605         BNE             RegTest2Error\r
606         CMP             #130, R13\r
607         BNE             RegTest2Error\r
608         CMP             #140, R14\r
609         BNE             RegTest2Error\r
610         CMP             #150, R15\r
611         BNE             RegTest2Error\r
612 \r
613         ; All comparisons passed, start a new itteratio of this loop.\r
614         BRA             TestLoop2\r
615 \r
616 RegTest2Error:\r
617         ; A compare failed, just loop here so the loop counter stops incrementing\r
618         ; - causing the check task to indicate the error.\r
619         BRA RegTest2Error\r
620 }\r
621 /*-----------------------------------------------------------*/\r
622 \r
623 \r
624 \r
625 \r