Add additional comments to SAM4E demo.

pull/4/head
Richard Barry 11 years ago
parent 6be1ffccfb
commit 0cbd5182a3

@ -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 /* 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. */ ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
#define configIP_ADDR0 172 #define configIP_ADDR0 192
#define configIP_ADDR1 25 #define configIP_ADDR1 168
#define configIP_ADDR2 218 #define configIP_ADDR2 0
#define configIP_ADDR3 200 #define configIP_ADDR3 200
/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to /* 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. */ 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
#define configGATEWAY_ADDR0 172 #define configGATEWAY_ADDR0 192
#define configGATEWAY_ADDR1 25 #define configGATEWAY_ADDR1 168
#define configGATEWAY_ADDR2 218 #define configGATEWAY_ADDR2 0
#define configGATEWAY_ADDR3 1 #define configGATEWAY_ADDR3 1
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and /* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and

@ -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 static IP address passed as a parameter to FreeRTOS_IPInit() if the
re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without
a DHCP reply being received. */ 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 ) #define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 999 / portTICK_RATE_MS )
#else
#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000 / portTICK_RATE_MS )
#endif /* _WINDOWS_ */
/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP /* 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 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 /* 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 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 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 #define ipconfigNUM_NETWORK_BUFFERS 10
/* A FreeRTOS queue is used to send events from application tasks to the IP /* A FreeRTOS queue is used to send events from application tasks to the IP
@ -242,6 +237,26 @@ Ethernet driver does all the necessary filtering in hardware then software
filtering can be removed by using a value other than 1 or 0. */ filtering can be removed by using a value other than 1 or 0. */
#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 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 /* 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 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 to one then the project must build the Nabto source code (or reference a

@ -65,11 +65,13 @@
/****************************************************************************** /******************************************************************************
* This project provides two demo applications. A simple blinky style project, * This project provides two demo applications. A simple blinky style project,
* and a more comprehensive application that makes use of FreeRTOS+ add-on * and a more comprehensive application that includes FreeRTOS+CLI, FreeRTOS+UDP
* components. The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this * and FreeRTOS+FAT SL. The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined
* file) is used to select between the two. The simply blinky demo is * 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 * implemented and described in main_blinky.c. The more comprehensive demo
* application is implemented and described in main_full.c. * 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 * This file implements the code that is not demo specific, including the
* hardware setup and FreeRTOS hook functions. * hardware setup and FreeRTOS hook functions.
@ -111,15 +113,17 @@ int main( void )
/* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
of this file. */ of this file. */
#if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )
{ {
main_blinky(); main_blinky();
} }
#else #else
{ {
/* Full user instructions are provided on the following URL:
http://www.FreeRTOS.org/Atmel_SAM4E_RTOS_Demo.html */
main_full(); main_full();
} }
#endif #endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */
return 0; return 0;
} }
@ -132,7 +136,6 @@ static void prvSetupHardware( void )
sysclk_init(); sysclk_init();
pmc_enable_periph_clk( ID_GMAC ); pmc_enable_periph_clk( ID_GMAC );
pmc_enable_periph_clk( ID_SMC ); pmc_enable_periph_clk( ID_SMC );
vParTestInitialise();
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -169,6 +172,7 @@ void vApplicationIdleHook( void )
{ {
extern void vFullDemoIdleHook( void ); extern void vFullDemoIdleHook( void );
/* Implemented in main_full.c. */
vFullDemoIdleHook(); vFullDemoIdleHook();
} }
#endif #endif
@ -181,8 +185,8 @@ void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName
( void ) pxTask; ( void ) pxTask;
/* Run time stack overflow checking is performed if /* Run time stack overflow checking is performed if
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is
function is called if a stack overflow is detected. */ called if a stack overflow is detected. */
vAssertCalled( __LINE__, __FILE__ ); vAssertCalled( __LINE__, __FILE__ );
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -200,6 +204,7 @@ void vApplicationTickHook( void )
{ {
extern void vFullDemoTickHook( void ); extern void vFullDemoTickHook( void );
/* Implemented in main_full.c. */
vFullDemoTickHook(); vFullDemoTickHook();
} }
#endif #endif
@ -210,14 +215,14 @@ void vAssertCalled( uint32_t ulLine, const char *pcFile )
{ {
/* The following two variables are just to ensure the parameters are not /* The following two variables are just to ensure the parameters are not
optimised away and therefore unavailable when viewed in the debugger. */ 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; volatile const char * const pcFileName = pcFile;
taskENTER_CRITICAL(); taskENTER_CRITICAL();
while( ulSetNoneZeroInDebuggerToReturn == 0 ) while( ulSetNonZeroInDebuggerToReturn == 0 )
{ {
/* If you want to set out of this function in the debugger to see the /* 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. */ value. */
} }
taskEXIT_CRITICAL(); taskEXIT_CRITICAL();

@ -65,19 +65,19 @@
/****************************************************************************** /******************************************************************************
* NOTE 1: This project provides two demo applications. A simple blinky style * NOTE 1: This project provides two demo applications. A simple blinky style
* project, and a more comprehensive demo application that makes use of some * project, and a more comprehensive demo application that makes use of
* add-on components. The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c * FreeRTOS_CLI, FreeRTOS+UDP and FreeRTOS+FAT SL. The
* is used to select between the two. See the notes on using * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select
* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY in main.c. This file implements the * between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY
* simply blinky style version. * 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 * NOTE 2: This file only contains the source code that is specific to the
* basic demo. Generic functions, such FreeRTOS hook functions, and functions * basic demo. Generic functions, such FreeRTOS hook functions, and functions
* required to configure the hardware, are defined in main.c. * required to configure the hardware, are defined in main.c.
****************************************************************************** ******************************************************************************
* *
* main_blinky() creates one queue, and two tasks and one software timer. It * main_blinky() creates one queue, two tasks and one software timer. It then
* then starts the scheduler. * starts the scheduler.
* *
* The Queue Send Task: * The Queue Send Task:
* The queue send task is implemented by the prvQueueSendTask() function in * 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. */ the queue empty. */
#define mainQUEUE_LENGTH ( 1 ) #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 /* The period of the blinky software timer. The period is specified in ms and
converted to ticks using the portTICK_RATE_MS constant. */ converted to ticks using the portTICK_RATE_MS constant. */
#define mainBLINKY_TIMER_PERIOD ( 50 / portTICK_RATE_MS ) #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". */ /* A block time of zero simply means "don't block". */
#define mainDONT_BLOCK ( 0 ) #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 mainTIMER_LED 0
#define mainTASK_LED 1 #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 ) void main_blinky( void )
{ {
xTimerHandle xTimer; xTimerHandle xTimer;
xQueueHandle xQueue;
/* Create the queue. */ /* Create the queue. */
xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) ); xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) );
@ -173,11 +164,11 @@ xTimerHandle xTimer;
xTaskCreate( prvQueueReceiveTask, /* The function that implements the task. */ 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. */ ( 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. */ 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. */ mainQUEUE_RECEIVE_TASK_PRIORITY, /* The priority assigned to the task. */
NULL ); /* The task handle is not required, so NULL is passed. */ 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. */ file. */
@ -211,9 +202,10 @@ static void prvQueueSendTask( void *pvParameters )
{ {
portTickType xNextWakeTime; portTickType xNextWakeTime;
const unsigned long ulValueToSend = 100UL; const unsigned long ulValueToSend = 100UL;
xQueueHandle xQueue;
/* Check the task parameter is as expected. */ /* The handle of the queue is passed in using the task's parameter. */
configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_SEND_PARAMETER ); xQueue = ( xQueueHandle ) pvParameters;
/* Initialise xNextWakeTime - this only needs to be done once. */ /* Initialise xNextWakeTime - this only needs to be done once. */
xNextWakeTime = xTaskGetTickCount(); 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 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 will not block - it shouldn't need to block as the queue should always
be empty at this point in the code. */ 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 ) static void prvQueueReceiveTask( void *pvParameters )
{ {
unsigned long ulReceivedValue; unsigned long ulReceivedValue;
xQueueHandle xQueue;
/* Check the task parameter is as expected. */ /* The queue is passed in as the task's parameter. */
configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_RECEIVE_PARAMETER ); xQueue = ( xQueueHandle ) pvParameters;
for( ;; ) for( ;; )
{ {

@ -63,6 +63,52 @@
1 tab == 4 spaces! 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. */ /* FreeRTOS includes. */
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "task.h" #include "task.h"
@ -127,7 +173,8 @@ 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 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 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 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 mainCONNECTED_IP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
#define mainDISCONNECTED_IP_TASK_PRIORITY ( tskIDLE_PRIORITY ) #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_PORT_NUMBER ( 5001UL )
#define mainUDP_CLI_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2U ) #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 #define mainINCLUDE_ECHO_CLIENT_TASKS 1
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -147,22 +197,24 @@ passed into the network event hook is eNetworkUp). */
static void prvCheckTimerCallback( xTimerHandle xTimer ); 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 ); 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 ); 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 ); 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 ); 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 }; const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
int main_full( void ) int main_full( void )
{ {
xTimerHandle xTimer = NULL; 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(); vInitialiseLCD();
/* If the file system is only going to be accessed from one task then /* 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 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 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 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 ) #if( F_FS_THREAD_AWARE == 0 )
{ {
/* Initialise the drive and file system, then create a few example /* Initialise the drive and file system, then create a few example
files. The output from this function just goes to the stdout window, files. The files can be viewed and accessed via the CLI. View the
allowing the output to be viewed when the UDP command console is not documentation page for this demo (link at the top of this file) for more
connected. */ information. */
vCreateAndVerifySampleFiles(); vCreateAndVerifySampleFiles();
} }
#endif #endif
/* Register example generic, file system related and UDP related CLI /* Register example generic, file system related and UDP related CLI
commands respectively. */ commands respectively. Type 'help' into the command console to view a list
of registered commands. */
vRegisterSampleCLICommands(); vRegisterSampleCLICommands();
vRegisterFileSystemCLICommands(); vRegisterFileSystemCLICommands();
vRegisterUDPCLICommands(); vRegisterUDPCLICommands();
@ -221,8 +276,8 @@ xTimerHandle xTimer = NULL;
created in the network event hook when the network is connected and ready 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 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 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 contacted. The IP address actually used is displayed on the LCD (after DHCP
ipconfigFREERTOS_PLUS_NABTO is set to 1 in FreeRTOSIPConfig.h. */ has completed if DHCP is used). */
FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress ); FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
/* Create all the other standard demo tasks. */ /* 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 ); vParTestToggleLED( mainCHECK_LED );
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -348,32 +406,49 @@ char cIPAddress[ 20 ];
passed into the network event hook is eNetworkUp). */ passed into the network event hook is eNetworkUp). */
if( eNetworkEvent == eNetworkUp ) if( eNetworkEvent == eNetworkUp )
{ {
/* Ensure tasks are only created once. */
if( lTasksAlreadyCreated == pdFALSE ) if( lTasksAlreadyCreated == pdFALSE )
{ {
/* Create the task that handles the CLI on a UDP port. The port number /* Create the task that handles the CLI on a UDP port. The port
is set using the configUDP_CLI_PORT_NUMBER setting in FreeRTOSConfig.h. */ 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 ); vStartUDPCommandInterpreterTask( mainUDP_CLI_TASK_STACK_SIZE, mainUDP_CLI_PORT_NUMBER, mainUDP_CLI_TASK_PRIORITY );
#if( mainINCLUDE_ECHO_CLIENT_TASKS == 1 ) #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 ); vStartEchoClientTasks( configMINIMAL_STACK_SIZE, tskIDLE_PRIORITY );
} }
#endif #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_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
FreeRTOS_inet_ntoa( ulIPAddress, cIPAddress ); FreeRTOS_inet_ntoa( ulIPAddress, cIPAddress );
ili93xx_draw_string( ulXCoord, ulYCoord, ( uint8_t * ) "IP: " ); ili93xx_draw_string( ulXCoord, ulYCoord, ( uint8_t * ) "IP: " );
ili93xx_draw_string( ulXCoord + ulIPAddressOffset, ulYCoord, ( uint8_t * ) cIPAddress ); 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 ); 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 ) 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 ); vTaskPrioritySet( NULL, tskIDLE_PRIORITY );
/* Disconnected - so no IP address. */
ili93xx_draw_string( ulXCoord, ulYCoord, ( uint8_t * ) "IP: " );
} }
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -405,10 +480,10 @@ void vFullDemoIdleHook( void )
void vFullDemoTickHook( void ) void vFullDemoTickHook( void )
{ {
/* Call the periodic queue overwrite from ISR demo. */ /* Call the periodic queue overwrite from ISR test function. */
vQueueOverwritePeriodicISRDemo(); vQueueOverwritePeriodicISRDemo();
/* Call the queue set ISR test function. */ /* Call the periodic queue set ISR test function. */
vQueueSetAccessQueueSetFromISR(); vQueueSetAccessQueueSetFromISR();
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -416,7 +491,8 @@ void vFullDemoTickHook( void )
/* Called automatically when a reply to an outgoing ping is received. */ /* Called automatically when a reply to an outgoing ping is received. */
void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifier ) 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 ) usIdentifier;
( void ) eStatus; ( void ) eStatus;
} }

Loading…
Cancel
Save