BBR 1 Ebene

Committer:
borlanic
Date:
Mon May 14 11:29:06 2018 +0000
Revision:
0:fbdae7e6d805
BBR

Who changed what in which revision?

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