ST Expansion SW Team / VL53L1

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   X_NUCLEO_53L1CB

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers vl53l1_platform_log.h Source File

vl53l1_platform_log.h

00001 
00002 /*******************************************************************************
00003  This file is part of VL53L1 Platform
00004 
00005  Copyright (c) 2020, STMicroelectronics - All Rights Reserved
00006 
00007  License terms: BSD 3-clause "New" or "Revised" License.
00008 
00009  Redistribution and use in source and binary forms, with or without
00010  modification, are permitted provided that the following conditions are met:
00011 
00012  1. Redistributions of source code must retain the above copyright notice, this
00013  list of conditions and the following disclaimer.
00014 
00015  2. Redistributions in binary form must reproduce the above copyright notice,
00016  this list of conditions and the following disclaimer in the documentation
00017  and/or other materials provided with the distribution.
00018 
00019  3. Neither the name of the copyright holder nor the names of its contributors
00020  may be used to endorse or promote products derived from this software
00021  without specific prior written permission.
00022 
00023  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00024  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00026  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00027  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00028  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00029  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00031  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00032  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 */
00035 
00036 
00037 
00038 
00039 
00040 #ifndef _VL53L1_PLATFORM_LOG_H_
00041 #define _VL53L1_PLATFORM_LOG_H_
00042 
00043 
00044 #ifdef VL53L1_LOG_ENABLE
00045     #include "vl53l1_platform_user_config.h"
00046 
00047     #ifdef _MSC_VER
00048     #   define EWOKPLUS_EXPORTS  __declspec(dllexport)
00049     #else
00050     #       define EWOKPLUS_EXPORTS
00051     #endif
00052 
00053     #include "vl53l1_types.h"
00054 
00055     #ifdef __cplusplus
00056     extern "C" {
00057     #endif
00058 
00059     #include <time.h>
00060 
00061 
00062 
00063     #define     VL53L1_TRACE_LEVEL_NONE         0x00000000
00064     #define     VL53L1_TRACE_LEVEL_ERRORS       0x00000001
00065     #define     VL53L1_TRACE_LEVEL_WARNING      0x00000002
00066     #define     VL53L1_TRACE_LEVEL_INFO         0x00000004
00067     #define     VL53L1_TRACE_LEVEL_DEBUG        0x00000008
00068     #define     VL53L1_TRACE_LEVEL_ALL          0x00000010
00069     #define     VL53L1_TRACE_LEVEL_IGNORE       0x00000020
00070 
00071     #define     VL53L1_TRACE_FUNCTION_NONE      0x00000000
00072     #define     VL53L1_TRACE_FUNCTION_I2C       0x00000001
00073     #define     VL53L1_TRACE_FUNCTION_ALL       0x7fffffff
00074 
00075     #define     VL53L1_TRACE_MODULE_NONE        0x00000000
00076     #define     VL53L1_TRACE_MODULE_API         0x00000001
00077     #define     VL53L1_TRACE_MODULE_CORE        0x00000002
00078     #define     VL53L1_TRACE_MODULE_PROTECTED       0x00000004
00079     #define     VL53L1_TRACE_MODULE_HISTOGRAM       0x00000008
00080     #define     VL53L1_TRACE_MODULE_REGISTERS       0x00000010
00081     #define     VL53L1_TRACE_MODULE_PLATFORM        0x00000020
00082     #define     VL53L1_TRACE_MODULE_NVM         0x00000040
00083     #define     VL53L1_TRACE_MODULE_CALIBRATION_DATA    0x00000080
00084     #define     VL53L1_TRACE_MODULE_NVM_DATA        0x00000100
00085     #define     VL53L1_TRACE_MODULE_HISTOGRAM_DATA  0x00000200
00086     #define     VL53L1_TRACE_MODULE_RANGE_RESULTS_DATA  0x00000400
00087     #define     VL53L1_TRACE_MODULE_XTALK_DATA      0x00000800
00088     #define     VL53L1_TRACE_MODULE_OFFSET_DATA     0x00001000
00089     #define     VL53L1_TRACE_MODULE_DATA_INIT       0x00002000
00090     #define     VL53L1_TRACE_MODULE_REF_SPAD_CHAR   0x00004000
00091     #define     VL53L1_TRACE_MODULE_SPAD_RATE_MAP   0x00008000
00092     #ifdef PAL_EXTENDED
00093         #define VL53L1_TRACE_MODULE_SPAD        0x01000000
00094         #define VL53L1_TRACE_MODULE_FMT         0x02000000
00095         #define VL53L1_TRACE_MODULE_UTILS       0x04000000
00096         #define VL53L1_TRACE_MODULE_BENCH_FUNCS 0x08000000
00097     #endif
00098     #define     VL53L1_TRACE_MODULE_CUSTOMER_API    0x40000000
00099     #define     VL53L1_TRACE_MODULE_ALL         0x7fffffff
00100 
00101 
00102     extern uint32_t _trace_level;
00103 
00104 
00105     EWOKPLUS_EXPORTS int8_t VL53L1_trace_config(
00106         char *filename,
00107         uint32_t modules,
00108         uint32_t level,
00109         uint32_t functions);
00110 
00111 
00112 
00113     EWOKPLUS_EXPORTS void VL53L1_trace_print_module_function(
00114         uint32_t module,
00115         uint32_t level,
00116         uint32_t function,
00117         const char *format, ...);
00118 
00119 
00120 
00121     uint32_t VL53L1_get_trace_functions(void);
00122 
00123 
00124 
00125     void VL53L1_set_trace_functions(uint32_t function);
00126 
00127 
00128 
00129 
00130     uint32_t VL53L1_clock(void);
00131 
00132     #define LOG_GET_TIME() \
00133         ((int)VL53L1_clock())
00134 
00135     #define _LOG_TRACE_PRINT(module, level, function, ...) \
00136         VL53L1_trace_print_module_function(module, level, function, ##__VA_ARGS__);
00137 
00138     #define _LOG_FUNCTION_START(module, fmt, ...) \
00139         VL53L1_trace_print_module_function(module, _trace_level, VL53L1_TRACE_FUNCTION_ALL, "%6ld <START> %s "fmt"\n", LOG_GET_TIME(), __FUNCTION__, ##__VA_ARGS__);
00140 
00141     #define _LOG_FUNCTION_END(module, status, ...)\
00142         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__)
00143 
00144     #define _LOG_FUNCTION_END_FMT(module, status, fmt, ...)\
00145         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__)
00146 
00147     #define _LOG_GET_TRACE_FUNCTIONS()\
00148         VL53L1_get_trace_functions()
00149 
00150     #define _LOG_SET_TRACE_FUNCTIONS(functions)\
00151         VL53L1_set_trace_functions(functions)
00152 
00153     #define _LOG_STRING_BUFFER(x) char x[VL53L1_MAX_STRING_LENGTH]
00154 
00155     #ifdef __cplusplus
00156     }
00157     #endif
00158 
00159 #else
00160 
00161     #define _LOG_TRACE_PRINT(module, level, function, ...)
00162     #define _LOG_FUNCTION_START(module, fmt, ...)
00163     #define _LOG_FUNCTION_END(module, status, ...)
00164     #define _LOG_FUNCTION_END_FMT(module, status, fmt, ...)
00165     #define _LOG_GET_TRACE_FUNCTIONS() 0
00166     #define _LOG_SET_TRACE_FUNCTIONS(functions)
00167     #define _LOG_STRING_BUFFER(x)
00168 
00169 #endif
00170 
00171 #endif
00172 
00173