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