CY Lim
/
mbed-os-example-lorawan
WPG
Fork of mbed-os-example-mbed5-lorawan by
trace_helper.cpp@30:99137c499371, 2018-07-27 (annotated)
- Committer:
- limchy
- Date:
- Fri Jul 27 03:36:51 2018 +0000
- Revision:
- 30:99137c499371
- Parent:
- 26:f07f5febf97f
Ver1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:7037ed05f54f | 1 | /** |
mbed_official | 0:7037ed05f54f | 2 | * Copyright (c) 2017, Arm Limited and affiliates. |
mbed_official | 0:7037ed05f54f | 3 | * SPDX-License-Identifier: Apache-2.0 |
mbed_official | 0:7037ed05f54f | 4 | * |
mbed_official | 0:7037ed05f54f | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mbed_official | 0:7037ed05f54f | 6 | * you may not use this file except in compliance with the License. |
mbed_official | 0:7037ed05f54f | 7 | * You may obtain a copy of the License at |
mbed_official | 0:7037ed05f54f | 8 | * |
mbed_official | 0:7037ed05f54f | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbed_official | 0:7037ed05f54f | 10 | * |
mbed_official | 0:7037ed05f54f | 11 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 0:7037ed05f54f | 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 0:7037ed05f54f | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 0:7037ed05f54f | 14 | * See the License for the specific language governing permissions and |
mbed_official | 0:7037ed05f54f | 15 | * limitations under the License. |
mbed_official | 0:7037ed05f54f | 16 | */ |
mbed_official | 0:7037ed05f54f | 17 | |
mbed_official | 0:7037ed05f54f | 18 | /** |
mbed_official | 0:7037ed05f54f | 19 | * If we have tracing library available, we can see traces from within the |
mbed_official | 0:7037ed05f54f | 20 | * stack. The library could be made unavailable by removing FEATURE_COMMON_PAL |
mbed_official | 0:7037ed05f54f | 21 | * from the mbed_app.json to save RAM. |
mbed_official | 0:7037ed05f54f | 22 | */ |
mbed_official | 26:f07f5febf97f | 23 | |
mbed_official | 26:f07f5febf97f | 24 | #include "mbed_trace.h" |
mbed_official | 0:7037ed05f54f | 25 | |
mbed_official | 26:f07f5febf97f | 26 | #ifdef FEA_TRACE_SUPPORT |
mbed_official | 26:f07f5febf97f | 27 | #include "platform/PlatformMutex.h" |
mbed_official | 0:7037ed05f54f | 28 | |
mbed_official | 26:f07f5febf97f | 29 | /** |
mbed_official | 26:f07f5febf97f | 30 | * Local mutex object for synchronization |
mbed_official | 26:f07f5febf97f | 31 | */ |
mbed_official | 26:f07f5febf97f | 32 | static PlatformMutex mutex; |
mbed_official | 0:7037ed05f54f | 33 | |
mbed_official | 26:f07f5febf97f | 34 | static void serial_lock(); |
mbed_official | 26:f07f5febf97f | 35 | static void serial_unlock(); |
mbed_official | 0:7037ed05f54f | 36 | |
mbed_official | 26:f07f5febf97f | 37 | /** |
mbed_official | 26:f07f5febf97f | 38 | * Sets up trace for the application |
mbed_official | 26:f07f5febf97f | 39 | * Wouldn't do anything if the FEATURE_COMMON_PAL is not added |
mbed_official | 26:f07f5febf97f | 40 | * or if the trace is disabled using mbed_app.json |
mbed_official | 26:f07f5febf97f | 41 | */ |
mbed_official | 26:f07f5febf97f | 42 | void setup_trace() |
mbed_official | 26:f07f5febf97f | 43 | { |
mbed_official | 26:f07f5febf97f | 44 | // setting up Mbed trace. |
mbed_official | 26:f07f5febf97f | 45 | mbed_trace_mutex_wait_function_set(serial_lock); |
mbed_official | 26:f07f5febf97f | 46 | mbed_trace_mutex_release_function_set(serial_unlock); |
mbed_official | 26:f07f5febf97f | 47 | mbed_trace_init(); |
mbed_official | 26:f07f5febf97f | 48 | } |
mbed_official | 0:7037ed05f54f | 49 | |
mbed_official | 26:f07f5febf97f | 50 | /** |
mbed_official | 26:f07f5febf97f | 51 | * Lock provided for serial printing used by trace library |
mbed_official | 26:f07f5febf97f | 52 | */ |
mbed_official | 26:f07f5febf97f | 53 | static void serial_lock() |
mbed_official | 26:f07f5febf97f | 54 | { |
mbed_official | 26:f07f5febf97f | 55 | mutex.lock(); |
mbed_official | 26:f07f5febf97f | 56 | } |
mbed_official | 0:7037ed05f54f | 57 | |
mbed_official | 26:f07f5febf97f | 58 | /** |
mbed_official | 26:f07f5febf97f | 59 | * Releasing lock provided for serial printing used by trace library |
mbed_official | 26:f07f5febf97f | 60 | */ |
mbed_official | 26:f07f5febf97f | 61 | static void serial_unlock() |
mbed_official | 26:f07f5febf97f | 62 | { |
mbed_official | 26:f07f5febf97f | 63 | mutex.unlock(); |
mbed_official | 26:f07f5febf97f | 64 | } |
mbed_official | 26:f07f5febf97f | 65 | #else |
mbed_official | 26:f07f5febf97f | 66 | void setup_trace() |
mbed_official | 26:f07f5febf97f | 67 | { |
mbed_official | 0:7037ed05f54f | 68 | |
mbed_official | 26:f07f5febf97f | 69 | } |
mbed_official | 0:7037ed05f54f | 70 | #endif |
mbed_official | 0:7037ed05f54f | 71 | |
mbed_official | 26:f07f5febf97f | 72 |