Knight KE / Mbed OS Game_Master
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cellular_tests_common.h Source File

cellular_tests_common.h

00001 /*
00002  * Copyright (c) 2018, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef CELLULAR_TESTS_COMMON_H_
00018 #define CELLULAR_TESTS_COMMON_H_
00019 
00020 #include "CellularLog.h"
00021 
00022 #if MBED_CONF_MBED_TRACE_ENABLE
00023 
00024 static rtos::Mutex trace_mutex;
00025 
00026 void trace_wait()
00027 {
00028     trace_mutex.lock();
00029 }
00030 
00031 void trace_release()
00032 {
00033     trace_mutex.unlock();
00034 }
00035 
00036 static char time_st[sizeof("[12345678]") + 1];
00037 
00038 static char *trace_time(size_t ss)
00039 {
00040     snprintf(time_st, sizeof("[12345678]"), "[%08llu]", rtos::Kernel::get_ms_count());
00041     return time_st;
00042 }
00043 
00044 static void trace_open()
00045 {
00046     mbed_trace_init();
00047     mbed_trace_prefix_function_set(&trace_time);
00048     mbed_trace_mutex_wait_function_set(trace_wait);
00049     mbed_trace_mutex_release_function_set(trace_release);
00050 
00051     mbed_cellular_trace::mutex_wait_function_set(trace_wait);
00052     mbed_cellular_trace::mutex_release_function_set(trace_release);
00053 }
00054 
00055 static void trace_close()
00056 {
00057     mbed_cellular_trace::mutex_wait_function_set(NULL);
00058     mbed_cellular_trace::mutex_release_function_set(NULL);
00059 
00060     mbed_trace_free();
00061 }
00062 
00063 #endif // MBED_CONF_MBED_TRACE_ENABLE
00064 
00065 
00066 #endif /* CELLULAR_TESTS_COMMON_H_ */