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