]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/event_groups.c
Add coverage test markers.
[freertos] / FreeRTOS / Source / event_groups.c
1 /*\r
2     FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.\r
3     All rights reserved\r
4 \r
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     ***************************************************************************\r
8      *                                                                       *\r
9      *    FreeRTOS provides completely free yet professionally developed,    *\r
10      *    robust, strictly quality controlled, supported, and cross          *\r
11      *    platform software that has become a de facto standard.             *\r
12      *                                                                       *\r
13      *    Help yourself get started quickly and support the FreeRTOS         *\r
14      *    project by purchasing a FreeRTOS tutorial book, reference          *\r
15      *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
16      *                                                                       *\r
17      *    Thank you!                                                         *\r
18      *                                                                       *\r
19     ***************************************************************************\r
20 \r
21     This file is part of the FreeRTOS distribution.\r
22 \r
23     FreeRTOS is free software; you can redistribute it and/or modify it under\r
24     the terms of the GNU General Public License (version 2) as published by the\r
25     Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
26 \r
27     >>! NOTE: The modification to the GPL is included to allow you to distribute\r
28     >>! a combined work that includes FreeRTOS without being obliged to provide\r
29     >>! the source code for proprietary components outside of the FreeRTOS\r
30     >>! kernel.\r
31 \r
32     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
33     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
34     FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
35     link: http://www.freertos.org/a00114.html\r
36 \r
37     1 tab == 4 spaces!\r
38 \r
39     ***************************************************************************\r
40      *                                                                       *\r
41      *    Having a problem?  Start by reading the FAQ "My application does   *\r
42      *    not run, what could be wrong?"                                     *\r
43      *                                                                       *\r
44      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
45      *                                                                       *\r
46     ***************************************************************************\r
47 \r
48     http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
49     license and Real Time Engineers Ltd. contact details.\r
50 \r
51     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
52     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
53     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
54 \r
55     http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
56     Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
57     licenses offer ticketed support, indemnification and middleware.\r
58 \r
59     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
60     engineered and independently SIL3 certified version for use in safety and\r
61     mission critical applications that require provable dependability.\r
62 \r
63     1 tab == 4 spaces!\r
64 */\r
65 \r
66 /* Standard includes. */\r
67 #include <stdlib.h>\r
68 \r
69 /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining\r
70 all the API functions to use the MPU wrappers.  That should only be done when\r
71 task.h is included from an application file. */\r
72 #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
73 \r
74 /* FreeRTOS includes. */\r
75 #include "FreeRTOS.h"\r
76 #include "task.h"\r
77 #include "timers.h"\r
78 #include "event_groups.h"\r
79 \r
80 /* Lint e961 and e750 are suppressed as a MISRA exception justified because the\r
81 MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the\r
82 header files above, but not in this file, in order to generate the correct\r
83 privileged Vs unprivileged linkage and placement. */\r
84 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */\r
85 \r
86 #if ( INCLUDE_xEventGroupSetBitFromISR == 1 ) && ( configUSE_TIMERS == 0 )\r
87         #error configUSE_TIMERS must be set to 1 to make the xEventGroupSetBitFromISR() function available.\r
88 #endif\r
89 \r
90 #if ( INCLUDE_xEventGroupSetBitFromISR == 1 ) && ( INCLUDE_xTimerPendCallbackFromISR == 0 )\r
91         #error INCLUDE_xTimerPendCallbackFromISR must also be set to one to make the xEventGroupSetBitFromISR() function available.\r
92 #endif\r
93 \r
94 /* The following bit fields convey control information in a task's event list\r
95 item value.  It is important they don't clash with the\r
96 taskEVENT_LIST_ITEM_VALUE_IN_USE definition. */\r
97 #if configUSE_16_BIT_TICKS == 1\r
98         #define eventCLEAR_EVENTS_ON_EXIT_BIT   0x0100U\r
99         #define eventUNBLOCKED_DUE_TO_BIT_SET   0x0200U\r
100         #define eventWAIT_FOR_ALL_BITS                  0x0400U\r
101         #define eventEVENT_BITS_CONTROL_BYTES   0xff00U\r
102 #else\r
103         #define eventCLEAR_EVENTS_ON_EXIT_BIT   0x01000000UL\r
104         #define eventUNBLOCKED_DUE_TO_BIT_SET   0x02000000UL\r
105         #define eventWAIT_FOR_ALL_BITS                  0x04000000UL\r
106         #define eventEVENT_BITS_CONTROL_BYTES   0xff000000UL\r
107 #endif\r
108 \r
109 typedef struct EventBitsDefinition\r
110 {\r
111         xEventBitsType uxEventBits;\r
112         xList xTasksWaitingForBits;             /*< List of tasks waiting for a bit to be set. */\r
113 } xEVENT_BITS;\r
114 \r
115 /* Used internally only. */\r
116 typedef struct EVENT_GROUP_CALLBACK_PARAMTERS\r
117 {\r
118         xEventGroupHandle xTargetEventGroup;\r
119         xEventBitsType xBitsToSet;\r
120 } xEventGroupCallbackParameters;\r
121 \r
122 /*-----------------------------------------------------------*/\r
123 \r
124 /*\r
125  * Test the bits set in uxCurrentEventBits to see if the wait condition is met.\r
126  * The wait condition is defined by xWaitForAllBits.  If xWaitForAllBits is\r
127  * pdTRUE then the wait condition is met if all the bits set in uxBitsToWaitFor\r
128  * are also set in uxCurrentEventBits.  If xWaitForAllBits is pdFALSE then the\r
129  * wait condition is met if any of the bits set in uxBitsToWait for are also set\r
130  * in uxCurrentEventBits.\r
131  */\r
132 static portBASE_TYPE prvTestWaitCondition( const xEventBitsType uxCurrentEventBits, const xEventBitsType uxBitsToWaitFor, const portBASE_TYPE xWaitForAllBits );\r
133 \r
134 /*-----------------------------------------------------------*/\r
135 \r
136 xEventGroupHandle xEventGroupCreate( void )\r
137 {\r
138 xEVENT_BITS *pxEventBits;\r
139 \r
140         pxEventBits = pvPortMalloc( sizeof( xEVENT_BITS ) );\r
141         if( pxEventBits != NULL )\r
142         {\r
143                 pxEventBits->uxEventBits = 0;\r
144                 vListInitialise( &( pxEventBits->xTasksWaitingForBits ) );\r
145                 traceEVENT_GROUP_CREATE( pxEventBits );\r
146         }\r
147         else\r
148         {\r
149                 traceEVENT_GROUP_CREATE_FAILED();\r
150         }\r
151 \r
152         return ( xEventGroupHandle ) pxEventBits;\r
153 }\r
154 /*-----------------------------------------------------------*/\r
155 \r
156 xEventBitsType xEventGroupSync( xEventGroupHandle xEventGroup, const xEventBitsType uxBitsToSet, const xEventBitsType uxBitsToWaitFor, portTickType xTicksToWait )\r
157 {\r
158 xEventBitsType uxOriginalBitValue, uxReturn;\r
159 xEVENT_BITS *pxEventBits = ( xEVENT_BITS * ) xEventGroup;\r
160 portBASE_TYPE xAlreadyYielded;\r
161 \r
162         configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 );\r
163         configASSERT( uxBitsToWaitFor != 0 );\r
164         #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )\r
165         {\r
166                 configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );\r
167         }\r
168         #endif\r
169 \r
170         vTaskSuspendAll();\r
171         {\r
172                 traceEVENT_GROUP_SYNC_START( xEventGroup, uxBitsToSet );\r
173 \r
174                 uxOriginalBitValue = pxEventBits->uxEventBits;\r
175 \r
176                 ( void ) xEventGroupSetBits( xEventGroup, uxBitsToSet );\r
177 \r
178                 if( ( ( uxOriginalBitValue | uxBitsToSet ) & uxBitsToWaitFor ) == uxBitsToWaitFor )\r
179                 {\r
180                         /* All the rendezvous bits are now set - no need to block. */\r
181                         uxReturn = ( uxOriginalBitValue | uxBitsToSet );\r
182 \r
183                         /* Rendezvous always clear the bits.  They will have been cleared\r
184                         already unless this is the only task in the rendezvous. */\r
185                         pxEventBits->uxEventBits &= uxBitsToWaitFor;\r
186 \r
187                         xTicksToWait = 0;\r
188                 }\r
189                 else\r
190                 {\r
191                         if( xTicksToWait != ( portTickType ) 0 )\r
192                         {\r
193                                 /* Store the bits that the calling task is waiting for in the\r
194                                 task's event list item so the kernel knows when a match is\r
195                                 found.  Then enter the blocked state. */\r
196                                 vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | eventCLEAR_EVENTS_ON_EXIT_BIT | eventWAIT_FOR_ALL_BITS ), xTicksToWait );\r
197 \r
198                                 /* This assignment is obsolete as uxReturn will get set after\r
199                                 the task unblocks, but some compilers mistakenly generate a\r
200                                 warning about uxReturn being returned without being set if the\r
201                                 assignment is omitted. */\r
202                                 uxReturn = 0;\r
203                         }\r
204                         else\r
205                         {\r
206                                 /* The rendezvous bits were not set, but no block time was\r
207                                 specified - just return the current event bit value. */\r
208                                 uxReturn = pxEventBits->uxEventBits;\r
209                         }\r
210                 }\r
211         }\r
212         xAlreadyYielded = xTaskResumeAll();\r
213 \r
214         if( xTicksToWait != ( portTickType ) 0 )\r
215         {\r
216                 if( xAlreadyYielded == pdFALSE )\r
217                 {\r
218                         portYIELD_WITHIN_API();\r
219                 }\r
220                 else\r
221                 {\r
222                         mtCOVERAGE_TEST_MARKER();\r
223                 }\r
224 \r
225                 /* The task blocked to wait for its required bits to be set - at this\r
226                 point either the required bits were set or the block time expired.  If\r
227                 the required bits were set they will have been stored in the task's\r
228                 event list item, and they should now be retrieved then cleared. */\r
229                 uxReturn = uxTaskResetEventItemValue();\r
230 \r
231                 if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( xEventBitsType ) 0 )\r
232                 {\r
233                         /* The task timed out, just return the current event bit value. */\r
234                         taskENTER_CRITICAL();\r
235                         {\r
236                                 uxReturn = pxEventBits->uxEventBits;\r
237 \r
238                                 /* Although the task got here because it timed out before the\r
239                                 bits it was waiting for were set, it is possible that since it\r
240                                 unblocked another task has set the bits.  If this is the case\r
241                                 then it may be required to clear the bits before exiting. */\r
242                                 if( ( uxReturn & uxBitsToWaitFor ) == uxBitsToWaitFor )\r
243                                 {\r
244                                         pxEventBits->uxEventBits &= ~uxBitsToWaitFor;\r
245                                 }\r
246                                 else\r
247                                 {\r
248                                         mtCOVERAGE_TEST_MARKER();\r
249                                 }\r
250                         }\r
251                         taskEXIT_CRITICAL();\r
252                 }\r
253                 else\r
254                 {\r
255                         /* The task unblocked because the bits were set.  Clear the control\r
256                         bits before returning the value. */\r
257                         uxReturn &= ~eventEVENT_BITS_CONTROL_BYTES;\r
258                 }\r
259         }\r
260 \r
261         traceEVENT_GROUP_SYNC_END( xEventGroup, uxReturn );\r
262         return uxReturn;\r
263 }\r
264 /*-----------------------------------------------------------*/\r
265 \r
266 xEventBitsType xEventGroupWaitBits( xEventGroupHandle xEventGroup, const xEventBitsType uxBitsToWaitFor, const portBASE_TYPE xClearOnExit, const portBASE_TYPE xWaitForAllBits, portTickType xTicksToWait )\r
267 {\r
268 xEVENT_BITS *pxEventBits = ( xEVENT_BITS * ) xEventGroup;\r
269 xEventBitsType uxReturn, uxControlBits = 0;\r
270 portBASE_TYPE xWaitConditionMet, xAlreadyYielded;\r
271 \r
272         /* Check the user is not attempting to wait on the bits used by the kernel\r
273         itself, and that at least one bit is being requested. */\r
274         configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 );\r
275         configASSERT( uxBitsToWaitFor != 0 );\r
276         #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )\r
277         {\r
278                 configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );\r
279         }\r
280         #endif\r
281 \r
282         vTaskSuspendAll();\r
283         {\r
284                 const xEventBitsType uxCurrentEventBits = pxEventBits->uxEventBits;\r
285 \r
286                 traceEVENT_GROUP_WAIT_BITS_START( xEventGroup, uxBitsToWaitFor );\r
287 \r
288                 /* Check to see if the wait condition is already met or not. */\r
289                 xWaitConditionMet = prvTestWaitCondition( uxCurrentEventBits, uxBitsToWaitFor, xWaitForAllBits );\r
290 \r
291                 if( xWaitConditionMet != pdFALSE )\r
292                 {\r
293                         /* The wait condition has already been met so there is no need to\r
294                         block. */\r
295                         uxReturn = uxCurrentEventBits;\r
296                         xTicksToWait = ( portTickType ) 0;\r
297 \r
298                         /* Clear the wait bits if requested to do so. */\r
299                         if( xClearOnExit != pdFALSE )\r
300                         {\r
301                                 pxEventBits->uxEventBits &= ~uxBitsToWaitFor;\r
302                         }\r
303                         else\r
304                         {\r
305                                 mtCOVERAGE_TEST_MARKER();\r
306                         }\r
307                 }\r
308                 else if( xTicksToWait == ( portTickType ) 0 )\r
309                 {\r
310                         /* The wait condition has not been met, but no block time was\r
311                         specified, so just return the current value. */\r
312                         uxReturn = uxCurrentEventBits;\r
313                 }\r
314                 else\r
315                 {\r
316                         /* The task is going to block to wait for its required bits to be\r
317                         set.  uxControlBits are used to remember the specified behaviour of\r
318                         this call to xEventGroupWaitBits() - for use when the event bits\r
319                         unblock the task. */\r
320                         if( xClearOnExit != pdFALSE )\r
321                         {\r
322                                 uxControlBits |= eventCLEAR_EVENTS_ON_EXIT_BIT;\r
323                         }\r
324                         else\r
325                         {\r
326                                 mtCOVERAGE_TEST_MARKER();\r
327                         }\r
328 \r
329                         if( xWaitForAllBits != pdFALSE )\r
330                         {\r
331                                 uxControlBits |= eventWAIT_FOR_ALL_BITS;\r
332                         }\r
333                         else\r
334                         {\r
335                                 mtCOVERAGE_TEST_MARKER();\r
336                         }\r
337 \r
338                         /* Store the bits that the calling task is waiting for in the\r
339                         task's event list item so the kernel knows when a match is\r
340                         found.  Then enter the blocked state. */\r
341                         vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | uxControlBits ), xTicksToWait );\r
342 \r
343                         /* This is obsolete as it will get set after the task unblocks, but\r
344                         some compilers mistakenly generate a warning about the variable\r
345                         being returned without being set if it is not done. */\r
346                         uxReturn = 0;\r
347                 }\r
348         }\r
349         xAlreadyYielded = xTaskResumeAll();\r
350 \r
351         if( xTicksToWait != ( portTickType ) 0 )\r
352         {\r
353                 if( xAlreadyYielded == pdFALSE )\r
354                 {\r
355                         portYIELD_WITHIN_API();\r
356                 }\r
357                 else\r
358                 {\r
359                         mtCOVERAGE_TEST_MARKER();\r
360                 }\r
361 \r
362                 /* The task blocked to wait for its required bits to be set - at this\r
363                 point either the required bits were set or the block time expired.  If\r
364                 the required bits were set they will have been stored in the task's\r
365                 event list item, and they should now be retrieved then cleared. */\r
366                 uxReturn = uxTaskResetEventItemValue();\r
367 \r
368                 if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( xEventBitsType ) 0 )\r
369                 {\r
370                         taskENTER_CRITICAL();\r
371                         {\r
372                                 /* The task timed out, just return the current event bit value. */\r
373                                 uxReturn = pxEventBits->uxEventBits;\r
374 \r
375                                 /* It is possible that the event bits were updated between this\r
376                                 task leaving the Blocked state and running again. */\r
377                                 if( prvTestWaitCondition( uxReturn, uxBitsToWaitFor, xWaitForAllBits ) != pdFALSE )\r
378                                 {\r
379                                         if( xClearOnExit != pdFALSE )\r
380                                         {\r
381                                                 pxEventBits->uxEventBits &= ~uxBitsToWaitFor;\r
382                                         }\r
383                                         else\r
384                                         {\r
385                                                 mtCOVERAGE_TEST_MARKER();\r
386                                         }\r
387                                 }\r
388                                 else\r
389                                 {\r
390                                         mtCOVERAGE_TEST_MARKER();\r
391                                 }\r
392                         }\r
393                         taskEXIT_CRITICAL();\r
394                 }\r
395                 else\r
396                 {\r
397                         /* The task unblocked because the bits were set.  Clear the control\r
398                         bits before returning the value. */\r
399                         uxReturn &= ~eventEVENT_BITS_CONTROL_BYTES;\r
400                 }\r
401         }\r
402 \r
403         traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxReturn );\r
404         return uxReturn;\r
405 }\r
406 /*-----------------------------------------------------------*/\r
407 \r
408 xEventBitsType xEventGroupClearBits( xEventGroupHandle xEventGroup, const xEventBitsType uxBitsToClear )\r
409 {\r
410 xEVENT_BITS *pxEventBits = ( xEVENT_BITS * ) xEventGroup;\r
411 xEventBitsType uxReturn;\r
412 \r
413         /* Check the user is not attempting to clear the bits used by the kernel\r
414         itself. */\r
415         configASSERT( ( uxBitsToClear & eventEVENT_BITS_CONTROL_BYTES ) == 0 );\r
416 \r
417         taskENTER_CRITICAL();\r
418         {\r
419                 traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear );\r
420 \r
421                 /* The value returned is the event group value prior to the bits being\r
422                 cleared. */\r
423                 uxReturn = pxEventBits->uxEventBits;\r
424 \r
425                 /* Clear the bits. */\r
426                 pxEventBits->uxEventBits &= ~uxBitsToClear;\r
427         }\r
428         taskEXIT_CRITICAL();\r
429 \r
430         return uxReturn;\r
431 }\r
432 /*-----------------------------------------------------------*/\r
433 \r
434 xEventBitsType xEventGroupSetBits( xEventGroupHandle xEventGroup, const xEventBitsType uxBitsToSet )\r
435 {\r
436 xListItem *pxListItem, *pxNext;\r
437 xListItem const *pxListEnd;\r
438 xList *pxList;\r
439 xEventBitsType uxBitsToClear = 0, uxBitsWaitedFor, uxControlBits;\r
440 xEVENT_BITS *pxEventBits = ( xEVENT_BITS * ) xEventGroup;\r
441 portBASE_TYPE xMatchFound = pdFALSE;\r
442 \r
443         /* Check the user is not attempting to set the bits used by the kernel\r
444         itself. */\r
445         configASSERT( ( uxBitsToSet & eventEVENT_BITS_CONTROL_BYTES ) == 0 );\r
446 \r
447         pxList = &( pxEventBits->xTasksWaitingForBits );\r
448         pxListEnd = listGET_END_MARKER( pxList ); /*lint !e826 !e740 The mini list structure is used as the list end to save RAM.  This is checked and valid. */\r
449         vTaskSuspendAll();\r
450         {\r
451                 traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet );\r
452 \r
453                 pxListItem = listGET_HEAD_ENTRY( pxList );\r
454 \r
455                 /* Set the bits. */\r
456                 pxEventBits->uxEventBits |= uxBitsToSet;\r
457 \r
458                 /* See if the new bit value should unblock any tasks. */\r
459                 while( pxListItem != pxListEnd )\r
460                 {\r
461                         pxNext = listGET_NEXT( pxListItem );\r
462                         uxBitsWaitedFor = listGET_LIST_ITEM_VALUE( pxListItem );\r
463                         xMatchFound = pdFALSE;\r
464 \r
465                         /* Split the bits waited for from the control bits. */\r
466                         uxControlBits = uxBitsWaitedFor & eventEVENT_BITS_CONTROL_BYTES;\r
467                         uxBitsWaitedFor &= ~eventEVENT_BITS_CONTROL_BYTES;\r
468 \r
469                         if( ( uxControlBits & eventWAIT_FOR_ALL_BITS ) == ( xEventBitsType ) 0 )\r
470                         {\r
471                                 /* Just looking for single bit being set. */\r
472                                 if( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) != ( xEventBitsType ) 0 )\r
473                                 {\r
474                                         xMatchFound = pdTRUE;\r
475                                 }\r
476                                 else\r
477                                 {\r
478                                         mtCOVERAGE_TEST_MARKER();\r
479                                 }\r
480                         }\r
481                         else if( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) == uxBitsWaitedFor )\r
482                         {\r
483                                 /* All bits are set. */\r
484                                 xMatchFound = pdTRUE;\r
485                         }\r
486                         else\r
487                         {\r
488                                 /* Need all bits to be set, but not all the bits were set. */\r
489                         }\r
490 \r
491                         if( xMatchFound != pdFALSE )\r
492                         {\r
493                                 /* The bits match.  Should the bits be cleared on exit? */\r
494                                 if( ( uxControlBits & eventCLEAR_EVENTS_ON_EXIT_BIT ) != ( xEventBitsType ) 0 )\r
495                                 {\r
496                                         uxBitsToClear |= uxBitsWaitedFor;\r
497                                 }\r
498                                 else\r
499                                 {\r
500                                         mtCOVERAGE_TEST_MARKER();\r
501                                 }\r
502 \r
503                                 /* Store the actual event flag value in the task's event list\r
504                                 item before removing the task from the event list.  The\r
505                                 eventUNBLOCKED_DUE_TO_BIT_SET bit is set so the task knows\r
506                                 that is was unblocked due to its required bits matching, rather\r
507                                 than because it timed out. */\r
508                                 ( void ) xTaskRemoveFromUnorderedEventList( pxListItem, pxEventBits->uxEventBits | eventUNBLOCKED_DUE_TO_BIT_SET );\r
509                         }\r
510 \r
511                         /* Move onto the next list item.  Note pxListItem->pxNext is not\r
512                         used here as the list item may have been removed from the event list\r
513                         and inserted into the ready/pending reading list. */\r
514                         pxListItem = pxNext;\r
515                 }\r
516 \r
517                 /* Clear any bits that matched when the eventCLEAR_EVENTS_ON_EXIT_BIT\r
518                 bit was set in the control word. */\r
519                 pxEventBits->uxEventBits &= ~uxBitsToClear;\r
520         }\r
521         ( void ) xTaskResumeAll();\r
522 \r
523         return pxEventBits->uxEventBits;\r
524 }\r
525 /*-----------------------------------------------------------*/\r
526 \r
527 void vEventGroupDelete( xEventGroupHandle xEventGroup )\r
528 {\r
529 xEVENT_BITS *pxEventBits = ( xEVENT_BITS * ) xEventGroup;\r
530 const xList *pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits );\r
531 \r
532         vTaskSuspendAll();\r
533         {\r
534                 traceEVENT_GROUP_DELETE( xEventGroup );\r
535 \r
536                 while( listCURRENT_LIST_LENGTH( pxTasksWaitingForBits ) > ( unsigned portBASE_TYPE ) 0 )\r
537                 {\r
538                         /* Unblock the task, returning 0 as the event list is being deleted\r
539                         and     cannot therefore have any bits set. */\r
540                         configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( xListItem * ) &( pxTasksWaitingForBits->xListEnd ) );\r
541                         ( void ) xTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, ( portTickType ) eventUNBLOCKED_DUE_TO_BIT_SET );\r
542                 }\r
543 \r
544                 vPortFree( pxEventBits );\r
545         }\r
546         ( void ) xTaskResumeAll();\r
547 }\r
548 /*-----------------------------------------------------------*/\r
549 \r
550 /* For internal use only - execute a 'set bits' command that was pended from\r
551 an interrupt. */\r
552 void vEventGroupSetBitsCallback( void *pvEventGroup, const unsigned long ulBitsToSet )\r
553 {\r
554         ( void ) xEventGroupSetBits( pvEventGroup, ( xEventBitsType ) ulBitsToSet );\r
555 }\r
556 /*-----------------------------------------------------------*/\r
557 \r
558 static portBASE_TYPE prvTestWaitCondition( const xEventBitsType uxCurrentEventBits, const xEventBitsType uxBitsToWaitFor, const portBASE_TYPE xWaitForAllBits )\r
559 {\r
560 portBASE_TYPE xWaitConditionMet = pdFALSE;\r
561 \r
562         if( xWaitForAllBits == pdFALSE )\r
563         {\r
564                 /* Task only has to wait for one bit within uxBitsToWaitFor to be\r
565                 set.  Is one already set? */\r
566                 if( ( uxCurrentEventBits & uxBitsToWaitFor ) != ( xEventBitsType ) 0 )\r
567                 {\r
568                         xWaitConditionMet = pdTRUE;\r
569                 }\r
570                 else\r
571                 {\r
572                         mtCOVERAGE_TEST_MARKER();\r
573                 }\r
574         }\r
575         else\r
576         {\r
577                 /* Task has to wait for all the bits in uxBitsToWaitFor to be set.\r
578                 Are they set already? */\r
579                 if( ( uxCurrentEventBits & uxBitsToWaitFor ) == uxBitsToWaitFor )\r
580                 {\r
581                         xWaitConditionMet = pdTRUE;\r
582                 }\r
583                 else\r
584                 {\r
585                         mtCOVERAGE_TEST_MARKER();\r
586                 }\r
587         }\r
588 \r
589         return xWaitConditionMet;\r
590 }\r
591 \r
592 \r