]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blobdiff - os/8.2.2/include/os/event_groups.h
Add FreeRTOS 8.2.2
[pes-rpp/rpp-lib.git] / os / 8.2.2 / include / os / event_groups.h
diff --git a/os/8.2.2/include/os/event_groups.h b/os/8.2.2/include/os/event_groups.h
new file mode 100644 (file)
index 0000000..106ed60
--- /dev/null
@@ -0,0 +1,730 @@
+/*\r
+    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+#ifndef EVENT_GROUPS_H\r
+#define EVENT_GROUPS_H\r
+\r
+#ifndef INC_FREERTOS_H\r
+       #error "include FreeRTOS.h" must appear in source files before "include event_groups.h"\r
+#endif\r
+\r
+#include "timers.h"\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/**\r
+ * An event group is a collection of bits to which an application can assign a\r
+ * meaning.  For example, an application may create an event group to convey\r
+ * the status of various CAN bus related events in which bit 0 might mean "A CAN\r
+ * message has been received and is ready for processing", bit 1 might mean "The\r
+ * application has queued a message that is ready for sending onto the CAN\r
+ * network", and bit 2 might mean "It is time to send a SYNC message onto the\r
+ * CAN network" etc.  A task can then test the bit values to see which events\r
+ * are active, and optionally enter the Blocked state to wait for a specified\r
+ * bit or a group of specified bits to be active.  To continue the CAN bus\r
+ * example, a CAN controlling task can enter the Blocked state (and therefore\r
+ * not consume any processing time) until either bit 0, bit 1 or bit 2 are\r
+ * active, at which time the bit that was actually active would inform the task\r
+ * which action it had to take (process a received message, send a message, or\r
+ * send a SYNC).\r
+ *\r
+ * The event groups implementation contains intelligence to avoid race\r
+ * conditions that would otherwise occur were an application to use a simple\r
+ * variable for the same purpose.  This is particularly important with respect\r
+ * to when a bit within an event group is to be cleared, and when bits have to\r
+ * be set and then tested atomically - as is the case where event groups are\r
+ * used to create a synchronisation point between multiple tasks (a\r
+ * 'rendezvous').\r
+ *\r
+ * \defgroup EventGroup\r
+ */\r
+\r
+\r
+\r
+/**\r
+ * event_groups.h\r
+ *\r
+ * Type by which event groups are referenced.  For example, a call to\r
+ * xEventGroupCreate() returns an EventGroupHandle_t variable that can then\r
+ * be used as a parameter to other event group functions.\r
+ *\r
+ * \defgroup EventGroupHandle_t EventGroupHandle_t\r
+ * \ingroup EventGroup\r
+ */\r
+typedef void * EventGroupHandle_t;\r
+\r
+/* \r
+ * The type that holds event bits always matches TickType_t - therefore the\r
+ * number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1,\r
+ * 32 bits if set to 0. \r
+ *\r
+ * \defgroup EventBits_t EventBits_t\r
+ * \ingroup EventGroup\r
+ */\r
+typedef TickType_t EventBits_t;\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+ EventGroupHandle_t xEventGroupCreate( void );\r
+ </pre>\r
+ *\r
+ * Create a new event group.  This function cannot be called from an interrupt.\r
+ *\r
+ * Although event groups are not related to ticks, for internal implementation\r
+ * reasons the number of bits available for use in an event group is dependent\r
+ * on the configUSE_16_BIT_TICKS setting in FreeRTOSConfig.h.  If\r
+ * configUSE_16_BIT_TICKS is 1 then each event group contains 8 usable bits (bit\r
+ * 0 to bit 7).  If configUSE_16_BIT_TICKS is set to 0 then each event group has\r
+ * 24 usable bits (bit 0 to bit 23).  The EventBits_t type is used to store\r
+ * event bits within an event group.\r
+ *\r
+ * @return If the event group was created then a handle to the event group is\r
+ * returned.  If there was insufficient FreeRTOS heap available to create the\r
+ * event group then NULL is returned.  See http://www.freertos.org/a00111.html\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+       // Declare a variable to hold the created event group.\r
+       EventGroupHandle_t xCreatedEventGroup;\r
+\r
+       // Attempt to create the event group.\r
+       xCreatedEventGroup = xEventGroupCreate();\r
+\r
+       // Was the event group created successfully?\r
+       if( xCreatedEventGroup == NULL )\r
+       {\r
+               // The event group was not created because there was insufficient\r
+               // FreeRTOS heap available.\r
+       }\r
+       else\r
+       {\r
+               // The event group was created.\r
+       }\r
+   </pre>\r
+ * \defgroup xEventGroupCreate xEventGroupCreate\r
+ * \ingroup EventGroup\r
+ */\r
+EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       EventBits_t xEventGroupWaitBits(        EventGroupHandle_t xEventGroup,\r
+                                                                               const EventBits_t uxBitsToWaitFor,\r
+                                                                               const BaseType_t xClearOnExit,\r
+                                                                               const BaseType_t xWaitForAllBits,\r
+                                                                               const TickType_t xTicksToWait );\r
+ </pre>\r
+ *\r
+ * [Potentially] block to wait for one or more bits to be set within a\r
+ * previously created event group.\r
+ *\r
+ * This function cannot be called from an interrupt.\r
+ *\r
+ * @param xEventGroup The event group in which the bits are being tested.  The\r
+ * event group must have previously been created using a call to\r
+ * xEventGroupCreate().\r
+ *\r
+ * @param uxBitsToWaitFor A bitwise value that indicates the bit or bits to test\r
+ * inside the event group.  For example, to wait for bit 0 and/or bit 2 set\r
+ * uxBitsToWaitFor to 0x05.  To wait for bits 0 and/or bit 1 and/or bit 2 set\r
+ * uxBitsToWaitFor to 0x07.  Etc.\r
+ *\r
+ * @param xClearOnExit If xClearOnExit is set to pdTRUE then any bits within\r
+ * uxBitsToWaitFor that are set within the event group will be cleared before\r
+ * xEventGroupWaitBits() returns if the wait condition was met (if the function\r
+ * returns for a reason other than a timeout).  If xClearOnExit is set to\r
+ * pdFALSE then the bits set in the event group are not altered when the call to\r
+ * xEventGroupWaitBits() returns.\r
+ *\r
+ * @param xWaitForAllBits If xWaitForAllBits is set to pdTRUE then\r
+ * xEventGroupWaitBits() will return when either all the bits in uxBitsToWaitFor\r
+ * are set or the specified block time expires.  If xWaitForAllBits is set to\r
+ * pdFALSE then xEventGroupWaitBits() will return when any one of the bits set\r
+ * in uxBitsToWaitFor is set or the specified block time expires.  The block\r
+ * time is specified by the xTicksToWait parameter.\r
+ *\r
+ * @param xTicksToWait The maximum amount of time (specified in 'ticks') to wait\r
+ * for one/all (depending on the xWaitForAllBits value) of the bits specified by\r
+ * uxBitsToWaitFor to become set.\r
+ *\r
+ * @return The value of the event group at the time either the bits being waited\r
+ * for became set, or the block time expired.  Test the return value to know\r
+ * which bits were set.  If xEventGroupWaitBits() returned because its timeout\r
+ * expired then not all the bits being waited for will be set.  If\r
+ * xEventGroupWaitBits() returned because the bits it was waiting for were set\r
+ * then the returned value is the event group value before any bits were\r
+ * automatically cleared in the case that xClearOnExit parameter was set to\r
+ * pdTRUE.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+   #define BIT_0       ( 1 << 0 )\r
+   #define BIT_4       ( 1 << 4 )\r
+\r
+   void aFunction( EventGroupHandle_t xEventGroup )\r
+   {\r
+   EventBits_t uxBits;\r
+   const TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;\r
+\r
+               // Wait a maximum of 100ms for either bit 0 or bit 4 to be set within\r
+               // the event group.  Clear the bits before exiting.\r
+               uxBits = xEventGroupWaitBits(\r
+                                       xEventGroup,    // The event group being tested.\r
+                                       BIT_0 | BIT_4,  // The bits within the event group to wait for.\r
+                                       pdTRUE,                 // BIT_0 and BIT_4 should be cleared before returning.\r
+                                       pdFALSE,                // Don't wait for both bits, either bit will do.\r
+                                       xTicksToWait ); // Wait a maximum of 100ms for either bit to be set.\r
+\r
+               if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )\r
+               {\r
+                       // xEventGroupWaitBits() returned because both bits were set.\r
+               }\r
+               else if( ( uxBits & BIT_0 ) != 0 )\r
+               {\r
+                       // xEventGroupWaitBits() returned because just BIT_0 was set.\r
+               }\r
+               else if( ( uxBits & BIT_4 ) != 0 )\r
+               {\r
+                       // xEventGroupWaitBits() returned because just BIT_4 was set.\r
+               }\r
+               else\r
+               {\r
+                       // xEventGroupWaitBits() returned because xTicksToWait ticks passed\r
+                       // without either BIT_0 or BIT_4 becoming set.\r
+               }\r
+   }\r
+   </pre>\r
+ * \defgroup xEventGroupWaitBits xEventGroupWaitBits\r
+ * \ingroup EventGroup\r
+ */\r
+EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear );\r
+ </pre>\r
+ *\r
+ * Clear bits within an event group.  This function cannot be called from an\r
+ * interrupt.\r
+ *\r
+ * @param xEventGroup The event group in which the bits are to be cleared.\r
+ *\r
+ * @param uxBitsToClear A bitwise value that indicates the bit or bits to clear\r
+ * in the event group.  For example, to clear bit 3 only, set uxBitsToClear to\r
+ * 0x08.  To clear bit 3 and bit 0 set uxBitsToClear to 0x09.\r
+ *\r
+ * @return The value of the event group before the specified bits were cleared.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+   #define BIT_0       ( 1 << 0 )\r
+   #define BIT_4       ( 1 << 4 )\r
+\r
+   void aFunction( EventGroupHandle_t xEventGroup )\r
+   {\r
+   EventBits_t uxBits;\r
+\r
+               // Clear bit 0 and bit 4 in xEventGroup.\r
+               uxBits = xEventGroupClearBits(\r
+                                                               xEventGroup,    // The event group being updated.\r
+                                                               BIT_0 | BIT_4 );// The bits being cleared.\r
+\r
+               if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )\r
+               {\r
+                       // Both bit 0 and bit 4 were set before xEventGroupClearBits() was\r
+                       // called.  Both will now be clear (not set).\r
+               }\r
+               else if( ( uxBits & BIT_0 ) != 0 )\r
+               {\r
+                       // Bit 0 was set before xEventGroupClearBits() was called.  It will\r
+                       // now be clear.\r
+               }\r
+               else if( ( uxBits & BIT_4 ) != 0 )\r
+               {\r
+                       // Bit 4 was set before xEventGroupClearBits() was called.  It will\r
+                       // now be clear.\r
+               }\r
+               else\r
+               {\r
+                       // Neither bit 0 nor bit 4 were set in the first place.\r
+               }\r
+   }\r
+   </pre>\r
+ * \defgroup xEventGroupClearBits xEventGroupClearBits\r
+ * \ingroup EventGroup\r
+ */\r
+EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );\r
+ </pre>\r
+ *\r
+ * A version of xEventGroupClearBits() that can be called from an interrupt.\r
+ *\r
+ * Setting bits in an event group is not a deterministic operation because there\r
+ * are an unknown number of tasks that may be waiting for the bit or bits being\r
+ * set.  FreeRTOS does not allow nondeterministic operations to be performed\r
+ * while interrupts are disabled, so protects event groups that are accessed\r
+ * from tasks by suspending the scheduler rather than disabling interrupts.  As\r
+ * a result event groups cannot be accessed directly from an interrupt service\r
+ * routine.  Therefore xEventGroupClearBitsFromISR() sends a message to the \r
+ * timer task to have the clear operation performed in the context of the timer \r
+ * task.\r
+ *\r
+ * @param xEventGroup The event group in which the bits are to be cleared.\r
+ *\r
+ * @param uxBitsToClear A bitwise value that indicates the bit or bits to clear.\r
+ * For example, to clear bit 3 only, set uxBitsToClear to 0x08.  To clear bit 3\r
+ * and bit 0 set uxBitsToClear to 0x09.\r
+ *\r
+ * @return If the request to execute the function was posted successfully then \r
+ * pdPASS is returned, otherwise pdFALSE is returned.  pdFALSE will be returned \r
+ * if the timer service queue was full.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+   #define BIT_0       ( 1 << 0 )\r
+   #define BIT_4       ( 1 << 4 )\r
+\r
+   // An event group which it is assumed has already been created by a call to\r
+   // xEventGroupCreate().\r
+   EventGroupHandle_t xEventGroup;\r
+\r
+   void anInterruptHandler( void )\r
+   {\r
+               // Clear bit 0 and bit 4 in xEventGroup.\r
+               xResult = xEventGroupClearBitsFromISR(\r
+                                                       xEventGroup,     // The event group being updated.\r
+                                                       BIT_0 | BIT_4 ); // The bits being set.\r
+\r
+               if( xResult == pdPASS )\r
+               {\r
+                       // The message was posted successfully.\r
+               }\r
+  }\r
+   </pre>\r
+ * \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR\r
+ * \ingroup EventGroup\r
+ */\r
+#if( configUSE_TRACE_FACILITY == 1 )\r
+       BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION;\r
+#else\r
+       #define xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear ) xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL )\r
+#endif\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );\r
+ </pre>\r
+ *\r
+ * Set bits within an event group.\r
+ * This function cannot be called from an interrupt.  xEventGroupSetBitsFromISR()\r
+ * is a version that can be called from an interrupt.\r
+ *\r
+ * Setting bits in an event group will automatically unblock tasks that are\r
+ * blocked waiting for the bits.\r
+ *\r
+ * @param xEventGroup The event group in which the bits are to be set.\r
+ *\r
+ * @param uxBitsToSet A bitwise value that indicates the bit or bits to set.\r
+ * For example, to set bit 3 only, set uxBitsToSet to 0x08.  To set bit 3\r
+ * and bit 0 set uxBitsToSet to 0x09.\r
+ *\r
+ * @return The value of the event group at the time the call to\r
+ * xEventGroupSetBits() returns.  There are two reasons why the returned value\r
+ * might have the bits specified by the uxBitsToSet parameter cleared.  First,\r
+ * if setting a bit results in a task that was waiting for the bit leaving the\r
+ * blocked state then it is possible the bit will be cleared automatically\r
+ * (see the xClearBitOnExit parameter of xEventGroupWaitBits()).  Second, any\r
+ * unblocked (or otherwise Ready state) task that has a priority above that of\r
+ * the task that called xEventGroupSetBits() will execute and may change the\r
+ * event group value before the call to xEventGroupSetBits() returns.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+   #define BIT_0       ( 1 << 0 )\r
+   #define BIT_4       ( 1 << 4 )\r
+\r
+   void aFunction( EventGroupHandle_t xEventGroup )\r
+   {\r
+   EventBits_t uxBits;\r
+\r
+               // Set bit 0 and bit 4 in xEventGroup.\r
+               uxBits = xEventGroupSetBits(\r
+                                                       xEventGroup,    // The event group being updated.\r
+                                                       BIT_0 | BIT_4 );// The bits being set.\r
+\r
+               if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )\r
+               {\r
+                       // Both bit 0 and bit 4 remained set when the function returned.\r
+               }\r
+               else if( ( uxBits & BIT_0 ) != 0 )\r
+               {\r
+                       // Bit 0 remained set when the function returned, but bit 4 was\r
+                       // cleared.  It might be that bit 4 was cleared automatically as a\r
+                       // task that was waiting for bit 4 was removed from the Blocked\r
+                       // state.\r
+               }\r
+               else if( ( uxBits & BIT_4 ) != 0 )\r
+               {\r
+                       // Bit 4 remained set when the function returned, but bit 0 was\r
+                       // cleared.  It might be that bit 0 was cleared automatically as a\r
+                       // task that was waiting for bit 0 was removed from the Blocked\r
+                       // state.\r
+               }\r
+               else\r
+               {\r
+                       // Neither bit 0 nor bit 4 remained set.  It might be that a task\r
+                       // was waiting for both of the bits to be set, and the bits were\r
+                       // cleared as the task left the Blocked state.\r
+               }\r
+   }\r
+   </pre>\r
+ * \defgroup xEventGroupSetBits xEventGroupSetBits\r
+ * \ingroup EventGroup\r
+ */\r
+EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken );\r
+ </pre>\r
+ *\r
+ * A version of xEventGroupSetBits() that can be called from an interrupt.\r
+ *\r
+ * Setting bits in an event group is not a deterministic operation because there\r
+ * are an unknown number of tasks that may be waiting for the bit or bits being\r
+ * set.  FreeRTOS does not allow nondeterministic operations to be performed in\r
+ * interrupts or from critical sections.  Therefore xEventGroupSetBitFromISR()\r
+ * sends a message to the timer task to have the set operation performed in the\r
+ * context of the timer task - where a scheduler lock is used in place of a\r
+ * critical section.\r
+ *\r
+ * @param xEventGroup The event group in which the bits are to be set.\r
+ *\r
+ * @param uxBitsToSet A bitwise value that indicates the bit or bits to set.\r
+ * For example, to set bit 3 only, set uxBitsToSet to 0x08.  To set bit 3\r
+ * and bit 0 set uxBitsToSet to 0x09.\r
+ *\r
+ * @param pxHigherPriorityTaskWoken As mentioned above, calling this function\r
+ * will result in a message being sent to the timer daemon task.  If the\r
+ * priority of the timer daemon task is higher than the priority of the\r
+ * currently running task (the task the interrupt interrupted) then\r
+ * *pxHigherPriorityTaskWoken will be set to pdTRUE by\r
+ * xEventGroupSetBitsFromISR(), indicating that a context switch should be\r
+ * requested before the interrupt exits.  For that reason\r
+ * *pxHigherPriorityTaskWoken must be initialised to pdFALSE.  See the\r
+ * example code below.\r
+ *\r
+ * @return If the request to execute the function was posted successfully then \r
+ * pdPASS is returned, otherwise pdFALSE is returned.  pdFALSE will be returned \r
+ * if the timer service queue was full.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+   #define BIT_0       ( 1 << 0 )\r
+   #define BIT_4       ( 1 << 4 )\r
+\r
+   // An event group which it is assumed has already been created by a call to\r
+   // xEventGroupCreate().\r
+   EventGroupHandle_t xEventGroup;\r
+\r
+   void anInterruptHandler( void )\r
+   {\r
+   BaseType_t xHigherPriorityTaskWoken, xResult;\r
+\r
+               // xHigherPriorityTaskWoken must be initialised to pdFALSE.\r
+               xHigherPriorityTaskWoken = pdFALSE;\r
+\r
+               // Set bit 0 and bit 4 in xEventGroup.\r
+               xResult = xEventGroupSetBitsFromISR(\r
+                                                       xEventGroup,    // The event group being updated.\r
+                                                       BIT_0 | BIT_4   // The bits being set.\r
+                                                       &xHigherPriorityTaskWoken );\r
+\r
+               // Was the message posted successfully?\r
+               if( xResult == pdPASS )\r
+               {\r
+                       // If xHigherPriorityTaskWoken is now set to pdTRUE then a context\r
+                       // switch should be requested.  The macro used is port specific and \r
+                       // will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - \r
+                       // refer to the documentation page for the port being used.\r
+                       portYIELD_FROM_ISR( xHigherPriorityTaskWoken );\r
+               }\r
+  }\r
+   </pre>\r
+ * \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR\r
+ * \ingroup EventGroup\r
+ */\r
+#if( configUSE_TRACE_FACILITY == 1 )\r
+       BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;\r
+#else\r
+       #define xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken ) xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken )\r
+#endif\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       EventBits_t xEventGroupSync(    EventGroupHandle_t xEventGroup,\r
+                                                                       const EventBits_t uxBitsToSet,\r
+                                                                       const EventBits_t uxBitsToWaitFor,\r
+                                                                       TickType_t xTicksToWait );\r
+ </pre>\r
+ *\r
+ * Atomically set bits within an event group, then wait for a combination of\r
+ * bits to be set within the same event group.  This functionality is typically\r
+ * used to synchronise multiple tasks, where each task has to wait for the other\r
+ * tasks to reach a synchronisation point before proceeding.\r
+ *\r
+ * This function cannot be used from an interrupt.\r
+ *\r
+ * The function will return before its block time expires if the bits specified\r
+ * by the uxBitsToWait parameter are set, or become set within that time.  In\r
+ * this case all the bits specified by uxBitsToWait will be automatically\r
+ * cleared before the function returns.\r
+ *\r
+ * @param xEventGroup The event group in which the bits are being tested.  The\r
+ * event group must have previously been created using a call to\r
+ * xEventGroupCreate().\r
+ *\r
+ * @param uxBitsToSet The bits to set in the event group before determining\r
+ * if, and possibly waiting for, all the bits specified by the uxBitsToWait\r
+ * parameter are set.\r
+ *\r
+ * @param uxBitsToWaitFor A bitwise value that indicates the bit or bits to test\r
+ * inside the event group.  For example, to wait for bit 0 and bit 2 set\r
+ * uxBitsToWaitFor to 0x05.  To wait for bits 0 and bit 1 and bit 2 set\r
+ * uxBitsToWaitFor to 0x07.  Etc.\r
+ *\r
+ * @param xTicksToWait The maximum amount of time (specified in 'ticks') to wait\r
+ * for all of the bits specified by uxBitsToWaitFor to become set.\r
+ *\r
+ * @return The value of the event group at the time either the bits being waited\r
+ * for became set, or the block time expired.  Test the return value to know\r
+ * which bits were set.  If xEventGroupSync() returned because its timeout\r
+ * expired then not all the bits being waited for will be set.  If\r
+ * xEventGroupSync() returned because all the bits it was waiting for were\r
+ * set then the returned value is the event group value before any bits were\r
+ * automatically cleared.\r
+ *\r
+ * Example usage:\r
+ <pre>\r
+ // Bits used by the three tasks.\r
+ #define TASK_0_BIT            ( 1 << 0 )\r
+ #define TASK_1_BIT            ( 1 << 1 )\r
+ #define TASK_2_BIT            ( 1 << 2 )\r
+\r
+ #define ALL_SYNC_BITS ( TASK_0_BIT | TASK_1_BIT | TASK_2_BIT )\r
+\r
+ // Use an event group to synchronise three tasks.  It is assumed this event\r
+ // group has already been created elsewhere.\r
+ EventGroupHandle_t xEventBits;\r
+\r
+ void vTask0( void *pvParameters )\r
+ {\r
+ EventBits_t uxReturn;\r
+ TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;\r
+\r
+        for( ;; )\r
+        {\r
+               // Perform task functionality here.\r
+\r
+               // Set bit 0 in the event flag to note this task has reached the\r
+               // sync point.  The other two tasks will set the other two bits defined\r
+               // by ALL_SYNC_BITS.  All three tasks have reached the synchronisation\r
+               // point when all the ALL_SYNC_BITS are set.  Wait a maximum of 100ms\r
+               // for this to happen.\r
+               uxReturn = xEventGroupSync( xEventBits, TASK_0_BIT, ALL_SYNC_BITS, xTicksToWait );\r
+\r
+               if( ( uxReturn & ALL_SYNC_BITS ) == ALL_SYNC_BITS )\r
+               {\r
+                       // All three tasks reached the synchronisation point before the call\r
+                       // to xEventGroupSync() timed out.\r
+               }\r
+       }\r
+ }\r
+\r
+ void vTask1( void *pvParameters )\r
+ {\r
+        for( ;; )\r
+        {\r
+               // Perform task functionality here.\r
+\r
+               // Set bit 1 in the event flag to note this task has reached the\r
+               // synchronisation point.  The other two tasks will set the other two\r
+               // bits defined by ALL_SYNC_BITS.  All three tasks have reached the\r
+               // synchronisation point when all the ALL_SYNC_BITS are set.  Wait\r
+               // indefinitely for this to happen.\r
+               xEventGroupSync( xEventBits, TASK_1_BIT, ALL_SYNC_BITS, portMAX_DELAY );\r
+\r
+               // xEventGroupSync() was called with an indefinite block time, so\r
+               // this task will only reach here if the syncrhonisation was made by all\r
+               // three tasks, so there is no need to test the return value.\r
+        }\r
+ }\r
+\r
+ void vTask2( void *pvParameters )\r
+ {\r
+        for( ;; )\r
+        {\r
+               // Perform task functionality here.\r
+\r
+               // Set bit 2 in the event flag to note this task has reached the\r
+               // synchronisation point.  The other two tasks will set the other two\r
+               // bits defined by ALL_SYNC_BITS.  All three tasks have reached the\r
+               // synchronisation point when all the ALL_SYNC_BITS are set.  Wait\r
+               // indefinitely for this to happen.\r
+               xEventGroupSync( xEventBits, TASK_2_BIT, ALL_SYNC_BITS, portMAX_DELAY );\r
+\r
+               // xEventGroupSync() was called with an indefinite block time, so\r
+               // this task will only reach here if the syncrhonisation was made by all\r
+               // three tasks, so there is no need to test the return value.\r
+       }\r
+ }\r
+\r
+ </pre>\r
+ * \defgroup xEventGroupSync xEventGroupSync\r
+ * \ingroup EventGroup\r
+ */\r
+EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
+\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       EventBits_t xEventGroupGetBits( EventGroupHandle_t xEventGroup );\r
+ </pre>\r
+ *\r
+ * Returns the current value of the bits in an event group.  This function\r
+ * cannot be used from an interrupt.\r
+ *\r
+ * @param xEventGroup The event group being queried.\r
+ *\r
+ * @return The event group bits at the time xEventGroupGetBits() was called.\r
+ *\r
+ * \defgroup xEventGroupGetBits xEventGroupGetBits\r
+ * \ingroup EventGroup\r
+ */\r
+#define xEventGroupGetBits( xEventGroup ) xEventGroupClearBits( xEventGroup, 0 )\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup );\r
+ </pre>\r
+ *\r
+ * A version of xEventGroupGetBits() that can be called from an ISR.\r
+ *\r
+ * @param xEventGroup The event group being queried.\r
+ *\r
+ * @return The event group bits at the time xEventGroupGetBitsFromISR() was called.\r
+ *\r
+ * \defgroup xEventGroupGetBitsFromISR xEventGroupGetBitsFromISR\r
+ * \ingroup EventGroup\r
+ */\r
+EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * event_groups.h\r
+ *<pre>\r
+       void xEventGroupDelete( EventGroupHandle_t xEventGroup );\r
+ </pre>\r
+ *\r
+ * Delete an event group that was previously created by a call to\r
+ * xEventGroupCreate().  Tasks that are blocked on the event group will be\r
+ * unblocked and obtain 0 as the event group's value.\r
+ *\r
+ * @param xEventGroup The event group being deleted.\r
+ */\r
+void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;\r
+\r
+/* For internal use only. */\r
+void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION;\r
+void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;\r
+\r
+#if (configUSE_TRACE_FACILITY == 1)\r
+       UBaseType_t uxEventGroupGetNumber( void* xEventGroup ) PRIVILEGED_FUNCTION;\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* EVENT_GROUPS_H */\r
+\r
+\r