amiro-lld / drivers / VL53L1X / v1 / api / platform / vl53l1_platform_log.h @ 4dba9195
History | View | Annotate | Download (8.806 KB)
1 | 4dba9195 | galberding | /*
|
---|---|---|---|
2 | * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
|
||
3 | *
|
||
4 | * This file is part of VL53L1 Core and is dual licensed,
|
||
5 | * either 'STMicroelectronics
|
||
6 | * Proprietary license'
|
||
7 | * or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||
8 | *
|
||
9 | ********************************************************************************
|
||
10 | *
|
||
11 | * 'STMicroelectronics Proprietary license'
|
||
12 | *
|
||
13 | ********************************************************************************
|
||
14 | *
|
||
15 | * License terms: STMicroelectronics Proprietary in accordance with licensing
|
||
16 | * terms at www.st.com/sla0081
|
||
17 | *
|
||
18 | * STMicroelectronics confidential
|
||
19 | * Reproduction and Communication of this document is strictly prohibited unless
|
||
20 | * specifically authorized in writing by STMicroelectronics.
|
||
21 | *
|
||
22 | *
|
||
23 | ********************************************************************************
|
||
24 | *
|
||
25 | * Alternatively, VL53L1 Core may be distributed under the terms of
|
||
26 | * 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||
27 | * provisions apply instead of the ones mentioned above :
|
||
28 | *
|
||
29 | ********************************************************************************
|
||
30 | *
|
||
31 | * License terms: BSD 3-clause "New" or "Revised" License.
|
||
32 | *
|
||
33 | * Redistribution and use in source and binary forms, with or without
|
||
34 | * modification, are permitted provided that the following conditions are met:
|
||
35 | *
|
||
36 | * 1. Redistributions of source code must retain the above copyright notice, this
|
||
37 | * list of conditions and the following disclaimer.
|
||
38 | *
|
||
39 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
||
40 | * this list of conditions and the following disclaimer in the documentation
|
||
41 | * and/or other materials provided with the distribution.
|
||
42 | *
|
||
43 | * 3. Neither the name of the copyright holder nor the names of its contributors
|
||
44 | * may be used to endorse or promote products derived from this software
|
||
45 | * without specific prior written permission.
|
||
46 | *
|
||
47 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||
48 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||
49 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||
50 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||
51 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||
52 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||
53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||
54 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||
55 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||
56 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
57 | *
|
||
58 | *
|
||
59 | ********************************************************************************
|
||
60 | *
|
||
61 | */
|
||
62 | |||
63 | /**
|
||
64 | * @file vl53l1_platform_log.h
|
||
65 | *
|
||
66 | * @brief EwokPlus25 platform logging function definition
|
||
67 | */
|
||
68 | |||
69 | |||
70 | #ifndef _VL53L1_PLATFORM_LOG_H_
|
||
71 | #define _VL53L1_PLATFORM_LOG_H_
|
||
72 | |||
73 | |||
74 | #ifdef VL53L1_LOG_ENABLE
|
||
75 | #include "vl53l1_platform_user_config.h" |
||
76 | |||
77 | #ifdef _MSC_VER
|
||
78 | # define EWOKPLUS_EXPORTS __declspec(dllexport)
|
||
79 | #else
|
||
80 | # define EWOKPLUS_EXPORTS
|
||
81 | #endif
|
||
82 | |||
83 | #include "vl53l1_types.h" |
||
84 | |||
85 | #ifdef __cplusplus
|
||
86 | extern "C" { |
||
87 | #endif
|
||
88 | |||
89 | #include <time.h> |
||
90 | |||
91 | /**
|
||
92 | * @brief Set the level, output and specific functions for module logging.
|
||
93 | *
|
||
94 | *
|
||
95 | * @param filename - full path of output log file, NULL for print to stdout
|
||
96 | *
|
||
97 | * @param modules - Module or None or All to trace
|
||
98 | * VL53L1_TRACE_MODULE_NONE
|
||
99 | * VL53L1_TRACE_MODULE_API
|
||
100 | * VL53L1_TRACE_MODULE_CORE
|
||
101 | * VL53L1_TRACE_MODULE_TUNING
|
||
102 | * VL53L1_TRACE_MODULE_CHARACTERISATION
|
||
103 | * VL53L1_TRACE_MODULE_PLATFORM
|
||
104 | * VL53L1_TRACE_MODULE_ALL
|
||
105 | *
|
||
106 | * @param level - trace level
|
||
107 | * VL53L1_TRACE_LEVEL_NONE
|
||
108 | * VL53L1_TRACE_LEVEL_ERRORS
|
||
109 | * VL53L1_TRACE_LEVEL_WARNING
|
||
110 | * VL53L1_TRACE_LEVEL_INFO
|
||
111 | * VL53L1_TRACE_LEVEL_DEBUG
|
||
112 | * VL53L1_TRACE_LEVEL_ALL
|
||
113 | * VL53L1_TRACE_LEVEL_IGNORE
|
||
114 | *
|
||
115 | * @param functions - function level to trace;
|
||
116 | * VL53L1_TRACE_FUNCTION_NONE
|
||
117 | * VL53L1_TRACE_FUNCTION_I2C
|
||
118 | * VL53L1_TRACE_FUNCTION_ALL
|
||
119 | *
|
||
120 | * @return status - always VL53L1_ERROR_NONE
|
||
121 | *
|
||
122 | */
|
||
123 | |||
124 | #define VL53L1_TRACE_LEVEL_NONE 0x00000000 |
||
125 | #define VL53L1_TRACE_LEVEL_ERRORS 0x00000001 |
||
126 | #define VL53L1_TRACE_LEVEL_WARNING 0x00000002 |
||
127 | #define VL53L1_TRACE_LEVEL_INFO 0x00000004 |
||
128 | #define VL53L1_TRACE_LEVEL_DEBUG 0x00000008 |
||
129 | #define VL53L1_TRACE_LEVEL_ALL 0x00000010 |
||
130 | #define VL53L1_TRACE_LEVEL_IGNORE 0x00000020 |
||
131 | |||
132 | #define VL53L1_TRACE_FUNCTION_NONE 0x00000000 |
||
133 | #define VL53L1_TRACE_FUNCTION_I2C 0x00000001 |
||
134 | #define VL53L1_TRACE_FUNCTION_ALL 0x7fffffff |
||
135 | |||
136 | #define VL53L1_TRACE_MODULE_NONE 0x00000000 |
||
137 | #define VL53L1_TRACE_MODULE_API 0x00000001 |
||
138 | #define VL53L1_TRACE_MODULE_CORE 0x00000002 |
||
139 | #define VL53L1_TRACE_MODULE_PROTECTED 0x00000004 |
||
140 | #define VL53L1_TRACE_MODULE_HISTOGRAM 0x00000008 |
||
141 | #define VL53L1_TRACE_MODULE_REGISTERS 0x00000010 |
||
142 | #define VL53L1_TRACE_MODULE_PLATFORM 0x00000020 |
||
143 | #define VL53L1_TRACE_MODULE_NVM 0x00000040 |
||
144 | #define VL53L1_TRACE_MODULE_CALIBRATION_DATA 0x00000080 |
||
145 | #define VL53L1_TRACE_MODULE_NVM_DATA 0x00000100 |
||
146 | #define VL53L1_TRACE_MODULE_HISTOGRAM_DATA 0x00000200 |
||
147 | #define VL53L1_TRACE_MODULE_RANGE_RESULTS_DATA 0x00000400 |
||
148 | #define VL53L1_TRACE_MODULE_XTALK_DATA 0x00000800 |
||
149 | #define VL53L1_TRACE_MODULE_OFFSET_DATA 0x00001000 |
||
150 | #define VL53L1_TRACE_MODULE_DATA_INIT 0x00002000 |
||
151 | #define VL53L1_TRACE_MODULE_REF_SPAD_CHAR 0x00004000 |
||
152 | #define VL53L1_TRACE_MODULE_SPAD_RATE_MAP 0x00008000 |
||
153 | #ifdef PAL_EXTENDED
|
||
154 | #define VL53L1_TRACE_MODULE_SPAD 0x01000000 |
||
155 | #define VL53L1_TRACE_MODULE_FMT 0x02000000 |
||
156 | #define VL53L1_TRACE_MODULE_UTILS 0x04000000 |
||
157 | #define VL53L1_TRACE_MODULE_BENCH_FUNCS 0x08000000 |
||
158 | #endif
|
||
159 | #define VL53L1_TRACE_MODULE_CUSTOMER_API 0x40000000 |
||
160 | #define VL53L1_TRACE_MODULE_ALL 0x7fffffff |
||
161 | |||
162 | |||
163 | extern uint32_t _trace_level;
|
||
164 | |||
165 | /*
|
||
166 | * NOTE: dynamically exported if we enable logging.
|
||
167 | * this way, Python interfaces can access this function, but we don't
|
||
168 | * need to include it in the .def files.
|
||
169 | */
|
||
170 | EWOKPLUS_EXPORTS int8_t VL53L1_trace_config( |
||
171 | char *filename,
|
||
172 | uint32_t modules, |
||
173 | uint32_t level, |
||
174 | uint32_t functions); |
||
175 | |||
176 | /**
|
||
177 | * @brief Print trace module function.
|
||
178 | *
|
||
179 | * @param module - ??
|
||
180 | * @param level - ??
|
||
181 | * @param function - ??
|
||
182 | * @param format - ??
|
||
183 | *
|
||
184 | */
|
||
185 | |||
186 | EWOKPLUS_EXPORTS void VL53L1_trace_print_module_function(
|
||
187 | uint32_t module, |
||
188 | uint32_t level, |
||
189 | uint32_t function, |
||
190 | const char *format, ...); |
||
191 | |||
192 | /**
|
||
193 | * @brief Get global _trace_functions parameter
|
||
194 | *
|
||
195 | * @return _trace_functions
|
||
196 | */
|
||
197 | |||
198 | uint32_t VL53L1_get_trace_functions(void);
|
||
199 | |||
200 | /**
|
||
201 | * @brief Set global _trace_functions parameter
|
||
202 | *
|
||
203 | * @param[in] function : new function code
|
||
204 | */
|
||
205 | |||
206 | void VL53L1_set_trace_functions(uint32_t function);
|
||
207 | |||
208 | |||
209 | /*
|
||
210 | * @brief Returns the current system tick count in [ms]
|
||
211 | *
|
||
212 | * @return time_ms : current time in [ms]
|
||
213 | *
|
||
214 | */
|
||
215 | |||
216 | uint32_t VL53L1_clock(void);
|
||
217 | |||
218 | #define LOG_GET_TIME() \
|
||
219 | ((int)VL53L1_clock())
|
||
220 | |||
221 | #define _LOG_TRACE_PRINT(module, level, function, ...) \
|
||
222 | VL53L1_trace_print_module_function(module, level, function, ##__VA_ARGS__); |
||
223 | |||
224 | #define _LOG_FUNCTION_START(module, fmt, ...) \
|
||
225 | VL53L1_trace_print_module_function(module, _trace_level, VL53L1_TRACE_FUNCTION_ALL, "%6ld <START> %s "fmt"\n", LOG_GET_TIME(), __FUNCTION__, ##__VA_ARGS__); |
||
226 | |||
227 | #define _LOG_FUNCTION_END(module, status, ...)\
|
||
228 | VL53L1_trace_print_module_function(module, _trace_level, VL53L1_TRACE_FUNCTION_ALL, "%6ld <END> %s %d\n", LOG_GET_TIME(), __FUNCTION__, (int)status, ##__VA_ARGS__) |
||
229 | |||
230 | #define _LOG_FUNCTION_END_FMT(module, status, fmt, ...)\
|
||
231 | VL53L1_trace_print_module_function(module, _trace_level, VL53L1_TRACE_FUNCTION_ALL, "%6ld <END> %s %d "fmt"\n", LOG_GET_TIME(), __FUNCTION__, (int)status, ##__VA_ARGS__) |
||
232 | |||
233 | #define _LOG_GET_TRACE_FUNCTIONS()\
|
||
234 | VL53L1_get_trace_functions() |
||
235 | |||
236 | #define _LOG_SET_TRACE_FUNCTIONS(functions)\
|
||
237 | VL53L1_set_trace_functions(functions) |
||
238 | |||
239 | #define _LOG_STRING_BUFFER(x) char x[VL53L1_MAX_STRING_LENGTH] |
||
240 | |||
241 | #ifdef __cplusplus
|
||
242 | } |
||
243 | #endif
|
||
244 | |||
245 | #else /* VL53L1_LOG_ENABLE - no logging */ |
||
246 | |||
247 | #define _LOG_TRACE_PRINT(module, level, function, ...)
|
||
248 | #define _LOG_FUNCTION_START(module, fmt, ...)
|
||
249 | #define _LOG_FUNCTION_END(module, status, ...)
|
||
250 | #define _LOG_FUNCTION_END_FMT(module, status, fmt, ...)
|
||
251 | #define _LOG_GET_TRACE_FUNCTIONS() 0 |
||
252 | #define _LOG_SET_TRACE_FUNCTIONS(functions)
|
||
253 | #define _LOG_STRING_BUFFER(x)
|
||
254 | |||
255 | #endif /* VL53L1_LOG_ENABLE */ |
||
256 | |||
257 | #endif /* _VL53L1_PLATFORM_LOG_H_ */ |