Working version without LEDs

Dependencies:   mbed WS2812

Voici le dernier schéma de cablage (version du 08/02/2020)

https://os.mbed.com/media/uploads/max_ence/schemarobot_fev2020.pdf

Committer:
elab
Date:
Sat May 30 09:31:57 2020 +0000
Revision:
1:69b5d8f0ba9c
Parent:
0:0e577ce96b2f
pour eLab;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elab 0:0e577ce96b2f 1 /*******************************************************************************
elab 0:0e577ce96b2f 2 Copyright © 2016, STMicroelectronics International N.V.
elab 0:0e577ce96b2f 3 All rights reserved.
elab 0:0e577ce96b2f 4
elab 0:0e577ce96b2f 5 Redistribution and use in source and binary forms, with or without
elab 0:0e577ce96b2f 6 modification, are permitted provided that the following conditions are met:
elab 0:0e577ce96b2f 7 * Redistributions of source code must retain the above copyright
elab 0:0e577ce96b2f 8 notice, this list of conditions and the following disclaimer.
elab 0:0e577ce96b2f 9 * Redistributions in binary form must reproduce the above copyright
elab 0:0e577ce96b2f 10 notice, this list of conditions and the following disclaimer in the
elab 0:0e577ce96b2f 11 documentation and/or other materials provided with the distribution.
elab 0:0e577ce96b2f 12 * Neither the name of STMicroelectronics nor the
elab 0:0e577ce96b2f 13 names of its contributors may be used to endorse or promote products
elab 0:0e577ce96b2f 14 derived from this software without specific prior written permission.
elab 0:0e577ce96b2f 15
elab 0:0e577ce96b2f 16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
elab 0:0e577ce96b2f 17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
elab 0:0e577ce96b2f 18 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
elab 0:0e577ce96b2f 19 NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
elab 0:0e577ce96b2f 20 IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
elab 0:0e577ce96b2f 21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
elab 0:0e577ce96b2f 22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
elab 0:0e577ce96b2f 23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
elab 0:0e577ce96b2f 24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
elab 0:0e577ce96b2f 25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
elab 0:0e577ce96b2f 26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
elab 0:0e577ce96b2f 27 *******************************************************************************/
elab 0:0e577ce96b2f 28
elab 0:0e577ce96b2f 29 /**
elab 0:0e577ce96b2f 30 * @file VL53L0X_def.h
elab 0:0e577ce96b2f 31 *
elab 0:0e577ce96b2f 32 * @brief Type definitions for VL53L0X API. */
elab 0:0e577ce96b2f 33
elab 0:0e577ce96b2f 34 #ifndef _VL53L0X_DEF_H_
elab 0:0e577ce96b2f 35 #define _VL53L0X_DEF_H_
elab 0:0e577ce96b2f 36
elab 0:0e577ce96b2f 37 #ifdef __cplusplus
elab 0:0e577ce96b2f 38 extern "C" {
elab 0:0e577ce96b2f 39 #endif
elab 0:0e577ce96b2f 40
elab 0:0e577ce96b2f 41 /** @defgroup VL53L0X_globaldefine_group VL53L0X Defines
elab 0:0e577ce96b2f 42 * @brief VL53L0X Defines
elab 0:0e577ce96b2f 43 * @{ */
elab 0:0e577ce96b2f 44 /** PAL SPECIFICATION major version */
elab 0:0e577ce96b2f 45 #define VL53L0X10_SPECIFICATION_VER_MAJOR 1
elab 0:0e577ce96b2f 46 /** PAL SPECIFICATION minor version */
elab 0:0e577ce96b2f 47 #define VL53L0X10_SPECIFICATION_VER_MINOR 2
elab 0:0e577ce96b2f 48 /** PAL SPECIFICATION sub version */
elab 0:0e577ce96b2f 49 #define VL53L0X10_SPECIFICATION_VER_SUB 7
elab 0:0e577ce96b2f 50 /** PAL SPECIFICATION sub version */
elab 0:0e577ce96b2f 51 #define VL53L0X10_SPECIFICATION_VER_REVISION 1440
elab 0:0e577ce96b2f 52
elab 0:0e577ce96b2f 53 /** VL53L0X PAL IMPLEMENTATION major version */
elab 0:0e577ce96b2f 54 #define VL53L0X10_IMPLEMENTATION_VER_MAJOR 1
elab 0:0e577ce96b2f 55 /** VL53L0X PAL IMPLEMENTATION minor version */
elab 0:0e577ce96b2f 56 #define VL53L0X10_IMPLEMENTATION_VER_MINOR 0
elab 0:0e577ce96b2f 57 /** VL53L0X PAL IMPLEMENTATION sub version */
elab 0:0e577ce96b2f 58 #define VL53L0X10_IMPLEMENTATION_VER_SUB 9
elab 0:0e577ce96b2f 59 /** VL53L0X PAL IMPLEMENTATION sub version */
elab 0:0e577ce96b2f 60 #define VL53L0X10_IMPLEMENTATION_VER_REVISION 3673
elab 0:0e577ce96b2f 61
elab 0:0e577ce96b2f 62 /** PAL SPECIFICATION major version */
elab 0:0e577ce96b2f 63 #define VL53L0X_SPECIFICATION_VER_MAJOR 1
elab 0:0e577ce96b2f 64 /** PAL SPECIFICATION minor version */
elab 0:0e577ce96b2f 65 #define VL53L0X_SPECIFICATION_VER_MINOR 2
elab 0:0e577ce96b2f 66 /** PAL SPECIFICATION sub version */
elab 0:0e577ce96b2f 67 #define VL53L0X_SPECIFICATION_VER_SUB 7
elab 0:0e577ce96b2f 68 /** PAL SPECIFICATION sub version */
elab 0:0e577ce96b2f 69 #define VL53L0X_SPECIFICATION_VER_REVISION 1440
elab 0:0e577ce96b2f 70
elab 0:0e577ce96b2f 71 /** VL53L0X PAL IMPLEMENTATION major version */
elab 0:0e577ce96b2f 72 #define VL53L0X_IMPLEMENTATION_VER_MAJOR 1
elab 0:0e577ce96b2f 73 /** VL53L0X PAL IMPLEMENTATION minor version */
elab 0:0e577ce96b2f 74 #define VL53L0X_IMPLEMENTATION_VER_MINOR 1
elab 0:0e577ce96b2f 75 /** VL53L0X PAL IMPLEMENTATION sub version */
elab 0:0e577ce96b2f 76 #define VL53L0X_IMPLEMENTATION_VER_SUB 21
elab 0:0e577ce96b2f 77 /** VL53L0X PAL IMPLEMENTATION sub version */
elab 0:0e577ce96b2f 78 #define VL53L0X_IMPLEMENTATION_VER_REVISION 4823
elab 0:0e577ce96b2f 79
elab 0:0e577ce96b2f 80 /** FixPoint1616_t is used where fractional values are needed
elab 0:0e577ce96b2f 81 * Given a floating point value f it's .16 bit point is (int)(f*(1<<16))*/
elab 0:0e577ce96b2f 82 typedef uint32_t FixPoint1616_t;
elab 0:0e577ce96b2f 83 #define VL53L0X_FP1616TOFP97(Value) (uint16_t)((Value>>9)&0xFFFF)
elab 0:0e577ce96b2f 84 #define VL53L0X_FP97TOFP1616(Value) (FixPoint1616_t)(Value<<9)
elab 0:0e577ce96b2f 85 #define VL53L0X_FP1616TOFP88(Value) (uint16_t)((Value>>8)&0xFFFF)
elab 0:0e577ce96b2f 86 #define VL53L0X_FP88TOFP1616(Value) (FixPoint1616_t)(Value<<8)
elab 0:0e577ce96b2f 87 #define VL53L0X_FP1616TOFP412(Value) (uint16_t)((Value>>4)&0xFFFF)
elab 0:0e577ce96b2f 88 #define VL53L0X_FP412TOFP1616(Value) (FixPoint1616_t)(Value<<4)
elab 0:0e577ce96b2f 89 #define VL53L0X_FP1616TOFP313(Value) (uint16_t)((Value>>3)&0xFFFF)
elab 0:0e577ce96b2f 90 #define VL53L0X_FP313TOFP1616(Value) (FixPoint1616_t)(Value<<3)
elab 0:0e577ce96b2f 91 #define VL53L0X_FP1616TOFP08(Value) (uint8_t)((Value>>8)&0x00FF)
elab 0:0e577ce96b2f 92 #define VL53L0X_FP08TOFP1616(Value) (FixPoint1616_t)(Value<<8)
elab 0:0e577ce96b2f 93 #define VL53L0X_FP1616TOFP53(Value) (uint8_t)((Value>>13)&0x00FF)
elab 0:0e577ce96b2f 94 #define VL53L0X_FP53TOFP1616(Value) (FixPoint1616_t)(Value<<13)
elab 0:0e577ce96b2f 95 #define VL53L0X_FP1616TOFP102(Value) (uint16_t)((Value>>14)&0x0FFF)
elab 0:0e577ce96b2f 96 #define VL53L0X_FP102TOFP1616(Value) (FixPoint1616_t)(Value<<12)
elab 0:0e577ce96b2f 97 #define VL53L0X_MAKEUINT16(lsb, msb) (uint16_t)((((uint16_t)msb)<<8) + (uint16_t)lsb)
elab 0:0e577ce96b2f 98
elab 0:0e577ce96b2f 99
elab 0:0e577ce96b2f 100 /** The device model ID */
elab 0:0e577ce96b2f 101 #define IDENTIFICATION_MODEL_ID 0x000
elab 0:0e577ce96b2f 102
elab 0:0e577ce96b2f 103 #define VL53L0X_OsDelay(...) wait_ms(2) // 2 msec delay. can also use wait(float secs)/wait_us(int)
elab 0:0e577ce96b2f 104
elab 0:0e577ce96b2f 105 /** Maximum buffer size to be used in i2c */
elab 0:0e577ce96b2f 106 #define VL53L0X_MAX_I2C_XFER_SIZE 64
elab 0:0e577ce96b2f 107
elab 0:0e577ce96b2f 108 #define VL53L0X_COPYSTRING(str, ...) strcpy(str, ##__VA_ARGS__)
elab 0:0e577ce96b2f 109
elab 0:0e577ce96b2f 110 /* Speed of light in um per 1E-10 Seconds */
elab 0:0e577ce96b2f 111 #define VL53L0X_SPEED_OF_LIGHT_IN_AIR 2997
elab 0:0e577ce96b2f 112
elab 0:0e577ce96b2f 113 /** default device address */
elab 0:0e577ce96b2f 114 #define VL53L0X_DEFAULT_ADDRESS 0x52 /* (8-bit) */
elab 0:0e577ce96b2f 115
elab 0:0e577ce96b2f 116 #define VL53L0X_DEFAULT_MAX_LOOP 2000
elab 0:0e577ce96b2f 117
elab 0:0e577ce96b2f 118 #define VL53L0X_MAX_STRING_LENGTH 32
elab 0:0e577ce96b2f 119
elab 0:0e577ce96b2f 120 /* equivalent to a range sigma of 655.35mm */
elab 0:0e577ce96b2f 121 #define VL53L0X_SIGMA_ESTIMATE_MAX_VALUE 65535
elab 0:0e577ce96b2f 122
elab 0:0e577ce96b2f 123 #define REF_ARRAY_SPAD_0 0
elab 0:0e577ce96b2f 124 #define REF_ARRAY_SPAD_5 5
elab 0:0e577ce96b2f 125 #define REF_ARRAY_SPAD_10 10
elab 0:0e577ce96b2f 126
elab 0:0e577ce96b2f 127 static uint32_t refArrayQuadrants[4] = {REF_ARRAY_SPAD_10, REF_ARRAY_SPAD_5,
elab 0:0e577ce96b2f 128 REF_ARRAY_SPAD_0, REF_ARRAY_SPAD_5 };
elab 0:0e577ce96b2f 129
elab 0:0e577ce96b2f 130 #define VL53L0X_STRING_DEVICE_INFO_NAME "VL53L0X cut1.0"
elab 0:0e577ce96b2f 131 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS0 "VL53L0X TS0"
elab 0:0e577ce96b2f 132 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS1 "VL53L0X TS1"
elab 0:0e577ce96b2f 133 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS2 "VL53L0X TS2"
elab 0:0e577ce96b2f 134 #define VL53L0X_STRING_DEVICE_INFO_NAME_ES1 "VL53L0X ES1 or later"
elab 0:0e577ce96b2f 135 #define VL53L0X_STRING_DEVICE_INFO_TYPE "VL53L0X"
elab 0:0e577ce96b2f 136
elab 0:0e577ce96b2f 137 /* sensor operating modes */
elab 0:0e577ce96b2f 138 typedef enum {
elab 0:0e577ce96b2f 139 range_single_shot_polling = 1,
elab 0:0e577ce96b2f 140 range_continuous_polling,
elab 0:0e577ce96b2f 141 range_continuous_interrupt,
elab 0:0e577ce96b2f 142 range_continuous_polling_low_threshold,
elab 0:0e577ce96b2f 143 range_continuous_polling_high_threshold,
elab 0:0e577ce96b2f 144 range_continuous_polling_out_of_window,
elab 0:0e577ce96b2f 145 range_continuous_interrupt_low_threshold,
elab 0:0e577ce96b2f 146 range_continuous_interrupt_high_threshold,
elab 0:0e577ce96b2f 147 range_continuous_interrupt_out_of_window,
elab 0:0e577ce96b2f 148 } OperatingMode;
elab 0:0e577ce96b2f 149
elab 0:0e577ce96b2f 150 /** @defgroup VL53L0X_DeviceError_group Device Error
elab 0:0e577ce96b2f 151 * @brief Device Error code
elab 0:0e577ce96b2f 152 *
elab 0:0e577ce96b2f 153 * This enum is Device specific it should be updated in the implementation
elab 0:0e577ce96b2f 154 * Use @a VL53L0X_GetStatusErrorString() to get the string.
elab 0:0e577ce96b2f 155 * It is related to Status Register of the Device.
elab 0:0e577ce96b2f 156 * @{ */
elab 0:0e577ce96b2f 157 typedef uint8_t VL53L0X_DeviceError;
elab 0:0e577ce96b2f 158 #define VL53L0X_DEVICEERROR_NONE ((VL53L0X_DeviceError) 0) /*!< 0 NoError */
elab 0:0e577ce96b2f 159 #define VL53L0X_DEVICEERROR_VCSELCONTINUITYTESTFAILURE ((VL53L0X_DeviceError) 1)
elab 0:0e577ce96b2f 160 #define VL53L0X_DEVICEERROR_VCSELWATCHDOGTESTFAILURE ((VL53L0X_DeviceError) 2)
elab 0:0e577ce96b2f 161 #define VL53L0X_DEVICEERROR_NOVHVVALUEFOUND ((VL53L0X_DeviceError) 3)
elab 0:0e577ce96b2f 162 #define VL53L0X_DEVICEERROR_MSRCNOTARGET ((VL53L0X_DeviceError) 4)
elab 0:0e577ce96b2f 163 #define VL53L0X_DEVICEERROR_SNRCHECK ((VL53L0X_DeviceError) 5)
elab 0:0e577ce96b2f 164 #define VL53L0X_DEVICEERROR_RANGEPHASECHECK ((VL53L0X_DeviceError) 6)
elab 0:0e577ce96b2f 165 #define VL53L0X_DEVICEERROR_SIGMATHRESHOLDCHECK ((VL53L0X_DeviceError) 7)
elab 0:0e577ce96b2f 166 #define VL53L0X_DEVICEERROR_TCC ((VL53L0X_DeviceError) 8)
elab 0:0e577ce96b2f 167 #define VL53L0X_DEVICEERROR_PHASECONSISTENCY ((VL53L0X_DeviceError) 9)
elab 0:0e577ce96b2f 168 #define VL53L0X_DEVICEERROR_MINCLIP ((VL53L0X_DeviceError) 10)
elab 0:0e577ce96b2f 169 #define VL53L0X_DEVICEERROR_RANGECOMPLETE ((VL53L0X_DeviceError) 11)
elab 0:0e577ce96b2f 170 #define VL53L0X_DEVICEERROR_ALGOUNDERFLOW ((VL53L0X_DeviceError) 12)
elab 0:0e577ce96b2f 171 #define VL53L0X_DEVICEERROR_ALGOOVERFLOW ((VL53L0X_DeviceError) 13)
elab 0:0e577ce96b2f 172 #define VL53L0X_DEVICEERROR_RANGEIGNORETHRESHOLD ((VL53L0X_DeviceError) 14)
elab 0:0e577ce96b2f 173 /** @} end of VL53L0X_DeviceError_group */
elab 0:0e577ce96b2f 174
elab 0:0e577ce96b2f 175
elab 0:0e577ce96b2f 176 /* PAL ERROR strings */
elab 0:0e577ce96b2f 177 #define VL53L0X_STRING_ERROR_NONE "No Error"
elab 0:0e577ce96b2f 178 #define VL53L0X_STRING_ERROR_CALIBRATION_WARNING "Calibration Warning Error"
elab 0:0e577ce96b2f 179 #define VL53L0X_STRING_ERROR_MIN_CLIPPED "Min clipped error"
elab 0:0e577ce96b2f 180 #define VL53L0X_STRING_ERROR_UNDEFINED "Undefined error"
elab 0:0e577ce96b2f 181 #define VL53L0X_STRING_ERROR_INVALID_PARAMS "Invalid parameters error"
elab 0:0e577ce96b2f 182 #define VL53L0X_STRING_ERROR_NOT_SUPPORTED "Not supported error"
elab 0:0e577ce96b2f 183 #define VL53L0X_STRING_ERROR_RANGE_ERROR "Range error"
elab 0:0e577ce96b2f 184 #define VL53L0X_STRING_ERROR_TIME_OUT "Time out error"
elab 0:0e577ce96b2f 185 #define VL53L0X_STRING_ERROR_MODE_NOT_SUPPORTED "Mode not supported error"
elab 0:0e577ce96b2f 186 #define VL53L0X_STRING_ERROR_BUFFER_TOO_SMALL "Buffer too small"
elab 0:0e577ce96b2f 187 #define VL53L0X_STRING_ERROR_GPIO_NOT_EXISTING "GPIO not existing"
elab 0:0e577ce96b2f 188 #define VL53L0X_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED "GPIO funct not supported"
elab 0:0e577ce96b2f 189 #define VL53L0X_STRING_ERROR_INTERRUPT_NOT_CLEARED "Interrupt not Cleared"
elab 0:0e577ce96b2f 190 #define VL53L0X_STRING_ERROR_CONTROL_INTERFACE "Control Interface Error"
elab 0:0e577ce96b2f 191 #define VL53L0X_STRING_ERROR_INVALID_COMMAND "Invalid Command Error"
elab 0:0e577ce96b2f 192 #define VL53L0X_STRING_ERROR_DIVISION_BY_ZERO "Division by zero Error"
elab 0:0e577ce96b2f 193 #define VL53L0X_STRING_ERROR_REF_SPAD_INIT "Reference Spad Init Error"
elab 0:0e577ce96b2f 194 #define VL53L0X_STRING_UNKNOW_ERROR_CODE "Unknown Error Code"
elab 0:0e577ce96b2f 195
elab 0:0e577ce96b2f 196 /* Range Status */
elab 0:0e577ce96b2f 197 #define VL53L0X_STRING_RANGESTATUS_NONE "No Update"
elab 0:0e577ce96b2f 198 #define VL53L0X_STRING_RANGESTATUS_RANGEVALID "Range Valid"
elab 0:0e577ce96b2f 199 #define VL53L0X_STRING_RANGESTATUS_SIGMA "Sigma Fail"
elab 0:0e577ce96b2f 200 #define VL53L0X_STRING_RANGESTATUS_SIGNAL "Signal Fail"
elab 0:0e577ce96b2f 201 #define VL53L0X_STRING_RANGESTATUS_MINRANGE "Min Range Fail"
elab 0:0e577ce96b2f 202 #define VL53L0X_STRING_RANGESTATUS_PHASE "Phase Fail"
elab 0:0e577ce96b2f 203 #define VL53L0X_STRING_RANGESTATUS_HW "Hardware Fail"
elab 0:0e577ce96b2f 204
elab 0:0e577ce96b2f 205 /* Range Status */
elab 0:0e577ce96b2f 206 #define VL53L0X_STRING_STATE_POWERDOWN "POWERDOWN State"
elab 0:0e577ce96b2f 207 #define VL53L0X_STRING_STATE_WAIT_STATICINIT "Wait for staticinit State"
elab 0:0e577ce96b2f 208 #define VL53L0X_STRING_STATE_STANDBY "STANDBY State"
elab 0:0e577ce96b2f 209 #define VL53L0X_STRING_STATE_IDLE "IDLE State"
elab 0:0e577ce96b2f 210 #define VL53L0X_STRING_STATE_RUNNING "RUNNING State"
elab 0:0e577ce96b2f 211 #define VL53L0X_STRING_STATE_UNKNOWN "UNKNOWN State"
elab 0:0e577ce96b2f 212 #define VL53L0X_STRING_STATE_ERROR "ERROR State"
elab 0:0e577ce96b2f 213
elab 0:0e577ce96b2f 214 /* Device Specific */
elab 0:0e577ce96b2f 215 #define VL53L0X_STRING_DEVICEERROR_NONE "No Update"
elab 0:0e577ce96b2f 216 #define VL53L0X_STRING_DEVICEERROR_VCSELCONTINUITYTESTFAILURE "VCSEL Continuity Test Failure"
elab 0:0e577ce96b2f 217 #define VL53L0X_STRING_DEVICEERROR_VCSELWATCHDOGTESTFAILURE "VCSEL Watchdog Test Failure"
elab 0:0e577ce96b2f 218 #define VL53L0X_STRING_DEVICEERROR_NOVHVVALUEFOUND "No VHV Value found"
elab 0:0e577ce96b2f 219 #define VL53L0X_STRING_DEVICEERROR_MSRCNOTARGET "MSRC No Target Error"
elab 0:0e577ce96b2f 220 #define VL53L0X_STRING_DEVICEERROR_SNRCHECK "SNR Check Exit"
elab 0:0e577ce96b2f 221 #define VL53L0X_STRING_DEVICEERROR_RANGEPHASECHECK "Range Phase Check Error"
elab 0:0e577ce96b2f 222 #define VL53L0X_STRING_DEVICEERROR_SIGMATHRESHOLDCHECK "Sigma Threshold Check Error"
elab 0:0e577ce96b2f 223 #define VL53L0X_STRING_DEVICEERROR_TCC "TCC Error"
elab 0:0e577ce96b2f 224 #define VL53L0X_STRING_DEVICEERROR_PHASECONSISTENCY "Phase Consistency Error"
elab 0:0e577ce96b2f 225 #define VL53L0X_STRING_DEVICEERROR_MINCLIP "Min Clip Error"
elab 0:0e577ce96b2f 226 #define VL53L0X_STRING_DEVICEERROR_RANGECOMPLETE "Range Complete"
elab 0:0e577ce96b2f 227 #define VL53L0X_STRING_DEVICEERROR_ALGOUNDERFLOW "Range Algo Underflow Error"
elab 0:0e577ce96b2f 228 #define VL53L0X_STRING_DEVICEERROR_ALGOOVERFLOW "Range Algo Overlow Error"
elab 0:0e577ce96b2f 229 #define VL53L0X_STRING_DEVICEERROR_RANGEIGNORETHRESHOLD "Range Ignore Threshold Error"
elab 0:0e577ce96b2f 230 #define VL53L0X_STRING_DEVICEERROR_UNKNOWN "Unknown error code"
elab 0:0e577ce96b2f 231
elab 0:0e577ce96b2f 232 /* Check Enable */
elab 0:0e577ce96b2f 233 #define VL53L0X_STRING_CHECKENABLE_SIGMA_FINAL_RANGE "SIGMA FINAL RANGE"
elab 0:0e577ce96b2f 234 #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE "SIGNAL RATE FINAL RANGE"
elab 0:0e577ce96b2f 235 #define VL53L0X_STRING_CHECKENABLE_SIGNAL_REF_CLIP "SIGNAL REF CLIP"
elab 0:0e577ce96b2f 236 #define VL53L0X_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD "RANGE IGNORE THRESHOLD"
elab 0:0e577ce96b2f 237 #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_MSRC "SIGNAL RATE MSRC"
elab 0:0e577ce96b2f 238 #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_PRE_RANGE "SIGNAL RATE PRE RANGE"
elab 0:0e577ce96b2f 239
elab 0:0e577ce96b2f 240 /* Sequence Step */
elab 0:0e577ce96b2f 241 #define VL53L0X_STRING_SEQUENCESTEP_TCC "TCC"
elab 0:0e577ce96b2f 242 #define VL53L0X_STRING_SEQUENCESTEP_DSS "DSS"
elab 0:0e577ce96b2f 243 #define VL53L0X_STRING_SEQUENCESTEP_MSRC "MSRC"
elab 0:0e577ce96b2f 244 #define VL53L0X_STRING_SEQUENCESTEP_PRE_RANGE "PRE RANGE"
elab 0:0e577ce96b2f 245 #define VL53L0X_STRING_SEQUENCESTEP_FINAL_RANGE "FINAL RANGE"
elab 0:0e577ce96b2f 246
elab 0:0e577ce96b2f 247
elab 0:0e577ce96b2f 248 /** @defgroup VL53L0X_CheckEnable_group Check Enable list
elab 0:0e577ce96b2f 249 * @brief Check Enable code
elab 0:0e577ce96b2f 250 *
elab 0:0e577ce96b2f 251 * Define used to specify the LimitCheckId.
elab 0:0e577ce96b2f 252 * Use @a VL53L0X_GetLimitCheckInfo() to get the string.
elab 0:0e577ce96b2f 253 * @{ */
elab 0:0e577ce96b2f 254 #define VL53L0X_CHECKENABLE_SIGMA_FINAL_RANGE 0
elab 0:0e577ce96b2f 255 #define VL53L0X_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE 1
elab 0:0e577ce96b2f 256 #define VL53L0X_CHECKENABLE_SIGNAL_REF_CLIP 2
elab 0:0e577ce96b2f 257 #define VL53L0X_CHECKENABLE_RANGE_IGNORE_THRESHOLD 3
elab 0:0e577ce96b2f 258 #define VL53L0X_CHECKENABLE_SIGNAL_RATE_MSRC 4
elab 0:0e577ce96b2f 259 #define VL53L0X_CHECKENABLE_SIGNAL_RATE_PRE_RANGE 5
elab 0:0e577ce96b2f 260 #define VL53L0X_CHECKENABLE_NUMBER_OF_CHECKS 6
elab 0:0e577ce96b2f 261 /** @} end of VL53L0X_CheckEnable_group */
elab 0:0e577ce96b2f 262
elab 0:0e577ce96b2f 263
elab 0:0e577ce96b2f 264
elab 0:0e577ce96b2f 265 /** @defgroup VL53L0X_DefineRegisters_group Define Registers
elab 0:0e577ce96b2f 266 * @brief List of all the defined registers
elab 0:0e577ce96b2f 267 * @{ */
elab 0:0e577ce96b2f 268 #define VL53L0X_REG_SYSRANGE_START 0x000
elab 0:0e577ce96b2f 269 /** mask existing bit in #VL53L0X_REG_SYSRANGE_START*/
elab 0:0e577ce96b2f 270 #define VL53L0X_REG_SYSRANGE_MODE_MASK 0x0F
elab 0:0e577ce96b2f 271 /** bit 0 in #VL53L0X_REG_SYSRANGE_START write 1 toggle state in
elab 0:0e577ce96b2f 272 * continuous mode and arm next shot in single shot mode */
elab 0:0e577ce96b2f 273 #define VL53L0X_REG_SYSRANGE_MODE_START_STOP 0x01
elab 0:0e577ce96b2f 274 /** bit 1 write 0 in #VL53L0X_REG_SYSRANGE_START set single shot mode */
elab 0:0e577ce96b2f 275 #define VL53L0X_REG_SYSRANGE_MODE_SINGLESHOT 0x00
elab 0:0e577ce96b2f 276 /** bit 1 write 1 in #VL53L0X_REG_SYSRANGE_START set back-to-back operation mode */
elab 0:0e577ce96b2f 277 #define VL53L0X_REG_SYSRANGE_MODE_BACKTOBACK 0x02
elab 0:0e577ce96b2f 278 /** bit 2 write 1 in #VL53L0X_REG_SYSRANGE_START set timed operation mode */
elab 0:0e577ce96b2f 279 #define VL53L0X_REG_SYSRANGE_MODE_TIMED 0x04
elab 0:0e577ce96b2f 280 /** bit 3 write 1 in #VL53L0X_REG_SYSRANGE_START set histogram operation mode */
elab 0:0e577ce96b2f 281 #define VL53L0X_REG_SYSRANGE_MODE_HISTOGRAM 0x08
elab 0:0e577ce96b2f 282 #define VL53L0X_REG_SYSTEM_THRESH_HIGH 0x000C
elab 0:0e577ce96b2f 283 #define VL53L0X_REG_SYSTEM_THRESH_LOW 0x000E
elab 0:0e577ce96b2f 284 #define VL53L0X_REG_SYSTEM_SEQUENCE_CONFIG 0x0001
elab 0:0e577ce96b2f 285 #define VL53L0X_REG_SYSTEM_RANGE_CONFIG 0x0009
elab 0:0e577ce96b2f 286 #define VL53L0X_REG_SYSTEM_INTERMEASUREMENT_PERIOD 0x0004
elab 0:0e577ce96b2f 287 #define VL53L0X_REG_SYSTEM_INTERRUPT_CONFIG_GPIO 0x000A
elab 0:0e577ce96b2f 288 #define VL53L0X_REG_SYSTEM_INTERRUPT_GPIO_DISABLED 0x00
elab 0:0e577ce96b2f 289 #define VL53L0X_REG_SYSTEM_INTERRUPT_GPIO_LEVEL_LOW 0x01
elab 0:0e577ce96b2f 290 #define VL53L0X_REG_SYSTEM_INTERRUPT_GPIO_LEVEL_HIGH 0x02
elab 0:0e577ce96b2f 291 #define VL53L0X_REG_SYSTEM_INTERRUPT_GPIO_OUT_OF_WINDOW 0x03
elab 0:0e577ce96b2f 292 #define VL53L0X_REG_SYSTEM_INTERRUPT_GPIO_NEW_SAMPLE_READY 0x04
elab 0:0e577ce96b2f 293 #define VL53L0X_REG_GPIO_HV_MUX_ACTIVE_HIGH 0x0084
elab 0:0e577ce96b2f 294 #define VL53L0X_REG_SYSTEM_INTERRUPT_CLEAR 0x000B
elab 0:0e577ce96b2f 295
elab 0:0e577ce96b2f 296 /* Result registers */
elab 0:0e577ce96b2f 297 #define VL53L0X_REG_RESULT_INTERRUPT_STATUS 0x0013
elab 0:0e577ce96b2f 298 #define VL53L0X_REG_RESULT_RANGE_STATUS 0x0014
elab 0:0e577ce96b2f 299 #define VL53L0X_REG_RESULT_CORE_PAGE 1
elab 0:0e577ce96b2f 300 #define VL53L0X_REG_RESULT_CORE_AMBIENT_WINDOW_EVENTS_RTN 0x00BC
elab 0:0e577ce96b2f 301 #define VL53L0X_REG_RESULT_CORE_RANGING_TOTAL_EVENTS_RTN 0x00C0
elab 0:0e577ce96b2f 302 #define VL53L0X_REG_RESULT_CORE_AMBIENT_WINDOW_EVENTS_REF 0x00D0
elab 0:0e577ce96b2f 303 #define VL53L0X_REG_RESULT_CORE_RANGING_TOTAL_EVENTS_REF 0x00D4
elab 0:0e577ce96b2f 304 #define VL53L0X_REG_RESULT_PEAK_SIGNAL_RATE_REF 0x00B6
elab 0:0e577ce96b2f 305 /* Algo register */
elab 0:0e577ce96b2f 306 #define VL53L0X_REG_ALGO_PART_TO_PART_RANGE_OFFSET_MM 0x0028
elab 0:0e577ce96b2f 307 #define VL53L0X_REG_I2C_SLAVE_DEVICE_ADDRESS 0x008a
elab 0:0e577ce96b2f 308 /* Check Limit registers */
elab 0:0e577ce96b2f 309 #define VL53L0X_REG_MSRC_CONFIG_CONTROL 0x0060
elab 0:0e577ce96b2f 310 #define VL53L0X_REG_PRE_RANGE_CONFIG_MIN_SNR 0X0027
elab 0:0e577ce96b2f 311 #define VL53L0X_REG_PRE_RANGE_CONFIG_VALID_PHASE_LOW 0x0056
elab 0:0e577ce96b2f 312 #define VL53L0X_REG_PRE_RANGE_CONFIG_VALID_PHASE_HIGH 0x0057
elab 0:0e577ce96b2f 313 #define VL53L0X_REG_PRE_RANGE_MIN_COUNT_RATE_RTN_LIMIT 0x0064
elab 0:0e577ce96b2f 314 #define VL53L0X_REG_FINAL_RANGE_CONFIG_MIN_SNR 0X0067
elab 0:0e577ce96b2f 315 #define VL53L0X_REG_FINAL_RANGE_CONFIG_VALID_PHASE_LOW 0x0047
elab 0:0e577ce96b2f 316 #define VL53L0X_REG_FINAL_RANGE_CONFIG_VALID_PHASE_HIGH 0x0048
elab 0:0e577ce96b2f 317 #define VL53L0X_REG_FINAL_RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT 0x0044
elab 0:0e577ce96b2f 318 #define VL53L0X_REG_PRE_RANGE_CONFIG_SIGMA_THRESH_HI 0X0061
elab 0:0e577ce96b2f 319 #define VL53L0X_REG_PRE_RANGE_CONFIG_SIGMA_THRESH_LO 0X0062
elab 0:0e577ce96b2f 320
elab 0:0e577ce96b2f 321 /* PRE RANGE registers */
elab 0:0e577ce96b2f 322 #define VL53L0X_REG_PRE_RANGE_CONFIG_VCSEL_PERIOD 0x0050
elab 0:0e577ce96b2f 323 #define VL53L0X_REG_PRE_RANGE_CONFIG_TIMEOUT_MACROP_HI 0x0051
elab 0:0e577ce96b2f 324 #define VL53L0X_REG_PRE_RANGE_CONFIG_TIMEOUT_MACROP_LO 0x0052
elab 0:0e577ce96b2f 325 #define VL53L0X_REG_SYSTEM_HISTOGRAM_BIN 0x0081
elab 0:0e577ce96b2f 326 #define VL53L0X_REG_HISTOGRAM_CONFIG_INITIAL_PHASE_SELECT 0x0033
elab 0:0e577ce96b2f 327 #define VL53L0X_REG_HISTOGRAM_CONFIG_READOUT_CTRL 0x0055
elab 0:0e577ce96b2f 328 #define VL53L0X_REG_FINAL_RANGE_CONFIG_VCSEL_PERIOD 0x0070
elab 0:0e577ce96b2f 329 #define VL53L0X_REG_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_HI 0x0071
elab 0:0e577ce96b2f 330 #define VL53L0X_REG_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_LO 0x0072
elab 0:0e577ce96b2f 331 #define VL53L0X_REG_CROSSTALK_COMPENSATION_PEAK_RATE_MHz 0x0020
elab 0:0e577ce96b2f 332 #define VL53L0X_REG_MSRC_CONFIG_TIMEOUT_MACROP 0x0046
elab 0:0e577ce96b2f 333 #define VL53L0X_REG_SOFT_RESET_GO2_SOFT_RESET_N 0x00bf
elab 0:0e577ce96b2f 334 #define VL53L0X_REG_IDENTIFICATION_MODEL_ID 0x00c0
elab 0:0e577ce96b2f 335 #define VL53L0X_REG_IDENTIFICATION_REVISION_ID 0x00c2
elab 0:0e577ce96b2f 336 #define VL53L0X_REG_OSC_CALIBRATE_VAL 0x00f8
elab 0:0e577ce96b2f 337 #define VL53L0X_REG_GLOBAL_CONFIG_VCSEL_WIDTH 0x0032
elab 0:0e577ce96b2f 338 #define VL53L0X_REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_0 0x00B0
elab 0:0e577ce96b2f 339 #define VL53L0X_REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_1 0x00B1
elab 0:0e577ce96b2f 340 #define VL53L0X_REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_2 0x00B2
elab 0:0e577ce96b2f 341 #define VL53L0X_REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_3 0x00B3
elab 0:0e577ce96b2f 342 #define VL53L0X_REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_4 0x00B4
elab 0:0e577ce96b2f 343 #define VL53L0X_REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_5 0x00B5
elab 0:0e577ce96b2f 344 #define VL53L0X_REG_GLOBAL_CONFIG_REF_EN_START_SELECT 0x00B6
elab 0:0e577ce96b2f 345 #define VL53L0X_REG_DYNAMIC_SPAD_NUM_REQUESTED_REF_SPAD 0x004E /* 0x14E */
elab 0:0e577ce96b2f 346 #define VL53L0X_REG_DYNAMIC_SPAD_REF_EN_START_OFFSET 0x004F /* 0x14F */
elab 0:0e577ce96b2f 347 #define VL53L0X_REG_POWER_MANAGEMENT_GO1_POWER_FORCE 0x0080
elab 0:0e577ce96b2f 348 #define VL53L0X_REG_VHV_CONFIG_PAD_SCL_SDA__EXTSUP_HV 0x0089
elab 0:0e577ce96b2f 349 #define VL53L0X_REG_ALGO_PHASECAL_LIM 0x0030 /* 0x130 */
elab 0:0e577ce96b2f 350 #define VL53L0X_REG_ALGO_PHASECAL_CONFIG_TIMEOUT 0x0030
elab 0:0e577ce96b2f 351 /** @} VL53L0X_DefineRegisters_group */
elab 0:0e577ce96b2f 352
elab 0:0e577ce96b2f 353
elab 0:0e577ce96b2f 354 static uint8_t DefaultTuningSettings[] = {
elab 0:0e577ce96b2f 355
elab 0:0e577ce96b2f 356 /* update 02/11/2015_v36 */
elab 0:0e577ce96b2f 357 0x01, 0xFF, 0x01, 0x01, 0x00, 0x00, 0x01, 0xFF, 0x00, 0x01, 0x09, 0x00,
elab 0:0e577ce96b2f 358 0x01, 0x10, 0x00, 0x01, 0x11, 0x00, 0x01, 0x24, 0x01, 0x01, 0x25, 0xff,
elab 0:0e577ce96b2f 359 0x01, 0x75, 0x00, 0x01, 0xFF, 0x01, 0x01, 0x4e, 0x2c, 0x01, 0x48, 0x00,
elab 0:0e577ce96b2f 360 0x01, 0x30, 0x20, 0x01, 0xFF, 0x00, 0x01, 0x30, 0x09, /* mja changed from 0x64. */
elab 0:0e577ce96b2f 361 0x01, 0x54, 0x00, 0x01, 0x31, 0x04, 0x01, 0x32, 0x03, 0x01, 0x40, 0x83,
elab 0:0e577ce96b2f 362 0x01, 0x46, 0x25, 0x01, 0x60, 0x00, 0x01, 0x27, 0x00, 0x01, 0x50, 0x06,
elab 0:0e577ce96b2f 363 0x01, 0x51, 0x00, 0x01, 0x52, 0x96, 0x01, 0x56, 0x08, 0x01, 0x57, 0x30,
elab 0:0e577ce96b2f 364 0x01, 0x61, 0x00, 0x01, 0x62, 0x00, 0x01, 0x64, 0x00, 0x01, 0x65, 0x00,
elab 0:0e577ce96b2f 365 0x01, 0x66, 0xa0, 0x01, 0xFF, 0x01, 0x01, 0x22, 0x32, 0x01, 0x47, 0x14,
elab 0:0e577ce96b2f 366 0x01, 0x49, 0xff, 0x01, 0x4a, 0x00, 0x01, 0xFF, 0x00, 0x01, 0x7a, 0x0a,
elab 0:0e577ce96b2f 367 0x01, 0x7b, 0x00, 0x01, 0x78, 0x21, 0x01, 0xFF, 0x01, 0x01, 0x23, 0x34,
elab 0:0e577ce96b2f 368 0x01, 0x42, 0x00, 0x01, 0x44, 0xff, 0x01, 0x45, 0x26, 0x01, 0x46, 0x05,
elab 0:0e577ce96b2f 369 0x01, 0x40, 0x40, 0x01, 0x0E, 0x06, 0x01, 0x20, 0x1a, 0x01, 0x43, 0x40,
elab 0:0e577ce96b2f 370 0x01, 0xFF, 0x00, 0x01, 0x34, 0x03, 0x01, 0x35, 0x44, 0x01, 0xFF, 0x01,
elab 0:0e577ce96b2f 371 0x01, 0x31, 0x04, 0x01, 0x4b, 0x09, 0x01, 0x4c, 0x05, 0x01, 0x4d, 0x04,
elab 0:0e577ce96b2f 372 0x01, 0xFF, 0x00, 0x01, 0x44, 0x00, 0x01, 0x45, 0x20, 0x01, 0x47, 0x08,
elab 0:0e577ce96b2f 373 0x01, 0x48, 0x28, 0x01, 0x67, 0x00, 0x01, 0x70, 0x04, 0x01, 0x71, 0x01,
elab 0:0e577ce96b2f 374 0x01, 0x72, 0xfe, 0x01, 0x76, 0x00, 0x01, 0x77, 0x00, 0x01, 0xFF, 0x01,
elab 0:0e577ce96b2f 375 0x01, 0x0d, 0x01, 0x01, 0xFF, 0x00, 0x01, 0x80, 0x01, 0x01, 0x01, 0xF8,
elab 0:0e577ce96b2f 376 0x01, 0xFF, 0x01, 0x01, 0x8e, 0x01, 0x01, 0x00, 0x01, 0x01, 0xFF, 0x00,
elab 0:0e577ce96b2f 377 0x01, 0x80, 0x00, 0x00, 0x00, 0x00
elab 0:0e577ce96b2f 378 };
elab 0:0e577ce96b2f 379
elab 0:0e577ce96b2f 380 static uint8_t InterruptThresholdSettings[] = {
elab 0:0e577ce96b2f 381 /* Start of Interrupt Threshold Settings */
elab 0:0e577ce96b2f 382 0x1, 0xff, 0x00, 0x1, 0x80, 0x01, 0x1, 0xff, 0x01, 0x1, 0x00, 0x00,
elab 0:0e577ce96b2f 383 0x1, 0xff, 0x01, 0x1, 0x4f, 0x02, 0x1, 0xFF, 0x0E, 0x1, 0x00, 0x03,
elab 0:0e577ce96b2f 384 0x1, 0x01, 0x84, 0x1, 0x02, 0x0A, 0x1, 0x03, 0x03, 0x1, 0x04, 0x08,
elab 0:0e577ce96b2f 385 0x1, 0x05, 0xC8, 0x1, 0x06, 0x03, 0x1, 0x07, 0x8D, 0x1, 0x08, 0x08,
elab 0:0e577ce96b2f 386 0x1, 0x09, 0xC6, 0x1, 0x0A, 0x01, 0x1, 0x0B, 0x02, 0x1, 0x0C, 0x00,
elab 0:0e577ce96b2f 387 0x1, 0x0D, 0xD5, 0x1, 0x0E, 0x18, 0x1, 0x0F, 0x12, 0x1, 0x10, 0x01,
elab 0:0e577ce96b2f 388 0x1, 0x11, 0x82, 0x1, 0x12, 0x00, 0x1, 0x13, 0xD5, 0x1, 0x14, 0x18,
elab 0:0e577ce96b2f 389 0x1, 0x15, 0x13, 0x1, 0x16, 0x03, 0x1, 0x17, 0x86, 0x1, 0x18, 0x0A,
elab 0:0e577ce96b2f 390 0x1, 0x19, 0x09, 0x1, 0x1A, 0x08, 0x1, 0x1B, 0xC2, 0x1, 0x1C, 0x03,
elab 0:0e577ce96b2f 391 0x1, 0x1D, 0x8F, 0x1, 0x1E, 0x0A, 0x1, 0x1F, 0x06, 0x1, 0x20, 0x01,
elab 0:0e577ce96b2f 392 0x1, 0x21, 0x02, 0x1, 0x22, 0x00, 0x1, 0x23, 0xD5, 0x1, 0x24, 0x18,
elab 0:0e577ce96b2f 393 0x1, 0x25, 0x22, 0x1, 0x26, 0x01, 0x1, 0x27, 0x82, 0x1, 0x28, 0x00,
elab 0:0e577ce96b2f 394 0x1, 0x29, 0xD5, 0x1, 0x2A, 0x18, 0x1, 0x2B, 0x0B, 0x1, 0x2C, 0x28,
elab 0:0e577ce96b2f 395 0x1, 0x2D, 0x78, 0x1, 0x2E, 0x28, 0x1, 0x2F, 0x91, 0x1, 0x30, 0x00,
elab 0:0e577ce96b2f 396 0x1, 0x31, 0x0B, 0x1, 0x32, 0x00, 0x1, 0x33, 0x0B, 0x1, 0x34, 0x00,
elab 0:0e577ce96b2f 397 0x1, 0x35, 0xA1, 0x1, 0x36, 0x00, 0x1, 0x37, 0xA0, 0x1, 0x38, 0x00,
elab 0:0e577ce96b2f 398 0x1, 0x39, 0x04, 0x1, 0x3A, 0x28, 0x1, 0x3B, 0x30, 0x1, 0x3C, 0x0C,
elab 0:0e577ce96b2f 399 0x1, 0x3D, 0x04, 0x1, 0x3E, 0x0F, 0x1, 0x3F, 0x79, 0x1, 0x40, 0x28,
elab 0:0e577ce96b2f 400 0x1, 0x41, 0x1E, 0x1, 0x42, 0x2F, 0x1, 0x43, 0x87, 0x1, 0x44, 0x00,
elab 0:0e577ce96b2f 401 0x1, 0x45, 0x0B, 0x1, 0x46, 0x00, 0x1, 0x47, 0x0B, 0x1, 0x48, 0x00,
elab 0:0e577ce96b2f 402 0x1, 0x49, 0xA7, 0x1, 0x4A, 0x00, 0x1, 0x4B, 0xA6, 0x1, 0x4C, 0x00,
elab 0:0e577ce96b2f 403 0x1, 0x4D, 0x04, 0x1, 0x4E, 0x01, 0x1, 0x4F, 0x00, 0x1, 0x50, 0x00,
elab 0:0e577ce96b2f 404 0x1, 0x51, 0x80, 0x1, 0x52, 0x09, 0x1, 0x53, 0x08, 0x1, 0x54, 0x01,
elab 0:0e577ce96b2f 405 0x1, 0x55, 0x00, 0x1, 0x56, 0x0F, 0x1, 0x57, 0x79, 0x1, 0x58, 0x09,
elab 0:0e577ce96b2f 406 0x1, 0x59, 0x05, 0x1, 0x5A, 0x00, 0x1, 0x5B, 0x60, 0x1, 0x5C, 0x05,
elab 0:0e577ce96b2f 407 0x1, 0x5D, 0xD1, 0x1, 0x5E, 0x0C, 0x1, 0x5F, 0x3C, 0x1, 0x60, 0x00,
elab 0:0e577ce96b2f 408 0x1, 0x61, 0xD0, 0x1, 0x62, 0x0B, 0x1, 0x63, 0x03, 0x1, 0x64, 0x28,
elab 0:0e577ce96b2f 409 0x1, 0x65, 0x10, 0x1, 0x66, 0x2A, 0x1, 0x67, 0x39, 0x1, 0x68, 0x0B,
elab 0:0e577ce96b2f 410 0x1, 0x69, 0x02, 0x1, 0x6A, 0x28, 0x1, 0x6B, 0x10, 0x1, 0x6C, 0x2A,
elab 0:0e577ce96b2f 411 0x1, 0x6D, 0x61, 0x1, 0x6E, 0x0C, 0x1, 0x6F, 0x00, 0x1, 0x70, 0x0F,
elab 0:0e577ce96b2f 412 0x1, 0x71, 0x79, 0x1, 0x72, 0x00, 0x1, 0x73, 0x0B, 0x1, 0x74, 0x00,
elab 0:0e577ce96b2f 413 0x1, 0x75, 0x0B, 0x1, 0x76, 0x00, 0x1, 0x77, 0xA1, 0x1, 0x78, 0x00,
elab 0:0e577ce96b2f 414 0x1, 0x79, 0xA0, 0x1, 0x7A, 0x00, 0x1, 0x7B, 0x04, 0x1, 0xFF, 0x04,
elab 0:0e577ce96b2f 415 0x1, 0x79, 0x1D, 0x1, 0x7B, 0x27, 0x1, 0x96, 0x0E, 0x1, 0x97, 0xFE,
elab 0:0e577ce96b2f 416 0x1, 0x98, 0x03, 0x1, 0x99, 0xEF, 0x1, 0x9A, 0x02, 0x1, 0x9B, 0x44,
elab 0:0e577ce96b2f 417 0x1, 0x73, 0x07, 0x1, 0x70, 0x01, 0x1, 0xff, 0x01, 0x1, 0x00, 0x01,
elab 0:0e577ce96b2f 418 0x1, 0xff, 0x00,
elab 0:0e577ce96b2f 419 0x0, 0x00, 0x00};
elab 0:0e577ce96b2f 420
elab 0:0e577ce96b2f 421 /** @defgroup VL53L0X_GpioFunctionality_group Gpio Functionality
elab 0:0e577ce96b2f 422 * @brief Defines the different functionalities for the device GPIO(s)
elab 0:0e577ce96b2f 423 * @{ */
elab 0:0e577ce96b2f 424 typedef uint8_t VL53L0X_GpioFunctionality;
elab 0:0e577ce96b2f 425 #define VL53L0X_GPIOFUNCTIONALITY_OFF \
elab 0:0e577ce96b2f 426 ((VL53L0X_GpioFunctionality) 0) /*!< NO Interrupt */
elab 0:0e577ce96b2f 427 #define VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW \
elab 0:0e577ce96b2f 428 ((VL53L0X_GpioFunctionality) 1) /*!< Level Low (value < thresh_low) */
elab 0:0e577ce96b2f 429 #define VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH \
elab 0:0e577ce96b2f 430 ((VL53L0X_GpioFunctionality) 2) /*!< Level High (value > thresh_high) */
elab 0:0e577ce96b2f 431 #define VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT \
elab 0:0e577ce96b2f 432 ((VL53L0X_GpioFunctionality) 3)
elab 0:0e577ce96b2f 433 /*!< Out Of Window (value < thresh_low OR value > thresh_high) */
elab 0:0e577ce96b2f 434 #define VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY \
elab 0:0e577ce96b2f 435 ((VL53L0X_GpioFunctionality) 4) /*!< New Sample Ready */
elab 0:0e577ce96b2f 436 /** @} end of VL53L0X_GpioFunctionality_group */
elab 0:0e577ce96b2f 437
elab 0:0e577ce96b2f 438
elab 0:0e577ce96b2f 439 /** @brief Defines the parameters of the Get Version Functions */
elab 0:0e577ce96b2f 440 typedef struct {
elab 0:0e577ce96b2f 441 uint32_t revision; /*!< revision number */
elab 0:0e577ce96b2f 442 uint8_t major; /*!< major number */
elab 0:0e577ce96b2f 443 uint8_t minor; /*!< minor number */
elab 0:0e577ce96b2f 444 uint8_t build; /*!< build number */
elab 0:0e577ce96b2f 445 } VL53L0X_Version_t;
elab 0:0e577ce96b2f 446
elab 0:0e577ce96b2f 447 /** @defgroup VL53L0X_define_Error_group Error and Warning code returned by API
elab 0:0e577ce96b2f 448 * The following DEFINE are used to identify the PAL ERROR
elab 0:0e577ce96b2f 449 * @{ */
elab 0:0e577ce96b2f 450 typedef int8_t VL53L0X_Error;
elab 0:0e577ce96b2f 451 #define VL53L0X_ERROR_NONE ((VL53L0X_Error) 0)
elab 0:0e577ce96b2f 452 #define VL53L0X_ERROR_CALIBRATION_WARNING ((VL53L0X_Error) -1)
elab 0:0e577ce96b2f 453 /*!< Warning invalid calibration data may be in used
elab 0:0e577ce96b2f 454 \a VL53L0X_InitData()
elab 0:0e577ce96b2f 455 \a VL53L0X_GetOffsetCalibrationData
elab 0:0e577ce96b2f 456 \a VL53L0X_SetOffsetCalibrationData */
elab 0:0e577ce96b2f 457 #define VL53L0X_ERROR_MIN_CLIPPED ((VL53L0X_Error) -2)
elab 0:0e577ce96b2f 458 /*!< Warning parameter passed was clipped to min before to be applied */
elab 0:0e577ce96b2f 459 #define VL53L0X_ERROR_UNDEFINED ((VL53L0X_Error) -3)
elab 0:0e577ce96b2f 460 /*!< Unqualified error */
elab 0:0e577ce96b2f 461 #define VL53L0X_ERROR_INVALID_PARAMS ((VL53L0X_Error) -4)
elab 0:0e577ce96b2f 462 /*!< Parameter passed is invalid or out of range */
elab 0:0e577ce96b2f 463 #define VL53L0X_ERROR_NOT_SUPPORTED ((VL53L0X_Error) -5)
elab 0:0e577ce96b2f 464 /*!< Function is not supported in current mode or configuration */
elab 0:0e577ce96b2f 465 #define VL53L0X_ERROR_RANGE_ERROR ((VL53L0X_Error) -6)
elab 0:0e577ce96b2f 466 /*!< Device report a ranging error interrupt status */
elab 0:0e577ce96b2f 467 #define VL53L0X_ERROR_TIME_OUT ((VL53L0X_Error) -7)
elab 0:0e577ce96b2f 468 /*!< Aborted due to time out */
elab 0:0e577ce96b2f 469 #define VL53L0X_ERROR_MODE_NOT_SUPPORTED ((VL53L0X_Error) -8)
elab 0:0e577ce96b2f 470 /*!< Asked mode is not supported by the device */
elab 0:0e577ce96b2f 471 #define VL53L0X_ERROR_BUFFER_TOO_SMALL ((VL53L0X_Error) -9)
elab 0:0e577ce96b2f 472 /*!< ... */
elab 0:0e577ce96b2f 473 #define VL53L0X_ERROR_GPIO_NOT_EXISTING ((VL53L0X_Error) -10)
elab 0:0e577ce96b2f 474 /*!< User tried to setup a non-existing GPIO pin */
elab 0:0e577ce96b2f 475 #define VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED ((VL53L0X_Error) -11)
elab 0:0e577ce96b2f 476 /*!< unsupported GPIO functionality */
elab 0:0e577ce96b2f 477 #define VL53L0X_ERROR_INTERRUPT_NOT_CLEARED ((VL53L0X_Error) -12)
elab 0:0e577ce96b2f 478 /*!< Error during interrupt clear */
elab 0:0e577ce96b2f 479 #define VL53L0X_ERROR_CONTROL_INTERFACE ((VL53L0X_Error) -20)
elab 0:0e577ce96b2f 480 /*!< error reported from IO functions */
elab 0:0e577ce96b2f 481 #define VL53L0X_ERROR_INVALID_COMMAND ((VL53L0X_Error) -30)
elab 0:0e577ce96b2f 482 /*!< The command is not allowed in the current device state (power down) */
elab 0:0e577ce96b2f 483 #define VL53L0X_ERROR_DIVISION_BY_ZERO ((VL53L0X_Error) -40)
elab 0:0e577ce96b2f 484 /*!< In the function a division by zero occurs */
elab 0:0e577ce96b2f 485 #define VL53L0X_ERROR_REF_SPAD_INIT ((VL53L0X_Error) -50)
elab 0:0e577ce96b2f 486 /*!< Error during reference SPAD initialization */
elab 0:0e577ce96b2f 487 /** @} VL53L0X_define_Error_group */
elab 0:0e577ce96b2f 488
elab 0:0e577ce96b2f 489
elab 0:0e577ce96b2f 490 /** @defgroup VL53L0X_define_DeviceModes_group Defines Device modes
elab 0:0e577ce96b2f 491 * Defines all possible modes for the device
elab 0:0e577ce96b2f 492 * @{ */
elab 0:0e577ce96b2f 493 typedef uint8_t VL53L0X_DeviceModes;
elab 0:0e577ce96b2f 494 #define VL53L0X_DEVICEMODE_SINGLE_RANGING ((VL53L0X_DeviceModes) 0)
elab 0:0e577ce96b2f 495 #define VL53L0X_DEVICEMODE_CONTINUOUS_RANGING ((VL53L0X_DeviceModes) 1)
elab 0:0e577ce96b2f 496 #define VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING ((VL53L0X_DeviceModes) 3)
elab 0:0e577ce96b2f 497 #define VL53L0X_DEVICEMODE_SINGLE_ALS ((VL53L0X_DeviceModes) 10)
elab 0:0e577ce96b2f 498 #define VL53L0X_DEVICEMODE_GPIO_DRIVE ((VL53L0X_DeviceModes) 20)
elab 0:0e577ce96b2f 499 #define VL53L0X_DEVICEMODE_GPIO_OSC ((VL53L0X_DeviceModes) 21)
elab 0:0e577ce96b2f 500 /* ... Modes to be added depending on device */
elab 0:0e577ce96b2f 501 /** @} VL53L0X_define_DeviceModes_group */
elab 0:0e577ce96b2f 502
elab 0:0e577ce96b2f 503
elab 0:0e577ce96b2f 504 /** @defgroup VL53L0X_define_PowerModes_group List of available Power Modes
elab 0:0e577ce96b2f 505 * List of available Power Modes
elab 0:0e577ce96b2f 506 * @{ */
elab 0:0e577ce96b2f 507 typedef uint8_t VL53L0X_PowerModes;
elab 0:0e577ce96b2f 508 #define VL53L0X_POWERMODE_STANDBY_LEVEL1 ((VL53L0X_PowerModes) 0)
elab 0:0e577ce96b2f 509 /*!< Standby level 1 */
elab 0:0e577ce96b2f 510 #define VL53L0X_POWERMODE_STANDBY_LEVEL2 ((VL53L0X_PowerModes) 1)
elab 0:0e577ce96b2f 511 /*!< Standby level 2 */
elab 0:0e577ce96b2f 512 #define VL53L0X_POWERMODE_IDLE_LEVEL1 ((VL53L0X_PowerModes) 2)
elab 0:0e577ce96b2f 513 /*!< Idle level 1 */
elab 0:0e577ce96b2f 514 #define VL53L0X_POWERMODE_IDLE_LEVEL2 ((VL53L0X_PowerModes) 3)
elab 0:0e577ce96b2f 515 /*!< Idle level 2 */
elab 0:0e577ce96b2f 516 /** @} VL53L0X_define_PowerModes_group */
elab 0:0e577ce96b2f 517
elab 0:0e577ce96b2f 518 /** @defgroup VL53L0X_define_State_group Defines the current status of the device
elab 0:0e577ce96b2f 519 * Defines the current status of the device
elab 0:0e577ce96b2f 520 * @{ */
elab 0:0e577ce96b2f 521 typedef uint8_t VL53L0X_State;
elab 0:0e577ce96b2f 522 #define VL53L0X_STATE_POWERDOWN ((VL53L0X_State) 0)
elab 0:0e577ce96b2f 523 /*!< Device is in HW reset */
elab 0:0e577ce96b2f 524 #define VL53L0X_STATE_WAIT_STATICINIT ((VL53L0X_State) 1)
elab 0:0e577ce96b2f 525 /*!< Device is initialized and wait for static initialization */
elab 0:0e577ce96b2f 526 #define VL53L0X_STATE_STANDBY ((VL53L0X_State) 2)
elab 0:0e577ce96b2f 527 /*!< Device is in Low power Standby mode */
elab 0:0e577ce96b2f 528 #define VL53L0X_STATE_IDLE ((VL53L0X_State) 3)
elab 0:0e577ce96b2f 529 /*!< Device has been initialized and ready to do measurements */
elab 0:0e577ce96b2f 530 #define VL53L0X_STATE_RUNNING ((VL53L0X_State) 4)
elab 0:0e577ce96b2f 531 /*!< Device is performing measurement */
elab 0:0e577ce96b2f 532 #define VL53L0X_STATE_UNKNOWN ((VL53L0X_State) 98)
elab 0:0e577ce96b2f 533 /*!< Device is in unknown state and need to be rebooted */
elab 0:0e577ce96b2f 534 #define VL53L0X_STATE_ERROR ((VL53L0X_State) 99)
elab 0:0e577ce96b2f 535 /*!< Device is in error state and need to be rebooted */
elab 0:0e577ce96b2f 536 /** @} VL53L0X_define_State_group */
elab 0:0e577ce96b2f 537
elab 0:0e577ce96b2f 538
elab 0:0e577ce96b2f 539 /** @brief Defines the parameters of the Get Device Info Functions */
elab 0:0e577ce96b2f 540 typedef struct {
elab 0:0e577ce96b2f 541 char Name[VL53L0X_MAX_STRING_LENGTH];
elab 0:0e577ce96b2f 542 /*!< Name of the Device e.g. Left_Distance */
elab 0:0e577ce96b2f 543 char Type[VL53L0X_MAX_STRING_LENGTH];
elab 0:0e577ce96b2f 544 /*!< Type of the Device e.g VL53L0X */
elab 0:0e577ce96b2f 545 char ProductId[VL53L0X_MAX_STRING_LENGTH];
elab 0:0e577ce96b2f 546 /*!< Product Identifier String */
elab 0:0e577ce96b2f 547 uint8_t ProductType;
elab 0:0e577ce96b2f 548 /*!< Product Type, VL53L0X = 1, VL53L1 = 2 */
elab 0:0e577ce96b2f 549 uint8_t ProductRevisionMajor;
elab 0:0e577ce96b2f 550 /*!< Product revision major */
elab 0:0e577ce96b2f 551 uint8_t ProductRevisionMinor;
elab 0:0e577ce96b2f 552 /*!< Product revision minor */
elab 0:0e577ce96b2f 553 } VL53L0X_DeviceInfo_t;
elab 0:0e577ce96b2f 554
elab 0:0e577ce96b2f 555 /** @brief Defines all parameters for the device */
elab 0:0e577ce96b2f 556 typedef struct {
elab 0:0e577ce96b2f 557 VL53L0X_DeviceModes DeviceMode;
elab 0:0e577ce96b2f 558 /*!< Defines type of measurement to be done for the next measurement */
elab 0:0e577ce96b2f 559 uint32_t MeasurementTimingBudget_us;
elab 0:0e577ce96b2f 560 /*!< Defines the allowed total time for a single measurement */
elab 0:0e577ce96b2f 561 uint32_t InterMeasurementPeriod_ms;
elab 0:0e577ce96b2f 562 /*!< Defines time between two consecutive measurements (between two
elab 0:0e577ce96b2f 563 * measurement starts). If set to 0 means back-to-back mode */
elab 0:0e577ce96b2f 564 uint8_t XTalkCompensationEnable;
elab 0:0e577ce96b2f 565 /*!< Tells if Crosstalk compensation shall be enable or not */
elab 0:0e577ce96b2f 566 uint16_t XTalkCompensationRange_mm;
elab 0:0e577ce96b2f 567 /*!< CrossTalk compensation range in _mm */
elab 0:0e577ce96b2f 568 FixPoint1616_t XTalkCompensationRate_MHz;
elab 0:0e577ce96b2f 569 /*!< CrossTalk compensation rate in Mega counts per seconds.
elab 0:0e577ce96b2f 570 * Expressed in 16.16 fixed point format. */
elab 0:0e577ce96b2f 571 int32_t RangeOffset_um;
elab 0:0e577ce96b2f 572 /*!< Range offset adjustment (mm) last programmed. */
elab 0:0e577ce96b2f 573 uint8_t LimitChecksEnable[VL53L0X_CHECKENABLE_NUMBER_OF_CHECKS];
elab 0:0e577ce96b2f 574 /*!< This Array store all the 6 Limit Check enables for this device. */
elab 0:0e577ce96b2f 575 uint8_t LimitChecksStatus[VL53L0X_CHECKENABLE_NUMBER_OF_CHECKS];
elab 0:0e577ce96b2f 576 /*!< This Array store all the 6 Status of the check linked to last measurement. */
elab 0:0e577ce96b2f 577 FixPoint1616_t LimitChecksValue[VL53L0X_CHECKENABLE_NUMBER_OF_CHECKS];
elab 0:0e577ce96b2f 578 /*!< This Array store all the Limit Check value for this device */
elab 0:0e577ce96b2f 579 uint8_t WrapAroundCheckEnable;
elab 0:0e577ce96b2f 580 /*!< Tells if Wrap Around Check shall be enable or not */
elab 0:0e577ce96b2f 581 } VL53L0X_DeviceParameters_t;
elab 0:0e577ce96b2f 582
elab 0:0e577ce96b2f 583 /**
elab 0:0e577ce96b2f 584 * @struct VL53L0X_RangeData_t
elab 0:0e577ce96b2f 585 * @brief Range measurement data. */
elab 0:0e577ce96b2f 586 typedef struct {
elab 0:0e577ce96b2f 587 uint16_t Range_mm; /*!< range distance in _mm. */
elab 0:0e577ce96b2f 588 uint16_t RangeDMax_mm; /*!< Tells what is the maximum detection distance of the device
elab 0:0e577ce96b2f 589 * in current setup and environment conditions (Filled when applicable) */
elab 0:0e577ce96b2f 590 FixPoint1616_t SignalRateRtn_MHz; /*!< Return signal rate (MHz), as 16.16 fix point, effectively a measure of target reflectance.*/
elab 0:0e577ce96b2f 591 FixPoint1616_t AmbientRateRtn_MHz; /*!< Return ambient rate (MHz), as 16.16 fix point, effectively a measure of the ambient light.*/
elab 0:0e577ce96b2f 592 uint16_t EffectiveSpadRtnCount; /*!< Return the effective SPAD count for the return signal, as a 8.8 fix point value. */
elab 0:0e577ce96b2f 593 uint8_t RangeFractionalPart; /*!< Fractional part of range distance. Final value is a FixPoint168 value.; only noise :( */
elab 0:0e577ce96b2f 594 uint8_t RangeStatus; /*!< Range Status for the current measurement. Value = 0 means value is valid. See \ref RangeStatusPage */
elab 0:0e577ce96b2f 595 FixPoint1616_t SigmaEstimate; /*!< Estimated Sigma - based on ambient & VCSEL rates and signal_total_events */
elab 0:0e577ce96b2f 596 } VL53L0X_RangingMeasurementData_t;
elab 0:0e577ce96b2f 597
elab 0:0e577ce96b2f 598
elab 0:0e577ce96b2f 599 #define VL53L0X_REF_SPAD_BUFFER_SIZE 6
elab 0:0e577ce96b2f 600 typedef struct {
elab 0:0e577ce96b2f 601 // merged in here all parts of "VL53L0X_DeviceSpecificParameters_t DeviceSpecificParameters;"
elab 0:0e577ce96b2f 602 FixPoint1616_t OscFrequency_MHz; /* Frequency used */
elab 0:0e577ce96b2f 603 uint16_t LastEncodedTimeout; /* last encoded Time out used for timing budget*/
elab 0:0e577ce96b2f 604 VL53L0X_GpioFunctionality Pin0GpioFunctionality; /* store the functionality of the GPIO: pin0 */
elab 0:0e577ce96b2f 605 uint32_t FinalRangeTimeout_us;/*!< Execution time of the final range*/
elab 0:0e577ce96b2f 606 uint8_t FinalRangeVcselPulsePeriod; /*!< Vcsel pulse period (pll clocks) for the final range measurement*/
elab 0:0e577ce96b2f 607 uint32_t PreRangeTimeout_us; /*!< Execution time of the final range*/
elab 0:0e577ce96b2f 608 uint8_t PreRangeVcselPulsePeriod; /*!< Vcsel pulse period (pll clocks) for the pre-range measurement*/
elab 0:0e577ce96b2f 609 uint8_t ReadDataFromDeviceDone; /* Indicate if read from device has been done (==1) or not (==0) */
elab 0:0e577ce96b2f 610 uint8_t ModuleId; /* Module ID */
elab 0:0e577ce96b2f 611 uint8_t Revision; /* test Revision */
elab 0:0e577ce96b2f 612 char ProductId[VL53L0X_MAX_STRING_LENGTH]; /* Product Identifier String */
elab 0:0e577ce96b2f 613 uint8_t ReferenceSpadCount; /* used for ref spad management */
elab 0:0e577ce96b2f 614 uint8_t ReferenceSpadType; /* used for ref spad management */
elab 0:0e577ce96b2f 615 uint8_t RefSpadsInitialised; /* reports if ref spads are initialised. */
elab 0:0e577ce96b2f 616 uint32_t PartUIDUpper; /*!< Unique Part ID Upper */
elab 0:0e577ce96b2f 617 uint32_t PartUIDLower; /*!< Unique Part ID Lower */
elab 0:0e577ce96b2f 618 FixPoint1616_t SignalRateMeasFixed400mm; /*!< Peek Signal rate at 400 mm*/
elab 0:0e577ce96b2f 619
elab 0:0e577ce96b2f 620 // Merged in here the VL53L0X_SpadData_t SpadData; /*!< Spad Data; Enables and Good-Map */
elab 0:0e577ce96b2f 621 uint8_t RefSpadEnables[VL53L0X_REF_SPAD_BUFFER_SIZE]; /*!< Reference Spad Enables */
elab 0:0e577ce96b2f 622 uint8_t RefGoodSpadMap[VL53L0X_REF_SPAD_BUFFER_SIZE]; /*!< Reference Spad Good Spad Map */
elab 0:0e577ce96b2f 623
elab 0:0e577ce96b2f 624 // Merged in here all parts of DeviceParams_t
elab 0:0e577ce96b2f 625 int32_t Part2PartOffsetNVM_um; /*!< backed up NVM value */
elab 0:0e577ce96b2f 626 int32_t Part2PartOffsetAdjustNVM_um; /*!< backed up NVM value representing additional offset adjustment */
elab 0:0e577ce96b2f 627 uint8_t SequenceConfig; /*!< Internal value for the sequence config */
elab 0:0e577ce96b2f 628 uint8_t RangeFractionalEnable; /*!< Enable/Disable fractional part of ranging data */
elab 0:0e577ce96b2f 629 VL53L0X_State PalState; /*!< Current state of the PAL for this device */
elab 0:0e577ce96b2f 630 VL53L0X_PowerModes PowerMode; /*!< Current Power Mode; Stdby1/2, Idle1/2 */
elab 0:0e577ce96b2f 631 uint16_t SigmaEstRefArray; /*!< Reference array sigma value in 1/100th of [mm] e.g. 100 = 1mm; loaded from tuning settings */
elab 0:0e577ce96b2f 632 uint16_t SigmaEstEffPulseWidth; /*!< Effective Pulse width for sigma estimate in 1/100th of ns e.g. 900 = 9.0ns */
elab 0:0e577ce96b2f 633 uint16_t SigmaEstEffAmbWidth; /*!< Effective Ambient width for sigma estimate in 1/100th of ns e.g. 500 = 5.0ns */
elab 0:0e577ce96b2f 634 uint8_t StopVariable; /*!< StopVariable used during the stop sequence */
elab 0:0e577ce96b2f 635 uint16_t targetRefRate; /*!< Target Ambient Rate for Ref spad management */
elab 0:0e577ce96b2f 636 FixPoint1616_t LastSignalRef_MHz; /*!< Latest Signal ref in MHz */
elab 0:0e577ce96b2f 637 uint8_t *pTuningSettingsPointer; /*!< Pointer for alternative Tuning Settings table */
elab 0:0e577ce96b2f 638 uint8_t UseInternalTuningSettings; /*!< Indicate if we use Tuning Settings table, default = True */
elab 0:0e577ce96b2f 639 uint16_t LinearityCorrectiveGain; /*!< Linearity Corrective Gain value in x1000 */
elab 0:0e577ce96b2f 640 uint16_t DmaxCalRange_mm; /*!< Dmax Calibration Range _mm */
elab 0:0e577ce96b2f 641 FixPoint1616_t DmaxCalSignalRateRtn_MHz;/*!< Dmax Calibration Signal Rate Return _MHz */
elab 0:0e577ce96b2f 642
elab 0:0e577ce96b2f 643 } VL53L0X_DevData_t;
elab 0:0e577ce96b2f 644
elab 0:0e577ce96b2f 645 /* All these macros were replaced with following regulator expressions:
elab 0:0e577ce96b2f 646 a) Search for: \QVL53L0X_SETARRAYPARAMETERFIELD(\E(\s*)([A-Z\d_]+)[[:punct:]](\s*)([A-Z\d_]+)[[:punct:]](\s*)([A-Z\d_\*]+)\Q);\E
elab 0:0e577ce96b2f 647 Replace by: Data.CurrentParameters.\2[\4] = \6;
elab 0:0e577ce96b2f 648 to replace this: VL53L0X_SETARRAYPARAMETERFIELD(field, index, value);
elab 0:0e577ce96b2f 649 by this: Data.CurrentParameters.field[index] = value;
elab 0:0e577ce96b2f 650
elab 0:0e577ce96b2f 651 b) Search for: \QVL53L0X_GETARRAYPARAMETERFIELD(\E(\s*)([A-Z\d_]+)[[:punct:]](\s*)([A-Z\d_]+)[[:punct:]](\s*)([A-Z\d_\*]+)\Q);\E
elab 0:0e577ce96b2f 652 Replace by: \6 = Data.CurrentParameters.\2[\4];
elab 0:0e577ce96b2f 653 to replace this: VL53L0X_GETARRAYPARAMETERFIELD( LimitChecksValue, limit_check_id, temp_fix1616);
elab 0:0e577ce96b2f 654 by this: temp_fix1616 = Data.CurrentParameters.LimitChecksValue[limit_check_id];
elab 0:0e577ce96b2f 655
elab 0:0e577ce96b2f 656 c) Search for: \QVL53L0X_SETPARAMETERFIELD(\E(\s*)([A-Z\d_]+)[[:punct:]](\s*)([A-Z\d_\*]+)\Q);\E
elab 0:0e577ce96b2f 657 Replace by: Data.CurrentParameters.\2 = \4;
elab 0:0e577ce96b2f 658 to replace this: VL53L0X_SETPARAMETERFIELD(field, value);
elab 0:0e577ce96b2f 659 by this: Data.CurrentParameters.field = value
elab 0:0e577ce96b2f 660
elab 0:0e577ce96b2f 661 d) Search for: \QVL53L0X_GETPARAMETERFIELD(\E(\s*)([A-Z\d_]+)[[:punct:]](\s*)([A-Z\d_\*]+)\Q);\E
elab 0:0e577ce96b2f 662 Replace by: \4 = Data.CurrentParameters.\2 ;
elab 0:0e577ce96b2f 663 to replace this: VL53L0X_GETPARAMET ERFIELD(field, variable);
elab 0:0e577ce96b2f 664 by this: variable = Data.CurrentParameters.field;
elab 0:0e577ce96b2f 665
elab 0:0e577ce96b2f 666 d) Search for: \QPALDevDataSet(\E(\s*)([A-Z\d_]+)[[:punct:]](\s*)([A-Z\d_\*]+)\Q);\E
elab 0:0e577ce96b2f 667 Replace by: Data.\2 = \4;
elab 0:0e577ce96b2f 668 to replace this: PALDevDataSet(field, value);
elab 0:0e577ce96b2f 669 by this: Data.field = value;
elab 0:0e577ce96b2f 670
elab 0:0e577ce96b2f 671 d) Search for: \QPALDevDataGet(\E(\s*)([A-Z\d]+)\Q)\E
elab 0:0e577ce96b2f 672 Replace by: Data.\2
elab 0:0e577ce96b2f 673 to replace this: PALDevDataGet(field)
elab 0:0e577ce96b2f 674 by this: Data.field
elab 0:0e577ce96b2f 675
elab 0:0e577ce96b2f 676 #define PALDevDataSet(field, value) (Data.field)=(value)
elab 0:0e577ce96b2f 677 #define PALDevDataGet(field) (Data.field)
elab 0:0e577ce96b2f 678 #define VL53L0X_SETPARAMETERFIELD(field, value) Data.CurrentParameters.field = value
elab 0:0e577ce96b2f 679 #define VL53L0X_GETPARAMETERFIELD(field, variable) variable = Data.CurrentParameters.field
elab 0:0e577ce96b2f 680 #define VL53L0X_SETARRAYPARAMETERFIELD(field, index, value) Data.CurrentParameters.field[index] = value
elab 0:0e577ce96b2f 681 #define VL53L0X_GETARRAYPARAMETERFIELD(field, index, variable) variable = Data.CurrentParameters.field[index]
elab 0:0e577ce96b2f 682 #define VL53L0X_SETDEVICESPECIFICPARAMETER(field, value) Data.field = value
elab 0:0e577ce96b2f 683 #define VL53L0X_GETDEVICESPECIFICPARAMETER(field) Data.field
elab 0:0e577ce96b2f 684 */
elab 0:0e577ce96b2f 685
elab 0:0e577ce96b2f 686
elab 0:0e577ce96b2f 687 /** @defgroup VL53L0X_define_InterruptPolarity_group Defines the Polarity of the Interrupt
elab 0:0e577ce96b2f 688 * Defines the Polarity of the Interrupt
elab 0:0e577ce96b2f 689 * @{
elab 0:0e577ce96b2f 690 */
elab 0:0e577ce96b2f 691 typedef uint8_t VL53L0X_InterruptPolarity;
elab 0:0e577ce96b2f 692 #define VL53L0X_INTERRUPTPOLARITY_LOW ((VL53L0X_InterruptPolarity) 0)
elab 0:0e577ce96b2f 693 /*!< Set active low polarity best setup for falling edge. */
elab 0:0e577ce96b2f 694 #define VL53L0X_INTERRUPTPOLARITY_HIGH ((VL53L0X_InterruptPolarity) 1)
elab 0:0e577ce96b2f 695 /*!< Set active high polarity best setup for rising edge. */
elab 0:0e577ce96b2f 696
elab 0:0e577ce96b2f 697 /** @} VL53L0X_define_InterruptPolarity_group */
elab 0:0e577ce96b2f 698
elab 0:0e577ce96b2f 699
elab 0:0e577ce96b2f 700 /** @defgroup VL53L0X_define_VcselPeriod_group Vcsel Period Defines
elab 0:0e577ce96b2f 701 * Defines the range measurement for which to access the vcsel period.
elab 0:0e577ce96b2f 702 * @{ */
elab 0:0e577ce96b2f 703 typedef uint8_t VL53L0X_VcselPeriod;
elab 0:0e577ce96b2f 704 #define VL53L0X_VCSEL_PERIOD_PRE_RANGE ((VL53L0X_VcselPeriod) 0)
elab 0:0e577ce96b2f 705 /*!<Identifies the pre-range vcsel period. */
elab 0:0e577ce96b2f 706 #define VL53L0X_VCSEL_PERIOD_FINAL_RANGE ((VL53L0X_VcselPeriod) 1)
elab 0:0e577ce96b2f 707 /*!<Identifies the final range vcsel period. */
elab 0:0e577ce96b2f 708
elab 0:0e577ce96b2f 709 /** @} VL53L0X_define_VcselPeriod_group */
elab 0:0e577ce96b2f 710 /** @defgroup VL53L0X_define_SchedulerSequence_group Defines the steps
elab 0:0e577ce96b2f 711 * carried out by the scheduler during a range measurement.
elab 0:0e577ce96b2f 712 * @{
elab 0:0e577ce96b2f 713 * Defines the states of all the steps in the scheduler i.e. enabled/disabled. */
elab 0:0e577ce96b2f 714 typedef struct {
elab 0:0e577ce96b2f 715 uint8_t TccOn; /*!<Reports if Target Centre Check On */
elab 0:0e577ce96b2f 716 uint8_t MsrcOn; /*!<Reports if MSRC On */
elab 0:0e577ce96b2f 717 uint8_t DssOn; /*!<Reports if DSS On */
elab 0:0e577ce96b2f 718 uint8_t PreRangeOn; /*!<Reports if Pre-Range On */
elab 0:0e577ce96b2f 719 uint8_t FinalRangeOn; /*!<Reports if Final-Range On */
elab 0:0e577ce96b2f 720 } VL53L0X_SchedulerSequenceSteps_t;
elab 0:0e577ce96b2f 721 /** @} VL53L0X_define_SchedulerSequence_group */
elab 0:0e577ce96b2f 722
elab 0:0e577ce96b2f 723 /** @defgroup VL53L0X_define_SequenceStepId_group
elab 0:0e577ce96b2f 724 * Defines the the sequence steps performed during ranging..
elab 0:0e577ce96b2f 725 * @{ */
elab 0:0e577ce96b2f 726 typedef uint8_t VL53L0X_SequenceStepId;
elab 0:0e577ce96b2f 727 #define VL53L0X_SEQUENCESTEP_TCC ((VL53L0X_VcselPeriod) 0) /*!<Target CentreCheck identifier. */
elab 0:0e577ce96b2f 728 #define VL53L0X_SEQUENCESTEP_DSS ((VL53L0X_VcselPeriod) 1) /*!<Dynamic Spad Selection function Identifier. */
elab 0:0e577ce96b2f 729 #define VL53L0X_SEQUENCESTEP_MSRC ((VL53L0X_VcselPeriod) 2) /*!<Minimum Signal Rate Check function Identifier. */
elab 0:0e577ce96b2f 730 #define VL53L0X_SEQUENCESTEP_PRE_RANGE ((VL53L0X_VcselPeriod) 3) /*!<Pre-Range check Identifier. */
elab 0:0e577ce96b2f 731 #define VL53L0X_SEQUENCESTEP_FINAL_RANGE ((VL53L0X_VcselPeriod) 4) /*!<Final Range Check Identifier. */
elab 0:0e577ce96b2f 732 #define VL53L0X_SEQUENCESTEP_NUMBER_OF_CHECKS 5 /*!<Number of Sequence Step Managed by the API. */
elab 0:0e577ce96b2f 733 /** @} VL53L0X_define_SequenceStepId_group */
elab 0:0e577ce96b2f 734
elab 0:0e577ce96b2f 735
elab 0:0e577ce96b2f 736 typedef enum {
elab 0:0e577ce96b2f 737 Range_Config_DEFAULT,
elab 0:0e577ce96b2f 738 Range_Config_LONG_RANGE,
elab 0:0e577ce96b2f 739 Range_Config_HIGH_ACCURACY,
elab 0:0e577ce96b2f 740 Range_Config_HIGH_SPEED
elab 0:0e577ce96b2f 741 } VL53L0X_RangingConfig;
elab 0:0e577ce96b2f 742 /** @} VL53L0X_define_SequenceStepId_group */
elab 0:0e577ce96b2f 743
elab 0:0e577ce96b2f 744 /** @} VL53L0X_globaldefine_group */
elab 0:0e577ce96b2f 745
elab 0:0e577ce96b2f 746
elab 0:0e577ce96b2f 747 #ifdef __cplusplus
elab 0:0e577ce96b2f 748 }
elab 0:0e577ce96b2f 749 #endif
elab 0:0e577ce96b2f 750
elab 0:0e577ce96b2f 751
elab 0:0e577ce96b2f 752 #endif /* _VL53L0X_DEF_H_ */