MCPcopy Create free account
hub / github.com/FreeRTOS/FreeRTOS-Kernel / xEventGroupSetBits

Function xEventGroupSetBits

event_groups.c:531–623  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

529/*-----------------------------------------------------------*/
530
531EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup,
532 const EventBits_t uxBitsToSet )
533{
534 ListItem_t * pxListItem, * pxNext;
535 ListItem_t const * pxListEnd;
536 List_t const * pxList;
537 EventBits_t uxBitsToClear = 0, uxBitsWaitedFor, uxControlBits;
538 EventGroup_t * pxEventBits = xEventGroup;
539 BaseType_t xMatchFound = pdFALSE;
540
541 /* Check the user is not attempting to set the bits used by the kernel
542 * itself. */
543 configASSERT( xEventGroup );
544 configASSERT( ( uxBitsToSet & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
545
546 pxList = &( pxEventBits->xTasksWaitingForBits );
547 pxListEnd = listGET_END_MARKER( pxList ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */
548 vTaskSuspendAll();
549 {
550 traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet );
551
552 pxListItem = listGET_HEAD_ENTRY( pxList );
553
554 /* Set the bits. */
555 pxEventBits->uxEventBits |= uxBitsToSet;
556
557 /* See if the new bit value should unblock any tasks. */
558 while( pxListItem != pxListEnd )
559 {
560 pxNext = listGET_NEXT( pxListItem );
561 uxBitsWaitedFor = listGET_LIST_ITEM_VALUE( pxListItem );
562 xMatchFound = pdFALSE;
563
564 /* Split the bits waited for from the control bits. */
565 uxControlBits = uxBitsWaitedFor & eventEVENT_BITS_CONTROL_BYTES;
566 uxBitsWaitedFor &= ~eventEVENT_BITS_CONTROL_BYTES;
567
568 if( ( uxControlBits & eventWAIT_FOR_ALL_BITS ) == ( EventBits_t ) 0 )
569 {
570 /* Just looking for single bit being set. */
571 if( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) != ( EventBits_t ) 0 )
572 {
573 xMatchFound = pdTRUE;
574 }
575 else
576 {
577 mtCOVERAGE_TEST_MARKER();
578 }
579 }
580 else if( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) == uxBitsWaitedFor )
581 {
582 /* All bits are set. */
583 xMatchFound = pdTRUE;
584 }
585 else
586 {
587 /* Need all bits to be set, but not all the bits were set. */
588 }

Callers 4

xEventGroupSyncFunction · 0.85
MPU_xEventGroupSetBitsFunction · 0.85

Calls 3

vTaskSuspendAllFunction · 0.85
xTaskResumeAllFunction · 0.85

Tested by

no test coverage detected