Condensed Version of Public VL53L0X

Dependents:   ToF-Only-Tryout

Committer:
mapellil
Date:
Mon Dec 18 08:27:21 2017 +0000
Revision:
4:d25c4fa216af
Parent:
2:d07edeaff6f1
Child:
5:b95f6951f7d5
Added vl53l0x_get_device() API

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nikapov 0:a1a69d32f310 1 /*******************************************************************************
nikapov 0:a1a69d32f310 2 Copyright © 2016, STMicroelectronics International N.V.
nikapov 0:a1a69d32f310 3 All rights reserved.
nikapov 0:a1a69d32f310 4
nikapov 0:a1a69d32f310 5 Redistribution and use in source and binary forms, with or without
nikapov 0:a1a69d32f310 6 modification, are permitted provided that the following conditions are met:
nikapov 0:a1a69d32f310 7 * Redistributions of source code must retain the above copyright
nikapov 0:a1a69d32f310 8 notice, this list of conditions and the following disclaimer.
nikapov 0:a1a69d32f310 9 * Redistributions in binary form must reproduce the above copyright
nikapov 0:a1a69d32f310 10 notice, this list of conditions and the following disclaimer in the
nikapov 0:a1a69d32f310 11 documentation and/or other materials provided with the distribution.
nikapov 0:a1a69d32f310 12 * Neither the name of STMicroelectronics nor the
nikapov 0:a1a69d32f310 13 names of its contributors may be used to endorse or promote products
nikapov 0:a1a69d32f310 14 derived from this software without specific prior written permission.
nikapov 0:a1a69d32f310 15
nikapov 0:a1a69d32f310 16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
nikapov 0:a1a69d32f310 17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
nikapov 0:a1a69d32f310 18 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
nikapov 0:a1a69d32f310 19 NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
nikapov 0:a1a69d32f310 20 IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
nikapov 0:a1a69d32f310 21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
nikapov 0:a1a69d32f310 22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
nikapov 0:a1a69d32f310 23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
nikapov 0:a1a69d32f310 24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
nikapov 0:a1a69d32f310 25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
nikapov 0:a1a69d32f310 26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
nikapov 0:a1a69d32f310 27 *****************************************************************************/
nikapov 0:a1a69d32f310 28
nikapov 0:a1a69d32f310 29 #ifndef __VL53L0X_CLASS_H
nikapov 0:a1a69d32f310 30 #define __VL53L0X_CLASS_H
nikapov 0:a1a69d32f310 31
nikapov 0:a1a69d32f310 32
nikapov 0:a1a69d32f310 33 #ifdef _MSC_VER
nikapov 0:a1a69d32f310 34 # ifdef VL53L0X_API_EXPORTS
nikapov 0:a1a69d32f310 35 # define VL53L0X_API __declspec(dllexport)
nikapov 0:a1a69d32f310 36 # else
nikapov 0:a1a69d32f310 37 # define VL53L0X_API
nikapov 0:a1a69d32f310 38 # endif
nikapov 0:a1a69d32f310 39 #else
nikapov 0:a1a69d32f310 40 # define VL53L0X_API
nikapov 0:a1a69d32f310 41 #endif
nikapov 0:a1a69d32f310 42
nikapov 0:a1a69d32f310 43
nikapov 0:a1a69d32f310 44 /* Includes ------------------------------------------------------------------*/
nikapov 0:a1a69d32f310 45 #include "mbed.h"
nikapov 0:a1a69d32f310 46 #include "RangeSensor.h"
nikapov 0:a1a69d32f310 47 #include "DevI2C.h"
nikapov 0:a1a69d32f310 48 #include "PinNames.h"
nikapov 0:a1a69d32f310 49 #include "VL53L0X_def.h"
nikapov 0:a1a69d32f310 50 #include "VL53L0X_platform.h"
nikapov 0:a1a69d32f310 51 #include "Stmpe1600.h"
nikapov 0:a1a69d32f310 52
nikapov 0:a1a69d32f310 53
nikapov 0:a1a69d32f310 54 /**
nikapov 0:a1a69d32f310 55 * The device model ID
nikapov 0:a1a69d32f310 56 */
nikapov 0:a1a69d32f310 57 #define IDENTIFICATION_MODEL_ID 0x000
nikapov 0:a1a69d32f310 58
nikapov 0:a1a69d32f310 59
nikapov 0:a1a69d32f310 60 #define STATUS_OK 0x00
nikapov 0:a1a69d32f310 61 #define STATUS_FAIL 0x01
nikapov 0:a1a69d32f310 62
nikapov 0:a1a69d32f310 63 #define VL53L0X_OsDelay(...) wait_ms(2) // 2 msec delay. can also use wait(float secs)/wait_us(int)
nikapov 0:a1a69d32f310 64
nikapov 0:a1a69d32f310 65 #ifdef USE_EMPTY_STRING
nikapov 0:a1a69d32f310 66 #define VL53L0X_STRING_DEVICE_INFO_NAME ""
nikapov 0:a1a69d32f310 67 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS0 ""
nikapov 0:a1a69d32f310 68 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS1 ""
nikapov 0:a1a69d32f310 69 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS2 ""
nikapov 0:a1a69d32f310 70 #define VL53L0X_STRING_DEVICE_INFO_NAME_ES1 ""
nikapov 0:a1a69d32f310 71 #define VL53L0X_STRING_DEVICE_INFO_TYPE ""
nikapov 0:a1a69d32f310 72
nikapov 0:a1a69d32f310 73 /* PAL ERROR strings */
nikapov 0:a1a69d32f310 74 #define VL53L0X_STRING_ERROR_NONE ""
nikapov 0:a1a69d32f310 75 #define VL53L0X_STRING_ERROR_CALIBRATION_WARNING ""
nikapov 0:a1a69d32f310 76 #define VL53L0X_STRING_ERROR_MIN_CLIPPED ""
nikapov 0:a1a69d32f310 77 #define VL53L0X_STRING_ERROR_UNDEFINED ""
nikapov 0:a1a69d32f310 78 #define VL53L0X_STRING_ERROR_INVALID_PARAMS ""
nikapov 0:a1a69d32f310 79 #define VL53L0X_STRING_ERROR_NOT_SUPPORTED ""
nikapov 0:a1a69d32f310 80 #define VL53L0X_STRING_ERROR_RANGE_ERROR ""
nikapov 0:a1a69d32f310 81 #define VL53L0X_STRING_ERROR_TIME_OUT ""
nikapov 0:a1a69d32f310 82 #define VL53L0X_STRING_ERROR_MODE_NOT_SUPPORTED ""
nikapov 0:a1a69d32f310 83 #define VL53L0X_STRING_ERROR_BUFFER_TOO_SMALL ""
nikapov 0:a1a69d32f310 84 #define VL53L0X_STRING_ERROR_GPIO_NOT_EXISTING ""
nikapov 0:a1a69d32f310 85 #define VL53L0X_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED ""
nikapov 0:a1a69d32f310 86 #define VL53L0X_STRING_ERROR_CONTROL_INTERFACE ""
nikapov 0:a1a69d32f310 87 #define VL53L0X_STRING_ERROR_INVALID_COMMAND ""
nikapov 0:a1a69d32f310 88 #define VL53L0X_STRING_ERROR_DIVISION_BY_ZERO ""
nikapov 0:a1a69d32f310 89 #define VL53L0X_STRING_ERROR_REF_SPAD_INIT ""
nikapov 0:a1a69d32f310 90 #define VL53L0X_STRING_ERROR_NOT_IMPLEMENTED ""
nikapov 0:a1a69d32f310 91
nikapov 0:a1a69d32f310 92 #define VL53L0X_STRING_UNKNOW_ERROR_CODE ""
nikapov 0:a1a69d32f310 93
nikapov 0:a1a69d32f310 94
nikapov 0:a1a69d32f310 95
nikapov 0:a1a69d32f310 96 /* Range Status */
nikapov 0:a1a69d32f310 97 #define VL53L0X_STRING_RANGESTATUS_NONE ""
nikapov 0:a1a69d32f310 98 #define VL53L0X_STRING_RANGESTATUS_RANGEVALID ""
nikapov 0:a1a69d32f310 99 #define VL53L0X_STRING_RANGESTATUS_SIGMA ""
nikapov 0:a1a69d32f310 100 #define VL53L0X_STRING_RANGESTATUS_SIGNAL ""
nikapov 0:a1a69d32f310 101 #define VL53L0X_STRING_RANGESTATUS_MINRANGE ""
nikapov 0:a1a69d32f310 102 #define VL53L0X_STRING_RANGESTATUS_PHASE ""
nikapov 0:a1a69d32f310 103 #define VL53L0X_STRING_RANGESTATUS_HW ""
nikapov 0:a1a69d32f310 104
nikapov 0:a1a69d32f310 105
nikapov 0:a1a69d32f310 106 /* Range Status */
nikapov 0:a1a69d32f310 107 #define VL53L0X_STRING_STATE_POWERDOWN ""
nikapov 0:a1a69d32f310 108 #define VL53L0X_STRING_STATE_WAIT_STATICINIT ""
nikapov 0:a1a69d32f310 109 #define VL53L0X_STRING_STATE_STANDBY ""
nikapov 0:a1a69d32f310 110 #define VL53L0X_STRING_STATE_IDLE ""
nikapov 0:a1a69d32f310 111 #define VL53L0X_STRING_STATE_RUNNING ""
nikapov 0:a1a69d32f310 112 #define VL53L0X_STRING_STATE_UNKNOWN ""
nikapov 0:a1a69d32f310 113 #define VL53L0X_STRING_STATE_ERROR ""
nikapov 0:a1a69d32f310 114
nikapov 0:a1a69d32f310 115
nikapov 0:a1a69d32f310 116 /* Device Specific */
nikapov 0:a1a69d32f310 117 #define VL53L0X_STRING_DEVICEERROR_NONE ""
nikapov 0:a1a69d32f310 118 #define VL53L0X_STRING_DEVICEERROR_VCSELCONTINUITYTESTFAILURE ""
nikapov 0:a1a69d32f310 119 #define VL53L0X_STRING_DEVICEERROR_VCSELWATCHDOGTESTFAILURE ""
nikapov 0:a1a69d32f310 120 #define VL53L0X_STRING_DEVICEERROR_NOVHVVALUEFOUND ""
nikapov 0:a1a69d32f310 121 #define VL53L0X_STRING_DEVICEERROR_MSRCNOTARGET ""
nikapov 0:a1a69d32f310 122 #define VL53L0X_STRING_DEVICEERROR_SNRCHECK ""
nikapov 0:a1a69d32f310 123 #define VL53L0X_STRING_DEVICEERROR_RANGEPHASECHECK ""
nikapov 0:a1a69d32f310 124 #define VL53L0X_STRING_DEVICEERROR_SIGMATHRESHOLDCHECK ""
nikapov 0:a1a69d32f310 125 #define VL53L0X_STRING_DEVICEERROR_TCC ""
nikapov 0:a1a69d32f310 126 #define VL53L0X_STRING_DEVICEERROR_PHASECONSISTENCY ""
nikapov 0:a1a69d32f310 127 #define VL53L0X_STRING_DEVICEERROR_MINCLIP ""
nikapov 0:a1a69d32f310 128 #define VL53L0X_STRING_DEVICEERROR_RANGECOMPLETE ""
nikapov 0:a1a69d32f310 129 #define VL53L0X_STRING_DEVICEERROR_ALGOUNDERFLOW ""
nikapov 0:a1a69d32f310 130 #define VL53L0X_STRING_DEVICEERROR_ALGOOVERFLOW ""
nikapov 0:a1a69d32f310 131 #define VL53L0X_STRING_DEVICEERROR_RANGEIGNORETHRESHOLD ""
nikapov 0:a1a69d32f310 132 #define VL53L0X_STRING_DEVICEERROR_UNKNOWN ""
nikapov 0:a1a69d32f310 133
nikapov 0:a1a69d32f310 134 /* Check Enable */
nikapov 0:a1a69d32f310 135 #define VL53L0X_STRING_CHECKENABLE_SIGMA_FINAL_RANGE ""
nikapov 0:a1a69d32f310 136 #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE ""
nikapov 0:a1a69d32f310 137 #define VL53L0X_STRING_CHECKENABLE_SIGNAL_REF_CLIP ""
nikapov 0:a1a69d32f310 138 #define VL53L0X_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD ""
nikapov 0:a1a69d32f310 139
nikapov 0:a1a69d32f310 140 /* Sequence Step */
nikapov 0:a1a69d32f310 141 #define VL53L0X_STRING_SEQUENCESTEP_TCC ""
nikapov 0:a1a69d32f310 142 #define VL53L0X_STRING_SEQUENCESTEP_DSS ""
nikapov 0:a1a69d32f310 143 #define VL53L0X_STRING_SEQUENCESTEP_MSRC ""
nikapov 0:a1a69d32f310 144 #define VL53L0X_STRING_SEQUENCESTEP_PRE_RANGE ""
nikapov 0:a1a69d32f310 145 #define VL53L0X_STRING_SEQUENCESTEP_FINAL_RANGE ""
nikapov 0:a1a69d32f310 146 #else
nikapov 0:a1a69d32f310 147 #define VL53L0X_STRING_DEVICE_INFO_NAME "VL53L0X cut1.0"
nikapov 0:a1a69d32f310 148 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS0 "VL53L0X TS0"
nikapov 0:a1a69d32f310 149 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS1 "VL53L0X TS1"
nikapov 0:a1a69d32f310 150 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS2 "VL53L0X TS2"
nikapov 0:a1a69d32f310 151 #define VL53L0X_STRING_DEVICE_INFO_NAME_ES1 "VL53L0X ES1 or later"
nikapov 0:a1a69d32f310 152 #define VL53L0X_STRING_DEVICE_INFO_TYPE "VL53L0X"
nikapov 0:a1a69d32f310 153
nikapov 0:a1a69d32f310 154 /* PAL ERROR strings */
nikapov 0:a1a69d32f310 155 #define VL53L0X_STRING_ERROR_NONE \
nikapov 0:a1a69d32f310 156 "No Error"
nikapov 0:a1a69d32f310 157 #define VL53L0X_STRING_ERROR_CALIBRATION_WARNING \
nikapov 0:a1a69d32f310 158 "Calibration Warning Error"
nikapov 0:a1a69d32f310 159 #define VL53L0X_STRING_ERROR_MIN_CLIPPED \
nikapov 0:a1a69d32f310 160 "Min clipped error"
nikapov 0:a1a69d32f310 161 #define VL53L0X_STRING_ERROR_UNDEFINED \
nikapov 0:a1a69d32f310 162 "Undefined error"
nikapov 0:a1a69d32f310 163 #define VL53L0X_STRING_ERROR_INVALID_PARAMS \
nikapov 0:a1a69d32f310 164 "Invalid parameters error"
nikapov 0:a1a69d32f310 165 #define VL53L0X_STRING_ERROR_NOT_SUPPORTED \
nikapov 0:a1a69d32f310 166 "Not supported error"
nikapov 0:a1a69d32f310 167 #define VL53L0X_STRING_ERROR_RANGE_ERROR \
nikapov 0:a1a69d32f310 168 "Range error"
nikapov 0:a1a69d32f310 169 #define VL53L0X_STRING_ERROR_TIME_OUT \
nikapov 0:a1a69d32f310 170 "Time out error"
nikapov 0:a1a69d32f310 171 #define VL53L0X_STRING_ERROR_MODE_NOT_SUPPORTED \
nikapov 0:a1a69d32f310 172 "Mode not supported error"
nikapov 0:a1a69d32f310 173 #define VL53L0X_STRING_ERROR_BUFFER_TOO_SMALL \
nikapov 0:a1a69d32f310 174 "Buffer too small"
nikapov 0:a1a69d32f310 175 #define VL53L0X_STRING_ERROR_GPIO_NOT_EXISTING \
nikapov 0:a1a69d32f310 176 "GPIO not existing"
nikapov 0:a1a69d32f310 177 #define VL53L0X_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED \
nikapov 0:a1a69d32f310 178 "GPIO funct not supported"
nikapov 0:a1a69d32f310 179 #define VL53L0X_STRING_ERROR_INTERRUPT_NOT_CLEARED \
nikapov 0:a1a69d32f310 180 "Interrupt not Cleared"
nikapov 0:a1a69d32f310 181 #define VL53L0X_STRING_ERROR_CONTROL_INTERFACE \
nikapov 0:a1a69d32f310 182 "Control Interface Error"
nikapov 0:a1a69d32f310 183 #define VL53L0X_STRING_ERROR_INVALID_COMMAND \
nikapov 0:a1a69d32f310 184 "Invalid Command Error"
nikapov 0:a1a69d32f310 185 #define VL53L0X_STRING_ERROR_DIVISION_BY_ZERO \
nikapov 0:a1a69d32f310 186 "Division by zero Error"
nikapov 0:a1a69d32f310 187 #define VL53L0X_STRING_ERROR_REF_SPAD_INIT \
nikapov 0:a1a69d32f310 188 "Reference Spad Init Error"
nikapov 0:a1a69d32f310 189 #define VL53L0X_STRING_ERROR_NOT_IMPLEMENTED \
nikapov 0:a1a69d32f310 190 "Not implemented error"
nikapov 0:a1a69d32f310 191
nikapov 0:a1a69d32f310 192 #define VL53L0X_STRING_UNKNOW_ERROR_CODE \
nikapov 0:a1a69d32f310 193 "Unknown Error Code"
nikapov 0:a1a69d32f310 194
nikapov 0:a1a69d32f310 195
nikapov 0:a1a69d32f310 196
nikapov 0:a1a69d32f310 197 /* Range Status */
nikapov 0:a1a69d32f310 198 #define VL53L0X_STRING_RANGESTATUS_NONE "No Update"
nikapov 0:a1a69d32f310 199 #define VL53L0X_STRING_RANGESTATUS_RANGEVALID "Range Valid"
nikapov 0:a1a69d32f310 200 #define VL53L0X_STRING_RANGESTATUS_SIGMA "Sigma Fail"
nikapov 0:a1a69d32f310 201 #define VL53L0X_STRING_RANGESTATUS_SIGNAL "Signal Fail"
nikapov 0:a1a69d32f310 202 #define VL53L0X_STRING_RANGESTATUS_MINRANGE "Min Range Fail"
nikapov 0:a1a69d32f310 203 #define VL53L0X_STRING_RANGESTATUS_PHASE "Phase Fail"
nikapov 0:a1a69d32f310 204 #define VL53L0X_STRING_RANGESTATUS_HW "Hardware Fail"
nikapov 0:a1a69d32f310 205
nikapov 0:a1a69d32f310 206
nikapov 0:a1a69d32f310 207 /* Range Status */
nikapov 0:a1a69d32f310 208 #define VL53L0X_STRING_STATE_POWERDOWN "POWERDOWN State"
nikapov 0:a1a69d32f310 209 #define VL53L0X_STRING_STATE_WAIT_STATICINIT \
nikapov 0:a1a69d32f310 210 "Wait for staticinit State"
nikapov 0:a1a69d32f310 211 #define VL53L0X_STRING_STATE_STANDBY "STANDBY State"
nikapov 0:a1a69d32f310 212 #define VL53L0X_STRING_STATE_IDLE "IDLE State"
nikapov 0:a1a69d32f310 213 #define VL53L0X_STRING_STATE_RUNNING "RUNNING State"
nikapov 0:a1a69d32f310 214 #define VL53L0X_STRING_STATE_UNKNOWN "UNKNOWN State"
nikapov 0:a1a69d32f310 215 #define VL53L0X_STRING_STATE_ERROR "ERROR State"
nikapov 0:a1a69d32f310 216
nikapov 0:a1a69d32f310 217
nikapov 0:a1a69d32f310 218 /* Device Specific */
nikapov 0:a1a69d32f310 219 #define VL53L0X_STRING_DEVICEERROR_NONE "No Update"
nikapov 0:a1a69d32f310 220 #define VL53L0X_STRING_DEVICEERROR_VCSELCONTINUITYTESTFAILURE \
nikapov 0:a1a69d32f310 221 "VCSEL Continuity Test Failure"
nikapov 0:a1a69d32f310 222 #define VL53L0X_STRING_DEVICEERROR_VCSELWATCHDOGTESTFAILURE \
nikapov 0:a1a69d32f310 223 "VCSEL Watchdog Test Failure"
nikapov 0:a1a69d32f310 224 #define VL53L0X_STRING_DEVICEERROR_NOVHVVALUEFOUND \
nikapov 0:a1a69d32f310 225 "No VHV Value found"
nikapov 0:a1a69d32f310 226 #define VL53L0X_STRING_DEVICEERROR_MSRCNOTARGET \
nikapov 0:a1a69d32f310 227 "MSRC No Target Error"
nikapov 0:a1a69d32f310 228 #define VL53L0X_STRING_DEVICEERROR_SNRCHECK \
nikapov 0:a1a69d32f310 229 "SNR Check Exit"
nikapov 0:a1a69d32f310 230 #define VL53L0X_STRING_DEVICEERROR_RANGEPHASECHECK \
nikapov 0:a1a69d32f310 231 "Range Phase Check Error"
nikapov 0:a1a69d32f310 232 #define VL53L0X_STRING_DEVICEERROR_SIGMATHRESHOLDCHECK \
nikapov 0:a1a69d32f310 233 "Sigma Threshold Check Error"
nikapov 0:a1a69d32f310 234 #define VL53L0X_STRING_DEVICEERROR_TCC \
nikapov 0:a1a69d32f310 235 "TCC Error"
nikapov 0:a1a69d32f310 236 #define VL53L0X_STRING_DEVICEERROR_PHASECONSISTENCY \
nikapov 0:a1a69d32f310 237 "Phase Consistency Error"
nikapov 0:a1a69d32f310 238 #define VL53L0X_STRING_DEVICEERROR_MINCLIP \
nikapov 0:a1a69d32f310 239 "Min Clip Error"
nikapov 0:a1a69d32f310 240 #define VL53L0X_STRING_DEVICEERROR_RANGECOMPLETE \
nikapov 0:a1a69d32f310 241 "Range Complete"
nikapov 0:a1a69d32f310 242 #define VL53L0X_STRING_DEVICEERROR_ALGOUNDERFLOW \
nikapov 0:a1a69d32f310 243 "Range Algo Underflow Error"
nikapov 0:a1a69d32f310 244 #define VL53L0X_STRING_DEVICEERROR_ALGOOVERFLOW \
nikapov 0:a1a69d32f310 245 "Range Algo Overlow Error"
nikapov 0:a1a69d32f310 246 #define VL53L0X_STRING_DEVICEERROR_RANGEIGNORETHRESHOLD \
nikapov 0:a1a69d32f310 247 "Range Ignore Threshold Error"
nikapov 0:a1a69d32f310 248 #define VL53L0X_STRING_DEVICEERROR_UNKNOWN \
nikapov 0:a1a69d32f310 249 "Unknown error code"
nikapov 0:a1a69d32f310 250
nikapov 0:a1a69d32f310 251 /* Check Enable */
nikapov 0:a1a69d32f310 252 #define VL53L0X_STRING_CHECKENABLE_SIGMA_FINAL_RANGE \
nikapov 0:a1a69d32f310 253 "SIGMA FINAL RANGE"
nikapov 0:a1a69d32f310 254 #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE \
nikapov 0:a1a69d32f310 255 "SIGNAL RATE FINAL RANGE"
nikapov 0:a1a69d32f310 256 #define VL53L0X_STRING_CHECKENABLE_SIGNAL_REF_CLIP \
nikapov 0:a1a69d32f310 257 "SIGNAL REF CLIP"
nikapov 0:a1a69d32f310 258 #define VL53L0X_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD \
nikapov 0:a1a69d32f310 259 "RANGE IGNORE THRESHOLD"
nikapov 0:a1a69d32f310 260 #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_MSRC \
nikapov 0:a1a69d32f310 261 "SIGNAL RATE MSRC"
nikapov 0:a1a69d32f310 262 #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_PRE_RANGE \
nikapov 0:a1a69d32f310 263 "SIGNAL RATE PRE RANGE"
nikapov 0:a1a69d32f310 264
nikapov 0:a1a69d32f310 265 /* Sequence Step */
nikapov 0:a1a69d32f310 266 #define VL53L0X_STRING_SEQUENCESTEP_TCC "TCC"
nikapov 0:a1a69d32f310 267 #define VL53L0X_STRING_SEQUENCESTEP_DSS "DSS"
nikapov 0:a1a69d32f310 268 #define VL53L0X_STRING_SEQUENCESTEP_MSRC "MSRC"
nikapov 0:a1a69d32f310 269 #define VL53L0X_STRING_SEQUENCESTEP_PRE_RANGE "PRE RANGE"
nikapov 0:a1a69d32f310 270 #define VL53L0X_STRING_SEQUENCESTEP_FINAL_RANGE "FINAL RANGE"
nikapov 0:a1a69d32f310 271 #endif /* USE_EMPTY_STRING */
nikapov 0:a1a69d32f310 272
nikapov 0:a1a69d32f310 273 /* sensor operating modes */
nikapov 0:a1a69d32f310 274 typedef enum {
nikapov 0:a1a69d32f310 275 range_single_shot_polling = 1,
nikapov 0:a1a69d32f310 276 range_continuous_polling,
nikapov 0:a1a69d32f310 277 range_continuous_interrupt,
nikapov 0:a1a69d32f310 278 range_continuous_polling_low_threshold,
nikapov 0:a1a69d32f310 279 range_continuous_polling_high_threshold,
nikapov 0:a1a69d32f310 280 range_continuous_polling_out_of_window,
nikapov 0:a1a69d32f310 281 range_continuous_interrupt_low_threshold,
nikapov 0:a1a69d32f310 282 range_continuous_interrupt_high_threshold,
nikapov 0:a1a69d32f310 283 range_continuous_interrupt_out_of_window,
nikapov 0:a1a69d32f310 284 } OperatingMode;
nikapov 0:a1a69d32f310 285
nikapov 0:a1a69d32f310 286 /** default device address */
nikapov 1:834986cdde0a 287 #define VL53L0X_DEFAULT_ADDRESS 0x52 /* (8-bit) */
nikapov 0:a1a69d32f310 288
nikapov 0:a1a69d32f310 289 /* Classes -------------------------------------------------------------------*/
nikapov 0:a1a69d32f310 290 /** Class representing a VL53L0 sensor component
nikapov 0:a1a69d32f310 291 */
nikapov 0:a1a69d32f310 292 class VL53L0X : public RangeSensor
nikapov 0:a1a69d32f310 293 {
nikapov 0:a1a69d32f310 294 public:
nikapov 0:a1a69d32f310 295 /** Constructor
nikapov 0:a1a69d32f310 296 * @param[in] &i2c device I2C to be used for communication
nikapov 0:a1a69d32f310 297 * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
nikapov 0:a1a69d32f310 298 * @param[in] dev_addr device address, 0x29 by default
nikapov 0:a1a69d32f310 299 */
nikapov 1:834986cdde0a 300 VL53L0X(DevI2C *i2c, DigitalOut *pin, PinName pin_gpio1, uint8_t dev_addr = VL53L0X_DEFAULT_ADDRESS) : _dev_i2c(i2c),
nikapov 0:a1a69d32f310 301 _gpio0(pin)
nikapov 0:a1a69d32f310 302 {
nikapov 0:a1a69d32f310 303 _my_device.I2cDevAddr = dev_addr;
nikapov 0:a1a69d32f310 304 _my_device.comms_type = 1; // VL53L0X_COMMS_I2C
nikapov 0:a1a69d32f310 305 _my_device.comms_speed_khz = 400;
nikapov 0:a1a69d32f310 306 _device = &_my_device;
nikapov 0:a1a69d32f310 307 _expgpio0 = NULL;
nikapov 0:a1a69d32f310 308 if (pin_gpio1 != NC) {
nikapov 0:a1a69d32f310 309 _gpio1Int = new InterruptIn(pin_gpio1);
nikapov 0:a1a69d32f310 310 } else {
nikapov 0:a1a69d32f310 311 _gpio1Int = NULL;
nikapov 0:a1a69d32f310 312 }
nikapov 0:a1a69d32f310 313 }
nikapov 0:a1a69d32f310 314
nikapov 0:a1a69d32f310 315 /** Constructor 2 (STMPE1600DigiOut)
nikapov 0:a1a69d32f310 316 * @param[in] i2c device I2C to be used for communication
nikapov 0:a1a69d32f310 317 * @param[in] &pin Gpio Expander STMPE1600DigiOut pin to be used as component GPIO_0 CE
nikapov 0:a1a69d32f310 318 * @param[in] pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
nikapov 0:a1a69d32f310 319 * @param[in] device address, 0x29 by default
nikapov 0:a1a69d32f310 320 */
nikapov 0:a1a69d32f310 321 VL53L0X(DevI2C *i2c, Stmpe1600DigiOut *pin, PinName pin_gpio1,
nikapov 1:834986cdde0a 322 uint8_t dev_addr = VL53L0X_DEFAULT_ADDRESS) : _dev_i2c(i2c), _expgpio0(pin)
nikapov 0:a1a69d32f310 323 {
nikapov 0:a1a69d32f310 324 _my_device.I2cDevAddr = dev_addr;
nikapov 0:a1a69d32f310 325 _my_device.comms_type = 1; // VL53L0X_COMMS_I2C
nikapov 0:a1a69d32f310 326 _my_device.comms_speed_khz = 400;
nikapov 0:a1a69d32f310 327 _device = &_my_device;
nikapov 0:a1a69d32f310 328 _gpio0 = NULL;
nikapov 0:a1a69d32f310 329 if (pin_gpio1 != NC) {
nikapov 0:a1a69d32f310 330 _gpio1Int = new InterruptIn(pin_gpio1);
nikapov 0:a1a69d32f310 331 } else {
nikapov 0:a1a69d32f310 332 _gpio1Int = NULL;
nikapov 0:a1a69d32f310 333 }
nikapov 0:a1a69d32f310 334 }
nikapov 0:a1a69d32f310 335
nikapov 0:a1a69d32f310 336 /** Destructor
nikapov 0:a1a69d32f310 337 */
nikapov 0:a1a69d32f310 338 virtual ~VL53L0X()
nikapov 0:a1a69d32f310 339 {
nikapov 0:a1a69d32f310 340 if (_gpio1Int != NULL) {
nikapov 0:a1a69d32f310 341 delete _gpio1Int;
nikapov 0:a1a69d32f310 342 }
nikapov 0:a1a69d32f310 343 }
nikapov 0:a1a69d32f310 344
nikapov 0:a1a69d32f310 345 /*** Interface Methods ***/
nikapov 0:a1a69d32f310 346 /*** High level API ***/
nikapov 0:a1a69d32f310 347 /**
nikapov 0:a1a69d32f310 348 * @brief PowerOn the sensor
nikapov 0:a1a69d32f310 349 * @return void
nikapov 0:a1a69d32f310 350 */
nikapov 0:a1a69d32f310 351 /* turns on the sensor */
nikapov 0:a1a69d32f310 352 void VL53L0X_on(void)
nikapov 0:a1a69d32f310 353 {
nikapov 0:a1a69d32f310 354 if (_gpio0) {
nikapov 0:a1a69d32f310 355 *_gpio0 = 1;
nikapov 0:a1a69d32f310 356 } else {
nikapov 0:a1a69d32f310 357 if (_expgpio0) {
Davidroid 2:d07edeaff6f1 358 *_expgpio0 = 1;
Davidroid 2:d07edeaff6f1 359 }
Davidroid 2:d07edeaff6f1 360 }
nikapov 0:a1a69d32f310 361 wait_ms(10);
nikapov 0:a1a69d32f310 362 }
nikapov 0:a1a69d32f310 363
nikapov 0:a1a69d32f310 364 /**
nikapov 0:a1a69d32f310 365 * @brief PowerOff the sensor
nikapov 0:a1a69d32f310 366 * @return void
nikapov 0:a1a69d32f310 367 */
nikapov 0:a1a69d32f310 368 /* turns off the sensor */
nikapov 0:a1a69d32f310 369 void VL53L0X_off(void)
nikapov 0:a1a69d32f310 370 {
nikapov 0:a1a69d32f310 371 if (_gpio0) {
nikapov 0:a1a69d32f310 372 *_gpio0 = 0;
nikapov 0:a1a69d32f310 373 } else {
nikapov 0:a1a69d32f310 374 if (_expgpio0) {
Davidroid 2:d07edeaff6f1 375 *_expgpio0 = 0;
Davidroid 2:d07edeaff6f1 376 }
Davidroid 2:d07edeaff6f1 377 }
nikapov 0:a1a69d32f310 378 wait_ms(10);
nikapov 0:a1a69d32f310 379 }
Davidroid 2:d07edeaff6f1 380
nikapov 0:a1a69d32f310 381
nikapov 0:a1a69d32f310 382 /**
nikapov 0:a1a69d32f310 383 * @brief Initialize the sensor with default values
nikapov 0:a1a69d32f310 384 * @return "0" on success
nikapov 0:a1a69d32f310 385 */
nikapov 0:a1a69d32f310 386 int init_sensor(uint8_t new_addr);
nikapov 0:a1a69d32f310 387
nikapov 0:a1a69d32f310 388 /**
nikapov 0:a1a69d32f310 389 * @brief Start the measure indicated by operating mode
nikapov 0:a1a69d32f310 390 * @param[in] operating_mode specifies requested measure
nikapov 0:a1a69d32f310 391 * @param[in] fptr specifies call back function must be !NULL in case of interrupt measure
nikapov 0:a1a69d32f310 392 * @return "0" on success
nikapov 0:a1a69d32f310 393 */
nikapov 0:a1a69d32f310 394 int start_measurement(OperatingMode operating_mode, void (*fptr)(void));
nikapov 0:a1a69d32f310 395
nikapov 0:a1a69d32f310 396 /**
nikapov 0:a1a69d32f310 397 * @brief Get results for the measure indicated by operating mode
nikapov 0:a1a69d32f310 398 * @param[in] operating_mode specifies requested measure results
nikapov 0:a1a69d32f310 399 * @param[out] p_data pointer to the MeasureData_t structure to read data in to
nikapov 0:a1a69d32f310 400 * @return "0" on success
nikapov 0:a1a69d32f310 401 */
nikapov 0:a1a69d32f310 402 int get_measurement(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *p_data);
nikapov 0:a1a69d32f310 403
nikapov 0:a1a69d32f310 404 /**
nikapov 0:a1a69d32f310 405 * @brief Stop the currently running measure indicate by operating_mode
nikapov 0:a1a69d32f310 406 * @param[in] operating_mode specifies requested measure to stop
nikapov 0:a1a69d32f310 407 * @return "0" on success
nikapov 0:a1a69d32f310 408 */
nikapov 0:a1a69d32f310 409 int stop_measurement(OperatingMode operating_mode);
nikapov 0:a1a69d32f310 410
nikapov 0:a1a69d32f310 411 /**
nikapov 0:a1a69d32f310 412 * @brief Interrupt handling func to be called by user after an INT is occourred
nikapov 0:a1a69d32f310 413 * @param[in] opeating_mode indicating the in progress measure
nikapov 0:a1a69d32f310 414 * @param[out] Data pointer to the MeasureData_t structure to read data in to
nikapov 0:a1a69d32f310 415 * @return "0" on success
nikapov 0:a1a69d32f310 416 */
nikapov 0:a1a69d32f310 417 int handle_irq(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *data);
nikapov 0:a1a69d32f310 418
nikapov 0:a1a69d32f310 419 /**
nikapov 0:a1a69d32f310 420 * @brief Enable interrupt measure IRQ
nikapov 0:a1a69d32f310 421 * @return "0" on success
nikapov 0:a1a69d32f310 422 */
nikapov 0:a1a69d32f310 423 void enable_interrupt_measure_detection_irq(void)
nikapov 0:a1a69d32f310 424 {
nikapov 0:a1a69d32f310 425 if (_gpio1Int != NULL) {
nikapov 0:a1a69d32f310 426 _gpio1Int->enable_irq();
nikapov 0:a1a69d32f310 427 }
nikapov 0:a1a69d32f310 428 }
nikapov 0:a1a69d32f310 429
nikapov 0:a1a69d32f310 430 /**
nikapov 0:a1a69d32f310 431 * @brief Disable interrupt measure IRQ
nikapov 0:a1a69d32f310 432 * @return "0" on success
nikapov 0:a1a69d32f310 433 */
nikapov 0:a1a69d32f310 434 void disable_interrupt_measure_detection_irq(void)
nikapov 0:a1a69d32f310 435 {
nikapov 0:a1a69d32f310 436 if (_gpio1Int != NULL) {
nikapov 0:a1a69d32f310 437 _gpio1Int->disable_irq();
nikapov 0:a1a69d32f310 438 }
nikapov 0:a1a69d32f310 439 }
nikapov 0:a1a69d32f310 440
nikapov 0:a1a69d32f310 441 /**
nikapov 0:a1a69d32f310 442 * @brief Attach a function to call when an interrupt is detected, i.e. measurement is ready
nikapov 0:a1a69d32f310 443 * @param[in] fptr pointer to call back function to be called whenever an interrupt occours
nikapov 0:a1a69d32f310 444 * @return "0" on success
nikapov 0:a1a69d32f310 445 */
nikapov 0:a1a69d32f310 446 void attach_interrupt_measure_detection_irq(void (*fptr)(void))
nikapov 0:a1a69d32f310 447 {
nikapov 0:a1a69d32f310 448 if (_gpio1Int != NULL) {
nikapov 0:a1a69d32f310 449 _gpio1Int->rise(fptr);
nikapov 0:a1a69d32f310 450 }
nikapov 0:a1a69d32f310 451 }
nikapov 0:a1a69d32f310 452
nikapov 0:a1a69d32f310 453 /** Wrapper functions */
nikapov 0:a1a69d32f310 454 /** @defgroup api_init Init functions
nikapov 0:a1a69d32f310 455 * @brief API init functions
nikapov 0:a1a69d32f310 456 * @ingroup api_hl
nikapov 0:a1a69d32f310 457 * @{
nikapov 0:a1a69d32f310 458 */
nikapov 0:a1a69d32f310 459
nikapov 0:a1a69d32f310 460 /**
nikapov 0:a1a69d32f310 461 *
nikapov 0:a1a69d32f310 462 * @brief One time device initialization
nikapov 0:a1a69d32f310 463 *
nikapov 0:a1a69d32f310 464 * To be called once and only once after device is brought out of reset (Chip enable) and booted.
nikapov 0:a1a69d32f310 465 *
nikapov 0:a1a69d32f310 466 * @par Function Description
nikapov 0:a1a69d32f310 467 * When not used after a fresh device "power up" or reset, it may return @a #CALIBRATION_WARNING
nikapov 0:a1a69d32f310 468 * meaning wrong calibration data may have been fetched from device that can result in ranging offset error\n
nikapov 0:a1a69d32f310 469 * If application cannot execute device reset or need to run VL53L0X_data_init multiple time
nikapov 0:a1a69d32f310 470 * then it must ensure proper offset calibration saving and restore on its own
nikapov 0:a1a69d32f310 471 * by using @a VL53L0X_get_offset_calibration_data_micro_meter() on first power up and then @a VL53L0X_set_offset_calibration_data_micro_meter() all all subsequent init
nikapov 0:a1a69d32f310 472 *
nikapov 0:a1a69d32f310 473 * @param void
nikapov 0:a1a69d32f310 474 * @return "0" on success, @a #CALIBRATION_WARNING if failed
nikapov 0:a1a69d32f310 475 */
nikapov 0:a1a69d32f310 476 virtual int init(void *init)
nikapov 0:a1a69d32f310 477 {
nikapov 0:a1a69d32f310 478 return VL53L0X_data_init(_device);
nikapov 0:a1a69d32f310 479 }
nikapov 0:a1a69d32f310 480
nikapov 0:a1a69d32f310 481 /**
nikapov 0:a1a69d32f310 482 * @brief Prepare device for operation
nikapov 0:a1a69d32f310 483 * @par Function Description
nikapov 0:a1a69d32f310 484 * Does static initialization and reprogram common default settings \n
nikapov 0:a1a69d32f310 485 * Device is prepared for new measure, ready single shot ranging or ALS typical polling operation\n
nikapov 0:a1a69d32f310 486 * After prepare user can : \n
nikapov 0:a1a69d32f310 487 * @li Call other API function to set other settings\n
nikapov 0:a1a69d32f310 488 * @li Configure the interrupt pins, etc... \n
nikapov 0:a1a69d32f310 489 * @li Then start ranging or ALS operations in single shot or continuous mode
nikapov 0:a1a69d32f310 490 *
nikapov 0:a1a69d32f310 491 * @param void
nikapov 0:a1a69d32f310 492 * @return "0" on success
nikapov 0:a1a69d32f310 493 */
nikapov 0:a1a69d32f310 494 int prepare()
nikapov 0:a1a69d32f310 495 {
nikapov 0:a1a69d32f310 496 VL53L0X_Error status = VL53L0X_ERROR_NONE;
nikapov 0:a1a69d32f310 497 uint32_t ref_spad_count;
nikapov 0:a1a69d32f310 498 uint8_t is_aperture_spads;
nikapov 0:a1a69d32f310 499 uint8_t vhv_settings;
nikapov 0:a1a69d32f310 500 uint8_t phase_cal;
nikapov 0:a1a69d32f310 501
nikapov 0:a1a69d32f310 502 if (status == VL53L0X_ERROR_NONE) {
nikapov 1:834986cdde0a 503 //printf("Call of VL53L0X_StaticInit\r\n");
nikapov 0:a1a69d32f310 504 status = VL53L0X_static_init(_device); // Device Initialization
nikapov 0:a1a69d32f310 505 }
nikapov 0:a1a69d32f310 506
nikapov 0:a1a69d32f310 507 if (status == VL53L0X_ERROR_NONE) {
nikapov 1:834986cdde0a 508 //printf("Call of VL53L0X_PerformRefCalibration\r\n");
nikapov 0:a1a69d32f310 509 status = VL53L0X_perform_ref_calibration(_device,
nikapov 0:a1a69d32f310 510 &vhv_settings, &phase_cal); // Device Initialization
nikapov 0:a1a69d32f310 511 }
nikapov 0:a1a69d32f310 512
nikapov 0:a1a69d32f310 513 if (status == VL53L0X_ERROR_NONE) {
nikapov 1:834986cdde0a 514 //printf("Call of VL53L0X_PerformRefSpadManagement\r\n");
nikapov 0:a1a69d32f310 515 status = VL53L0X_perform_ref_spad_management(_device,
nikapov 0:a1a69d32f310 516 &ref_spad_count, &is_aperture_spads); // Device Initialization
nikapov 0:a1a69d32f310 517 // printf ("refSpadCount = %d, isApertureSpads = %d\r\n", refSpadCount, isApertureSpads);
nikapov 0:a1a69d32f310 518 }
nikapov 0:a1a69d32f310 519
nikapov 0:a1a69d32f310 520 return status;
nikapov 0:a1a69d32f310 521 }
nikapov 0:a1a69d32f310 522
nikapov 0:a1a69d32f310 523 /**
nikapov 0:a1a69d32f310 524 * @brief Start continuous ranging mode
nikapov 0:a1a69d32f310 525 *
nikapov 0:a1a69d32f310 526 * @details End user should ensure device is in idle state and not already running
nikapov 0:a1a69d32f310 527 * @return "0" on success
nikapov 0:a1a69d32f310 528 */
nikapov 0:a1a69d32f310 529 int range_start_continuous_mode()
nikapov 0:a1a69d32f310 530 {
nikapov 0:a1a69d32f310 531 int status;
nikapov 0:a1a69d32f310 532 status = VL53L0X_set_device_mode(_device, VL53L0X_DEVICEMODE_CONTINUOUS_RANGING);
nikapov 0:a1a69d32f310 533
nikapov 0:a1a69d32f310 534 if (status == VL53L0X_ERROR_NONE) {
nikapov 1:834986cdde0a 535 //printf ("Call of VL53L0X_StartMeasurement\r\n");
nikapov 0:a1a69d32f310 536 status = VL53L0X_start_measurement(_device);
nikapov 0:a1a69d32f310 537 }
nikapov 0:a1a69d32f310 538
nikapov 0:a1a69d32f310 539 return status;
nikapov 0:a1a69d32f310 540 }
nikapov 0:a1a69d32f310 541
nikapov 0:a1a69d32f310 542 /**
nikapov 0:a1a69d32f310 543 * @brief Get ranging result and only that
nikapov 0:a1a69d32f310 544 *
nikapov 0:a1a69d32f310 545 * @par Function Description
nikapov 0:a1a69d32f310 546 * Unlike @a VL53L0X_get_ranging_measurement_data() this function only retrieves the range in millimeter \n
nikapov 0:a1a69d32f310 547 * It does any required up-scale translation\n
nikapov 0:a1a69d32f310 548 * It can be called after success status polling or in interrupt mode \n
nikapov 0:a1a69d32f310 549 * @warning these function is not doing wrap around filtering \n
nikapov 0:a1a69d32f310 550 * This function doesn't perform any data ready check!
nikapov 0:a1a69d32f310 551 *
nikapov 0:a1a69d32f310 552 * @param p_data Pointer to range distance
nikapov 0:a1a69d32f310 553 * @return "0" on success
nikapov 0:a1a69d32f310 554 */
nikapov 0:a1a69d32f310 555 virtual int get_distance(uint32_t *p_data)
nikapov 0:a1a69d32f310 556 {
nikapov 0:a1a69d32f310 557 int status = 0;
nikapov 0:a1a69d32f310 558 VL53L0X_RangingMeasurementData_t p_ranging_measurement_data;
nikapov 0:a1a69d32f310 559
nikapov 0:a1a69d32f310 560 status = start_measurement(range_single_shot_polling, NULL);
nikapov 0:a1a69d32f310 561 if (!status) {
nikapov 0:a1a69d32f310 562 status = get_measurement(range_single_shot_polling, &p_ranging_measurement_data);
nikapov 0:a1a69d32f310 563 }
nikapov 0:a1a69d32f310 564 if (p_ranging_measurement_data.RangeStatus == 0) {
nikapov 0:a1a69d32f310 565 // we have a valid range.
nikapov 0:a1a69d32f310 566 *p_data = p_ranging_measurement_data.RangeMilliMeter;
nikapov 0:a1a69d32f310 567 } else {
nikapov 0:a1a69d32f310 568 *p_data = 0;
nikapov 0:a1a69d32f310 569 status = VL53L0X_ERROR_RANGE_ERROR;
nikapov 0:a1a69d32f310 570 }
nikapov 0:a1a69d32f310 571 stop_measurement(range_single_shot_polling);
nikapov 0:a1a69d32f310 572 return status;
nikapov 0:a1a69d32f310 573 }
nikapov 0:a1a69d32f310 574
nikapov 0:a1a69d32f310 575 /** @} */
nikapov 0:a1a69d32f310 576
nikapov 0:a1a69d32f310 577 /**
nikapov 0:a1a69d32f310 578 * @brief Set new device i2c address
nikapov 0:a1a69d32f310 579 *
nikapov 0:a1a69d32f310 580 * After completion the device will answer to the new address programmed.
nikapov 0:a1a69d32f310 581 *
nikapov 0:a1a69d32f310 582 * @param new_addr The new i2c address (7bit)
nikapov 0:a1a69d32f310 583 * @return "0" on success
nikapov 0:a1a69d32f310 584 */
nikapov 0:a1a69d32f310 585 int set_device_address(int new_addr)
nikapov 0:a1a69d32f310 586 {
nikapov 0:a1a69d32f310 587 int status;
nikapov 0:a1a69d32f310 588
nikapov 0:a1a69d32f310 589 status = VL53L0X_set_device_address(_device, new_addr);
nikapov 0:a1a69d32f310 590 if (!status) {
nikapov 0:a1a69d32f310 591 _device->I2cDevAddr = new_addr;
nikapov 0:a1a69d32f310 592 }
nikapov 0:a1a69d32f310 593 return status;
nikapov 0:a1a69d32f310 594
nikapov 0:a1a69d32f310 595 }
nikapov 0:a1a69d32f310 596
nikapov 0:a1a69d32f310 597 /**
nikapov 0:a1a69d32f310 598 * @brief Clear given system interrupt condition
nikapov 0:a1a69d32f310 599 *
nikapov 0:a1a69d32f310 600 * @par Function Description
nikapov 0:a1a69d32f310 601 * Clear given interrupt cause by writing into register #SYSTEM_INTERRUPT_CLEAR register.
nikapov 0:a1a69d32f310 602 * @param dev The device
nikapov 0:a1a69d32f310 603 * @param int_clear Which interrupt source to clear. Use any combinations of #INTERRUPT_CLEAR_RANGING , #INTERRUPT_CLEAR_ALS , #INTERRUPT_CLEAR_ERROR.
nikapov 0:a1a69d32f310 604 * @return "0" on success
nikapov 0:a1a69d32f310 605 */
nikapov 0:a1a69d32f310 606 int clear_interrupt(uint8_t int_clear)
nikapov 0:a1a69d32f310 607 {
nikapov 0:a1a69d32f310 608 return VL53L0X_clear_interrupt_mask(_device, int_clear);
nikapov 0:a1a69d32f310 609 }
nikapov 0:a1a69d32f310 610
nikapov 0:a1a69d32f310 611 /**
nikapov 0:a1a69d32f310 612 *
mapellil 4:d25c4fa216af 613 * @brief Get the 53L0 device
mapellil 4:d25c4fa216af 614 *
mapellil 4:d25c4fa216af 615 * To be called to retrive the internal device descriptor to allow usage of
mapellil 4:d25c4fa216af 616 * low level API having device as parameter. To be called after set_device_address()
mapellil 4:d25c4fa216af 617 * (if any).
mapellil 4:d25c4fa216af 618 *
mapellil 4:d25c4fa216af 619 * @par Function Description
mapellil 4:d25c4fa216af 620 * To be called if low level API usage is needed as those functions requires
mapellil 4:d25c4fa216af 621 * device as a parameter.TICINIT.
mapellil 4:d25c4fa216af 622 *
mapellil 4:d25c4fa216af 623 * @note This function return a pointer to an object internal structure
mapellil 4:d25c4fa216af 624 *
mapellil 4:d25c4fa216af 625 * @param dev ptr to ptr to Device Handle
mapellil 4:d25c4fa216af 626 * @return VL53L0X_ERROR_NONE Success
mapellil 4:d25c4fa216af 627 * @return "Other error code" See ::VL53L0X_Error
mapellil 4:d25c4fa216af 628 */
mapellil 4:d25c4fa216af 629 VL53L0X_Error vl53l0x_get_device(VL53L0X_DEV *dev)
mapellil 4:d25c4fa216af 630 {
mapellil 4:d25c4fa216af 631 *dev = _device;
mapellil 4:d25c4fa216af 632 return VL53L0X_ERROR_NONE;
mapellil 4:d25c4fa216af 633 }
mapellil 4:d25c4fa216af 634
mapellil 4:d25c4fa216af 635 /**
mapellil 4:d25c4fa216af 636 *
nikapov 0:a1a69d32f310 637 * @brief One time device initialization
nikapov 0:a1a69d32f310 638 *
nikapov 0:a1a69d32f310 639 * To be called once and only once after device is brought out of reset
nikapov 0:a1a69d32f310 640 * (Chip enable) and booted see @a VL53L0X_WaitDeviceBooted()
nikapov 0:a1a69d32f310 641 *
nikapov 0:a1a69d32f310 642 * @par Function Description
nikapov 0:a1a69d32f310 643 * When not used after a fresh device "power up" or reset, it may return
nikapov 0:a1a69d32f310 644 * @a #VL53L0X_ERROR_CALIBRATION_WARNING meaning wrong calibration data
nikapov 0:a1a69d32f310 645 * may have been fetched from device that can result in ranging offset error\n
nikapov 0:a1a69d32f310 646 * If application cannot execute device reset or need to run VL53L0X_DataInit
nikapov 0:a1a69d32f310 647 * multiple time then it must ensure proper offset calibration saving and
nikapov 0:a1a69d32f310 648 * restore on its own by using @a VL53L0X_GetOffsetCalibrationData() on first
nikapov 0:a1a69d32f310 649 * power up and then @a VL53L0X_SetOffsetCalibrationData() in all subsequent init
nikapov 0:a1a69d32f310 650 * This function will change the VL53L0X_State from VL53L0X_STATE_POWERDOWN to
nikapov 0:a1a69d32f310 651 * VL53L0X_STATE_WAIT_STATICINIT.
nikapov 0:a1a69d32f310 652 *
nikapov 0:a1a69d32f310 653 * @note This function accesses to the device
nikapov 0:a1a69d32f310 654 *
nikapov 0:a1a69d32f310 655 * @param dev Device Handle
nikapov 0:a1a69d32f310 656 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 657 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 658 */
nikapov 0:a1a69d32f310 659 VL53L0X_Error VL53L0X_data_init(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 660
nikapov 0:a1a69d32f310 661 /**
nikapov 0:a1a69d32f310 662 * @brief Do basic device init (and eventually patch loading)
nikapov 0:a1a69d32f310 663 * This function will change the VL53L0X_State from
nikapov 0:a1a69d32f310 664 * VL53L0X_STATE_WAIT_STATICINIT to VL53L0X_STATE_IDLE.
nikapov 0:a1a69d32f310 665 * In this stage all default setting will be applied.
nikapov 0:a1a69d32f310 666 *
nikapov 0:a1a69d32f310 667 * @note This function Access to the device
nikapov 0:a1a69d32f310 668 *
nikapov 0:a1a69d32f310 669 * @param dev Device Handle
nikapov 0:a1a69d32f310 670 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 671 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 672 */
nikapov 0:a1a69d32f310 673 VL53L0X_Error VL53L0X_static_init(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 674
nikapov 0:a1a69d32f310 675 /**
nikapov 0:a1a69d32f310 676 * @brief Perform Reference Calibration
nikapov 0:a1a69d32f310 677 *
nikapov 0:a1a69d32f310 678 * @details Perform a reference calibration of the Device.
nikapov 0:a1a69d32f310 679 * This function should be run from time to time before doing
nikapov 0:a1a69d32f310 680 * a ranging measurement.
nikapov 0:a1a69d32f310 681 * This function will launch a special ranging measurement, so
nikapov 0:a1a69d32f310 682 * if interrupt are enable an interrupt will be done.
nikapov 0:a1a69d32f310 683 * This function will clear the interrupt generated automatically.
nikapov 0:a1a69d32f310 684 *
nikapov 0:a1a69d32f310 685 * @warning This function is a blocking function
nikapov 0:a1a69d32f310 686 *
nikapov 0:a1a69d32f310 687 * @note This function Access to the device
nikapov 0:a1a69d32f310 688 *
nikapov 0:a1a69d32f310 689 * @param dev Device Handle
nikapov 0:a1a69d32f310 690 * @param p_vhv_settings Pointer to vhv settings parameter.
nikapov 0:a1a69d32f310 691 * @param p_phase_cal Pointer to PhaseCal parameter.
nikapov 0:a1a69d32f310 692 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 693 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 694 */
nikapov 0:a1a69d32f310 695 VL53L0X_Error VL53L0X_perform_ref_calibration(VL53L0X_DEV dev, uint8_t *p_vhv_settings,
nikapov 0:a1a69d32f310 696 uint8_t *p_phase_cal);
nikapov 0:a1a69d32f310 697
nikapov 0:a1a69d32f310 698 /**
nikapov 0:a1a69d32f310 699 * @brief Get Reference Calibration Parameters
nikapov 0:a1a69d32f310 700 *
nikapov 0:a1a69d32f310 701 * @par Function Description
nikapov 0:a1a69d32f310 702 * Get Reference Calibration Parameters.
nikapov 0:a1a69d32f310 703 *
nikapov 0:a1a69d32f310 704 * @note This function Access to the device
nikapov 0:a1a69d32f310 705 *
nikapov 0:a1a69d32f310 706 * @param dev Device Handle
nikapov 0:a1a69d32f310 707 * @param p_vhv_settings Pointer to VHV parameter
nikapov 0:a1a69d32f310 708 * @param p_phase_cal Pointer to PhaseCal Parameter
nikapov 0:a1a69d32f310 709 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 710 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 711 */
nikapov 0:a1a69d32f310 712 VL53L0X_Error VL53L0X_get_ref_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 713 uint8_t *p_vhv_settings, uint8_t *p_phase_cal);
nikapov 0:a1a69d32f310 714
nikapov 0:a1a69d32f310 715 VL53L0X_Error VL53L0X_set_ref_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 716 uint8_t vhv_settings, uint8_t phase_cal);
nikapov 0:a1a69d32f310 717
nikapov 0:a1a69d32f310 718 /**
nikapov 0:a1a69d32f310 719 * @brief Performs Reference Spad Management
nikapov 0:a1a69d32f310 720 *
nikapov 0:a1a69d32f310 721 * @par Function Description
nikapov 0:a1a69d32f310 722 * The reference SPAD initialization procedure determines the minimum amount
nikapov 0:a1a69d32f310 723 * of reference spads to be enables to achieve a target reference signal rate
nikapov 0:a1a69d32f310 724 * and should be performed once during initialization.
nikapov 0:a1a69d32f310 725 *
nikapov 0:a1a69d32f310 726 * @note This function Access to the device
nikapov 0:a1a69d32f310 727 *
nikapov 0:a1a69d32f310 728 * @note This function change the device mode to
nikapov 0:a1a69d32f310 729 * VL53L0X_DEVICEMODE_SINGLE_RANGING
nikapov 0:a1a69d32f310 730 *
nikapov 0:a1a69d32f310 731 * @param dev Device Handle
nikapov 0:a1a69d32f310 732 * @param ref_spad_count Reports ref Spad Count
nikapov 0:a1a69d32f310 733 * @param is_aperture_spads Reports if spads are of type
nikapov 0:a1a69d32f310 734 * aperture or non-aperture.
nikapov 0:a1a69d32f310 735 * 1:=aperture, 0:=Non-Aperture
nikapov 0:a1a69d32f310 736 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 737 * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the Ref Spad procedure.
nikapov 0:a1a69d32f310 738 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 739 */
nikapov 0:a1a69d32f310 740 VL53L0X_Error VL53L0X_perform_ref_spad_management(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 741 uint32_t *ref_spad_count, uint8_t *is_aperture_spads);
nikapov 0:a1a69d32f310 742
nikapov 0:a1a69d32f310 743 /**
nikapov 0:a1a69d32f310 744 * @brief Applies Reference SPAD configuration
nikapov 0:a1a69d32f310 745 *
nikapov 0:a1a69d32f310 746 * @par Function Description
nikapov 0:a1a69d32f310 747 * This function applies a given number of reference spads, identified as
nikapov 0:a1a69d32f310 748 * either Aperture or Non-Aperture.
nikapov 0:a1a69d32f310 749 * The requested spad count and type are stored within the device specific
nikapov 0:a1a69d32f310 750 * parameters data for access by the host.
nikapov 0:a1a69d32f310 751 *
nikapov 0:a1a69d32f310 752 * @note This function Access to the device
nikapov 0:a1a69d32f310 753 *
nikapov 0:a1a69d32f310 754 * @param dev Device Handle
nikapov 0:a1a69d32f310 755 * @param refSpadCount Number of ref spads.
nikapov 0:a1a69d32f310 756 * @param is_aperture_spads Defines if spads are of type
nikapov 0:a1a69d32f310 757 * aperture or non-aperture.
nikapov 0:a1a69d32f310 758 * 1:=aperture, 0:=Non-Aperture
nikapov 0:a1a69d32f310 759 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 760 * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the in the reference
nikapov 0:a1a69d32f310 761 * spad configuration.
nikapov 0:a1a69d32f310 762 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 763 */
nikapov 0:a1a69d32f310 764 VL53L0X_Error VL53L0X_set_reference_spads(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 765 uint32_t refSpadCount, uint8_t is_aperture_spads);
nikapov 0:a1a69d32f310 766
nikapov 0:a1a69d32f310 767 /**
nikapov 0:a1a69d32f310 768 * @brief Retrieves SPAD configuration
nikapov 0:a1a69d32f310 769 *
nikapov 0:a1a69d32f310 770 * @par Function Description
nikapov 0:a1a69d32f310 771 * This function retrieves the current number of applied reference spads
nikapov 0:a1a69d32f310 772 * and also their type : Aperture or Non-Aperture.
nikapov 0:a1a69d32f310 773 *
nikapov 0:a1a69d32f310 774 * @note This function Access to the device
nikapov 0:a1a69d32f310 775 *
nikapov 0:a1a69d32f310 776 * @param dev Device Handle
nikapov 0:a1a69d32f310 777 * @param p_spad_count Number ref Spad Count
nikapov 0:a1a69d32f310 778 * @param p_is_aperture_spads Reports if spads are of type
nikapov 0:a1a69d32f310 779 * aperture or non-aperture.
nikapov 0:a1a69d32f310 780 * 1:=aperture, 0:=Non-Aperture
nikapov 0:a1a69d32f310 781 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 782 * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the in the reference
nikapov 0:a1a69d32f310 783 * spad configuration.
nikapov 0:a1a69d32f310 784 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 785 */
nikapov 0:a1a69d32f310 786 VL53L0X_Error VL53L0X_get_reference_spads(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 787 uint32_t *p_spad_count, uint8_t *p_is_aperture_spads);
nikapov 0:a1a69d32f310 788
nikapov 0:a1a69d32f310 789 /**
nikapov 0:a1a69d32f310 790 * @brief Get part to part calibration offset
nikapov 0:a1a69d32f310 791 *
nikapov 0:a1a69d32f310 792 * @par Function Description
nikapov 0:a1a69d32f310 793 * Should only be used after a successful call to @a VL53L0X_DataInit to backup
nikapov 0:a1a69d32f310 794 * device NVM value
nikapov 0:a1a69d32f310 795 *
nikapov 0:a1a69d32f310 796 * @note This function Access to the device
nikapov 0:a1a69d32f310 797 *
nikapov 0:a1a69d32f310 798 * @param dev Device Handle
nikapov 0:a1a69d32f310 799 * @param p_offset_calibration_data_micro_meter Return part to part
nikapov 0:a1a69d32f310 800 * calibration offset from device (microns)
nikapov 0:a1a69d32f310 801 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 802 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 803 */
nikapov 0:a1a69d32f310 804 VL53L0X_Error VL53L0X_get_offset_calibration_data_micro_meter(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 805 int32_t *p_offset_calibration_data_micro_meter);
nikapov 0:a1a69d32f310 806 /**
nikapov 0:a1a69d32f310 807 * Set or over-hide part to part calibration offset
nikapov 0:a1a69d32f310 808 * \sa VL53L0X_DataInit() VL53L0X_GetOffsetCalibrationDataMicroMeter()
nikapov 0:a1a69d32f310 809 *
nikapov 0:a1a69d32f310 810 * @note This function Access to the device
nikapov 0:a1a69d32f310 811 *
nikapov 0:a1a69d32f310 812 * @param dev Device Handle
nikapov 0:a1a69d32f310 813 * @param p_offset_calibration_data_micro_meter Offset (microns)
nikapov 0:a1a69d32f310 814 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 815 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 816 */
nikapov 0:a1a69d32f310 817 VL53L0X_Error VL53L0X_set_offset_calibration_data_micro_meter(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 818 int32_t offset_calibration_data_micro_meter);
nikapov 0:a1a69d32f310 819
nikapov 0:a1a69d32f310 820 VL53L0X_Error VL53L0X_perform_offset_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 821 FixPoint1616_t cal_distance_milli_meter,
nikapov 0:a1a69d32f310 822 int32_t *p_offset_micro_meter);
nikapov 0:a1a69d32f310 823
nikapov 0:a1a69d32f310 824 VL53L0X_Error VL53L0X_perform_xtalk_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 825 FixPoint1616_t xtalk_cal_distance,
nikapov 0:a1a69d32f310 826 FixPoint1616_t *p_xtalk_compensation_rate_mega_cps);
nikapov 0:a1a69d32f310 827
nikapov 0:a1a69d32f310 828 /**
nikapov 0:a1a69d32f310 829 * @brief Perform XTalk Measurement
nikapov 0:a1a69d32f310 830 *
nikapov 0:a1a69d32f310 831 * @details Measures the current cross talk from glass in front
nikapov 0:a1a69d32f310 832 * of the sensor.
nikapov 0:a1a69d32f310 833 * This functions performs a histogram measurement and uses the results
nikapov 0:a1a69d32f310 834 * to measure the crosstalk. For the function to be successful, there
nikapov 0:a1a69d32f310 835 * must be no target in front of the sensor.
nikapov 0:a1a69d32f310 836 *
nikapov 0:a1a69d32f310 837 * @warning This function is a blocking function
nikapov 0:a1a69d32f310 838 *
nikapov 0:a1a69d32f310 839 * @warning This function is not supported when the final range
nikapov 0:a1a69d32f310 840 * vcsel clock period is set below 10 PCLKS.
nikapov 0:a1a69d32f310 841 *
nikapov 0:a1a69d32f310 842 * @note This function Access to the device
nikapov 0:a1a69d32f310 843 *
nikapov 0:a1a69d32f310 844 * @param dev Device Handle
nikapov 0:a1a69d32f310 845 * @param timeout_ms Histogram measurement duration.
nikapov 0:a1a69d32f310 846 * @param p_xtalk_per_spad Output parameter containing the crosstalk
nikapov 0:a1a69d32f310 847 * measurement result, in MCPS/Spad.
nikapov 0:a1a69d32f310 848 * Format fixpoint 16:16.
nikapov 0:a1a69d32f310 849 * @param p_ambient_too_high Output parameter which indicate that
nikapov 0:a1a69d32f310 850 * pXtalkPerSpad is not good if the Ambient
nikapov 0:a1a69d32f310 851 * is too high.
nikapov 0:a1a69d32f310 852 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 853 * @return VL53L0X_ERROR_INVALID_PARAMS vcsel clock period not supported
nikapov 0:a1a69d32f310 854 * for this operation.
nikapov 0:a1a69d32f310 855 * Must not be less than 10PCLKS.
nikapov 0:a1a69d32f310 856 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 857 */
nikapov 0:a1a69d32f310 858 VL53L0X_Error VL53L0X_perform_xtalk_measurement(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 859 uint32_t timeout_ms, FixPoint1616_t *p_xtalk_per_spad,
nikapov 0:a1a69d32f310 860 uint8_t *p_ambient_too_high);
nikapov 0:a1a69d32f310 861
nikapov 0:a1a69d32f310 862 /**
nikapov 0:a1a69d32f310 863 * @brief Enable/Disable Cross talk compensation feature
nikapov 0:a1a69d32f310 864 *
nikapov 0:a1a69d32f310 865 * @note This function is not Implemented.
nikapov 0:a1a69d32f310 866 * Enable/Disable Cross Talk by set to zero the Cross Talk value
nikapov 0:a1a69d32f310 867 * by using @a VL53L0X_SetXTalkCompensationRateMegaCps().
nikapov 0:a1a69d32f310 868 *
nikapov 0:a1a69d32f310 869 * @param dev Device Handle
nikapov 0:a1a69d32f310 870 * @param x_talk_compensation_enable Cross talk compensation
nikapov 0:a1a69d32f310 871 * to be set 0=disabled else = enabled
nikapov 0:a1a69d32f310 872 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
nikapov 0:a1a69d32f310 873 */
nikapov 0:a1a69d32f310 874 VL53L0X_Error VL53L0X_set_x_talk_compensation_enable(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 875 uint8_t x_talk_compensation_enable);
nikapov 0:a1a69d32f310 876
nikapov 0:a1a69d32f310 877 /**
nikapov 0:a1a69d32f310 878 * @brief Get Cross talk compensation rate
nikapov 0:a1a69d32f310 879 *
nikapov 0:a1a69d32f310 880 * @note This function is not Implemented.
nikapov 0:a1a69d32f310 881 * Enable/Disable Cross Talk by set to zero the Cross Talk value by
nikapov 0:a1a69d32f310 882 * using @a VL53L0X_SetXTalkCompensationRateMegaCps().
nikapov 0:a1a69d32f310 883 *
nikapov 0:a1a69d32f310 884 * @param dev Device Handle
nikapov 0:a1a69d32f310 885 * @param p_x_talk_compensation_enable Pointer to the Cross talk compensation
nikapov 0:a1a69d32f310 886 * state 0=disabled or 1 = enabled
nikapov 0:a1a69d32f310 887 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
nikapov 0:a1a69d32f310 888 */
nikapov 0:a1a69d32f310 889 VL53L0X_Error VL53L0X_get_x_talk_compensation_enable(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 890 uint8_t *p_x_talk_compensation_enable);
nikapov 0:a1a69d32f310 891 /**
nikapov 0:a1a69d32f310 892 * @brief Set Cross talk compensation rate
nikapov 0:a1a69d32f310 893 *
nikapov 0:a1a69d32f310 894 * @par Function Description
nikapov 0:a1a69d32f310 895 * Set Cross talk compensation rate.
nikapov 0:a1a69d32f310 896 *
nikapov 0:a1a69d32f310 897 * @note This function Access to the device
nikapov 0:a1a69d32f310 898 *
nikapov 0:a1a69d32f310 899 * @param dev Device Handle
nikapov 0:a1a69d32f310 900 * @param x_talk_compensation_rate_mega_cps Compensation rate in
nikapov 0:a1a69d32f310 901 * Mega counts per second
nikapov 0:a1a69d32f310 902 * (16.16 fix point) see
nikapov 0:a1a69d32f310 903 * datasheet for details
nikapov 0:a1a69d32f310 904 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 905 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 906 */
nikapov 0:a1a69d32f310 907 VL53L0X_Error VL53L0X_set_x_talk_compensation_rate_mega_cps(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 908 FixPoint1616_t x_talk_compensation_rate_mega_cps);
nikapov 0:a1a69d32f310 909
nikapov 0:a1a69d32f310 910 /**
nikapov 0:a1a69d32f310 911 * @brief Get Cross talk compensation rate
nikapov 0:a1a69d32f310 912 *
nikapov 0:a1a69d32f310 913 * @par Function Description
nikapov 0:a1a69d32f310 914 * Get Cross talk compensation rate.
nikapov 0:a1a69d32f310 915 *
nikapov 0:a1a69d32f310 916 * @note This function Access to the device
nikapov 0:a1a69d32f310 917 *
nikapov 0:a1a69d32f310 918 * @param dev Device Handle
nikapov 0:a1a69d32f310 919 * @param p_xtalk_compensation_rate_mega_cps Pointer to Compensation rate
nikapov 0:a1a69d32f310 920 * in Mega counts per second
nikapov 0:a1a69d32f310 921 * (16.16 fix point) see
nikapov 0:a1a69d32f310 922 * datasheet for details
nikapov 0:a1a69d32f310 923 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 924 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 925 */
nikapov 0:a1a69d32f310 926 VL53L0X_Error VL53L0X_get_x_talk_compensation_rate_mega_cps(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 927 FixPoint1616_t *p_xtalk_compensation_rate_mega_cps);
nikapov 0:a1a69d32f310 928
nikapov 0:a1a69d32f310 929 /**
nikapov 0:a1a69d32f310 930 * @brief Set a new device mode
nikapov 0:a1a69d32f310 931 * @par Function Description
nikapov 0:a1a69d32f310 932 * Set device to a new mode (ranging, histogram ...)
nikapov 0:a1a69d32f310 933 *
nikapov 0:a1a69d32f310 934 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 935 *
nikapov 0:a1a69d32f310 936 * @param dev Device Handle
nikapov 0:a1a69d32f310 937 * @param device_mode New device mode to apply
nikapov 0:a1a69d32f310 938 * Valid values are:
nikapov 0:a1a69d32f310 939 * VL53L0X_DEVICEMODE_SINGLE_RANGING
nikapov 0:a1a69d32f310 940 * VL53L0X_DEVICEMODE_CONTINUOUS_RANGING
nikapov 0:a1a69d32f310 941 * VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING
nikapov 0:a1a69d32f310 942 * VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM
nikapov 0:a1a69d32f310 943 * VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY
nikapov 0:a1a69d32f310 944 * VL53L0X_HISTOGRAMMODE_RETURN_ONLY
nikapov 0:a1a69d32f310 945 * VL53L0X_HISTOGRAMMODE_BOTH
nikapov 0:a1a69d32f310 946 *
nikapov 0:a1a69d32f310 947 *
nikapov 0:a1a69d32f310 948 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 949 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when
nikapov 0:a1a69d32f310 950 * DeviceMode is not in the
nikapov 0:a1a69d32f310 951 * supported list
nikapov 0:a1a69d32f310 952 */
nikapov 0:a1a69d32f310 953 VL53L0X_Error VL53L0X_set_device_mode(VL53L0X_DEV dev, VL53L0X_DeviceModes device_mode);
nikapov 0:a1a69d32f310 954
nikapov 0:a1a69d32f310 955 /**
nikapov 0:a1a69d32f310 956 * @brief Get current new device mode
nikapov 0:a1a69d32f310 957 * @par Function Description
nikapov 0:a1a69d32f310 958 * Get actual mode of the device(ranging, histogram ...)
nikapov 0:a1a69d32f310 959 *
nikapov 0:a1a69d32f310 960 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 961 *
nikapov 0:a1a69d32f310 962 * @param dev Device Handle
nikapov 0:a1a69d32f310 963 * @param p_device_mode Pointer to current apply mode value
nikapov 0:a1a69d32f310 964 * Valid values are:
nikapov 0:a1a69d32f310 965 * VL53L0X_DEVICEMODE_SINGLE_RANGING
nikapov 0:a1a69d32f310 966 * VL53L0X_DEVICEMODE_CONTINUOUS_RANGING
nikapov 0:a1a69d32f310 967 * VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING
nikapov 0:a1a69d32f310 968 * VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM
nikapov 0:a1a69d32f310 969 * VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY
nikapov 0:a1a69d32f310 970 * VL53L0X_HISTOGRAMMODE_RETURN_ONLY
nikapov 0:a1a69d32f310 971 * VL53L0X_HISTOGRAMMODE_BOTH
nikapov 0:a1a69d32f310 972 *
nikapov 0:a1a69d32f310 973 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 974 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when
nikapov 0:a1a69d32f310 975 * DeviceMode is not in the
nikapov 0:a1a69d32f310 976 * supported list
nikapov 0:a1a69d32f310 977 */
nikapov 0:a1a69d32f310 978 VL53L0X_Error VL53L0X_get_device_mode(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 979 VL53L0X_DeviceModes *p_device_mode);
nikapov 0:a1a69d32f310 980
nikapov 0:a1a69d32f310 981 /**
nikapov 0:a1a69d32f310 982 * @brief Get current configuration for GPIO pin for a given device
nikapov 0:a1a69d32f310 983 *
nikapov 0:a1a69d32f310 984 * @note This function Access to the device
nikapov 0:a1a69d32f310 985 *
nikapov 0:a1a69d32f310 986 * @param dev Device Handle
nikapov 0:a1a69d32f310 987 * @param pin ID of the GPIO Pin
nikapov 0:a1a69d32f310 988 * @param p_device_mode Pointer to Device Mode associated to the Gpio.
nikapov 0:a1a69d32f310 989 * @param p_functionality Pointer to Pin functionality.
nikapov 0:a1a69d32f310 990 * Refer to ::VL53L0X_GpioFunctionality
nikapov 0:a1a69d32f310 991 * @param p_polarity Pointer to interrupt polarity.
nikapov 0:a1a69d32f310 992 * Active high or active low see
nikapov 0:a1a69d32f310 993 * ::VL53L0X_InterruptPolarity
nikapov 0:a1a69d32f310 994 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 995 * @return VL53L0X_ERROR_GPIO_NOT_EXISTING Only Pin=0 is accepted.
nikapov 0:a1a69d32f310 996 * @return VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED
nikapov 0:a1a69d32f310 997 * This error occurs
nikapov 0:a1a69d32f310 998 * when Funcionality programmed is not in the supported list:
nikapov 0:a1a69d32f310 999 * Supported value are:
nikapov 0:a1a69d32f310 1000 * VL53L0X_GPIOFUNCTIONALITY_OFF,
nikapov 0:a1a69d32f310 1001 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW,
nikapov 0:a1a69d32f310 1002 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH,
nikapov 0:a1a69d32f310 1003 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT,
nikapov 0:a1a69d32f310 1004 * VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY
nikapov 0:a1a69d32f310 1005 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1006 */
nikapov 0:a1a69d32f310 1007 VL53L0X_Error VL53L0X_get_gpio_config(VL53L0X_DEV dev, uint8_t pin,
nikapov 0:a1a69d32f310 1008 VL53L0X_DeviceModes *p_device_mode,
nikapov 0:a1a69d32f310 1009 VL53L0X_GpioFunctionality *p_functionality,
nikapov 0:a1a69d32f310 1010 VL53L0X_InterruptPolarity *p_polarity);
nikapov 0:a1a69d32f310 1011
nikapov 0:a1a69d32f310 1012 /**
nikapov 0:a1a69d32f310 1013 * @brief Set the configuration of GPIO pin for a given device
nikapov 0:a1a69d32f310 1014 *
nikapov 0:a1a69d32f310 1015 * @note This function Access to the device
nikapov 0:a1a69d32f310 1016 *
nikapov 0:a1a69d32f310 1017 * @param dev Device Handle
nikapov 0:a1a69d32f310 1018 * @param pin ID of the GPIO Pin
nikapov 0:a1a69d32f310 1019 * @param functionality Select Pin functionality.
nikapov 0:a1a69d32f310 1020 * Refer to ::VL53L0X_GpioFunctionality
nikapov 0:a1a69d32f310 1021 * @param device_mode Device Mode associated to the Gpio.
nikapov 0:a1a69d32f310 1022 * @param polarity Set interrupt polarity. Active high
nikapov 0:a1a69d32f310 1023 * or active low see ::VL53L0X_InterruptPolarity
nikapov 0:a1a69d32f310 1024 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1025 * @return VL53L0X_ERROR_GPIO_NOT_EXISTING Only Pin=0 is accepted.
nikapov 0:a1a69d32f310 1026 * @return VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED This error occurs
nikapov 0:a1a69d32f310 1027 * when Functionality programmed is not in the supported list:
nikapov 0:a1a69d32f310 1028 * Supported value are:
nikapov 0:a1a69d32f310 1029 * VL53L0X_GPIOFUNCTIONALITY_OFF,
nikapov 0:a1a69d32f310 1030 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW,
nikapov 0:a1a69d32f310 1031 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH,
nikapov 0:a1a69d32f310 1032 VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT,
nikapov 0:a1a69d32f310 1033 * VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY
nikapov 0:a1a69d32f310 1034 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1035 */
nikapov 0:a1a69d32f310 1036 VL53L0X_Error VL53L0X_set_gpio_config(VL53L0X_DEV dev, uint8_t pin,
nikapov 0:a1a69d32f310 1037 VL53L0X_DeviceModes device_mode, VL53L0X_GpioFunctionality functionality,
nikapov 0:a1a69d32f310 1038 VL53L0X_InterruptPolarity polarity);
nikapov 0:a1a69d32f310 1039
nikapov 0:a1a69d32f310 1040 /**
nikapov 0:a1a69d32f310 1041 * @brief Start device measurement
nikapov 0:a1a69d32f310 1042 *
nikapov 0:a1a69d32f310 1043 * @details Started measurement will depend on device parameters set through
nikapov 0:a1a69d32f310 1044 * @a VL53L0X_SetParameters()
nikapov 0:a1a69d32f310 1045 * This is a non-blocking function.
nikapov 0:a1a69d32f310 1046 * This function will change the VL53L0X_State from VL53L0X_STATE_IDLE to
nikapov 0:a1a69d32f310 1047 * VL53L0X_STATE_RUNNING.
nikapov 0:a1a69d32f310 1048 *
nikapov 0:a1a69d32f310 1049 * @note This function Access to the device
nikapov 0:a1a69d32f310 1050 *
nikapov 0:a1a69d32f310 1051
nikapov 0:a1a69d32f310 1052 * @param dev Device Handle
nikapov 0:a1a69d32f310 1053 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1054 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when
nikapov 0:a1a69d32f310 1055 * DeviceMode programmed with @a VL53L0X_SetDeviceMode is not in the supported
nikapov 0:a1a69d32f310 1056 * list:
nikapov 0:a1a69d32f310 1057 * Supported mode are:
nikapov 0:a1a69d32f310 1058 * VL53L0X_DEVICEMODE_SINGLE_RANGING,
nikapov 0:a1a69d32f310 1059 * VL53L0X_DEVICEMODE_CONTINUOUS_RANGING,
nikapov 0:a1a69d32f310 1060 * VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING
nikapov 0:a1a69d32f310 1061 * @return VL53L0X_ERROR_TIME_OUT Time out on start measurement
nikapov 0:a1a69d32f310 1062 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1063 */
nikapov 0:a1a69d32f310 1064 VL53L0X_Error VL53L0X_start_measurement(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1065
nikapov 0:a1a69d32f310 1066 /**
nikapov 0:a1a69d32f310 1067 * @brief Stop device measurement
nikapov 0:a1a69d32f310 1068 *
nikapov 0:a1a69d32f310 1069 * @details Will set the device in standby mode at end of current measurement\n
nikapov 0:a1a69d32f310 1070 * Not necessary in single mode as device shall return automatically
nikapov 0:a1a69d32f310 1071 * in standby mode at end of measurement.
nikapov 0:a1a69d32f310 1072 * This function will change the VL53L0X_State from VL53L0X_STATE_RUNNING
nikapov 0:a1a69d32f310 1073 * to VL53L0X_STATE_IDLE.
nikapov 0:a1a69d32f310 1074 *
nikapov 0:a1a69d32f310 1075 * @note This function Access to the device
nikapov 0:a1a69d32f310 1076 *
nikapov 0:a1a69d32f310 1077 * @param dev Device Handle
nikapov 0:a1a69d32f310 1078 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1079 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1080 */
nikapov 0:a1a69d32f310 1081 VL53L0X_Error VL53L0X_stop_measurement(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1082
nikapov 0:a1a69d32f310 1083 /**
nikapov 0:a1a69d32f310 1084 * @brief Return device stop completion status
nikapov 0:a1a69d32f310 1085 *
nikapov 0:a1a69d32f310 1086 * @par Function Description
nikapov 0:a1a69d32f310 1087 * Returns stop completiob status.
nikapov 0:a1a69d32f310 1088 * User shall call this function after a stop command
nikapov 0:a1a69d32f310 1089 *
nikapov 0:a1a69d32f310 1090 * @note This function Access to the device
nikapov 0:a1a69d32f310 1091 *
nikapov 0:a1a69d32f310 1092 * @param dev Device Handle
nikapov 0:a1a69d32f310 1093 * @param p_stop_status Pointer to status variable to update
nikapov 0:a1a69d32f310 1094 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1095 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1096 */
nikapov 0:a1a69d32f310 1097 VL53L0X_Error VL53L0X_get_stop_completed_status(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1098 uint32_t *p_stop_status);
nikapov 0:a1a69d32f310 1099
nikapov 0:a1a69d32f310 1100 /**
nikapov 0:a1a69d32f310 1101 * @brief Return Measurement Data Ready
nikapov 0:a1a69d32f310 1102 *
nikapov 0:a1a69d32f310 1103 * @par Function Description
nikapov 0:a1a69d32f310 1104 * This function indicate that a measurement data is ready.
nikapov 0:a1a69d32f310 1105 * This function check if interrupt mode is used then check is done accordingly.
nikapov 0:a1a69d32f310 1106 * If perform function clear the interrupt, this function will not work,
nikapov 0:a1a69d32f310 1107 * like in case of @a VL53L0X_PerformSingleRangingMeasurement().
nikapov 0:a1a69d32f310 1108 * The previous function is blocking function, VL53L0X_GetMeasurementDataReady
nikapov 0:a1a69d32f310 1109 * is used for non-blocking capture.
nikapov 0:a1a69d32f310 1110 *
nikapov 0:a1a69d32f310 1111 * @note This function Access to the device
nikapov 0:a1a69d32f310 1112 *
nikapov 0:a1a69d32f310 1113 * @param dev Device Handle
nikapov 0:a1a69d32f310 1114 * @param p_measurement_data_ready Pointer to Measurement Data Ready.
nikapov 0:a1a69d32f310 1115 * 0=data not ready, 1 = data ready
nikapov 0:a1a69d32f310 1116 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1117 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1118 */
nikapov 0:a1a69d32f310 1119 VL53L0X_Error VL53L0X_get_measurement_data_ready(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1120 uint8_t *p_measurement_data_ready);
nikapov 0:a1a69d32f310 1121
nikapov 0:a1a69d32f310 1122 /**
nikapov 0:a1a69d32f310 1123 * @brief Retrieve the measurements from device for a given setup
nikapov 0:a1a69d32f310 1124 *
nikapov 0:a1a69d32f310 1125 * @par Function Description
nikapov 0:a1a69d32f310 1126 * Get data from last successful Ranging measurement
nikapov 0:a1a69d32f310 1127 * @warning USER should take care about @a VL53L0X_GetNumberOfROIZones()
nikapov 0:a1a69d32f310 1128 * before get data.
nikapov 0:a1a69d32f310 1129 * PAL will fill a NumberOfROIZones times the corresponding data
nikapov 0:a1a69d32f310 1130 * structure used in the measurement function.
nikapov 0:a1a69d32f310 1131 *
nikapov 0:a1a69d32f310 1132 * @note This function Access to the device
nikapov 0:a1a69d32f310 1133 *
nikapov 0:a1a69d32f310 1134 * @param dev Device Handle
nikapov 0:a1a69d32f310 1135 * @param p_ranging_measurement_data Pointer to the data structure to fill up.
nikapov 0:a1a69d32f310 1136 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1137 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1138 */
nikapov 0:a1a69d32f310 1139 VL53L0X_Error VL53L0X_get_ranging_measurement_data(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1140 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data);
nikapov 0:a1a69d32f310 1141
nikapov 0:a1a69d32f310 1142 /**
nikapov 0:a1a69d32f310 1143 * @brief Clear given system interrupt condition
nikapov 0:a1a69d32f310 1144 *
nikapov 0:a1a69d32f310 1145 * @par Function Description
nikapov 0:a1a69d32f310 1146 * Clear given interrupt(s).
nikapov 0:a1a69d32f310 1147 *
nikapov 0:a1a69d32f310 1148 * @note This function Access to the device
nikapov 0:a1a69d32f310 1149 *
nikapov 0:a1a69d32f310 1150 * @param dev Device Handle
nikapov 0:a1a69d32f310 1151 * @param interrupt_mask Mask of interrupts to clear
nikapov 0:a1a69d32f310 1152 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1153 * @return VL53L0X_ERROR_INTERRUPT_NOT_CLEARED Cannot clear interrupts
nikapov 0:a1a69d32f310 1154 *
nikapov 0:a1a69d32f310 1155 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1156 */
nikapov 0:a1a69d32f310 1157 VL53L0X_Error VL53L0X_clear_interrupt_mask(VL53L0X_DEV dev, uint32_t interrupt_mask);
nikapov 0:a1a69d32f310 1158
nikapov 0:a1a69d32f310 1159 /**
nikapov 0:a1a69d32f310 1160 * @brief Return device interrupt status
nikapov 0:a1a69d32f310 1161 *
nikapov 0:a1a69d32f310 1162 * @par Function Description
nikapov 0:a1a69d32f310 1163 * Returns currently raised interrupts by the device.
nikapov 0:a1a69d32f310 1164 * User shall be able to activate/deactivate interrupts through
nikapov 0:a1a69d32f310 1165 * @a VL53L0X_SetGpioConfig()
nikapov 0:a1a69d32f310 1166 *
nikapov 0:a1a69d32f310 1167 * @note This function Access to the device
nikapov 0:a1a69d32f310 1168 *
nikapov 0:a1a69d32f310 1169 * @param dev Device Handle
nikapov 0:a1a69d32f310 1170 * @param p_interrupt_mask_status Pointer to status variable to update
nikapov 0:a1a69d32f310 1171 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1172 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1173 */
nikapov 0:a1a69d32f310 1174 VL53L0X_Error VL53L0X_get_interrupt_mask_status(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1175 uint32_t *p_interrupt_mask_status);
nikapov 0:a1a69d32f310 1176
nikapov 0:a1a69d32f310 1177 /**
nikapov 0:a1a69d32f310 1178 * @brief Performs a single ranging measurement and retrieve the ranging
nikapov 0:a1a69d32f310 1179 * measurement data
nikapov 0:a1a69d32f310 1180 *
nikapov 0:a1a69d32f310 1181 * @par Function Description
nikapov 0:a1a69d32f310 1182 * This function will change the device mode to VL53L0X_DEVICEMODE_SINGLE_RANGING
nikapov 0:a1a69d32f310 1183 * with @a VL53L0X_SetDeviceMode(),
nikapov 0:a1a69d32f310 1184 * It performs measurement with @a VL53L0X_PerformSingleMeasurement()
nikapov 0:a1a69d32f310 1185 * It get data from last successful Ranging measurement with
nikapov 0:a1a69d32f310 1186 * @a VL53L0X_GetRangingMeasurementData.
nikapov 0:a1a69d32f310 1187 * Finally it clear the interrupt with @a VL53L0X_ClearInterruptMask().
nikapov 0:a1a69d32f310 1188 *
nikapov 0:a1a69d32f310 1189 * @note This function Access to the device
nikapov 0:a1a69d32f310 1190 *
nikapov 0:a1a69d32f310 1191 * @note This function change the device mode to
nikapov 0:a1a69d32f310 1192 * VL53L0X_DEVICEMODE_SINGLE_RANGING
nikapov 0:a1a69d32f310 1193 *
nikapov 0:a1a69d32f310 1194 * @param dev Device Handle
nikapov 0:a1a69d32f310 1195 * @param p_ranging_measurement_data Pointer to the data structure to fill up.
nikapov 0:a1a69d32f310 1196 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1197 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1198 */
nikapov 0:a1a69d32f310 1199 VL53L0X_Error VL53L0X_perform_single_ranging_measurement(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1200 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data);
nikapov 0:a1a69d32f310 1201
nikapov 0:a1a69d32f310 1202 /**
nikapov 0:a1a69d32f310 1203 * @brief Single shot measurement.
nikapov 0:a1a69d32f310 1204 *
nikapov 0:a1a69d32f310 1205 * @par Function Description
nikapov 0:a1a69d32f310 1206 * Perform simple measurement sequence (Start measure, Wait measure to end,
nikapov 0:a1a69d32f310 1207 * and returns when measurement is done).
nikapov 0:a1a69d32f310 1208 * Once function returns, user can get valid data by calling
nikapov 0:a1a69d32f310 1209 * VL53L0X_GetRangingMeasurement or VL53L0X_GetHistogramMeasurement
nikapov 0:a1a69d32f310 1210 * depending on defined measurement mode
nikapov 0:a1a69d32f310 1211 * User should Clear the interrupt in case this are enabled by using the
nikapov 0:a1a69d32f310 1212 * function VL53L0X_ClearInterruptMask().
nikapov 0:a1a69d32f310 1213 *
nikapov 0:a1a69d32f310 1214 * @warning This function is a blocking function
nikapov 0:a1a69d32f310 1215 *
nikapov 0:a1a69d32f310 1216 * @note This function Access to the device
nikapov 0:a1a69d32f310 1217 *
nikapov 0:a1a69d32f310 1218 * @param dev Device Handle
nikapov 0:a1a69d32f310 1219 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1220 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1221 */
nikapov 0:a1a69d32f310 1222 VL53L0X_Error VL53L0X_perform_single_measurement(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1223
nikapov 0:a1a69d32f310 1224 /**
nikapov 0:a1a69d32f310 1225 * @brief Read current status of the error register for the selected device
nikapov 0:a1a69d32f310 1226 *
nikapov 0:a1a69d32f310 1227 * @note This function Access to the device
nikapov 0:a1a69d32f310 1228 *
nikapov 0:a1a69d32f310 1229 * @param dev Device Handle
nikapov 0:a1a69d32f310 1230 * @param p_device_error_status Pointer to current error code of the device
nikapov 0:a1a69d32f310 1231 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1232 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1233 */
nikapov 0:a1a69d32f310 1234 VL53L0X_Error VL53L0X_get_device_error_status(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1235 VL53L0X_DeviceError *p_device_error_status);
nikapov 0:a1a69d32f310 1236
nikapov 0:a1a69d32f310 1237 /**
nikapov 0:a1a69d32f310 1238 * @brief Human readable error string for a given Error Code
nikapov 0:a1a69d32f310 1239 *
nikapov 0:a1a69d32f310 1240 * @note This function doesn't access to the device
nikapov 0:a1a69d32f310 1241 *
nikapov 0:a1a69d32f310 1242 * @param error_code The error code as stored on ::VL53L0X_DeviceError
nikapov 0:a1a69d32f310 1243 * @param p_device_error_string The error string corresponding to the ErrorCode
nikapov 0:a1a69d32f310 1244 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1245 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1246 */
nikapov 0:a1a69d32f310 1247 VL53L0X_Error VL53L0X_get_device_error_string(
nikapov 0:a1a69d32f310 1248 VL53L0X_DeviceError error_code, char *p_device_error_string);
nikapov 0:a1a69d32f310 1249
nikapov 0:a1a69d32f310 1250 /**
nikapov 0:a1a69d32f310 1251 * @brief Human readable Range Status string for a given RangeStatus
nikapov 0:a1a69d32f310 1252 *
nikapov 0:a1a69d32f310 1253 * @note This function doesn't access to the device
nikapov 0:a1a69d32f310 1254 *
nikapov 0:a1a69d32f310 1255 * @param range_status The RangeStatus code as stored on
nikapov 0:a1a69d32f310 1256 * @a VL53L0X_RangingMeasurementData_t
nikapov 0:a1a69d32f310 1257 * @param p_range_status_string The returned RangeStatus string.
nikapov 0:a1a69d32f310 1258 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1259 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1260 */
nikapov 0:a1a69d32f310 1261 VL53L0X_Error VL53L0X_get_range_status_string(uint8_t range_status,
nikapov 0:a1a69d32f310 1262 char *p_range_status_string);
nikapov 0:a1a69d32f310 1263
nikapov 0:a1a69d32f310 1264 VL53L0X_Error VL53L0X_get_total_signal_rate(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1265 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
nikapov 0:a1a69d32f310 1266 FixPoint1616_t *p_total_signal_rate_mcps);
nikapov 0:a1a69d32f310 1267
nikapov 0:a1a69d32f310 1268 VL53L0X_Error VL53L0X_get_total_xtalk_rate(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1269 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
nikapov 0:a1a69d32f310 1270 FixPoint1616_t *p_total_xtalk_rate_mcps);
nikapov 0:a1a69d32f310 1271
nikapov 0:a1a69d32f310 1272 /**
nikapov 0:a1a69d32f310 1273 * @brief Get Ranging Timing Budget in microseconds
nikapov 0:a1a69d32f310 1274 *
nikapov 0:a1a69d32f310 1275 * @par Function Description
nikapov 0:a1a69d32f310 1276 * Returns the programmed the maximum time allowed by the user to the
nikapov 0:a1a69d32f310 1277 * device to run a full ranging sequence for the current mode
nikapov 0:a1a69d32f310 1278 * (ranging, histogram, ASL ...)
nikapov 0:a1a69d32f310 1279 *
nikapov 0:a1a69d32f310 1280 * @note This function Access to the device
nikapov 0:a1a69d32f310 1281 *
nikapov 0:a1a69d32f310 1282 * @param dev Device Handle
nikapov 0:a1a69d32f310 1283 * @param p_measurement_timing_budget_micro_seconds Max measurement time in
nikapov 0:a1a69d32f310 1284 * microseconds.
nikapov 0:a1a69d32f310 1285 * Valid values are:
nikapov 0:a1a69d32f310 1286 * >= 17000 microsecs when wraparound enabled
nikapov 0:a1a69d32f310 1287 * >= 12000 microsecs when wraparound disabled
nikapov 0:a1a69d32f310 1288 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1289 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1290 */
nikapov 0:a1a69d32f310 1291 VL53L0X_Error VL53L0X_get_measurement_timing_budget_micro_seconds(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1292 uint32_t *p_measurement_timing_budget_micro_seconds);
nikapov 0:a1a69d32f310 1293
nikapov 0:a1a69d32f310 1294 /**
nikapov 0:a1a69d32f310 1295 * @brief Set Ranging Timing Budget in microseconds
nikapov 0:a1a69d32f310 1296 *
nikapov 0:a1a69d32f310 1297 * @par Function Description
nikapov 0:a1a69d32f310 1298 * Defines the maximum time allowed by the user to the device to run a
nikapov 0:a1a69d32f310 1299 * full ranging sequence for the current mode (ranging, histogram, ASL ...)
nikapov 0:a1a69d32f310 1300 *
nikapov 0:a1a69d32f310 1301 * @note This function Access to the device
nikapov 0:a1a69d32f310 1302 *
nikapov 0:a1a69d32f310 1303 * @param dev Device Handle
nikapov 0:a1a69d32f310 1304 * @param measurement_timing_budget_micro_seconds Max measurement time in
nikapov 0:a1a69d32f310 1305 * microseconds.
nikapov 0:a1a69d32f310 1306 * Valid values are:
nikapov 0:a1a69d32f310 1307 * >= 17000 microsecs when wraparound enabled
nikapov 0:a1a69d32f310 1308 * >= 12000 microsecs when wraparound disabled
nikapov 0:a1a69d32f310 1309 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1310 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned if
nikapov 0:a1a69d32f310 1311 MeasurementTimingBudgetMicroSeconds out of range
nikapov 0:a1a69d32f310 1312 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1313 */
nikapov 0:a1a69d32f310 1314 VL53L0X_Error VL53L0X_set_measurement_timing_budget_micro_seconds(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1315 uint32_t measurement_timing_budget_micro_seconds);
nikapov 0:a1a69d32f310 1316
nikapov 0:a1a69d32f310 1317 /**
nikapov 0:a1a69d32f310 1318 * @brief Get specific limit check enable state
nikapov 0:a1a69d32f310 1319 *
nikapov 0:a1a69d32f310 1320 * @par Function Description
nikapov 0:a1a69d32f310 1321 * This function get the enable state of a specific limit check.
nikapov 0:a1a69d32f310 1322 * The limit check is identified with the LimitCheckId.
nikapov 0:a1a69d32f310 1323 *
nikapov 0:a1a69d32f310 1324 * @note This function Access to the device
nikapov 0:a1a69d32f310 1325 *
nikapov 0:a1a69d32f310 1326 * @param dev Device Handle
nikapov 0:a1a69d32f310 1327 * @param limit_check_id Limit Check ID
nikapov 0:a1a69d32f310 1328 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
nikapov 0:a1a69d32f310 1329 * @param p_limit_check_enable Pointer to the check limit enable
nikapov 0:a1a69d32f310 1330 * value.
nikapov 0:a1a69d32f310 1331 * if 1 the check limit
nikapov 0:a1a69d32f310 1332 * corresponding to LimitCheckId is Enabled
nikapov 0:a1a69d32f310 1333 * if 0 the check limit
nikapov 0:a1a69d32f310 1334 * corresponding to LimitCheckId is disabled
nikapov 0:a1a69d32f310 1335 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1336 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned
nikapov 0:a1a69d32f310 1337 * when LimitCheckId value is out of range.
nikapov 0:a1a69d32f310 1338 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1339 */
nikapov 0:a1a69d32f310 1340 VL53L0X_Error VL53L0X_get_limit_check_enable(VL53L0X_DEV dev, uint16_t limit_check_id,
nikapov 0:a1a69d32f310 1341 uint8_t *p_limit_check_enable);
nikapov 0:a1a69d32f310 1342
nikapov 0:a1a69d32f310 1343 /**
nikapov 0:a1a69d32f310 1344 * @brief Enable/Disable a specific limit check
nikapov 0:a1a69d32f310 1345 *
nikapov 0:a1a69d32f310 1346 * @par Function Description
nikapov 0:a1a69d32f310 1347 * This function Enable/Disable a specific limit check.
nikapov 0:a1a69d32f310 1348 * The limit check is identified with the LimitCheckId.
nikapov 0:a1a69d32f310 1349 *
nikapov 0:a1a69d32f310 1350 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 1351 *
nikapov 0:a1a69d32f310 1352 * @param dev Device Handle
nikapov 0:a1a69d32f310 1353 * @param limit_check_id Limit Check ID
nikapov 0:a1a69d32f310 1354 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
nikapov 0:a1a69d32f310 1355 * @param limit_check_enable if 1 the check limit
nikapov 0:a1a69d32f310 1356 * corresponding to LimitCheckId is Enabled
nikapov 0:a1a69d32f310 1357 * if 0 the check limit
nikapov 0:a1a69d32f310 1358 * corresponding to LimitCheckId is disabled
nikapov 0:a1a69d32f310 1359 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1360 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned
nikapov 0:a1a69d32f310 1361 * when LimitCheckId value is out of range.
nikapov 0:a1a69d32f310 1362 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1363 */
nikapov 0:a1a69d32f310 1364 VL53L0X_Error VL53L0X_set_limit_check_enable(VL53L0X_DEV dev, uint16_t limit_check_id,
nikapov 0:a1a69d32f310 1365 uint8_t limit_check_enable);
nikapov 0:a1a69d32f310 1366
nikapov 0:a1a69d32f310 1367 /**
nikapov 0:a1a69d32f310 1368 * @brief Get a specific limit check value
nikapov 0:a1a69d32f310 1369 *
nikapov 0:a1a69d32f310 1370 * @par Function Description
nikapov 0:a1a69d32f310 1371 * This function get a specific limit check value from device then it updates
nikapov 0:a1a69d32f310 1372 * internal values and check enables.
nikapov 0:a1a69d32f310 1373 * The limit check is identified with the LimitCheckId.
nikapov 0:a1a69d32f310 1374 *
nikapov 0:a1a69d32f310 1375 * @note This function Access to the device
nikapov 0:a1a69d32f310 1376 *
nikapov 0:a1a69d32f310 1377 * @param dev Device Handle
nikapov 0:a1a69d32f310 1378 * @param limit_check_id Limit Check ID
nikapov 0:a1a69d32f310 1379 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
nikapov 0:a1a69d32f310 1380 * @param p_limit_check_value Pointer to Limit
nikapov 0:a1a69d32f310 1381 * check Value for a given LimitCheckId.
nikapov 0:a1a69d32f310 1382 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1383 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned
nikapov 0:a1a69d32f310 1384 * when LimitCheckId value is out of range.
nikapov 0:a1a69d32f310 1385 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1386 */
nikapov 0:a1a69d32f310 1387 VL53L0X_Error VL53L0X_get_limit_check_value(VL53L0X_DEV dev, uint16_t limit_check_id,
nikapov 0:a1a69d32f310 1388 FixPoint1616_t *p_limit_check_value);
nikapov 0:a1a69d32f310 1389
nikapov 0:a1a69d32f310 1390 /**
nikapov 0:a1a69d32f310 1391 * @brief Set a specific limit check value
nikapov 0:a1a69d32f310 1392 *
nikapov 0:a1a69d32f310 1393 * @par Function Description
nikapov 0:a1a69d32f310 1394 * This function set a specific limit check value.
nikapov 0:a1a69d32f310 1395 * The limit check is identified with the LimitCheckId.
nikapov 0:a1a69d32f310 1396 *
nikapov 0:a1a69d32f310 1397 * @note This function Access to the device
nikapov 0:a1a69d32f310 1398 *
nikapov 0:a1a69d32f310 1399 * @param dev Device Handle
nikapov 0:a1a69d32f310 1400 * @param limit_check_id Limit Check ID
nikapov 0:a1a69d32f310 1401 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
nikapov 0:a1a69d32f310 1402 * @param limit_check_value Limit check Value for a given
nikapov 0:a1a69d32f310 1403 * LimitCheckId
nikapov 0:a1a69d32f310 1404 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1405 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned when either
nikapov 0:a1a69d32f310 1406 * LimitCheckId or LimitCheckValue value is out of range.
nikapov 0:a1a69d32f310 1407 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1408 */
nikapov 0:a1a69d32f310 1409 VL53L0X_Error VL53L0X_set_limit_check_value(VL53L0X_DEV dev, uint16_t limit_check_id,
nikapov 0:a1a69d32f310 1410 FixPoint1616_t limit_check_value);
nikapov 0:a1a69d32f310 1411
nikapov 0:a1a69d32f310 1412 /**
nikapov 0:a1a69d32f310 1413 * @brief Get the current value of the signal used for the limit check
nikapov 0:a1a69d32f310 1414 *
nikapov 0:a1a69d32f310 1415 * @par Function Description
nikapov 0:a1a69d32f310 1416 * This function get a the current value of the signal used for the limit check.
nikapov 0:a1a69d32f310 1417 * To obtain the latest value you should run a ranging before.
nikapov 0:a1a69d32f310 1418 * The value reported is linked to the limit check identified with the
nikapov 0:a1a69d32f310 1419 * LimitCheckId.
nikapov 0:a1a69d32f310 1420 *
nikapov 0:a1a69d32f310 1421 * @note This function Access to the device
nikapov 0:a1a69d32f310 1422 *
nikapov 0:a1a69d32f310 1423 * @param dev Device Handle
nikapov 0:a1a69d32f310 1424 * @param limit_check_id Limit Check ID
nikapov 0:a1a69d32f310 1425 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
nikapov 0:a1a69d32f310 1426 * @param p_limit_check_current Pointer to current Value for a
nikapov 0:a1a69d32f310 1427 * given LimitCheckId.
nikapov 0:a1a69d32f310 1428 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1429 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned when
nikapov 0:a1a69d32f310 1430 * LimitCheckId value is out of range.
nikapov 0:a1a69d32f310 1431 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1432 */
nikapov 0:a1a69d32f310 1433 VL53L0X_Error VL53L0X_get_limit_check_current(VL53L0X_DEV dev, uint16_t limit_check_id,
nikapov 0:a1a69d32f310 1434 FixPoint1616_t *p_limit_check_current);
nikapov 0:a1a69d32f310 1435
nikapov 0:a1a69d32f310 1436 /**
nikapov 0:a1a69d32f310 1437 * @brief Return a the Status of the specified check limit
nikapov 0:a1a69d32f310 1438 *
nikapov 0:a1a69d32f310 1439 * @par Function Description
nikapov 0:a1a69d32f310 1440 * This function returns the Status of the specified check limit.
nikapov 0:a1a69d32f310 1441 * The value indicate if the check is fail or not.
nikapov 0:a1a69d32f310 1442 * The limit check is identified with the LimitCheckId.
nikapov 0:a1a69d32f310 1443 *
nikapov 0:a1a69d32f310 1444 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 1445 *
nikapov 0:a1a69d32f310 1446 * @param dev Device Handle
nikapov 0:a1a69d32f310 1447 * @param limit_check_id Limit Check ID
nikapov 0:a1a69d32f310 1448 (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
nikapov 0:a1a69d32f310 1449 * @param p_limit_check_status Pointer to the
nikapov 0:a1a69d32f310 1450 Limit Check Status of the given check limit.
nikapov 0:a1a69d32f310 1451 * LimitCheckStatus :
nikapov 0:a1a69d32f310 1452 * 0 the check is not fail
nikapov 0:a1a69d32f310 1453 * 1 the check if fail or not enabled
nikapov 0:a1a69d32f310 1454 *
nikapov 0:a1a69d32f310 1455 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1456 * @return VL53L0X_ERROR_INVALID_PARAMS This error is
nikapov 0:a1a69d32f310 1457 returned when LimitCheckId value is out of range.
nikapov 0:a1a69d32f310 1458 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1459 */
nikapov 0:a1a69d32f310 1460 VL53L0X_Error VL53L0X_get_limit_check_status(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1461 uint16_t limit_check_id, uint8_t *p_limit_check_status);
nikapov 0:a1a69d32f310 1462
nikapov 0:a1a69d32f310 1463 /**
nikapov 0:a1a69d32f310 1464 * Get continuous mode Inter-Measurement period in milliseconds
nikapov 0:a1a69d32f310 1465 *
nikapov 0:a1a69d32f310 1466 * @par Function Description
nikapov 0:a1a69d32f310 1467 * When trying to set too short time return INVALID_PARAMS minimal value
nikapov 0:a1a69d32f310 1468 *
nikapov 0:a1a69d32f310 1469 * @note This function Access to the device
nikapov 0:a1a69d32f310 1470 *
nikapov 0:a1a69d32f310 1471 * @param dev Device Handle
nikapov 0:a1a69d32f310 1472 * @param p_inter_measurement_period_milli_seconds Pointer to programmed
nikapov 0:a1a69d32f310 1473 * Inter-Measurement Period in milliseconds.
nikapov 0:a1a69d32f310 1474 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1475 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1476 */
nikapov 0:a1a69d32f310 1477 VL53L0X_Error VL53L0X_get_inter_measurement_period_milli_seconds(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1478 uint32_t *p_inter_measurement_period_milli_seconds);
nikapov 0:a1a69d32f310 1479
nikapov 0:a1a69d32f310 1480 /**
nikapov 0:a1a69d32f310 1481 * Program continuous mode Inter-Measurement period in milliseconds
nikapov 0:a1a69d32f310 1482 *
nikapov 0:a1a69d32f310 1483 * @par Function Description
nikapov 0:a1a69d32f310 1484 * When trying to set too short time return INVALID_PARAMS minimal value
nikapov 0:a1a69d32f310 1485 *
nikapov 0:a1a69d32f310 1486 * @note This function Access to the device
nikapov 0:a1a69d32f310 1487 *
nikapov 0:a1a69d32f310 1488 * @param dev Device Handle
nikapov 0:a1a69d32f310 1489 * @param inter_measurement_period_milli_seconds Inter-Measurement Period in ms.
nikapov 0:a1a69d32f310 1490 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1491 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1492 */
nikapov 0:a1a69d32f310 1493 VL53L0X_Error VL53L0X_set_inter_measurement_period_milli_seconds(
nikapov 0:a1a69d32f310 1494 VL53L0X_DEV dev, uint32_t inter_measurement_period_milli_seconds);
nikapov 0:a1a69d32f310 1495
nikapov 0:a1a69d32f310 1496 /**
nikapov 0:a1a69d32f310 1497 * @brief Set new device address
nikapov 0:a1a69d32f310 1498 *
nikapov 0:a1a69d32f310 1499 * After completion the device will answer to the new address programmed.
nikapov 0:a1a69d32f310 1500 * This function should be called when several devices are used in parallel
nikapov 0:a1a69d32f310 1501 * before start programming the sensor.
nikapov 0:a1a69d32f310 1502 * When a single device us used, there is no need to call this function.
nikapov 0:a1a69d32f310 1503 *
nikapov 0:a1a69d32f310 1504 * @note This function Access to the device
nikapov 0:a1a69d32f310 1505 *
nikapov 0:a1a69d32f310 1506 * @param dev Device Handle
nikapov 0:a1a69d32f310 1507 * @param device_address The new Device address
nikapov 0:a1a69d32f310 1508 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1509 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1510 */
nikapov 0:a1a69d32f310 1511 VL53L0X_Error VL53L0X_set_device_address(VL53L0X_DEV dev, uint8_t device_address);
nikapov 0:a1a69d32f310 1512
nikapov 0:a1a69d32f310 1513 /**
nikapov 0:a1a69d32f310 1514 * @brief Do an hard reset or soft reset (depending on implementation) of the
nikapov 0:a1a69d32f310 1515 * device \nAfter call of this function, device must be in same state as right
nikapov 0:a1a69d32f310 1516 * after a power-up sequence.This function will change the VL53L0X_State to
nikapov 0:a1a69d32f310 1517 * VL53L0X_STATE_POWERDOWN.
nikapov 0:a1a69d32f310 1518 *
nikapov 0:a1a69d32f310 1519 * @note This function Access to the device
nikapov 0:a1a69d32f310 1520 *
nikapov 0:a1a69d32f310 1521 * @param dev Device Handle
nikapov 0:a1a69d32f310 1522 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1523 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1524 */
nikapov 0:a1a69d32f310 1525 VL53L0X_Error VL53L0X_reset_device(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1526
nikapov 0:a1a69d32f310 1527 /**
nikapov 0:a1a69d32f310 1528 * @brief Get setup of Wrap around Check
nikapov 0:a1a69d32f310 1529 *
nikapov 0:a1a69d32f310 1530 * @par Function Description
nikapov 0:a1a69d32f310 1531 * This function get the wrapAround check enable parameters
nikapov 0:a1a69d32f310 1532 *
nikapov 0:a1a69d32f310 1533 * @note This function Access to the device
nikapov 0:a1a69d32f310 1534 *
nikapov 0:a1a69d32f310 1535 * @param dev Device Handle
nikapov 0:a1a69d32f310 1536 * @param p_wrap_around_check_enable Pointer to the Wrap around Check state
nikapov 0:a1a69d32f310 1537 * 0=disabled or 1 = enabled
nikapov 0:a1a69d32f310 1538 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1539 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1540 */
nikapov 0:a1a69d32f310 1541 VL53L0X_Error VL53L0X_get_wrap_around_check_enable(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1542 uint8_t *p_wrap_around_check_enable);
nikapov 0:a1a69d32f310 1543
nikapov 0:a1a69d32f310 1544 /**
nikapov 0:a1a69d32f310 1545 * @brief Enable (or disable) Wrap around Check
nikapov 0:a1a69d32f310 1546 *
nikapov 0:a1a69d32f310 1547 * @note This function Access to the device
nikapov 0:a1a69d32f310 1548 *
nikapov 0:a1a69d32f310 1549 * @param dev Device Handle
nikapov 0:a1a69d32f310 1550 * @param wrap_around_check_enable Wrap around Check to be set
nikapov 0:a1a69d32f310 1551 * 0=disabled, other = enabled
nikapov 0:a1a69d32f310 1552 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1553 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1554 */
nikapov 0:a1a69d32f310 1555 VL53L0X_Error VL53L0X_set_wrap_around_check_enable(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1556 uint8_t wrap_around_check_enable);
nikapov 0:a1a69d32f310 1557
nikapov 0:a1a69d32f310 1558 /**
nikapov 0:a1a69d32f310 1559 * @brief Gets the VCSEL pulse period.
nikapov 0:a1a69d32f310 1560 *
nikapov 0:a1a69d32f310 1561 * @par Function Description
nikapov 0:a1a69d32f310 1562 * This function retrieves the VCSEL pulse period for the given period type.
nikapov 0:a1a69d32f310 1563 *
nikapov 0:a1a69d32f310 1564 * @note This function Accesses the device
nikapov 0:a1a69d32f310 1565 *
nikapov 0:a1a69d32f310 1566 * @param dev Device Handle
nikapov 0:a1a69d32f310 1567 * @param vcsel_period_type VCSEL period identifier (pre-range|final).
nikapov 0:a1a69d32f310 1568 * @param p_vcsel_pulse_period_pclk Pointer to VCSEL period value.
nikapov 0:a1a69d32f310 1569 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1570 * @return VL53L0X_ERROR_INVALID_PARAMS Error VcselPeriodType parameter not
nikapov 0:a1a69d32f310 1571 * supported.
nikapov 0:a1a69d32f310 1572 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1573 */
nikapov 0:a1a69d32f310 1574 VL53L0X_Error VL53L0X_get_vcsel_pulse_period(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1575 VL53L0X_VcselPeriod vcsel_period_type, uint8_t *p_vcsel_pulse_period_pclk);
nikapov 0:a1a69d32f310 1576
nikapov 0:a1a69d32f310 1577 /**
nikapov 0:a1a69d32f310 1578 * @brief Sets the VCSEL pulse period.
nikapov 0:a1a69d32f310 1579 *
nikapov 0:a1a69d32f310 1580 * @par Function Description
nikapov 0:a1a69d32f310 1581 * This function retrieves the VCSEL pulse period for the given period type.
nikapov 0:a1a69d32f310 1582 *
nikapov 0:a1a69d32f310 1583 * @note This function Accesses the device
nikapov 0:a1a69d32f310 1584 *
nikapov 0:a1a69d32f310 1585 * @param dev Device Handle
nikapov 0:a1a69d32f310 1586 * @param vcsel_period_type VCSEL period identifier (pre-range|final).
nikapov 0:a1a69d32f310 1587 * @param vcsel_pulse_period VCSEL period value
nikapov 0:a1a69d32f310 1588 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1589 * @return VL53L0X_ERROR_INVALID_PARAMS Error VcselPeriodType parameter not
nikapov 0:a1a69d32f310 1590 * supported.
nikapov 0:a1a69d32f310 1591 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1592 */
nikapov 0:a1a69d32f310 1593 VL53L0X_Error VL53L0X_set_vcsel_pulse_period(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1594 VL53L0X_VcselPeriod vcsel_period_type, uint8_t vcsel_pulse_period);
nikapov 0:a1a69d32f310 1595
nikapov 0:a1a69d32f310 1596 /**
nikapov 0:a1a69d32f310 1597 * @brief Set low and high Interrupt thresholds for a given mode
nikapov 0:a1a69d32f310 1598 * (ranging, ALS, ...) for a given device
nikapov 0:a1a69d32f310 1599 *
nikapov 0:a1a69d32f310 1600 * @par Function Description
nikapov 0:a1a69d32f310 1601 * Set low and high Interrupt thresholds for a given mode (ranging, ALS, ...)
nikapov 0:a1a69d32f310 1602 * for a given device
nikapov 0:a1a69d32f310 1603 *
nikapov 0:a1a69d32f310 1604 * @note This function Access to the device
nikapov 0:a1a69d32f310 1605 *
nikapov 0:a1a69d32f310 1606 * @note DeviceMode is ignored for the current device
nikapov 0:a1a69d32f310 1607 *
nikapov 0:a1a69d32f310 1608 * @param dev Device Handle
nikapov 0:a1a69d32f310 1609 * @param device_mode Device Mode for which change thresholds
nikapov 0:a1a69d32f310 1610 * @param threshold_low Low threshold (mm, lux ..., depending on the mode)
nikapov 0:a1a69d32f310 1611 * @param threshold_high High threshold (mm, lux ..., depending on the mode)
nikapov 0:a1a69d32f310 1612 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1613 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1614 */
nikapov 0:a1a69d32f310 1615 VL53L0X_Error VL53L0X_set_interrupt_thresholds(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1616 VL53L0X_DeviceModes device_mode, FixPoint1616_t threshold_low,
nikapov 0:a1a69d32f310 1617 FixPoint1616_t threshold_high);
nikapov 0:a1a69d32f310 1618
nikapov 0:a1a69d32f310 1619 /**
nikapov 0:a1a69d32f310 1620 * @brief Get high and low Interrupt thresholds for a given mode
nikapov 0:a1a69d32f310 1621 * (ranging, ALS, ...) for a given device
nikapov 0:a1a69d32f310 1622 *
nikapov 0:a1a69d32f310 1623 * @par Function Description
nikapov 0:a1a69d32f310 1624 * Get high and low Interrupt thresholds for a given mode (ranging, ALS, ...)
nikapov 0:a1a69d32f310 1625 * for a given device
nikapov 0:a1a69d32f310 1626 *
nikapov 0:a1a69d32f310 1627 * @note This function Access to the device
nikapov 0:a1a69d32f310 1628 *
nikapov 0:a1a69d32f310 1629 * @note DeviceMode is ignored for the current device
nikapov 0:a1a69d32f310 1630 *
nikapov 0:a1a69d32f310 1631 * @param dev Device Handle
nikapov 0:a1a69d32f310 1632 * @param device_mode Device Mode from which read thresholds
nikapov 0:a1a69d32f310 1633 * @param p_threshold_low Low threshold (mm, lux ..., depending on the mode)
nikapov 0:a1a69d32f310 1634 * @param p_threshold_high High threshold (mm, lux ..., depending on the mode)
nikapov 0:a1a69d32f310 1635 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1636 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1637 */
nikapov 0:a1a69d32f310 1638 VL53L0X_Error VL53L0X_get_interrupt_thresholds(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1639 VL53L0X_DeviceModes device_mode, FixPoint1616_t *p_threshold_low,
nikapov 0:a1a69d32f310 1640 FixPoint1616_t *p_threshold_high);
nikapov 0:a1a69d32f310 1641
nikapov 0:a1a69d32f310 1642 /**
nikapov 0:a1a69d32f310 1643 * @brief Reads the Device information for given Device
nikapov 0:a1a69d32f310 1644 *
nikapov 0:a1a69d32f310 1645 * @note This function Access to the device
nikapov 0:a1a69d32f310 1646 *
nikapov 0:a1a69d32f310 1647 * @param dev Device Handle
nikapov 0:a1a69d32f310 1648 * @param p_VL53L0X_device_info Pointer to current device info for a given
nikapov 0:a1a69d32f310 1649 * Device
nikapov 0:a1a69d32f310 1650 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1651 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1652 */
nikapov 0:a1a69d32f310 1653 VL53L0X_Error VL53L0X_get_device_info(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1654 VL53L0X_DeviceInfo_t *p_VL53L0X_device_info);
nikapov 0:a1a69d32f310 1655
nikapov 0:a1a69d32f310 1656 /**
nikapov 0:a1a69d32f310 1657 * @brief Gets the (on/off) state of all sequence steps.
nikapov 0:a1a69d32f310 1658 *
nikapov 0:a1a69d32f310 1659 * @par Function Description
nikapov 0:a1a69d32f310 1660 * This function retrieves the state of all sequence step in the scheduler.
nikapov 0:a1a69d32f310 1661 *
nikapov 0:a1a69d32f310 1662 * @note This function Accesses the device
nikapov 0:a1a69d32f310 1663 *
nikapov 0:a1a69d32f310 1664 * @param dev Device Handle
nikapov 0:a1a69d32f310 1665 * @param p_scheduler_sequence_steps Pointer to struct containing result.
nikapov 0:a1a69d32f310 1666 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1667 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1668 */
nikapov 0:a1a69d32f310 1669 VL53L0X_Error VL53L0X_get_sequence_step_enables(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1670 VL53L0X_SchedulerSequenceSteps_t *p_scheduler_sequence_steps);
nikapov 0:a1a69d32f310 1671
nikapov 0:a1a69d32f310 1672 /**
nikapov 0:a1a69d32f310 1673 * @brief Sets the (on/off) state of a requested sequence step.
nikapov 0:a1a69d32f310 1674 *
nikapov 0:a1a69d32f310 1675 * @par Function Description
nikapov 0:a1a69d32f310 1676 * This function enables/disables a requested sequence step.
nikapov 0:a1a69d32f310 1677 *
nikapov 0:a1a69d32f310 1678 * @note This function Accesses the device
nikapov 0:a1a69d32f310 1679 *
nikapov 0:a1a69d32f310 1680 * @param dev Device Handle
nikapov 0:a1a69d32f310 1681 * @param sequence_step_id Sequence step identifier.
nikapov 0:a1a69d32f310 1682 * @param sequence_step_enabled Demanded state {0=Off,1=On}
nikapov 0:a1a69d32f310 1683 * is enabled.
nikapov 0:a1a69d32f310 1684 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1685 * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not
nikapov 0:a1a69d32f310 1686 * supported.
nikapov 0:a1a69d32f310 1687 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1688 */
nikapov 0:a1a69d32f310 1689 VL53L0X_Error VL53L0X_set_sequence_step_enable(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1690 VL53L0X_SequenceStepId sequence_step_id, uint8_t sequence_step_enabled);
nikapov 0:a1a69d32f310 1691
nikapov 0:a1a69d32f310 1692 /**
nikapov 0:a1a69d32f310 1693 * @brief Gets the fraction enable parameter indicating the resolution of
nikapov 0:a1a69d32f310 1694 * range measurements.
nikapov 0:a1a69d32f310 1695 *
nikapov 0:a1a69d32f310 1696 * @par Function Description
nikapov 0:a1a69d32f310 1697 * Gets the fraction enable state, which translates to the resolution of
nikapov 0:a1a69d32f310 1698 * range measurements as follows :Enabled:=0.25mm resolution,
nikapov 0:a1a69d32f310 1699 * Not Enabled:=1mm resolution.
nikapov 0:a1a69d32f310 1700 *
nikapov 0:a1a69d32f310 1701 * @note This function Accesses the device
nikapov 0:a1a69d32f310 1702 *
nikapov 0:a1a69d32f310 1703 * @param dev Device Handle
nikapov 0:a1a69d32f310 1704 * @param p_enabled Output Parameter reporting the fraction enable state.
nikapov 0:a1a69d32f310 1705 *
nikapov 0:a1a69d32f310 1706 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1707 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1708 */
nikapov 0:a1a69d32f310 1709 VL53L0X_Error VL53L0X_get_fraction_enable(VL53L0X_DEV dev, uint8_t *p_enabled);
nikapov 0:a1a69d32f310 1710
nikapov 0:a1a69d32f310 1711 /**
nikapov 0:a1a69d32f310 1712 * @brief Sets the resolution of range measurements.
nikapov 0:a1a69d32f310 1713 * @par Function Description
nikapov 0:a1a69d32f310 1714 * Set resolution of range measurements to either 0.25mm if
nikapov 0:a1a69d32f310 1715 * fraction enabled or 1mm if not enabled.
nikapov 0:a1a69d32f310 1716 *
nikapov 0:a1a69d32f310 1717 * @note This function Accesses the device
nikapov 0:a1a69d32f310 1718 *
nikapov 0:a1a69d32f310 1719 * @param dev Device Handle
nikapov 0:a1a69d32f310 1720 * @param enable Enable high resolution
nikapov 0:a1a69d32f310 1721 *
nikapov 0:a1a69d32f310 1722 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1723 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1724 */
nikapov 0:a1a69d32f310 1725 VL53L0X_Error VL53L0X_set_range_fraction_enable(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1726 uint8_t enable);
nikapov 0:a1a69d32f310 1727
nikapov 0:a1a69d32f310 1728 /**
nikapov 0:a1a69d32f310 1729 * @brief Return the VL53L0X PAL Implementation Version
nikapov 0:a1a69d32f310 1730 *
nikapov 0:a1a69d32f310 1731 * @note This function doesn't access to the device
nikapov 0:a1a69d32f310 1732 *
nikapov 0:a1a69d32f310 1733 * @param p_version Pointer to current PAL Implementation Version
nikapov 0:a1a69d32f310 1734 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1735 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1736 */
nikapov 0:a1a69d32f310 1737 VL53L0X_Error VL53L0X_get_version(VL53L0X_Version_t *p_version);
nikapov 0:a1a69d32f310 1738
nikapov 0:a1a69d32f310 1739 /**
nikapov 0:a1a69d32f310 1740 * @brief Reads the Product Revision for a for given Device
nikapov 0:a1a69d32f310 1741 * This function can be used to distinguish cut1.0 from cut1.1.
nikapov 0:a1a69d32f310 1742 *
nikapov 0:a1a69d32f310 1743 * @note This function Access to the device
nikapov 0:a1a69d32f310 1744 *
nikapov 0:a1a69d32f310 1745 * @param dev Device Handle
nikapov 0:a1a69d32f310 1746 * @param p_product_revision_major Pointer to Product Revision Major
nikapov 0:a1a69d32f310 1747 * for a given Device
nikapov 0:a1a69d32f310 1748 * @param p_product_revision_minor Pointer to Product Revision Minor
nikapov 0:a1a69d32f310 1749 * for a given Device
nikapov 0:a1a69d32f310 1750 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1751 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1752 */
nikapov 0:a1a69d32f310 1753 VL53L0X_Error VL53L0X_get_product_revision(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1754 uint8_t *p_product_revision_major, uint8_t *p_product_revision_minor);
nikapov 0:a1a69d32f310 1755
nikapov 0:a1a69d32f310 1756 /**
nikapov 0:a1a69d32f310 1757 * @brief Retrieve current device parameters
nikapov 0:a1a69d32f310 1758 * @par Function Description
nikapov 0:a1a69d32f310 1759 * Get actual parameters of the device
nikapov 0:a1a69d32f310 1760 * @li Then start ranging operation.
nikapov 0:a1a69d32f310 1761 *
nikapov 0:a1a69d32f310 1762 * @note This function Access to the device
nikapov 0:a1a69d32f310 1763 *
nikapov 0:a1a69d32f310 1764 * @param dev Device Handle
nikapov 0:a1a69d32f310 1765 * @param p_device_parameters Pointer to store current device parameters.
nikapov 0:a1a69d32f310 1766 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1767 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1768 */
nikapov 0:a1a69d32f310 1769 VL53L0X_Error VL53L0X_get_device_parameters(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1770 VL53L0X_DeviceParameters_t *p_device_parameters);
nikapov 0:a1a69d32f310 1771
nikapov 0:a1a69d32f310 1772 /**
nikapov 0:a1a69d32f310 1773 * @brief Human readable error string for current PAL error status
nikapov 0:a1a69d32f310 1774 *
nikapov 0:a1a69d32f310 1775 * @note This function doesn't access to the device
nikapov 0:a1a69d32f310 1776 *
nikapov 0:a1a69d32f310 1777 * @param pal_error_code The error code as stored on @a VL53L0X_Error
nikapov 0:a1a69d32f310 1778 * @param p_pal_error_string The error string corresponding to the
nikapov 0:a1a69d32f310 1779 * PalErrorCode
nikapov 0:a1a69d32f310 1780 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1781 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1782 */
nikapov 0:a1a69d32f310 1783 VL53L0X_Error VL53L0X_get_pal_error_string(VL53L0X_Error pal_error_code,
nikapov 0:a1a69d32f310 1784 char *p_pal_error_string);
nikapov 0:a1a69d32f310 1785
nikapov 0:a1a69d32f310 1786 /**
nikapov 0:a1a69d32f310 1787 * @brief Return the PAL Specification Version used for the current
nikapov 0:a1a69d32f310 1788 * implementation.
nikapov 0:a1a69d32f310 1789 *
nikapov 0:a1a69d32f310 1790 * @note This function doesn't access to the device
nikapov 0:a1a69d32f310 1791 *
nikapov 0:a1a69d32f310 1792 * @param p_pal_spec_version Pointer to current PAL Specification Version
nikapov 0:a1a69d32f310 1793 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1794 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1795 */
nikapov 0:a1a69d32f310 1796 VL53L0X_Error VL53L0X_get_pal_spec_version(
nikapov 0:a1a69d32f310 1797 VL53L0X_Version_t *p_pal_spec_version);
nikapov 0:a1a69d32f310 1798
nikapov 0:a1a69d32f310 1799 /**
nikapov 0:a1a69d32f310 1800 * @brief Reads the internal state of the PAL for a given Device
nikapov 0:a1a69d32f310 1801 *
nikapov 0:a1a69d32f310 1802 * @note This function doesn't access to the device
nikapov 0:a1a69d32f310 1803 *
nikapov 0:a1a69d32f310 1804 * @param dev Device Handle
nikapov 0:a1a69d32f310 1805 * @param p_pal_state Pointer to current state of the PAL for a
nikapov 0:a1a69d32f310 1806 * given Device
nikapov 0:a1a69d32f310 1807 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1808 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1809 */
nikapov 0:a1a69d32f310 1810 VL53L0X_Error VL53L0X_get_pal_state(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1811 VL53L0X_State *p_pal_state);
nikapov 0:a1a69d32f310 1812
nikapov 0:a1a69d32f310 1813 /**
nikapov 0:a1a69d32f310 1814 * @brief Human readable PAL State string
nikapov 0:a1a69d32f310 1815 *
nikapov 0:a1a69d32f310 1816 * @note This function doesn't access to the device
nikapov 0:a1a69d32f310 1817 *
nikapov 0:a1a69d32f310 1818 * @param pal_state_code The State code as stored on @a VL53L0X_State
nikapov 0:a1a69d32f310 1819 * @param p_pal_state_string The State string corresponding to the
nikapov 0:a1a69d32f310 1820 * PalStateCode
nikapov 0:a1a69d32f310 1821 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1822 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1823 */
nikapov 0:a1a69d32f310 1824 VL53L0X_Error VL53L0X_get_pal_state_string(VL53L0X_State pal_state_code,
nikapov 0:a1a69d32f310 1825 char *p_pal_state_string);
nikapov 0:a1a69d32f310 1826
nikapov 0:a1a69d32f310 1827 /*** End High level API ***/
nikapov 0:a1a69d32f310 1828 private:
nikapov 0:a1a69d32f310 1829 /* api.h functions */
nikapov 0:a1a69d32f310 1830
nikapov 0:a1a69d32f310 1831 /**
nikapov 0:a1a69d32f310 1832 * @brief Wait for device booted after chip enable (hardware standby)
nikapov 0:a1a69d32f310 1833 * This function can be run only when VL53L0X_State is VL53L0X_STATE_POWERDOWN.
nikapov 0:a1a69d32f310 1834 *
nikapov 0:a1a69d32f310 1835 * @note This function is not Implemented
nikapov 0:a1a69d32f310 1836 *
nikapov 0:a1a69d32f310 1837 * @param dev Device Handle
nikapov 0:a1a69d32f310 1838 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
nikapov 0:a1a69d32f310 1839 *
nikapov 0:a1a69d32f310 1840 */
nikapov 0:a1a69d32f310 1841 VL53L0X_Error VL53L0X_wait_device_booted(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1842
nikapov 0:a1a69d32f310 1843
nikapov 0:a1a69d32f310 1844 VL53L0X_Error sequence_step_enabled(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1845 VL53L0X_SequenceStepId sequence_step_id, uint8_t sequence_config,
nikapov 0:a1a69d32f310 1846 uint8_t *p_sequence_step_enabled);
nikapov 0:a1a69d32f310 1847
nikapov 0:a1a69d32f310 1848 VL53L0X_Error VL53L0X_check_and_load_interrupt_settings(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1849 uint8_t start_not_stopflag);
nikapov 0:a1a69d32f310 1850
nikapov 0:a1a69d32f310 1851
nikapov 0:a1a69d32f310 1852 /* api_core.h functions */
nikapov 0:a1a69d32f310 1853
nikapov 0:a1a69d32f310 1854 VL53L0X_Error VL53L0X_get_info_from_device(VL53L0X_DEV dev, uint8_t option);
nikapov 0:a1a69d32f310 1855
nikapov 0:a1a69d32f310 1856 VL53L0X_Error VL53L0X_device_read_strobe(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1857
nikapov 0:a1a69d32f310 1858 VL53L0X_Error wrapped_VL53L0X_get_measurement_timing_budget_micro_seconds(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1859 uint32_t *p_measurement_timing_budget_micro_seconds);
nikapov 0:a1a69d32f310 1860
nikapov 0:a1a69d32f310 1861 VL53L0X_Error wrapped_VL53L0X_get_vcsel_pulse_period(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1862 VL53L0X_VcselPeriod vcsel_period_type, uint8_t *p_vcsel_pulse_period_pclk);
nikapov 0:a1a69d32f310 1863
nikapov 0:a1a69d32f310 1864 uint8_t VL53L0X_decode_vcsel_period(uint8_t vcsel_period_reg);
nikapov 0:a1a69d32f310 1865
nikapov 0:a1a69d32f310 1866 uint32_t VL53L0X_decode_timeout(uint16_t encoded_timeout);
nikapov 0:a1a69d32f310 1867
nikapov 0:a1a69d32f310 1868 uint32_t VL53L0X_calc_timeout_us(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1869 uint16_t timeout_period_mclks,
nikapov 0:a1a69d32f310 1870 uint8_t vcsel_period_pclks);
nikapov 0:a1a69d32f310 1871
nikapov 0:a1a69d32f310 1872 uint32_t VL53L0X_calc_macro_period_ps(VL53L0X_DEV dev, uint8_t vcsel_period_pclks);
nikapov 0:a1a69d32f310 1873
nikapov 0:a1a69d32f310 1874 VL53L0X_Error VL53L0X_measurement_poll_for_completion(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1875
nikapov 0:a1a69d32f310 1876 VL53L0X_Error VL53L0X_load_tuning_settings(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1877 uint8_t *p_tuning_setting_buffer);
nikapov 0:a1a69d32f310 1878
nikapov 0:a1a69d32f310 1879 VL53L0X_Error VL53L0X_get_pal_range_status(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1880 uint8_t device_range_status,
nikapov 0:a1a69d32f310 1881 FixPoint1616_t signal_rate,
nikapov 0:a1a69d32f310 1882 uint16_t effective_spad_rtn_count,
nikapov 0:a1a69d32f310 1883 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
nikapov 0:a1a69d32f310 1884 uint8_t *p_pal_range_status);
nikapov 0:a1a69d32f310 1885 VL53L0X_Error VL53L0X_calc_sigma_estimate(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1886 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
nikapov 0:a1a69d32f310 1887 FixPoint1616_t *p_sigma_estimate,
nikapov 0:a1a69d32f310 1888 uint32_t *p_dmax_mm);
nikapov 0:a1a69d32f310 1889 uint32_t VL53L0X_calc_timeout_mclks(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1890 uint32_t timeout_period_us,
nikapov 0:a1a69d32f310 1891 uint8_t vcsel_period_pclks);
nikapov 0:a1a69d32f310 1892 uint32_t VL53L0X_isqrt(uint32_t num);
nikapov 0:a1a69d32f310 1893
nikapov 0:a1a69d32f310 1894 uint32_t VL53L0X_quadrature_sum(uint32_t a, uint32_t b);
nikapov 0:a1a69d32f310 1895
nikapov 0:a1a69d32f310 1896 VL53L0X_Error VL53L0X_calc_dmax(
nikapov 0:a1a69d32f310 1897 VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1898 FixPoint1616_t total_signal_rate_mcps,
nikapov 0:a1a69d32f310 1899 FixPoint1616_t total_corr_signal_rate_mcps,
nikapov 0:a1a69d32f310 1900 FixPoint1616_t pw_mult,
nikapov 0:a1a69d32f310 1901 uint32_t sigma_estimate_p1,
nikapov 0:a1a69d32f310 1902 FixPoint1616_t sigma_estimate_p2,
nikapov 0:a1a69d32f310 1903 uint32_t peak_vcsel_duration_us,
nikapov 0:a1a69d32f310 1904 uint32_t *pd_max_mm);
nikapov 0:a1a69d32f310 1905 VL53L0X_Error wrapped_VL53L0X_set_measurement_timing_budget_micro_seconds(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1906 uint32_t measurement_timing_budget_micro_seconds);
nikapov 0:a1a69d32f310 1907 VL53L0X_Error get_sequence_step_timeout(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1908 VL53L0X_SequenceStepId sequence_step_id,
nikapov 0:a1a69d32f310 1909 uint32_t *p_time_out_micro_secs);
nikapov 0:a1a69d32f310 1910 VL53L0X_Error set_sequence_step_timeout(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1911 VL53L0X_SequenceStepId sequence_step_id,
nikapov 0:a1a69d32f310 1912 uint32_t timeout_micro_secs);
nikapov 0:a1a69d32f310 1913 uint16_t VL53L0X_encode_timeout(uint32_t timeout_macro_clks);
nikapov 0:a1a69d32f310 1914 VL53L0X_Error wrapped_VL53L0X_set_vcsel_pulse_period(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1915 VL53L0X_VcselPeriod vcsel_period_type, uint8_t vcsel_pulse_period_pclk);
nikapov 0:a1a69d32f310 1916 uint8_t lv53l0x_encode_vcsel_period(uint8_t vcsel_period_pclks);
nikapov 0:a1a69d32f310 1917
nikapov 0:a1a69d32f310 1918 /* api_calibration.h functions */
nikapov 0:a1a69d32f310 1919 VL53L0X_Error VL53L0X_apply_offset_adjustment(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1920 VL53L0X_Error wrapped_VL53L0X_get_offset_calibration_data_micro_meter(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1921 int32_t *p_offset_calibration_data_micro_meter);
nikapov 0:a1a69d32f310 1922 VL53L0X_Error wrapped_VL53L0X_set_offset_calibration_data_micro_meter(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1923 int32_t offset_calibration_data_micro_meter);
nikapov 0:a1a69d32f310 1924 VL53L0X_Error wrapped_VL53L0X_perform_ref_spad_management(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1925 uint32_t *ref_spad_count,
nikapov 0:a1a69d32f310 1926 uint8_t *is_aperture_spads);
nikapov 0:a1a69d32f310 1927 VL53L0X_Error VL53L0X_perform_ref_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1928 uint8_t *p_vhv_settings, uint8_t *p_phase_cal, uint8_t get_data_enable);
nikapov 0:a1a69d32f310 1929 VL53L0X_Error VL53L0X_perform_vhv_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1930 uint8_t *p_vhv_settings, const uint8_t get_data_enable,
nikapov 0:a1a69d32f310 1931 const uint8_t restore_config);
nikapov 0:a1a69d32f310 1932 VL53L0X_Error VL53L0X_perform_single_ref_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1933 uint8_t vhv_init_byte);
nikapov 0:a1a69d32f310 1934 VL53L0X_Error VL53L0X_ref_calibration_io(VL53L0X_DEV dev, uint8_t read_not_write,
nikapov 0:a1a69d32f310 1935 uint8_t vhv_settings, uint8_t phase_cal,
nikapov 0:a1a69d32f310 1936 uint8_t *p_vhv_settings, uint8_t *p_phase_cal,
nikapov 0:a1a69d32f310 1937 const uint8_t vhv_enable, const uint8_t phase_enable);
nikapov 0:a1a69d32f310 1938 VL53L0X_Error VL53L0X_perform_phase_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1939 uint8_t *p_phase_cal, const uint8_t get_data_enable,
nikapov 0:a1a69d32f310 1940 const uint8_t restore_config);
nikapov 0:a1a69d32f310 1941 VL53L0X_Error enable_ref_spads(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1942 uint8_t aperture_spads,
nikapov 0:a1a69d32f310 1943 uint8_t good_spad_array[],
nikapov 0:a1a69d32f310 1944 uint8_t spad_array[],
nikapov 0:a1a69d32f310 1945 uint32_t size,
nikapov 0:a1a69d32f310 1946 uint32_t start,
nikapov 0:a1a69d32f310 1947 uint32_t offset,
nikapov 0:a1a69d32f310 1948 uint32_t spad_count,
nikapov 0:a1a69d32f310 1949 uint32_t *p_last_spad);
nikapov 0:a1a69d32f310 1950 void get_next_good_spad(uint8_t good_spad_array[], uint32_t size,
nikapov 0:a1a69d32f310 1951 uint32_t curr, int32_t *p_next);
nikapov 0:a1a69d32f310 1952 uint8_t is_aperture(uint32_t spad_index);
nikapov 0:a1a69d32f310 1953 VL53L0X_Error enable_spad_bit(uint8_t spad_array[], uint32_t size,
nikapov 0:a1a69d32f310 1954 uint32_t spad_index);
nikapov 0:a1a69d32f310 1955 VL53L0X_Error set_ref_spad_map(VL53L0X_DEV dev, uint8_t *p_ref_spad_array);
nikapov 0:a1a69d32f310 1956 VL53L0X_Error get_ref_spad_map(VL53L0X_DEV dev, uint8_t *p_ref_spad_array);
nikapov 0:a1a69d32f310 1957 VL53L0X_Error perform_ref_signal_measurement(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1958 uint16_t *p_ref_signal_rate);
nikapov 0:a1a69d32f310 1959 VL53L0X_Error wrapped_VL53L0X_set_reference_spads(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1960 uint32_t count, uint8_t is_aperture_spads);
nikapov 0:a1a69d32f310 1961
nikapov 0:a1a69d32f310 1962 /* api_strings.h functions */
nikapov 0:a1a69d32f310 1963 VL53L0X_Error wrapped_VL53L0X_get_device_info(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1964 VL53L0X_DeviceInfo_t *p_VL53L0X_device_info);
nikapov 0:a1a69d32f310 1965 VL53L0X_Error VL53L0X_check_part_used(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1966 uint8_t *revision,
nikapov 0:a1a69d32f310 1967 VL53L0X_DeviceInfo_t *p_VL53L0X_device_info);
Davidroid 2:d07edeaff6f1 1968
Davidroid 2:d07edeaff6f1 1969 /* Read function of the ID device */
nikapov 0:a1a69d32f310 1970 // virtual int read_id();
nikapov 0:a1a69d32f310 1971 virtual int read_id(uint8_t *id);
nikapov 0:a1a69d32f310 1972
nikapov 0:a1a69d32f310 1973 VL53L0X_Error wait_measurement_data_ready(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1974
nikapov 0:a1a69d32f310 1975 VL53L0X_Error wait_stop_completed(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1976
nikapov 0:a1a69d32f310 1977 /* Write and read functions from I2C */
nikapov 0:a1a69d32f310 1978 /**
nikapov 0:a1a69d32f310 1979 * Write single byte register
nikapov 0:a1a69d32f310 1980 * @param dev Device Handle
nikapov 0:a1a69d32f310 1981 * @param index The register index
nikapov 0:a1a69d32f310 1982 * @param data 8 bit register data
nikapov 0:a1a69d32f310 1983 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1984 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1985 */
nikapov 0:a1a69d32f310 1986 VL53L0X_Error VL53L0X_write_byte(VL53L0X_DEV dev, uint8_t index, uint8_t data);
nikapov 0:a1a69d32f310 1987 /**
nikapov 0:a1a69d32f310 1988 * Write word register
nikapov 0:a1a69d32f310 1989 * @param dev Device Handle
nikapov 0:a1a69d32f310 1990 * @param index The register index
nikapov 0:a1a69d32f310 1991 * @param data 16 bit register data
nikapov 0:a1a69d32f310 1992 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1993 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1994 */
nikapov 0:a1a69d32f310 1995 VL53L0X_Error VL53L0X_write_word(VL53L0X_DEV dev, uint8_t index, uint16_t data);
nikapov 0:a1a69d32f310 1996 /**
nikapov 0:a1a69d32f310 1997 * Write double word (4 byte) register
nikapov 0:a1a69d32f310 1998 * @param dev Device Handle
nikapov 0:a1a69d32f310 1999 * @param index The register index
nikapov 0:a1a69d32f310 2000 * @param data 32 bit register data
nikapov 0:a1a69d32f310 2001 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2002 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2003 */
nikapov 0:a1a69d32f310 2004 VL53L0X_Error VL53L0X_write_dword(VL53L0X_DEV dev, uint8_t index, uint32_t data);
nikapov 0:a1a69d32f310 2005 /**
nikapov 0:a1a69d32f310 2006 * Read single byte register
nikapov 0:a1a69d32f310 2007 * @param dev Device Handle
nikapov 0:a1a69d32f310 2008 * @param index The register index
nikapov 0:a1a69d32f310 2009 * @param data pointer to 8 bit data
nikapov 0:a1a69d32f310 2010 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2011 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2012 */
nikapov 0:a1a69d32f310 2013 VL53L0X_Error VL53L0X_read_byte(VL53L0X_DEV dev, uint8_t index, uint8_t *p_data);
nikapov 0:a1a69d32f310 2014 /**
nikapov 0:a1a69d32f310 2015 * Read word (2byte) register
nikapov 0:a1a69d32f310 2016 * @param dev Device Handle
nikapov 0:a1a69d32f310 2017 * @param index The register index
nikapov 0:a1a69d32f310 2018 * @param data pointer to 16 bit data
nikapov 0:a1a69d32f310 2019 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2020 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2021 */
nikapov 0:a1a69d32f310 2022 VL53L0X_Error VL53L0X_read_word(VL53L0X_DEV dev, uint8_t index, uint16_t *p_data);
nikapov 0:a1a69d32f310 2023 /**
nikapov 0:a1a69d32f310 2024 * Read dword (4byte) register
nikapov 0:a1a69d32f310 2025 * @param dev Device Handle
nikapov 0:a1a69d32f310 2026 * @param index The register index
nikapov 0:a1a69d32f310 2027 * @param data pointer to 32 bit data
nikapov 0:a1a69d32f310 2028 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2029 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2030 */
nikapov 0:a1a69d32f310 2031 VL53L0X_Error VL53L0X_read_dword(VL53L0X_DEV dev, uint8_t index, uint32_t *p_data);
nikapov 0:a1a69d32f310 2032 /**
nikapov 0:a1a69d32f310 2033 * Threat safe Update (read/modify/write) single byte register
nikapov 0:a1a69d32f310 2034 *
nikapov 0:a1a69d32f310 2035 * Final_reg = (Initial_reg & and_data) |or_data
nikapov 0:a1a69d32f310 2036 *
nikapov 0:a1a69d32f310 2037 * @param dev Device Handle
nikapov 0:a1a69d32f310 2038 * @param index The register index
nikapov 0:a1a69d32f310 2039 * @param and_data 8 bit and data
nikapov 0:a1a69d32f310 2040 * @param or_data 8 bit or data
nikapov 0:a1a69d32f310 2041 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2042 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2043 */
nikapov 0:a1a69d32f310 2044 VL53L0X_Error VL53L0X_update_byte(VL53L0X_DEV dev, uint8_t index, uint8_t and_data, uint8_t or_data);
nikapov 0:a1a69d32f310 2045 /**
nikapov 0:a1a69d32f310 2046 * Writes the supplied byte buffer to the device
nikapov 0:a1a69d32f310 2047 * @param dev Device Handle
nikapov 0:a1a69d32f310 2048 * @param index The register index
nikapov 0:a1a69d32f310 2049 * @param p_data Pointer to uint8_t buffer containing the data to be written
nikapov 0:a1a69d32f310 2050 * @param count Number of bytes in the supplied byte buffer
nikapov 0:a1a69d32f310 2051 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2052 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2053 */
nikapov 0:a1a69d32f310 2054 VL53L0X_Error VL53L0X_write_multi(VL53L0X_DEV dev, uint8_t index, uint8_t *p_data, uint32_t count);
nikapov 0:a1a69d32f310 2055 /**
nikapov 0:a1a69d32f310 2056 * Reads the requested number of bytes from the device
nikapov 0:a1a69d32f310 2057 * @param dev Device Handle
nikapov 0:a1a69d32f310 2058 * @param index The register index
nikapov 0:a1a69d32f310 2059 * @param p_data Pointer to the uint8_t buffer to store read data
nikapov 0:a1a69d32f310 2060 * @param count Number of uint8_t's to read
nikapov 0:a1a69d32f310 2061 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2062 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2063 */
nikapov 0:a1a69d32f310 2064 VL53L0X_Error VL53L0X_read_multi(VL53L0X_DEV dev, uint8_t index, uint8_t *p_data, uint32_t count);
nikapov 0:a1a69d32f310 2065
nikapov 0:a1a69d32f310 2066 /**
nikapov 0:a1a69d32f310 2067 * @brief Writes a buffer towards the I2C peripheral device.
nikapov 0:a1a69d32f310 2068 * @param dev Device Handle
nikapov 0:a1a69d32f310 2069 * @param p_data pointer to the byte-array data to send
nikapov 0:a1a69d32f310 2070 * @param number_of_bytes number of bytes to be written.
nikapov 0:a1a69d32f310 2071 * @retval 0 if ok,
nikapov 0:a1a69d32f310 2072 * @retval -1 if an I2C error has occured
nikapov 0:a1a69d32f310 2073 * @note On some devices if NumByteToWrite is greater
nikapov 0:a1a69d32f310 2074 * than one, the RegisterAddr must be masked correctly!
nikapov 0:a1a69d32f310 2075 */
nikapov 0:a1a69d32f310 2076 VL53L0X_Error VL53L0X_i2c_write(uint8_t dev, uint8_t index, uint8_t *p_data, uint16_t number_of_bytes);
nikapov 0:a1a69d32f310 2077
nikapov 0:a1a69d32f310 2078 /**
nikapov 0:a1a69d32f310 2079 * @brief Reads a buffer from the I2C peripheral device.
nikapov 0:a1a69d32f310 2080 * @param dev Device Handle
nikapov 0:a1a69d32f310 2081 * @param p_data pointer to the byte-array to read data in to
nikapov 0:a1a69d32f310 2082 * @param number_of_bytes number of bytes to be read.
nikapov 0:a1a69d32f310 2083 * @retval 0 if ok,
nikapov 0:a1a69d32f310 2084 * @retval -1 if an I2C error has occured
nikapov 0:a1a69d32f310 2085 * @note On some devices if NumByteToWrite is greater
nikapov 0:a1a69d32f310 2086 * than one, the RegisterAddr must be masked correctly!
nikapov 0:a1a69d32f310 2087 */
nikapov 0:a1a69d32f310 2088 VL53L0X_Error VL53L0X_i2c_read(uint8_t dev, uint8_t index, uint8_t *p_data, uint16_t number_of_bytes);
nikapov 0:a1a69d32f310 2089
nikapov 0:a1a69d32f310 2090 /**
nikapov 0:a1a69d32f310 2091 * @brief execute delay in all polling API call
nikapov 0:a1a69d32f310 2092 *
nikapov 0:a1a69d32f310 2093 * A typical multi-thread or RTOs implementation is to sleep the task for some 5ms (with 100Hz max rate faster polling is not needed)
nikapov 0:a1a69d32f310 2094 * if nothing specific is need you can define it as an empty/void macro
nikapov 0:a1a69d32f310 2095 * @code
nikapov 0:a1a69d32f310 2096 * #define VL53L0X_PollingDelay(...) (void)0
nikapov 0:a1a69d32f310 2097 * @endcode
nikapov 0:a1a69d32f310 2098 * @param dev Device Handle
nikapov 0:a1a69d32f310 2099 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2100 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2101 */
nikapov 0:a1a69d32f310 2102 VL53L0X_Error VL53L0X_polling_delay(VL53L0X_DEV dev); /* usually best implemented as a real function */
nikapov 0:a1a69d32f310 2103
nikapov 0:a1a69d32f310 2104 int is_present()
nikapov 0:a1a69d32f310 2105 {
nikapov 0:a1a69d32f310 2106 int status;
nikapov 0:a1a69d32f310 2107 uint8_t id = 0;
nikapov 0:a1a69d32f310 2108
nikapov 0:a1a69d32f310 2109 status = read_id(&id);
nikapov 0:a1a69d32f310 2110 if (status) {
nikapov 0:a1a69d32f310 2111 VL53L0X_ErrLog("Failed to read ID device. Device not present!\n\r");
nikapov 0:a1a69d32f310 2112 }
nikapov 0:a1a69d32f310 2113 return status;
nikapov 0:a1a69d32f310 2114 }
nikapov 0:a1a69d32f310 2115
nikapov 0:a1a69d32f310 2116 ///////////////////////////////////////////////////////////////////////////////////////////////////////
nikapov 0:a1a69d32f310 2117 //Added functions //
nikapov 0:a1a69d32f310 2118 ///////////////////////////////////////////////////////////////////////////////////////////////////////
nikapov 0:a1a69d32f310 2119
nikapov 0:a1a69d32f310 2120 /**
nikapov 0:a1a69d32f310 2121 * @brief Cycle Power to Device
nikapov 0:a1a69d32f310 2122 *
nikapov 0:a1a69d32f310 2123 * @return status - status 0 = ok, 1 = error
nikapov 0:a1a69d32f310 2124 *
nikapov 0:a1a69d32f310 2125 */
nikapov 0:a1a69d32f310 2126 int32_t VL53L0X_cycle_power(void);
nikapov 0:a1a69d32f310 2127
nikapov 0:a1a69d32f310 2128 uint8_t VL53L0X_encode_vcsel_period(uint8_t vcsel_period_pclks);
nikapov 0:a1a69d32f310 2129
nikapov 0:a1a69d32f310 2130 VL53L0X_Error wrapped_VL53L0X_get_device_error_string(VL53L0X_DeviceError error_code,
nikapov 0:a1a69d32f310 2131 char *p_device_error_string);
nikapov 0:a1a69d32f310 2132
nikapov 0:a1a69d32f310 2133 VL53L0X_Error wrapped_VL53L0X_get_limit_check_info(VL53L0X_DEV dev, uint16_t limit_check_id,
nikapov 0:a1a69d32f310 2134 char *p_limit_check_string);
nikapov 0:a1a69d32f310 2135
nikapov 0:a1a69d32f310 2136 VL53L0X_Error wrapped_VL53L0X_get_pal_error_string(VL53L0X_Error pal_error_code,
nikapov 0:a1a69d32f310 2137 char *p_pal_error_string);
nikapov 0:a1a69d32f310 2138
nikapov 0:a1a69d32f310 2139 VL53L0X_Error wrapped_VL53L0X_get_pal_state_string(VL53L0X_State pal_state_code,
nikapov 0:a1a69d32f310 2140 char *p_pal_state_string);
nikapov 0:a1a69d32f310 2141
nikapov 0:a1a69d32f310 2142 VL53L0X_Error wrapped_VL53L0X_get_range_status_string(uint8_t range_status,
nikapov 0:a1a69d32f310 2143 char *p_range_status_string);
nikapov 0:a1a69d32f310 2144
nikapov 0:a1a69d32f310 2145 VL53L0X_Error wrapped_VL53L0X_get_ref_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2146 uint8_t *p_vhv_settings, uint8_t *p_phase_cal);
nikapov 0:a1a69d32f310 2147
nikapov 0:a1a69d32f310 2148
nikapov 0:a1a69d32f310 2149 VL53L0X_Error count_enabled_spads(uint8_t spad_array[],
nikapov 0:a1a69d32f310 2150 uint32_t byte_count, uint32_t max_spads,
nikapov 0:a1a69d32f310 2151 uint32_t *p_total_spads_enabled, uint8_t *p_is_aperture);
nikapov 0:a1a69d32f310 2152
nikapov 0:a1a69d32f310 2153 VL53L0X_Error wrapped_VL53L0X_get_sequence_steps_info(VL53L0X_SequenceStepId sequence_step_id,
nikapov 0:a1a69d32f310 2154 char *p_sequence_steps_string);
nikapov 0:a1a69d32f310 2155
nikapov 0:a1a69d32f310 2156
nikapov 0:a1a69d32f310 2157 /**
nikapov 0:a1a69d32f310 2158 * @brief Gets the name of a given sequence step.
nikapov 0:a1a69d32f310 2159 *
nikapov 0:a1a69d32f310 2160 * @par Function Description
nikapov 0:a1a69d32f310 2161 * This function retrieves the name of sequence steps corresponding to
nikapov 0:a1a69d32f310 2162 * SequenceStepId.
nikapov 0:a1a69d32f310 2163 *
nikapov 0:a1a69d32f310 2164 * @note This function doesn't Accesses the device
nikapov 0:a1a69d32f310 2165 *
nikapov 0:a1a69d32f310 2166 * @param sequence_step_id Sequence step identifier.
nikapov 0:a1a69d32f310 2167 * @param p_sequence_steps_string Pointer to Info string
nikapov 0:a1a69d32f310 2168 *
nikapov 0:a1a69d32f310 2169 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2170 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2171 */
nikapov 0:a1a69d32f310 2172 VL53L0X_Error VL53L0X_get_sequence_steps_info(VL53L0X_SequenceStepId sequence_step_id,
nikapov 0:a1a69d32f310 2173 char *p_sequence_steps_string);
nikapov 0:a1a69d32f310 2174
nikapov 0:a1a69d32f310 2175 /**
nikapov 0:a1a69d32f310 2176 * @brief Get the frequency of the timer used for ranging results time stamps
nikapov 0:a1a69d32f310 2177 *
nikapov 0:a1a69d32f310 2178 * @param[out] p_timer_freq_hz : pointer for timer frequency
nikapov 0:a1a69d32f310 2179 *
nikapov 0:a1a69d32f310 2180 * @return status : 0 = ok, 1 = error
nikapov 0:a1a69d32f310 2181 *
nikapov 0:a1a69d32f310 2182 */
nikapov 0:a1a69d32f310 2183 int32_t VL53L0X_get_timer_frequency(int32_t *p_timer_freq_hz);
nikapov 0:a1a69d32f310 2184
nikapov 0:a1a69d32f310 2185 /**
nikapov 0:a1a69d32f310 2186 * @brief Get the timer value in units of timer_freq_hz (see VL53L0X_get_timestamp_frequency())
nikapov 0:a1a69d32f310 2187 *
nikapov 0:a1a69d32f310 2188 * @param[out] p_timer_count : pointer for timer count value
nikapov 0:a1a69d32f310 2189 *
nikapov 0:a1a69d32f310 2190 * @return status : 0 = ok, 1 = error
nikapov 0:a1a69d32f310 2191 *
nikapov 0:a1a69d32f310 2192 */
nikapov 0:a1a69d32f310 2193 int32_t VL53L0X_get_timer_value(int32_t *p_timer_count);
nikapov 0:a1a69d32f310 2194
nikapov 0:a1a69d32f310 2195 /**
nikapov 0:a1a69d32f310 2196 * @brief Configure ranging interrupt reported to system
nikapov 0:a1a69d32f310 2197 *
nikapov 0:a1a69d32f310 2198 * @note This function is not Implemented
nikapov 0:a1a69d32f310 2199 *
nikapov 0:a1a69d32f310 2200 * @param dev Device Handle
nikapov 0:a1a69d32f310 2201 * @param interrupt_mask Mask of interrupt to Enable/disable
nikapov 0:a1a69d32f310 2202 * (0:interrupt disabled or 1: interrupt enabled)
nikapov 0:a1a69d32f310 2203 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
nikapov 0:a1a69d32f310 2204 */
nikapov 0:a1a69d32f310 2205 VL53L0X_Error VL53L0X_enable_interrupt_mask(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2206 uint32_t interrupt_mask);
nikapov 0:a1a69d32f310 2207
nikapov 0:a1a69d32f310 2208 /**
nikapov 0:a1a69d32f310 2209 * @brief Get Dmax Calibration Parameters for a given device
nikapov 0:a1a69d32f310 2210 *
nikapov 0:a1a69d32f310 2211 *
nikapov 0:a1a69d32f310 2212 * @note This function Access to the device
nikapov 0:a1a69d32f310 2213 *
nikapov 0:a1a69d32f310 2214 * @param dev Device Handle
nikapov 0:a1a69d32f310 2215 * @param p_range_milli_meter Pointer to Calibration Distance
nikapov 0:a1a69d32f310 2216 * @param p_signal_rate_rtn_mega_cps Pointer to Signal rate return
nikapov 0:a1a69d32f310 2217 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2218 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2219 */
nikapov 0:a1a69d32f310 2220 VL53L0X_Error VL53L0X_get_dmax_cal_parameters(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2221 uint16_t *p_range_milli_meter, FixPoint1616_t *p_signal_rate_rtn_mega_cps);
nikapov 0:a1a69d32f310 2222
nikapov 0:a1a69d32f310 2223 /**
nikapov 0:a1a69d32f310 2224 * @brief Set Dmax Calibration Parameters for a given device
nikapov 0:a1a69d32f310 2225 * When one of the parameter is zero, this function will get parameter
nikapov 0:a1a69d32f310 2226 * from NVM.
nikapov 0:a1a69d32f310 2227 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 2228 *
nikapov 0:a1a69d32f310 2229 * @param dev Device Handle
nikapov 0:a1a69d32f310 2230 * @param range_milli_meter Calibration Distance
nikapov 0:a1a69d32f310 2231 * @param signal_rate_rtn_mega_cps Signal rate return read at CalDistance
nikapov 0:a1a69d32f310 2232 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2233 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2234 */
nikapov 0:a1a69d32f310 2235 VL53L0X_Error VL53L0X_get_dmax_cal_parameters(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2236 uint16_t range_milli_meter, FixPoint1616_t signal_rate_rtn_mega_cps);
nikapov 0:a1a69d32f310 2237
nikapov 0:a1a69d32f310 2238 /**
nikapov 0:a1a69d32f310 2239 * @brief Retrieve the measurements from device for a given setup
nikapov 0:a1a69d32f310 2240 *
nikapov 0:a1a69d32f310 2241 * @par Function Description
nikapov 0:a1a69d32f310 2242 * Get data from last successful Histogram measurement
nikapov 0:a1a69d32f310 2243 * @warning USER should take care about @a VL53L0X_GetNumberOfROIZones()
nikapov 0:a1a69d32f310 2244 * before get data.
nikapov 0:a1a69d32f310 2245 * PAL will fill a NumberOfROIZones times the corresponding data structure
nikapov 0:a1a69d32f310 2246 * used in the measurement function.
nikapov 0:a1a69d32f310 2247 *
nikapov 0:a1a69d32f310 2248 * @note This function is not Implemented
nikapov 0:a1a69d32f310 2249 *
nikapov 0:a1a69d32f310 2250 * @param dev Device Handle
nikapov 0:a1a69d32f310 2251 * @param p_histogram_measurement_data Pointer to the histogram data structure.
nikapov 0:a1a69d32f310 2252 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
nikapov 0:a1a69d32f310 2253 */
nikapov 0:a1a69d32f310 2254 VL53L0X_Error VL53L0X_get_histogram_measurement_data(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2255 VL53L0X_HistogramMeasurementData_t *p_histogram_measurement_data);
nikapov 0:a1a69d32f310 2256
nikapov 0:a1a69d32f310 2257 /**
nikapov 0:a1a69d32f310 2258 * @brief Get current new device mode
nikapov 0:a1a69d32f310 2259 * @par Function Description
nikapov 0:a1a69d32f310 2260 * Get current Histogram mode of a Device
nikapov 0:a1a69d32f310 2261 *
nikapov 0:a1a69d32f310 2262 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 2263 *
nikapov 0:a1a69d32f310 2264 * @param dev Device Handle
nikapov 0:a1a69d32f310 2265 * @param p_histogram_mode Pointer to current Histogram Mode value
nikapov 0:a1a69d32f310 2266 * Valid values are:
nikapov 0:a1a69d32f310 2267 * VL53L0X_HISTOGRAMMODE_DISABLED
nikapov 0:a1a69d32f310 2268 * VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM
nikapov 0:a1a69d32f310 2269 * VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY
nikapov 0:a1a69d32f310 2270 * VL53L0X_HISTOGRAMMODE_RETURN_ONLY
nikapov 0:a1a69d32f310 2271 * VL53L0X_HISTOGRAMMODE_BOTH
nikapov 0:a1a69d32f310 2272 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2273 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2274 */
nikapov 0:a1a69d32f310 2275 VL53L0X_Error VL53L0X_get_histogram_mode(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2276 VL53L0X_HistogramModes *p_histogram_mode);
nikapov 0:a1a69d32f310 2277
nikapov 0:a1a69d32f310 2278 /**
nikapov 0:a1a69d32f310 2279 * @brief Set a new Histogram mode
nikapov 0:a1a69d32f310 2280 * @par Function Description
nikapov 0:a1a69d32f310 2281 * Set device to a new Histogram mode
nikapov 0:a1a69d32f310 2282 *
nikapov 0:a1a69d32f310 2283 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 2284 *
nikapov 0:a1a69d32f310 2285 * @param dev Device Handle
nikapov 0:a1a69d32f310 2286 * @param histogram_mode New device mode to apply
nikapov 0:a1a69d32f310 2287 * Valid values are:
nikapov 0:a1a69d32f310 2288 * VL53L0X_HISTOGRAMMODE_DISABLED
nikapov 0:a1a69d32f310 2289 * VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM
nikapov 0:a1a69d32f310 2290 * VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY
nikapov 0:a1a69d32f310 2291 * VL53L0X_HISTOGRAMMODE_RETURN_ONLY
nikapov 0:a1a69d32f310 2292 * VL53L0X_HISTOGRAMMODE_BOTH
nikapov 0:a1a69d32f310 2293 *
nikapov 0:a1a69d32f310 2294 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2295 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when
nikapov 0:a1a69d32f310 2296 * HistogramMode is not in the supported list
nikapov 0:a1a69d32f310 2297 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2298 */
nikapov 0:a1a69d32f310 2299 VL53L0X_Error VL53L0X_set_histogram_mode(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2300 VL53L0X_HistogramModes histogram_mode);
nikapov 0:a1a69d32f310 2301
nikapov 0:a1a69d32f310 2302 /**
nikapov 0:a1a69d32f310 2303 * @brief Return a description string for a given limit check number
nikapov 0:a1a69d32f310 2304 *
nikapov 0:a1a69d32f310 2305 * @par Function Description
nikapov 0:a1a69d32f310 2306 * This function returns a description string for a given limit check number.
nikapov 0:a1a69d32f310 2307 * The limit check is identified with the LimitCheckId.
nikapov 0:a1a69d32f310 2308 *
nikapov 0:a1a69d32f310 2309 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 2310 *
nikapov 0:a1a69d32f310 2311 * @param dev Device Handle
nikapov 0:a1a69d32f310 2312 * @param limit_check_id Limit Check ID
nikapov 0:a1a69d32f310 2313 (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
nikapov 0:a1a69d32f310 2314 * @param p_limit_check_string Pointer to the
nikapov 0:a1a69d32f310 2315 description string of the given check limit.
nikapov 0:a1a69d32f310 2316 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2317 * @return VL53L0X_ERROR_INVALID_PARAMS This error is
nikapov 0:a1a69d32f310 2318 returned when LimitCheckId value is out of range.
nikapov 0:a1a69d32f310 2319 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2320 */
nikapov 0:a1a69d32f310 2321 VL53L0X_Error VL53L0X_get_limit_check_info(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2322 uint16_t limit_check_id, char *p_limit_check_string);
nikapov 0:a1a69d32f310 2323
nikapov 0:a1a69d32f310 2324 /**
nikapov 0:a1a69d32f310 2325 * @brief Get the linearity corrective gain
nikapov 0:a1a69d32f310 2326 *
nikapov 0:a1a69d32f310 2327 * @par Function Description
nikapov 0:a1a69d32f310 2328 * Should only be used after a successful call to @a VL53L0X_DataInit to backup
nikapov 0:a1a69d32f310 2329 * device NVM value
nikapov 0:a1a69d32f310 2330 *
nikapov 0:a1a69d32f310 2331 * @note This function Access to the device
nikapov 0:a1a69d32f310 2332 *
nikapov 0:a1a69d32f310 2333 * @param dev Device Handle
nikapov 0:a1a69d32f310 2334 * @param p_linearity_corrective_gain Pointer to the linearity
nikapov 0:a1a69d32f310 2335 * corrective gain in x1000
nikapov 0:a1a69d32f310 2336 * if value is 1000 then no modification is applied.
nikapov 0:a1a69d32f310 2337 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2338 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2339 */
nikapov 0:a1a69d32f310 2340 VL53L0X_Error VL53L0X_get_linearity_corrective_gain(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2341 uint16_t *p_linearity_corrective_gain);
nikapov 0:a1a69d32f310 2342
nikapov 0:a1a69d32f310 2343 /**
nikapov 0:a1a69d32f310 2344 * Set the linearity corrective gain
nikapov 0:a1a69d32f310 2345 *
nikapov 0:a1a69d32f310 2346 * @note This function Access to the device
nikapov 0:a1a69d32f310 2347 *
nikapov 0:a1a69d32f310 2348 * @param dev Device Handle
nikapov 0:a1a69d32f310 2349 * @param linearity_corrective_gain Linearity corrective
nikapov 0:a1a69d32f310 2350 * gain in x1000
nikapov 0:a1a69d32f310 2351 * if value is 1000 then no modification is applied.
nikapov 0:a1a69d32f310 2352 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2353 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2354 */
nikapov 0:a1a69d32f310 2355 VL53L0X_Error VL53L0X_set_linearity_corrective_gain(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2356 int16_t linearity_corrective_gain);
nikapov 0:a1a69d32f310 2357
nikapov 0:a1a69d32f310 2358 /**
nikapov 0:a1a69d32f310 2359 * @brief Get the Maximum number of ROI Zones managed by the Device
nikapov 0:a1a69d32f310 2360 *
nikapov 0:a1a69d32f310 2361 * @par Function Description
nikapov 0:a1a69d32f310 2362 * Get Maximum number of ROI Zones managed by the Device.
nikapov 0:a1a69d32f310 2363 *
nikapov 0:a1a69d32f310 2364 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 2365 *
nikapov 0:a1a69d32f310 2366 * @param dev Device Handle
nikapov 0:a1a69d32f310 2367 * @param p_max_number_of_roi_zones Pointer to the Maximum Number
nikapov 0:a1a69d32f310 2368 * of ROI Zones value.
nikapov 0:a1a69d32f310 2369 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2370 */
nikapov 0:a1a69d32f310 2371 VL53L0X_Error VL53L0X_get_max_number_of_roi_zones(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2372 uint8_t *p_max_number_of_roi_zones);
nikapov 0:a1a69d32f310 2373
nikapov 0:a1a69d32f310 2374 /**
nikapov 0:a1a69d32f310 2375 * @brief Retrieve the Reference Signal after a measurements
nikapov 0:a1a69d32f310 2376 *
nikapov 0:a1a69d32f310 2377 * @par Function Description
nikapov 0:a1a69d32f310 2378 * Get Reference Signal from last successful Ranging measurement
nikapov 0:a1a69d32f310 2379 * This function return a valid value after that you call the
nikapov 0:a1a69d32f310 2380 * @a VL53L0X_GetRangingMeasurementData().
nikapov 0:a1a69d32f310 2381 *
nikapov 0:a1a69d32f310 2382 * @note This function Access to the device
nikapov 0:a1a69d32f310 2383 *
nikapov 0:a1a69d32f310 2384 * @param dev Device Handle
nikapov 0:a1a69d32f310 2385 * @param p_measurement_ref_signal Pointer to the Ref Signal to fill up.
nikapov 0:a1a69d32f310 2386 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2387 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2388 */
nikapov 0:a1a69d32f310 2389 VL53L0X_Error VL53L0X_get_measurement_ref_signal(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2390 FixPoint1616_t *p_measurement_ref_signal);
nikapov 0:a1a69d32f310 2391
nikapov 0:a1a69d32f310 2392 /**
nikapov 0:a1a69d32f310 2393 * @brief Get the number of the check limit managed by a given Device
nikapov 0:a1a69d32f310 2394 *
nikapov 0:a1a69d32f310 2395 * @par Function Description
nikapov 0:a1a69d32f310 2396 * This function give the number of the check limit managed by the Device
nikapov 0:a1a69d32f310 2397 *
nikapov 0:a1a69d32f310 2398 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 2399 *
nikapov 0:a1a69d32f310 2400 * @param p_number_of_limit_check Pointer to the number of check limit.
nikapov 0:a1a69d32f310 2401 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2402 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2403 */
nikapov 0:a1a69d32f310 2404 VL53L0X_Error VL53L0X_get_number_of_limit_check(
nikapov 0:a1a69d32f310 2405 uint16_t *p_number_of_limit_check);
nikapov 0:a1a69d32f310 2406
nikapov 0:a1a69d32f310 2407 /**
nikapov 0:a1a69d32f310 2408 * @brief Get the number of ROI Zones managed by the Device
nikapov 0:a1a69d32f310 2409 *
nikapov 0:a1a69d32f310 2410 * @par Function Description
nikapov 0:a1a69d32f310 2411 * Get number of ROI Zones managed by the Device
nikapov 0:a1a69d32f310 2412 * USER should take care about @a VL53L0X_GetNumberOfROIZones()
nikapov 0:a1a69d32f310 2413 * before get data after a perform measurement.
nikapov 0:a1a69d32f310 2414 * PAL will fill a NumberOfROIZones times the corresponding data
nikapov 0:a1a69d32f310 2415 * structure used in the measurement function.
nikapov 0:a1a69d32f310 2416 *
nikapov 0:a1a69d32f310 2417 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 2418 *
nikapov 0:a1a69d32f310 2419 * @param dev Device Handle
nikapov 0:a1a69d32f310 2420 * @param p_number_of_roi_zones Pointer to the Number of ROI Zones value.
nikapov 0:a1a69d32f310 2421 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2422 */
nikapov 0:a1a69d32f310 2423 VL53L0X_Error VL53L0X_get_number_of_roi_zones(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2424 uint8_t *p_number_of_roi_zones);
nikapov 0:a1a69d32f310 2425
nikapov 0:a1a69d32f310 2426 /**
nikapov 0:a1a69d32f310 2427 * @brief Set the number of ROI Zones to be used for a specific Device
nikapov 0:a1a69d32f310 2428 *
nikapov 0:a1a69d32f310 2429 * @par Function Description
nikapov 0:a1a69d32f310 2430 * Set the number of ROI Zones to be used for a specific Device.
nikapov 0:a1a69d32f310 2431 * The programmed value should be less than the max number of ROI Zones given
nikapov 0:a1a69d32f310 2432 * with @a VL53L0X_GetMaxNumberOfROIZones().
nikapov 0:a1a69d32f310 2433 * This version of API manage only one zone.
nikapov 0:a1a69d32f310 2434 *
nikapov 0:a1a69d32f310 2435 * @param dev Device Handle
nikapov 0:a1a69d32f310 2436 * @param number_of_roi_zones Number of ROI Zones to be used for a
nikapov 0:a1a69d32f310 2437 * specific Device.
nikapov 0:a1a69d32f310 2438 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2439 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned if
nikapov 0:a1a69d32f310 2440 * NumberOfROIZones != 1
nikapov 0:a1a69d32f310 2441 */
nikapov 0:a1a69d32f310 2442 VL53L0X_Error VL53L0X_set_number_of_roi_zones(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2443 uint8_t number_of_roi_zones);
nikapov 0:a1a69d32f310 2444
nikapov 0:a1a69d32f310 2445 /**
nikapov 0:a1a69d32f310 2446 * @brief Gets number of sequence steps managed by the API.
nikapov 0:a1a69d32f310 2447 *
nikapov 0:a1a69d32f310 2448 * @par Function Description
nikapov 0:a1a69d32f310 2449 * This function retrieves the number of sequence steps currently managed
nikapov 0:a1a69d32f310 2450 * by the API
nikapov 0:a1a69d32f310 2451 *
nikapov 0:a1a69d32f310 2452 * @note This function Accesses the device
nikapov 0:a1a69d32f310 2453 *
nikapov 0:a1a69d32f310 2454 * @param dev Device Handle
nikapov 0:a1a69d32f310 2455 * @param p_number_of_sequence_steps Out parameter reporting the number of
nikapov 0:a1a69d32f310 2456 * sequence steps.
nikapov 0:a1a69d32f310 2457 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2458 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2459 */
nikapov 0:a1a69d32f310 2460 VL53L0X_Error VL53L0X_get_number_of_sequence_steps(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2461 uint8_t *p_number_of_sequence_steps);
nikapov 0:a1a69d32f310 2462 /**
nikapov 0:a1a69d32f310 2463 * @brief Get the power mode for a given Device
nikapov 0:a1a69d32f310 2464 *
nikapov 0:a1a69d32f310 2465 * @note This function Access to the device
nikapov 0:a1a69d32f310 2466 *
nikapov 0:a1a69d32f310 2467 * @param dev Device Handle
nikapov 0:a1a69d32f310 2468 * @param p_power_mode Pointer to the current value of the power
nikapov 0:a1a69d32f310 2469 * mode. see ::VL53L0X_PowerModes
nikapov 0:a1a69d32f310 2470 * Valid values are:
nikapov 0:a1a69d32f310 2471 * VL53L0X_POWERMODE_STANDBY_LEVEL1,
nikapov 0:a1a69d32f310 2472 * VL53L0X_POWERMODE_IDLE_LEVEL1
nikapov 0:a1a69d32f310 2473 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2474 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2475 */
nikapov 0:a1a69d32f310 2476 VL53L0X_Error VL53L0X_get_power_mode(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2477 VL53L0X_PowerModes *p_power_mode);
nikapov 0:a1a69d32f310 2478
nikapov 0:a1a69d32f310 2479 /**
nikapov 0:a1a69d32f310 2480 * @brief Set the power mode for a given Device
nikapov 0:a1a69d32f310 2481 * The power mode can be Standby or Idle. Different level of both Standby and
nikapov 0:a1a69d32f310 2482 * Idle can exists.
nikapov 0:a1a69d32f310 2483 * This function should not be used when device is in Ranging state.
nikapov 0:a1a69d32f310 2484 *
nikapov 0:a1a69d32f310 2485 * @note This function Access to the device
nikapov 0:a1a69d32f310 2486 *
nikapov 0:a1a69d32f310 2487 * @param dev Device Handle
nikapov 0:a1a69d32f310 2488 * @param power_mode The value of the power mode to set.
nikapov 0:a1a69d32f310 2489 * see ::VL53L0X_PowerModes
nikapov 0:a1a69d32f310 2490 * Valid values are:
nikapov 0:a1a69d32f310 2491 * VL53L0X_POWERMODE_STANDBY_LEVEL1,
nikapov 0:a1a69d32f310 2492 * VL53L0X_POWERMODE_IDLE_LEVEL1
nikapov 0:a1a69d32f310 2493 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2494 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when PowerMode
nikapov 0:a1a69d32f310 2495 * is not in the supported list
nikapov 0:a1a69d32f310 2496 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2497 */
nikapov 0:a1a69d32f310 2498 VL53L0X_Error VL53L0X_set_power_mode(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2499 VL53L0X_PowerModes power_mode);
nikapov 0:a1a69d32f310 2500
nikapov 0:a1a69d32f310 2501 /**
nikapov 0:a1a69d32f310 2502 * @brief Retrieves SPAD configuration
nikapov 0:a1a69d32f310 2503 *
nikapov 0:a1a69d32f310 2504 * @par Function Description
nikapov 0:a1a69d32f310 2505 * This function retrieves the current number of applied reference spads
nikapov 0:a1a69d32f310 2506 * and also their type : Aperture or Non-Aperture.
nikapov 0:a1a69d32f310 2507 *
nikapov 0:a1a69d32f310 2508 * @note This function Access to the device
nikapov 0:a1a69d32f310 2509 *
nikapov 0:a1a69d32f310 2510 * @param dev Device Handle
nikapov 0:a1a69d32f310 2511 * @param p_spad_count Number ref Spad Count
nikapov 0:a1a69d32f310 2512 * @param p_is_aperture_spads Reports if spads are of type
nikapov 0:a1a69d32f310 2513 * aperture or non-aperture.
nikapov 0:a1a69d32f310 2514 * 1:=aperture, 0:=Non-Aperture
nikapov 0:a1a69d32f310 2515 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2516 * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the in the reference
nikapov 0:a1a69d32f310 2517 * spad configuration.
nikapov 0:a1a69d32f310 2518 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2519 */
nikapov 0:a1a69d32f310 2520 VL53L0X_Error wrapped_VL53L0X_get_reference_spads(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2521 uint32_t *p_spad_count, uint8_t *p_is_aperture_spads);
nikapov 0:a1a69d32f310 2522
nikapov 0:a1a69d32f310 2523 /**
nikapov 0:a1a69d32f310 2524 * @brief Gets the (on/off) state of a requested sequence step.
nikapov 0:a1a69d32f310 2525 *
nikapov 0:a1a69d32f310 2526 * @par Function Description
nikapov 0:a1a69d32f310 2527 * This function retrieves the state of a requested sequence step, i.e. on/off.
nikapov 0:a1a69d32f310 2528 *
nikapov 0:a1a69d32f310 2529 * @note This function Accesses the device
nikapov 0:a1a69d32f310 2530 *
nikapov 0:a1a69d32f310 2531 * @param dev Device Handle
nikapov 0:a1a69d32f310 2532 * @param sequence_step_id Sequence step identifier.
nikapov 0:a1a69d32f310 2533 * @param p_sequence_step_enabled Out parameter reporting if the sequence step
nikapov 0:a1a69d32f310 2534 * is enabled {0=Off,1=On}.
nikapov 0:a1a69d32f310 2535 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2536 * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not
nikapov 0:a1a69d32f310 2537 * supported.
nikapov 0:a1a69d32f310 2538 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2539 */
nikapov 0:a1a69d32f310 2540 VL53L0X_Error VL53L0X_get_sequence_step_enable(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2541 VL53L0X_SequenceStepId sequence_step_id, uint8_t *p_sequence_step_enabled);
nikapov 0:a1a69d32f310 2542
nikapov 0:a1a69d32f310 2543
nikapov 0:a1a69d32f310 2544 /**
nikapov 0:a1a69d32f310 2545 * @brief Gets the timeout of a requested sequence step.
nikapov 0:a1a69d32f310 2546 *
nikapov 0:a1a69d32f310 2547 * @par Function Description
nikapov 0:a1a69d32f310 2548 * This function retrieves the timeout of a requested sequence step.
nikapov 0:a1a69d32f310 2549 *
nikapov 0:a1a69d32f310 2550 * @note This function Accesses the device
nikapov 0:a1a69d32f310 2551 *
nikapov 0:a1a69d32f310 2552 * @param dev Device Handle
nikapov 0:a1a69d32f310 2553 * @param sequence_step_id Sequence step identifier.
nikapov 0:a1a69d32f310 2554 * @param p_time_out_milli_secs Timeout value.
nikapov 0:a1a69d32f310 2555 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2556 * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not
nikapov 0:a1a69d32f310 2557 * supported.
nikapov 0:a1a69d32f310 2558 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2559 */
nikapov 0:a1a69d32f310 2560 VL53L0X_Error VL53L0X_get_sequence_step_timeout(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2561 VL53L0X_SequenceStepId sequence_step_id,
nikapov 0:a1a69d32f310 2562 FixPoint1616_t *p_time_out_milli_secs);
nikapov 0:a1a69d32f310 2563
nikapov 0:a1a69d32f310 2564 /**
nikapov 0:a1a69d32f310 2565 * @brief Sets the timeout of a requested sequence step.
nikapov 0:a1a69d32f310 2566 *
nikapov 0:a1a69d32f310 2567 * @par Function Description
nikapov 0:a1a69d32f310 2568 * This function sets the timeout of a requested sequence step.
nikapov 0:a1a69d32f310 2569 *
nikapov 0:a1a69d32f310 2570 * @note This function Accesses the device
nikapov 0:a1a69d32f310 2571 *
nikapov 0:a1a69d32f310 2572 * @param dev Device Handle
nikapov 0:a1a69d32f310 2573 * @param sequence_step_id Sequence step identifier.
nikapov 0:a1a69d32f310 2574 * @param time_out_milli_secs Demanded timeout
nikapov 0:a1a69d32f310 2575 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2576 * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not
nikapov 0:a1a69d32f310 2577 * supported.
nikapov 0:a1a69d32f310 2578 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2579 */
nikapov 0:a1a69d32f310 2580 VL53L0X_Error VL53L0X_set_sequence_step_timeout(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2581 VL53L0X_SequenceStepId sequence_step_id, FixPoint1616_t time_out_milli_secs);
nikapov 0:a1a69d32f310 2582
nikapov 0:a1a69d32f310 2583 /**
nikapov 0:a1a69d32f310 2584 * @brief Get the current SPAD Ambient Damper Factor value
nikapov 0:a1a69d32f310 2585 *
nikapov 0:a1a69d32f310 2586 * @par Function Description
nikapov 0:a1a69d32f310 2587 * This function get the SPAD Ambient Damper Factor value
nikapov 0:a1a69d32f310 2588 *
nikapov 0:a1a69d32f310 2589 * @note This function Access to the device
nikapov 0:a1a69d32f310 2590 *
nikapov 0:a1a69d32f310 2591 * @param dev Device Handle
nikapov 0:a1a69d32f310 2592 * @param p_spad_ambient_damper_factor Pointer to programmed SPAD Ambient
nikapov 0:a1a69d32f310 2593 * Damper Factor value
nikapov 0:a1a69d32f310 2594 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2595 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2596 */
nikapov 0:a1a69d32f310 2597 VL53L0X_Error VL53L0X_get_spad_ambient_damper_factor(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2598 uint16_t *p_spad_ambient_damper_factor);
nikapov 0:a1a69d32f310 2599 /**
nikapov 0:a1a69d32f310 2600 * @brief Set the SPAD Ambient Damper Factor value
nikapov 0:a1a69d32f310 2601 *
nikapov 0:a1a69d32f310 2602 * @par Function Description
nikapov 0:a1a69d32f310 2603 * This function set the SPAD Ambient Damper Factor value
nikapov 0:a1a69d32f310 2604 *
nikapov 0:a1a69d32f310 2605 * @note This function Access to the device
nikapov 0:a1a69d32f310 2606 *
nikapov 0:a1a69d32f310 2607 * @param dev Device Handle
nikapov 0:a1a69d32f310 2608 * @param spad_ambient_damper_factor SPAD Ambient Damper Factor value
nikapov 0:a1a69d32f310 2609 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2610 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2611 */
nikapov 0:a1a69d32f310 2612 VL53L0X_Error VL53L0X_set_spad_ambient_damper_factor(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2613 uint16_t spad_ambient_damper_factor);
nikapov 0:a1a69d32f310 2614
nikapov 0:a1a69d32f310 2615 /**
nikapov 0:a1a69d32f310 2616 * @brief Get the current SPAD Ambient Damper Threshold value
nikapov 0:a1a69d32f310 2617 *
nikapov 0:a1a69d32f310 2618 * @par Function Description
nikapov 0:a1a69d32f310 2619 * This function get the SPAD Ambient Damper Threshold value
nikapov 0:a1a69d32f310 2620 *
nikapov 0:a1a69d32f310 2621 * @note This function Access to the device
nikapov 0:a1a69d32f310 2622 *
nikapov 0:a1a69d32f310 2623 * @param dev Device Handle
nikapov 0:a1a69d32f310 2624 * @param p_spad_ambient_damper_threshold Pointer to programmed
nikapov 0:a1a69d32f310 2625 * SPAD Ambient Damper Threshold value
nikapov 0:a1a69d32f310 2626 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2627 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2628 */
nikapov 0:a1a69d32f310 2629 VL53L0X_Error VL53L0X_get_spad_ambient_damper_threshold(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2630 uint16_t *p_spad_ambient_damper_threshold);
nikapov 0:a1a69d32f310 2631
nikapov 0:a1a69d32f310 2632 /**
nikapov 0:a1a69d32f310 2633 * @brief Set the SPAD Ambient Damper Threshold value
nikapov 0:a1a69d32f310 2634 *
nikapov 0:a1a69d32f310 2635 * @par Function Description
nikapov 0:a1a69d32f310 2636 * This function set the SPAD Ambient Damper Threshold value
nikapov 0:a1a69d32f310 2637 *
nikapov 0:a1a69d32f310 2638 * @note This function Access to the device
nikapov 0:a1a69d32f310 2639 *
nikapov 0:a1a69d32f310 2640 * @param dev Device Handle
nikapov 0:a1a69d32f310 2641 * @param spad_ambient_damper_threshold SPAD Ambient Damper Threshold value
nikapov 0:a1a69d32f310 2642 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2643 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2644 */
nikapov 0:a1a69d32f310 2645 VL53L0X_Error VL53L0X_set_spad_ambient_damper_threshold(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2646 uint16_t spad_ambient_damper_threshold);
nikapov 0:a1a69d32f310 2647
nikapov 0:a1a69d32f310 2648 /**
nikapov 0:a1a69d32f310 2649 * @brief Get the maximal distance for actual setup
nikapov 0:a1a69d32f310 2650 * @par Function Description
nikapov 0:a1a69d32f310 2651 * Device must be initialized through @a VL53L0X_SetParameters() prior calling
nikapov 0:a1a69d32f310 2652 * this function.
nikapov 0:a1a69d32f310 2653 *
nikapov 0:a1a69d32f310 2654 * Any range value more than the value returned is to be considered as
nikapov 0:a1a69d32f310 2655 * "no target detected" or
nikapov 0:a1a69d32f310 2656 * "no target in detectable range"\n
nikapov 0:a1a69d32f310 2657 * @warning The maximal distance depends on the setup
nikapov 0:a1a69d32f310 2658 *
nikapov 0:a1a69d32f310 2659 * @note This function is not Implemented
nikapov 0:a1a69d32f310 2660 *
nikapov 0:a1a69d32f310 2661 * @param dev Device Handle
nikapov 0:a1a69d32f310 2662 * @param p_upper_limit_milli_meter The maximal range limit for actual setup
nikapov 0:a1a69d32f310 2663 * (in millimeter)
nikapov 0:a1a69d32f310 2664 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
nikapov 0:a1a69d32f310 2665 */
nikapov 0:a1a69d32f310 2666 VL53L0X_Error VL53L0X_get_upper_limit_milli_meter(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2667 uint16_t *p_upper_limit_milli_meter);
nikapov 0:a1a69d32f310 2668
nikapov 0:a1a69d32f310 2669 /**
nikapov 0:a1a69d32f310 2670 * @brief Get the tuning settings pointer and the internal external switch
nikapov 0:a1a69d32f310 2671 * value.
nikapov 0:a1a69d32f310 2672 *
nikapov 0:a1a69d32f310 2673 * This function is used to get the Tuning settings buffer pointer and the
nikapov 0:a1a69d32f310 2674 * value.
nikapov 0:a1a69d32f310 2675 * of the switch to select either external or internal tuning settings.
nikapov 0:a1a69d32f310 2676 *
nikapov 0:a1a69d32f310 2677 * @note This function Access to the device
nikapov 0:a1a69d32f310 2678 *
nikapov 0:a1a69d32f310 2679 * @param dev Device Handle
nikapov 0:a1a69d32f310 2680 * @param pp_tuning_setting_buffer Pointer to tuning settings buffer.
nikapov 0:a1a69d32f310 2681 * @param p_use_internal_tuning_settings Pointer to store Use internal tuning
nikapov 0:a1a69d32f310 2682 * settings value.
nikapov 0:a1a69d32f310 2683 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2684 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2685 */
nikapov 0:a1a69d32f310 2686 VL53L0X_Error VL53L0X_get_tuning_setting_buffer(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2687 uint8_t **pp_tuning_setting_buffer, uint8_t *p_use_internal_tuning_settings);
nikapov 0:a1a69d32f310 2688
nikapov 0:a1a69d32f310 2689 /**
nikapov 0:a1a69d32f310 2690 * @brief Set the tuning settings pointer
nikapov 0:a1a69d32f310 2691 *
nikapov 0:a1a69d32f310 2692 * This function is used to specify the Tuning settings buffer to be used
nikapov 0:a1a69d32f310 2693 * for a given device. The buffer contains all the necessary data to permit
nikapov 0:a1a69d32f310 2694 * the API to write tuning settings.
nikapov 0:a1a69d32f310 2695 * This function permit to force the usage of either external or internal
nikapov 0:a1a69d32f310 2696 * tuning settings.
nikapov 0:a1a69d32f310 2697 *
nikapov 0:a1a69d32f310 2698 * @note This function Access to the device
nikapov 0:a1a69d32f310 2699 *
nikapov 0:a1a69d32f310 2700 * @param dev Device Handle
nikapov 0:a1a69d32f310 2701 * @param p_tuning_setting_buffer Pointer to tuning settings buffer.
nikapov 0:a1a69d32f310 2702 * @param use_internal_tuning_settings Use internal tuning settings value.
nikapov 0:a1a69d32f310 2703 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2704 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2705 */
nikapov 0:a1a69d32f310 2706 VL53L0X_Error VL53L0X_set_tuning_setting_buffer(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2707 uint8_t *p_tuning_setting_buffer, uint8_t use_internal_tuning_settings);
nikapov 0:a1a69d32f310 2708
nikapov 0:a1a69d32f310 2709 /**
nikapov 0:a1a69d32f310 2710 * @defgroup VL53L0X_registerAccess_group PAL Register Access Functions
nikapov 0:a1a69d32f310 2711 * @brief PAL Register Access Functions
nikapov 0:a1a69d32f310 2712 * @{
nikapov 0:a1a69d32f310 2713 */
nikapov 0:a1a69d32f310 2714
nikapov 0:a1a69d32f310 2715 /**
nikapov 0:a1a69d32f310 2716 * Lock comms interface to serialize all commands to a shared I2C interface for a specific device
nikapov 0:a1a69d32f310 2717 * @param dev Device Handle
nikapov 0:a1a69d32f310 2718 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2719 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2720 */
nikapov 0:a1a69d32f310 2721 VL53L0X_Error VL53L0X_lock_sequence_access(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 2722
nikapov 0:a1a69d32f310 2723 /**
nikapov 0:a1a69d32f310 2724 * Unlock comms interface to serialize all commands to a shared I2C interface for a specific device
nikapov 0:a1a69d32f310 2725 * @param dev Device Handle
nikapov 0:a1a69d32f310 2726 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2727 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2728 */
nikapov 0:a1a69d32f310 2729 VL53L0X_Error VL53L0X_unlock_sequence_access(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 2730
nikapov 0:a1a69d32f310 2731 /**
nikapov 0:a1a69d32f310 2732 * @brief Prepare device for operation
nikapov 0:a1a69d32f310 2733 * @par Function Description
nikapov 0:a1a69d32f310 2734 * Update device with provided parameters
nikapov 0:a1a69d32f310 2735 * @li Then start ranging operation.
nikapov 0:a1a69d32f310 2736 *
nikapov 0:a1a69d32f310 2737 * @note This function Access to the device
nikapov 0:a1a69d32f310 2738 *
nikapov 0:a1a69d32f310 2739 * @param Dev Device Handle
nikapov 0:a1a69d32f310 2740 * @param pDeviceParameters Pointer to store current device parameters.
nikapov 0:a1a69d32f310 2741 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2742 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2743 */
nikapov 0:a1a69d32f310 2744 VL53L0X_Error vl53L0x_set_device_parameters(VL53L0X_DEV Dev,
nikapov 0:a1a69d32f310 2745 const VL53L0X_DeviceParameters_t *pDeviceParameters);
nikapov 0:a1a69d32f310 2746
nikapov 0:a1a69d32f310 2747 /**
nikapov 0:a1a69d32f310 2748 * Set Group parameter Hold state
nikapov 0:a1a69d32f310 2749 *
nikapov 0:a1a69d32f310 2750 * @par Function Description
nikapov 0:a1a69d32f310 2751 * Set or remove device internal group parameter hold
nikapov 0:a1a69d32f310 2752 *
nikapov 0:a1a69d32f310 2753 * @note This function is not Implemented
nikapov 0:a1a69d32f310 2754 *
nikapov 0:a1a69d32f310 2755 * @param dev Device Handle
nikapov 0:a1a69d32f310 2756 * @param group_param_hold Group parameter Hold state to be set (on/off)
nikapov 0:a1a69d32f310 2757 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
nikapov 0:a1a69d32f310 2758 */
nikapov 0:a1a69d32f310 2759 VL53L0X_Error VL53L0X_set_group_param_hold(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2760 uint8_t group_param_hold);
nikapov 0:a1a69d32f310 2761
nikapov 0:a1a69d32f310 2762
nikapov 0:a1a69d32f310 2763 /**
nikapov 0:a1a69d32f310 2764 * @brief Wait for device ready for a new measurement command.
nikapov 0:a1a69d32f310 2765 * Blocking function.
nikapov 0:a1a69d32f310 2766 *
nikapov 0:a1a69d32f310 2767 * @note This function is not Implemented
nikapov 0:a1a69d32f310 2768 *
nikapov 0:a1a69d32f310 2769 * @param dev Device Handle
nikapov 0:a1a69d32f310 2770 * @param max_loop Max Number of polling loop (timeout).
nikapov 0:a1a69d32f310 2771 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
nikapov 0:a1a69d32f310 2772 */
nikapov 0:a1a69d32f310 2773 VL53L0X_Error VL53L0X_wait_device_ready_for_new_measurement(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2774 uint32_t max_loop);
nikapov 0:a1a69d32f310 2775
nikapov 0:a1a69d32f310 2776 VL53L0X_Error VL53L0X_reverse_bytes(uint8_t *data, uint32_t size);
nikapov 0:a1a69d32f310 2777
nikapov 0:a1a69d32f310 2778 int range_meas_int_continuous_mode(void (*fptr)(void));
nikapov 0:a1a69d32f310 2779
nikapov 0:a1a69d32f310 2780
nikapov 0:a1a69d32f310 2781 VL53L0X_DeviceInfo_t _device_info;
nikapov 0:a1a69d32f310 2782
nikapov 0:a1a69d32f310 2783 /* IO Device */
nikapov 0:a1a69d32f310 2784 DevI2C *_dev_i2c;
nikapov 0:a1a69d32f310 2785 /* Digital out pin */
nikapov 0:a1a69d32f310 2786 DigitalOut *_gpio0;
nikapov 0:a1a69d32f310 2787 /* GPIO expander */
nikapov 0:a1a69d32f310 2788 Stmpe1600DigiOut *_expgpio0;
nikapov 0:a1a69d32f310 2789 /* Measure detection IRQ */
nikapov 0:a1a69d32f310 2790 InterruptIn *_gpio1Int;
nikapov 0:a1a69d32f310 2791 /* Device data */
nikapov 0:a1a69d32f310 2792 VL53L0X_Dev_t _my_device;
nikapov 0:a1a69d32f310 2793 VL53L0X_DEV _device;
nikapov 0:a1a69d32f310 2794 };
nikapov 0:a1a69d32f310 2795
nikapov 0:a1a69d32f310 2796
nikapov 0:a1a69d32f310 2797 #endif /* _VL53L0X_CLASS_H_ */