RTC auf true
rtos/EventFlags.cpp@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 | #include "rtos/EventFlags.h" |
kevman | 0:38ceb79fef03 | 23 | #include <string.h> |
kevman | 0:38ceb79fef03 | 24 | #include "mbed_error.h" |
kevman | 0:38ceb79fef03 | 25 | #include "mbed_assert.h" |
kevman | 0:38ceb79fef03 | 26 | |
kevman | 0:38ceb79fef03 | 27 | namespace rtos { |
kevman | 0:38ceb79fef03 | 28 | |
kevman | 0:38ceb79fef03 | 29 | EventFlags::EventFlags() |
kevman | 0:38ceb79fef03 | 30 | { |
kevman | 0:38ceb79fef03 | 31 | constructor(); |
kevman | 0:38ceb79fef03 | 32 | } |
kevman | 0:38ceb79fef03 | 33 | |
kevman | 0:38ceb79fef03 | 34 | EventFlags::EventFlags(const char *name) |
kevman | 0:38ceb79fef03 | 35 | { |
kevman | 0:38ceb79fef03 | 36 | constructor(name); |
kevman | 0:38ceb79fef03 | 37 | } |
kevman | 0:38ceb79fef03 | 38 | |
kevman | 0:38ceb79fef03 | 39 | void EventFlags::constructor(const char *name) |
kevman | 0:38ceb79fef03 | 40 | { |
kevman | 0:38ceb79fef03 | 41 | memset(&_obj_mem, 0, sizeof(_obj_mem)); |
kevman | 0:38ceb79fef03 | 42 | osEventFlagsAttr_t attr; |
kevman | 0:38ceb79fef03 | 43 | attr.name = name ? name : "application_unnamed_event_flags"; |
kevman | 0:38ceb79fef03 | 44 | attr.cb_mem = &_obj_mem; |
kevman | 0:38ceb79fef03 | 45 | attr.cb_size = sizeof(_obj_mem); |
kevman | 0:38ceb79fef03 | 46 | _id = osEventFlagsNew(&attr); |
kevman | 0:38ceb79fef03 | 47 | MBED_ASSERT(_id); |
kevman | 0:38ceb79fef03 | 48 | } |
kevman | 0:38ceb79fef03 | 49 | |
kevman | 0:38ceb79fef03 | 50 | uint32_t EventFlags::set(uint32_t flags) |
kevman | 0:38ceb79fef03 | 51 | { |
kevman | 0:38ceb79fef03 | 52 | return osEventFlagsSet(_id, flags); |
kevman | 0:38ceb79fef03 | 53 | } |
kevman | 0:38ceb79fef03 | 54 | |
kevman | 0:38ceb79fef03 | 55 | uint32_t EventFlags::clear(uint32_t flags) |
kevman | 0:38ceb79fef03 | 56 | { |
kevman | 0:38ceb79fef03 | 57 | return osEventFlagsClear(_id, flags); |
kevman | 0:38ceb79fef03 | 58 | } |
kevman | 0:38ceb79fef03 | 59 | |
kevman | 0:38ceb79fef03 | 60 | uint32_t EventFlags::get() const |
kevman | 0:38ceb79fef03 | 61 | { |
kevman | 0:38ceb79fef03 | 62 | return osEventFlagsGet(_id); |
kevman | 0:38ceb79fef03 | 63 | } |
kevman | 0:38ceb79fef03 | 64 | |
kevman | 0:38ceb79fef03 | 65 | uint32_t EventFlags::wait_all(uint32_t flags, uint32_t timeout, bool clear) |
kevman | 0:38ceb79fef03 | 66 | { |
kevman | 0:38ceb79fef03 | 67 | return wait(flags, osFlagsWaitAll, timeout, clear); |
kevman | 0:38ceb79fef03 | 68 | } |
kevman | 0:38ceb79fef03 | 69 | |
kevman | 0:38ceb79fef03 | 70 | uint32_t EventFlags::wait_any(uint32_t flags, uint32_t timeout, bool clear) |
kevman | 0:38ceb79fef03 | 71 | { |
kevman | 0:38ceb79fef03 | 72 | return wait(flags, osFlagsWaitAny, timeout, clear); |
kevman | 0:38ceb79fef03 | 73 | } |
kevman | 0:38ceb79fef03 | 74 | |
kevman | 0:38ceb79fef03 | 75 | EventFlags::~EventFlags() |
kevman | 0:38ceb79fef03 | 76 | { |
kevman | 0:38ceb79fef03 | 77 | osEventFlagsDelete(_id); |
kevman | 0:38ceb79fef03 | 78 | } |
kevman | 0:38ceb79fef03 | 79 | |
kevman | 0:38ceb79fef03 | 80 | uint32_t EventFlags::wait(uint32_t flags, uint32_t opt, uint32_t timeout, bool clear) |
kevman | 0:38ceb79fef03 | 81 | { |
kevman | 0:38ceb79fef03 | 82 | if (clear == false) { |
kevman | 0:38ceb79fef03 | 83 | opt |= osFlagsNoClear; |
kevman | 0:38ceb79fef03 | 84 | } |
kevman | 0:38ceb79fef03 | 85 | |
kevman | 0:38ceb79fef03 | 86 | return osEventFlagsWait(_id, flags, opt, timeout); |
kevman | 0:38ceb79fef03 | 87 | } |
kevman | 0:38ceb79fef03 | 88 | |
kevman | 0:38ceb79fef03 | 89 | } |