]> git.sur5r.net Git - freertos/blobdiff - Demo/PC/main.c
Update to V5.0.2
[freertos] / Demo / PC / main.c
index f6aae3a0e00fab19c1834d9a9bcb4dde93835e6a..012d05091ab3ca47f46c3cc517e195e1e39238f4 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-       FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.\r
+       FreeRTOS.org V5.0.2 - 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
-\r
-       Please ensure to read the configuration and relevant port sections of the \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
+       Please ensure to read the configuration and relevant port sections of the\r
        online documentation.\r
 \r
-       +++ http://www.FreeRTOS.org +++\r
-       Documentation, latest information, license and contact details.  \r
-\r
-       +++ http://www.SafeRTOS.com +++\r
-       A version that is certified for use in safety critical systems.\r
+       http://www.FreeRTOS.org - Documentation, latest information, license and \r
+       contact details.\r
 \r
-       +++ http://www.OpenRTOS.com +++\r
-       Commercial support, development, porting, licensing and training services.\r
+       http://www.SafeRTOS.com - A version that is certified for use in safety \r
+       critical systems.\r
 \r
-       ***************************************************************************\r
+       http://www.OpenRTOS.com - Commercial support, development, porting, \r
+       licensing and training services.\r
 */\r
 \r
 /**\r
@@ -146,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
@@ -193,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
@@ -205,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
@@ -315,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
@@ -430,6 +474,32 @@ static portSHORT sErrorHasOccurred = pdFALSE;
                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