]> git.sur5r.net Git - freertos/blobdiff - Demo/PC/main.c
Update to V5.0.3.
[freertos] / Demo / PC / main.c
index dfac727b7db78629747d1dc6e0a61ff7de91b115..9c32c6adaf083b6f140ae257c207daa74dd6f16a 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-       FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.\r
+       FreeRTOS.org V5.0.3 - Copyright (C) 2003-2008 Richard Barry.\r
 \r
        This file is part of the FreeRTOS.org distribution.\r
 \r
        of http://www.FreeRTOS.org for full details of how and when the exception\r
        can be applied.\r
 \r
-       ***************************************************************************\r
-       See http://www.FreeRTOS.org for documentation, latest information, license \r
-       and contact details.  Please ensure to read the configuration and relevant \r
-       port sections of the online documentation.\r
+    ***************************************************************************\r
+    ***************************************************************************\r
+    *                                                                         *\r
+    * SAVE TIME AND MONEY!  We can port FreeRTOS.org to your own hardware,    *\r
+    * and even write all or part of your application on your behalf.          *\r
+    * See http://www.OpenRTOS.com for details of the services we provide to   *\r
+    * expedite your project.                                                  *\r
+    *                                                                         *\r
+    ***************************************************************************\r
+    ***************************************************************************\r
 \r
-       Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along\r
-       with commercial development and support options.\r
-       ***************************************************************************\r
+       Please ensure to read the configuration and relevant port sections of the\r
+       online documentation.\r
+\r
+       http://www.FreeRTOS.org - Documentation, latest information, license and \r
+       contact details.\r
+\r
+       http://www.SafeRTOS.com - A version that is certified for use in safety \r
+       critical systems.\r
+\r
+       http://www.OpenRTOS.com - Commercial support, development, porting, \r
+       licensing and training services.\r
 */\r
 \r
 /**\r
  * <HR>\r
  */\r
 \r
-/*\r
-Changes from V1.00:\r
-\r
-       + Prevent the call to kbhit() for debug builds as the debugger seems to\r
-         have problems stepping over the call.\r
-\r
-Changes from V1.2.3\r
-\r
-       + The integer and comtest tasks are now used when the cooperative scheduler \r
-         is being used.  Previously they were only used with the preemptive\r
-         scheduler.\r
-\r
-Changes from V1.2.6\r
-\r
-       + Create new tasks as defined by the new demo application file dynamic.c.\r
-\r
-Changes from V2.0.0\r
-\r
-       + Delay periods are now specified using variables and constants of\r
-         portTickType rather than unsigned portLONG.\r
-\r
-Changes from V3.1.1\r
-\r
-       + The tasks defined in the new file "events.c" are now created and \r
-         monitored for errors. \r
-\r
-Changes from V3.2.4\r
-\r
-       + Now includes the flash co-routine demo rather than the flash task demo.\r
-         This is to demonstrate the co-routine functionality.\r
-*/\r
-\r
 #include <stdlib.h>\r
 #include <conio.h>\r
 #include "FreeRTOS.h"\r
@@ -119,8 +101,14 @@ Changes from V3.2.4
 #include "mevents.h"\r
 #include "crhook.h"\r
 #include "blocktim.h"\r
+#include "AltBlock.h"\r
 #include "GenQTest.h"\r
 #include "QPeek.h"\r
+#include "countsem.h"\r
+#include "AltQTest.h"\r
+#include "AltPollQ.h"\r
+#include "AltBlckQ.h"\r
+#include "RecMutex.h"\r
 \r
 /* Priority definitions for the tasks in the demo application. */\r
 #define mainLED_TASK_PRIORITY          ( tskIDLE_PRIORITY + 1 )\r
@@ -165,6 +153,14 @@ static void prvStartMathTasks( void );
 /* Check which ever tasks are relevant to this build. */\r
 static portBASE_TYPE prvCheckMathTasksAreStillRunning( void );\r
 \r
+/* Used to demonstrate the "task switched in" callback function. */\r
+static portBASE_TYPE prvExampleTaskHook( void * pvParameter );\r
+\r
+/* Just used to count the number of times the example task callback function is\r
+called, and the number of times a queue send passes. */\r
+static unsigned portLONG portLONG uxCheckTaskHookCallCount = 0;\r
+static unsigned portLONG portLONG uxQueueSendPassedCount = 0;\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 portSHORT main( void )\r
@@ -184,7 +180,13 @@ portSHORT main( void )
        vStartDynamicPriorityTasks();\r
        vStartMultiEventTasks();\r
        vStartQueuePeekTasks();\r
-\r
+       vStartCountingSemaphoreTasks();\r
+       vStartAltGenericQueueTasks( mainGENERIC_QUEUE_PRIORITY );\r
+       vCreateAltBlockTimeTasks();\r
+       vStartAltBlockingQueueTasks( mainQUEUE_BLOCK_PRIORITY );        \r
+       vStartAltPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
+       vStartRecursiveMutexTasks();\r
+               \r
        /* Create the "Print" task as described at the top of the file. */\r
        xTaskCreate( vErrorChecks, "Print", mainPRINT_STACK_SIZE, NULL, mainPRINT_TASK_PRIORITY, NULL );\r
 \r
@@ -206,6 +208,31 @@ portSHORT main( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+static portBASE_TYPE prvExampleTaskHook( void * pvParameter )\r
+{\r
+       if( pvParameter != ( void * ) 0xabcd )\r
+       {\r
+               /* The parameter did not contain the value we expected, so cause an\r
+               error to be detected by setting the call count back to zero. */\r
+               uxCheckTaskHookCallCount = 0;\r
+       }\r
+       else\r
+       {\r
+               /* Simply increment a number so we know the callback has been executed. */\r
+               uxCheckTaskHookCallCount++;\r
+       }\r
+\r
+       return 0;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vMainQueueSendPassed( void )\r
+{\r
+       /* This is just an example implementation of the "queue send" trace hook. */\r
+       uxQueueSendPassedCount++;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
 static void vErrorChecks( void *pvParameters )\r
 {\r
 portTickType xExpectedWakeTime;\r
@@ -218,6 +245,9 @@ const portCHAR * const pcTaskBlockedTooLongMsg = "Print task blocked too long!\r
 \r
        ( void ) pvParameters;\r
 \r
+       /* Register our callback function. */\r
+       vTaskSetApplicationTaskTag( NULL, prvExampleTaskHook );\r
+\r
        /* Loop continuously, blocking, then checking all the other tasks are still\r
        running, before blocking once again.  This task blocks on the queue of\r
        messages that require displaying so will wake either by its time out expiring,\r
@@ -328,6 +358,7 @@ portSHORT sIn;
 static void prvCheckOtherTasksAreStillRunning( void )\r
 {\r
 static portSHORT sErrorHasOccurred = pdFALSE;\r
+static unsigned portLONG portLONG uxLastHookCallCount = 0, uxLastQueueSendCount = 0;\r
 \r
        if( prvCheckMathTasksAreStillRunning() != pdTRUE )\r
        {\r
@@ -347,12 +378,24 @@ static portSHORT sErrorHasOccurred = pdFALSE;
                sErrorHasOccurred = pdTRUE;\r
        }\r
 \r
+       if( xAreAltBlockingQueuesStillRunning() != pdTRUE )\r
+       {\r
+               vDisplayMessage( "Alt blocking queues count unchanged!\r\n" );\r
+               sErrorHasOccurred = pdTRUE;\r
+       }\r
+\r
        if( xArePollingQueuesStillRunning() != pdTRUE )\r
        {\r
                vDisplayMessage( "Polling queue count unchanged!\r\n" );\r
                sErrorHasOccurred = pdTRUE;\r
        }\r
 \r
+       if( xAreAltPollingQueuesStillRunning() != pdTRUE )\r
+       {\r
+               vDisplayMessage( "Alt polling queue count unchanged!\r\n" );\r
+               sErrorHasOccurred = pdTRUE;\r
+       }\r
+\r
        if( xIsCreateTaskStillRunning() != pdTRUE )\r
        {\r
                vDisplayMessage( "Incorrect number of tasks running!\r\n" );\r
@@ -395,18 +438,68 @@ static portSHORT sErrorHasOccurred = pdFALSE;
                sErrorHasOccurred = pdTRUE;\r
        }\r
 \r
+       if( xAreAltBlockTimeTestTasksStillRunning() != pdTRUE )\r
+       {\r
+               vDisplayMessage( "Error in fast block time test tasks!\r\n" );\r
+               sErrorHasOccurred = pdTRUE;\r
+       }\r
+\r
        if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
        {\r
                vDisplayMessage( "Error in generic queue test task!\r\n" );\r
                sErrorHasOccurred = pdTRUE;             \r
        }\r
 \r
+       if( xAreAltGenericQueueTasksStillRunning() != pdTRUE )\r
+       {\r
+               vDisplayMessage( "Error in fast generic queue test task!\r\n" );\r
+               sErrorHasOccurred = pdTRUE;             \r
+       }\r
+\r
        if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
        {\r
                vDisplayMessage( "Error in queue peek test task!\r\n" );\r
                sErrorHasOccurred = pdTRUE;\r
        }\r
 \r
+       if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )\r
+       {\r
+               vDisplayMessage( "Error in counting semaphore demo task!\r\n" );\r
+               sErrorHasOccurred = pdTRUE;\r
+       }\r
+\r
+       if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
+       {\r
+               vDisplayMessage( "Error in recursive mutex tasks!\r\n" );\r
+               sErrorHasOccurred = pdTRUE;\r
+       }\r
+\r
+       /* The hook function associated with this task is called each time the task\r
+       is switched in.  We therefore expect the number of times the callback \r
+       function has been executed to have increrment since the last time this \r
+       function executed. */\r
+       if( uxCheckTaskHookCallCount <= uxLastHookCallCount )\r
+       {\r
+               vDisplayMessage( "Error in task hook call count!\r\n" );\r
+               sErrorHasOccurred = pdTRUE;\r
+       }\r
+       else\r
+       {\r
+               uxLastHookCallCount = uxCheckTaskHookCallCount;\r
+       }\r
+\r
+       /* We would expect some queue sending to occur between calls of this \r
+       function. */\r
+       if( uxQueueSendPassedCount <= uxLastQueueSendCount )\r
+       {\r
+               vDisplayMessage( "Error in queue send hook call count!\r\n" );\r
+               sErrorHasOccurred = pdTRUE;\r
+       }\r
+       else\r
+       {\r
+               uxLastQueueSendCount = uxQueueSendPassedCount;\r
+       }\r
+\r
        if( sErrorHasOccurred == pdFALSE )\r
        {\r
                vDisplayMessage( "OK " );\r