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