Mistake on this page?
Report an issue in GitHub or email us
EventFlags.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2006-2017 ARM Limited
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
22 #ifndef EVENT_FLAG_H
23 #define EVENT_FLAG_H
24 
25 #include <stdint.h>
26 #include "cmsis_os2.h"
27 #include "mbed_rtos1_types.h"
28 #include "mbed_rtos_storage.h"
29 
30 #include "platform/NonCopyable.h"
31 
32 namespace rtos {
33 /** \addtogroup rtos */
34 /** @{*/
35 /**
36  * \defgroup rtos_EventFlags EventFlags class
37  * @{
38  */
39 
40 /** The EventFlags class is used to control event flags or wait for event flags other threads control.
41 
42  @note
43  EventFlags support 31 flags. The MSB flag is ignored. It is used to return an error code (@a osFlagsError).
44 
45  @note
46  Memory considerations: The EventFlags control structures will be created on the current thread's stack, both for the Mbed OS
47  and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).
48 */
49 class EventFlags : private mbed::NonCopyable<EventFlags> {
50 public:
51  /** Create and initialize an EventFlags object.
52  *
53  * @note You cannot call this function from ISR context.
54  */
55  EventFlags();
56 
57  /** Create and initialize an EventFlags object.
58 
59  @param name name to be used for this EventFlags. It has to stay allocated for the lifetime of the thread.
60 
61  @note You cannot call this function from ISR context.
62  */
63  EventFlags(const char *name);
64 
65  /** Set the specified event flags.
66  @param flags the flags that will be set.
67  @return event flags after setting or error code if highest bit set (see @a osFlagsError for details).
68 
69  @note This function may be called from ISR context.
70  */
71  uint32_t set(uint32_t flags);
72 
73  /** Clear the specified event flags.
74  @param flags the flags that will be cleared (default: 0x7fffffff -- all flags).
75  @return event flags before clearing or error code if highest bit set (see @a osFlagsError for details).
76 
77  @note You may call this function from ISR context.
78  */
79  uint32_t clear(uint32_t flags = 0x7fffffff);
80 
81  /** Get the currently set event flags.
82  @return current event flags.
83 
84  @note You may call this function from ISR context.
85  */
86  uint32_t get() const;
87 
88  /** Wait for all of the specified event flags to become signaled.
89  @param flags the flags to wait for (default: 0 -- no flags).
90  @param millisec timeout value (default: osWaitForever).
91  @param clear clear specified event flags after waiting for them (default: true).
92  @return event flags before clearing or error code if highest bit set (see @a osFlagsError for details).
93 
94  @note You may call this function from ISR context if the millisec parameter is set to 0.
95  */
96  uint32_t wait_all(uint32_t flags = 0, uint32_t millisec = osWaitForever, bool clear = true);
97 
98  /** Wait for any of the specified event flags to become signaled.
99  @param flags the flags to wait for (default: 0 -- no flags).
100  @param millisec timeout value (default: osWaitForever).
101  @param clear clear specified event flags after waiting for them (default: true).
102  @return event flags before clearing or error code if highest bit set (see @a osFlagsError for details).
103 
104  @note This function may be called from ISR context if the millisec parameter is set to 0.
105  */
106  uint32_t wait_any(uint32_t flags = 0, uint32_t millisec = osWaitForever, bool clear = true);
107 
108  /** EventFlags destructor.
109 
110  @note You cannot call this function from ISR context.
111  */
112  ~EventFlags();
113 
114 private:
115  void constructor(const char *name = NULL);
116  uint32_t wait(uint32_t flags, uint32_t opt, uint32_t millisec, bool clear);
117  osEventFlagsId_t _id;
118  mbed_rtos_storage_event_flags_t _obj_mem;
119 };
120 
121 /** @}*/
122 /** @}*/
123 
124 }
125 #endif
126 
~EventFlags()
EventFlags destructor.
The EventFlags class is used to control event flags or wait for event flags other threads control...
Definition: EventFlags.h:49
uint32_t clear(uint32_t flags=0x7fffffff)
Clear the specified event flags.
Prevents generation of copy constructor and copy assignment operator in derived classes.
Definition: NonCopyable.h:168
uint32_t wait_all(uint32_t flags=0, uint32_t millisec=osWaitForever, bool clear=true)
Wait for all of the specified event flags to become signaled.
EventFlags()
Create and initialize an EventFlags object.
uint32_t wait_any(uint32_t flags=0, uint32_t millisec=osWaitForever, bool clear=true)
Wait for any of the specified event flags to become signaled.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.