amiro-lld / include / VL53L0X / v1 / Api_vl53l0x / platform / inc / vl53l0x_platform_log.h @ c368a765
History | View | Annotate | Download (4.04 KB)
1 | 6ebebd4d | Andre Raming | /*******************************************************************************
|
---|---|---|---|
2 | Copyright � 2015, STMicroelectronics International N.V.
|
||
3 | All rights reserved.
|
||
4 | |||
5 | Redistribution and use in source and binary forms, with or without
|
||
6 | modification, are permitted provided that the following conditions are met:
|
||
7 | * Redistributions of source code must retain the above copyright
|
||
8 | notice, this list of conditions and the following disclaimer.
|
||
9 | * Redistributions in binary form must reproduce the above copyright
|
||
10 | notice, this list of conditions and the following disclaimer in the
|
||
11 | documentation and/or other materials provided with the distribution.
|
||
12 | * Neither the name of STMicroelectronics nor the
|
||
13 | names of its contributors may be used to endorse or promote products
|
||
14 | derived from this software without specific prior written permission.
|
||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||
18 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
||
19 | NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
|
||
20 | IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
|
||
21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||
22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||
23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||
24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||
25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||
26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
27 | ********************************************************************************/
|
||
28 | |||
29 | |||
30 | #ifndef _VL53L0X_PLATFORM_LOG_H_
|
||
31 | #define _VL53L0X_PLATFORM_LOG_H_
|
||
32 | |||
33 | #include <stdio.h> |
||
34 | #include <string.h> |
||
35 | /* LOG Functions */
|
||
36 | |||
37 | #ifdef __cplusplus
|
||
38 | extern "C" { |
||
39 | #endif
|
||
40 | |||
41 | /**
|
||
42 | * @file vl53l0x_platform_log.h
|
||
43 | *
|
||
44 | * @brief platform log function definition
|
||
45 | */
|
||
46 | |||
47 | // id include error in linker TODO
|
||
48 | //#define VL53L0X_LOG_ENABLE 0
|
||
49 | |||
50 | enum {
|
||
51 | TRACE_LEVEL_NONE, |
||
52 | TRACE_LEVEL_ERRORS, |
||
53 | TRACE_LEVEL_WARNING, |
||
54 | TRACE_LEVEL_INFO, |
||
55 | TRACE_LEVEL_DEBUG, |
||
56 | TRACE_LEVEL_ALL, |
||
57 | TRACE_LEVEL_IGNORE |
||
58 | }; |
||
59 | |||
60 | enum {
|
||
61 | TRACE_FUNCTION_NONE = 0,
|
||
62 | TRACE_FUNCTION_I2C = 1,
|
||
63 | TRACE_FUNCTION_ALL = 0x7fffffff //all bits except sign |
||
64 | }; |
||
65 | |||
66 | enum {
|
||
67 | TRACE_MODULE_NONE = 0x0,
|
||
68 | TRACE_MODULE_API = 0x1,
|
||
69 | TRACE_MODULE_PLATFORM = 0x2,
|
||
70 | TRACE_MODULE_ALL = 0x7fffffff //all bits except sign |
||
71 | }; |
||
72 | |||
73 | |||
74 | #ifdef VL53L0X_LOG_ENABLE
|
||
75 | |||
76 | #include <sys/time.h> |
||
77 | |||
78 | extern uint32_t _trace_level;
|
||
79 | |||
80 | |||
81 | |||
82 | int32_t VL53L0X_trace_config(char *filename, uint32_t modules, uint32_t level, uint32_t functions);
|
||
83 | |||
84 | void trace_print_module_function(uint32_t module, uint32_t level, uint32_t function, const char *format, ...); |
||
85 | |||
86 | |||
87 | //extern FILE * log_file;
|
||
88 | |||
89 | #define LOG_GET_TIME() (int)clock() |
||
90 | |||
91 | #define _LOG_FUNCTION_START(module, fmt, ... ) \
|
||
92 | trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld <START> %s "fmt"\n", LOG_GET_TIME(), __FUNCTION__, ##__VA_ARGS__); |
||
93 | |||
94 | #define _LOG_FUNCTION_END(module, status, ... )\
|
||
95 | trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld <END> %s %d\n", LOG_GET_TIME(), __FUNCTION__, (int)status, ##__VA_ARGS__) |
||
96 | |||
97 | #define _LOG_FUNCTION_END_FMT(module, status, fmt, ... )\
|
||
98 | trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld <END> %s %d "fmt"\n", LOG_GET_TIME(), __FUNCTION__, (int)status,##__VA_ARGS__) |
||
99 | |||
100 | // __func__ is gcc only
|
||
101 | //#define VL53L0X_ErrLog( fmt, ...) fprintf(stderr, "VL53L0X_ErrLog %s" fmt "\n", __func__, ##__VA_ARGS__)
|
||
102 | |||
103 | #else /* VL53L0X_LOG_ENABLE no logging */ |
||
104 | #define VL53L0X_ErrLog(...) (void)0 |
||
105 | #define _LOG_FUNCTION_START(module, fmt, ... ) (void)0 |
||
106 | #define _LOG_FUNCTION_END(module, status, ... ) (void)0 |
||
107 | #define _LOG_FUNCTION_END_FMT(module, status, fmt, ... ) (void)0 |
||
108 | #endif /* else */ |
||
109 | |||
110 | #define VL53L0X_COPYSTRING(str, ...) strcpy(str, ##__VA_ARGS__) |
||
111 | |||
112 | #ifdef __cplusplus
|
||
113 | } |
||
114 | #endif
|
||
115 | |||
116 | #endif /* _VL53L0X_PLATFORM_LOG_H_ */ |
||
117 | |||
118 |