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.

Committer:
charlesmn
Date:
Fri Nov 06 10:06:37 2020 +0000
Revision:
0:3ac96e360672
Child:
7:1add29d51e72
Library for ST Vl53L1A1 time of flight sensor.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
charlesmn 0:3ac96e360672 1 /******************************************************************************
charlesmn 0:3ac96e360672 2 * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
charlesmn 0:3ac96e360672 3
charlesmn 0:3ac96e360672 4 This file is part of VL53L1 Core and is dual licensed,
charlesmn 0:3ac96e360672 5 either 'STMicroelectronics
charlesmn 0:3ac96e360672 6 Proprietary license'
charlesmn 0:3ac96e360672 7 or 'BSD 3-clause "New" or "Revised" License' , at your option.
charlesmn 0:3ac96e360672 8
charlesmn 0:3ac96e360672 9 ******************************************************************************
charlesmn 0:3ac96e360672 10
charlesmn 0:3ac96e360672 11 'STMicroelectronics Proprietary license'
charlesmn 0:3ac96e360672 12
charlesmn 0:3ac96e360672 13 *******************************************************************************
charlesmn 0:3ac96e360672 14
charlesmn 0:3ac96e360672 15 License terms: STMicroelectronics Proprietary in accordance with licensing
charlesmn 0:3ac96e360672 16 terms at www.st.com/sla0081
charlesmn 0:3ac96e360672 17
charlesmn 0:3ac96e360672 18 STMicroelectronics confidential
charlesmn 0:3ac96e360672 19 Reproduction and Communication of this document is strictly prohibited unless
charlesmn 0:3ac96e360672 20 specifically authorized in writing by STMicroelectronics.
charlesmn 0:3ac96e360672 21
charlesmn 0:3ac96e360672 22
charlesmn 0:3ac96e360672 23 *******************************************************************************
charlesmn 0:3ac96e360672 24
charlesmn 0:3ac96e360672 25 Alternatively, VL53L1 Core may be distributed under the terms of
charlesmn 0:3ac96e360672 26 'BSD 3-clause "New" or "Revised" License', in which case the following
charlesmn 0:3ac96e360672 27 provisions apply instead of the ones mentioned above :
charlesmn 0:3ac96e360672 28
charlesmn 0:3ac96e360672 29 *******************************************************************************
charlesmn 0:3ac96e360672 30
charlesmn 0:3ac96e360672 31 License terms: BSD 3-clause "New" or "Revised" License.
charlesmn 0:3ac96e360672 32
charlesmn 0:3ac96e360672 33 Redistribution and use in source and binary forms, with or without
charlesmn 0:3ac96e360672 34 modification, are permitted provided that the following conditions are met:
charlesmn 0:3ac96e360672 35
charlesmn 0:3ac96e360672 36 1. Redistributions of source code must retain the above copyright notice, this
charlesmn 0:3ac96e360672 37 list of conditions and the following disclaimer.
charlesmn 0:3ac96e360672 38
charlesmn 0:3ac96e360672 39 2. Redistributions in binary form must reproduce the above copyright notice,
charlesmn 0:3ac96e360672 40 this list of conditions and the following disclaimer in the documentation
charlesmn 0:3ac96e360672 41 and/or other materials provided with the distribution.
charlesmn 0:3ac96e360672 42
charlesmn 0:3ac96e360672 43 3. Neither the name of the copyright holder nor the names of its contributors
charlesmn 0:3ac96e360672 44 may be used to endorse or promote products derived from this software
charlesmn 0:3ac96e360672 45 without specific prior written permission.
charlesmn 0:3ac96e360672 46
charlesmn 0:3ac96e360672 47 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
charlesmn 0:3ac96e360672 48 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
charlesmn 0:3ac96e360672 49 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
charlesmn 0:3ac96e360672 50 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
charlesmn 0:3ac96e360672 51 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
charlesmn 0:3ac96e360672 52 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
charlesmn 0:3ac96e360672 53 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
charlesmn 0:3ac96e360672 54 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
charlesmn 0:3ac96e360672 55 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
charlesmn 0:3ac96e360672 56 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
charlesmn 0:3ac96e360672 57
charlesmn 0:3ac96e360672 58
charlesmn 0:3ac96e360672 59 *******************************************************************************
charlesmn 0:3ac96e360672 60 */
charlesmn 0:3ac96e360672 61
charlesmn 0:3ac96e360672 62 /**
charlesmn 0:3ac96e360672 63 * @file vl53l1_def.h
charlesmn 0:3ac96e360672 64 *
charlesmn 0:3ac96e360672 65 * @brief Type definitions for VL53L1 API.
charlesmn 0:3ac96e360672 66 *
charlesmn 0:3ac96e360672 67 */
charlesmn 0:3ac96e360672 68
charlesmn 0:3ac96e360672 69
charlesmn 0:3ac96e360672 70 #ifndef _VL53L1_DEF_H_
charlesmn 0:3ac96e360672 71 #define _VL53L1_DEF_H_
charlesmn 0:3ac96e360672 72
charlesmn 0:3ac96e360672 73 #include "vl53l1_ll_def.h"
charlesmn 0:3ac96e360672 74
charlesmn 0:3ac96e360672 75 #ifdef __cplusplus
charlesmn 0:3ac96e360672 76 extern "C" {
charlesmn 0:3ac96e360672 77 #endif
charlesmn 0:3ac96e360672 78
charlesmn 0:3ac96e360672 79 /** @defgroup VL53L1_globaldefine_group VL53L1 Defines
charlesmn 0:3ac96e360672 80 * @brief VL53L1 Defines
charlesmn 0:3ac96e360672 81 * @{
charlesmn 0:3ac96e360672 82 */
charlesmn 0:3ac96e360672 83
charlesmn 0:3ac96e360672 84
charlesmn 0:3ac96e360672 85 /** VL53L1 IMPLEMENTATION major version */
charlesmn 0:3ac96e360672 86 #define VL53L1_IMPLEMENTATION_VER_MAJOR 6
charlesmn 0:3ac96e360672 87 /** VL53L1 IMPLEMENTATION minor version */
charlesmn 0:3ac96e360672 88 #define VL53L1_IMPLEMENTATION_VER_MINOR 6
charlesmn 0:3ac96e360672 89 /** VL53L1 IMPLEMENTATION sub version */
charlesmn 0:3ac96e360672 90 #define VL53L1_IMPLEMENTATION_VER_SUB 1
charlesmn 0:3ac96e360672 91 /** VL53L1 IMPLEMENTATION sub version */
charlesmn 0:3ac96e360672 92 #define VL53L1_IMPLEMENTATION_VER_REVISION 2432
charlesmn 0:3ac96e360672 93
charlesmn 0:3ac96e360672 94 /****************************************
charlesmn 0:3ac96e360672 95 * PRIVATE define do not edit
charlesmn 0:3ac96e360672 96 ****************************************/
charlesmn 0:3ac96e360672 97
charlesmn 0:3ac96e360672 98 /** @brief Defines the parameters of the Get Version Functions
charlesmn 0:3ac96e360672 99 */
charlesmn 0:3ac96e360672 100 typedef struct {
charlesmn 0:3ac96e360672 101 uint32_t revision; /*!< revision number */
charlesmn 0:3ac96e360672 102 uint8_t major; /*!< major number */
charlesmn 0:3ac96e360672 103 uint8_t minor; /*!< minor number */
charlesmn 0:3ac96e360672 104 uint8_t build; /*!< build number */
charlesmn 0:3ac96e360672 105 } VL53L1_Version_t;
charlesmn 0:3ac96e360672 106
charlesmn 0:3ac96e360672 107
charlesmn 0:3ac96e360672 108 #define VL53L1_DEVINFO_STRLEN 32
charlesmn 0:3ac96e360672 109
charlesmn 0:3ac96e360672 110 /** @brief Defines the parameters of the Get Device Info Functions
charlesmn 0:3ac96e360672 111 */
charlesmn 0:3ac96e360672 112 typedef struct {
charlesmn 0:3ac96e360672 113 char Name[VL53L1_DEVINFO_STRLEN];
charlesmn 0:3ac96e360672 114 /*!< Full Name of the Device e.g. VL53L1 cut1.1 */
charlesmn 0:3ac96e360672 115 char Type[VL53L1_DEVINFO_STRLEN];
charlesmn 0:3ac96e360672 116 /*!< Type of the Device e.g VL53L1 */
charlesmn 0:3ac96e360672 117 char ProductId[VL53L1_DEVINFO_STRLEN];
charlesmn 0:3ac96e360672 118 /*!< Product Identifier String
charlesmn 0:3ac96e360672 119 * @warning Not yet implemented
charlesmn 0:3ac96e360672 120 */
charlesmn 0:3ac96e360672 121 uint8_t ProductType;
charlesmn 0:3ac96e360672 122 /*!< Product Type, VL53L1 = 0xCC, VL53L3 = 0xAA
charlesmn 0:3ac96e360672 123 * Stands as module_type in the datasheet
charlesmn 0:3ac96e360672 124 */
charlesmn 0:3ac96e360672 125 uint8_t ProductRevisionMajor;
charlesmn 0:3ac96e360672 126 /*!< Product revision major */
charlesmn 0:3ac96e360672 127 uint8_t ProductRevisionMinor;
charlesmn 0:3ac96e360672 128 /*!< Product revision minor */
charlesmn 0:3ac96e360672 129 } VL53L1_DeviceInfo_t;
charlesmn 0:3ac96e360672 130
charlesmn 0:3ac96e360672 131
charlesmn 0:3ac96e360672 132
charlesmn 0:3ac96e360672 133 /** @defgroup VL53L1_define_PresetModes_group Defines Preset modes
charlesmn 0:3ac96e360672 134 * Defines all possible preset modes for the device
charlesmn 0:3ac96e360672 135 * @{
charlesmn 0:3ac96e360672 136 */
charlesmn 0:3ac96e360672 137 typedef uint8_t VL53L1_PresetModes;
charlesmn 0:3ac96e360672 138
charlesmn 0:3ac96e360672 139 #define VL53L1_PRESETMODE_RANGING ((VL53L1_PresetModes) 1)
charlesmn 0:3ac96e360672 140 #define VL53L1_PRESETMODE_MULTIZONES_SCANNING ((VL53L1_PresetModes) 2)
charlesmn 0:3ac96e360672 141 #define VL53L1_PRESETMODE_AUTONOMOUS ((VL53L1_PresetModes) 3)
charlesmn 0:3ac96e360672 142 #define VL53L1_PRESETMODE_LITE_RANGING ((VL53L1_PresetModes) 4)
charlesmn 0:3ac96e360672 143 #define VL53L1_PRESETMODE_OLT ((VL53L1_PresetModes) 7)
charlesmn 0:3ac96e360672 144 #define VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS ((VL53L1_PresetModes) 8)
charlesmn 0:3ac96e360672 145 #define VL53L1_PRESETMODE_PROXY_RANGING_MODE ((VL53L1_PresetModes) 9)
charlesmn 0:3ac96e360672 146
charlesmn 0:3ac96e360672 147 /* ... Modes to be added depending on device */
charlesmn 0:3ac96e360672 148 /** @} VL53L1_define_PresetModes_group */
charlesmn 0:3ac96e360672 149
charlesmn 0:3ac96e360672 150
charlesmn 0:3ac96e360672 151 /** @defgroup VL53L1_define_DistanceModes_group Defines Distance modes
charlesmn 0:3ac96e360672 152 * Defines all possible Distance modes for the device
charlesmn 0:3ac96e360672 153 * @{
charlesmn 0:3ac96e360672 154 */
charlesmn 0:3ac96e360672 155 typedef uint8_t VL53L1_DistanceModes;
charlesmn 0:3ac96e360672 156
charlesmn 0:3ac96e360672 157 #define VL53L1_DISTANCEMODE_SHORT ((VL53L1_DistanceModes) 1)
charlesmn 0:3ac96e360672 158 #define VL53L1_DISTANCEMODE_MEDIUM ((VL53L1_DistanceModes) 2)
charlesmn 0:3ac96e360672 159 #define VL53L1_DISTANCEMODE_LONG ((VL53L1_DistanceModes) 3)
charlesmn 0:3ac96e360672 160 /** @} VL53L1_define_DistanceModes_group */
charlesmn 0:3ac96e360672 161
charlesmn 0:3ac96e360672 162 /** @defgroup VL53L1_define_OutputModes_group Defines Output modes
charlesmn 0:3ac96e360672 163 * Defines all possible Output modes for the device
charlesmn 0:3ac96e360672 164 * @{
charlesmn 0:3ac96e360672 165 */
charlesmn 0:3ac96e360672 166 typedef uint8_t VL53L1_OutputModes;
charlesmn 0:3ac96e360672 167
charlesmn 0:3ac96e360672 168 #define VL53L1_OUTPUTMODE_NEAREST ((VL53L1_OutputModes) 1)
charlesmn 0:3ac96e360672 169 #define VL53L1_OUTPUTMODE_STRONGEST ((VL53L1_OutputModes) 2)
charlesmn 0:3ac96e360672 170
charlesmn 0:3ac96e360672 171 /** @} VL53L1_define_OutputModes_group */
charlesmn 0:3ac96e360672 172
charlesmn 0:3ac96e360672 173 /** @defgroup VL53L1_define_XtalkCal_group Defines Xtalk Calibration modes
charlesmn 0:3ac96e360672 174 * Defines all possible Offset Calibration modes for the device
charlesmn 0:3ac96e360672 175 * @{
charlesmn 0:3ac96e360672 176 */
charlesmn 0:3ac96e360672 177 typedef uint8_t VL53L1_XtalkCalibrationModes;
charlesmn 0:3ac96e360672 178
charlesmn 0:3ac96e360672 179 #define VL53L1_XTALKCALIBRATIONMODE_NO_TARGET \
charlesmn 0:3ac96e360672 180 ((VL53L1_OffsetCalibrationModes) 0)
charlesmn 0:3ac96e360672 181 /*!< To perform Xtalk calibration with no target below 80 cm */
charlesmn 0:3ac96e360672 182 #define VL53L1_XTALKCALIBRATIONMODE_SINGLE_TARGET \
charlesmn 0:3ac96e360672 183 ((VL53L1_OffsetCalibrationModes) 1)
charlesmn 0:3ac96e360672 184 /*!< To perform Xtalk calibration with one target */
charlesmn 0:3ac96e360672 185 #define VL53L1_XTALKCALIBRATIONMODE_FULL_ROI \
charlesmn 0:3ac96e360672 186 ((VL53L1_OffsetCalibrationModes) 2)
charlesmn 0:3ac96e360672 187 /*!< To perform Xtalk calibration based on histogram with full ROI */
charlesmn 0:3ac96e360672 188
charlesmn 0:3ac96e360672 189 /** @} VL53L1_define_XtalkCal_group */
charlesmn 0:3ac96e360672 190
charlesmn 0:3ac96e360672 191 /** @defgroup VL53L1_define_OffsetCal_group Defines Offset Calibration modes
charlesmn 0:3ac96e360672 192 * Defines all possible Offset Calibration modes for the device
charlesmn 0:3ac96e360672 193 * @{
charlesmn 0:3ac96e360672 194 */
charlesmn 0:3ac96e360672 195 typedef uint8_t VL53L1_OffsetCalibrationModes;
charlesmn 0:3ac96e360672 196
charlesmn 0:3ac96e360672 197 #define VL53L1_OFFSETCALIBRATIONMODE_STANDARD \
charlesmn 0:3ac96e360672 198 ((VL53L1_OffsetCalibrationModes) 1)
charlesmn 0:3ac96e360672 199 #define VL53L1_OFFSETCALIBRATIONMODE_PRERANGE_ONLY \
charlesmn 0:3ac96e360672 200 ((VL53L1_OffsetCalibrationModes) 2)
charlesmn 0:3ac96e360672 201 #define VL53L1_OFFSETCALIBRATIONMODE_MULTI_ZONE \
charlesmn 0:3ac96e360672 202 ((VL53L1_OffsetCalibrationModes) 3)
charlesmn 0:3ac96e360672 203
charlesmn 0:3ac96e360672 204 /** @} VL53L1_define_OffsetCal_group */
charlesmn 0:3ac96e360672 205
charlesmn 0:3ac96e360672 206 /** @defgroup VL53L1_define_DeviceDmaxModes_group Defines Dmax source modes
charlesmn 0:3ac96e360672 207 * Defines all possible sources for Dmax calibration for the device
charlesmn 0:3ac96e360672 208 * @{
charlesmn 0:3ac96e360672 209 */
charlesmn 0:3ac96e360672 210 typedef uint8_t VL53L1_DeviceDmaxModes;
charlesmn 0:3ac96e360672 211
charlesmn 0:3ac96e360672 212 #define VL53L1_DMAXMODE_FMT_CAL_DATA ((VL53L1_DeviceDmaxModes) 1)
charlesmn 0:3ac96e360672 213 #define VL53L1_DMAXMODE_CUSTCAL_DATA ((VL53L1_DeviceDmaxModes) 2)
charlesmn 0:3ac96e360672 214 #define VL53L1_DMAXMODE_PER_ZONE_CAL_DATA ((VL53L1_DeviceDmaxModes) 3)
charlesmn 0:3ac96e360672 215
charlesmn 0:3ac96e360672 216 /** @} VL53L1_define_DeviceDmaxModes_group */
charlesmn 0:3ac96e360672 217
charlesmn 0:3ac96e360672 218 /** @defgroup VL53L1_define_OffsetCorrectionModesBD_group
charlesmn 0:3ac96e360672 219 * Device Offset Correction Mode
charlesmn 0:3ac96e360672 220 *
charlesmn 0:3ac96e360672 221 * @brief Defines all possible offset correction modes for the device
charlesmn 0:3ac96e360672 222 * @{
charlesmn 0:3ac96e360672 223 */
charlesmn 0:3ac96e360672 224 typedef uint8_t VL53L1_OffsetCorrectionModes;
charlesmn 0:3ac96e360672 225
charlesmn 0:3ac96e360672 226 #define VL53L1_OFFSETCORRECTIONMODE_STANDARD ((VL53L1_OffsetCorrectionMode) 1)
charlesmn 0:3ac96e360672 227 #define VL53L1_OFFSETCORRECTIONMODE_PERZONE ((VL53L1_OffsetCorrectionMode) 2)
charlesmn 0:3ac96e360672 228 #define VL53L1_OFFSETCORRECTIONMODE_PERVCSEL ((VL53L1_OffsetCorrectionMode) 3)
charlesmn 0:3ac96e360672 229
charlesmn 0:3ac96e360672 230 /** @} VL53L1_define_OffsetCorrectionModesBD_group */
charlesmn 0:3ac96e360672 231
charlesmn 0:3ac96e360672 232 /** @defgroup VL53L1_define_RoiStatus_group Defines Roi Status
charlesmn 0:3ac96e360672 233 * Defines the read status mode
charlesmn 0:3ac96e360672 234 * @{
charlesmn 0:3ac96e360672 235 */
charlesmn 0:3ac96e360672 236 typedef uint8_t VL53L1_RoiStatus;
charlesmn 0:3ac96e360672 237
charlesmn 0:3ac96e360672 238 #define VL53L1_ROISTATUS_NOT_VALID ((VL53L1_RoiStatus) 0)
charlesmn 0:3ac96e360672 239 #define VL53L1_ROISTATUS_VALID_NOT_LAST ((VL53L1_RoiStatus) 1)
charlesmn 0:3ac96e360672 240 #define VL53L1_ROISTATUS_VALID_LAST ((VL53L1_RoiStatus) 2)
charlesmn 0:3ac96e360672 241 /** @} VL53L1_define_RoiStatus_group */
charlesmn 0:3ac96e360672 242
charlesmn 0:3ac96e360672 243
charlesmn 0:3ac96e360672 244 /** @defgroup VL53L1_CheckEnable_group Check Enable list
charlesmn 0:3ac96e360672 245 * @brief Check Enable code
charlesmn 0:3ac96e360672 246 *
charlesmn 0:3ac96e360672 247 * Define used to specify the LimitCheckId.
charlesmn 0:3ac96e360672 248 * Use @a VL53L1_GetLimitCheckInfo() to get the string.
charlesmn 0:3ac96e360672 249 * @{
charlesmn 0:3ac96e360672 250 */
charlesmn 0:3ac96e360672 251
charlesmn 0:3ac96e360672 252 #define VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE 0
charlesmn 0:3ac96e360672 253 #define VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE 1
charlesmn 0:3ac96e360672 254
charlesmn 0:3ac96e360672 255 #define VL53L1_CHECKENABLE_NUMBER_OF_CHECKS 2
charlesmn 0:3ac96e360672 256
charlesmn 0:3ac96e360672 257 /** @} end of VL53L1_CheckEnable_group */
charlesmn 0:3ac96e360672 258
charlesmn 0:3ac96e360672 259
charlesmn 0:3ac96e360672 260 /** @defgroup VL53L1_ThresholdMode_gropup Detection Functionality
charlesmn 0:3ac96e360672 261 * @brief Defines the different functionalities for the detection feature
charlesmn 0:3ac96e360672 262 * @{
charlesmn 0:3ac96e360672 263 */
charlesmn 0:3ac96e360672 264 typedef uint8_t VL53L1_ThresholdMode;
charlesmn 0:3ac96e360672 265
charlesmn 0:3ac96e360672 266 #define VL53L1_THRESHOLD_CROSSED_LOW \
charlesmn 0:3ac96e360672 267 ((VL53L1_ThresholdMode) 0)
charlesmn 0:3ac96e360672 268 /*!< Trigger interrupt if value < thresh_low */
charlesmn 0:3ac96e360672 269 #define VL53L1_THRESHOLD_CROSSED_HIGH \
charlesmn 0:3ac96e360672 270 ((VL53L1_ThresholdMode) 1)
charlesmn 0:3ac96e360672 271 /*!< Trigger interrupt if value > thresh_high */
charlesmn 0:3ac96e360672 272 #define VL53L1_THRESHOLD_OUT_OF_WINDOW \
charlesmn 0:3ac96e360672 273 ((VL53L1_ThresholdMode) 2)
charlesmn 0:3ac96e360672 274 /*!< Trigger interrupt if value < thresh_low OR value > thresh_high */
charlesmn 0:3ac96e360672 275 #define VL53L1_THRESHOLD_IN_WINDOW \
charlesmn 0:3ac96e360672 276 ((VL53L1_ThresholdMode) 3)
charlesmn 0:3ac96e360672 277 /*!< Trigger interrupt if value > thresh_low AND value < thresh_high */
charlesmn 0:3ac96e360672 278
charlesmn 0:3ac96e360672 279 /** @} end of VL53L1_ThresholdMode_gropup */
charlesmn 0:3ac96e360672 280
charlesmn 0:3ac96e360672 281 /** @brief Defines parameters for Distance detection Thresholds configuration
charlesmn 0:3ac96e360672 282 */
charlesmn 0:3ac96e360672 283 typedef struct {
charlesmn 0:3ac96e360672 284 VL53L1_ThresholdMode CrossMode;
charlesmn 0:3ac96e360672 285 uint16_t High; /*!< Distance threshold high limit in mm */
charlesmn 0:3ac96e360672 286 uint16_t Low; /*!< Distance threshold low limit in mm */
charlesmn 0:3ac96e360672 287 } VL53L1_DistanceThreshold_t;
charlesmn 0:3ac96e360672 288
charlesmn 0:3ac96e360672 289 /** @brief Defines parameters for Signal rate detection Thresholds configuration
charlesmn 0:3ac96e360672 290 */
charlesmn 0:3ac96e360672 291 typedef struct {
charlesmn 0:3ac96e360672 292 VL53L1_ThresholdMode CrossMode;
charlesmn 0:3ac96e360672 293 FixPoint1616_t High; /*!< Signal rate threshold high limit */
charlesmn 0:3ac96e360672 294 FixPoint1616_t Low; /*!< Signal rate threshold low limit */
charlesmn 0:3ac96e360672 295 } VL53L1_RateThreshold_t;
charlesmn 0:3ac96e360672 296
charlesmn 0:3ac96e360672 297 /** @defgroup VL53L1_DetectionMode_group Gpio Functionality
charlesmn 0:3ac96e360672 298 * @brief Defines conditions leading to device's IT on GPIO
charlesmn 0:3ac96e360672 299 * @{
charlesmn 0:3ac96e360672 300 */
charlesmn 0:3ac96e360672 301 typedef uint8_t VL53L1_DetectionMode;
charlesmn 0:3ac96e360672 302
charlesmn 0:3ac96e360672 303 #define VL53L1_DETECTION_NORMAL_RUN \
charlesmn 0:3ac96e360672 304 ((VL53L1_DetectionMode) 0)
charlesmn 0:3ac96e360672 305 /*!< Trigger interrupt on new measurement regardless of threshold
charlesmn 0:3ac96e360672 306 * just like after a VL53L1_SetPresetMode() call
charlesmn 0:3ac96e360672 307 */
charlesmn 0:3ac96e360672 308 #define VL53L1_DETECTION_DISTANCE_ONLY \
charlesmn 0:3ac96e360672 309 ((VL53L1_DetectionMode) 1)
charlesmn 0:3ac96e360672 310 /*!< Trigger interrupt if "threshold event" occurs on distance */
charlesmn 0:3ac96e360672 311 #define VL53L1_DETECTION_RATE_ONLY \
charlesmn 0:3ac96e360672 312 ((VL53L1_DetectionMode) 2)
charlesmn 0:3ac96e360672 313 /*!< Trigger interrupt if "threshold event" occurs on signal rate */
charlesmn 0:3ac96e360672 314 #define VL53L1_DETECTION_DISTANCE_AND_RATE \
charlesmn 0:3ac96e360672 315 ((VL53L1_DetectionMode) 3)
charlesmn 0:3ac96e360672 316 /*!< Trigger interrupt if "threshold event" occurs on distance AND rate
charlesmn 0:3ac96e360672 317 */
charlesmn 0:3ac96e360672 318 #define VL53L1_DETECTION_DISTANCE_OR_RATE \
charlesmn 0:3ac96e360672 319 ((VL53L1_DetectionMode) 4)
charlesmn 0:3ac96e360672 320 /*!< Trigger interrupt if "threshold event" occurs on distance OR rate
charlesmn 0:3ac96e360672 321 */
charlesmn 0:3ac96e360672 322
charlesmn 0:3ac96e360672 323 /** @} end of VL53L1_DetectionMode_group */
charlesmn 0:3ac96e360672 324
charlesmn 0:3ac96e360672 325 /** @brief Defines parameters for User/object Detection configuration
charlesmn 0:3ac96e360672 326 */
charlesmn 0:3ac96e360672 327 typedef struct {
charlesmn 0:3ac96e360672 328 VL53L1_DetectionMode DetectionMode; /*!< See #VL53L1_DetectionMode*/
charlesmn 0:3ac96e360672 329 uint8_t IntrNoTarget; /*!< 1 to trigger IT in case of no target found */
charlesmn 0:3ac96e360672 330 VL53L1_DistanceThreshold_t Distance; /*!< limits in mm */
charlesmn 0:3ac96e360672 331 VL53L1_RateThreshold_t Rate;/*!< limits in FixPoint1616_t */
charlesmn 0:3ac96e360672 332 } VL53L1_DetectionConfig_t;
charlesmn 0:3ac96e360672 333
charlesmn 0:3ac96e360672 334
charlesmn 0:3ac96e360672 335 /** @brief Defines all parameters for the device
charlesmn 0:3ac96e360672 336 */
charlesmn 0:3ac96e360672 337 typedef struct {
charlesmn 0:3ac96e360672 338 VL53L1_PresetModes PresetMode;
charlesmn 0:3ac96e360672 339 /*!< Defines the operating mode to be used for the next measure */
charlesmn 0:3ac96e360672 340 VL53L1_OutputModes OutputMode;
charlesmn 0:3ac96e360672 341 /*!< Defines the Output mode to be used for the next measure */
charlesmn 0:3ac96e360672 342 VL53L1_DistanceModes DistanceMode;
charlesmn 0:3ac96e360672 343 /*!< Defines the operating mode to be used for the next measure */
charlesmn 0:3ac96e360672 344 uint32_t MeasurementTimingBudgetMicroSeconds;
charlesmn 0:3ac96e360672 345 /*!< Defines the allowed total time for a single measurement */
charlesmn 0:3ac96e360672 346 uint8_t LimitChecksEnable[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
charlesmn 0:3ac96e360672 347 /*!< This Array store all the Limit Check enable for this device. */
charlesmn 0:3ac96e360672 348 uint8_t LimitChecksStatus[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
charlesmn 0:3ac96e360672 349 /*!< This Array stores all the Status of the check linked to last
charlesmn 0:3ac96e360672 350 * measurement.
charlesmn 0:3ac96e360672 351 */
charlesmn 0:3ac96e360672 352 FixPoint1616_t LimitChecksValue[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
charlesmn 0:3ac96e360672 353 /*!< This Array stores all the Limit Check value for this device */
charlesmn 0:3ac96e360672 354 FixPoint1616_t LimitChecksCurrent[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
charlesmn 0:3ac96e360672 355 /*!< This Array stores all the Limit Check current value from latest
charlesmn 0:3ac96e360672 356 * ranging
charlesmn 0:3ac96e360672 357 */
charlesmn 0:3ac96e360672 358 } VL53L1_DeviceParameters_t;
charlesmn 0:3ac96e360672 359
charlesmn 0:3ac96e360672 360
charlesmn 0:3ac96e360672 361 /** @defgroup VL53L1_define_State_group Defines the current status of the device
charlesmn 0:3ac96e360672 362 * Defines the current status of the device
charlesmn 0:3ac96e360672 363 * @{
charlesmn 0:3ac96e360672 364 */
charlesmn 0:3ac96e360672 365
charlesmn 0:3ac96e360672 366 typedef uint8_t VL53L1_State;
charlesmn 0:3ac96e360672 367
charlesmn 0:3ac96e360672 368 #define VL53L1_STATE_POWERDOWN ((VL53L1_State) 0)
charlesmn 0:3ac96e360672 369 /*!< Device is in HW reset */
charlesmn 0:3ac96e360672 370 #define VL53L1_STATE_WAIT_STATICINIT ((VL53L1_State) 1)
charlesmn 0:3ac96e360672 371 /*!< Device is initialized and wait for static initialization */
charlesmn 0:3ac96e360672 372 #define VL53L1_STATE_STANDBY ((VL53L1_State) 2)
charlesmn 0:3ac96e360672 373 /*!< Device is in Low power Standby mode */
charlesmn 0:3ac96e360672 374 #define VL53L1_STATE_IDLE ((VL53L1_State) 3)
charlesmn 0:3ac96e360672 375 /*!< Device has been initialized and ready to do measurements */
charlesmn 0:3ac96e360672 376 #define VL53L1_STATE_RUNNING ((VL53L1_State) 4)
charlesmn 0:3ac96e360672 377 /*!< Device is performing measurement */
charlesmn 0:3ac96e360672 378 #define VL53L1_STATE_RESET ((VL53L1_State) 5)
charlesmn 0:3ac96e360672 379 /*!< Soft reset has been run on Device */
charlesmn 0:3ac96e360672 380 #define VL53L1_STATE_UNKNOWN ((VL53L1_State) 98)
charlesmn 0:3ac96e360672 381 /*!< Device is in unknown state and need to be rebooted */
charlesmn 0:3ac96e360672 382 #define VL53L1_STATE_ERROR ((VL53L1_State) 99)
charlesmn 0:3ac96e360672 383 /*!< Device is in error state and need to be rebooted */
charlesmn 0:3ac96e360672 384
charlesmn 0:3ac96e360672 385 /** @} VL53L1_define_State_group */
charlesmn 0:3ac96e360672 386
charlesmn 0:3ac96e360672 387 /** @defgroup VL53L1_define_Smudge_Mode_group Defines smudge correction modes
charlesmn 0:3ac96e360672 388 * Defines the smudge correction modes
charlesmn 0:3ac96e360672 389 * @{
charlesmn 0:3ac96e360672 390 */
charlesmn 0:3ac96e360672 391
charlesmn 0:3ac96e360672 392 typedef uint8_t VL53L1_SmudgeCorrectionModes;
charlesmn 0:3ac96e360672 393
charlesmn 0:3ac96e360672 394 #define VL53L1_SMUDGE_CORRECTION_NONE ((VL53L1_SmudgeCorrectionModes) 0)
charlesmn 0:3ac96e360672 395 /*!< Smudge correction is applied continously accross the rangings */
charlesmn 0:3ac96e360672 396 #define VL53L1_SMUDGE_CORRECTION_CONTINUOUS ((VL53L1_SmudgeCorrectionModes) 1)
charlesmn 0:3ac96e360672 397 /*!< Smudge correction is applied continously accross the rangings */
charlesmn 0:3ac96e360672 398 #define VL53L1_SMUDGE_CORRECTION_SINGLE ((VL53L1_SmudgeCorrectionModes) 2)
charlesmn 0:3ac96e360672 399 /*!< Smudge correction is applied only once accross the rangings */
charlesmn 0:3ac96e360672 400 #define VL53L1_SMUDGE_CORRECTION_DEBUG ((VL53L1_SmudgeCorrectionModes) 3)
charlesmn 0:3ac96e360672 401 /*!< Smudge detection is applied continously but Xtalk values are not
charlesmn 0:3ac96e360672 402 * updated automatically within the driver
charlesmn 0:3ac96e360672 403 */
charlesmn 0:3ac96e360672 404
charlesmn 0:3ac96e360672 405 /** @} VL53L1_define_Smudge_Correction_Mode_group */
charlesmn 0:3ac96e360672 406
charlesmn 0:3ac96e360672 407
charlesmn 0:3ac96e360672 408 /**
charlesmn 0:3ac96e360672 409 * @struct VL53L1_RangingMeasurementData_t
charlesmn 0:3ac96e360672 410 * @brief Single Range measurement data.
charlesmn 0:3ac96e360672 411 */
charlesmn 0:3ac96e360672 412 typedef struct {
charlesmn 0:3ac96e360672 413 uint32_t TimeStamp;
charlesmn 0:3ac96e360672 414 /*!< 32-bit time stamp.
charlesmn 0:3ac96e360672 415 * @warning Not yet implemented
charlesmn 0:3ac96e360672 416 */
charlesmn 0:3ac96e360672 417
charlesmn 0:3ac96e360672 418 uint8_t StreamCount;
charlesmn 0:3ac96e360672 419 /*!< 8-bit Stream Count. */
charlesmn 0:3ac96e360672 420
charlesmn 0:3ac96e360672 421 uint8_t RangeQualityLevel;
charlesmn 0:3ac96e360672 422 /*!< indicate a quality level in percentage from 0 to 100
charlesmn 0:3ac96e360672 423 * @warning Not yet implemented
charlesmn 0:3ac96e360672 424 */
charlesmn 0:3ac96e360672 425
charlesmn 0:3ac96e360672 426 FixPoint1616_t SignalRateRtnMegaCps;
charlesmn 0:3ac96e360672 427 /*!< Return signal rate (MCPS)\n these is a 16.16 fix point
charlesmn 0:3ac96e360672 428 * value, which is effectively a measure of target
charlesmn 0:3ac96e360672 429 * reflectance.
charlesmn 0:3ac96e360672 430 */
charlesmn 0:3ac96e360672 431
charlesmn 0:3ac96e360672 432 FixPoint1616_t AmbientRateRtnMegaCps;
charlesmn 0:3ac96e360672 433 /*!< Return ambient rate (MCPS)\n these is a 16.16 fix point
charlesmn 0:3ac96e360672 434 * value, which is effectively a measure of the ambien
charlesmn 0:3ac96e360672 435 * t light.
charlesmn 0:3ac96e360672 436 */
charlesmn 0:3ac96e360672 437
charlesmn 0:3ac96e360672 438 uint16_t EffectiveSpadRtnCount;
charlesmn 0:3ac96e360672 439 /*!< Return the effective SPAD count for the return signal.
charlesmn 0:3ac96e360672 440 * To obtain Real value it should be divided by 256
charlesmn 0:3ac96e360672 441 */
charlesmn 0:3ac96e360672 442
charlesmn 0:3ac96e360672 443 FixPoint1616_t SigmaMilliMeter;
charlesmn 0:3ac96e360672 444 /*!< Return the Sigma value in millimeter */
charlesmn 0:3ac96e360672 445
charlesmn 0:3ac96e360672 446 int16_t RangeMilliMeter;
charlesmn 0:3ac96e360672 447 /*!< range distance in millimeter. This should be between
charlesmn 0:3ac96e360672 448 * RangeMinMilliMeter and RangeMaxMilliMeter
charlesmn 0:3ac96e360672 449 */
charlesmn 0:3ac96e360672 450
charlesmn 0:3ac96e360672 451 uint8_t RangeFractionalPart;
charlesmn 0:3ac96e360672 452 /*!< Fractional part of range distance. Final value is a
charlesmn 0:3ac96e360672 453 * RangeMilliMeter + RangeFractionalPart/256.
charlesmn 0:3ac96e360672 454 * @warning Not yet implemented
charlesmn 0:3ac96e360672 455 */
charlesmn 0:3ac96e360672 456
charlesmn 0:3ac96e360672 457 uint8_t RangeStatus;
charlesmn 0:3ac96e360672 458 /*!< Range Status for the current measurement. This is device
charlesmn 0:3ac96e360672 459 * dependent. Value = 0 means value is valid.
charlesmn 0:3ac96e360672 460 */
charlesmn 0:3ac96e360672 461 } VL53L1_RangingMeasurementData_t;
charlesmn 0:3ac96e360672 462
charlesmn 0:3ac96e360672 463 /**
charlesmn 0:3ac96e360672 464 * @struct VL53L1_TargetRangeData_t
charlesmn 0:3ac96e360672 465 * @brief One Range measurement data for each target.
charlesmn 0:3ac96e360672 466 */
charlesmn 0:3ac96e360672 467 typedef struct {
charlesmn 0:3ac96e360672 468 uint8_t RangeQualityLevel;
charlesmn 0:3ac96e360672 469 /*!< indicate a quality level in percentage from 0 to 100
charlesmn 0:3ac96e360672 470 * @warning Not yet implemented
charlesmn 0:3ac96e360672 471 */
charlesmn 0:3ac96e360672 472
charlesmn 0:3ac96e360672 473 int16_t RangeMaxMilliMeter;
charlesmn 0:3ac96e360672 474 /*!< Tells what is the maximum detection distance of the object
charlesmn 0:3ac96e360672 475 * in current setup and environment conditions (Filled when
charlesmn 0:3ac96e360672 476 * applicable)
charlesmn 0:3ac96e360672 477 */
charlesmn 0:3ac96e360672 478
charlesmn 0:3ac96e360672 479 int16_t RangeMinMilliMeter;
charlesmn 0:3ac96e360672 480 /*!< Tells what is the minimum detection distance of the object
charlesmn 0:3ac96e360672 481 * in current setup and environment conditions (Filled when
charlesmn 0:3ac96e360672 482 * applicable)
charlesmn 0:3ac96e360672 483 */
charlesmn 0:3ac96e360672 484
charlesmn 0:3ac96e360672 485 FixPoint1616_t SignalRateRtnMegaCps;
charlesmn 0:3ac96e360672 486 /*!< Return signal rate (MCPS)\n these is a 16.16 fix point
charlesmn 0:3ac96e360672 487 * value, which is effectively a measure of target
charlesmn 0:3ac96e360672 488 * reflectance.
charlesmn 0:3ac96e360672 489 */
charlesmn 0:3ac96e360672 490
charlesmn 0:3ac96e360672 491 FixPoint1616_t AmbientRateRtnMegaCps;
charlesmn 0:3ac96e360672 492 /*!< Return ambient rate (MCPS)\n these is a 16.16 fix point
charlesmn 0:3ac96e360672 493 * value, which is effectively a measure of the ambien
charlesmn 0:3ac96e360672 494 * t light.
charlesmn 0:3ac96e360672 495 */
charlesmn 0:3ac96e360672 496
charlesmn 0:3ac96e360672 497 FixPoint1616_t SigmaMilliMeter;
charlesmn 0:3ac96e360672 498 /*!< Return the Sigma value in millimeter */
charlesmn 0:3ac96e360672 499
charlesmn 0:3ac96e360672 500 int16_t RangeMilliMeter;
charlesmn 0:3ac96e360672 501 /*!< range distance in millimeter. This should be between
charlesmn 0:3ac96e360672 502 * RangeMinMilliMeter and RangeMaxMilliMeter
charlesmn 0:3ac96e360672 503 */
charlesmn 0:3ac96e360672 504
charlesmn 0:3ac96e360672 505 uint8_t RangeFractionalPart;
charlesmn 0:3ac96e360672 506 /*!< Fractional part of range distance. Final value is a
charlesmn 0:3ac96e360672 507 * RangeMilliMeter + RangeFractionalPart/256.
charlesmn 0:3ac96e360672 508 * @warning Not yet implemented
charlesmn 0:3ac96e360672 509 */
charlesmn 0:3ac96e360672 510
charlesmn 0:3ac96e360672 511 uint8_t RangeStatus;
charlesmn 0:3ac96e360672 512 /*!< Range Status for the current measurement. This is device
charlesmn 0:3ac96e360672 513 * dependent. Value = 0 means value is valid.
charlesmn 0:3ac96e360672 514 */
charlesmn 0:3ac96e360672 515
charlesmn 0:3ac96e360672 516 uint8_t ExtendedRange;
charlesmn 0:3ac96e360672 517 /*!< Extended range flag for the current measurement.
charlesmn 0:3ac96e360672 518 * Value = 1 means timings A&B are combined to increase the
charlesmn 0:3ac96e360672 519 * maximum distance range.
charlesmn 0:3ac96e360672 520 */
charlesmn 0:3ac96e360672 521 } VL53L1_TargetRangeData_t;
charlesmn 0:3ac96e360672 522 /**
charlesmn 0:3ac96e360672 523 * @struct VL53L1_MultiRangingData_t
charlesmn 0:3ac96e360672 524 * @brief Structure for storing the set of range results for a single ROI
charlesmn 0:3ac96e360672 525 *
charlesmn 0:3ac96e360672 526 */
charlesmn 0:3ac96e360672 527 typedef struct {
charlesmn 0:3ac96e360672 528 uint32_t TimeStamp;
charlesmn 0:3ac96e360672 529 /*!< 32-bit time stamp.
charlesmn 0:3ac96e360672 530 * @warning Not yet implemented
charlesmn 0:3ac96e360672 531 */
charlesmn 0:3ac96e360672 532
charlesmn 0:3ac96e360672 533 uint8_t StreamCount;
charlesmn 0:3ac96e360672 534 /*!< 8-bit Stream Count. */
charlesmn 0:3ac96e360672 535
charlesmn 0:3ac96e360672 536 uint8_t RoiNumber;
charlesmn 0:3ac96e360672 537 /*!< Denotes on which ROI the range data is related to. */
charlesmn 0:3ac96e360672 538 uint8_t NumberOfObjectsFound;
charlesmn 0:3ac96e360672 539 /*!< Indicate the number of objects found in the current ROI.
charlesmn 0:3ac96e360672 540 * This is used to know how many ranging data should be get.
charlesmn 0:3ac96e360672 541 * NumberOfObjectsFound is in the range 0 to
charlesmn 0:3ac96e360672 542 * VL53L1_MAX_RANGE_RESULTS.
charlesmn 0:3ac96e360672 543 */
charlesmn 0:3ac96e360672 544 VL53L1_RoiStatus RoiStatus;
charlesmn 0:3ac96e360672 545 /*!< Indicate if the data read is valid or not or if this is
charlesmn 0:3ac96e360672 546 * the last valid data in the ROI.
charlesmn 0:3ac96e360672 547 */
charlesmn 0:3ac96e360672 548 VL53L1_TargetRangeData_t RangeData[VL53L1_MAX_RANGE_RESULTS];
charlesmn 0:3ac96e360672 549 /*!< Range data each target distance */
charlesmn 0:3ac96e360672 550 uint8_t HasXtalkValueChanged;
charlesmn 0:3ac96e360672 551 /*!< set to 1 if a new Xtalk value has been computed whilst
charlesmn 0:3ac96e360672 552 * smudge correction mode enable by with
charlesmn 0:3ac96e360672 553 * VL53L1_SmudgeCorrectionEnable() function is either
charlesmn 0:3ac96e360672 554 * VL53L1_SMUDGE_CORRECTION_CONTINUOUS or
charlesmn 0:3ac96e360672 555 * VL53L1_SMUDGE_CORRECTION_SINGLE.
charlesmn 0:3ac96e360672 556 */
charlesmn 0:3ac96e360672 557 uint16_t EffectiveSpadRtnCount;
charlesmn 0:3ac96e360672 558 /*!< Return the effective SPAD count for the return signal.
charlesmn 0:3ac96e360672 559 * To obtain Real value it should be divided by 256
charlesmn 0:3ac96e360672 560 */
charlesmn 0:3ac96e360672 561 int16_t DmaxMilliMeter;
charlesmn 0:3ac96e360672 562 /*!< range Dmax distance in millimeter.
charlesmn 0:3ac96e360672 563 */
charlesmn 0:3ac96e360672 564 VL53L1_DistanceModes RecommendedDistanceMode;
charlesmn 0:3ac96e360672 565 /*!< suggestion for a better distance mode choice to improve
charlesmn 0:3ac96e360672 566 * range accuracy.
charlesmn 0:3ac96e360672 567 */
charlesmn 0:3ac96e360672 568 } VL53L1_MultiRangingData_t;
charlesmn 0:3ac96e360672 569
charlesmn 0:3ac96e360672 570
charlesmn 0:3ac96e360672 571 /** @brief Defines User Zone(ROI) parameters
charlesmn 0:3ac96e360672 572 *
charlesmn 0:3ac96e360672 573 */
charlesmn 0:3ac96e360672 574 typedef struct {
charlesmn 0:3ac96e360672 575
charlesmn 0:3ac96e360672 576 uint8_t TopLeftX; /*!< Top Left x coordinate: 0-15 range */
charlesmn 0:3ac96e360672 577 uint8_t TopLeftY; /*!< Top Left y coordinate: 0-15 range */
charlesmn 0:3ac96e360672 578 uint8_t BotRightX; /*!< Bot Right x coordinate: 0-15 range */
charlesmn 0:3ac96e360672 579 uint8_t BotRightY; /*!< Bot Right y coordinate: 0-15 range */
charlesmn 0:3ac96e360672 580
charlesmn 0:3ac96e360672 581 } VL53L1_UserRoi_t;
charlesmn 0:3ac96e360672 582
charlesmn 0:3ac96e360672 583
charlesmn 0:3ac96e360672 584 /** @brief Defines ROI configuration parameters
charlesmn 0:3ac96e360672 585 *
charlesmn 0:3ac96e360672 586 * Support up a max of 16 zones, Each Zone has the same size
charlesmn 0:3ac96e360672 587 *
charlesmn 0:3ac96e360672 588 */
charlesmn 0:3ac96e360672 589 typedef struct {
charlesmn 0:3ac96e360672 590
charlesmn 0:3ac96e360672 591 uint8_t NumberOfRoi; /*!< Number of Rois defined*/
charlesmn 0:3ac96e360672 592
charlesmn 0:3ac96e360672 593 VL53L1_UserRoi_t UserRois[VL53L1_MAX_USER_ZONES];
charlesmn 0:3ac96e360672 594 /*!< List of Rois */
charlesmn 0:3ac96e360672 595
charlesmn 0:3ac96e360672 596 } VL53L1_RoiConfig_t;
charlesmn 0:3ac96e360672 597
charlesmn 0:3ac96e360672 598 /**
charlesmn 0:3ac96e360672 599 * @struct VL53L1_CustomerNvmManaged_t
charlesmn 0:3ac96e360672 600 *
charlesmn 0:3ac96e360672 601 */
charlesmn 0:3ac96e360672 602
charlesmn 0:3ac96e360672 603 typedef struct {
charlesmn 0:3ac96e360672 604 uint8_t global_config__spad_enables_ref_0;
charlesmn 0:3ac96e360672 605 uint8_t global_config__spad_enables_ref_1;
charlesmn 0:3ac96e360672 606 uint8_t global_config__spad_enables_ref_2;
charlesmn 0:3ac96e360672 607 uint8_t global_config__spad_enables_ref_3;
charlesmn 0:3ac96e360672 608 uint8_t global_config__spad_enables_ref_4;
charlesmn 0:3ac96e360672 609 uint8_t global_config__spad_enables_ref_5;
charlesmn 0:3ac96e360672 610 uint8_t global_config__ref_en_start_select;
charlesmn 0:3ac96e360672 611 uint8_t ref_spad_man__num_requested_ref_spads;
charlesmn 0:3ac96e360672 612 uint8_t ref_spad_man__ref_location;
charlesmn 0:3ac96e360672 613 uint32_t algo__crosstalk_compensation_plane_offset_kcps;
charlesmn 0:3ac96e360672 614 int16_t algo__crosstalk_compensation_x_plane_gradient_kcps;
charlesmn 0:3ac96e360672 615 int16_t algo__crosstalk_compensation_y_plane_gradient_kcps;
charlesmn 0:3ac96e360672 616 uint16_t ref_spad_char__total_rate_target_mcps;
charlesmn 0:3ac96e360672 617 int16_t algo__part_to_part_range_offset_mm;
charlesmn 0:3ac96e360672 618 int16_t mm_config__inner_offset_mm;
charlesmn 0:3ac96e360672 619 int16_t mm_config__outer_offset_mm;
charlesmn 0:3ac96e360672 620 } VL53L1_CustomerNvmManaged_t;
charlesmn 0:3ac96e360672 621
charlesmn 0:3ac96e360672 622 /**
charlesmn 0:3ac96e360672 623 * @struct VL53L1_CalibrationData_t
charlesmn 0:3ac96e360672 624 * @brief Structure for storing the Calibration Data
charlesmn 0:3ac96e360672 625 *
charlesmn 0:3ac96e360672 626 */
charlesmn 0:3ac96e360672 627
charlesmn 0:3ac96e360672 628 typedef struct {
charlesmn 0:3ac96e360672 629
charlesmn 0:3ac96e360672 630 uint32_t struct_version;
charlesmn 0:3ac96e360672 631 VL53L1_CustomerNvmManaged_t customer;
charlesmn 0:3ac96e360672 632 VL53L1_dmax_calibration_data_t fmt_dmax_cal;
charlesmn 0:3ac96e360672 633 VL53L1_dmax_calibration_data_t cust_dmax_cal;
charlesmn 0:3ac96e360672 634 VL53L1_additional_offset_cal_data_t add_off_cal_data;
charlesmn 0:3ac96e360672 635 VL53L1_optical_centre_t optical_centre;
charlesmn 0:3ac96e360672 636 VL53L1_xtalk_histogram_data_t xtalkhisto;
charlesmn 0:3ac96e360672 637 VL53L1_gain_calibration_data_t gain_cal;
charlesmn 0:3ac96e360672 638 VL53L1_cal_peak_rate_map_t cal_peak_rate_map;
charlesmn 0:3ac96e360672 639 VL53L1_per_vcsel_period_offset_cal_data_t per_vcsel_cal_data;
charlesmn 0:3ac96e360672 640 uint32_t algo__xtalk_cpo_HistoMerge_kcps[VL53L1_BIN_REC_SIZE];
charlesmn 0:3ac96e360672 641 } VL53L1_CalibrationData_t;
charlesmn 0:3ac96e360672 642
charlesmn 0:3ac96e360672 643 #define VL53L1_ADDITIONAL_CALIBRATION_DATA_STRUCT_VERSION 0x20
charlesmn 0:3ac96e360672 644 /** VL53L1 additional Calibration Data struct version final struct version
charlesmn 0:3ac96e360672 645 * is given by adding it to VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION
charlesmn 0:3ac96e360672 646 */
charlesmn 0:3ac96e360672 647
charlesmn 0:3ac96e360672 648 #define VL53L1_CALIBRATION_DATA_STRUCT_VERSION \
charlesmn 0:3ac96e360672 649 (VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION + \
charlesmn 0:3ac96e360672 650 VL53L1_ADDITIONAL_CALIBRATION_DATA_STRUCT_VERSION)
charlesmn 0:3ac96e360672 651 /* VL53L1 Calibration Data struct version */
charlesmn 0:3ac96e360672 652
charlesmn 0:3ac96e360672 653 /**
charlesmn 0:3ac96e360672 654 * @struct VL53L1_AdditionalData_t
charlesmn 0:3ac96e360672 655 * @brief Structure for storing the Additional Data
charlesmn 0:3ac96e360672 656 *
charlesmn 0:3ac96e360672 657 */
charlesmn 0:3ac96e360672 658 typedef VL53L1_additional_data_t VL53L1_AdditionalData_t;
charlesmn 0:3ac96e360672 659
charlesmn 0:3ac96e360672 660 /**
charlesmn 0:3ac96e360672 661 * @struct VL53L1_ZoneCalibrationData_t
charlesmn 0:3ac96e360672 662 * @brief Structure for storing the Zone Calibration Data
charlesmn 0:3ac96e360672 663 *
charlesmn 0:3ac96e360672 664 */
charlesmn 0:3ac96e360672 665 typedef VL53L1_zone_calibration_results_t VL53L1_ZoneCalibrationData_t;
charlesmn 0:3ac96e360672 666
charlesmn 0:3ac96e360672 667 /** @defgroup VL53L1_define_SequenceStepId_group Defines the SequenceStep
charlesmn 0:3ac96e360672 668 * Defines the the sequence steps performed during ranging..
charlesmn 0:3ac96e360672 669 * @{
charlesmn 0:3ac96e360672 670 */
charlesmn 0:3ac96e360672 671 typedef uint8_t VL53L1_SequenceStepId;
charlesmn 0:3ac96e360672 672
charlesmn 0:3ac96e360672 673 #define VL53L1_SEQUENCESTEP_VHV ((VL53L1_SequenceStepId) 0)
charlesmn 0:3ac96e360672 674 /*!<VHV. */
charlesmn 0:3ac96e360672 675 #define VL53L1_SEQUENCESTEP_PHASECAL ((VL53L1_SequenceStepId) 1)
charlesmn 0:3ac96e360672 676 /*!<Phase Calibration. */
charlesmn 0:3ac96e360672 677 #define VL53L1_SEQUENCESTEP_REFPHASE ((VL53L1_SequenceStepId) 2)
charlesmn 0:3ac96e360672 678 /*!<Reference Phase. */
charlesmn 0:3ac96e360672 679 #define VL53L1_SEQUENCESTEP_DSS1 ((VL53L1_SequenceStepId) 3)
charlesmn 0:3ac96e360672 680 /*!<DSS1. */
charlesmn 0:3ac96e360672 681 #define VL53L1_SEQUENCESTEP_DSS2 ((VL53L1_SequenceStepId) 4)
charlesmn 0:3ac96e360672 682 /*!<DSS2. */
charlesmn 0:3ac96e360672 683 #define VL53L1_SEQUENCESTEP_MM1 ((VL53L1_SequenceStepId) 5)
charlesmn 0:3ac96e360672 684 /*!<Mode Mitigation 1. */
charlesmn 0:3ac96e360672 685 #define VL53L1_SEQUENCESTEP_MM2 ((VL53L1_SequenceStepId) 6)
charlesmn 0:3ac96e360672 686 /*!<Mode Mitigation 2. */
charlesmn 0:3ac96e360672 687 #define VL53L1_SEQUENCESTEP_RANGE ((VL53L1_SequenceStepId) 7)
charlesmn 0:3ac96e360672 688 /*!<Final Range step. */
charlesmn 0:3ac96e360672 689
charlesmn 0:3ac96e360672 690 #define VL53L1_SEQUENCESTEP_NUMBER_OF_ITEMS 8
charlesmn 0:3ac96e360672 691 /*!<Number of Sequence Step Managed by the API. */
charlesmn 0:3ac96e360672 692
charlesmn 0:3ac96e360672 693 /** @} VL53L1_define_SequenceStepId_group */
charlesmn 0:3ac96e360672 694
charlesmn 0:3ac96e360672 695 /** @defgroup VL53L1_define_RangeStatus_group Defines the Range Status
charlesmn 0:3ac96e360672 696 * @{
charlesmn 0:3ac96e360672 697 */
charlesmn 0:3ac96e360672 698 #define VL53L1_RANGESTATUS_RANGE_VALID 0
charlesmn 0:3ac96e360672 699 /*!<The Range is valid. */
charlesmn 0:3ac96e360672 700 #define VL53L1_RANGESTATUS_SIGMA_FAIL 1
charlesmn 0:3ac96e360672 701 /*!<Sigma Fail. */
charlesmn 0:3ac96e360672 702 #define VL53L1_RANGESTATUS_SIGNAL_FAIL 2
charlesmn 0:3ac96e360672 703 /*!<Signal fail. */
charlesmn 0:3ac96e360672 704 #define VL53L1_RANGESTATUS_RANGE_VALID_MIN_RANGE_CLIPPED 3
charlesmn 0:3ac96e360672 705 /*!<Target is below minimum detection threshold. */
charlesmn 0:3ac96e360672 706 #define VL53L1_RANGESTATUS_OUTOFBOUNDS_FAIL 4
charlesmn 0:3ac96e360672 707 /*!<Phase out of valid limits - different to a wrap exit. */
charlesmn 0:3ac96e360672 708 #define VL53L1_RANGESTATUS_HARDWARE_FAIL 5
charlesmn 0:3ac96e360672 709 /*!<Hardware fail. */
charlesmn 0:3ac96e360672 710 #define VL53L1_RANGESTATUS_RANGE_VALID_NO_WRAP_CHECK_FAIL 6
charlesmn 0:3ac96e360672 711 /*!<The Range is valid but the wraparound check has not been done. */
charlesmn 0:3ac96e360672 712 #define VL53L1_RANGESTATUS_WRAP_TARGET_FAIL 7
charlesmn 0:3ac96e360672 713 /*!<Wrapped target - no matching phase in other VCSEL period timing. */
charlesmn 0:3ac96e360672 714 #define VL53L1_RANGESTATUS_PROCESSING_FAIL 8
charlesmn 0:3ac96e360672 715 /*!<Internal algo underflow or overflow in lite ranging. */
charlesmn 0:3ac96e360672 716 #define VL53L1_RANGESTATUS_XTALK_SIGNAL_FAIL 9
charlesmn 0:3ac96e360672 717 /*!<Specific to lite ranging. */
charlesmn 0:3ac96e360672 718 #define VL53L1_RANGESTATUS_SYNCRONISATION_INT 10
charlesmn 0:3ac96e360672 719 /*!<1st interrupt when starting ranging in back to back mode. Ignore data. */
charlesmn 0:3ac96e360672 720 #define VL53L1_RANGESTATUS_RANGE_VALID_MERGED_PULSE 11
charlesmn 0:3ac96e360672 721 /*!<All Range ok but object is result of multiple pulses merging together.
charlesmn 0:3ac96e360672 722 * Used by RQL for merged pulse detection
charlesmn 0:3ac96e360672 723 */
charlesmn 0:3ac96e360672 724 #define VL53L1_RANGESTATUS_TARGET_PRESENT_LACK_OF_SIGNAL 12
charlesmn 0:3ac96e360672 725 /*!<Used by RQL as different to phase fail. */
charlesmn 0:3ac96e360672 726 #define VL53L1_RANGESTATUS_MIN_RANGE_FAIL 13
charlesmn 0:3ac96e360672 727 /*!<User ROI input is not valid e.g. beyond SPAD Array.*/
charlesmn 0:3ac96e360672 728 #define VL53L1_RANGESTATUS_RANGE_INVALID 14
charlesmn 0:3ac96e360672 729 /*!<lld returned valid range but negative value ! */
charlesmn 0:3ac96e360672 730 #define VL53L1_RANGESTATUS_NONE 255
charlesmn 0:3ac96e360672 731 /*!<No Update. */
charlesmn 0:3ac96e360672 732
charlesmn 0:3ac96e360672 733 /** @} VL53L1_define_RangeStatus_group */
charlesmn 0:3ac96e360672 734
charlesmn 0:3ac96e360672 735
charlesmn 0:3ac96e360672 736 /** @brief Contains the Internal data of the Bare Driver
charlesmn 0:3ac96e360672 737 */
charlesmn 0:3ac96e360672 738
charlesmn 0:3ac96e360672 739 typedef struct {
charlesmn 0:3ac96e360672 740 VL53L1_LLDriverData_t LLData;
charlesmn 0:3ac96e360672 741 /*!< Low Level Driver data structure */
charlesmn 0:3ac96e360672 742
charlesmn 0:3ac96e360672 743 VL53L1_LLDriverResults_t llresults;
charlesmn 0:3ac96e360672 744 /*!< Low Level Driver data structure */
charlesmn 0:3ac96e360672 745
charlesmn 0:3ac96e360672 746 VL53L1_State PalState; /* Store the pal state */
charlesmn 0:3ac96e360672 747 VL53L1_DeviceParameters_t CurrentParameters;
charlesmn 0:3ac96e360672 748 /*!< Current Device Parameter */
charlesmn 0:3ac96e360672 749
charlesmn 0:3ac96e360672 750 } VL53L1_DevData_t;
charlesmn 0:3ac96e360672 751
charlesmn 0:3ac96e360672 752
charlesmn 0:3ac96e360672 753 /* MACRO Definitions */
charlesmn 0:3ac96e360672 754 /** @defgroup VL53L1_define_GeneralMacro_group General Macro Defines
charlesmn 0:3ac96e360672 755 * General Macro Defines
charlesmn 0:3ac96e360672 756 * @{
charlesmn 0:3ac96e360672 757 */
charlesmn 0:3ac96e360672 758
charlesmn 0:3ac96e360672 759 /* Defines */
charlesmn 0:3ac96e360672 760 #define VL53L1_SETPARAMETERFIELD(Dev, field, value) \
charlesmn 0:3ac96e360672 761 (VL53L1DevDataSet(Dev, CurrentParameters.field, value))
charlesmn 0:3ac96e360672 762
charlesmn 0:3ac96e360672 763 #define VL53L1_GETPARAMETERFIELD(Dev, field, variable) \
charlesmn 0:3ac96e360672 764 (variable = VL53L1DevDataGet(Dev, CurrentParameters).field)
charlesmn 0:3ac96e360672 765
charlesmn 0:3ac96e360672 766
charlesmn 0:3ac96e360672 767 #define VL53L1_SETARRAYPARAMETERFIELD(Dev, field, index, value) \
charlesmn 0:3ac96e360672 768 (VL53L1DevDataSet(Dev, CurrentParameters.field[index], value))
charlesmn 0:3ac96e360672 769
charlesmn 0:3ac96e360672 770 #define VL53L1_GETARRAYPARAMETERFIELD(Dev, field, index, variable) \
charlesmn 0:3ac96e360672 771 (variable = VL53L1DevDataGet(Dev, CurrentParameters).field[index])
charlesmn 0:3ac96e360672 772
charlesmn 0:3ac96e360672 773
charlesmn 0:3ac96e360672 774 #define VL53L1_SETDEVICESPECIFICPARAMETER(Dev, field, value) \
charlesmn 0:3ac96e360672 775 (VL53L1DevDataSet(Dev, DeviceSpecificParameters.field, value))
charlesmn 0:3ac96e360672 776
charlesmn 0:3ac96e360672 777 #define VL53L1_GETDEVICESPECIFICPARAMETER(Dev, field) \
charlesmn 0:3ac96e360672 778 (VL53L1DevDataGet(Dev, DeviceSpecificParameters).field)
charlesmn 0:3ac96e360672 779
charlesmn 0:3ac96e360672 780
charlesmn 0:3ac96e360672 781 #define VL53L1_FIXPOINT1616TOFIXPOINT44(Value) \
charlesmn 0:3ac96e360672 782 (uint16_t)((Value>>12)&0xFFFF)
charlesmn 0:3ac96e360672 783 #define VL53L1_FIXPOINT44TOFIXPOINT1616(Value) \
charlesmn 0:3ac96e360672 784 (FixPoint1616_t)((uint32_t)Value<<12)
charlesmn 0:3ac96e360672 785
charlesmn 0:3ac96e360672 786 #define VL53L1_FIXPOINT1616TOFIXPOINT72(Value) \
charlesmn 0:3ac96e360672 787 (uint16_t)((Value>>14)&0xFFFF)
charlesmn 0:3ac96e360672 788 #define VL53L1_FIXPOINT72TOFIXPOINT1616(Value) \
charlesmn 0:3ac96e360672 789 (FixPoint1616_t)((uint32_t)Value<<14)
charlesmn 0:3ac96e360672 790
charlesmn 0:3ac96e360672 791 #define VL53L1_FIXPOINT1616TOFIXPOINT97(Value) \
charlesmn 0:3ac96e360672 792 (uint16_t)((Value>>9)&0xFFFF)
charlesmn 0:3ac96e360672 793 #define VL53L1_FIXPOINT97TOFIXPOINT1616(Value) \
charlesmn 0:3ac96e360672 794 (FixPoint1616_t)((uint32_t)Value<<9)
charlesmn 0:3ac96e360672 795
charlesmn 0:3ac96e360672 796 #define VL53L1_FIXPOINT1616TOFIXPOINT88(Value) \
charlesmn 0:3ac96e360672 797 (uint16_t)((Value>>8)&0xFFFF)
charlesmn 0:3ac96e360672 798 #define VL53L1_FIXPOINT88TOFIXPOINT1616(Value) \
charlesmn 0:3ac96e360672 799 (FixPoint1616_t)((uint32_t)Value<<8)
charlesmn 0:3ac96e360672 800
charlesmn 0:3ac96e360672 801 #define VL53L1_FIXPOINT1616TOFIXPOINT412(Value) \
charlesmn 0:3ac96e360672 802 (uint16_t)((Value>>4)&0xFFFF)
charlesmn 0:3ac96e360672 803 #define VL53L1_FIXPOINT412TOFIXPOINT1616(Value) \
charlesmn 0:3ac96e360672 804 (FixPoint1616_t)((uint32_t)Value<<4)
charlesmn 0:3ac96e360672 805
charlesmn 0:3ac96e360672 806 #define VL53L1_FIXPOINT1616TOFIXPOINT313(Value) \
charlesmn 0:3ac96e360672 807 (uint16_t)((Value>>3)&0xFFFF)
charlesmn 0:3ac96e360672 808 #define VL53L1_FIXPOINT313TOFIXPOINT1616(Value) \
charlesmn 0:3ac96e360672 809 (FixPoint1616_t)((uint32_t)Value<<3)
charlesmn 0:3ac96e360672 810
charlesmn 0:3ac96e360672 811 #define VL53L1_FIXPOINT1616TOFIXPOINT08(Value) \
charlesmn 0:3ac96e360672 812 (uint8_t)((Value>>8)&0x00FF)
charlesmn 0:3ac96e360672 813 #define VL53L1_FIXPOINT08TOFIXPOINT1616(Value) \
charlesmn 0:3ac96e360672 814 (FixPoint1616_t)((uint32_t)Value<<8)
charlesmn 0:3ac96e360672 815
charlesmn 0:3ac96e360672 816 #define VL53L1_FIXPOINT1616TOFIXPOINT53(Value) \
charlesmn 0:3ac96e360672 817 (uint8_t)((Value>>13)&0x00FF)
charlesmn 0:3ac96e360672 818 #define VL53L1_FIXPOINT53TOFIXPOINT1616(Value) \
charlesmn 0:3ac96e360672 819 (FixPoint1616_t)((uint32_t)Value<<13)
charlesmn 0:3ac96e360672 820
charlesmn 0:3ac96e360672 821 #define VL53L1_FIXPOINT1616TOFIXPOINT102(Value) \
charlesmn 0:3ac96e360672 822 (uint16_t)((Value>>14)&0x0FFF)
charlesmn 0:3ac96e360672 823 #define VL53L1_FIXPOINT102TOFIXPOINT1616(Value) \
charlesmn 0:3ac96e360672 824 (FixPoint1616_t)((uint32_t)Value<<14)
charlesmn 0:3ac96e360672 825
charlesmn 0:3ac96e360672 826 #define VL53L1_FIXPOINT1616TOFIXPOINT142(Value) \
charlesmn 0:3ac96e360672 827 (uint16_t)((Value>>14)&0xFFFF)
charlesmn 0:3ac96e360672 828 #define VL53L1_FIXPOINT142TOFIXPOINT1616(Value) \
charlesmn 0:3ac96e360672 829 (FixPoint1616_t)((uint32_t)Value<<14)
charlesmn 0:3ac96e360672 830
charlesmn 0:3ac96e360672 831 #define VL53L1_FIXPOINT1616TOFIXPOINT160(Value) \
charlesmn 0:3ac96e360672 832 (uint16_t)((Value>>16)&0xFFFF)
charlesmn 0:3ac96e360672 833 #define VL53L1_FIXPOINT160TOFIXPOINT1616(Value) \
charlesmn 0:3ac96e360672 834 (FixPoint1616_t)((uint32_t)Value<<16)
charlesmn 0:3ac96e360672 835
charlesmn 0:3ac96e360672 836 #define VL53L1_MAKEUINT16(lsb, msb) (uint16_t)((((uint16_t)msb)<<8) + \
charlesmn 0:3ac96e360672 837 (uint16_t)lsb)
charlesmn 0:3ac96e360672 838
charlesmn 0:3ac96e360672 839 #ifndef SUPPRESS_UNUSED_WARNING
charlesmn 0:3ac96e360672 840 #define SUPPRESS_UNUSED_WARNING(x) ((void) (x))
charlesmn 0:3ac96e360672 841 #endif
charlesmn 0:3ac96e360672 842
charlesmn 0:3ac96e360672 843 /** @} VL53L1_define_GeneralMacro_group */
charlesmn 0:3ac96e360672 844
charlesmn 0:3ac96e360672 845 /** @} VL53L1_globaldefine_group */
charlesmn 0:3ac96e360672 846
charlesmn 0:3ac96e360672 847
charlesmn 0:3ac96e360672 848
charlesmn 0:3ac96e360672 849 #ifdef __cplusplus
charlesmn 0:3ac96e360672 850 }
charlesmn 0:3ac96e360672 851 #endif
charlesmn 0:3ac96e360672 852
charlesmn 0:3ac96e360672 853
charlesmn 0:3ac96e360672 854 #endif /* _VL53L1_DEF_H_ */
charlesmn 0:3ac96e360672 855