2 * FreeRTOS Kernel V10.0.1
3 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * http://www.FreeRTOS.org
23 * http://aws.amazon.com/freertos
28 /* Standard includes. */
31 /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
32 all the API functions to use the MPU wrappers. That should only be done when
33 task.h is included from an application file. */
34 #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
36 /* FreeRTOS includes. */
40 #include "event_groups.h"
42 /* Lint e961 and e750 are suppressed as a MISRA exception justified because the
43 MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the
44 header files above, but not in this file, in order to generate the correct
45 privileged Vs unprivileged linkage and placement. */
46 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */
48 /* The following bit fields convey control information in a task's event list
49 item value. It is important they don't clash with the
50 taskEVENT_LIST_ITEM_VALUE_IN_USE definition. */
51 #if configUSE_16_BIT_TICKS == 1
52 #define eventCLEAR_EVENTS_ON_EXIT_BIT 0x0100U
53 #define eventUNBLOCKED_DUE_TO_BIT_SET 0x0200U
54 #define eventWAIT_FOR_ALL_BITS 0x0400U
55 #define eventEVENT_BITS_CONTROL_BYTES 0xff00U
57 #define eventCLEAR_EVENTS_ON_EXIT_BIT 0x01000000UL
58 #define eventUNBLOCKED_DUE_TO_BIT_SET 0x02000000UL
59 #define eventWAIT_FOR_ALL_BITS 0x04000000UL
60 #define eventEVENT_BITS_CONTROL_BYTES 0xff000000UL
63 typedef struct xEventGroupDefinition
65 EventBits_t uxEventBits;
66 List_t xTasksWaitingForBits; /*< List of tasks waiting for a bit to be set. */
68 #if( configUSE_TRACE_FACILITY == 1 )
69 UBaseType_t uxEventGroupNumber;
72 #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
73 uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the event group is statically allocated to ensure no attempt is made to free the memory. */
77 /*-----------------------------------------------------------*/
80 * Test the bits set in uxCurrentEventBits to see if the wait condition is met.
81 * The wait condition is defined by xWaitForAllBits. If xWaitForAllBits is
82 * pdTRUE then the wait condition is met if all the bits set in uxBitsToWaitFor
83 * are also set in uxCurrentEventBits. If xWaitForAllBits is pdFALSE then the
84 * wait condition is met if any of the bits set in uxBitsToWait for are also set
85 * in uxCurrentEventBits.
87 static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, const EventBits_t uxBitsToWaitFor, const BaseType_t xWaitForAllBits ) PRIVILEGED_FUNCTION;
89 /*-----------------------------------------------------------*/
91 #if( configSUPPORT_STATIC_ALLOCATION == 1 )
93 EventGroupHandle_t xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer )
95 EventGroup_t *pxEventBits;
97 /* A StaticEventGroup_t object must be provided. */
98 configASSERT( pxEventGroupBuffer );
100 #if( configASSERT_DEFINED == 1 )
102 /* Sanity check that the size of the structure used to declare a
103 variable of type StaticEventGroup_t equals the size of the real
104 event group structure. */
105 volatile size_t xSize = sizeof( StaticEventGroup_t );
106 configASSERT( xSize == sizeof( EventGroup_t ) );
108 #endif /* configASSERT_DEFINED */
110 /* The user has provided a statically allocated event group - use it. */
111 pxEventBits = ( EventGroup_t * ) pxEventGroupBuffer; /*lint !e740 EventGroup_t and StaticEventGroup_t are guaranteed to have the same size and alignment requirement - checked by configASSERT(). */
113 if( pxEventBits != NULL )
115 pxEventBits->uxEventBits = 0;
116 vListInitialise( &( pxEventBits->xTasksWaitingForBits ) );
118 #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
120 /* Both static and dynamic allocation can be used, so note that
121 this event group was created statically in case the event group
123 pxEventBits->ucStaticallyAllocated = pdTRUE;
125 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
127 traceEVENT_GROUP_CREATE( pxEventBits );
131 traceEVENT_GROUP_CREATE_FAILED();
134 return ( EventGroupHandle_t ) pxEventBits;
137 #endif /* configSUPPORT_STATIC_ALLOCATION */
138 /*-----------------------------------------------------------*/
140 #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
142 EventGroupHandle_t xEventGroupCreate( void )
144 EventGroup_t *pxEventBits;
146 /* Allocate the event group. */
147 pxEventBits = ( EventGroup_t * ) pvPortMalloc( sizeof( EventGroup_t ) );
149 if( pxEventBits != NULL )
151 pxEventBits->uxEventBits = 0;
152 vListInitialise( &( pxEventBits->xTasksWaitingForBits ) );
154 #if( configSUPPORT_STATIC_ALLOCATION == 1 )
156 /* Both static and dynamic allocation can be used, so note this
157 event group was allocated statically in case the event group is
159 pxEventBits->ucStaticallyAllocated = pdFALSE;
161 #endif /* configSUPPORT_STATIC_ALLOCATION */
163 traceEVENT_GROUP_CREATE( pxEventBits );
167 traceEVENT_GROUP_CREATE_FAILED();
170 return ( EventGroupHandle_t ) pxEventBits;
173 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
174 /*-----------------------------------------------------------*/
176 EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait )
178 EventBits_t uxOriginalBitValue, uxReturn;
179 EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
180 BaseType_t xAlreadyYielded;
181 BaseType_t xTimeoutOccurred = pdFALSE;
183 configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
184 configASSERT( uxBitsToWaitFor != 0 );
185 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
187 configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
193 uxOriginalBitValue = pxEventBits->uxEventBits;
195 ( void ) xEventGroupSetBits( xEventGroup, uxBitsToSet );
197 if( ( ( uxOriginalBitValue | uxBitsToSet ) & uxBitsToWaitFor ) == uxBitsToWaitFor )
199 /* All the rendezvous bits are now set - no need to block. */
200 uxReturn = ( uxOriginalBitValue | uxBitsToSet );
202 /* Rendezvous always clear the bits. They will have been cleared
203 already unless this is the only task in the rendezvous. */
204 pxEventBits->uxEventBits &= ~uxBitsToWaitFor;
210 if( xTicksToWait != ( TickType_t ) 0 )
212 traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor );
214 /* Store the bits that the calling task is waiting for in the
215 task's event list item so the kernel knows when a match is
216 found. Then enter the blocked state. */
217 vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | eventCLEAR_EVENTS_ON_EXIT_BIT | eventWAIT_FOR_ALL_BITS ), xTicksToWait );
219 /* This assignment is obsolete as uxReturn will get set after
220 the task unblocks, but some compilers mistakenly generate a
221 warning about uxReturn being returned without being set if the
222 assignment is omitted. */
227 /* The rendezvous bits were not set, but no block time was
228 specified - just return the current event bit value. */
229 uxReturn = pxEventBits->uxEventBits;
230 xTimeoutOccurred = pdTRUE;
234 xAlreadyYielded = xTaskResumeAll();
236 if( xTicksToWait != ( TickType_t ) 0 )
238 if( xAlreadyYielded == pdFALSE )
240 portYIELD_WITHIN_API();
244 mtCOVERAGE_TEST_MARKER();
247 /* The task blocked to wait for its required bits to be set - at this
248 point either the required bits were set or the block time expired. If
249 the required bits were set they will have been stored in the task's
250 event list item, and they should now be retrieved then cleared. */
251 uxReturn = uxTaskResetEventItemValue();
253 if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 )
255 /* The task timed out, just return the current event bit value. */
256 taskENTER_CRITICAL();
258 uxReturn = pxEventBits->uxEventBits;
260 /* Although the task got here because it timed out before the
261 bits it was waiting for were set, it is possible that since it
262 unblocked another task has set the bits. If this is the case
263 then it needs to clear the bits before exiting. */
264 if( ( uxReturn & uxBitsToWaitFor ) == uxBitsToWaitFor )
266 pxEventBits->uxEventBits &= ~uxBitsToWaitFor;
270 mtCOVERAGE_TEST_MARKER();
275 xTimeoutOccurred = pdTRUE;
279 /* The task unblocked because the bits were set. */
282 /* Control bits might be set as the task had blocked should not be
284 uxReturn &= ~eventEVENT_BITS_CONTROL_BYTES;
287 traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred );
289 /* Prevent compiler warnings when trace macros are not used. */
290 ( void ) xTimeoutOccurred;
294 /*-----------------------------------------------------------*/
296 EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait )
298 EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
299 EventBits_t uxReturn, uxControlBits = 0;
300 BaseType_t xWaitConditionMet, xAlreadyYielded;
301 BaseType_t xTimeoutOccurred = pdFALSE;
303 /* Check the user is not attempting to wait on the bits used by the kernel
304 itself, and that at least one bit is being requested. */
305 configASSERT( xEventGroup );
306 configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
307 configASSERT( uxBitsToWaitFor != 0 );
308 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
310 configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
316 const EventBits_t uxCurrentEventBits = pxEventBits->uxEventBits;
318 /* Check to see if the wait condition is already met or not. */
319 xWaitConditionMet = prvTestWaitCondition( uxCurrentEventBits, uxBitsToWaitFor, xWaitForAllBits );
321 if( xWaitConditionMet != pdFALSE )
323 /* The wait condition has already been met so there is no need to
325 uxReturn = uxCurrentEventBits;
326 xTicksToWait = ( TickType_t ) 0;
328 /* Clear the wait bits if requested to do so. */
329 if( xClearOnExit != pdFALSE )
331 pxEventBits->uxEventBits &= ~uxBitsToWaitFor;
335 mtCOVERAGE_TEST_MARKER();
338 else if( xTicksToWait == ( TickType_t ) 0 )
340 /* The wait condition has not been met, but no block time was
341 specified, so just return the current value. */
342 uxReturn = uxCurrentEventBits;
343 xTimeoutOccurred = pdTRUE;
347 /* The task is going to block to wait for its required bits to be
348 set. uxControlBits are used to remember the specified behaviour of
349 this call to xEventGroupWaitBits() - for use when the event bits
351 if( xClearOnExit != pdFALSE )
353 uxControlBits |= eventCLEAR_EVENTS_ON_EXIT_BIT;
357 mtCOVERAGE_TEST_MARKER();
360 if( xWaitForAllBits != pdFALSE )
362 uxControlBits |= eventWAIT_FOR_ALL_BITS;
366 mtCOVERAGE_TEST_MARKER();
369 /* Store the bits that the calling task is waiting for in the
370 task's event list item so the kernel knows when a match is
371 found. Then enter the blocked state. */
372 vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | uxControlBits ), xTicksToWait );
374 /* This is obsolete as it will get set after the task unblocks, but
375 some compilers mistakenly generate a warning about the variable
376 being returned without being set if it is not done. */
379 traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor );
382 xAlreadyYielded = xTaskResumeAll();
384 if( xTicksToWait != ( TickType_t ) 0 )
386 if( xAlreadyYielded == pdFALSE )
388 portYIELD_WITHIN_API();
392 mtCOVERAGE_TEST_MARKER();
395 /* The task blocked to wait for its required bits to be set - at this
396 point either the required bits were set or the block time expired. If
397 the required bits were set they will have been stored in the task's
398 event list item, and they should now be retrieved then cleared. */
399 uxReturn = uxTaskResetEventItemValue();
401 if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 )
403 taskENTER_CRITICAL();
405 /* The task timed out, just return the current event bit value. */
406 uxReturn = pxEventBits->uxEventBits;
408 /* It is possible that the event bits were updated between this
409 task leaving the Blocked state and running again. */
410 if( prvTestWaitCondition( uxReturn, uxBitsToWaitFor, xWaitForAllBits ) != pdFALSE )
412 if( xClearOnExit != pdFALSE )
414 pxEventBits->uxEventBits &= ~uxBitsToWaitFor;
418 mtCOVERAGE_TEST_MARKER();
423 mtCOVERAGE_TEST_MARKER();
425 xTimeoutOccurred = pdTRUE;
431 /* The task unblocked because the bits were set. */
434 /* The task blocked so control bits may have been set. */
435 uxReturn &= ~eventEVENT_BITS_CONTROL_BYTES;
437 traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred );
439 /* Prevent compiler warnings when trace macros are not used. */
440 ( void ) xTimeoutOccurred;
444 /*-----------------------------------------------------------*/
446 EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear )
448 EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
449 EventBits_t uxReturn;
451 /* Check the user is not attempting to clear the bits used by the kernel
453 configASSERT( xEventGroup );
454 configASSERT( ( uxBitsToClear & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
456 taskENTER_CRITICAL();
458 traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear );
460 /* The value returned is the event group value prior to the bits being
462 uxReturn = pxEventBits->uxEventBits;
464 /* Clear the bits. */
465 pxEventBits->uxEventBits &= ~uxBitsToClear;
471 /*-----------------------------------------------------------*/
473 #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
475 BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear )
479 traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear );
480 xReturn = xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL );
486 /*-----------------------------------------------------------*/
488 EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup )
490 UBaseType_t uxSavedInterruptStatus;
491 EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
492 EventBits_t uxReturn;
494 uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
496 uxReturn = pxEventBits->uxEventBits;
498 portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );
502 /*-----------------------------------------------------------*/
504 EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet )
506 ListItem_t *pxListItem, *pxNext;
507 ListItem_t const *pxListEnd;
509 EventBits_t uxBitsToClear = 0, uxBitsWaitedFor, uxControlBits;
510 EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
511 BaseType_t xMatchFound = pdFALSE;
513 /* Check the user is not attempting to set the bits used by the kernel
515 configASSERT( xEventGroup );
516 configASSERT( ( uxBitsToSet & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
518 pxList = &( pxEventBits->xTasksWaitingForBits );
519 pxListEnd = listGET_END_MARKER( pxList ); /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
522 traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet );
524 pxListItem = listGET_HEAD_ENTRY( pxList );
527 pxEventBits->uxEventBits |= uxBitsToSet;
529 /* See if the new bit value should unblock any tasks. */
530 while( pxListItem != pxListEnd )
532 pxNext = listGET_NEXT( pxListItem );
533 uxBitsWaitedFor = listGET_LIST_ITEM_VALUE( pxListItem );
534 xMatchFound = pdFALSE;
536 /* Split the bits waited for from the control bits. */
537 uxControlBits = uxBitsWaitedFor & eventEVENT_BITS_CONTROL_BYTES;
538 uxBitsWaitedFor &= ~eventEVENT_BITS_CONTROL_BYTES;
540 if( ( uxControlBits & eventWAIT_FOR_ALL_BITS ) == ( EventBits_t ) 0 )
542 /* Just looking for single bit being set. */
543 if( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) != ( EventBits_t ) 0 )
545 xMatchFound = pdTRUE;
549 mtCOVERAGE_TEST_MARKER();
552 else if( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) == uxBitsWaitedFor )
554 /* All bits are set. */
555 xMatchFound = pdTRUE;
559 /* Need all bits to be set, but not all the bits were set. */
562 if( xMatchFound != pdFALSE )
564 /* The bits match. Should the bits be cleared on exit? */
565 if( ( uxControlBits & eventCLEAR_EVENTS_ON_EXIT_BIT ) != ( EventBits_t ) 0 )
567 uxBitsToClear |= uxBitsWaitedFor;
571 mtCOVERAGE_TEST_MARKER();
574 /* Store the actual event flag value in the task's event list
575 item before removing the task from the event list. The
576 eventUNBLOCKED_DUE_TO_BIT_SET bit is set so the task knows
577 that is was unblocked due to its required bits matching, rather
578 than because it timed out. */
579 vTaskRemoveFromUnorderedEventList( pxListItem, pxEventBits->uxEventBits | eventUNBLOCKED_DUE_TO_BIT_SET );
582 /* Move onto the next list item. Note pxListItem->pxNext is not
583 used here as the list item may have been removed from the event list
584 and inserted into the ready/pending reading list. */
588 /* Clear any bits that matched when the eventCLEAR_EVENTS_ON_EXIT_BIT
589 bit was set in the control word. */
590 pxEventBits->uxEventBits &= ~uxBitsToClear;
592 ( void ) xTaskResumeAll();
594 return pxEventBits->uxEventBits;
596 /*-----------------------------------------------------------*/
598 void vEventGroupDelete( EventGroupHandle_t xEventGroup )
600 EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
601 const List_t *pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits );
605 traceEVENT_GROUP_DELETE( xEventGroup );
607 while( listCURRENT_LIST_LENGTH( pxTasksWaitingForBits ) > ( UBaseType_t ) 0 )
609 /* Unblock the task, returning 0 as the event list is being deleted
610 and cannot therefore have any bits set. */
611 configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( const ListItem_t * ) &( pxTasksWaitingForBits->xListEnd ) );
612 vTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET );
615 #if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) )
617 /* The event group can only have been allocated dynamically - free
619 vPortFree( pxEventBits );
621 #elif( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
623 /* The event group could have been allocated statically or
624 dynamically, so check before attempting to free the memory. */
625 if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdFALSE )
627 vPortFree( pxEventBits );
631 mtCOVERAGE_TEST_MARKER();
634 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
636 ( void ) xTaskResumeAll();
638 /*-----------------------------------------------------------*/
640 /* For internal use only - execute a 'set bits' command that was pended from
642 void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet )
644 ( void ) xEventGroupSetBits( pvEventGroup, ( EventBits_t ) ulBitsToSet );
646 /*-----------------------------------------------------------*/
648 /* For internal use only - execute a 'clear bits' command that was pended from
650 void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear )
652 ( void ) xEventGroupClearBits( pvEventGroup, ( EventBits_t ) ulBitsToClear );
654 /*-----------------------------------------------------------*/
656 static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, const EventBits_t uxBitsToWaitFor, const BaseType_t xWaitForAllBits )
658 BaseType_t xWaitConditionMet = pdFALSE;
660 if( xWaitForAllBits == pdFALSE )
662 /* Task only has to wait for one bit within uxBitsToWaitFor to be
663 set. Is one already set? */
664 if( ( uxCurrentEventBits & uxBitsToWaitFor ) != ( EventBits_t ) 0 )
666 xWaitConditionMet = pdTRUE;
670 mtCOVERAGE_TEST_MARKER();
675 /* Task has to wait for all the bits in uxBitsToWaitFor to be set.
676 Are they set already? */
677 if( ( uxCurrentEventBits & uxBitsToWaitFor ) == uxBitsToWaitFor )
679 xWaitConditionMet = pdTRUE;
683 mtCOVERAGE_TEST_MARKER();
687 return xWaitConditionMet;
689 /*-----------------------------------------------------------*/
691 #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
693 BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken )
697 traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet );
698 xReturn = xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken );
704 /*-----------------------------------------------------------*/
706 #if (configUSE_TRACE_FACILITY == 1)
708 UBaseType_t uxEventGroupGetNumber( void* xEventGroup )
711 EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
713 if( xEventGroup == NULL )
719 xReturn = pxEventBits->uxEventGroupNumber;
725 #endif /* configUSE_TRACE_FACILITY */
726 /*-----------------------------------------------------------*/
728 #if ( configUSE_TRACE_FACILITY == 1 )
730 void vEventGroupSetNumber( void * xEventGroup, UBaseType_t uxEventGroupNumber )
732 ( ( EventGroup_t * ) xEventGroup )->uxEventGroupNumber = uxEventGroupNumber;
735 #endif /* configUSE_TRACE_FACILITY */
736 /*-----------------------------------------------------------*/