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 ) );\r
smc_set_cycle_timing( SMC, ILI93XX_LCD_CS, SMC_CYCLE_NWE_CYCLE( 10 )| SMC_CYCLE_NRD_CYCLE( 22 ) );\r
smc_set_mode( SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE | SMC_MODE_WRITE_MODE );\r
- \r
+\r
/* Initialise the LCD. */\r
g_ili93xx_display_opt.ul_width = ILI93XX_LCD_WIDTH;\r
g_ili93xx_display_opt.ul_height = ILI93XX_LCD_HEIGHT;\r
\r
/* Turn on LCD */\r
ili93xx_display_on();\r
- \r
+\r
/* Clear. */\r
ili93xx_set_foreground_color( COLOR_WHITE );\r
ili93xx_draw_filled_rectangle( 0, 0, ILI93XX_LCD_WIDTH, ILI93XX_LCD_HEIGHT );\r
- \r
+\r
/* Draw logos. */\r
ili93xx_set_cursor_position( 0,0 );\r
gfx_draw_bmpfile( logo_atmel_bmp );\r
- \r
+\r
/* Set foreground colour ready to write text. */\r
ili93xx_set_foreground_color( COLOR_BLACK );\r
}\r
/*\r
- FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. \r
+ FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.\r
All rights reserved\r
\r
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
#define partestNUM_LEDS ( 3UL )\r
\r
/* The index of the pins to which the LEDs are connected. The ordering of the\r
-LEDs in this array is intentional and matches the order they appear on the \r
+LEDs in this array is intentional and matches the order they appear on the\r
hardware. */\r
static const uint32_t ulLED[] = { LED0_GPIO, LED1_GPIO, LED2_GPIO };\r
\r
\r
void vParTestInitialise( void )\r
{\r
- /* LEDs are initialised in the Atmel provided board initialisation \r
+ /* LEDs are initialised in the Atmel provided board initialisation\r
function. */\r
}\r
/*-----------------------------------------------------------*/\r
\r
void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )\r
-{ \r
+{\r
if( uxLED < partestNUM_LEDS )\r
{\r
/* Turn the LED off. */\r
if( uxLED < partestNUM_LEDS )\r
{\r
taskENTER_CRITICAL();\r
- { \r
+ {\r
ioport_toggle_pin_level( ulLED[ uxLED ] );\r
}\r
- taskEXIT_CRITICAL(); \r
+ taskEXIT_CRITICAL();\r
}\r
}\r
- \r
+\r
\r
\r
/*\r
- FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. \r
+ FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.\r
All rights reserved\r
\r
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
/*\r
- FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. \r
+ FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd.\r
All rights reserved\r
\r
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
\r
/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or\r
ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */\r
-#define configIP_ADDR0 172\r
-#define configIP_ADDR1 25\r
-#define configIP_ADDR2 218\r
+#define configIP_ADDR0 192\r
+#define configIP_ADDR1 168\r
+#define configIP_ADDR2 0\r
#define configIP_ADDR3 200\r
\r
/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to\r
0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */\r
-#define configGATEWAY_ADDR0 172\r
-#define configGATEWAY_ADDR1 25\r
-#define configGATEWAY_ADDR2 218\r
+#define configGATEWAY_ADDR0 192\r
+#define configGATEWAY_ADDR1 168\r
+#define configGATEWAY_ADDR2 0\r
#define configGATEWAY_ADDR3 1\r
\r
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and\r
#define configNET_MASK3 0\r
\r
/* The address of the echo server. Used when the demo is build to include the\r
-UDP echo tasks (when mainINCLUDE_ECHO_CLIENT_TASKS is set to 1 in \r
+UDP echo tasks (when mainINCLUDE_ECHO_CLIENT_TASKS is set to 1 in\r
FreeRTOSConfig.h.\r
http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/Embedded_Ethernet_Examples/Common_Echo_Clients.shtml */\r
#define configECHO_SERVER_ADDR0 192\r
* This file is part of the FreeRTOS+UDP distribution. The FreeRTOS+UDP license\r
* terms are different to the FreeRTOS license terms.\r
*\r
- * FreeRTOS+UDP uses a dual license model that allows the software to be used \r
- * under a standard GPL open source license, or a commercial license. The \r
- * standard GPL license (unlike the modified GPL license under which FreeRTOS \r
- * itself is distributed) requires that all software statically linked with \r
- * FreeRTOS+UDP is also distributed under the same GPL V2 license terms. \r
+ * FreeRTOS+UDP uses a dual license model that allows the software to be used\r
+ * under a standard GPL open source license, or a commercial license. The\r
+ * standard GPL license (unlike the modified GPL license under which FreeRTOS\r
+ * itself is distributed) requires that all software statically linked with\r
+ * FreeRTOS+UDP is also distributed under the same GPL V2 license terms.\r
* Details of both license options follow:\r
*\r
* - Open source licensing -\r
configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in\r
FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to\r
the priority assigned to the task executing the IP stack relative to the\r
-priority assigned to tasks that use the IP stack. \r
+priority assigned to tasks that use the IP stack.\r
\r
Note: If the application is started without the network cable plugged in then\r
this should be set to the lowest priority - otherwise the Atmel ASF GMAC driver\r
static IP address passed as a parameter to FreeRTOS_IPInit() if the\r
re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without\r
a DHCP reply being received. */\r
-#ifdef _WINDOWS_\r
- /* The windows simulated time is not real time so the max delay is much\r
- shorter. */\r
- #define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 999 / portTICK_RATE_MS )\r
-#else\r
- #define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_RATE_MS )\r
-#endif /* _WINDOWS_ */\r
+#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 999 / portTICK_RATE_MS )\r
\r
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP\r
stack can only send a UDP message to a remove IP address if it knowns the MAC\r
/* ipconfigNUM_NETWORK_BUFFERS defines the total number of network buffer that\r
are available to the IP stack. The total number of network buffers is limited\r
to ensure the total amount of RAM that can be consumed by the IP stack is capped\r
-to a pre-determinable value. */\r
+to a pre-determinable value. NOTE: This constant is not used when all buffers\r
+are dynamically allocated and freed. */\r
#define ipconfigNUM_NETWORK_BUFFERS 10\r
\r
/* A FreeRTOS queue is used to send events from application tasks to the IP\r
filtering can be removed by using a value other than 1 or 0. */\r
#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 0\r
\r
+/* If ipconfigETHERNET_DRIVER_ADDS_UDP_CHECKSUM is set to 1 then a UDP checksum\r
+will not be calculated and added to a packet before the packet is sent to the\r
+hardware for transmission. */\r
+#define ipconfigETHERNET_DRIVER_ADDS_UDP_CHECKSUM 0\r
+\r
+/* If ipconfigETHERNET_DRIVER_ADDS_IP_CHECKSUM is set to 1 then an IP checksum\r
+will not be calculated and added to a packet before the packet is sent to the\r
+hardware for transmission. */\r
+#define ipconfigETHERNET_DRIVER_ADDS_IP_CHECKSUM 0\r
+\r
+/* If ipconfigETHERNET_DRIVER_CHECKS_IP_CHECKSUM is set to 1 then the IP \r
+checksum will be ignored on incoming packets on the assumption IP packets with \r
+an invalid checksum are not passed to the stack. */\r
+#define ipconfigETHERNET_DRIVER_CHECKS_IP_CHECKSUM 0\r
+\r
+/* If ipconfigETHERNET_DRIVER_CHECKS_UDP_CHECKSUM is set to 1 then the UDP\r
+checksum will be ignored on incoming packets on the assumption the UDP packets\r
+with an invalid checksum are not passed to the stack. */\r
+#define ipconfigETHERNET_DRIVER_CHECKS_UDP_CHECKSUM 0\r
+\r
/* Set ipconfigFREERTOS_PLUS_NABTO to 1 to support the Nabto protocol, or 0 to\r
exclude support for the Nabto protocol. If ipconfigFREERTOS_PLUS_NABTO is set\r
to one then the project must build the Nabto source code (or reference a\r
pre-build Nabto library. */\r
-#define ipconfigFREERTOS_PLUS_NABTO 0\r
+#define ipconfigFREERTOS_PLUS_NABTO 0\r
\r
/* Sets the size of the stack used by the Nabto service task. The Nabto event\r
handler executes in the context of the Nabto service task. If the event handler\r
uses a lot of stack then it is possible the value set here will need to be\r
increased. It is recommended to have FreeRTOS stack overflow checking turned\r
-on during development (see the configCHECK_FOR_STACK_OVERFLOW in \r
+on during development (see the configCHECK_FOR_STACK_OVERFLOW in\r
FreeRTOSConfig.h and in the documentation. */\r
#define ipconfigNABTO_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 )\r
\r
/*\r
- FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. \r
+ FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.\r
All rights reserved\r
\r
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
\r
/******************************************************************************\r
* This project provides two demo applications. A simple blinky style project,\r
- * and a more comprehensive application that makes use of FreeRTOS+ add-on\r
- * components. The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this \r
- * file) is used to select between the two. The simply blinky demo is \r
- * implemented and described in main_blinky.c. The more comprehensive demo \r
- * application is implemented and described in main_full.c.\r
+ * and a more comprehensive application that includes FreeRTOS+CLI, FreeRTOS+UDP\r
+ * and FreeRTOS+FAT SL. The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined\r
+ * in this file) is used to select between the two. The simply blinky demo is\r
+ * implemented and described in main_blinky.c. The more comprehensive demo\r
+ * application is implemented and described in main_full.c and full user\r
+ * instructions are provided on the following URL:\r
+ * http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html\r
*\r
* This file implements the code that is not demo specific, including the\r
* hardware setup and FreeRTOS hook functions.\r
#include "partest.h"\r
\r
/* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,\r
-or 0 to run the more comprehensive demo application that includes add-on \r
+or 0 to run the more comprehensive demo application that includes add-on\r
components. */\r
#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0\r
\r
\r
/* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top\r
of this file. */\r
- #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1\r
+ #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )\r
{\r
main_blinky();\r
}\r
#else\r
{\r
+ /* Full user instructions are provided on the following URL:\r
+ http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html */\r
main_full();\r
}\r
- #endif\r
+ #endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */\r
\r
return 0;\r
}\r
sysclk_init();\r
pmc_enable_periph_clk( ID_GMAC );\r
pmc_enable_periph_clk( ID_SMC );\r
- vParTestInitialise();\r
}\r
/*-----------------------------------------------------------*/\r
\r
important that vApplicationIdleHook() is permitted to return to its calling\r
function, because it is the responsibility of the idle task to clean up\r
memory allocated by the kernel to any task that has since been deleted. */\r
- \r
+\r
/* The simple blinky demo does not use the idle hook - the full demo does. */\r
#if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )\r
{\r
extern void vFullDemoIdleHook( void );\r
- \r
+\r
+ /* Implemented in main_full.c. */\r
vFullDemoIdleHook();\r
}\r
#endif\r
( void ) pxTask;\r
\r
/* Run time stack overflow checking is performed if\r
- configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook\r
- function is called if a stack overflow is detected. */\r
+ configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is\r
+ called if a stack overflow is detected. */\r
vAssertCalled( __LINE__, __FILE__ );\r
}\r
/*-----------------------------------------------------------*/\r
added here, but the tick hook is called from an interrupt context, so\r
code must not attempt to block, and only the interrupt safe FreeRTOS API\r
functions can be used (those that end in FromISR()). */\r
- \r
+\r
/* The simple blinky demo does not use the tick hook - the full demo does. */\r
#if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )\r
{\r
extern void vFullDemoTickHook( void );\r
- \r
+\r
+ /* Implemented in main_full.c. */\r
vFullDemoTickHook();\r
}\r
#endif\r
{\r
/* The following two variables are just to ensure the parameters are not\r
optimised away and therefore unavailable when viewed in the debugger. */\r
-volatile uint32_t ulLineNumber = ulLine, ulSetNoneZeroInDebuggerToReturn = 0;\r
+volatile uint32_t ulLineNumber = ulLine, ulSetNonZeroInDebuggerToReturn = 0;\r
volatile const char * const pcFileName = pcFile;\r
\r
taskENTER_CRITICAL();\r
- while( ulSetNoneZeroInDebuggerToReturn == 0 )\r
+ while( ulSetNonZeroInDebuggerToReturn == 0 )\r
{\r
/* If you want to set out of this function in the debugger to see the\r
- assert() location then set ulSetNoneZeroInDebuggerToReturn to a non-zero\r
+ assert() location then set ulSetNonZeroInDebuggerToReturn to a non-zero\r
value. */\r
}\r
taskEXIT_CRITICAL();\r
- \r
+\r
( void ) pcFileName;\r
( void ) ulLineNumber;\r
}\r
/*\r
- FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. \r
+ FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.\r
All rights reserved\r
\r
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
\r
/******************************************************************************\r
* NOTE 1: This project provides two demo applications. A simple blinky style\r
- * project, and a more comprehensive demo application that makes use of some\r
- * add-on components. The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c \r
- * is used to select between the two. See the notes on using \r
- * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY in main.c. This file implements the \r
- * simply blinky style version.\r
+ * project, and a more comprehensive demo application that makes use of\r
+ * FreeRTOS_CLI, FreeRTOS+UDP and FreeRTOS+FAT SL. The\r
+ * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select\r
+ * between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY\r
+ * in main.c. This file implements the simply blinky style version.\r
*\r
* NOTE 2: This file only contains the source code that is specific to the\r
* basic demo. Generic functions, such FreeRTOS hook functions, and functions\r
* required to configure the hardware, are defined in main.c.\r
******************************************************************************\r
*\r
- * main_blinky() creates one queue, and two tasks and one software timer. It \r
- * then starts the scheduler.\r
+ * main_blinky() creates one queue, two tasks and one software timer. It then\r
+ * starts the scheduler.\r
*\r
* The Queue Send Task:\r
* The queue send task is implemented by the prvQueueSendTask() function in\r
the queue empty. */\r
#define mainQUEUE_LENGTH ( 1 )\r
\r
-/* Values passed to the two tasks just to check the task parameter\r
-functionality. */\r
-#define mainQUEUE_SEND_PARAMETER ( 0x1111UL )\r
-#define mainQUEUE_RECEIVE_PARAMETER ( 0x22UL )\r
-\r
/* The period of the blinky software timer. The period is specified in ms and\r
converted to ticks using the portTICK_RATE_MS constant. */\r
#define mainBLINKY_TIMER_PERIOD ( 50 / portTICK_RATE_MS )\r
/* A block time of zero simply means "don't block". */\r
#define mainDONT_BLOCK ( 0 )\r
\r
-/* The LEDs toggled by the timer and queue receive task respectively. */\r
+/* The LEDs toggled by the timer callback and queue receive task respectively. */\r
#define mainTIMER_LED 0\r
#define mainTASK_LED 1\r
\r
\r
/*-----------------------------------------------------------*/\r
\r
-/* The queue used by both tasks. */\r
-static xQueueHandle xQueue = NULL;\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
void main_blinky( void )\r
{\r
xTimerHandle xTimer;\r
+xQueueHandle xQueue;\r
\r
/* Create the queue. */\r
xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) );\r
xTaskCreate( prvQueueReceiveTask, /* The function that implements the task. */\r
( signed char * ) "Rx", /* The text name assigned to the task - for debug only as it is not used by the kernel. */\r
configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the task. */\r
- ( void * ) mainQUEUE_RECEIVE_PARAMETER, /* The parameter passed to the task - just to check the functionality. */\r
+ ( void * ) xQueue, /* Pass the queue into the task using the task parameter. */\r
mainQUEUE_RECEIVE_TASK_PRIORITY, /* The priority assigned to the task. */\r
NULL ); /* The task handle is not required, so NULL is passed. */\r
\r
- xTaskCreate( prvQueueSendTask, ( signed char * ) "TX", configMINIMAL_STACK_SIZE, ( void * ) mainQUEUE_SEND_PARAMETER, mainQUEUE_SEND_TASK_PRIORITY, NULL );\r
+ xTaskCreate( prvQueueSendTask, ( signed char * ) "TX", configMINIMAL_STACK_SIZE, ( void * ) xQueue, mainQUEUE_SEND_TASK_PRIORITY, NULL );\r
\r
- /* Create the blinky software timer as described at the top of this \r
+ /* Create the blinky software timer as described at the top of this\r
file. */\r
xTimer = xTimerCreate( ( const signed char * ) "Blinky",/* A text name, purely to help debugging. */\r
( mainBLINKY_TIMER_PERIOD ), /* The timer period. */\r
{\r
portTickType xNextWakeTime;\r
const unsigned long ulValueToSend = 100UL;\r
+xQueueHandle xQueue;\r
\r
- /* Check the task parameter is as expected. */\r
- configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_SEND_PARAMETER );\r
+ /* The handle of the queue is passed in using the task's parameter. */\r
+ xQueue = ( xQueueHandle ) pvParameters;\r
\r
/* Initialise xNextWakeTime - this only needs to be done once. */\r
xNextWakeTime = xTaskGetTickCount();\r
toggle the LED. 0 is used as the block time so the sending operation\r
will not block - it shouldn't need to block as the queue should always\r
be empty at this point in the code. */\r
- xQueueSend( xQueue, &ulValueToSend, 0U );\r
+ xQueueSend( xQueue, &ulValueToSend, mainDONT_BLOCK );\r
}\r
}\r
/*-----------------------------------------------------------*/\r
static void prvQueueReceiveTask( void *pvParameters )\r
{\r
unsigned long ulReceivedValue;\r
+xQueueHandle xQueue;\r
\r
- /* Check the task parameter is as expected. */\r
- configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_RECEIVE_PARAMETER );\r
+ /* The queue is passed in as the task's parameter. */\r
+ xQueue = ( xQueueHandle ) pvParameters;\r
\r
for( ;; )\r
{\r
/*\r
- FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. \r
+ FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.\r
All rights reserved\r
\r
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
1 tab == 4 spaces!\r
*/\r
\r
+/******************************************************************************\r
+ * NOTE 1: This project provides two demo applications. A simple blinky style\r
+ * project, and a more comprehensive test and demo application that makes use of\r
+ * the FreeRTOS+CLI, FreeRTOS+UDP and FreeRTOS+FAT SL components. The\r
+ * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select\r
+ * between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY\r
+ * in main.c. This file implements the comprehensive test and demo version,\r
+ * which is fully documented on the following URL:\r
+ * http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html\r
+ *\r
+ * NOTE 2: This file only contains the source code that is specific to the\r
+ * full demo. Generic functions, such FreeRTOS hook functions, and functions\r
+ * required to configure the hardware, are defined in main.c.\r
+ ******************************************************************************\r
+ *\r
+ * Full user instructions are provided on the following URL:\r
+ * http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html\r
+ *\r
+ * main_full():\r
+ * + Uses FreeRTOS+FAT SL to create a set of example files on a RAM disk.\r
+ * + Displays some bitmaps on the LCD.\r
+ * + Registers sample generic, file system related and UDP related commands\r
+ * with FreeRTOS+CLI.\r
+ * + Creates all the standard demo application tasks and software timers.\r
+ * + Starts the scheduler.\r
+ *\r
+ * A UDP command server and optionally two UDP echo client tasks are created\r
+ * from the network event hook after an IP address has been obtained. The IP\r
+ * address is displayed on the LCD.\r
+ *\r
+ * A "check software timer" is created to provide visual feedback of the system\r
+ * status. The timer's period is initially set to three seconds. The callback\r
+ * function associated with the timer checks all the standard demo tasks are not\r
+ * only still executed, but are executing without reporting any errors. If the\r
+ * timer discovers a task has either stalled, or reported an error, then it\r
+ * changes its own period from the initial three seconds, to just 200ms. The\r
+ * check software timer also toggles the LED marked D4 - so if the LED toggles\r
+ * every three seconds then no potential errors have been found, and if the LED\r
+ * toggles every 200ms then a potential error has been found in at least one\r
+ * task.\r
+ *\r
+ * Information on accessing the CLI and file system, and using the UDP echo\r
+ * tasks is provided on http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html\r
+ *\r
+ */\r
+\r
/* FreeRTOS includes. */\r
#include "FreeRTOS.h"\r
#include "task.h"\r
/* Misc. */\r
#define mainDONT_BLOCK ( 0 )\r
\r
-/* Note: If the application is started without the network cable plugged in \r
+/* Note: If the application is started without the network cable plugged in\r
then ipconfigUDP_TASK_PRIORITY should be set to 0 in FreeRTOSIPConfig.h to\r
-ensure the IP task is created at the idle priority. This is because the Atmel \r
-ASF GMAC driver polls the GMAC looking for a connection, and doing so will \r
-prevent any lower priority tasks from executing. In this demo the IP task is \r
-started at the idle priority, then set to configMAX_PRIORITIES - 2 in the \r
+ensure the IP task is created at the idle priority. This is because the Atmel\r
+ASF GMAC driver polls the GMAC looking for a connection, and doing so will\r
+prevent any lower priority tasks from executing. In this demo the IP task is\r
+started at the idle priority, then set to configMAX_PRIORITIES - 2 in the\r
network event hook only after a connection has been established (when the event\r
-passed into the network event hook is eNetworkUp). */\r
+passed into the network event hook is eNetworkUp).\r
+http://www.FreeRTOS.org/udp */\r
#define mainCONNECTED_IP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )\r
#define mainDISCONNECTED_IP_TASK_PRIORITY ( tskIDLE_PRIORITY )\r
\r
#define mainUDP_CLI_PORT_NUMBER ( 5001UL )\r
#define mainUDP_CLI_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2U )\r
\r
-/* Set to 1 to include the UDP echo client tasks. */\r
+/* Set to 1 to include the UDP echo client tasks in the build. The echo clients\r
+require the IP address of the echo server to be defined using the\r
+configECHO_SERVER_ADDR0 to configECHO_SERVER_ADDR3 constants in\r
+FreeRTOSConfig.h. */\r
#define mainINCLUDE_ECHO_CLIENT_TASKS 1\r
\r
/*-----------------------------------------------------------*/\r
*/\r
static void prvCheckTimerCallback( xTimerHandle xTimer );\r
\r
-/* \r
- * Creates a set of sample files on a RAM disk. \r
+/*\r
+ * Creates a set of sample files on a RAM disk. http://www.FreeRTOS.org/fat_sl\r
*/\r
extern void vCreateAndVerifySampleFiles( void );\r
\r
/*\r
- * Register the generic commands that can be used with FreeRTOS+CLI.\r
+ * Register sample generic commands that can be used with FreeRTOS+CLI. Type\r
+ * 'help' in the command line to see a list of registered commands.\r
+ * http://www.FreeRTOS.org/cli\r
*/\r
extern void vRegisterSampleCLICommands( void );\r
\r
/*\r
- * Register the file system commands that can be used with FreeRTOS+CLI.\r
+ * Register sample file system commands that can be used with FreeRTOS+CLI.\r
*/\r
extern void vRegisterFileSystemCLICommands( void );\r
\r
/*\r
- * Register the UDP related commands that can be used with FreeRTOS+CLI.\r
+ * Register sample UDP related commands that can be used with FreeRTOS+CLI.\r
*/\r
extern void vRegisterUDPCLICommands( void );\r
\r
const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };\r
\r
/*-----------------------------------------------------------*/\r
+\r
int main_full( void )\r
{\r
xTimerHandle xTimer = NULL;\r
\r
- /* Initialise the LCD and output the bitmap. */\r
+ /* Initialise the LCD and output a bitmap. The IP address will also be\r
+ displayed on the LCD when it has been obtained. */\r
vInitialiseLCD();\r
\r
/* If the file system is only going to be accessed from one task then\r
before the RTOS scheduler is started. If the file system is going to be\r
access from more than one task then F_FS_THREAD_AWARE must be set to 1 and\r
the set of sample files are created from the idle task hook function\r
- vApplicationIdleHook() - which is defined in this file. */\r
+ vApplicationIdleHook(). */\r
#if( F_FS_THREAD_AWARE == 0 )\r
{\r
/* Initialise the drive and file system, then create a few example\r
- files. The output from this function just goes to the stdout window,\r
- allowing the output to be viewed when the UDP command console is not\r
- connected. */\r
+ files. The files can be viewed and accessed via the CLI. View the\r
+ documentation page for this demo (link at the top of this file) for more\r
+ information. */\r
vCreateAndVerifySampleFiles();\r
}\r
#endif\r
\r
- /* Register example generic, file system related and UDP related CLI \r
- commands respectively. */\r
+ /* Register example generic, file system related and UDP related CLI\r
+ commands respectively. Type 'help' into the command console to view a list\r
+ of registered commands. */\r
vRegisterSampleCLICommands();\r
vRegisterFileSystemCLICommands();\r
vRegisterUDPCLICommands();\r
created in the network event hook when the network is connected and ready\r
for use. The address values passed in here are used if ipconfigUSE_DHCP is\r
set to 0, or if ipconfigUSE_DHCP is set to 1 but a DHCP server cannot be\r
- contacted. The Nabto service task is created automatically if\r
- ipconfigFREERTOS_PLUS_NABTO is set to 1 in FreeRTOSIPConfig.h. */\r
+ contacted. The IP address actually used is displayed on the LCD (after DHCP\r
+ has completed if DHCP is used). */\r
FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );\r
\r
/* Create all the other standard demo tasks. */\r
}\r
}\r
\r
+ /* Toggle the LED to give visual feedback of the system status. The rate at\r
+ which the LED toggles will increase to mainERROR_CHECK_TIMER_PERIOD_MS if a\r
+ suspected error has been found in any of the standard demo tasks. */\r
vParTestToggleLED( mainCHECK_LED );\r
}\r
/*-----------------------------------------------------------*/\r
passed into the network event hook is eNetworkUp). */\r
if( eNetworkEvent == eNetworkUp )\r
{\r
+ /* Ensure tasks are only created once. */\r
if( lTasksAlreadyCreated == pdFALSE )\r
- { \r
- /* Create the task that handles the CLI on a UDP port. The port number\r
- is set using the configUDP_CLI_PORT_NUMBER setting in FreeRTOSConfig.h. */\r
+ {\r
+ /* Create the task that handles the CLI on a UDP port. The port\r
+ number is set using the configUDP_CLI_PORT_NUMBER setting in\r
+ FreeRTOSConfig.h. */\r
vStartUDPCommandInterpreterTask( mainUDP_CLI_TASK_STACK_SIZE, mainUDP_CLI_PORT_NUMBER, mainUDP_CLI_TASK_PRIORITY );\r
- \r
+\r
#if( mainINCLUDE_ECHO_CLIENT_TASKS == 1 )\r
{\r
+ /* Create the UDP echo tasks. The UDP echo tasks require the IP\r
+ address of the echo server to be defined using the\r
+ configECHO_SERVER_ADDR0 to configECHO_SERVER_ADDR3 constants in\r
+ FreeRTOSConfig.h. */\r
vStartEchoClientTasks( configMINIMAL_STACK_SIZE, tskIDLE_PRIORITY );\r
}\r
#endif\r
}\r
- \r
- /* Obtain the IP address, convert it to a string, then display. */\r
+\r
+ /* Obtain the IP address, convert it to a string, then display it on the\r
+ LCD. */\r
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );\r
FreeRTOS_inet_ntoa( ulIPAddress, cIPAddress );\r
ili93xx_draw_string( ulXCoord, ulYCoord, ( uint8_t * ) "IP: " );\r
ili93xx_draw_string( ulXCoord + ulIPAddressOffset, ulYCoord, ( uint8_t * ) cIPAddress );\r
- \r
- /* Set the IP task up to the desired priority now it has connected. */\r
+\r
+ /* Set the priority of the IP task up to the desired priority now it has\r
+ connected. */\r
vTaskPrioritySet( NULL, mainCONNECTED_IP_TASK_PRIORITY );\r
}\r
\r
+ /* NOTE: At the time of writing the Ethernet driver does not report the\r
+ cable being unplugged - so the following if() condition will never be met.\r
+ It is included for possible future updates to the driver. */\r
if( eNetworkEvent == eNetworkDown )\r
{\r
+ /* Ensure the Atmel GMAC drivers don't hog all the CPU time as they look\r
+ for a new connection by lowering the priority of the IP task to that of\r
+ the Idle task. */\r
vTaskPrioritySet( NULL, tskIDLE_PRIORITY );\r
+ \r
+ /* Disconnected - so no IP address. */\r
+ ili93xx_draw_string( ulXCoord, ulYCoord, ( uint8_t * ) "IP: " );\r
}\r
}\r
/*-----------------------------------------------------------*/\r
\r
void vFullDemoIdleHook( void )\r
-{ \r
+{\r
/* If the file system is only going to be accessed from one task then\r
F_FS_THREAD_AWARE can be set to 0 and the set of example files is created\r
before the RTOS scheduler is started. If the file system is going to be\r
\r
void vFullDemoTickHook( void )\r
{\r
- /* Call the periodic queue overwrite from ISR demo. */\r
+ /* Call the periodic queue overwrite from ISR test function. */\r
vQueueOverwritePeriodicISRDemo();\r
\r
- /* Call the queue set ISR test function. */\r
+ /* Call the periodic queue set ISR test function. */\r
vQueueSetAccessQueueSetFromISR();\r
}\r
/*-----------------------------------------------------------*/\r
/* Called automatically when a reply to an outgoing ping is received. */\r
void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifier )\r
{\r
- /* This demo has nowhere to output any information so does nothing. */\r
+ /* This demo has nowhere to output any information so does nothing, but the\r
+ IP address resolved for the pined URL is displayed in the CLI. */\r
( void ) usIdentifier;\r
( void ) eStatus;\r
}\r
static void printchar(char **str, int c)
{
extern int putchar(int c);
-
+
if (str) {
**str = c;
++(*str);
int printf(const char *format, ...)
{
va_list args;
-
+
va_start( args, format );
return print( 0, format, args );
}
int sprintf(char *out, const char *format, ...)
{
va_list args;
-
+
va_start( args, format );
return print( &out, format, args );
}
int snprintf( char *buf, unsigned int count, const char *format, ... )\r
{\r
va_list args;
-
+
( void ) count;\r
- \r
+\r
va_start( args, format );\r
return print( &buf, format, args );\r
}\r