| 313 | /*-----------------------------------------------------------*/ |
| 314 | |
| 315 | EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, |
| 316 | const EventBits_t uxBitsToWaitFor, |
| 317 | const BaseType_t xClearOnExit, |
| 318 | const BaseType_t xWaitForAllBits, |
| 319 | TickType_t xTicksToWait ) |
| 320 | { |
| 321 | EventGroup_t * pxEventBits = xEventGroup; |
| 322 | EventBits_t uxReturn, uxControlBits = 0; |
| 323 | BaseType_t xWaitConditionMet, xAlreadyYielded; |
| 324 | BaseType_t xTimeoutOccurred = pdFALSE; |
| 325 | |
| 326 | /* Check the user is not attempting to wait on the bits used by the kernel |
| 327 | * itself, and that at least one bit is being requested. */ |
| 328 | configASSERT( xEventGroup ); |
| 329 | configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 ); |
| 330 | configASSERT( uxBitsToWaitFor != 0 ); |
| 331 | #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) |
| 332 | { |
| 333 | configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); |
| 334 | } |
| 335 | #endif |
| 336 | |
| 337 | vTaskSuspendAll(); |
| 338 | { |
| 339 | const EventBits_t uxCurrentEventBits = pxEventBits->uxEventBits; |
| 340 | |
| 341 | /* Check to see if the wait condition is already met or not. */ |
| 342 | xWaitConditionMet = prvTestWaitCondition( uxCurrentEventBits, uxBitsToWaitFor, xWaitForAllBits ); |
| 343 | |
| 344 | if( xWaitConditionMet != pdFALSE ) |
| 345 | { |
| 346 | /* The wait condition has already been met so there is no need to |
| 347 | * block. */ |
| 348 | uxReturn = uxCurrentEventBits; |
| 349 | xTicksToWait = ( TickType_t ) 0; |
| 350 | |
| 351 | /* Clear the wait bits if requested to do so. */ |
| 352 | if( xClearOnExit != pdFALSE ) |
| 353 | { |
| 354 | pxEventBits->uxEventBits &= ~uxBitsToWaitFor; |
| 355 | } |
| 356 | else |
| 357 | { |
| 358 | mtCOVERAGE_TEST_MARKER(); |
| 359 | } |
| 360 | } |
| 361 | else if( xTicksToWait == ( TickType_t ) 0 ) |
| 362 | { |
| 363 | /* The wait condition has not been met, but no block time was |
| 364 | * specified, so just return the current value. */ |
| 365 | uxReturn = uxCurrentEventBits; |
| 366 | xTimeoutOccurred = pdTRUE; |
| 367 | } |
| 368 | else |
| 369 | { |
| 370 | /* The task is going to block to wait for its required bits to be |
| 371 | * set. uxControlBits are used to remember the specified behaviour of |
| 372 | * this call to xEventGroupWaitBits() - for use when the event bits |
no test coverage detected