]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RX600_RX63N-RDK_Renesas/RTOSDemo/main-full.c
Minor updates and change version number for V7.5.0 release.
[freertos] / FreeRTOS / Demo / RX600_RX63N-RDK_Renesas / RTOSDemo / main-full.c
1 /*\r
2     FreeRTOS V7.5.0 - 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.  The Blinky \r
69  * configuration builds main-blinky.c in place of this file.\r
70  * ****************************************************************************\r
71  *\r
72  * Creates all the demo application tasks, then starts the scheduler.  The web\r
73  * documentation provides more details of the standard demo application tasks,\r
74  * which provide no particular functionality but do provide a good example of\r
75  * how to use the FreeRTOS API.  The tasks defined in flop.c are included in the\r
76  * set of standard demo tasks to ensure the floating point unit gets some\r
77  * exercise.\r
78  *\r
79  * In addition to the standard demo tasks, the following tasks and tests are\r
80  * defined and/or created within this file:\r
81  *\r
82  * Webserver ("uIP") task - This serves a number of dynamically generated WEB\r
83  * pages to a standard WEB browser.  The IP and MAC addresses are configured by\r
84  * constants defined at the bottom of FreeRTOSConfig.h.  Use either a standard\r
85  * Ethernet cable to connect through a hug, or a cross over (point to point)\r
86  * cable to connect directly.  Ensure the IP address used is compatible with the\r
87  * IP address of the machine running the browser - the easiest way to achieve\r
88  * this is to ensure the first three octets of the IP addresses are the same.\r
89  *\r
90  * "Reg test" tasks - These fill the registers with known values, then check\r
91  * that each register still contains its expected value.  Each task uses\r
92  * different values.  The tasks run with very low priority so get preempted\r
93  * very frequently.  A check variable is incremented on each iteration of the\r
94  * test loop.  A register containing an unexpected value is indicative of an\r
95  * error in the context switching mechanism and will result in a branch to a\r
96  * null loop - which in turn will prevent the check variable from incrementing\r
97  * any further and allow the check task (described below) to determine that an\r
98  * error has occurred.  The nature of the reg test tasks necessitates that they\r
99  * are written in assembly code.\r
100  *\r
101  * "Check" timer - The check software timer period is initially set to five\r
102  * seconds.  The callback function associated with the check software timer\r
103  * checks that all the standard demo tasks, and the register check tasks, are\r
104  * not only still executing, but are executing without reporting any errors.  If\r
105  * the check software timer discovers that a task has either stalled, or\r
106  * reported an error, then it changes its own execution period from the initial\r
107  * five seconds, to just 200ms.  The check software timer callback function\r
108  * also toggles LED3 each time it is called.  This provides a visual indication \r
109  * of the system status:  If LED3 toggles every five seconds, then no issues \r
110  * have been discovered.  If the LED toggles every 200ms, then an issue has been \r
111  * discovered with at least one task.\r
112  *\r
113  * "High frequency timer test" - A high frequency periodic interrupt is\r
114  * generated using a timer - the interrupt is assigned a priority above\r
115  * configMAX_SYSCALL_INTERRUPT_PRIORITY so should not be effected by anything\r
116  * the kernel is doing.  The frequency and priority of the interrupt, in\r
117  * combination with other standard tests executed in this demo, should result\r
118  * in interrupts nesting at least 3 and probably 4 deep.  This test is only\r
119  * included in build configurations that have the optimiser switched on.  In\r
120  * optimised builds the count of high frequency ticks is used as the time base\r
121  * for the run time stats.\r
122  *\r
123  * *NOTE 1* If LED3 is toggling every 5 seconds then all the demo application\r
124  * tasks are executing as expected and no errors have been reported in any\r
125  * tasks.  The toggle rate increasing to 200ms indicates that at least one task\r
126  * has reported unexpected behaviour.\r
127  *\r
128  * *NOTE 2* vApplicationSetupTimerInterrupt() is called by the kernel to let\r
129  * the application set up a timer to generate the tick interrupt.  In this\r
130  * example a compare match timer is used for this purpose.\r
131  *\r
132  * *NOTE 3* The CPU must be in Supervisor mode when the scheduler is started.\r
133  * The PowerON_Reset_PC() supplied in resetprg.c with this demo has\r
134  * Change_PSW_PM_to_UserMode() commented out to ensure this is the case.\r
135  *\r
136  * *NOTE 4* The IntQueue common demo tasks test interrupt nesting and make use\r
137  * of all the 8bit timers (as two cascaded 16bit units).\r
138  *\r
139  * *\r
140 */\r
141 \r
142 #include <string.h>\r
143 \r
144 /* Kernel includes. */\r
145 #include "FreeRTOS.h"\r
146 #include "task.h"\r
147 #include "timers.h"\r
148 #include "semphr.h"\r
149 \r
150 /* Standard demo includes. */\r
151 #include "partest.h"\r
152 #include "flash_timer.h"\r
153 #include "IntQueue.h"\r
154 #include "BlockQ.h"\r
155 #include "death.h"\r
156 #include "integer.h"\r
157 #include "blocktim.h"\r
158 #include "semtest.h"\r
159 #include "PollQ.h"\r
160 #include "GenQTest.h"\r
161 #include "QPeek.h"\r
162 #include "recmutex.h"\r
163 #include "flop.h"\r
164 \r
165 /* Values that are passed into the reg test tasks using the task parameter.  The\r
166 tasks check that the values are passed in correctly. */\r
167 #define mainREG_TEST_1_PARAMETER        ( 0x12121212UL )\r
168 #define mainREG_TEST_2_PARAMETER        ( 0x12345678UL )\r
169 \r
170 /* Priorities at which the tasks are created. */\r
171 #define mainCHECK_TASK_PRIORITY         ( configMAX_PRIORITIES - 1 )\r
172 #define mainQUEUE_POLL_PRIORITY         ( tskIDLE_PRIORITY + 1 )\r
173 #define mainSEM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 1 )\r
174 #define mainBLOCK_Q_PRIORITY            ( tskIDLE_PRIORITY + 2 )\r
175 #define mainCREATOR_TASK_PRIORITY   ( tskIDLE_PRIORITY + 3 )\r
176 #define mainuIP_TASK_PRIORITY           ( tskIDLE_PRIORITY + 2 )\r
177 #define mainINTEGER_TASK_PRIORITY   ( tskIDLE_PRIORITY )\r
178 #define mainGEN_QUEUE_TASK_PRIORITY     ( tskIDLE_PRIORITY )\r
179 #define mainFLOP_TASK_PRIORITY          ( tskIDLE_PRIORITY )\r
180 \r
181 /* The WEB server uses string handling functions, which in turn use a bit more\r
182 stack than most of the other tasks. */\r
183 #define mainuIP_STACK_SIZE                      ( configMINIMAL_STACK_SIZE * 3 )\r
184 \r
185 /* The LED toggled by the check timer. */\r
186 #define mainCHECK_LED                           ( 3 )\r
187 \r
188 /* The rate at which mainCHECK_LED will toggle when all the tasks are running\r
189 without error.  Controlled by the check timer as described at the top of this\r
190 file. */\r
191 #define mainNO_ERROR_CHECK_TIMER_PERIOD_MS      ( 5000 / portTICK_RATE_MS )\r
192 \r
193 /* The rate at which mainCHECK_LED will toggle when an error has been reported\r
194 by at least one task.  Controlled by the check timer as described at the top of\r
195 this file. */\r
196 #define mainERROR_CHECK_TIMER_PERIOD_MS         ( 200 / portTICK_RATE_MS )\r
197 \r
198 /* A block time of zero simply means "don't block". */\r
199 #define mainDONT_BLOCK  ( 0UL )\r
200 \r
201 /* A set of timers are created, each of which toggles and LED.  This specifies\r
202 the number of timers to create. */\r
203 #define mainNUMBER_OF_LEDS_TO_FLASH             ( 3 )\r
204 \r
205 /*\r
206  * vApplicationMallocFailedHook() will only be called if\r
207  * configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook\r
208  * function that will execute if a call to pvPortMalloc() fails.\r
209  * pvPortMalloc() is called internally by the kernel whenever a task, queue or\r
210  * semaphore is created.  It is also called by various parts of the demo\r
211  * application.\r
212  */\r
213 void vApplicationMallocFailedHook( void );\r
214 \r
215 /*\r
216  * vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set to 1\r
217  * in FreeRTOSConfig.h.  It is a hook function that is called on each iteration\r
218  * of the idle task.  It is essential that code added to this hook function\r
219  * never attempts to block in any way (for example, call xQueueReceive() with\r
220  * a block time specified).  If the application makes use of the vTaskDelete()\r
221  * API function (as this demo application does) then it is also important that\r
222  * vApplicationIdleHook() is permitted to return to its calling function because\r
223  * it is the responsibility of the idle task to clean up memory allocated by the\r
224  * kernel to any task that has since been deleted.\r
225  */\r
226 void vApplicationIdleHook( void );\r
227 \r
228 /*\r
229  * vApplicationStackOverflowHook() will only be called if\r
230  * configCHECK_FOR_STACK_OVERFLOW is set to a non-zero value.  The handle and\r
231  * name of the offending task should be passed in the function parameters, but\r
232  * it is possible that the stack overflow will have corrupted these - in which\r
233  * case pxCurrentTCB can be inspected to find the same information.\r
234  */\r
235 void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName );\r
236 \r
237 /*\r
238  * The reg test tasks as described at the top of this file.\r
239  */\r
240 static void prvRegTest1Task( void *pvParameters );\r
241 static void prvRegTest2Task( void *pvParameters );\r
242 \r
243 /*\r
244  * The actual implementation of the reg test functionality, which, because of\r
245  * the direct register access, have to be in assembly.\r
246  */\r
247 static void prvRegTest1Implementation( void );\r
248 static void prvRegTest2Implementation( void );\r
249 \r
250 /*\r
251  * The check timer callback function, as described at the top of this file.\r
252  */\r
253 static void prvCheckTimerCallback( xTimerHandle xTimer );\r
254 \r
255 /*\r
256  * Contains the implementation of the WEB server.\r
257  */\r
258 extern void vuIP_Task( void *pvParameters );\r
259 \r
260 /*-----------------------------------------------------------*/\r
261 \r
262 /* Variables that are incremented on each iteration of the reg test tasks -\r
263 provided the tasks have not reported any errors.  The check task inspects these\r
264 variables to ensure they are still incrementing as expected.  If a variable\r
265 stops incrementing then it is likely that its associate task has stalled. */\r
266 unsigned long ulRegTest1CycleCount = 0UL, ulRegTest2CycleCount = 0UL;\r
267 \r
268 /* The status message that is displayed at the bottom of the "task stats" web\r
269 page, which is served by the uIP task.  This will report any errors picked up\r
270 by the reg test task. */\r
271 const char *pcStatusMessage = "All tasks executing without error.";\r
272 \r
273 /*-----------------------------------------------------------*/\r
274 \r
275 void main(void)\r
276 {\r
277 xTimerHandle xCheckTimer;\r
278 extern void HardwareSetup( void );\r
279 \r
280         /* Turn all LEDs off. */\r
281         vParTestInitialise();\r
282 \r
283         /* Start the reg test tasks which test the context switching mechanism. */\r
284         xTaskCreate( prvRegTest1Task, "RegTst1", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_1_PARAMETER, tskIDLE_PRIORITY, NULL );\r
285         xTaskCreate( prvRegTest2Task, "RegTst2", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_2_PARAMETER, tskIDLE_PRIORITY, NULL );\r
286 \r
287         /* The web server task. */\r
288         xTaskCreate( vuIP_Task, "uIP", mainuIP_STACK_SIZE, NULL, mainuIP_TASK_PRIORITY, NULL );\r
289 \r
290         /* Create the standard demo tasks. */\r
291         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
292         vCreateBlockTimeTasks();\r
293         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
294         vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
295         vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );\r
296         vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY ); \r
297         vStartQueuePeekTasks();\r
298         vStartRecursiveMutexTasks();\r
299         vStartInterruptQueueTasks();\r
300         vStartMathTasks( mainFLOP_TASK_PRIORITY );\r
301 \r
302         /* Create the timers used to toggle the LEDs. */\r
303         vStartLEDFlashTimers( mainNUMBER_OF_LEDS_TO_FLASH );\r
304 \r
305         /* Create the software timer that performs the 'check' functionality,\r
306         as described at the top of this file. */\r
307         xCheckTimer = xTimerCreate( "CheckTimer",                                                       /* A text name, purely to help debugging. */\r
308                                                                 ( mainNO_ERROR_CHECK_TIMER_PERIOD_MS ), /* The timer period, in this case 5000ms (5s). */\r
309                                                                 pdTRUE,                                                                 /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */\r
310                                                                 ( void * ) 0,                                                   /* The ID is not used, so can be set to anything. */\r
311                                                                 prvCheckTimerCallback                                   /* The callback function that inspects the status of all the other tasks. */\r
312                                                           );    \r
313         \r
314         if( xCheckTimer != NULL )\r
315         {\r
316                 xTimerStart( xCheckTimer, mainDONT_BLOCK );\r
317         }\r
318 \r
319         /* The suicide tasks must be created last as they need to know how many\r
320         tasks were running prior to their creation in order to ascertain whether\r
321         or not the correct/expected number of tasks are running at any given time. */\r
322         vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
323 \r
324         /* Start the tasks running. */\r
325         vTaskStartScheduler();\r
326 \r
327         /* If all is well, the scheduler will now be running, and the following line\r
328         will never be reached.  If the following line does execute, then there was\r
329         insufficient FreeRTOS heap memory available for the idle and/or timer tasks\r
330         to be created.  See the memory management section on the FreeRTOS web site\r
331         for more details. */\r
332         for( ;; );\r
333 }\r
334 /*-----------------------------------------------------------*/\r
335 \r
336 static void prvCheckTimerCallback( xTimerHandle xTimer )\r
337 {\r
338 static long lChangedTimerPeriodAlready = pdFALSE;\r
339 static unsigned long ulLastRegTest1CycleCount = 0, ulLastRegTest2CycleCount = 0;\r
340 long lErrorFound = pdFALSE;\r
341 \r
342         /* If this is being executed then the kernel has been started.  Start the \r
343         high frequency timer test as described at the top of this file.  This is \r
344         only included in the optimised build configuration - otherwise it takes up \r
345         too much CPU time and can disrupt other tests. */\r
346         #ifdef INCLUDE_HIGH_FREQUENCY_TIMER_TEST\r
347                 vSetupHighFrequencyTimer();\r
348         #endif\r
349 \r
350         /* Check the standard demo tasks are running without error. */\r
351         if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
352         {\r
353                 lErrorFound = pdTRUE;\r
354                 pcStatusMessage = "Error: GenQueue";\r
355         }\r
356         else if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
357         {\r
358                 lErrorFound = pdTRUE;\r
359                 pcStatusMessage = "Error: QueuePeek";\r
360         }\r
361         else if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
362         {\r
363                 lErrorFound = pdTRUE;\r
364                 pcStatusMessage = "Error: BlockQueue";\r
365         }\r
366         else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
367         {\r
368                 lErrorFound = pdTRUE;\r
369                 pcStatusMessage = "Error: BlockTime";\r
370         }\r
371         else if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
372         {\r
373                 lErrorFound = pdTRUE;\r
374                 pcStatusMessage = "Error: SemTest";\r
375         }\r
376         else if( xArePollingQueuesStillRunning() != pdTRUE )\r
377         {\r
378                 lErrorFound = pdTRUE;\r
379                 pcStatusMessage = "Error: PollQueue";\r
380         }\r
381         else if( xIsCreateTaskStillRunning() != pdTRUE )\r
382         {\r
383                 lErrorFound = pdTRUE;\r
384                 pcStatusMessage = "Error: Death";\r
385         }\r
386         else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
387         {\r
388                 lErrorFound = pdTRUE;\r
389                 pcStatusMessage = "Error: IntMath";\r
390         }\r
391         else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
392         {\r
393                 lErrorFound = pdTRUE;\r
394                 pcStatusMessage = "Error: RecMutex";\r
395         }\r
396         else if( xAreIntQueueTasksStillRunning() != pdPASS )\r
397         {\r
398                 lErrorFound = pdTRUE;\r
399                 pcStatusMessage = "Error: IntQueue";\r
400         }\r
401         else if( xAreMathsTaskStillRunning() != pdPASS )\r
402         {\r
403                 lErrorFound = pdTRUE;\r
404                 pcStatusMessage = "Error: Flop";\r
405         }\r
406 \r
407         /* Check the reg test tasks are still cycling.  They will stop incrementing\r
408         their loop counters if they encounter an error. */\r
409         if( ulRegTest1CycleCount == ulLastRegTest1CycleCount )\r
410         {\r
411                 lErrorFound = pdTRUE;\r
412                 pcStatusMessage = "Error: RegTest1";\r
413         }\r
414 \r
415         if( ulRegTest2CycleCount == ulLastRegTest2CycleCount )\r
416         {\r
417                 lErrorFound = pdTRUE;\r
418                 pcStatusMessage = "Error: RegTest2";\r
419         }\r
420 \r
421         ulLastRegTest1CycleCount = ulRegTest1CycleCount;\r
422         ulLastRegTest2CycleCount = ulRegTest2CycleCount;\r
423 \r
424         /* Toggle the check LED to give an indication of the system status.  If\r
425         the LED toggles every mainNO_ERROR_CHECK_TIMER_PERIOD_MS milliseconds then\r
426         everything is ok.  A faster toggle indicates an error. */\r
427         vParTestToggleLED( mainCHECK_LED );     \r
428         \r
429         /* Have any errors been latch in lErrorFound?  If so, shorten the\r
430         period of the check timer to mainERROR_CHECK_TIMER_PERIOD_MS milliseconds.\r
431         This will result in an increase in the rate at which mainCHECK_LED\r
432         toggles. */\r
433         if( lErrorFound != pdFALSE )\r
434         {\r
435                 if( lChangedTimerPeriodAlready == pdFALSE )\r
436                 {\r
437                         lChangedTimerPeriodAlready = pdTRUE;\r
438                         \r
439                         /* This call to xTimerChangePeriod() uses a zero block time.\r
440                         Functions called from inside of a timer callback function must\r
441                         *never* attempt to block. */\r
442                         xTimerChangePeriod( xTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK );\r
443                 }\r
444         }\r
445 }\r
446 /*-----------------------------------------------------------*/\r
447 \r
448 /* The RX port uses this callback function to configure its tick interrupt.\r
449 This allows the application to choose the tick interrupt source. */\r
450 void vApplicationSetupTimerInterrupt( void )\r
451 {\r
452         /* Enable compare match timer 0. */\r
453         MSTP( CMT0 ) = 0;\r
454 \r
455         /* Interrupt on compare match. */\r
456         CMT0.CMCR.BIT.CMIE = 1;\r
457 \r
458         /* Set the compare match value. */\r
459         CMT0.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ ) -1 ) / 8 );\r
460 \r
461         /* Divide the PCLK by 8. */\r
462         CMT0.CMCR.BIT.CKS = 0;\r
463 \r
464         /* Enable the interrupt... */\r
465         _IEN( _CMT0_CMI0 ) = 1;\r
466 \r
467         /* ...and set its priority to the application defined kernel priority. */\r
468         _IPR( _CMT0_CMI0 ) = configKERNEL_INTERRUPT_PRIORITY;\r
469 \r
470         /* Start the timer. */\r
471         CMT.CMSTR0.BIT.STR0 = 1;\r
472 }\r
473 /*-----------------------------------------------------------*/\r
474 \r
475 /* This function is explained by the comments above its prototype at the top\r
476 of this file. */\r
477 void vApplicationMallocFailedHook( void )\r
478 {\r
479         for( ;; );\r
480 }\r
481 /*-----------------------------------------------------------*/\r
482 \r
483 /* This function is explained by the comments above its prototype at the top\r
484 of this file. */\r
485 void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )\r
486 {\r
487         for( ;; );\r
488 }\r
489 /*-----------------------------------------------------------*/\r
490 \r
491 /* This function is explained by the comments above its prototype at the top\r
492 of this file. */\r
493 void vApplicationIdleHook( void )\r
494 {\r
495 }\r
496 /*-----------------------------------------------------------*/\r
497 \r
498 /* This function is explained in the comments at the top of this file. */\r
499 static void prvRegTest1Task( void *pvParameters )\r
500 {\r
501         if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_1_PARAMETER )\r
502         {\r
503                 /* The parameter did not contain the expected value. */\r
504                 for( ;; )\r
505                 {\r
506                         /* Stop the tick interrupt so its obvious something has gone wrong. */\r
507                         taskDISABLE_INTERRUPTS();\r
508                 }\r
509         }\r
510 \r
511         /* This is an inline asm function that never returns. */\r
512         prvRegTest1Implementation();\r
513 }\r
514 /*-----------------------------------------------------------*/\r
515 \r
516 /* This function is explained in the comments at the top of this file. */\r
517 static void prvRegTest2Task( void *pvParameters )\r
518 {\r
519         if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_2_PARAMETER )\r
520         {\r
521                 /* The parameter did not contain the expected value. */\r
522                 for( ;; )\r
523                 {\r
524                         /* Stop the tick interrupt so its obvious something has gone wrong. */\r
525                         taskDISABLE_INTERRUPTS();\r
526                 }\r
527         }\r
528 \r
529         /* This is an inline asm function that never returns. */\r
530         prvRegTest2Implementation();\r
531 }\r
532 /*-----------------------------------------------------------*/\r
533 \r
534 /* This function is explained in the comments at the top of this file. */\r
535 #pragma inline_asm prvRegTest1Implementation\r
536 static void prvRegTest1Implementation( void )\r
537 {\r
538         ; Put a known value in each register.\r
539         MOV.L   #1, R1\r
540         MOV.L   #2, R2\r
541         MOV.L   #3, R3\r
542         MOV.L   #4, R4\r
543         MOV.L   #5, R5\r
544         MOV.L   #6, R6\r
545         MOV.L   #7, R7\r
546         MOV.L   #8, R8\r
547         MOV.L   #9, R9\r
548         MOV.L   #10, R10\r
549         MOV.L   #11, R11\r
550         MOV.L   #12, R12\r
551         MOV.L   #13, R13\r
552         MOV.L   #14, R14\r
553         MOV.L   #15, R15\r
554 \r
555         ; Loop, checking each itteration that each register still contains the\r
556         ; expected value.\r
557 TestLoop1:\r
558 \r
559         ; Push the registers that are going to get clobbered.\r
560         PUSHM   R14-R15\r
561 \r
562         ; Increment the loop counter to show this task is still getting CPU time.\r
563         MOV.L   #_ulRegTest1CycleCount, R14\r
564         MOV.L   [ R14 ], R15\r
565         ADD             #1, R15\r
566         MOV.L   R15, [ R14 ]\r
567 \r
568         ; Yield to extend the text coverage.  Set the bit in the ITU SWINTR register.\r
569         MOV.L   #1, R14\r
570         MOV.L   #0872E0H, R15\r
571         MOV.B   R14, [R15]\r
572         NOP\r
573         NOP\r
574 \r
575         ; Restore the clobbered registers.\r
576         POPM    R14-R15\r
577 \r
578         ; Now compare each register to ensure it still contains the value that was\r
579         ; set before this loop was entered.\r
580         CMP             #1, R1\r
581         BNE             RegTest1Error\r
582         CMP             #2, R2\r
583         BNE             RegTest1Error\r
584         CMP             #3, R3\r
585         BNE             RegTest1Error\r
586         CMP             #4, R4\r
587         BNE             RegTest1Error\r
588         CMP             #5, R5\r
589         BNE             RegTest1Error\r
590         CMP             #6, R6\r
591         BNE             RegTest1Error\r
592         CMP             #7, R7\r
593         BNE             RegTest1Error\r
594         CMP             #8, R8\r
595         BNE             RegTest1Error\r
596         CMP             #9, R9\r
597         BNE             RegTest1Error\r
598         CMP             #10, R10\r
599         BNE             RegTest1Error\r
600         CMP             #11, R11\r
601         BNE             RegTest1Error\r
602         CMP             #12, R12\r
603         BNE             RegTest1Error\r
604         CMP             #13, R13\r
605         BNE             RegTest1Error\r
606         CMP             #14, R14\r
607         BNE             RegTest1Error\r
608         CMP             #15, R15\r
609         BNE             RegTest1Error\r
610 \r
611         ; All comparisons passed, start a new itteratio of this loop.\r
612         BRA             TestLoop1\r
613 \r
614 RegTest1Error:\r
615         ; A compare failed, just loop here so the loop counter stops incrementing\r
616         ; causing the check task to indicate the error.\r
617         BRA RegTest1Error\r
618 }\r
619 /*-----------------------------------------------------------*/\r
620 \r
621 /* This function is explained in the comments at the top of this file. */\r
622 #pragma inline_asm prvRegTest2Implementation\r
623 static void prvRegTest2Implementation( void )\r
624 {\r
625         ; Put a known value in each register.\r
626         MOV.L   #10, R1\r
627         MOV.L   #20, R2\r
628         MOV.L   #30, R3\r
629         MOV.L   #40, R4\r
630         MOV.L   #50, R5\r
631         MOV.L   #60, R6\r
632         MOV.L   #70, R7\r
633         MOV.L   #80, R8\r
634         MOV.L   #90, R9\r
635         MOV.L   #100, R10\r
636         MOV.L   #110, R11\r
637         MOV.L   #120, R12\r
638         MOV.L   #130, R13\r
639         MOV.L   #140, R14\r
640         MOV.L   #150, R15\r
641 \r
642         ; Loop, checking on each itteration that each register still contains the\r
643         ; expected value.\r
644 TestLoop2:\r
645 \r
646         ; Push the registers that are going to get clobbered.\r
647         PUSHM   R14-R15\r
648 \r
649         ; Increment the loop counter to show this task is still getting CPU time.\r
650         MOV.L   #_ulRegTest2CycleCount, R14\r
651         MOV.L   [ R14 ], R15\r
652         ADD             #1, R15\r
653         MOV.L   R15, [ R14 ]\r
654 \r
655         ; Restore the clobbered registers.\r
656         POPM    R14-R15\r
657 \r
658         CMP             #10, R1\r
659         BNE             RegTest2Error\r
660         CMP             #20, R2\r
661         BNE             RegTest2Error\r
662         CMP             #30, R3\r
663         BNE             RegTest2Error\r
664         CMP             #40, R4\r
665         BNE             RegTest2Error\r
666         CMP             #50, R5\r
667         BNE             RegTest2Error\r
668         CMP             #60, R6\r
669         BNE             RegTest2Error\r
670         CMP             #70, R7\r
671         BNE             RegTest2Error\r
672         CMP             #80, R8\r
673         BNE             RegTest2Error\r
674         CMP             #90, R9\r
675         BNE             RegTest2Error\r
676         CMP             #100, R10\r
677         BNE             RegTest2Error\r
678         CMP             #110, R11\r
679         BNE             RegTest2Error\r
680         CMP             #120, R12\r
681         BNE             RegTest2Error\r
682         CMP             #130, R13\r
683         BNE             RegTest2Error\r
684         CMP             #140, R14\r
685         BNE             RegTest2Error\r
686         CMP             #150, R15\r
687         BNE             RegTest2Error\r
688 \r
689         ; All comparisons passed, start a new itteratio of this loop.\r
690         BRA             TestLoop2\r
691 \r
692 RegTest2Error:\r
693         ; A compare failed, just loop here so the loop counter stops incrementing\r
694         ; - causing the check task to indicate the error.\r
695         BRA RegTest2Error\r
696 }\r
697 /*-----------------------------------------------------------*/\r
698 \r
699 char *pcGetTaskStatusMessage( void )\r
700 {\r
701         /* Not bothered about a critical section here although technically because of\r
702         the task priorities the pointer could change it will be atomic if not near\r
703         atomic and its not critical. */\r
704         return ( char * ) pcStatusMessage;\r
705 }\r
706 /*-----------------------------------------------------------*/\r
707 \r
708 \r
709 \r