]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M4F_ATSAM4E_Atmel_Studio/src/main_full.c
Update license information text files for the CLI, TCP and UDP products to be correct...
[freertos] / FreeRTOS / Demo / CORTEX_M4F_ATSAM4E_Atmel_Studio / src / main_full.c
1 /*\r
2  * FreeRTOS Kernel V10.0.0\r
3  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software. If you wish to use our Amazon\r
14  * FreeRTOS name, please do so in a fair use way that does not cause confusion.\r
15  *\r
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
22  *\r
23  * http://www.FreeRTOS.org\r
24  * http://aws.amazon.com/freertos\r
25  *\r
26  * 1 tab == 4 spaces!\r
27  */\r
28 \r
29 /******************************************************************************\r
30  * NOTE 1:  This project provides two demo applications.  A simple blinky style\r
31  * project, and a more comprehensive test and demo application that makes use of\r
32  * the FreeRTOS+CLI, FreeRTOS+UDP and FreeRTOS+FAT SL components.  The\r
33  * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select\r
34  * between the two.  See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY\r
35  * in main.c.  This file implements the comprehensive test and demo version,\r
36  * which is fully documented on the following URL:\r
37  * http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html\r
38  *\r
39  * NOTE 2:  This file only contains the source code that is specific to the\r
40  * full demo.  Generic functions, such FreeRTOS hook functions, and functions\r
41  * required to configure the hardware, are defined in main.c.\r
42  ******************************************************************************\r
43  *\r
44  * Full user instructions are provided on the following URL:\r
45  * http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html\r
46  *\r
47  * main_full():\r
48  *      + Uses FreeRTOS+FAT SL to create a set of example files on a RAM disk.\r
49  *  + Displays some bitmaps on the LCD.\r
50  *  + Registers sample generic, file system related and UDP related commands\r
51  *        with FreeRTOS+CLI.\r
52  *      + Creates all the standard demo application tasks and software timers.\r
53  *      + Starts the scheduler.\r
54  *\r
55  * A UDP command server and optionally two UDP echo client tasks are created\r
56  * from the network event hook after an IP address has been obtained.  The IP\r
57  * address is displayed on the LCD.\r
58  *\r
59  * A "check software timer" is created to provide visual feedback of the system\r
60  * status.  The timer's period is initially set to three seconds.  The callback\r
61  * function associated with the timer checks all the standard demo tasks are not\r
62  * only still executed, but are executing without reporting any errors.  If the\r
63  * timer discovers a task has either stalled, or reported an error, then it\r
64  * changes its own period from the initial three seconds, to just 200ms.  The\r
65  * check software timer also toggles the LED marked D4 - so if the LED toggles\r
66  * every three seconds then no potential errors have been found, and if the LED\r
67  * toggles every 200ms then a potential error has been found in at least one\r
68  * task.\r
69  *\r
70  * Information on accessing the CLI and file system, and using the UDP echo\r
71  * tasks is provided on http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html\r
72  *\r
73  */\r
74 \r
75 /* FreeRTOS includes. */\r
76 #include "FreeRTOS.h"\r
77 #include "task.h"\r
78 #include "timers.h"\r
79 \r
80 /* FreeRTOS+UDP includes. */\r
81 #include "FreeRTOS_UDP_IP.h"\r
82 #include "FreeRTOS_Sockets.h"\r
83 \r
84 /* UDP demo includes. */\r
85 #include "UDPCommandInterpreter.h"\r
86 #include "TwoEchoClients.h"\r
87 \r
88 /* Standard demo includes. */\r
89 #include "partest.h"\r
90 #include "blocktim.h"\r
91 #include "flash_timer.h"\r
92 #include "semtest.h"\r
93 #include "GenQTest.h"\r
94 #include "QPeek.h"\r
95 #include "IntQueue.h"\r
96 #include "countsem.h"\r
97 #include "dynamic.h"\r
98 #include "QueueOverwrite.h"\r
99 #include "QueueSet.h"\r
100 #include "recmutex.h"\r
101 #include "EventGroupsDemo.h"\r
102 #include "TaskNotify.h"\r
103 #include "IntSemTest.h"\r
104 #include "TimerDemo.h"\r
105 #include "IntQueue.h"\r
106 \r
107 /* The period after which the check timer will expire, in ms, provided no errors\r
108 have been reported by any of the standard demo tasks.  ms are converted to the\r
109 equivalent in ticks using the portTICK_PERIOD_MS constant. */\r
110 #define mainCHECK_TIMER_PERIOD_MS                       ( 3000UL / portTICK_PERIOD_MS )\r
111 \r
112 /* The period at which the check timer will expire, in ms, if an error has been\r
113 reported in one of the standard demo tasks.  ms are converted to the equivalent\r
114 in ticks using the portTICK_PERIOD_MS constant. */\r
115 #define mainERROR_CHECK_TIMER_PERIOD_MS         ( 200UL / portTICK_PERIOD_MS )\r
116 \r
117 /* The priorities of the various demo application tasks. */\r
118 #define mainSEM_TEST_PRIORITY                           ( tskIDLE_PRIORITY + 1 )\r
119 #define mainBLOCK_Q_PRIORITY                            ( tskIDLE_PRIORITY + 2 )\r
120 #define mainCOM_TEST_PRIORITY                           ( tskIDLE_PRIORITY + 2 )\r
121 #define mainINTEGER_TASK_PRIORITY           ( tskIDLE_PRIORITY )\r
122 #define mainGEN_QUEUE_TASK_PRIORITY                     ( tskIDLE_PRIORITY )\r
123 #define mainQUEUE_OVERWRITE_TASK_PRIORITY       ( tskIDLE_PRIORITY )\r
124 \r
125 /* The LED controlled by the 'check' software timer. */\r
126 #define mainCHECK_LED                                           ( 2 )\r
127 \r
128 /* The number of LEDs that should be controlled by the flash software timer\r
129 standard demo.  In this case it is only 1 as the starter kit has three LEDs, one\r
130 of which is controlled by the check timer and one of which is controlled by the\r
131 ISR triggered task. */\r
132 #define mainNUM_FLASH_TIMER_LEDS                        ( 1 )\r
133 \r
134 /* Misc. */\r
135 #define mainDONT_BLOCK                                          ( 0 )\r
136 \r
137 /* Note:  If the application is started without the network cable plugged in\r
138 then ipconfigUDP_TASK_PRIORITY should be set to 0 in FreeRTOSIPConfig.h to\r
139 ensure the IP task is created at the idle priority.  This is because the Atmel\r
140 ASF GMAC driver polls the GMAC looking for a connection, and doing so will\r
141 prevent any lower priority tasks from executing.  In this demo the IP task is\r
142 started at the idle priority, then set to configMAX_PRIORITIES - 2 in the\r
143 network event hook only after a connection has been established (when the event\r
144 passed into the network event hook is eNetworkUp).\r
145 http://www.FreeRTOS.org/udp */\r
146 #define mainCONNECTED_IP_TASK_PRIORITY          ( configMAX_PRIORITIES - 1 )\r
147 #define mainDISCONNECTED_IP_TASK_PRIORITY       ( tskIDLE_PRIORITY )\r
148 \r
149 /* UDP command server and echo task parameters. */\r
150 #define mainUDP_CLI_TASK_PRIORITY                       ( tskIDLE_PRIORITY )\r
151 #define mainUDP_CLI_PORT_NUMBER                         ( 5001UL )\r
152 #define mainUDP_CLI_TASK_STACK_SIZE                     ( configMINIMAL_STACK_SIZE + 90 )\r
153 #define mainECHO_CLIENT_STACK_SIZE                      ( configMINIMAL_STACK_SIZE + 30 )\r
154 \r
155 /* Set to 1 to include the UDP echo client tasks in the build.  The echo clients\r
156 require the IP address of the echo server to be defined using the\r
157 configECHO_SERVER_ADDR0 to configECHO_SERVER_ADDR3 constants in\r
158 FreeRTOSConfig.h. */\r
159 #define mainINCLUDE_ECHO_CLIENT_TASKS           1\r
160 \r
161 /* Used by the standard demo timer tasks. */\r
162 #define mainTIMER_TEST_PERIOD                           ( 50 )\r
163 \r
164 /*-----------------------------------------------------------*/\r
165 \r
166 /*\r
167  * The check timer callback function, as described at the top of this file.\r
168  */\r
169 static void prvCheckTimerCallback( TimerHandle_t xTimer );\r
170 \r
171 /*\r
172  * Creates a set of sample files on a RAM disk.  http://www.FreeRTOS.org/fat_sl\r
173  */\r
174 extern void vCreateAndVerifySampleFiles( void );\r
175 \r
176 /*\r
177  * Register sample generic commands that can be used with FreeRTOS+CLI.  Type\r
178  * 'help' in the command line to see a list of registered commands.\r
179  * http://www.FreeRTOS.org/cli\r
180  */\r
181 extern void vRegisterSampleCLICommands( void );\r
182 \r
183 /*\r
184  * Register sample file system commands that can be used with FreeRTOS+CLI.\r
185  */\r
186 extern void vRegisterFileSystemCLICommands( void );\r
187 \r
188 /*\r
189  * Register sample UDP related commands that can be used with FreeRTOS+CLI.\r
190  */\r
191 extern void vRegisterUDPCLICommands( void );\r
192 \r
193 /*\r
194  * Initialise the LCD and output a bitmap.\r
195  */\r
196 extern void vInitialiseLCD( void );\r
197 \r
198 /*\r
199  * Register check tasks, and the tasks used to write over and check the contents\r
200  * of the FPU registers, as described at the top of this file.  The nature of\r
201  * these files necessitates that they are written in an assembly file.\r
202  */\r
203 static void prvRegTest1Task( void *pvParameters ) __attribute__((naked));\r
204 static void prvRegTest2Task( void *pvParameters ) __attribute__((naked));\r
205 \r
206 /*-----------------------------------------------------------*/\r
207 \r
208 /* The default IP and MAC address used by the demo.  The address configuration\r
209 defined here will be used if ipconfigUSE_DHCP is 0, or if ipconfigUSE_DHCP is\r
210 1 but a DHCP server could not be contacted.  See the online documentation for\r
211 more information. */\r
212 static const uint8_t ucIPAddress[ 4 ] = { configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 };\r
213 static const uint8_t ucNetMask[ 4 ] = { configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 };\r
214 static const uint8_t ucGatewayAddress[ 4 ] = { configGATEWAY_ADDR0, configGATEWAY_ADDR1, configGATEWAY_ADDR2, configGATEWAY_ADDR3 };\r
215 static const uint8_t ucDNSServerAddress[ 4 ] = { configDNS_SERVER_ADDR0, configDNS_SERVER_ADDR1, configDNS_SERVER_ADDR2, configDNS_SERVER_ADDR3 };\r
216 \r
217 /* The MAC address used by the demo.  In production units the MAC address would\r
218 probably be read from flash memory or an EEPROM.  Here it is just hard coded.\r
219 Note each node on a network must have a unique MAC address. */\r
220 const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };\r
221 \r
222 /* The following two variables are used to communicate the status of the\r
223 register check tasks to the check software timer.  If the variables keep\r
224 incrementing, then the register check tasks have not discovered any errors.  If\r
225 a variable stops incrementing, then an error has been found. */\r
226 volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL;\r
227 \r
228 /*-----------------------------------------------------------*/\r
229 \r
230 int main_full( void )\r
231 {\r
232         /* Usage instructions on http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html */\r
233 \r
234         /* Initialise the LCD and output a bitmap.  The IP address will also be\r
235         displayed on the LCD when it has been obtained. */\r
236         vInitialiseLCD();\r
237 \r
238         /* If the file system is only going to be accessed from one task then\r
239         F_FS_THREAD_AWARE can be set to 0 and the set of example files are created\r
240         before the RTOS scheduler is started.  If the file system is going to be\r
241         access from more than one task then F_FS_THREAD_AWARE must be set to 1 and\r
242         the     set of sample files are created from the idle task hook function\r
243         vApplicationIdleHook(). */\r
244         #if( F_FS_THREAD_AWARE == 0 )\r
245         {\r
246                 /* Initialise the drive and file system, then create a few example\r
247                 files.  The files can be viewed and accessed via the CLI.  View the\r
248                 documentation page for this demo (link at the top of this file) for more\r
249                 information. */\r
250                 vCreateAndVerifySampleFiles();\r
251         }\r
252         #endif\r
253 \r
254         /* Register example generic, file system related and UDP related CLI\r
255         commands respectively.  Type 'help' into the command console to view a list\r
256         of registered commands. */\r
257         vRegisterSampleCLICommands();\r
258         vRegisterFileSystemCLICommands();\r
259         vRegisterUDPCLICommands();\r
260 \r
261         /* Initialise the network interface.  Tasks that use the network are\r
262         created in the network event hook when the network is connected and ready\r
263         for use.  The address values passed in here are used if ipconfigUSE_DHCP is\r
264         set to 0, or if ipconfigUSE_DHCP is set to 1 but a DHCP server cannot be\r
265         contacted.  The IP address actually used is displayed on the LCD (after DHCP\r
266         has completed if DHCP is used). */\r
267         FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );\r
268 \r
269         /* Create all the other standard demo tasks. */ \r
270         vCreateBlockTimeTasks();\r
271         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
272         vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );\r
273         vStartQueuePeekTasks();\r
274         vStartCountingSemaphoreTasks();\r
275         vStartDynamicPriorityTasks();\r
276         vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_TASK_PRIORITY );\r
277         vStartQueueSetTasks();\r
278         vStartRecursiveMutexTasks();\r
279         vStartEventGroupTasks();\r
280         vStartTaskNotifyTask();\r
281         vStartInterruptSemaphoreTasks();\r
282         vStartTimerDemoTask( mainTIMER_TEST_PERIOD );\r
283         vStartInterruptQueueTasks();\r
284 \r
285         /* Create the register check tasks, as described at the top of this\r
286         file */\r
287         xTaskCreate( prvRegTest1Task, "Reg1", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );\r
288         xTaskCreate( prvRegTest2Task, "Reg2", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );\r
289 \r
290         /* Start the scheduler itself. */\r
291         vTaskStartScheduler();\r
292 \r
293         /* If all is well, the scheduler will now be running, and the following line\r
294         will never be reached.  If the following line does execute, then there was\r
295         insufficient FreeRTOS heap memory available for the idle and/or timer tasks\r
296         to be created.  See the memory management section on the FreeRTOS web site\r
297         for more details. */\r
298         for( ;; );\r
299 }\r
300 /*-----------------------------------------------------------*/\r
301 \r
302 static void prvCheckTimerCallback( TimerHandle_t xTimer )\r
303 {\r
304 static long lChangedTimerPeriodAlready = pdFALSE;\r
305 static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;\r
306 unsigned long ulErrorOccurred = pdFALSE;\r
307 \r
308         /* Avoid compiler warnings. */\r
309         ( void ) xTimer;\r
310 \r
311         /* Have any of the standard demo tasks detected an error in their\r
312         operation? */\r
313         if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
314         {\r
315                 ulErrorOccurred |= ( 0x01UL << 3UL );\r
316         }\r
317         else if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
318         {\r
319                 ulErrorOccurred |= ( 0x01UL << 4UL );\r
320         }\r
321         else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
322         {\r
323                 ulErrorOccurred |= ( 0x01UL << 5UL );\r
324         }\r
325         else if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
326         {\r
327                 ulErrorOccurred |= ( 0x01UL << 6UL );\r
328         }\r
329         else if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )\r
330         {\r
331                 ulErrorOccurred |= ( 0x01UL << 8UL );\r
332         }\r
333         else if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
334         {\r
335                 ulErrorOccurred |= ( 0x01UL << 9UL );\r
336         }\r
337         else if( xIsQueueOverwriteTaskStillRunning() != pdTRUE )\r
338         {\r
339                 ulErrorOccurred |= ( 0x01UL << 10UL );\r
340         }\r
341         else if( xAreQueueSetTasksStillRunning() != pdTRUE )\r
342         {\r
343                 ulErrorOccurred |= ( 0x01UL << 11UL );\r
344         }\r
345         else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
346         {\r
347                 ulErrorOccurred |= ( 0x01UL << 12UL );\r
348         }\r
349         else if( xAreEventGroupTasksStillRunning() != pdTRUE )\r
350         {\r
351                 ulErrorOccurred |= ( 0x01UL << 13UL );\r
352         }\r
353         else if( xAreTaskNotificationTasksStillRunning() != pdTRUE )\r
354         {\r
355                 ulErrorOccurred |= ( 0x01UL << 14UL );\r
356         }\r
357         else if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )\r
358         {\r
359                 ulErrorOccurred |= ( 0x01UL << 15UL );\r
360         }\r
361         else if( xAreTimerDemoTasksStillRunning( mainCHECK_TIMER_PERIOD_MS ) != pdTRUE )\r
362         {\r
363                 ulErrorOccurred |= 1UL << 16UL;\r
364         }       \r
365         else if( xAreIntQueueTasksStillRunning() != pdTRUE )\r
366         {\r
367                 ulErrorOccurred |= 1UL << 17UL;\r
368         }\r
369 \r
370         \r
371         /* Check that the register test 1 task is still running. */\r
372         if( ulLastRegTest1Value == ulRegTest1LoopCounter )\r
373         {\r
374                 ulErrorOccurred |= 1UL << 18UL;\r
375         }\r
376         ulLastRegTest1Value = ulRegTest1LoopCounter;\r
377 \r
378         /* Check that the register test 2 task is still running. */\r
379         if( ulLastRegTest2Value == ulRegTest2LoopCounter )\r
380         {\r
381                 ulErrorOccurred |= 1UL << 19UL;\r
382         }\r
383         ulLastRegTest2Value = ulRegTest2LoopCounter;\r
384 \r
385         if( ulErrorOccurred != pdFALSE )\r
386         {\r
387                 /* An error occurred.  Increase the frequency at which the check timer\r
388                 toggles its LED to give visual feedback of the potential error\r
389                 condition. */\r
390                 if( lChangedTimerPeriodAlready == pdFALSE )\r
391                 {\r
392                         lChangedTimerPeriodAlready = pdTRUE;\r
393 \r
394                         /* This call to xTimerChangePeriod() uses a zero block time.\r
395                         Functions called from inside of a timer callback function must\r
396                         *never* attempt to block as to do so could impact other software\r
397                         timers. */\r
398                         xTimerChangePeriod( xTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK );\r
399                 }\r
400         }\r
401 \r
402         /* Toggle the LED to give visual feedback of the system status.  The rate at\r
403         which the LED toggles will increase to mainERROR_CHECK_TIMER_PERIOD_MS if a\r
404         suspected error has been found in any of the standard demo tasks. */\r
405         vParTestToggleLED( mainCHECK_LED );\r
406 }\r
407 /*-----------------------------------------------------------*/\r
408 \r
409 /* Called by FreeRTOS+UDP when the network connects. */\r
410 void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )\r
411 {\r
412 static long lTasksAlreadyCreated = pdFALSE;\r
413 const unsigned long ulXCoord = 3, ulYCoord = 3, ulIPAddressOffset = 45;\r
414 unsigned long ulIPAddress;\r
415 char cIPAddress[ 20 ];\r
416 \r
417         /* Note:  If the application is started without the network cable plugged in\r
418         then ipconfigUDP_TASK_PRIORITY should be set to 0 in FreeRTOSIPConfig.h to\r
419         ensure the IP task is created at the idle priority.  This is because the Atmel\r
420         ASF GMAC driver polls the GMAC looking for a connection, and doing so will\r
421         prevent any lower priority tasks from executing.  In this demo the IP task is\r
422         started at the idle priority, then set to configMAX_PRIORITIES - 2 in the\r
423         network event hook only after a connection has been established (when the event\r
424         passed into the network event hook is eNetworkUp). */\r
425         if( eNetworkEvent == eNetworkUp )\r
426         {\r
427                 /* Ensure tasks are only created once. */\r
428                 if( lTasksAlreadyCreated == pdFALSE )\r
429                 {\r
430                         /* Create the task that handles the CLI on a UDP port.  The port\r
431                         number is set using the configUDP_CLI_PORT_NUMBER setting in\r
432                         FreeRTOSConfig.h. */\r
433                         vStartUDPCommandInterpreterTask( mainUDP_CLI_TASK_STACK_SIZE, mainUDP_CLI_PORT_NUMBER, mainUDP_CLI_TASK_PRIORITY );\r
434 \r
435                         #if( mainINCLUDE_ECHO_CLIENT_TASKS == 1 )\r
436                         {\r
437                                 /* Create the UDP echo tasks.  The UDP echo tasks require the IP\r
438                                 address of the echo server to be defined using the\r
439                                 configECHO_SERVER_ADDR0 to configECHO_SERVER_ADDR3 constants in\r
440                                 FreeRTOSConfig.h. */\r
441                                 vStartEchoClientTasks( mainECHO_CLIENT_STACK_SIZE, tskIDLE_PRIORITY );\r
442                         }\r
443                         #endif\r
444                 }\r
445 \r
446                 /* Obtain the IP address, convert it to a string, then display it on the\r
447                 LCD. */\r
448                 FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );\r
449                 FreeRTOS_inet_ntoa( ulIPAddress, cIPAddress );\r
450                 ili93xx_draw_string( ulXCoord, ulYCoord, ( uint8_t * ) "IP: " );\r
451                 ili93xx_draw_string( ulXCoord + ulIPAddressOffset, ulYCoord, ( uint8_t * ) cIPAddress );\r
452 \r
453                 /* Set the priority of the IP task up to the desired priority now it has\r
454                 connected. */\r
455                 vTaskPrioritySet( NULL, mainCONNECTED_IP_TASK_PRIORITY );\r
456         }\r
457 \r
458         /* NOTE:  At the time of writing the Ethernet driver does not report the\r
459         cable being unplugged - so the following if() condition will never be met.\r
460         It is included for possible future updates to the driver. */\r
461         if( eNetworkEvent == eNetworkDown )\r
462         {\r
463                 /* Ensure the Atmel GMAC drivers don't hog all the CPU time as they look\r
464                 for a new connection by lowering the priority of the IP task to that of\r
465                 the Idle task. */\r
466                 vTaskPrioritySet( NULL, tskIDLE_PRIORITY );\r
467 \r
468                 /* Disconnected - so no IP address. */\r
469                 ili93xx_draw_string( ulXCoord, ulYCoord, ( uint8_t * ) "IP:                  " );\r
470         }\r
471 }\r
472 /*-----------------------------------------------------------*/\r
473 \r
474 void vFullDemoIdleHook( void )\r
475 {\r
476 static TimerHandle_t xCheckTimer = NULL;\r
477                 \r
478         if( xCheckTimer == NULL )\r
479         {\r
480                 /* Create the software timer that performs the 'check' \r
481                 functionality, in the full demo.  This is not done before the\r
482                 scheduler is started as to do so would prevent the standard demo\r
483                 timer tasks from passing their tests (they expect the timer\r
484                 command queue to be empty. */\r
485                 xCheckTimer = xTimerCreate( "CheckTimer",                                       /* A text name, purely to help debugging. */\r
486                                                                         ( mainCHECK_TIMER_PERIOD_MS ),  /* The timer period, in this case 3000ms (3s). */\r
487                                                                         pdTRUE,                                                 /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */\r
488                                                                         ( void * ) 0,                                   /* The ID is not used, so can be set to anything. */\r
489                                                                         prvCheckTimerCallback );                /* The callback function that inspects the status of all the other tasks. */\r
490 \r
491                 if( xCheckTimer != NULL )\r
492                 {\r
493                         xTimerStart( xCheckTimer, mainDONT_BLOCK );\r
494                 }\r
495                 \r
496                 /* Also start some timers that just flash LEDs. */\r
497                 vStartLEDFlashTimers( mainNUM_FLASH_TIMER_LEDS );\r
498         }\r
499         \r
500         /* If the file system is only going to be accessed from one task then\r
501         F_FS_THREAD_AWARE can be set to 0 and the set of example files is created\r
502         before the RTOS scheduler is started.  If the file system is going to be\r
503         access from more than one task then F_FS_THREAD_AWARE must be set to 1 and\r
504         the     set of sample files are created from the idle task hook function. */\r
505         #if( F_FS_THREAD_AWARE == 1 )\r
506         {\r
507                 static portBASE_TYPE xCreatedSampleFiles = pdFALSE;\r
508 \r
509                 /* Initialise the drive and file system, then create a few example\r
510                 files.  The output from this function just goes to the stdout window,\r
511                 allowing the output to be viewed when the UDP command console is not\r
512                 connected. */\r
513                 if( xCreatedSampleFiles == pdFALSE )\r
514                 {\r
515                         vCreateAndVerifySampleFiles();\r
516                         xCreatedSampleFiles = pdTRUE;\r
517                 }\r
518         }\r
519         #endif\r
520 }\r
521 /*-----------------------------------------------------------*/\r
522 \r
523 void vFullDemoTickHook( void )\r
524 {\r
525         /* Call the periodic queue overwrite from ISR test function. */\r
526         vQueueOverwritePeriodicISRDemo();\r
527 \r
528         /* Call the periodic queue set ISR test function. */\r
529         vQueueSetAccessQueueSetFromISR();\r
530         \r
531         /* Call the event group ISR tests. */\r
532         vPeriodicEventGroupsProcessing();\r
533         \r
534         /* Exercise task notifications from interrupts. */\r
535         xNotifyTaskFromISR();\r
536         \r
537         /* Use mutexes from interrupts. */\r
538         vInterruptSemaphorePeriodicTest();\r
539         \r
540         /* Use timers from an interrupt. */\r
541         vTimerPeriodicISRTests();\r
542 }\r
543 /*-----------------------------------------------------------*/\r
544 \r
545 /* Called automatically when a reply to an outgoing ping is received. */\r
546 void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifier )\r
547 {\r
548         /* This demo has nowhere to output any information so does nothing, but the\r
549         IP address resolved for the pined URL is displayed in the CLI. */\r
550         ( void ) usIdentifier;\r
551         ( void ) eStatus;\r
552 }\r
553 /*-----------------------------------------------------------*/\r
554 \r
555 /* This is a naked function. */\r
556 static void prvRegTest1Task( void *pvParameters )\r
557 {\r
558         __asm volatile\r
559         (\r
560                 "       /* Fill the core registers with known values. */                \n"\r
561                 "       mov r0, #100                                                                                    \n"\r
562                 "       mov r1, #101                                                                                    \n"\r
563                 "       mov r2, #102                                                                                    \n"\r
564                 "       mov r3, #103                                                                                    \n"\r
565                 "       mov     r4, #104                                                                                        \n"\r
566                 "       mov     r5, #105                                                                                        \n"\r
567                 "       mov     r6, #106                                                                                        \n"\r
568                 "       mov r7, #107                                                                                    \n"\r
569                 "       mov     r8, #108                                                                                        \n"\r
570                 "       mov     r9, #109                                                                                        \n"\r
571                 "       mov     r10, #110                                                                                       \n"\r
572                 "       mov     r11, #111                                                                                       \n"\r
573                 "       mov r12, #112                                                                                   \n"\r
574                 "                                                                                                                       \n"\r
575                 "       /* Fill the VFP registers with known values. */                 \n"\r
576                 "       vmov d0, r0, r1                                                                                 \n"\r
577                 "       vmov d1, r2, r3                                                                                 \n"\r
578                 "       vmov d2, r4, r5                                                                                 \n"\r
579                 "       vmov d3, r6, r7                                                                                 \n"\r
580                 "       vmov d4, r8, r9                                                                                 \n"\r
581                 "       vmov d5, r10, r11                                                                               \n"\r
582                 "       vmov d6, r0, r1                                                                                 \n"\r
583                 "       vmov d7, r2, r3                                                                                 \n"\r
584                 "       vmov d8, r4, r5                                                                                 \n"\r
585                 "       vmov d9, r6, r7                                                                                 \n"\r
586                 "       vmov d10, r8, r9                                                                                \n"\r
587                 "       vmov d11, r10, r11                                                                              \n"\r
588                 "       vmov d12, r0, r1                                                                                \n"\r
589                 "       vmov d13, r2, r3                                                                                \n"\r
590                 "       vmov d14, r4, r5                                                                                \n"\r
591                 "       vmov d15, r6, r7                                                                                \n"\r
592                 "                                                                                                                       \n"\r
593                 "reg1_loop:                                                                                                     \n"\r
594                 "       /* Check all the VFP registers still contain the values set above.\n"\r
595                 "       First save registers that are clobbered by the test. */ \n"\r
596                 "       push { r0-r1 }                                                                                  \n"\r
597                 "                                                                                                                       \n"\r
598                 "       vmov r0, r1, d0                                                                                 \n"\r
599                 "       cmp r0, #100                                                                                    \n"\r
600                 "       bne reg1_error_loopf                                                                    \n"\r
601                 "       cmp r1, #101                                                                                    \n"\r
602                 "       bne reg1_error_loopf                                                                    \n"\r
603                 "       vmov r0, r1, d1                                                                                 \n"\r
604                 "       cmp r0, #102                                                                                    \n"\r
605                 "       bne reg1_error_loopf                                                                    \n"\r
606                 "       cmp r1, #103                                                                                    \n"\r
607                 "       bne reg1_error_loopf                                                                    \n"\r
608                 "       vmov r0, r1, d2                                                                                 \n"\r
609                 "       cmp r0, #104                                                                                    \n"\r
610                 "       bne reg1_error_loopf                                                                    \n"\r
611                 "       cmp r1, #105                                                                                    \n"\r
612                 "       bne reg1_error_loopf                                                                    \n"\r
613                 "       vmov r0, r1, d3                                                                                 \n"\r
614                 "       cmp r0, #106                                                                                    \n"\r
615                 "       bne reg1_error_loopf                                                                    \n"\r
616                 "       cmp r1, #107                                                                                    \n"\r
617                 "       bne reg1_error_loopf                                                                    \n"\r
618                 "       vmov r0, r1, d4                                                                                 \n"\r
619                 "       cmp r0, #108                                                                                    \n"\r
620                 "       bne reg1_error_loopf                                                                    \n"\r
621                 "       cmp r1, #109                                                                                    \n"\r
622                 "       bne reg1_error_loopf                                                                    \n"\r
623                 "       vmov r0, r1, d5                                                                                 \n"\r
624                 "       cmp r0, #110                                                                                    \n"\r
625                 "       bne reg1_error_loopf                                                                    \n"\r
626                 "       cmp r1, #111                                                                                    \n"\r
627                 "       bne reg1_error_loopf                                                                    \n"\r
628                 "       vmov r0, r1, d6                                                                                 \n"\r
629                 "       cmp r0, #100                                                                                    \n"\r
630                 "       bne reg1_error_loopf                                                                    \n"\r
631                 "       cmp r1, #101                                                                                    \n"\r
632                 "       bne reg1_error_loopf                                                                    \n"\r
633                 "       vmov r0, r1, d7                                                                                 \n"\r
634                 "       cmp r0, #102                                                                                    \n"\r
635                 "       bne reg1_error_loopf                                                                    \n"\r
636                 "       cmp r1, #103                                                                                    \n"\r
637                 "       bne reg1_error_loopf                                                                    \n"\r
638                 "       vmov r0, r1, d8                                                                                 \n"\r
639                 "       cmp r0, #104                                                                                    \n"\r
640                 "       bne reg1_error_loopf                                                                    \n"\r
641                 "       cmp r1, #105                                                                                    \n"\r
642                 "       bne reg1_error_loopf                                                                    \n"\r
643                 "       vmov r0, r1, d9                                                                                 \n"\r
644                 "       cmp r0, #106                                                                                    \n"\r
645                 "       bne reg1_error_loopf                                                                    \n"\r
646                 "       cmp r1, #107                                                                                    \n"\r
647                 "       bne reg1_error_loopf                                                                    \n"\r
648                 "       vmov r0, r1, d10                                                                                \n"\r
649                 "       cmp r0, #108                                                                                    \n"\r
650                 "       bne reg1_error_loopf                                                                    \n"\r
651                 "       cmp r1, #109                                                                                    \n"\r
652                 "       bne reg1_error_loopf                                                                    \n"\r
653                 "       vmov r0, r1, d11                                                                                \n"\r
654                 "       cmp r0, #110                                                                                    \n"\r
655                 "       bne reg1_error_loopf                                                                    \n"\r
656                 "       cmp r1, #111                                                                                    \n"\r
657                 "       bne reg1_error_loopf                                                                    \n"\r
658                 "       vmov r0, r1, d12                                                                                \n"\r
659                 "       cmp r0, #100                                                                                    \n"\r
660                 "       bne reg1_error_loopf                                                                    \n"\r
661                 "       cmp r1, #101                                                                                    \n"\r
662                 "       bne reg1_error_loopf                                                                    \n"\r
663                 "       vmov r0, r1, d13                                                                                \n"\r
664                 "       cmp r0, #102                                                                                    \n"\r
665                 "       bne reg1_error_loopf                                                                    \n"\r
666                 "       cmp r1, #103                                                                                    \n"\r
667                 "       bne reg1_error_loopf                                                                    \n"\r
668                 "       vmov r0, r1, d14                                                                                \n"\r
669                 "       cmp r0, #104                                                                                    \n"\r
670                 "       bne reg1_error_loopf                                                                    \n"\r
671                 "       cmp r1, #105                                                                                    \n"\r
672                 "       bne reg1_error_loopf                                                                    \n"\r
673                 "       vmov r0, r1, d15                                                                                \n"\r
674                 "       cmp r0, #106                                                                                    \n"\r
675                 "       bne reg1_error_loopf                                                                    \n"\r
676                 "       cmp r1, #107                                                                                    \n"\r
677                 "       bne reg1_error_loopf                                                                    \n"\r
678                 "                                                                                                                       \n"\r
679                 "       /* Restore the registers that were clobbered by the test. */\n"\r
680                 "       pop {r0-r1}                                                                                             \n"\r
681                 "                                                                                                                       \n"\r
682                 "       /* VFP register test passed.  Jump to the core register test. */\n"\r
683                 "       b reg1_loopf_pass                                                                               \n"\r
684                 "                                                                                                                       \n"\r
685                 "reg1_error_loopf:                                                                                      \n"\r
686                 "       /* If this line is hit then a VFP register value was found to be\n"\r
687                 "       incorrect. */                                                                                   \n"\r
688                 "       b reg1_error_loopf                                                                              \n"\r
689                 "                                                                                                                       \n"\r
690                 "reg1_loopf_pass:                                                                                       \n"\r
691                 "                                                                                                                       \n"\r
692                 "       cmp     r0, #100                                                                                        \n"\r
693                 "       bne     reg1_error_loop                                                                         \n"\r
694                 "       cmp     r1, #101                                                                                        \n"\r
695                 "       bne     reg1_error_loop                                                                         \n"\r
696                 "       cmp     r2, #102                                                                                        \n"\r
697                 "       bne     reg1_error_loop                                                                         \n"\r
698                 "       cmp r3, #103                                                                                    \n"\r
699                 "       bne     reg1_error_loop                                                                         \n"\r
700                 "       cmp     r4, #104                                                                                        \n"\r
701                 "       bne     reg1_error_loop                                                                         \n"\r
702                 "       cmp     r5, #105                                                                                        \n"\r
703                 "       bne     reg1_error_loop                                                                         \n"\r
704                 "       cmp     r6, #106                                                                                        \n"\r
705                 "       bne     reg1_error_loop                                                                         \n"\r
706                 "       cmp     r7, #107                                                                                        \n"\r
707                 "       bne     reg1_error_loop                                                                         \n"\r
708                 "       cmp     r8, #108                                                                                        \n"\r
709                 "       bne     reg1_error_loop                                                                         \n"\r
710                 "       cmp     r9, #109                                                                                        \n"\r
711                 "       bne     reg1_error_loop                                                                         \n"\r
712                 "       cmp     r10, #110                                                                                       \n"\r
713                 "       bne     reg1_error_loop                                                                         \n"\r
714                 "       cmp     r11, #111                                                                                       \n"\r
715                 "       bne     reg1_error_loop                                                                         \n"\r
716                 "       cmp     r12, #112                                                                                       \n"\r
717                 "       bne     reg1_error_loop                                                                         \n"\r
718                 "                                                                                                                       \n"\r
719                 "       /* Everything passed, increment the loop counter. */    \n"\r
720                 "       push { r0-r1 }                                                                                  \n"\r
721                 "       ldr     r0, =ulRegTest1LoopCounter                                                      \n"\r
722                 "       ldr r1, [r0]                                                                                    \n"\r
723                 "       adds r1, r1, #1                                                                                 \n"\r
724                 "       str r1, [r0]                                                                                    \n"\r
725                 "       pop { r0-r1 }                                                                                   \n"\r
726                 "                                                                                                                       \n"\r
727                 "       /* Start again. */                                                                              \n"\r
728                 "       b reg1_loop                                                                                             \n"\r
729                 "                                                                                                                       \n"\r
730                 "reg1_error_loop:                                                                                       \n"\r
731                 "       /* If this line is hit then there was an error in a core register value.\n"\r
732                 "       The loop ensures the loop counter stops incrementing. */\n"\r
733                 "       b reg1_error_loop                                                                               \n"\r
734                 "       nop                                                                                                             "\r
735         );\r
736         \r
737         /* Remove compiler warnings about unused parameters. */\r
738         ( void ) pvParameters;\r
739 }\r
740 /*-----------------------------------------------------------*/\r
741 \r
742 /* This is a naked function. */\r
743 static void prvRegTest2Task( void *pvParameters )\r
744 {\r
745         __asm volatile\r
746         (\r
747                 "       /* Set all the core registers to known values. */               \n"\r
748                 "       mov r0, #-1                                                                                             \n"\r
749                 "       mov r1, #1                                                                                              \n"\r
750                 "       mov r2, #2                                                                                              \n"\r
751                 "       mov r3, #3                                                                                              \n"\r
752                 "       mov     r4, #4                                                                                          \n"\r
753                 "       mov     r5, #5                                                                                          \n"\r
754                 "       mov     r6, #6                                                                                          \n"\r
755                 "       mov r7, #7                                                                                              \n"\r
756                 "       mov     r8, #8                                                                                          \n"\r
757                 "       mov     r9, #9                                                                                          \n"\r
758                 "       mov     r10, #10                                                                                        \n"\r
759                 "       mov     r11, #11                                                                                        \n"\r
760                 "       mov r12, #12                                                                                    \n"\r
761                 "                                                                                                                       \n"\r
762                 "       /* Set all the VFP to known values. */                                  \n"\r
763                 "       vmov d0, r0, r1                                                                                 \n"\r
764                 "       vmov d1, r2, r3                                                                                 \n"\r
765                 "       vmov d2, r4, r5                                                                                 \n"\r
766                 "       vmov d3, r6, r7                                                                                 \n"\r
767                 "       vmov d4, r8, r9                                                                                 \n"\r
768                 "       vmov d5, r10, r11                                                                               \n"\r
769                 "       vmov d6, r0, r1                                                                                 \n"\r
770                 "       vmov d7, r2, r3                                                                                 \n"\r
771                 "       vmov d8, r4, r5                                                                                 \n"\r
772                 "       vmov d9, r6, r7                                                                                 \n"\r
773                 "       vmov d10, r8, r9                                                                                \n"\r
774                 "       vmov d11, r10, r11                                                                              \n"\r
775                 "       vmov d12, r0, r1                                                                                \n"\r
776                 "       vmov d13, r2, r3                                                                                \n"\r
777                 "       vmov d14, r4, r5                                                                                \n"\r
778                 "       vmov d15, r6, r7                                                                                \n"\r
779                 "                                                                                                                       \n"\r
780                 "reg2_loop:                                                                                                     \n"\r
781                 "                                                                                                                       \n"\r
782                 "       /* Check all the VFP registers still contain the values set above.\n"\r
783                 "       First save registers that are clobbered by the test. */ \n"\r
784                 "       push { r0-r1 }                                                                                  \n"\r
785                 "                                                                                                                       \n"\r
786                 "       vmov r0, r1, d0                                                                                 \n"\r
787                 "       cmp r0, #-1                                                                                             \n"\r
788                 "       bne reg2_error_loopf                                                                    \n"\r
789                 "       cmp r1, #1                                                                                              \n"\r
790                 "       bne reg2_error_loopf                                                                    \n"\r
791                 "       vmov r0, r1, d1                                                                                 \n"\r
792                 "       cmp r0, #2                                                                                              \n"\r
793                 "       bne reg2_error_loopf                                                                    \n"\r
794                 "       cmp r1, #3                                                                                              \n"\r
795                 "       bne reg2_error_loopf                                                                    \n"\r
796                 "       vmov r0, r1, d2                                                                                 \n"\r
797                 "       cmp r0, #4                                                                                              \n"\r
798                 "       bne reg2_error_loopf                                                                    \n"\r
799                 "       cmp r1, #5                                                                                              \n"\r
800                 "       bne reg2_error_loopf                                                                    \n"\r
801                 "       vmov r0, r1, d3                                                                                 \n"\r
802                 "       cmp r0, #6                                                                                              \n"\r
803                 "       bne reg2_error_loopf                                                                    \n"\r
804                 "       cmp r1, #7                                                                                              \n"\r
805                 "       bne reg2_error_loopf                                                                    \n"\r
806                 "       vmov r0, r1, d4                                                                                 \n"\r
807                 "       cmp r0, #8                                                                                              \n"\r
808                 "       bne reg2_error_loopf                                                                    \n"\r
809                 "       cmp r1, #9                                                                                              \n"\r
810                 "       bne reg2_error_loopf                                                                    \n"\r
811                 "       vmov r0, r1, d5                                                                                 \n"\r
812                 "       cmp r0, #10                                                                                             \n"\r
813                 "       bne reg2_error_loopf                                                                    \n"\r
814                 "       cmp r1, #11                                                                                             \n"\r
815                 "       bne reg2_error_loopf                                                                    \n"\r
816                 "       vmov r0, r1, d6                                                                                 \n"\r
817                 "       cmp r0, #-1                                                                                             \n"\r
818                 "       bne reg2_error_loopf                                                                    \n"\r
819                 "       cmp r1, #1                                                                                              \n"\r
820                 "       bne reg2_error_loopf                                                                    \n"\r
821                 "       vmov r0, r1, d7                                                                                 \n"\r
822                 "       cmp r0, #2                                                                                              \n"\r
823                 "       bne reg2_error_loopf                                                                    \n"\r
824                 "       cmp r1, #3                                                                                              \n"\r
825                 "       bne reg2_error_loopf                                                                    \n"\r
826                 "       vmov r0, r1, d8                                                                                 \n"\r
827                 "       cmp r0, #4                                                                                              \n"\r
828                 "       bne reg2_error_loopf                                                                    \n"\r
829                 "       cmp r1, #5                                                                                              \n"\r
830                 "       bne reg2_error_loopf                                                                    \n"\r
831                 "       vmov r0, r1, d9                                                                                 \n"\r
832                 "       cmp r0, #6                                                                                              \n"\r
833                 "       bne reg2_error_loopf                                                                    \n"\r
834                 "       cmp r1, #7                                                                                              \n"\r
835                 "       bne reg2_error_loopf                                                                    \n"\r
836                 "       vmov r0, r1, d10                                                                                \n"\r
837                 "       cmp r0, #8                                                                                              \n"\r
838                 "       bne reg2_error_loopf                                                                    \n"\r
839                 "       cmp r1, #9                                                                                              \n"\r
840                 "       bne reg2_error_loopf                                                                    \n"\r
841                 "       vmov r0, r1, d11                                                                                \n"\r
842                 "       cmp r0, #10                                                                                             \n"\r
843                 "       bne reg2_error_loopf                                                                    \n"\r
844                 "       cmp r1, #11                                                                                             \n"\r
845                 "       bne reg2_error_loopf                                                                    \n"\r
846                 "       vmov r0, r1, d12                                                                                \n"\r
847                 "       cmp r0, #-1                                                                                             \n"\r
848                 "       bne reg2_error_loopf                                                                    \n"\r
849                 "       cmp r1, #1                                                                                              \n"\r
850                 "       bne reg2_error_loopf                                                                    \n"\r
851                 "       vmov r0, r1, d13                                                                                \n"\r
852                 "       cmp r0, #2                                                                                              \n"\r
853                 "       bne reg2_error_loopf                                                                    \n"\r
854                 "       cmp r1, #3                                                                                              \n"\r
855                 "       bne reg2_error_loopf                                                                    \n"\r
856                 "       vmov r0, r1, d14                                                                                \n"\r
857                 "       cmp r0, #4                                                                                              \n"\r
858                 "       bne reg2_error_loopf                                                                    \n"\r
859                 "       cmp r1, #5                                                                                              \n"\r
860                 "       bne reg2_error_loopf                                                                    \n"\r
861                 "       vmov r0, r1, d15                                                                                \n"\r
862                 "       cmp r0, #6                                                                                              \n"\r
863                 "       bne reg2_error_loopf                                                                    \n"\r
864                 "       cmp r1, #7                                                                                              \n"\r
865                 "       bne reg2_error_loopf                                                                    \n"\r
866                 "                                                                                                                       \n"\r
867                 "       /* Restore the registers that were clobbered by the test. */\n"\r
868                 "       pop {r0-r1}                                                                                             \n"\r
869                 "                                                                                                                       \n"\r
870                 "       /* VFP register test passed.  Jump to the core register test. */\n"\r
871                 "       b reg2_loopf_pass                                                                               \n"\r
872                 "                                                                                                                       \n"\r
873                 "reg2_error_loopf:                                                                                      \n"\r
874                 "       /* If this line is hit then a VFP register value was found to be\n"\r
875                 "       incorrect. */                                                                                   \n"\r
876                 "       b reg2_error_loopf                                                                              \n"\r
877                 "                                                                                                                       \n"\r
878                 "reg2_loopf_pass:                                                                                       \n"\r
879                 "                                                                                                                       \n"\r
880                 "       cmp     r0, #-1                                                                                         \n"\r
881                 "       bne     reg2_error_loop                                                                         \n"\r
882                 "       cmp     r1, #1                                                                                          \n"\r
883                 "       bne     reg2_error_loop                                                                         \n"\r
884                 "       cmp     r2, #2                                                                                          \n"\r
885                 "       bne     reg2_error_loop                                                                         \n"\r
886                 "       cmp r3, #3                                                                                              \n"\r
887                 "       bne     reg2_error_loop                                                                         \n"\r
888                 "       cmp     r4, #4                                                                                          \n"\r
889                 "       bne     reg2_error_loop                                                                         \n"\r
890                 "       cmp     r5, #5                                                                                          \n"\r
891                 "       bne     reg2_error_loop                                                                         \n"\r
892                 "       cmp     r6, #6                                                                                          \n"\r
893                 "       bne     reg2_error_loop                                                                         \n"\r
894                 "       cmp     r7, #7                                                                                          \n"\r
895                 "       bne     reg2_error_loop                                                                         \n"\r
896                 "       cmp     r8, #8                                                                                          \n"\r
897                 "       bne     reg2_error_loop                                                                         \n"\r
898                 "       cmp     r9, #9                                                                                          \n"\r
899                 "       bne     reg2_error_loop                                                                         \n"\r
900                 "       cmp     r10, #10                                                                                        \n"\r
901                 "       bne     reg2_error_loop                                                                         \n"\r
902                 "       cmp     r11, #11                                                                                        \n"\r
903                 "       bne     reg2_error_loop                                                                         \n"\r
904                 "       cmp     r12, #12                                                                                        \n"\r
905                 "       bne     reg2_error_loop                                                                         \n"\r
906                 "                                                                                                                       \n"\r
907                 "       /* Increment the loop counter to indicate this test is still functioning\n"\r
908                 "       correctly. */                                                                                   \n"\r
909                 "       push { r0-r1 }                                                                                  \n"\r
910                 "       ldr     r0, =ulRegTest2LoopCounter                                                      \n"\r
911                 "       ldr r1, [r0]                                                                                    \n"\r
912                 "       adds r1, r1, #1                                                                                 \n"\r
913                 "       str r1, [r0]                                                                                    \n"\r
914                 "                                                                                                                       \n"\r
915                 "       /* Yield to increase test coverage. */                                  \n"\r
916                 "       movs r0, #0x01                                                                                  \n"\r
917                 "       ldr r1, =0xe000ed04                                                                     \n" /* NVIC_INT_CTRL */\r
918                 "       lsl r0, #28                                                                                     \n" /* Shift to PendSV bit */\r
919                 "       str r0, [r1]                                                                                    \n"\r
920                 "       dsb                                                                                                             \n"\r
921                 "       pop { r0-r1 }                                                                                   \n"\r
922                 "                                                                                                                       \n"\r
923                 "       /* Start again. */                                                                              \n"\r
924                 "       b reg2_loop                                                                                             \n"\r
925                 "                                                                                                                       \n"\r
926                 "reg2_error_loop:                                                                                       \n"\r
927                 "       /* If this line is hit then there was an error in a core register value.\n"\r
928                 "       This loop ensures the loop counter variable stops incrementing. */\n"\r
929                 "       b reg2_error_loop                                                                               \n"\r
930                 "       nop                                                                                                             \n"\r
931         );\r
932 \r
933         /* Remove compiler warnings about unused parameters. */\r
934         ( void ) pvParameters;\r
935 }\r