예제 #1
0
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++;
}
예제 #2
0
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
}