Committer:
borlanic
Date:
Thu Mar 29 07:02:09 2018 +0000
Revision:
0:380207fcb5c1
Encoder, IMU --> OK; Controller --> in bearbeitung

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:380207fcb5c1 1 /* mbed Microcontroller Library
borlanic 0:380207fcb5c1 2 * Copyright (c) 2006-2017 ARM Limited
borlanic 0:380207fcb5c1 3 *
borlanic 0:380207fcb5c1 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
borlanic 0:380207fcb5c1 5 * of this software and associated documentation files (the "Software"), to deal
borlanic 0:380207fcb5c1 6 * in the Software without restriction, including without limitation the rights
borlanic 0:380207fcb5c1 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
borlanic 0:380207fcb5c1 8 * copies of the Software, and to permit persons to whom the Software is
borlanic 0:380207fcb5c1 9 * furnished to do so, subject to the following conditions:
borlanic 0:380207fcb5c1 10 *
borlanic 0:380207fcb5c1 11 * The above copyright notice and this permission notice shall be included in
borlanic 0:380207fcb5c1 12 * all copies or substantial portions of the Software.
borlanic 0:380207fcb5c1 13 *
borlanic 0:380207fcb5c1 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
borlanic 0:380207fcb5c1 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
borlanic 0:380207fcb5c1 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
borlanic 0:380207fcb5c1 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
borlanic 0:380207fcb5c1 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
borlanic 0:380207fcb5c1 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
borlanic 0:380207fcb5c1 20 * SOFTWARE.
borlanic 0:380207fcb5c1 21 */
borlanic 0:380207fcb5c1 22 #include "rtos/EventFlags.h"
borlanic 0:380207fcb5c1 23 #include <string.h>
borlanic 0:380207fcb5c1 24 #include "mbed_error.h"
borlanic 0:380207fcb5c1 25 #include "mbed_assert.h"
borlanic 0:380207fcb5c1 26
borlanic 0:380207fcb5c1 27 namespace rtos {
borlanic 0:380207fcb5c1 28
borlanic 0:380207fcb5c1 29 EventFlags::EventFlags()
borlanic 0:380207fcb5c1 30 {
borlanic 0:380207fcb5c1 31 constructor();
borlanic 0:380207fcb5c1 32 }
borlanic 0:380207fcb5c1 33
borlanic 0:380207fcb5c1 34 EventFlags::EventFlags(const char *name)
borlanic 0:380207fcb5c1 35 {
borlanic 0:380207fcb5c1 36 constructor(name);
borlanic 0:380207fcb5c1 37 }
borlanic 0:380207fcb5c1 38
borlanic 0:380207fcb5c1 39 void EventFlags::constructor(const char *name)
borlanic 0:380207fcb5c1 40 {
borlanic 0:380207fcb5c1 41 memset(&_obj_mem, 0, sizeof(_obj_mem));
borlanic 0:380207fcb5c1 42 osEventFlagsAttr_t attr;
borlanic 0:380207fcb5c1 43 attr.name = name ? name : "application_unnamed_event_flags";
borlanic 0:380207fcb5c1 44 attr.cb_mem = &_obj_mem;
borlanic 0:380207fcb5c1 45 attr.cb_size = sizeof(_obj_mem);
borlanic 0:380207fcb5c1 46 _id = osEventFlagsNew(&attr);
borlanic 0:380207fcb5c1 47 MBED_ASSERT(_id);
borlanic 0:380207fcb5c1 48 }
borlanic 0:380207fcb5c1 49
borlanic 0:380207fcb5c1 50 uint32_t EventFlags::set(uint32_t flags)
borlanic 0:380207fcb5c1 51 {
borlanic 0:380207fcb5c1 52 return osEventFlagsSet(_id, flags);
borlanic 0:380207fcb5c1 53 }
borlanic 0:380207fcb5c1 54
borlanic 0:380207fcb5c1 55 uint32_t EventFlags::clear(uint32_t flags)
borlanic 0:380207fcb5c1 56 {
borlanic 0:380207fcb5c1 57 return osEventFlagsClear(_id, flags);
borlanic 0:380207fcb5c1 58 }
borlanic 0:380207fcb5c1 59
borlanic 0:380207fcb5c1 60 uint32_t EventFlags::get() const
borlanic 0:380207fcb5c1 61 {
borlanic 0:380207fcb5c1 62 return osEventFlagsGet(_id);
borlanic 0:380207fcb5c1 63 }
borlanic 0:380207fcb5c1 64
borlanic 0:380207fcb5c1 65 uint32_t EventFlags::wait_all(uint32_t flags, uint32_t timeout, bool clear)
borlanic 0:380207fcb5c1 66 {
borlanic 0:380207fcb5c1 67 return wait(flags, osFlagsWaitAll, timeout, clear);
borlanic 0:380207fcb5c1 68 }
borlanic 0:380207fcb5c1 69
borlanic 0:380207fcb5c1 70 uint32_t EventFlags::wait_any(uint32_t flags, uint32_t timeout, bool clear)
borlanic 0:380207fcb5c1 71 {
borlanic 0:380207fcb5c1 72 return wait(flags, osFlagsWaitAny, timeout, clear);
borlanic 0:380207fcb5c1 73 }
borlanic 0:380207fcb5c1 74
borlanic 0:380207fcb5c1 75 EventFlags::~EventFlags()
borlanic 0:380207fcb5c1 76 {
borlanic 0:380207fcb5c1 77 osEventFlagsDelete(_id);
borlanic 0:380207fcb5c1 78 }
borlanic 0:380207fcb5c1 79
borlanic 0:380207fcb5c1 80 uint32_t EventFlags::wait(uint32_t flags, uint32_t opt, uint32_t timeout, bool clear)
borlanic 0:380207fcb5c1 81 {
borlanic 0:380207fcb5c1 82 if (clear == false) {
borlanic 0:380207fcb5c1 83 opt |= osFlagsNoClear;
borlanic 0:380207fcb5c1 84 }
borlanic 0:380207fcb5c1 85
borlanic 0:380207fcb5c1 86 return osEventFlagsWait(_id, flags, opt, timeout);
borlanic 0:380207fcb5c1 87 }
borlanic 0:380207fcb5c1 88
borlanic 0:380207fcb5c1 89 }