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