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