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

Function xEventGroupSync

event_groups.c:192–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190/*-----------------------------------------------------------*/
191
192EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
193 const EventBits_t uxBitsToSet,
194 const EventBits_t uxBitsToWaitFor,
195 TickType_t xTicksToWait )
196{
197 EventBits_t uxOriginalBitValue, uxReturn;
198 EventGroup_t * pxEventBits = xEventGroup;
199 BaseType_t xAlreadyYielded;
200 BaseType_t xTimeoutOccurred = pdFALSE;
201
202 configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
203 configASSERT( uxBitsToWaitFor != 0 );
204 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
205 {
206 configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
207 }
208 #endif
209
210 vTaskSuspendAll();
211 {
212 uxOriginalBitValue = pxEventBits->uxEventBits;
213
214 ( void ) xEventGroupSetBits( xEventGroup, uxBitsToSet );
215
216 if( ( ( uxOriginalBitValue | uxBitsToSet ) & uxBitsToWaitFor ) == uxBitsToWaitFor )
217 {
218 /* All the rendezvous bits are now set - no need to block. */
219 uxReturn = ( uxOriginalBitValue | uxBitsToSet );
220
221 /* Rendezvous always clear the bits. They will have been cleared
222 * already unless this is the only task in the rendezvous. */
223 pxEventBits->uxEventBits &= ~uxBitsToWaitFor;
224
225 xTicksToWait = 0;
226 }
227 else
228 {
229 if( xTicksToWait != ( TickType_t ) 0 )
230 {
231 traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor );
232
233 /* Store the bits that the calling task is waiting for in the
234 * task's event list item so the kernel knows when a match is
235 * found. Then enter the blocked state. */
236 vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | eventCLEAR_EVENTS_ON_EXIT_BIT | eventWAIT_FOR_ALL_BITS ), xTicksToWait );
237
238 /* This assignment is obsolete as uxReturn will get set after
239 * the task unblocks, but some compilers mistakenly generate a
240 * warning about uxReturn being returned without being set if the
241 * assignment is omitted. */
242 uxReturn = 0;
243 }
244 else
245 {
246 /* The rendezvous bits were not set, but no block time was
247 * specified - just return the current event bit value. */
248 uxReturn = pxEventBits->uxEventBits;
249 xTimeoutOccurred = pdTRUE;

Callers 1

MPU_xEventGroupSyncFunction · 0.85

Calls 7

xTaskGetSchedulerStateFunction · 0.85
vTaskSuspendAllFunction · 0.85
xEventGroupSetBitsFunction · 0.85
xTaskResumeAllFunction · 0.85
vTaskYieldWithinAPIFunction · 0.85

Tested by

no test coverage detected