2 * FreeRTOS Kernel V10.1.0
\r
3 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 * this software and associated documentation files (the "Software"), to deal in
\r
7 * the Software without restriction, including without limitation the rights to
\r
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 * subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
22 * http://www.FreeRTOS.org
\r
23 * http://aws.amazon.com/freertos
\r
25 * 1 tab == 4 spaces!
\r
28 /******************************************************************************
\r
29 * NOTE 1: This project provides two demo applications. A simple blinky style
\r
30 * project, and a more comprehensive test and demo application that makes use of
\r
31 * the FreeRTOS+CLI, FreeRTOS+UDP and FreeRTOS+FAT SL components. The
\r
32 * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select
\r
33 * between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY
\r
34 * in main.c. This file implements the comprehensive test and demo version,
\r
35 * which is fully documented on the following URL:
\r
36 * http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html
\r
38 * NOTE 2: This file only contains the source code that is specific to the
\r
39 * full demo. Generic functions, such FreeRTOS hook functions, and functions
\r
40 * required to configure the hardware, are defined in main.c.
\r
41 ******************************************************************************
\r
43 * Full user instructions are provided on the following URL:
\r
44 * http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html
\r
47 * + Uses FreeRTOS+FAT SL to create a set of example files on a RAM disk.
\r
48 * + Displays some bitmaps on the LCD.
\r
49 * + Registers sample generic, file system related and UDP related commands
\r
50 * with FreeRTOS+CLI.
\r
51 * + Creates all the standard demo application tasks and software timers.
\r
52 * + Starts the scheduler.
\r
54 * A UDP command server and optionally two UDP echo client tasks are created
\r
55 * from the network event hook after an IP address has been obtained. The IP
\r
56 * address is displayed on the LCD.
\r
58 * A "check software timer" is created to provide visual feedback of the system
\r
59 * status. The timer's period is initially set to three seconds. The callback
\r
60 * function associated with the timer checks all the standard demo tasks are not
\r
61 * only still executed, but are executing without reporting any errors. If the
\r
62 * timer discovers a task has either stalled, or reported an error, then it
\r
63 * changes its own period from the initial three seconds, to just 200ms. The
\r
64 * check software timer also toggles the LED marked D4 - so if the LED toggles
\r
65 * every three seconds then no potential errors have been found, and if the LED
\r
66 * toggles every 200ms then a potential error has been found in at least one
\r
69 * Information on accessing the CLI and file system, and using the UDP echo
\r
70 * tasks is provided on http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html
\r
74 /* FreeRTOS includes. */
\r
75 #include "FreeRTOS.h"
\r
79 /* FreeRTOS+UDP includes. */
\r
80 #include "FreeRTOS_UDP_IP.h"
\r
81 #include "FreeRTOS_Sockets.h"
\r
83 /* UDP demo includes. */
\r
84 #include "UDPCommandInterpreter.h"
\r
85 #include "TwoEchoClients.h"
\r
87 /* Standard demo includes. */
\r
88 #include "partest.h"
\r
89 #include "blocktim.h"
\r
90 #include "flash_timer.h"
\r
91 #include "semtest.h"
\r
92 #include "GenQTest.h"
\r
94 #include "IntQueue.h"
\r
95 #include "countsem.h"
\r
96 #include "dynamic.h"
\r
97 #include "QueueOverwrite.h"
\r
98 #include "QueueSet.h"
\r
99 #include "recmutex.h"
\r
100 #include "EventGroupsDemo.h"
\r
101 #include "TaskNotify.h"
\r
102 #include "IntSemTest.h"
\r
103 #include "TimerDemo.h"
\r
104 #include "IntQueue.h"
\r
106 /* The period after which the check timer will expire, in ms, provided no errors
\r
107 have been reported by any of the standard demo tasks. ms are converted to the
\r
108 equivalent in ticks using the portTICK_PERIOD_MS constant. */
\r
109 #define mainCHECK_TIMER_PERIOD_MS ( 3000UL / portTICK_PERIOD_MS )
\r
111 /* The period at which the check timer will expire, in ms, if an error has been
\r
112 reported in one of the standard demo tasks. ms are converted to the equivalent
\r
113 in ticks using the portTICK_PERIOD_MS constant. */
\r
114 #define mainERROR_CHECK_TIMER_PERIOD_MS ( 200UL / portTICK_PERIOD_MS )
\r
116 /* The priorities of the various demo application tasks. */
\r
117 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
118 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
119 #define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
120 #define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
121 #define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
122 #define mainQUEUE_OVERWRITE_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
124 /* The LED controlled by the 'check' software timer. */
\r
125 #define mainCHECK_LED ( 2 )
\r
127 /* The number of LEDs that should be controlled by the flash software timer
\r
128 standard demo. In this case it is only 1 as the starter kit has three LEDs, one
\r
129 of which is controlled by the check timer and one of which is controlled by the
\r
130 ISR triggered task. */
\r
131 #define mainNUM_FLASH_TIMER_LEDS ( 1 )
\r
134 #define mainDONT_BLOCK ( 0 )
\r
136 /* Note: If the application is started without the network cable plugged in
\r
137 then ipconfigUDP_TASK_PRIORITY should be set to 0 in FreeRTOSIPConfig.h to
\r
138 ensure the IP task is created at the idle priority. This is because the Atmel
\r
139 ASF GMAC driver polls the GMAC looking for a connection, and doing so will
\r
140 prevent any lower priority tasks from executing. In this demo the IP task is
\r
141 started at the idle priority, then set to configMAX_PRIORITIES - 2 in the
\r
142 network event hook only after a connection has been established (when the event
\r
143 passed into the network event hook is eNetworkUp).
\r
144 http://www.FreeRTOS.org/udp */
\r
145 #define mainCONNECTED_IP_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
\r
146 #define mainDISCONNECTED_IP_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
148 /* UDP command server and echo task parameters. */
\r
149 #define mainUDP_CLI_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
150 #define mainUDP_CLI_PORT_NUMBER ( 5001UL )
\r
151 #define mainUDP_CLI_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE + 90 )
\r
152 #define mainECHO_CLIENT_STACK_SIZE ( configMINIMAL_STACK_SIZE + 30 )
\r
154 /* Set to 1 to include the UDP echo client tasks in the build. The echo clients
\r
155 require the IP address of the echo server to be defined using the
\r
156 configECHO_SERVER_ADDR0 to configECHO_SERVER_ADDR3 constants in
\r
157 FreeRTOSConfig.h. */
\r
158 #define mainINCLUDE_ECHO_CLIENT_TASKS 1
\r
160 /* Used by the standard demo timer tasks. */
\r
161 #define mainTIMER_TEST_PERIOD ( 50 )
\r
163 /*-----------------------------------------------------------*/
\r
166 * The check timer callback function, as described at the top of this file.
\r
168 static void prvCheckTimerCallback( TimerHandle_t xTimer );
\r
171 * Creates a set of sample files on a RAM disk. http://www.FreeRTOS.org/fat_sl
\r
173 extern void vCreateAndVerifySampleFiles( void );
\r
176 * Register sample generic commands that can be used with FreeRTOS+CLI. Type
\r
177 * 'help' in the command line to see a list of registered commands.
\r
178 * http://www.FreeRTOS.org/cli
\r
180 extern void vRegisterSampleCLICommands( void );
\r
183 * Register sample file system commands that can be used with FreeRTOS+CLI.
\r
185 extern void vRegisterFileSystemCLICommands( void );
\r
188 * Register sample UDP related commands that can be used with FreeRTOS+CLI.
\r
190 extern void vRegisterUDPCLICommands( void );
\r
193 * Initialise the LCD and output a bitmap.
\r
195 extern void vInitialiseLCD( void );
\r
198 * Register check tasks, and the tasks used to write over and check the contents
\r
199 * of the FPU registers, as described at the top of this file. The nature of
\r
200 * these files necessitates that they are written in an assembly file.
\r
202 static void prvRegTest1Task( void *pvParameters ) __attribute__((naked));
\r
203 static void prvRegTest2Task( void *pvParameters ) __attribute__((naked));
\r
205 /*-----------------------------------------------------------*/
\r
207 /* The default IP and MAC address used by the demo. The address configuration
\r
208 defined here will be used if ipconfigUSE_DHCP is 0, or if ipconfigUSE_DHCP is
\r
209 1 but a DHCP server could not be contacted. See the online documentation for
\r
210 more information. */
\r
211 static const uint8_t ucIPAddress[ 4 ] = { configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 };
\r
212 static const uint8_t ucNetMask[ 4 ] = { configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 };
\r
213 static const uint8_t ucGatewayAddress[ 4 ] = { configGATEWAY_ADDR0, configGATEWAY_ADDR1, configGATEWAY_ADDR2, configGATEWAY_ADDR3 };
\r
214 static const uint8_t ucDNSServerAddress[ 4 ] = { configDNS_SERVER_ADDR0, configDNS_SERVER_ADDR1, configDNS_SERVER_ADDR2, configDNS_SERVER_ADDR3 };
\r
216 /* The MAC address used by the demo. In production units the MAC address would
\r
217 probably be read from flash memory or an EEPROM. Here it is just hard coded.
\r
218 Note each node on a network must have a unique MAC address. */
\r
219 const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
\r
221 /* The following two variables are used to communicate the status of the
\r
222 register check tasks to the check software timer. If the variables keep
\r
223 incrementing, then the register check tasks have not discovered any errors. If
\r
224 a variable stops incrementing, then an error has been found. */
\r
225 volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL;
\r
227 /*-----------------------------------------------------------*/
\r
229 int main_full( void )
\r
231 /* Usage instructions on http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html */
\r
233 /* Initialise the LCD and output a bitmap. The IP address will also be
\r
234 displayed on the LCD when it has been obtained. */
\r
237 /* If the file system is only going to be accessed from one task then
\r
238 F_FS_THREAD_AWARE can be set to 0 and the set of example files are created
\r
239 before the RTOS scheduler is started. If the file system is going to be
\r
240 access from more than one task then F_FS_THREAD_AWARE must be set to 1 and
\r
241 the set of sample files are created from the idle task hook function
\r
242 vApplicationIdleHook(). */
\r
243 #if( F_FS_THREAD_AWARE == 0 )
\r
245 /* Initialise the drive and file system, then create a few example
\r
246 files. The files can be viewed and accessed via the CLI. View the
\r
247 documentation page for this demo (link at the top of this file) for more
\r
249 vCreateAndVerifySampleFiles();
\r
253 /* Register example generic, file system related and UDP related CLI
\r
254 commands respectively. Type 'help' into the command console to view a list
\r
255 of registered commands. */
\r
256 vRegisterSampleCLICommands();
\r
257 vRegisterFileSystemCLICommands();
\r
258 vRegisterUDPCLICommands();
\r
260 /* Initialise the network interface. Tasks that use the network are
\r
261 created in the network event hook when the network is connected and ready
\r
262 for use. The address values passed in here are used if ipconfigUSE_DHCP is
\r
263 set to 0, or if ipconfigUSE_DHCP is set to 1 but a DHCP server cannot be
\r
264 contacted. The IP address actually used is displayed on the LCD (after DHCP
\r
265 has completed if DHCP is used). */
\r
266 FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
\r
268 /* Create all the other standard demo tasks. */
\r
269 vCreateBlockTimeTasks();
\r
270 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
271 vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
\r
272 vStartQueuePeekTasks();
\r
273 vStartCountingSemaphoreTasks();
\r
274 vStartDynamicPriorityTasks();
\r
275 vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_TASK_PRIORITY );
\r
276 vStartQueueSetTasks();
\r
277 vStartRecursiveMutexTasks();
\r
278 vStartEventGroupTasks();
\r
279 vStartTaskNotifyTask();
\r
280 vStartInterruptSemaphoreTasks();
\r
281 vStartTimerDemoTask( mainTIMER_TEST_PERIOD );
\r
282 vStartInterruptQueueTasks();
\r
284 /* Create the register check tasks, as described at the top of this
\r
286 xTaskCreate( prvRegTest1Task, "Reg1", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );
\r
287 xTaskCreate( prvRegTest2Task, "Reg2", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );
\r
289 /* Start the scheduler itself. */
\r
290 vTaskStartScheduler();
\r
292 /* If all is well, the scheduler will now be running, and the following line
\r
293 will never be reached. If the following line does execute, then there was
\r
294 insufficient FreeRTOS heap memory available for the idle and/or timer tasks
\r
295 to be created. See the memory management section on the FreeRTOS web site
\r
296 for more details. */
\r
299 /*-----------------------------------------------------------*/
\r
301 static void prvCheckTimerCallback( TimerHandle_t xTimer )
\r
303 static long lChangedTimerPeriodAlready = pdFALSE;
\r
304 static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;
\r
305 unsigned long ulErrorOccurred = pdFALSE;
\r
307 /* Avoid compiler warnings. */
\r
310 /* Have any of the standard demo tasks detected an error in their
\r
312 if( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
314 ulErrorOccurred |= ( 0x01UL << 3UL );
\r
316 else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
\r
318 ulErrorOccurred |= ( 0x01UL << 4UL );
\r
320 else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
322 ulErrorOccurred |= ( 0x01UL << 5UL );
\r
324 else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
326 ulErrorOccurred |= ( 0x01UL << 6UL );
\r
328 else if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )
\r
330 ulErrorOccurred |= ( 0x01UL << 8UL );
\r
332 else if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
\r
334 ulErrorOccurred |= ( 0x01UL << 9UL );
\r
336 else if( xIsQueueOverwriteTaskStillRunning() != pdTRUE )
\r
338 ulErrorOccurred |= ( 0x01UL << 10UL );
\r
340 else if( xAreQueueSetTasksStillRunning() != pdTRUE )
\r
342 ulErrorOccurred |= ( 0x01UL << 11UL );
\r
344 else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
\r
346 ulErrorOccurred |= ( 0x01UL << 12UL );
\r
348 else if( xAreEventGroupTasksStillRunning() != pdTRUE )
\r
350 ulErrorOccurred |= ( 0x01UL << 13UL );
\r
352 else if( xAreTaskNotificationTasksStillRunning() != pdTRUE )
\r
354 ulErrorOccurred |= ( 0x01UL << 14UL );
\r
356 else if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )
\r
358 ulErrorOccurred |= ( 0x01UL << 15UL );
\r
360 else if( xAreTimerDemoTasksStillRunning( mainCHECK_TIMER_PERIOD_MS ) != pdTRUE )
\r
362 ulErrorOccurred |= 1UL << 16UL;
\r
364 else if( xAreIntQueueTasksStillRunning() != pdTRUE )
\r
366 ulErrorOccurred |= 1UL << 17UL;
\r
370 /* Check that the register test 1 task is still running. */
\r
371 if( ulLastRegTest1Value == ulRegTest1LoopCounter )
\r
373 ulErrorOccurred |= 1UL << 18UL;
\r
375 ulLastRegTest1Value = ulRegTest1LoopCounter;
\r
377 /* Check that the register test 2 task is still running. */
\r
378 if( ulLastRegTest2Value == ulRegTest2LoopCounter )
\r
380 ulErrorOccurred |= 1UL << 19UL;
\r
382 ulLastRegTest2Value = ulRegTest2LoopCounter;
\r
384 if( ulErrorOccurred != pdFALSE )
\r
386 /* An error occurred. Increase the frequency at which the check timer
\r
387 toggles its LED to give visual feedback of the potential error
\r
389 if( lChangedTimerPeriodAlready == pdFALSE )
\r
391 lChangedTimerPeriodAlready = pdTRUE;
\r
393 /* This call to xTimerChangePeriod() uses a zero block time.
\r
394 Functions called from inside of a timer callback function must
\r
395 *never* attempt to block as to do so could impact other software
\r
397 xTimerChangePeriod( xTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK );
\r
401 /* Toggle the LED to give visual feedback of the system status. The rate at
\r
402 which the LED toggles will increase to mainERROR_CHECK_TIMER_PERIOD_MS if a
\r
403 suspected error has been found in any of the standard demo tasks. */
\r
404 vParTestToggleLED( mainCHECK_LED );
\r
406 /*-----------------------------------------------------------*/
\r
408 /* Called by FreeRTOS+UDP when the network connects. */
\r
409 void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
\r
411 static long lTasksAlreadyCreated = pdFALSE;
\r
412 const unsigned long ulXCoord = 3, ulYCoord = 3, ulIPAddressOffset = 45;
\r
413 unsigned long ulIPAddress;
\r
414 char cIPAddress[ 20 ];
\r
416 /* Note: If the application is started without the network cable plugged in
\r
417 then ipconfigUDP_TASK_PRIORITY should be set to 0 in FreeRTOSIPConfig.h to
\r
418 ensure the IP task is created at the idle priority. This is because the Atmel
\r
419 ASF GMAC driver polls the GMAC looking for a connection, and doing so will
\r
420 prevent any lower priority tasks from executing. In this demo the IP task is
\r
421 started at the idle priority, then set to configMAX_PRIORITIES - 2 in the
\r
422 network event hook only after a connection has been established (when the event
\r
423 passed into the network event hook is eNetworkUp). */
\r
424 if( eNetworkEvent == eNetworkUp )
\r
426 /* Ensure tasks are only created once. */
\r
427 if( lTasksAlreadyCreated == pdFALSE )
\r
429 /* Create the task that handles the CLI on a UDP port. The port
\r
430 number is set using the configUDP_CLI_PORT_NUMBER setting in
\r
431 FreeRTOSConfig.h. */
\r
432 vStartUDPCommandInterpreterTask( mainUDP_CLI_TASK_STACK_SIZE, mainUDP_CLI_PORT_NUMBER, mainUDP_CLI_TASK_PRIORITY );
\r
434 #if( mainINCLUDE_ECHO_CLIENT_TASKS == 1 )
\r
436 /* Create the UDP echo tasks. The UDP echo tasks require the IP
\r
437 address of the echo server to be defined using the
\r
438 configECHO_SERVER_ADDR0 to configECHO_SERVER_ADDR3 constants in
\r
439 FreeRTOSConfig.h. */
\r
440 vStartEchoClientTasks( mainECHO_CLIENT_STACK_SIZE, tskIDLE_PRIORITY );
\r
445 /* Obtain the IP address, convert it to a string, then display it on the
\r
447 FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
\r
448 FreeRTOS_inet_ntoa( ulIPAddress, cIPAddress );
\r
449 ili93xx_draw_string( ulXCoord, ulYCoord, ( uint8_t * ) "IP: " );
\r
450 ili93xx_draw_string( ulXCoord + ulIPAddressOffset, ulYCoord, ( uint8_t * ) cIPAddress );
\r
452 /* Set the priority of the IP task up to the desired priority now it has
\r
454 vTaskPrioritySet( NULL, mainCONNECTED_IP_TASK_PRIORITY );
\r
457 /* NOTE: At the time of writing the Ethernet driver does not report the
\r
458 cable being unplugged - so the following if() condition will never be met.
\r
459 It is included for possible future updates to the driver. */
\r
460 if( eNetworkEvent == eNetworkDown )
\r
462 /* Ensure the Atmel GMAC drivers don't hog all the CPU time as they look
\r
463 for a new connection by lowering the priority of the IP task to that of
\r
465 vTaskPrioritySet( NULL, tskIDLE_PRIORITY );
\r
467 /* Disconnected - so no IP address. */
\r
468 ili93xx_draw_string( ulXCoord, ulYCoord, ( uint8_t * ) "IP: " );
\r
471 /*-----------------------------------------------------------*/
\r
473 void vFullDemoIdleHook( void )
\r
475 static TimerHandle_t xCheckTimer = NULL;
\r
477 if( xCheckTimer == NULL )
\r
479 /* Create the software timer that performs the 'check'
\r
480 functionality, in the full demo. This is not done before the
\r
481 scheduler is started as to do so would prevent the standard demo
\r
482 timer tasks from passing their tests (they expect the timer
\r
483 command queue to be empty. */
\r
484 xCheckTimer = xTimerCreate( "CheckTimer", /* A text name, purely to help debugging. */
\r
485 ( mainCHECK_TIMER_PERIOD_MS ), /* The timer period, in this case 3000ms (3s). */
\r
486 pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */
\r
487 ( void * ) 0, /* The ID is not used, so can be set to anything. */
\r
488 prvCheckTimerCallback ); /* The callback function that inspects the status of all the other tasks. */
\r
490 if( xCheckTimer != NULL )
\r
492 xTimerStart( xCheckTimer, mainDONT_BLOCK );
\r
495 /* Also start some timers that just flash LEDs. */
\r
496 vStartLEDFlashTimers( mainNUM_FLASH_TIMER_LEDS );
\r
499 /* If the file system is only going to be accessed from one task then
\r
500 F_FS_THREAD_AWARE can be set to 0 and the set of example files is created
\r
501 before the RTOS scheduler is started. If the file system is going to be
\r
502 access from more than one task then F_FS_THREAD_AWARE must be set to 1 and
\r
503 the set of sample files are created from the idle task hook function. */
\r
504 #if( F_FS_THREAD_AWARE == 1 )
\r
506 static portBASE_TYPE xCreatedSampleFiles = pdFALSE;
\r
508 /* Initialise the drive and file system, then create a few example
\r
509 files. The output from this function just goes to the stdout window,
\r
510 allowing the output to be viewed when the UDP command console is not
\r
512 if( xCreatedSampleFiles == pdFALSE )
\r
514 vCreateAndVerifySampleFiles();
\r
515 xCreatedSampleFiles = pdTRUE;
\r
520 /*-----------------------------------------------------------*/
\r
522 void vFullDemoTickHook( void )
\r
524 /* Call the periodic queue overwrite from ISR test function. */
\r
525 vQueueOverwritePeriodicISRDemo();
\r
527 /* Call the periodic queue set ISR test function. */
\r
528 vQueueSetAccessQueueSetFromISR();
\r
530 /* Call the event group ISR tests. */
\r
531 vPeriodicEventGroupsProcessing();
\r
533 /* Exercise task notifications from interrupts. */
\r
534 xNotifyTaskFromISR();
\r
536 /* Use mutexes from interrupts. */
\r
537 vInterruptSemaphorePeriodicTest();
\r
539 /* Use timers from an interrupt. */
\r
540 vTimerPeriodicISRTests();
\r
542 /*-----------------------------------------------------------*/
\r
544 /* Called automatically when a reply to an outgoing ping is received. */
\r
545 void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifier )
\r
547 /* This demo has nowhere to output any information so does nothing, but the
\r
548 IP address resolved for the pined URL is displayed in the CLI. */
\r
549 ( void ) usIdentifier;
\r
552 /*-----------------------------------------------------------*/
\r
554 /* This is a naked function. */
\r
555 static void prvRegTest1Task( void *pvParameters )
\r
559 " /* Fill the core registers with known values. */ \n"
\r
570 " mov r10, #110 \n"
\r
571 " mov r11, #111 \n"
\r
572 " mov r12, #112 \n"
\r
574 " /* Fill the VFP registers with known values. */ \n"
\r
575 " vmov d0, r0, r1 \n"
\r
576 " vmov d1, r2, r3 \n"
\r
577 " vmov d2, r4, r5 \n"
\r
578 " vmov d3, r6, r7 \n"
\r
579 " vmov d4, r8, r9 \n"
\r
580 " vmov d5, r10, r11 \n"
\r
581 " vmov d6, r0, r1 \n"
\r
582 " vmov d7, r2, r3 \n"
\r
583 " vmov d8, r4, r5 \n"
\r
584 " vmov d9, r6, r7 \n"
\r
585 " vmov d10, r8, r9 \n"
\r
586 " vmov d11, r10, r11 \n"
\r
587 " vmov d12, r0, r1 \n"
\r
588 " vmov d13, r2, r3 \n"
\r
589 " vmov d14, r4, r5 \n"
\r
590 " vmov d15, r6, r7 \n"
\r
593 " /* Check all the VFP registers still contain the values set above.\n"
\r
594 " First save registers that are clobbered by the test. */ \n"
\r
595 " push { r0-r1 } \n"
\r
597 " vmov r0, r1, d0 \n"
\r
599 " bne reg1_error_loopf \n"
\r
601 " bne reg1_error_loopf \n"
\r
602 " vmov r0, r1, d1 \n"
\r
604 " bne reg1_error_loopf \n"
\r
606 " bne reg1_error_loopf \n"
\r
607 " vmov r0, r1, d2 \n"
\r
609 " bne reg1_error_loopf \n"
\r
611 " bne reg1_error_loopf \n"
\r
612 " vmov r0, r1, d3 \n"
\r
614 " bne reg1_error_loopf \n"
\r
616 " bne reg1_error_loopf \n"
\r
617 " vmov r0, r1, d4 \n"
\r
619 " bne reg1_error_loopf \n"
\r
621 " bne reg1_error_loopf \n"
\r
622 " vmov r0, r1, d5 \n"
\r
624 " bne reg1_error_loopf \n"
\r
626 " bne reg1_error_loopf \n"
\r
627 " vmov r0, r1, d6 \n"
\r
629 " bne reg1_error_loopf \n"
\r
631 " bne reg1_error_loopf \n"
\r
632 " vmov r0, r1, d7 \n"
\r
634 " bne reg1_error_loopf \n"
\r
636 " bne reg1_error_loopf \n"
\r
637 " vmov r0, r1, d8 \n"
\r
639 " bne reg1_error_loopf \n"
\r
641 " bne reg1_error_loopf \n"
\r
642 " vmov r0, r1, d9 \n"
\r
644 " bne reg1_error_loopf \n"
\r
646 " bne reg1_error_loopf \n"
\r
647 " vmov r0, r1, d10 \n"
\r
649 " bne reg1_error_loopf \n"
\r
651 " bne reg1_error_loopf \n"
\r
652 " vmov r0, r1, d11 \n"
\r
654 " bne reg1_error_loopf \n"
\r
656 " bne reg1_error_loopf \n"
\r
657 " vmov r0, r1, d12 \n"
\r
659 " bne reg1_error_loopf \n"
\r
661 " bne reg1_error_loopf \n"
\r
662 " vmov r0, r1, d13 \n"
\r
664 " bne reg1_error_loopf \n"
\r
666 " bne reg1_error_loopf \n"
\r
667 " vmov r0, r1, d14 \n"
\r
669 " bne reg1_error_loopf \n"
\r
671 " bne reg1_error_loopf \n"
\r
672 " vmov r0, r1, d15 \n"
\r
674 " bne reg1_error_loopf \n"
\r
676 " bne reg1_error_loopf \n"
\r
678 " /* Restore the registers that were clobbered by the test. */\n"
\r
681 " /* VFP register test passed. Jump to the core register test. */\n"
\r
682 " b reg1_loopf_pass \n"
\r
684 "reg1_error_loopf: \n"
\r
685 " /* If this line is hit then a VFP register value was found to be\n"
\r
686 " incorrect. */ \n"
\r
687 " b reg1_error_loopf \n"
\r
689 "reg1_loopf_pass: \n"
\r
692 " bne reg1_error_loop \n"
\r
694 " bne reg1_error_loop \n"
\r
696 " bne reg1_error_loop \n"
\r
698 " bne reg1_error_loop \n"
\r
700 " bne reg1_error_loop \n"
\r
702 " bne reg1_error_loop \n"
\r
704 " bne reg1_error_loop \n"
\r
706 " bne reg1_error_loop \n"
\r
708 " bne reg1_error_loop \n"
\r
710 " bne reg1_error_loop \n"
\r
711 " cmp r10, #110 \n"
\r
712 " bne reg1_error_loop \n"
\r
713 " cmp r11, #111 \n"
\r
714 " bne reg1_error_loop \n"
\r
715 " cmp r12, #112 \n"
\r
716 " bne reg1_error_loop \n"
\r
718 " /* Everything passed, increment the loop counter. */ \n"
\r
719 " push { r0-r1 } \n"
\r
720 " ldr r0, =ulRegTest1LoopCounter \n"
\r
722 " adds r1, r1, #1 \n"
\r
724 " pop { r0-r1 } \n"
\r
726 " /* Start again. */ \n"
\r
729 "reg1_error_loop: \n"
\r
730 " /* If this line is hit then there was an error in a core register value.\n"
\r
731 " The loop ensures the loop counter stops incrementing. */\n"
\r
732 " b reg1_error_loop \n"
\r
736 /* Remove compiler warnings about unused parameters. */
\r
737 ( void ) pvParameters;
\r
739 /*-----------------------------------------------------------*/
\r
741 /* This is a naked function. */
\r
742 static void prvRegTest2Task( void *pvParameters )
\r
746 " /* Set all the core registers to known values. */ \n"
\r
761 " /* Set all the VFP to known values. */ \n"
\r
762 " vmov d0, r0, r1 \n"
\r
763 " vmov d1, r2, r3 \n"
\r
764 " vmov d2, r4, r5 \n"
\r
765 " vmov d3, r6, r7 \n"
\r
766 " vmov d4, r8, r9 \n"
\r
767 " vmov d5, r10, r11 \n"
\r
768 " vmov d6, r0, r1 \n"
\r
769 " vmov d7, r2, r3 \n"
\r
770 " vmov d8, r4, r5 \n"
\r
771 " vmov d9, r6, r7 \n"
\r
772 " vmov d10, r8, r9 \n"
\r
773 " vmov d11, r10, r11 \n"
\r
774 " vmov d12, r0, r1 \n"
\r
775 " vmov d13, r2, r3 \n"
\r
776 " vmov d14, r4, r5 \n"
\r
777 " vmov d15, r6, r7 \n"
\r
781 " /* Check all the VFP registers still contain the values set above.\n"
\r
782 " First save registers that are clobbered by the test. */ \n"
\r
783 " push { r0-r1 } \n"
\r
785 " vmov r0, r1, d0 \n"
\r
787 " bne reg2_error_loopf \n"
\r
789 " bne reg2_error_loopf \n"
\r
790 " vmov r0, r1, d1 \n"
\r
792 " bne reg2_error_loopf \n"
\r
794 " bne reg2_error_loopf \n"
\r
795 " vmov r0, r1, d2 \n"
\r
797 " bne reg2_error_loopf \n"
\r
799 " bne reg2_error_loopf \n"
\r
800 " vmov r0, r1, d3 \n"
\r
802 " bne reg2_error_loopf \n"
\r
804 " bne reg2_error_loopf \n"
\r
805 " vmov r0, r1, d4 \n"
\r
807 " bne reg2_error_loopf \n"
\r
809 " bne reg2_error_loopf \n"
\r
810 " vmov r0, r1, d5 \n"
\r
812 " bne reg2_error_loopf \n"
\r
814 " bne reg2_error_loopf \n"
\r
815 " vmov r0, r1, d6 \n"
\r
817 " bne reg2_error_loopf \n"
\r
819 " bne reg2_error_loopf \n"
\r
820 " vmov r0, r1, d7 \n"
\r
822 " bne reg2_error_loopf \n"
\r
824 " bne reg2_error_loopf \n"
\r
825 " vmov r0, r1, d8 \n"
\r
827 " bne reg2_error_loopf \n"
\r
829 " bne reg2_error_loopf \n"
\r
830 " vmov r0, r1, d9 \n"
\r
832 " bne reg2_error_loopf \n"
\r
834 " bne reg2_error_loopf \n"
\r
835 " vmov r0, r1, d10 \n"
\r
837 " bne reg2_error_loopf \n"
\r
839 " bne reg2_error_loopf \n"
\r
840 " vmov r0, r1, d11 \n"
\r
842 " bne reg2_error_loopf \n"
\r
844 " bne reg2_error_loopf \n"
\r
845 " vmov r0, r1, d12 \n"
\r
847 " bne reg2_error_loopf \n"
\r
849 " bne reg2_error_loopf \n"
\r
850 " vmov r0, r1, d13 \n"
\r
852 " bne reg2_error_loopf \n"
\r
854 " bne reg2_error_loopf \n"
\r
855 " vmov r0, r1, d14 \n"
\r
857 " bne reg2_error_loopf \n"
\r
859 " bne reg2_error_loopf \n"
\r
860 " vmov r0, r1, d15 \n"
\r
862 " bne reg2_error_loopf \n"
\r
864 " bne reg2_error_loopf \n"
\r
866 " /* Restore the registers that were clobbered by the test. */\n"
\r
869 " /* VFP register test passed. Jump to the core register test. */\n"
\r
870 " b reg2_loopf_pass \n"
\r
872 "reg2_error_loopf: \n"
\r
873 " /* If this line is hit then a VFP register value was found to be\n"
\r
874 " incorrect. */ \n"
\r
875 " b reg2_error_loopf \n"
\r
877 "reg2_loopf_pass: \n"
\r
880 " bne reg2_error_loop \n"
\r
882 " bne reg2_error_loop \n"
\r
884 " bne reg2_error_loop \n"
\r
886 " bne reg2_error_loop \n"
\r
888 " bne reg2_error_loop \n"
\r
890 " bne reg2_error_loop \n"
\r
892 " bne reg2_error_loop \n"
\r
894 " bne reg2_error_loop \n"
\r
896 " bne reg2_error_loop \n"
\r
898 " bne reg2_error_loop \n"
\r
900 " bne reg2_error_loop \n"
\r
902 " bne reg2_error_loop \n"
\r
904 " bne reg2_error_loop \n"
\r
906 " /* Increment the loop counter to indicate this test is still functioning\n"
\r
907 " correctly. */ \n"
\r
908 " push { r0-r1 } \n"
\r
909 " ldr r0, =ulRegTest2LoopCounter \n"
\r
911 " adds r1, r1, #1 \n"
\r
914 " /* Yield to increase test coverage. */ \n"
\r
915 " movs r0, #0x01 \n"
\r
916 " ldr r1, =0xe000ed04 \n" /* NVIC_INT_CTRL */
\r
917 " lsl r0, #28 \n" /* Shift to PendSV bit */
\r
920 " pop { r0-r1 } \n"
\r
922 " /* Start again. */ \n"
\r
925 "reg2_error_loop: \n"
\r
926 " /* If this line is hit then there was an error in a core register value.\n"
\r
927 " This loop ensures the loop counter variable stops incrementing. */\n"
\r
928 " b reg2_error_loop \n"
\r
932 /* Remove compiler warnings about unused parameters. */
\r
933 ( void ) pvParameters;
\r