2 FreeRTOS V9.0.0rc2 - Copyright (C) 2016 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 This file is part of the FreeRTOS distribution.
\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
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
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
25 ***************************************************************************
\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
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
37 ***************************************************************************
\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
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
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
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
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
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
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
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
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
85 * Full user instructions are provided on the following URL:
\r
86 * http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html
\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
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
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
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
116 /* FreeRTOS includes. */
\r
117 #include "FreeRTOS.h"
\r
119 #include "timers.h"
\r
121 /* FreeRTOS+UDP includes. */
\r
122 #include "FreeRTOS_UDP_IP.h"
\r
123 #include "FreeRTOS_Sockets.h"
\r
125 /* UDP demo includes. */
\r
126 #include "UDPCommandInterpreter.h"
\r
127 #include "TwoEchoClients.h"
\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
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
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
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
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
166 /* The LED controlled by the 'check' software timer. */
\r
167 #define mainCHECK_LED ( 2 )
\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
176 #define mainDONT_BLOCK ( 0 )
\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
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
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
202 /* Used by the standard demo timer tasks. */
\r
203 #define mainTIMER_TEST_PERIOD ( 50 )
\r
205 /*-----------------------------------------------------------*/
\r
208 * The check timer callback function, as described at the top of this file.
\r
210 static void prvCheckTimerCallback( TimerHandle_t xTimer );
\r
213 * Creates a set of sample files on a RAM disk. http://www.FreeRTOS.org/fat_sl
\r
215 extern void vCreateAndVerifySampleFiles( void );
\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
222 extern void vRegisterSampleCLICommands( void );
\r
225 * Register sample file system commands that can be used with FreeRTOS+CLI.
\r
227 extern void vRegisterFileSystemCLICommands( void );
\r
230 * Register sample UDP related commands that can be used with FreeRTOS+CLI.
\r
232 extern void vRegisterUDPCLICommands( void );
\r
235 * Initialise the LCD and output a bitmap.
\r
237 extern void vInitialiseLCD( void );
\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
244 static void prvRegTest1Task( void *pvParameters ) __attribute__((naked));
\r
245 static void prvRegTest2Task( void *pvParameters ) __attribute__((naked));
\r
247 /*-----------------------------------------------------------*/
\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
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
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
269 /*-----------------------------------------------------------*/
\r
271 int main_full( void )
\r
273 /* Usage instructions on http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html */
\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
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
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
291 vCreateAndVerifySampleFiles();
\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
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
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
326 /* Create the register check tasks, as described at the top of this
\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
331 /* Start the scheduler itself. */
\r
332 vTaskStartScheduler();
\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
341 /*-----------------------------------------------------------*/
\r
343 static void prvCheckTimerCallback( TimerHandle_t xTimer )
\r
345 static long lChangedTimerPeriodAlready = pdFALSE;
\r
346 static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;
\r
347 unsigned long ulErrorOccurred = pdFALSE;
\r
349 /* Avoid compiler warnings. */
\r
352 /* Have any of the standard demo tasks detected an error in their
\r
354 if( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
356 ulErrorOccurred |= ( 0x01UL << 3UL );
\r
358 else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
\r
360 ulErrorOccurred |= ( 0x01UL << 4UL );
\r
362 else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
364 ulErrorOccurred |= ( 0x01UL << 5UL );
\r
366 else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
368 ulErrorOccurred |= ( 0x01UL << 6UL );
\r
370 else if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )
\r
372 ulErrorOccurred |= ( 0x01UL << 8UL );
\r
374 else if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
\r
376 ulErrorOccurred |= ( 0x01UL << 9UL );
\r
378 else if( xIsQueueOverwriteTaskStillRunning() != pdTRUE )
\r
380 ulErrorOccurred |= ( 0x01UL << 10UL );
\r
382 else if( xAreQueueSetTasksStillRunning() != pdTRUE )
\r
384 ulErrorOccurred |= ( 0x01UL << 11UL );
\r
386 else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
\r
388 ulErrorOccurred |= ( 0x01UL << 12UL );
\r
390 else if( xAreEventGroupTasksStillRunning() != pdTRUE )
\r
392 ulErrorOccurred |= ( 0x01UL << 13UL );
\r
394 else if( xAreTaskNotificationTasksStillRunning() != pdTRUE )
\r
396 ulErrorOccurred |= ( 0x01UL << 14UL );
\r
398 else if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )
\r
400 ulErrorOccurred |= ( 0x01UL << 15UL );
\r
402 else if( xAreTimerDemoTasksStillRunning( mainCHECK_TIMER_PERIOD_MS ) != pdTRUE )
\r
404 ulErrorOccurred |= 1UL << 16UL;
\r
406 else if( xAreIntQueueTasksStillRunning() != pdTRUE )
\r
408 ulErrorOccurred |= 1UL << 17UL;
\r
412 /* Check that the register test 1 task is still running. */
\r
413 if( ulLastRegTest1Value == ulRegTest1LoopCounter )
\r
415 ulErrorOccurred |= 1UL << 18UL;
\r
417 ulLastRegTest1Value = ulRegTest1LoopCounter;
\r
419 /* Check that the register test 2 task is still running. */
\r
420 if( ulLastRegTest2Value == ulRegTest2LoopCounter )
\r
422 ulErrorOccurred |= 1UL << 19UL;
\r
424 ulLastRegTest2Value = ulRegTest2LoopCounter;
\r
426 if( ulErrorOccurred != pdFALSE )
\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
431 if( lChangedTimerPeriodAlready == pdFALSE )
\r
433 lChangedTimerPeriodAlready = pdTRUE;
\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
439 xTimerChangePeriod( xTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK );
\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
448 /*-----------------------------------------------------------*/
\r
450 /* Called by FreeRTOS+UDP when the network connects. */
\r
451 void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
\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
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
468 /* Ensure tasks are only created once. */
\r
469 if( lTasksAlreadyCreated == pdFALSE )
\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
476 #if( mainINCLUDE_ECHO_CLIENT_TASKS == 1 )
\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
487 /* Obtain the IP address, convert it to a string, then display it on the
\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
494 /* Set the priority of the IP task up to the desired priority now it has
\r
496 vTaskPrioritySet( NULL, mainCONNECTED_IP_TASK_PRIORITY );
\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
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
507 vTaskPrioritySet( NULL, tskIDLE_PRIORITY );
\r
509 /* Disconnected - so no IP address. */
\r
510 ili93xx_draw_string( ulXCoord, ulYCoord, ( uint8_t * ) "IP: " );
\r
513 /*-----------------------------------------------------------*/
\r
515 void vFullDemoIdleHook( void )
\r
517 static TimerHandle_t xCheckTimer = NULL;
\r
519 if( xCheckTimer == NULL )
\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
532 if( xCheckTimer != NULL )
\r
534 xTimerStart( xCheckTimer, mainDONT_BLOCK );
\r
537 /* Also start some timers that just flash LEDs. */
\r
538 vStartLEDFlashTimers( mainNUM_FLASH_TIMER_LEDS );
\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
548 static portBASE_TYPE xCreatedSampleFiles = pdFALSE;
\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
554 if( xCreatedSampleFiles == pdFALSE )
\r
556 vCreateAndVerifySampleFiles();
\r
557 xCreatedSampleFiles = pdTRUE;
\r
562 /*-----------------------------------------------------------*/
\r
564 void vFullDemoTickHook( void )
\r
566 /* Call the periodic queue overwrite from ISR test function. */
\r
567 vQueueOverwritePeriodicISRDemo();
\r
569 /* Call the periodic queue set ISR test function. */
\r
570 vQueueSetAccessQueueSetFromISR();
\r
572 /* Call the event group ISR tests. */
\r
573 vPeriodicEventGroupsProcessing();
\r
575 /* Exercise task notifications from interrupts. */
\r
576 xNotifyTaskFromISR();
\r
578 /* Use mutexes from interrupts. */
\r
579 vInterruptSemaphorePeriodicTest();
\r
581 /* Use timers from an interrupt. */
\r
582 vTimerPeriodicISRTests();
\r
584 /*-----------------------------------------------------------*/
\r
586 /* Called automatically when a reply to an outgoing ping is received. */
\r
587 void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifier )
\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
594 /*-----------------------------------------------------------*/
\r
596 /* This is a naked function. */
\r
597 static void prvRegTest1Task( void *pvParameters )
\r
601 " /* Fill the core registers with known values. */ \n"
\r
612 " mov r10, #110 \n"
\r
613 " mov r11, #111 \n"
\r
614 " mov r12, #112 \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
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
639 " vmov r0, r1, d0 \n"
\r
641 " bne reg1_error_loopf \n"
\r
643 " bne reg1_error_loopf \n"
\r
644 " vmov r0, r1, d1 \n"
\r
646 " bne reg1_error_loopf \n"
\r
648 " bne reg1_error_loopf \n"
\r
649 " vmov r0, r1, d2 \n"
\r
651 " bne reg1_error_loopf \n"
\r
653 " bne reg1_error_loopf \n"
\r
654 " vmov r0, r1, d3 \n"
\r
656 " bne reg1_error_loopf \n"
\r
658 " bne reg1_error_loopf \n"
\r
659 " vmov r0, r1, d4 \n"
\r
661 " bne reg1_error_loopf \n"
\r
663 " bne reg1_error_loopf \n"
\r
664 " vmov r0, r1, d5 \n"
\r
666 " bne reg1_error_loopf \n"
\r
668 " bne reg1_error_loopf \n"
\r
669 " vmov r0, r1, d6 \n"
\r
671 " bne reg1_error_loopf \n"
\r
673 " bne reg1_error_loopf \n"
\r
674 " vmov r0, r1, d7 \n"
\r
676 " bne reg1_error_loopf \n"
\r
678 " bne reg1_error_loopf \n"
\r
679 " vmov r0, r1, d8 \n"
\r
681 " bne reg1_error_loopf \n"
\r
683 " bne reg1_error_loopf \n"
\r
684 " vmov r0, r1, d9 \n"
\r
686 " bne reg1_error_loopf \n"
\r
688 " bne reg1_error_loopf \n"
\r
689 " vmov r0, r1, d10 \n"
\r
691 " bne reg1_error_loopf \n"
\r
693 " bne reg1_error_loopf \n"
\r
694 " vmov r0, r1, d11 \n"
\r
696 " bne reg1_error_loopf \n"
\r
698 " bne reg1_error_loopf \n"
\r
699 " vmov r0, r1, d12 \n"
\r
701 " bne reg1_error_loopf \n"
\r
703 " bne reg1_error_loopf \n"
\r
704 " vmov r0, r1, d13 \n"
\r
706 " bne reg1_error_loopf \n"
\r
708 " bne reg1_error_loopf \n"
\r
709 " vmov r0, r1, d14 \n"
\r
711 " bne reg1_error_loopf \n"
\r
713 " bne reg1_error_loopf \n"
\r
714 " vmov r0, r1, d15 \n"
\r
716 " bne reg1_error_loopf \n"
\r
718 " bne reg1_error_loopf \n"
\r
720 " /* Restore the registers that were clobbered by the test. */\n"
\r
723 " /* VFP register test passed. Jump to the core register test. */\n"
\r
724 " b reg1_loopf_pass \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
731 "reg1_loopf_pass: \n"
\r
734 " bne reg1_error_loop \n"
\r
736 " bne reg1_error_loop \n"
\r
738 " bne reg1_error_loop \n"
\r
740 " bne reg1_error_loop \n"
\r
742 " bne reg1_error_loop \n"
\r
744 " bne reg1_error_loop \n"
\r
746 " bne reg1_error_loop \n"
\r
748 " bne reg1_error_loop \n"
\r
750 " bne reg1_error_loop \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
760 " /* Everything passed, increment the loop counter. */ \n"
\r
761 " push { r0-r1 } \n"
\r
762 " ldr r0, =ulRegTest1LoopCounter \n"
\r
764 " adds r1, r1, #1 \n"
\r
766 " pop { r0-r1 } \n"
\r
768 " /* Start again. */ \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
778 /* Remove compiler warnings about unused parameters. */
\r
779 ( void ) pvParameters;
\r
781 /*-----------------------------------------------------------*/
\r
783 /* This is a naked function. */
\r
784 static void prvRegTest2Task( void *pvParameters )
\r
788 " /* Set all the core registers to known values. */ \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
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
827 " vmov r0, r1, d0 \n"
\r
829 " bne reg2_error_loopf \n"
\r
831 " bne reg2_error_loopf \n"
\r
832 " vmov r0, r1, d1 \n"
\r
834 " bne reg2_error_loopf \n"
\r
836 " bne reg2_error_loopf \n"
\r
837 " vmov r0, r1, d2 \n"
\r
839 " bne reg2_error_loopf \n"
\r
841 " bne reg2_error_loopf \n"
\r
842 " vmov r0, r1, d3 \n"
\r
844 " bne reg2_error_loopf \n"
\r
846 " bne reg2_error_loopf \n"
\r
847 " vmov r0, r1, d4 \n"
\r
849 " bne reg2_error_loopf \n"
\r
851 " bne reg2_error_loopf \n"
\r
852 " vmov r0, r1, d5 \n"
\r
854 " bne reg2_error_loopf \n"
\r
856 " bne reg2_error_loopf \n"
\r
857 " vmov r0, r1, d6 \n"
\r
859 " bne reg2_error_loopf \n"
\r
861 " bne reg2_error_loopf \n"
\r
862 " vmov r0, r1, d7 \n"
\r
864 " bne reg2_error_loopf \n"
\r
866 " bne reg2_error_loopf \n"
\r
867 " vmov r0, r1, d8 \n"
\r
869 " bne reg2_error_loopf \n"
\r
871 " bne reg2_error_loopf \n"
\r
872 " vmov r0, r1, d9 \n"
\r
874 " bne reg2_error_loopf \n"
\r
876 " bne reg2_error_loopf \n"
\r
877 " vmov r0, r1, d10 \n"
\r
879 " bne reg2_error_loopf \n"
\r
881 " bne reg2_error_loopf \n"
\r
882 " vmov r0, r1, d11 \n"
\r
884 " bne reg2_error_loopf \n"
\r
886 " bne reg2_error_loopf \n"
\r
887 " vmov r0, r1, d12 \n"
\r
889 " bne reg2_error_loopf \n"
\r
891 " bne reg2_error_loopf \n"
\r
892 " vmov r0, r1, d13 \n"
\r
894 " bne reg2_error_loopf \n"
\r
896 " bne reg2_error_loopf \n"
\r
897 " vmov r0, r1, d14 \n"
\r
899 " bne reg2_error_loopf \n"
\r
901 " bne reg2_error_loopf \n"
\r
902 " vmov r0, r1, d15 \n"
\r
904 " bne reg2_error_loopf \n"
\r
906 " bne reg2_error_loopf \n"
\r
908 " /* Restore the registers that were clobbered by the test. */\n"
\r
911 " /* VFP register test passed. Jump to the core register test. */\n"
\r
912 " b reg2_loopf_pass \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
919 "reg2_loopf_pass: \n"
\r
922 " bne reg2_error_loop \n"
\r
924 " bne reg2_error_loop \n"
\r
926 " bne reg2_error_loop \n"
\r
928 " bne reg2_error_loop \n"
\r
930 " bne reg2_error_loop \n"
\r
932 " bne reg2_error_loop \n"
\r
934 " bne reg2_error_loop \n"
\r
936 " bne reg2_error_loop \n"
\r
938 " bne reg2_error_loop \n"
\r
940 " bne reg2_error_loop \n"
\r
942 " bne reg2_error_loop \n"
\r
944 " bne reg2_error_loop \n"
\r
946 " bne reg2_error_loop \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
953 " adds r1, r1, #1 \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
962 " pop { r0-r1 } \n"
\r
964 " /* Start again. */ \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
974 /* Remove compiler warnings about unused parameters. */
\r
975 ( void ) pvParameters;
\r