From 8835e6a7483537ca055ae14c2a02e5c7e68b1342 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Sun, 17 Nov 2013 14:14:22 +0000 Subject: [PATCH] Add additional comments to SAM4E demo. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2102 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../RTOSDemo.atsuo | Bin 94720 -> 95232 bytes .../src/LCDUtils.c | 8 +- .../src/ParTest.c | 14 +- .../src/RunTimeStatsTimer.c | 2 +- .../src/config/FreeRTOSConfig.h | 16 +- .../src/config/FreeRTOSIPConfig.h | 47 ++++-- .../CORTEX_M4_ATSAM4E_Atmel_Studio/src/main.c | 45 +++--- .../src/main_blinky.c | 47 +++--- .../src/main_full.c | 144 +++++++++++++----- .../src/printf-stdarg.c | 10 +- 10 files changed, 211 insertions(+), 122 deletions(-) diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/RTOSDemo.atsuo b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/RTOSDemo.atsuo index 6280b307596ffaa730c889cc572ae1770f2756c5..b648c532d25fef28eaeeadbbd0c352ab292e3dff 100644 GIT binary patch delta 2917 zcmZ`*2~?EV75?wcKf|yHGvIP$RuR4hGZqo%7AR?|XOd|CYNv z^F5jQTUouURF=+h+-!801`k2Zb^6N?r!8L}Bu}(HOuhu*WXW7TzFc zh{zh&X+&0TLjz8Z8|=RZiC}a{l`0B|a2TW_^fS90mt2vVXt!(&x^eE zGlI!QZ=-M{X2c+E>``x(ys#5CxNYF&i)iBfyV&a)%X<#iF=_r{3o>F&2N}crfrZa)|0NsYZkoq?2;2q!e`#G814~< zMLsj}B0ov!@!2^F8@`D}gC(dTrUg{_3yKc0ZN`-N?-CdM=zsHsed#=I|n78Ubo7^M_< zLam7l=R&w-ZWfm;ge`%gc;RR*cF$AVzns1*PGil*U}5SS9jJD$nvvwP-59Ui@wr>& z;gEP=(c(eVNvT3j`lAQ~wVUMSrf3R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+8}K5Fss!a?!6#|`K#J*l9uLN6iptp;LHy|HMgi@;Mw?N9bU4bxez39w zJgg0qawO3p`SN^D%cWr>{On-%N?-;rsH6^xwdKg+i~@7}x-j^)VD$OcoqZM#jv*yn z1iTm?Z+qko*A;@7)8RZtD!eBINCQ=eYw<6Ke9-W~*S6OmJV0uk|4LPcKDY*Nbp4ze z)zE_O4e3KGzyj=(a_rJ z0x!;_g@bJ}5`txzTN!POHo#$Eb`2!q?&*DKxTj=IS{Pzh4MfU@IF4QW8T4VL+0&cj z)=6DLL*g-vX`!#JJrd)i{l&bYdjP$dlvBs@av)Tdx;wR0G{p{&*LkZ<|K7ApMa94j zk&plr41D1aX|K>jQqJw>lDXef-<5K^I5W40+eV44BJ}@DV`-1q=Rfpy#lCuWPuIr5y z2I+ZwUZu>D24gH`GsH1RIv5t8q0P>6^JZvf=@}HH9k&dqzv6+f9tyAxZ-F|%z>cGs zK4DtAPGlvf3Ra+i<2DLrx(B3)Bl97^GIqcawv3nI{Xd4Y!zPHs@u$O5yrWr2dDM64cmdL&DjxFv<<2k-Shx_*qMXMP7PC(fEG24{nB;I zI!hoQ&BuN}! diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/LCDUtils.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/LCDUtils.c index 27abd4845..3e11a5820 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/LCDUtils.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/LCDUtils.c @@ -103,7 +103,7 @@ struct ili93xx_opt_t g_ili93xx_display_opt; smc_set_pulse_timing( SMC, ILI93XX_LCD_CS, SMC_PULSE_NWE_PULSE( 4 ) | SMC_PULSE_NCS_WR_PULSE( 4 ) | SMC_PULSE_NRD_PULSE( 10 )| SMC_PULSE_NCS_RD_PULSE( 10 ) ); smc_set_cycle_timing( SMC, ILI93XX_LCD_CS, SMC_CYCLE_NWE_CYCLE( 10 )| SMC_CYCLE_NRD_CYCLE( 22 ) ); smc_set_mode( SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE | SMC_MODE_WRITE_MODE ); - + /* Initialise the LCD. */ g_ili93xx_display_opt.ul_width = ILI93XX_LCD_WIDTH; g_ili93xx_display_opt.ul_height = ILI93XX_LCD_HEIGHT; @@ -116,15 +116,15 @@ struct ili93xx_opt_t g_ili93xx_display_opt; /* Turn on LCD */ ili93xx_display_on(); - + /* Clear. */ ili93xx_set_foreground_color( COLOR_WHITE ); ili93xx_draw_filled_rectangle( 0, 0, ILI93XX_LCD_WIDTH, ILI93XX_LCD_HEIGHT ); - + /* Draw logos. */ ili93xx_set_cursor_position( 0,0 ); gfx_draw_bmpfile( logo_atmel_bmp ); - + /* Set foreground colour ready to write text. */ ili93xx_set_foreground_color( COLOR_BLACK ); } diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/ParTest.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/ParTest.c index 7f379f6e6..4cdb7f95a 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/ParTest.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/ParTest.c @@ -1,5 +1,5 @@ /* - FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. + FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. @@ -78,7 +78,7 @@ #define partestNUM_LEDS ( 3UL ) /* The index of the pins to which the LEDs are connected. The ordering of the -LEDs in this array is intentional and matches the order they appear on the +LEDs in this array is intentional and matches the order they appear on the hardware. */ static const uint32_t ulLED[] = { LED0_GPIO, LED1_GPIO, LED2_GPIO }; @@ -86,13 +86,13 @@ static const uint32_t ulLED[] = { LED0_GPIO, LED1_GPIO, LED2_GPIO }; void vParTestInitialise( void ) { - /* LEDs are initialised in the Atmel provided board initialisation + /* LEDs are initialised in the Atmel provided board initialisation function. */ } /*-----------------------------------------------------------*/ void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue ) -{ +{ if( uxLED < partestNUM_LEDS ) { /* Turn the LED off. */ @@ -110,12 +110,12 @@ void vParTestToggleLED( unsigned portBASE_TYPE uxLED ) if( uxLED < partestNUM_LEDS ) { taskENTER_CRITICAL(); - { + { ioport_toggle_pin_level( ulLED[ uxLED ] ); } - taskEXIT_CRITICAL(); + taskEXIT_CRITICAL(); } } - + diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/RunTimeStatsTimer.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/RunTimeStatsTimer.c index 635a1e527..7c94fff71 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/RunTimeStatsTimer.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/RunTimeStatsTimer.c @@ -1,5 +1,5 @@ /* - FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. + FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/config/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/config/FreeRTOSConfig.h index 2c5311b56..d7696232e 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/config/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/config/FreeRTOSConfig.h @@ -1,5 +1,5 @@ /* - FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. + FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. @@ -185,16 +185,16 @@ each node on the network has a unique MAC address. */ /* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */ -#define configIP_ADDR0 172 -#define configIP_ADDR1 25 -#define configIP_ADDR2 218 +#define configIP_ADDR0 192 +#define configIP_ADDR1 168 +#define configIP_ADDR2 0 #define configIP_ADDR3 200 /* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */ -#define configGATEWAY_ADDR0 172 -#define configGATEWAY_ADDR1 25 -#define configGATEWAY_ADDR2 218 +#define configGATEWAY_ADDR0 192 +#define configGATEWAY_ADDR1 168 +#define configGATEWAY_ADDR2 0 #define configGATEWAY_ADDR3 1 /* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and @@ -213,7 +213,7 @@ ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */ #define configNET_MASK3 0 /* The address of the echo server. Used when the demo is build to include the -UDP echo tasks (when mainINCLUDE_ECHO_CLIENT_TASKS is set to 1 in +UDP echo tasks (when mainINCLUDE_ECHO_CLIENT_TASKS is set to 1 in FreeRTOSConfig.h. http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/Embedded_Ethernet_Examples/Common_Echo_Clients.shtml */ #define configECHO_SERVER_ADDR0 192 diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/config/FreeRTOSIPConfig.h b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/config/FreeRTOSIPConfig.h index 05ef01180..34084d453 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/config/FreeRTOSIPConfig.h +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/config/FreeRTOSIPConfig.h @@ -5,11 +5,11 @@ * This file is part of the FreeRTOS+UDP distribution. The FreeRTOS+UDP license * terms are different to the FreeRTOS license terms. * - * FreeRTOS+UDP uses a dual license model that allows the software to be used - * under a standard GPL open source license, or a commercial license. The - * standard GPL license (unlike the modified GPL license under which FreeRTOS - * itself is distributed) requires that all software statically linked with - * FreeRTOS+UDP is also distributed under the same GPL V2 license terms. + * FreeRTOS+UDP uses a dual license model that allows the software to be used + * under a standard GPL open source license, or a commercial license. The + * standard GPL license (unlike the modified GPL license under which FreeRTOS + * itself is distributed) requires that all software statically linked with + * FreeRTOS+UDP is also distributed under the same GPL V2 license terms. * Details of both license options follow: * * - Open source licensing - @@ -58,7 +58,7 @@ priority) to (configMAX_PRIORITIES - 1) (the highest priority). configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to the priority assigned to the task executing the IP stack relative to the -priority assigned to tasks that use the IP stack. +priority assigned to tasks that use the IP stack. Note: If the application is started without the network cable plugged in then this should be set to the lowest priority - otherwise the Atmel ASF GMAC driver @@ -120,13 +120,7 @@ ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the static IP address passed as a parameter to FreeRTOS_IPInit() if the re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without a DHCP reply being received. */ -#ifdef _WINDOWS_ - /* The windows simulated time is not real time so the max delay is much - shorter. */ - #define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 999 / portTICK_RATE_MS ) -#else - #define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_RATE_MS ) -#endif /* _WINDOWS_ */ +#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 999 / portTICK_RATE_MS ) /* The ARP cache is a table that maps IP addresses to MAC addresses. The IP stack can only send a UDP message to a remove IP address if it knowns the MAC @@ -166,7 +160,8 @@ not set to 1 then only FreeRTOS_indet_addr_quick() is available. */ /* ipconfigNUM_NETWORK_BUFFERS defines the total number of network buffer that are available to the IP stack. The total number of network buffers is limited to ensure the total amount of RAM that can be consumed by the IP stack is capped -to a pre-determinable value. */ +to a pre-determinable value. NOTE: This constant is not used when all buffers +are dynamically allocated and freed. */ #define ipconfigNUM_NETWORK_BUFFERS 10 /* A FreeRTOS queue is used to send events from application tasks to the IP @@ -242,17 +237,37 @@ Ethernet driver does all the necessary filtering in hardware then software filtering can be removed by using a value other than 1 or 0. */ #define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 0 +/* If ipconfigETHERNET_DRIVER_ADDS_UDP_CHECKSUM is set to 1 then a UDP checksum +will not be calculated and added to a packet before the packet is sent to the +hardware for transmission. */ +#define ipconfigETHERNET_DRIVER_ADDS_UDP_CHECKSUM 0 + +/* If ipconfigETHERNET_DRIVER_ADDS_IP_CHECKSUM is set to 1 then an IP checksum +will not be calculated and added to a packet before the packet is sent to the +hardware for transmission. */ +#define ipconfigETHERNET_DRIVER_ADDS_IP_CHECKSUM 0 + +/* If ipconfigETHERNET_DRIVER_CHECKS_IP_CHECKSUM is set to 1 then the IP +checksum will be ignored on incoming packets on the assumption IP packets with +an invalid checksum are not passed to the stack. */ +#define ipconfigETHERNET_DRIVER_CHECKS_IP_CHECKSUM 0 + +/* If ipconfigETHERNET_DRIVER_CHECKS_UDP_CHECKSUM is set to 1 then the UDP +checksum will be ignored on incoming packets on the assumption the UDP packets +with an invalid checksum are not passed to the stack. */ +#define ipconfigETHERNET_DRIVER_CHECKS_UDP_CHECKSUM 0 + /* Set ipconfigFREERTOS_PLUS_NABTO to 1 to support the Nabto protocol, or 0 to exclude support for the Nabto protocol. If ipconfigFREERTOS_PLUS_NABTO is set to one then the project must build the Nabto source code (or reference a pre-build Nabto library. */ -#define ipconfigFREERTOS_PLUS_NABTO 0 +#define ipconfigFREERTOS_PLUS_NABTO 0 /* Sets the size of the stack used by the Nabto service task. The Nabto event handler executes in the context of the Nabto service task. If the event handler uses a lot of stack then it is possible the value set here will need to be increased. It is recommended to have FreeRTOS stack overflow checking turned -on during development (see the configCHECK_FOR_STACK_OVERFLOW in +on during development (see the configCHECK_FOR_STACK_OVERFLOW in FreeRTOSConfig.h and in the documentation. */ #define ipconfigNABTO_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 ) diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main.c index 66b806014..e7df6cbdf 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main.c @@ -1,5 +1,5 @@ /* - FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. + FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. @@ -65,11 +65,13 @@ /****************************************************************************** * This project provides two demo applications. A simple blinky style project, - * and a more comprehensive application that makes use of FreeRTOS+ add-on - * components. The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this - * file) is used to select between the two. The simply blinky demo is - * implemented and described in main_blinky.c. The more comprehensive demo - * application is implemented and described in main_full.c. + * and a more comprehensive application that includes FreeRTOS+CLI, FreeRTOS+UDP + * and FreeRTOS+FAT SL. The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined + * in this file) is used to select between the two. The simply blinky demo is + * implemented and described in main_blinky.c. The more comprehensive demo + * application is implemented and described in main_full.c and full user + * instructions are provided on the following URL: + * http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html * * This file implements the code that is not demo specific, including the * hardware setup and FreeRTOS hook functions. @@ -84,7 +86,7 @@ #include "partest.h" /* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo, -or 0 to run the more comprehensive demo application that includes add-on +or 0 to run the more comprehensive demo application that includes add-on components. */ #define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0 @@ -111,15 +113,17 @@ int main( void ) /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top of this file. */ - #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 + #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 ) { main_blinky(); } #else { + /* Full user instructions are provided on the following URL: + http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html */ main_full(); } - #endif + #endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */ return 0; } @@ -132,7 +136,6 @@ static void prvSetupHardware( void ) sysclk_init(); pmc_enable_periph_clk( ID_GMAC ); pmc_enable_periph_clk( ID_SMC ); - vParTestInitialise(); } /*-----------------------------------------------------------*/ @@ -163,12 +166,13 @@ void vApplicationIdleHook( void ) important that vApplicationIdleHook() is permitted to return to its calling function, because it is the responsibility of the idle task to clean up memory allocated by the kernel to any task that has since been deleted. */ - + /* The simple blinky demo does not use the idle hook - the full demo does. */ #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 ) { extern void vFullDemoIdleHook( void ); - + + /* Implemented in main_full.c. */ vFullDemoIdleHook(); } #endif @@ -181,8 +185,8 @@ void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName ( void ) pxTask; /* Run time stack overflow checking is performed if - configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook - function is called if a stack overflow is detected. */ + configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is + called if a stack overflow is detected. */ vAssertCalled( __LINE__, __FILE__ ); } /*-----------------------------------------------------------*/ @@ -194,12 +198,13 @@ void vApplicationTickHook( void ) added here, but the tick hook is called from an interrupt context, so code must not attempt to block, and only the interrupt safe FreeRTOS API functions can be used (those that end in FromISR()). */ - + /* The simple blinky demo does not use the tick hook - the full demo does. */ #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 ) { extern void vFullDemoTickHook( void ); - + + /* Implemented in main_full.c. */ vFullDemoTickHook(); } #endif @@ -210,18 +215,18 @@ void vAssertCalled( uint32_t ulLine, const char *pcFile ) { /* The following two variables are just to ensure the parameters are not optimised away and therefore unavailable when viewed in the debugger. */ -volatile uint32_t ulLineNumber = ulLine, ulSetNoneZeroInDebuggerToReturn = 0; +volatile uint32_t ulLineNumber = ulLine, ulSetNonZeroInDebuggerToReturn = 0; volatile const char * const pcFileName = pcFile; taskENTER_CRITICAL(); - while( ulSetNoneZeroInDebuggerToReturn == 0 ) + while( ulSetNonZeroInDebuggerToReturn == 0 ) { /* If you want to set out of this function in the debugger to see the - assert() location then set ulSetNoneZeroInDebuggerToReturn to a non-zero + assert() location then set ulSetNonZeroInDebuggerToReturn to a non-zero value. */ } taskEXIT_CRITICAL(); - + ( void ) pcFileName; ( void ) ulLineNumber; } diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_blinky.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_blinky.c index 1e52ba68a..c49f9a9e1 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_blinky.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_blinky.c @@ -1,5 +1,5 @@ /* - FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. + FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. @@ -65,19 +65,19 @@ /****************************************************************************** * NOTE 1: This project provides two demo applications. A simple blinky style - * project, and a more comprehensive demo application that makes use of some - * add-on components. The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c - * is used to select between the two. See the notes on using - * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY in main.c. This file implements the - * simply blinky style version. + * project, and a more comprehensive demo application that makes use of + * FreeRTOS_CLI, FreeRTOS+UDP and FreeRTOS+FAT SL. The + * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select + * between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY + * in main.c. This file implements the simply blinky style version. * * NOTE 2: This file only contains the source code that is specific to the * basic demo. Generic functions, such FreeRTOS hook functions, and functions * required to configure the hardware, are defined in main.c. ****************************************************************************** * - * main_blinky() creates one queue, and two tasks and one software timer. It - * then starts the scheduler. + * main_blinky() creates one queue, two tasks and one software timer. It then + * starts the scheduler. * * The Queue Send Task: * The queue send task is implemented by the prvQueueSendTask() function in @@ -116,11 +116,6 @@ will remove items as they are added, meaning the send task should always find the queue empty. */ #define mainQUEUE_LENGTH ( 1 ) -/* Values passed to the two tasks just to check the task parameter -functionality. */ -#define mainQUEUE_SEND_PARAMETER ( 0x1111UL ) -#define mainQUEUE_RECEIVE_PARAMETER ( 0x22UL ) - /* The period of the blinky software timer. The period is specified in ms and converted to ticks using the portTICK_RATE_MS constant. */ #define mainBLINKY_TIMER_PERIOD ( 50 / portTICK_RATE_MS ) @@ -128,7 +123,7 @@ converted to ticks using the portTICK_RATE_MS constant. */ /* A block time of zero simply means "don't block". */ #define mainDONT_BLOCK ( 0 ) -/* The LEDs toggled by the timer and queue receive task respectively. */ +/* The LEDs toggled by the timer callback and queue receive task respectively. */ #define mainTIMER_LED 0 #define mainTASK_LED 1 @@ -154,14 +149,10 @@ void main_blinky( void ); /*-----------------------------------------------------------*/ -/* The queue used by both tasks. */ -static xQueueHandle xQueue = NULL; - -/*-----------------------------------------------------------*/ - void main_blinky( void ) { xTimerHandle xTimer; +xQueueHandle xQueue; /* Create the queue. */ xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) ); @@ -173,13 +164,13 @@ xTimerHandle xTimer; xTaskCreate( prvQueueReceiveTask, /* The function that implements the task. */ ( signed char * ) "Rx", /* The text name assigned to the task - for debug only as it is not used by the kernel. */ configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the task. */ - ( void * ) mainQUEUE_RECEIVE_PARAMETER, /* The parameter passed to the task - just to check the functionality. */ + ( void * ) xQueue, /* Pass the queue into the task using the task parameter. */ mainQUEUE_RECEIVE_TASK_PRIORITY, /* The priority assigned to the task. */ NULL ); /* The task handle is not required, so NULL is passed. */ - xTaskCreate( prvQueueSendTask, ( signed char * ) "TX", configMINIMAL_STACK_SIZE, ( void * ) mainQUEUE_SEND_PARAMETER, mainQUEUE_SEND_TASK_PRIORITY, NULL ); + xTaskCreate( prvQueueSendTask, ( signed char * ) "TX", configMINIMAL_STACK_SIZE, ( void * ) xQueue, mainQUEUE_SEND_TASK_PRIORITY, NULL ); - /* Create the blinky software timer as described at the top of this + /* Create the blinky software timer as described at the top of this file. */ xTimer = xTimerCreate( ( const signed char * ) "Blinky",/* A text name, purely to help debugging. */ ( mainBLINKY_TIMER_PERIOD ), /* The timer period. */ @@ -211,9 +202,10 @@ static void prvQueueSendTask( void *pvParameters ) { portTickType xNextWakeTime; const unsigned long ulValueToSend = 100UL; +xQueueHandle xQueue; - /* Check the task parameter is as expected. */ - configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_SEND_PARAMETER ); + /* The handle of the queue is passed in using the task's parameter. */ + xQueue = ( xQueueHandle ) pvParameters; /* Initialise xNextWakeTime - this only needs to be done once. */ xNextWakeTime = xTaskGetTickCount(); @@ -230,7 +222,7 @@ const unsigned long ulValueToSend = 100UL; toggle the LED. 0 is used as the block time so the sending operation will not block - it shouldn't need to block as the queue should always be empty at this point in the code. */ - xQueueSend( xQueue, &ulValueToSend, 0U ); + xQueueSend( xQueue, &ulValueToSend, mainDONT_BLOCK ); } } /*-----------------------------------------------------------*/ @@ -238,9 +230,10 @@ const unsigned long ulValueToSend = 100UL; static void prvQueueReceiveTask( void *pvParameters ) { unsigned long ulReceivedValue; +xQueueHandle xQueue; - /* Check the task parameter is as expected. */ - configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_RECEIVE_PARAMETER ); + /* The queue is passed in as the task's parameter. */ + xQueue = ( xQueueHandle ) pvParameters; for( ;; ) { diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_full.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_full.c index e6a5ff01b..7d9269e32 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_full.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_full.c @@ -1,5 +1,5 @@ /* - FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. + FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. @@ -63,6 +63,52 @@ 1 tab == 4 spaces! */ +/****************************************************************************** + * NOTE 1: This project provides two demo applications. A simple blinky style + * project, and a more comprehensive test and demo application that makes use of + * the FreeRTOS+CLI, FreeRTOS+UDP and FreeRTOS+FAT SL components. The + * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select + * between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY + * in main.c. This file implements the comprehensive test and demo version, + * which is fully documented on the following URL: + * http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html + * + * NOTE 2: This file only contains the source code that is specific to the + * full demo. Generic functions, such FreeRTOS hook functions, and functions + * required to configure the hardware, are defined in main.c. + ****************************************************************************** + * + * Full user instructions are provided on the following URL: + * http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html + * + * main_full(): + * + Uses FreeRTOS+FAT SL to create a set of example files on a RAM disk. + * + Displays some bitmaps on the LCD. + * + Registers sample generic, file system related and UDP related commands + * with FreeRTOS+CLI. + * + Creates all the standard demo application tasks and software timers. + * + Starts the scheduler. + * + * A UDP command server and optionally two UDP echo client tasks are created + * from the network event hook after an IP address has been obtained. The IP + * address is displayed on the LCD. + * + * A "check software timer" is created to provide visual feedback of the system + * status. The timer's period is initially set to three seconds. The callback + * function associated with the timer checks all the standard demo tasks are not + * only still executed, but are executing without reporting any errors. If the + * timer discovers a task has either stalled, or reported an error, then it + * changes its own period from the initial three seconds, to just 200ms. The + * check software timer also toggles the LED marked D4 - so if the LED toggles + * every three seconds then no potential errors have been found, and if the LED + * toggles every 200ms then a potential error has been found in at least one + * task. + * + * Information on accessing the CLI and file system, and using the UDP echo + * tasks is provided on http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html + * + */ + /* FreeRTOS includes. */ #include "FreeRTOS.h" #include "task.h" @@ -120,14 +166,15 @@ ISR triggered task. */ /* Misc. */ #define mainDONT_BLOCK ( 0 ) -/* Note: If the application is started without the network cable plugged in +/* Note: If the application is started without the network cable plugged in then ipconfigUDP_TASK_PRIORITY should be set to 0 in FreeRTOSIPConfig.h to -ensure the IP task is created at the idle priority. This is because the Atmel -ASF GMAC driver polls the GMAC looking for a connection, and doing so will -prevent any lower priority tasks from executing. In this demo the IP task is -started at the idle priority, then set to configMAX_PRIORITIES - 2 in the +ensure the IP task is created at the idle priority. This is because the Atmel +ASF GMAC driver polls the GMAC looking for a connection, and doing so will +prevent any lower priority tasks from executing. In this demo the IP task is +started at the idle priority, then set to configMAX_PRIORITIES - 2 in the network event hook only after a connection has been established (when the event -passed into the network event hook is eNetworkUp). */ +passed into the network event hook is eNetworkUp). +http://www.FreeRTOS.org/udp */ #define mainCONNECTED_IP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 ) #define mainDISCONNECTED_IP_TASK_PRIORITY ( tskIDLE_PRIORITY ) @@ -136,7 +183,10 @@ passed into the network event hook is eNetworkUp). */ #define mainUDP_CLI_PORT_NUMBER ( 5001UL ) #define mainUDP_CLI_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2U ) -/* Set to 1 to include the UDP echo client tasks. */ +/* Set to 1 to include the UDP echo client tasks in the build. The echo clients +require the IP address of the echo server to be defined using the +configECHO_SERVER_ADDR0 to configECHO_SERVER_ADDR3 constants in +FreeRTOSConfig.h. */ #define mainINCLUDE_ECHO_CLIENT_TASKS 1 /*-----------------------------------------------------------*/ @@ -146,23 +196,25 @@ passed into the network event hook is eNetworkUp). */ */ static void prvCheckTimerCallback( xTimerHandle xTimer ); -/* - * Creates a set of sample files on a RAM disk. +/* + * Creates a set of sample files on a RAM disk. http://www.FreeRTOS.org/fat_sl */ extern void vCreateAndVerifySampleFiles( void ); /* - * Register the generic commands that can be used with FreeRTOS+CLI. + * Register sample generic commands that can be used with FreeRTOS+CLI. Type + * 'help' in the command line to see a list of registered commands. + * http://www.FreeRTOS.org/cli */ extern void vRegisterSampleCLICommands( void ); /* - * Register the file system commands that can be used with FreeRTOS+CLI. + * Register sample file system commands that can be used with FreeRTOS+CLI. */ extern void vRegisterFileSystemCLICommands( void ); /* - * Register the UDP related commands that can be used with FreeRTOS+CLI. + * Register sample UDP related commands that can be used with FreeRTOS+CLI. */ extern void vRegisterUDPCLICommands( void ); @@ -188,11 +240,13 @@ Note each node on a network must have a unique MAC address. */ const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 }; /*-----------------------------------------------------------*/ + int main_full( void ) { xTimerHandle xTimer = NULL; - /* Initialise the LCD and output the bitmap. */ + /* Initialise the LCD and output a bitmap. The IP address will also be + displayed on the LCD when it has been obtained. */ vInitialiseLCD(); /* If the file system is only going to be accessed from one task then @@ -200,19 +254,20 @@ xTimerHandle xTimer = NULL; before the RTOS scheduler is started. If the file system is going to be access from more than one task then F_FS_THREAD_AWARE must be set to 1 and the set of sample files are created from the idle task hook function - vApplicationIdleHook() - which is defined in this file. */ + vApplicationIdleHook(). */ #if( F_FS_THREAD_AWARE == 0 ) { /* Initialise the drive and file system, then create a few example - files. The output from this function just goes to the stdout window, - allowing the output to be viewed when the UDP command console is not - connected. */ + files. The files can be viewed and accessed via the CLI. View the + documentation page for this demo (link at the top of this file) for more + information. */ vCreateAndVerifySampleFiles(); } #endif - /* Register example generic, file system related and UDP related CLI - commands respectively. */ + /* Register example generic, file system related and UDP related CLI + commands respectively. Type 'help' into the command console to view a list + of registered commands. */ vRegisterSampleCLICommands(); vRegisterFileSystemCLICommands(); vRegisterUDPCLICommands(); @@ -221,8 +276,8 @@ xTimerHandle xTimer = NULL; created in the network event hook when the network is connected and ready for use. The address values passed in here are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1 but a DHCP server cannot be - contacted. The Nabto service task is created automatically if - ipconfigFREERTOS_PLUS_NABTO is set to 1 in FreeRTOSIPConfig.h. */ + contacted. The IP address actually used is displayed on the LCD (after DHCP + has completed if DHCP is used). */ FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress ); /* Create all the other standard demo tasks. */ @@ -326,6 +381,9 @@ unsigned long ulErrorOccurred = pdFALSE; } } + /* Toggle the LED to give visual feedback of the system status. The rate at + which the LED toggles will increase to mainERROR_CHECK_TIMER_PERIOD_MS if a + suspected error has been found in any of the standard demo tasks. */ vParTestToggleLED( mainCHECK_LED ); } /*-----------------------------------------------------------*/ @@ -348,38 +406,55 @@ char cIPAddress[ 20 ]; passed into the network event hook is eNetworkUp). */ if( eNetworkEvent == eNetworkUp ) { + /* Ensure tasks are only created once. */ if( lTasksAlreadyCreated == pdFALSE ) - { - /* Create the task that handles the CLI on a UDP port. The port number - is set using the configUDP_CLI_PORT_NUMBER setting in FreeRTOSConfig.h. */ + { + /* Create the task that handles the CLI on a UDP port. The port + number is set using the configUDP_CLI_PORT_NUMBER setting in + FreeRTOSConfig.h. */ vStartUDPCommandInterpreterTask( mainUDP_CLI_TASK_STACK_SIZE, mainUDP_CLI_PORT_NUMBER, mainUDP_CLI_TASK_PRIORITY ); - + #if( mainINCLUDE_ECHO_CLIENT_TASKS == 1 ) { + /* Create the UDP echo tasks. The UDP echo tasks require the IP + address of the echo server to be defined using the + configECHO_SERVER_ADDR0 to configECHO_SERVER_ADDR3 constants in + FreeRTOSConfig.h. */ vStartEchoClientTasks( configMINIMAL_STACK_SIZE, tskIDLE_PRIORITY ); } #endif } - - /* Obtain the IP address, convert it to a string, then display. */ + + /* Obtain the IP address, convert it to a string, then display it on the + LCD. */ FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL ); FreeRTOS_inet_ntoa( ulIPAddress, cIPAddress ); ili93xx_draw_string( ulXCoord, ulYCoord, ( uint8_t * ) "IP: " ); ili93xx_draw_string( ulXCoord + ulIPAddressOffset, ulYCoord, ( uint8_t * ) cIPAddress ); - - /* Set the IP task up to the desired priority now it has connected. */ + + /* Set the priority of the IP task up to the desired priority now it has + connected. */ vTaskPrioritySet( NULL, mainCONNECTED_IP_TASK_PRIORITY ); } + /* NOTE: At the time of writing the Ethernet driver does not report the + cable being unplugged - so the following if() condition will never be met. + It is included for possible future updates to the driver. */ if( eNetworkEvent == eNetworkDown ) { + /* Ensure the Atmel GMAC drivers don't hog all the CPU time as they look + for a new connection by lowering the priority of the IP task to that of + the Idle task. */ vTaskPrioritySet( NULL, tskIDLE_PRIORITY ); + + /* Disconnected - so no IP address. */ + ili93xx_draw_string( ulXCoord, ulYCoord, ( uint8_t * ) "IP: " ); } } /*-----------------------------------------------------------*/ void vFullDemoIdleHook( void ) -{ +{ /* If the file system is only going to be accessed from one task then F_FS_THREAD_AWARE can be set to 0 and the set of example files is created before the RTOS scheduler is started. If the file system is going to be @@ -405,10 +480,10 @@ void vFullDemoIdleHook( void ) void vFullDemoTickHook( void ) { - /* Call the periodic queue overwrite from ISR demo. */ + /* Call the periodic queue overwrite from ISR test function. */ vQueueOverwritePeriodicISRDemo(); - /* Call the queue set ISR test function. */ + /* Call the periodic queue set ISR test function. */ vQueueSetAccessQueueSetFromISR(); } /*-----------------------------------------------------------*/ @@ -416,7 +491,8 @@ void vFullDemoTickHook( void ) /* Called automatically when a reply to an outgoing ping is received. */ void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifier ) { - /* This demo has nowhere to output any information so does nothing. */ + /* This demo has nowhere to output any information so does nothing, but the + IP address resolved for the pined URL is displayed in the CLI. */ ( void ) usIdentifier; ( void ) eStatus; } diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/printf-stdarg.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/printf-stdarg.c index 45a824384..7062a04e4 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/printf-stdarg.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/printf-stdarg.c @@ -31,7 +31,7 @@ static void printchar(char **str, int c) { extern int putchar(int c); - + if (str) { **str = c; ++(*str); @@ -185,7 +185,7 @@ static int print( char **out, const char *format, va_list args ) int printf(const char *format, ...) { va_list args; - + va_start( args, format ); return print( 0, format, args ); } @@ -193,7 +193,7 @@ int printf(const char *format, ...) int sprintf(char *out, const char *format, ...) { va_list args; - + va_start( args, format ); return print( &out, format, args ); } @@ -202,9 +202,9 @@ int sprintf(char *out, const char *format, ...) int snprintf( char *buf, unsigned int count, const char *format, ... ) { va_list args; - + ( void ) count; - + va_start( args, format ); return print( &buf, format, args ); } -- 2.39.5