]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/WIN32-MingW/main_full.c
Update version number to 9.0.0rc2.
[freertos] / FreeRTOS / Demo / WIN32-MingW / main_full.c
index dcc496bf6cb0b5af9d823724c5259fda5dc21508..9aaedfce030559bf58b69fb875a541a13ad6086d 100644 (file)
@@ -1,60 +1,64 @@
 /*\r
-    FreeRTOS V8.0.0:rc1 - Copyright (C) 2014 Real Time Engineers Ltd.\r
+    FreeRTOS V9.0.0rc2 - Copyright (C) 2016 Real Time Engineers Ltd.\r
     All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
 \r
-    ***************************************************************************\r
-     *                                                                       *\r
-     *    FreeRTOS provides completely free yet professionally developed,    *\r
-     *    robust, strictly quality controlled, supported, and cross          *\r
-     *    platform software that has become a de facto standard.             *\r
-     *                                                                       *\r
-     *    Help yourself get started quickly and support the FreeRTOS         *\r
-     *    project by purchasing a FreeRTOS tutorial book, reference          *\r
-     *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
-     *                                                                       *\r
-     *    Thank you!                                                         *\r
-     *                                                                       *\r
-    ***************************************************************************\r
-\r
     This file is part of the FreeRTOS distribution.\r
 \r
     FreeRTOS is free software; you can redistribute it and/or modify it under\r
     the terms of the GNU General Public License (version 2) as published by the\r
-    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+    Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.\r
 \r
-    >>! NOTE: The modification to the GPL is included to allow you to distribute\r
-    >>! a combined work that includes FreeRTOS without being obliged to provide\r
-    >>! the source code for proprietary components outside of the FreeRTOS\r
-    >>! kernel.\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
 \r
     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
-    FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
     link: http://www.freertos.org/a00114.html\r
 \r
-    1 tab == 4 spaces!\r
-\r
     ***************************************************************************\r
      *                                                                       *\r
-     *    Having a problem?  Start by reading the FAQ "My application does   *\r
-     *    not run, what could be wrong?"                                     *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
      *                                                                       *\r
-     *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
      *                                                                       *\r
     ***************************************************************************\r
 \r
-    http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
-    license and Real Time Engineers Ltd. contact details.\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
 \r
     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
 \r
-    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
-    Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
-    licenses offer ticketed support, indemnification and middleware.\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
 \r
     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
     engineered and independently SIL3 certified version for use in safety and\r
 #include "QueueSet.h"\r
 #include "QueueOverwrite.h"\r
 #include "EventGroupsDemo.h"\r
+#include "IntSemTest.h"\r
+#include "TaskNotify.h"\r
+#include "QueueSetPolling.h"\r
+#include "blocktim.h"\r
+#include "AbortDelay.h"\r
 \r
 /* Priorities at which the tasks are created. */\r
 #define mainCHECK_TASK_PRIORITY                        ( configMAX_PRIORITIES - 2 )\r
@@ -162,7 +171,7 @@ static void prvTestTask( void *pvParameters );
 static void prvDemonstrateTaskStateAndHandleGetFunctions( void );\r
 \r
 /*\r
- * Called from the idle task hook function to demonstrate the use of \r
+ * Called from the idle task hook function to demonstrate the use of\r
  * xTimerPendFunctionCall() as xTimerPendFunctionCall() is not demonstrated by\r
  * any of the standard demo tasks.\r
  */\r
@@ -185,7 +194,7 @@ static char *pcStatusMessage = "OK";
 \r
 /* This semaphore is created purely to test using the vSemaphoreDelete() and\r
 semaphore tracing API functions.  It has no other purpose. */\r
-static xSemaphoreHandle xMutexToDelete = NULL;\r
+static SemaphoreHandle_t xMutexToDelete = NULL;\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -195,6 +204,7 @@ int main_full( void )
        xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
 \r
        /* Create the standard demo tasks. */\r
+       vStartTaskNotifyTask();\r
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
        vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
        vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
@@ -209,6 +219,10 @@ int main_full( void )
        vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );\r
        xTaskCreate( prvDemoQueueSpaceFunctions, "QSpace", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
        vStartEventGroupTasks();\r
+       vStartInterruptSemaphoreTasks();\r
+       vStartQueueSetPollingTask();\r
+       vCreateBlockTimeTasks();\r
+       vCreateAbortDelayTasks();\r
 \r
        #if( configUSE_PREEMPTION != 0  )\r
        {\r
@@ -230,16 +244,16 @@ int main_full( void )
        /* Start the scheduler itself. */\r
        vTaskStartScheduler();\r
 \r
-    /* Should never get here unless there was not enough heap space to create\r
+       /* Should never get here unless there was not enough heap space to create\r
        the idle and other system tasks. */\r
-    return 0;\r
+       return 0;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 static void prvCheckTask( void *pvParameters )\r
 {\r
-portTickType xNextWakeTime;\r
-const portTickType xCycleFrequency = 2500 / portTICK_RATE_MS;\r
+TickType_t xNextWakeTime;\r
+const TickType_t xCycleFrequency = pdMS_TO_TICKS( 2500UL );\r
 \r
        /* Just to remove compiler warning. */\r
        ( void ) pvParameters;\r
@@ -263,7 +277,16 @@ const portTickType xCycleFrequency = 2500 / portTICK_RATE_MS;
                }\r
                #endif\r
 \r
-               if( xAreEventGroupTasksStillRunning() != pdTRUE )\r
+               if( xAreTaskNotificationTasksStillRunning() != pdTRUE )\r
+               {\r
+                       pcStatusMessage = "Error:  Notification";\r
+               }\r
+\r
+               if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )\r
+               {\r
+                       pcStatusMessage = "Error: IntSem";\r
+               }\r
+               else if( xAreEventGroupTasksStillRunning() != pdTRUE )\r
                {\r
                        pcStatusMessage = "Error: EventGroup";\r
                }\r
@@ -319,6 +342,18 @@ const portTickType xCycleFrequency = 2500 / portTICK_RATE_MS;
                {\r
                        pcStatusMessage = "Error: Queue overwrite";\r
                }\r
+               else if( xAreQueueSetPollTasksStillRunning() != pdPASS )\r
+               {\r
+                       pcStatusMessage = "Error: Queue set polling";\r
+               }\r
+               else if( xAreBlockTimeTestTasksStillRunning() != pdPASS )\r
+               {\r
+                       pcStatusMessage = "Error: Block time";\r
+               }\r
+               else if( xAreAbortDelayTestTasksStillRunning() != pdPASS )\r
+               {\r
+                       pcStatusMessage = "Error: Abort delay";\r
+               }\r
 \r
                /* This is the only task that uses stdout so its ok to call printf()\r
                directly. */\r
@@ -350,17 +385,8 @@ const unsigned long ulMSToSleep = 5;
 void vFullDemoIdleFunction( void )\r
 {\r
 const unsigned long ulMSToSleep = 15;\r
-const unsigned portBASE_TYPE uxConstQueueNumber = 0xaaU;\r
 void *pvAllocated;\r
 \r
-/* These three functions are only meant for use by trace code, and not for\r
-direct use from application code, hence their prototypes are not in queue.h. */\r
-extern void vQueueSetQueueNumber( xQueueHandle pxQueue, unsigned portBASE_TYPE uxQueueNumber );\r
-extern unsigned portBASE_TYPE uxQueueGetQueueNumber( xQueueHandle pxQueue );\r
-extern uint8_t ucQueueGetQueueType( xQueueHandle pxQueue );\r
-extern void vTaskSetTaskNumber( xTaskHandle xTask, unsigned portBASE_TYPE uxHandle );\r
-extern unsigned portBASE_TYPE uxTaskGetTaskNumber( xTaskHandle xTask );\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
@@ -379,21 +405,11 @@ extern unsigned portBASE_TYPE uxTaskGetTaskNumber( xTaskHandle xTask );
        that has tasks blocked on it. */\r
        if( xMutexToDelete != NULL )\r
        {\r
-               /* Before deleting the semaphore, test the function used to set its\r
-               number.  This would normally only be done from trace software, rather\r
-               than application code. */\r
-               vQueueSetQueueNumber( xMutexToDelete, uxConstQueueNumber );\r
-\r
-               /* Before deleting the semaphore, test the functions used to get its\r
-               type and number.  Again, these would normally only be done from trace\r
-               software, rather than application code. */\r
-               configASSERT( uxQueueGetQueueNumber( xMutexToDelete ) == uxConstQueueNumber );\r
-               configASSERT( ucQueueGetQueueType( xMutexToDelete ) == queueQUEUE_TYPE_MUTEX );\r
                vSemaphoreDelete( xMutexToDelete );\r
                xMutexToDelete = NULL;\r
        }\r
 \r
-       /* Exercise heap_4 a bit.  The malloc failed hook will trap failed\r
+       /* Exercise heap_5 a bit.  The malloc failed hook will trap failed\r
        allocations so there is no need to test here. */\r
        pvAllocated = pvPortMalloc( ( rand() % 100 ) + 1 );\r
        vPortFree( pvAllocated );\r
@@ -418,9 +434,16 @@ void vFullDemoTickHookFunction( void )
        /* Write to a queue that is in use as part of the queue set demo to\r
        demonstrate using queue sets from an ISR. */\r
        vQueueSetAccessQueueSetFromISR();\r
+       vQueueSetPollingInterruptAccess();\r
 \r
        /* Exercise event groups from interrupts. */\r
        vPeriodicEventGroupsProcessing();\r
+\r
+       /* Exercise giving mutexes from an interrupt. */\r
+       vInterruptSemaphorePeriodicTest();\r
+\r
+       /* Exercise using task notifications from an interrupt. */\r
+       xNotifyTaskFromISR();\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -458,19 +481,16 @@ const TickType_t xDontBlock = 0; /* This is called from the idle task so must *n
 \r
 static void prvDemonstrateTaskStateAndHandleGetFunctions( void )\r
 {\r
-xTaskHandle xIdleTaskHandle, xTimerTaskHandle;\r
-const unsigned char ucConstTaskNumber = 0x55U;\r
+TaskHandle_t xIdleTaskHandle, xTimerTaskHandle;\r
 char *pcTaskName;\r
 static portBASE_TYPE xPerformedOneShotTests = pdFALSE;\r
-xTaskHandle xTestTask;\r
+TaskHandle_t xTestTask;\r
 \r
        /* Demonstrate the use of the xTimerGetTimerDaemonTaskHandle() and\r
        xTaskGetIdleTaskHandle() functions.  Also try using the function that sets\r
        the task number. */\r
        xIdleTaskHandle = xTaskGetIdleTaskHandle();\r
        xTimerTaskHandle = xTimerGetTimerDaemonTaskHandle();\r
-       vTaskSetTaskNumber( xIdleTaskHandle, ( unsigned long ) ucConstTaskNumber );\r
-       configASSERT( uxTaskGetTaskNumber( xIdleTaskHandle ) == ucConstTaskNumber );\r
 \r
        /* This is the idle hook, so the current task handle should equal the\r
        returned idle task handle. */\r
@@ -480,7 +500,7 @@ xTaskHandle xTestTask;
        }\r
 \r
        /* Check the timer task handle was returned correctly. */\r
-       pcTaskName = pcTaskGetTaskName( xTimerTaskHandle );\r
+       pcTaskName = pcTaskGetName( xTimerTaskHandle );\r
        if( strcmp( pcTaskName, "Tmr Svc" ) != 0 )\r
        {\r
                pcStatusMessage = "Error:  Returned timer task handle was incorrect";\r
@@ -535,7 +555,7 @@ xTaskHandle xTestTask;
 \r
 static void prvDemoQueueSpaceFunctions( void *pvParameters )\r
 {\r
-xQueueHandle xQueue = NULL;\r
+QueueHandle_t xQueue = NULL;\r
 const unsigned portBASE_TYPE uxQueueLength = 10;\r
 unsigned portBASE_TYPE uxReturn, x;\r
 \r