TI's CC3100 websocket camera demo with Arducam mini ov5642 and freertos. Should work with other M3's. Work in progress test demo.
event_groups.h
00001 /* 00002 FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd. 00003 All rights reserved 00004 00005 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. 00006 00007 This file is part of the FreeRTOS distribution. 00008 00009 FreeRTOS is free software; you can redistribute it and/or modify it under 00010 the terms of the GNU General Public License (version 2) as published by the 00011 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. 00012 00013 *************************************************************************** 00014 >>! NOTE: The modification to the GPL is included to allow you to !<< 00015 >>! distribute a combined work that includes FreeRTOS without being !<< 00016 >>! obliged to provide the source code for proprietary components !<< 00017 >>! outside of the FreeRTOS kernel. !<< 00018 *************************************************************************** 00019 00020 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY 00021 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00022 FOR A PARTICULAR PURPOSE. Full license text is available on the following 00023 link: http://www.freertos.org/a00114.html 00024 00025 *************************************************************************** 00026 * * 00027 * FreeRTOS provides completely free yet professionally developed, * 00028 * robust, strictly quality controlled, supported, and cross * 00029 * platform software that is more than just the market leader, it * 00030 * is the industry's de facto standard. * 00031 * * 00032 * Help yourself get started quickly while simultaneously helping * 00033 * to support the FreeRTOS project by purchasing a FreeRTOS * 00034 * tutorial book, reference manual, or both: * 00035 * http://www.FreeRTOS.org/Documentation * 00036 * * 00037 *************************************************************************** 00038 00039 http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading 00040 the FAQ page "My application does not run, what could be wrong?". Have you 00041 defined configASSERT()? 00042 00043 http://www.FreeRTOS.org/support - In return for receiving this top quality 00044 embedded software for free we request you assist our global community by 00045 participating in the support forum. 00046 00047 http://www.FreeRTOS.org/training - Investing in training allows your team to 00048 be as productive as possible as early as possible. Now you can receive 00049 FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers 00050 Ltd, and the world's leading authority on the world's leading RTOS. 00051 00052 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, 00053 including FreeRTOS+Trace - an indispensable productivity tool, a DOS 00054 compatible FAT file system, and our tiny thread aware UDP/IP stack. 00055 00056 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. 00057 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. 00058 00059 http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High 00060 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS 00061 licenses offer ticketed support, indemnification and commercial middleware. 00062 00063 http://www.SafeRTOS.com - High Integrity Systems also provide a safety 00064 engineered and independently SIL3 certified version for use in safety and 00065 mission critical applications that require provable dependability. 00066 00067 1 tab == 4 spaces! 00068 */ 00069 00070 #ifndef EVENT_GROUPS_H 00071 #define EVENT_GROUPS_H 00072 00073 #ifndef INC_FREERTOS_H 00074 #error "include FreeRTOS.h" must appear in source files before "include event_groups.h" 00075 #endif 00076 00077 #include "timers.h" 00078 00079 #ifdef __cplusplus 00080 extern "C" { 00081 #endif 00082 00083 /** 00084 * An event group is a collection of bits to which an application can assign a 00085 * meaning. For example, an application may create an event group to convey 00086 * the status of various CAN bus related events in which bit 0 might mean "A CAN 00087 * message has been received and is ready for processing", bit 1 might mean "The 00088 * application has queued a message that is ready for sending onto the CAN 00089 * network", and bit 2 might mean "It is time to send a SYNC message onto the 00090 * CAN network" etc. A task can then test the bit values to see which events 00091 * are active, and optionally enter the Blocked state to wait for a specified 00092 * bit or a group of specified bits to be active. To continue the CAN bus 00093 * example, a CAN controlling task can enter the Blocked state (and therefore 00094 * not consume any processing time) until either bit 0, bit 1 or bit 2 are 00095 * active, at which time the bit that was actually active would inform the task 00096 * which action it had to take (process a received message, send a message, or 00097 * send a SYNC). 00098 * 00099 * The event groups implementation contains intelligence to avoid race 00100 * conditions that would otherwise occur were an application to use a simple 00101 * variable for the same purpose. This is particularly important with respect 00102 * to when a bit within an event group is to be cleared, and when bits have to 00103 * be set and then tested atomically - as is the case where event groups are 00104 * used to create a synchronisation point between multiple tasks (a 00105 * 'rendezvous'). 00106 * 00107 * \defgroup EventGroup 00108 */ 00109 00110 00111 00112 /** 00113 * event_groups.h 00114 * 00115 * Type by which event groups are referenced. For example, a call to 00116 * xEventGroupCreate() returns an EventGroupHandle_t variable that can then 00117 * be used as a parameter to other event group functions. 00118 * 00119 * \defgroup EventGroupHandle_t EventGroupHandle_t 00120 * \ingroup EventGroup 00121 */ 00122 typedef void * EventGroupHandle_t; 00123 00124 /* 00125 * The type that holds event bits always matches TickType_t - therefore the 00126 * number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1, 00127 * 32 bits if set to 0. 00128 * 00129 * \defgroup EventBits_t EventBits_t 00130 * \ingroup EventGroup 00131 */ 00132 typedef TickType_t EventBits_t; 00133 00134 /** 00135 * event_groups.h 00136 *<pre> 00137 EventGroupHandle_t xEventGroupCreate( void ); 00138 </pre> 00139 * 00140 * Create a new event group. This function cannot be called from an interrupt. 00141 * 00142 * Although event groups are not related to ticks, for internal implementation 00143 * reasons the number of bits available for use in an event group is dependent 00144 * on the configUSE_16_BIT_TICKS setting in FreeRTOSConfig.h. If 00145 * configUSE_16_BIT_TICKS is 1 then each event group contains 8 usable bits (bit 00146 * 0 to bit 7). If configUSE_16_BIT_TICKS is set to 0 then each event group has 00147 * 24 usable bits (bit 0 to bit 23). The EventBits_t type is used to store 00148 * event bits within an event group. 00149 * 00150 * @return If the event group was created then a handle to the event group is 00151 * returned. If there was insufficient FreeRTOS heap available to create the 00152 * event group then NULL is returned. See http://www.freertos.org/a00111.html 00153 * 00154 * Example usage: 00155 <pre> 00156 // Declare a variable to hold the created event group. 00157 EventGroupHandle_t xCreatedEventGroup; 00158 00159 // Attempt to create the event group. 00160 xCreatedEventGroup = xEventGroupCreate(); 00161 00162 // Was the event group created successfully? 00163 if( xCreatedEventGroup == NULL ) 00164 { 00165 // The event group was not created because there was insufficient 00166 // FreeRTOS heap available. 00167 } 00168 else 00169 { 00170 // The event group was created. 00171 } 00172 </pre> 00173 * \defgroup xEventGroupCreate xEventGroupCreate 00174 * \ingroup EventGroup 00175 */ 00176 EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION; 00177 00178 /** 00179 * event_groups.h 00180 *<pre> 00181 EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, 00182 const EventBits_t uxBitsToWaitFor, 00183 const BaseType_t xClearOnExit, 00184 const BaseType_t xWaitForAllBits, 00185 const TickType_t xTicksToWait ); 00186 </pre> 00187 * 00188 * [Potentially] block to wait for one or more bits to be set within a 00189 * previously created event group. 00190 * 00191 * This function cannot be called from an interrupt. 00192 * 00193 * @param xEventGroup The event group in which the bits are being tested. The 00194 * event group must have previously been created using a call to 00195 * xEventGroupCreate(). 00196 * 00197 * @param uxBitsToWaitFor A bitwise value that indicates the bit or bits to test 00198 * inside the event group. For example, to wait for bit 0 and/or bit 2 set 00199 * uxBitsToWaitFor to 0x05. To wait for bits 0 and/or bit 1 and/or bit 2 set 00200 * uxBitsToWaitFor to 0x07. Etc. 00201 * 00202 * @param xClearOnExit If xClearOnExit is set to pdTRUE then any bits within 00203 * uxBitsToWaitFor that are set within the event group will be cleared before 00204 * xEventGroupWaitBits() returns if the wait condition was met (if the function 00205 * returns for a reason other than a timeout). If xClearOnExit is set to 00206 * pdFALSE then the bits set in the event group are not altered when the call to 00207 * xEventGroupWaitBits() returns. 00208 * 00209 * @param xWaitForAllBits If xWaitForAllBits is set to pdTRUE then 00210 * xEventGroupWaitBits() will return when either all the bits in uxBitsToWaitFor 00211 * are set or the specified block time expires. If xWaitForAllBits is set to 00212 * pdFALSE then xEventGroupWaitBits() will return when any one of the bits set 00213 * in uxBitsToWaitFor is set or the specified block time expires. The block 00214 * time is specified by the xTicksToWait parameter. 00215 * 00216 * @param xTicksToWait The maximum amount of time (specified in 'ticks') to wait 00217 * for one/all (depending on the xWaitForAllBits value) of the bits specified by 00218 * uxBitsToWaitFor to become set. 00219 * 00220 * @return The value of the event group at the time either the bits being waited 00221 * for became set, or the block time expired. Test the return value to know 00222 * which bits were set. If xEventGroupWaitBits() returned because its timeout 00223 * expired then not all the bits being waited for will be set. If 00224 * xEventGroupWaitBits() returned because the bits it was waiting for were set 00225 * then the returned value is the event group value before any bits were 00226 * automatically cleared in the case that xClearOnExit parameter was set to 00227 * pdTRUE. 00228 * 00229 * Example usage: 00230 <pre> 00231 #define BIT_0 ( 1 << 0 ) 00232 #define BIT_4 ( 1 << 4 ) 00233 00234 void aFunction( EventGroupHandle_t xEventGroup ) 00235 { 00236 EventBits_t uxBits; 00237 const TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS; 00238 00239 // Wait a maximum of 100ms for either bit 0 or bit 4 to be set within 00240 // the event group. Clear the bits before exiting. 00241 uxBits = xEventGroupWaitBits( 00242 xEventGroup, // The event group being tested. 00243 BIT_0 | BIT_4, // The bits within the event group to wait for. 00244 pdTRUE, // BIT_0 and BIT_4 should be cleared before returning. 00245 pdFALSE, // Don't wait for both bits, either bit will do. 00246 xTicksToWait ); // Wait a maximum of 100ms for either bit to be set. 00247 00248 if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) ) 00249 { 00250 // xEventGroupWaitBits() returned because both bits were set. 00251 } 00252 else if( ( uxBits & BIT_0 ) != 0 ) 00253 { 00254 // xEventGroupWaitBits() returned because just BIT_0 was set. 00255 } 00256 else if( ( uxBits & BIT_4 ) != 0 ) 00257 { 00258 // xEventGroupWaitBits() returned because just BIT_4 was set. 00259 } 00260 else 00261 { 00262 // xEventGroupWaitBits() returned because xTicksToWait ticks passed 00263 // without either BIT_0 or BIT_4 becoming set. 00264 } 00265 } 00266 </pre> 00267 * \defgroup xEventGroupWaitBits xEventGroupWaitBits 00268 * \ingroup EventGroup 00269 */ 00270 EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; 00271 00272 /** 00273 * event_groups.h 00274 *<pre> 00275 EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ); 00276 </pre> 00277 * 00278 * Clear bits within an event group. This function cannot be called from an 00279 * interrupt. 00280 * 00281 * @param xEventGroup The event group in which the bits are to be cleared. 00282 * 00283 * @param uxBitsToClear A bitwise value that indicates the bit or bits to clear 00284 * in the event group. For example, to clear bit 3 only, set uxBitsToClear to 00285 * 0x08. To clear bit 3 and bit 0 set uxBitsToClear to 0x09. 00286 * 00287 * @return The value of the event group before the specified bits were cleared. 00288 * 00289 * Example usage: 00290 <pre> 00291 #define BIT_0 ( 1 << 0 ) 00292 #define BIT_4 ( 1 << 4 ) 00293 00294 void aFunction( EventGroupHandle_t xEventGroup ) 00295 { 00296 EventBits_t uxBits; 00297 00298 // Clear bit 0 and bit 4 in xEventGroup. 00299 uxBits = xEventGroupClearBits( 00300 xEventGroup, // The event group being updated. 00301 BIT_0 | BIT_4 );// The bits being cleared. 00302 00303 if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) ) 00304 { 00305 // Both bit 0 and bit 4 were set before xEventGroupClearBits() was 00306 // called. Both will now be clear (not set). 00307 } 00308 else if( ( uxBits & BIT_0 ) != 0 ) 00309 { 00310 // Bit 0 was set before xEventGroupClearBits() was called. It will 00311 // now be clear. 00312 } 00313 else if( ( uxBits & BIT_4 ) != 0 ) 00314 { 00315 // Bit 4 was set before xEventGroupClearBits() was called. It will 00316 // now be clear. 00317 } 00318 else 00319 { 00320 // Neither bit 0 nor bit 4 were set in the first place. 00321 } 00322 } 00323 </pre> 00324 * \defgroup xEventGroupClearBits xEventGroupClearBits 00325 * \ingroup EventGroup 00326 */ 00327 EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; 00328 00329 /** 00330 * event_groups.h 00331 *<pre> 00332 BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ); 00333 </pre> 00334 * 00335 * A version of xEventGroupClearBits() that can be called from an interrupt. 00336 * 00337 * Setting bits in an event group is not a deterministic operation because there 00338 * are an unknown number of tasks that may be waiting for the bit or bits being 00339 * set. FreeRTOS does not allow nondeterministic operations to be performed 00340 * while interrupts are disabled, so protects event groups that are accessed 00341 * from tasks by suspending the scheduler rather than disabling interrupts. As 00342 * a result event groups cannot be accessed directly from an interrupt service 00343 * routine. Therefore xEventGroupClearBitsFromISR() sends a message to the 00344 * timer task to have the clear operation performed in the context of the timer 00345 * task. 00346 * 00347 * @param xEventGroup The event group in which the bits are to be cleared. 00348 * 00349 * @param uxBitsToClear A bitwise value that indicates the bit or bits to clear. 00350 * For example, to clear bit 3 only, set uxBitsToClear to 0x08. To clear bit 3 00351 * and bit 0 set uxBitsToClear to 0x09. 00352 * 00353 * @return If the request to execute the function was posted successfully then 00354 * pdPASS is returned, otherwise pdFALSE is returned. pdFALSE will be returned 00355 * if the timer service queue was full. 00356 * 00357 * Example usage: 00358 <pre> 00359 #define BIT_0 ( 1 << 0 ) 00360 #define BIT_4 ( 1 << 4 ) 00361 00362 // An event group which it is assumed has already been created by a call to 00363 // xEventGroupCreate(). 00364 EventGroupHandle_t xEventGroup; 00365 00366 void anInterruptHandler( void ) 00367 { 00368 // Clear bit 0 and bit 4 in xEventGroup. 00369 xResult = xEventGroupClearBitsFromISR( 00370 xEventGroup, // The event group being updated. 00371 BIT_0 | BIT_4 ); // The bits being set. 00372 00373 if( xResult == pdPASS ) 00374 { 00375 // The message was posted successfully. 00376 } 00377 } 00378 </pre> 00379 * \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR 00380 * \ingroup EventGroup 00381 */ 00382 #if( configUSE_TRACE_FACILITY == 1 ) 00383 BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ); 00384 #else 00385 #define xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear ) xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL ) 00386 #endif 00387 00388 /** 00389 * event_groups.h 00390 *<pre> 00391 EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ); 00392 </pre> 00393 * 00394 * Set bits within an event group. 00395 * This function cannot be called from an interrupt. xEventGroupSetBitsFromISR() 00396 * is a version that can be called from an interrupt. 00397 * 00398 * Setting bits in an event group will automatically unblock tasks that are 00399 * blocked waiting for the bits. 00400 * 00401 * @param xEventGroup The event group in which the bits are to be set. 00402 * 00403 * @param uxBitsToSet A bitwise value that indicates the bit or bits to set. 00404 * For example, to set bit 3 only, set uxBitsToSet to 0x08. To set bit 3 00405 * and bit 0 set uxBitsToSet to 0x09. 00406 * 00407 * @return The value of the event group at the time the call to 00408 * xEventGroupSetBits() returns. There are two reasons why the returned value 00409 * might have the bits specified by the uxBitsToSet parameter cleared. First, 00410 * if setting a bit results in a task that was waiting for the bit leaving the 00411 * blocked state then it is possible the bit will be cleared automatically 00412 * (see the xClearBitOnExit parameter of xEventGroupWaitBits()). Second, any 00413 * unblocked (or otherwise Ready state) task that has a priority above that of 00414 * the task that called xEventGroupSetBits() will execute and may change the 00415 * event group value before the call to xEventGroupSetBits() returns. 00416 * 00417 * Example usage: 00418 <pre> 00419 #define BIT_0 ( 1 << 0 ) 00420 #define BIT_4 ( 1 << 4 ) 00421 00422 void aFunction( EventGroupHandle_t xEventGroup ) 00423 { 00424 EventBits_t uxBits; 00425 00426 // Set bit 0 and bit 4 in xEventGroup. 00427 uxBits = xEventGroupSetBits( 00428 xEventGroup, // The event group being updated. 00429 BIT_0 | BIT_4 );// The bits being set. 00430 00431 if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) ) 00432 { 00433 // Both bit 0 and bit 4 remained set when the function returned. 00434 } 00435 else if( ( uxBits & BIT_0 ) != 0 ) 00436 { 00437 // Bit 0 remained set when the function returned, but bit 4 was 00438 // cleared. It might be that bit 4 was cleared automatically as a 00439 // task that was waiting for bit 4 was removed from the Blocked 00440 // state. 00441 } 00442 else if( ( uxBits & BIT_4 ) != 0 ) 00443 { 00444 // Bit 4 remained set when the function returned, but bit 0 was 00445 // cleared. It might be that bit 0 was cleared automatically as a 00446 // task that was waiting for bit 0 was removed from the Blocked 00447 // state. 00448 } 00449 else 00450 { 00451 // Neither bit 0 nor bit 4 remained set. It might be that a task 00452 // was waiting for both of the bits to be set, and the bits were 00453 // cleared as the task left the Blocked state. 00454 } 00455 } 00456 </pre> 00457 * \defgroup xEventGroupSetBits xEventGroupSetBits 00458 * \ingroup EventGroup 00459 */ 00460 EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION; 00461 00462 /** 00463 * event_groups.h 00464 *<pre> 00465 BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken ); 00466 </pre> 00467 * 00468 * A version of xEventGroupSetBits() that can be called from an interrupt. 00469 * 00470 * Setting bits in an event group is not a deterministic operation because there 00471 * are an unknown number of tasks that may be waiting for the bit or bits being 00472 * set. FreeRTOS does not allow nondeterministic operations to be performed in 00473 * interrupts or from critical sections. Therefore xEventGroupSetBitFromISR() 00474 * sends a message to the timer task to have the set operation performed in the 00475 * context of the timer task - where a scheduler lock is used in place of a 00476 * critical section. 00477 * 00478 * @param xEventGroup The event group in which the bits are to be set. 00479 * 00480 * @param uxBitsToSet A bitwise value that indicates the bit or bits to set. 00481 * For example, to set bit 3 only, set uxBitsToSet to 0x08. To set bit 3 00482 * and bit 0 set uxBitsToSet to 0x09. 00483 * 00484 * @param pxHigherPriorityTaskWoken As mentioned above, calling this function 00485 * will result in a message being sent to the timer daemon task. If the 00486 * priority of the timer daemon task is higher than the priority of the 00487 * currently running task (the task the interrupt interrupted) then 00488 * *pxHigherPriorityTaskWoken will be set to pdTRUE by 00489 * xEventGroupSetBitsFromISR(), indicating that a context switch should be 00490 * requested before the interrupt exits. For that reason 00491 * *pxHigherPriorityTaskWoken must be initialised to pdFALSE. See the 00492 * example code below. 00493 * 00494 * @return If the request to execute the function was posted successfully then 00495 * pdPASS is returned, otherwise pdFALSE is returned. pdFALSE will be returned 00496 * if the timer service queue was full. 00497 * 00498 * Example usage: 00499 <pre> 00500 #define BIT_0 ( 1 << 0 ) 00501 #define BIT_4 ( 1 << 4 ) 00502 00503 // An event group which it is assumed has already been created by a call to 00504 // xEventGroupCreate(). 00505 EventGroupHandle_t xEventGroup; 00506 00507 void anInterruptHandler( void ) 00508 { 00509 BaseType_t xHigherPriorityTaskWoken, xResult; 00510 00511 // xHigherPriorityTaskWoken must be initialised to pdFALSE. 00512 xHigherPriorityTaskWoken = pdFALSE; 00513 00514 // Set bit 0 and bit 4 in xEventGroup. 00515 xResult = xEventGroupSetBitsFromISR( 00516 xEventGroup, // The event group being updated. 00517 BIT_0 | BIT_4 // The bits being set. 00518 &xHigherPriorityTaskWoken ); 00519 00520 // Was the message posted successfully? 00521 if( xResult == pdPASS ) 00522 { 00523 // If xHigherPriorityTaskWoken is now set to pdTRUE then a context 00524 // switch should be requested. The macro used is port specific and 00525 // will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - 00526 // refer to the documentation page for the port being used. 00527 portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); 00528 } 00529 } 00530 </pre> 00531 * \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR 00532 * \ingroup EventGroup 00533 */ 00534 #if( configUSE_TRACE_FACILITY == 1 ) 00535 BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken ); 00536 #else 00537 #define xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken ) xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken ) 00538 #endif 00539 00540 /** 00541 * event_groups.h 00542 *<pre> 00543 EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, 00544 const EventBits_t uxBitsToSet, 00545 const EventBits_t uxBitsToWaitFor, 00546 TickType_t xTicksToWait ); 00547 </pre> 00548 * 00549 * Atomically set bits within an event group, then wait for a combination of 00550 * bits to be set within the same event group. This functionality is typically 00551 * used to synchronise multiple tasks, where each task has to wait for the other 00552 * tasks to reach a synchronisation point before proceeding. 00553 * 00554 * This function cannot be used from an interrupt. 00555 * 00556 * The function will return before its block time expires if the bits specified 00557 * by the uxBitsToWait parameter are set, or become set within that time. In 00558 * this case all the bits specified by uxBitsToWait will be automatically 00559 * cleared before the function returns. 00560 * 00561 * @param xEventGroup The event group in which the bits are being tested. The 00562 * event group must have previously been created using a call to 00563 * xEventGroupCreate(). 00564 * 00565 * @param uxBitsToSet The bits to set in the event group before determining 00566 * if, and possibly waiting for, all the bits specified by the uxBitsToWait 00567 * parameter are set. 00568 * 00569 * @param uxBitsToWaitFor A bitwise value that indicates the bit or bits to test 00570 * inside the event group. For example, to wait for bit 0 and bit 2 set 00571 * uxBitsToWaitFor to 0x05. To wait for bits 0 and bit 1 and bit 2 set 00572 * uxBitsToWaitFor to 0x07. Etc. 00573 * 00574 * @param xTicksToWait The maximum amount of time (specified in 'ticks') to wait 00575 * for all of the bits specified by uxBitsToWaitFor to become set. 00576 * 00577 * @return The value of the event group at the time either the bits being waited 00578 * for became set, or the block time expired. Test the return value to know 00579 * which bits were set. If xEventGroupSync() returned because its timeout 00580 * expired then not all the bits being waited for will be set. If 00581 * xEventGroupSync() returned because all the bits it was waiting for were 00582 * set then the returned value is the event group value before any bits were 00583 * automatically cleared. 00584 * 00585 * Example usage: 00586 <pre> 00587 // Bits used by the three tasks. 00588 #define TASK_0_BIT ( 1 << 0 ) 00589 #define TASK_1_BIT ( 1 << 1 ) 00590 #define TASK_2_BIT ( 1 << 2 ) 00591 00592 #define ALL_SYNC_BITS ( TASK_0_BIT | TASK_1_BIT | TASK_2_BIT ) 00593 00594 // Use an event group to synchronise three tasks. It is assumed this event 00595 // group has already been created elsewhere. 00596 EventGroupHandle_t xEventBits; 00597 00598 void vTask0( void *pvParameters ) 00599 { 00600 EventBits_t uxReturn; 00601 TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS; 00602 00603 for( ;; ) 00604 { 00605 // Perform task functionality here. 00606 00607 // Set bit 0 in the event flag to note this task has reached the 00608 // sync point. The other two tasks will set the other two bits defined 00609 // by ALL_SYNC_BITS. All three tasks have reached the synchronisation 00610 // point when all the ALL_SYNC_BITS are set. Wait a maximum of 100ms 00611 // for this to happen. 00612 uxReturn = xEventGroupSync( xEventBits, TASK_0_BIT, ALL_SYNC_BITS, xTicksToWait ); 00613 00614 if( ( uxReturn & ALL_SYNC_BITS ) == ALL_SYNC_BITS ) 00615 { 00616 // All three tasks reached the synchronisation point before the call 00617 // to xEventGroupSync() timed out. 00618 } 00619 } 00620 } 00621 00622 void vTask1( void *pvParameters ) 00623 { 00624 for( ;; ) 00625 { 00626 // Perform task functionality here. 00627 00628 // Set bit 1 in the event flag to note this task has reached the 00629 // synchronisation point. The other two tasks will set the other two 00630 // bits defined by ALL_SYNC_BITS. All three tasks have reached the 00631 // synchronisation point when all the ALL_SYNC_BITS are set. Wait 00632 // indefinitely for this to happen. 00633 xEventGroupSync( xEventBits, TASK_1_BIT, ALL_SYNC_BITS, portMAX_DELAY ); 00634 00635 // xEventGroupSync() was called with an indefinite block time, so 00636 // this task will only reach here if the syncrhonisation was made by all 00637 // three tasks, so there is no need to test the return value. 00638 } 00639 } 00640 00641 void vTask2( void *pvParameters ) 00642 { 00643 for( ;; ) 00644 { 00645 // Perform task functionality here. 00646 00647 // Set bit 2 in the event flag to note this task has reached the 00648 // synchronisation point. The other two tasks will set the other two 00649 // bits defined by ALL_SYNC_BITS. All three tasks have reached the 00650 // synchronisation point when all the ALL_SYNC_BITS are set. Wait 00651 // indefinitely for this to happen. 00652 xEventGroupSync( xEventBits, TASK_2_BIT, ALL_SYNC_BITS, portMAX_DELAY ); 00653 00654 // xEventGroupSync() was called with an indefinite block time, so 00655 // this task will only reach here if the syncrhonisation was made by all 00656 // three tasks, so there is no need to test the return value. 00657 } 00658 } 00659 00660 </pre> 00661 * \defgroup xEventGroupSync xEventGroupSync 00662 * \ingroup EventGroup 00663 */ 00664 EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; 00665 00666 00667 /** 00668 * event_groups.h 00669 *<pre> 00670 EventBits_t xEventGroupGetBits( EventGroupHandle_t xEventGroup ); 00671 </pre> 00672 * 00673 * Returns the current value of the bits in an event group. This function 00674 * cannot be used from an interrupt. 00675 * 00676 * @param xEventGroup The event group being queried. 00677 * 00678 * @return The event group bits at the time xEventGroupGetBits() was called. 00679 * 00680 * \defgroup xEventGroupGetBits xEventGroupGetBits 00681 * \ingroup EventGroup 00682 */ 00683 #define xEventGroupGetBits( xEventGroup ) xEventGroupClearBits( xEventGroup, 0 ) 00684 00685 /** 00686 * event_groups.h 00687 *<pre> 00688 EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ); 00689 </pre> 00690 * 00691 * A version of xEventGroupGetBits() that can be called from an ISR. 00692 * 00693 * @param xEventGroup The event group being queried. 00694 * 00695 * @return The event group bits at the time xEventGroupGetBitsFromISR() was called. 00696 * 00697 * \defgroup xEventGroupGetBitsFromISR xEventGroupGetBitsFromISR 00698 * \ingroup EventGroup 00699 */ 00700 EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ); 00701 00702 /** 00703 * event_groups.h 00704 *<pre> 00705 void xEventGroupDelete( EventGroupHandle_t xEventGroup ); 00706 </pre> 00707 * 00708 * Delete an event group that was previously created by a call to 00709 * xEventGroupCreate(). Tasks that are blocked on the event group will be 00710 * unblocked and obtain 0 as the event group's value. 00711 * 00712 * @param xEventGroup The event group being deleted. 00713 */ 00714 void vEventGroupDelete( EventGroupHandle_t xEventGroup ); 00715 00716 /* For internal use only. */ 00717 void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet ); 00718 void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear ); 00719 00720 #if (configUSE_TRACE_FACILITY == 1) 00721 UBaseType_t uxEventGroupGetNumber( void* xEventGroup ); 00722 #endif 00723 00724 #ifdef __cplusplus 00725 } 00726 #endif 00727 00728 #endif /* EVENT_GROUPS_H */ 00729 00730 00731
Generated on Wed Jul 13 2022 15:58:45 by 1.7.2