The VL53L1CB proximity sensor, based on ST’s FlightSense™, Time-of-Flight technology.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: VL53L1CB_noshield_1sensor_polls_auton VL53L1CB_noshield_1sensor_interrupt_auton X_NUCLEO_53L1A2
Based on VL53L1 library, this is a library for the VL53L1CB ToF chip.
inc/vl53l1_platform_log.h@0:3ac96e360672, 2020-11-06 (annotated)
- Committer:
- charlesmn
- Date:
- Fri Nov 06 10:06:37 2020 +0000
- Revision:
- 0:3ac96e360672
- Child:
- 18:0696efe39d08
Library for ST Vl53L1A1 time of flight sensor.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
charlesmn | 0:3ac96e360672 | 1 | |
charlesmn | 0:3ac96e360672 | 2 | /******************************************************************************* |
charlesmn | 0:3ac96e360672 | 3 | This file is part of VL53L1 Platform |
charlesmn | 0:3ac96e360672 | 4 | |
charlesmn | 0:3ac96e360672 | 5 | Copyright (c) 2020, STMicroelectronics - All Rights Reserved |
charlesmn | 0:3ac96e360672 | 6 | |
charlesmn | 0:3ac96e360672 | 7 | License terms: BSD 3-clause "New" or "Revised" License. |
charlesmn | 0:3ac96e360672 | 8 | |
charlesmn | 0:3ac96e360672 | 9 | Redistribution and use in source and binary forms, with or without |
charlesmn | 0:3ac96e360672 | 10 | modification, are permitted provided that the following conditions are met: |
charlesmn | 0:3ac96e360672 | 11 | |
charlesmn | 0:3ac96e360672 | 12 | 1. Redistributions of source code must retain the above copyright notice, this |
charlesmn | 0:3ac96e360672 | 13 | list of conditions and the following disclaimer. |
charlesmn | 0:3ac96e360672 | 14 | |
charlesmn | 0:3ac96e360672 | 15 | 2. Redistributions in binary form must reproduce the above copyright notice, |
charlesmn | 0:3ac96e360672 | 16 | this list of conditions and the following disclaimer in the documentation |
charlesmn | 0:3ac96e360672 | 17 | and/or other materials provided with the distribution. |
charlesmn | 0:3ac96e360672 | 18 | |
charlesmn | 0:3ac96e360672 | 19 | 3. Neither the name of the copyright holder nor the names of its contributors |
charlesmn | 0:3ac96e360672 | 20 | may be used to endorse or promote products derived from this software |
charlesmn | 0:3ac96e360672 | 21 | without specific prior written permission. |
charlesmn | 0:3ac96e360672 | 22 | |
charlesmn | 0:3ac96e360672 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
charlesmn | 0:3ac96e360672 | 24 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
charlesmn | 0:3ac96e360672 | 25 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
charlesmn | 0:3ac96e360672 | 26 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
charlesmn | 0:3ac96e360672 | 27 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
charlesmn | 0:3ac96e360672 | 28 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
charlesmn | 0:3ac96e360672 | 29 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
charlesmn | 0:3ac96e360672 | 30 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
charlesmn | 0:3ac96e360672 | 31 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
charlesmn | 0:3ac96e360672 | 32 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
charlesmn | 0:3ac96e360672 | 33 | |
charlesmn | 0:3ac96e360672 | 34 | */ |
charlesmn | 0:3ac96e360672 | 35 | |
charlesmn | 0:3ac96e360672 | 36 | |
charlesmn | 0:3ac96e360672 | 37 | |
charlesmn | 0:3ac96e360672 | 38 | |
charlesmn | 0:3ac96e360672 | 39 | |
charlesmn | 0:3ac96e360672 | 40 | #ifndef _VL53L1_PLATFORM_LOG_H_ |
charlesmn | 0:3ac96e360672 | 41 | #define _VL53L1_PLATFORM_LOG_H_ |
charlesmn | 0:3ac96e360672 | 42 | |
charlesmn | 0:3ac96e360672 | 43 | |
charlesmn | 0:3ac96e360672 | 44 | #ifdef VL53L1_LOG_ENABLE |
charlesmn | 0:3ac96e360672 | 45 | #include "vl53l1_platform_user_config.h" |
charlesmn | 0:3ac96e360672 | 46 | |
charlesmn | 0:3ac96e360672 | 47 | #ifdef _MSC_VER |
charlesmn | 0:3ac96e360672 | 48 | # define EWOKPLUS_EXPORTS __declspec(dllexport) |
charlesmn | 0:3ac96e360672 | 49 | #else |
charlesmn | 0:3ac96e360672 | 50 | # define EWOKPLUS_EXPORTS |
charlesmn | 0:3ac96e360672 | 51 | #endif |
charlesmn | 0:3ac96e360672 | 52 | |
charlesmn | 0:3ac96e360672 | 53 | #include "vl53l1_types.h" |
charlesmn | 0:3ac96e360672 | 54 | |
charlesmn | 0:3ac96e360672 | 55 | #ifdef __cplusplus |
charlesmn | 0:3ac96e360672 | 56 | extern "C" { |
charlesmn | 0:3ac96e360672 | 57 | #endif |
charlesmn | 0:3ac96e360672 | 58 | |
charlesmn | 0:3ac96e360672 | 59 | #include <time.h> |
charlesmn | 0:3ac96e360672 | 60 | |
charlesmn | 0:3ac96e360672 | 61 | |
charlesmn | 0:3ac96e360672 | 62 | |
charlesmn | 0:3ac96e360672 | 63 | #define VL53L1_TRACE_LEVEL_NONE 0x00000000 |
charlesmn | 0:3ac96e360672 | 64 | #define VL53L1_TRACE_LEVEL_ERRORS 0x00000001 |
charlesmn | 0:3ac96e360672 | 65 | #define VL53L1_TRACE_LEVEL_WARNING 0x00000002 |
charlesmn | 0:3ac96e360672 | 66 | #define VL53L1_TRACE_LEVEL_INFO 0x00000004 |
charlesmn | 0:3ac96e360672 | 67 | #define VL53L1_TRACE_LEVEL_DEBUG 0x00000008 |
charlesmn | 0:3ac96e360672 | 68 | #define VL53L1_TRACE_LEVEL_ALL 0x00000010 |
charlesmn | 0:3ac96e360672 | 69 | #define VL53L1_TRACE_LEVEL_IGNORE 0x00000020 |
charlesmn | 0:3ac96e360672 | 70 | |
charlesmn | 0:3ac96e360672 | 71 | #define VL53L1_TRACE_FUNCTION_NONE 0x00000000 |
charlesmn | 0:3ac96e360672 | 72 | #define VL53L1_TRACE_FUNCTION_I2C 0x00000001 |
charlesmn | 0:3ac96e360672 | 73 | #define VL53L1_TRACE_FUNCTION_ALL 0x7fffffff |
charlesmn | 0:3ac96e360672 | 74 | |
charlesmn | 0:3ac96e360672 | 75 | #define VL53L1_TRACE_MODULE_NONE 0x00000000 |
charlesmn | 0:3ac96e360672 | 76 | #define VL53L1_TRACE_MODULE_API 0x00000001 |
charlesmn | 0:3ac96e360672 | 77 | #define VL53L1_TRACE_MODULE_CORE 0x00000002 |
charlesmn | 0:3ac96e360672 | 78 | #define VL53L1_TRACE_MODULE_PROTECTED 0x00000004 |
charlesmn | 0:3ac96e360672 | 79 | #define VL53L1_TRACE_MODULE_HISTOGRAM 0x00000008 |
charlesmn | 0:3ac96e360672 | 80 | #define VL53L1_TRACE_MODULE_REGISTERS 0x00000010 |
charlesmn | 0:3ac96e360672 | 81 | #define VL53L1_TRACE_MODULE_PLATFORM 0x00000020 |
charlesmn | 0:3ac96e360672 | 82 | #define VL53L1_TRACE_MODULE_NVM 0x00000040 |
charlesmn | 0:3ac96e360672 | 83 | #define VL53L1_TRACE_MODULE_CALIBRATION_DATA 0x00000080 |
charlesmn | 0:3ac96e360672 | 84 | #define VL53L1_TRACE_MODULE_NVM_DATA 0x00000100 |
charlesmn | 0:3ac96e360672 | 85 | #define VL53L1_TRACE_MODULE_HISTOGRAM_DATA 0x00000200 |
charlesmn | 0:3ac96e360672 | 86 | #define VL53L1_TRACE_MODULE_RANGE_RESULTS_DATA 0x00000400 |
charlesmn | 0:3ac96e360672 | 87 | #define VL53L1_TRACE_MODULE_XTALK_DATA 0x00000800 |
charlesmn | 0:3ac96e360672 | 88 | #define VL53L1_TRACE_MODULE_OFFSET_DATA 0x00001000 |
charlesmn | 0:3ac96e360672 | 89 | #define VL53L1_TRACE_MODULE_DATA_INIT 0x00002000 |
charlesmn | 0:3ac96e360672 | 90 | #define VL53L1_TRACE_MODULE_REF_SPAD_CHAR 0x00004000 |
charlesmn | 0:3ac96e360672 | 91 | #define VL53L1_TRACE_MODULE_SPAD_RATE_MAP 0x00008000 |
charlesmn | 0:3ac96e360672 | 92 | #ifdef PAL_EXTENDED |
charlesmn | 0:3ac96e360672 | 93 | #define VL53L1_TRACE_MODULE_SPAD 0x01000000 |
charlesmn | 0:3ac96e360672 | 94 | #define VL53L1_TRACE_MODULE_FMT 0x02000000 |
charlesmn | 0:3ac96e360672 | 95 | #define VL53L1_TRACE_MODULE_UTILS 0x04000000 |
charlesmn | 0:3ac96e360672 | 96 | #define VL53L1_TRACE_MODULE_BENCH_FUNCS 0x08000000 |
charlesmn | 0:3ac96e360672 | 97 | #endif |
charlesmn | 0:3ac96e360672 | 98 | #define VL53L1_TRACE_MODULE_CUSTOMER_API 0x40000000 |
charlesmn | 0:3ac96e360672 | 99 | #define VL53L1_TRACE_MODULE_ALL 0x7fffffff |
charlesmn | 0:3ac96e360672 | 100 | |
charlesmn | 0:3ac96e360672 | 101 | |
charlesmn | 0:3ac96e360672 | 102 | extern uint32_t _trace_level; |
charlesmn | 0:3ac96e360672 | 103 | |
charlesmn | 0:3ac96e360672 | 104 | |
charlesmn | 0:3ac96e360672 | 105 | EWOKPLUS_EXPORTS int8_t VL53L1_trace_config( |
charlesmn | 0:3ac96e360672 | 106 | char *filename, |
charlesmn | 0:3ac96e360672 | 107 | uint32_t modules, |
charlesmn | 0:3ac96e360672 | 108 | uint32_t level, |
charlesmn | 0:3ac96e360672 | 109 | uint32_t functions); |
charlesmn | 0:3ac96e360672 | 110 | |
charlesmn | 0:3ac96e360672 | 111 | |
charlesmn | 0:3ac96e360672 | 112 | |
charlesmn | 0:3ac96e360672 | 113 | EWOKPLUS_EXPORTS void VL53L1_trace_print_module_function( |
charlesmn | 0:3ac96e360672 | 114 | uint32_t module, |
charlesmn | 0:3ac96e360672 | 115 | uint32_t level, |
charlesmn | 0:3ac96e360672 | 116 | uint32_t function, |
charlesmn | 0:3ac96e360672 | 117 | const char *format, ...); |
charlesmn | 0:3ac96e360672 | 118 | |
charlesmn | 0:3ac96e360672 | 119 | |
charlesmn | 0:3ac96e360672 | 120 | |
charlesmn | 0:3ac96e360672 | 121 | uint32_t VL53L1_get_trace_functions(void); |
charlesmn | 0:3ac96e360672 | 122 | |
charlesmn | 0:3ac96e360672 | 123 | |
charlesmn | 0:3ac96e360672 | 124 | |
charlesmn | 0:3ac96e360672 | 125 | void VL53L1_set_trace_functions(uint32_t function); |
charlesmn | 0:3ac96e360672 | 126 | |
charlesmn | 0:3ac96e360672 | 127 | |
charlesmn | 0:3ac96e360672 | 128 | |
charlesmn | 0:3ac96e360672 | 129 | |
charlesmn | 0:3ac96e360672 | 130 | uint32_t VL53L1_clock(void); |
charlesmn | 0:3ac96e360672 | 131 | |
charlesmn | 0:3ac96e360672 | 132 | #define LOG_GET_TIME() \ |
charlesmn | 0:3ac96e360672 | 133 | ((int)VL53L1_clock()) |
charlesmn | 0:3ac96e360672 | 134 | |
charlesmn | 0:3ac96e360672 | 135 | #define _LOG_TRACE_PRINT(module, level, function, ...) \ |
charlesmn | 0:3ac96e360672 | 136 | VL53L1_trace_print_module_function(module, level, function, ##__VA_ARGS__); |
charlesmn | 0:3ac96e360672 | 137 | |
charlesmn | 0:3ac96e360672 | 138 | #define _LOG_FUNCTION_START(module, fmt, ...) \ |
charlesmn | 0:3ac96e360672 | 139 | VL53L1_trace_print_module_function(module, _trace_level, VL53L1_TRACE_FUNCTION_ALL, "%6ld <START> %s "fmt"\n", LOG_GET_TIME(), __FUNCTION__, ##__VA_ARGS__); |
charlesmn | 0:3ac96e360672 | 140 | |
charlesmn | 0:3ac96e360672 | 141 | #define _LOG_FUNCTION_END(module, status, ...)\ |
charlesmn | 0:3ac96e360672 | 142 | 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__) |
charlesmn | 0:3ac96e360672 | 143 | |
charlesmn | 0:3ac96e360672 | 144 | #define _LOG_FUNCTION_END_FMT(module, status, fmt, ...)\ |
charlesmn | 0:3ac96e360672 | 145 | 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__) |
charlesmn | 0:3ac96e360672 | 146 | |
charlesmn | 0:3ac96e360672 | 147 | #define _LOG_GET_TRACE_FUNCTIONS()\ |
charlesmn | 0:3ac96e360672 | 148 | VL53L1_get_trace_functions() |
charlesmn | 0:3ac96e360672 | 149 | |
charlesmn | 0:3ac96e360672 | 150 | #define _LOG_SET_TRACE_FUNCTIONS(functions)\ |
charlesmn | 0:3ac96e360672 | 151 | VL53L1_set_trace_functions(functions) |
charlesmn | 0:3ac96e360672 | 152 | |
charlesmn | 0:3ac96e360672 | 153 | #define _LOG_STRING_BUFFER(x) char x[VL53L1_MAX_STRING_LENGTH] |
charlesmn | 0:3ac96e360672 | 154 | |
charlesmn | 0:3ac96e360672 | 155 | #ifdef __cplusplus |
charlesmn | 0:3ac96e360672 | 156 | } |
charlesmn | 0:3ac96e360672 | 157 | #endif |
charlesmn | 0:3ac96e360672 | 158 | |
charlesmn | 0:3ac96e360672 | 159 | #else |
charlesmn | 0:3ac96e360672 | 160 | |
charlesmn | 0:3ac96e360672 | 161 | #define _LOG_TRACE_PRINT(module, level, function, ...) |
charlesmn | 0:3ac96e360672 | 162 | #define _LOG_FUNCTION_START(module, fmt, ...) |
charlesmn | 0:3ac96e360672 | 163 | #define _LOG_FUNCTION_END(module, status, ...) |
charlesmn | 0:3ac96e360672 | 164 | #define _LOG_FUNCTION_END_FMT(module, status, fmt, ...) |
charlesmn | 0:3ac96e360672 | 165 | #define _LOG_GET_TRACE_FUNCTIONS() 0 |
charlesmn | 0:3ac96e360672 | 166 | #define _LOG_SET_TRACE_FUNCTIONS(functions) |
charlesmn | 0:3ac96e360672 | 167 | #define _LOG_STRING_BUFFER(x) |
charlesmn | 0:3ac96e360672 | 168 | |
charlesmn | 0:3ac96e360672 | 169 | #endif |
charlesmn | 0:3ac96e360672 | 170 | |
charlesmn | 0:3ac96e360672 | 171 | #endif |
charlesmn | 0:3ac96e360672 | 172 | |
charlesmn | 0:3ac96e360672 | 173 |