2 FreeRTOS V8.2.0rc1 - Copyright (C) 2014 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 This file is part of the FreeRTOS distribution.
\r
9 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
10 the terms of the GNU General Public License (version 2) as published by the
\r
11 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
\r
13 >>! NOTE: The modification to the GPL is included to allow you to !<<
\r
14 >>! distribute a combined work that includes FreeRTOS without being !<<
\r
15 >>! obliged to provide the source code for proprietary components !<<
\r
16 >>! outside of the FreeRTOS kernel. !<<
\r
18 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
19 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
20 FOR A PARTICULAR PURPOSE. Full license text is available on the following
\r
21 link: http://www.freertos.org/a00114.html
\r
25 ***************************************************************************
\r
27 * Having a problem? Start by reading the FAQ "My application does *
\r
28 * not run, what could be wrong?". Have you defined configASSERT()? *
\r
30 * http://www.FreeRTOS.org/FAQHelp.html *
\r
32 ***************************************************************************
\r
34 ***************************************************************************
\r
36 * FreeRTOS provides completely free yet professionally developed, *
\r
37 * robust, strictly quality controlled, supported, and cross *
\r
38 * platform software that is more than just the market leader, it *
\r
39 * is the industry's de facto standard. *
\r
41 * Help yourself get started quickly while simultaneously helping *
\r
42 * to support the FreeRTOS project by purchasing a FreeRTOS *
\r
43 * tutorial book, reference manual, or both: *
\r
44 * http://www.FreeRTOS.org/Documentation *
\r
46 ***************************************************************************
\r
48 ***************************************************************************
\r
50 * Investing in training allows your team to be as productive as *
\r
51 * possible as early as possible, lowering your overall development *
\r
52 * cost, and enabling you to bring a more robust product to market *
\r
53 * earlier than would otherwise be possible. Richard Barry is both *
\r
54 * the architect and key author of FreeRTOS, and so also the world's *
\r
55 * leading authority on what is the world's most popular real time *
\r
56 * kernel for deeply embedded MCU designs. Obtaining your training *
\r
57 * from Richard ensures your team will gain directly from his in-depth *
\r
58 * product knowledge and years of usage experience. Contact Real Time *
\r
59 * Engineers Ltd to enquire about the FreeRTOS Masterclass, presented *
\r
60 * by Richard Barry: http://www.FreeRTOS.org/contact
\r
62 ***************************************************************************
\r
64 ***************************************************************************
\r
66 * You are receiving this top quality software for free. Please play *
\r
67 * fair and reciprocate by reporting any suspected issues and *
\r
68 * participating in the community forum: *
\r
69 * http://www.FreeRTOS.org/support *
\r
73 ***************************************************************************
\r
75 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
\r
76 license and Real Time Engineers Ltd. contact details.
\r
78 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
79 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
80 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
82 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
\r
83 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
\r
85 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
\r
86 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
87 licenses offer ticketed support, indemnification and commercial middleware.
\r
89 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
90 engineered and independently SIL3 certified version for use in safety and
\r
91 mission critical applications that require provable dependability.
\r
96 /* Standard includes. */
\r
99 /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
\r
100 all the API functions to use the MPU wrappers. That should only be done when
\r
101 task.h is included from an application file. */
\r
102 #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
\r
104 /* FreeRTOS includes. */
\r
105 #include "FreeRTOS.h"
\r
107 #include "timers.h"
\r
108 #include "event_groups.h"
\r
110 /* Lint e961 and e750 are suppressed as a MISRA exception justified because the
\r
111 MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the
\r
112 header files above, but not in this file, in order to generate the correct
\r
113 privileged Vs unprivileged linkage and placement. */
\r
114 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */
\r
116 #if ( INCLUDE_xEventGroupSetBitFromISR == 1 ) && ( configUSE_TIMERS == 0 )
\r
117 #error configUSE_TIMERS must be set to 1 to make the xEventGroupSetBitFromISR() function available.
\r
120 #if ( INCLUDE_xEventGroupSetBitFromISR == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 0 )
\r
121 #error INCLUDE_xTimerPendFunctionCall must also be set to one to make the xEventGroupSetBitFromISR() function available.
\r
124 /* The following bit fields convey control information in a task's event list
\r
125 item value. It is important they don't clash with the
\r
126 taskEVENT_LIST_ITEM_VALUE_IN_USE definition. */
\r
127 #if configUSE_16_BIT_TICKS == 1
\r
128 #define eventCLEAR_EVENTS_ON_EXIT_BIT 0x0100U
\r
129 #define eventUNBLOCKED_DUE_TO_BIT_SET 0x0200U
\r
130 #define eventWAIT_FOR_ALL_BITS 0x0400U
\r
131 #define eventEVENT_BITS_CONTROL_BYTES 0xff00U
\r
133 #define eventCLEAR_EVENTS_ON_EXIT_BIT 0x01000000UL
\r
134 #define eventUNBLOCKED_DUE_TO_BIT_SET 0x02000000UL
\r
135 #define eventWAIT_FOR_ALL_BITS 0x04000000UL
\r
136 #define eventEVENT_BITS_CONTROL_BYTES 0xff000000UL
\r
139 typedef struct xEventGroupDefinition
\r
141 EventBits_t uxEventBits;
\r
142 List_t xTasksWaitingForBits; /*< List of tasks waiting for a bit to be set. */
\r
144 #if( configUSE_TRACE_FACILITY == 1 )
\r
145 UBaseType_t uxEventGroupNumber;
\r
150 /*-----------------------------------------------------------*/
\r
153 * Test the bits set in uxCurrentEventBits to see if the wait condition is met.
\r
154 * The wait condition is defined by xWaitForAllBits. If xWaitForAllBits is
\r
155 * pdTRUE then the wait condition is met if all the bits set in uxBitsToWaitFor
\r
156 * are also set in uxCurrentEventBits. If xWaitForAllBits is pdFALSE then the
\r
157 * wait condition is met if any of the bits set in uxBitsToWait for are also set
\r
158 * in uxCurrentEventBits.
\r
160 static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, const EventBits_t uxBitsToWaitFor, const BaseType_t xWaitForAllBits );
\r
162 /*-----------------------------------------------------------*/
\r
164 EventGroupHandle_t xEventGroupCreate( void )
\r
166 EventGroup_t *pxEventBits;
\r
168 pxEventBits = pvPortMalloc( sizeof( EventGroup_t ) );
\r
169 if( pxEventBits != NULL )
\r
171 pxEventBits->uxEventBits = 0;
\r
172 vListInitialise( &( pxEventBits->xTasksWaitingForBits ) );
\r
173 traceEVENT_GROUP_CREATE( pxEventBits );
\r
177 traceEVENT_GROUP_CREATE_FAILED();
\r
180 return ( EventGroupHandle_t ) pxEventBits;
\r
182 /*-----------------------------------------------------------*/
\r
184 EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait )
\r
186 EventBits_t uxOriginalBitValue, uxReturn;
\r
187 EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
\r
188 BaseType_t xAlreadyYielded;
\r
189 BaseType_t xTimeoutOccurred = pdFALSE;
\r
191 configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
\r
192 configASSERT( uxBitsToWaitFor != 0 );
\r
193 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
\r
195 configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
\r
201 uxOriginalBitValue = pxEventBits->uxEventBits;
\r
203 ( void ) xEventGroupSetBits( xEventGroup, uxBitsToSet );
\r
205 if( ( ( uxOriginalBitValue | uxBitsToSet ) & uxBitsToWaitFor ) == uxBitsToWaitFor )
\r
207 /* All the rendezvous bits are now set - no need to block. */
\r
208 uxReturn = ( uxOriginalBitValue | uxBitsToSet );
\r
210 /* Rendezvous always clear the bits. They will have been cleared
\r
211 already unless this is the only task in the rendezvous. */
\r
212 pxEventBits->uxEventBits &= ~uxBitsToWaitFor;
\r
218 if( xTicksToWait != ( TickType_t ) 0 )
\r
220 traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor );
\r
222 /* Store the bits that the calling task is waiting for in the
\r
223 task's event list item so the kernel knows when a match is
\r
224 found. Then enter the blocked state. */
\r
225 vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | eventCLEAR_EVENTS_ON_EXIT_BIT | eventWAIT_FOR_ALL_BITS ), xTicksToWait );
\r
227 /* This assignment is obsolete as uxReturn will get set after
\r
228 the task unblocks, but some compilers mistakenly generate a
\r
229 warning about uxReturn being returned without being set if the
\r
230 assignment is omitted. */
\r
235 /* The rendezvous bits were not set, but no block time was
\r
236 specified - just return the current event bit value. */
\r
237 uxReturn = pxEventBits->uxEventBits;
\r
241 xAlreadyYielded = xTaskResumeAll();
\r
243 if( xTicksToWait != ( TickType_t ) 0 )
\r
245 if( xAlreadyYielded == pdFALSE )
\r
247 portYIELD_WITHIN_API();
\r
251 mtCOVERAGE_TEST_MARKER();
\r
254 /* The task blocked to wait for its required bits to be set - at this
\r
255 point either the required bits were set or the block time expired. If
\r
256 the required bits were set they will have been stored in the task's
\r
257 event list item, and they should now be retrieved then cleared. */
\r
258 uxReturn = uxTaskResetEventItemValue();
\r
260 if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 )
\r
262 /* The task timed out, just return the current event bit value. */
\r
263 taskENTER_CRITICAL();
\r
265 uxReturn = pxEventBits->uxEventBits;
\r
267 /* Although the task got here because it timed out before the
\r
268 bits it was waiting for were set, it is possible that since it
\r
269 unblocked another task has set the bits. If this is the case
\r
270 then it needs to clear the bits before exiting. */
\r
271 if( ( uxReturn & uxBitsToWaitFor ) == uxBitsToWaitFor )
\r
273 pxEventBits->uxEventBits &= ~uxBitsToWaitFor;
\r
277 mtCOVERAGE_TEST_MARKER();
\r
280 taskEXIT_CRITICAL();
\r
282 xTimeoutOccurred = pdTRUE;
\r
286 /* The task unblocked because the bits were set. */
\r
289 /* Control bits might be set as the task had blocked should not be
\r
291 uxReturn &= ~eventEVENT_BITS_CONTROL_BYTES;
\r
294 traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred );
\r
298 /*-----------------------------------------------------------*/
\r
300 EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait )
\r
302 EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
\r
303 EventBits_t uxReturn, uxControlBits = 0;
\r
304 BaseType_t xWaitConditionMet, xAlreadyYielded;
\r
305 BaseType_t xTimeoutOccurred = pdFALSE;
\r
307 /* Check the user is not attempting to wait on the bits used by the kernel
\r
308 itself, and that at least one bit is being requested. */
\r
309 configASSERT( xEventGroup );
\r
310 configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
\r
311 configASSERT( uxBitsToWaitFor != 0 );
\r
312 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
\r
314 configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
\r
320 const EventBits_t uxCurrentEventBits = pxEventBits->uxEventBits;
\r
322 /* Check to see if the wait condition is already met or not. */
\r
323 xWaitConditionMet = prvTestWaitCondition( uxCurrentEventBits, uxBitsToWaitFor, xWaitForAllBits );
\r
325 if( xWaitConditionMet != pdFALSE )
\r
327 /* The wait condition has already been met so there is no need to
\r
329 uxReturn = uxCurrentEventBits;
\r
330 xTicksToWait = ( TickType_t ) 0;
\r
332 /* Clear the wait bits if requested to do so. */
\r
333 if( xClearOnExit != pdFALSE )
\r
335 pxEventBits->uxEventBits &= ~uxBitsToWaitFor;
\r
339 mtCOVERAGE_TEST_MARKER();
\r
342 else if( xTicksToWait == ( TickType_t ) 0 )
\r
344 /* The wait condition has not been met, but no block time was
\r
345 specified, so just return the current value. */
\r
346 uxReturn = uxCurrentEventBits;
\r
350 /* The task is going to block to wait for its required bits to be
\r
351 set. uxControlBits are used to remember the specified behaviour of
\r
352 this call to xEventGroupWaitBits() - for use when the event bits
\r
353 unblock the task. */
\r
354 if( xClearOnExit != pdFALSE )
\r
356 uxControlBits |= eventCLEAR_EVENTS_ON_EXIT_BIT;
\r
360 mtCOVERAGE_TEST_MARKER();
\r
363 if( xWaitForAllBits != pdFALSE )
\r
365 uxControlBits |= eventWAIT_FOR_ALL_BITS;
\r
369 mtCOVERAGE_TEST_MARKER();
\r
372 /* Store the bits that the calling task is waiting for in the
\r
373 task's event list item so the kernel knows when a match is
\r
374 found. Then enter the blocked state. */
\r
375 vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | uxControlBits ), xTicksToWait );
\r
377 /* This is obsolete as it will get set after the task unblocks, but
\r
378 some compilers mistakenly generate a warning about the variable
\r
379 being returned without being set if it is not done. */
\r
382 traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor );
\r
385 xAlreadyYielded = xTaskResumeAll();
\r
387 if( xTicksToWait != ( TickType_t ) 0 )
\r
389 if( xAlreadyYielded == pdFALSE )
\r
391 portYIELD_WITHIN_API();
\r
395 mtCOVERAGE_TEST_MARKER();
\r
398 /* The task blocked to wait for its required bits to be set - at this
\r
399 point either the required bits were set or the block time expired. If
\r
400 the required bits were set they will have been stored in the task's
\r
401 event list item, and they should now be retrieved then cleared. */
\r
402 uxReturn = uxTaskResetEventItemValue();
\r
404 if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 )
\r
406 taskENTER_CRITICAL();
\r
408 /* The task timed out, just return the current event bit value. */
\r
409 uxReturn = pxEventBits->uxEventBits;
\r
411 /* It is possible that the event bits were updated between this
\r
412 task leaving the Blocked state and running again. */
\r
413 if( prvTestWaitCondition( uxReturn, uxBitsToWaitFor, xWaitForAllBits ) != pdFALSE )
\r
415 if( xClearOnExit != pdFALSE )
\r
417 pxEventBits->uxEventBits &= ~uxBitsToWaitFor;
\r
421 mtCOVERAGE_TEST_MARKER();
\r
426 mtCOVERAGE_TEST_MARKER();
\r
429 taskEXIT_CRITICAL();
\r
431 /* Prevent compiler warnings when trace macros are not used. */
\r
432 xTimeoutOccurred = pdFALSE;
\r
436 /* The task unblocked because the bits were set. */
\r
439 /* The task blocked so control bits may have been set. */
\r
440 uxReturn &= ~eventEVENT_BITS_CONTROL_BYTES;
\r
442 traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred );
\r
446 /*-----------------------------------------------------------*/
\r
448 EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear )
\r
450 EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
\r
451 EventBits_t uxReturn;
\r
453 /* Check the user is not attempting to clear the bits used by the kernel
\r
455 configASSERT( xEventGroup );
\r
456 configASSERT( ( uxBitsToClear & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
\r
458 taskENTER_CRITICAL();
\r
460 traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear );
\r
462 /* The value returned is the event group value prior to the bits being
\r
464 uxReturn = pxEventBits->uxEventBits;
\r
466 /* Clear the bits. */
\r
467 pxEventBits->uxEventBits &= ~uxBitsToClear;
\r
469 taskEXIT_CRITICAL();
\r
473 /*-----------------------------------------------------------*/
\r
475 #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
\r
477 BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear )
\r
479 BaseType_t xReturn;
\r
481 traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear );
\r
482 xReturn = xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL );
\r
488 /*-----------------------------------------------------------*/
\r
490 EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup )
\r
492 UBaseType_t uxSavedInterruptStatus;
\r
493 EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
\r
494 EventBits_t uxReturn;
\r
496 uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
\r
498 uxReturn = pxEventBits->uxEventBits;
\r
500 portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );
\r
504 /*-----------------------------------------------------------*/
\r
506 EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet )
\r
508 ListItem_t *pxListItem, *pxNext;
\r
509 ListItem_t const *pxListEnd;
\r
511 EventBits_t uxBitsToClear = 0, uxBitsWaitedFor, uxControlBits;
\r
512 EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
\r
513 BaseType_t xMatchFound = pdFALSE;
\r
515 /* Check the user is not attempting to set the bits used by the kernel
\r
517 configASSERT( xEventGroup );
\r
518 configASSERT( ( uxBitsToSet & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
\r
520 pxList = &( pxEventBits->xTasksWaitingForBits );
\r
521 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
524 traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet );
\r
526 pxListItem = listGET_HEAD_ENTRY( pxList );
\r
528 /* Set the bits. */
\r
529 pxEventBits->uxEventBits |= uxBitsToSet;
\r
531 /* See if the new bit value should unblock any tasks. */
\r
532 while( pxListItem != pxListEnd )
\r
534 pxNext = listGET_NEXT( pxListItem );
\r
535 uxBitsWaitedFor = listGET_LIST_ITEM_VALUE( pxListItem );
\r
536 xMatchFound = pdFALSE;
\r
538 /* Split the bits waited for from the control bits. */
\r
539 uxControlBits = uxBitsWaitedFor & eventEVENT_BITS_CONTROL_BYTES;
\r
540 uxBitsWaitedFor &= ~eventEVENT_BITS_CONTROL_BYTES;
\r
542 if( ( uxControlBits & eventWAIT_FOR_ALL_BITS ) == ( EventBits_t ) 0 )
\r
544 /* Just looking for single bit being set. */
\r
545 if( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) != ( EventBits_t ) 0 )
\r
547 xMatchFound = pdTRUE;
\r
551 mtCOVERAGE_TEST_MARKER();
\r
554 else if( ( uxBitsWaitedFor & pxEventBits->uxEventBits ) == uxBitsWaitedFor )
\r
556 /* All bits are set. */
\r
557 xMatchFound = pdTRUE;
\r
561 /* Need all bits to be set, but not all the bits were set. */
\r
564 if( xMatchFound != pdFALSE )
\r
566 /* The bits match. Should the bits be cleared on exit? */
\r
567 if( ( uxControlBits & eventCLEAR_EVENTS_ON_EXIT_BIT ) != ( EventBits_t ) 0 )
\r
569 uxBitsToClear |= uxBitsWaitedFor;
\r
573 mtCOVERAGE_TEST_MARKER();
\r
576 /* Store the actual event flag value in the task's event list
\r
577 item before removing the task from the event list. The
\r
578 eventUNBLOCKED_DUE_TO_BIT_SET bit is set so the task knows
\r
579 that is was unblocked due to its required bits matching, rather
\r
580 than because it timed out. */
\r
581 ( void ) xTaskRemoveFromUnorderedEventList( pxListItem, pxEventBits->uxEventBits | eventUNBLOCKED_DUE_TO_BIT_SET );
\r
584 /* Move onto the next list item. Note pxListItem->pxNext is not
\r
585 used here as the list item may have been removed from the event list
\r
586 and inserted into the ready/pending reading list. */
\r
587 pxListItem = pxNext;
\r
590 /* Clear any bits that matched when the eventCLEAR_EVENTS_ON_EXIT_BIT
\r
591 bit was set in the control word. */
\r
592 pxEventBits->uxEventBits &= ~uxBitsToClear;
\r
594 ( void ) xTaskResumeAll();
\r
596 return pxEventBits->uxEventBits;
\r
598 /*-----------------------------------------------------------*/
\r
600 void vEventGroupDelete( EventGroupHandle_t xEventGroup )
\r
602 EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
\r
603 const List_t *pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits );
\r
607 traceEVENT_GROUP_DELETE( xEventGroup );
\r
609 while( listCURRENT_LIST_LENGTH( pxTasksWaitingForBits ) > ( UBaseType_t ) 0 )
\r
611 /* Unblock the task, returning 0 as the event list is being deleted
\r
612 and cannot therefore have any bits set. */
\r
613 configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( ListItem_t * ) &( pxTasksWaitingForBits->xListEnd ) );
\r
614 ( void ) xTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET );
\r
617 vPortFree( pxEventBits );
\r
619 ( void ) xTaskResumeAll();
\r
621 /*-----------------------------------------------------------*/
\r
623 /* For internal use only - execute a 'set bits' command that was pended from
\r
625 void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet )
\r
627 ( void ) xEventGroupSetBits( pvEventGroup, ( EventBits_t ) ulBitsToSet );
\r
629 /*-----------------------------------------------------------*/
\r
631 /* For internal use only - execute a 'clear bits' command that was pended from
\r
633 void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear )
\r
635 ( void ) xEventGroupClearBits( pvEventGroup, ( EventBits_t ) ulBitsToClear );
\r
637 /*-----------------------------------------------------------*/
\r
639 static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits, const EventBits_t uxBitsToWaitFor, const BaseType_t xWaitForAllBits )
\r
641 BaseType_t xWaitConditionMet = pdFALSE;
\r
643 if( xWaitForAllBits == pdFALSE )
\r
645 /* Task only has to wait for one bit within uxBitsToWaitFor to be
\r
646 set. Is one already set? */
\r
647 if( ( uxCurrentEventBits & uxBitsToWaitFor ) != ( EventBits_t ) 0 )
\r
649 xWaitConditionMet = pdTRUE;
\r
653 mtCOVERAGE_TEST_MARKER();
\r
658 /* Task has to wait for all the bits in uxBitsToWaitFor to be set.
\r
659 Are they set already? */
\r
660 if( ( uxCurrentEventBits & uxBitsToWaitFor ) == uxBitsToWaitFor )
\r
662 xWaitConditionMet = pdTRUE;
\r
666 mtCOVERAGE_TEST_MARKER();
\r
670 return xWaitConditionMet;
\r
672 /*-----------------------------------------------------------*/
\r
674 #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
\r
676 BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken )
\r
678 BaseType_t xReturn;
\r
680 traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet );
\r
681 xReturn = xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken );
\r
687 /*-----------------------------------------------------------*/
\r
689 #if (configUSE_TRACE_FACILITY == 1)
\r
691 UBaseType_t uxEventGroupGetNumber( void* xEventGroup )
\r
693 UBaseType_t xReturn;
\r
694 EventGroup_t *pxEventBits = ( EventGroup_t * ) xEventGroup;
\r
696 if( xEventGroup == NULL )
\r
702 xReturn = pxEventBits->uxEventGroupNumber;
\r