2 FreeRTOS V8.0.1 - Copyright (C) 2014 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 ***************************************************************************
\r
9 * FreeRTOS provides completely free yet professionally developed, *
\r
10 * robust, strictly quality controlled, supported, and cross *
\r
11 * platform software that has become a de facto standard. *
\r
13 * Help yourself get started quickly and support the FreeRTOS *
\r
14 * project by purchasing a FreeRTOS tutorial book, reference *
\r
15 * manual, or both from: http://www.FreeRTOS.org/Documentation *
\r
19 ***************************************************************************
\r
21 This file is part of the FreeRTOS distribution.
\r
23 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
24 the terms of the GNU General Public License (version 2) as published by the
\r
25 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
\r
27 >>! NOTE: The modification to the GPL is included to allow you to !<<
\r
28 >>! distribute a combined work that includes FreeRTOS without being !<<
\r
29 >>! obliged to provide the source code for proprietary components !<<
\r
30 >>! outside of the FreeRTOS kernel. !<<
\r
32 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
33 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
34 FOR A PARTICULAR PURPOSE. Full license text is available from the following
\r
35 link: http://www.freertos.org/a00114.html
\r
39 ***************************************************************************
\r
41 * Having a problem? Start by reading the FAQ "My application does *
\r
42 * not run, what could be wrong?" *
\r
44 * http://www.FreeRTOS.org/FAQHelp.html *
\r
46 ***************************************************************************
\r
48 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
\r
49 license and Real Time Engineers Ltd. contact details.
\r
51 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
52 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
53 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
55 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
\r
56 Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
57 licenses offer ticketed support, indemnification and middleware.
\r
59 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
60 engineered and independently SIL3 certified version for use in safety and
\r
61 mission critical applications that require provable dependability.
\r
67 * Tests the use of queue sets.
\r
69 * A receive task creates a number of queues and adds them to a queue set before
\r
70 * blocking on the queue set receive. A transmit task and (optionally) an
\r
71 * interrupt repeatedly unblocks the receive task by sending messages to the
\r
72 * queues in a pseudo random order. The receive task removes the messages from
\r
73 * the queues and flags an error if the received message does not match that
\r
74 * expected. The task sends values in the range 0 to
\r
75 * queuesetINITIAL_ISR_TX_VALUE, and the ISR sends value in the range
\r
76 * queuesetINITIAL_ISR_TX_VALUE to ULONG_MAX.
\r
80 /* Standard includes. */
\r
84 /* Kernel includes. */
\r
85 #include "FreeRTOS.h"
\r
89 /* Demo includes. */
\r
90 #include "QueueSet.h"
\r
92 /* The number of queues that are created and added to the queue set. */
\r
93 #define queuesetNUM_QUEUES_IN_SET 3
\r
95 /* The length of each created queue. */
\r
96 #define queuesetQUEUE_LENGTH 3
\r
98 /* Block times used in this demo. A block time or 0 means "don't block". */
\r
99 #define queuesetSHORT_DELAY 200
\r
100 #define queuesetDONT_BLOCK 0
\r
102 /* Messages are sent in incrementing order from both a task and an interrupt.
\r
103 The task sends values in the range 0 to 0xfffe, and the interrupt sends values
\r
104 in the range of 0xffff to ULONG_MAX. */
\r
105 #define queuesetINITIAL_ISR_TX_VALUE 0xffffUL
\r
107 /* The priorities used in this demo. */
\r
108 #define queuesetLOW_PRIORITY ( tskIDLE_PRIORITY )
\r
109 #define queuesetMEDIUM_PRIORITY ( queuesetLOW_PRIORITY + 1 )
\r
111 /* For test purposes the priority of the sending task is changed after every
\r
112 queuesetPRIORITY_CHANGE_LOOPS number of values are sent to a queue. */
\r
113 #define queuesetPRIORITY_CHANGE_LOOPS ( ( queuesetNUM_QUEUES_IN_SET * queuesetQUEUE_LENGTH ) * 2 )
\r
115 /* The ISR sends to the queue every queuesetISR_TX_PERIOD ticks. */
\r
116 #define queuesetISR_TX_PERIOD ( 100UL )
\r
118 /* A delay inserted when the Tx task changes its priority to be above the idle
\r
119 task priority to ensure the idle priority tasks get some CPU time before the
\r
120 next iteration of the queue set Tx task. */
\r
121 #define queuesetTX_LOOP_DELAY ( 200 / portTICK_PERIOD_MS )
\r
123 /* The allowable maximum deviation between a received value and the expected
\r
124 received value. A deviation will occur when data is received from a queue
\r
125 inside an ISR in between a task receiving from a queue and the task checking
\r
126 the received value. */
\r
127 #define queuesetALLOWABLE_RX_DEVIATION 3
\r
129 /* Ignore values that are at the boundaries of allowable values to make the
\r
130 testing of limits easier (don't have to deal with wrapping values). */
\r
131 #define queuesetIGNORED_BOUNDARY ( queuesetALLOWABLE_RX_DEVIATION * 2 )
\r
135 eEqualPriority = 0, /* Tx and Rx tasks have the same priority. */
\r
136 eTxHigherPriority, /* The priority of the Tx task is above that of the Rx task. */
\r
137 eTxLowerPriority /* The priority of the Tx task is below that of the Rx task. */
\r
138 } eRelativePriorities;
\r
141 * The task that periodically sends to the queue set.
\r
143 static void prvQueueSetSendingTask( void *pvParameters );
\r
146 * The task that reads from the queue set.
\r
148 static void prvQueueSetReceivingTask( void *pvParameters );
\r
151 * Check the value received from a queue is the expected value. Some values
\r
152 * originate from the send task, some values originate from the ISR, with the
\r
153 * range of the value being used to distinguish between the two message
\r
156 static void prvCheckReceivedValue( uint32_t ulReceived );
\r
159 * For purposes of test coverage, functions that read from and write to a
\r
160 * queue set from an ISR respectively.
\r
162 static void prvReceiveFromQueueInSetFromISR( void );
\r
163 static void prvSendToQueueInSetFromISR( void );
\r
166 * Create the queues and add them to a queue set before resuming the Tx
\r
169 static void prvSetupTest( void );
\r
172 * Checks a value received from a queue falls within the range of expected
\r
175 static BaseType_t prvCheckReceivedValueWithinExpectedRange( uint32_t ulReceived, uint32_t ulExpectedReceived );
\r
178 * Increase test coverage by occasionally change the priorities of the two tasks
\r
179 * relative to each other. */
\r
180 static void prvChangeRelativePriorities( void );
\r
183 * Local pseudo random number seed and return functions. Used to avoid calls
\r
184 * to the standard library.
\r
186 static uint32_t prvRand( void );
\r
187 static void prvSRand( uint32_t ulSeed );
\r
189 /*-----------------------------------------------------------*/
\r
191 /* The queues that are added to the set. */
\r
192 static QueueHandle_t xQueues[ queuesetNUM_QUEUES_IN_SET ] = { 0 };
\r
194 /* Counts how many times each queue in the set is used to ensure all the
\r
195 queues are used. */
\r
196 static uint32_t ulQueueUsedCounter[ queuesetNUM_QUEUES_IN_SET ] = { 0 };
\r
198 /* The handle of the queue set to which the queues are added. */
\r
199 static QueueSetHandle_t xQueueSet;
\r
201 /* If the prvQueueSetReceivingTask() task has not detected any errors then
\r
202 it increments ulCycleCounter on each iteration.
\r
203 xAreQueueSetTasksStillRunning() returns pdPASS if the value of
\r
204 ulCycleCounter has changed between consecutive calls, and pdFALSE if
\r
205 ulCycleCounter has stopped incrementing (indicating an error condition). */
\r
206 static volatile uint32_t ulCycleCounter = 0UL;
\r
208 /* Set to pdFAIL if an error is detected by any queue set task.
\r
209 ulCycleCounter will only be incremented if xQueueSetTasksSatus equals pdPASS. */
\r
210 static volatile BaseType_t xQueueSetTasksStatus = pdPASS;
\r
212 /* Just a flag to let the function that writes to a queue from an ISR know that
\r
213 the queues are setup and can be used. */
\r
214 static volatile BaseType_t xSetupComplete = pdFALSE;
\r
216 /* The value sent to the queue from the ISR is file scope so the
\r
217 xAreQueeuSetTasksStillRunning() function can check it is incrementing as
\r
219 static volatile uint32_t ulISRTxValue = queuesetINITIAL_ISR_TX_VALUE;
\r
221 /* Used by the pseudo random number generator. */
\r
222 static uint32_t ulNextRand = 0;
\r
224 /* The task handles are stored so their priorities can be changed. */
\r
225 TaskHandle_t xQueueSetSendingTask, xQueueSetReceivingTask;
\r
227 /*-----------------------------------------------------------*/
\r
229 void vStartQueueSetTasks( void )
\r
231 /* Create the tasks. */
\r
232 xTaskCreate( prvQueueSetSendingTask, "SetTx", configMINIMAL_STACK_SIZE, NULL, queuesetMEDIUM_PRIORITY, &xQueueSetSendingTask );
\r
233 xTaskCreate( prvQueueSetReceivingTask, "SetRx", configMINIMAL_STACK_SIZE, ( void * ) xQueueSetSendingTask, queuesetMEDIUM_PRIORITY, &xQueueSetReceivingTask );
\r
235 /* It is important that the sending task does not attempt to write to a
\r
236 queue before the queue has been created. It is therefore placed into the
\r
237 suspended state before the scheduler has started. It is resumed by the
\r
238 receiving task after the receiving task has created the queues and added the
\r
239 queues to the queue set. */
\r
240 vTaskSuspend( xQueueSetSendingTask );
\r
242 /*-----------------------------------------------------------*/
\r
244 BaseType_t xAreQueueSetTasksStillRunning( void )
\r
246 static uint32_t ulLastCycleCounter, ulLastISRTxValue = 0;
\r
247 static uint32_t ulLastQueueUsedCounter[ queuesetNUM_QUEUES_IN_SET ] = { 0 };
\r
248 BaseType_t xReturn = pdPASS, x;
\r
250 if( ulLastCycleCounter == ulCycleCounter )
\r
252 /* The cycle counter is no longer being incremented. Either one of the
\r
253 tasks is stalled or an error has been detected. */
\r
257 ulLastCycleCounter = ulCycleCounter;
\r
259 /* Ensure that all the queues in the set have been used. This ensures the
\r
260 test is working as intended and guards against the rand() in the Tx task
\r
261 missing some values. */
\r
262 for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )
\r
264 if( ulLastQueueUsedCounter[ x ] == ulQueueUsedCounter[ x ] )
\r
269 ulLastQueueUsedCounter[ x ] = ulQueueUsedCounter[ x ];
\r
272 /* Check the global status flag. */
\r
273 if( xQueueSetTasksStatus != pdPASS )
\r
278 /* Check that the ISR is still sending values to the queues too. */
\r
279 if( ulISRTxValue == ulLastISRTxValue )
\r
285 ulLastISRTxValue = ulISRTxValue;
\r
290 /*-----------------------------------------------------------*/
\r
292 static void prvQueueSetSendingTask( void *pvParameters )
\r
294 uint32_t ulTaskTxValue = 0, ulQueueToWriteTo;
\r
295 QueueHandle_t xQueueInUse;
\r
297 /* Remove compiler warning about the unused parameter. */
\r
298 ( void ) pvParameters;
\r
300 /* Seed mini pseudo random number generator. */
\r
301 prvSRand( ( uint32_t ) &ulTaskTxValue );
\r
305 /* Generate the index for the queue to which a value is to be sent. */
\r
306 ulQueueToWriteTo = prvRand() % queuesetNUM_QUEUES_IN_SET;
\r
307 xQueueInUse = xQueues[ ulQueueToWriteTo ];
\r
309 /* Note which index is being written to to ensure all the queues are
\r
311 ( ulQueueUsedCounter[ ulQueueToWriteTo ] )++;
\r
313 /* Send to the queue to unblock the task that is waiting for data to
\r
314 arrive on a queue within the queue set to which this queue belongs. */
\r
315 if( xQueueSendToBack( xQueueInUse, &ulTaskTxValue, portMAX_DELAY ) != pdPASS )
\r
317 /* The send should always pass as an infinite block time was
\r
319 xQueueSetTasksStatus = pdFAIL;
\r
322 #if( configUSE_PREEMPTION == 0 )
\r
328 /* If the Tx value has reached the range used by the ISR then set it
\r
330 if( ulTaskTxValue == queuesetINITIAL_ISR_TX_VALUE )
\r
335 /* Increase test coverage by occasionally change the priorities of the
\r
336 two tasks relative to each other. */
\r
337 prvChangeRelativePriorities();
\r
340 /*-----------------------------------------------------------*/
\r
342 static void prvChangeRelativePriorities( void )
\r
344 static UBaseType_t ulLoops = 0;
\r
345 static eRelativePriorities ePriorities = eEqualPriority;
\r
347 /* Occasionally change the task priority relative to the priority of
\r
348 the receiving task. */
\r
350 if( ulLoops >= queuesetPRIORITY_CHANGE_LOOPS )
\r
354 switch( ePriorities )
\r
356 case eEqualPriority:
\r
357 /* Both tasks are running with medium priority. Now lower the
\r
358 priority of the receiving task so the Tx task has the higher
\r
359 relative priority. */
\r
360 vTaskPrioritySet( xQueueSetReceivingTask, queuesetLOW_PRIORITY );
\r
361 ePriorities = eTxHigherPriority;
\r
364 case eTxHigherPriority:
\r
365 /* The Tx task is running with a higher priority than the Rx
\r
366 task. Switch the priorities around so the Rx task has the
\r
367 higher relative priority. */
\r
368 vTaskPrioritySet( xQueueSetReceivingTask, queuesetMEDIUM_PRIORITY );
\r
369 vTaskPrioritySet( xQueueSetSendingTask, queuesetLOW_PRIORITY );
\r
370 ePriorities = eTxLowerPriority;
\r
373 case eTxLowerPriority:
\r
374 /* The Tx task is running with a lower priority than the Rx
\r
375 task. Make the priorities equal again. */
\r
376 vTaskPrioritySet( xQueueSetSendingTask, queuesetMEDIUM_PRIORITY );
\r
377 ePriorities = eEqualPriority;
\r
379 /* When both tasks are using a non-idle priority the queue set
\r
380 tasks will starve idle priority tasks of execution time - so
\r
381 relax a bit before the next iteration to minimise the impact. */
\r
382 vTaskDelay( queuesetTX_LOOP_DELAY );
\r
388 /*-----------------------------------------------------------*/
\r
390 static void prvQueueSetReceivingTask( void *pvParameters )
\r
392 uint32_t ulReceived;
\r
393 QueueHandle_t xActivatedQueue;
\r
395 /* Remove compiler warnings. */
\r
396 ( void ) pvParameters;
\r
398 /* Create the queues and add them to the queue set before resuming the Tx
\r
404 /* Wait for a message to arrive on one of the queues in the set. */
\r
405 xActivatedQueue = xQueueSelectFromSet( xQueueSet, portMAX_DELAY );
\r
406 configASSERT( xActivatedQueue );
\r
408 if( xActivatedQueue == NULL )
\r
410 /* This should not happen as an infinite delay was used. */
\r
411 xQueueSetTasksStatus = pdFAIL;
\r
415 /* Reading from the queue should pass with a zero block time as
\r
416 this task will only run when something has been posted to a task
\r
417 in the queue set. */
\r
418 if( xQueueReceive( xActivatedQueue, &ulReceived, queuesetDONT_BLOCK ) != pdPASS )
\r
420 xQueueSetTasksStatus = pdFAIL;
\r
423 /* Ensure the value received was the value expected. This function
\r
424 manipulates file scope data and is also called from an ISR, hence
\r
425 the critical section. */
\r
426 taskENTER_CRITICAL();
\r
428 prvCheckReceivedValue( ulReceived );
\r
430 taskEXIT_CRITICAL();
\r
433 if( xQueueSetTasksStatus == pdPASS )
\r
439 /*-----------------------------------------------------------*/
\r
441 void vQueueSetAccessQueueSetFromISR( void )
\r
443 static uint32_t ulCallCount = 0;
\r
445 /* xSetupComplete is set to pdTRUE when the queues have been created and
\r
446 are available for use. */
\r
447 if( xSetupComplete == pdTRUE )
\r
449 /* It is intended that this function is called from the tick hook
\r
450 function, so each call is one tick period apart. */
\r
452 if( ulCallCount > queuesetISR_TX_PERIOD )
\r
456 /* First attempt to read from the queue set. */
\r
457 prvReceiveFromQueueInSetFromISR();
\r
459 /* Then write to the queue set. */
\r
460 prvSendToQueueInSetFromISR();
\r
464 /*-----------------------------------------------------------*/
\r
466 static void prvCheckReceivedValue( uint32_t ulReceived )
\r
468 static uint32_t ulExpectedReceivedFromTask = 0, ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;
\r
470 /* Values are received in tasks and interrupts. It is likely that the
\r
471 receiving task will sometimes get preempted by the receiving interrupt
\r
472 between reading a value from the queue and calling this function. When
\r
473 that happens, if the receiving interrupt calls this function the values
\r
474 will get passed into this function slightly out of order. For that
\r
475 reason the value passed in is tested against a small range of expected
\r
476 values, rather than a single absolute value. To make the range testing
\r
477 easier values in the range limits are ignored. */
\r
479 /* If the received value is equal to or greater than
\r
480 queuesetINITIAL_ISR_TX_VALUE then it was sent by an ISR. */
\r
481 if( ulReceived >= queuesetINITIAL_ISR_TX_VALUE )
\r
483 /* The value was sent from the ISR. */
\r
484 if( ( ulReceived - queuesetINITIAL_ISR_TX_VALUE ) < queuesetIGNORED_BOUNDARY )
\r
486 /* The value received is at the lower limit of the expected range.
\r
487 Don't test it and expect to receive one higher next time. */
\r
489 else if( ( ULONG_MAX - ulReceived ) <= queuesetIGNORED_BOUNDARY )
\r
491 /* The value received is at the higher limit of the expected range.
\r
492 Don't test it and expect to wrap soon. */
\r
496 /* Check the value against its expected value range. */
\r
497 if( prvCheckReceivedValueWithinExpectedRange( ulReceived, ulExpectedReceivedFromISR ) != pdPASS )
\r
499 xQueueSetTasksStatus = pdFAIL;
\r
503 configASSERT( xQueueSetTasksStatus );
\r
505 /* It is expected to receive an incrementing number. */
\r
506 ulExpectedReceivedFromISR++;
\r
507 if( ulExpectedReceivedFromISR == 0 )
\r
509 ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;
\r
514 /* The value was sent from the Tx task. */
\r
515 if( ulReceived < queuesetIGNORED_BOUNDARY )
\r
517 /* The value received is at the lower limit of the expected range.
\r
518 Don't test it, and expect to receive one higher next time. */
\r
520 else if( ( ( queuesetINITIAL_ISR_TX_VALUE - 1 ) - ulReceived ) <= queuesetIGNORED_BOUNDARY )
\r
522 /* The value received is at the higher limit of the expected range.
\r
523 Don't test it and expect to wrap soon. */
\r
527 /* Check the value against its expected value range. */
\r
528 if( prvCheckReceivedValueWithinExpectedRange( ulReceived, ulExpectedReceivedFromTask ) != pdPASS )
\r
530 xQueueSetTasksStatus = pdFAIL;
\r
534 configASSERT( xQueueSetTasksStatus );
\r
536 /* It is expected to receive an incrementing number. */
\r
537 ulExpectedReceivedFromTask++;
\r
538 if( ulExpectedReceivedFromTask >= queuesetINITIAL_ISR_TX_VALUE )
\r
540 ulExpectedReceivedFromTask = 0;
\r
544 /*-----------------------------------------------------------*/
\r
546 static BaseType_t prvCheckReceivedValueWithinExpectedRange( uint32_t ulReceived, uint32_t ulExpectedReceived )
\r
548 BaseType_t xReturn = pdPASS;
\r
550 if( ulReceived > ulExpectedReceived )
\r
552 configASSERT( ( ulReceived - ulExpectedReceived ) <= queuesetALLOWABLE_RX_DEVIATION );
\r
553 if( ( ulReceived - ulExpectedReceived ) > queuesetALLOWABLE_RX_DEVIATION )
\r
560 configASSERT( ( ulExpectedReceived - ulReceived ) <= queuesetALLOWABLE_RX_DEVIATION );
\r
561 if( ( ulExpectedReceived - ulReceived ) > queuesetALLOWABLE_RX_DEVIATION )
\r
569 /*-----------------------------------------------------------*/
\r
571 static void prvReceiveFromQueueInSetFromISR( void )
\r
573 QueueSetMemberHandle_t xActivatedQueue;
\r
574 uint32_t ulReceived;
\r
576 /* See if any of the queues in the set contain data. */
\r
577 xActivatedQueue = xQueueSelectFromSetFromISR( xQueueSet );
\r
579 if( xActivatedQueue != NULL )
\r
581 /* Reading from the queue for test purposes only. */
\r
582 if( xQueueReceiveFromISR( xActivatedQueue, &ulReceived, NULL ) != pdPASS )
\r
584 /* Data should have been available as the handle was returned from
\r
585 xQueueSelectFromSetFromISR(). */
\r
586 xQueueSetTasksStatus = pdFAIL;
\r
589 /* Ensure the value received was the value expected. */
\r
590 prvCheckReceivedValue( ulReceived );
\r
593 /*-----------------------------------------------------------*/
\r
595 static void prvSendToQueueInSetFromISR( void )
\r
597 static BaseType_t xQueueToWriteTo = 0;
\r
599 if( xQueueSendFromISR( xQueues[ xQueueToWriteTo ], ( void * ) &ulISRTxValue, NULL ) == pdPASS )
\r
603 /* If the Tx value has wrapped then set it back to its
\r
605 if( ulISRTxValue == 0UL )
\r
607 ulISRTxValue = queuesetINITIAL_ISR_TX_VALUE;
\r
610 /* Use a different queue next time. */
\r
612 if( xQueueToWriteTo >= queuesetNUM_QUEUES_IN_SET )
\r
614 xQueueToWriteTo = 0;
\r
618 /*-----------------------------------------------------------*/
\r
620 static void prvSetupTest( void )
\r
623 uint32_t ulValueToSend = 0;
\r
625 /* Ensure the queues are created and the queue set configured before the
\r
626 sending task is unsuspended.
\r
628 First Create the queue set such that it will be able to hold a message for
\r
629 every space in every queue in the set. */
\r
630 xQueueSet = xQueueCreateSet( queuesetNUM_QUEUES_IN_SET * queuesetQUEUE_LENGTH );
\r
632 for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )
\r
634 /* Create the queue and add it to the set. The queue is just holding
\r
636 xQueues[ x ] = xQueueCreate( queuesetQUEUE_LENGTH, sizeof( uint32_t ) );
\r
637 configASSERT( xQueues[ x ] );
\r
638 if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdPASS )
\r
640 xQueueSetTasksStatus = pdFAIL;
\r
644 /* The queue has now been added to the queue set and cannot be added to
\r
646 if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdFAIL )
\r
648 xQueueSetTasksStatus = pdFAIL;
\r
653 /* Attempt to remove a queue from a queue set it does not belong
\r
654 to (NULL being passed as the queue set in this case). */
\r
655 if( xQueueRemoveFromSet( xQueues[ 0 ], NULL ) != pdFAIL )
\r
657 /* It is not possible to successfully remove a queue from a queue
\r
658 set it does not belong to. */
\r
659 xQueueSetTasksStatus = pdFAIL;
\r
662 /* Attempt to remove a queue from the queue set it does belong to. */
\r
663 if( xQueueRemoveFromSet( xQueues[ 0 ], xQueueSet ) != pdPASS )
\r
665 /* It should be possible to remove the queue from the queue set it
\r
667 xQueueSetTasksStatus = pdFAIL;
\r
670 /* Add an item to the queue before attempting to add it back into the
\r
672 xQueueSend( xQueues[ 0 ], ( void * ) &ulValueToSend, 0 );
\r
673 if( xQueueAddToSet( xQueues[ 0 ], xQueueSet ) != pdFAIL )
\r
675 /* Should not be able to add a non-empty queue to a set. */
\r
676 xQueueSetTasksStatus = pdFAIL;
\r
679 /* Remove the item from the queue before adding the queue back into the
\r
680 set so the dynamic tests can begin. */
\r
681 xQueueReceive( xQueues[ 0 ], &ulValueToSend, 0 );
\r
682 if( xQueueAddToSet( xQueues[ 0 ], xQueueSet ) != pdPASS )
\r
684 /* If the queue was successfully removed from the queue set then it
\r
685 should be possible to add it back in again. */
\r
686 xQueueSetTasksStatus = pdFAIL;
\r
689 /* The task that sends to the queues is not running yet, so attempting to
\r
690 read from the queue set should fail. */
\r
691 if( xQueueSelectFromSet( xQueueSet, queuesetSHORT_DELAY ) != NULL )
\r
693 xQueueSetTasksStatus = pdFAIL;
\r
696 /* Resume the task that writes to the queues. */
\r
697 vTaskResume( xQueueSetSendingTask );
\r
699 /* Let the ISR access the queues also. */
\r
700 xSetupComplete = pdTRUE;
\r
702 /*-----------------------------------------------------------*/
\r
704 static uint32_t prvRand( void )
\r
706 ulNextRand = ( ulNextRand * 1103515245UL ) + 12345UL;
\r
707 return ( ulNextRand / 65536UL ) % 32768UL;
\r
709 /*-----------------------------------------------------------*/
\r
711 static void prvSRand( uint32_t ulSeed )
\r
713 ulNextRand = ulSeed;
\r