vl53l1_platform_log.h
Go to the documentation of this file.
1 /*
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 
70 #ifndef _VL53L1_PLATFORM_LOG_H_
71 #define _VL53L1_PLATFORM_LOG_H_
72 
73 
74 #ifdef VL53L1_LOG_ENABLE
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 
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 
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 
198  uint32_t VL53L1_get_trace_functions(void);
199 
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_ */
int8_t
signed char int8_t
Typedef defining 8 bit char type. The developer should modify this to suit the platform being deploye...
Definition: vl53l1_types.h:138
uint32_t
unsigned int uint32_t
Typedef defining 32 bit unsigned int type. The developer should modify this to suit the platform bein...
Definition: vl53l1_types.h:113
vl53l1_types.h
VL53L1 types definition.
time.h
vl53l1_platform_user_config.h
EwokPlus compile time user modifiable configuration.


vl53l1x
Author(s):
autogenerated on Fri Aug 2 2024 08:35:54