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