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