]> git.sur5r.net Git - freertos/blobdiff - Demo/WIN32-MSVC/main.c
Move the MSVC/lwIP code into the main line.
[freertos] / Demo / WIN32-MSVC / main.c
index 8eee4938117236cb489c374ea95cb3ad19ad1c81..6aa0e3270dad056b209e28578e86af7a3eae820b 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V7.0.0 - Copyright (C) 2011 Real Time Engineers Ltd.\r
+    FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.\r
        \r
 \r
     ***************************************************************************\r
@@ -86,6 +86,8 @@
 #include <FreeRTOS.h>\r
 #include "task.h"\r
 #include "queue.h"\r
+#include "timers.h"\r
+#include "semphr.h"\r
 \r
 /* Standard demo includes. */\r
 #include "BlockQ.h"\r
 /* Task function prototypes. */\r
 static void prvCheckTask( void *pvParameters );\r
 \r
+/* The variable into which error messages are latched. */\r
+static char *pcStatusMessage = "OK";\r
+\r
+/* This semaphore is created purely to test using the vSemaphoreDelete() API\r
+function.  It has no other purpose. */\r
+static xSemaphoreHandle xSemaphoreToDelete = NULL;\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 int main( void )\r
@@ -135,6 +144,10 @@ int main( void )
        vStartTimerDemoTask( mainTIMER_TEST_PERIOD );\r
        vStartCountingSemaphoreTasks();\r
 \r
+       /* Create the semaphore that will be deleted in the idle task hook.  This\r
+       is done purely to test the use of vSemaphoreDelete(). */\r
+       xSemaphoreToDelete = xSemaphoreCreateMutex();\r
+\r
        /* Start the scheduler itself. */\r
        vTaskStartScheduler();\r
 \r
@@ -148,7 +161,6 @@ static void prvCheckTask( void *pvParameters )
 {\r
 portTickType xNextWakeTime;\r
 const portTickType xCycleFrequency = 1000 / portTICK_RATE_MS;\r
-char *pcStatusMessage = "OK";\r
 \r
        /* Just to remove compiler warning. */\r
        ( void ) pvParameters;\r
@@ -213,10 +225,41 @@ char *pcStatusMessage = "OK";
 void vApplicationIdleHook( void )\r
 {\r
 const unsigned long ulMSToSleep = 5;\r
+xTaskHandle xIdleTaskHandle, xTimerTaskHandle;\r
+signed char *pcTaskName;\r
 \r
        /* Sleep to reduce CPU load, but don't sleep indefinitely in case there are\r
        tasks waiting to be terminated by the idle task. */\r
        Sleep( ulMSToSleep );\r
+\r
+       /* Demonstrate the use of the xTimerGetTimerTaskHandle() and \r
+       xTaskGetIdleTaskHandle() functions. */\r
+       xIdleTaskHandle = xTaskGetIdleTaskHandle();\r
+       xTimerTaskHandle = xTimerGetTimerTaskHandle();\r
+\r
+       /* This is the idle hook, so the current task handle should equal the \r
+       returned idle task handle. */\r
+       if( xTaskGetCurrentTaskHandle() != xIdleTaskHandle )\r
+       {\r
+               pcStatusMessage = "Error:  Returned idle task handle was incorrect";\r
+       }\r
+\r
+       /* Check the timer task handle was returned correctly. */\r
+       pcTaskName = pcTaskGetTaskName( xTimerTaskHandle );\r
+       if( strcmp( pcTaskName, "Tmr Svc" ) != 0 )\r
+       {\r
+               pcStatusMessage = "Error:  Returned timer task handle was incorrect";\r
+       }\r
+\r
+       /* If xSemaphoreToDelete has not already been deleted, then delete it now.\r
+       This is done purely to demonstrate the use of, and test, the \r
+       vSemaphoreDelete() macro.  Care must be taken not to delete a semaphore\r
+       that has tasks blocked on it. */\r
+       if( xSemaphoreToDelete != NULL )\r
+       {\r
+               vSemaphoreDelete( xSemaphoreToDelete );\r
+               xSemaphoreToDelete = NULL;\r
+       }\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r