]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_full.c
Add graphics to the SAM4E demo.
[freertos] / FreeRTOS / Demo / CORTEX_M4_ATSAM4E_Atmel_Studio / src / main_full.c
index 22376afca1d8e4a6bffa905aa4155d80a0ff823d..e6a5ff01b82669bc8e07f8193c28337f9b0fb490 100644 (file)
 \r
 /* FreeRTOS+UDP includes. */\r
 #include "FreeRTOS_UDP_IP.h"\r
+#include "FreeRTOS_Sockets.h"\r
 \r
-/* Demo application includes. */\r
+/* UDP demo includes. */\r
 #include "UDPCommandInterpreter.h"\r
+#include "TwoEchoClients.h"\r
+\r
+/* Standard demo includes. */\r
 #include "partest.h"\r
 #include "blocktim.h"\r
 #include "flash_timer.h"\r
@@ -128,9 +132,12 @@ passed into the network event hook is eNetworkUp). */
 #define mainDISCONNECTED_IP_TASK_PRIORITY      ( tskIDLE_PRIORITY )\r
 \r
 /* UDP command server task parameters. */\r
-#define mainUDP_CLI_TASK_PRIORITY                                      ( tskIDLE_PRIORITY )\r
-#define mainUDP_CLI_PORT_NUMBER                                                ( 5001UL )\r
-#define mainUDP_CLI_TASK_STACK_SIZE                                    ( configMINIMAL_STACK_SIZE * 2U )\r
+#define mainUDP_CLI_TASK_PRIORITY                      ( tskIDLE_PRIORITY )\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
+#define mainINCLUDE_ECHO_CLIENT_TASKS          1\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -159,6 +166,11 @@ extern void vRegisterFileSystemCLICommands( void );
  */\r
 extern void vRegisterUDPCLICommands( void );\r
 \r
+/*\r
+ * Initialise the LCD and output a bitmap.\r
+ */\r
+extern void vInitialiseLCD( void );\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /* The default IP and MAC address used by the demo.  The address configuration\r
@@ -180,6 +192,9 @@ int main_full( void )
 {\r
 xTimerHandle xTimer = NULL;\r
 \r
+       /* Initialise the LCD and output the bitmap. */\r
+       vInitialiseLCD();\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 are created\r
        before the RTOS scheduler is started.  If the file system is going to be\r
@@ -319,6 +334,9 @@ unsigned long ulErrorOccurred = pdFALSE;
 void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )\r
 {\r
 static long lTasksAlreadyCreated = pdFALSE;\r
+const unsigned long ulXCoord = 3, ulYCoord = 3, ulIPAddressOffset = 45;\r
+unsigned long ulIPAddress;\r
+char cIPAddress[ 20 ];\r
 \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
@@ -330,14 +348,27 @@ static long lTasksAlreadyCreated = pdFALSE;
        passed into the network event hook is eNetworkUp). */\r
        if( eNetworkEvent == eNetworkUp )\r
        {\r
-               vTaskPrioritySet( NULL, mainCONNECTED_IP_TASK_PRIORITY );\r
-\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
                        vStartUDPCommandInterpreterTask( mainUDP_CLI_TASK_STACK_SIZE, mainUDP_CLI_PORT_NUMBER, mainUDP_CLI_TASK_PRIORITY );\r
+                       \r
+                       #if( mainINCLUDE_ECHO_CLIENT_TASKS == 1 )\r
+                       {\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
+               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
+               vTaskPrioritySet( NULL, mainCONNECTED_IP_TASK_PRIORITY );\r
        }\r
 \r
        if( eNetworkEvent == eNetworkDown )\r
@@ -387,25 +418,7 @@ void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifie
 {\r
        /* This demo has nowhere to output any information so does nothing. */\r
        ( void ) usIdentifier;\r
-       \r
-       switch( eStatus )\r
-       {\r
-               case eSuccess   :\r
-                       break;\r
-\r
-               case eInvalidChecksum :\r
-                       break;\r
-\r
-               case eInvalidData :\r
-                       break;\r
-\r
-               default :\r
-                       /* It is not possible to get here as all enums have their own\r
-                       case. */\r
-                       break;\r
-       }\r
+       ( void ) eStatus;\r
 }\r
-\r
-\r
-\r
+/*-----------------------------------------------------------*/\r
 \r