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