Updates to follow mbed SDK coding style guidelines.

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON

Dependents:   53L0A1_Satellites_with_Interrupts_OS5 Display_53L0A1_OS5

Fork of X_NUCLEO_53L0A1 by ST

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers vl53l0x_class.h Source File

vl53l0x_class.h

00001 /*******************************************************************************
00002  Copyright © 2016, STMicroelectronics International N.V.
00003  All rights reserved.
00004 
00005  Redistribution and use in source and binary forms, with or without
00006  modification, are permitted provided that the following conditions are met:
00007  * Redistributions of source code must retain the above copyright
00008  notice, this list of conditions and the following disclaimer.
00009  * Redistributions in binary form must reproduce the above copyright
00010  notice, this list of conditions and the following disclaimer in the
00011  documentation and/or other materials provided with the distribution.
00012  * Neither the name of STMicroelectronics nor the
00013  names of its contributors may be used to endorse or promote products
00014  derived from this software without specific prior written permission.
00015 
00016  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018  WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
00019  NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
00020  IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
00021  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00022  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00023  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00024  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00026  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  *****************************************************************************/
00028 
00029 #ifndef __VL53L0X_CLASS_H
00030 #define __VL53L0X_CLASS_H
00031 
00032 
00033 #ifdef _MSC_VER
00034 #   ifdef VL53L0X_API_EXPORTS
00035 #       define VL53L0X_API  __declspec(dllexport)
00036 #   else
00037 #       define VL53L0X_API
00038 #   endif
00039 #else
00040 #   define VL53L0X_API
00041 #endif
00042 
00043 
00044 /* Includes ------------------------------------------------------------------*/
00045 #include "mbed.h"
00046 #include "RangeSensor.h"
00047 #include "DevI2C.h"
00048 #include "PinNames.h"
00049 #include "vl53l0x_def.h"
00050 #include "vl53l0x_platform.h"
00051 #include "stmpe1600_class.h"
00052 
00053 
00054 /**
00055  * The device model ID
00056  */
00057 #define IDENTIFICATION_MODEL_ID                 0x000
00058 
00059 
00060 #define STATUS_OK              0x00
00061 #define STATUS_FAIL            0x01
00062 
00063 
00064 #define VL53L0X_OsDelay(...) wait_ms(2) // 2 msec delay. can also use wait(float secs)/wait_us(int)
00065 
00066 #ifdef USE_EMPTY_STRING
00067 #define  VL53L0X_STRING_DEVICE_INFO_NAME                             ""
00068 #define  VL53L0X_STRING_DEVICE_INFO_NAME_TS0                         ""
00069 #define  VL53L0X_STRING_DEVICE_INFO_NAME_TS1                         ""
00070 #define  VL53L0X_STRING_DEVICE_INFO_NAME_TS2                         ""
00071 #define  VL53L0X_STRING_DEVICE_INFO_NAME_ES1                         ""
00072 #define  VL53L0X_STRING_DEVICE_INFO_TYPE                             ""
00073 
00074 /* PAL ERROR strings */
00075 #define  VL53L0X_STRING_ERROR_NONE                                   ""
00076 #define  VL53L0X_STRING_ERROR_CALIBRATION_WARNING                    ""
00077 #define  VL53L0X_STRING_ERROR_MIN_CLIPPED                            ""
00078 #define  VL53L0X_STRING_ERROR_UNDEFINED                              ""
00079 #define  VL53L0X_STRING_ERROR_INVALID_PARAMS                         ""
00080 #define  VL53L0X_STRING_ERROR_NOT_SUPPORTED                          ""
00081 #define  VL53L0X_STRING_ERROR_RANGE_ERROR                            ""
00082 #define  VL53L0X_STRING_ERROR_TIME_OUT                               ""
00083 #define  VL53L0X_STRING_ERROR_MODE_NOT_SUPPORTED                     ""
00084 #define  VL53L0X_STRING_ERROR_BUFFER_TOO_SMALL                       ""
00085 #define  VL53L0X_STRING_ERROR_GPIO_NOT_EXISTING                      ""
00086 #define  VL53L0X_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED       ""
00087 #define  VL53L0X_STRING_ERROR_CONTROL_INTERFACE                      ""
00088 #define  VL53L0X_STRING_ERROR_INVALID_COMMAND                        ""
00089 #define  VL53L0X_STRING_ERROR_DIVISION_BY_ZERO                       ""
00090 #define  VL53L0X_STRING_ERROR_REF_SPAD_INIT                          ""
00091 #define  VL53L0X_STRING_ERROR_NOT_IMPLEMENTED                        ""
00092 
00093 #define  VL53L0X_STRING_UNKNOW_ERROR_CODE                            ""
00094 
00095 
00096 
00097 /* Range Status */
00098 #define  VL53L0X_STRING_RANGESTATUS_NONE                             ""
00099 #define  VL53L0X_STRING_RANGESTATUS_RANGEVALID                       ""
00100 #define  VL53L0X_STRING_RANGESTATUS_SIGMA                            ""
00101 #define  VL53L0X_STRING_RANGESTATUS_SIGNAL                           ""
00102 #define  VL53L0X_STRING_RANGESTATUS_MINRANGE                         ""
00103 #define  VL53L0X_STRING_RANGESTATUS_PHASE                            ""
00104 #define  VL53L0X_STRING_RANGESTATUS_HW                               ""
00105 
00106 
00107 /* Range Status */
00108 #define  VL53L0X_STRING_STATE_POWERDOWN                              ""
00109 #define  VL53L0X_STRING_STATE_WAIT_STATICINIT                        ""
00110 #define  VL53L0X_STRING_STATE_STANDBY                                ""
00111 #define  VL53L0X_STRING_STATE_IDLE                                   ""
00112 #define  VL53L0X_STRING_STATE_RUNNING                                ""
00113 #define  VL53L0X_STRING_STATE_UNKNOWN                                ""
00114 #define  VL53L0X_STRING_STATE_ERROR                                  ""
00115 
00116 
00117 /* Device Specific */
00118 #define  VL53L0X_STRING_DEVICEERROR_NONE                             ""
00119 #define  VL53L0X_STRING_DEVICEERROR_VCSELCONTINUITYTESTFAILURE       ""
00120 #define  VL53L0X_STRING_DEVICEERROR_VCSELWATCHDOGTESTFAILURE         ""
00121 #define  VL53L0X_STRING_DEVICEERROR_NOVHVVALUEFOUND                  ""
00122 #define  VL53L0X_STRING_DEVICEERROR_MSRCNOTARGET                     ""
00123 #define  VL53L0X_STRING_DEVICEERROR_SNRCHECK                         ""
00124 #define  VL53L0X_STRING_DEVICEERROR_RANGEPHASECHECK                  ""
00125 #define  VL53L0X_STRING_DEVICEERROR_SIGMATHRESHOLDCHECK              ""
00126 #define  VL53L0X_STRING_DEVICEERROR_TCC                              ""
00127 #define  VL53L0X_STRING_DEVICEERROR_PHASECONSISTENCY                 ""
00128 #define  VL53L0X_STRING_DEVICEERROR_MINCLIP                          ""
00129 #define  VL53L0X_STRING_DEVICEERROR_RANGECOMPLETE                    ""
00130 #define  VL53L0X_STRING_DEVICEERROR_ALGOUNDERFLOW                    ""
00131 #define  VL53L0X_STRING_DEVICEERROR_ALGOOVERFLOW                     ""
00132 #define  VL53L0X_STRING_DEVICEERROR_RANGEIGNORETHRESHOLD             ""
00133 #define  VL53L0X_STRING_DEVICEERROR_UNKNOWN                          ""
00134 
00135 /* Check Enable */
00136 #define  VL53L0X_STRING_CHECKENABLE_SIGMA_FINAL_RANGE                ""
00137 #define  VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE          ""
00138 #define  VL53L0X_STRING_CHECKENABLE_SIGNAL_REF_CLIP                  ""
00139 #define  VL53L0X_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD           ""
00140 
00141 /* Sequence Step */
00142 #define  VL53L0X_STRING_SEQUENCESTEP_TCC                             ""
00143 #define  VL53L0X_STRING_SEQUENCESTEP_DSS                             ""
00144 #define  VL53L0X_STRING_SEQUENCESTEP_MSRC                            ""
00145 #define  VL53L0X_STRING_SEQUENCESTEP_PRE_RANGE                       ""
00146 #define  VL53L0X_STRING_SEQUENCESTEP_FINAL_RANGE                     ""
00147 #else
00148 #define  VL53L0X_STRING_DEVICE_INFO_NAME          "VL53L0X cut1.0"
00149 #define  VL53L0X_STRING_DEVICE_INFO_NAME_TS0      "VL53L0X TS0"
00150 #define  VL53L0X_STRING_DEVICE_INFO_NAME_TS1      "VL53L0X TS1"
00151 #define  VL53L0X_STRING_DEVICE_INFO_NAME_TS2      "VL53L0X TS2"
00152 #define  VL53L0X_STRING_DEVICE_INFO_NAME_ES1      "VL53L0X ES1 or later"
00153 #define  VL53L0X_STRING_DEVICE_INFO_TYPE          "VL53L0X"
00154 
00155 /* PAL ERROR strings */
00156 #define  VL53L0X_STRING_ERROR_NONE \
00157             "No Error"
00158 #define  VL53L0X_STRING_ERROR_CALIBRATION_WARNING \
00159             "Calibration Warning Error"
00160 #define  VL53L0X_STRING_ERROR_MIN_CLIPPED \
00161             "Min clipped error"
00162 #define  VL53L0X_STRING_ERROR_UNDEFINED \
00163             "Undefined error"
00164 #define  VL53L0X_STRING_ERROR_INVALID_PARAMS \
00165             "Invalid parameters error"
00166 #define  VL53L0X_STRING_ERROR_NOT_SUPPORTED \
00167             "Not supported error"
00168 #define  VL53L0X_STRING_ERROR_RANGE_ERROR \
00169             "Range error"
00170 #define  VL53L0X_STRING_ERROR_TIME_OUT \
00171             "Time out error"
00172 #define  VL53L0X_STRING_ERROR_MODE_NOT_SUPPORTED \
00173             "Mode not supported error"
00174 #define  VL53L0X_STRING_ERROR_BUFFER_TOO_SMALL \
00175             "Buffer too small"
00176 #define  VL53L0X_STRING_ERROR_GPIO_NOT_EXISTING \
00177             "GPIO not existing"
00178 #define  VL53L0X_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED \
00179             "GPIO funct not supported"
00180 #define  VL53L0X_STRING_ERROR_INTERRUPT_NOT_CLEARED \
00181             "Interrupt not Cleared"
00182 #define  VL53L0X_STRING_ERROR_CONTROL_INTERFACE \
00183             "Control Interface Error"
00184 #define  VL53L0X_STRING_ERROR_INVALID_COMMAND \
00185             "Invalid Command Error"
00186 #define  VL53L0X_STRING_ERROR_DIVISION_BY_ZERO \
00187             "Division by zero Error"
00188 #define  VL53L0X_STRING_ERROR_REF_SPAD_INIT \
00189             "Reference Spad Init Error"
00190 #define  VL53L0X_STRING_ERROR_NOT_IMPLEMENTED \
00191             "Not implemented error"
00192 
00193 #define  VL53L0X_STRING_UNKNOW_ERROR_CODE \
00194             "Unknown Error Code"
00195 
00196 
00197 
00198 /* Range Status */
00199 #define  VL53L0X_STRING_RANGESTATUS_NONE                 "No Update"
00200 #define  VL53L0X_STRING_RANGESTATUS_RANGEVALID           "Range Valid"
00201 #define  VL53L0X_STRING_RANGESTATUS_SIGMA                "Sigma Fail"
00202 #define  VL53L0X_STRING_RANGESTATUS_SIGNAL               "Signal Fail"
00203 #define  VL53L0X_STRING_RANGESTATUS_MINRANGE             "Min Range Fail"
00204 #define  VL53L0X_STRING_RANGESTATUS_PHASE                "Phase Fail"
00205 #define  VL53L0X_STRING_RANGESTATUS_HW                   "Hardware Fail"
00206 
00207 
00208 /* Range Status */
00209 #define  VL53L0X_STRING_STATE_POWERDOWN               "POWERDOWN State"
00210 #define  VL53L0X_STRING_STATE_WAIT_STATICINIT \
00211             "Wait for staticinit State"
00212 #define  VL53L0X_STRING_STATE_STANDBY                 "STANDBY State"
00213 #define  VL53L0X_STRING_STATE_IDLE                    "IDLE State"
00214 #define  VL53L0X_STRING_STATE_RUNNING                 "RUNNING State"
00215 #define  VL53L0X_STRING_STATE_UNKNOWN                 "UNKNOWN State"
00216 #define  VL53L0X_STRING_STATE_ERROR                   "ERROR State"
00217 
00218 
00219 /* Device Specific */
00220 #define  VL53L0X_STRING_DEVICEERROR_NONE                   "No Update"
00221 #define  VL53L0X_STRING_DEVICEERROR_VCSELCONTINUITYTESTFAILURE \
00222             "VCSEL Continuity Test Failure"
00223 #define  VL53L0X_STRING_DEVICEERROR_VCSELWATCHDOGTESTFAILURE \
00224             "VCSEL Watchdog Test Failure"
00225 #define  VL53L0X_STRING_DEVICEERROR_NOVHVVALUEFOUND \
00226             "No VHV Value found"
00227 #define  VL53L0X_STRING_DEVICEERROR_MSRCNOTARGET \
00228             "MSRC No Target Error"
00229 #define  VL53L0X_STRING_DEVICEERROR_SNRCHECK \
00230             "SNR Check Exit"
00231 #define  VL53L0X_STRING_DEVICEERROR_RANGEPHASECHECK \
00232             "Range Phase Check Error"
00233 #define  VL53L0X_STRING_DEVICEERROR_SIGMATHRESHOLDCHECK \
00234             "Sigma Threshold Check Error"
00235 #define  VL53L0X_STRING_DEVICEERROR_TCC \
00236             "TCC Error"
00237 #define  VL53L0X_STRING_DEVICEERROR_PHASECONSISTENCY \
00238             "Phase Consistency Error"
00239 #define  VL53L0X_STRING_DEVICEERROR_MINCLIP \
00240             "Min Clip Error"
00241 #define  VL53L0X_STRING_DEVICEERROR_RANGECOMPLETE \
00242             "Range Complete"
00243 #define  VL53L0X_STRING_DEVICEERROR_ALGOUNDERFLOW \
00244             "Range Algo Underflow Error"
00245 #define  VL53L0X_STRING_DEVICEERROR_ALGOOVERFLOW \
00246             "Range Algo Overlow Error"
00247 #define  VL53L0X_STRING_DEVICEERROR_RANGEIGNORETHRESHOLD \
00248             "Range Ignore Threshold Error"
00249 #define  VL53L0X_STRING_DEVICEERROR_UNKNOWN \
00250             "Unknown error code"
00251 
00252 /* Check Enable */
00253 #define  VL53L0X_STRING_CHECKENABLE_SIGMA_FINAL_RANGE \
00254             "SIGMA FINAL RANGE"
00255 #define  VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE \
00256             "SIGNAL RATE FINAL RANGE"
00257 #define  VL53L0X_STRING_CHECKENABLE_SIGNAL_REF_CLIP \
00258             "SIGNAL REF CLIP"
00259 #define  VL53L0X_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD \
00260             "RANGE IGNORE THRESHOLD"
00261 #define  VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_MSRC \
00262             "SIGNAL RATE MSRC"
00263 #define  VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_PRE_RANGE \
00264             "SIGNAL RATE PRE RANGE"
00265 
00266 /* Sequence Step */
00267 #define  VL53L0X_STRING_SEQUENCESTEP_TCC                   "TCC"
00268 #define  VL53L0X_STRING_SEQUENCESTEP_DSS                   "DSS"
00269 #define  VL53L0X_STRING_SEQUENCESTEP_MSRC                  "MSRC"
00270 #define  VL53L0X_STRING_SEQUENCESTEP_PRE_RANGE             "PRE RANGE"
00271 #define  VL53L0X_STRING_SEQUENCESTEP_FINAL_RANGE           "FINAL RANGE"
00272 #endif /* USE_EMPTY_STRING */
00273 
00274 
00275 
00276 
00277 
00278 /* sensor operating modes */
00279 typedef enum {
00280     range_single_shot_polling = 1,
00281     range_continuous_polling,
00282     range_continuous_interrupt,
00283     range_continuous_polling_low_threshold,
00284     range_continuous_polling_high_threshold,
00285     range_continuous_polling_out_of_window,
00286     range_continuous_interrupt_low_threshold,
00287     range_continuous_interrupt_high_threshold,
00288     range_continuous_interrupt_out_of_window,
00289 } OperatingMode;
00290 
00291 /** default device address */
00292 #define DEFAULT_DEVICE_ADDRESS      0x52 /* (8-bit) */
00293 
00294 /* Classes -------------------------------------------------------------------*/
00295 /** Class representing a VL53L0 sensor component
00296  */
00297 class VL53L0X : public RangeSensor
00298 {
00299 public:
00300     /** Constructor
00301      * @param[in] &i2c device I2C to be used for communication
00302      * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
00303      * @param[in] dev_addr device address, 0x29 by default
00304      */
00305     VL53L0X( DevI2C &i2c, DigitalOut &pin, PinName pin_gpio1, uint8_t dev_addr = DEFAULT_DEVICE_ADDRESS ) : dev_i2c( i2c ),
00306         gpio0( &pin )
00307     {
00308         _my_device.I2cDevAddr  = dev_addr;
00309         _my_device.comms_type  = 1; // VL53L0X_COMMS_I2C
00310         _my_device.comms_speed_khz  = 400;
00311         _device = &_my_device;
00312         expgpio0 = NULL;
00313         if ( pin_gpio1 != NC ) {
00314             gpio1Int = new InterruptIn( pin_gpio1 );
00315         } else {
00316             gpio1Int = NULL;
00317         }
00318     }
00319 
00320     /** Constructor 2 (STMPE1600DigiOut)
00321      * @param[in] i2c device I2C to be used for communication
00322      * @param[in] &pin Gpio Expander STMPE1600DigiOut pin to be used as component GPIO_0 CE
00323      * @param[in] pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
00324      * @param[in] device address, 0x29 by default
00325      */
00326     VL53L0X( DevI2C &i2c, Stmpe1600DigiOut &pin, PinName pin_gpio1,
00327              uint8_t dev_addr = DEFAULT_DEVICE_ADDRESS ) : dev_i2c( i2c ), expgpio0( &pin )
00328     {
00329         _my_device.I2cDevAddr  = dev_addr;
00330         _my_device.comms_type  = 1; // VL53L0X_COMMS_I2C
00331         _my_device.comms_speed_khz  = 400;
00332         _device = &_my_device;
00333         gpio0 = NULL;
00334         if ( pin_gpio1 != NC ) {
00335             gpio1Int = new InterruptIn( pin_gpio1 );
00336         } else {
00337             gpio1Int = NULL;
00338         }
00339     }
00340 
00341     /** Destructor
00342      */
00343     virtual ~VL53L0X()
00344     {
00345         if ( gpio1Int != NULL ) delete gpio1Int;
00346     }
00347     /* warning: VL53L0X class inherits from GenericSensor, RangeSensor and LightSensor, that haven`t a destructor.
00348        The warning should request to introduce a virtual destructor to make sure to delete the object */
00349 
00350     /*** Interface Methods ***/
00351     /*** High level API ***/
00352     /**
00353      * @brief       PowerOn the sensor
00354      * @return      void
00355      */
00356     /* turns on the sensor */
00357     void vl53l0x_on( void )
00358     {
00359         if ( gpio0 )
00360             *gpio0 = 1;
00361         else if ( expgpio0 )
00362             *expgpio0 = 1;
00363         wait_ms( 10 );
00364     }
00365 
00366     /**
00367      * @brief       PowerOff the sensor
00368      * @return      void
00369      */
00370     /* turns off the sensor */
00371     void vl53l0x_off( void )
00372     {
00373         if ( gpio0 )
00374             *gpio0 = 0;
00375         else if ( expgpio0 )
00376             *expgpio0 = 0;
00377         wait_ms( 10 );
00378     }
00379 
00380     /**
00381      * @brief       Initialize the sensor with default values
00382      * @return      0 on Success
00383      */
00384     int init_sensor( uint8_t new_addr );
00385 
00386     /**
00387      * @brief       Start the measure indicated by operating mode
00388      * @param[in]   operating_mode specifies requested measure
00389      * @param[in]   fptr specifies call back function must be !NULL in case of interrupt measure
00390      * @return      0 on Success
00391      */
00392     int start_measurement( OperatingMode operating_mode, void ( *fptr )( void ) );
00393 
00394     /**
00395      * @brief       Get results for the measure indicated by operating mode
00396      * @param[in]   operating_mode specifies requested measure results
00397      * @param[out]  p_data pointer to the MeasureData_t structure to read data in to
00398      * @return      0 on Success
00399      */
00400     int get_measurement( OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *p_data );
00401 
00402     /**
00403      * @brief       Stop the currently running measure indicate by operating_mode
00404      * @param[in]   operating_mode specifies requested measure to stop
00405      * @return      0 on Success
00406      */
00407     int stop_measurement( OperatingMode operating_mode );
00408 
00409     /**
00410      * @brief       Interrupt handling func to be called by user after an INT is occourred
00411      * @param[in]   opeating_mode indicating the in progress measure
00412      * @param[out]  Data pointer to the MeasureData_t structure to read data in to
00413      * @return      0 on Success
00414      */
00415     int handle_irq( OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *data );
00416 
00417     /**
00418      * @brief       Enable interrupt measure IRQ
00419      * @return      0 on Success
00420      */
00421     void enable_interrupt_measure_detection_irq( void )
00422     {
00423         if ( gpio1Int != NULL ) gpio1Int->enable_irq();
00424     }
00425 
00426     /**
00427      * @brief       Disable interrupt measure IRQ
00428      * @return      0 on Success
00429      */
00430     void disable_interrupt_measure_detection_irq( void )
00431     {
00432         if ( gpio1Int != NULL ) gpio1Int->disable_irq();
00433     }
00434     /*** End High level API ***/
00435 
00436     /**
00437      * @brief       Attach a function to call when an interrupt is detected, i.e. measurement is ready
00438      * @param[in]   fptr pointer to call back function to be called whenever an interrupt occours
00439      * @return      0 on Success
00440      */
00441     void attach_interrupt_measure_detection_irq( void ( *fptr )( void ) )
00442     {
00443         if ( gpio1Int != NULL ) gpio1Int->rise( fptr );
00444     }
00445 
00446     /**
00447      * @brief       Check the sensor presence
00448      * @return      1 when device is present
00449      */
00450     unsigned present()
00451     {
00452 //       return Device->Present;
00453         return 1;
00454     }
00455 
00456     /** Wrapper functions */
00457     /** @defgroup api_init Init functions
00458      *  @brief    API init functions
00459      *  @ingroup api_hl
00460      *  @{
00461      */
00462     /**
00463      * @brief Wait for device booted after chip enable (hardware standby)
00464      * @par Function Description
00465      * After Chip enable Application you can also simply wait at least 1ms to ensure device is ready
00466      * @warning After device chip enable (gpio0) de-asserted  user must wait gpio1 to get asserted (hardware standby).
00467      * or wait at least 400usec prior to do any low level access or api call .
00468      *
00469      * This function implements polling for standby but you must ensure 400usec from chip enable passed\n
00470      * @warning if device get prepared @a VL53L0X_Prepare() re-using these function can hold indefinitely\n
00471      *
00472      * @param       void
00473      * @return     0 on success
00474      */
00475     int wait_device_booted()
00476     {
00477         return wrapped_vl53l0x_wait_device_booted( _device );
00478     }
00479 
00480 
00481     /**
00482      *
00483      * @brief One time device initialization
00484      *
00485      * To be called once and only once after device is brought out of reset (Chip enable) and booted see @a VL6180x_WaitDeviceBooted()
00486      *
00487      * @par Function Description
00488      * When not used after a fresh device "power up" or reset, it may return @a #CALIBRATION_WARNING
00489      * meaning wrong calibration data may have been fetched from device that can result in ranging offset error\n
00490      * If application cannot execute device reset or need to run VL6180x_InitData  multiple time
00491      * then it  must ensure proper offset calibration saving and restore on its own
00492      * by using @a VL6180x_GetOffsetCalibrationData() on first power up and then @a VL6180x_SetOffsetCalibrationData() all all subsequent init
00493      *
00494      * @param void
00495      * @return     0 on success,  @a #CALIBRATION_WARNING if failed
00496      */
00497     virtual int init( void *init )
00498     {
00499         return vl53l0x_data_init( _device );
00500     }
00501 
00502     /**
00503      * @brief Configure GPIO1 function and set polarity.
00504      * @par Function Description
00505      * To be used prior to arm single shot measure or start  continuous mode.
00506      *
00507      * The function uses @a VL6180x_SetupGPIOx() for setting gpio 1.
00508      * @warning  changing polarity can generate a spurious interrupt on pins.
00509      * It sets an interrupt flags condition that must be cleared to avoid polling hangs. \n
00510      * It is safe to run VL6180x_ClearAllInterrupt() just after.
00511      *
00512      * @param IntFunction   The interrupt functionality to use one of :\n
00513      *  @a #GPIOx_SELECT_OFF \n
00514      *  @a #GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT
00515      * @param ActiveHigh  The interrupt line polarity see ::IntrPol_e
00516      *      use @a #INTR_POL_LOW (falling edge) or @a #INTR_POL_HIGH (rising edge)
00517      * @return 0 on success
00518      */
00519     int setup_gpio1( uint8_t InitFunction, int ActiveHigh )
00520     {
00521         return 1;
00522     }
00523 
00524     /**
00525       * @brief  Prepare device for operation
00526       * @par Function Description
00527       * Does static initialization and reprogram common default settings \n
00528       * Device is prepared for new measure, ready single shot ranging or ALS typical polling operation\n
00529       * After prepare user can : \n
00530       * @li Call other API function to set other settings\n
00531       * @li Configure the interrupt pins, etc... \n
00532       * @li Then start ranging or ALS operations in single shot or continuous mode
00533       *
00534       * @param void
00535       * @return      0 on success
00536       */
00537     int prepare()
00538     {
00539         VL53L0X_Error status = VL53L0X_ERROR_NONE;
00540         uint32_t ref_spad_count;
00541         uint8_t is_aperture_spads;
00542         uint8_t vhv_settings;
00543         uint8_t phase_cal;
00544 
00545         if( status == VL53L0X_ERROR_NONE ) {
00546             printf ( "Call of VL53L0X_StaticInit\n" );
00547             status = vl53l0x_static_init( _device ); // Device Initialization
00548         }
00549 
00550         if( status == VL53L0X_ERROR_NONE ) {
00551             printf ( "Call of VL53L0X_PerformRefCalibration\n" );
00552             status = vl53l0x_perform_ref_calibration( _device,
00553                      &vhv_settings, &phase_cal ); // Device Initialization
00554         }
00555 
00556         if( status == VL53L0X_ERROR_NONE ) {
00557             printf ( "Call of VL53L0X_PerformRefSpadManagement\n" );
00558             status = vl53l0x_perform_ref_spad_management( _device,
00559                      &ref_spad_count, &is_aperture_spads ); // Device Initialization
00560 //            printf ("refSpadCount = %d, isApertureSpads = %d\n", refSpadCount, isApertureSpads);
00561         }
00562 
00563         return status;
00564     }
00565 
00566     /**
00567     * @brief Start continuous ranging mode
00568     *
00569     * @details End user should ensure device is in idle state and not already running
00570     * @return      0 on success
00571     */
00572     int range_start_continuous_mode()
00573     {
00574         int status;
00575         status = vl53l0x_set_device_mode( _device, VL53L0X_DEVICEMODE_CONTINUOUS_RANGING );
00576 
00577         if( status == VL53L0X_ERROR_NONE ) {
00578             printf ( "Call of VL53L0X_StartMeasurement\n" );
00579             status = vl53l0x_start_measurement( _device );
00580         }
00581 
00582         return status;
00583     }
00584 
00585     /**
00586      * @brief Start single shot ranging measure
00587      *
00588      * @details End user should ensure device is in idle state and not already running
00589      * @return      0 on success
00590      */
00591     int range_start_single_shot()
00592     {
00593         return 1;
00594     }
00595 
00596     /**
00597      * @brief Set maximum convergence time
00598      *
00599      * @par Function Description
00600      * Setting a low convergence time can impact maximal detectable distance.
00601      * Refer to VL6180x Datasheet Table 7 : Typical range convergence time.
00602      * A typical value for up to x3 scaling is 50 ms
00603      *
00604      * @param max_con_time_msec
00605      * @return 0 on success. <0 on error. >0 for calibration warning status
00606      */
00607     int range_set_max_convergence_time( uint8_t max_con_time_msec )
00608     {
00609         return 1;
00610     }
00611 
00612     /**
00613       * @brief Single shot Range measurement in polling mode.
00614       *
00615       * @par Function Description
00616       * Kick off a new single shot range  then wait for ready to retrieve it by polling interrupt status \n
00617       * Ranging must be prepared by a first call to  @a VL6180x_Prepare() and it is safer to clear  very first poll call \n
00618       * This function reference VL6180x_PollDelay(dev) porting macro/call on each polling loop,
00619       * but PollDelay(dev) may never be called if measure in ready on first poll loop \n
00620       * Should not be use in continuous mode operation as it will stop it and cause stop/start misbehaviour \n
00621       * \n This function clears Range Interrupt status , but not error one. For that uses  @a VL6180x_ClearErrorInterrupt() \n
00622       * This range error is not related VL6180x_RangeData_t::errorStatus that refer measure status \n
00623       *
00624       * @param p_range_data   Will be populated with the result ranging data @a  VL6180x_RangeData_t
00625       * @return 0 on success , @a #RANGE_ERROR if device reports an error case in it status (not cleared) use
00626       *
00627       * \sa ::VL6180x_RangeData_t
00628       */
00629     int range_poll_measurement( VL53L0X_RangingMeasurementData_t *p_range_data )
00630     {
00631         return 1;
00632     }
00633 
00634     /**
00635      * @brief Check for measure readiness and get it if ready
00636      *
00637      * @par Function Description
00638      * Using this function is an alternative to @a VL6180x_RangePollMeasurement() to avoid polling operation. This is suitable for applications
00639      * where host CPU is triggered on a interrupt (not from VL6180X) to perform ranging operation. In this scenario, we assume that the very first ranging
00640      * operation is triggered by a call to @a VL6180x_RangeStartSingleShot(). Then, host CPU regularly calls @a VL6180x_RangeGetMeasurementIfReady() to
00641      * get a distance measure if ready. In case the distance is not ready, host may get it at the next call.\n
00642      *
00643      * @warning
00644      * This function does not re-start a new measurement : this is up to the host CPU to do it.\n
00645      * This function clears Range Interrupt for measure ready , but not error interrupts. For that, uses  @a VL6180x_ClearErrorInterrupt() \n
00646      *
00647      * @param p_range_data  Will be populated with the result ranging data if available
00648      * @return  0 when measure is ready pRange data is updated (untouched when not ready),  >0 for warning and @a #NOT_READY if measurement not yet ready, <0 for error @a #RANGE_ERROR if device report an error,
00649      */
00650     int range_get_measurement_if_ready( VL53L0X_RangingMeasurementData_t *p_range_data )
00651     {
00652         return 1;
00653     }
00654 
00655     /**
00656      * @brief Retrieve range measurements set  from device
00657      *
00658      * @par Function Description
00659      * The measurement is made of range_mm status and error code @a VL6180x_RangeData_t \n
00660      * Based on configuration selected extra measures are included.
00661      *
00662      * @warning should not be used in continuous if wrap around filter is active \n
00663      * Does not perform any wait nor check for result availability or validity.
00664      *\sa VL6180x_RangeGetResult for "range only" measurement
00665      *
00666      * @param p_range_data  Pointer to the data structure to fill up
00667      * @return            0 on success
00668      */
00669     int range_get_measurement( VL53L0X_RangingMeasurementData_t *p_range_data )
00670     {
00671         return 1;
00672     }
00673 
00674     /**
00675      * @brief Get ranging result and only that
00676      *
00677      * @par Function Description
00678      * Unlike @a VL6180x_RangeGetMeasurement() this function only retrieves the range in millimeter \n
00679      * It does any required up-scale translation\n
00680      * It can be called after success status polling or in interrupt mode \n
00681      * @warning these function is not doing wrap around filtering \n
00682      * This function doesn't perform any data ready check!
00683      *
00684      * @param p_data  Pointer to range distance
00685      * @return           0 on success
00686      */
00687     virtual int get_distance( uint32_t *p_data )
00688     {
00689         int status = 0;
00690         VL53L0X_RangingMeasurementData_t p_ranging_measurement_data;
00691 
00692         status = start_measurement( range_single_shot_polling, NULL );
00693         if ( !status ) {
00694             status = get_measurement( range_single_shot_polling, &p_ranging_measurement_data );
00695         }
00696         if ( p_ranging_measurement_data.RangeStatus == 0 ) {
00697             // we have a valid range.
00698             *p_data = p_ranging_measurement_data.RangeMilliMeter;
00699         } else {
00700             *p_data = 0;
00701             status = VL53L0X_ERROR_RANGE_ERROR;
00702         }
00703         stop_measurement( range_single_shot_polling );
00704         return status;
00705     }
00706 
00707     /**
00708      * @brief Configure ranging interrupt reported to application
00709      *
00710      * @param config_gpio_int  Select ranging report\n select one (and only one) of:\n
00711      *   @a #CONFIG_GPIO_INTERRUPT_DISABLED \n
00712      *   @a #CONFIG_GPIO_INTERRUPT_LEVEL_LOW \n
00713      *   @a #CONFIG_GPIO_INTERRUPT_LEVEL_HIGH \n
00714      *   @a #CONFIG_GPIO_INTERRUPT_OUT_OF_WINDOW \n
00715      *   @a #CONFIG_GPIO_INTERRUPT_NEW_SAMPLE_READY
00716      * @return   0 on success
00717      */
00718     int range_config_interrupt( uint8_t config_gpio_int )
00719     {
00720         int status = VL53L0X_ERROR_NONE;
00721         /*       if( ConfigGpioInt<= VL53L0X_REG_SYSTEM_INTERRUPT_GPIO_NEW_SAMPLE_READY)
00722                  {
00723                     status = VL53L0X_UpdateByte(Device, VL53L0X_REG_SYSTEM_INTERRUPT_CONFIG_GPIO, (uint8_t)(~(0x7<<0)), ConfigGpioInt);
00724                  }
00725                  else
00726                  {
00727                     status = 1;
00728                  }
00729         */
00730         return status;
00731     }
00732 
00733     /**
00734      * @brief Return ranging error interrupt status
00735      *
00736      * @par Function Description
00737      * Appropriate Interrupt report must have been selected first by @a VL6180x_RangeConfigInterrupt() or @a  VL6180x_Prepare() \n
00738      *
00739      * Can be used in polling loop to wait for a given ranging event or in interrupt to read the trigger \n
00740      * Events triggers are : \n
00741      * @a #RES_INT_STAT_GPIO_LOW_LEVEL_THRESHOLD \n
00742      * @a #RES_INT_STAT_GPIO_HIGH_LEVEL_THRESHOLD \n
00743      * @a #RES_INT_STAT_GPIO_OUT_OF_WINDOW \n (RES_INT_STAT_GPIO_LOW_LEVEL_THRESHOLD|RES_INT_STAT_GPIO_HIGH_LEVEL_THRESHOLD)
00744      * @a #RES_INT_STAT_GPIO_NEW_SAMPLE_READY \n
00745      *
00746      * @sa IntrStatus_t
00747      * @param p_status Pointer to status variable to update
00748      * @return           0 on success
00749      */
00750     int range_get_interrupt_status( uint8_t *p_status )
00751     {
00752         return 1;
00753     }
00754 
00755     /**
00756      * @brief Low level ranging and ALS register static settings (you should call @a VL6180x_Prepare() function instead)
00757      *
00758      * @return 0 on success
00759      */
00760     int static_init()
00761     {
00762         return 1;
00763     }
00764 
00765     /**
00766      * @brief Wait for device to be ready (before a new ranging command can be issued by application)
00767      * @param max_loop    Max Number of i2c polling loop see @a #msec_2_i2cloop
00768      * @return           0 on success. <0 when fail \n
00769      *                   @ref VL6180x_ErrCode_t::TIME_OUT for time out \n
00770      *                   @ref VL6180x_ErrCode_t::INVALID_PARAMS if MaxLop<1
00771      */
00772     int range_wait_device_deady( int max_loop )
00773     {
00774         return 1;
00775     }
00776 
00777     /**
00778      * @brief Program Inter measurement period (used only in continuous mode)
00779      *
00780      * @par Function Description
00781      * When trying to set too long time, it returns #INVALID_PARAMS
00782      *
00783      * @param inter_meas_time_msec Requires inter-measurement time in msec
00784      * @return 0 on success
00785      */
00786     int range_set_inter_meas_period( uint32_t  inter_meas_time_msec )
00787     {
00788         return 1;
00789     }
00790 
00791     /**
00792      * @brief Set device ranging scaling factor
00793      *
00794      * @par Function Description
00795      * The ranging scaling factor is applied on the raw distance measured by the device to increase operating ranging at the price of the precision.
00796      * Changing the scaling factor when device is not in f/w standby state (free running) is not safe.
00797      * It can be source of spurious interrupt, wrongly scaled range etc ...
00798      * @warning __This  function doesns't update high/low threshold and other programmed settings linked to scaling factor__.
00799      *  To ensure proper operation, threshold and scaling changes should be done following this procedure: \n
00800      *  @li Set Group hold  : @a VL6180x_SetGroupParamHold() \n
00801      *  @li Get Threshold @a VL6180x_RangeGetThresholds() \n
00802      *  @li Change scaling : @a VL6180x_UpscaleSetScaling() \n
00803      *  @li Set Threshold : @a VL6180x_RangeSetThresholds() \n
00804      *  @li Unset Group Hold : @a VL6180x_SetGroupParamHold()
00805      *
00806      * @param scaling  Scaling factor to apply (1,2 or 3)
00807      * @return          0 on success when up-scale support is not configured it fail for any
00808      *                  scaling than the one statically configured.
00809      */
00810     int upscale_set_scaling( uint8_t scaling )
00811     {
00812         return 1;
00813     }
00814 
00815     /**
00816      * @brief Get current ranging scaling factor
00817      *
00818      * @return    The current scaling factor
00819      */
00820     int upscale_get_scaling()
00821     {
00822         return 1;
00823     }
00824 
00825     /**
00826      * @brief Get the maximal distance for actual scaling
00827      * @par Function Description
00828      * Do not use prior to @a VL6180x_Prepare() or at least @a VL6180x_InitData()
00829      *
00830      * Any range value more than the value returned by this function is to be considered as "no target detected"
00831      * or "no target in detectable range" \n
00832      * @warning The maximal distance depends on the scaling
00833      *
00834      * @return    The maximal range limit for actual mode and scaling
00835      */
00836     uint16_t get_upper_limit()
00837     {
00838         return 1;
00839     }
00840 
00841     /**
00842      * @brief Apply low and high ranging thresholds that are considered only in continuous mode
00843      *
00844      * @par Function Description
00845      * This function programs low and high ranging thresholds that are considered in continuous mode :
00846      * interrupt will be raised only when an object is detected at a distance inside this [low:high] range.
00847      * The function takes care of applying current scaling factor if any.\n
00848      * To be safe, in continuous operation, thresholds must be changed under "group parameter hold" cover.
00849      * Group hold can be activated/deactivated directly in the function or externally (then set 0)
00850      * using /a VL6180x_SetGroupParamHold() function.
00851      *
00852      * @param low      Low threshold in mm
00853      * @param high     High threshold in mm
00854      * @param safe_hold  Use of group parameters hold to surround threshold programming.
00855      * @return  0 On success
00856      */
00857     int range_set_thresholds( uint16_t low, uint16_t high, int safe_hold )
00858     {
00859         return 1;
00860     }
00861 
00862     /**
00863      * @brief  Get scaled high and low threshold from device
00864      *
00865      * @par Function Description
00866      * Due to scaling factor, the returned value may be different from what has been programmed first (precision lost).
00867      * For instance VL6180x_RangeSetThresholds(dev,11,22) with scale 3
00868      * will read back 9 ((11/3)x3) and 21 ((22/3)x3).
00869      *
00870      * @param low  scaled low Threshold ptr  can be NULL if not needed
00871      * @param high scaled High Threshold ptr can be NULL if not needed
00872      * @return 0 on success, return value is undefined if both low and high are NULL
00873      * @warning return value is undefined if both low and high are NULL
00874      */
00875     int range_get_thresholds( uint16_t *low, uint16_t *high )
00876     {
00877         return 1;
00878     }
00879 
00880     /**
00881      * @brief Set ranging raw thresholds (scaling not considered so not recommended to use it)
00882      *
00883      * @param low  raw low threshold set to raw register
00884      * @param high raw high threshold set to raw  register
00885      * @return 0 on success
00886      */
00887     int range_set_raw_thresholds( uint8_t low, uint8_t high )
00888     {
00889         return 1;
00890     }
00891 
00892     /**
00893      * @brief Set Early Convergence Estimate ratio
00894      * @par Function Description
00895      * For more information on ECE check datasheet
00896      * @warning May return a calibration warning in some use cases
00897      *
00898      * @param factor_m    ECE factor M in M/D
00899      * @param factor_d    ECE factor D in M/D
00900      * @return           0 on success. <0 on error. >0 on warning
00901      */
00902     int range_set_ece_factor( uint16_t  factor_m, uint16_t factor_d )
00903     {
00904         return 1;
00905     }
00906 
00907     /**
00908      * @brief Set Early Convergence Estimate state (See #SYSRANGE_RANGE_CHECK_ENABLES register)
00909      * @param enable    State to be set 0=disabled, otherwise enabled
00910      * @return          0 on success
00911      */
00912     int range_set_ece_state( int enable )
00913     {
00914         return 1;
00915     }
00916 
00917     /**
00918      * @brief Set activation state of the wrap around filter
00919      * @param state New activation state (0=off,  otherwise on)
00920      * @return      0 on success
00921      */
00922     int filter_set_state( int state )
00923     {
00924         return 1;
00925     }
00926 
00927     /**
00928      * Get activation state of the wrap around filter
00929      * @return     Filter enabled or not, when filter is not supported it always returns 0S
00930      */
00931     int filter_get_state()
00932     {
00933         return 1;
00934     }
00935 
00936     /**
00937      * @brief Set activation state of  DMax computation
00938      * @param state New activation state (0=off,  otherwise on)
00939      * @return      0 on success
00940      */
00941     int dmax_set_state( int state )
00942     {
00943         return 1;
00944     }
00945 
00946     /**
00947      * Get activation state of DMax computation
00948      * @return     Filter enabled or not, when filter is not supported it always returns 0S
00949      */
00950     int dmax_get_state()
00951     {
00952         return 1;
00953     }
00954 
00955     /**
00956      * @brief Set ranging mode and start/stop measure (use high level functions instead : @a VL6180x_RangeStartSingleShot() or @a VL6180x_RangeStartContinuousMode())
00957      *
00958      * @par Function Description
00959      * When used outside scope of known polling single shot stopped state, \n
00960      * user must ensure the device state is "idle" before to issue a new command.
00961      *
00962      * @param mode  A combination of working mode (#MODE_SINGLESHOT or #MODE_CONTINUOUS) and start/stop condition (#MODE_START_STOP) \n
00963      * @return      0 on success
00964      */
00965     int range_set_system_mode( uint8_t mode )
00966     {
00967         int status;
00968         /* FIXME we are not checking device is ready via @a VL6180X_RangeWaitDeviceReady
00969          * so if called back to back real fast we are not checking
00970          * if previous mode "set" got absorbed => bit 0 must be 0 so that it work
00971          */
00972         if( mode <= 3 ) {
00973             status = vl53l0x_write_byte( _device, VL53L0X_REG_SYSRANGE_START, mode );
00974             if( status ) {
00975                 VL53L0X_ErrLog( "SYSRANGE_START wr fail" );
00976             }
00977         } else {
00978             status = 1;
00979         }
00980         return status;
00981     }
00982 
00983     /** @}  */
00984 
00985     /** @defgroup api_ll_range_calibration Ranging calibration functions
00986      *  @brief    Ranging calibration functions
00987      *  @ingroup api_ll
00988      *  @{
00989      */
00990     /**
00991      * @brief Get part to part calibration offset
00992      *
00993      * @par Function Description
00994      * Should only be used after a successful call to @a VL6180x_InitData to backup device nvm value
00995      *
00996      * @return part to part calibration offset from device
00997      */
00998     int8_t get_offset_calibration_data()
00999     {
01000         return 1;
01001     }
01002 
01003     /**
01004      * Set or over-write part to part calibration offset
01005      * \sa VL6180x_InitData(), VL6180x_GetOffsetCalibrationData()
01006      * @param offset   Offset
01007      */
01008     void set_offset_calibration_data( int8_t offset )
01009     {
01010         return;
01011     }
01012 
01013     /**
01014      * @brief Set Cross talk compensation rate
01015      *
01016      * @par Function Description
01017      * It programs register @a #SYSRANGE_CROSSTALK_COMPENSATION_RATE
01018      *
01019      * @param rate Compensation rate (9.7 fix point) see datasheet for details
01020      * @return     0 on success
01021      */
01022     int set_xtalk_compensation_rate( uint16_t rate )
01023     {
01024         return 1;
01025     }
01026     /** @}  */
01027 
01028     /**
01029      * @brief Set new device i2c address
01030      *
01031      * After completion the device will answer to the new address programmed.
01032      *
01033      * @sa AN4478: Using multiple VL6180X's in a single design
01034      * @param new_addr   The new i2c address (7bit)
01035      * @return          0 on success
01036      */
01037     int set_device_address( int new_addr )
01038     {
01039         int status;
01040 
01041         status = vl53l0x_set_device_address( _device, new_addr );
01042         if( !status )
01043             _device->I2cDevAddr  = new_addr;
01044         return status;
01045 
01046     }
01047 
01048     /**
01049      * @brief Fully configure gpio 0/1 pin : polarity and functionality
01050      *
01051      * @param pin          gpio pin 0 or 1
01052      * @param int_function  Pin functionality : either #GPIOx_SELECT_OFF or #GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT (refer to #SYSTEM_MODE_GPIO1 register definition)
01053      * @param active_high   Set active high polarity, or active low see @a ::IntrPol_e
01054      * @return             0 on success
01055      */
01056     int setup_gpiox( int pin, uint8_t int_function, int active_high )
01057     {
01058         return 1;
01059     }
01060 
01061     /**
01062      * @brief Set interrupt pin polarity for the given GPIO
01063      *
01064      * @param pin          Pin 0 or 1
01065      * @param active_high  select active high or low polarity using @ref IntrPol_e
01066      * @return             0 on success
01067      */
01068     int set_gpiox_polarity( int pin, int active_high )
01069     {
01070         return 1;
01071     }
01072 
01073     /**
01074      * Select interrupt functionality for the given GPIO
01075      *
01076      * @par Function Description
01077      * Functionality refer to @a SYSTEM_MODE_GPIO0
01078      *
01079      * @param pin            Pin to configure 0 or 1 (gpio0 or gpio1)\nNote that gpio0 is chip enable at power up !
01080      * @param functionality  Pin functionality : either #GPIOx_SELECT_OFF or #GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT (refer to #SYSTEM_MODE_GPIO1 register definition)
01081      * @return              0 on success
01082      */
01083     int set_gpiox_functionality( int pin, uint8_t functionality )
01084     {
01085         return 1;
01086     }
01087 
01088     /**
01089      * #brief Disable and turn to Hi-Z gpio output pin
01090      *
01091      * @param pin  The pin number to disable 0 or 1
01092      * @return     0 on success
01093      */
01094     int disable_gpiox_out( int pin )
01095     {
01096         return 1;
01097     }
01098 
01099     /** @}  */
01100 
01101     /** @defgroup api_ll_intr Interrupts management functions
01102      *  @brief    Interrupts management functions
01103      *  @ingroup api_ll
01104      *  @{
01105      */
01106 
01107     /**
01108      * @brief     Get all interrupts cause
01109      *
01110      * @param status Ptr to interrupt status. You can use @a IntrStatus_t::val
01111      * @return 0 on success
01112      */
01113     int get_interrupt_status( uint8_t *status )
01114     {
01115         return 1;
01116     }
01117 
01118     /**
01119      * @brief Clear given system interrupt condition
01120      *
01121      * @par Function Description
01122      * Clear given interrupt cause by writing into register #SYSTEM_INTERRUPT_CLEAR register.
01123      * @param dev       The device
01124      * @param int_clear  Which interrupt source to clear. Use any combinations of #INTERRUPT_CLEAR_RANGING , #INTERRUPT_CLEAR_ALS , #INTERRUPT_CLEAR_ERROR.
01125      * @return  0       On success
01126      */
01127     int clear_interrupt( uint8_t int_clear )
01128     {
01129         return vl53l0x_clear_interrupt_mask( _device, int_clear );
01130     }
01131 
01132 
01133 private:
01134     /* api.h functions */
01135 
01136     /**
01137      *
01138      * @brief One time device initialization
01139      *
01140      * To be called once and only once after device is brought out of reset
01141      * (Chip enable) and booted see @a VL53L0X_WaitDeviceBooted()
01142      *
01143      * @par Function Description
01144      * When not used after a fresh device "power up" or reset, it may return
01145      * @a #VL53L0X_ERROR_CALIBRATION_WARNING meaning wrong calibration data
01146      * may have been fetched from device that can result in ranging offset error\n
01147      * If application cannot execute device reset or need to run VL53L0X_DataInit
01148      * multiple time then it  must ensure proper offset calibration saving and
01149      * restore on its own by using @a VL53L0X_GetOffsetCalibrationData() on first
01150      * power up and then @a VL53L0X_SetOffsetCalibrationData() in all subsequent init
01151      * This function will change the VL53L0X_State from VL53L0X_STATE_POWERDOWN to
01152      * VL53L0X_STATE_WAIT_STATICINIT.
01153      *
01154      * @note This function Access to the device
01155      *
01156      * @param   dev                   Device Handle
01157      * @return  VL53L0X_ERROR_NONE     Success
01158      * @return  "Other error code"    See ::VL53L0X_Error
01159      */
01160     VL53L0X_Error vl53l0x_data_init( VL53L0X_DEV dev );
01161     /**
01162      * @brief Get part to part calibration offset
01163      *
01164      * @par Function Description
01165      * Should only be used after a successful call to @a VL53L0X_DataInit to backup
01166      * device NVM value
01167      *
01168      * @note This function Access to the device
01169      *
01170      * @param   dev                                Device Handle
01171      * @param   p_offset_calibration_data_micro_meter   Return part to part
01172      * calibration offset from device (microns)
01173      * @return  VL53L0X_ERROR_NONE                  Success
01174      * @return  "Other error code"                 See ::VL53L0X_Error
01175      */
01176     VL53L0X_Error vl53l0x_get_offset_calibration_data_micro_meter( VL53L0X_DEV dev,
01177             int32_t *p_offset_calibration_data_micro_meter );
01178     /**
01179      * Set or over-hide part to part calibration offset
01180      * \sa VL53L0X_DataInit()   VL53L0X_GetOffsetCalibrationDataMicroMeter()
01181      *
01182      * @note This function Access to the device
01183      *
01184      * @param   dev                                Device Handle
01185      * @param   p_offset_calibration_data_micro_meter    Offset (microns)
01186      * @return  VL53L0X_ERROR_NONE                  Success
01187      * @return  "Other error code"                 See ::VL53L0X_Error
01188      */
01189     VL53L0X_Error vl53l0x_set_offset_calibration_data_micro_meter( VL53L0X_DEV dev,
01190             int32_t offset_calibration_data_micro_meter );
01191     /**
01192      * @brief  Retrieve current device parameters
01193      * @par Function Description
01194      * Get actual parameters of the device
01195      * @li Then start ranging operation.
01196      *
01197      * @note This function Access to the device
01198      *
01199      * @param   dev                   Device Handle
01200      * @param   p_device_parameters     Pointer to store current device parameters.
01201      * @return  VL53L0X_ERROR_NONE     Success
01202      * @return  "Other error code"    See ::VL53L0X_Error
01203      */
01204     VL53L0X_Error vl53l0x_get_device_parameters( VL53L0X_DEV dev,
01205             VL53L0X_DeviceParameters_t *p_device_parameters );
01206     /**
01207      * @brief  Get current new device mode
01208      * @par Function Description
01209      * Get actual mode of the device(ranging, histogram ...)
01210      *
01211      * @note This function doesn't Access to the device
01212      *
01213      * @param   dev                   Device Handle
01214      * @param   p_device_mode           Pointer to current apply mode value
01215      *                                Valid values are:
01216      *                                VL53L0X_DEVICEMODE_SINGLE_RANGING
01217      *                                VL53L0X_DEVICEMODE_CONTINUOUS_RANGING
01218      *                                VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING
01219      *                                VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM
01220      *                                VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY
01221      *                                VL53L0X_HISTOGRAMMODE_RETURN_ONLY
01222      *                                VL53L0X_HISTOGRAMMODE_BOTH
01223      *
01224      * @return  VL53L0X_ERROR_NONE                   Success
01225      * @return  VL53L0X_ERROR_MODE_NOT_SUPPORTED     This error occurs when
01226      * DeviceMode is not in the supported list
01227      */
01228     VL53L0X_Error vl53l0x_get_device_mode( VL53L0X_DEV dev,
01229                                            VL53L0X_DeviceModes *p_device_mode );
01230     /**
01231      * Get continuous mode Inter-Measurement period in milliseconds
01232      *
01233      * @par Function Description
01234      * When trying to set too short time return  INVALID_PARAMS minimal value
01235      *
01236      * @note This function Access to the device
01237      *
01238      * @param   dev                                  Device Handle
01239      * @param   p_inter_measurement_period_milli_seconds  Pointer to programmed
01240      *  Inter-Measurement Period in milliseconds.
01241      * @return  VL53L0X_ERROR_NONE                    Success
01242      * @return  "Other error code"                   See ::VL53L0X_Error
01243      */
01244     VL53L0X_Error vl53l0x_get_inter_measurement_period_milli_seconds( VL53L0X_DEV dev,
01245             uint32_t *p_inter_measurement_period_milli_seconds );
01246     /**
01247      * @brief Get Cross talk compensation rate
01248      *
01249      * @par Function Description
01250      * Get Cross talk compensation rate.
01251      *
01252      * @note This function Access to the device
01253      *
01254      * @param   dev                            Device Handle
01255      * @param   p_xtalk_compensation_rate_mega_cps  Pointer to Compensation rate
01256      in Mega counts per second (16.16 fix point) see datasheet for details
01257      * @return  VL53L0X_ERROR_NONE              Success
01258      * @return  "Other error code"             See ::VL53L0X_Error
01259      */
01260     VL53L0X_Error vl53l0x_get_x_talk_compensation_rate_mega_cps( VL53L0X_DEV dev,
01261             FixPoint1616_t *p_xtalk_compensation_rate_mega_cps );
01262     /**
01263      * @brief  Get a specific limit check value
01264      *
01265      * @par Function Description
01266      * This function get a specific limit check value from device then it updates
01267      * internal values and check enables.
01268      * The limit check is identified with the LimitCheckId.
01269      *
01270      * @note This function Access to the device
01271      *
01272      * @param   dev                           Device Handle
01273      * @param   limit_check_id                  Limit Check ID
01274      *  (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
01275      * @param   p_limit_check_value              Pointer to Limit
01276      *  check Value for a given LimitCheckId.
01277      * @return  VL53L0X_ERROR_NONE             Success
01278      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is returned
01279      *  when LimitCheckId value is out of range.
01280      * @return  "Other error code"            See ::VL53L0X_Error
01281      */
01282     VL53L0X_Error vl53l0x_get_limit_check_value( VL53L0X_DEV dev, uint16_t limit_check_id,
01283             FixPoint1616_t *p_limit_check_value );
01284     /**
01285      * @brief  Get specific limit check enable state
01286      *
01287      * @par Function Description
01288      * This function get the enable state of a specific limit check.
01289      * The limit check is identified with the LimitCheckId.
01290      *
01291      * @note This function Access to the device
01292      *
01293      * @param   dev                           Device Handle
01294      * @param   limit_check_id                  Limit Check ID
01295      *  (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
01296      * @param   p_limit_check_enable             Pointer to the check limit enable
01297      * value.
01298      *  if 1 the check limit
01299      *        corresponding to LimitCheckId is Enabled
01300      *  if 0 the check limit
01301      *        corresponding to LimitCheckId is disabled
01302      * @return  VL53L0X_ERROR_NONE             Success
01303      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is returned
01304      *  when LimitCheckId value is out of range.
01305      * @return  "Other error code"            See ::VL53L0X_Error
01306      */
01307     VL53L0X_Error vl53l0x_get_limit_check_enable( VL53L0X_DEV dev, uint16_t limit_check_id,
01308             uint8_t *p_limit_check_enable );
01309     /**
01310      * @brief  Get setup of Wrap around Check
01311      *
01312      * @par Function Description
01313      * This function get the wrapAround check enable parameters
01314      *
01315      * @note This function Access to the device
01316      *
01317      * @param   dev                     Device Handle
01318      * @param   p_wrap_around_check_enable  Pointer to the Wrap around Check state
01319      *                                  0=disabled or 1 = enabled
01320      * @return  VL53L0X_ERROR_NONE       Success
01321      * @return  "Other error code"      See ::VL53L0X_Error
01322      */
01323     VL53L0X_Error vl53l0x_get_wrap_around_check_enable( VL53L0X_DEV dev,
01324             uint8_t *p_wrap_around_check_enable );
01325     /**
01326      * @brief Get Ranging Timing Budget in microseconds
01327      *
01328      * @par Function Description
01329      * Returns the programmed the maximum time allowed by the user to the
01330      * device to run a full ranging sequence for the current mode
01331      * (ranging, histogram, ASL ...)
01332      *
01333      * @note This function Access to the device
01334      *
01335      * @param   dev                                    Device Handle
01336      * @param   p_measurement_timing_budget_micro_seconds   Max measurement time in
01337      * microseconds.
01338      *                                   Valid values are:
01339      *                                   >= 17000 microsecs when wraparound enabled
01340      *                                   >= 12000 microsecs when wraparound disabled
01341      * @return  VL53L0X_ERROR_NONE                      Success
01342      * @return  "Other error code"                     See ::VL53L0X_Error
01343      */
01344     VL53L0X_Error vl53l0x_get_measurement_timing_budget_micro_seconds( VL53L0X_DEV dev,
01345             uint32_t *p_measurement_timing_budget_micro_seconds );
01346 
01347     /**
01348      * @brief Gets the (on/off) state of all sequence steps.
01349      *
01350      * @par Function Description
01351      * This function retrieves the state of all sequence step in the scheduler.
01352      *
01353      * @note This function Accesses the device
01354      *
01355      * @param   dev                          Device Handle
01356      * @param   p_scheduler_sequence_steps      Pointer to struct containing result.
01357      * @return  VL53L0X_ERROR_NONE            Success
01358      * @return  "Other error code"           See ::VL53L0X_Error
01359      */
01360     VL53L0X_Error vl53l0x_get_sequence_step_enables( VL53L0X_DEV dev,
01361             VL53L0X_SchedulerSequenceSteps_t *p_scheduler_sequence_steps );
01362     /**
01363      * @brief Gets the VCSEL pulse period.
01364      *
01365      * @par Function Description
01366      * This function retrieves the VCSEL pulse period for the given period type.
01367      *
01368      * @note This function Accesses the device
01369      *
01370      * @param   dev                      Device Handle
01371      * @param   vcsel_period_type          VCSEL period identifier (pre-range|final).
01372      * @param   p_vcsel_pulse_period_pclk        Pointer to VCSEL period value.
01373      * @return  VL53L0X_ERROR_NONE        Success
01374      * @return  VL53L0X_ERROR_INVALID_PARAMS  Error VcselPeriodType parameter not
01375      *                                       supported.
01376      * @return  "Other error code"           See ::VL53L0X_Error
01377      */
01378     VL53L0X_Error vl53l0x_get_vcsel_pulse_period( VL53L0X_DEV dev,
01379             VL53L0X_VcselPeriod vcsel_period_type, uint8_t *p_vcsel_pulse_period_pclk );
01380     /**
01381      * @brief Reads the Device information for given Device
01382      *
01383      * @note This function Access to the device
01384      *
01385      * @param   dev                 Device Handle
01386      * @param   p_vl53l0x_device_info  Pointer to current device info for a given
01387      *  Device
01388      * @return  VL53L0X_ERROR_NONE   Success
01389      * @return  "Other error code"  See ::VL53L0X_Error
01390      */
01391     VL53L0X_Error vl53l0x_get_device_info( VL53L0X_DEV dev,
01392                                            VL53L0X_DeviceInfo_t *p_vl53l0x_device_info );
01393     /**
01394      * @brief Do basic device init (and eventually patch loading)
01395      * This function will change the VL53L0X_State from
01396      * VL53L0X_STATE_WAIT_STATICINIT to VL53L0X_STATE_IDLE.
01397      * In this stage all default setting will be applied.
01398      *
01399      * @note This function Access to the device
01400      *
01401      * @param   dev                   Device Handle
01402      * @return  VL53L0X_ERROR_NONE     Success
01403      * @return  "Other error code"    See ::VL53L0X_Error
01404      */
01405     VL53L0X_Error vl53l0x_static_init( VL53L0X_DEV dev );
01406 
01407     /**
01408      * @brief Return Measurement Data Ready
01409      *
01410      * @par Function Description
01411      * This function indicate that a measurement data is ready.
01412      * This function check if interrupt mode is used then check is done accordingly.
01413      * If perform function clear the interrupt, this function will not work,
01414      * like in case of @a VL53L0X_PerformSingleRangingMeasurement().
01415      * The previous function is blocking function, VL53L0X_GetMeasurementDataReady
01416      * is used for non-blocking capture.
01417      *
01418      * @note This function Access to the device
01419      *
01420      * @param   dev                    Device Handle
01421      * @param   p_measurement_data_ready  Pointer to Measurement Data Ready.
01422      *  0=data not ready, 1 = data ready
01423      * @return  VL53L0X_ERROR_NONE      Success
01424      * @return  "Other error code"     See ::VL53L0X_Error
01425      */
01426     VL53L0X_Error vl53l0x_get_measurement_data_ready( VL53L0X_DEV dev,
01427             uint8_t *p_measurement_data_ready );
01428     /**
01429      * @brief Return device interrupt status
01430      *
01431      * @par Function Description
01432      * Returns currently raised interrupts by the device.
01433      * User shall be able to activate/deactivate interrupts through
01434      * @a VL53L0X_SetGpioConfig()
01435      *
01436      * @note This function Access to the device
01437      *
01438      * @param   dev                    Device Handle
01439      * @param   p_interrupt_mask_status   Pointer to status variable to update
01440      * @return  VL53L0X_ERROR_NONE      Success
01441      * @return  "Other error code"     See ::VL53L0X_Error
01442      */
01443     VL53L0X_Error vl53l0x_get_interrupt_mask_status( VL53L0X_DEV dev,
01444             uint32_t *p_interrupt_mask_status );
01445     /**
01446      * @brief Clear given system interrupt condition
01447      *
01448      * @par Function Description
01449      * Clear given interrupt(s).
01450      *
01451      * @note This function Access to the device
01452      *
01453      * @param   dev                  Device Handle
01454      * @param   interrupt_mask        Mask of interrupts to clear
01455      * @return  VL53L0X_ERROR_NONE    Success
01456      * @return  VL53L0X_ERROR_INTERRUPT_NOT_CLEARED    Cannot clear interrupts
01457      *
01458      * @return  "Other error code"   See ::VL53L0X_Error
01459      */
01460     VL53L0X_Error vl53l0x_clear_interrupt_mask( VL53L0X_DEV dev, uint32_t interrupt_mask );
01461     /**
01462      * @brief Performs a single ranging measurement and retrieve the ranging
01463      * measurement data
01464      *
01465      * @par Function Description
01466      * This function will change the device mode to VL53L0X_DEVICEMODE_SINGLE_RANGING
01467      * with @a VL53L0X_SetDeviceMode(),
01468      * It performs measurement with @a VL53L0X_PerformSingleMeasurement()
01469      * It get data from last successful Ranging measurement with
01470      * @a VL53L0X_GetRangingMeasurementData.
01471      * Finally it clear the interrupt with @a VL53L0X_ClearInterruptMask().
01472      *
01473      * @note This function Access to the device
01474      *
01475      * @note This function change the device mode to
01476      * VL53L0X_DEVICEMODE_SINGLE_RANGING
01477      *
01478      * @param   dev                       Device Handle
01479      * @param   p_ranging_measurement_data   Pointer to the data structure to fill up.
01480      * @return  VL53L0X_ERROR_NONE         Success
01481      * @return  "Other error code"        See ::VL53L0X_Error
01482      */
01483     VL53L0X_Error vl53l0x_perform_single_ranging_measurement( VL53L0X_DEV dev,
01484             VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data );
01485     /**
01486      * @brief  Set a new device mode
01487      * @par Function Description
01488      * Set device to a new mode (ranging, histogram ...)
01489      *
01490      * @note This function doesn't Access to the device
01491      *
01492      * @param   dev                   Device Handle
01493      * @param   device_mode            New device mode to apply
01494      *                                Valid values are:
01495      *                                VL53L0X_DEVICEMODE_SINGLE_RANGING
01496      *                                VL53L0X_DEVICEMODE_CONTINUOUS_RANGING
01497      *                                VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING
01498      *                                VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM
01499      *                                VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY
01500      *                                VL53L0X_HISTOGRAMMODE_RETURN_ONLY
01501      *                                VL53L0X_HISTOGRAMMODE_BOTH
01502      *
01503      *
01504      * @return  VL53L0X_ERROR_NONE               Success
01505      * @return  VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when DeviceMode is
01506      *                                          not in the supported list
01507      */
01508     VL53L0X_Error vl53l0x_set_device_mode( VL53L0X_DEV dev, VL53L0X_DeviceModes device_mode );
01509     /**
01510      * @brief Single shot measurement.
01511      *
01512      * @par Function Description
01513      * Perform simple measurement sequence (Start measure, Wait measure to end,
01514      * and returns when measurement is done).
01515      * Once function returns, user can get valid data by calling
01516      * VL53L0X_GetRangingMeasurement or VL53L0X_GetHistogramMeasurement
01517      * depending on defined measurement mode
01518      * User should Clear the interrupt in case this are enabled by using the
01519      * function VL53L0X_ClearInterruptMask().
01520      *
01521      * @warning This function is a blocking function
01522      *
01523      * @note This function Access to the device
01524      *
01525      * @param   dev                  Device Handle
01526      * @return  VL53L0X_ERROR_NONE    Success
01527      * @return  "Other error code"   See ::VL53L0X_Error
01528      */
01529     VL53L0X_Error vl53l0x_perform_single_measurement( VL53L0X_DEV dev );
01530     /**
01531      * @brief Start device measurement
01532      *
01533      * @details Started measurement will depend on device parameters set through
01534      * @a VL53L0X_SetParameters()
01535      * This is a non-blocking function.
01536      * This function will change the VL53L0X_State from VL53L0X_STATE_IDLE to
01537      * VL53L0X_STATE_RUNNING.
01538      *
01539      * @note This function Access to the device
01540      *
01541 
01542      * @param   dev                  Device Handle
01543      * @return  VL53L0X_ERROR_NONE                  Success
01544      * @return  VL53L0X_ERROR_MODE_NOT_SUPPORTED    This error occurs when
01545      * DeviceMode programmed with @a VL53L0X_SetDeviceMode is not in the supported
01546      * list:
01547      *                                   Supported mode are:
01548      *                                   VL53L0X_DEVICEMODE_SINGLE_RANGING,
01549      *                                   VL53L0X_DEVICEMODE_CONTINUOUS_RANGING,
01550      *                                   VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING
01551      * @return  VL53L0X_ERROR_TIME_OUT    Time out on start measurement
01552      * @return  "Other error code"   See ::VL53L0X_Error
01553      */
01554     VL53L0X_Error vl53l0x_start_measurement( VL53L0X_DEV dev );
01555 
01556     /**
01557      * @brief Set low and high Interrupt thresholds for a given mode
01558      * (ranging, ALS, ...) for a given device
01559      *
01560      * @par Function Description
01561      * Set low and high Interrupt thresholds for a given mode (ranging, ALS, ...)
01562      * for a given device
01563      *
01564      * @note This function Access to the device
01565      *
01566      * @note DeviceMode is ignored for the current device
01567      *
01568      * @param   dev              Device Handle
01569      * @param   device_mode       Device Mode for which change thresholds
01570      * @param   threshold_low     Low threshold (mm, lux ..., depending on the mode)
01571      * @param   threshold_high    High threshold (mm, lux ..., depending on the mode)
01572      * @return  VL53L0X_ERROR_NONE    Success
01573      * @return  "Other error code"   See ::VL53L0X_Error
01574      */
01575     VL53L0X_Error vl53l0x_set_interrupt_thresholds( VL53L0X_DEV dev,
01576             VL53L0X_DeviceModes device_mode, FixPoint1616_t threshold_low,
01577             FixPoint1616_t threshold_high );
01578     /**
01579      * @brief  Get high and low Interrupt thresholds for a given mode
01580      *  (ranging, ALS, ...) for a given device
01581      *
01582      * @par Function Description
01583      * Get high and low Interrupt thresholds for a given mode (ranging, ALS, ...)
01584      * for a given device
01585      *
01586      * @note This function Access to the device
01587      *
01588      * @note DeviceMode is ignored for the current device
01589      *
01590      * @param   dev              Device Handle
01591      * @param   device_mode       Device Mode from which read thresholds
01592      * @param   p_threshold_low    Low threshold (mm, lux ..., depending on the mode)
01593      * @param   p_threshold_high   High threshold (mm, lux ..., depending on the mode)
01594      * @return  VL53L0X_ERROR_NONE   Success
01595      * @return  "Other error code"  See ::VL53L0X_Error
01596      */
01597     VL53L0X_Error vl53l0x_get_interrupt_thresholds( VL53L0X_DEV dev,
01598             VL53L0X_DeviceModes device_mode, FixPoint1616_t *p_threshold_low,
01599             FixPoint1616_t *p_threshold_high );
01600 
01601     /**
01602      * @brief Retrieve the measurements from device for a given setup
01603      *
01604      * @par Function Description
01605      * Get data from last successful Ranging measurement
01606      * @warning USER should take care about  @a VL53L0X_GetNumberOfROIZones()
01607      * before get data.
01608      * PAL will fill a NumberOfROIZones times the corresponding data
01609      * structure used in the measurement function.
01610      *
01611      * @note This function Access to the device
01612      *
01613      * @param   dev                      Device Handle
01614      * @param   p_ranging_measurement_data  Pointer to the data structure to fill up.
01615      * @return  VL53L0X_ERROR_NONE        Success
01616      * @return  "Other error code"       See ::VL53L0X_Error
01617      */
01618     VL53L0X_Error vl53l0x_get_ranging_measurement_data( VL53L0X_DEV dev,
01619             VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data );
01620     /**
01621      * @brief Get Cross talk compensation rate
01622      *
01623      * @note This function is not Implemented.
01624      * Enable/Disable Cross Talk by set to zero the Cross Talk value by
01625      * using @a VL53L0X_SetXTalkCompensationRateMegaCps().
01626      *
01627      * @param   dev                        Device Handle
01628      * @param   p_x_talk_compensation_enable   Pointer to the Cross talk compensation
01629      *  state 0=disabled or 1 = enabled
01630      * @return  VL53L0X_ERROR_NOT_IMPLEMENTED   Not implemented
01631      */
01632     VL53L0X_Error vl53l0x_get_x_talk_compensation_enable( VL53L0X_DEV dev,
01633             uint8_t *p_x_talk_compensation_enable );
01634     /**
01635      * @brief Wait for device booted after chip enable (hardware standby)
01636      * This function can be run only when VL53L0X_State is VL53L0X_STATE_POWERDOWN.
01637      *
01638      * @note This function is not Implemented
01639      *
01640      * @param   dev      Device Handle
01641      * @return  VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
01642      *
01643      */
01644     VL53L0X_Error vl53l0x_wait_device_booted( VL53L0X_DEV dev );
01645     /**
01646      * @brief Perform Reference Calibration
01647      *
01648      * @details Perform a reference calibration of the Device.
01649      * This function should be run from time to time before doing
01650      * a ranging measurement.
01651      * This function will launch a special ranging measurement, so
01652      * if interrupt are enable an interrupt will be done.
01653      * This function will clear the interrupt generated automatically.
01654      *
01655      * @warning This function is a blocking function
01656      *
01657      * @note This function Access to the device
01658      *
01659      * @param   dev                  Device Handle
01660      * @param   p_vhv_settings         Pointer to vhv settings parameter.
01661      * @param   p_phase_cal            Pointer to PhaseCal parameter.
01662      * @return  VL53L0X_ERROR_NONE    Success
01663      * @return  "Other error code"   See ::VL53L0X_Error
01664      */
01665     VL53L0X_Error vl53l0x_perform_ref_calibration( VL53L0X_DEV dev, uint8_t *p_vhv_settings,
01666             uint8_t *p_phase_cal );
01667     /**
01668      * @brief Performs Reference Spad Management
01669      *
01670      * @par Function Description
01671      * The reference SPAD initialization procedure determines the minimum amount
01672      * of reference spads to be enables to achieve a target reference signal rate
01673      * and should be performed once during initialization.
01674      *
01675      * @note This function Access to the device
01676      *
01677      * @note This function change the device mode to
01678      * VL53L0X_DEVICEMODE_SINGLE_RANGING
01679      *
01680      * @param   dev                          Device Handle
01681      * @param   ref_spad_count                 Reports ref Spad Count
01682      * @param   is_aperture_spads              Reports if spads are of type
01683      *                                       aperture or non-aperture.
01684      *                                       1:=aperture, 0:=Non-Aperture
01685      * @return  VL53L0X_ERROR_NONE            Success
01686      * @return  VL53L0X_ERROR_REF_SPAD_INIT   Error in the Ref Spad procedure.
01687      * @return  "Other error code"           See ::VL53L0X_Error
01688      */
01689     VL53L0X_Error vl53l0x_perform_ref_spad_management( VL53L0X_DEV dev,
01690             uint32_t *ref_spad_count, uint8_t *is_aperture_spads );
01691     /**
01692      * @brief Set new device address
01693      *
01694      * After completion the device will answer to the new address programmed.
01695      * This function should be called when several devices are used in parallel
01696      * before start programming the sensor.
01697      * When a single device us used, there is no need to call this function.
01698      *
01699      * @note This function Access to the device
01700      *
01701      * @param   dev                   Device Handle
01702      * @param   device_address         The new Device address
01703      * @return  VL53L0X_ERROR_NONE     Success
01704      * @return  "Other error code"    See ::VL53L0X_Error
01705      */
01706     VL53L0X_Error vl53l0x_set_device_address( VL53L0X_DEV dev, uint8_t device_address );
01707     /**
01708      * @brief Set the configuration of GPIO pin for a given device
01709      *
01710      * @note This function Access to the device
01711      *
01712      * @param   dev                   Device Handle
01713      * @param   pin                   ID of the GPIO Pin
01714      * @param   functionality         Select Pin functionality.
01715      *  Refer to ::VL53L0X_GpioFunctionality
01716      * @param   device_mode            Device Mode associated to the Gpio.
01717      * @param   polarity              Set interrupt polarity. Active high
01718      *   or active low see ::VL53L0X_InterruptPolarity
01719      * @return  VL53L0X_ERROR_NONE                            Success
01720      * @return  VL53L0X_ERROR_GPIO_NOT_EXISTING               Only Pin=0 is accepted.
01721      * @return  VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED    This error occurs
01722      * when Functionality programmed is not in the supported list:
01723      *                             Supported value are:
01724      *                             VL53L0X_GPIOFUNCTIONALITY_OFF,
01725      *                             VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW,
01726      *                             VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH,
01727      VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT,
01728      *                               VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY
01729      * @return  "Other error code"    See ::VL53L0X_Error
01730      */
01731     VL53L0X_Error vl53l0x_set_gpio_config( VL53L0X_DEV dev, uint8_t pin,
01732                                            VL53L0X_DeviceModes device_mode, VL53L0X_GpioFunctionality functionality,
01733                                            VL53L0X_InterruptPolarity polarity );
01734     /**
01735      * @brief  Gets the fraction enable parameter indicating the resolution of
01736      * range measurements.
01737      *
01738      * @par Function Description
01739      * Gets the fraction enable state, which translates to the resolution of
01740      * range measurements as follows :Enabled:=0.25mm resolution,
01741      * Not Enabled:=1mm resolution.
01742      *
01743      * @note This function Accesses the device
01744      *
01745      * @param   dev               Device Handle
01746      * @param   p_enabled           Output Parameter reporting the fraction enable state.
01747      *
01748      * @return  VL53L0X_ERROR_NONE                   Success
01749      * @return  "Other error code"                  See ::VL53L0X_Error
01750      */
01751     VL53L0X_Error vl53l0x_get_fraction_enable( VL53L0X_DEV dev, uint8_t *p_enabled );
01752 
01753     /**
01754      * @brief Sets the (on/off) state of a requested sequence step.
01755      *
01756      * @par Function Description
01757      * This function enables/disables a requested sequence step.
01758      *
01759      * @note This function Accesses the device
01760      *
01761      * @param   dev                          Device Handle
01762      * @param   sequence_step_id             Sequence step identifier.
01763      * @param   sequence_step_enabled          Demanded state {0=Off,1=On}
01764      *                                       is enabled.
01765      * @return  VL53L0X_ERROR_NONE            Success
01766      * @return  VL53L0X_ERROR_INVALID_PARAMS  Error SequenceStepId parameter not
01767      *                                       supported.
01768      * @return  "Other error code"           See ::VL53L0X_Error
01769      */
01770     VL53L0X_Error vl53l0x_set_sequence_step_enable( VL53L0X_DEV dev,
01771             VL53L0X_SequenceStepId sequence_step_id, uint8_t sequence_step_enabled );
01772     /**
01773      * @brief Set Ranging Timing Budget in microseconds
01774      *
01775      * @par Function Description
01776      * Defines the maximum time allowed by the user to the device to run a
01777      * full ranging sequence for the current mode (ranging, histogram, ASL ...)
01778      *
01779      * @note This function Access to the device
01780      *
01781      * @param   dev                                Device Handle
01782      * @param measurement_timing_budget_micro_seconds  Max measurement time in
01783      * microseconds.
01784      *                                   Valid values are:
01785      *                                   >= 17000 microsecs when wraparound enabled
01786      *                                   >= 12000 microsecs when wraparound disabled
01787      * @return  VL53L0X_ERROR_NONE             Success
01788      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is returned if
01789      MeasurementTimingBudgetMicroSeconds out of range
01790      * @return  "Other error code"            See ::VL53L0X_Error
01791      */
01792     VL53L0X_Error vl53l0x_set_measurement_timing_budget_micro_seconds( VL53L0X_DEV dev,
01793             uint32_t measurement_timing_budget_micro_seconds );
01794     /**
01795      * @brief  Enable/Disable a specific limit check
01796      *
01797      * @par Function Description
01798      * This function Enable/Disable a specific limit check.
01799      * The limit check is identified with the LimitCheckId.
01800      *
01801      * @note This function doesn't Access to the device
01802      *
01803      * @param   dev                           Device Handle
01804      * @param   limit_check_id                  Limit Check ID
01805      *  (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
01806      * @param   limit_check_enable              if 1 the check limit
01807      *  corresponding to LimitCheckId is Enabled
01808      *                                        if 0 the check limit
01809      *  corresponding to LimitCheckId is disabled
01810      * @return  VL53L0X_ERROR_NONE             Success
01811      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is returned
01812      *  when LimitCheckId value is out of range.
01813      * @return  "Other error code"            See ::VL53L0X_Error
01814      */
01815     VL53L0X_Error vl53l0x_set_limit_check_enable( VL53L0X_DEV dev, uint16_t limit_check_id,
01816             uint8_t limit_check_enable );
01817     /**
01818      * @brief  Set a specific limit check value
01819      *
01820      * @par Function Description
01821      * This function set a specific limit check value.
01822      * The limit check is identified with the LimitCheckId.
01823      *
01824      * @note This function Access to the device
01825      *
01826      * @param   dev                           Device Handle
01827      * @param   limit_check_id                  Limit Check ID
01828      *  (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
01829      * @param   limit_check_value               Limit check Value for a given
01830      * LimitCheckId
01831      * @return  VL53L0X_ERROR_NONE             Success
01832      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is returned when either
01833      *  LimitCheckId or LimitCheckValue value is out of range.
01834      * @return  "Other error code"            See ::VL53L0X_Error
01835      */
01836     VL53L0X_Error vl53l0x_set_limit_check_value( VL53L0X_DEV dev, uint16_t limit_check_id,
01837             FixPoint1616_t limit_check_value );
01838     /**
01839      * @brief Stop device measurement
01840      *
01841      * @details Will set the device in standby mode at end of current measurement\n
01842      *          Not necessary in single mode as device shall return automatically
01843      *          in standby mode at end of measurement.
01844      *          This function will change the VL53L0X_State from VL53L0X_STATE_RUNNING
01845      *          to VL53L0X_STATE_IDLE.
01846      *
01847      * @note This function Access to the device
01848      *
01849      * @param   dev                  Device Handle
01850      * @return  VL53L0X_ERROR_NONE    Success
01851      * @return  "Other error code"   See ::VL53L0X_Error
01852      */
01853     VL53L0X_Error vl53l0x_stop_measurement( VL53L0X_DEV dev );
01854     /**
01855      * @brief Return device stop completion status
01856      *
01857      * @par Function Description
01858      * Returns stop completiob status.
01859      * User shall call this function after a stop command
01860      *
01861      * @note This function Access to the device
01862      *
01863      * @param   dev                    Device Handle
01864      * @param   p_stop_status            Pointer to status variable to update
01865      * @return  VL53L0X_ERROR_NONE      Success
01866      * @return  "Other error code"     See ::VL53L0X_Error
01867      */
01868     VL53L0X_Error vl53l0x_get_stop_completed_status( VL53L0X_DEV dev,
01869             uint32_t *p_stop_status );
01870     /**
01871      * @brief Sets the VCSEL pulse period.
01872      *
01873      * @par Function Description
01874      * This function retrieves the VCSEL pulse period for the given period type.
01875      *
01876      * @note This function Accesses the device
01877      *
01878      * @param   dev                       Device Handle
01879      * @param   vcsel_period_type         VCSEL period identifier (pre-range|final).
01880      * @param   vcsel_pulse_period          VCSEL period value
01881      * @return  VL53L0X_ERROR_NONE            Success
01882      * @return  VL53L0X_ERROR_INVALID_PARAMS  Error VcselPeriodType parameter not
01883      *                                       supported.
01884      * @return  "Other error code"           See ::VL53L0X_Error
01885      */
01886     VL53L0X_Error vl53l0x_set_vcsel_pulse_period( VL53L0X_DEV dev,
01887             VL53L0X_VcselPeriod vcsel_period_type, uint8_t vcsel_pulse_period );
01888 
01889 
01890     VL53L0X_Error sequence_step_enabled( VL53L0X_DEV dev,
01891                                          VL53L0X_SequenceStepId sequence_step_id, uint8_t sequence_config,
01892                                          uint8_t *p_sequence_step_enabled );
01893 
01894     VL53L0X_Error vl53l0x_check_and_load_interrupt_settings( VL53L0X_DEV dev,
01895             uint8_t start_not_stopflag );
01896 
01897 
01898     /* api_core.h functions */
01899 
01900     VL53L0X_Error vl53l0x_get_info_from_device( VL53L0X_DEV dev, uint8_t option );
01901 
01902     VL53L0X_Error vl53l0x_device_read_strobe( VL53L0X_DEV dev );
01903 
01904     VL53L0X_Error wrapped_vl53l0x_get_measurement_timing_budget_micro_seconds( VL53L0X_DEV dev,
01905             uint32_t *p_measurement_timing_budget_micro_seconds );
01906 
01907     VL53L0X_Error wrapped_vl53l0x_get_vcsel_pulse_period( VL53L0X_DEV dev,
01908             VL53L0X_VcselPeriod vcsel_period_type, uint8_t *p_vcsel_pulse_period_pclk );
01909 
01910     uint8_t vl53l0x_decode_vcsel_period( uint8_t vcsel_period_reg );
01911 
01912     uint32_t vl53l0x_decode_timeout( uint16_t encoded_timeout );
01913 
01914     uint32_t vl53l0x_calc_timeout_us( VL53L0X_DEV dev,
01915                                       uint16_t timeout_period_mclks,
01916                                       uint8_t vcsel_period_pclks );
01917 
01918     uint32_t vl53l0x_calc_macro_period_ps( VL53L0X_DEV dev, uint8_t vcsel_period_pclks );
01919 
01920     VL53L0X_Error vl53l0x_measurement_poll_for_completion( VL53L0X_DEV dev );
01921 
01922     VL53L0X_Error vl53l0x_load_tuning_settings( VL53L0X_DEV dev,
01923             uint8_t *p_tuning_setting_buffer );
01924 
01925     VL53L0X_Error vl53l0x_get_pal_range_status( VL53L0X_DEV dev,
01926             uint8_t device_range_status,
01927             FixPoint1616_t signal_rate,
01928             uint16_t effective_spad_rtn_count,
01929             VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
01930             uint8_t *p_pal_range_status );
01931     VL53L0X_Error vl53l0x_calc_sigma_estimate( VL53L0X_DEV dev,
01932             VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
01933             FixPoint1616_t *p_sigma_estimate,
01934             uint32_t *p_dmax_mm );
01935     VL53L0X_Error vl53l0x_get_total_signal_rate( VL53L0X_DEV dev,
01936             VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
01937             FixPoint1616_t *p_total_signal_rate_mcps );
01938     VL53L0X_Error vl53l0x_get_total_xtalk_rate( VL53L0X_DEV dev,
01939             VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
01940             FixPoint1616_t *p_total_xtalk_rate_mcps );
01941     uint32_t vl53l0x_calc_timeout_mclks( VL53L0X_DEV dev,
01942                                          uint32_t timeout_period_us,
01943                                          uint8_t vcsel_period_pclks );
01944     uint32_t vl53l0x_isqrt( uint32_t num );
01945 
01946     uint32_t vl53l0x_quadrature_sum( uint32_t a, uint32_t b );
01947 
01948     VL53L0X_Error vl53l0x_calc_dmax(
01949         VL53L0X_DEV dev,
01950         FixPoint1616_t total_signal_rate_mcps,
01951         FixPoint1616_t total_corr_signal_rate_mcps,
01952         FixPoint1616_t pw_mult,
01953         uint32_t sigma_estimate_p1,
01954         FixPoint1616_t sigma_estimate_p2,
01955         uint32_t peak_vcsel_duration_us,
01956         uint32_t *pd_max_mm );
01957     VL53L0X_Error wrapped_vl53l0x_set_measurement_timing_budget_micro_seconds( VL53L0X_DEV dev,
01958             uint32_t measurement_timing_budget_micro_seconds );
01959     VL53L0X_Error get_sequence_step_timeout( VL53L0X_DEV dev,
01960             VL53L0X_SequenceStepId sequence_step_id,
01961             uint32_t *p_time_out_micro_secs );
01962     VL53L0X_Error set_sequence_step_timeout( VL53L0X_DEV dev,
01963             VL53L0X_SequenceStepId sequence_step_id,
01964             uint32_t timeout_micro_secs );
01965     uint16_t vl53l0x_encode_timeout( uint32_t timeout_macro_clks );
01966     VL53L0X_Error wrapped_vl53l0x_set_vcsel_pulse_period( VL53L0X_DEV dev,
01967             VL53L0X_VcselPeriod vcsel_period_type, uint8_t vcsel_pulse_period_pclk );
01968     uint8_t lv53l0x_encode_vcsel_period( uint8_t vcsel_period_pclks );
01969 
01970     /* api_calibration.h functions */
01971     VL53L0X_Error vl53l0x_apply_offset_adjustment( VL53L0X_DEV dev );
01972     VL53L0X_Error wrapped_vl53l0x_get_offset_calibration_data_micro_meter( VL53L0X_DEV dev,
01973             int32_t *p_offset_calibration_data_micro_meter );
01974     VL53L0X_Error wrapped_vl53l0x_set_offset_calibration_data_micro_meter( VL53L0X_DEV dev,
01975             int32_t offset_calibration_data_micro_meter );
01976     VL53L0X_Error wrapped_vl53l0x_perform_ref_spad_management( VL53L0X_DEV dev,
01977             uint32_t *ref_spad_count,
01978             uint8_t *is_aperture_spads );
01979     VL53L0X_Error vl53l0x_perform_ref_calibration( VL53L0X_DEV dev,
01980             uint8_t *p_vhv_settings, uint8_t *p_phase_cal, uint8_t get_data_enable );
01981     VL53L0X_Error vl53l0x_perform_vhv_calibration( VL53L0X_DEV dev,
01982             uint8_t *p_vhv_settings, const uint8_t get_data_enable,
01983             const uint8_t restore_config );
01984     VL53L0X_Error vl53l0x_perform_single_ref_calibration( VL53L0X_DEV dev,
01985             uint8_t vhv_init_byte );
01986     VL53L0X_Error vl53l0x_ref_calibration_io( VL53L0X_DEV dev, uint8_t read_not_write,
01987             uint8_t vhv_settings, uint8_t phase_cal,
01988             uint8_t *p_vhv_settings, uint8_t *p_phase_cal,
01989             const uint8_t vhv_enable, const uint8_t phase_enable );
01990     VL53L0X_Error vl53l0x_perform_phase_calibration( VL53L0X_DEV dev,
01991             uint8_t *p_phase_cal, const uint8_t get_data_enable,
01992             const uint8_t restore_config );
01993     VL53L0X_Error enable_ref_spads( VL53L0X_DEV dev,
01994                                     uint8_t aperture_spads,
01995                                     uint8_t good_spad_array[],
01996                                     uint8_t spad_array[],
01997                                     uint32_t size,
01998                                     uint32_t start,
01999                                     uint32_t offset,
02000                                     uint32_t spad_count,
02001                                     uint32_t *p_last_spad );
02002     void get_next_good_spad( uint8_t good_spad_array[], uint32_t size,
02003                              uint32_t curr, int32_t *p_next );
02004     uint8_t is_aperture( uint32_t spad_index );
02005     VL53L0X_Error enable_spad_bit( uint8_t spad_array[], uint32_t size,
02006                                    uint32_t spad_index );
02007     VL53L0X_Error set_ref_spad_map( VL53L0X_DEV dev, uint8_t *p_ref_spad_array );
02008     VL53L0X_Error get_ref_spad_map( VL53L0X_DEV dev, uint8_t *p_ref_spad_array );
02009     VL53L0X_Error perform_ref_signal_measurement( VL53L0X_DEV dev,
02010             uint16_t *p_ref_signal_rate );
02011     VL53L0X_Error wrapped_vl53l0x_set_reference_spads( VL53L0X_DEV dev,
02012             uint32_t count, uint8_t is_aperture_spads );
02013 
02014     /* api_strings.h functions */
02015     VL53L0X_Error wrapped_vl53l0x_get_device_info( VL53L0X_DEV dev,
02016             VL53L0X_DeviceInfo_t *p_vl53l0x_device_info );
02017     VL53L0X_Error vl53l0x_check_part_used( VL53L0X_DEV dev,
02018                                            uint8_t *revision,
02019                                            VL53L0X_DeviceInfo_t *p_vl53l0x_device_info );
02020 
02021     /* Read function of the ID device */
02022     //   virtual int read_id();
02023     virtual int read_id( uint8_t *id );
02024 
02025     VL53L0X_Error wait_measurement_data_ready( VL53L0X_DEV dev );
02026 
02027     VL53L0X_Error wait_stop_completed( VL53L0X_DEV dev );
02028 
02029     /* Write and read functions from I2C */
02030     /**
02031      * Write single byte register
02032      * @param   dev       Device Handle
02033      * @param   index     The register index
02034      * @param   data      8 bit register data
02035      * @return  VL53L0X_ERROR_NONE        Success
02036      * @return  "Other error code"    See ::VL53L0X_Error
02037      */
02038     VL53L0X_Error vl53l0x_write_byte( VL53L0X_DEV dev, uint8_t index, uint8_t data );
02039     /**
02040      * Write word register
02041      * @param   dev       Device Handle
02042      * @param   index     The register index
02043      * @param   data      16 bit register data
02044      * @return  VL53L0X_ERROR_NONE        Success
02045      * @return  "Other error code"    See ::VL53L0X_Error
02046      */
02047     VL53L0X_Error vl53l0x_write_word( VL53L0X_DEV dev, uint8_t index, uint16_t data );
02048     /**
02049      * Write double word (4 byte) register
02050      * @param   dev       Device Handle
02051      * @param   index     The register index
02052      * @param   data      32 bit register data
02053      * @return  VL53L0X_ERROR_NONE        Success
02054      * @return  "Other error code"    See ::VL53L0X_Error
02055      */
02056     VL53L0X_Error vl53l0x_write_dword( VL53L0X_DEV dev, uint8_t index, uint32_t data );
02057     /**
02058      * Read single byte register
02059      * @param   dev       Device Handle
02060      * @param   index     The register index
02061      * @param   data      pointer to 8 bit data
02062      * @return  VL53L0X_ERROR_NONE        Success
02063      * @return  "Other error code"    See ::VL53L0X_Error
02064      */
02065     VL53L0X_Error vl53l0x_read_byte( VL53L0X_DEV dev, uint8_t index, uint8_t *p_data );
02066     /**
02067      * Read word (2byte) register
02068      * @param   dev       Device Handle
02069      * @param   index     The register index
02070      * @param   data      pointer to 16 bit data
02071      * @return  VL53L0X_ERROR_NONE        Success
02072      * @return  "Other error code"    See ::VL53L0X_Error
02073      */
02074     VL53L0X_Error vl53l0x_read_word( VL53L0X_DEV dev, uint8_t index, uint16_t *p_data );
02075     /**
02076      * Read dword (4byte) register
02077      * @param   dev       Device Handle
02078      * @param   index     The register index
02079      * @param   data      pointer to 32 bit data
02080      * @return  VL53L0X_ERROR_NONE        Success
02081      * @return  "Other error code"    See ::VL53L0X_Error
02082      */
02083     VL53L0X_Error vl53l0x_read_dword( VL53L0X_DEV dev, uint8_t index, uint32_t *p_data );
02084     /**
02085      * Threat safe Update (read/modify/write) single byte register
02086      *
02087      * Final_reg = (Initial_reg & and_data) |or_data
02088      *
02089      * @param   dev        Device Handle
02090      * @param   index      The register index
02091      * @param   and_data    8 bit and data
02092      * @param   or_data     8 bit or data
02093      * @return  VL53L0X_ERROR_NONE        Success
02094      * @return  "Other error code"    See ::VL53L0X_Error
02095      */
02096     VL53L0X_Error vl53l0x_update_byte( VL53L0X_DEV dev, uint8_t index, uint8_t and_data, uint8_t or_data );
02097     /**
02098      * Writes the supplied byte buffer to the device
02099      * @param   dev       Device Handle
02100      * @param   index     The register index
02101      * @param   p_data     Pointer to uint8_t buffer containing the data to be written
02102      * @param   count     Number of bytes in the supplied byte buffer
02103      * @return  VL53L0X_ERROR_NONE        Success
02104      * @return  "Other error code"    See ::VL53L0X_Error
02105      */
02106     VL53L0X_Error vl53l0x_write_multi( VL53L0X_DEV dev, uint8_t index, uint8_t *p_data, uint32_t count );
02107     /**
02108      * Reads the requested number of bytes from the device
02109      * @param   dev       Device Handle
02110      * @param   index     The register index
02111      * @param   p_data     Pointer to the uint8_t buffer to store read data
02112      * @param   count     Number of uint8_t's to read
02113      * @return  VL53L0X_ERROR_NONE        Success
02114      * @return  "Other error code"    See ::VL53L0X_Error
02115      */
02116     VL53L0X_Error vl53l0x_read_multi( VL53L0X_DEV dev, uint8_t index, uint8_t *p_data, uint32_t count );
02117 
02118     /**
02119      * @brief  Writes a buffer towards the I2C peripheral device.
02120      * @param  dev       Device Handle
02121      * @param  p_data pointer to the byte-array data to send
02122      * @param  number_of_bytes number of bytes to be written.
02123      * @retval 0 if ok,
02124      * @retval -1 if an I2C error has occured
02125      * @note   On some devices if NumByteToWrite is greater
02126      *         than one, the RegisterAddr must be masked correctly!
02127      */
02128     VL53L0X_Error vl53l0x_i2c_write( uint8_t dev, uint8_t index, uint8_t *p_data, uint16_t number_of_bytes );
02129 
02130     /**
02131      * @brief  Reads a buffer from the I2C peripheral device.
02132      * @param  dev       Device Handle
02133      * @param  p_data pointer to the byte-array to read data in to
02134      * @param  number_of_bytes number of bytes to be read.
02135      * @retval 0 if ok,
02136      * @retval -1 if an I2C error has occured
02137      * @note   On some devices if NumByteToWrite is greater
02138      *         than one, the RegisterAddr must be masked correctly!
02139      */
02140     VL53L0X_Error vl53l0x_i2c_read( uint8_t dev, uint8_t index, uint8_t *p_data, uint16_t number_of_bytes );
02141 
02142     /**
02143      * @brief execute delay in all polling API call
02144      *
02145      * A typical multi-thread or RTOs implementation is to sleep the task for some 5ms (with 100Hz max rate faster polling is not needed)
02146      * if nothing specific is need you can define it as an empty/void macro
02147      * @code
02148      * #define VL53L0X_PollingDelay(...) (void)0
02149      * @endcode
02150      * @param dev       Device Handle
02151      * @return  VL53L0X_ERROR_NONE        Success
02152      * @return  "Other error code"    See ::VL53L0X_Error
02153      */
02154     VL53L0X_Error vl53l0x_polling_delay( VL53L0X_DEV dev ); /* usually best implemented as a real function */
02155 
02156     int is_present()
02157     {
02158         int status;
02159         uint8_t id = 0;
02160 
02161         status = read_id( &id );
02162         if( status )
02163             VL53L0X_ErrLog( "Failed to read ID device. Device not present!\n\r" );
02164         return status;
02165     }
02166 
02167     ///////////////////////////////////////////////////////////////////////////////////////////////////////
02168     //Added functions                                                                                    //
02169     ///////////////////////////////////////////////////////////////////////////////////////////////////////
02170 
02171     /**
02172      * @brief  Cycle Power to Device
02173      *
02174      * @return status - status 0 = ok, 1 = error
02175      *
02176      */
02177     int32_t vl53l0x_cycle_power( void );
02178 
02179     uint8_t vl53l0x_encode_vcsel_period( uint8_t vcsel_period_pclks );
02180 
02181     VL53L0X_Error wrapped_vl53l0x_get_device_error_string( VL53L0X_DeviceError error_code,
02182             char *p_device_error_string );
02183 
02184     VL53L0X_Error wrapped_vl53l0x_get_limit_check_info( VL53L0X_DEV dev, uint16_t limit_check_id,
02185             char *p_limit_check_string );
02186 
02187     VL53L0X_Error wrapped_vl53l0x_get_pal_error_string( VL53L0X_Error pal_error_code,
02188             char *p_pal_error_string );
02189 
02190     VL53L0X_Error wrapped_vl53l0x_get_pal_state_string( VL53L0X_State pal_state_code,
02191             char *p_pal_state_string );
02192 
02193     VL53L0X_Error wrapped_vl53l0x_get_range_status_string( uint8_t range_status,
02194             char *p_range_status_string );
02195 
02196     VL53L0X_Error wrapped_vl53l0x_get_ref_calibration( VL53L0X_DEV dev,
02197             uint8_t *p_vhv_settings, uint8_t *p_phase_cal );
02198 
02199 
02200     VL53L0X_Error count_enabled_spads( uint8_t spad_array[],
02201                                        uint32_t byte_count, uint32_t max_spads,
02202                                        uint32_t *p_total_spads_enabled, uint8_t *p_is_aperture );
02203 
02204     VL53L0X_Error wrapped_vl53l0x_get_sequence_steps_info( VL53L0X_SequenceStepId sequence_step_id,
02205             char *p_sequence_steps_string );
02206 
02207 
02208     /**
02209      * @brief Gets the name of a given sequence step.
02210      *
02211      * @par Function Description
02212      * This function retrieves the name of sequence steps corresponding to
02213      * SequenceStepId.
02214      *
02215      * @note This function doesn't Accesses the device
02216      *
02217      * @param   sequence_step_id               Sequence step identifier.
02218      * @param   p_sequence_steps_string         Pointer to Info string
02219      *
02220      * @return  VL53L0X_ERROR_NONE            Success
02221      * @return  "Other error code"           See ::VL53L0X_Error
02222      */
02223     VL53L0X_API VL53L0X_Error vl53l0x_get_sequence_steps_info( VL53L0X_SequenceStepId sequence_step_id,
02224             char *p_sequence_steps_string );
02225 
02226     /**
02227     * @brief Get the frequency of the timer used for ranging results time stamps
02228     *
02229     * @param[out] p_timer_freq_hz : pointer for timer frequency
02230     *
02231     * @return status : 0 = ok, 1 = error
02232     *
02233     */
02234     int32_t vl53l0x_get_timer_frequency( int32_t *p_timer_freq_hz );
02235 
02236     /**
02237     * @brief Get the timer value in units of timer_freq_hz (see VL53L0X_get_timestamp_frequency())
02238     *
02239     * @param[out] p_timer_count : pointer for timer count value
02240     *
02241     * @return status : 0 = ok, 1 = error
02242     *
02243     */
02244     int32_t vl53l0x_get_timer_value( int32_t *p_timer_count );
02245 
02246     /**
02247     * @brief Configure ranging interrupt reported to system
02248     *
02249     * @note This function is not Implemented
02250     *
02251     * @param   dev                  Device Handle
02252     * @param   interrupt_mask         Mask of interrupt to Enable/disable
02253     *  (0:interrupt disabled or 1: interrupt enabled)
02254     * @return  VL53L0X_ERROR_NOT_IMPLEMENTED   Not implemented
02255     */
02256     VL53L0X_Error vl53l0x_enable_interrupt_mask( VL53L0X_DEV dev,
02257             uint32_t interrupt_mask );
02258 
02259     /**
02260     * @brief Read current status of the error register for the selected device
02261     *
02262     * @note This function Access to the device
02263     *
02264     * @param   dev                   Device Handle
02265     * @param   p_device_error_status    Pointer to current error code of the device
02266     * @return  VL53L0X_ERROR_NONE     Success
02267     * @return  "Other error code"    See ::VL53L0X_Error
02268     */
02269     VL53L0X_Error vl53l0x_get_device_error_status( VL53L0X_DEV dev,
02270             VL53L0X_DeviceError *p_device_error_status );
02271     /**
02272     * @brief Human readable error string for a given Error Code
02273     *
02274     * @note This function doesn't access to the device
02275     *
02276     * @param   error_code           The error code as stored on ::VL53L0X_DeviceError
02277     * @param   p_device_error_string  The error string corresponding to the ErrorCode
02278     * @return  VL53L0X_ERROR_NONE   Success
02279     * @return  "Other error code"  See ::VL53L0X_Error
02280     */
02281     VL53L0X_Error vl53l0x_get_device_error_string(
02282         VL53L0X_DeviceError error_code, char *p_device_error_string );
02283 
02284     /**
02285      * @brief  Get Dmax Calibration Parameters for a given device
02286      *
02287      *
02288      * @note This function Access to the device
02289      *
02290      * @param   dev                     Device Handle
02291      * @param   p_range_milli_meter        Pointer to Calibration Distance
02292      * @param   p_signal_rate_rtn_mega_cps   Pointer to Signal rate return
02293      * @return  VL53L0X_ERROR_NONE       Success
02294      * @return  "Other error code"      See ::VL53L0X_Error
02295      */
02296     VL53L0X_API VL53L0X_Error vl53l0x_get_dmax_cal_parameters( VL53L0X_DEV dev,
02297             uint16_t *p_range_milli_meter, FixPoint1616_t *p_signal_rate_rtn_mega_cps );
02298 
02299     /**
02300     * @brief   Set Dmax Calibration Parameters for a given device
02301     * When one of the parameter is zero, this function will get parameter
02302     * from NVM.
02303     * @note This function doesn't Access to the device
02304     *
02305     * @param   dev                    Device Handle
02306     * @param   range_milli_meter        Calibration Distance
02307     * @param   signal_rate_rtn_mega_cps   Signal rate return read at CalDistance
02308     * @return  VL53L0X_ERROR_NONE      Success
02309     * @return  "Other error code"     See ::VL53L0X_Error
02310     */
02311     VL53L0X_API VL53L0X_Error vl53l0x_get_dmax_cal_parameters( VL53L0X_DEV dev,
02312             uint16_t range_milli_meter, FixPoint1616_t signal_rate_rtn_mega_cps );
02313 
02314     /**
02315     * @brief Get current configuration for GPIO pin for a given device
02316     *
02317     * @note This function Access to the device
02318     *
02319     * @param   dev                   Device Handle
02320     * @param   pin                   ID of the GPIO Pin
02321     * @param   p_device_mode           Pointer to Device Mode associated to the Gpio.
02322     * @param   p_functionality        Pointer to Pin functionality.
02323     *  Refer to ::VL53L0X_GpioFunctionality
02324     * @param   p_polarity             Pointer to interrupt polarity.
02325     *  Active high or active low see ::VL53L0X_InterruptPolarity
02326     * @return  VL53L0X_ERROR_NONE                            Success
02327     * @return  VL53L0X_ERROR_GPIO_NOT_EXISTING               Only Pin=0 is accepted.
02328     * @return  VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED   This error occurs
02329     * when Functionality programmed is not in the supported list:
02330     *                      Supported value are:
02331     *                      VL53L0X_GPIOFUNCTIONALITY_OFF,
02332     *                      VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW,
02333     *                      VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH,
02334     *                      VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT,
02335     *                      VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY
02336     * @return  "Other error code"    See ::VL53L0X_Error
02337     */
02338     VL53L0X_API VL53L0X_Error vl53l0x_get_gpio_config( VL53L0X_DEV dev, uint8_t pin,
02339             VL53L0X_DeviceModes *p_device_mode,
02340             VL53L0X_GpioFunctionality *p_functionality,
02341             VL53L0X_InterruptPolarity *p_polarity );
02342 
02343     /**
02344     * @brief Set the configuration of GPIO pin for a given device
02345     *
02346     * @note This function Access to the device
02347     *
02348     * @param   dev                   Device Handle
02349     * @param   pin                   ID of the GPIO Pin
02350     * @param   functionality         Select Pin functionality.
02351     *  Refer to ::VL53L0X_GpioFunctionality
02352     * @param   device_mode            Device Mode associated to the Gpio.
02353     * @param   polarity              Set interrupt polarity. Active high
02354     *   or active low see ::VL53L0X_InterruptPolarity
02355     * @return  VL53L0X_ERROR_NONE                            Success
02356     * @return  VL53L0X_ERROR_GPIO_NOT_EXISTING               Only Pin=0 is accepted.
02357     * @return  VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED    This error occurs
02358     * when Functionality programmed is not in the supported list:
02359     *                             Supported value are:
02360     *                             VL53L0X_GPIOFUNCTIONALITY_OFF,
02361     *                             VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW,
02362     *                             VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH,
02363     VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT,
02364     *                               VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY
02365     * @return  "Other error code"    See ::VL53L0X_Error
02366     */
02367     VL53L0X_API VL53L0X_Error vl53L0x_set_gpio_config( VL53L0X_DEV dev, uint8_t pin,
02368             VL53L0X_DeviceModes device_mode, VL53L0X_GpioFunctionality functionality,
02369             VL53L0X_InterruptPolarity polarity );
02370 
02371     /**
02372     * @brief Retrieve the measurements from device for a given setup
02373     *
02374     * @par Function Description
02375     * Get data from last successful Histogram measurement
02376     * @warning USER should take care about  @a VL53L0X_GetNumberOfROIZones()
02377     * before get data.
02378     * PAL will fill a NumberOfROIZones times the corresponding data structure
02379     * used in the measurement function.
02380     *
02381     * @note This function is not Implemented
02382     *
02383     * @param   dev                         Device Handle
02384     * @param   p_histogram_measurement_data   Pointer to the histogram data structure.
02385     * @return  VL53L0X_ERROR_NOT_IMPLEMENTED   Not implemented
02386     */
02387     VL53L0X_API VL53L0X_Error vl53l0x_get_histogram_measurement_data( VL53L0X_DEV dev,
02388             VL53L0X_HistogramMeasurementData_t *p_histogram_measurement_data );
02389 
02390     /**
02391     * @brief  Get current new device mode
02392     * @par Function Description
02393     * Get current Histogram mode of a Device
02394     *
02395     * @note This function doesn't Access to the device
02396     *
02397     * @param   dev                   Device Handle
02398     * @param   p_histogram_mode        Pointer to current Histogram Mode value
02399     *                                Valid values are:
02400     *                                VL53L0X_HISTOGRAMMODE_DISABLED
02401     *                                VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM
02402     *                                VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY
02403     *                                VL53L0X_HISTOGRAMMODE_RETURN_ONLY
02404     *                                VL53L0X_HISTOGRAMMODE_BOTH
02405     * @return  VL53L0X_ERROR_NONE     Success
02406     * @return  "Other error code"    See ::VL53L0X_Error
02407     */
02408     VL53L0X_API VL53L0X_Error vl53l0x_get_histogram_mode( VL53L0X_DEV dev,
02409             VL53L0X_HistogramModes *p_histogram_mode );
02410 
02411     /**
02412      * @brief  Set a new Histogram mode
02413      * @par Function Description
02414      * Set device to a new Histogram mode
02415      *
02416      * @note This function doesn't Access to the device
02417      *
02418      * @param   dev                   Device Handle
02419      * @param   histogram_mode         New device mode to apply
02420      *                                Valid values are:
02421      *                                VL53L0X_HISTOGRAMMODE_DISABLED
02422      *                                VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM
02423      *                                VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY
02424      *                                VL53L0X_HISTOGRAMMODE_RETURN_ONLY
02425      *                                VL53L0X_HISTOGRAMMODE_BOTH
02426      *
02427      * @return  VL53L0X_ERROR_NONE                   Success
02428      * @return  VL53L0X_ERROR_MODE_NOT_SUPPORTED     This error occurs when
02429      * HistogramMode is not in the supported list
02430      * @return  "Other error code"    See ::VL53L0X_Error
02431      */
02432     VL53L0X_API VL53L0X_Error vl53l0x_set_histogram_mode( VL53L0X_DEV dev,
02433             VL53L0X_HistogramModes histogram_mode );
02434 
02435     /**
02436      * @brief  Get the current value of the signal used for the limit check
02437      *
02438      * @par Function Description
02439      * This function get a the current value of the signal used for the limit check.
02440      * To obtain the latest value you should run a ranging before.
02441      * The value reported is linked to the limit check identified with the
02442      * LimitCheckId.
02443      *
02444      * @note This function Access to the device
02445      *
02446      * @param   dev                           Device Handle
02447      * @param   limit_check_id                  Limit Check ID
02448      *  (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
02449      * @param   p_limit_check_current            Pointer to current Value for a
02450      * given LimitCheckId.
02451      * @return  VL53L0X_ERROR_NONE             Success
02452      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is returned when
02453      * LimitCheckId value is out of range.
02454      * @return  "Other error code"            See ::VL53L0X_Error
02455      */
02456     VL53L0X_API VL53L0X_Error vl53l0x_get_limit_check_current( VL53L0X_DEV dev, uint16_t limit_check_id,
02457             FixPoint1616_t *p_limit_check_current );
02458 
02459     /**
02460      * @brief  Return a description string for a given limit check number
02461      *
02462      * @par Function Description
02463      * This function returns a description string for a given limit check number.
02464      * The limit check is identified with the LimitCheckId.
02465      *
02466      * @note This function doesn't Access to the device
02467      *
02468      * @param   dev                           Device Handle
02469      * @param   limit_check_id                  Limit Check ID
02470      (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
02471      * @param   p_limit_check_string             Pointer to the
02472      description string of the given check limit.
02473      * @return  VL53L0X_ERROR_NONE             Success
02474      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is
02475      returned when LimitCheckId value is out of range.
02476      * @return  "Other error code"            See ::VL53L0X_Error
02477      */
02478     VL53L0X_API VL53L0X_Error vl53l0x_get_limit_check_info( VL53L0X_DEV dev,
02479             uint16_t limit_check_id, char *p_limit_check_string );
02480 
02481     /**
02482      * @brief  Return a the Status of the specified check limit
02483      *
02484      * @par Function Description
02485      * This function returns the Status of the specified check limit.
02486      * The value indicate if the check is fail or not.
02487      * The limit check is identified with the LimitCheckId.
02488      *
02489      * @note This function doesn't Access to the device
02490      *
02491      * @param   dev                           Device Handle
02492      * @param   limit_check_id                  Limit Check ID
02493      (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
02494      * @param   p_limit_check_status             Pointer to the
02495      Limit Check Status of the given check limit.
02496      * LimitCheckStatus :
02497      * 0 the check is not fail
02498      * 1 the check if fail or not enabled
02499      *
02500      * @return  VL53L0X_ERROR_NONE             Success
02501      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is
02502      returned when LimitCheckId value is out of range.
02503      * @return  "Other error code"            See ::VL53L0X_Error
02504      */
02505     VL53L0X_API VL53L0X_Error vl53l0x_get_limit_check_status( VL53L0X_DEV dev,
02506             uint16_t limit_check_id, uint8_t *p_limit_check_status );
02507 
02508     /**
02509      * @brief Get the linearity corrective gain
02510      *
02511      * @par Function Description
02512      * Should only be used after a successful call to @a VL53L0X_DataInit to backup
02513      * device NVM value
02514      *
02515      * @note This function Access to the device
02516      *
02517      * @param   dev                                Device Handle
02518      * @param   p_linearity_corrective_gain           Pointer to the linearity
02519      * corrective gain in x1000
02520      * if value is 1000 then no modification is applied.
02521      * @return  VL53L0X_ERROR_NONE                  Success
02522      * @return  "Other error code"                 See ::VL53L0X_Error
02523      */
02524     VL53L0X_API VL53L0X_Error vl53l0x_get_linearity_corrective_gain( VL53L0X_DEV dev,
02525             uint16_t *p_linearity_corrective_gain );
02526 
02527     /**
02528      * Set the linearity corrective gain
02529      *
02530      * @note This function Access to the device
02531      *
02532      * @param   dev                                Device Handle
02533      * @param   linearity_corrective_gain            Linearity corrective
02534      * gain in x1000
02535      * if value is 1000 then no modification is applied.
02536      * @return  VL53L0X_ERROR_NONE                  Success
02537      * @return  "Other error code"                 See ::VL53L0X_Error
02538      */
02539     VL53L0X_API VL53L0X_Error vl53l0x_set_linearity_corrective_gain( VL53L0X_DEV dev,
02540             int16_t linearity_corrective_gain );
02541 
02542     /**
02543      * @brief Get the Maximum number of ROI Zones managed by the Device
02544      *
02545      * @par Function Description
02546      * Get Maximum number of ROI Zones managed by the Device.
02547      *
02548      * @note This function doesn't Access to the device
02549      *
02550      * @param   dev                    Device Handle
02551      * @param   p_max_number_of_roi_zones   Pointer to the Maximum Number
02552      *  of ROI Zones value.
02553      * @return  VL53L0X_ERROR_NONE      Success
02554      */
02555     VL53L0X_API VL53L0X_Error vl53l0x_get_max_number_of_roi_zones( VL53L0X_DEV dev,
02556             uint8_t *p_max_number_of_roi_zones );
02557 
02558     /**
02559      * @brief Retrieve the Reference Signal after a measurements
02560      *
02561      * @par Function Description
02562      * Get Reference Signal from last successful Ranging measurement
02563      * This function return a valid value after that you call the
02564      * @a VL53L0X_GetRangingMeasurementData().
02565      *
02566      * @note This function Access to the device
02567      *
02568      * @param   dev                      Device Handle
02569      * @param   p_measurement_ref_signal    Pointer to the Ref Signal to fill up.
02570      * @return  VL53L0X_ERROR_NONE        Success
02571      * @return  "Other error code"       See ::VL53L0X_Error
02572      */
02573     VL53L0X_API VL53L0X_Error vl53l0x_get_measurement_ref_signal( VL53L0X_DEV dev,
02574             FixPoint1616_t *p_measurement_ref_signal );
02575 
02576     /**
02577      * @brief  Get the number of the check limit managed by a given Device
02578      *
02579      * @par Function Description
02580      * This function give the number of the check limit managed by the Device
02581      *
02582      * @note This function doesn't Access to the device
02583      *
02584      * @param   p_number_of_limit_check           Pointer to the number of check limit.
02585      * @return  VL53L0X_ERROR_NONE             Success
02586      * @return  "Other error code"            See ::VL53L0X_Error
02587      */
02588     VL53L0X_API VL53L0X_Error vl53l0x_get_number_of_limit_check(
02589         uint16_t *p_number_of_limit_check );
02590 
02591     /**
02592      * @brief Get the number of ROI Zones managed by the Device
02593      *
02594      * @par Function Description
02595      * Get number of ROI Zones managed by the Device
02596      * USER should take care about  @a VL53L0X_GetNumberOfROIZones()
02597      * before get data after a perform measurement.
02598      * PAL will fill a NumberOfROIZones times the corresponding data
02599      * structure used in the measurement function.
02600      *
02601      * @note This function doesn't Access to the device
02602      *
02603      * @param   dev                   Device Handle
02604      * @param   p_number_of_roi_zones     Pointer to the Number of ROI Zones value.
02605      * @return  VL53L0X_ERROR_NONE     Success
02606      */
02607     VL53L0X_API VL53L0X_Error vl53l0x_get_number_of_roi_zones( VL53L0X_DEV dev,
02608             uint8_t *p_number_of_roi_zones );
02609 
02610     /**
02611      * @brief Set the number of ROI Zones to be used for a specific Device
02612      *
02613      * @par Function Description
02614      * Set the number of ROI Zones to be used for a specific Device.
02615      * The programmed value should be less than the max number of ROI Zones given
02616      * with @a VL53L0X_GetMaxNumberOfROIZones().
02617      * This version of API manage only one zone.
02618      *
02619      * @param   dev                           Device Handle
02620      * @param   number_of_roi_zones              Number of ROI Zones to be used for a
02621      *  specific Device.
02622      * @return  VL53L0X_ERROR_NONE             Success
02623      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is returned if
02624      * NumberOfROIZones != 1
02625      */
02626     VL53L0X_API VL53L0X_Error vl53l0x_set_number_of_roi_zones( VL53L0X_DEV dev,
02627             uint8_t number_of_roi_zones );
02628 
02629     /**
02630      * @brief Gets number of sequence steps managed by the API.
02631      *
02632      * @par Function Description
02633      * This function retrieves the number of sequence steps currently managed
02634      * by the API
02635      *
02636      * @note This function Accesses the device
02637      *
02638      * @param   dev                          Device Handle
02639      * @param   p_number_of_sequence_steps       Out parameter reporting the number of
02640      *                                       sequence steps.
02641      * @return  VL53L0X_ERROR_NONE            Success
02642      * @return  "Other error code"           See ::VL53L0X_Error
02643      */
02644     VL53L0X_API VL53L0X_Error vl53l0x_get_number_of_sequence_steps( VL53L0X_DEV dev,
02645             uint8_t *p_number_of_sequence_steps );
02646     /**
02647      * @brief Human readable error string for current PAL error status
02648      *
02649      * @note This function doesn't access to the device
02650      *
02651      * @param   pal_error_code       The error code as stored on @a VL53L0X_Error
02652      * @param   p_pal_error_string    The error string corresponding to the
02653      * PalErrorCode
02654      * @return  VL53L0X_ERROR_NONE  Success
02655      * @return  "Other error code" See ::VL53L0X_Error
02656      */
02657     VL53L0X_API VL53L0X_Error vl53l0x_get_pal_error_string( VL53L0X_Error pal_error_code,
02658             char *p_pal_error_string );
02659 
02660     /**
02661      * @brief Return the PAL Specification Version used for the current
02662      * implementation.
02663      *
02664      * @note This function doesn't access to the device
02665      *
02666      * @param   p_pal_spec_version       Pointer to current PAL Specification Version
02667      * @return  VL53L0X_ERROR_NONE        Success
02668      * @return  "Other error code"    See ::VL53L0X_Error
02669      */
02670     VL53L0X_API VL53L0X_Error vl53l0x_get_pal_spec_version(
02671         VL53L0X_Version_t *p_pal_spec_version );
02672 
02673     /**
02674      * @brief Reads the internal state of the PAL for a given Device
02675      *
02676      * @note This function doesn't access to the device
02677      *
02678      * @param   dev                   Device Handle
02679      * @param   p_pal_state             Pointer to current state of the PAL for a
02680      * given Device
02681      * @return  VL53L0X_ERROR_NONE     Success
02682      * @return  "Other error code"    See ::VL53L0X_Error
02683      */
02684     VL53L0X_API VL53L0X_Error vl53l0x_get_pal_state( VL53L0X_DEV dev,
02685             VL53L0X_State *p_pal_state );
02686 
02687     /**
02688      * @brief Human readable PAL State string
02689      *
02690      * @note This function doesn't access to the device
02691      *
02692      * @param   pal_state_code          The State code as stored on @a VL53L0X_State
02693      * @param   p_pal_state_string       The State string corresponding to the
02694      * PalStateCode
02695      * @return  VL53L0X_ERROR_NONE     Success
02696      * @return  "Other error code"    See ::VL53L0X_Error
02697      */
02698     VL53L0X_API VL53L0X_Error vl53l0x_get_pal_state_string( VL53L0X_State pal_state_code,
02699             char *p_pal_state_string );
02700 
02701     /**
02702      * @brief Get the power mode for a given Device
02703      *
02704      * @note This function Access to the device
02705      *
02706      * @param   dev                   Device Handle
02707      * @param   p_power_mode            Pointer to the current value of the power
02708      * mode. see ::VL53L0X_PowerModes
02709      *                                Valid values are:
02710      *                                VL53L0X_POWERMODE_STANDBY_LEVEL1,
02711      *                                VL53L0X_POWERMODE_IDLE_LEVEL1
02712      * @return  VL53L0X_ERROR_NONE     Success
02713      * @return  "Other error code"    See ::VL53L0X_Error
02714      */
02715     VL53L0X_API VL53L0X_Error vl53l0x_get_power_mode( VL53L0X_DEV dev,
02716             VL53L0X_PowerModes *p_power_mode );
02717 
02718     /**
02719      * @brief Set the power mode for a given Device
02720      * The power mode can be Standby or Idle. Different level of both Standby and
02721      * Idle can exists.
02722      * This function should not be used when device is in Ranging state.
02723      *
02724      * @note This function Access to the device
02725      *
02726      * @param   dev                   Device Handle
02727      * @param   power_mode             The value of the power mode to set.
02728      * see ::VL53L0X_PowerModes
02729      *                                Valid values are:
02730      *                                VL53L0X_POWERMODE_STANDBY_LEVEL1,
02731      *                                VL53L0X_POWERMODE_IDLE_LEVEL1
02732      * @return  VL53L0X_ERROR_NONE                  Success
02733      * @return  VL53L0X_ERROR_MODE_NOT_SUPPORTED    This error occurs when PowerMode
02734      * is not in the supported list
02735      * @return  "Other error code"    See ::VL53L0X_Error
02736      */
02737     VL53L0X_API VL53L0X_Error vl53l0x_set_power_mode( VL53L0X_DEV dev,
02738             VL53L0X_PowerModes power_mode );
02739 
02740     /**
02741      * @brief Reads the Product Revision for a for given Device
02742      * This function can be used to distinguish cut1.0 from cut1.1.
02743      *
02744      * @note This function Access to the device
02745      *
02746      * @param   dev                 Device Handle
02747      * @param   p_product_revision_major  Pointer to Product Revision Major
02748      * for a given Device
02749      * @param   p_product_revision_minor  Pointer to Product Revision Minor
02750      * for a given Device
02751      * @return  VL53L0X_ERROR_NONE      Success
02752      * @return  "Other error code"  See ::VL53L0X_Error
02753      */
02754     VL53L0X_API VL53L0X_Error vl53l0x_get_product_revision( VL53L0X_DEV dev,
02755             uint8_t *p_product_revision_major, uint8_t *p_product_revision_minor );
02756 
02757     /**
02758      * @brief Human readable Range Status string for a given RangeStatus
02759      *
02760      * @note This function doesn't access to the device
02761      *
02762      * @param   range_status         The RangeStatus code as stored on
02763      * @a VL53L0X_RangingMeasurementData_t
02764      * @param   p_range_status_string  The returned RangeStatus string.
02765      * @return  VL53L0X_ERROR_NONE   Success
02766      * @return  "Other error code"  See ::VL53L0X_Error
02767      */
02768     VL53L0X_API VL53L0X_Error vl53l0x_get_range_status_string( uint8_t range_status,
02769             char *p_range_status_string );
02770 
02771     /**
02772      * @brief Get Reference Calibration Parameters
02773      *
02774      * @par Function Description
02775      * Get Reference Calibration Parameters.
02776      *
02777      * @note This function Access to the device
02778      *
02779      * @param   dev                            Device Handle
02780      * @param   p_vhv_settings                   Pointer to VHV parameter
02781      * @param   p_phase_cal                      Pointer to PhaseCal Parameter
02782      * @return  VL53L0X_ERROR_NONE              Success
02783      * @return  "Other error code"             See ::VL53L0X_Error
02784      */
02785     VL53L0X_API VL53L0X_Error vl53l0x_get_ref_calibration( VL53L0X_DEV dev,
02786             uint8_t *p_vhv_settings, uint8_t *p_phase_cal );
02787 
02788     /**
02789      * @brief Retrieves SPAD configuration
02790      *
02791      * @par Function Description
02792      * This function retrieves the current number of applied reference spads
02793      * and also their type : Aperture or Non-Aperture.
02794      *
02795      * @note This function Access to the device
02796      *
02797      * @param   dev                          Device Handle
02798      * @param   p_spad_count                 Number ref Spad Count
02799      * @param   p_is_aperture_spads              Reports if spads are of type
02800      *                                       aperture or non-aperture.
02801      *                                       1:=aperture, 0:=Non-Aperture
02802      * @return  VL53L0X_ERROR_NONE            Success
02803      * @return  VL53L0X_ERROR_REF_SPAD_INIT   Error in the in the reference
02804      *                                       spad configuration.
02805      * @return  "Other error code"           See ::VL53L0X_Error
02806      */
02807     VL53L0X_API VL53L0X_Error wrapped_vl53l0x_get_reference_spads( VL53L0X_DEV dev,
02808             uint32_t *p_spad_count, uint8_t *p_is_aperture_spads );
02809 
02810     /**
02811      * @brief Gets the (on/off) state of a requested sequence step.
02812      *
02813      * @par Function Description
02814      * This function retrieves the state of a requested sequence step, i.e. on/off.
02815      *
02816      * @note This function Accesses the device
02817      *
02818      * @param   dev                    Device Handle
02819      * @param   sequence_step_id         Sequence step identifier.
02820      * @param   p_sequence_step_enabled   Out parameter reporting if the sequence step
02821      *                                 is enabled {0=Off,1=On}.
02822      * @return  VL53L0X_ERROR_NONE            Success
02823      * @return  VL53L0X_ERROR_INVALID_PARAMS  Error SequenceStepId parameter not
02824      *                                       supported.
02825      * @return  "Other error code"           See ::VL53L0X_Error
02826      */
02827     VL53L0X_API VL53L0X_Error vl53l0x_get_sequence_step_enable( VL53L0X_DEV dev,
02828             VL53L0X_SequenceStepId sequence_step_id, uint8_t *p_sequence_step_enabled );
02829 
02830 
02831     /**
02832      * @brief Gets the timeout of a requested sequence step.
02833      *
02834      * @par Function Description
02835      * This function retrieves the timeout of a requested sequence step.
02836      *
02837      * @note This function Accesses the device
02838      *
02839      * @param   dev                          Device Handle
02840      * @param   sequence_step_id               Sequence step identifier.
02841      * @param   p_time_out_milli_secs            Timeout value.
02842      * @return  VL53L0X_ERROR_NONE            Success
02843      * @return  VL53L0X_ERROR_INVALID_PARAMS  Error SequenceStepId parameter not
02844      *                                       supported.
02845      * @return  "Other error code"           See ::VL53L0X_Error
02846      */
02847     VL53L0X_API VL53L0X_Error vl53l0x_get_sequence_step_timeout( VL53L0X_DEV dev,
02848             VL53L0X_SequenceStepId sequence_step_id,
02849             FixPoint1616_t *p_time_out_milli_secs );
02850 
02851     /**
02852      * @brief Sets the timeout of a requested sequence step.
02853      *
02854      * @par Function Description
02855      * This function sets the timeout of a requested sequence step.
02856      *
02857      * @note This function Accesses the device
02858      *
02859      * @param   dev                          Device Handle
02860      * @param   sequence_step_id               Sequence step identifier.
02861      * @param   time_out_milli_secs             Demanded timeout
02862      * @return  VL53L0X_ERROR_NONE            Success
02863      * @return  VL53L0X_ERROR_INVALID_PARAMS  Error SequenceStepId parameter not
02864      *                                       supported.
02865      * @return  "Other error code"           See ::VL53L0X_Error
02866      */
02867     VL53L0X_API VL53L0X_Error vl53l0x_set_sequence_step_timeout( VL53L0X_DEV dev,
02868             VL53L0X_SequenceStepId sequence_step_id, FixPoint1616_t time_out_milli_secs );
02869 
02870     /**
02871     * @brief  Get the current SPAD Ambient Damper Factor value
02872     *
02873     * @par Function Description
02874     * This function get the SPAD Ambient Damper Factor value
02875     *
02876     * @note This function Access to the device
02877     *
02878     * @param   dev                           Device Handle
02879     * @param   p_spad_ambient_damper_factor      Pointer to programmed SPAD Ambient
02880     * Damper Factor value
02881     * @return  VL53L0X_ERROR_NONE             Success
02882     * @return  "Other error code"            See ::VL53L0X_Error
02883     */
02884     VL53L0X_API VL53L0X_Error vl53l0x_get_spad_ambient_damper_factor( VL53L0X_DEV dev,
02885             uint16_t *p_spad_ambient_damper_factor );
02886     /**
02887     * @brief  Set the SPAD Ambient Damper Factor value
02888     *
02889     * @par Function Description
02890     * This function set the SPAD Ambient Damper Factor value
02891     *
02892     * @note This function Access to the device
02893     *
02894     * @param   dev                           Device Handle
02895     * @param   spad_ambient_damper_factor       SPAD Ambient Damper Factor value
02896     * @return  VL53L0X_ERROR_NONE             Success
02897     * @return  "Other error code"            See ::VL53L0X_Error
02898     */
02899     VL53L0X_API VL53L0X_Error vl53l0x_set_spad_ambient_damper_factor( VL53L0X_DEV dev,
02900             uint16_t spad_ambient_damper_factor );
02901 
02902     /**
02903      * @brief  Get the current SPAD Ambient Damper Threshold value
02904      *
02905      * @par Function Description
02906      * This function get the SPAD Ambient Damper Threshold value
02907      *
02908      * @note This function Access to the device
02909      *
02910      * @param   dev                           Device Handle
02911      * @param   p_spad_ambient_damper_threshold   Pointer to programmed
02912      *                                        SPAD Ambient Damper Threshold value
02913      * @return  VL53L0X_ERROR_NONE             Success
02914      * @return  "Other error code"            See ::VL53L0X_Error
02915      */
02916     VL53L0X_API VL53L0X_Error vl53l0x_get_spad_ambient_damper_threshold( VL53L0X_DEV dev,
02917             uint16_t *p_spad_ambient_damper_threshold );
02918 
02919     /**
02920      * @brief  Set the SPAD Ambient Damper Threshold value
02921      *
02922      * @par Function Description
02923      * This function set the SPAD Ambient Damper Threshold value
02924      *
02925      * @note This function Access to the device
02926      *
02927      * @param   dev                           Device Handle
02928      * @param   spad_ambient_damper_threshold    SPAD Ambient Damper Threshold value
02929      * @return  VL53L0X_ERROR_NONE             Success
02930      * @return  "Other error code"            See ::VL53L0X_Error
02931      */
02932     VL53L0X_API VL53L0X_Error vl53l0x_set_spad_ambient_damper_threshold( VL53L0X_DEV dev,
02933             uint16_t spad_ambient_damper_threshold );
02934 
02935     /**
02936      * @brief Get the maximal distance for actual setup
02937      * @par Function Description
02938      * Device must be initialized through @a VL53L0X_SetParameters() prior calling
02939      * this function.
02940      *
02941      * Any range value more than the value returned is to be considered as
02942      * "no target detected" or
02943      * "no target in detectable range"\n
02944      * @warning The maximal distance depends on the setup
02945      *
02946      * @note This function is not Implemented
02947      *
02948      * @param   dev      Device Handle
02949      * @param   p_upper_limit_milli_meter   The maximal range limit for actual setup
02950      * (in millimeter)
02951      * @return  VL53L0X_ERROR_NOT_IMPLEMENTED        Not implemented
02952      */
02953     VL53L0X_API VL53L0X_Error vl53l0x_get_upper_limit_milli_meter( VL53L0X_DEV dev,
02954             uint16_t *p_upper_limit_milli_meter );
02955 
02956     /**
02957     * @brief Get the tuning settings pointer and the internal external switch
02958     * value.
02959     *
02960     * This function is used to get the Tuning settings buffer pointer and the
02961     * value.
02962     * of the switch to select either external or internal tuning settings.
02963     *
02964     * @note This function Access to the device
02965     *
02966     * @param   dev                        Device Handle
02967     * @param   pp_tuning_setting_buffer      Pointer to tuning settings buffer.
02968     * @param   p_use_internal_tuning_settings Pointer to store Use internal tuning
02969     *                                     settings value.
02970     * @return  VL53L0X_ERROR_NONE          Success
02971     * @return  "Other error code"         See ::VL53L0X_Error
02972     */
02973     VL53L0X_API VL53L0X_Error vl53l0x_get_tuning_setting_buffer( VL53L0X_DEV dev,
02974             uint8_t **pp_tuning_setting_buffer, uint8_t *p_use_internal_tuning_settings );
02975 
02976     /**
02977      * @brief Set the tuning settings pointer
02978      *
02979      * This function is used to specify the Tuning settings buffer to be used
02980      * for a given device. The buffer contains all the necessary data to permit
02981      * the API to write tuning settings.
02982      * This function permit to force the usage of either external or internal
02983      * tuning settings.
02984      *
02985      * @note This function Access to the device
02986      *
02987      * @param   dev                             Device Handle
02988      * @param   p_tuning_setting_buffer            Pointer to tuning settings buffer.
02989      * @param   use_internal_tuning_settings       Use internal tuning settings value.
02990      * @return  VL53L0X_ERROR_NONE     Success
02991      * @return  "Other error code"    See ::VL53L0X_Error
02992      */
02993     VL53L0X_API VL53L0X_Error vl53l0x_set_tuning_setting_buffer( VL53L0X_DEV dev,
02994             uint8_t *p_tuning_setting_buffer, uint8_t use_internal_tuning_settings );
02995 
02996     /**
02997     * @brief Return the VL53L0X PAL Implementation Version
02998     *
02999     * @note This function doesn't access to the device
03000     *
03001     * @param   p_version              Pointer to current PAL Implementation Version
03002     * @return  VL53L0X_ERROR_NONE     Success
03003     * @return  "Other error code"    See ::VL53L0X_Error
03004     */
03005     VL53L0X_API VL53L0X_Error vl53l0x_get_version( VL53L0X_Version_t *p_version );
03006 
03007     /**
03008      * @defgroup VL53L0X_registerAccess_group PAL Register Access Functions
03009      * @brief    PAL Register Access Functions
03010      *  @{
03011      */
03012 
03013     /**
03014      * Lock comms interface to serialize all commands to a shared I2C interface for a specific device
03015      * @param   dev       Device Handle
03016      * @return  VL53L0X_ERROR_NONE        Success
03017      * @return  "Other error code"    See ::VL53L0X_Error
03018      */
03019     VL53L0X_Error vl53l0x_lock_sequence_access( VL53L0X_DEV dev );
03020 
03021     /**
03022      * Unlock comms interface to serialize all commands to a shared I2C interface for a specific device
03023      * @param   dev       Device Handle
03024      * @return  VL53L0X_ERROR_NONE        Success
03025      * @return  "Other error code"    See ::VL53L0X_Error
03026      */
03027     VL53L0X_Error vl53l0x_unlock_sequence_access( VL53L0X_DEV dev );
03028 
03029     /**
03030      * @brief Enable/Disable Cross talk compensation feature
03031      *
03032      * @note This function is not Implemented.
03033      * Enable/Disable Cross Talk by set to zero the Cross Talk value
03034      * by using @a VL53L0X_SetXTalkCompensationRateMegaCps().
03035      *
03036      * @param   dev                       Device Handle
03037      * @param   x_talk_compensation_enable   Cross talk compensation
03038      *  to be set 0=disabled else = enabled
03039      * @return  VL53L0X_ERROR_NOT_IMPLEMENTED   Not implemented
03040      */
03041     VL53L0X_API VL53L0X_Error vl53l0x_set_x_talk_compensation_enable( VL53L0X_DEV dev,
03042             uint8_t x_talk_compensation_enable );
03043 
03044     /**
03045      * @brief Set Cross talk compensation rate
03046      *
03047      * @par Function Description
03048      * Set Cross talk compensation rate.
03049      *
03050      * @note This function Access to the device
03051      *
03052      * @param   dev                            Device Handle
03053      * @param   x_talk_compensation_rate_mega_cps   Compensation rate in
03054      *  Mega counts per second (16.16 fix point) see datasheet for details
03055      * @return  VL53L0X_ERROR_NONE              Success
03056      * @return  "Other error code"             See ::VL53L0X_Error
03057      */
03058     VL53L0X_API VL53L0X_Error vl53l0x_set_x_talk_compensation_rate_mega_cps( VL53L0X_DEV dev,
03059             FixPoint1616_t x_talk_compensation_rate_mega_cps );
03060 
03061     /**
03062      * @brief Perform XTalk Measurement
03063      *
03064      * @details Measures the current cross talk from glass in front
03065      * of the sensor.
03066      * This functions performs a histogram measurement and uses the results
03067      * to measure the crosstalk. For the function to be successful, there
03068      * must be no target in front of the sensor.
03069      *
03070      * @warning This function is a blocking function
03071      *
03072      * @warning This function is not supported when the final range
03073      * vcsel clock period is set below 10 PCLKS.
03074      *
03075      * @note This function Access to the device
03076      *
03077      * @param   dev                  Device Handle
03078      * @param   timeout_ms            Histogram measurement duration.
03079      * @param   p_xtalk_per_spad        Output parameter containing the crosstalk
03080      * measurement result, in MCPS/Spad. Format fixpoint 16:16.
03081      * @param   p_ambient_too_high      Output parameter which indicate that
03082      * pXtalkPerSpad is not good if the Ambient is too high.
03083      * @return  VL53L0X_ERROR_NONE    Success
03084      * @return  VL53L0X_ERROR_INVALID_PARAMS vcsel clock period not supported
03085      * for this operation. Must not be less than 10PCLKS.
03086      * @return  "Other error code"   See ::VL53L0X_Error
03087      */
03088     VL53L0X_API VL53L0X_Error vl53l0x_perform_xtalk_measurement( VL53L0X_DEV dev,
03089             uint32_t timeout_ms, FixPoint1616_t *p_xtalk_per_spad,
03090             uint8_t *p_ambient_too_high );
03091 
03092     /**
03093      * @brief Do an hard reset or soft reset (depending on implementation) of the
03094      * device \nAfter call of this function, device must be in same state as right
03095      * after a power-up sequence.This function will change the VL53L0X_State to
03096      * VL53L0X_STATE_POWERDOWN.
03097      *
03098      * @note This function Access to the device
03099      *
03100      * @param   dev                   Device Handle
03101      * @return  VL53L0X_ERROR_NONE     Success
03102      * @return  "Other error code"    See ::VL53L0X_Error
03103      */
03104     VL53L0X_API VL53L0X_Error vl53l0x_reset_device( VL53L0X_DEV dev );
03105 
03106     /**
03107      * @brief  Prepare device for operation
03108      * @par Function Description
03109      * Update device with provided parameters
03110      * @li Then start ranging operation.
03111      *
03112      * @note This function Access to the device
03113      *
03114      * @param   Dev                   Device Handle
03115      * @param   pDeviceParameters     Pointer to store current device parameters.
03116      * @return  VL53L0X_ERROR_NONE     Success
03117      * @return  "Other error code"    See ::VL53L0X_Error
03118      */
03119     VL53L0X_API VL53L0X_Error VL53L0X_SetDeviceParameters( VL53L0X_DEV Dev,
03120             const VL53L0X_DeviceParameters_t *pDeviceParameters );
03121 
03122     /**
03123      * Program continuous mode Inter-Measurement period in milliseconds
03124      *
03125      * @par Function Description
03126      * When trying to set too short time return  INVALID_PARAMS minimal value
03127      *
03128      * @note This function Access to the device
03129      *
03130      * @param   dev                                  Device Handle
03131      * @param   inter_measurement_period_milli_seconds   Inter-Measurement Period in ms.
03132      * @return  VL53L0X_ERROR_NONE                    Success
03133      * @return  "Other error code"                   See ::VL53L0X_Error
03134      */
03135     VL53L0X_API VL53L0X_Error vl53l0x_set_inter_measurement_period_milli_seconds(
03136         VL53L0X_DEV dev, uint32_t inter_measurement_period_milli_seconds );
03137 
03138     /**
03139      * @brief  Enable (or disable) Wrap around Check
03140      *
03141      * @note This function Access to the device
03142      *
03143      * @param   dev                    Device Handle
03144      * @param   wrap_around_check_enable  Wrap around Check to be set
03145      *                                 0=disabled, other = enabled
03146      * @return  VL53L0X_ERROR_NONE      Success
03147      * @return  "Other error code"     See ::VL53L0X_Error
03148      */
03149     VL53L0X_API VL53L0X_Error vl53l0x_set_wrap_around_check_enable( VL53L0X_DEV dev,
03150             uint8_t wrap_around_check_enable );
03151 
03152     /**
03153      * Set Group parameter Hold state
03154      *
03155      * @par Function Description
03156      * Set or remove device internal group parameter hold
03157      *
03158      * @note This function is not Implemented
03159      *
03160      * @param   dev      Device Handle
03161      * @param   group_param_hold   Group parameter Hold state to be set (on/off)
03162      * @return  VL53L0X_ERROR_NOT_IMPLEMENTED        Not implemented
03163      */
03164     VL53L0X_API VL53L0X_Error vl53l0x_set_group_param_hold( VL53L0X_DEV dev,
03165             uint8_t group_param_hold );
03166 
03167     /**
03168      * @brief  Sets the resolution of range measurements.
03169      * @par Function Description
03170      * Set resolution of range measurements to either 0.25mm if
03171      * fraction enabled or 1mm if not enabled.
03172      *
03173      * @note This function Accesses the device
03174      *
03175      * @param   dev               Device Handle
03176      * @param   enable            Enable high resolution
03177      *
03178      * @return  VL53L0X_ERROR_NONE               Success
03179      * @return  "Other error code"              See ::VL53L0X_Error
03180      */
03181     VL53L0X_API VL53L0X_Error vl53l0x_set_range_fraction_enable( VL53L0X_DEV dev,
03182             uint8_t enable );
03183 
03184     /**
03185      * @brief Applies Reference SPAD configuration
03186      *
03187      * @par Function Description
03188      * This function applies a given number of reference spads, identified as
03189      * either Aperture or Non-Aperture.
03190      * The requested spad count and type are stored within the device specific
03191      * parameters data for access by the host.
03192      *
03193      * @note This function Access to the device
03194      *
03195      * @param   dev                          Device Handle
03196      * @param   refSpadCount                 Number of ref spads.
03197      * @param   is_aperture_spads              Defines if spads are of type
03198      *                                       aperture or non-aperture.
03199      *                                       1:=aperture, 0:=Non-Aperture
03200      * @return  VL53L0X_ERROR_NONE            Success
03201      * @return  VL53L0X_ERROR_REF_SPAD_INIT   Error in the in the reference
03202      *                                       spad configuration.
03203      * @return  "Other error code"           See ::VL53L0X_Error
03204      */
03205     VL53L0X_API VL53L0X_Error vl53l0x_set_reference_spads( VL53L0X_DEV dev,
03206             uint32_t refSpadCount, uint8_t is_aperture_spads );
03207 
03208     /**
03209      * @brief Retrieves SPAD configuration
03210      *
03211      * @par Function Description
03212      * This function retrieves the current number of applied reference spads
03213      * and also their type : Aperture or Non-Aperture.
03214      *
03215      * @note This function Access to the device
03216      *
03217      * @param   dev                          Device Handle
03218      * @param   p_spad_count                 Number ref Spad Count
03219      * @param   p_is_aperture_spads              Reports if spads are of type
03220      *                                       aperture or non-aperture.
03221      *                                       1:=aperture, 0:=Non-Aperture
03222      * @return  VL53L0X_ERROR_NONE            Success
03223      * @return  VL53L0X_ERROR_REF_SPAD_INIT   Error in the in the reference
03224      *                                       spad configuration.
03225      * @return  "Other error code"           See ::VL53L0X_Error
03226      */
03227     VL53L0X_API VL53L0X_Error vl53l0x_get_reference_spads( VL53L0X_DEV dev,
03228             uint32_t *p_spad_count, uint8_t *p_is_aperture_spads );
03229 
03230     /**
03231     * @brief Wait for device booted after chip enable (hardware standby)
03232     * This function can be run only when VL53L0X_State is VL53L0X_STATE_POWERDOWN.
03233     *
03234     * @note This function is not Implemented
03235     *
03236     * @param   dev      Device Handle
03237     * @return  VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
03238     *
03239     */
03240     VL53L0X_API VL53L0X_Error wrapped_vl53l0x_wait_device_booted( VL53L0X_DEV dev );
03241 
03242     /**
03243      * @brief Wait for device ready for a new measurement command.
03244      * Blocking function.
03245      *
03246      * @note This function is not Implemented
03247      *
03248      * @param   dev      Device Handle
03249      * @param   max_loop    Max Number of polling loop (timeout).
03250      * @return  VL53L0X_ERROR_NOT_IMPLEMENTED   Not implemented
03251      */
03252     VL53L0X_API VL53L0X_Error vl53l0x_wait_device_ready_for_new_measurement( VL53L0X_DEV dev,
03253             uint32_t max_loop );
03254 
03255 
03256     VL53L0X_Error vl53l0x_perform_offset_calibration( VL53L0X_DEV dev,
03257             FixPoint1616_t cal_distance_milli_meter,
03258             int32_t *p_offset_micro_meter );
03259 
03260     VL53L0X_Error vl53l0x_perform_xtalk_calibration( VL53L0X_DEV dev,
03261             FixPoint1616_t xtalk_cal_distance,
03262             FixPoint1616_t *p_xtalk_compensation_rate_mega_cps );
03263 
03264     VL53L0X_Error VL53L0X_reverse_bytes( uint8_t *data, uint32_t size );
03265 
03266     VL53L0X_Error vl53l0x_set_ref_calibration( VL53L0X_DEV dev,
03267             uint8_t vhv_settings, uint8_t phase_cal );
03268 
03269     /*
03270     int StopRangeMeasurement(OperatingMode operating_mode);
03271     int GetRangeMeas(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *Data);
03272     int RangeSetLowThreshold(uint16_t threshold);
03273     int RangeSetHighThreshold(uint16_t threshold);
03274     int GetRangeError(VL53L0X_RangingMeasurementData_t *Data, VL53L0X_RangingMeasurementData_t RangeData);
03275     int RangeMeasPollSingleShot();
03276     int RangeMeasPollContinuousMode();
03277     */
03278     int range_meas_int_continuous_mode( void ( *fptr )( void ) );
03279 
03280 
03281     VL53L0X_DeviceInfo_t _device_info;
03282 
03283     /* IO Device */
03284     DevI2C &dev_i2c;
03285     /* Digital out pin */
03286     DigitalOut *gpio0;
03287     /* GPIO expander */
03288     Stmpe1600DigiOut *expgpio0;
03289     /* Measure detection IRQ */
03290     InterruptIn *gpio1Int;
03291     /* Device data */
03292     VL53L0X_Dev_t _my_device;
03293     VL53L0X_DEV _device;
03294 };
03295 
03296 
03297 #endif /* _VL53L0X_CLASS_H_ */