Mistake on this page?
Report an issue in GitHub or email us
cellular_tests_common.h
1 /*
2  * Copyright (c) 2018, Arm Limited and affiliates.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef CELLULAR_TESTS_COMMON_H_
18 #define CELLULAR_TESTS_COMMON_H_
19 
20 #include "CellularLog.h"
21 
22 #if MBED_CONF_MBED_TRACE_ENABLE
23 
24 static rtos::Mutex trace_mutex;
25 
26 void trace_wait()
27 {
28  trace_mutex.lock();
29 }
30 
31 void trace_release()
32 {
33  trace_mutex.unlock();
34 }
35 
36 static char time_st[sizeof("[12345678]") + 1];
37 
38 static char *trace_time(size_t ss)
39 {
40  snprintf(time_st, sizeof("[12345678]"), "[%08llu]", rtos::Kernel::get_ms_count());
41  return time_st;
42 }
43 
44 static void trace_open()
45 {
46  mbed_trace_init();
47  mbed_trace_prefix_function_set(&trace_time);
48  mbed_trace_mutex_wait_function_set(trace_wait);
49  mbed_trace_mutex_release_function_set(trace_release);
50 
51  mbed_cellular_trace::mutex_wait_function_set(trace_wait);
52  mbed_cellular_trace::mutex_release_function_set(trace_release);
53 }
54 
55 static void trace_close()
56 {
57  mbed_cellular_trace::mutex_wait_function_set(NULL);
58  mbed_cellular_trace::mutex_release_function_set(NULL);
59 
60  mbed_trace_free();
61 }
62 
63 #endif // MBED_CONF_MBED_TRACE_ENABLE
64 
65 
66 #endif /* CELLULAR_TESTS_COMMON_H_ */
osStatus lock(void)
Wait until a Mutex becomes available.
osStatus unlock()
Unlock the mutex that has previously been locked by the same thread.
The Mutex class is used to synchronize the execution of threads.
Definition: Mutex.h:66
uint64_t get_ms_count()
Read the current RTOS kernel millisecond tick count.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.