eLab Team / Mbed 2 deprecated myRobot

Dependencies:   mbed WS2812

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers VL53L0X.h Source File

VL53L0X.h

00001 /*******************************************************************************
00002  Copyright © 2016, STMicroelectronics International N.V.
00003  All rights reserved.
00004 
00005  Redistribution and use in source and binary forms, with or without
00006  modification, are permitted provided that the following conditions are met:
00007  * Redistributions of source code must retain the above copyright
00008  notice, this list of conditions and the following disclaimer.
00009  * Redistributions in binary form must reproduce the above copyright
00010  notice, this list of conditions and the following disclaimer in the
00011  documentation and/or other materials provided with the distribution.
00012  * Neither the name of STMicroelectronics nor the
00013  names of its contributors may be used to endorse or promote products
00014  derived from this software without specific prior written permission.
00015 
00016  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018  WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
00019  NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
00020  IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
00021  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00022  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00023  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00024  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00026  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  *****************************************************************************/
00028 
00029 #ifndef __VL53L0X_CLASS_H
00030 #define __VL53L0X_CLASS_H
00031 
00032 
00033 /* Includes ------------------------------------------------------------------*/
00034 #include "mbed.h"
00035 #include "pinmap.h"
00036 #include "PinNames.h"
00037 #include "VL53L0X_def.h"
00038 
00039 /* Classes -------------------------------------------------------------------*/
00040 /** Class representing a VL53L0 sensor component  */
00041 class VL53L0X
00042 {
00043 public:
00044     /** Constructor
00045      * @param[in] &i2c device I2C to be used for communication
00046      * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
00047      * @param[in] dev_addr device address, 0x29 by default
00048      */
00049     VL53L0X(I2C *i2c, DigitalOut *pin, PinName pin_gpio1, uint8_t dev_addr = VL53L0X_DEFAULT_ADDRESS) :  _gpio0(pin), _dev_i2c(i2c)  
00050     {   I2cDevAddr  = dev_addr;
00051         comms_type  = 1; // VL53L0X_COMMS_I2C
00052         comms_speed_khz  = 400;
00053         if (pin_gpio1 != NC) { _gpio1Int = new InterruptIn(pin_gpio1); } 
00054             else { _gpio1Int = NULL;  }
00055     }
00056 
00057     /** Destructor
00058      */
00059     virtual ~VL53L0X()
00060     { if (_gpio1Int != NULL) { delete _gpio1Int; }  }
00061 
00062     /*** Interface Methods   High level API ***/
00063     /**
00064      * @brief       PowerOn the sensor
00065      * @return      void
00066      */
00067     /* turns on the sensor */
00068     void VL53L0X_on(void)
00069     {
00070         if (_gpio0) { *_gpio0 = 1; } 
00071         wait_ms(10);
00072     }
00073 
00074     /**
00075      * @brief       PowerOff the sensor
00076      * @return      void
00077      */
00078     /* turns off the sensor */
00079     void VL53L0X_off(void)
00080     {
00081         if (_gpio0) { *_gpio0 = 0; } 
00082         wait_ms(10);
00083     }
00084 
00085 
00086     /**
00087      * @brief       Initialize the sensor with default values
00088      * @return      "0" on success
00089      */
00090     int init_sensor(uint8_t new_addr = VL53L0X_DEFAULT_ADDRESS);
00091 
00092     /**
00093      * @brief       Start the measure indicated by operating mode
00094      * @param[in]   operating_mode specifies requested measure
00095      * @param[in]   fptr specifies call back function must be !NULL in case of interrupt measure
00096      * @return      "0" on success
00097      */
00098     int start_measurement(OperatingMode operating_mode, void (*fptr)(void), 
00099                                VL53L0X_RangingConfig rangingConfig );
00100 
00101     /**
00102      * @brief       Get results for the measure indicated by operating mode
00103      * @param[in]   operating_mode specifies requested measure results
00104      * @param[out]  p_data pointer to the MeasureData_t structure to read data in to
00105      * @return      "0" on success
00106      */
00107     int get_measurement(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *p_data);
00108 
00109     /**
00110      * @brief       Stop the currently running measure indicate by operating_mode
00111      * @param[in]   operating_mode specifies requested measure to stop
00112      * @return      "0" on success
00113      */
00114     int stop_measurement(OperatingMode operating_mode);
00115 
00116     /**
00117      * @brief       Interrupt handling func to be called by user after an INT is occourred
00118      * @param[in]   opeating_mode indicating the in progress measure
00119      * @param[out]  Data pointer to the MeasureData_t structure to read data in to
00120      * @return      "0" on success
00121      */
00122     int handle_irq(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *data);
00123 
00124     /**
00125      * @brief       Enable interrupt measure IRQ
00126      * @return      "0" on success
00127      */
00128     void enable_interrupt_measure_detection_irq(void)
00129     {  if (_gpio1Int != NULL) { _gpio1Int->enable_irq();}  }
00130 
00131     /**
00132      * @brief       Disable interrupt measure IRQ
00133      * @return      "0" on success
00134      */
00135     void disable_interrupt_measure_detection_irq(void)
00136     { if (_gpio1Int != NULL) {  _gpio1Int->disable_irq(); }  }
00137 
00138     /**
00139      * @brief       Attach a function to call when an interrupt is detected, i.e. measurement is ready
00140      * @param[in]   fptr pointer to call back function to be called whenever an interrupt occours
00141      * @return      "0" on success
00142      */
00143     void attach_interrupt_measure_detection_irq(void (*fptr)(void))
00144     {   if (_gpio1Int != NULL) {  _gpio1Int->rise(fptr); }  }
00145 
00146     /** Wrapper functions */
00147     /** @defgroup api_init Init functions
00148      *  @brief    API init functions
00149      *  @ingroup  api_hl
00150      *  @{
00151      */
00152 
00153     /**
00154       * @brief  Prepare device for operation
00155       * @par Function Description
00156       * Does static initialization and reprogram common default settings \n
00157       * Device is prepared for new measure, ready single shot ranging or ALS typical polling operation\n
00158       * After prepare user can : \n
00159       * @li Call other API function to set other settings\n
00160       * @li Configure the interrupt pins, etc... \n
00161       * @li Then start ranging or ALS operations in single shot or continuous mode
00162       *
00163       * @param void
00164       * @return  "0" on success
00165       */
00166     int prepare();
00167 
00168     /**
00169     * @brief Start continuous ranging mode
00170     *
00171     * @details End user should ensure device is in idle state and not already running
00172     * @return  "0" on success
00173     */
00174     int range_start_continuous_mode();
00175 
00176     /**
00177      * @brief Get ranging result and only that
00178      *
00179      * @par Function Description
00180      * Unlike @a VL53L0X_get_ranging_measurement_data() this function only retrieves the range in _mm \n
00181      * It does any required up-scale translation\n
00182      * It can be called after success status polling or in interrupt mode \n
00183      * @warning these function is not doing wrap around filtering \n
00184      * This function doesn't perform any data ready check!
00185      *
00186      * @param p_data  Pointer to range distance
00187      * @return        "0" on success
00188      */
00189     int get_distance(uint32_t *p_data);
00190 
00191     /** @}  */
00192 
00193     /** @brief Set new device i2c address
00194      *
00195      * After completion the device will answer to the new address programmed.
00196      *
00197      * @param new_addr  The new i2c address (7bit)
00198      * @return          "0" on success
00199      */
00200     int set_device_address(int new_addr)
00201     {
00202         int status;
00203 
00204         status = VL53L0X_set_device_address(new_addr);
00205         if (!status) { I2cDevAddr  = new_addr; }
00206         return status;
00207     }
00208 
00209     /**
00210      * @brief Clear given system interrupt condition
00211      *
00212      * @par Function Description
00213      * Clear given interrupt cause by writing into register #SYSTEM_INTERRUPT_CLEAR register.
00214       * @param int_clear  Which interrupt source to clear. Use any combinations of #INTERRUPT_CLEAR_RANGING , #INTERRUPT_CLEAR_ALS , #INTERRUPT_CLEAR_ERROR.
00215      * @return           "0" on success
00216      */
00217     int clear_interrupt(uint8_t int_clear)
00218     {   return VL53L0X_clear_interrupt_mask(int_clear);  }
00219 
00220     /**  @brief One time device initialization
00221      *
00222      * To be called once and only once after device is brought out of reset
00223      * (Chip enable) and booted see @a VL53L0X_WaitDeviceBooted()
00224      *
00225      * @par Function Description
00226      * When not used after a fresh device "power up" or reset, it may return
00227      * @a #VL53L0X_ERROR_CALIBRATION_WARNING meaning wrong calibration data
00228      * may have been fetched from device that can result in ranging offset error\n
00229      * If application cannot execute device reset or need to run VL53L0X_DataInit
00230      * multiple time then it  must ensure proper offset calibration saving and
00231      * restore on its own by using @a VL53L0X_GetOffsetCalibrationData() on first
00232      * power up and then @a VL53L0X_SetOffsetCalibrationData() in all subsequent init
00233      * This function will change the VL53L0X_State from VL53L0X_STATE_POWERDOWN to
00234      * VL53L0X_STATE_WAIT_STATICINIT.
00235      *
00236      * @note This function accesses to the device
00237      *
00238      * @return  VL53L0X_ERROR_NONE    Success
00239      * @return  "Other error code"    See ::VL53L0X_Error
00240      */
00241     VL53L0X_Error VL53L0X_data_init(void);
00242 
00243     /**
00244      * @brief Do basic device init (and eventually patch loading)
00245      * This function will change the VL53L0X_State from
00246      * VL53L0X_STATE_WAIT_STATICINIT to VL53L0X_STATE_IDLE.
00247      * In this stage all default setting will be applied.
00248      *
00249      * @note This function Access to the device
00250      *
00251      *
00252      * @return  VL53L0X_ERROR_NONE    Success
00253      * @return  "Other error code"    See ::VL53L0X_Error
00254      */
00255     VL53L0X_Error VL53L0X_static_init(void);
00256 
00257     /**
00258      * @brief Perform Reference Calibration
00259      *
00260      * @details Perform a reference calibration of the Device.
00261      * This function should be run from time to time before doing
00262      * a ranging measurement.
00263      * This function will launch a special ranging measurement, so
00264      * if interrupt are enable an interrupt will be done.
00265      * This function will clear the interrupt generated automatically.
00266      *
00267      * @warning This function is a blocking function
00268      *
00269      * @note This function Access to the device
00270      *
00271      *
00272      * @param   p_vhv_settings       Pointer to vhv settings parameter.
00273      * @param   p_phase_cal          Pointer to PhaseCal parameter.
00274      * @return  VL53L0X_ERROR_NONE   Success
00275      * @return  "Other error code"   See ::VL53L0X_Error
00276      */
00277     VL53L0X_Error VL53L0X_perform_ref_calibration( uint8_t *p_vhv_settings,
00278             uint8_t *p_phase_cal);
00279 
00280     /**
00281      * @brief Get Reference Calibration Parameters
00282      *
00283      * @par Function Description
00284      * Get Reference Calibration Parameters.
00285      *
00286      * @note This function Access to the device
00287      *
00288      *
00289      * @param   p_vhv_settings                 Pointer to VHV parameter
00290      * @param   p_phase_cal                    Pointer to PhaseCal Parameter
00291      * @return  VL53L0X_ERROR_NONE             Success
00292      * @return  "Other error code"             See ::VL53L0X_Error
00293      */
00294     VL53L0X_Error VL53L0X_get_ref_calibration(
00295             uint8_t *p_vhv_settings, uint8_t *p_phase_cal);
00296 
00297     VL53L0X_Error VL53L0X_set_ref_calibration(
00298             uint8_t vhv_settings, uint8_t phase_cal);
00299 
00300     /**
00301      * @brief Performs Reference Spad Management
00302      *
00303      * @par Function Description
00304      * The reference SPAD initialization procedure determines the minimum amount
00305      * of reference spads to be enables to achieve a target reference signal rate
00306      * and should be performed once during initialization.
00307      *
00308      * @note This function Access to the device
00309      *
00310      * @note This function change the device mode to VL53L0X_DEVICEMODE_SINGLE_RANGING
00311      *
00312      * @param   ref_spad_count               Reports ref Spad Count
00313      * @param   is_aperture_spads            Reports if spads are of type
00314      *                                       aperture or non-aperture.
00315      *                                       1:=aperture, 0:=Non-Aperture
00316      * @return  VL53L0X_ERROR_NONE           Success
00317      * @return  VL53L0X_ERROR_REF_SPAD_INIT  Error in the Ref Spad procedure.
00318      * @return  "Other error code"           See ::VL53L0X_Error
00319      */
00320     VL53L0X_Error VL53L0X_perform_ref_spad_management(
00321             uint32_t *ref_spad_count, uint8_t *is_aperture_spads);
00322 
00323     /**
00324      * @brief Applies Reference SPAD configuration
00325      *
00326      * @par Function Description
00327      * This function applies a given number of reference spads, identified as
00328      * either Aperture or Non-Aperture.
00329      * The requested spad count and type are stored within the device specific
00330      * parameters data for access by the host.
00331      *
00332      * @note This function Access to the device
00333      *
00334      *
00335      * @param   refSpadCount                 Number of ref spads.
00336      * @param   is_aperture_spads            Defines if spads are of type
00337      *                                       aperture or non-aperture.
00338      *                                       1:=aperture, 0:=Non-Aperture
00339      * @return  VL53L0X_ERROR_NONE           Success
00340      * @return  VL53L0X_ERROR_REF_SPAD_INIT  Error in the in the reference
00341      *                                       spad configuration.
00342      * @return  "Other error code"           See ::VL53L0X_Error
00343      */
00344     VL53L0X_Error VL53L0X_set_reference_spads(
00345             uint32_t refSpadCount, uint8_t is_aperture_spads);
00346 
00347     /**
00348      * @brief Retrieves SPAD configuration
00349      *
00350      * @par Function Description
00351      * This function retrieves the current number of applied reference spads
00352      * and also their type : Aperture or Non-Aperture.
00353      *
00354      * @note This function Access to the device
00355      *
00356      *
00357      * @param   p_spad_count                 Number ref Spad Count
00358      * @param   p_is_aperture_spads          Reports if spads are of type
00359      *                                       aperture or non-aperture.
00360      *                                       1:=aperture, 0:=Non-Aperture
00361      * @return  VL53L0X_ERROR_NONE           Success
00362      * @return  VL53L0X_ERROR_REF_SPAD_INIT  Error in the in the reference
00363      *                                       spad configuration.
00364      * @return  "Other error code"           See ::VL53L0X_Error
00365      */
00366     VL53L0X_Error VL53L0X_get_reference_spads(
00367             uint32_t *p_spad_count, uint8_t *p_is_aperture_spads);
00368 
00369     /**
00370      * @brief Get part to part calibration offset
00371      *
00372      * @par Function Description
00373      * Should only be used after a successful call to @a VL53L0X_DataInit to backup
00374      * device NVM value
00375      *
00376      * @note This function Access to the device
00377      *
00378      * @param   p_offset_calibration_data_micro_meter   Return part to part
00379      * calibration offset from device (microns)
00380      * @return  VL53L0X_ERROR_NONE                      Success
00381      * @return  "Other error code"                      See ::VL53L0X_Error
00382      */
00383     VL53L0X_Error VL53L0X_get_offset_calibration_data_micro_meter(
00384             int32_t *p_offset_calibration_data_micro_meter);
00385     /**
00386      * Set or over-hide part to part calibration offset
00387      * \sa VL53L0X_DataInit()   VL53L0X_GetOffsetCalibrationData_um()
00388      *
00389      * @note This function Access to the device
00390      *
00391      * @param   p_offset_calibration_data_micro_meter    Offset (microns)
00392      * @return  VL53L0X_ERROR_NONE                       Success
00393      * @return  "Other error code"                       See ::VL53L0X_Error
00394      */
00395     VL53L0X_Error VL53L0X_set_offset_calibration_data_micro_meter(
00396             int32_t offset_calibration_data_micro_meter);
00397 
00398     VL53L0X_Error VL53L0X_perform_offset_calibration(
00399             FixPoint1616_t cal_distance_milli_meter,
00400             int32_t *p_offset_micro_meter);
00401 
00402     VL53L0X_Error VL53L0X_perform_xtalk_calibration(
00403             FixPoint1616_t xtalk_cal_distance,
00404             FixPoint1616_t *p_xtalk_compensation_rate_MHz);
00405 
00406     /**
00407      * @brief Set Cross talk compensation rate
00408      *
00409      * @par Function Description
00410      * Set Cross talk compensation rate.
00411      *
00412      * @note This function Access to the device
00413      *
00414      * @param   x_talk_compensation_rate_MHz   Compensation rate in
00415      *                                              Mega counts per second
00416      *                                              (16.16 fix point) see
00417      *                                              datasheet for details
00418      * @return  VL53L0X_ERROR_NONE                  Success
00419      * @return  "Other error code"                  See ::VL53L0X_Error
00420      */
00421     VL53L0X_Error VL53L0X_set_x_talk_compensation_rate_MHz(
00422             FixPoint1616_t x_talk_compensation_rate_MHz);
00423 
00424     /**
00425      * @brief Get Cross talk compensation rate
00426      *
00427      * @par Function Description
00428      * Get Cross talk compensation rate.
00429      *
00430      * @note This function Access to the device
00431      *
00432      * @param   p_xtalk_compensation_rate_MHz  Pointer to Compensation rate
00433      *                                              in Mega counts per second
00434      *                                              (16.16 fix point) see
00435      *                                              datasheet for details
00436      * @return  VL53L0X_ERROR_NONE                  Success
00437      * @return  "Other error code"                  See ::VL53L0X_Error
00438      */
00439     VL53L0X_Error VL53L0X_get_x_talk_compensation_rate_MHz(
00440             FixPoint1616_t *p_xtalk_compensation_rate_MHz);
00441 
00442     /**
00443      * @brief Get Cross talk enable
00444      *
00445      * Enable/Disable Cross Talk by set to zero the Cross Talk value by
00446      * using @a VL53L0X_SetXTalkCompensationRate_MHz().
00447      *
00448      * @param   dev                           Device Handle
00449      * @param   p_x_talk_compensation_enable  Pointer to the Cross talk compensation
00450      *                                        state 0=disabled or 1 = enabled
00451      * @return  VL53L0X_ERROR_NONE                  Success
00452      * @return  "Other error code"                  See ::VL53L0X_Error
00453      */
00454     VL53L0X_Error VL53L0X_get_x_talk_compensation_enable(uint8_t *p_x_talk_compensation_enable);
00455 
00456     /**
00457      * @brief  Set a new device mode
00458      * @par Function Description
00459      * Set device to a new mode (ranging, histogram ...)
00460      *
00461      * @note This function doesn't Access to the device
00462      *
00463      * @param   device_mode           New device mode to apply
00464      *                                Valid values are:
00465      *                                VL53L0X_DEVICEMODE_SINGLE_RANGING
00466      *                                VL53L0X_DEVICEMODE_CONTINUOUS_RANGING
00467      *                                VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING
00468      *
00469      *
00470      * @return  VL53L0X_ERROR_NONE               Success
00471      * @return  VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when
00472      *                                           DeviceMode is not in the
00473      *                                           supported list
00474      */
00475     VL53L0X_Error VL53L0X_set_device_mode( VL53L0X_DeviceModes device_mode);
00476 
00477 
00478     /**
00479     * @brief Get current configuration for GPIO pin for a given device
00480     *
00481     * @note This function Access to the device
00482     *
00483     *
00484     * @param   pin                   ID of the GPIO Pin
00485     * @param   p_device_mode         Pointer to Device Mode associated to the Gpio.
00486     * @param   p_functionality       Pointer to Pin functionality.
00487     *                                Refer to ::VL53L0X_GpioFunctionality
00488     * @param   p_polarity            Pointer to interrupt polarity.
00489     *                                Active high or active low see
00490     *                                ::VL53L0X_InterruptPolarity
00491     * @return  VL53L0X_ERROR_NONE    Success
00492     * @return  VL53L0X_ERROR_GPIO_NOT_EXISTING           Only Pin=0 is accepted.
00493     * @return  VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED
00494     *          This error occurs
00495     *          when Funcionality programmed is not in the supported list:
00496     *                      Supported value are:
00497     *                      VL53L0X_GPIOFUNCTIONALITY_OFF,
00498     *                      VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW,
00499     *                      VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH,
00500     *                      VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT,
00501     *                      VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY
00502     * @return  "Other error code"    See ::VL53L0X_Error
00503     */
00504     VL53L0X_Error VL53L0X_get_gpio_config( uint8_t pin,
00505                                           VL53L0X_DeviceModes *p_device_mode,
00506                                           VL53L0X_GpioFunctionality *p_functionality,
00507                                           VL53L0X_InterruptPolarity *p_polarity);
00508 
00509     /**
00510      * @brief Set the configuration of GPIO pin for a given device
00511      *
00512      * @note This function Access to the device
00513      *
00514      * @param   pin                   ID of the GPIO Pin
00515      * @param   functionality         Select Pin functionality.
00516      *  Refer to ::VL53L0X_GpioFunctionality
00517      * @param   device_mode            Device Mode associated to the Gpio.
00518      * @param   polarity              Set interrupt polarity. Active high
00519      *   or active low see ::VL53L0X_InterruptPolarity
00520      * @return  VL53L0X_ERROR_NONE                            Success
00521      * @return  VL53L0X_ERROR_GPIO_NOT_EXISTING               Only Pin=0 is accepted.
00522      * @return  VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED    This error occurs
00523      * when Functionality programmed is not in the supported list:
00524      *                             Supported value are:
00525      *                             VL53L0X_GPIOFUNCTIONALITY_OFF,
00526      *                             VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW,
00527      *                             VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH,
00528      VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT,
00529      *                               VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY
00530      * @return  "Other error code"    See ::VL53L0X_Error
00531      */
00532     VL53L0X_Error VL53L0X_set_gpio_config( uint8_t pin,
00533                                           VL53L0X_DeviceModes device_mode, VL53L0X_GpioFunctionality functionality,
00534                                           VL53L0X_InterruptPolarity polarity);
00535 
00536     /**
00537      * @brief Start device measurement
00538      *
00539      * @details Started measurement will depend on device parameters set through
00540      * @a VL53L0X_SetParameters()
00541      * This is a non-blocking function.
00542      * This function will change the VL53L0X_State from VL53L0X_STATE_IDLE to
00543      * VL53L0X_STATE_RUNNING.
00544      *
00545      * @note This function Access to the device
00546      *
00547      * @return  VL53L0X_ERROR_NONE                  Success
00548      * @return  VL53L0X_ERROR_MODE_NOT_SUPPORTED    This error occurs when
00549      * DeviceMode programmed with @a VL53L0X_SetDeviceMode is not in the supported
00550      * list:
00551      *                                   Supported mode are:
00552      *                                   VL53L0X_DEVICEMODE_SINGLE_RANGING,
00553      *                                   VL53L0X_DEVICEMODE_CONTINUOUS_RANGING,
00554      *                                   VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING
00555      * @return  VL53L0X_ERROR_TIME_OUT    Time out on start measurement
00556      * @return  "Other error code"   See ::VL53L0X_Error
00557      */
00558     VL53L0X_Error VL53L0X_start_measurement(void);
00559 
00560     /**
00561      * @brief Stop device measurement
00562      *
00563      * @details Will set the device in standby mode at end of current measurement\n
00564      *          Not necessary in single mode as device shall return automatically
00565      *          in standby mode at end of measurement.
00566      *          This function will change the VL53L0X_State from VL53L0X_STATE_RUNNING
00567      *          to VL53L0X_STATE_IDLE.
00568      *
00569      * @note This function Access to the device
00570      *
00571      * @return  VL53L0X_ERROR_NONE    Success
00572      * @return  "Other error code"   See ::VL53L0X_Error
00573      */
00574     VL53L0X_Error VL53L0X_stop_measurement(void);
00575 
00576     /**
00577      * @brief Return device stop completion status
00578      *
00579      * @par Function Description
00580      * Returns stop completiob status.
00581      * User shall call this function after a stop command
00582      *
00583      * @note This function Access to the device
00584      *
00585      *
00586      * @param   p_stop_status            Pointer to status variable to update
00587      * @return  VL53L0X_ERROR_NONE      Success
00588      * @return  "Other error code"     See ::VL53L0X_Error
00589      */
00590     VL53L0X_Error VL53L0X_get_stop_completed_status(
00591             uint32_t *p_stop_status);
00592 
00593     /**
00594      * @brief Return Measurement Data Ready
00595      *
00596      * @par Function Description
00597      * This function indicate that a measurement data is ready.
00598      * This function check if interrupt mode is used then check is done accordingly.
00599      * If perform function clear the interrupt, this function will not work,
00600      * like in case of @a VL53L0X_PerformSingleRangingMeasurement().
00601      * The previous function is blocking function, VL53L0X_GetMeasurementDataReady
00602      * is used for non-blocking capture.
00603      *
00604      * @note This function Access to the device
00605      *
00606      *
00607      * @param   p_measurement_data_ready  Pointer to Measurement Data Ready.
00608      *  0=data not ready, 1 = data ready
00609      * @return  VL53L0X_ERROR_NONE      Success
00610      * @return  "Other error code"     See ::VL53L0X_Error
00611      */
00612     VL53L0X_Error VL53L0X_get_measurement_data_ready(
00613             uint8_t *p_measurement_data_ready);
00614 
00615     /**
00616      * @brief Retrieve the measurements from device for a given setup
00617      *
00618      * @par Function Description
00619      * Get data from last successful Ranging measurement
00620      * @warning USER should take care about  @a VL53L0X_GetNumberOfROIZones()
00621      * before get data.
00622      * PAL will fill a NumberOfROIZones times the corresponding data
00623      * structure used in the measurement function.
00624      *
00625      * @note This function Access to the device
00626      *
00627      *
00628      * @param   p_ranging_measurement_data  Pointer to the data structure to fill up.
00629      * @return  VL53L0X_ERROR_NONE        Success
00630      * @return  "Other error code"       See ::VL53L0X_Error
00631      */
00632     VL53L0X_Error VL53L0X_get_ranging_measurement_data(
00633             VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data);
00634 
00635     /**
00636      * @brief Clear given system interrupt condition
00637      *
00638      * @par Function Description
00639      * Clear given interrupt(s).
00640      *
00641      * @note This function Access to the device
00642      *
00643      *
00644      * @param   interrupt_mask        Mask of interrupts to clear
00645      * @return  VL53L0X_ERROR_NONE    Success
00646      * @return  VL53L0X_ERROR_INTERRUPT_NOT_CLEARED    Cannot clear interrupts
00647      *
00648      * @return  "Other error code"   See ::VL53L0X_Error
00649      */
00650     VL53L0X_Error VL53L0X_clear_interrupt_mask( uint32_t interrupt_mask);
00651 
00652     /**
00653      * @brief Return device interrupt status
00654      *
00655      * @par Function Description
00656      * Returns currently raised interrupts by the device.
00657      * User shall be able to activate/deactivate interrupts through
00658      * @a VL53L0X_SetGpioConfig()
00659      *
00660      * @note This function Access to the device
00661      *
00662      * @param   p_interrupt_mask_status   Pointer to status variable to update
00663      * @return  VL53L0X_ERROR_NONE      Success
00664      * @return  "Other error code"     See ::VL53L0X_Error
00665      */
00666     VL53L0X_Error VL53L0X_get_interrupt_mask_status(
00667             uint32_t *p_interrupt_mask_status);
00668 
00669     /**
00670      * @brief Performs a single ranging measurement and retrieve the ranging
00671      * measurement data
00672      *
00673      * @par Function Description
00674      * This function will change the device mode to VL53L0X_DEVICEMODE_SINGLE_RANGING
00675      * with @a VL53L0X_SetDeviceMode(),
00676      * It performs measurement with @a VL53L0X_PerformSingleMeasurement()
00677      * It get data from last successful Ranging measurement with
00678      * @a VL53L0X_GetRangingMeasurementData.
00679      * Finally it clear the interrupt with @a VL53L0X_ClearInterruptMask().
00680      *
00681      * @note This function Access to the device
00682      *
00683      * @param   p_ranging_measurement_data   Pointer to the data structure to fill up.
00684      * @return  VL53L0X_ERROR_NONE         Success
00685      * @return  "Other error code"        See ::VL53L0X_Error
00686      */
00687     VL53L0X_Error VL53L0X_perform_single_ranging_measurement(
00688             VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data);
00689 
00690     /**
00691      * @brief Single shot measurement.
00692      *
00693      * @par Function Description
00694      * Perform simple measurement sequence (Start measure, Wait measure to end,
00695      * and returns when measurement is done).
00696      * Once function returns, user can get valid data by calling
00697      * VL53L0X_GetRangingMeasurement or VL53L0X_GetHistogramMeasurement
00698      * depending on defined measurement mode
00699      * User should Clear the interrupt in case this are enabled by using the
00700      * function VL53L0X_ClearInterruptMask().
00701      *
00702      * @warning This function is a blocking function
00703      *
00704      * @note This function Access to the device
00705      *
00706      * @return  VL53L0X_ERROR_NONE    Success
00707      * @return  "Other error code"   See ::VL53L0X_Error
00708      */
00709     VL53L0X_Error VL53L0X_perform_single_measurement(void);
00710 
00711     VL53L0X_Error VL53L0X_get_total_signal_rate(
00712             VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
00713             FixPoint1616_t *p_total_signal_rate_MHz);
00714 
00715     VL53L0X_Error VL53L0X_get_total_xtalk_rate(
00716             VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
00717             FixPoint1616_t *p_total_xtalk_rate_MHz);
00718 
00719     /**
00720      * @brief Get Ranging Timing Budget in us
00721      *
00722      * @par Function Description
00723      * Returns the programmed the maximum time allowed by the user to the
00724      * device to run a full ranging sequence for the current mode
00725      * (ranging, histogram, ASL ...)
00726      *
00727      * @note This function Access to the device
00728      *
00729      * @param   p_measurement_timing_budget_us   Max measurement time in
00730      *us.
00731      *                                   Valid values are:
00732      *                                   >= 17000us when wraparound enabled
00733      *                                   >= 12000us when wraparound disabled
00734      * @return  VL53L0X_ERROR_NONE                      Success
00735      * @return  "Other error code"                     See ::VL53L0X_Error
00736      */
00737     VL53L0X_Error VL53L0X_get_measurement_timing_budget_us(
00738             uint32_t *p_measurement_timing_budget_us);
00739 
00740     /**
00741      * @brief Set Ranging Timing Budget in us
00742      *
00743      * @par Function Description
00744      * Defines the maximum time allowed by the user to the device to run a
00745      * full ranging sequence for the current mode (ranging, histogram, ASL ...)
00746      *
00747      * @note This function Access to the device
00748      *
00749      * @param measurement_timing_budget_us  Max measurement time in us.
00750      *                                   Valid values are:
00751      *                                   >= 17000us when wraparound enabled
00752      *                                   >= 12000us when wraparound disabled
00753      * @return  VL53L0X_ERROR_NONE             Success
00754      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is returned if
00755      MeasurementTimingBudget_us out of range
00756      * @return  "Other error code"            See ::VL53L0X_Error
00757      */
00758     VL53L0X_Error VL53L0X_set_measurement_timing_budget_us(
00759             uint32_t measurement_timing_budget_us);
00760 
00761     /**
00762      * @brief  Get specific limit check enable state
00763      *
00764      * @par Function Description
00765      * This function get the enable state of a specific limit check.
00766      * The limit check is identified with the LimitCheckId.
00767      *
00768      * @note This function Access to the device
00769      *
00770      *
00771      * @param   limit_check_id                  Limit Check ID
00772      *  (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
00773      * @param   p_limit_check_enable             Pointer to the check limit enable
00774      * value.
00775      *  if 1 the check limit
00776      *        corresponding to LimitCheckId is Enabled
00777      *  if 0 the check limit
00778      *        corresponding to LimitCheckId is disabled
00779      * @return  VL53L0X_ERROR_NONE             Success
00780      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is returned
00781      *  when LimitCheckId value is out of range.
00782      * @return  "Other error code"            See ::VL53L0X_Error
00783      */
00784     VL53L0X_Error VL53L0X_get_limit_check_enable( uint16_t limit_check_id,
00785             uint8_t *p_limit_check_enable);
00786 
00787     /**
00788      * @brief  Enable/Disable a specific limit check
00789      *
00790      * @par Function Description
00791      * This function Enable/Disable a specific limit check.
00792      * The limit check is identified with the LimitCheckId.
00793      *
00794      * @note This function doesn't Access to the device
00795      *
00796      *
00797      * @param   limit_check_id                  Limit Check ID
00798      *  (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
00799      * @param   limit_check_enable              if 1 the check limit
00800      *  corresponding to LimitCheckId is Enabled
00801      *                                        if 0 the check limit
00802      *  corresponding to LimitCheckId is disabled
00803      * @return  VL53L0X_ERROR_NONE             Success
00804      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is returned
00805      *  when LimitCheckId value is out of range.
00806      * @return  "Other error code"            See ::VL53L0X_Error
00807      */
00808     VL53L0X_Error VL53L0X_set_limit_check_enable( uint16_t limit_check_id,
00809             uint8_t limit_check_enable);
00810 
00811     /**
00812      * @brief  Get a specific limit check value
00813      *
00814      * @par Function Description
00815      * This function get a specific limit check value from device then it updates
00816      * internal values and check enables.
00817      * The limit check is identified with the LimitCheckId.
00818      *
00819      * @note This function Access to the device
00820      *
00821      *
00822      * @param   limit_check_id                  Limit Check ID
00823      *  (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
00824      * @param   p_limit_check_value              Pointer to Limit
00825      *  check Value for a given LimitCheckId.
00826      * @return  VL53L0X_ERROR_NONE             Success
00827      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is returned
00828      *  when LimitCheckId value is out of range.
00829      * @return  "Other error code"            See ::VL53L0X_Error
00830      */
00831     VL53L0X_Error VL53L0X_get_limit_check_value( uint16_t limit_check_id,
00832             FixPoint1616_t *p_limit_check_value);
00833 
00834     /**
00835      * @brief  Set a specific limit check value
00836      *
00837      * @par Function Description
00838      * This function set a specific limit check value.
00839      * The limit check is identified with the LimitCheckId.
00840      *
00841      * @note This function Access to the device
00842      *
00843      *
00844      * @param   limit_check_id                  Limit Check ID
00845      *  (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
00846      * @param   limit_check_value               Limit check Value for a given
00847      * LimitCheckId
00848      * @return  VL53L0X_ERROR_NONE             Success
00849      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is returned when either
00850      *  LimitCheckId or LimitCheckValue value is out of range.
00851      * @return  "Other error code"            See ::VL53L0X_Error
00852      */
00853     VL53L0X_Error VL53L0X_set_limit_check_value( uint16_t limit_check_id,
00854             FixPoint1616_t limit_check_value);
00855 
00856     /**
00857      * @brief  Get the current value of the signal used for the limit check
00858      *
00859      * @par Function Description
00860      * This function get a the current value of the signal used for the limit check.
00861      * To obtain the latest value you should run a ranging before.
00862      * The value reported is linked to the limit check identified with the
00863      * LimitCheckId.
00864      *
00865      * @note This function Access to the device
00866      *
00867      *
00868      * @param   limit_check_id                  Limit Check ID
00869      *  (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
00870      * @param   p_limit_check_current            Pointer to current Value for a
00871      * given LimitCheckId.
00872      * @return  VL53L0X_ERROR_NONE             Success
00873      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is returned when
00874      * LimitCheckId value is out of range.
00875      * @return  "Other error code"            See ::VL53L0X_Error
00876      */
00877     VL53L0X_Error VL53L0X_get_limit_check_current( uint16_t limit_check_id,
00878             FixPoint1616_t *p_limit_check_current);
00879 
00880     /**
00881      * @brief  Return a the Status of the specified check limit
00882      *
00883      * @par Function Description
00884      * This function returns the Status of the specified check limit.
00885      * The value indicate if the check is fail or not.
00886      * The limit check is identified with the LimitCheckId.
00887      *
00888      * @note This function doesn't Access to the device
00889      *
00890      *
00891      * @param   limit_check_id                  Limit Check ID
00892      (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
00893      * @param   p_limit_check_status             Pointer to the
00894      Limit Check Status of the given check limit.
00895      * LimitCheckStatus :
00896      * 0 the check is not fail
00897      * 1 the check if fail or not enabled
00898      *
00899      * @return  VL53L0X_ERROR_NONE             Success
00900      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is
00901      returned when LimitCheckId value is out of range.
00902      * @return  "Other error code"            See ::VL53L0X_Error
00903      */
00904     VL53L0X_Error VL53L0X_get_limit_check_status(
00905             uint16_t limit_check_id, uint8_t *p_limit_check_status);
00906 
00907     /**
00908      * Get continuous mode Inter-Measurement period in _ms
00909      *
00910      * @par Function Description
00911      * When trying to set too short time return  INVALID_PARAMS minimal value
00912      *
00913      * @note This function Access to the device
00914      *
00915      *
00916      * @param   p_inter_measurement_period_ms  Pointer to programmed
00917      *  Inter-Measurement Period in _ms.
00918      * @return  VL53L0X_ERROR_NONE                    Success
00919      * @return  "Other error code"                   See ::VL53L0X_Error
00920      */
00921     VL53L0X_Error VL53L0X_get_inter_measurement_period_ms(
00922             uint32_t *p_inter_measurement_period_ms);
00923 
00924     /**
00925      * Program continuous mode Inter-Measurement period in _ms
00926      *
00927      * @par Function Description
00928      * When trying to set too short time return  INVALID_PARAMS minimal value
00929      *
00930      * @note This function Access to the device
00931      *
00932      *
00933      * @param   inter_measurement_period_ms   Inter-Measurement Period in ms.
00934      * @return  VL53L0X_ERROR_NONE                    Success
00935      * @return  "Other error code"                   See ::VL53L0X_Error
00936      */
00937     VL53L0X_Error VL53L0X_set_inter_measurement_period_ms(
00938          uint32_t inter_measurement_period_ms);
00939 
00940     /**
00941      * @brief Set new device address
00942      *
00943      * After completion the device will answer to the new address programmed.
00944      * This function should be called when several devices are used in parallel
00945      * before start programming the sensor.
00946      * When a single device us used, there is no need to call this function.
00947      *
00948      * @note This function Access to the device
00949      *
00950      *
00951      * @param   device_address         The new Device address
00952      * @return  VL53L0X_ERROR_NONE     Success
00953      * @return  "Other error code"    See ::VL53L0X_Error
00954      */
00955     VL53L0X_Error VL53L0X_set_device_address( uint8_t device_address);
00956 
00957     /**
00958      * @brief Do an hard reset or soft reset (depending on implementation) of the
00959      * device \nAfter call of this function, device must be in same state as right
00960      * after a power-up sequence.This function will change the VL53L0X_State to
00961      * VL53L0X_STATE_POWERDOWN.
00962      *
00963      * @note This function Access to the device
00964      *
00965      *
00966      * @return  VL53L0X_ERROR_NONE     Success
00967      * @return  "Other error code"    See ::VL53L0X_Error
00968      */
00969     VL53L0X_Error VL53L0X_reset_device(void);
00970 
00971     /**
00972      * @brief  Get setup of Wrap around Check
00973      *
00974      * @par Function Description
00975      * This function get the wrapAround check enable parameters
00976      *
00977      * @note This function Access to the device
00978      *
00979      *
00980      * @param   p_wrap_around_check_enable  Pointer to the Wrap around Check state
00981      *                                  0=disabled or 1 = enabled
00982      * @return  VL53L0X_ERROR_NONE       Success
00983      * @return  "Other error code"      See ::VL53L0X_Error
00984      */
00985     VL53L0X_Error VL53L0X_get_wrap_around_check_enable(
00986             uint8_t *p_wrap_around_check_enable);
00987 
00988     /**
00989      * @brief  Enable (or disable) Wrap around Check
00990      *
00991      * @note This function Access to the device
00992      *
00993      *
00994      * @param   wrap_around_check_enable  Wrap around Check to be set
00995      *                                 0=disabled, other = enabled
00996      * @return  VL53L0X_ERROR_NONE      Success
00997      * @return  "Other error code"     See ::VL53L0X_Error
00998      */
00999     VL53L0X_Error VL53L0X_set_wrap_around_check_enable(
01000             uint8_t wrap_around_check_enable);
01001 
01002     /**
01003      * @brief Gets the VCSEL pulse period.
01004      *
01005      * @par Function Description
01006      * This function retrieves the VCSEL pulse period for the given period type.
01007      *
01008      * @note This function Accesses the device
01009      *
01010      *
01011      * @param   vcsel_period_type          VCSEL period identifier (pre-range|final).
01012      * @param   p_vcsel_pulse_period_pclk        Pointer to VCSEL period value.
01013      * @return  VL53L0X_ERROR_NONE        Success
01014      * @return  VL53L0X_ERROR_INVALID_PARAMS  Error VcselPeriodType parameter not
01015      *                                       supported.
01016      * @return  "Other error code"           See ::VL53L0X_Error
01017      */
01018     VL53L0X_Error VL53L0X_get_vcsel_pulse_period(
01019             VL53L0X_VcselPeriod vcsel_period_type, uint8_t *p_vcsel_pulse_period_pclk);
01020 
01021     /**
01022      * @brief Sets the VCSEL pulse period.
01023      *
01024      * @par Function Description
01025      * This function retrieves the VCSEL pulse period for the given period type.
01026      *
01027      * @note This function Accesses the device
01028      *
01029      *
01030      * @param   vcsel_period_type         VCSEL period identifier (pre-range|final).
01031      * @param   vcsel_pulse_period          VCSEL period value
01032      * @return  VL53L0X_ERROR_NONE            Success
01033      * @return  VL53L0X_ERROR_INVALID_PARAMS  Error VcselPeriodType parameter not
01034      *                                       supported.
01035      * @return  "Other error code"           See ::VL53L0X_Error
01036      */
01037     VL53L0X_Error VL53L0X_set_vcsel_pulse_period(
01038             VL53L0X_VcselPeriod vcsel_period_type, uint8_t vcsel_pulse_period);
01039 
01040     /**
01041      * @brief Set low and high Interrupt thresholds for a given mode
01042      * (ranging, ALS, ...) for a given device
01043      *
01044      * @par Function Description
01045      * Set low and high Interrupt thresholds for a given mode (ranging, ALS, ...)
01046      * for a given device
01047      *
01048      * @note This function Access to the device
01049      *
01050      * @note DeviceMode is ignored for the current device
01051      *
01052      *
01053      * @param   device_mode       Device Mode for which change thresholds
01054      * @param   threshold_low     Low threshold (mm, lux ..., depending on the mode)
01055      * @param   threshold_high    High threshold (mm, lux ..., depending on the mode)
01056      * @return  VL53L0X_ERROR_NONE    Success
01057      * @return  "Other error code"   See ::VL53L0X_Error
01058      */
01059     VL53L0X_Error VL53L0X_set_interrupt_thresholds(
01060             VL53L0X_DeviceModes device_mode, FixPoint1616_t threshold_low,
01061             FixPoint1616_t threshold_high);
01062 
01063     /**
01064      * @brief  Get high and low Interrupt thresholds for a given mode
01065      *  (ranging, ALS, ...) for a given device
01066      *
01067      * @par Function Description
01068      * Get high and low Interrupt thresholds for a given mode (ranging, ALS, ...)
01069      * for a given device
01070      *
01071      * @note This function Access to the device
01072      *
01073      * @note DeviceMode is ignored for the current device
01074      *
01075      *
01076      * @param   device_mode       Device Mode from which read thresholds
01077      * @param   p_threshold_low    Low threshold (mm, lux ..., depending on the mode)
01078      * @param   p_threshold_high   High threshold (mm, lux ..., depending on the mode)
01079      * @return  VL53L0X_ERROR_NONE   Success
01080      * @return  "Other error code"  See ::VL53L0X_Error
01081      */
01082     VL53L0X_Error VL53L0X_get_interrupt_thresholds(
01083             VL53L0X_DeviceModes device_mode, FixPoint1616_t *p_threshold_low,
01084             FixPoint1616_t *p_threshold_high);
01085 
01086     /**
01087      * @brief Reads the Device information for given Device
01088      *
01089      * @note This function Access to the device
01090      * _device_info  structure is directly filled
01091      * @return  VL53L0X_ERROR_NONE   Success
01092      * @return  "Other error code"  See ::VL53L0X_Error
01093      */
01094     VL53L0X_Error VL53L0X_get_device_info( );
01095 
01096     /**
01097      * @brief Gets the (on/off) state of all sequence steps.
01098      *
01099      * @par Function Description
01100      * This function retrieves the state of all sequence step in the scheduler.
01101      *
01102      * @note This function Accesses the device
01103      *
01104      *
01105      * @param   p_scheduler_sequence_steps      Pointer to struct containing result.
01106      * @return  VL53L0X_ERROR_NONE            Success
01107      * @return  "Other error code"           See ::VL53L0X_Error
01108      */
01109     VL53L0X_Error VL53L0X_get_sequence_step_enables(
01110             VL53L0X_SchedulerSequenceSteps_t *p_scheduler_sequence_steps);
01111 
01112     /**
01113      * @brief Sets the (on/off) state of a requested sequence step.
01114      *
01115      * @par Function Description
01116      * This function enables/disables a requested sequence step.
01117      *
01118      * @note This function Accesses the device
01119      *
01120      *
01121      * @param   sequence_step_id             Sequence step identifier.
01122      * @param   sequence_step_enabled          Demanded state {0=Off,1=On}
01123      *                                       is enabled.
01124      * @return  VL53L0X_ERROR_NONE            Success
01125      * @return  VL53L0X_ERROR_INVALID_PARAMS  Error SequenceStepId parameter not
01126      *                                       supported.
01127      * @return  "Other error code"           See ::VL53L0X_Error
01128      */
01129     VL53L0X_Error VL53L0X_set_sequence_step_enable(
01130             VL53L0X_SequenceStepId sequence_step_id, uint8_t sequence_step_enabled);
01131 
01132     /**
01133      * @brief  Gets the fraction enable parameter indicating the resolution of
01134      * range measurements.
01135      *
01136      * @par Function Description
01137      * Gets the fraction enable state, which translates to the resolution of
01138      * range measurements as follows :Enabled:=0.25mm resolution,
01139      * Not Enabled:=1mm resolution.
01140      *
01141      * @note This function Accesses the device
01142      *
01143      *
01144      * @param   p_enabled           Output Parameter reporting the fraction enable state.
01145      *
01146      * @return  VL53L0X_ERROR_NONE                   Success
01147      * @return  "Other error code"                  See ::VL53L0X_Error
01148      */
01149     VL53L0X_Error VL53L0X_get_fraction_enable( uint8_t *p_enabled);
01150 
01151     /**
01152      * @brief  Sets the resolution of range measurements.
01153      * @par Function Description
01154      * Set resolution of range measurements to either 0.25mm if
01155      * fraction enabled or 1mm if not enabled.
01156      *
01157      * @note This function Accesses the device
01158      *
01159      *
01160      * @param   enable            Enable high resolution
01161      *
01162      * @return  VL53L0X_ERROR_NONE               Success
01163      * @return  "Other error code"              See ::VL53L0X_Error
01164      */
01165     VL53L0X_Error VL53L0X_set_range_fraction_enable(uint8_t enable);
01166 
01167     /**
01168      * @brief  Retrieve current device parameters
01169      * @par Function Description
01170      * Get actual parameters of the device
01171      * @li Then start ranging operation.
01172      *
01173      * @note This function Access to the device
01174      *
01175      *
01176      * @param   p_device_parameters     Pointer to store current device parameters.
01177      * @return  VL53L0X_ERROR_NONE     Success
01178      * @return  "Other error code"    See ::VL53L0X_Error
01179      */
01180     VL53L0X_Error VL53L0X_get_device_parameters(
01181             VL53L0X_DeviceParameters_t *p_device_parameters);
01182 
01183 
01184     /*** End High level API ***/
01185 public:
01186     /* api.h functions */
01187 
01188     VL53L0X_Error sequence_step_enabled(VL53L0X_SequenceStepId sequence_step_id, uint8_t sequence_config,
01189                                         uint8_t *p_sequence_step_enabled);
01190 
01191     VL53L0X_Error VL53L0X_check_and_load_interrupt_settings(
01192             uint8_t start_not_stopflag);
01193 
01194 
01195     /* api_core.h functions */
01196 
01197     VL53L0X_Error VL53L0X_get_info_from_device( uint8_t option);
01198 
01199     VL53L0X_Error VL53L0X_device_read_strobe(void);
01200 
01201     uint8_t VL53L0X_decode_vcsel_period (uint8_t vcsel_period_reg);
01202 
01203     uint32_t VL53L0X_decode_timeout (uint16_t encoded_timeout);
01204 
01205     uint32_t VL53L0X_calc_timeout_us(
01206                                      uint16_t timeout_period_mclks,
01207                                      uint8_t vcsel_period_pclks);
01208 
01209     uint32_t VL53L0X_calc_macro_period_ps( uint8_t vcsel_period_pclks);
01210 
01211     VL53L0X_Error VL53L0X_measurement_poll_for_completion(void);
01212 
01213     VL53L0X_Error VL53L0X_load_tuning_settings(
01214             uint8_t *p_tuning_setting_buffer);
01215 
01216     VL53L0X_Error VL53L0X_get_pal_range_status( uint8_t device_range_status,
01217             FixPoint1616_t signal_rate,  uint16_t effective_spad_rtn_count,
01218             VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
01219             uint8_t *p_pal_range_status);
01220     VL53L0X_Error VL53L0X_calc_sigma_estimate(
01221             VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
01222             FixPoint1616_t *p_sigma_estimate,
01223             uint32_t *p_dmax_mm);
01224     uint32_t VL53L0X_calc_timeout_mclks( uint32_t timeout_period_us,
01225                                         uint8_t vcsel_period_pclks);
01226     uint32_t VL53L0X_isqrt(uint32_t num);
01227 
01228     uint32_t VL53L0X_quadrature_sum(uint32_t a, uint32_t b);
01229 
01230     VL53L0X_Error VL53L0X_calc_dmax(
01231         FixPoint1616_t total_signal_rate_MHz,
01232         FixPoint1616_t total_corr_signal_rate_MHz,
01233         FixPoint1616_t pw_mult,
01234         uint32_t sigma_estimate_p1,
01235         FixPoint1616_t sigma_estimate_p2,
01236         uint32_t peak_vcsel_duration_us,
01237         uint32_t *pd_max_mm);
01238     VL53L0X_Error wrapped_VL53L0X_set_measurement_timing_budget_us(
01239             uint32_t measurement_timing_budget_us);
01240     VL53L0X_Error get_sequence_step_timeout(VL53L0X_SequenceStepId sequence_step_id,
01241                                             uint32_t *p_time_out_micro_secs);
01242     VL53L0X_Error set_sequence_step_timeout(VL53L0X_SequenceStepId sequence_step_id,
01243                                             uint32_t timeout_micro_secs);
01244     uint16_t VL53L0X_encode_timeout (uint32_t timeout_macro_clks);
01245     VL53L0X_Error wrapped_VL53L0X_set_vcsel_pulse_period(
01246             VL53L0X_VcselPeriod vcsel_period_type, uint8_t vcsel_pulse_period_pclk);
01247     uint8_t lv53l0x_encode_vcsel_period (uint8_t vcsel_period_pclks);
01248 
01249     /* api_calibration.h functions */
01250     VL53L0X_Error VL53L0X_apply_offset_adjustment(void);
01251     VL53L0X_Error wrapped_VL53L0X_perform_ref_spad_management(
01252             uint32_t *ref_spad_count,
01253             uint8_t *is_aperture_spads);
01254     VL53L0X_Error VL53L0X_perform_ref_calibration(
01255             uint8_t *p_vhv_settings, uint8_t *p_phase_cal, uint8_t get_data_enable);
01256     VL53L0X_Error VL53L0X_perform_vhv_calibration(
01257             uint8_t *p_vhv_settings, const uint8_t get_data_enable,
01258             const uint8_t restore_config);
01259     VL53L0X_Error VL53L0X_perform_single_ref_calibration(
01260             uint8_t vhv_init_byte);
01261     VL53L0X_Error VL53L0X_ref_calibration_io( uint8_t read_not_write,
01262             uint8_t vhv_settings, uint8_t phase_cal,
01263             uint8_t *p_vhv_settings, uint8_t *p_phase_cal,
01264             const uint8_t vhv_enable, const uint8_t phase_enable);
01265     VL53L0X_Error VL53L0X_perform_phase_calibration(
01266             uint8_t *p_phase_cal, const uint8_t get_data_enable,
01267             const uint8_t restore_config);
01268     VL53L0X_Error enable_ref_spads(uint8_t aperture_spads,
01269                                    uint8_t good_spad_array[],
01270                                    uint8_t spad_array[],
01271                                    uint32_t size,
01272                                    uint32_t start,
01273                                    uint32_t offset,
01274                                    uint32_t spad_count,
01275                                    uint32_t *p_last_spad);
01276     void get_next_good_spad(uint8_t good_spad_array[], uint32_t size,
01277                             uint32_t curr, int32_t *p_next);
01278     uint8_t is_aperture(uint32_t spad_index);
01279     VL53L0X_Error enable_spad_bit(uint8_t spad_array[], uint32_t size,
01280                                   uint32_t spad_index);
01281     VL53L0X_Error set_ref_spad_map( uint8_t *p_ref_spad_array);
01282     VL53L0X_Error get_ref_spad_map( uint8_t *p_ref_spad_array);
01283     VL53L0X_Error perform_ref_signal_measurement(
01284             uint16_t *p_ref_signal_rate);
01285     VL53L0X_Error wrapped_VL53L0X_set_reference_spads(
01286             uint32_t count, uint8_t is_aperture_spads);
01287 
01288     /* api_strings.h functions */
01289     VL53L0X_Error VL53L0X_check_part_used(uint8_t *revision);
01290 
01291     /* Read function of the ID device */
01292     //   virtual int read_id();
01293     virtual int read_id(uint8_t *id);
01294 
01295     VL53L0X_Error wait_measurement_data_ready(void);
01296 
01297     VL53L0X_Error wait_stop_completed(void);
01298 
01299 
01300     /**
01301      * @brief execute delay in all polling API call
01302      *
01303      * A typical multi-thread or RTOs implementation is to sleep the task for some 5ms (with 100Hz max rate faster polling is not needed)
01304      * if nothing specific is need you can define it as an empty/void macro
01305      * @code
01306      * #define VL53L0X_PollingDelay(...) (void)0
01307      * @endcode
01308      *
01309      * @return  VL53L0X_ERROR_NONE        Success
01310      * @return  "Other error code"    See ::VL53L0X_Error
01311      */
01312     VL53L0X_Error VL53L0X_polling_delay(void);   /* usually best implemented as a real function */
01313 
01314     ///////////////////////////////////////////////////////////////////////////////////////////////////////
01315     //Added functions                                                                                    //
01316     ///////////////////////////////////////////////////////////////////////////////////////////////////////
01317 
01318     /**
01319      * @brief  Cycle Power to Device
01320      *
01321      * @return status - status 0 = ok, 1 = error
01322      *
01323      */
01324     int32_t VL53L0X_cycle_power(void);
01325 
01326     uint8_t VL53L0X_encode_vcsel_period(uint8_t vcsel_period_pclks);
01327 
01328     VL53L0X_Error wrapped_VL53L0X_get_limit_check_info( uint16_t limit_check_id,
01329             char *p_limit_check_string);
01330 
01331     VL53L0X_Error wrapped_VL53L0X_get_ref_calibration(
01332             uint8_t *p_vhv_settings, uint8_t *p_phase_cal);
01333 
01334 
01335     VL53L0X_Error count_enabled_spads(uint8_t spad_array[],
01336                                       uint32_t byte_count, uint32_t max_spads,
01337                                       uint32_t *p_total_spads_enabled, uint8_t *p_is_aperture);
01338 
01339     VL53L0X_Error wrapped_VL53L0X_get_sequence_steps_info(VL53L0X_SequenceStepId sequence_step_id,
01340             char *p_sequence_steps_string);
01341 
01342 
01343     /**
01344      * @brief Gets the name of a given sequence step.
01345      *
01346      * @par Function Description
01347      * This function retrieves the name of sequence steps corresponding to
01348      * SequenceStepId.
01349      *
01350      * @note This function doesn't Accesses the device
01351      *
01352      * @param   sequence_step_id               Sequence step identifier.
01353      * @param   p_sequence_steps_string         Pointer to Info string
01354      *
01355      * @return  VL53L0X_ERROR_NONE            Success
01356      * @return  "Other error code"           See ::VL53L0X_Error
01357      */
01358     VL53L0X_Error VL53L0X_get_sequence_steps_info(VL53L0X_SequenceStepId sequence_step_id,
01359             char *p_sequence_steps_string);
01360 
01361     /**
01362     * @brief Get the frequency of the timer used for ranging results time stamps
01363     *
01364     * @param[out] p_timer_freq_hz : pointer for timer frequency
01365     *
01366     * @return status : 0 = ok, 1 = error
01367     *
01368     */
01369     int32_t VL53L0X_get_timer_frequency(int32_t *p_timer_freq_hz);
01370 
01371     /**
01372     * @brief Get the timer value in units of timer_freq_hz (see VL53L0X_get_timestamp_frequency())
01373     *
01374     * @param[out] p_timer_count : pointer for timer count value
01375     *
01376     * @return status : 0 = ok, 1 = error
01377     *
01378     */
01379     int32_t VL53L0X_get_timer_value(int32_t *p_timer_count);
01380 
01381     /**
01382      * @brief  Get Dmax Calibration Parameters for a given device
01383      *
01384      * @note This function Access to the device
01385      *
01386      * @param   p_range_milli_meter        Pointer to Calibration Distance
01387      * @param   p_signal_rate_rtn_MHz   Pointer to Signal rate return
01388      * @return  VL53L0X_ERROR_NONE       Success
01389      * @return  "Other error code"      See ::VL53L0X_Error
01390      */
01391     VL53L0X_Error VL53L0X_get_dmax_cal_parameters(
01392             uint16_t *p_range_milli_meter, FixPoint1616_t *p_signal_rate_rtn_MHz);
01393 
01394     /**
01395     * @brief   Set Dmax Calibration Parameters for a given device
01396     * When one of the parameter is zero, this function will get parameter
01397     * from NVM.
01398     * @note This function doesn't Access to the device
01399     *
01400     *
01401     * @param   range_milli_meter        Calibration Distance
01402     * @param   signal_rate_rtn_MHz   Signal rate return read at CalDistance
01403     * @return  VL53L0X_ERROR_NONE      Success
01404     * @return  "Other error code"     See ::VL53L0X_Error
01405     */
01406     VL53L0X_Error VL53L0X_get_dmax_cal_parameters(
01407             uint16_t range_milli_meter, FixPoint1616_t signal_rate_rtn_MHz);
01408 
01409 
01410 
01411     /**
01412      * @brief  Return a description string for a given limit check number
01413      *
01414      * @par Function Description
01415      * This function returns a description string for a given limit check number.
01416      * The limit check is identified with the LimitCheckId.
01417      *
01418      * @note This function doesn't Access to the device
01419      *
01420      *
01421      * @param   limit_check_id                  Limit Check ID
01422      (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
01423      * @param   p_limit_check_string             Pointer to the
01424      description string of the given check limit.
01425      * @return  VL53L0X_ERROR_NONE             Success
01426      * @return  VL53L0X_ERROR_INVALID_PARAMS   This error is
01427      returned when LimitCheckId value is out of range.
01428      * @return  "Other error code"            See ::VL53L0X_Error
01429      */
01430     VL53L0X_Error VL53L0X_get_limit_check_info(
01431             uint16_t limit_check_id, char *p_limit_check_string);
01432 
01433     /**
01434      * @brief Get the linearity corrective gain
01435      *
01436      * @par Function Description
01437      * Should only be used after a successful call to @a VL53L0X_DataInit to backup
01438      * device NVM value
01439      *
01440      * @note This function Access to the device
01441      *
01442      *
01443      * @param   p_linearity_corrective_gain           Pointer to the linearity
01444      * corrective gain in x1000
01445      * if value is 1000 then no modification is applied.
01446      * @return  VL53L0X_ERROR_NONE                  Success
01447      * @return  "Other error code"                 See ::VL53L0X_Error
01448      */
01449     VL53L0X_Error VL53L0X_get_linearity_corrective_gain(
01450             uint16_t *p_linearity_corrective_gain);
01451 
01452     /**
01453      * Set the linearity corrective gain
01454      *
01455      * @note This function Access to the device
01456      *
01457      *
01458      * @param   linearity_corrective_gain            Linearity corrective
01459      * gain in x1000
01460      * if value is 1000 then no modification is applied.
01461      * @return  VL53L0X_ERROR_NONE                  Success
01462      * @return  "Other error code"                 See ::VL53L0X_Error
01463      */
01464     VL53L0X_Error VL53L0X_set_linearity_corrective_gain(
01465             int16_t linearity_corrective_gain);
01466 
01467     /**
01468      * @brief Get the Maximum number of ROI Zones managed by the Device
01469      *
01470      * @par Function Description
01471      * Get Maximum number of ROI Zones managed by the Device.
01472      *
01473      * @note This function doesn't Access to the device
01474      *
01475      *
01476      * @param   p_max_number_of_roi_zones   Pointer to the Maximum Number
01477      *  of ROI Zones value.
01478      * @return  VL53L0X_ERROR_NONE      Success
01479      */
01480     VL53L0X_Error VL53L0X_get_max_number_of_roi_zones(
01481             uint8_t *p_max_number_of_roi_zones);
01482 
01483     /**
01484      * @brief Retrieve the Reference Signal after a measurements
01485      *
01486      * @par Function Description
01487      * Get Reference Signal from last successful Ranging measurement
01488      * This function return a valid value after that you call the
01489      * @a VL53L0X_GetRangingMeasurementData().
01490      *
01491      * @note This function Access to the device
01492      *
01493      *
01494      * @param   p_measurement_ref_signal    Pointer to the Ref Signal to fill up.
01495      * @return  VL53L0X_ERROR_NONE        Success
01496      * @return  "Other error code"       See ::VL53L0X_Error
01497      */
01498     VL53L0X_Error VL53L0X_get_measurement_ref_signal(
01499             FixPoint1616_t *p_measurement_ref_signal);
01500 
01501     /**
01502      * @brief  Get the number of the check limit managed by a given Device
01503      *
01504      * @par Function Description
01505      * This function give the number of the check limit managed by the Device
01506      *
01507      * @note This function doesn't Access to the device
01508      *
01509      * @param   p_number_of_limit_check           Pointer to the number of check limit.
01510      * @return  VL53L0X_ERROR_NONE             Success
01511      * @return  "Other error code"            See ::VL53L0X_Error
01512      */
01513     VL53L0X_Error VL53L0X_get_number_of_limit_check(
01514         uint16_t *p_number_of_limit_check);
01515 
01516     /**
01517      * @brief Gets number of sequence steps managed by the API.
01518      *
01519      * @par Function Description
01520      * This function retrieves the number of sequence steps currently managed
01521      * by the API
01522      *
01523      * @note This function Accesses the device
01524      *
01525      * @param   p_number_of_sequence_steps       Out parameter reporting the number of
01526      *                                       sequence steps.
01527      * @return  VL53L0X_ERROR_NONE            Success
01528      * @return  "Other error code"           See ::VL53L0X_Error
01529      */
01530     VL53L0X_Error VL53L0X_get_number_of_sequence_steps(
01531             uint8_t *p_number_of_sequence_steps);
01532     /**
01533      * @brief Get the power mode for a given Device
01534      *
01535      * @note This function Access to the device
01536      *
01537      *
01538      * @param   p_power_mode            Pointer to the current value of the power
01539      * mode. see ::VL53L0X_PowerModes
01540      *                                Valid values are:
01541      *                                VL53L0X_POWERMODE_STANDBY_LEVEL1,
01542      *                                VL53L0X_POWERMODE_IDLE_LEVEL1
01543      * @return  VL53L0X_ERROR_NONE     Success
01544      * @return  "Other error code"    See ::VL53L0X_Error
01545      */
01546     VL53L0X_Error VL53L0X_get_power_mode(
01547                                          VL53L0X_PowerModes *p_power_mode);
01548 
01549     /**
01550      * @brief Set the power mode for a given Device
01551      * The power mode can be Standby or Idle. Different level of both Standby and
01552      * Idle can exists.
01553      * This function should not be used when device is in Ranging state.
01554      *
01555      * @note This function Access to the device
01556      *
01557      * @param   power_mode             The value of the power mode to set.
01558      * see ::VL53L0X_PowerModes
01559      *                                Valid values are:
01560      *                                VL53L0X_POWERMODE_STANDBY_LEVEL1,
01561      *                                VL53L0X_POWERMODE_IDLE_LEVEL1
01562      * @return  VL53L0X_ERROR_NONE                  Success
01563      * @return  VL53L0X_ERROR_MODE_NOT_SUPPORTED    This error occurs when PowerMode
01564      * is not in the supported list
01565      * @return  "Other error code"    See ::VL53L0X_Error
01566      */
01567     VL53L0X_Error VL53L0X_set_power_mode(VL53L0X_PowerModes power_mode);
01568 
01569     /**
01570      * @brief Retrieves SPAD configuration
01571      *
01572      * @par Function Description
01573      * This function retrieves the current number of applied reference spads
01574      * and also their type : Aperture or Non-Aperture.
01575      *
01576      * @note This function Access to the device
01577      *
01578      *
01579      * @param   p_spad_count                 Number ref Spad Count
01580      * @param   p_is_aperture_spads              Reports if spads are of type
01581      *                                       aperture or non-aperture.
01582      *                                       1:=aperture, 0:=Non-Aperture
01583      * @return  VL53L0X_ERROR_NONE            Success
01584      * @return  VL53L0X_ERROR_REF_SPAD_INIT   Error in the in the reference
01585      *                                       spad configuration.
01586      * @return  "Other error code"           See ::VL53L0X_Error
01587      */
01588     VL53L0X_Error wrapped_VL53L0X_get_reference_spads(
01589             uint32_t *p_spad_count, uint8_t *p_is_aperture_spads);
01590 
01591     /**
01592      * @brief Gets the (on/off) state of a requested sequence step.
01593      *
01594      * @par Function Description
01595      * This function retrieves the state of a requested sequence step, i.e. on/off.
01596      *
01597      * @note This function Accesses the device
01598      *
01599      *
01600      * @param   sequence_step_id         Sequence step identifier.
01601      * @param   p_sequence_step_enabled   Out parameter reporting if the sequence step
01602      *                                 is enabled {0=Off,1=On}.
01603      * @return  VL53L0X_ERROR_NONE            Success
01604      * @return  VL53L0X_ERROR_INVALID_PARAMS  Error SequenceStepId parameter not
01605      *                                       supported.
01606      * @return  "Other error code"           See ::VL53L0X_Error
01607      */
01608     VL53L0X_Error VL53L0X_get_sequence_step_enable(
01609             VL53L0X_SequenceStepId sequence_step_id, uint8_t *p_sequence_step_enabled);
01610 
01611     /**
01612      * @brief Gets the timeout of a requested sequence step.
01613      *
01614      * @par Function Description
01615      * This function retrieves the timeout of a requested sequence step.
01616      *
01617      * @note This function Accesses the device
01618      *
01619      * @param   sequence_step_id               Sequence step identifier.
01620      * @param   p_time_out_milli_secs            Timeout value.
01621      * @return  VL53L0X_ERROR_NONE            Success
01622      * @return  VL53L0X_ERROR_INVALID_PARAMS  Error SequenceStepId parameter not
01623      *                                       supported.
01624      * @return  "Other error code"           See ::VL53L0X_Error
01625      */
01626     VL53L0X_Error VL53L0X_get_sequence_step_timeout(VL53L0X_SequenceStepId sequence_step_id,
01627             FixPoint1616_t *p_time_out_milli_secs);
01628 
01629     /**
01630      * @brief Sets the timeout of a requested sequence step.
01631      *
01632      * @par Function Description
01633      * This function sets the timeout of a requested sequence step.
01634      *
01635      * @note This function Accesses the device
01636      *
01637      *
01638      * @param   sequence_step_id               Sequence step identifier.
01639      * @param   time_out_milli_secs             Demanded timeout
01640      * @return  VL53L0X_ERROR_NONE            Success
01641      * @return  VL53L0X_ERROR_INVALID_PARAMS  Error SequenceStepId parameter not
01642      *                                       supported.
01643      * @return  "Other error code"           See ::VL53L0X_Error
01644      */
01645     VL53L0X_Error VL53L0X_set_sequence_step_timeout(
01646             VL53L0X_SequenceStepId sequence_step_id, FixPoint1616_t time_out_milli_secs);
01647 
01648     /**
01649     * @brief Get the tuning settings pointer and the internal external switch
01650     * value.
01651     *
01652     * This function is used to get the Tuning settings buffer pointer and the
01653     * value.
01654     * of the switch to select either external or internal tuning settings.
01655     *
01656     * @note This function Access to the device
01657     *
01658     *
01659     * @param   pp_tuning_setting_buffer      Pointer to tuning settings buffer.
01660     * @param   p_use_internal_tuning_settings Pointer to store Use internal tuning
01661     *                                     settings value.
01662     * @return  VL53L0X_ERROR_NONE          Success
01663     * @return  "Other error code"         See ::VL53L0X_Error
01664     */
01665     VL53L0X_Error VL53L0X_get_tuning_setting_buffer(
01666             uint8_t **pp_tuning_setting_buffer, uint8_t *p_use_internal_tuning_settings);
01667 
01668     /**
01669      * @brief Set the tuning settings pointer
01670      *
01671      * This function is used to specify the Tuning settings buffer to be used
01672      * for a given device. The buffer contains all the necessary data to permit
01673      * the API to write tuning settings.
01674      * This function permit to force the usage of either external or internal
01675      * tuning settings.
01676      *
01677      * @note This function Access to the device
01678      *
01679      *
01680      * @param   p_tuning_setting_buffer            Pointer to tuning settings buffer.
01681      * @param   use_internal_tuning_settings       Use internal tuning settings value.
01682      * @return  VL53L0X_ERROR_NONE     Success
01683      * @return  "Other error code"    See ::VL53L0X_Error
01684      */
01685     VL53L0X_Error VL53L0X_set_tuning_setting_buffer(
01686             uint8_t *p_tuning_setting_buffer, uint8_t use_internal_tuning_settings);
01687 
01688     /**
01689      * @defgroup VL53L0X_registerAccess_group PAL Register Access Functions
01690      * @brief    PAL Register Access Functions
01691      *  @{
01692      */
01693 
01694     /**
01695      * @brief  Prepare device for operation
01696      * @par Function Description
01697      * Update device with provided parameters
01698      * @li Then start ranging operation.
01699      *
01700      * @note This function Access to the device
01701      *
01702      *
01703      * @param   pDeviceParameters     Pointer to store current device parameters.
01704      * @return  VL53L0X_ERROR_NONE     Success
01705      * @return  "Other error code"    See ::VL53L0X_Error
01706      */
01707     VL53L0X_Error vl53L0x_set_device_parameters(
01708             const VL53L0X_DeviceParameters_t *pDeviceParameters);
01709 
01710     VL53L0X_Error VL53L0X_reverse_bytes(uint8_t *data, uint32_t size);
01711 
01712     int range_meas_int_continuous_mode(void (*fptr)(void));
01713 
01714     /* Digital out pin */
01715     DigitalOut *_gpio0;
01716     /* Measure detection IRQ */
01717     InterruptIn *_gpio1Int;
01718     
01719     VL53L0X_DevData_t Data;
01720     VL53L0X_DeviceInfo_t Device_Info;
01721     VL53L0X_DeviceParameters_t CurrentParameters ; /*!< Current Device Parameter */
01722     VL53L0X_RangingMeasurementData_t LastRangeMeasure ; /*!< Last Performed Ranging Data */
01723     
01724 public: 
01725     /* IO Device */
01726     I2C *_dev_i2c;
01727     uint8_t   I2cDevAddr ;         /*!< i2c device address user specific field */
01728     uint8_t   comms_type ;         /*!< Type of comms : VL53L0X_COMMS_I2C or VL53L0X_COMMS_SPI */
01729     uint16_t  comms_speed_khz ;    /*!< Comms speed [kHz] : typically 400kHz for I2C           */
01730 
01731     /* Write and read functions from I2C */
01732     /**  Write single byte register
01733      *
01734      * @param   index     The register index
01735      * @param   data      8 bit register data
01736      * @return  VL53L0X_ERROR_NONE        Success
01737      * @return  "Other error code"    See ::VL53L0X_Error  */
01738      
01739     VL53L0X_Error VL53L0X_write_byte( uint8_t index, uint8_t data);
01740     /**  Write word register
01741      *
01742      * @param   index     The register index
01743      * @param   data      16 bit register data
01744      * @return  VL53L0X_ERROR_NONE        Success
01745      * @return  "Other error code"    See ::VL53L0X_Error  */
01746      
01747     VL53L0X_Error VL53L0X_write_word( uint8_t index, uint16_t data);
01748     /**  Write double word (4 byte) register
01749      *
01750      * @param   index     The register index
01751      * @param   data      32 bit register data
01752      * @return  VL53L0X_ERROR_NONE        Success
01753      * @return  "Other error code"    See ::VL53L0X_Error  */
01754      
01755     VL53L0X_Error VL53L0X_write_dword( uint8_t index, uint32_t data);
01756     /**  Read single byte register
01757      *
01758      * @param   index     The register index
01759      * @param   data      pointer to 8 bit data
01760      * @return  VL53L0X_ERROR_NONE        Success
01761      * @return  "Other error code"    See ::VL53L0X_Error  */
01762      
01763     VL53L0X_Error VL53L0X_read_byte( uint8_t index, uint8_t *p_data);
01764     /**  Read word (2byte) register
01765      *
01766      * @param   index     The register index
01767      * @param   data      pointer to 16 bit data
01768      * @return  VL53L0X_ERROR_NONE        Success
01769      * @return  "Other error code"    See ::VL53L0X_Error  */
01770      
01771     VL53L0X_Error VL53L0X_read_word( uint8_t index, uint16_t *p_data);
01772     /**  Read dword (4byte) register
01773      *
01774      * @param   index     The register index
01775      * @param   data      pointer to 32 bit data
01776      * @return  VL53L0X_ERROR_NONE        Success
01777      * @return  "Other error code"    See ::VL53L0X_Error  */
01778     VL53L0X_Error VL53L0X_read_dword( uint8_t index, uint32_t *p_data);
01779     
01780     /**  Thread safe Update (read/modify/write) single byte register
01781      *
01782      * Final_reg = (Initial_reg & and_data) |or_data
01783      *
01784      * @param   index      The register index
01785      * @param   and_data    8 bit and data
01786      * @param   or_data     8 bit or data
01787      * @return  VL53L0X_ERROR_NONE        Success
01788      * @return  "Other error code"    See ::VL53L0X_Error  */
01789     VL53L0X_Error VL53L0X_update_byte( uint8_t index, uint8_t and_data, uint8_t or_data);
01790 
01791     /**   Reads the requested number of bytes from the device
01792      *
01793      * @param   index     The register index
01794      * @param   p_data     Pointer to the uint8_t buffer to store read data
01795      * @param   count     Number of uint8_t's to read
01796      * @return  VL53L0X_ERROR_NONE        Success
01797      * @return  "Other error code"    See ::VL53L0X_Error  */
01798     VL53L0X_Error VL53L0X_read_multi( uint8_t index, uint8_t *p_data, uint32_t count);
01799     
01800      /**  @brief  Writes a buffer towards the I2C peripheral device.
01801      *
01802      * @param  p_data pointer to the byte-array data to send
01803      * @param  number_of_bytes number of bytes to be written.
01804      * @retval 0 if ok,
01805      * @retval -1 if an I2C error has occured
01806      * @note   On some devices if NumByteToWrite is greater
01807      *         than one, the RegisterAddr must be masked correctly!  */
01808     VL53L0X_Error VL53L0X_i2c_write(uint8_t index, uint8_t *p_data, uint16_t number_of_bytes);
01809 
01810     /**  @brief  Reads a buffer from the I2C peripheral device.
01811      *
01812      * @param  p_data pointer to the byte-array to read data in to
01813      * @param  number_of_bytes number of bytes to be read.
01814      * @retval 0 if ok,
01815      * @retval -1 if an I2C error has occured
01816      * @note   On some devices if NumByteToWrite is greater
01817      *         than one, the RegisterAddr must be masked correctly!  */
01818     VL53L0X_Error VL53L0X_i2c_read(uint8_t index, uint8_t *p_data, uint16_t number_of_bytes);
01819 };
01820 
01821 void Report_Deep_Infos (VL53L0X TOF1, Serial *aSerial);
01822 void Report_Range_Infos(VL53L0X_RangingMeasurementData_t RangeResults, Serial *aSerial);
01823 
01824 #endif /* _VL53L0X_CLASS_H_ */