]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RX600_RX62N-RDK_Renesas/RTOSDemo/main-full.c
df1e3e818c205fb8a0308df8b77e19f6794b0c93
[freertos] / FreeRTOS / Demo / RX600_RX62N-RDK_Renesas / RTOSDemo / main-full.c
1 /*\r
2     FreeRTOS V7.4.1 - Copyright (C) 2013 Real Time Engineers Ltd.\r
3 \r
4     FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT\r
5     http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     ***************************************************************************\r
8      *                                                                       *\r
9      *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
10      *    Complete, revised, and edited pdf reference manuals are also       *\r
11      *    available.                                                         *\r
12      *                                                                       *\r
13      *    Purchasing FreeRTOS documentation will not only help you, by       *\r
14      *    ensuring you get running as quickly as possible and with an        *\r
15      *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
16      *    the FreeRTOS project to continue with its mission of providing     *\r
17      *    professional grade, cross platform, de facto standard solutions    *\r
18      *    for microcontrollers - completely free of charge!                  *\r
19      *                                                                       *\r
20      *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
21      *                                                                       *\r
22      *    Thank you for using FreeRTOS, and thank you for your support!      *\r
23      *                                                                       *\r
24     ***************************************************************************\r
25 \r
26 \r
27     This file is part of the FreeRTOS distribution.\r
28 \r
29     FreeRTOS is free software; you can redistribute it and/or modify it under\r
30     the terms of the GNU General Public License (version 2) as published by the\r
31     Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
32 \r
33     >>>>>>NOTE<<<<<< The modification to the GPL is included to allow you to\r
34     distribute a combined work that includes FreeRTOS without being obliged to\r
35     provide the source code for proprietary components outside of the FreeRTOS\r
36     kernel.\r
37 \r
38     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
39     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
40     FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more\r
41     details. You should have received a copy of the GNU General Public License\r
42     and the FreeRTOS license exception along with FreeRTOS; if not it can be\r
43     viewed here: http://www.freertos.org/a00114.html and also obtained by\r
44     writing to Real Time Engineers Ltd., contact details for whom are available\r
45     on the FreeRTOS WEB site.\r
46 \r
47     1 tab == 4 spaces!\r
48 \r
49     ***************************************************************************\r
50      *                                                                       *\r
51      *    Having a problem?  Start by reading the FAQ "My application does   *\r
52      *    not run, what could be wrong?"                                     *\r
53      *                                                                       *\r
54      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
55      *                                                                       *\r
56     ***************************************************************************\r
57 \r
58 \r
59     http://www.FreeRTOS.org - Documentation, books, training, latest versions, \r
60     license and Real Time Engineers Ltd. contact details.\r
61 \r
62     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
63     including FreeRTOS+Trace - an indispensable productivity tool, and our new\r
64     fully thread aware and reentrant UDP/IP stack.\r
65 \r
66     http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High \r
67     Integrity Systems, who sell the code with commercial support, \r
68     indemnification and middleware, under the OpenRTOS brand.\r
69     \r
70     http://www.SafeRTOS.com - High Integrity Systems also provide a safety \r
71     engineered and independently SIL3 certified version for use in safety and \r
72     mission critical applications that require provable dependability.\r
73 */\r
74 \r
75 /* ****************************************************************************\r
76  * This project includes a lot of tasks and tests and is therefore complex.\r
77  * If you would prefer a much simpler project to get started with then select\r
78  * the 'Blinky' build configuration within the HEW IDE.\r
79  * ****************************************************************************\r
80  *\r
81  * Creates all the demo application tasks, then starts the scheduler.  The web\r
82  * documentation provides more details of the standard demo application tasks,\r
83  * which provide no particular functionality but do provide a good example of\r
84  * how to use the FreeRTOS API.  The tasks defined in flop.c are included in the\r
85  * set of standard demo tasks to ensure the floating point unit gets some\r
86  * exercise.\r
87  *\r
88  * In addition to the standard demo tasks, the following tasks and tests are\r
89  * defined and/or created within this file:\r
90  *\r
91  * Webserver ("uIP") task - This serves a number of dynamically generated WEB\r
92  * pages to a standard WEB browser.  The IP and MAC addresses are configured by\r
93  * constants defined at the bottom of FreeRTOSConfig.h.  Use either a standard\r
94  * Ethernet cable to connect through a hug, or a cross over (point to point)\r
95  * cable to connect directly.  Ensure the IP address used is compatible with the\r
96  * IP address of the machine running the browser - the easiest way to achieve\r
97  * this is to ensure the first three octets of the IP addresses are the same.\r
98  *\r
99  * "Reg test" tasks - These fill the registers with known values, then check\r
100  * that each register still contains its expected value.  Each task uses\r
101  * different values.  The tasks run with very low priority so get preempted\r
102  * very frequently.  A check variable is incremented on each iteration of the\r
103  * test loop.  A register containing an unexpected value is indicative of an\r
104  * error in the context switching mechanism and will result in a branch to a\r
105  * null loop - which in turn will prevent the check variable from incrementing\r
106  * any further and allow the check task (described below) to determine that an\r
107  * error has occurred.  The nature of the reg test tasks necessitates that they\r
108  * are written in assembly code.\r
109  *\r
110  * "Check" task - This only executes every five seconds but has a high priority\r
111  * to ensure it gets processor time.  Its main function is to check that all the\r
112  * standard demo tasks are still operational.  While no errors have been\r
113  * discovered the check task will toggle LED 5 (marked LED 9 on the silk \r
114  * screen!) every 5 seconds - the toggle rate increasing to 200ms being a visual \r
115  * indication that at least one task has reported unexpected behaviour.\r
116  *\r
117  * "High frequency timer test" - A high frequency periodic interrupt is\r
118  * generated using a timer - the interrupt is assigned a priority above\r
119  * configMAX_SYSCALL_INTERRUPT_PRIORITY so should not be effected by anything\r
120  * the kernel is doing.  The frequency and priority of the interrupt, in\r
121  * combination with other standard tests executed in this demo, should result\r
122  * in interrupts nesting at least 3 and probably 4 deep.  This test is only\r
123  * included in build configurations that have the optimiser switched on.  In\r
124  * optimised builds the count of high frequency ticks is used as the time base\r
125  * for the run time stats.\r
126  *\r
127  * *NOTE 1* If LED5 is toggling every 5 seconds then all the demo application\r
128  * tasks are executing as expected and no errors have been reported in any\r
129  * tasks.  The toggle rate increasing to 200ms indicates that at least one task\r
130  * has reported unexpected behaviour.\r
131  *\r
132  * *NOTE 2* vApplicationSetupTimerInterrupt() is called by the kernel to let\r
133  * the application set up a timer to generate the tick interrupt.  In this\r
134  * example a compare match timer is used for this purpose.\r
135  *\r
136  * *NOTE 3* The CPU must be in Supervisor mode when the scheduler is started.\r
137  * The PowerON_Reset_PC() supplied in resetprg.c with this demo has\r
138  * Change_PSW_PM_to_UserMode() commented out to ensure this is the case.\r
139  *\r
140  * *NOTE 4* The IntQueue common demo tasks test interrupt nesting and make use\r
141  * of all the 8bit timers (as two cascaded 16bit units).\r
142 */\r
143 \r
144 /* Hardware specific includes. */\r
145 #include "iodefine.h"\r
146 \r
147 /* Kernel includes. */\r
148 #include "FreeRTOS.h"\r
149 #include "task.h"\r
150 \r
151 /* Standard demo includes. */\r
152 #include "partest.h"\r
153 #include "flash.h"\r
154 #include "IntQueue.h"\r
155 #include "BlockQ.h"\r
156 #include "death.h"\r
157 #include "integer.h"\r
158 #include "blocktim.h"\r
159 #include "semtest.h"\r
160 #include "PollQ.h"\r
161 #include "GenQTest.h"\r
162 #include "QPeek.h"\r
163 #include "recmutex.h"\r
164 #include "flop.h"\r
165 \r
166 /* Values that are passed into the reg test tasks using the task parameter.  The\r
167 tasks check that the values are passed in correctly. */\r
168 #define mainREG_TEST_1_PARAMETER        ( 0x12121212UL )\r
169 #define mainREG_TEST_2_PARAMETER        ( 0x12345678UL )\r
170 \r
171 /* Priorities at which the tasks are created. */\r
172 #define mainCHECK_TASK_PRIORITY         ( configMAX_PRIORITIES - 1 )\r
173 #define mainQUEUE_POLL_PRIORITY         ( tskIDLE_PRIORITY + 1 )\r
174 #define mainSEM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 1 )\r
175 #define mainBLOCK_Q_PRIORITY            ( tskIDLE_PRIORITY + 2 )\r
176 #define mainCREATOR_TASK_PRIORITY   ( tskIDLE_PRIORITY + 3 )\r
177 #define mainFLASH_TASK_PRIORITY         ( tskIDLE_PRIORITY + 1 )\r
178 #define mainuIP_TASK_PRIORITY           ( tskIDLE_PRIORITY + 2 )\r
179 #define mainINTEGER_TASK_PRIORITY   ( tskIDLE_PRIORITY )\r
180 #define mainGEN_QUEUE_TASK_PRIORITY     ( tskIDLE_PRIORITY )\r
181 #define mainFLOP_TASK_PRIORITY          ( tskIDLE_PRIORITY )\r
182 \r
183 /* The WEB server uses string handling functions, which in turn use a bit more\r
184 stack than most of the other tasks. */\r
185 #define mainuIP_STACK_SIZE                      ( configMINIMAL_STACK_SIZE * 3 )\r
186 \r
187 /* The LED toggled by the check task. */\r
188 #define mainCHECK_LED                           ( 5 ) /* Marked LED 9 on the RDK silk screen. */\r
189 \r
190 /* The rate at which mainCHECK_LED will toggle when all the tasks are running\r
191 without error.  Controlled by the check task as described at the top of this\r
192 file. */\r
193 #define mainNO_ERROR_CYCLE_TIME         ( 5000 / portTICK_RATE_MS )\r
194 \r
195 /* The rate at which mainCHECK_LED will toggle when an error has been reported\r
196 by at least one task.  Controlled by the check task as described at the top of\r
197 this file. */\r
198 #define mainERROR_CYCLE_TIME            ( 200 / portTICK_RATE_MS )\r
199 \r
200 /*\r
201  * vApplicationMallocFailedHook() will only be called if\r
202  * configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook\r
203  * function that will execute if a call to pvPortMalloc() fails.\r
204  * pvPortMalloc() is called internally by the kernel whenever a task, queue or\r
205  * semaphore is created.  It is also called by various parts of the demo\r
206  * application.\r
207  */\r
208 void vApplicationMallocFailedHook( void );\r
209 \r
210 /*\r
211  * vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set to 1\r
212  * in FreeRTOSConfig.h.  It is a hook function that is called on each iteration\r
213  * of the idle task.  It is essential that code added to this hook function\r
214  * never attempts to block in any way (for example, call xQueueReceive() with\r
215  * a block time specified).  If the application makes use of the vTaskDelete()\r
216  * API function (as this demo application does) then it is also important that\r
217  * vApplicationIdleHook() is permitted to return to its calling function because\r
218  * it is the responsibility of the idle task to clean up memory allocated by the\r
219  * kernel to any task that has since been deleted.\r
220  */\r
221 void vApplicationIdleHook( void );\r
222 \r
223 /*\r
224  * vApplicationStackOverflowHook() will only be called if\r
225  * configCHECK_FOR_STACK_OVERFLOW is set to a non-zero value.  The handle and\r
226  * name of the offending task should be passed in the function parameters, but\r
227  * it is possible that the stack overflow will have corrupted these - in which\r
228  * case pxCurrentTCB can be inspected to find the same information.\r
229  */\r
230 void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName );\r
231 \r
232 /*\r
233  * The reg test tasks as described at the top of this file.\r
234  */\r
235 static void prvRegTest1Task( void *pvParameters );\r
236 static void prvRegTest2Task( void *pvParameters );\r
237 \r
238 /*\r
239  * The actual implementation of the reg test functionality, which, because of\r
240  * the direct register access, have to be in assembly.\r
241  */\r
242 static void prvRegTest1Implementation( void );\r
243 static void prvRegTest2Implementation( void );\r
244 \r
245 /*\r
246  * The check task as described at the top of this file.\r
247  */\r
248 static void prvCheckTask( void *pvParameters );\r
249 \r
250 /*\r
251  * Contains the implementation of the WEB server.\r
252  */\r
253 extern void vuIP_Task( void *pvParameters );\r
254 \r
255 /*-----------------------------------------------------------*/\r
256 \r
257 /* Variables that are incremented on each iteration of the reg test tasks -\r
258 provided the tasks have not reported any errors.  The check task inspects these\r
259 variables to ensure they are still incrementing as expected.  If a variable\r
260 stops incrementing then it is likely that its associate task has stalled. */\r
261 unsigned long ulRegTest1CycleCount = 0UL, ulRegTest2CycleCount = 0UL;\r
262 \r
263 /* The status message that is displayed at the bottom of the "task stats" web\r
264 page, which is served by the uIP task.  This will report any errors picked up\r
265 by the reg test task. */\r
266 const char *pcStatusMessage = "All tasks executing without error.";\r
267 \r
268 /*-----------------------------------------------------------*/\r
269 \r
270 void main(void)\r
271 {\r
272 extern void HardwareSetup( void );\r
273 \r
274         /* Renesas provided CPU configuration routine.  The clocks are configured in\r
275         here. */\r
276         HardwareSetup();\r
277 \r
278         /* Turn all LEDs off. */\r
279         vParTestInitialise();\r
280 \r
281         /* Start the reg test tasks which test the context switching mechanism. */\r
282         xTaskCreate( prvRegTest1Task, "RegTst1", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_1_PARAMETER, tskIDLE_PRIORITY, NULL );\r
283         xTaskCreate( prvRegTest2Task, "RegTst2", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_2_PARAMETER, tskIDLE_PRIORITY, NULL );\r
284 \r
285         /* The web server task. */\r
286         xTaskCreate( vuIP_Task, "uIP", mainuIP_STACK_SIZE, NULL, mainuIP_TASK_PRIORITY, NULL );\r
287 \r
288         /* Start the check task as described at the top of this file. */\r
289         xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE * 3, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
290 \r
291         /* Create the standard demo tasks. */\r
292         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
293         vCreateBlockTimeTasks();\r
294         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
295         vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
296         vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );\r
297         vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );\r
298         vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );\r
299         vStartQueuePeekTasks();\r
300         vStartRecursiveMutexTasks();\r
301         vStartInterruptQueueTasks();\r
302         vStartMathTasks( mainFLOP_TASK_PRIORITY );\r
303 \r
304         /* The suicide tasks must be created last as they need to know how many\r
305         tasks were running prior to their creation in order to ascertain whether\r
306         or not the correct/expected number of tasks are running at any given time. */\r
307         vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
308 \r
309         /* Start the tasks running. */\r
310         vTaskStartScheduler();\r
311 \r
312         /* If all is well we will never reach here as the scheduler will now be\r
313         running.  If we do reach here then it is likely that there was insufficient\r
314         heap available for the idle task to be created. */\r
315         for( ;; );\r
316 }\r
317 /*-----------------------------------------------------------*/\r
318 \r
319 static void prvCheckTask( void *pvParameters )\r
320 {\r
321 static volatile unsigned long ulLastRegTest1CycleCount = 0UL, ulLastRegTest2CycleCount = 0UL;\r
322 portTickType xNextWakeTime, xCycleFrequency = mainNO_ERROR_CYCLE_TIME;\r
323 extern void vSetupHighFrequencyTimer( void );\r
324 \r
325         /* If this is being executed then the kernel has been started.  Start the high\r
326         frequency timer test as described at the top of this file.  This is only\r
327         included in the optimised build configuration - otherwise it takes up too much\r
328         CPU time and can disrupt other tests. */\r
329         #ifdef INCLUDE_HIGH_FREQUENCY_TIMER_TEST\r
330                 vSetupHighFrequencyTimer();\r
331         #endif\r
332 \r
333         /* Initialise xNextWakeTime - this only needs to be done once. */\r
334         xNextWakeTime = xTaskGetTickCount();\r
335 \r
336         for( ;; )\r
337         {\r
338                 /* Place this task in the blocked state until it is time to run again. */\r
339                 vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );\r
340 \r
341                 /* Check the standard demo tasks are running without error. */\r
342                 if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
343                 {\r
344                         /* Increase the rate at which this task cycles, which will increase the\r
345                         rate at which mainCHECK_LED flashes to give visual feedback that an error\r
346                         has occurred. */\r
347                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
348                         pcStatusMessage = "Error: GenQueue";\r
349                 }\r
350                 else if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
351                 {\r
352                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
353                         pcStatusMessage = "Error: QueuePeek";\r
354                 }\r
355                 else if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
356                 {\r
357                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
358                         pcStatusMessage = "Error: BlockQueue";\r
359                 }\r
360                 else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
361                 {\r
362                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
363                         pcStatusMessage = "Error: BlockTime";\r
364                 }\r
365                 else if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
366                 {\r
367                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
368                         pcStatusMessage = "Error: SemTest";\r
369                 }\r
370                 else if( xArePollingQueuesStillRunning() != pdTRUE )\r
371                 {\r
372                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
373                         pcStatusMessage = "Error: PollQueue";\r
374                 }\r
375                 else if( xIsCreateTaskStillRunning() != pdTRUE )\r
376                 {\r
377                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
378                         pcStatusMessage = "Error: Death";\r
379                 }\r
380                 else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
381                 {\r
382                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
383                         pcStatusMessage = "Error: IntMath";\r
384                 }\r
385                 else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
386                 {\r
387                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
388                         pcStatusMessage = "Error: RecMutex";\r
389                 }\r
390                 else if( xAreIntQueueTasksStillRunning() != pdPASS )\r
391                 {\r
392                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
393                         pcStatusMessage = "Error: IntQueue";\r
394                 }\r
395                 else if( xAreMathsTaskStillRunning() != pdPASS )\r
396                 {\r
397                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
398                         pcStatusMessage = "Error: Flop";\r
399                 }\r
400 \r
401                 /* Check the reg test tasks are still cycling.  They will stop incrementing\r
402                 their loop counters if they encounter an error. */\r
403                 if( ulRegTest1CycleCount == ulLastRegTest1CycleCount )\r
404                 {\r
405                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
406                         pcStatusMessage = "Error: RegTest1";\r
407                 }\r
408 \r
409                 if( ulRegTest2CycleCount == ulLastRegTest2CycleCount )\r
410                 {\r
411                         xCycleFrequency = mainERROR_CYCLE_TIME;\r
412                         pcStatusMessage = "Error: RegTest2";\r
413                 }\r
414 \r
415                 ulLastRegTest1CycleCount = ulRegTest1CycleCount;\r
416                 ulLastRegTest2CycleCount = ulRegTest2CycleCount;\r
417 \r
418                 /* Toggle the check LED to give an indication of the system status.  If\r
419                 the LED toggles every 5 seconds then everything is ok.  A faster toggle\r
420                 indicates an error. */\r
421                 vParTestToggleLED( mainCHECK_LED );\r
422         }\r
423 }\r
424 /*-----------------------------------------------------------*/\r
425 \r
426 /* The RX port uses this callback function to configure its tick interrupt.\r
427 This allows the application to choose the tick interrupt source. */\r
428 void vApplicationSetupTimerInterrupt( void )\r
429 {\r
430         /* Enable compare match timer 0. */\r
431         MSTP( CMT0 ) = 0;\r
432 \r
433         /* Interrupt on compare match. */\r
434         CMT0.CMCR.BIT.CMIE = 1;\r
435 \r
436         /* Set the compare match value. */\r
437         CMT0.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ ) -1 ) / 8 );\r
438 \r
439         /* Divide the PCLK by 8. */\r
440         CMT0.CMCR.BIT.CKS = 0;\r
441 \r
442         /* Enable the interrupt... */\r
443         _IEN( _CMT0_CMI0 ) = 1;\r
444 \r
445         /* ...and set its priority to the application defined kernel priority. */\r
446         _IPR( _CMT0_CMI0 ) = configKERNEL_INTERRUPT_PRIORITY;\r
447 \r
448         /* Start the timer. */\r
449         CMT.CMSTR0.BIT.STR0 = 1;\r
450 }\r
451 /*-----------------------------------------------------------*/\r
452 \r
453 /* This function is explained by the comments above its prototype at the top\r
454 of this file. */\r
455 void vApplicationMallocFailedHook( void )\r
456 {\r
457         for( ;; );\r
458 }\r
459 /*-----------------------------------------------------------*/\r
460 \r
461 /* This function is explained by the comments above its prototype at the top\r
462 of this file. */\r
463 void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )\r
464 {\r
465         for( ;; );\r
466 }\r
467 /*-----------------------------------------------------------*/\r
468 \r
469 /* This function is explained by the comments above its prototype at the top\r
470 of this file. */\r
471 void vApplicationIdleHook( void )\r
472 {\r
473 }\r
474 /*-----------------------------------------------------------*/\r
475 \r
476 /* This function is explained in the comments at the top of this file. */\r
477 static void prvRegTest1Task( void *pvParameters )\r
478 {\r
479         if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_1_PARAMETER )\r
480         {\r
481                 /* The parameter did not contain the expected value. */\r
482                 for( ;; )\r
483                 {\r
484                         /* Stop the tick interrupt so its obvious something has gone wrong. */\r
485                         taskDISABLE_INTERRUPTS();\r
486                 }\r
487         }\r
488 \r
489         /* This is an inline asm function that never returns. */\r
490         prvRegTest1Implementation();\r
491 }\r
492 /*-----------------------------------------------------------*/\r
493 \r
494 /* This function is explained in the comments at the top of this file. */\r
495 static void prvRegTest2Task( void *pvParameters )\r
496 {\r
497         if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_2_PARAMETER )\r
498         {\r
499                 /* The parameter did not contain the expected value. */\r
500                 for( ;; )\r
501                 {\r
502                         /* Stop the tick interrupt so its obvious something has gone wrong. */\r
503                         taskDISABLE_INTERRUPTS();\r
504                 }\r
505         }\r
506 \r
507         /* This is an inline asm function that never returns. */\r
508         prvRegTest2Implementation();\r
509 }\r
510 /*-----------------------------------------------------------*/\r
511 \r
512 /* This function is explained in the comments at the top of this file. */\r
513 #pragma inline_asm prvRegTest1Implementation\r
514 static void prvRegTest1Implementation( void )\r
515 {\r
516         ; Put a known value in each register.\r
517         MOV.L   #1, R1\r
518         MOV.L   #2, R2\r
519         MOV.L   #3, R3\r
520         MOV.L   #4, R4\r
521         MOV.L   #5, R5\r
522         MOV.L   #6, R6\r
523         MOV.L   #7, R7\r
524         MOV.L   #8, R8\r
525         MOV.L   #9, R9\r
526         MOV.L   #10, R10\r
527         MOV.L   #11, R11\r
528         MOV.L   #12, R12\r
529         MOV.L   #13, R13\r
530         MOV.L   #14, R14\r
531         MOV.L   #15, R15\r
532 \r
533         ; Loop, checking each itteration that each register still contains the\r
534         ; expected value.\r
535 TestLoop1:\r
536 \r
537         ; Push the registers that are going to get clobbered.\r
538         PUSHM   R14-R15\r
539 \r
540         ; Increment the loop counter to show this task is still getting CPU time.\r
541         MOV.L   #_ulRegTest1CycleCount, R14\r
542         MOV.L   [ R14 ], R15\r
543         ADD             #1, R15\r
544         MOV.L   R15, [ R14 ]\r
545 \r
546         ; Yield to extend the text coverage.  Set the bit in the ITU SWINTR register.\r
547         MOV.L   #1, R14\r
548         MOV.L   #0872E0H, R15\r
549         MOV.B   R14, [R15]\r
550         NOP\r
551         NOP\r
552 \r
553         ; Restore the clobbered registers.\r
554         POPM    R14-R15\r
555 \r
556         ; Now compare each register to ensure it still contains the value that was\r
557         ; set before this loop was entered.\r
558         CMP             #1, R1\r
559         BNE             RegTest1Error\r
560         CMP             #2, R2\r
561         BNE             RegTest1Error\r
562         CMP             #3, R3\r
563         BNE             RegTest1Error\r
564         CMP             #4, R4\r
565         BNE             RegTest1Error\r
566         CMP             #5, R5\r
567         BNE             RegTest1Error\r
568         CMP             #6, R6\r
569         BNE             RegTest1Error\r
570         CMP             #7, R7\r
571         BNE             RegTest1Error\r
572         CMP             #8, R8\r
573         BNE             RegTest1Error\r
574         CMP             #9, R9\r
575         BNE             RegTest1Error\r
576         CMP             #10, R10\r
577         BNE             RegTest1Error\r
578         CMP             #11, R11\r
579         BNE             RegTest1Error\r
580         CMP             #12, R12\r
581         BNE             RegTest1Error\r
582         CMP             #13, R13\r
583         BNE             RegTest1Error\r
584         CMP             #14, R14\r
585         BNE             RegTest1Error\r
586         CMP             #15, R15\r
587         BNE             RegTest1Error\r
588 \r
589         ; All comparisons passed, start a new itteratio of this loop.\r
590         BRA             TestLoop1\r
591 \r
592 RegTest1Error:\r
593         ; A compare failed, just loop here so the loop counter stops incrementing\r
594         ; causing the check task to indicate the error.\r
595         BRA RegTest1Error\r
596 }\r
597 /*-----------------------------------------------------------*/\r
598 \r
599 /* This function is explained in the comments at the top of this file. */\r
600 #pragma inline_asm prvRegTest2Implementation\r
601 static void prvRegTest2Implementation( void )\r
602 {\r
603         ; Put a known value in each register.\r
604         MOV.L   #10, R1\r
605         MOV.L   #20, R2\r
606         MOV.L   #30, R3\r
607         MOV.L   #40, R4\r
608         MOV.L   #50, R5\r
609         MOV.L   #60, R6\r
610         MOV.L   #70, R7\r
611         MOV.L   #80, R8\r
612         MOV.L   #90, R9\r
613         MOV.L   #100, R10\r
614         MOV.L   #110, R11\r
615         MOV.L   #120, R12\r
616         MOV.L   #130, R13\r
617         MOV.L   #140, R14\r
618         MOV.L   #150, R15\r
619 \r
620         ; Loop, checking on each itteration that each register still contains the\r
621         ; expected value.\r
622 TestLoop2:\r
623 \r
624         ; Push the registers that are going to get clobbered.\r
625         PUSHM   R14-R15\r
626 \r
627         ; Increment the loop counter to show this task is still getting CPU time.\r
628         MOV.L   #_ulRegTest2CycleCount, R14\r
629         MOV.L   [ R14 ], R15\r
630         ADD             #1, R15\r
631         MOV.L   R15, [ R14 ]\r
632 \r
633         ; Restore the clobbered registers.\r
634         POPM    R14-R15\r
635 \r
636         CMP             #10, R1\r
637         BNE             RegTest2Error\r
638         CMP             #20, R2\r
639         BNE             RegTest2Error\r
640         CMP             #30, R3\r
641         BNE             RegTest2Error\r
642         CMP             #40, R4\r
643         BNE             RegTest2Error\r
644         CMP             #50, R5\r
645         BNE             RegTest2Error\r
646         CMP             #60, R6\r
647         BNE             RegTest2Error\r
648         CMP             #70, R7\r
649         BNE             RegTest2Error\r
650         CMP             #80, R8\r
651         BNE             RegTest2Error\r
652         CMP             #90, R9\r
653         BNE             RegTest2Error\r
654         CMP             #100, R10\r
655         BNE             RegTest2Error\r
656         CMP             #110, R11\r
657         BNE             RegTest2Error\r
658         CMP             #120, R12\r
659         BNE             RegTest2Error\r
660         CMP             #130, R13\r
661         BNE             RegTest2Error\r
662         CMP             #140, R14\r
663         BNE             RegTest2Error\r
664         CMP             #150, R15\r
665         BNE             RegTest2Error\r
666 \r
667         ; All comparisons passed, start a new itteratio of this loop.\r
668         BRA             TestLoop2\r
669 \r
670 RegTest2Error:\r
671         ; A compare failed, just loop here so the loop counter stops incrementing\r
672         ; - causing the check task to indicate the error.\r
673         BRA RegTest2Error\r
674 }\r
675 /*-----------------------------------------------------------*/\r
676 \r
677 char *pcGetTaskStatusMessage( void )\r
678 {\r
679         /* Not bothered about a critical section here although technically because of\r
680         the task priorities the pointer could change it will be atomic if not near\r
681         atomic and its not critical. */\r
682         return ( char * ) pcStatusMessage;\r
683 }\r
684 /*-----------------------------------------------------------*/\r
685 \r
686 \r