]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/RX600_RX63N-RSK_Renesas/RTOSDemo/main-full.c
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / RX600_RX63N-RSK_Renesas / RTOSDemo / main-full.c
diff --git a/FreeRTOS/Demo/RX600_RX63N-RSK_Renesas/RTOSDemo/main-full.c b/FreeRTOS/Demo/RX600_RX63N-RSK_Renesas/RTOSDemo/main-full.c
new file mode 100644 (file)
index 0000000..e43a12d
--- /dev/null
@@ -0,0 +1,701 @@
+/*\r
+    FreeRTOS V7.1.0 - Copyright (C) 2011 Real Time Engineers Ltd.\r
+       \r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
+     *    Complete, revised, and edited pdf reference manuals are also       *\r
+     *    available.                                                         *\r
+     *                                                                       *\r
+     *    Purchasing FreeRTOS documentation will not only help you, by       *\r
+     *    ensuring you get running as quickly as possible and with an        *\r
+     *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
+     *    the FreeRTOS project to continue with its mission of providing     *\r
+     *    professional grade, cross platform, de facto standard solutions    *\r
+     *    for microcontrollers - completely free of charge!                  *\r
+     *                                                                       *\r
+     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
+     *                                                                       *\r
+     *    Thank you for using FreeRTOS, and thank you for your support!      *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\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
+    >>>NOTE<<< The modification to the GPL is included to allow you to\r
+    distribute a combined work that includes FreeRTOS without being obliged to\r
+    provide the source code for proprietary components outside of the FreeRTOS\r
+    kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
+    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
+    more details. You should have received a copy of the GNU General Public\r
+    License and the FreeRTOS license exception along with FreeRTOS; if not it\r
+    can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
+    by writing to Richard Barry, contact details for whom are available on the\r
+    FreeRTOS WEB site.\r
+\r
+    1 tab == 4 spaces!\r
+\r
+    http://www.FreeRTOS.org - Documentation, latest information, license and\r
+    contact details.\r
+\r
+    http://www.SafeRTOS.com - A version that is certified for use in safety\r
+    critical systems.\r
+\r
+    http://www.OpenRTOS.com - Commercial support, development, porting,\r
+    licensing and training services.\r
+*/\r
+\r
+/* ****************************************************************************\r
+ * This project includes a lot of tasks and tests and is therefore complex.\r
+ * If you would prefer a much simpler project to get started with then select\r
+ * the 'Blinky' build configuration within the HEW IDE.  The Blinky \r
+ * configuration builds main-blinky.c in place of this file.\r
+ * ****************************************************************************\r
+ *\r
+ * Creates all the demo application tasks, then starts the scheduler.  The web\r
+ * documentation provides more details of the standard demo application tasks,\r
+ * which provide no particular functionality but do provide a good example of\r
+ * how to use the FreeRTOS API.  The tasks defined in flop.c are included in the\r
+ * set of standard demo tasks to ensure the floating point unit gets some\r
+ * exercise.\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
+ * Webserver ("uIP") task - This serves a number of dynamically generated WEB\r
+ * pages to a standard WEB browser.  The IP and MAC addresses are configured by\r
+ * constants defined at the bottom of FreeRTOSConfig.h.  Use either a standard\r
+ * Ethernet cable to connect through a hug, or a cross over (point to point)\r
+ * cable to connect directly.  Ensure the IP address used is compatible with the\r
+ * IP address of the machine running the browser - the easiest way to achieve\r
+ * this is to ensure the first three octets of the IP addresses are the same.\r
+ *\r
+ * "Reg test" tasks - These fill the registers with known values, then check\r
+ * that each register still contains its expected value.  Each task uses\r
+ * different values.  The tasks run with very low priority so get preempted\r
+ * very frequently.  A check variable is incremented on each iteration of the\r
+ * test loop.  A register containing an unexpected value is indicative of an\r
+ * error in the context switching mechanism and will result in a branch to a\r
+ * null loop - which in turn will prevent the check variable from incrementing\r
+ * any further and allow the check task (described below) to determine that an\r
+ * error has occurred.  The nature of the reg test tasks necessitates that they\r
+ * are written in assembly code.\r
+ *\r
+ * "Check" timer - The check software timer period is initially set to five\r
+ * seconds.  The callback function associated with the check software timer\r
+ * checks that all the standard demo tasks, and the register check tasks, are\r
+ * not only still executing, but are executing without reporting any errors.  If\r
+ * the check software timer discovers that a task has either stalled, or\r
+ * reported an error, then it changes its own execution period from the initial\r
+ * five seconds, to just 200ms.  The check software timer callback function\r
+ * also toggles LED3 each time it is called.  This provides a visual indication \r
+ * of the system status:  If LED3 toggles every five seconds, then no issues \r
+ * have been discovered.  If the LED toggles every 200ms, then an issue has been \r
+ * discovered with at least one task.\r
+ *\r
+ * "High frequency timer test" - A high frequency periodic interrupt is\r
+ * generated using a timer - the interrupt is assigned a priority above\r
+ * configMAX_SYSCALL_INTERRUPT_PRIORITY so should not be effected by anything\r
+ * the kernel is doing.  The frequency and priority of the interrupt, in\r
+ * combination with other standard tests executed in this demo, should result\r
+ * in interrupts nesting at least 3 and probably 4 deep.  This test is only\r
+ * included in build configurations that have the optimiser switched on.  In\r
+ * optimised builds the count of high frequency ticks is used as the time base\r
+ * for the run time stats.\r
+ *\r
+ * *NOTE 1* If LED3 is toggling every 5 seconds then all the demo application\r
+ * tasks are executing as expected and no errors have been reported in any\r
+ * tasks.  The toggle rate increasing to 200ms indicates that at least one task\r
+ * has reported unexpected behaviour.\r
+ *\r
+ * *NOTE 2* vApplicationSetupTimerInterrupt() is called by the kernel to let\r
+ * the application set up a timer to generate the tick interrupt.  In this\r
+ * example a compare match timer is used for this purpose.\r
+ *\r
+ * *NOTE 3* The CPU must be in Supervisor mode when the scheduler is started.\r
+ * The PowerON_Reset_PC() supplied in resetprg.c with this demo has\r
+ * Change_PSW_PM_to_UserMode() commented out to ensure this is the case.\r
+ *\r
+ * *NOTE 4* The IntQueue common demo tasks test interrupt nesting and make use\r
+ * of all the 8bit timers (as two cascaded 16bit units).\r
+ *\r
+ */\r
+\r
+#include <string.h>\r
+\r
+/* Hardware specific includes. */\r
+#include "iodefine.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 includes. */\r
+#include "partest.h"\r
+#include "flash_timer.h"\r
+#include "IntQueue.h"\r
+#include "BlockQ.h"\r
+#include "death.h"\r
+#include "integer.h"\r
+#include "blocktim.h"\r
+#include "semtest.h"\r
+#include "PollQ.h"\r
+#include "GenQTest.h"\r
+#include "QPeek.h"\r
+#include "recmutex.h"\r
+#include "flop.h"\r
+\r
+/* Values that are passed into the reg test tasks using the task parameter.  The\r
+tasks check that the values are passed in correctly. */\r
+#define mainREG_TEST_1_PARAMETER       ( 0x12121212UL )\r
+#define mainREG_TEST_2_PARAMETER       ( 0x12345678UL )\r
+\r
+/* Priorities at which the tasks are created. */\r
+#define mainCHECK_TASK_PRIORITY                ( configMAX_PRIORITIES - 1 )\r
+#define mainQUEUE_POLL_PRIORITY                ( tskIDLE_PRIORITY + 1 )\r
+#define mainSEM_TEST_PRIORITY          ( tskIDLE_PRIORITY + 1 )\r
+#define mainBLOCK_Q_PRIORITY           ( tskIDLE_PRIORITY + 2 )\r
+#define mainCREATOR_TASK_PRIORITY   ( tskIDLE_PRIORITY + 3 )\r
+#define mainuIP_TASK_PRIORITY          ( tskIDLE_PRIORITY + 2 )\r
+#define mainINTEGER_TASK_PRIORITY   ( tskIDLE_PRIORITY )\r
+#define mainGEN_QUEUE_TASK_PRIORITY    ( tskIDLE_PRIORITY )\r
+#define mainFLOP_TASK_PRIORITY         ( tskIDLE_PRIORITY )\r
+\r
+/* The WEB server uses string handling functions, which in turn use a bit more\r
+stack than most of the other tasks. */\r
+#define mainuIP_STACK_SIZE                     ( configMINIMAL_STACK_SIZE * 3 )\r
+\r
+/* The LED toggled by the check timer. */\r
+#define mainCHECK_LED                          ( 3 )\r
+\r
+/* The rate at which mainCHECK_LED will toggle when all the tasks are running\r
+without error.  Controlled by the check timer as described at the top of this\r
+file. */\r
+#define mainNO_ERROR_CHECK_TIMER_PERIOD_MS     ( 5000 / portTICK_RATE_MS )\r
+\r
+/* The rate at which mainCHECK_LED will toggle when an error has been reported\r
+by at least one task.  Controlled by the check timer as described at the top of\r
+this file. */\r
+#define mainERROR_CHECK_TIMER_PERIOD_MS                ( 200 / portTICK_RATE_MS )\r
+\r
+/* A block time of zero simply means "don't block". */\r
+#define mainDONT_BLOCK ( 0UL )\r
+\r
+/* A set of timers are created, each of which toggles and LED.  This specifies\r
+the number of timers to create. */\r
+#define mainNUMBER_OF_LEDS_TO_FLASH            ( 3 )\r
+\r
+/*\r
+ * vApplicationMallocFailedHook() will only be called if\r
+ * configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook\r
+ * function that will execute if a call to pvPortMalloc() fails.\r
+ * pvPortMalloc() is called internally by the kernel whenever a task, queue or\r
+ * semaphore is created.  It is also called by various parts of the demo\r
+ * application.\r
+ */\r
+void vApplicationMallocFailedHook( void );\r
+\r
+/*\r
+ * vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set to 1\r
+ * in FreeRTOSConfig.h.  It is a hook function that is called on each iteration\r
+ * of the idle task.  It is essential that code added to this hook function\r
+ * never attempts to block in any way (for example, call xQueueReceive() with\r
+ * a block time specified).  If the application makes use of the vTaskDelete()\r
+ * API function (as this demo application does) then it is also important that\r
+ * vApplicationIdleHook() is permitted to return to its calling function because\r
+ * it is the responsibility of the idle task to clean up memory allocated by the\r
+ * kernel to any task that has since been deleted.\r
+ */\r
+void vApplicationIdleHook( void );\r
+\r
+/*\r
+ * vApplicationStackOverflowHook() will only be called if\r
+ * configCHECK_FOR_STACK_OVERFLOW is set to a non-zero value.  The handle and\r
+ * name of the offending task should be passed in the function parameters, but\r
+ * it is possible that the stack overflow will have corrupted these - in which\r
+ * case pxCurrentTCB can be inspected to find the same information.\r
+ */\r
+void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName );\r
+\r
+/*\r
+ * The reg test tasks as described at the top of this file.\r
+ */\r
+static void prvRegTest1Task( void *pvParameters );\r
+static void prvRegTest2Task( void *pvParameters );\r
+\r
+/*\r
+ * The actual implementation of the reg test functionality, which, because of\r
+ * the direct register access, have to be in assembly.\r
+ */\r
+static void prvRegTest1Implementation( void );\r
+static void prvRegTest2Implementation( void );\r
+\r
+/*\r
+ * The check timer callback function, as described at the top of this file.\r
+ */\r
+static void prvCheckTimerCallback( xTimerHandle xTimer );\r
+\r
+/*\r
+ * Contains the implementation of the WEB server.\r
+ */\r
+extern void vuIP_Task( void *pvParameters );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Variables that are incremented on each iteration of the reg test tasks -\r
+provided the tasks have not reported any errors.  The check task inspects these\r
+variables to ensure they are still incrementing as expected.  If a variable\r
+stops incrementing then it is likely that its associate task has stalled. */\r
+unsigned long ulRegTest1CycleCount = 0UL, ulRegTest2CycleCount = 0UL;\r
+\r
+/* The status message that is displayed at the bottom of the "task stats" web\r
+page, which is served by the uIP task.  This will report any errors picked up\r
+by the reg test task. */\r
+const char *pcStatusMessage = "All tasks executing without error.";\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void main(void)\r
+{\r
+xTimerHandle xCheckTimer;\r
+extern void HardwareSetup( void );\r
+\r
+       /* Turn all LEDs off. */\r
+       vParTestInitialise();\r
+\r
+       /* Start the reg test tasks which test the context switching mechanism. */\r
+       xTaskCreate( prvRegTest1Task, "RegTst1", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_1_PARAMETER, tskIDLE_PRIORITY, NULL );\r
+       xTaskCreate( prvRegTest2Task, "RegTst2", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_2_PARAMETER, tskIDLE_PRIORITY, NULL );\r
+\r
+       /* The web server task.  NOTE: COMMENTED OUT AS THE ETHERNET PORT IS NOT\r
+       YET BEING CONFIGURED IN hwsetup.c. */\r
+       //xTaskCreate( vuIP_Task, "uIP", mainuIP_STACK_SIZE, NULL, mainuIP_TASK_PRIORITY, NULL );\r
+\r
+       /* Create the standard demo tasks. */\r
+       vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
+       vCreateBlockTimeTasks();\r
+       vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
+       vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
+       vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );\r
+       vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY ); \r
+       vStartQueuePeekTasks();\r
+       vStartRecursiveMutexTasks();\r
+       vStartInterruptQueueTasks();\r
+       vStartMathTasks( mainFLOP_TASK_PRIORITY );\r
+\r
+       /* Create the timers used to toggle the LEDs. */\r
+       vStartLEDFlashTimers( mainNUMBER_OF_LEDS_TO_FLASH );\r
+\r
+       /* Create the software timer that performs the 'check' functionality,\r
+       as described at the top of this file. */\r
+       xCheckTimer = xTimerCreate( "CheckTimer",                                                       /* A text name, purely to help debugging. */\r
+                                                               ( mainNO_ERROR_CHECK_TIMER_PERIOD_MS ), /* The timer period, in this case 5000ms (5s). */\r
+                                                               pdTRUE,                                                                 /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */\r
+                                                               ( void * ) 0,                                                   /* The ID is not used, so can be set to anything. */\r
+                                                               prvCheckTimerCallback                                   /* The callback function that inspects the status of all the other tasks. */\r
+                                                         );    \r
+       \r
+       if( xCheckTimer != NULL )\r
+       {\r
+               xTimerStart( xCheckTimer, mainDONT_BLOCK );\r
+       }\r
+\r
+       /* The suicide tasks must be created last as they need to know how many\r
+       tasks were running prior to their creation in order to ascertain whether\r
+       or not the correct/expected number of tasks are running at any given time. */\r
+       vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
+\r
+       /* Start the tasks running. */\r
+       vTaskStartScheduler();\r
+\r
+       /* If all is well, the scheduler will now be running, and the following line\r
+       will never be reached.  If the following line does execute, then there was\r
+       insufficient FreeRTOS heap memory available for the idle and/or timer tasks\r
+       to be created.  See the memory management section on the FreeRTOS web site\r
+       for more details. */\r
+       for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCheckTimerCallback( xTimerHandle xTimer )\r
+{\r
+static long lChangedTimerPeriodAlready = pdFALSE;\r
+static unsigned long ulLastRegTest1CycleCount = 0, ulLastRegTest2CycleCount = 0;\r
+long lErrorFound = pdFALSE;\r
+\r
+       /* If this is being executed then the kernel has been started.  Start the \r
+       high frequency timer test as described at the top of this file.  This is \r
+       only included in the optimised build configuration - otherwise it takes up \r
+       too much CPU time and can disrupt other tests. */\r
+       #ifdef INCLUDE_HIGH_FREQUENCY_TIMER_TEST\r
+               vSetupHighFrequencyTimer();\r
+       #endif\r
+\r
+       /* Check the standard demo tasks are running without error. */\r
+       if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
+       {\r
+               lErrorFound = pdTRUE;\r
+               pcStatusMessage = "Error: GenQueue";\r
+       }\r
+       else if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
+       {\r
+               lErrorFound = pdTRUE;\r
+               pcStatusMessage = "Error: QueuePeek";\r
+       }\r
+       else if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
+       {\r
+               lErrorFound = pdTRUE;\r
+               pcStatusMessage = "Error: BlockQueue";\r
+       }\r
+       else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
+       {\r
+               lErrorFound = pdTRUE;\r
+               pcStatusMessage = "Error: BlockTime";\r
+       }\r
+       else if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
+       {\r
+               lErrorFound = pdTRUE;\r
+               pcStatusMessage = "Error: SemTest";\r
+       }\r
+       else if( xArePollingQueuesStillRunning() != pdTRUE )\r
+       {\r
+               lErrorFound = pdTRUE;\r
+               pcStatusMessage = "Error: PollQueue";\r
+       }\r
+       else if( xIsCreateTaskStillRunning() != pdTRUE )\r
+       {\r
+               lErrorFound = pdTRUE;\r
+               pcStatusMessage = "Error: Death";\r
+       }\r
+       else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
+       {\r
+               lErrorFound = pdTRUE;\r
+               pcStatusMessage = "Error: IntMath";\r
+       }\r
+       else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
+       {\r
+               lErrorFound = pdTRUE;\r
+               pcStatusMessage = "Error: RecMutex";\r
+       }\r
+       else if( xAreIntQueueTasksStillRunning() != pdPASS )\r
+       {\r
+               lErrorFound = pdTRUE;\r
+               pcStatusMessage = "Error: IntQueue";\r
+       }\r
+       else if( xAreMathsTaskStillRunning() != pdPASS )\r
+       {\r
+               lErrorFound = pdTRUE;\r
+               pcStatusMessage = "Error: Flop";\r
+       }\r
+\r
+       /* Check the reg test tasks are still cycling.  They will stop incrementing\r
+       their loop counters if they encounter an error. */\r
+       if( ulRegTest1CycleCount == ulLastRegTest1CycleCount )\r
+       {\r
+               lErrorFound = pdTRUE;\r
+               pcStatusMessage = "Error: RegTest1";\r
+       }\r
+\r
+       if( ulRegTest2CycleCount == ulLastRegTest2CycleCount )\r
+       {\r
+               lErrorFound = pdTRUE;\r
+               pcStatusMessage = "Error: RegTest2";\r
+       }\r
+\r
+       ulLastRegTest1CycleCount = ulRegTest1CycleCount;\r
+       ulLastRegTest2CycleCount = ulRegTest2CycleCount;\r
+\r
+       /* Toggle the check LED to give an indication of the system status.  If\r
+       the LED toggles every mainNO_ERROR_CHECK_TIMER_PERIOD_MS milliseconds then\r
+       everything is ok.  A faster toggle indicates an error. */\r
+       vParTestToggleLED( mainCHECK_LED );     \r
+       \r
+       /* Have any errors been latch in lErrorFound?  If so, shorten the\r
+       period of the check timer to mainERROR_CHECK_TIMER_PERIOD_MS milliseconds.\r
+       This will result in an increase in the rate at which mainCHECK_LED\r
+       toggles. */\r
+       if( lErrorFound != pdFALSE )\r
+       {\r
+               if( lChangedTimerPeriodAlready == pdFALSE )\r
+               {\r
+                       lChangedTimerPeriodAlready = pdTRUE;\r
+                       \r
+                       /* This call to xTimerChangePeriod() uses a zero block time.\r
+                       Functions called from inside of a timer callback function must\r
+                       *never* attempt to block. */\r
+                       xTimerChangePeriod( xTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK );\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/* The RX port uses this callback function to configure its tick interrupt.\r
+This allows the application to choose the tick interrupt source. */\r
+void vApplicationSetupTimerInterrupt( void )\r
+{\r
+       /* Enable compare match timer 0. */\r
+       MSTP( CMT0 ) = 0;\r
+\r
+       /* Interrupt on compare match. */\r
+       CMT0.CMCR.BIT.CMIE = 1;\r
+\r
+       /* Set the compare match value. */\r
+       CMT0.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ ) -1 ) / 8 );\r
+\r
+       /* Divide the PCLK by 8. */\r
+       CMT0.CMCR.BIT.CKS = 0;\r
+\r
+       /* Enable the interrupt... */\r
+       _IEN( _CMT0_CMI0 ) = 1;\r
+\r
+       /* ...and set its priority to the application defined kernel priority. */\r
+       _IPR( _CMT0_CMI0 ) = configKERNEL_INTERRUPT_PRIORITY;\r
+\r
+       /* Start the timer. */\r
+       CMT.CMSTR0.BIT.STR0 = 1;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/* This function is explained by the comments above its prototype at the top\r
+of this file. */\r
+void vApplicationMallocFailedHook( void )\r
+{\r
+       for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/* This function is explained by the comments above its prototype at the top\r
+of this file. */\r
+void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )\r
+{\r
+       for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/* This function is explained by the comments above its prototype at the top\r
+of this file. */\r
+void vApplicationIdleHook( void )\r
+{\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( ( ( unsigned long ) 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( ( ( unsigned long ) 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   #_ulRegTest1CycleCount, 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   #_ulRegTest2CycleCount, 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
+char *pcGetTaskStatusMessage( void )\r
+{\r
+       /* Not bothered about a critical section here although technically because of\r
+       the task priorities the pointer could change it will be atomic if not near\r
+       atomic and its not critical. */\r
+       return ( char * ) pcStatusMessage;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+\r
+\r