]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/Common/Minimal/QueueSet.c
Update version number to 8.1.2 after moving the defaulting of configUSE_PORT_OPTIMISE...
[freertos] / FreeRTOS / Demo / Common / Minimal / QueueSet.c
index 1b8dec6de57244c3a1956e70e66b9df9443d0d51..969606c8f045f87014b267f1f6752f159136099c 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. \r
+    FreeRTOS V8.1.2 - Copyright (C) 2014 Real Time Engineers Ltd. \r
     All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\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
 \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
+    >>!   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
     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
@@ -118,7 +118,7 @@ queuesetPRIORITY_CHANGE_LOOPS number of values are sent to a queue. */
 /* A delay inserted when the Tx task changes its priority to be above the idle\r
 task priority to ensure the idle priority tasks get some CPU time before the\r
 next iteration of the queue set Tx task. */\r
-#define queuesetTX_LOOP_DELAY  ( 200 / portTICK_RATE_MS )\r
+#define queuesetTX_LOOP_DELAY  ( 200 / portTICK_PERIOD_MS )\r
 \r
 /* The allowable maximum deviation between a received value and the expected\r
 received value.  A deviation will occur when data is received from a queue\r
@@ -153,7 +153,7 @@ static void prvQueueSetReceivingTask( void *pvParameters );
  * range of the value being used to distinguish between the two message\r
  * sources.\r
  */\r
-static void prvCheckReceivedValue( unsigned long ulReceived );\r
+static void prvCheckReceivedValue( uint32_t ulReceived );\r
 \r
 /*\r
  * For purposes of test coverage, functions that read from and write to a\r
@@ -172,7 +172,7 @@ static void prvSetupTest( void );
  * Checks a value received from a queue falls within the range of expected\r
  * values.\r
  */\r
-static portBASE_TYPE prvCheckReceivedValueWithinExpectedRange( unsigned long ulReceived, unsigned long ulExpectedReceived );\r
+static BaseType_t prvCheckReceivedValueWithinExpectedRange( uint32_t ulReceived, uint32_t ulExpectedReceived );\r
 \r
 /*\r
  * Increase test coverage by occasionally change the priorities of the two tasks\r
@@ -183,54 +183,54 @@ static void prvChangeRelativePriorities( void );
  * Local pseudo random number seed and return functions.  Used to avoid calls\r
  * to the standard library.\r
  */\r
-static unsigned long prvRand( void );\r
-static void prvSRand( unsigned long ulSeed );\r
+static uint32_t prvRand( void );\r
+static void prvSRand( uint32_t ulSeed );\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
 /* The queues that are added to the set. */\r
-static xQueueHandle xQueues[ queuesetNUM_QUEUES_IN_SET ] = { 0 };\r
+static QueueHandle_t xQueues[ queuesetNUM_QUEUES_IN_SET ] = { 0 };\r
 \r
 /* Counts how many times each queue in the set is used to ensure all the\r
 queues are used. */\r
-static unsigned long ulQueueUsedCounter[ queuesetNUM_QUEUES_IN_SET ] = { 0 };\r
+static uint32_t ulQueueUsedCounter[ queuesetNUM_QUEUES_IN_SET ] = { 0 };\r
 \r
 /* The handle of the queue set to which the queues are added. */\r
-static xQueueSetHandle xQueueSet;\r
+static QueueSetHandle_t xQueueSet;\r
 \r
 /* If the prvQueueSetReceivingTask() task has not detected any errors then\r
 it increments ulCycleCounter on each iteration.\r
 xAreQueueSetTasksStillRunning() returns pdPASS if the value of\r
 ulCycleCounter has changed between consecutive calls, and pdFALSE if\r
 ulCycleCounter has stopped incrementing (indicating an error condition). */\r
-static volatile unsigned long ulCycleCounter = 0UL;\r
+static volatile uint32_t ulCycleCounter = 0UL;\r
 \r
 /* Set to pdFAIL if an error is detected by any queue set task.\r
 ulCycleCounter will only be incremented if xQueueSetTasksSatus equals pdPASS. */\r
-static volatile portBASE_TYPE xQueueSetTasksStatus = pdPASS;\r
+static volatile BaseType_t xQueueSetTasksStatus = pdPASS;\r
 \r
 /* Just a flag to let the function that writes to a queue from an ISR know that\r
 the queues are setup and can be used. */\r
-static volatile portBASE_TYPE xSetupComplete = pdFALSE;\r
+static volatile BaseType_t xSetupComplete = pdFALSE;\r
 \r
 /* The value sent to the queue from the ISR is file scope so the\r
 xAreQueeuSetTasksStillRunning() function can check it is incrementing as\r
 expected. */\r
-static volatile unsigned long ulISRTxValue = queuesetINITIAL_ISR_TX_VALUE;\r
+static volatile uint32_t ulISRTxValue = queuesetINITIAL_ISR_TX_VALUE;\r
 \r
 /* Used by the pseudo random number generator. */\r
-static unsigned long ulNextRand = 0;\r
+static uint32_t ulNextRand = 0;\r
 \r
 /* The task handles are stored so their priorities can be changed. */\r
-xTaskHandle xQueueSetSendingTask, xQueueSetReceivingTask;\r
+TaskHandle_t xQueueSetSendingTask, xQueueSetReceivingTask;\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
 void vStartQueueSetTasks( void )\r
 {\r
        /* Create the tasks. */\r
-       xTaskCreate( prvQueueSetSendingTask, ( signed char * ) "SetTx", configMINIMAL_STACK_SIZE, NULL, queuesetMEDIUM_PRIORITY, &xQueueSetSendingTask );\r
-       xTaskCreate( prvQueueSetReceivingTask, ( signed char * ) "SetRx", configMINIMAL_STACK_SIZE, ( void * ) xQueueSetSendingTask, queuesetMEDIUM_PRIORITY, &xQueueSetReceivingTask );\r
+       xTaskCreate( prvQueueSetSendingTask, "SetTx", configMINIMAL_STACK_SIZE, NULL, queuesetMEDIUM_PRIORITY, &xQueueSetSendingTask );\r
+       xTaskCreate( prvQueueSetReceivingTask, "SetRx", configMINIMAL_STACK_SIZE, ( void * ) xQueueSetSendingTask, queuesetMEDIUM_PRIORITY, &xQueueSetReceivingTask );\r
 \r
        /* It is important that the sending task does not attempt to write to a\r
        queue before the queue has been created.  It is therefore placed into the\r
@@ -241,11 +241,11 @@ void vStartQueueSetTasks( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-portBASE_TYPE xAreQueueSetTasksStillRunning( void )\r
+BaseType_t xAreQueueSetTasksStillRunning( void )\r
 {\r
-static unsigned long ulLastCycleCounter, ulLastISRTxValue = 0;\r
-static unsigned long ulLastQueueUsedCounter[ queuesetNUM_QUEUES_IN_SET ] = { 0 };\r
-portBASE_TYPE xReturn = pdPASS, x;\r
+static uint32_t ulLastCycleCounter, ulLastISRTxValue = 0;\r
+static uint32_t ulLastQueueUsedCounter[ queuesetNUM_QUEUES_IN_SET ] = { 0 };\r
+BaseType_t xReturn = pdPASS, x;\r
 \r
        if( ulLastCycleCounter == ulCycleCounter )\r
        {\r
@@ -291,14 +291,14 @@ portBASE_TYPE xReturn = pdPASS, x;
 \r
 static void prvQueueSetSendingTask( void *pvParameters )\r
 {\r
-unsigned long ulTaskTxValue = 0, ulQueueToWriteTo;\r
-xQueueHandle xQueueInUse;\r
+uint32_t ulTaskTxValue = 0, ulQueueToWriteTo;\r
+QueueHandle_t xQueueInUse;\r
 \r
        /* Remove compiler warning about the unused parameter. */\r
        ( void ) pvParameters;\r
 \r
        /* Seed mini pseudo random number generator. */\r
-       prvSRand( ( unsigned long ) &ulTaskTxValue );\r
+       prvSRand( ( uint32_t ) &ulTaskTxValue );\r
 \r
        for( ;; )\r
        {\r
@@ -319,6 +319,10 @@ xQueueHandle xQueueInUse;
                        xQueueSetTasksStatus = pdFAIL;\r
                }\r
 \r
+               #if( configUSE_PREEMPTION == 0 )\r
+                       taskYIELD();\r
+               #endif\r
+\r
                ulTaskTxValue++;\r
 \r
                /* If the Tx value has reached the range used by the ISR then set it\r
@@ -337,7 +341,7 @@ xQueueHandle xQueueInUse;
 \r
 static void prvChangeRelativePriorities( void )\r
 {\r
-static unsigned portBASE_TYPE ulLoops = 0;\r
+static UBaseType_t ulLoops = 0;\r
 static eRelativePriorities ePriorities = eEqualPriority;\r
 \r
        /* Occasionally change the task priority relative to the priority of\r
@@ -385,8 +389,8 @@ static eRelativePriorities ePriorities = eEqualPriority;
 \r
 static void prvQueueSetReceivingTask( void *pvParameters )\r
 {\r
-unsigned long ulReceived;\r
-xQueueHandle xActivatedQueue;\r
+uint32_t ulReceived;\r
+QueueHandle_t xActivatedQueue;\r
 \r
        /* Remove compiler warnings. */\r
        ( void ) pvParameters;\r
@@ -436,7 +440,7 @@ xQueueHandle xActivatedQueue;
 \r
 void vQueueSetAccessQueueSetFromISR( void )\r
 {\r
-static unsigned long ulCallCount = 0;\r
+static uint32_t ulCallCount = 0;\r
 \r
        /* xSetupComplete is set to pdTRUE when the queues have been created and\r
        are available for use. */\r
@@ -459,9 +463,9 @@ static unsigned long ulCallCount = 0;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvCheckReceivedValue( unsigned long ulReceived )\r
+static void prvCheckReceivedValue( uint32_t ulReceived )\r
 {\r
-static unsigned long ulExpectedReceivedFromTask = 0, ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;\r
+static uint32_t ulExpectedReceivedFromTask = 0, ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;\r
 \r
        /* Values are received in tasks and interrupts.  It is likely that the\r
        receiving task will sometimes get preempted by the receiving interrupt\r
@@ -539,9 +543,9 @@ static unsigned long ulExpectedReceivedFromTask = 0, ulExpectedReceivedFromISR =
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static portBASE_TYPE prvCheckReceivedValueWithinExpectedRange( unsigned long ulReceived, unsigned long ulExpectedReceived )\r
+static BaseType_t prvCheckReceivedValueWithinExpectedRange( uint32_t ulReceived, uint32_t ulExpectedReceived )\r
 {\r
-portBASE_TYPE xReturn = pdPASS;\r
+BaseType_t xReturn = pdPASS;\r
 \r
        if( ulReceived > ulExpectedReceived )\r
        {\r
@@ -566,8 +570,8 @@ portBASE_TYPE xReturn = pdPASS;
 \r
 static void prvReceiveFromQueueInSetFromISR( void )\r
 {\r
-xQueueSetMemberHandle xActivatedQueue;\r
-unsigned long ulReceived;\r
+QueueSetMemberHandle_t xActivatedQueue;\r
+uint32_t ulReceived;\r
 \r
        /* See if any of the queues in the set contain data. */\r
        xActivatedQueue = xQueueSelectFromSetFromISR( xQueueSet );\r
@@ -590,7 +594,7 @@ unsigned long ulReceived;
 \r
 static void prvSendToQueueInSetFromISR( void )\r
 {\r
-static portBASE_TYPE xQueueToWriteTo = 0;\r
+static BaseType_t xQueueToWriteTo = 0;\r
 \r
        if( xQueueSendFromISR( xQueues[ xQueueToWriteTo ], ( void * ) &ulISRTxValue, NULL ) == pdPASS )\r
        {\r
@@ -615,8 +619,8 @@ static portBASE_TYPE xQueueToWriteTo = 0;
 \r
 static void prvSetupTest( void )\r
 {\r
-portBASE_TYPE x;\r
-unsigned long ulValueToSend = 0;\r
+BaseType_t x;\r
+uint32_t ulValueToSend = 0;\r
 \r
        /* Ensure the queues are created and the queue set configured before the\r
        sending task is unsuspended.\r
@@ -628,8 +632,8 @@ unsigned long ulValueToSend = 0;
        for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )\r
        {\r
                /* Create the queue and add it to the set.  The queue is just holding\r
-               unsigned long value. */\r
-               xQueues[ x ] = xQueueCreate( queuesetQUEUE_LENGTH, sizeof( unsigned long ) );\r
+               uint32_t value. */\r
+               xQueues[ x ] = xQueueCreate( queuesetQUEUE_LENGTH, sizeof( uint32_t ) );\r
                configASSERT( xQueues[ x ] );\r
                if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdPASS )\r
                {\r
@@ -697,14 +701,14 @@ unsigned long ulValueToSend = 0;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static unsigned long prvRand( void )\r
+static uint32_t prvRand( void )\r
 {\r
        ulNextRand = ( ulNextRand * 1103515245UL ) + 12345UL;\r
     return ( ulNextRand / 65536UL ) % 32768UL;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvSRand( unsigned long ulSeed )\r
+static void prvSRand( uint32_t ulSeed )\r
 {\r
     ulNextRand = ulSeed;\r
 }\r