]> git.sur5r.net Git - freertos/blobdiff - Demo/CORTEX_LPC1768_GCC_Rowley/main.c
Prepare for release.
[freertos] / Demo / CORTEX_LPC1768_GCC_Rowley / main.c
index 6d258ababf31df77fb4c04f389f5c4f2e6d130d8..2897325380218ec2e655b452162634ed1202afb8 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-       FreeRTOS.org V5.3.1 - Copyright (C) 2003-2009 Richard Barry.\r
+       FreeRTOS.org V5.4.0 - Copyright (C) 2003-2009 Richard Barry.\r
 \r
        This file is part of the FreeRTOS.org distribution.\r
 \r
  * In addition to the standard demo tasks, the following tasks and tests are\r
  * defined and/or created within this file:\r
  *\r
- * "LCD" task - the LCD task is a 'gatekeeper' task.  It is the only task that\r
- * is permitted to access the display directly.  Other tasks wishing to write a\r
- * message to the LCD send the message on a queue to the LCD task instead of\r
- * accessing the LCD themselves.  The LCD task just blocks on the queue waiting\r
- * for messages - waking and displaying the messages as they arrive.  The use\r
- * of a gatekeeper in this manner permits both tasks and interrupts to write to\r
- * the LCD without worrying about mutual exclusion.  This is demonstrated by the\r
- * check hook (see below) which sends messages to the display even though it\r
- * executes from an interrupt context.\r
- *\r
  * "Check" hook -  This only executes fully every five seconds from the tick\r
  * hook.  Its main function is to check that all the standard demo tasks are\r
- * still operational.  Should any unexpected behaviour be discovered within a\r
- * demo task then the tick hook will write an error to the LCD (via the LCD task).\r
- * If all the demo tasks are executing with their expected behaviour then the\r
- * check hook writes PASS to the LCD (again via the LCD task), as described above.\r
- * The check hook also toggles LED 4 each time it executes.\r
- *\r
- * LED tasks - These just demonstrate how multiple instances of a single task\r
- * definition can be created.  Each LED task simply toggles an LED.  The task\r
- * parameter is used to pass the number of the LED to be toggled into the task.\r
+ * still operational.  The status can be viewed using on the Task Stats page\r
+ * served by the WEB server.\r
  *\r
  * "uIP" task -  This is the task that handles the uIP stack.  All TCP/IP\r
  * processing is performed in this task.\r
  */\r
 \r
-/* Standard includes. */\r
-#include <stdio.h>\r
-\r
 /* Scheduler includes. */\r
 #include "FreeRTOS.h"\r
 #include "task.h"\r
-#include "queue.h"\r
-#include "semphr.h"\r
 \r
 /* Demo app includes. */\r
 #include "BlockQ.h"\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
-/* The number of LED tasks that will be created. */\r
-#define mainNUM_LED_TASKS                                      ( 6 )\r
-\r
 /* The time between cycles of the 'check' functionality (defined within the\r
-tick hook. */\r
+tick hook). */\r
 #define mainCHECK_DELAY                                                ( ( portTickType ) 5000 / portTICK_RATE_MS )\r
 \r
 /* Task priorities. */\r
@@ -120,7 +95,6 @@ tick hook. */
 #define mainSEM_TEST_PRIORITY                          ( tskIDLE_PRIORITY + 1 )\r
 #define mainBLOCK_Q_PRIORITY                           ( tskIDLE_PRIORITY + 2 )\r
 #define mainUIP_TASK_PRIORITY                          ( tskIDLE_PRIORITY + 3 )\r
-#define mainLCD_TASK_PRIORITY                          ( tskIDLE_PRIORITY + 2 )\r
 #define mainINTEGER_TASK_PRIORITY           ( tskIDLE_PRIORITY )\r
 #define mainGEN_QUEUE_TASK_PRIORITY                    ( tskIDLE_PRIORITY )\r
 #define mainFLASH_TASK_PRIORITY                                ( tskIDLE_PRIORITY + 2 )\r
@@ -129,11 +103,10 @@ tick hook. */
 handling library calls. */\r
 #define mainBASIC_WEB_STACK_SIZE            ( configMINIMAL_STACK_SIZE * 4 )\r
 \r
-/* The length of the queue used to send messages to the LCD task. */\r
-#define mainQUEUE_SIZE                                         ( 3 )\r
+/* The message displayed by the WEB server when all tasks are executing\r
+without an error being reported. */\r
+#define mainPASS_STATUS_MESSAGE                                "All tasks are executing without error."\r
 \r
-/* The task that is toggled by the check task. */\r
-#define mainCHECK_TASK_LED                                     ( 4 )\r
 /*-----------------------------------------------------------*/\r
 \r
 /*\r
@@ -141,11 +114,6 @@ handling library calls. */
  */\r
 static void prvSetupHardware( void );\r
 \r
-/*\r
- * Very simple task that toggles an LED.\r
- */\r
-static void vLEDTask( void *pvParameters );\r
-\r
 /*\r
  * The task that handles the uIP stack.  All TCP/IP processing is performed in\r
  * this task.\r
@@ -153,14 +121,14 @@ static void vLEDTask( void *pvParameters );
 extern void vuIP_Task( void *pvParameters );\r
 \r
 /*\r
- * The LCD gatekeeper task as described in the comments at the top of this file.\r
- * */\r
-static void vLCDTask( void *pvParameters );\r
+ * Simply returns the current status message for display on served WEB pages.\r
+ */\r
+char *pcGetTaskStatusMessage( void );\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
-/* The queue used to send messages to the LCD task. */\r
-xQueueHandle xLCDQueue;\r
+/* Holds the status message displayed by the WEB server. */\r
+static char *pcStatusMessage = mainPASS_STATUS_MESSAGE;\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -184,14 +152,6 @@ int main( void )
        /* Create the uIP task.  The WEB server runs in this task. */\r
     xTaskCreate( vuIP_Task, ( signed char * ) "uIP", mainBASIC_WEB_STACK_SIZE, ( void * ) NULL, mainUIP_TASK_PRIORITY, NULL );\r
 \r
-       /* Create the queue used by the LCD task.  Messages for display on the LCD\r
-       are received via this queue. */\r
-       xLCDQueue = xQueueCreate( mainQUEUE_SIZE, sizeof( xLCDMessage ) );\r
-\r
-       /* Start the LCD gatekeeper task - as described in the comments at the top\r
-       of this file. */\r
-       xTaskCreate( vLCDTask, ( signed portCHAR * ) "LCD", configMINIMAL_STACK_SIZE * 2, NULL, mainLCD_TASK_PRIORITY, NULL );\r
-\r
     /* Start the scheduler. */\r
        vTaskStartScheduler();\r
 \r
@@ -201,35 +161,9 @@ int main( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vLCDTask( void *pvParameters )\r
-{\r
-xLCDMessage xMessage;\r
-unsigned long ulRow = 0;\r
-char cIPAddr[ 17 ]; /* To fit max IP address length of xxx.xxx.xxx.xxx\0 */\r
-\r
-       ( void ) pvParameters;\r
-\r
-       /* The LCD gatekeeper task as described in the comments at the top of this\r
-       file. */\r
-\r
-       /* Initialise the LCD and display a startup message that includes the\r
-       configured IP address. */\r
-    sprintf( cIPAddr, "%d.%d.%d.%d", configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 );\r
-\r
-       for( ;; )\r
-       {\r
-               /* Wait for a message to arrive to be displayed. */\r
-               while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS );\r
-\r
-       }\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
 void vApplicationTickHook( void )\r
 {\r
-static xLCDMessage xMessage = { "PASS" };\r
 static unsigned portLONG ulTicksSinceLastDisplay = 0;\r
-portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
 \r
        /* Called from every tick interrupt as described in the comments at the top\r
        of this file.\r
@@ -246,51 +180,47 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
                /* Has an error been found in any task? */\r
                if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
                {\r
-                       xMessage.pcMessage = "ERROR: GEN Q";\r
+                       pcStatusMessage = "An error has been detected in the Generic Queue test/demo.";\r
                }\r
                else if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
                {\r
-                       xMessage.pcMessage = "ERROR: PEEK Q";\r
+                       pcStatusMessage = "An error has been detected in the Peek Queue test/demo.";\r
                }\r
                else if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
                {\r
-                       xMessage.pcMessage = "ERROR: BLOCK Q";\r
+                       pcStatusMessage = "An error has been detected in the Block Queue test/demo.";\r
                }\r
                else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
                {\r
-                       xMessage.pcMessage = "ERROR: BLOCK TIME";\r
+                       pcStatusMessage = "An error has been detected in the Block Time test/demo.";\r
                }\r
            else if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
            {\r
-               xMessage.pcMessage = "ERROR: SEMAPHR";\r
+               pcStatusMessage = "An error has been detected in the Semaphore test/demo.";\r
            }\r
            else if( xArePollingQueuesStillRunning() != pdTRUE )\r
            {\r
-               xMessage.pcMessage = "ERROR: POLL Q";\r
+               pcStatusMessage = "An error has been detected in the Poll Queue test/demo.";\r
            }\r
            else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
            {\r
-               xMessage.pcMessage = "ERROR: INT MATH";\r
+               pcStatusMessage = "An error has been detected in the Int Math test/demo.";\r
            }\r
            else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
            {\r
-               xMessage.pcMessage = "ERROR: REC MUTEX";\r
+               pcStatusMessage = "An error has been detected in the Mutex test/demo.";\r
            }\r
-\r
-               /* Send the message to the OLED gatekeeper for display.  The\r
-               xHigherPriorityTaskWoken parameter is not actually used here\r
-               as this function is running in the tick interrupt anyway - but\r
-               it must still be supplied. */\r
-               xHigherPriorityTaskWoken = pdFALSE;\r
-               xQueueSendFromISR( xLCDQueue, &xMessage, &xHigherPriorityTaskWoken );\r
-\r
-               /* Also toggle and LED.  This can be done from here because in this port\r
-               the LED toggling functions don't use critical sections. */\r
-        vParTestToggleLED( mainCHECK_TASK_LED );\r
        }\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+char *pcGetTaskStatusMessage( void )\r
+{\r
+       /* Not bothered about a critical section here. */\r
+       return pcStatusMessage;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
 void prvSetupHardware( void )\r
 {\r
        /* Disable peripherals power. */\r
@@ -372,7 +302,7 @@ const unsigned long TCR_COUNT_RESET = 2, CTCR_CTM_TIMER = 0x00, TCR_COUNT_ENABLE
        collecting run time statistical information - basically the percentage\r
        of CPU time that each task is utilising.  It is called automatically when\r
        the scheduler is started (assuming configGENERATE_RUN_TIME_STATS is set\r
-       to 1. */\r
+       to 1). */\r
 \r
        /* Power up and feed the timer. */\r
        SC->PCONP |= 0x02UL;\r