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