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