/*\r
- FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+ FreeRTOS V9.0.1 - Copyright (C) 2017 Real Time Engineers Ltd.\r
All rights reserved\r
\r
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
UBaseType_t uxEventGroupNumber;\r
#endif\r
\r
- #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
- uint8_t ucStaticallyAllocated;\r
+ #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )\r
+ uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the event group is statically allocated to ensure no attempt is made to free the memory. */\r
#endif\r
} EventGroup_t;\r
\r
* wait condition is met if any of the bits set in uxBitsToWait for are also set\r
* in uxCurrentEventBits.\r
*/\r
-static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, const EventBits_t uxBitsToWaitFor, const BaseType_t xWaitForAllBits );\r
+static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, const EventBits_t uxBitsToWaitFor, const BaseType_t xWaitForAllBits ) PRIVILEGED_FUNCTION;\r
\r
/*-----------------------------------------------------------*/\r
\r
-EventGroupHandle_t xEventGroupGenericCreate( StaticEventGroup_t *pxStaticEventGroup )\r
-{\r
-EventGroup_t *pxEventBits;\r
+#if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
\r
- if( pxStaticEventGroup == NULL )\r
- {\r
- /* The user has not provided a statically allocated event group, so\r
- create on dynamically. */\r
- pxEventBits = ( EventGroup_t * ) pvPortMalloc( sizeof( EventGroup_t ) );\r
- }\r
- else\r
+ EventGroupHandle_t xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer )\r
{\r
+ EventGroup_t *pxEventBits;\r
+\r
+ /* A StaticEventGroup_t object must be provided. */\r
+ configASSERT( pxEventGroupBuffer );\r
+\r
+ #if( configASSERT_DEFINED == 1 )\r
+ {\r
+ /* Sanity check that the size of the structure used to declare a\r
+ variable of type StaticEventGroup_t equals the size of the real\r
+ event group structure. */\r
+ volatile size_t xSize = sizeof( StaticEventGroup_t );\r
+ configASSERT( xSize == sizeof( EventGroup_t ) );\r
+ }\r
+ #endif /* configASSERT_DEFINED */\r
+\r
/* The user has provided a statically allocated event group - use it. */\r
- pxEventBits = ( EventGroup_t * ) pxStaticEventGroup;\r
+ pxEventBits = ( EventGroup_t * ) pxEventGroupBuffer; /*lint !e740 EventGroup_t and StaticEventGroup_t are guaranteed to have the same size and alignment requirement - checked by configASSERT(). */\r
+\r
+ if( pxEventBits != NULL )\r
+ {\r
+ pxEventBits->uxEventBits = 0;\r
+ vListInitialise( &( pxEventBits->xTasksWaitingForBits ) );\r
+\r
+ #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )\r
+ {\r
+ /* Both static and dynamic allocation can be used, so note that\r
+ this event group was created statically in case the event group\r
+ is later deleted. */\r
+ pxEventBits->ucStaticallyAllocated = pdTRUE;\r
+ }\r
+ #endif /* configSUPPORT_DYNAMIC_ALLOCATION */\r
+\r
+ traceEVENT_GROUP_CREATE( pxEventBits );\r
+ }\r
+ else\r
+ {\r
+ traceEVENT_GROUP_CREATE_FAILED();\r
+ }\r
+\r
+ return ( EventGroupHandle_t ) pxEventBits;\r
}\r
\r
- if( pxEventBits != NULL )\r
+#endif /* configSUPPORT_STATIC_ALLOCATION */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )\r
+\r
+ EventGroupHandle_t xEventGroupCreate( void )\r
{\r
- pxEventBits->uxEventBits = 0;\r
- vListInitialise( &( pxEventBits->xTasksWaitingForBits ) );\r
+ EventGroup_t *pxEventBits;\r
\r
- #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+ /* Allocate the event group. */\r
+ pxEventBits = ( EventGroup_t * ) pvPortMalloc( sizeof( EventGroup_t ) );\r
+\r
+ if( pxEventBits != NULL )\r
{\r
- if( pxStaticEventGroup == NULL )\r
+ pxEventBits->uxEventBits = 0;\r
+ vListInitialise( &( pxEventBits->xTasksWaitingForBits ) );\r
+\r
+ #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
{\r
+ /* Both static and dynamic allocation can be used, so note this\r
+ event group was allocated statically in case the event group is\r
+ later deleted. */\r
pxEventBits->ucStaticallyAllocated = pdFALSE;\r
}\r
- else\r
- {\r
- pxEventBits->ucStaticallyAllocated = pdTRUE;\r
- }\r
+ #endif /* configSUPPORT_STATIC_ALLOCATION */\r
+\r
+ traceEVENT_GROUP_CREATE( pxEventBits );\r
+ }\r
+ else\r
+ {\r
+ traceEVENT_GROUP_CREATE_FAILED();\r
}\r
- #endif /* configSUPPORT_STATIC_ALLOCATION */\r
\r
- traceEVENT_GROUP_CREATE( pxEventBits );\r
- }\r
- else\r
- {\r
- traceEVENT_GROUP_CREATE_FAILED();\r
+ return ( EventGroupHandle_t ) pxEventBits;\r
}\r
\r
- return ( EventGroupHandle_t ) pxEventBits;\r
-}\r
+#endif /* configSUPPORT_DYNAMIC_ALLOCATION */\r
/*-----------------------------------------------------------*/\r
\r
EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait )\r
eventUNBLOCKED_DUE_TO_BIT_SET bit is set so the task knows\r
that is was unblocked due to its required bits matching, rather\r
than because it timed out. */\r
- ( void ) xTaskRemoveFromUnorderedEventList( pxListItem, pxEventBits->uxEventBits | eventUNBLOCKED_DUE_TO_BIT_SET );\r
+ vTaskRemoveFromUnorderedEventList( pxListItem, pxEventBits->uxEventBits | eventUNBLOCKED_DUE_TO_BIT_SET );\r
}\r
\r
/* Move onto the next list item. Note pxListItem->pxNext is not\r
while( listCURRENT_LIST_LENGTH( pxTasksWaitingForBits ) > ( UBaseType_t ) 0 )\r
{\r
/* Unblock the task, returning 0 as the event list is being deleted\r
- and cannot therefore have any bits set. */\r
- configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( ListItem_t * ) &( pxTasksWaitingForBits->xListEnd ) );\r
- ( void ) xTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET );\r
+ and cannot therefore have any bits set. */\r
+ configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( const ListItem_t * ) &( pxTasksWaitingForBits->xListEnd ) );\r
+ vTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET );\r
}\r
\r
- /* Only free the memory if it was allocated dynamically. */\r
- #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+ #if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) )\r
+ {\r
+ /* The event group can only have been allocated dynamically - free\r
+ it again. */\r
+ vPortFree( pxEventBits );\r
+ }\r
+ #elif( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )\r
{\r
- if( pxEventBits->ucStaticallyAllocated == pdFALSE )\r
+ /* The event group could have been allocated statically or\r
+ dynamically, so check before attempting to free the memory. */\r
+ if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdFALSE )\r
{\r
vPortFree( pxEventBits );\r
}\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
+ }\r
}\r
- #else\r
- {\r
- vPortFree( pxEventBits );\r
- }\r
- #endif /* configSUPPORT_STATIC_ALLOCATION */\r
+ #endif /* configSUPPORT_DYNAMIC_ALLOCATION */\r
}\r
( void ) xTaskResumeAll();\r
}\r