]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/RX113-RSK_Renesas_e2studio/src/Full_Demo/main_full.c
Baseline new GCC and Renesas compiler projects for RX71M and RX113 before adding...
[freertos] / FreeRTOS / Demo / RX113-RSK_Renesas_e2studio / src / Full_Demo / main_full.c
diff --git a/FreeRTOS/Demo/RX113-RSK_Renesas_e2studio/src/Full_Demo/main_full.c b/FreeRTOS/Demo/RX113-RSK_Renesas_e2studio/src/Full_Demo/main_full.c
new file mode 100644 (file)
index 0000000..859a90c
--- /dev/null
@@ -0,0 +1,665 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+/******************************************************************************\r
+ * NOTE 1:  This project provides two demo applications.  A simple blinky\r
+ * style project, and a more comprehensive test and demo application.  The\r
+ * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to\r
+ * select between the two.  See the notes on using\r
+ * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY in main.c.  This file implements the\r
+ * comprehensive version.\r
+ *\r
+ * NOTE 2:  This file only contains the source code that is specific to the\r
+ * full demo.  Generic functions, such FreeRTOS hook functions, and functions\r
+ * required to configure the hardware, are defined in main.c.\r
+ *\r
+ ******************************************************************************\r
+ *\r
+ * main_full() creates all the demo application tasks and software timers, then\r
+ * starts the scheduler.  The web documentation provides more details of the\r
+ * standard demo application tasks, which provide no particular functionality,\r
+ * but do provide a good example of how to use the FreeRTOS API.\r
+ *\r
+ * In addition to the standard demo tasks, the following tasks and tests are\r
+ * defined and/or created within this file:\r
+ *\r
+ * "Reg test" tasks - These fill both the core and floating point registers with\r
+ * known values, then check that each register maintains its expected value for\r
+ * the lifetime of the task.  Each task uses a different set of values.  The reg\r
+ * test tasks execute with a very low priority, so get preempted very\r
+ * frequently.  A register containing an unexpected value is indicative of an\r
+ * error in the context switching mechanism.\r
+ *\r
+ * "Check" task - The check task period is initially set to three seconds.  The\r
+ * task checks that all the standard demo tasks, and the register check tasks,\r
+ * are not only still executing, but are executing without reporting any errors.\r
+ * If the check task discovers that a task has either stalled, or reported an\r
+ * error, then it changes its own execution period from the initial three\r
+ * seconds, to just 200ms.  The check task also toggles an LED each time it is\r
+ * called.  This provides a visual indication of the system status:  If the LED\r
+ * toggles every three seconds, then no issues have been discovered.  If the LED\r
+ * toggles every 200ms, then an issue has been discovered with at least one\r
+ * task.\r
+ */\r
+\r
+/* Standard includes. */\r
+#include <stdio.h>\r
+\r
+/* Kernel includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+#include "timers.h"\r
+#include "semphr.h"\r
+\r
+/* Standard demo application includes. */\r
+#include "semtest.h"\r
+#include "dynamic.h"\r
+#include "BlockQ.h"\r
+#include "blocktim.h"\r
+#include "countsem.h"\r
+#include "GenQTest.h"\r
+#include "recmutex.h"\r
+#include "death.h"\r
+#include "partest.h"\r
+#include "comtest2.h"\r
+#include "serial.h"\r
+#include "TimerDemo.h"\r
+#include "QueueOverwrite.h"\r
+#include "IntQueue.h"\r
+#include "EventGroupsDemo.h"\r
+#include "TaskNotify.h"\r
+#include "IntSemTest.h"\r
+\r
+/* Renesas includes. */\r
+#include <rskrx113def.h>\r
+#include "r_cg_macrodriver.h"\r
+#include "r_cg_userdefine.h"\r
+\r
+/* Priorities for the demo application tasks. */\r
+#define mainSEM_TEST_PRIORITY                          ( tskIDLE_PRIORITY + 1UL )\r
+#define mainBLOCK_Q_PRIORITY                           ( tskIDLE_PRIORITY + 2UL )\r
+#define mainCREATOR_TASK_PRIORITY                      ( tskIDLE_PRIORITY + 3UL )\r
+#define mainUART_COMMAND_CONSOLE_STACK_SIZE    ( configMINIMAL_STACK_SIZE * 3UL )\r
+#define mainCOM_TEST_TASK_PRIORITY                     ( tskIDLE_PRIORITY + 2 )\r
+#define mainCHECK_TASK_PRIORITY                                ( configMAX_PRIORITIES - 1 )\r
+#define mainQUEUE_OVERWRITE_PRIORITY           ( tskIDLE_PRIORITY )\r
+\r
+/* The priority used by the UART command console task. */\r
+#define mainUART_COMMAND_CONSOLE_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )\r
+\r
+/* A block time of zero simply means "don't block". */\r
+#define mainDONT_BLOCK                                         ( 0UL )\r
+\r
+/* The period after which the check timer will expire, in ms, provided no errors\r
+have been reported by any of the standard demo tasks.  ms are converted to the\r
+equivalent in ticks using the portTICK_PERIOD_MS constant. */\r
+#define mainNO_ERROR_CHECK_TASK_PERIOD         ( 3000UL / portTICK_PERIOD_MS )\r
+\r
+/* The period at which the check timer will expire, in ms, if an error has been\r
+reported in one of the standard demo tasks.  ms are converted to the equivalent\r
+in ticks using the portTICK_PERIOD_MS constant. */\r
+#define mainERROR_CHECK_TASK_PERIOD            ( 200UL / portTICK_PERIOD_MS )\r
+\r
+/* Parameters that are passed into the register check tasks solely for the\r
+purpose of ensuring parameters are passed into tasks correctly. */\r
+#define mainREG_TEST_1_PARAMETER       ( ( void * ) 0x12121212UL )\r
+#define mainREG_TEST_2_PARAMETER       ( ( void * ) 0x12345678UL )\r
+\r
+/* The base period used by the timer test tasks. */\r
+#define mainTIMER_TEST_PERIOD                          ( 50 )\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Entry point for the comprehensive demo (as opposed to the simple blinky\r
+ * demo).\r
+ */\r
+void main_full( void );\r
+\r
+/*\r
+ * The full demo includes some functionality called from the tick hook.\r
+ */\r
+void vFullDemoTickHook( void );\r
+\r
+ /*\r
+ * The check task, as described at the top of this file.\r
+ */\r
+static void prvCheckTask( void *pvParameters );\r
+\r
+/*\r
+ * Register check tasks, and the tasks used to write over and check the contents\r
+ * of the registers, as described at the top of this file.  The nature of these\r
+ * files necessitates that they are written in assembly, but the entry points\r
+ * are kept in the C file for the convenience of checking the task parameter.\r
+ */\r
+static void prvRegTest1Task( void *pvParameters );\r
+static void prvRegTest2Task( void *pvParameters );\r
+static void prvRegTest1Implementation( void );\r
+static void prvRegTest2Implementation( void );\r
+\r
+/*\r
+ * A high priority task that does nothing other than execute at a pseudo random\r
+ * time to ensure the other test tasks don't just execute in a repeating\r
+ * pattern.\r
+ */\r
+static void prvPseudoRandomiser( void *pvParameters );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* The following two variables are used to communicate the status of the\r
+register check tasks to the check task.  If the variables keep incrementing,\r
+then the register check tasks have not discovered any errors.  If a variable\r
+stops incrementing, then an error has been found. */\r
+volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL;\r
+\r
+/* String for display in the web server.  It is set to an error message if the\r
+check task detects an error.  */\r
+const char *pcStatusMessage = "All tasks running without error";\r
+/*-----------------------------------------------------------*/\r
+\r
+void main_full( void )\r
+{\r
+       /* Start all the other standard demo/test tasks.  They have no particular\r
+       functionality, but do demonstrate how to use the FreeRTOS API and test the\r
+       kernel port. */\r
+       vStartInterruptQueueTasks();\r
+       vStartDynamicPriorityTasks();\r
+       vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
+       vCreateBlockTimeTasks();\r
+       vStartCountingSemaphoreTasks();\r
+       vStartGenericQueueTasks( tskIDLE_PRIORITY );\r
+       vStartRecursiveMutexTasks();\r
+       vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
+       vStartTimerDemoTask( mainTIMER_TEST_PERIOD );\r
+       vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );\r
+       vStartEventGroupTasks();\r
+       vStartTaskNotifyTask();\r
+       vStartInterruptSemaphoreTasks();\r
+\r
+       /* Create the register check tasks, as described at the top of this     file */\r
+       xTaskCreate( prvRegTest1Task, "RegTst1", configMINIMAL_STACK_SIZE, mainREG_TEST_1_PARAMETER, tskIDLE_PRIORITY, NULL );\r
+       xTaskCreate( prvRegTest2Task, "RegTst2", configMINIMAL_STACK_SIZE, mainREG_TEST_2_PARAMETER, tskIDLE_PRIORITY, NULL );\r
+\r
+       /* Create the task that just adds a little random behaviour. */\r
+       xTaskCreate( prvPseudoRandomiser, "Rnd", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL );\r
+\r
+       /* Create the task that performs the 'check' functionality,     as described at\r
+       the top of this file. */\r
+       xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
+\r
+       /* The set of tasks created by the following function call have to be\r
+       created last as they keep account of the number of tasks they expect to see\r
+       running. */\r
+       vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
+\r
+       /* Start the scheduler. */\r
+       vTaskStartScheduler();\r
+\r
+       /* If all is well, the scheduler will now be running, and the following\r
+       line will never be reached.  If the following line does execute, then\r
+       there was either insufficient FreeRTOS heap memory available for the idle\r
+       and/or timer tasks to be created, or vTaskStartScheduler() was called from\r
+       User mode.  See the memory management section on the FreeRTOS web site for\r
+       more details on the FreeRTOS heap http://www.freertos.org/a00111.html.  The\r
+       mode from which main() is called is set in the C start up code and must be\r
+       a privileged mode (not user mode). */\r
+       for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCheckTask( void *pvParameters )\r
+{\r
+TickType_t xDelayPeriod = mainNO_ERROR_CHECK_TASK_PERIOD;\r
+TickType_t xLastExecutionTime;\r
+static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;\r
+unsigned long ulErrorFound = pdFALSE;\r
+\r
+       /* Just to stop compiler warnings. */\r
+       ( void ) pvParameters;\r
+\r
+       /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()\r
+       works correctly. */\r
+       xLastExecutionTime = xTaskGetTickCount();\r
+\r
+       /* Cycle for ever, delaying then checking all the other tasks are still\r
+       operating without error.  The onboard LED is toggled on each iteration.\r
+       If an error is detected then the delay period is decreased from\r
+       mainNO_ERROR_CHECK_TASK_PERIOD to mainERROR_CHECK_TASK_PERIOD.  This has the\r
+       effect of increasing the rate at which the onboard LED toggles, and in so\r
+       doing gives visual feedback of the system status. */\r
+       for( ;; )\r
+       {\r
+               /* Delay until it is time to execute again. */\r
+               vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );\r
+\r
+               /* Check all the demo tasks (other than the flash tasks) to ensure\r
+               that they are all still running, and that none have detected an error. */\r
+               if( xAreIntQueueTasksStillRunning() != pdTRUE )\r
+               {\r
+                       ulErrorFound |= 1UL << 0UL;\r
+               }\r
+\r
+               if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
+               {\r
+                       ulErrorFound |= 1UL << 2UL;\r
+               }\r
+\r
+               if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
+               {\r
+                       ulErrorFound |= 1UL << 3UL;\r
+               }\r
+\r
+               if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
+               {\r
+                       ulErrorFound |= 1UL << 4UL;\r
+               }\r
+\r
+               if ( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
+               {\r
+                       ulErrorFound |= 1UL << 5UL;\r
+               }\r
+\r
+               if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
+               {\r
+                       ulErrorFound |= 1UL << 6UL;\r
+               }\r
+\r
+               if( xIsCreateTaskStillRunning() != pdTRUE )\r
+               {\r
+                       ulErrorFound |= 1UL << 7UL;\r
+               }\r
+\r
+               if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
+               {\r
+                       ulErrorFound |= 1UL << 8UL;\r
+               }\r
+\r
+               if( xAreTimerDemoTasksStillRunning( ( TickType_t ) mainNO_ERROR_CHECK_TASK_PERIOD ) != pdPASS )\r
+               {\r
+                       ulErrorFound |= 1UL << 9UL;\r
+               }\r
+\r
+               if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )\r
+               {\r
+                       ulErrorFound |= 1UL << 10UL;\r
+               }\r
+\r
+               if( xIsQueueOverwriteTaskStillRunning() != pdPASS )\r
+               {\r
+                       ulErrorFound |= 1UL << 11UL;\r
+               }\r
+\r
+               if( xAreEventGroupTasksStillRunning() != pdPASS )\r
+               {\r
+                       ulErrorFound |= 1UL << 12UL;\r
+               }\r
+\r
+               if( xAreTaskNotificationTasksStillRunning() != pdTRUE )\r
+               {\r
+                       ulErrorFound |= 1UL << 13UL;\r
+               }\r
+\r
+               if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )\r
+               {\r
+                       ulErrorFound |= 1UL << 14UL;\r
+               }\r
+\r
+               /* Check that the register test 1 task is still running. */\r
+               if( ulLastRegTest1Value == ulRegTest1LoopCounter )\r
+               {\r
+                       ulErrorFound |= 1UL << 15UL;\r
+               }\r
+               ulLastRegTest1Value = ulRegTest1LoopCounter;\r
+\r
+               /* Check that the register test 2 task is still running. */\r
+               if( ulLastRegTest2Value == ulRegTest2LoopCounter )\r
+               {\r
+                       ulErrorFound |= 1UL << 16UL;\r
+               }\r
+               ulLastRegTest2Value = ulRegTest2LoopCounter;\r
+\r
+               /* Toggle the check LED to give an indication of the system status.  If\r
+               the LED toggles every mainNO_ERROR_CHECK_TASK_PERIOD milliseconds then\r
+               everything is ok.  A faster toggle indicates an error. */\r
+               LED0 = !LED0;\r
+\r
+               if( ulErrorFound != pdFALSE )\r
+               {\r
+                       /* An error has been detected in one of the tasks - flash the LED\r
+                       at a higher frequency to give visible feedback that something has\r
+                       gone wrong (it might just be that the loop back connector required\r
+                       by the comtest tasks has not been fitted). */\r
+                       xDelayPeriod = mainERROR_CHECK_TASK_PERIOD;\r
+                       pcStatusMessage = "Error found in at least one task.";\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvPseudoRandomiser( void *pvParameters )\r
+{\r
+const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL, ulMinDelay = ( 35 / portTICK_PERIOD_MS );\r
+volatile uint32_t ulNextRand = ( uint32_t ) &pvParameters, ulValue;\r
+\r
+       /* This task does nothing other than ensure there is a little bit of\r
+       disruption in the scheduling pattern of the other tasks.  Normally this is\r
+       done by generating interrupts at pseudo random times. */\r
+       for( ;; )\r
+       {\r
+               ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;\r
+               ulValue = ( ulNextRand >> 16UL ) & 0xffUL;\r
+\r
+               if( ulValue < ulMinDelay )\r
+               {\r
+                       ulValue = ulMinDelay;\r
+               }\r
+\r
+               vTaskDelay( ulValue );\r
+\r
+               while( ulValue > 0 )\r
+               {\r
+                       nop();\r
+                       nop();\r
+                       nop();\r
+                       nop();\r
+                       nop();\r
+                       nop();\r
+                       nop();\r
+                       nop();\r
+\r
+                       ulValue--;\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vFullDemoTickHook( void )\r
+{\r
+       /* The full demo includes a software timer demo/test that requires\r
+       prodding periodically from the tick interrupt. */\r
+       vTimerPeriodicISRTests();\r
+\r
+       /* Call the periodic queue overwrite from ISR demo. */\r
+       vQueueOverwritePeriodicISRDemo();\r
+\r
+       /* Call the periodic event group from ISR demo. */\r
+       vPeriodicEventGroupsProcessing();\r
+\r
+       /* Use task notifications from an interrupt. */\r
+       xNotifyTaskFromISR();\r
+\r
+       /* Use mutexes from interrupts. */\r
+       vInterruptSemaphorePeriodicTest();\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/* This function is explained in the comments at the top of this file. */\r
+static void prvRegTest1Task( void *pvParameters )\r
+{\r
+       if( pvParameters != mainREG_TEST_1_PARAMETER )\r
+       {\r
+               /* The parameter did not contain the expected value. */\r
+               for( ;; )\r
+               {\r
+                       /* Stop the tick interrupt so its obvious something has gone wrong. */\r
+                       taskDISABLE_INTERRUPTS();\r
+               }\r
+       }\r
+\r
+       /* This is an inline asm function that never returns. */\r
+       prvRegTest1Implementation();\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/* This function is explained in the comments at the top of this file. */\r
+static void prvRegTest2Task( void *pvParameters )\r
+{\r
+       if( pvParameters != mainREG_TEST_2_PARAMETER )\r
+       {\r
+               /* The parameter did not contain the expected value. */\r
+               for( ;; )\r
+               {\r
+                       /* Stop the tick interrupt so its obvious something has gone wrong. */\r
+                       taskDISABLE_INTERRUPTS();\r
+               }\r
+       }\r
+\r
+       /* This is an inline asm function that never returns. */\r
+       prvRegTest2Implementation();\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/* This function is explained in the comments at the top of this file. */\r
+#pragma inline_asm prvRegTest1Implementation\r
+static void prvRegTest1Implementation( void )\r
+{\r
+       ; Put a known value in each register.\r
+       MOV.L   #1, R1\r
+       MOV.L   #2, R2\r
+       MOV.L   #3, R3\r
+       MOV.L   #4, R4\r
+       MOV.L   #5, R5\r
+       MOV.L   #6, R6\r
+       MOV.L   #7, R7\r
+       MOV.L   #8, R8\r
+       MOV.L   #9, R9\r
+       MOV.L   #10, R10\r
+       MOV.L   #11, R11\r
+       MOV.L   #12, R12\r
+       MOV.L   #13, R13\r
+       MOV.L   #14, R14\r
+       MOV.L   #15, R15\r
+\r
+       ; Loop, checking each itteration that each register still contains the\r
+       ; expected value.\r
+TestLoop1:\r
+\r
+       ; Push the registers that are going to get clobbered.\r
+       PUSHM   R14-R15\r
+\r
+       ; Increment the loop counter to show this task is still getting CPU time.\r
+       MOV.L   #_ulRegTest1LoopCounter, R14\r
+       MOV.L   [ R14 ], R15\r
+       ADD             #1, R15\r
+       MOV.L   R15, [ R14 ]\r
+\r
+       ; Yield to extend the text coverage.  Set the bit in the ITU SWINTR register.\r
+       MOV.L   #1, R14\r
+       MOV.L   #0872E0H, R15\r
+       MOV.B   R14, [R15]\r
+       NOP\r
+       NOP\r
+\r
+       ; Restore the clobbered registers.\r
+       POPM    R14-R15\r
+\r
+       ; Now compare each register to ensure it still contains the value that was\r
+       ; set before this loop was entered.\r
+       CMP             #1, R1\r
+       BNE             RegTest1Error\r
+       CMP             #2, R2\r
+       BNE             RegTest1Error\r
+       CMP             #3, R3\r
+       BNE             RegTest1Error\r
+       CMP             #4, R4\r
+       BNE             RegTest1Error\r
+       CMP             #5, R5\r
+       BNE             RegTest1Error\r
+       CMP             #6, R6\r
+       BNE             RegTest1Error\r
+       CMP             #7, R7\r
+       BNE             RegTest1Error\r
+       CMP             #8, R8\r
+       BNE             RegTest1Error\r
+       CMP             #9, R9\r
+       BNE             RegTest1Error\r
+       CMP             #10, R10\r
+       BNE             RegTest1Error\r
+       CMP             #11, R11\r
+       BNE             RegTest1Error\r
+       CMP             #12, R12\r
+       BNE             RegTest1Error\r
+       CMP             #13, R13\r
+       BNE             RegTest1Error\r
+       CMP             #14, R14\r
+       BNE             RegTest1Error\r
+       CMP             #15, R15\r
+       BNE             RegTest1Error\r
+\r
+       ; All comparisons passed, start a new itteratio of this loop.\r
+       BRA             TestLoop1\r
+\r
+RegTest1Error:\r
+       ; A compare failed, just loop here so the loop counter stops incrementing\r
+       ; causing the check task to indicate the error.\r
+       BRA RegTest1Error\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/* This function is explained in the comments at the top of this file. */\r
+#pragma inline_asm prvRegTest2Implementation\r
+static void prvRegTest2Implementation( void )\r
+{\r
+       ; Put a known value in each register.\r
+       MOV.L   #10, R1\r
+       MOV.L   #20, R2\r
+       MOV.L   #30, R3\r
+       MOV.L   #40, R4\r
+       MOV.L   #50, R5\r
+       MOV.L   #60, R6\r
+       MOV.L   #70, R7\r
+       MOV.L   #80, R8\r
+       MOV.L   #90, R9\r
+       MOV.L   #100, R10\r
+       MOV.L   #110, R11\r
+       MOV.L   #120, R12\r
+       MOV.L   #130, R13\r
+       MOV.L   #140, R14\r
+       MOV.L   #150, R15\r
+\r
+       ; Loop, checking on each itteration that each register still contains the\r
+       ; expected value.\r
+TestLoop2:\r
+\r
+       ; Push the registers that are going to get clobbered.\r
+       PUSHM   R14-R15\r
+\r
+       ; Increment the loop counter to show this task is still getting CPU time.\r
+       MOV.L   #_ulRegTest2LoopCounter, R14\r
+       MOV.L   [ R14 ], R15\r
+       ADD             #1, R15\r
+       MOV.L   R15, [ R14 ]\r
+\r
+       ; Restore the clobbered registers.\r
+       POPM    R14-R15\r
+\r
+       CMP             #10, R1\r
+       BNE             RegTest2Error\r
+       CMP             #20, R2\r
+       BNE             RegTest2Error\r
+       CMP             #30, R3\r
+       BNE             RegTest2Error\r
+       CMP             #40, R4\r
+       BNE             RegTest2Error\r
+       CMP             #50, R5\r
+       BNE             RegTest2Error\r
+       CMP             #60, R6\r
+       BNE             RegTest2Error\r
+       CMP             #70, R7\r
+       BNE             RegTest2Error\r
+       CMP             #80, R8\r
+       BNE             RegTest2Error\r
+       CMP             #90, R9\r
+       BNE             RegTest2Error\r
+       CMP             #100, R10\r
+       BNE             RegTest2Error\r
+       CMP             #110, R11\r
+       BNE             RegTest2Error\r
+       CMP             #120, R12\r
+       BNE             RegTest2Error\r
+       CMP             #130, R13\r
+       BNE             RegTest2Error\r
+       CMP             #140, R14\r
+       BNE             RegTest2Error\r
+       CMP             #150, R15\r
+       BNE             RegTest2Error\r
+\r
+       ; All comparisons passed, start a new itteratio of this loop.\r
+       BRA             TestLoop2\r
+\r
+RegTest2Error:\r
+       ; A compare failed, just loop here so the loop counter stops incrementing\r
+       ; - causing the check task to indicate the error.\r
+       BRA RegTest2Error\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+\r
+\r
+\r