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