static void prvCreateAndDeleteStaticallyAllocatedEventGroups( void ) { EventGroupHandle_t xEventGroup; /* StaticEventGroup_t is a publicly accessible structure that has the same size and alignment requirements as the real event group structure. It is provided as a mechanism for applications to know the size of the event group (which is dependent on the architecture and configuration file settings) without breaking the strict data hiding policy by exposing the real event group internals. This StaticEventGroup_t variable is passed into the xSemaphoreCreateEventGroupStatic() function calls within this function. */ StaticEventGroup_t xEventGroupBuffer; /* Create the event group. xEventGroupCreateStatic() has an extra parameter than the normal xEventGroupCreate() API function. The parameter is a pointer to the StaticEventGroup_t structure that will hold the event group structure. If the parameter is passed as NULL then the structure will be allocated dynamically, just as if xEventGroupCreate() had been called. */ xEventGroup = xEventGroupCreateStatic( &xEventGroupBuffer ); /* The event group handle should equal the static event group structure passed into the xEventGroupCreateStatic() function. */ configASSERT( xEventGroup == ( EventGroupHandle_t ) &xEventGroupBuffer ); /* Ensure the event group passes a few sanity checks as a valid event group. */ prvSanityCheckCreatedEventGroup( xEventGroup ); /* Delete the event group again so the buffers can be reused. */ vEventGroupDelete( xEventGroup ); /* The event group created above had a statically allocated event group structure. Repeat the above using NULL as the xEventGroupCreateStatic() parameter so the event group structure is instead allocated dynamically. */ xEventGroup = xEventGroupCreateStatic( NULL ); /* Ensure the event group passes a few sanity checks as a valid event group. */ prvSanityCheckCreatedEventGroup( xEventGroup ); /* Delete the event group again so the buffers can be reused. */ vEventGroupDelete( xEventGroup ); /* Ensure lower priority tasks get CPU time. */ vTaskDelay( prvGetNextDelayTime() ); /* Just to show the check task that this task is still executing. */ uxCycleCounter++; }
static void prvTestAbortingEventGroupWait( void ) { TickType_t xTimeAtStart; EventGroupHandle_t xEventGroup; EventBits_t xBitsToWaitFor = ( EventBits_t ) 0x01, xReturn; #if( configSUPPORT_STATIC_ALLOCATION == 1 ) { static StaticEventGroup_t xEventGroupBuffer; /* Create the event group. Statically allocated memory is used so the creation cannot fail. */ xEventGroup = xEventGroupCreateStatic( &xEventGroupBuffer ); } #else { xEventGroup = xEventGroupCreate(); configASSERT( xEventGroup ); } #endif /* Note the time before the delay so the length of the delay is known. */ xTimeAtStart = xTaskGetTickCount(); /* This first delay should just time out. */ xReturn = xEventGroupWaitBits( xEventGroup, xBitsToWaitFor, pdTRUE, pdTRUE, xMaxBlockTime ); if( xReturn != 0x00 ) { xErrorOccurred = pdTRUE; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); /* Note the time before the delay so the length of the delay is known. */ xTimeAtStart = xTaskGetTickCount(); /* This second delay should be aborted by the primary task half way through. */ xReturn = xEventGroupWaitBits( xEventGroup, xBitsToWaitFor, pdTRUE, pdTRUE, xMaxBlockTime ); if( xReturn != 0x00 ) { xErrorOccurred = pdTRUE; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xHalfMaxBlockTime ); /* Note the time before the delay so the length of the delay is known. */ xTimeAtStart = xTaskGetTickCount(); /* This third delay should just time out again. */ xReturn = xEventGroupWaitBits( xEventGroup, xBitsToWaitFor, pdTRUE, pdTRUE, xMaxBlockTime ); if( xReturn != 0x00 ) { xErrorOccurred = pdTRUE; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); /* Not really necessary in this case, but for completeness. */ vEventGroupDelete( xEventGroup ); }
EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer ) { EventGroupHandle_t xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); xReturn = xEventGroupCreateStatic( pxEventGroupBuffer ); vPortResetPrivilege( xRunningPrivileged ); return xReturn; }
static void prvCreateAndDeleteStaticallyAllocatedEventGroups( void ) { EventGroupHandle_t xEventGroup; /* StaticEventGroup_t is a publicly accessible structure that has the same size and alignment requirements as the real event group structure. It is provided as a mechanism for applications to know the size of the event group (which is dependent on the architecture and configuration file settings) without breaking the strict data hiding policy by exposing the real event group internals. This StaticEventGroup_t variable is passed into the xSemaphoreCreateEventGroupStatic() function calls within this function. */ StaticEventGroup_t xEventGroupBuffer; /* Create the event group. xEventGroupCreateStatic() has an extra parameter than the normal xEventGroupCreate() API function. The parameter is a pointer to the StaticEventGroup_t structure that will hold the event group structure. */ xEventGroup = xEventGroupCreateStatic( &xEventGroupBuffer ); /* The event group handle should equal the static event group structure passed into the xEventGroupCreateStatic() function. */ configASSERT( xEventGroup == ( EventGroupHandle_t ) &xEventGroupBuffer ); /* Ensure the event group passes a few sanity checks as a valid event group. */ prvSanityCheckCreatedEventGroup( xEventGroup ); /* Delete the event group again so the buffers can be reused. */ vEventGroupDelete( xEventGroup ); /* Now do the same using a dynamically allocated event group to ensure the delete function is working correctly in both the static and dynamic allocation cases. */ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) { xEventGroup = xEventGroupCreate(); configASSERT( xEventGroup != NULL ); prvSanityCheckCreatedEventGroup( xEventGroup ); vEventGroupDelete( xEventGroup ); } #endif }