![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
rfsdfg
trace_helper.cpp@17:2fc16c1d6434, 2018-05-11 (annotated)
- Committer:
- mbed_official
- Date:
- Fri May 11 07:30:15 2018 +0100
- Revision:
- 17:2fc16c1d6434
- Parent:
- 8:7594ad70d2bf
- Child:
- 26:f07f5febf97f
Remove unnecessary Serial object
Current trend in mbed-os is to use stdio for tracing. Therefore unnecessary
Serial objects should be removed.
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-lorawan
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 | 0:7037ed05f54f | 23 | #if defined(FEATURE_COMMON_PAL) |
mbed_official | 0:7037ed05f54f | 24 | |
mbed_official | 0:7037ed05f54f | 25 | #include "platform/PlatformMutex.h" |
mbed_official | 0:7037ed05f54f | 26 | #include "mbed_trace.h" |
mbed_official | 0:7037ed05f54f | 27 | |
mbed_official | 0:7037ed05f54f | 28 | /** |
mbed_official | 0:7037ed05f54f | 29 | * Local mutex object for synchronization |
mbed_official | 0:7037ed05f54f | 30 | */ |
mbed_official | 0:7037ed05f54f | 31 | static PlatformMutex mutex; |
mbed_official | 0:7037ed05f54f | 32 | |
mbed_official | 0:7037ed05f54f | 33 | static void serial_lock(); |
mbed_official | 0:7037ed05f54f | 34 | static void serial_unlock(); |
mbed_official | 0:7037ed05f54f | 35 | |
mbed_official | 0:7037ed05f54f | 36 | /** |
mbed_official | 0:7037ed05f54f | 37 | * Sets up trace for the application |
mbed_official | 0:7037ed05f54f | 38 | * Wouldn't do anything if the FEATURE_COMMON_PAL is not added |
mbed_official | 0:7037ed05f54f | 39 | * or if the trace is disabled using mbed_app.json |
mbed_official | 0:7037ed05f54f | 40 | */ |
mbed_official | 0:7037ed05f54f | 41 | void setup_trace() |
mbed_official | 0:7037ed05f54f | 42 | { |
mbed_official | 0:7037ed05f54f | 43 | // setting up Mbed trace. |
mbed_official | 0:7037ed05f54f | 44 | mbed_trace_mutex_wait_function_set(serial_lock); |
mbed_official | 0:7037ed05f54f | 45 | mbed_trace_mutex_release_function_set(serial_unlock); |
mbed_official | 0:7037ed05f54f | 46 | mbed_trace_init(); |
mbed_official | 0:7037ed05f54f | 47 | } |
mbed_official | 0:7037ed05f54f | 48 | |
mbed_official | 0:7037ed05f54f | 49 | /** |
mbed_official | 0:7037ed05f54f | 50 | * Lock provided for serial printing used by trace library |
mbed_official | 0:7037ed05f54f | 51 | */ |
mbed_official | 0:7037ed05f54f | 52 | static void serial_lock() |
mbed_official | 0:7037ed05f54f | 53 | { |
mbed_official | 0:7037ed05f54f | 54 | mutex.lock(); |
mbed_official | 0:7037ed05f54f | 55 | } |
mbed_official | 0:7037ed05f54f | 56 | |
mbed_official | 0:7037ed05f54f | 57 | /** |
mbed_official | 0:7037ed05f54f | 58 | * Releasing lock provided for serial printing used by trace library |
mbed_official | 0:7037ed05f54f | 59 | */ |
mbed_official | 0:7037ed05f54f | 60 | static void serial_unlock() |
mbed_official | 0:7037ed05f54f | 61 | { |
mbed_official | 0:7037ed05f54f | 62 | mutex.unlock(); |
mbed_official | 0:7037ed05f54f | 63 | } |
mbed_official | 0:7037ed05f54f | 64 | |
mbed_official | 0:7037ed05f54f | 65 | #else |
mbed_official | 0:7037ed05f54f | 66 | |
mbed_official | 0:7037ed05f54f | 67 | void setup_trace() |
mbed_official | 0:7037ed05f54f | 68 | { |
mbed_official | 0:7037ed05f54f | 69 | } |
mbed_official | 0:7037ed05f54f | 70 | |
mbed_official | 0:7037ed05f54f | 71 | #endif |
mbed_official | 0:7037ed05f54f | 72 |