FreeRTOS v_8.2.1 for LPC1768

Dependents:   frtos_v_8_bluetooth frtos_v_8_pololu frtos_v_8_Final

Committer:
JoaoJardim
Date:
Mon Dec 10 10:04:09 2018 +0000
Revision:
1:2f4de0d9dc8b
Parent:
0:91ad48ad5687
Same implementation as freertos_bluetooth at this time, but with FreeRTOS v_8.2.1

Who changed what in which revision?

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