Condensed Version of Public VL53L0X
Embed:
(wiki syntax)
Show/hide line numbers
VL53L0X_def.h
Go to the documentation of this file.
00001 /******************************************************************************* 00002 Copyright © 2016, STMicroelectronics International N.V. 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without 00006 modification, are permitted provided that the following conditions are met: 00007 * Redistributions of source code must retain the above copyright 00008 notice, this list of conditions and the following disclaimer. 00009 * Redistributions in binary form must reproduce the above copyright 00010 notice, this list of conditions and the following disclaimer in the 00011 documentation and/or other materials provided with the distribution. 00012 * Neither the name of STMicroelectronics nor the 00013 names of its contributors may be used to endorse or promote products 00014 derived from this software without specific prior written permission. 00015 00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00018 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND 00019 NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED. 00020 IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY 00021 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00022 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00023 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00024 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00025 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00026 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 *******************************************************************************/ 00028 00029 /** 00030 * @file VL53L0X_def.h 00031 * 00032 * @brief Type definitions for VL53L0X API. 00033 * 00034 */ 00035 00036 00037 #ifndef _VL53L0X_DEF_H_ 00038 #define _VL53L0X_DEF_H_ 00039 00040 00041 #ifdef __cplusplus 00042 extern "C" { 00043 #endif 00044 00045 /** @defgroup VL53L0X_globaldefine_group VL53L0X Defines 00046 * @brief VL53L0X Defines 00047 * @{ 00048 */ 00049 00050 /****************** define for i2c configuration *******************************/ 00051 /** Maximum buffer size to be used in i2c */ 00052 #define VL53L0X_MAX_I2C_XFER_SIZE 64 /* Maximum buffer size to be used in i2c */ 00053 #define VL53L0X_I2C_USER_VAR /* none but could be for a flag var to get/pass to mutex interruptible return flags and try again */ 00054 00055 00056 /** Device SPECIFICATION major version */ 00057 #define VL53L0X10_SPECIFICATION_VER_MAJOR 1 00058 /** Device SPECIFICATION minor version */ 00059 #define VL53L0X10_SPECIFICATION_VER_MINOR 2 00060 /** Device SPECIFICATION sub version */ 00061 #define VL53L0X10_SPECIFICATION_VER_SUB 7 00062 /** Device SPECIFICATION sub version */ 00063 #define VL53L0X10_SPECIFICATION_VER_REVISION 1440 00064 00065 /** VL53L0X Device IMPLEMENTATION major version */ 00066 #define VL53L0X10_IMPLEMENTATION_VER_MAJOR 1 00067 /** VL53L0X Device IMPLEMENTATION minor version */ 00068 #define VL53L0X10_IMPLEMENTATION_VER_MINOR 0 00069 /** VL53L0X Device IMPLEMENTATION sub version */ 00070 #define VL53L0X10_IMPLEMENTATION_VER_SUB 9 00071 /** VL53L0X Device IMPLEMENTATION sub version */ 00072 #define VL53L0X10_IMPLEMENTATION_VER_REVISION 3673 00073 00074 /** Device SPECIFICATION major version */ 00075 #define VL53L0X_SPECIFICATION_VER_MAJOR 1 00076 /** Device SPECIFICATION minor version */ 00077 #define VL53L0X_SPECIFICATION_VER_MINOR 2 00078 /** Device SPECIFICATION sub version */ 00079 #define VL53L0X_SPECIFICATION_VER_SUB 7 00080 /** Device SPECIFICATION sub version */ 00081 #define VL53L0X_SPECIFICATION_VER_REVISION 1440 00082 00083 /** VL53L0X Device IMPLEMENTATION major version */ 00084 #define VL53L0X_IMPLEMENTATION_VER_MAJOR 1 00085 /** VL53L0X Device IMPLEMENTATION minor version */ 00086 #define VL53L0X_IMPLEMENTATION_VER_MINOR 1 00087 /** VL53L0X Device IMPLEMENTATION sub version */ 00088 #define VL53L0X_IMPLEMENTATION_VER_SUB 21 00089 /** VL53L0X Device IMPLEMENTATION sub version */ 00090 #define VL53L0X_IMPLEMENTATION_VER_REVISION 4823 00091 00092 00093 #define VL53L0X_DEFAULT_MAX_LOOP 2000 00094 #define VL53L0X_MAX_STRING_LENGTH 32 00095 00096 /** The device model ID */ 00097 #define IDENTIFICATION_MODEL_ID 0x000 00098 #define STATUS_OK 0x00 00099 #define STATUS_FAIL 0x01 00100 00101 /** default device address */ 00102 #define VL53L0X_DEFAULT_ADDRESS 0x52 /* (8-bit) */ 00103 00104 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS0 "VL53L0X TS0" 00105 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS1 "VL53L0X TS1" 00106 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS2 "VL53L0X TS2" 00107 #define VL53L0X_STRING_DEVICE_INFO_NAME_ES1 "VL53L0X ES1 or later" 00108 #define VL53L0X_STRING_DEVICE_INFO_TYPE "VL53L0X" 00109 00110 #define REF_ARRAY_SPAD_0 0 00111 #define REF_ARRAY_SPAD_5 5 00112 #define REF_ARRAY_SPAD_10 10 00113 00114 00115 /* sensor operating modes */ 00116 typedef enum { 00117 op_single_shot_poll = 1, 00118 op_poll, // was range_continuous_polling 00119 op_INT, 00120 op_poll_low_threshold, 00121 op_poll_high_threshold, 00122 op_poll_out_of_window, 00123 op_INT_low_threshold, 00124 op_INT_high_threshold, 00125 op_INT_out_of_window, 00126 } TOperatingMode; 00127 00128 /** 00129 * Device specific defines. To be adapted by implementer for the targeted 00130 * device. 00131 */ 00132 00133 /** use where fractional values are expected 00134 * 00135 * Given a floating point value f it's 16.16 bit point is (int)(f*(1<<16))*/ 00136 typedef uint32_t TFP1616; 00137 00138 /** @defgroup VL53L0X_DevSpecDefines_group VL53L0X cut1.1 Device Specific Defines 00139 * @brief VL53L0X cut1.1 Device Specific Defines 00140 * @{ 00141 */ 00142 00143 /** @defgroup VL53L0X_DeviceError_group Device Error 00144 * @brief Device Error code 00145 * 00146 * This enum is Device specific it should be updated in the implementation 00147 * Use @a VL53L0X_GetStatusErrorString() to get the string. 00148 * It is related to Status Register of the Device. 00149 * @{ 00150 */ 00151 typedef uint8_t TDevError; 00152 00153 #define VL53L0X_DEVICEERROR_NONE ((TDevError) 0) 00154 /*!< 0 NoError */ 00155 #define VL53L0X_DEVICEERROR_VCSELCONTINUITYTESTFAILURE ((TDevError) 1) 00156 #define VL53L0X_DEVICEERROR_VCSELWATCHDOGTESTFAILURE ((TDevError) 2) 00157 #define VL53L0X_DEVICEERROR_NOVHVVALUEFOUND ((TDevError) 3) 00158 #define VL53L0X_DEVICEERROR_MSRCNOTARGET ((TDevError) 4) 00159 #define VL53L0X_DEVICEERROR_SNRCHECK ((TDevError) 5) 00160 #define VL53L0X_DEVICEERROR_RANGEPHASECHECK ((TDevError) 6) 00161 #define VL53L0X_DEVICEERROR_SIGMATHRESHOLDCHECK ((TDevError) 7) 00162 #define VL53L0X_DEVICEERROR_TCC ((TDevError) 8) 00163 #define VL53L0X_DEVICEERROR_MINCLIP ((TDevError) 10) 00164 #define VL53L0X_DEVICEERROR_RANGECOMPLETE ((TDevError) 11) 00165 #define VL53L0X_DEVICEERROR_ALGOUNDERFLOW ((TDevError) 12) 00166 #define VL53L0X_DEVICEERROR_ALGOOVERFLOW ((TDevError) 13) 00167 #define VL53L0X_DEVICEERROR_RANGEIGNORETHRESHOLD ((TDevError) 14) 00168 00169 /** @} end of VL53L0X_DeviceError_group */ 00170 00171 00172 /** @defgroup VL53L0X_CHECKEN_group Check Enable list 00173 * @brief Check Enable code 00174 * 00175 * Define used to specify the LimitCheckId. 00176 * Use @a VL53L0X_GetLimitCheckInfo() to get the string. 00177 * @{ 00178 */ 00179 #define VL53L0X_CHECKEN_SIGMA_FINAL_RANGE 0 00180 #define VL53L0X_CHECKEN_SIG_RATE_FINAL_RANGE 1 00181 #define VL53L0X_CHECKEN_SIG_REF_CLIP 2 00182 #define VL53L0X_CHECKEN_RANGE_IGNORE_THRESHOLD 3 00183 #define VL53L0X_CHECKEN_SIG_RATE_MSRC 4 00184 #define VL53L0X_CHECKEN_SIG_RATE_PRE_RANGE 5 00185 #define VL53L0X_CHECKEN_NUMBER_OF_CHECKS 6 00186 /** @} end of VL53L0X_CHECKEN_group */ 00187 00188 00189 /** @defgroup GPIO_Func_group Gpio Functionality 00190 * @brief Defines the different functionalities for the device GPIO(s) 00191 * @{ */ 00192 typedef enum { 00193 GPIO_FUNC_OFF = 0, /*!< NO Interrupt */ 00194 GPIO_FUNC_THRESHOLD_CROSSED_LOW , /*!< Level Low (value < thresh_low) */ 00195 GPIO_FUNC_THRESHOLD_CROSSED_HIGH , /*!< Level High (value > thresh_high) */ 00196 GPIO_FUNC_THRESHOLD_CROSSED_OUT , /*!< Out Of Window (value < thresh_low OR value > thresh_high) */ 00197 GPIO_FUNC_NEW_MEASURE_READY /*!< New Sample Ready */ 00198 } TGPIO_Func ; 00199 /** @} end of GPIO_FUNC_group */ 00200 00201 00202 /* Device register map */ 00203 00204 /** @defgroup VL53L0X_DefineRegisters_group Define Registers 00205 * @brief List of all the defined registers 00206 * @{ 00207 */ 00208 #define REG_SYSRANGE_START 0x000 00209 /** mask existing bit in #REG_SYSRANGE_START*/ 00210 #define REG_SYSRANGE_MODE_MASK 0x0F 00211 /** bit 0 in #REG_SYSRANGE_START write 1 toggle state in 00212 * continuous mode and arm next shot in single shot mode */ 00213 #define REG_SYSRANGE_MODE_START_STOP 0x01 00214 /** bit 1 write 0 in #REG_SYSRANGE_START set single shot mode */ 00215 #define REG_SYSRANGE_MODE_SINGLESHOT 0x00 00216 /** bit 1 write 1 in #REG_SYSRANGE_START set back-to-back 00217 * operation mode */ 00218 #define REG_SYSRANGE_MODE_BACKTOBACK 0x02 00219 /** bit 2 write 1 in #REG_SYSRANGE_START set timed operation 00220 * mode */ 00221 #define REG_SYSRANGE_MODE_TIMED 0x04 00222 /** bit 3 write 1 in #REG_SYSRANGE_START set histogram operation 00223 * mode */ 00224 #define REG_SYSRANGE_MODE_HISTOGRAM 0x08 00225 00226 #define REG_SYSTEM_THRESH_HIGH 0x0C 00227 #define REG_SYSTEM_THRESH_LOW 0x0E 00228 #define REG_SYSTEM_SEQUENCE_CONFIG 0x01 00229 #define REG_SYSTEM_RANGE_CONFIG 0x09 00230 #define REG_SYSTEM_MEASURE_PERIOD 0x04 00231 00232 #define REG_SYSINT_CONFIG_GPIO 0x0A 00233 #define REG_SYSINT_GPIO_DISABLED 0x00 00234 #define REG_SYSINT_GPIO_LEVEL_LOW 0x01 00235 #define REG_SYSINT_GPIO_LEVEL_HIGH 0x02 00236 #define REG_SYSINT_GPIO_OUT_OF_WINDOW 0x03 00237 #define REG_SYSINT_GPIO_NEW_SAMPLE_READY 0x04 00238 00239 #define REG_GPIO_HV_MUX_ACTIVE_HIGH 0x84 00240 #define REG_SYSINT_CLEAR 0x0B 00241 00242 /* Result registers */ 00243 #define REG_RESULT_INTERRUPT_STATUS 0x13 00244 #define REG_RESULT_RANGE_STATUS 0x14 00245 00246 #define REG_RESULT_CORE_PAGE 1 00247 #define REG_RESULT_CORE_AMBIENT_WINDOW_EVENTS_RTN 0xBC 00248 #define REG_RESULT_CORE_RANGING_TOTAL_EVENTS_RTN 0xC0 00249 #define REG_RESULT_CORE_AMBIENT_WINDOW_EVENTS_REF 0xD0 00250 #define REG_RESULT_CORE_RANGING_TOTAL_EVENTS_REF 0xD4 00251 #define REG_RESULT_PEAK_SIG_RATE_REF 0xB6 00252 00253 /* Algo register */ 00254 #define REG_ALGO_PART_TO_PART_RANGE_OFFSET_MM 0x28 00255 #define REG_I2C_SLAVE_DEVICE_ADDRESS 0x8a 00256 00257 /* Check Limit registers */ 00258 #define REG_MSRC_CONFIG_CONTROL 0x60 00259 00260 #define REG_PRE_RANGE_CONFIG_MIN_SNR 0X27 00261 #define REG_PRE_RANGE_CONFIG_VALID_PHASE_LOW 0x56 00262 #define REG_PRE_RANGE_CONFIG_VALID_PHASE_HIGH 0x57 00263 #define REG_PRE_RANGE_MIN_COUNT_RATE_RTN_LIMIT 0x64 00264 00265 #define REG_FINAL_RANGE_CONFIG_MIN_SNR 0X67 00266 #define REG_FINAL_RANGE_CONFIG_VALID_PHASE_LOW 0x47 00267 #define REG_FINAL_RANGE_CONFIG_VALID_PHASE_HIGH 0x48 00268 #define REG_FINAL_RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT 0x44 00269 00270 #define REG_PRE_RANGE_CONFIG_SIGMA_THRESH_HI 0x61 00271 #define REG_PRE_RANGE_CONFIG_SIGMA_THRESH_LO 0x62 00272 00273 /* PRE RANGE registers */ 00274 #define REG_PRE_RANGE_CONFIG_VCSEL_PERIOD 0x50 00275 #define REG_PRE_RANGE_CONFIG_TIMEOUT_MACROP_HI 0x51 00276 #define REG_PRE_RANGE_CONFIG_TIMEOUT_MACROP_LO 0x52 00277 00278 #define REG_SYSTEM_HISTOGRAM_BIN 0x81 00279 #define REG_HISTOGRAM_CONFIG_INITIAL_PHASE_SELECT 0x33 00280 #define REG_HISTOGRAM_CONFIG_READOUT_CTRL 0x55 00281 00282 #define REG_FINAL_RANGE_CONFIG_VCSEL_PERIOD 0x70 00283 #define REG_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_HI 0x71 00284 #define REG_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_LO 0x72 00285 #define REG_XTALK_COMPENS_RATE_MHz 0x20 00286 00287 #define REG_MSRC_CONFIG_TIMEOUT_MACROP 0x46 00288 00289 #define REG_SOFT_RESET_GO2_SOFT_RESET_N 0xbf 00290 #define REG_IDENTIFICATION_MODEL_ID 0xc0 00291 #define REG_IDENTIFICATION_REVISION_ID 0xc2 00292 00293 #define REG_OSC_CALIBRATE_VAL 0xf8 00294 00295 #define VL53L0X_SIGMA_ESTIMATE_MAX_VALUE 0xffff 00296 /* equivalent to a range sigma of 655.35mm */ 00297 00298 #define REG_GLOBAL_CONFIG_VCSEL_WIDTH 0x32 00299 #define REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_0 0xB0 00300 #define REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_1 0xB1 00301 #define REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_2 0xB2 00302 #define REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_3 0xB3 00303 #define REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_4 0xB4 00304 #define REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_5 0xB5 00305 00306 #define REG_GLOBAL_CONFIG_REF_EN_START_SELECT 0xB6 00307 #define REG_DYNAMIC_SPAD_NUM_REQUESTED_REF_SPAD 0x4E 00308 #define REG_DYNAMIC_SPAD_REF_EN_START_OFFSET 0x4F 00309 #define REG_POWER_MANAGEMENT_GO1_POWER_FORCE 0x80 00310 00311 /* Speed of light in um per 1E-10 Seconds */ 00312 #define VL53L0X_SPEED_OF_LIGHT_IN_AIR 2997 00313 00314 #define REG_VHV_CONFIG_PAD_SCL_SDA__EXTSUP_HV 0x89 00315 00316 #define REG_ALGO_PHASECAL_LIM 0x30 00317 #define REG_ALGO_PHASECAL_CONFIG_TIMEOUT 0x30 00318 00319 /** @} VL53L0X_DefineRegisters_group */ 00320 00321 /** @} VL53L0X_DevSpecDefines_group */ 00322 00323 00324 /**************************************** 00325 * PRIVATE define do not edit 00326 ****************************************/ 00327 00328 /** @brief Defines the parameters of the Get Version Functions 00329 */ 00330 typedef struct { 00331 uint32_t revision; /*!< revision number */ 00332 uint8_t major; /*!< major number */ 00333 uint8_t minor; /*!< minor number */ 00334 uint8_t build; /*!< build number */ 00335 } VL53L0X_Version_t; 00336 00337 00338 /** @brief Defines the parameters of the Get Device Info Functions 00339 */ 00340 typedef struct { 00341 char Name[VL53L0X_MAX_STRING_LENGTH]; 00342 /*!< Name of the Device e.g. Left_Distance */ 00343 char Type[VL53L0X_MAX_STRING_LENGTH]; 00344 /*!< Type of the Device e.g VL53L0X */ 00345 char ProductId[VL53L0X_MAX_STRING_LENGTH]; 00346 /*!< Product Identifier String */ 00347 uint8_t ProductType; 00348 /*!< Product Type, VL53L0X = 1, VL53L1 = 2 */ 00349 uint8_t ProductRevisionMajor; 00350 /*!< Product revision major */ 00351 uint8_t ProductRevisionMinor; 00352 /*!< Product revision minor */ 00353 } TVL53L0X_DeviceInfo; 00354 00355 00356 typedef TVL53L0X_DeviceInfo* PVL53L0X_DeviceInfo; 00357 00358 /** @defgroup VL53L0X_define_Error_group Error and Warning code returned by API 00359 * The following DEFINE are used to identify the Device ERROR 00360 * @{ 00361 */ 00362 00363 typedef int8_t VL53L0X_Error; 00364 00365 #define VL53L0X_OK ((VL53L0X_Error) 0) 00366 #define VL53L0X_ERROR_CALIBRATION_WARNING ((VL53L0X_Error) -1) 00367 /*!< Warning invalid calibration data may be in used 00368 \a VL53L0X_InitData() 00369 \a VL53L0X_GetOffsetCalibrationData 00370 \a VL53L0X_SetOffsetCalibrationData */ 00371 #define VL53L0X_ERROR_MIN_CLIPPED ((VL53L0X_Error) -2) 00372 /*!< Warning parameter passed was clipped to min before to be applied */ 00373 #define VL53L0X_ERROR_UNDEFINED ((VL53L0X_Error) -3) 00374 /*!< Unqualified error */ 00375 #define VL53L0X_ERROR_INVALID_PARAMS ((VL53L0X_Error) -4) 00376 /*!< Parameter passed is invalid or out of range */ 00377 #define VL53L0X_ERROR_NOT_SUPPORTED ((VL53L0X_Error) -5) 00378 /*!< Function is not supported in current mode or configuration */ 00379 #define VL53L0X_ERROR_RANGE_ERROR ((VL53L0X_Error) -6) 00380 /*!< Device report a ranging error interrupt status */ 00381 #define VL53L0X_ERROR_TIME_OUT ((VL53L0X_Error) -7) 00382 /*!< Aborted due to time out */ 00383 #define VL53L0X_ERROR_MODE_NOT_SUPPORTED ((VL53L0X_Error) -8) 00384 /*!< Asked mode is not supported by the device */ 00385 #define VL53L0X_ERROR_BUFFER_TOO_SMALL ((VL53L0X_Error) -9) 00386 /*!< ... */ 00387 #define VL53L0X_ERROR_GPIO_NOT_EXISTING ((VL53L0X_Error) -10) 00388 /*!< User tried to setup a non-existing GPIO pin */ 00389 #define VL53L0X_ERROR_GPIO_FUNC_NOT_SUPPORTED ((VL53L0X_Error) -11) 00390 /*!< unsupported GPIO functionality */ 00391 #define VL53L0X_ERROR_INTERRUPT_NOT_CLEARED ((VL53L0X_Error) -12) 00392 /*!< Error during interrupt clear */ 00393 #define VL53L0X_ERROR_CONTROL_INTERFACE ((VL53L0X_Error) -20) 00394 #define VL53L0X_ERROR_I2C_BUF_OVERFLOW ((VL53L0X_Error) -22) 00395 #define VL53L0X_ERROR_I2C_WRONG_DEV_ID ((VL53L0X_Error) -23) 00396 /*!< error reported from IO functions */ 00397 #define VL53L0X_ERROR_INVALID_COMMAND ((VL53L0X_Error) -30) 00398 /*!< The command is not allowed in the current device state (power down) */ 00399 #define VL53L0X_ERROR_DIVISION_BY_ZERO ((VL53L0X_Error) -40) 00400 /*!< In the function a division by zero occurs */ 00401 #define VL53L0X_ERROR_REF_SPAD_INIT ((VL53L0X_Error) -50) 00402 /*!< Error during reference SPAD initialization */ 00403 #define VL53L0X_ERROR_NOT_IMPLEMENTED ((VL53L0X_Error) -99) 00404 /*!< Tells requested functionality has not been implemented yet or 00405 * not compatible with the device */ 00406 /** @} VL53L0X_define_Error_group */ 00407 00408 00409 /** @defgroup VL53L0X_define_DeviceModes_group Defines Device modes 00410 * Defines all possible modes for the device 00411 * @{ 00412 */ 00413 typedef uint8_t VL53L0X_DeviceModes; 00414 00415 #define VL53L0X_DEVICEMODE_SINGLE_RANGING ((VL53L0X_DeviceModes) 0) 00416 #define VL53L0X_DEVICEMODE_CONTINUOUS_RANGING ((VL53L0X_DeviceModes) 1) 00417 #define VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM ((VL53L0X_DeviceModes) 2) 00418 #define VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING ((VL53L0X_DeviceModes) 3) 00419 #define VL53L0X_DEVICEMODE_SINGLE_ALS ((VL53L0X_DeviceModes) 10) 00420 #define VL53L0X_DEVICEMODE_GPIO_DRIVE ((VL53L0X_DeviceModes) 20) 00421 #define VL53L0X_DEVICEMODE_GPIO_OSC ((VL53L0X_DeviceModes) 21) 00422 /* ... Modes to be added depending on device */ 00423 /** @} VL53L0X_define_DeviceModes_group */ 00424 00425 /** @defgroup VL53L0X_define_HistogramModes_group Defines Histogram modes 00426 * Defines all possible Histogram modes for the device 00427 * @{ 00428 */ 00429 typedef uint8_t VL53L0X_HistogramModes; 00430 00431 #define VL53L0X_HISTOGRAMMODE_DISABLED ((VL53L0X_HistogramModes) 0) 00432 /*!< Histogram Disabled */ 00433 #define VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY ((VL53L0X_HistogramModes) 1) 00434 /*!< Histogram Reference array only */ 00435 #define VL53L0X_HISTOGRAMMODE_RETURN_ONLY ((VL53L0X_HistogramModes) 2) 00436 /*!< Histogram Return array only */ 00437 #define VL53L0X_HISTOGRAMMODE_BOTH ((VL53L0X_HistogramModes) 3) 00438 /*!< Histogram both Reference and Return Arrays */ 00439 /* ... Modes to be added depending on device */ 00440 /** @} VL53L0X_define_HistogramModes_group */ 00441 00442 00443 /** @defgroup VL53L0X_define_PowerModes_group List of available Power Modes 00444 * List of available Power Modes 00445 * @{ 00446 */ 00447 00448 typedef uint8_t VL53L0X_PowerModes; 00449 00450 #define VL53L0X_POWERMODE_STANDBY_LEVEL1 ((VL53L0X_PowerModes) 0) 00451 /*!< Standby level 1 */ 00452 #define VL53L0X_POWERMODE_STANDBY_LEVEL2 ((VL53L0X_PowerModes) 1) 00453 /*!< Standby level 2 */ 00454 #define VL53L0X_POWERMODE_IDLE_LEVEL1 ((VL53L0X_PowerModes) 2) 00455 /*!< Idle level 1 */ 00456 #define VL53L0X_POWERMODE_IDLE_LEVEL2 ((VL53L0X_PowerModes) 3) 00457 /*!< Idle level 2 */ 00458 00459 /** @} VL53L0X_define_PowerModes_group */ 00460 00461 /** @brief Defines all parameters for the device 00462 */ 00463 typedef struct { 00464 VL53L0X_DeviceModes DeviceMode; 00465 /*!< Defines type of measurement to be done for the next measure */ 00466 VL53L0X_HistogramModes HistogramMode; 00467 /*!< Defines type of histogram measurement to be done for the next 00468 * measure */ 00469 uint32_t Measure_Time_Budget_us; // was MeasurementTimingBudget_us 00470 /*!< Defines the allowed total time for a single measurement */ 00471 uint32_t Measure_Period_ms; 00472 /*!< Defines time between two consecutive measurements (between two 00473 * measurement starts). If set to 0 means back-to-back mode */ 00474 uint8_t XTalk_Compens_En; 00475 /*!< Tells if Crosstalk compensation shall be enable or not */ 00476 uint16_t XTalkCompensationRangeMilliMeter; 00477 /*!< CrossTalk compensation range in millimeter */ 00478 TFP1616 Xtalk_CompRate_MHz; 00479 /*!< CrossTalk compensation rate in Mega counts per seconds. 00480 * Expressed in 16.16 fixed point format. */ 00481 int32_t Offset_Cal_um; 00482 /*!< Range offset adjustment (um) last programmed. */ 00483 00484 uint8_t Limit_Chk_En[VL53L0X_CHECKEN_NUMBER_OF_CHECKS]; 00485 /*!< This Array store all the Limit Check enable for this device. */ 00486 uint8_t LimitChecksStatus[VL53L0X_CHECKEN_NUMBER_OF_CHECKS]; 00487 /*!< This Array store all the Status of the check linked to last 00488 * measurement. */ 00489 TFP1616 Limit_Chk_Val[VL53L0X_CHECKEN_NUMBER_OF_CHECKS]; 00490 /*!< This Array store all the Limit Check value for this device */ 00491 uint8_t Wrap_Around_Chk_En; 00492 /*!< Tells if Wrap Around Check shall be enable or not */ 00493 } VL53L0X_DeviceParams_t; 00494 00495 00496 /** @defgroup VL53L0X_define_State_group Defines the current status of the device 00497 * Defines the current status of the device 00498 * @{ 00499 */ 00500 typedef uint8_t VL53L0X_State; 00501 00502 #define VL53L0X_STATE_POWERDOWN ((VL53L0X_State) 0) 00503 /*!< Device is in HW reset */ 00504 #define VL53L0X_STATE_WAIT_STATICINIT ((VL53L0X_State) 1) 00505 /*!< Device is initialized and wait for static initialization */ 00506 #define VL53L0X_STATE_STANDBY ((VL53L0X_State) 2) 00507 /*!< Device is in Low power Standby mode */ 00508 #define VL53L0X_STATE_IDLE ((VL53L0X_State) 3) 00509 /*!< Device has been initialized and ready to do measurements */ 00510 #define VL53L0X_STATE_RUNNING ((VL53L0X_State) 4) 00511 /*!< Device is performing measurement */ 00512 #define VL53L0X_STATE_UNKNOWN ((VL53L0X_State) 98) 00513 /*!< Device is in unknown state and need to be rebooted */ 00514 #define VL53L0X_STATE_ERROR ((VL53L0X_State) 99) 00515 /*!< Device is in error state and need to be rebooted */ 00516 /** @} VL53L0X_define_State_group */ 00517 00518 00519 /** @brief Structure containing the Dmax computation parameters and data 00520 */ 00521 typedef struct { 00522 int32_t AmbTuningWindowFactor_K; 00523 /*!< internal algo tuning (*1000) */ 00524 int32_t RetSignalAt0mm; 00525 /*!< intermediate dmax computation value caching */ 00526 } VL53L0X_DMaxData_t; 00527 00528 /** 00529 * @struct VL53L0X_RangeData_t 00530 * @brief Range measurement data. 00531 */ 00532 typedef struct { 00533 uint32_t TimeStamp; /*!< 32-bit time stamp. */ 00534 uint32_t MeasurementTimeUsec; 00535 /*!< Give the Measurement time needed by the device to do the measurement.*/ 00536 00537 uint16_t RangeMilliMeter; /*!< range distance in millimeter. */ 00538 00539 uint16_t RangeDMaxMilliMeter; 00540 /*!< Tells what is the maximum detection distance of the device 00541 * in current setup and environment conditions (Filled when 00542 * applicable) */ 00543 00544 TFP1616 SignalRateRtnMHz; 00545 /*!< Return signal rate (MHz)\n these is a 16.16 fix point 00546 * value, which is effectively a measure of target 00547 * reflectance.*/ 00548 TFP1616 AmbientRateRtnMHz; 00549 /*!< Return ambient rate (MHz)\n these is a 16.16 fix point 00550 * value, which is effectively a measure of the ambien 00551 * t light.*/ 00552 00553 uint16_t EffectiveSPADRtnCount; 00554 /*!< Return the effective SPAD count for the return signal. 00555 * To obtain Real value it should be divided by 256 */ 00556 00557 uint8_t ZoneId; 00558 /*!< Denotes which zone and range scheduler stage the range 00559 * data relates to. */ 00560 uint8_t RangeFractionalPart; 00561 /*!< Fractional part of range distance. Final value is a 00562 * FixPoint168 value. */ 00563 uint8_t RangeStatus; 00564 /*!< Range Status for the current measurement. This is device 00565 * dependent. Value = 0 means value is valid. 00566 * See \ref RangeStatusPage */ 00567 } TRangeResults; // was VL53L0X_RangingMeasurementData_t 00568 00569 00570 #define VL53L0X_HISTOGRAM_BUFFER_SIZE 24 00571 00572 /** 00573 * @struct VL53L0X_HistogramData_t 00574 * @brief Histogram measurement data. 00575 */ 00576 typedef struct { /* Histogram Measurement data */ 00577 uint32_t HistogramData[VL53L0X_HISTOGRAM_BUFFER_SIZE]; 00578 /*!< Histogram data */ 00579 uint8_t HistogramType; /*!< Indicate the types of histogram data : 00580 Return only, Reference only, both Return and Reference */ 00581 uint8_t FirstBin; /*!< First Bin value */ 00582 uint8_t BufferSize; /*!< Buffer Size - Set by the user.*/ 00583 uint8_t NumberOfBins;/*!< Number of bins filled by the histogram measurement */ 00584 TDevError ErrorStatus; 00585 /*!< Error status of the current measurement. \n 00586 see @a ::TDevError @a VL53L0X_GetStatusErrorString() */ 00587 } VL53L0X_HistogramMeasurementData_t; 00588 00589 #define VL53L0X_PLL_PERIOD_PS = 1655; 00590 #define VL53L0X_MACRO_PERIOD_VCLKS = 2304; 00591 00592 /** 00593 * @struct VL53L0X_SPADData_t 00594 * @brief SPAD Configuration Data. 00595 */ 00596 #define REF_SPAD_ARRAY_SIZE 6 00597 00598 typedef struct { 00599 uint8_t RefSPADEnables[REF_SPAD_ARRAY_SIZE]; 00600 /*!< Reference SPAD Enables */ 00601 uint8_t RefGoodSPADMap[REF_SPAD_ARRAY_SIZE]; 00602 /*!< Reference SPAD Good SPAD Map */ 00603 } VL53L0X_SPADData_t; 00604 00605 00606 /** @defgroup VL53L0X_define_InterruptPolarity_group Defines the Polarity 00607 * of the Interrupt 00608 * Defines the Polarity of the Interrupt 00609 * @{ 00610 */ 00611 typedef uint8_t VL53L0X_InterruptPolarity; 00612 #define VL53L0X_INTERRUPTPOLARITY_LOW ((VL53L0X_InterruptPolarity) 0) 00613 /*!< Set active low polarity best setup for falling edge. */ 00614 #define VL53L0X_INTERRUPTPOLARITY_HIGH ((VL53L0X_InterruptPolarity) 1) 00615 /*!< Set active high polarity best setup for rising edge. */ 00616 00617 /** @} VL53L0X_define_InterruptPolarity_group */ 00618 00619 00620 /** @defgroup VL53L0X_define_VcselPeriod_group Vcsel Period Defines 00621 * Defines the range measurement for which to access the vcsel Phase. 00622 * @{ 00623 */ 00624 typedef uint8_t VL53L0X_Range_Phase; 00625 00626 #define VL53L0X_VCSEL_PRE_RANGE ((VL53L0X_Range_Phase) 0) 00627 /*!<Identifies the pre-range vcsel Phase. */ 00628 #define VL53L0X_VCSEL_FINAL_RANGE ((VL53L0X_Range_Phase) 1) 00629 /*!<Identifies the final range vcsel Phase . */ 00630 00631 /** @} VL53L0X_define_VcselPeriod_group */ 00632 00633 /** @defgroup VL53L0X_define_SchedulerSequence_group Defines the steps 00634 * carried out by the scheduler during a range measurement. 00635 * @{ 00636 * Defines the states of all the steps in the scheduler 00637 * i.e. enabled/disabled. 00638 */ 00639 typedef struct { 00640 uint8_t TccOn; /*!<Reports if Target Centre Check On */ 00641 uint8_t MsrcOn; /*!<Reports if MSRC On */ 00642 uint8_t DssOn; /*!<Reports if DSS On */ 00643 uint8_t PreRangeOn; /*!<Reports if Pre-Range On */ 00644 uint8_t FinalRangeOn; /*!<Reports if Final-Range On */ 00645 } VL53L0X_Sequence_Steps_t; 00646 00647 /** @} VL53L0X_define_SchedulerSequence_group */ 00648 00649 /** @defgroup VL53L0X_define_SequenceStepId_group Defines the Polarity 00650 * of the Interrupt 00651 * Defines the the sequence steps performed during ranging.. 00652 * @{ 00653 */ 00654 typedef uint8_t VL53L0X_SequenceStepId; 00655 00656 #define VL53L0X_SEQUENCESTEP_TCC ((VL53L0X_SequenceStepId) 0) 00657 /*!<Target CentreCheck identifier. */ 00658 #define VL53L0X_SEQUENCESTEP_DSS ((VL53L0X_SequenceStepId) 1) 00659 /*!<Dynamic SPAD Selection function Identifier. */ 00660 #define VL53L0X_SEQUENCESTEP_MSRC ((VL53L0X_SequenceStepId) 2) 00661 /*!<Minimum Signal Rate Check function Identifier. */ 00662 #define VL53L0X_SEQUENCESTEP_PRE_RANGE ((VL53L0X_SequenceStepId) 3) 00663 /*!<Pre-Range check Identifier. */ 00664 #define VL53L0X_SEQUENCESTEP_FINAL_RANGE ((VL53L0X_SequenceStepId) 4) 00665 /*!<Final Range Check Identifier. */ 00666 00667 #define VL53L0X_SEQUENCESTEP_NUMBER_OF_CHECKS 5 00668 /*!<Number of Sequence Step Managed by the API. */ 00669 00670 /** @} VL53L0X_define_SequenceStepId_group */ 00671 00672 /* MACRO Definitions */ 00673 /** @defgroup VL53L0X_define_GeneralMacro_group General Macro Defines 00674 * General Macro Defines 00675 * @{ 00676 */ 00677 00678 /* Defines */ 00679 #define FP1616_TO_FP97(Value) (uint16_t)((Value>>9)&0xFFFF) 00680 #define FP97_TO_FP1616(Value) (TFP1616)(Value<<9) 00681 00682 #define FP1616_TO_FP88(Value) (uint16_t)((Value>>8)&0xFFFF) 00683 #define FP88_TO_FP1616(Value) (TFP1616)(Value<<8) 00684 00685 #define FP1616_TO_FP412(Value) (uint16_t)((Value>>4)&0xFFFF) 00686 #define FP412_TO_FP1616(Value) (TFP1616)(Value<<4) 00687 00688 #define FP1616_TO_FP313(Value) (uint16_t)((Value>>3)&0xFFFF) 00689 #define FP313_TO_FP1616(Value) (TFP1616)(Value<<3) 00690 00691 #define FP1616_TO_FP08(Value) (uint8_t)((Value>>8)&0x00FF) 00692 #define FP08_TO_FP1616(Value) (TFP1616)(Value<<8) 00693 00694 #define FP1616_TO_FP53(Value) (uint8_t)((Value>>13)&0x00FF) 00695 #define FP53_TO_FP1616(Value) (TFP1616)(Value<<13) 00696 00697 #define FP1616_TO_FP102(Value) (uint16_t)((Value>>14)&0x0FFF) 00698 #define FP102_TO_FP1616(Value) (TFP1616)(Value<<12) 00699 00700 #define VL53L0X_MAKEUINT16(lsb, msb) (uint16_t)((((uint16_t)msb)<<8) + (uint16_t)lsb) 00701 00702 /** @} VL53L0X_define_GeneralMacro_group */ 00703 00704 /** @} VL53L0X_globaldefine_group */ 00705 00706 #ifdef __cplusplus 00707 } 00708 #endif 00709 00710 #endif /* _VL53L0X_DEF_H_ */
Generated on Mon Jul 18 2022 17:03:18 by 1.7.2