Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: nRF51_Vdd TextLCD BME280
EventFlags.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2017 ARM Limited 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy 00005 * of this software and associated documentation files (the "Software"), to deal 00006 * in the Software without restriction, including without limitation the rights 00007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 * copies of the Software, and to permit persons to whom the Software is 00009 * furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included in 00012 * all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00020 * SOFTWARE. 00021 */ 00022 #ifndef EVENT_FLAG_H 00023 #define EVENT_FLAG_H 00024 00025 #include <stdint.h> 00026 #include "cmsis_os2.h" 00027 #include "mbed_rtos1_types.h" 00028 #include "mbed_rtos_storage.h" 00029 00030 #include "platform/NonCopyable.h" 00031 00032 namespace rtos { 00033 /** \addtogroup rtos */ 00034 /** @{*/ 00035 /** 00036 * \defgroup rtos_EventFlags EventFlags class 00037 * @{ 00038 */ 00039 00040 /** The EventFlags class is used to control event flags or wait for event flags other threads control. 00041 00042 @note 00043 EventFlags support 31 flags. The MSB flag is ignored. It is used to return an error code (@a osFlagsError). 00044 00045 @note 00046 Memory considerations: The EventFlags control structures will be created on the current thread's stack, both for the Mbed OS 00047 and underlying RTOS objects (static or dynamic RTOS memory pools are not being used). 00048 */ 00049 class EventFlags : private mbed::NonCopyable<EventFlags> { 00050 public: 00051 /** Create and initialize an EventFlags object. 00052 * 00053 * @note You cannot call this function from ISR context. 00054 */ 00055 EventFlags(); 00056 00057 /** Create and initialize an EventFlags object. 00058 00059 @param name name to be used for this EventFlags. It has to stay allocated for the lifetime of the thread. 00060 00061 @note You cannot call this function from ISR context. 00062 */ 00063 EventFlags(const char *name); 00064 00065 /** Set the specified event flags. 00066 @param flags the flags that will be set. 00067 @return event flags after setting or error code if highest bit set (see @a osFlagsError for details). 00068 00069 @note This function may be called from ISR context. 00070 */ 00071 uint32_t set(uint32_t flags); 00072 00073 /** Clear the specified event flags. 00074 @param flags the flags that will be cleared (default: 0x7fffffff -- all flags). 00075 @return event flags before clearing or error code if highest bit set (see @a osFlagsError for details). 00076 00077 @note You may call this function from ISR context. 00078 */ 00079 uint32_t clear(uint32_t flags = 0x7fffffff); 00080 00081 /** Get the currently set event flags. 00082 @return current event flags. 00083 00084 @note You may call this function from ISR context. 00085 */ 00086 uint32_t get() const; 00087 00088 /** Wait for all of the specified event flags to become signaled. 00089 @param flags the flags to wait for (default: 0 -- no flags). 00090 @param timeout timeout value or 0 in case of no time-out (default: osWaitForever). 00091 @param clear clear specified event flags after waiting for them (default: true). 00092 @return event flags before clearing or error code if highest bit set (see @a osFlagsError for details). 00093 00094 @note You may call this function from ISR context if the timeout parameter is set to 0. 00095 */ 00096 uint32_t wait_all(uint32_t flags = 0, uint32_t timeout = osWaitForever, bool clear = true); 00097 00098 /** Wait for any of the specified event flags to become signaled. 00099 @param flags the flags to wait for (default: 0 -- no flags). 00100 @param timeout timeout value or 0 in case of no timeout (default: osWaitForever). 00101 @param clear clear specified event flags after waiting for them (default: true). 00102 @return event flags before clearing or error code if highest bit set (see @a osFlagsError for details). 00103 00104 @note This function may be called from ISR context if the timeout parameter is set to 0. 00105 */ 00106 uint32_t wait_any(uint32_t flags = 0, uint32_t timeout = osWaitForever, bool clear = true); 00107 00108 /** EventFlags destructor. 00109 00110 @note You cannot call this function from ISR context. 00111 */ 00112 ~EventFlags(); 00113 00114 private: 00115 void constructor(const char *name = NULL); 00116 uint32_t wait(uint32_t flags, uint32_t opt, uint32_t timeout, bool clear); 00117 osEventFlagsId_t _id; 00118 mbed_rtos_storage_event_flags_t _obj_mem; 00119 }; 00120 00121 /** @}*/ 00122 /** @}*/ 00123 00124 } 00125 #endif 00126
Generated on Tue Jul 12 2022 15:15:44 by
