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