NuMaker mbed OS v6.x LoRaWAN

Committer:
cyliang
Date:
Tue Sep 01 20:28:04 2020 +0800
Revision:
0:a160d512fe55
Mbed OS v6.x LoRaWAN example for NuMaker platforms

Who changed what in which revision?

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