2 FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.
\r
4 FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT
\r
5 http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 ***************************************************************************
\r
9 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
10 * Complete, revised, and edited pdf reference manuals are also *
\r
13 * Purchasing FreeRTOS documentation will not only help you, by *
\r
14 * ensuring you get running as quickly as possible and with an *
\r
15 * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
16 * the FreeRTOS project to continue with its mission of providing *
\r
17 * professional grade, cross platform, de facto standard solutions *
\r
18 * for microcontrollers - completely free of charge! *
\r
20 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
22 * Thank you for using FreeRTOS, and thank you for your support! *
\r
24 ***************************************************************************
\r
27 This file is part of the FreeRTOS distribution.
\r
29 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
30 the terms of the GNU General Public License (version 2) as published by the
\r
31 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
32 >>>NOTE<<< The modification to the GPL is included to allow you to
\r
33 distribute a combined work that includes FreeRTOS without being obliged to
\r
34 provide the source code for proprietary components outside of the FreeRTOS
\r
35 kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
36 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
37 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
38 more details. You should have received a copy of the GNU General Public
\r
39 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
40 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
41 by writing to Richard Barry, contact details for whom are available on the
\r
46 ***************************************************************************
\r
48 * Having a problem? Start by reading the FAQ "My application does *
\r
49 * not run, what could be wrong?" *
\r
51 * http://www.FreeRTOS.org/FAQHelp.html *
\r
53 ***************************************************************************
\r
56 http://www.FreeRTOS.org - Documentation, training, latest versions, license
\r
57 and contact details.
\r
59 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
60 including FreeRTOS+Trace - an indispensable productivity tool.
\r
62 Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
\r
63 the code with commercial support, indemnification, and middleware, under
\r
64 the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
\r
65 provide a safety engineered and independently SIL3 certified version under
\r
66 the SafeRTOS brand: http://www.SafeRTOS.com.
\r
72 /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
\r
73 all the API functions to use the MPU wrappers. That should only be done when
\r
74 task.h is included from an application file. */
\r
75 #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
\r
77 #include "FreeRTOS.h"
\r
80 #if ( configUSE_CO_ROUTINES == 1 )
\r
81 #include "croutine.h"
\r
84 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
\r
86 /* Constants used with the cRxLock and xTxLock structure members. */
\r
87 #define queueUNLOCKED ( ( signed portBASE_TYPE ) -1 )
\r
88 #define queueLOCKED_UNMODIFIED ( ( signed portBASE_TYPE ) 0 )
\r
90 #define queueERRONEOUS_UNBLOCK ( -1 )
\r
92 /* For internal use only. */
\r
93 #define queueSEND_TO_BACK ( 0 )
\r
94 #define queueSEND_TO_FRONT ( 1 )
\r
96 /* Effectively make a union out of the xQUEUE structure. */
\r
97 #define pxMutexHolder pcTail
\r
98 #define uxQueueType pcHead
\r
99 #define uxRecursiveCallCount pcReadFrom
\r
100 #define queueQUEUE_IS_MUTEX NULL
\r
102 /* Semaphores do not actually store or copy data, so have an items size of
\r
104 #define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( unsigned portBASE_TYPE ) 0 )
\r
105 #define queueDONT_BLOCK ( ( portTickType ) 0U )
\r
106 #define queueMUTEX_GIVE_BLOCK_TIME ( ( portTickType ) 0U )
\r
108 /* These definitions *must* match those in queue.h. */
\r
109 #define queueQUEUE_TYPE_BASE ( 0U )
\r
110 #define queueQUEUE_TYPE_MUTEX ( 1U )
\r
111 #define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( 2U )
\r
112 #define queueQUEUE_TYPE_BINARY_SEMAPHORE ( 3U )
\r
113 #define queueQUEUE_TYPE_RECURSIVE_MUTEX ( 4U )
\r
114 #define queueQUEUE_TYPE_SET ( 5U )
\r
117 * Definition of the queue used by the scheduler.
\r
118 * Items are queued by copy, not reference.
\r
120 typedef struct QueueDefinition
\r
122 signed char *pcHead; /*< Points to the beginning of the queue storage area. */
\r
123 signed char *pcTail; /*< Points to the byte at the end of the queue storage area. Once more byte is allocated than necessary to store the queue items, this is used as a marker. */
\r
125 signed char *pcWriteTo; /*< Points to the free next place in the storage area. */
\r
126 signed char *pcReadFrom; /*< Points to the last place that a queued item was read from. */
\r
128 xList xTasksWaitingToSend; /*< List of tasks that are blocked waiting to post onto this queue. Stored in priority order. */
\r
129 xList xTasksWaitingToReceive; /*< List of tasks that are blocked waiting to read from this queue. Stored in priority order. */
\r
131 volatile unsigned portBASE_TYPE uxMessagesWaiting;/*< The number of items currently in the queue. */
\r
132 unsigned portBASE_TYPE uxLength; /*< The length of the queue defined as the number of items it will hold, not the number of bytes. */
\r
133 unsigned portBASE_TYPE uxItemSize; /*< The size of each items that the queue will hold. */
\r
135 volatile signed portBASE_TYPE xRxLock; /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */
\r
136 volatile signed portBASE_TYPE xTxLock; /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */
\r
138 #if ( configUSE_TRACE_FACILITY == 1 )
\r
139 unsigned char ucQueueNumber;
\r
140 unsigned char ucQueueType;
\r
143 #if ( configUSE_QUEUE_SETS == 1 )
\r
144 struct QueueDefinition *pxQueueSetContainer;
\r
148 /*-----------------------------------------------------------*/
\r
151 * Inside this file xQueueHandle and xQueueSetHandle are both pointers to xQUEUE
\r
152 * structures. To keep the definition private the API header file defines both
\r
153 * as pointers to void.
\r
155 typedef xQUEUE * xQueueHandle;
\r
156 typedef xQUEUE * xQueueSetHandle;
\r
159 * Queue sets can contain both queues and semaphores, so the
\r
160 * xQueueSetMemberHandle is defined as a type to be used where a parameter or
\r
161 * return value can be either an xQueueHandle or an xSemaphoreHandle.
\r
163 typedef xQUEUE * xQueueSetMemberHandle;
\r
166 * In order to implement strict data hiding, the queue.h header file defines
\r
167 * xQueueHandle and xQueueSetHandle as pointers to void. In this file
\r
168 * xQueueHandle and xQueueSetHandle are defined as pointers to xQUEUE objects.
\r
169 * Therefore the queue.h header file cannot be included in this source file,
\r
170 * and the function prototypes are provided directly.
\r
172 xQueueHandle xQueueGenericCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize, unsigned char ucQueueType ) PRIVILEGED_FUNCTION;
\r
173 signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;
\r
174 unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
\r
175 void vQueueDelete( xQueueHandle xQueue ) PRIVILEGED_FUNCTION;
\r
176 signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;
\r
177 signed portBASE_TYPE xQueueGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ) PRIVILEGED_FUNCTION;
\r
178 signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
\r
179 xQueueHandle xQueueCreateMutex( unsigned char ucQueueType ) PRIVILEGED_FUNCTION;
\r
180 xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount ) PRIVILEGED_FUNCTION;
\r
181 portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle xMutex, portTickType xBlockTime ) PRIVILEGED_FUNCTION;
\r
182 portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle xMutex ) PRIVILEGED_FUNCTION;
\r
183 signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;
\r
184 signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ) PRIVILEGED_FUNCTION;
\r
185 signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
\r
186 signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
\r
187 unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
\r
188 void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;
\r
189 unsigned char ucQueueGetQueueNumber( xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
\r
190 void vQueueSetQueueNumber( xQueueHandle pxQueue, unsigned char ucQueueNumber ) PRIVILEGED_FUNCTION;
\r
191 unsigned char ucQueueGetQueueType( xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
\r
192 portBASE_TYPE xQueueGenericReset( xQueueHandle pxQueue, portBASE_TYPE xNewQueue ) PRIVILEGED_FUNCTION;
\r
193 xTaskHandle xQueueGetMutexHolder( xQueueHandle xSemaphore ) PRIVILEGED_FUNCTION;
\r
194 xQueueSetHandle xQueueSetCreate( unsigned portBASE_TYPE uxEventQueueLength ) PRIVILEGED_FUNCTION;
\r
195 xQueueSetMemberHandle xQueueBlockMultiple( xQueueSetHandle xQueueSet, portTickType xBlockTimeTicks ) PRIVILEGED_FUNCTION;
\r
196 portBASE_TYPE xQueueAddToQueueSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet ) PRIVILEGED_FUNCTION;
\r
197 portBASE_TYPE xQueueRemoveFromQueueSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet ) PRIVILEGED_FUNCTION;
\r
200 * Co-routine queue functions differ from task queue functions. Co-routines are
\r
201 * an optional component.
\r
203 #if ( configUSE_CO_ROUTINES == 1 )
\r
204 signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken ) PRIVILEGED_FUNCTION;
\r
205 signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken ) PRIVILEGED_FUNCTION;
\r
206 signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;
\r
207 signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;
\r
211 * The queue registry is just a means for kernel aware debuggers to locate
\r
212 * queue structures. It has no other purpose so is an optional component.
\r
214 #if ( configQUEUE_REGISTRY_SIZE > 0 )
\r
216 /* The type stored within the queue registry array. This allows a name
\r
217 to be assigned to each queue making kernel aware debugging a little
\r
218 more user friendly. */
\r
219 typedef struct QUEUE_REGISTRY_ITEM
\r
221 signed char *pcQueueName;
\r
222 xQueueHandle xHandle;
\r
223 } xQueueRegistryItem;
\r
225 /* The queue registry is simply an array of xQueueRegistryItem structures.
\r
226 The pcQueueName member of a structure being NULL is indicative of the
\r
227 array position being vacant. */
\r
228 xQueueRegistryItem xQueueRegistry[ configQUEUE_REGISTRY_SIZE ];
\r
230 /* Removes a queue from the registry by simply setting the pcQueueName
\r
232 static void vQueueUnregisterQueue( xQueueHandle xQueue ) PRIVILEGED_FUNCTION;
\r
233 void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcQueueName ) PRIVILEGED_FUNCTION;
\r
237 * Unlocks a queue locked by a call to prvLockQueue. Locking a queue does not
\r
238 * prevent an ISR from adding or removing items to the queue, but does prevent
\r
239 * an ISR from removing tasks from the queue event lists. If an ISR finds a
\r
240 * queue is locked it will instead increment the appropriate queue lock count
\r
241 * to indicate that a task may require unblocking. When the queue in unlocked
\r
242 * these lock counts are inspected, and the appropriate action taken.
\r
244 static void prvUnlockQueue( xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
\r
247 * Uses a critical section to determine if there is any data in a queue.
\r
249 * @return pdTRUE if the queue contains no items, otherwise pdFALSE.
\r
251 static signed portBASE_TYPE prvIsQueueEmpty( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
\r
254 * Uses a critical section to determine if there is any space in a queue.
\r
256 * @return pdTRUE if there is no space, otherwise pdFALSE;
\r
258 static signed portBASE_TYPE prvIsQueueFull( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
\r
261 * Copies an item into the queue, either at the front of the queue or the
\r
262 * back of the queue.
\r
264 static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, portBASE_TYPE xPosition ) PRIVILEGED_FUNCTION;
\r
267 * Copies an item out of a queue.
\r
269 static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer ) PRIVILEGED_FUNCTION;
\r
271 #if ( configUSE_QUEUE_SETS == 1 )
\r
273 * Checks to see if a queue is a member of a queue set, and if so, notifies
\r
274 * the queue set that the queue contains data.
\r
276 static portBASE_TYPE prvNotifyQueueSetContainer( xQUEUE *pxQueue, portBASE_TYPE xCopyPosition );
\r
279 /*-----------------------------------------------------------*/
\r
282 * Macro to mark a queue as locked. Locking a queue prevents an ISR from
\r
283 * accessing the queue event lists.
\r
285 #define prvLockQueue( pxQueue ) \
\r
286 taskENTER_CRITICAL(); \
\r
288 if( ( pxQueue )->xRxLock == queueUNLOCKED ) \
\r
290 ( pxQueue )->xRxLock = queueLOCKED_UNMODIFIED; \
\r
292 if( ( pxQueue )->xTxLock == queueUNLOCKED ) \
\r
294 ( pxQueue )->xTxLock = queueLOCKED_UNMODIFIED; \
\r
297 taskEXIT_CRITICAL()
\r
298 /*-----------------------------------------------------------*/
\r
300 portBASE_TYPE xQueueGenericReset( xQueueHandle pxQueue, portBASE_TYPE xNewQueue )
\r
302 configASSERT( pxQueue );
\r
304 taskENTER_CRITICAL();
\r
306 pxQueue->pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize );
\r
307 pxQueue->uxMessagesWaiting = ( unsigned portBASE_TYPE ) 0U;
\r
308 pxQueue->pcWriteTo = pxQueue->pcHead;
\r
309 pxQueue->pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - ( unsigned portBASE_TYPE ) 1U ) * pxQueue->uxItemSize );
\r
310 pxQueue->xRxLock = queueUNLOCKED;
\r
311 pxQueue->xTxLock = queueUNLOCKED;
\r
313 if( xNewQueue == pdFALSE )
\r
315 /* If there are tasks blocked waiting to read from the queue, then
\r
316 the tasks will remain blocked as after this function exits the queue
\r
317 will still be empty. If there are tasks blocked waiting to write to
\r
318 the queue, then one should be unblocked as after this function exits
\r
319 it will be possible to write to it. */
\r
320 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
\r
322 if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )
\r
324 portYIELD_WITHIN_API();
\r
330 /* Ensure the event queues start in the correct state. */
\r
331 vListInitialise( &( pxQueue->xTasksWaitingToSend ) );
\r
332 vListInitialise( &( pxQueue->xTasksWaitingToReceive ) );
\r
335 taskEXIT_CRITICAL();
\r
337 /* A value is returned for calling semantic consistency with previous
\r
341 /*-----------------------------------------------------------*/
\r
343 xQueueHandle xQueueGenericCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize, unsigned char ucQueueType )
\r
345 xQUEUE *pxNewQueue;
\r
346 size_t xQueueSizeInBytes;
\r
347 xQueueHandle xReturn = NULL;
\r
349 /* Remove compiler warnings about unused parameters should
\r
350 configUSE_TRACE_FACILITY not be set to 1. */
\r
351 ( void ) ucQueueType;
\r
353 /* Allocate the new queue structure. */
\r
354 if( uxQueueLength > ( unsigned portBASE_TYPE ) 0 )
\r
356 pxNewQueue = ( xQUEUE * ) pvPortMalloc( sizeof( xQUEUE ) );
\r
357 if( pxNewQueue != NULL )
\r
359 /* Create the list of pointers to queue items. The queue is one byte
\r
360 longer than asked for to make wrap checking easier/faster. */
\r
361 xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1;
\r
363 pxNewQueue->pcHead = ( signed char * ) pvPortMalloc( xQueueSizeInBytes );
\r
364 if( pxNewQueue->pcHead != NULL )
\r
366 /* Initialise the queue members as described above where the
\r
367 queue type is defined. */
\r
368 pxNewQueue->uxLength = uxQueueLength;
\r
369 pxNewQueue->uxItemSize = uxItemSize;
\r
370 xQueueGenericReset( pxNewQueue, pdTRUE );
\r
372 #if ( configUSE_TRACE_FACILITY == 1 )
\r
374 pxNewQueue->ucQueueType = ucQueueType;
\r
376 #endif /* configUSE_TRACE_FACILITY */
\r
378 #if( configUSE_QUEUE_SETS == 1 )
\r
380 pxNewQueue->pxQueueSetContainer = NULL;
\r
382 #endif /* configUSE_QUEUE_SETS */
\r
384 traceQUEUE_CREATE( pxNewQueue );
\r
385 xReturn = pxNewQueue;
\r
389 traceQUEUE_CREATE_FAILED( ucQueueType );
\r
390 vPortFree( pxNewQueue );
\r
395 configASSERT( xReturn );
\r
399 /*-----------------------------------------------------------*/
\r
401 #if ( configUSE_MUTEXES == 1 )
\r
403 xQueueHandle xQueueCreateMutex( unsigned char ucQueueType )
\r
405 xQUEUE *pxNewQueue;
\r
407 /* Prevent compiler warnings about unused parameters if
\r
408 configUSE_TRACE_FACILITY does not equal 1. */
\r
409 ( void ) ucQueueType;
\r
411 /* Allocate the new queue structure. */
\r
412 pxNewQueue = ( xQUEUE * ) pvPortMalloc( sizeof( xQUEUE ) );
\r
413 if( pxNewQueue != NULL )
\r
415 /* Information required for priority inheritance. */
\r
416 pxNewQueue->pxMutexHolder = NULL;
\r
417 pxNewQueue->uxQueueType = queueQUEUE_IS_MUTEX;
\r
419 /* Queues used as a mutex no data is actually copied into or out
\r
421 pxNewQueue->pcWriteTo = NULL;
\r
422 pxNewQueue->pcReadFrom = NULL;
\r
424 /* Each mutex has a length of 1 (like a binary semaphore) and
\r
425 an item size of 0 as nothing is actually copied into or out
\r
427 pxNewQueue->uxMessagesWaiting = ( unsigned portBASE_TYPE ) 0U;
\r
428 pxNewQueue->uxLength = ( unsigned portBASE_TYPE ) 1U;
\r
429 pxNewQueue->uxItemSize = ( unsigned portBASE_TYPE ) 0U;
\r
430 pxNewQueue->xRxLock = queueUNLOCKED;
\r
431 pxNewQueue->xTxLock = queueUNLOCKED;
\r
433 #if ( configUSE_TRACE_FACILITY == 1 )
\r
435 pxNewQueue->ucQueueType = ucQueueType;
\r
439 #if ( configUSE_QUEUE_SETS == 1 )
\r
441 pxNewQueue->pxQueueSetContainer = NULL;
\r
445 /* Ensure the event queues start with the correct state. */
\r
446 vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) );
\r
447 vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );
\r
449 traceCREATE_MUTEX( pxNewQueue );
\r
451 /* Start with the semaphore in the expected state. */
\r
452 xQueueGenericSend( pxNewQueue, NULL, ( portTickType ) 0U, queueSEND_TO_BACK );
\r
456 traceCREATE_MUTEX_FAILED();
\r
459 configASSERT( pxNewQueue );
\r
463 #endif /* configUSE_MUTEXES */
\r
464 /*-----------------------------------------------------------*/
\r
466 #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
\r
468 void* xQueueGetMutexHolder( xQueueHandle xSemaphore )
\r
472 /* This function is called by xSemaphoreGetMutexHolder(), and should not
\r
473 be called directly. Note: This is is a good way of determining if the
\r
474 calling task is the mutex holder, but not a good way of determining the
\r
475 identity of the mutex holder, as the holder may change between the
\r
476 following critical section exiting and the function returning. */
\r
477 taskENTER_CRITICAL();
\r
479 if( xSemaphore->uxQueueType == queueQUEUE_IS_MUTEX )
\r
481 pxReturn = ( void * ) xSemaphore->pxMutexHolder;
\r
488 taskEXIT_CRITICAL();
\r
494 /*-----------------------------------------------------------*/
\r
496 #if ( configUSE_RECURSIVE_MUTEXES == 1 )
\r
498 portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle pxMutex )
\r
500 portBASE_TYPE xReturn;
\r
502 configASSERT( pxMutex );
\r
504 /* If this is the task that holds the mutex then pxMutexHolder will not
\r
505 change outside of this task. If this task does not hold the mutex then
\r
506 pxMutexHolder can never coincidentally equal the tasks handle, and as
\r
507 this is the only condition we are interested in it does not matter if
\r
508 pxMutexHolder is accessed simultaneously by another task. Therefore no
\r
509 mutual exclusion is required to test the pxMutexHolder variable. */
\r
510 if( pxMutex->pxMutexHolder == xTaskGetCurrentTaskHandle() )
\r
512 traceGIVE_MUTEX_RECURSIVE( pxMutex );
\r
514 /* uxRecursiveCallCount cannot be zero if pxMutexHolder is equal to
\r
515 the task handle, therefore no underflow check is required. Also,
\r
516 uxRecursiveCallCount is only modified by the mutex holder, and as
\r
517 there can only be one, no mutual exclusion is required to modify the
\r
518 uxRecursiveCallCount member. */
\r
519 ( pxMutex->uxRecursiveCallCount )--;
\r
521 /* Have we unwound the call count? */
\r
522 if( pxMutex->uxRecursiveCallCount == 0 )
\r
524 /* Return the mutex. This will automatically unblock any other
\r
525 task that might be waiting to access the mutex. */
\r
526 xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK );
\r
533 /* We cannot give the mutex because we are not the holder. */
\r
536 traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex );
\r
542 #endif /* configUSE_RECURSIVE_MUTEXES */
\r
543 /*-----------------------------------------------------------*/
\r
545 #if ( configUSE_RECURSIVE_MUTEXES == 1 )
\r
547 portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle pxMutex, portTickType xBlockTime )
\r
549 portBASE_TYPE xReturn;
\r
551 configASSERT( pxMutex );
\r
553 /* Comments regarding mutual exclusion as per those within
\r
554 xQueueGiveMutexRecursive(). */
\r
556 traceTAKE_MUTEX_RECURSIVE( pxMutex );
\r
558 if( pxMutex->pxMutexHolder == xTaskGetCurrentTaskHandle() )
\r
560 ( pxMutex->uxRecursiveCallCount )++;
\r
565 xReturn = xQueueGenericReceive( pxMutex, NULL, xBlockTime, pdFALSE );
\r
567 /* pdPASS will only be returned if we successfully obtained the mutex,
\r
568 we may have blocked to reach here. */
\r
569 if( xReturn == pdPASS )
\r
571 ( pxMutex->uxRecursiveCallCount )++;
\r
575 traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex );
\r
582 #endif /* configUSE_RECURSIVE_MUTEXES */
\r
583 /*-----------------------------------------------------------*/
\r
585 #if ( configUSE_COUNTING_SEMAPHORES == 1 )
\r
587 xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount )
\r
589 xQueueHandle pxHandle;
\r
591 pxHandle = xQueueGenericCreate( ( unsigned portBASE_TYPE ) uxCountValue, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE );
\r
593 if( pxHandle != NULL )
\r
595 pxHandle->uxMessagesWaiting = uxInitialCount;
\r
597 traceCREATE_COUNTING_SEMAPHORE();
\r
601 traceCREATE_COUNTING_SEMAPHORE_FAILED();
\r
604 configASSERT( pxHandle );
\r
608 #endif /* configUSE_COUNTING_SEMAPHORES */
\r
609 /*-----------------------------------------------------------*/
\r
611 signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition )
\r
613 signed portBASE_TYPE xEntryTimeSet = pdFALSE;
\r
614 xTimeOutType xTimeOut;
\r
616 configASSERT( pxQueue );
\r
617 configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );
\r
619 /* This function relaxes the coding standard somewhat to allow return
\r
620 statements within the function itself. This is done in the interest
\r
621 of execution time efficiency. */
\r
624 taskENTER_CRITICAL();
\r
626 /* Is there room on the queue now? To be running we must be
\r
627 the highest priority task wanting to access the queue. */
\r
628 if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )
\r
630 traceQUEUE_SEND( pxQueue );
\r
631 prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
\r
633 /* If there was a task waiting for data to arrive on the
\r
634 queue then unblock it now. */
\r
635 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
\r
637 if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE )
\r
639 /* The unblocked task has a priority higher than
\r
640 our own so yield immediately. Yes it is ok to do
\r
641 this from within the critical section - the kernel
\r
642 takes care of that. */
\r
643 portYIELD_WITHIN_API();
\r
648 #if ( configUSE_QUEUE_SETS == 1 )
\r
650 if( pxQueue->pxQueueSetContainer != NULL )
\r
652 if( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) == pdTRUE )
\r
654 /* The queue is a member of a queue set, and posting to
\r
655 the queue set caused a higher priority task to unblock.
\r
656 A context switch is required. */
\r
657 portYIELD_WITHIN_API();
\r
661 #endif /* configUSE_QUEUE_SETS */
\r
664 taskEXIT_CRITICAL();
\r
666 /* Return to the original privilege level before exiting the
\r
672 if( xTicksToWait == ( portTickType ) 0 )
\r
674 /* The queue was full and no block time is specified (or
\r
675 the block time has expired) so leave now. */
\r
676 taskEXIT_CRITICAL();
\r
678 /* Return to the original privilege level before exiting
\r
680 traceQUEUE_SEND_FAILED( pxQueue );
\r
681 return errQUEUE_FULL;
\r
683 else if( xEntryTimeSet == pdFALSE )
\r
685 /* The queue was full and a block time was specified so
\r
686 configure the timeout structure. */
\r
687 vTaskSetTimeOutState( &xTimeOut );
\r
688 xEntryTimeSet = pdTRUE;
\r
692 taskEXIT_CRITICAL();
\r
694 /* Interrupts and other tasks can send to and receive from the queue
\r
695 now the critical section has been exited. */
\r
698 prvLockQueue( pxQueue );
\r
700 /* Update the timeout state to see if it has expired yet. */
\r
701 if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
\r
703 if( prvIsQueueFull( pxQueue ) != pdFALSE )
\r
705 traceBLOCKING_ON_QUEUE_SEND( pxQueue );
\r
706 vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );
\r
708 /* Unlocking the queue means queue events can effect the
\r
709 event list. It is possible that interrupts occurring now
\r
710 remove this task from the event list again - but as the
\r
711 scheduler is suspended the task will go onto the pending
\r
712 ready last instead of the actual ready list. */
\r
713 prvUnlockQueue( pxQueue );
\r
715 /* Resuming the scheduler will move tasks from the pending
\r
716 ready list into the ready list - so it is feasible that this
\r
717 task is already in a ready list before it yields - in which
\r
718 case the yield will not cause a context switch unless there
\r
719 is also a higher priority task in the pending ready list. */
\r
720 if( xTaskResumeAll() == pdFALSE )
\r
722 portYIELD_WITHIN_API();
\r
728 prvUnlockQueue( pxQueue );
\r
729 ( void ) xTaskResumeAll();
\r
734 /* The timeout has expired. */
\r
735 prvUnlockQueue( pxQueue );
\r
736 ( void ) xTaskResumeAll();
\r
738 /* Return to the original privilege level before exiting the
\r
740 traceQUEUE_SEND_FAILED( pxQueue );
\r
741 return errQUEUE_FULL;
\r
745 /*-----------------------------------------------------------*/
\r
747 #if ( configUSE_ALTERNATIVE_API == 1 )
\r
749 signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition )
\r
751 signed portBASE_TYPE xEntryTimeSet = pdFALSE;
\r
752 xTimeOutType xTimeOut;
\r
754 configASSERT( pxQueue );
\r
755 configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );
\r
759 taskENTER_CRITICAL();
\r
761 /* Is there room on the queue now? To be running we must be
\r
762 the highest priority task wanting to access the queue. */
\r
763 if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )
\r
765 traceQUEUE_SEND( pxQueue );
\r
766 prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
\r
768 /* If there was a task waiting for data to arrive on the
\r
769 queue then unblock it now. */
\r
770 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
\r
772 if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE )
\r
774 /* The unblocked task has a priority higher than
\r
775 our own so yield immediately. */
\r
776 portYIELD_WITHIN_API();
\r
780 taskEXIT_CRITICAL();
\r
785 if( xTicksToWait == ( portTickType ) 0 )
\r
787 taskEXIT_CRITICAL();
\r
788 return errQUEUE_FULL;
\r
790 else if( xEntryTimeSet == pdFALSE )
\r
792 vTaskSetTimeOutState( &xTimeOut );
\r
793 xEntryTimeSet = pdTRUE;
\r
797 taskEXIT_CRITICAL();
\r
799 taskENTER_CRITICAL();
\r
801 if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
\r
803 if( prvIsQueueFull( pxQueue ) != pdFALSE )
\r
805 traceBLOCKING_ON_QUEUE_SEND( pxQueue );
\r
806 vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );
\r
807 portYIELD_WITHIN_API();
\r
812 taskEXIT_CRITICAL();
\r
813 traceQUEUE_SEND_FAILED( pxQueue );
\r
814 return errQUEUE_FULL;
\r
817 taskEXIT_CRITICAL();
\r
821 #endif /* configUSE_ALTERNATIVE_API */
\r
822 /*-----------------------------------------------------------*/
\r
824 #if ( configUSE_ALTERNATIVE_API == 1 )
\r
826 signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking )
\r
828 signed portBASE_TYPE xEntryTimeSet = pdFALSE;
\r
829 xTimeOutType xTimeOut;
\r
830 signed char *pcOriginalReadPosition;
\r
832 configASSERT( pxQueue );
\r
833 configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );
\r
837 taskENTER_CRITICAL();
\r
839 if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
\r
841 /* Remember our read position in case we are just peeking. */
\r
842 pcOriginalReadPosition = pxQueue->pcReadFrom;
\r
844 prvCopyDataFromQueue( pxQueue, pvBuffer );
\r
846 if( xJustPeeking == pdFALSE )
\r
848 traceQUEUE_RECEIVE( pxQueue );
\r
850 /* We are actually removing data. */
\r
851 --( pxQueue->uxMessagesWaiting );
\r
853 #if ( configUSE_MUTEXES == 1 )
\r
855 if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
\r
857 /* Record the information required to implement
\r
858 priority inheritance should it become necessary. */
\r
859 pxQueue->pxMutexHolder = xTaskGetCurrentTaskHandle();
\r
864 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
\r
866 if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )
\r
868 portYIELD_WITHIN_API();
\r
874 traceQUEUE_PEEK( pxQueue );
\r
876 /* We are not removing the data, so reset our read
\r
878 pxQueue->pcReadFrom = pcOriginalReadPosition;
\r
880 /* The data is being left in the queue, so see if there are
\r
881 any other tasks waiting for the data. */
\r
882 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
\r
884 /* Tasks that are removed from the event list will get added to
\r
885 the pending ready list as the scheduler is still suspended. */
\r
886 if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
\r
888 /* The task waiting has a higher priority than this task. */
\r
889 portYIELD_WITHIN_API();
\r
895 taskEXIT_CRITICAL();
\r
900 if( xTicksToWait == ( portTickType ) 0 )
\r
902 taskEXIT_CRITICAL();
\r
903 traceQUEUE_RECEIVE_FAILED( pxQueue );
\r
904 return errQUEUE_EMPTY;
\r
906 else if( xEntryTimeSet == pdFALSE )
\r
908 vTaskSetTimeOutState( &xTimeOut );
\r
909 xEntryTimeSet = pdTRUE;
\r
913 taskEXIT_CRITICAL();
\r
915 taskENTER_CRITICAL();
\r
917 if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
\r
919 if( prvIsQueueEmpty( pxQueue ) != pdFALSE )
\r
921 traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );
\r
923 #if ( configUSE_MUTEXES == 1 )
\r
925 if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
\r
927 portENTER_CRITICAL();
\r
929 vTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder );
\r
931 portEXIT_CRITICAL();
\r
936 vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );
\r
937 portYIELD_WITHIN_API();
\r
942 taskEXIT_CRITICAL();
\r
943 traceQUEUE_RECEIVE_FAILED( pxQueue );
\r
944 return errQUEUE_EMPTY;
\r
947 taskEXIT_CRITICAL();
\r
952 #endif /* configUSE_ALTERNATIVE_API */
\r
953 /*-----------------------------------------------------------*/
\r
955 signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition )
\r
957 signed portBASE_TYPE xReturn;
\r
958 unsigned portBASE_TYPE uxSavedInterruptStatus;
\r
960 configASSERT( pxQueue );
\r
961 configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );
\r
963 /* Similar to xQueueGenericSend, except we don't block if there is no room
\r
964 in the queue. Also we don't directly wake a task that was blocked on a
\r
965 queue read, instead we return a flag to say whether a context switch is
\r
966 required or not (i.e. has a task with a higher priority than us been woken
\r
968 uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
\r
970 if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )
\r
972 traceQUEUE_SEND_FROM_ISR( pxQueue );
\r
974 prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
\r
976 /* If the queue is locked we do not alter the event list. This will
\r
977 be done when the queue is unlocked later. */
\r
978 if( pxQueue->xTxLock == queueUNLOCKED )
\r
980 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
\r
982 if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
\r
984 /* The task waiting has a higher priority so record that a
\r
985 context switch is required. */
\r
986 if( pxHigherPriorityTaskWoken != NULL )
\r
988 *pxHigherPriorityTaskWoken = pdTRUE;
\r
994 #if ( configUSE_QUEUE_SETS == 1 )
\r
996 if( pxQueue->pxQueueSetContainer != NULL )
\r
998 if( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) == pdTRUE )
\r
1000 /* The queue is a member of a queue set, and posting
\r
1001 to the queue set caused a higher priority task to
\r
1002 unblock. A context switch is required. */
\r
1003 if( pxHigherPriorityTaskWoken != NULL )
\r
1005 *pxHigherPriorityTaskWoken = pdTRUE;
\r
1010 #endif /* configUSE_QUEUE_SETS */
\r
1015 /* Increment the lock count so the task that unlocks the queue
\r
1016 knows that data was posted while it was locked. */
\r
1017 ++( pxQueue->xTxLock );
\r
1024 traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue );
\r
1025 xReturn = errQUEUE_FULL;
\r
1028 portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );
\r
1032 /*-----------------------------------------------------------*/
\r
1034 signed portBASE_TYPE xQueueGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking )
\r
1036 signed portBASE_TYPE xEntryTimeSet = pdFALSE;
\r
1037 xTimeOutType xTimeOut;
\r
1038 signed char *pcOriginalReadPosition;
\r
1040 configASSERT( pxQueue );
\r
1041 configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );
\r
1043 /* This function relaxes the coding standard somewhat to allow return
\r
1044 statements within the function itself. This is done in the interest
\r
1045 of execution time efficiency. */
\r
1049 taskENTER_CRITICAL();
\r
1051 /* Is there data in the queue now? To be running we must be
\r
1052 the highest priority task wanting to access the queue. */
\r
1053 if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
\r
1055 /* Remember our read position in case we are just peeking. */
\r
1056 pcOriginalReadPosition = pxQueue->pcReadFrom;
\r
1058 prvCopyDataFromQueue( pxQueue, pvBuffer );
\r
1060 if( xJustPeeking == pdFALSE )
\r
1062 traceQUEUE_RECEIVE( pxQueue );
\r
1064 /* We are actually removing data. */
\r
1065 --( pxQueue->uxMessagesWaiting );
\r
1067 #if ( configUSE_MUTEXES == 1 )
\r
1069 if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
\r
1071 /* Record the information required to implement
\r
1072 priority inheritance should it become necessary. */
\r
1073 pxQueue->pxMutexHolder = xTaskGetCurrentTaskHandle();
\r
1078 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
\r
1080 if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )
\r
1082 portYIELD_WITHIN_API();
\r
1088 traceQUEUE_PEEK( pxQueue );
\r
1090 /* The data is not being removed, so reset the read
\r
1092 pxQueue->pcReadFrom = pcOriginalReadPosition;
\r
1094 /* The data is being left in the queue, so see if there are
\r
1095 any other tasks waiting for the data. */
\r
1096 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
\r
1098 /* Tasks that are removed from the event list will get added to
\r
1099 the pending ready list as the scheduler is still suspended. */
\r
1100 if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
\r
1102 /* The task waiting has a higher priority than this task. */
\r
1103 portYIELD_WITHIN_API();
\r
1108 taskEXIT_CRITICAL();
\r
1113 if( xTicksToWait == ( portTickType ) 0 )
\r
1115 /* The queue was empty and no block time is specified (or
\r
1116 the block time has expired) so leave now. */
\r
1117 taskEXIT_CRITICAL();
\r
1118 traceQUEUE_RECEIVE_FAILED( pxQueue );
\r
1119 return errQUEUE_EMPTY;
\r
1121 else if( xEntryTimeSet == pdFALSE )
\r
1123 /* The queue was empty and a block time was specified so
\r
1124 configure the timeout structure. */
\r
1125 vTaskSetTimeOutState( &xTimeOut );
\r
1126 xEntryTimeSet = pdTRUE;
\r
1130 taskEXIT_CRITICAL();
\r
1132 /* Interrupts and other tasks can send to and receive from the queue
\r
1133 now the critical section has been exited. */
\r
1135 vTaskSuspendAll();
\r
1136 prvLockQueue( pxQueue );
\r
1138 /* Update the timeout state to see if it has expired yet. */
\r
1139 if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
\r
1141 if( prvIsQueueEmpty( pxQueue ) != pdFALSE )
\r
1143 traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );
\r
1145 #if ( configUSE_MUTEXES == 1 )
\r
1147 if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
\r
1149 portENTER_CRITICAL();
\r
1151 vTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder );
\r
1153 portEXIT_CRITICAL();
\r
1158 vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );
\r
1159 prvUnlockQueue( pxQueue );
\r
1160 if( xTaskResumeAll() == pdFALSE )
\r
1162 portYIELD_WITHIN_API();
\r
1168 prvUnlockQueue( pxQueue );
\r
1169 ( void ) xTaskResumeAll();
\r
1174 prvUnlockQueue( pxQueue );
\r
1175 ( void ) xTaskResumeAll();
\r
1176 traceQUEUE_RECEIVE_FAILED( pxQueue );
\r
1177 return errQUEUE_EMPTY;
\r
1181 /*-----------------------------------------------------------*/
\r
1183 signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken )
\r
1185 signed portBASE_TYPE xReturn;
\r
1186 unsigned portBASE_TYPE uxSavedInterruptStatus;
\r
1188 configASSERT( pxQueue );
\r
1189 configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );
\r
1191 uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
\r
1193 /* We cannot block from an ISR, so check there is data available. */
\r
1194 if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
\r
1196 traceQUEUE_RECEIVE_FROM_ISR( pxQueue );
\r
1198 prvCopyDataFromQueue( pxQueue, pvBuffer );
\r
1199 --( pxQueue->uxMessagesWaiting );
\r
1201 /* If the queue is locked we will not modify the event list. Instead
\r
1202 we update the lock count so the task that unlocks the queue will know
\r
1203 that an ISR has removed data while the queue was locked. */
\r
1204 if( pxQueue->xRxLock == queueUNLOCKED )
\r
1206 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
\r
1208 if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
\r
1210 /* The task waiting has a higher priority than us so
\r
1211 force a context switch. */
\r
1212 if( pxHigherPriorityTaskWoken != NULL )
\r
1214 *pxHigherPriorityTaskWoken = pdTRUE;
\r
1221 /* Increment the lock count so the task that unlocks the queue
\r
1222 knows that data was removed while it was locked. */
\r
1223 ++( pxQueue->xRxLock );
\r
1231 traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue );
\r
1234 portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );
\r
1238 /*-----------------------------------------------------------*/
\r
1240 unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue )
\r
1242 unsigned portBASE_TYPE uxReturn;
\r
1244 configASSERT( pxQueue );
\r
1246 taskENTER_CRITICAL();
\r
1247 uxReturn = pxQueue->uxMessagesWaiting;
\r
1248 taskEXIT_CRITICAL();
\r
1252 /*-----------------------------------------------------------*/
\r
1254 unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue )
\r
1256 unsigned portBASE_TYPE uxReturn;
\r
1258 configASSERT( pxQueue );
\r
1260 uxReturn = pxQueue->uxMessagesWaiting;
\r
1264 /*-----------------------------------------------------------*/
\r
1266 void vQueueDelete( xQueueHandle pxQueue )
\r
1268 configASSERT( pxQueue );
\r
1270 traceQUEUE_DELETE( pxQueue );
\r
1271 vQueueUnregisterQueue( pxQueue );
\r
1272 vPortFree( pxQueue->pcHead );
\r
1273 vPortFree( pxQueue );
\r
1275 /*-----------------------------------------------------------*/
\r
1277 #if ( configUSE_TRACE_FACILITY == 1 )
\r
1279 unsigned char ucQueueGetQueueNumber( xQueueHandle pxQueue )
\r
1281 return pxQueue->ucQueueNumber;
\r
1284 #endif /* configUSE_TRACE_FACILITY */
\r
1285 /*-----------------------------------------------------------*/
\r
1287 #if ( configUSE_TRACE_FACILITY == 1 )
\r
1289 void vQueueSetQueueNumber( xQueueHandle pxQueue, unsigned char ucQueueNumber )
\r
1291 pxQueue->ucQueueNumber = ucQueueNumber;
\r
1294 #endif /* configUSE_TRACE_FACILITY */
\r
1295 /*-----------------------------------------------------------*/
\r
1297 #if ( configUSE_TRACE_FACILITY == 1 )
\r
1299 unsigned char ucQueueGetQueueType( xQueueHandle pxQueue )
\r
1301 return pxQueue->ucQueueType;
\r
1304 #endif /* configUSE_TRACE_FACILITY */
\r
1305 /*-----------------------------------------------------------*/
\r
1307 static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, portBASE_TYPE xPosition )
\r
1309 if( pxQueue->uxItemSize == ( unsigned portBASE_TYPE ) 0 )
\r
1311 #if ( configUSE_MUTEXES == 1 )
\r
1313 if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
\r
1315 /* The mutex is no longer being held. */
\r
1316 vTaskPriorityDisinherit( ( void * ) pxQueue->pxMutexHolder );
\r
1317 pxQueue->pxMutexHolder = NULL;
\r
1322 else if( xPosition == queueSEND_TO_BACK )
\r
1324 memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( unsigned ) pxQueue->uxItemSize );
\r
1325 pxQueue->pcWriteTo += pxQueue->uxItemSize;
\r
1326 if( pxQueue->pcWriteTo >= pxQueue->pcTail )
\r
1328 pxQueue->pcWriteTo = pxQueue->pcHead;
\r
1333 memcpy( ( void * ) pxQueue->pcReadFrom, pvItemToQueue, ( unsigned ) pxQueue->uxItemSize );
\r
1334 pxQueue->pcReadFrom -= pxQueue->uxItemSize;
\r
1335 if( pxQueue->pcReadFrom < pxQueue->pcHead )
\r
1337 pxQueue->pcReadFrom = ( pxQueue->pcTail - pxQueue->uxItemSize );
\r
1341 ++( pxQueue->uxMessagesWaiting );
\r
1343 /*-----------------------------------------------------------*/
\r
1345 static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer )
\r
1347 if( pxQueue->uxQueueType != queueQUEUE_IS_MUTEX )
\r
1349 pxQueue->pcReadFrom += pxQueue->uxItemSize;
\r
1350 if( pxQueue->pcReadFrom >= pxQueue->pcTail )
\r
1352 pxQueue->pcReadFrom = pxQueue->pcHead;
\r
1354 memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize );
\r
1357 /*-----------------------------------------------------------*/
\r
1359 static void prvUnlockQueue( xQueueHandle pxQueue )
\r
1361 /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. */
\r
1363 /* The lock counts contains the number of extra data items placed or
\r
1364 removed from the queue while the queue was locked. When a queue is
\r
1365 locked items can be added or removed, but the event lists cannot be
\r
1367 taskENTER_CRITICAL();
\r
1369 /* See if data was added to the queue while it was locked. */
\r
1370 while( pxQueue->xTxLock > queueLOCKED_UNMODIFIED )
\r
1372 /* Data was posted while the queue was locked. Are any tasks
\r
1373 blocked waiting for data to become available? */
\r
1374 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
\r
1376 /* Tasks that are removed from the event list will get added to
\r
1377 the pending ready list as the scheduler is still suspended. */
\r
1378 if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
\r
1380 /* The task waiting has a higher priority so record that a
\r
1381 context switch is required. */
\r
1382 vTaskMissedYield();
\r
1386 #if ( configUSE_QUEUE_SETS == 1 )
\r
1388 /* It is highly unlikely that this code will ever run,
\r
1389 for the following reason:
\r
1390 + A task will only lock a queue that is part of a
\r
1391 queue set when it is blocking on a write to the
\r
1393 + An interrupt can only add something to a queue
\r
1394 while the queue is locked (resulting in the
\r
1395 following code executing when the queue is unlocked)
\r
1396 if the queue is not full, meaning a task will never
\r
1397 have blocked on a write in the first place.
\r
1398 The code could execute if an interrupt is also removing
\r
1399 items from a queue. */
\r
1400 if( pxQueue->pxQueueSetContainer != NULL )
\r
1402 if( prvNotifyQueueSetContainer( pxQueue, queueSEND_TO_BACK ) == pdTRUE )
\r
1404 /* The queue is a member of a queue set, and posting to
\r
1405 the queue set caused a higher priority task to unblock.
\r
1406 A context switch is required. */
\r
1407 vTaskMissedYield();
\r
1411 #endif /* configUSE_QUEUE_SETS */
\r
1414 --( pxQueue->xTxLock );
\r
1422 pxQueue->xTxLock = queueUNLOCKED;
\r
1424 taskEXIT_CRITICAL();
\r
1426 /* Do the same for the Rx lock. */
\r
1427 taskENTER_CRITICAL();
\r
1429 while( pxQueue->xRxLock > queueLOCKED_UNMODIFIED )
\r
1431 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
\r
1433 if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
\r
1435 vTaskMissedYield();
\r
1438 --( pxQueue->xRxLock );
\r
1446 pxQueue->xRxLock = queueUNLOCKED;
\r
1448 taskEXIT_CRITICAL();
\r
1450 /*-----------------------------------------------------------*/
\r
1452 static signed portBASE_TYPE prvIsQueueEmpty( const xQueueHandle pxQueue )
\r
1454 signed portBASE_TYPE xReturn;
\r
1456 taskENTER_CRITICAL();
\r
1457 xReturn = ( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 );
\r
1458 taskEXIT_CRITICAL();
\r
1462 /*-----------------------------------------------------------*/
\r
1464 signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue )
\r
1466 signed portBASE_TYPE xReturn;
\r
1468 configASSERT( pxQueue );
\r
1469 xReturn = ( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 );
\r
1473 /*-----------------------------------------------------------*/
\r
1475 static signed portBASE_TYPE prvIsQueueFull( const xQueueHandle pxQueue )
\r
1477 signed portBASE_TYPE xReturn;
\r
1479 taskENTER_CRITICAL();
\r
1480 xReturn = ( pxQueue->uxMessagesWaiting == pxQueue->uxLength );
\r
1481 taskEXIT_CRITICAL();
\r
1485 /*-----------------------------------------------------------*/
\r
1487 signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue )
\r
1489 signed portBASE_TYPE xReturn;
\r
1491 configASSERT( pxQueue );
\r
1492 xReturn = ( pxQueue->uxMessagesWaiting == pxQueue->uxLength );
\r
1496 /*-----------------------------------------------------------*/
\r
1498 #if ( configUSE_CO_ROUTINES == 1 )
\r
1500 signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait )
\r
1502 signed portBASE_TYPE xReturn;
\r
1504 /* If the queue is already full we may have to block. A critical section
\r
1505 is required to prevent an interrupt removing something from the queue
\r
1506 between the check to see if the queue is full and blocking on the queue. */
\r
1507 portDISABLE_INTERRUPTS();
\r
1509 if( prvIsQueueFull( pxQueue ) != pdFALSE )
\r
1511 /* The queue is full - do we want to block or just leave without
\r
1513 if( xTicksToWait > ( portTickType ) 0 )
\r
1515 /* As this is called from a coroutine we cannot block directly, but
\r
1516 return indicating that we need to block. */
\r
1517 vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToSend ) );
\r
1518 portENABLE_INTERRUPTS();
\r
1519 return errQUEUE_BLOCKED;
\r
1523 portENABLE_INTERRUPTS();
\r
1524 return errQUEUE_FULL;
\r
1528 portENABLE_INTERRUPTS();
\r
1532 portDISABLE_INTERRUPTS();
\r
1534 if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )
\r
1536 /* There is room in the queue, copy the data into the queue. */
\r
1537 prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK );
\r
1540 /* Were any co-routines waiting for data to become available? */
\r
1541 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
\r
1543 /* In this instance the co-routine could be placed directly
\r
1544 into the ready list as we are within a critical section.
\r
1545 Instead the same pending ready list mechanism is used as if
\r
1546 the event were caused from within an interrupt. */
\r
1547 if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
\r
1549 /* The co-routine waiting has a higher priority so record
\r
1550 that a yield might be appropriate. */
\r
1551 xReturn = errQUEUE_YIELD;
\r
1557 xReturn = errQUEUE_FULL;
\r
1560 portENABLE_INTERRUPTS();
\r
1565 #endif /* configUSE_CO_ROUTINES */
\r
1566 /*-----------------------------------------------------------*/
\r
1568 #if ( configUSE_CO_ROUTINES == 1 )
\r
1570 signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait )
\r
1572 signed portBASE_TYPE xReturn;
\r
1574 /* If the queue is already empty we may have to block. A critical section
\r
1575 is required to prevent an interrupt adding something to the queue
\r
1576 between the check to see if the queue is empty and blocking on the queue. */
\r
1577 portDISABLE_INTERRUPTS();
\r
1579 if( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 )
\r
1581 /* There are no messages in the queue, do we want to block or just
\r
1582 leave with nothing? */
\r
1583 if( xTicksToWait > ( portTickType ) 0 )
\r
1585 /* As this is a co-routine we cannot block directly, but return
\r
1586 indicating that we need to block. */
\r
1587 vCoRoutineAddToDelayedList( xTicksToWait, &( pxQueue->xTasksWaitingToReceive ) );
\r
1588 portENABLE_INTERRUPTS();
\r
1589 return errQUEUE_BLOCKED;
\r
1593 portENABLE_INTERRUPTS();
\r
1594 return errQUEUE_FULL;
\r
1598 portENABLE_INTERRUPTS();
\r
1602 portDISABLE_INTERRUPTS();
\r
1604 if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
\r
1606 /* Data is available from the queue. */
\r
1607 pxQueue->pcReadFrom += pxQueue->uxItemSize;
\r
1608 if( pxQueue->pcReadFrom >= pxQueue->pcTail )
\r
1610 pxQueue->pcReadFrom = pxQueue->pcHead;
\r
1612 --( pxQueue->uxMessagesWaiting );
\r
1613 memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize );
\r
1617 /* Were any co-routines waiting for space to become available? */
\r
1618 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
\r
1620 /* In this instance the co-routine could be placed directly
\r
1621 into the ready list as we are within a critical section.
\r
1622 Instead the same pending ready list mechanism is used as if
\r
1623 the event were caused from within an interrupt. */
\r
1624 if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
\r
1626 xReturn = errQUEUE_YIELD;
\r
1635 portENABLE_INTERRUPTS();
\r
1640 #endif /* configUSE_CO_ROUTINES */
\r
1641 /*-----------------------------------------------------------*/
\r
1643 #if ( configUSE_CO_ROUTINES == 1 )
\r
1645 signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken )
\r
1647 /* Cannot block within an ISR so if there is no space on the queue then
\r
1648 exit without doing anything. */
\r
1649 if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )
\r
1651 prvCopyDataToQueue( pxQueue, pvItemToQueue, queueSEND_TO_BACK );
\r
1653 /* We only want to wake one co-routine per ISR, so check that a
\r
1654 co-routine has not already been woken. */
\r
1655 if( xCoRoutinePreviouslyWoken == pdFALSE )
\r
1657 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
\r
1659 if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
\r
1667 return xCoRoutinePreviouslyWoken;
\r
1670 #endif /* configUSE_CO_ROUTINES */
\r
1671 /*-----------------------------------------------------------*/
\r
1673 #if ( configUSE_CO_ROUTINES == 1 )
\r
1675 signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxCoRoutineWoken )
\r
1677 signed portBASE_TYPE xReturn;
\r
1679 /* We cannot block from an ISR, so check there is data available. If
\r
1680 not then just leave without doing anything. */
\r
1681 if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
\r
1683 /* Copy the data from the queue. */
\r
1684 pxQueue->pcReadFrom += pxQueue->uxItemSize;
\r
1685 if( pxQueue->pcReadFrom >= pxQueue->pcTail )
\r
1687 pxQueue->pcReadFrom = pxQueue->pcHead;
\r
1689 --( pxQueue->uxMessagesWaiting );
\r
1690 memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize );
\r
1692 if( ( *pxCoRoutineWoken ) == pdFALSE )
\r
1694 if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
\r
1696 if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
\r
1698 *pxCoRoutineWoken = pdTRUE;
\r
1713 #endif /* configUSE_CO_ROUTINES */
\r
1714 /*-----------------------------------------------------------*/
\r
1716 #if ( configQUEUE_REGISTRY_SIZE > 0 )
\r
1718 void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcQueueName )
\r
1720 unsigned portBASE_TYPE ux;
\r
1722 /* See if there is an empty space in the registry. A NULL name denotes
\r
1724 for( ux = ( unsigned portBASE_TYPE ) 0U; ux < ( unsigned portBASE_TYPE ) configQUEUE_REGISTRY_SIZE; ux++ )
\r
1726 if( xQueueRegistry[ ux ].pcQueueName == NULL )
\r
1728 /* Store the information on this queue. */
\r
1729 xQueueRegistry[ ux ].pcQueueName = pcQueueName;
\r
1730 xQueueRegistry[ ux ].xHandle = xQueue;
\r
1736 #endif /* configQUEUE_REGISTRY_SIZE */
\r
1737 /*-----------------------------------------------------------*/
\r
1739 #if ( configQUEUE_REGISTRY_SIZE > 0 )
\r
1741 static void vQueueUnregisterQueue( xQueueHandle xQueue )
\r
1743 unsigned portBASE_TYPE ux;
\r
1745 /* See if the handle of the queue being unregistered in actually in the
\r
1747 for( ux = ( unsigned portBASE_TYPE ) 0U; ux < ( unsigned portBASE_TYPE ) configQUEUE_REGISTRY_SIZE; ux++ )
\r
1749 if( xQueueRegistry[ ux ].xHandle == xQueue )
\r
1751 /* Set the name to NULL to show that this slot if free again. */
\r
1752 xQueueRegistry[ ux ].pcQueueName = NULL;
\r
1759 #endif /* configQUEUE_REGISTRY_SIZE */
\r
1760 /*-----------------------------------------------------------*/
\r
1762 #if ( configUSE_TIMERS == 1 )
\r
1764 void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait )
\r
1766 /* This function should not be called by application code hence the
\r
1767 'Restricted' in its name. It is not part of the public API. It is
\r
1768 designed for use by kernel code, and has special calling requirements.
\r
1769 It can result in vListInsert() being called on a list that can only
\r
1770 possibly ever have one item in it, so the list will be fast, but even
\r
1771 so it should be called with the scheduler locked and not from a critical
\r
1774 /* Only do anything if there are no messages in the queue. This function
\r
1775 will not actually cause the task to block, just place it on a blocked
\r
1776 list. It will not block until the scheduler is unlocked - at which
\r
1777 time a yield will be performed. If an item is added to the queue while
\r
1778 the queue is locked, and the calling task blocks on the queue, then the
\r
1779 calling task will be immediately unblocked when the queue is unlocked. */
\r
1780 prvLockQueue( pxQueue );
\r
1781 if( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0U )
\r
1783 /* There is nothing in the queue, block for the specified period. */
\r
1784 vTaskPlaceOnEventListRestricted( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );
\r
1786 prvUnlockQueue( pxQueue );
\r
1789 #endif /* configUSE_TIMERS */
\r
1790 /*-----------------------------------------------------------*/
\r
1792 #if ( configUSE_QUEUE_SETS == 1 )
\r
1794 xQueueSetHandle xQueueSetCreate( unsigned portBASE_TYPE uxEventQueueLength )
\r
1798 pxQueue = xQueueGenericCreate( uxEventQueueLength, sizeof( xQUEUE * ), queueQUEUE_TYPE_SET );
\r
1800 return ( xQueueSetHandle ) pxQueue;
\r
1803 #endif /* configUSE_QUEUE_SETS */
\r
1804 /*-----------------------------------------------------------*/
\r
1806 #if ( configUSE_QUEUE_SETS == 1 )
\r
1808 portBASE_TYPE xQueueAddToQueueSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet )
\r
1810 portBASE_TYPE xReturn;
\r
1812 if( xQueueOrSemaphore->pxQueueSetContainer != NULL )
\r
1818 taskENTER_CRITICAL();
\r
1820 xQueueOrSemaphore->pxQueueSetContainer = xQueueSet;
\r
1822 taskEXIT_CRITICAL();
\r
1829 #endif /* configUSE_QUEUE_SETS */
\r
1830 /*-----------------------------------------------------------*/
\r
1832 #if ( configUSE_QUEUE_SETS == 1 )
\r
1834 portBASE_TYPE xQueueRemoveFromQueueSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet )
\r
1836 portBASE_TYPE xReturn;
\r
1838 if( xQueueOrSemaphore->pxQueueSetContainer != xQueueSet )
\r
1844 taskENTER_CRITICAL();
\r
1846 xQueueOrSemaphore->pxQueueSetContainer = NULL;
\r
1848 taskEXIT_CRITICAL();
\r
1855 #endif /* configUSE_QUEUE_SETS */
\r
1856 /*-----------------------------------------------------------*/
\r
1858 #if ( configUSE_QUEUE_SETS == 1 )
\r
1860 xQueueSetMemberHandle xQueueBlockMultiple( xQueueSetHandle xQueueSet, portTickType xBlockTimeTicks )
\r
1862 xQueueSetMemberHandle xReturn = NULL;
\r
1864 xQueueGenericReceive( ( xQueueHandle ) xQueueSet, &xReturn, xBlockTimeTicks, pdFALSE );
\r
1868 #endif /* configUSE_QUEUE_SETS */
\r
1869 /*-----------------------------------------------------------*/
\r
1871 #if ( configUSE_QUEUE_SETS == 1 )
\r
1873 static portBASE_TYPE prvNotifyQueueSetContainer( xQUEUE *pxQueue, portBASE_TYPE xCopyPosition )
\r
1875 xQUEUE *pxQueueSetContainer = pxQueue->pxQueueSetContainer;
\r
1876 portBASE_TYPE xReturn = pdFALSE;
\r
1878 configASSERT( pxQueueSetContainer );
\r
1879 configASSERT( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength );
\r
1881 if( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength )
\r
1883 prvCopyDataToQueue( pxQueueSetContainer, &pxQueue, xCopyPosition );
\r
1884 if( listLIST_IS_EMPTY( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) == pdFALSE )
\r
1886 if( xTaskRemoveFromEventList( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) != pdFALSE )
\r
1888 /* The task waiting has a higher priority */
\r
1897 #endif /* configUSE_QUEUE_SETS */
\r