Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
VL53L0X.h
00001 /******************************************************************************* 00002 Copyright © 2016, STMicroelectronics International N.V. 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without 00006 modification, are permitted provided that the following conditions are met: 00007 * Redistributions of source code must retain the above copyright 00008 notice, this list of conditions and the following disclaimer. 00009 * Redistributions in binary form must reproduce the above copyright 00010 notice, this list of conditions and the following disclaimer in the 00011 documentation and/or other materials provided with the distribution. 00012 * Neither the name of STMicroelectronics nor the 00013 names of its contributors may be used to endorse or promote products 00014 derived from this software without specific prior written permission. 00015 00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00018 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND 00019 NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED. 00020 IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY 00021 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00022 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00023 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00024 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00025 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00026 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 *****************************************************************************/ 00028 00029 #ifndef __VL53L0X_CLASS_H 00030 #define __VL53L0X_CLASS_H 00031 00032 00033 #ifdef _MSC_VER 00034 # ifdef VL53L0X_API_EXPORTS 00035 # define VL53L0X_API __declspec(dllexport) 00036 # else 00037 # define VL53L0X_API 00038 # endif 00039 #else 00040 # define VL53L0X_API 00041 #endif 00042 00043 00044 /* Includes ------------------------------------------------------------------*/ 00045 #include "mbed.h" 00046 #include "RangeSensor.h" 00047 #include "DevI2C.h" 00048 #include "PinNames.h" 00049 #include "VL53L0X_def.h" 00050 #include "VL53L0X_platform.h" 00051 #include "Stmpe1600.h" 00052 00053 00054 /** 00055 * The device model ID 00056 */ 00057 #define IDENTIFICATION_MODEL_ID 0x000 00058 00059 00060 #define STATUS_OK 0x00 00061 #define STATUS_FAIL 0x01 00062 00063 #define VL53L0X_OsDelay(...) wait_ms(2) // 2 msec delay. can also use wait(float secs)/wait_us(int) 00064 00065 #ifdef USE_EMPTY_STRING 00066 #define VL53L0X_STRING_DEVICE_INFO_NAME "" 00067 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS0 "" 00068 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS1 "" 00069 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS2 "" 00070 #define VL53L0X_STRING_DEVICE_INFO_NAME_ES1 "" 00071 #define VL53L0X_STRING_DEVICE_INFO_TYPE "" 00072 00073 /* PAL ERROR strings */ 00074 #define VL53L0X_STRING_ERROR_NONE "" 00075 #define VL53L0X_STRING_ERROR_CALIBRATION_WARNING "" 00076 #define VL53L0X_STRING_ERROR_MIN_CLIPPED "" 00077 #define VL53L0X_STRING_ERROR_UNDEFINED "" 00078 #define VL53L0X_STRING_ERROR_INVALID_PARAMS "" 00079 #define VL53L0X_STRING_ERROR_NOT_SUPPORTED "" 00080 #define VL53L0X_STRING_ERROR_RANGE_ERROR "" 00081 #define VL53L0X_STRING_ERROR_TIME_OUT "" 00082 #define VL53L0X_STRING_ERROR_MODE_NOT_SUPPORTED "" 00083 #define VL53L0X_STRING_ERROR_BUFFER_TOO_SMALL "" 00084 #define VL53L0X_STRING_ERROR_GPIO_NOT_EXISTING "" 00085 #define VL53L0X_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED "" 00086 #define VL53L0X_STRING_ERROR_CONTROL_INTERFACE "" 00087 #define VL53L0X_STRING_ERROR_INVALID_COMMAND "" 00088 #define VL53L0X_STRING_ERROR_DIVISION_BY_ZERO "" 00089 #define VL53L0X_STRING_ERROR_REF_SPAD_INIT "" 00090 #define VL53L0X_STRING_ERROR_NOT_IMPLEMENTED "" 00091 00092 #define VL53L0X_STRING_UNKNOW_ERROR_CODE "" 00093 00094 00095 00096 /* Range Status */ 00097 #define VL53L0X_STRING_RANGESTATUS_NONE "" 00098 #define VL53L0X_STRING_RANGESTATUS_RANGEVALID "" 00099 #define VL53L0X_STRING_RANGESTATUS_SIGMA "" 00100 #define VL53L0X_STRING_RANGESTATUS_SIGNAL "" 00101 #define VL53L0X_STRING_RANGESTATUS_MINRANGE "" 00102 #define VL53L0X_STRING_RANGESTATUS_PHASE "" 00103 #define VL53L0X_STRING_RANGESTATUS_HW "" 00104 00105 00106 /* Range Status */ 00107 #define VL53L0X_STRING_STATE_POWERDOWN "" 00108 #define VL53L0X_STRING_STATE_WAIT_STATICINIT "" 00109 #define VL53L0X_STRING_STATE_STANDBY "" 00110 #define VL53L0X_STRING_STATE_IDLE "" 00111 #define VL53L0X_STRING_STATE_RUNNING "" 00112 #define VL53L0X_STRING_STATE_UNKNOWN "" 00113 #define VL53L0X_STRING_STATE_ERROR "" 00114 00115 00116 /* Device Specific */ 00117 #define VL53L0X_STRING_DEVICEERROR_NONE "" 00118 #define VL53L0X_STRING_DEVICEERROR_VCSELCONTINUITYTESTFAILURE "" 00119 #define VL53L0X_STRING_DEVICEERROR_VCSELWATCHDOGTESTFAILURE "" 00120 #define VL53L0X_STRING_DEVICEERROR_NOVHVVALUEFOUND "" 00121 #define VL53L0X_STRING_DEVICEERROR_MSRCNOTARGET "" 00122 #define VL53L0X_STRING_DEVICEERROR_SNRCHECK "" 00123 #define VL53L0X_STRING_DEVICEERROR_RANGEPHASECHECK "" 00124 #define VL53L0X_STRING_DEVICEERROR_SIGMATHRESHOLDCHECK "" 00125 #define VL53L0X_STRING_DEVICEERROR_TCC "" 00126 #define VL53L0X_STRING_DEVICEERROR_PHASECONSISTENCY "" 00127 #define VL53L0X_STRING_DEVICEERROR_MINCLIP "" 00128 #define VL53L0X_STRING_DEVICEERROR_RANGECOMPLETE "" 00129 #define VL53L0X_STRING_DEVICEERROR_ALGOUNDERFLOW "" 00130 #define VL53L0X_STRING_DEVICEERROR_ALGOOVERFLOW "" 00131 #define VL53L0X_STRING_DEVICEERROR_RANGEIGNORETHRESHOLD "" 00132 #define VL53L0X_STRING_DEVICEERROR_UNKNOWN "" 00133 00134 /* Check Enable */ 00135 #define VL53L0X_STRING_CHECKENABLE_SIGMA_FINAL_RANGE "" 00136 #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE "" 00137 #define VL53L0X_STRING_CHECKENABLE_SIGNAL_REF_CLIP "" 00138 #define VL53L0X_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD "" 00139 00140 /* Sequence Step */ 00141 #define VL53L0X_STRING_SEQUENCESTEP_TCC "" 00142 #define VL53L0X_STRING_SEQUENCESTEP_DSS "" 00143 #define VL53L0X_STRING_SEQUENCESTEP_MSRC "" 00144 #define VL53L0X_STRING_SEQUENCESTEP_PRE_RANGE "" 00145 #define VL53L0X_STRING_SEQUENCESTEP_FINAL_RANGE "" 00146 #else 00147 #define VL53L0X_STRING_DEVICE_INFO_NAME "VL53L0X cut1.0" 00148 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS0 "VL53L0X TS0" 00149 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS1 "VL53L0X TS1" 00150 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS2 "VL53L0X TS2" 00151 #define VL53L0X_STRING_DEVICE_INFO_NAME_ES1 "VL53L0X ES1 or later" 00152 #define VL53L0X_STRING_DEVICE_INFO_TYPE "VL53L0X" 00153 00154 /* PAL ERROR strings */ 00155 #define VL53L0X_STRING_ERROR_NONE \ 00156 "No Error" 00157 #define VL53L0X_STRING_ERROR_CALIBRATION_WARNING \ 00158 "Calibration Warning Error" 00159 #define VL53L0X_STRING_ERROR_MIN_CLIPPED \ 00160 "Min clipped error" 00161 #define VL53L0X_STRING_ERROR_UNDEFINED \ 00162 "Undefined error" 00163 #define VL53L0X_STRING_ERROR_INVALID_PARAMS \ 00164 "Invalid parameters error" 00165 #define VL53L0X_STRING_ERROR_NOT_SUPPORTED \ 00166 "Not supported error" 00167 #define VL53L0X_STRING_ERROR_RANGE_ERROR \ 00168 "Range error" 00169 #define VL53L0X_STRING_ERROR_TIME_OUT \ 00170 "Time out error" 00171 #define VL53L0X_STRING_ERROR_MODE_NOT_SUPPORTED \ 00172 "Mode not supported error" 00173 #define VL53L0X_STRING_ERROR_BUFFER_TOO_SMALL \ 00174 "Buffer too small" 00175 #define VL53L0X_STRING_ERROR_GPIO_NOT_EXISTING \ 00176 "GPIO not existing" 00177 #define VL53L0X_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED \ 00178 "GPIO funct not supported" 00179 #define VL53L0X_STRING_ERROR_INTERRUPT_NOT_CLEARED \ 00180 "Interrupt not Cleared" 00181 #define VL53L0X_STRING_ERROR_CONTROL_INTERFACE \ 00182 "Control Interface Error" 00183 #define VL53L0X_STRING_ERROR_INVALID_COMMAND \ 00184 "Invalid Command Error" 00185 #define VL53L0X_STRING_ERROR_DIVISION_BY_ZERO \ 00186 "Division by zero Error" 00187 #define VL53L0X_STRING_ERROR_REF_SPAD_INIT \ 00188 "Reference Spad Init Error" 00189 #define VL53L0X_STRING_ERROR_NOT_IMPLEMENTED \ 00190 "Not implemented error" 00191 00192 #define VL53L0X_STRING_UNKNOW_ERROR_CODE \ 00193 "Unknown Error Code" 00194 00195 00196 00197 /* Range Status */ 00198 #define VL53L0X_STRING_RANGESTATUS_NONE "No Update" 00199 #define VL53L0X_STRING_RANGESTATUS_RANGEVALID "Range Valid" 00200 #define VL53L0X_STRING_RANGESTATUS_SIGMA "Sigma Fail" 00201 #define VL53L0X_STRING_RANGESTATUS_SIGNAL "Signal Fail" 00202 #define VL53L0X_STRING_RANGESTATUS_MINRANGE "Min Range Fail" 00203 #define VL53L0X_STRING_RANGESTATUS_PHASE "Phase Fail" 00204 #define VL53L0X_STRING_RANGESTATUS_HW "Hardware Fail" 00205 00206 00207 /* Range Status */ 00208 #define VL53L0X_STRING_STATE_POWERDOWN "POWERDOWN State" 00209 #define VL53L0X_STRING_STATE_WAIT_STATICINIT \ 00210 "Wait for staticinit State" 00211 #define VL53L0X_STRING_STATE_STANDBY "STANDBY State" 00212 #define VL53L0X_STRING_STATE_IDLE "IDLE State" 00213 #define VL53L0X_STRING_STATE_RUNNING "RUNNING State" 00214 #define VL53L0X_STRING_STATE_UNKNOWN "UNKNOWN State" 00215 #define VL53L0X_STRING_STATE_ERROR "ERROR State" 00216 00217 00218 /* Device Specific */ 00219 #define VL53L0X_STRING_DEVICEERROR_NONE "No Update" 00220 #define VL53L0X_STRING_DEVICEERROR_VCSELCONTINUITYTESTFAILURE \ 00221 "VCSEL Continuity Test Failure" 00222 #define VL53L0X_STRING_DEVICEERROR_VCSELWATCHDOGTESTFAILURE \ 00223 "VCSEL Watchdog Test Failure" 00224 #define VL53L0X_STRING_DEVICEERROR_NOVHVVALUEFOUND \ 00225 "No VHV Value found" 00226 #define VL53L0X_STRING_DEVICEERROR_MSRCNOTARGET \ 00227 "MSRC No Target Error" 00228 #define VL53L0X_STRING_DEVICEERROR_SNRCHECK \ 00229 "SNR Check Exit" 00230 #define VL53L0X_STRING_DEVICEERROR_RANGEPHASECHECK \ 00231 "Range Phase Check Error" 00232 #define VL53L0X_STRING_DEVICEERROR_SIGMATHRESHOLDCHECK \ 00233 "Sigma Threshold Check Error" 00234 #define VL53L0X_STRING_DEVICEERROR_TCC \ 00235 "TCC Error" 00236 #define VL53L0X_STRING_DEVICEERROR_PHASECONSISTENCY \ 00237 "Phase Consistency Error" 00238 #define VL53L0X_STRING_DEVICEERROR_MINCLIP \ 00239 "Min Clip Error" 00240 #define VL53L0X_STRING_DEVICEERROR_RANGECOMPLETE \ 00241 "Range Complete" 00242 #define VL53L0X_STRING_DEVICEERROR_ALGOUNDERFLOW \ 00243 "Range Algo Underflow Error" 00244 #define VL53L0X_STRING_DEVICEERROR_ALGOOVERFLOW \ 00245 "Range Algo Overlow Error" 00246 #define VL53L0X_STRING_DEVICEERROR_RANGEIGNORETHRESHOLD \ 00247 "Range Ignore Threshold Error" 00248 #define VL53L0X_STRING_DEVICEERROR_UNKNOWN \ 00249 "Unknown error code" 00250 00251 /* Check Enable */ 00252 #define VL53L0X_STRING_CHECKENABLE_SIGMA_FINAL_RANGE \ 00253 "SIGMA FINAL RANGE" 00254 #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE \ 00255 "SIGNAL RATE FINAL RANGE" 00256 #define VL53L0X_STRING_CHECKENABLE_SIGNAL_REF_CLIP \ 00257 "SIGNAL REF CLIP" 00258 #define VL53L0X_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD \ 00259 "RANGE IGNORE THRESHOLD" 00260 #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_MSRC \ 00261 "SIGNAL RATE MSRC" 00262 #define VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_PRE_RANGE \ 00263 "SIGNAL RATE PRE RANGE" 00264 00265 /* Sequence Step */ 00266 #define VL53L0X_STRING_SEQUENCESTEP_TCC "TCC" 00267 #define VL53L0X_STRING_SEQUENCESTEP_DSS "DSS" 00268 #define VL53L0X_STRING_SEQUENCESTEP_MSRC "MSRC" 00269 #define VL53L0X_STRING_SEQUENCESTEP_PRE_RANGE "PRE RANGE" 00270 #define VL53L0X_STRING_SEQUENCESTEP_FINAL_RANGE "FINAL RANGE" 00271 #endif /* USE_EMPTY_STRING */ 00272 00273 /* sensor operating modes */ 00274 typedef enum { 00275 range_single_shot_polling = 1, 00276 range_continuous_polling, 00277 range_continuous_interrupt, 00278 range_continuous_polling_low_threshold, 00279 range_continuous_polling_high_threshold, 00280 range_continuous_polling_out_of_window, 00281 range_continuous_interrupt_low_threshold, 00282 range_continuous_interrupt_high_threshold, 00283 range_continuous_interrupt_out_of_window, 00284 } OperatingMode; 00285 00286 /** default device address */ 00287 #define VL53L0X_DEFAULT_ADDRESS 0x52 /* (8-bit) */ 00288 00289 /* Classes -------------------------------------------------------------------*/ 00290 /** Class representing a VL53L0 sensor component 00291 */ 00292 class VL53L0X : public RangeSensor 00293 { 00294 public: 00295 /** Constructor 00296 * @param[in] &i2c device I2C to be used for communication 00297 * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT 00298 * @param[in] dev_addr device address, 0x29 by default 00299 */ 00300 VL53L0X(DevI2C *i2c, DigitalOut *pin, PinName pin_gpio1, uint8_t dev_addr = VL53L0X_DEFAULT_ADDRESS) : _dev_i2c(i2c), 00301 _gpio0(pin) 00302 { 00303 _my_device.I2cDevAddr = dev_addr; 00304 _my_device.comms_type = 1; // VL53L0X_COMMS_I2C 00305 _my_device.comms_speed_khz = 400; 00306 _device = &_my_device; 00307 _expgpio0 = NULL; 00308 if (pin_gpio1 != NC) { 00309 _gpio1Int = new InterruptIn(pin_gpio1); 00310 } else { 00311 _gpio1Int = NULL; 00312 } 00313 } 00314 00315 /** Constructor 2 (STMPE1600DigiOut) 00316 * @param[in] i2c device I2C to be used for communication 00317 * @param[in] &pin Gpio Expander STMPE1600DigiOut pin to be used as component GPIO_0 CE 00318 * @param[in] pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT 00319 * @param[in] device address, 0x29 by default 00320 */ 00321 VL53L0X(DevI2C *i2c, Stmpe1600DigiOut *pin, PinName pin_gpio1, 00322 uint8_t dev_addr = VL53L0X_DEFAULT_ADDRESS) : _dev_i2c(i2c), _expgpio0(pin) 00323 { 00324 _my_device.I2cDevAddr = dev_addr; 00325 _my_device.comms_type = 1; // VL53L0X_COMMS_I2C 00326 _my_device.comms_speed_khz = 400; 00327 _device = &_my_device; 00328 _gpio0 = NULL; 00329 if (pin_gpio1 != NC) { 00330 _gpio1Int = new InterruptIn(pin_gpio1); 00331 } else { 00332 _gpio1Int = NULL; 00333 } 00334 } 00335 00336 /** Destructor 00337 */ 00338 virtual ~VL53L0X() 00339 { 00340 if (_gpio1Int != NULL) { 00341 delete _gpio1Int; 00342 } 00343 } 00344 00345 /*** Interface Methods ***/ 00346 /*** High level API ***/ 00347 /** 00348 * @brief PowerOn the sensor 00349 * @return void 00350 */ 00351 /* turns on the sensor */ 00352 void VL53L0X_on(void) 00353 { 00354 if (_gpio0) { 00355 *_gpio0 = 1; 00356 } else { 00357 if (_expgpio0) { 00358 *_expgpio0 = 1; 00359 } 00360 } 00361 wait_ms(10); 00362 } 00363 00364 /** 00365 * @brief PowerOff the sensor 00366 * @return void 00367 */ 00368 /* turns off the sensor */ 00369 void VL53L0X_off(void) 00370 { 00371 if (_gpio0) { 00372 *_gpio0 = 0; 00373 } else { 00374 if (_expgpio0) { 00375 *_expgpio0 = 0; 00376 } 00377 } 00378 wait_ms(10); 00379 } 00380 00381 00382 /** 00383 * @brief Initialize the sensor with default values 00384 * @return "0" on success 00385 */ 00386 int init_sensor(uint8_t new_addr); 00387 00388 /** 00389 * @brief Start the measure indicated by operating mode 00390 * @param[in] operating_mode specifies requested measure 00391 * @param[in] fptr specifies call back function must be !NULL in case of interrupt measure 00392 * @return "0" on success 00393 */ 00394 int start_measurement(OperatingMode operating_mode, void (*fptr)(void)); 00395 00396 /** 00397 * @brief Get results for the measure indicated by operating mode 00398 * @param[in] operating_mode specifies requested measure results 00399 * @param[out] p_data pointer to the MeasureData_t structure to read data in to 00400 * @return "0" on success 00401 */ 00402 int get_measurement(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *p_data); 00403 00404 /** 00405 * @brief Stop the currently running measure indicate by operating_mode 00406 * @param[in] operating_mode specifies requested measure to stop 00407 * @return "0" on success 00408 */ 00409 int stop_measurement(OperatingMode operating_mode); 00410 00411 /** 00412 * @brief Interrupt handling func to be called by user after an INT is occourred 00413 * @param[in] opeating_mode indicating the in progress measure 00414 * @param[out] Data pointer to the MeasureData_t structure to read data in to 00415 * @return "0" on success 00416 */ 00417 int handle_irq(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *data); 00418 00419 /** 00420 * @brief Enable interrupt measure IRQ 00421 * @return "0" on success 00422 */ 00423 void enable_interrupt_measure_detection_irq(void) 00424 { 00425 if (_gpio1Int != NULL) { 00426 _gpio1Int->enable_irq(); 00427 } 00428 } 00429 00430 /** 00431 * @brief Disable interrupt measure IRQ 00432 * @return "0" on success 00433 */ 00434 void disable_interrupt_measure_detection_irq(void) 00435 { 00436 if (_gpio1Int != NULL) { 00437 _gpio1Int->disable_irq(); 00438 } 00439 } 00440 00441 /** 00442 * @brief Attach a function to call when an interrupt is detected, i.e. measurement is ready 00443 * @param[in] fptr pointer to call back function to be called whenever an interrupt occours 00444 * @return "0" on success 00445 */ 00446 void attach_interrupt_measure_detection_irq(void (*fptr)(void)) 00447 { 00448 if (_gpio1Int != NULL) { 00449 _gpio1Int->rise(fptr); 00450 } 00451 } 00452 00453 /** Wrapper functions */ 00454 /** @defgroup api_init Init functions 00455 * @brief API init functions 00456 * @ingroup api_hl 00457 * @{ 00458 */ 00459 00460 /** 00461 * 00462 * @brief One time device initialization 00463 * 00464 * To be called once and only once after device is brought out of reset (Chip enable) and booted. 00465 * 00466 * @par Function Description 00467 * When not used after a fresh device "power up" or reset, it may return @a #CALIBRATION_WARNING 00468 * meaning wrong calibration data may have been fetched from device that can result in ranging offset error\n 00469 * If application cannot execute device reset or need to run VL53L0X_data_init multiple time 00470 * then it must ensure proper offset calibration saving and restore on its own 00471 * 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 00472 * 00473 * @param void 00474 * @return "0" on success, @a #CALIBRATION_WARNING if failed 00475 */ 00476 virtual int init(void *init) 00477 { 00478 return VL53L0X_data_init(_device); 00479 } 00480 00481 /** 00482 * @brief Prepare device for operation 00483 * @par Function Description 00484 * Does static initialization and reprogram common default settings \n 00485 * Device is prepared for new measure, ready single shot ranging or ALS typical polling operation\n 00486 * After prepare user can : \n 00487 * @li Call other API function to set other settings\n 00488 * @li Configure the interrupt pins, etc... \n 00489 * @li Then start ranging or ALS operations in single shot or continuous mode 00490 * 00491 * @param void 00492 * @return "0" on success 00493 */ 00494 int prepare() 00495 { 00496 VL53L0X_Error status = VL53L0X_ERROR_NONE; 00497 uint32_t ref_spad_count; 00498 uint8_t is_aperture_spads; 00499 uint8_t vhv_settings; 00500 uint8_t phase_cal; 00501 00502 if (status == VL53L0X_ERROR_NONE) { 00503 //printf("Call of VL53L0X_StaticInit\r\n"); 00504 status = VL53L0X_static_init(_device); // Device Initialization 00505 } 00506 00507 if (status == VL53L0X_ERROR_NONE) { 00508 //printf("Call of VL53L0X_PerformRefCalibration\r\n"); 00509 status = VL53L0X_perform_ref_calibration(_device, 00510 &vhv_settings, &phase_cal); // Device Initialization 00511 } 00512 00513 if (status == VL53L0X_ERROR_NONE) { 00514 //printf("Call of VL53L0X_PerformRefSpadManagement\r\n"); 00515 status = VL53L0X_perform_ref_spad_management(_device, 00516 &ref_spad_count, &is_aperture_spads); // Device Initialization 00517 // printf ("refSpadCount = %d, isApertureSpads = %d\r\n", refSpadCount, isApertureSpads); 00518 } 00519 00520 return status; 00521 } 00522 00523 /** 00524 * @brief Start continuous ranging mode 00525 * 00526 * @details End user should ensure device is in idle state and not already running 00527 * @return "0" on success 00528 */ 00529 int range_start_continuous_mode() 00530 { 00531 int status; 00532 status = VL53L0X_set_device_mode(_device, VL53L0X_DEVICEMODE_CONTINUOUS_RANGING); 00533 00534 if (status == VL53L0X_ERROR_NONE) { 00535 //printf ("Call of VL53L0X_StartMeasurement\r\n"); 00536 status = VL53L0X_start_measurement(_device); 00537 } 00538 00539 return status; 00540 } 00541 00542 /** 00543 * @brief Get ranging result and only that 00544 * 00545 * @par Function Description 00546 * Unlike @a VL53L0X_get_ranging_measurement_data() this function only retrieves the range in millimeter \n 00547 * It does any required up-scale translation\n 00548 * It can be called after success status polling or in interrupt mode \n 00549 * @warning these function is not doing wrap around filtering \n 00550 * This function doesn't perform any data ready check! 00551 * 00552 * @param p_data Pointer to range distance 00553 * @return "0" on success 00554 */ 00555 virtual int get_distance(uint32_t *p_data) 00556 { 00557 int status = 0; 00558 VL53L0X_RangingMeasurementData_t p_ranging_measurement_data; 00559 00560 status = start_measurement(range_single_shot_polling, NULL); 00561 if (!status) { 00562 status = get_measurement(range_single_shot_polling, &p_ranging_measurement_data); 00563 } 00564 if (p_ranging_measurement_data.RangeStatus == 0) { 00565 // we have a valid range. 00566 *p_data = p_ranging_measurement_data.RangeMilliMeter; 00567 } else { 00568 *p_data = 0; 00569 status = VL53L0X_ERROR_RANGE_ERROR; 00570 } 00571 stop_measurement(range_single_shot_polling); 00572 return status; 00573 } 00574 00575 /** @} */ 00576 00577 /** 00578 * @brief Set new device i2c address 00579 * 00580 * After completion the device will answer to the new address programmed. 00581 * 00582 * @param new_addr The new i2c address (7bit) 00583 * @return "0" on success 00584 */ 00585 int set_device_address(int new_addr) 00586 { 00587 int status; 00588 00589 status = VL53L0X_set_device_address(_device, new_addr); 00590 if (!status) { 00591 _device->I2cDevAddr = new_addr; 00592 } 00593 return status; 00594 00595 } 00596 00597 /** 00598 * @brief Clear given system interrupt condition 00599 * 00600 * @par Function Description 00601 * Clear given interrupt cause by writing into register #SYSTEM_INTERRUPT_CLEAR register. 00602 * @param dev The device 00603 * @param int_clear Which interrupt source to clear. Use any combinations of #INTERRUPT_CLEAR_RANGING , #INTERRUPT_CLEAR_ALS , #INTERRUPT_CLEAR_ERROR. 00604 * @return "0" on success 00605 */ 00606 int clear_interrupt(uint8_t int_clear) 00607 { 00608 return VL53L0X_clear_interrupt_mask(_device, int_clear); 00609 } 00610 00611 /** 00612 * 00613 * @brief One time device initialization 00614 * 00615 * To be called once and only once after device is brought out of reset 00616 * (Chip enable) and booted see @a VL53L0X_WaitDeviceBooted() 00617 * 00618 * @par Function Description 00619 * When not used after a fresh device "power up" or reset, it may return 00620 * @a #VL53L0X_ERROR_CALIBRATION_WARNING meaning wrong calibration data 00621 * may have been fetched from device that can result in ranging offset error\n 00622 * If application cannot execute device reset or need to run VL53L0X_DataInit 00623 * multiple time then it must ensure proper offset calibration saving and 00624 * restore on its own by using @a VL53L0X_GetOffsetCalibrationData() on first 00625 * power up and then @a VL53L0X_SetOffsetCalibrationData() in all subsequent init 00626 * This function will change the VL53L0X_State from VL53L0X_STATE_POWERDOWN to 00627 * VL53L0X_STATE_WAIT_STATICINIT. 00628 * 00629 * @note This function accesses to the device 00630 * 00631 * @param dev Device Handle 00632 * @return VL53L0X_ERROR_NONE Success 00633 * @return "Other error code" See ::VL53L0X_Error 00634 */ 00635 VL53L0X_Error VL53L0X_data_init(VL53L0X_DEV dev); 00636 00637 /** 00638 * @brief Do basic device init (and eventually patch loading) 00639 * This function will change the VL53L0X_State from 00640 * VL53L0X_STATE_WAIT_STATICINIT to VL53L0X_STATE_IDLE. 00641 * In this stage all default setting will be applied. 00642 * 00643 * @note This function Access to the device 00644 * 00645 * @param dev Device Handle 00646 * @return VL53L0X_ERROR_NONE Success 00647 * @return "Other error code" See ::VL53L0X_Error 00648 */ 00649 VL53L0X_Error VL53L0X_static_init(VL53L0X_DEV dev); 00650 00651 /** 00652 * @brief Perform Reference Calibration 00653 * 00654 * @details Perform a reference calibration of the Device. 00655 * This function should be run from time to time before doing 00656 * a ranging measurement. 00657 * This function will launch a special ranging measurement, so 00658 * if interrupt are enable an interrupt will be done. 00659 * This function will clear the interrupt generated automatically. 00660 * 00661 * @warning This function is a blocking function 00662 * 00663 * @note This function Access to the device 00664 * 00665 * @param dev Device Handle 00666 * @param p_vhv_settings Pointer to vhv settings parameter. 00667 * @param p_phase_cal Pointer to PhaseCal parameter. 00668 * @return VL53L0X_ERROR_NONE Success 00669 * @return "Other error code" See ::VL53L0X_Error 00670 */ 00671 VL53L0X_Error VL53L0X_perform_ref_calibration(VL53L0X_DEV dev, uint8_t *p_vhv_settings, 00672 uint8_t *p_phase_cal); 00673 00674 /** 00675 * @brief Get Reference Calibration Parameters 00676 * 00677 * @par Function Description 00678 * Get Reference Calibration Parameters. 00679 * 00680 * @note This function Access to the device 00681 * 00682 * @param dev Device Handle 00683 * @param p_vhv_settings Pointer to VHV parameter 00684 * @param p_phase_cal Pointer to PhaseCal Parameter 00685 * @return VL53L0X_ERROR_NONE Success 00686 * @return "Other error code" See ::VL53L0X_Error 00687 */ 00688 VL53L0X_Error VL53L0X_get_ref_calibration(VL53L0X_DEV dev, 00689 uint8_t *p_vhv_settings, uint8_t *p_phase_cal); 00690 00691 VL53L0X_Error VL53L0X_set_ref_calibration(VL53L0X_DEV dev, 00692 uint8_t vhv_settings, uint8_t phase_cal); 00693 00694 /** 00695 * @brief Performs Reference Spad Management 00696 * 00697 * @par Function Description 00698 * The reference SPAD initialization procedure determines the minimum amount 00699 * of reference spads to be enables to achieve a target reference signal rate 00700 * and should be performed once during initialization. 00701 * 00702 * @note This function Access to the device 00703 * 00704 * @note This function change the device mode to 00705 * VL53L0X_DEVICEMODE_SINGLE_RANGING 00706 * 00707 * @param dev Device Handle 00708 * @param ref_spad_count Reports ref Spad Count 00709 * @param is_aperture_spads Reports if spads are of type 00710 * aperture or non-aperture. 00711 * 1:=aperture, 0:=Non-Aperture 00712 * @return VL53L0X_ERROR_NONE Success 00713 * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the Ref Spad procedure. 00714 * @return "Other error code" See ::VL53L0X_Error 00715 */ 00716 VL53L0X_Error VL53L0X_perform_ref_spad_management(VL53L0X_DEV dev, 00717 uint32_t *ref_spad_count, uint8_t *is_aperture_spads); 00718 00719 /** 00720 * @brief Applies Reference SPAD configuration 00721 * 00722 * @par Function Description 00723 * This function applies a given number of reference spads, identified as 00724 * either Aperture or Non-Aperture. 00725 * The requested spad count and type are stored within the device specific 00726 * parameters data for access by the host. 00727 * 00728 * @note This function Access to the device 00729 * 00730 * @param dev Device Handle 00731 * @param refSpadCount Number of ref spads. 00732 * @param is_aperture_spads Defines if spads are of type 00733 * aperture or non-aperture. 00734 * 1:=aperture, 0:=Non-Aperture 00735 * @return VL53L0X_ERROR_NONE Success 00736 * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the in the reference 00737 * spad configuration. 00738 * @return "Other error code" See ::VL53L0X_Error 00739 */ 00740 VL53L0X_Error VL53L0X_set_reference_spads(VL53L0X_DEV dev, 00741 uint32_t refSpadCount, uint8_t is_aperture_spads); 00742 00743 /** 00744 * @brief Retrieves SPAD configuration 00745 * 00746 * @par Function Description 00747 * This function retrieves the current number of applied reference spads 00748 * and also their type : Aperture or Non-Aperture. 00749 * 00750 * @note This function Access to the device 00751 * 00752 * @param dev Device Handle 00753 * @param p_spad_count Number ref Spad Count 00754 * @param p_is_aperture_spads Reports if spads are of type 00755 * aperture or non-aperture. 00756 * 1:=aperture, 0:=Non-Aperture 00757 * @return VL53L0X_ERROR_NONE Success 00758 * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the in the reference 00759 * spad configuration. 00760 * @return "Other error code" See ::VL53L0X_Error 00761 */ 00762 VL53L0X_Error VL53L0X_get_reference_spads(VL53L0X_DEV dev, 00763 uint32_t *p_spad_count, uint8_t *p_is_aperture_spads); 00764 00765 /** 00766 * @brief Get part to part calibration offset 00767 * 00768 * @par Function Description 00769 * Should only be used after a successful call to @a VL53L0X_DataInit to backup 00770 * device NVM value 00771 * 00772 * @note This function Access to the device 00773 * 00774 * @param dev Device Handle 00775 * @param p_offset_calibration_data_micro_meter Return part to part 00776 * calibration offset from device (microns) 00777 * @return VL53L0X_ERROR_NONE Success 00778 * @return "Other error code" See ::VL53L0X_Error 00779 */ 00780 VL53L0X_Error VL53L0X_get_offset_calibration_data_micro_meter(VL53L0X_DEV dev, 00781 int32_t *p_offset_calibration_data_micro_meter); 00782 /** 00783 * Set or over-hide part to part calibration offset 00784 * \sa VL53L0X_DataInit() VL53L0X_GetOffsetCalibrationDataMicroMeter() 00785 * 00786 * @note This function Access to the device 00787 * 00788 * @param dev Device Handle 00789 * @param p_offset_calibration_data_micro_meter Offset (microns) 00790 * @return VL53L0X_ERROR_NONE Success 00791 * @return "Other error code" See ::VL53L0X_Error 00792 */ 00793 VL53L0X_Error VL53L0X_set_offset_calibration_data_micro_meter(VL53L0X_DEV dev, 00794 int32_t offset_calibration_data_micro_meter); 00795 00796 VL53L0X_Error VL53L0X_perform_offset_calibration(VL53L0X_DEV dev, 00797 FixPoint1616_t cal_distance_milli_meter, 00798 int32_t *p_offset_micro_meter); 00799 00800 VL53L0X_Error VL53L0X_perform_xtalk_calibration(VL53L0X_DEV dev, 00801 FixPoint1616_t xtalk_cal_distance, 00802 FixPoint1616_t *p_xtalk_compensation_rate_mega_cps); 00803 00804 /** 00805 * @brief Perform XTalk Measurement 00806 * 00807 * @details Measures the current cross talk from glass in front 00808 * of the sensor. 00809 * This functions performs a histogram measurement and uses the results 00810 * to measure the crosstalk. For the function to be successful, there 00811 * must be no target in front of the sensor. 00812 * 00813 * @warning This function is a blocking function 00814 * 00815 * @warning This function is not supported when the final range 00816 * vcsel clock period is set below 10 PCLKS. 00817 * 00818 * @note This function Access to the device 00819 * 00820 * @param dev Device Handle 00821 * @param timeout_ms Histogram measurement duration. 00822 * @param p_xtalk_per_spad Output parameter containing the crosstalk 00823 * measurement result, in MCPS/Spad. 00824 * Format fixpoint 16:16. 00825 * @param p_ambient_too_high Output parameter which indicate that 00826 * pXtalkPerSpad is not good if the Ambient 00827 * is too high. 00828 * @return VL53L0X_ERROR_NONE Success 00829 * @return VL53L0X_ERROR_INVALID_PARAMS vcsel clock period not supported 00830 * for this operation. 00831 * Must not be less than 10PCLKS. 00832 * @return "Other error code" See ::VL53L0X_Error 00833 */ 00834 VL53L0X_Error VL53L0X_perform_xtalk_measurement(VL53L0X_DEV dev, 00835 uint32_t timeout_ms, FixPoint1616_t *p_xtalk_per_spad, 00836 uint8_t *p_ambient_too_high); 00837 00838 /** 00839 * @brief Enable/Disable Cross talk compensation feature 00840 * 00841 * @note This function is not Implemented. 00842 * Enable/Disable Cross Talk by set to zero the Cross Talk value 00843 * by using @a VL53L0X_SetXTalkCompensationRateMegaCps(). 00844 * 00845 * @param dev Device Handle 00846 * @param x_talk_compensation_enable Cross talk compensation 00847 * to be set 0=disabled else = enabled 00848 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented 00849 */ 00850 VL53L0X_Error VL53L0X_set_x_talk_compensation_enable(VL53L0X_DEV dev, 00851 uint8_t x_talk_compensation_enable); 00852 00853 /** 00854 * @brief Get Cross talk compensation rate 00855 * 00856 * @note This function is not Implemented. 00857 * Enable/Disable Cross Talk by set to zero the Cross Talk value by 00858 * using @a VL53L0X_SetXTalkCompensationRateMegaCps(). 00859 * 00860 * @param dev Device Handle 00861 * @param p_x_talk_compensation_enable Pointer to the Cross talk compensation 00862 * state 0=disabled or 1 = enabled 00863 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented 00864 */ 00865 VL53L0X_Error VL53L0X_get_x_talk_compensation_enable(VL53L0X_DEV dev, 00866 uint8_t *p_x_talk_compensation_enable); 00867 /** 00868 * @brief Set Cross talk compensation rate 00869 * 00870 * @par Function Description 00871 * Set Cross talk compensation rate. 00872 * 00873 * @note This function Access to the device 00874 * 00875 * @param dev Device Handle 00876 * @param x_talk_compensation_rate_mega_cps Compensation rate in 00877 * Mega counts per second 00878 * (16.16 fix point) see 00879 * datasheet for details 00880 * @return VL53L0X_ERROR_NONE Success 00881 * @return "Other error code" See ::VL53L0X_Error 00882 */ 00883 VL53L0X_Error VL53L0X_set_x_talk_compensation_rate_mega_cps(VL53L0X_DEV dev, 00884 FixPoint1616_t x_talk_compensation_rate_mega_cps); 00885 00886 /** 00887 * @brief Get Cross talk compensation rate 00888 * 00889 * @par Function Description 00890 * Get Cross talk compensation rate. 00891 * 00892 * @note This function Access to the device 00893 * 00894 * @param dev Device Handle 00895 * @param p_xtalk_compensation_rate_mega_cps Pointer to Compensation rate 00896 * in Mega counts per second 00897 * (16.16 fix point) see 00898 * datasheet for details 00899 * @return VL53L0X_ERROR_NONE Success 00900 * @return "Other error code" See ::VL53L0X_Error 00901 */ 00902 VL53L0X_Error VL53L0X_get_x_talk_compensation_rate_mega_cps(VL53L0X_DEV dev, 00903 FixPoint1616_t *p_xtalk_compensation_rate_mega_cps); 00904 00905 /** 00906 * @brief Set a new device mode 00907 * @par Function Description 00908 * Set device to a new mode (ranging, histogram ...) 00909 * 00910 * @note This function doesn't Access to the device 00911 * 00912 * @param dev Device Handle 00913 * @param device_mode New device mode to apply 00914 * Valid values are: 00915 * VL53L0X_DEVICEMODE_SINGLE_RANGING 00916 * VL53L0X_DEVICEMODE_CONTINUOUS_RANGING 00917 * VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING 00918 * VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM 00919 * VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY 00920 * VL53L0X_HISTOGRAMMODE_RETURN_ONLY 00921 * VL53L0X_HISTOGRAMMODE_BOTH 00922 * 00923 * 00924 * @return VL53L0X_ERROR_NONE Success 00925 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when 00926 * DeviceMode is not in the 00927 * supported list 00928 */ 00929 VL53L0X_Error VL53L0X_set_device_mode(VL53L0X_DEV dev, VL53L0X_DeviceModes device_mode); 00930 00931 /** 00932 * @brief Get current new device mode 00933 * @par Function Description 00934 * Get actual mode of the device(ranging, histogram ...) 00935 * 00936 * @note This function doesn't Access to the device 00937 * 00938 * @param dev Device Handle 00939 * @param p_device_mode Pointer to current apply mode value 00940 * Valid values are: 00941 * VL53L0X_DEVICEMODE_SINGLE_RANGING 00942 * VL53L0X_DEVICEMODE_CONTINUOUS_RANGING 00943 * VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING 00944 * VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM 00945 * VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY 00946 * VL53L0X_HISTOGRAMMODE_RETURN_ONLY 00947 * VL53L0X_HISTOGRAMMODE_BOTH 00948 * 00949 * @return VL53L0X_ERROR_NONE Success 00950 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when 00951 * DeviceMode is not in the 00952 * supported list 00953 */ 00954 VL53L0X_Error VL53L0X_get_device_mode(VL53L0X_DEV dev, 00955 VL53L0X_DeviceModes *p_device_mode); 00956 00957 /** 00958 * @brief Get current configuration for GPIO pin for a given device 00959 * 00960 * @note This function Access to the device 00961 * 00962 * @param dev Device Handle 00963 * @param pin ID of the GPIO Pin 00964 * @param p_device_mode Pointer to Device Mode associated to the Gpio. 00965 * @param p_functionality Pointer to Pin functionality. 00966 * Refer to ::VL53L0X_GpioFunctionality 00967 * @param p_polarity Pointer to interrupt polarity. 00968 * Active high or active low see 00969 * ::VL53L0X_InterruptPolarity 00970 * @return VL53L0X_ERROR_NONE Success 00971 * @return VL53L0X_ERROR_GPIO_NOT_EXISTING Only Pin=0 is accepted. 00972 * @return VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED 00973 * This error occurs 00974 * when Funcionality programmed is not in the supported list: 00975 * Supported value are: 00976 * VL53L0X_GPIOFUNCTIONALITY_OFF, 00977 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW, 00978 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH, 00979 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT, 00980 * VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY 00981 * @return "Other error code" See ::VL53L0X_Error 00982 */ 00983 VL53L0X_Error VL53L0X_get_gpio_config(VL53L0X_DEV dev, uint8_t pin, 00984 VL53L0X_DeviceModes *p_device_mode, 00985 VL53L0X_GpioFunctionality *p_functionality, 00986 VL53L0X_InterruptPolarity *p_polarity); 00987 00988 /** 00989 * @brief Set the configuration of GPIO pin for a given device 00990 * 00991 * @note This function Access to the device 00992 * 00993 * @param dev Device Handle 00994 * @param pin ID of the GPIO Pin 00995 * @param functionality Select Pin functionality. 00996 * Refer to ::VL53L0X_GpioFunctionality 00997 * @param device_mode Device Mode associated to the Gpio. 00998 * @param polarity Set interrupt polarity. Active high 00999 * or active low see ::VL53L0X_InterruptPolarity 01000 * @return VL53L0X_ERROR_NONE Success 01001 * @return VL53L0X_ERROR_GPIO_NOT_EXISTING Only Pin=0 is accepted. 01002 * @return VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED This error occurs 01003 * when Functionality programmed is not in the supported list: 01004 * Supported value are: 01005 * VL53L0X_GPIOFUNCTIONALITY_OFF, 01006 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW, 01007 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH, 01008 VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT, 01009 * VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY 01010 * @return "Other error code" See ::VL53L0X_Error 01011 */ 01012 VL53L0X_Error VL53L0X_set_gpio_config(VL53L0X_DEV dev, uint8_t pin, 01013 VL53L0X_DeviceModes device_mode, VL53L0X_GpioFunctionality functionality, 01014 VL53L0X_InterruptPolarity polarity); 01015 01016 /** 01017 * @brief Start device measurement 01018 * 01019 * @details Started measurement will depend on device parameters set through 01020 * @a VL53L0X_SetParameters() 01021 * This is a non-blocking function. 01022 * This function will change the VL53L0X_State from VL53L0X_STATE_IDLE to 01023 * VL53L0X_STATE_RUNNING. 01024 * 01025 * @note This function Access to the device 01026 * 01027 01028 * @param dev Device Handle 01029 * @return VL53L0X_ERROR_NONE Success 01030 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when 01031 * DeviceMode programmed with @a VL53L0X_SetDeviceMode is not in the supported 01032 * list: 01033 * Supported mode are: 01034 * VL53L0X_DEVICEMODE_SINGLE_RANGING, 01035 * VL53L0X_DEVICEMODE_CONTINUOUS_RANGING, 01036 * VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING 01037 * @return VL53L0X_ERROR_TIME_OUT Time out on start measurement 01038 * @return "Other error code" See ::VL53L0X_Error 01039 */ 01040 VL53L0X_Error VL53L0X_start_measurement(VL53L0X_DEV dev); 01041 01042 /** 01043 * @brief Stop device measurement 01044 * 01045 * @details Will set the device in standby mode at end of current measurement\n 01046 * Not necessary in single mode as device shall return automatically 01047 * in standby mode at end of measurement. 01048 * This function will change the VL53L0X_State from VL53L0X_STATE_RUNNING 01049 * to VL53L0X_STATE_IDLE. 01050 * 01051 * @note This function Access to the device 01052 * 01053 * @param dev Device Handle 01054 * @return VL53L0X_ERROR_NONE Success 01055 * @return "Other error code" See ::VL53L0X_Error 01056 */ 01057 VL53L0X_Error VL53L0X_stop_measurement(VL53L0X_DEV dev); 01058 01059 /** 01060 * @brief Return device stop completion status 01061 * 01062 * @par Function Description 01063 * Returns stop completiob status. 01064 * User shall call this function after a stop command 01065 * 01066 * @note This function Access to the device 01067 * 01068 * @param dev Device Handle 01069 * @param p_stop_status Pointer to status variable to update 01070 * @return VL53L0X_ERROR_NONE Success 01071 * @return "Other error code" See ::VL53L0X_Error 01072 */ 01073 VL53L0X_Error VL53L0X_get_stop_completed_status(VL53L0X_DEV dev, 01074 uint32_t *p_stop_status); 01075 01076 /** 01077 * @brief Return Measurement Data Ready 01078 * 01079 * @par Function Description 01080 * This function indicate that a measurement data is ready. 01081 * This function check if interrupt mode is used then check is done accordingly. 01082 * If perform function clear the interrupt, this function will not work, 01083 * like in case of @a VL53L0X_PerformSingleRangingMeasurement(). 01084 * The previous function is blocking function, VL53L0X_GetMeasurementDataReady 01085 * is used for non-blocking capture. 01086 * 01087 * @note This function Access to the device 01088 * 01089 * @param dev Device Handle 01090 * @param p_measurement_data_ready Pointer to Measurement Data Ready. 01091 * 0=data not ready, 1 = data ready 01092 * @return VL53L0X_ERROR_NONE Success 01093 * @return "Other error code" See ::VL53L0X_Error 01094 */ 01095 VL53L0X_Error VL53L0X_get_measurement_data_ready(VL53L0X_DEV dev, 01096 uint8_t *p_measurement_data_ready); 01097 01098 /** 01099 * @brief Retrieve the measurements from device for a given setup 01100 * 01101 * @par Function Description 01102 * Get data from last successful Ranging measurement 01103 * @warning USER should take care about @a VL53L0X_GetNumberOfROIZones() 01104 * before get data. 01105 * PAL will fill a NumberOfROIZones times the corresponding data 01106 * structure used in the measurement function. 01107 * 01108 * @note This function Access to the device 01109 * 01110 * @param dev Device Handle 01111 * @param p_ranging_measurement_data Pointer to the data structure to fill up. 01112 * @return VL53L0X_ERROR_NONE Success 01113 * @return "Other error code" See ::VL53L0X_Error 01114 */ 01115 VL53L0X_Error VL53L0X_get_ranging_measurement_data(VL53L0X_DEV dev, 01116 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data); 01117 01118 /** 01119 * @brief Clear given system interrupt condition 01120 * 01121 * @par Function Description 01122 * Clear given interrupt(s). 01123 * 01124 * @note This function Access to the device 01125 * 01126 * @param dev Device Handle 01127 * @param interrupt_mask Mask of interrupts to clear 01128 * @return VL53L0X_ERROR_NONE Success 01129 * @return VL53L0X_ERROR_INTERRUPT_NOT_CLEARED Cannot clear interrupts 01130 * 01131 * @return "Other error code" See ::VL53L0X_Error 01132 */ 01133 VL53L0X_Error VL53L0X_clear_interrupt_mask(VL53L0X_DEV dev, uint32_t interrupt_mask); 01134 01135 /** 01136 * @brief Return device interrupt status 01137 * 01138 * @par Function Description 01139 * Returns currently raised interrupts by the device. 01140 * User shall be able to activate/deactivate interrupts through 01141 * @a VL53L0X_SetGpioConfig() 01142 * 01143 * @note This function Access to the device 01144 * 01145 * @param dev Device Handle 01146 * @param p_interrupt_mask_status Pointer to status variable to update 01147 * @return VL53L0X_ERROR_NONE Success 01148 * @return "Other error code" See ::VL53L0X_Error 01149 */ 01150 VL53L0X_Error VL53L0X_get_interrupt_mask_status(VL53L0X_DEV dev, 01151 uint32_t *p_interrupt_mask_status); 01152 01153 /** 01154 * @brief Performs a single ranging measurement and retrieve the ranging 01155 * measurement data 01156 * 01157 * @par Function Description 01158 * This function will change the device mode to VL53L0X_DEVICEMODE_SINGLE_RANGING 01159 * with @a VL53L0X_SetDeviceMode(), 01160 * It performs measurement with @a VL53L0X_PerformSingleMeasurement() 01161 * It get data from last successful Ranging measurement with 01162 * @a VL53L0X_GetRangingMeasurementData. 01163 * Finally it clear the interrupt with @a VL53L0X_ClearInterruptMask(). 01164 * 01165 * @note This function Access to the device 01166 * 01167 * @note This function change the device mode to 01168 * VL53L0X_DEVICEMODE_SINGLE_RANGING 01169 * 01170 * @param dev Device Handle 01171 * @param p_ranging_measurement_data Pointer to the data structure to fill up. 01172 * @return VL53L0X_ERROR_NONE Success 01173 * @return "Other error code" See ::VL53L0X_Error 01174 */ 01175 VL53L0X_Error VL53L0X_perform_single_ranging_measurement(VL53L0X_DEV dev, 01176 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data); 01177 01178 /** 01179 * @brief Single shot measurement. 01180 * 01181 * @par Function Description 01182 * Perform simple measurement sequence (Start measure, Wait measure to end, 01183 * and returns when measurement is done). 01184 * Once function returns, user can get valid data by calling 01185 * VL53L0X_GetRangingMeasurement or VL53L0X_GetHistogramMeasurement 01186 * depending on defined measurement mode 01187 * User should Clear the interrupt in case this are enabled by using the 01188 * function VL53L0X_ClearInterruptMask(). 01189 * 01190 * @warning This function is a blocking function 01191 * 01192 * @note This function Access to the device 01193 * 01194 * @param dev Device Handle 01195 * @return VL53L0X_ERROR_NONE Success 01196 * @return "Other error code" See ::VL53L0X_Error 01197 */ 01198 VL53L0X_Error VL53L0X_perform_single_measurement(VL53L0X_DEV dev); 01199 01200 /** 01201 * @brief Read current status of the error register for the selected device 01202 * 01203 * @note This function Access to the device 01204 * 01205 * @param dev Device Handle 01206 * @param p_device_error_status Pointer to current error code of the device 01207 * @return VL53L0X_ERROR_NONE Success 01208 * @return "Other error code" See ::VL53L0X_Error 01209 */ 01210 VL53L0X_Error VL53L0X_get_device_error_status(VL53L0X_DEV dev, 01211 VL53L0X_DeviceError *p_device_error_status); 01212 01213 /** 01214 * @brief Human readable error string for a given Error Code 01215 * 01216 * @note This function doesn't access to the device 01217 * 01218 * @param error_code The error code as stored on ::VL53L0X_DeviceError 01219 * @param p_device_error_string The error string corresponding to the ErrorCode 01220 * @return VL53L0X_ERROR_NONE Success 01221 * @return "Other error code" See ::VL53L0X_Error 01222 */ 01223 VL53L0X_Error VL53L0X_get_device_error_string( 01224 VL53L0X_DeviceError error_code, char *p_device_error_string); 01225 01226 /** 01227 * @brief Human readable Range Status string for a given RangeStatus 01228 * 01229 * @note This function doesn't access to the device 01230 * 01231 * @param range_status The RangeStatus code as stored on 01232 * @a VL53L0X_RangingMeasurementData_t 01233 * @param p_range_status_string The returned RangeStatus string. 01234 * @return VL53L0X_ERROR_NONE Success 01235 * @return "Other error code" See ::VL53L0X_Error 01236 */ 01237 VL53L0X_Error VL53L0X_get_range_status_string(uint8_t range_status, 01238 char *p_range_status_string); 01239 01240 VL53L0X_Error VL53L0X_get_total_signal_rate(VL53L0X_DEV dev, 01241 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data, 01242 FixPoint1616_t *p_total_signal_rate_mcps); 01243 01244 VL53L0X_Error VL53L0X_get_total_xtalk_rate(VL53L0X_DEV dev, 01245 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data, 01246 FixPoint1616_t *p_total_xtalk_rate_mcps); 01247 01248 /** 01249 * @brief Get Ranging Timing Budget in microseconds 01250 * 01251 * @par Function Description 01252 * Returns the programmed the maximum time allowed by the user to the 01253 * device to run a full ranging sequence for the current mode 01254 * (ranging, histogram, ASL ...) 01255 * 01256 * @note This function Access to the device 01257 * 01258 * @param dev Device Handle 01259 * @param p_measurement_timing_budget_micro_seconds Max measurement time in 01260 * microseconds. 01261 * Valid values are: 01262 * >= 17000 microsecs when wraparound enabled 01263 * >= 12000 microsecs when wraparound disabled 01264 * @return VL53L0X_ERROR_NONE Success 01265 * @return "Other error code" See ::VL53L0X_Error 01266 */ 01267 VL53L0X_Error VL53L0X_get_measurement_timing_budget_micro_seconds(VL53L0X_DEV dev, 01268 uint32_t *p_measurement_timing_budget_micro_seconds); 01269 01270 /** 01271 * @brief Set Ranging Timing Budget in microseconds 01272 * 01273 * @par Function Description 01274 * Defines the maximum time allowed by the user to the device to run a 01275 * full ranging sequence for the current mode (ranging, histogram, ASL ...) 01276 * 01277 * @note This function Access to the device 01278 * 01279 * @param dev Device Handle 01280 * @param measurement_timing_budget_micro_seconds Max measurement time in 01281 * microseconds. 01282 * Valid values are: 01283 * >= 17000 microsecs when wraparound enabled 01284 * >= 12000 microsecs when wraparound disabled 01285 * @return VL53L0X_ERROR_NONE Success 01286 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned if 01287 MeasurementTimingBudgetMicroSeconds out of range 01288 * @return "Other error code" See ::VL53L0X_Error 01289 */ 01290 VL53L0X_Error VL53L0X_set_measurement_timing_budget_micro_seconds(VL53L0X_DEV dev, 01291 uint32_t measurement_timing_budget_micro_seconds); 01292 01293 /** 01294 * @brief Get specific limit check enable state 01295 * 01296 * @par Function Description 01297 * This function get the enable state of a specific limit check. 01298 * The limit check is identified with the LimitCheckId. 01299 * 01300 * @note This function Access to the device 01301 * 01302 * @param dev Device Handle 01303 * @param limit_check_id Limit Check ID 01304 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ). 01305 * @param p_limit_check_enable Pointer to the check limit enable 01306 * value. 01307 * if 1 the check limit 01308 * corresponding to LimitCheckId is Enabled 01309 * if 0 the check limit 01310 * corresponding to LimitCheckId is disabled 01311 * @return VL53L0X_ERROR_NONE Success 01312 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned 01313 * when LimitCheckId value is out of range. 01314 * @return "Other error code" See ::VL53L0X_Error 01315 */ 01316 VL53L0X_Error VL53L0X_get_limit_check_enable(VL53L0X_DEV dev, uint16_t limit_check_id, 01317 uint8_t *p_limit_check_enable); 01318 01319 /** 01320 * @brief Enable/Disable a specific limit check 01321 * 01322 * @par Function Description 01323 * This function Enable/Disable a specific limit check. 01324 * The limit check is identified with the LimitCheckId. 01325 * 01326 * @note This function doesn't Access to the device 01327 * 01328 * @param dev Device Handle 01329 * @param limit_check_id Limit Check ID 01330 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ). 01331 * @param limit_check_enable if 1 the check limit 01332 * corresponding to LimitCheckId is Enabled 01333 * if 0 the check limit 01334 * corresponding to LimitCheckId is disabled 01335 * @return VL53L0X_ERROR_NONE Success 01336 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned 01337 * when LimitCheckId value is out of range. 01338 * @return "Other error code" See ::VL53L0X_Error 01339 */ 01340 VL53L0X_Error VL53L0X_set_limit_check_enable(VL53L0X_DEV dev, uint16_t limit_check_id, 01341 uint8_t limit_check_enable); 01342 01343 /** 01344 * @brief Get a specific limit check value 01345 * 01346 * @par Function Description 01347 * This function get a specific limit check value from device then it updates 01348 * internal values and check enables. 01349 * The limit check is identified with the LimitCheckId. 01350 * 01351 * @note This function Access to the device 01352 * 01353 * @param dev Device Handle 01354 * @param limit_check_id Limit Check ID 01355 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ). 01356 * @param p_limit_check_value Pointer to Limit 01357 * check Value for a given LimitCheckId. 01358 * @return VL53L0X_ERROR_NONE Success 01359 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned 01360 * when LimitCheckId value is out of range. 01361 * @return "Other error code" See ::VL53L0X_Error 01362 */ 01363 VL53L0X_Error VL53L0X_get_limit_check_value(VL53L0X_DEV dev, uint16_t limit_check_id, 01364 FixPoint1616_t *p_limit_check_value); 01365 01366 /** 01367 * @brief Set a specific limit check value 01368 * 01369 * @par Function Description 01370 * This function set a specific limit check value. 01371 * The limit check is identified with the LimitCheckId. 01372 * 01373 * @note This function Access to the device 01374 * 01375 * @param dev Device Handle 01376 * @param limit_check_id Limit Check ID 01377 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ). 01378 * @param limit_check_value Limit check Value for a given 01379 * LimitCheckId 01380 * @return VL53L0X_ERROR_NONE Success 01381 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned when either 01382 * LimitCheckId or LimitCheckValue value is out of range. 01383 * @return "Other error code" See ::VL53L0X_Error 01384 */ 01385 VL53L0X_Error VL53L0X_set_limit_check_value(VL53L0X_DEV dev, uint16_t limit_check_id, 01386 FixPoint1616_t limit_check_value); 01387 01388 /** 01389 * @brief Get the current value of the signal used for the limit check 01390 * 01391 * @par Function Description 01392 * This function get a the current value of the signal used for the limit check. 01393 * To obtain the latest value you should run a ranging before. 01394 * The value reported is linked to the limit check identified with the 01395 * LimitCheckId. 01396 * 01397 * @note This function Access to the device 01398 * 01399 * @param dev Device Handle 01400 * @param limit_check_id Limit Check ID 01401 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ). 01402 * @param p_limit_check_current Pointer to current Value for a 01403 * given LimitCheckId. 01404 * @return VL53L0X_ERROR_NONE Success 01405 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned when 01406 * LimitCheckId value is out of range. 01407 * @return "Other error code" See ::VL53L0X_Error 01408 */ 01409 VL53L0X_Error VL53L0X_get_limit_check_current(VL53L0X_DEV dev, uint16_t limit_check_id, 01410 FixPoint1616_t *p_limit_check_current); 01411 01412 /** 01413 * @brief Return a the Status of the specified check limit 01414 * 01415 * @par Function Description 01416 * This function returns the Status of the specified check limit. 01417 * The value indicate if the check is fail or not. 01418 * The limit check is identified with the LimitCheckId. 01419 * 01420 * @note This function doesn't Access to the device 01421 * 01422 * @param dev Device Handle 01423 * @param limit_check_id Limit Check ID 01424 (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ). 01425 * @param p_limit_check_status Pointer to the 01426 Limit Check Status of the given check limit. 01427 * LimitCheckStatus : 01428 * 0 the check is not fail 01429 * 1 the check if fail or not enabled 01430 * 01431 * @return VL53L0X_ERROR_NONE Success 01432 * @return VL53L0X_ERROR_INVALID_PARAMS This error is 01433 returned when LimitCheckId value is out of range. 01434 * @return "Other error code" See ::VL53L0X_Error 01435 */ 01436 VL53L0X_Error VL53L0X_get_limit_check_status(VL53L0X_DEV dev, 01437 uint16_t limit_check_id, uint8_t *p_limit_check_status); 01438 01439 /** 01440 * Get continuous mode Inter-Measurement period in milliseconds 01441 * 01442 * @par Function Description 01443 * When trying to set too short time return INVALID_PARAMS minimal value 01444 * 01445 * @note This function Access to the device 01446 * 01447 * @param dev Device Handle 01448 * @param p_inter_measurement_period_milli_seconds Pointer to programmed 01449 * Inter-Measurement Period in milliseconds. 01450 * @return VL53L0X_ERROR_NONE Success 01451 * @return "Other error code" See ::VL53L0X_Error 01452 */ 01453 VL53L0X_Error VL53L0X_get_inter_measurement_period_milli_seconds(VL53L0X_DEV dev, 01454 uint32_t *p_inter_measurement_period_milli_seconds); 01455 01456 /** 01457 * Program continuous mode Inter-Measurement period in milliseconds 01458 * 01459 * @par Function Description 01460 * When trying to set too short time return INVALID_PARAMS minimal value 01461 * 01462 * @note This function Access to the device 01463 * 01464 * @param dev Device Handle 01465 * @param inter_measurement_period_milli_seconds Inter-Measurement Period in ms. 01466 * @return VL53L0X_ERROR_NONE Success 01467 * @return "Other error code" See ::VL53L0X_Error 01468 */ 01469 VL53L0X_Error VL53L0X_set_inter_measurement_period_milli_seconds( 01470 VL53L0X_DEV dev, uint32_t inter_measurement_period_milli_seconds); 01471 01472 /** 01473 * @brief Set new device address 01474 * 01475 * After completion the device will answer to the new address programmed. 01476 * This function should be called when several devices are used in parallel 01477 * before start programming the sensor. 01478 * When a single device us used, there is no need to call this function. 01479 * 01480 * @note This function Access to the device 01481 * 01482 * @param dev Device Handle 01483 * @param device_address The new Device address 01484 * @return VL53L0X_ERROR_NONE Success 01485 * @return "Other error code" See ::VL53L0X_Error 01486 */ 01487 VL53L0X_Error VL53L0X_set_device_address(VL53L0X_DEV dev, uint8_t device_address); 01488 01489 /** 01490 * @brief Do an hard reset or soft reset (depending on implementation) of the 01491 * device \nAfter call of this function, device must be in same state as right 01492 * after a power-up sequence.This function will change the VL53L0X_State to 01493 * VL53L0X_STATE_POWERDOWN. 01494 * 01495 * @note This function Access to the device 01496 * 01497 * @param dev Device Handle 01498 * @return VL53L0X_ERROR_NONE Success 01499 * @return "Other error code" See ::VL53L0X_Error 01500 */ 01501 VL53L0X_Error VL53L0X_reset_device(VL53L0X_DEV dev); 01502 01503 /** 01504 * @brief Get setup of Wrap around Check 01505 * 01506 * @par Function Description 01507 * This function get the wrapAround check enable parameters 01508 * 01509 * @note This function Access to the device 01510 * 01511 * @param dev Device Handle 01512 * @param p_wrap_around_check_enable Pointer to the Wrap around Check state 01513 * 0=disabled or 1 = enabled 01514 * @return VL53L0X_ERROR_NONE Success 01515 * @return "Other error code" See ::VL53L0X_Error 01516 */ 01517 VL53L0X_Error VL53L0X_get_wrap_around_check_enable(VL53L0X_DEV dev, 01518 uint8_t *p_wrap_around_check_enable); 01519 01520 /** 01521 * @brief Enable (or disable) Wrap around Check 01522 * 01523 * @note This function Access to the device 01524 * 01525 * @param dev Device Handle 01526 * @param wrap_around_check_enable Wrap around Check to be set 01527 * 0=disabled, other = enabled 01528 * @return VL53L0X_ERROR_NONE Success 01529 * @return "Other error code" See ::VL53L0X_Error 01530 */ 01531 VL53L0X_Error VL53L0X_set_wrap_around_check_enable(VL53L0X_DEV dev, 01532 uint8_t wrap_around_check_enable); 01533 01534 /** 01535 * @brief Gets the VCSEL pulse period. 01536 * 01537 * @par Function Description 01538 * This function retrieves the VCSEL pulse period for the given period type. 01539 * 01540 * @note This function Accesses the device 01541 * 01542 * @param dev Device Handle 01543 * @param vcsel_period_type VCSEL period identifier (pre-range|final). 01544 * @param p_vcsel_pulse_period_pclk Pointer to VCSEL period value. 01545 * @return VL53L0X_ERROR_NONE Success 01546 * @return VL53L0X_ERROR_INVALID_PARAMS Error VcselPeriodType parameter not 01547 * supported. 01548 * @return "Other error code" See ::VL53L0X_Error 01549 */ 01550 VL53L0X_Error VL53L0X_get_vcsel_pulse_period(VL53L0X_DEV dev, 01551 VL53L0X_VcselPeriod vcsel_period_type, uint8_t *p_vcsel_pulse_period_pclk); 01552 01553 /** 01554 * @brief Sets the VCSEL pulse period. 01555 * 01556 * @par Function Description 01557 * This function retrieves the VCSEL pulse period for the given period type. 01558 * 01559 * @note This function Accesses the device 01560 * 01561 * @param dev Device Handle 01562 * @param vcsel_period_type VCSEL period identifier (pre-range|final). 01563 * @param vcsel_pulse_period VCSEL period value 01564 * @return VL53L0X_ERROR_NONE Success 01565 * @return VL53L0X_ERROR_INVALID_PARAMS Error VcselPeriodType parameter not 01566 * supported. 01567 * @return "Other error code" See ::VL53L0X_Error 01568 */ 01569 VL53L0X_Error VL53L0X_set_vcsel_pulse_period(VL53L0X_DEV dev, 01570 VL53L0X_VcselPeriod vcsel_period_type, uint8_t vcsel_pulse_period); 01571 01572 /** 01573 * @brief Set low and high Interrupt thresholds for a given mode 01574 * (ranging, ALS, ...) for a given device 01575 * 01576 * @par Function Description 01577 * Set low and high Interrupt thresholds for a given mode (ranging, ALS, ...) 01578 * for a given device 01579 * 01580 * @note This function Access to the device 01581 * 01582 * @note DeviceMode is ignored for the current device 01583 * 01584 * @param dev Device Handle 01585 * @param device_mode Device Mode for which change thresholds 01586 * @param threshold_low Low threshold (mm, lux ..., depending on the mode) 01587 * @param threshold_high High threshold (mm, lux ..., depending on the mode) 01588 * @return VL53L0X_ERROR_NONE Success 01589 * @return "Other error code" See ::VL53L0X_Error 01590 */ 01591 VL53L0X_Error VL53L0X_set_interrupt_thresholds(VL53L0X_DEV dev, 01592 VL53L0X_DeviceModes device_mode, FixPoint1616_t threshold_low, 01593 FixPoint1616_t threshold_high); 01594 01595 /** 01596 * @brief Get high and low Interrupt thresholds for a given mode 01597 * (ranging, ALS, ...) for a given device 01598 * 01599 * @par Function Description 01600 * Get high and low Interrupt thresholds for a given mode (ranging, ALS, ...) 01601 * for a given device 01602 * 01603 * @note This function Access to the device 01604 * 01605 * @note DeviceMode is ignored for the current device 01606 * 01607 * @param dev Device Handle 01608 * @param device_mode Device Mode from which read thresholds 01609 * @param p_threshold_low Low threshold (mm, lux ..., depending on the mode) 01610 * @param p_threshold_high High threshold (mm, lux ..., depending on the mode) 01611 * @return VL53L0X_ERROR_NONE Success 01612 * @return "Other error code" See ::VL53L0X_Error 01613 */ 01614 VL53L0X_Error VL53L0X_get_interrupt_thresholds(VL53L0X_DEV dev, 01615 VL53L0X_DeviceModes device_mode, FixPoint1616_t *p_threshold_low, 01616 FixPoint1616_t *p_threshold_high); 01617 01618 /** 01619 * @brief Reads the Device information for given Device 01620 * 01621 * @note This function Access to the device 01622 * 01623 * @param dev Device Handle 01624 * @param p_VL53L0X_device_info Pointer to current device info for a given 01625 * Device 01626 * @return VL53L0X_ERROR_NONE Success 01627 * @return "Other error code" See ::VL53L0X_Error 01628 */ 01629 VL53L0X_Error VL53L0X_get_device_info(VL53L0X_DEV dev, 01630 VL53L0X_DeviceInfo_t *p_VL53L0X_device_info); 01631 01632 /** 01633 * @brief Gets the (on/off) state of all sequence steps. 01634 * 01635 * @par Function Description 01636 * This function retrieves the state of all sequence step in the scheduler. 01637 * 01638 * @note This function Accesses the device 01639 * 01640 * @param dev Device Handle 01641 * @param p_scheduler_sequence_steps Pointer to struct containing result. 01642 * @return VL53L0X_ERROR_NONE Success 01643 * @return "Other error code" See ::VL53L0X_Error 01644 */ 01645 VL53L0X_Error VL53L0X_get_sequence_step_enables(VL53L0X_DEV dev, 01646 VL53L0X_SchedulerSequenceSteps_t *p_scheduler_sequence_steps); 01647 01648 /** 01649 * @brief Sets the (on/off) state of a requested sequence step. 01650 * 01651 * @par Function Description 01652 * This function enables/disables a requested sequence step. 01653 * 01654 * @note This function Accesses the device 01655 * 01656 * @param dev Device Handle 01657 * @param sequence_step_id Sequence step identifier. 01658 * @param sequence_step_enabled Demanded state {0=Off,1=On} 01659 * is enabled. 01660 * @return VL53L0X_ERROR_NONE Success 01661 * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not 01662 * supported. 01663 * @return "Other error code" See ::VL53L0X_Error 01664 */ 01665 VL53L0X_Error VL53L0X_set_sequence_step_enable(VL53L0X_DEV dev, 01666 VL53L0X_SequenceStepId sequence_step_id, uint8_t sequence_step_enabled); 01667 01668 /** 01669 * @brief Gets the fraction enable parameter indicating the resolution of 01670 * range measurements. 01671 * 01672 * @par Function Description 01673 * Gets the fraction enable state, which translates to the resolution of 01674 * range measurements as follows :Enabled:=0.25mm resolution, 01675 * Not Enabled:=1mm resolution. 01676 * 01677 * @note This function Accesses the device 01678 * 01679 * @param dev Device Handle 01680 * @param p_enabled Output Parameter reporting the fraction enable state. 01681 * 01682 * @return VL53L0X_ERROR_NONE Success 01683 * @return "Other error code" See ::VL53L0X_Error 01684 */ 01685 VL53L0X_Error VL53L0X_get_fraction_enable(VL53L0X_DEV dev, uint8_t *p_enabled); 01686 01687 /** 01688 * @brief Sets the resolution of range measurements. 01689 * @par Function Description 01690 * Set resolution of range measurements to either 0.25mm if 01691 * fraction enabled or 1mm if not enabled. 01692 * 01693 * @note This function Accesses the device 01694 * 01695 * @param dev Device Handle 01696 * @param enable Enable high resolution 01697 * 01698 * @return VL53L0X_ERROR_NONE Success 01699 * @return "Other error code" See ::VL53L0X_Error 01700 */ 01701 VL53L0X_Error VL53L0X_set_range_fraction_enable(VL53L0X_DEV dev, 01702 uint8_t enable); 01703 01704 /** 01705 * @brief Return the VL53L0X PAL Implementation Version 01706 * 01707 * @note This function doesn't access to the device 01708 * 01709 * @param p_version Pointer to current PAL Implementation Version 01710 * @return VL53L0X_ERROR_NONE Success 01711 * @return "Other error code" See ::VL53L0X_Error 01712 */ 01713 VL53L0X_Error VL53L0X_get_version(VL53L0X_Version_t *p_version); 01714 01715 /** 01716 * @brief Reads the Product Revision for a for given Device 01717 * This function can be used to distinguish cut1.0 from cut1.1. 01718 * 01719 * @note This function Access to the device 01720 * 01721 * @param dev Device Handle 01722 * @param p_product_revision_major Pointer to Product Revision Major 01723 * for a given Device 01724 * @param p_product_revision_minor Pointer to Product Revision Minor 01725 * for a given Device 01726 * @return VL53L0X_ERROR_NONE Success 01727 * @return "Other error code" See ::VL53L0X_Error 01728 */ 01729 VL53L0X_Error VL53L0X_get_product_revision(VL53L0X_DEV dev, 01730 uint8_t *p_product_revision_major, uint8_t *p_product_revision_minor); 01731 01732 /** 01733 * @brief Retrieve current device parameters 01734 * @par Function Description 01735 * Get actual parameters of the device 01736 * @li Then start ranging operation. 01737 * 01738 * @note This function Access to the device 01739 * 01740 * @param dev Device Handle 01741 * @param p_device_parameters Pointer to store current device parameters. 01742 * @return VL53L0X_ERROR_NONE Success 01743 * @return "Other error code" See ::VL53L0X_Error 01744 */ 01745 VL53L0X_Error VL53L0X_get_device_parameters(VL53L0X_DEV dev, 01746 VL53L0X_DeviceParameters_t *p_device_parameters); 01747 01748 /** 01749 * @brief Human readable error string for current PAL error status 01750 * 01751 * @note This function doesn't access to the device 01752 * 01753 * @param pal_error_code The error code as stored on @a VL53L0X_Error 01754 * @param p_pal_error_string The error string corresponding to the 01755 * PalErrorCode 01756 * @return VL53L0X_ERROR_NONE Success 01757 * @return "Other error code" See ::VL53L0X_Error 01758 */ 01759 VL53L0X_Error VL53L0X_get_pal_error_string(VL53L0X_Error pal_error_code, 01760 char *p_pal_error_string); 01761 01762 /** 01763 * @brief Return the PAL Specification Version used for the current 01764 * implementation. 01765 * 01766 * @note This function doesn't access to the device 01767 * 01768 * @param p_pal_spec_version Pointer to current PAL Specification Version 01769 * @return VL53L0X_ERROR_NONE Success 01770 * @return "Other error code" See ::VL53L0X_Error 01771 */ 01772 VL53L0X_Error VL53L0X_get_pal_spec_version( 01773 VL53L0X_Version_t *p_pal_spec_version); 01774 01775 /** 01776 * @brief Reads the internal state of the PAL for a given Device 01777 * 01778 * @note This function doesn't access to the device 01779 * 01780 * @param dev Device Handle 01781 * @param p_pal_state Pointer to current state of the PAL for a 01782 * given Device 01783 * @return VL53L0X_ERROR_NONE Success 01784 * @return "Other error code" See ::VL53L0X_Error 01785 */ 01786 VL53L0X_Error VL53L0X_get_pal_state(VL53L0X_DEV dev, 01787 VL53L0X_State *p_pal_state); 01788 01789 /** 01790 * @brief Human readable PAL State string 01791 * 01792 * @note This function doesn't access to the device 01793 * 01794 * @param pal_state_code The State code as stored on @a VL53L0X_State 01795 * @param p_pal_state_string The State string corresponding to the 01796 * PalStateCode 01797 * @return VL53L0X_ERROR_NONE Success 01798 * @return "Other error code" See ::VL53L0X_Error 01799 */ 01800 VL53L0X_Error VL53L0X_get_pal_state_string(VL53L0X_State pal_state_code, 01801 char *p_pal_state_string); 01802 01803 /*** End High level API ***/ 01804 private: 01805 /* api.h functions */ 01806 01807 /** 01808 * @brief Wait for device booted after chip enable (hardware standby) 01809 * This function can be run only when VL53L0X_State is VL53L0X_STATE_POWERDOWN. 01810 * 01811 * @note This function is not Implemented 01812 * 01813 * @param dev Device Handle 01814 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented 01815 * 01816 */ 01817 VL53L0X_Error VL53L0X_wait_device_booted(VL53L0X_DEV dev); 01818 01819 01820 VL53L0X_Error sequence_step_enabled(VL53L0X_DEV dev, 01821 VL53L0X_SequenceStepId sequence_step_id, uint8_t sequence_config, 01822 uint8_t *p_sequence_step_enabled); 01823 01824 VL53L0X_Error VL53L0X_check_and_load_interrupt_settings(VL53L0X_DEV dev, 01825 uint8_t start_not_stopflag); 01826 01827 01828 /* api_core.h functions */ 01829 01830 VL53L0X_Error VL53L0X_get_info_from_device(VL53L0X_DEV dev, uint8_t option); 01831 01832 VL53L0X_Error VL53L0X_device_read_strobe(VL53L0X_DEV dev); 01833 01834 VL53L0X_Error wrapped_VL53L0X_get_measurement_timing_budget_micro_seconds(VL53L0X_DEV dev, 01835 uint32_t *p_measurement_timing_budget_micro_seconds); 01836 01837 VL53L0X_Error wrapped_VL53L0X_get_vcsel_pulse_period(VL53L0X_DEV dev, 01838 VL53L0X_VcselPeriod vcsel_period_type, uint8_t *p_vcsel_pulse_period_pclk); 01839 01840 uint8_t VL53L0X_decode_vcsel_period(uint8_t vcsel_period_reg); 01841 01842 uint32_t VL53L0X_decode_timeout(uint16_t encoded_timeout); 01843 01844 uint32_t VL53L0X_calc_timeout_us(VL53L0X_DEV dev, 01845 uint16_t timeout_period_mclks, 01846 uint8_t vcsel_period_pclks); 01847 01848 uint32_t VL53L0X_calc_macro_period_ps(VL53L0X_DEV dev, uint8_t vcsel_period_pclks); 01849 01850 VL53L0X_Error VL53L0X_measurement_poll_for_completion(VL53L0X_DEV dev); 01851 01852 VL53L0X_Error VL53L0X_load_tuning_settings(VL53L0X_DEV dev, 01853 uint8_t *p_tuning_setting_buffer); 01854 01855 VL53L0X_Error VL53L0X_get_pal_range_status(VL53L0X_DEV dev, 01856 uint8_t device_range_status, 01857 FixPoint1616_t signal_rate, 01858 uint16_t effective_spad_rtn_count, 01859 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data, 01860 uint8_t *p_pal_range_status); 01861 VL53L0X_Error VL53L0X_calc_sigma_estimate(VL53L0X_DEV dev, 01862 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data, 01863 FixPoint1616_t *p_sigma_estimate, 01864 uint32_t *p_dmax_mm); 01865 uint32_t VL53L0X_calc_timeout_mclks(VL53L0X_DEV dev, 01866 uint32_t timeout_period_us, 01867 uint8_t vcsel_period_pclks); 01868 uint32_t VL53L0X_isqrt(uint32_t num); 01869 01870 uint32_t VL53L0X_quadrature_sum(uint32_t a, uint32_t b); 01871 01872 VL53L0X_Error VL53L0X_calc_dmax( 01873 VL53L0X_DEV dev, 01874 FixPoint1616_t total_signal_rate_mcps, 01875 FixPoint1616_t total_corr_signal_rate_mcps, 01876 FixPoint1616_t pw_mult, 01877 uint32_t sigma_estimate_p1, 01878 FixPoint1616_t sigma_estimate_p2, 01879 uint32_t peak_vcsel_duration_us, 01880 uint32_t *pd_max_mm); 01881 VL53L0X_Error wrapped_VL53L0X_set_measurement_timing_budget_micro_seconds(VL53L0X_DEV dev, 01882 uint32_t measurement_timing_budget_micro_seconds); 01883 VL53L0X_Error get_sequence_step_timeout(VL53L0X_DEV dev, 01884 VL53L0X_SequenceStepId sequence_step_id, 01885 uint32_t *p_time_out_micro_secs); 01886 VL53L0X_Error set_sequence_step_timeout(VL53L0X_DEV dev, 01887 VL53L0X_SequenceStepId sequence_step_id, 01888 uint32_t timeout_micro_secs); 01889 uint16_t VL53L0X_encode_timeout(uint32_t timeout_macro_clks); 01890 VL53L0X_Error wrapped_VL53L0X_set_vcsel_pulse_period(VL53L0X_DEV dev, 01891 VL53L0X_VcselPeriod vcsel_period_type, uint8_t vcsel_pulse_period_pclk); 01892 uint8_t lv53l0x_encode_vcsel_period(uint8_t vcsel_period_pclks); 01893 01894 /* api_calibration.h functions */ 01895 VL53L0X_Error VL53L0X_apply_offset_adjustment(VL53L0X_DEV dev); 01896 VL53L0X_Error wrapped_VL53L0X_get_offset_calibration_data_micro_meter(VL53L0X_DEV dev, 01897 int32_t *p_offset_calibration_data_micro_meter); 01898 VL53L0X_Error wrapped_VL53L0X_set_offset_calibration_data_micro_meter(VL53L0X_DEV dev, 01899 int32_t offset_calibration_data_micro_meter); 01900 VL53L0X_Error wrapped_VL53L0X_perform_ref_spad_management(VL53L0X_DEV dev, 01901 uint32_t *ref_spad_count, 01902 uint8_t *is_aperture_spads); 01903 VL53L0X_Error VL53L0X_perform_ref_calibration(VL53L0X_DEV dev, 01904 uint8_t *p_vhv_settings, uint8_t *p_phase_cal, uint8_t get_data_enable); 01905 VL53L0X_Error VL53L0X_perform_vhv_calibration(VL53L0X_DEV dev, 01906 uint8_t *p_vhv_settings, const uint8_t get_data_enable, 01907 const uint8_t restore_config); 01908 VL53L0X_Error VL53L0X_perform_single_ref_calibration(VL53L0X_DEV dev, 01909 uint8_t vhv_init_byte); 01910 VL53L0X_Error VL53L0X_ref_calibration_io(VL53L0X_DEV dev, uint8_t read_not_write, 01911 uint8_t vhv_settings, uint8_t phase_cal, 01912 uint8_t *p_vhv_settings, uint8_t *p_phase_cal, 01913 const uint8_t vhv_enable, const uint8_t phase_enable); 01914 VL53L0X_Error VL53L0X_perform_phase_calibration(VL53L0X_DEV dev, 01915 uint8_t *p_phase_cal, const uint8_t get_data_enable, 01916 const uint8_t restore_config); 01917 VL53L0X_Error enable_ref_spads(VL53L0X_DEV dev, 01918 uint8_t aperture_spads, 01919 uint8_t good_spad_array[], 01920 uint8_t spad_array[], 01921 uint32_t size, 01922 uint32_t start, 01923 uint32_t offset, 01924 uint32_t spad_count, 01925 uint32_t *p_last_spad); 01926 void get_next_good_spad(uint8_t good_spad_array[], uint32_t size, 01927 uint32_t curr, int32_t *p_next); 01928 uint8_t is_aperture(uint32_t spad_index); 01929 VL53L0X_Error enable_spad_bit(uint8_t spad_array[], uint32_t size, 01930 uint32_t spad_index); 01931 VL53L0X_Error set_ref_spad_map(VL53L0X_DEV dev, uint8_t *p_ref_spad_array); 01932 VL53L0X_Error get_ref_spad_map(VL53L0X_DEV dev, uint8_t *p_ref_spad_array); 01933 VL53L0X_Error perform_ref_signal_measurement(VL53L0X_DEV dev, 01934 uint16_t *p_ref_signal_rate); 01935 VL53L0X_Error wrapped_VL53L0X_set_reference_spads(VL53L0X_DEV dev, 01936 uint32_t count, uint8_t is_aperture_spads); 01937 01938 /* api_strings.h functions */ 01939 VL53L0X_Error wrapped_VL53L0X_get_device_info(VL53L0X_DEV dev, 01940 VL53L0X_DeviceInfo_t *p_VL53L0X_device_info); 01941 VL53L0X_Error VL53L0X_check_part_used(VL53L0X_DEV dev, 01942 uint8_t *revision, 01943 VL53L0X_DeviceInfo_t *p_VL53L0X_device_info); 01944 01945 /* Read function of the ID device */ 01946 // virtual int read_id(); 01947 virtual int read_id(uint8_t *id); 01948 01949 VL53L0X_Error wait_measurement_data_ready(VL53L0X_DEV dev); 01950 01951 VL53L0X_Error wait_stop_completed(VL53L0X_DEV dev); 01952 01953 /* Write and read functions from I2C */ 01954 /** 01955 * Write single byte register 01956 * @param dev Device Handle 01957 * @param index The register index 01958 * @param data 8 bit register data 01959 * @return VL53L0X_ERROR_NONE Success 01960 * @return "Other error code" See ::VL53L0X_Error 01961 */ 01962 VL53L0X_Error VL53L0X_write_byte(VL53L0X_DEV dev, uint8_t index, uint8_t data); 01963 /** 01964 * Write word register 01965 * @param dev Device Handle 01966 * @param index The register index 01967 * @param data 16 bit register data 01968 * @return VL53L0X_ERROR_NONE Success 01969 * @return "Other error code" See ::VL53L0X_Error 01970 */ 01971 VL53L0X_Error VL53L0X_write_word(VL53L0X_DEV dev, uint8_t index, uint16_t data); 01972 /** 01973 * Write double word (4 byte) register 01974 * @param dev Device Handle 01975 * @param index The register index 01976 * @param data 32 bit register data 01977 * @return VL53L0X_ERROR_NONE Success 01978 * @return "Other error code" See ::VL53L0X_Error 01979 */ 01980 VL53L0X_Error VL53L0X_write_dword(VL53L0X_DEV dev, uint8_t index, uint32_t data); 01981 /** 01982 * Read single byte register 01983 * @param dev Device Handle 01984 * @param index The register index 01985 * @param data pointer to 8 bit data 01986 * @return VL53L0X_ERROR_NONE Success 01987 * @return "Other error code" See ::VL53L0X_Error 01988 */ 01989 VL53L0X_Error VL53L0X_read_byte(VL53L0X_DEV dev, uint8_t index, uint8_t *p_data); 01990 /** 01991 * Read word (2byte) register 01992 * @param dev Device Handle 01993 * @param index The register index 01994 * @param data pointer to 16 bit data 01995 * @return VL53L0X_ERROR_NONE Success 01996 * @return "Other error code" See ::VL53L0X_Error 01997 */ 01998 VL53L0X_Error VL53L0X_read_word(VL53L0X_DEV dev, uint8_t index, uint16_t *p_data); 01999 /** 02000 * Read dword (4byte) register 02001 * @param dev Device Handle 02002 * @param index The register index 02003 * @param data pointer to 32 bit data 02004 * @return VL53L0X_ERROR_NONE Success 02005 * @return "Other error code" See ::VL53L0X_Error 02006 */ 02007 VL53L0X_Error VL53L0X_read_dword(VL53L0X_DEV dev, uint8_t index, uint32_t *p_data); 02008 /** 02009 * Threat safe Update (read/modify/write) single byte register 02010 * 02011 * Final_reg = (Initial_reg & and_data) |or_data 02012 * 02013 * @param dev Device Handle 02014 * @param index The register index 02015 * @param and_data 8 bit and data 02016 * @param or_data 8 bit or data 02017 * @return VL53L0X_ERROR_NONE Success 02018 * @return "Other error code" See ::VL53L0X_Error 02019 */ 02020 VL53L0X_Error VL53L0X_update_byte(VL53L0X_DEV dev, uint8_t index, uint8_t and_data, uint8_t or_data); 02021 /** 02022 * Writes the supplied byte buffer to the device 02023 * @param dev Device Handle 02024 * @param index The register index 02025 * @param p_data Pointer to uint8_t buffer containing the data to be written 02026 * @param count Number of bytes in the supplied byte buffer 02027 * @return VL53L0X_ERROR_NONE Success 02028 * @return "Other error code" See ::VL53L0X_Error 02029 */ 02030 VL53L0X_Error VL53L0X_write_multi(VL53L0X_DEV dev, uint8_t index, uint8_t *p_data, uint32_t count); 02031 /** 02032 * Reads the requested number of bytes from the device 02033 * @param dev Device Handle 02034 * @param index The register index 02035 * @param p_data Pointer to the uint8_t buffer to store read data 02036 * @param count Number of uint8_t's to read 02037 * @return VL53L0X_ERROR_NONE Success 02038 * @return "Other error code" See ::VL53L0X_Error 02039 */ 02040 VL53L0X_Error VL53L0X_read_multi(VL53L0X_DEV dev, uint8_t index, uint8_t *p_data, uint32_t count); 02041 02042 /** 02043 * @brief Writes a buffer towards the I2C peripheral device. 02044 * @param dev Device Handle 02045 * @param p_data pointer to the byte-array data to send 02046 * @param number_of_bytes number of bytes to be written. 02047 * @retval 0 if ok, 02048 * @retval -1 if an I2C error has occured 02049 * @note On some devices if NumByteToWrite is greater 02050 * than one, the RegisterAddr must be masked correctly! 02051 */ 02052 VL53L0X_Error VL53L0X_i2c_write(uint8_t dev, uint8_t index, uint8_t *p_data, uint16_t number_of_bytes); 02053 02054 /** 02055 * @brief Reads a buffer from the I2C peripheral device. 02056 * @param dev Device Handle 02057 * @param p_data pointer to the byte-array to read data in to 02058 * @param number_of_bytes number of bytes to be read. 02059 * @retval 0 if ok, 02060 * @retval -1 if an I2C error has occured 02061 * @note On some devices if NumByteToWrite is greater 02062 * than one, the RegisterAddr must be masked correctly! 02063 */ 02064 VL53L0X_Error VL53L0X_i2c_read(uint8_t dev, uint8_t index, uint8_t *p_data, uint16_t number_of_bytes); 02065 02066 /** 02067 * @brief execute delay in all polling API call 02068 * 02069 * A typical multi-thread or RTOs implementation is to sleep the task for some 5ms (with 100Hz max rate faster polling is not needed) 02070 * if nothing specific is need you can define it as an empty/void macro 02071 * @code 02072 * #define VL53L0X_PollingDelay(...) (void)0 02073 * @endcode 02074 * @param dev Device Handle 02075 * @return VL53L0X_ERROR_NONE Success 02076 * @return "Other error code" See ::VL53L0X_Error 02077 */ 02078 VL53L0X_Error VL53L0X_polling_delay(VL53L0X_DEV dev); /* usually best implemented as a real function */ 02079 02080 int is_present() 02081 { 02082 int status; 02083 uint8_t id = 0; 02084 02085 status = read_id(&id); 02086 if (status) { 02087 VL53L0X_ErrLog("Failed to read ID device. Device not present!\n\r"); 02088 } 02089 return status; 02090 } 02091 02092 /////////////////////////////////////////////////////////////////////////////////////////////////////// 02093 //Added functions // 02094 /////////////////////////////////////////////////////////////////////////////////////////////////////// 02095 02096 /** 02097 * @brief Cycle Power to Device 02098 * 02099 * @return status - status 0 = ok, 1 = error 02100 * 02101 */ 02102 int32_t VL53L0X_cycle_power(void); 02103 02104 uint8_t VL53L0X_encode_vcsel_period(uint8_t vcsel_period_pclks); 02105 02106 VL53L0X_Error wrapped_VL53L0X_get_device_error_string(VL53L0X_DeviceError error_code, 02107 char *p_device_error_string); 02108 02109 VL53L0X_Error wrapped_VL53L0X_get_limit_check_info(VL53L0X_DEV dev, uint16_t limit_check_id, 02110 char *p_limit_check_string); 02111 02112 VL53L0X_Error wrapped_VL53L0X_get_pal_error_string(VL53L0X_Error pal_error_code, 02113 char *p_pal_error_string); 02114 02115 VL53L0X_Error wrapped_VL53L0X_get_pal_state_string(VL53L0X_State pal_state_code, 02116 char *p_pal_state_string); 02117 02118 VL53L0X_Error wrapped_VL53L0X_get_range_status_string(uint8_t range_status, 02119 char *p_range_status_string); 02120 02121 VL53L0X_Error wrapped_VL53L0X_get_ref_calibration(VL53L0X_DEV dev, 02122 uint8_t *p_vhv_settings, uint8_t *p_phase_cal); 02123 02124 02125 VL53L0X_Error count_enabled_spads(uint8_t spad_array[], 02126 uint32_t byte_count, uint32_t max_spads, 02127 uint32_t *p_total_spads_enabled, uint8_t *p_is_aperture); 02128 02129 VL53L0X_Error wrapped_VL53L0X_get_sequence_steps_info(VL53L0X_SequenceStepId sequence_step_id, 02130 char *p_sequence_steps_string); 02131 02132 02133 /** 02134 * @brief Gets the name of a given sequence step. 02135 * 02136 * @par Function Description 02137 * This function retrieves the name of sequence steps corresponding to 02138 * SequenceStepId. 02139 * 02140 * @note This function doesn't Accesses the device 02141 * 02142 * @param sequence_step_id Sequence step identifier. 02143 * @param p_sequence_steps_string Pointer to Info string 02144 * 02145 * @return VL53L0X_ERROR_NONE Success 02146 * @return "Other error code" See ::VL53L0X_Error 02147 */ 02148 VL53L0X_Error VL53L0X_get_sequence_steps_info(VL53L0X_SequenceStepId sequence_step_id, 02149 char *p_sequence_steps_string); 02150 02151 /** 02152 * @brief Get the frequency of the timer used for ranging results time stamps 02153 * 02154 * @param[out] p_timer_freq_hz : pointer for timer frequency 02155 * 02156 * @return status : 0 = ok, 1 = error 02157 * 02158 */ 02159 int32_t VL53L0X_get_timer_frequency(int32_t *p_timer_freq_hz); 02160 02161 /** 02162 * @brief Get the timer value in units of timer_freq_hz (see VL53L0X_get_timestamp_frequency()) 02163 * 02164 * @param[out] p_timer_count : pointer for timer count value 02165 * 02166 * @return status : 0 = ok, 1 = error 02167 * 02168 */ 02169 int32_t VL53L0X_get_timer_value(int32_t *p_timer_count); 02170 02171 /** 02172 * @brief Configure ranging interrupt reported to system 02173 * 02174 * @note This function is not Implemented 02175 * 02176 * @param dev Device Handle 02177 * @param interrupt_mask Mask of interrupt to Enable/disable 02178 * (0:interrupt disabled or 1: interrupt enabled) 02179 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented 02180 */ 02181 VL53L0X_Error VL53L0X_enable_interrupt_mask(VL53L0X_DEV dev, 02182 uint32_t interrupt_mask); 02183 02184 /** 02185 * @brief Get Dmax Calibration Parameters for a given device 02186 * 02187 * 02188 * @note This function Access to the device 02189 * 02190 * @param dev Device Handle 02191 * @param p_range_milli_meter Pointer to Calibration Distance 02192 * @param p_signal_rate_rtn_mega_cps Pointer to Signal rate return 02193 * @return VL53L0X_ERROR_NONE Success 02194 * @return "Other error code" See ::VL53L0X_Error 02195 */ 02196 VL53L0X_Error VL53L0X_get_dmax_cal_parameters(VL53L0X_DEV dev, 02197 uint16_t *p_range_milli_meter, FixPoint1616_t *p_signal_rate_rtn_mega_cps); 02198 02199 /** 02200 * @brief Set Dmax Calibration Parameters for a given device 02201 * When one of the parameter is zero, this function will get parameter 02202 * from NVM. 02203 * @note This function doesn't Access to the device 02204 * 02205 * @param dev Device Handle 02206 * @param range_milli_meter Calibration Distance 02207 * @param signal_rate_rtn_mega_cps Signal rate return read at CalDistance 02208 * @return VL53L0X_ERROR_NONE Success 02209 * @return "Other error code" See ::VL53L0X_Error 02210 */ 02211 VL53L0X_Error VL53L0X_get_dmax_cal_parameters(VL53L0X_DEV dev, 02212 uint16_t range_milli_meter, FixPoint1616_t signal_rate_rtn_mega_cps); 02213 02214 /** 02215 * @brief Retrieve the measurements from device for a given setup 02216 * 02217 * @par Function Description 02218 * Get data from last successful Histogram measurement 02219 * @warning USER should take care about @a VL53L0X_GetNumberOfROIZones() 02220 * before get data. 02221 * PAL will fill a NumberOfROIZones times the corresponding data structure 02222 * used in the measurement function. 02223 * 02224 * @note This function is not Implemented 02225 * 02226 * @param dev Device Handle 02227 * @param p_histogram_measurement_data Pointer to the histogram data structure. 02228 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented 02229 */ 02230 VL53L0X_Error VL53L0X_get_histogram_measurement_data(VL53L0X_DEV dev, 02231 VL53L0X_HistogramMeasurementData_t *p_histogram_measurement_data); 02232 02233 /** 02234 * @brief Get current new device mode 02235 * @par Function Description 02236 * Get current Histogram mode of a Device 02237 * 02238 * @note This function doesn't Access to the device 02239 * 02240 * @param dev Device Handle 02241 * @param p_histogram_mode Pointer to current Histogram Mode value 02242 * Valid values are: 02243 * VL53L0X_HISTOGRAMMODE_DISABLED 02244 * VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM 02245 * VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY 02246 * VL53L0X_HISTOGRAMMODE_RETURN_ONLY 02247 * VL53L0X_HISTOGRAMMODE_BOTH 02248 * @return VL53L0X_ERROR_NONE Success 02249 * @return "Other error code" See ::VL53L0X_Error 02250 */ 02251 VL53L0X_Error VL53L0X_get_histogram_mode(VL53L0X_DEV dev, 02252 VL53L0X_HistogramModes *p_histogram_mode); 02253 02254 /** 02255 * @brief Set a new Histogram mode 02256 * @par Function Description 02257 * Set device to a new Histogram mode 02258 * 02259 * @note This function doesn't Access to the device 02260 * 02261 * @param dev Device Handle 02262 * @param histogram_mode New device mode to apply 02263 * Valid values are: 02264 * VL53L0X_HISTOGRAMMODE_DISABLED 02265 * VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM 02266 * VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY 02267 * VL53L0X_HISTOGRAMMODE_RETURN_ONLY 02268 * VL53L0X_HISTOGRAMMODE_BOTH 02269 * 02270 * @return VL53L0X_ERROR_NONE Success 02271 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when 02272 * HistogramMode is not in the supported list 02273 * @return "Other error code" See ::VL53L0X_Error 02274 */ 02275 VL53L0X_Error VL53L0X_set_histogram_mode(VL53L0X_DEV dev, 02276 VL53L0X_HistogramModes histogram_mode); 02277 02278 /** 02279 * @brief Return a description string for a given limit check number 02280 * 02281 * @par Function Description 02282 * This function returns a description string for a given limit check number. 02283 * The limit check is identified with the LimitCheckId. 02284 * 02285 * @note This function doesn't Access to the device 02286 * 02287 * @param dev Device Handle 02288 * @param limit_check_id Limit Check ID 02289 (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ). 02290 * @param p_limit_check_string Pointer to the 02291 description string of the given check limit. 02292 * @return VL53L0X_ERROR_NONE Success 02293 * @return VL53L0X_ERROR_INVALID_PARAMS This error is 02294 returned when LimitCheckId value is out of range. 02295 * @return "Other error code" See ::VL53L0X_Error 02296 */ 02297 VL53L0X_Error VL53L0X_get_limit_check_info(VL53L0X_DEV dev, 02298 uint16_t limit_check_id, char *p_limit_check_string); 02299 02300 /** 02301 * @brief Get the linearity corrective gain 02302 * 02303 * @par Function Description 02304 * Should only be used after a successful call to @a VL53L0X_DataInit to backup 02305 * device NVM value 02306 * 02307 * @note This function Access to the device 02308 * 02309 * @param dev Device Handle 02310 * @param p_linearity_corrective_gain Pointer to the linearity 02311 * corrective gain in x1000 02312 * if value is 1000 then no modification is applied. 02313 * @return VL53L0X_ERROR_NONE Success 02314 * @return "Other error code" See ::VL53L0X_Error 02315 */ 02316 VL53L0X_Error VL53L0X_get_linearity_corrective_gain(VL53L0X_DEV dev, 02317 uint16_t *p_linearity_corrective_gain); 02318 02319 /** 02320 * Set the linearity corrective gain 02321 * 02322 * @note This function Access to the device 02323 * 02324 * @param dev Device Handle 02325 * @param linearity_corrective_gain Linearity corrective 02326 * gain in x1000 02327 * if value is 1000 then no modification is applied. 02328 * @return VL53L0X_ERROR_NONE Success 02329 * @return "Other error code" See ::VL53L0X_Error 02330 */ 02331 VL53L0X_Error VL53L0X_set_linearity_corrective_gain(VL53L0X_DEV dev, 02332 int16_t linearity_corrective_gain); 02333 02334 /** 02335 * @brief Get the Maximum number of ROI Zones managed by the Device 02336 * 02337 * @par Function Description 02338 * Get Maximum number of ROI Zones managed by the Device. 02339 * 02340 * @note This function doesn't Access to the device 02341 * 02342 * @param dev Device Handle 02343 * @param p_max_number_of_roi_zones Pointer to the Maximum Number 02344 * of ROI Zones value. 02345 * @return VL53L0X_ERROR_NONE Success 02346 */ 02347 VL53L0X_Error VL53L0X_get_max_number_of_roi_zones(VL53L0X_DEV dev, 02348 uint8_t *p_max_number_of_roi_zones); 02349 02350 /** 02351 * @brief Retrieve the Reference Signal after a measurements 02352 * 02353 * @par Function Description 02354 * Get Reference Signal from last successful Ranging measurement 02355 * This function return a valid value after that you call the 02356 * @a VL53L0X_GetRangingMeasurementData(). 02357 * 02358 * @note This function Access to the device 02359 * 02360 * @param dev Device Handle 02361 * @param p_measurement_ref_signal Pointer to the Ref Signal to fill up. 02362 * @return VL53L0X_ERROR_NONE Success 02363 * @return "Other error code" See ::VL53L0X_Error 02364 */ 02365 VL53L0X_Error VL53L0X_get_measurement_ref_signal(VL53L0X_DEV dev, 02366 FixPoint1616_t *p_measurement_ref_signal); 02367 02368 /** 02369 * @brief Get the number of the check limit managed by a given Device 02370 * 02371 * @par Function Description 02372 * This function give the number of the check limit managed by the Device 02373 * 02374 * @note This function doesn't Access to the device 02375 * 02376 * @param p_number_of_limit_check Pointer to the number of check limit. 02377 * @return VL53L0X_ERROR_NONE Success 02378 * @return "Other error code" See ::VL53L0X_Error 02379 */ 02380 VL53L0X_Error VL53L0X_get_number_of_limit_check( 02381 uint16_t *p_number_of_limit_check); 02382 02383 /** 02384 * @brief Get the number of ROI Zones managed by the Device 02385 * 02386 * @par Function Description 02387 * Get number of ROI Zones managed by the Device 02388 * USER should take care about @a VL53L0X_GetNumberOfROIZones() 02389 * before get data after a perform measurement. 02390 * PAL will fill a NumberOfROIZones times the corresponding data 02391 * structure used in the measurement function. 02392 * 02393 * @note This function doesn't Access to the device 02394 * 02395 * @param dev Device Handle 02396 * @param p_number_of_roi_zones Pointer to the Number of ROI Zones value. 02397 * @return VL53L0X_ERROR_NONE Success 02398 */ 02399 VL53L0X_Error VL53L0X_get_number_of_roi_zones(VL53L0X_DEV dev, 02400 uint8_t *p_number_of_roi_zones); 02401 02402 /** 02403 * @brief Set the number of ROI Zones to be used for a specific Device 02404 * 02405 * @par Function Description 02406 * Set the number of ROI Zones to be used for a specific Device. 02407 * The programmed value should be less than the max number of ROI Zones given 02408 * with @a VL53L0X_GetMaxNumberOfROIZones(). 02409 * This version of API manage only one zone. 02410 * 02411 * @param dev Device Handle 02412 * @param number_of_roi_zones Number of ROI Zones to be used for a 02413 * specific Device. 02414 * @return VL53L0X_ERROR_NONE Success 02415 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned if 02416 * NumberOfROIZones != 1 02417 */ 02418 VL53L0X_Error VL53L0X_set_number_of_roi_zones(VL53L0X_DEV dev, 02419 uint8_t number_of_roi_zones); 02420 02421 /** 02422 * @brief Gets number of sequence steps managed by the API. 02423 * 02424 * @par Function Description 02425 * This function retrieves the number of sequence steps currently managed 02426 * by the API 02427 * 02428 * @note This function Accesses the device 02429 * 02430 * @param dev Device Handle 02431 * @param p_number_of_sequence_steps Out parameter reporting the number of 02432 * sequence steps. 02433 * @return VL53L0X_ERROR_NONE Success 02434 * @return "Other error code" See ::VL53L0X_Error 02435 */ 02436 VL53L0X_Error VL53L0X_get_number_of_sequence_steps(VL53L0X_DEV dev, 02437 uint8_t *p_number_of_sequence_steps); 02438 /** 02439 * @brief Get the power mode for a given Device 02440 * 02441 * @note This function Access to the device 02442 * 02443 * @param dev Device Handle 02444 * @param p_power_mode Pointer to the current value of the power 02445 * mode. see ::VL53L0X_PowerModes 02446 * Valid values are: 02447 * VL53L0X_POWERMODE_STANDBY_LEVEL1, 02448 * VL53L0X_POWERMODE_IDLE_LEVEL1 02449 * @return VL53L0X_ERROR_NONE Success 02450 * @return "Other error code" See ::VL53L0X_Error 02451 */ 02452 VL53L0X_Error VL53L0X_get_power_mode(VL53L0X_DEV dev, 02453 VL53L0X_PowerModes *p_power_mode); 02454 02455 /** 02456 * @brief Set the power mode for a given Device 02457 * The power mode can be Standby or Idle. Different level of both Standby and 02458 * Idle can exists. 02459 * This function should not be used when device is in Ranging state. 02460 * 02461 * @note This function Access to the device 02462 * 02463 * @param dev Device Handle 02464 * @param power_mode The value of the power mode to set. 02465 * see ::VL53L0X_PowerModes 02466 * Valid values are: 02467 * VL53L0X_POWERMODE_STANDBY_LEVEL1, 02468 * VL53L0X_POWERMODE_IDLE_LEVEL1 02469 * @return VL53L0X_ERROR_NONE Success 02470 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when PowerMode 02471 * is not in the supported list 02472 * @return "Other error code" See ::VL53L0X_Error 02473 */ 02474 VL53L0X_Error VL53L0X_set_power_mode(VL53L0X_DEV dev, 02475 VL53L0X_PowerModes power_mode); 02476 02477 /** 02478 * @brief Retrieves SPAD configuration 02479 * 02480 * @par Function Description 02481 * This function retrieves the current number of applied reference spads 02482 * and also their type : Aperture or Non-Aperture. 02483 * 02484 * @note This function Access to the device 02485 * 02486 * @param dev Device Handle 02487 * @param p_spad_count Number ref Spad Count 02488 * @param p_is_aperture_spads Reports if spads are of type 02489 * aperture or non-aperture. 02490 * 1:=aperture, 0:=Non-Aperture 02491 * @return VL53L0X_ERROR_NONE Success 02492 * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the in the reference 02493 * spad configuration. 02494 * @return "Other error code" See ::VL53L0X_Error 02495 */ 02496 VL53L0X_Error wrapped_VL53L0X_get_reference_spads(VL53L0X_DEV dev, 02497 uint32_t *p_spad_count, uint8_t *p_is_aperture_spads); 02498 02499 /** 02500 * @brief Gets the (on/off) state of a requested sequence step. 02501 * 02502 * @par Function Description 02503 * This function retrieves the state of a requested sequence step, i.e. on/off. 02504 * 02505 * @note This function Accesses the device 02506 * 02507 * @param dev Device Handle 02508 * @param sequence_step_id Sequence step identifier. 02509 * @param p_sequence_step_enabled Out parameter reporting if the sequence step 02510 * is enabled {0=Off,1=On}. 02511 * @return VL53L0X_ERROR_NONE Success 02512 * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not 02513 * supported. 02514 * @return "Other error code" See ::VL53L0X_Error 02515 */ 02516 VL53L0X_Error VL53L0X_get_sequence_step_enable(VL53L0X_DEV dev, 02517 VL53L0X_SequenceStepId sequence_step_id, uint8_t *p_sequence_step_enabled); 02518 02519 02520 /** 02521 * @brief Gets the timeout of a requested sequence step. 02522 * 02523 * @par Function Description 02524 * This function retrieves the timeout of a requested sequence step. 02525 * 02526 * @note This function Accesses the device 02527 * 02528 * @param dev Device Handle 02529 * @param sequence_step_id Sequence step identifier. 02530 * @param p_time_out_milli_secs Timeout value. 02531 * @return VL53L0X_ERROR_NONE Success 02532 * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not 02533 * supported. 02534 * @return "Other error code" See ::VL53L0X_Error 02535 */ 02536 VL53L0X_Error VL53L0X_get_sequence_step_timeout(VL53L0X_DEV dev, 02537 VL53L0X_SequenceStepId sequence_step_id, 02538 FixPoint1616_t *p_time_out_milli_secs); 02539 02540 /** 02541 * @brief Sets the timeout of a requested sequence step. 02542 * 02543 * @par Function Description 02544 * This function sets the timeout of a requested sequence step. 02545 * 02546 * @note This function Accesses the device 02547 * 02548 * @param dev Device Handle 02549 * @param sequence_step_id Sequence step identifier. 02550 * @param time_out_milli_secs Demanded timeout 02551 * @return VL53L0X_ERROR_NONE Success 02552 * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not 02553 * supported. 02554 * @return "Other error code" See ::VL53L0X_Error 02555 */ 02556 VL53L0X_Error VL53L0X_set_sequence_step_timeout(VL53L0X_DEV dev, 02557 VL53L0X_SequenceStepId sequence_step_id, FixPoint1616_t time_out_milli_secs); 02558 02559 /** 02560 * @brief Get the current SPAD Ambient Damper Factor value 02561 * 02562 * @par Function Description 02563 * This function get the SPAD Ambient Damper Factor value 02564 * 02565 * @note This function Access to the device 02566 * 02567 * @param dev Device Handle 02568 * @param p_spad_ambient_damper_factor Pointer to programmed SPAD Ambient 02569 * Damper Factor value 02570 * @return VL53L0X_ERROR_NONE Success 02571 * @return "Other error code" See ::VL53L0X_Error 02572 */ 02573 VL53L0X_Error VL53L0X_get_spad_ambient_damper_factor(VL53L0X_DEV dev, 02574 uint16_t *p_spad_ambient_damper_factor); 02575 /** 02576 * @brief Set the SPAD Ambient Damper Factor value 02577 * 02578 * @par Function Description 02579 * This function set the SPAD Ambient Damper Factor value 02580 * 02581 * @note This function Access to the device 02582 * 02583 * @param dev Device Handle 02584 * @param spad_ambient_damper_factor SPAD Ambient Damper Factor value 02585 * @return VL53L0X_ERROR_NONE Success 02586 * @return "Other error code" See ::VL53L0X_Error 02587 */ 02588 VL53L0X_Error VL53L0X_set_spad_ambient_damper_factor(VL53L0X_DEV dev, 02589 uint16_t spad_ambient_damper_factor); 02590 02591 /** 02592 * @brief Get the current SPAD Ambient Damper Threshold value 02593 * 02594 * @par Function Description 02595 * This function get the SPAD Ambient Damper Threshold value 02596 * 02597 * @note This function Access to the device 02598 * 02599 * @param dev Device Handle 02600 * @param p_spad_ambient_damper_threshold Pointer to programmed 02601 * SPAD Ambient Damper Threshold value 02602 * @return VL53L0X_ERROR_NONE Success 02603 * @return "Other error code" See ::VL53L0X_Error 02604 */ 02605 VL53L0X_Error VL53L0X_get_spad_ambient_damper_threshold(VL53L0X_DEV dev, 02606 uint16_t *p_spad_ambient_damper_threshold); 02607 02608 /** 02609 * @brief Set the SPAD Ambient Damper Threshold value 02610 * 02611 * @par Function Description 02612 * This function set the SPAD Ambient Damper Threshold value 02613 * 02614 * @note This function Access to the device 02615 * 02616 * @param dev Device Handle 02617 * @param spad_ambient_damper_threshold SPAD Ambient Damper Threshold value 02618 * @return VL53L0X_ERROR_NONE Success 02619 * @return "Other error code" See ::VL53L0X_Error 02620 */ 02621 VL53L0X_Error VL53L0X_set_spad_ambient_damper_threshold(VL53L0X_DEV dev, 02622 uint16_t spad_ambient_damper_threshold); 02623 02624 /** 02625 * @brief Get the maximal distance for actual setup 02626 * @par Function Description 02627 * Device must be initialized through @a VL53L0X_SetParameters() prior calling 02628 * this function. 02629 * 02630 * Any range value more than the value returned is to be considered as 02631 * "no target detected" or 02632 * "no target in detectable range"\n 02633 * @warning The maximal distance depends on the setup 02634 * 02635 * @note This function is not Implemented 02636 * 02637 * @param dev Device Handle 02638 * @param p_upper_limit_milli_meter The maximal range limit for actual setup 02639 * (in millimeter) 02640 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented 02641 */ 02642 VL53L0X_Error VL53L0X_get_upper_limit_milli_meter(VL53L0X_DEV dev, 02643 uint16_t *p_upper_limit_milli_meter); 02644 02645 /** 02646 * @brief Get the tuning settings pointer and the internal external switch 02647 * value. 02648 * 02649 * This function is used to get the Tuning settings buffer pointer and the 02650 * value. 02651 * of the switch to select either external or internal tuning settings. 02652 * 02653 * @note This function Access to the device 02654 * 02655 * @param dev Device Handle 02656 * @param pp_tuning_setting_buffer Pointer to tuning settings buffer. 02657 * @param p_use_internal_tuning_settings Pointer to store Use internal tuning 02658 * settings value. 02659 * @return VL53L0X_ERROR_NONE Success 02660 * @return "Other error code" See ::VL53L0X_Error 02661 */ 02662 VL53L0X_Error VL53L0X_get_tuning_setting_buffer(VL53L0X_DEV dev, 02663 uint8_t **pp_tuning_setting_buffer, uint8_t *p_use_internal_tuning_settings); 02664 02665 /** 02666 * @brief Set the tuning settings pointer 02667 * 02668 * This function is used to specify the Tuning settings buffer to be used 02669 * for a given device. The buffer contains all the necessary data to permit 02670 * the API to write tuning settings. 02671 * This function permit to force the usage of either external or internal 02672 * tuning settings. 02673 * 02674 * @note This function Access to the device 02675 * 02676 * @param dev Device Handle 02677 * @param p_tuning_setting_buffer Pointer to tuning settings buffer. 02678 * @param use_internal_tuning_settings Use internal tuning settings value. 02679 * @return VL53L0X_ERROR_NONE Success 02680 * @return "Other error code" See ::VL53L0X_Error 02681 */ 02682 VL53L0X_Error VL53L0X_set_tuning_setting_buffer(VL53L0X_DEV dev, 02683 uint8_t *p_tuning_setting_buffer, uint8_t use_internal_tuning_settings); 02684 02685 /** 02686 * @defgroup VL53L0X_registerAccess_group PAL Register Access Functions 02687 * @brief PAL Register Access Functions 02688 * @{ 02689 */ 02690 02691 /** 02692 * Lock comms interface to serialize all commands to a shared I2C interface for a specific device 02693 * @param dev Device Handle 02694 * @return VL53L0X_ERROR_NONE Success 02695 * @return "Other error code" See ::VL53L0X_Error 02696 */ 02697 VL53L0X_Error VL53L0X_lock_sequence_access(VL53L0X_DEV dev); 02698 02699 /** 02700 * Unlock comms interface to serialize all commands to a shared I2C interface for a specific device 02701 * @param dev Device Handle 02702 * @return VL53L0X_ERROR_NONE Success 02703 * @return "Other error code" See ::VL53L0X_Error 02704 */ 02705 VL53L0X_Error VL53L0X_unlock_sequence_access(VL53L0X_DEV dev); 02706 02707 /** 02708 * @brief Prepare device for operation 02709 * @par Function Description 02710 * Update device with provided parameters 02711 * @li Then start ranging operation. 02712 * 02713 * @note This function Access to the device 02714 * 02715 * @param Dev Device Handle 02716 * @param pDeviceParameters Pointer to store current device parameters. 02717 * @return VL53L0X_ERROR_NONE Success 02718 * @return "Other error code" See ::VL53L0X_Error 02719 */ 02720 VL53L0X_Error vl53L0x_set_device_parameters(VL53L0X_DEV Dev, 02721 const VL53L0X_DeviceParameters_t *pDeviceParameters); 02722 02723 /** 02724 * Set Group parameter Hold state 02725 * 02726 * @par Function Description 02727 * Set or remove device internal group parameter hold 02728 * 02729 * @note This function is not Implemented 02730 * 02731 * @param dev Device Handle 02732 * @param group_param_hold Group parameter Hold state to be set (on/off) 02733 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented 02734 */ 02735 VL53L0X_Error VL53L0X_set_group_param_hold(VL53L0X_DEV dev, 02736 uint8_t group_param_hold); 02737 02738 02739 /** 02740 * @brief Wait for device ready for a new measurement command. 02741 * Blocking function. 02742 * 02743 * @note This function is not Implemented 02744 * 02745 * @param dev Device Handle 02746 * @param max_loop Max Number of polling loop (timeout). 02747 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented 02748 */ 02749 VL53L0X_Error VL53L0X_wait_device_ready_for_new_measurement(VL53L0X_DEV dev, 02750 uint32_t max_loop); 02751 02752 VL53L0X_Error VL53L0X_reverse_bytes(uint8_t *data, uint32_t size); 02753 02754 int range_meas_int_continuous_mode(void (*fptr)(void)); 02755 02756 02757 VL53L0X_DeviceInfo_t _device_info; 02758 02759 /* IO Device */ 02760 DevI2C *_dev_i2c; 02761 /* Digital out pin */ 02762 DigitalOut *_gpio0; 02763 /* GPIO expander */ 02764 Stmpe1600DigiOut *_expgpio0; 02765 /* Measure detection IRQ */ 02766 InterruptIn *_gpio1Int; 02767 /* Device data */ 02768 VL53L0X_Dev_t _my_device; 02769 VL53L0X_DEV _device; 02770 }; 02771 02772 02773 #endif /* _VL53L0X_CLASS_H_ */
Generated on Fri Jul 15 2022 04:42:55 by
