Working version without LEDs

Dependencies:   mbed WS2812

Voici le dernier schéma de cablage (version du 08/02/2020)

https://os.mbed.com/media/uploads/max_ence/schemarobot_fev2020.pdf

Committer:
elab
Date:
Sat May 30 09:31:57 2020 +0000
Revision:
1:69b5d8f0ba9c
Parent:
0:0e577ce96b2f
pour eLab;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elab 0:0e577ce96b2f 1 /*******************************************************************************
elab 0:0e577ce96b2f 2 Copyright © 2016, STMicroelectronics International N.V.
elab 0:0e577ce96b2f 3 All rights reserved.
elab 0:0e577ce96b2f 4
elab 0:0e577ce96b2f 5 Redistribution and use in source and binary forms, with or without
elab 0:0e577ce96b2f 6 modification, are permitted provided that the following conditions are met:
elab 0:0e577ce96b2f 7 * Redistributions of source code must retain the above copyright
elab 0:0e577ce96b2f 8 notice, this list of conditions and the following disclaimer.
elab 0:0e577ce96b2f 9 * Redistributions in binary form must reproduce the above copyright
elab 0:0e577ce96b2f 10 notice, this list of conditions and the following disclaimer in the
elab 0:0e577ce96b2f 11 documentation and/or other materials provided with the distribution.
elab 0:0e577ce96b2f 12 * Neither the name of STMicroelectronics nor the
elab 0:0e577ce96b2f 13 names of its contributors may be used to endorse or promote products
elab 0:0e577ce96b2f 14 derived from this software without specific prior written permission.
elab 0:0e577ce96b2f 15
elab 0:0e577ce96b2f 16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
elab 0:0e577ce96b2f 17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
elab 0:0e577ce96b2f 18 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
elab 0:0e577ce96b2f 19 NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
elab 0:0e577ce96b2f 20 IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
elab 0:0e577ce96b2f 21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
elab 0:0e577ce96b2f 22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
elab 0:0e577ce96b2f 23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
elab 0:0e577ce96b2f 24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
elab 0:0e577ce96b2f 25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
elab 0:0e577ce96b2f 26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
elab 0:0e577ce96b2f 27 *****************************************************************************/
elab 0:0e577ce96b2f 28
elab 0:0e577ce96b2f 29 #ifndef __VL53L0X_CLASS_H
elab 0:0e577ce96b2f 30 #define __VL53L0X_CLASS_H
elab 0:0e577ce96b2f 31
elab 0:0e577ce96b2f 32
elab 0:0e577ce96b2f 33 /* Includes ------------------------------------------------------------------*/
elab 0:0e577ce96b2f 34 #include "mbed.h"
elab 0:0e577ce96b2f 35 #include "pinmap.h"
elab 0:0e577ce96b2f 36 #include "PinNames.h"
elab 0:0e577ce96b2f 37 #include "VL53L0X_def.h"
elab 0:0e577ce96b2f 38
elab 0:0e577ce96b2f 39 /* Classes -------------------------------------------------------------------*/
elab 0:0e577ce96b2f 40 /** Class representing a VL53L0 sensor component */
elab 0:0e577ce96b2f 41 class VL53L0X
elab 0:0e577ce96b2f 42 {
elab 0:0e577ce96b2f 43 public:
elab 0:0e577ce96b2f 44 /** Constructor
elab 0:0e577ce96b2f 45 * @param[in] &i2c device I2C to be used for communication
elab 0:0e577ce96b2f 46 * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
elab 0:0e577ce96b2f 47 * @param[in] dev_addr device address, 0x29 by default
elab 0:0e577ce96b2f 48 */
elab 0:0e577ce96b2f 49 VL53L0X(I2C *i2c, DigitalOut *pin, PinName pin_gpio1, uint8_t dev_addr = VL53L0X_DEFAULT_ADDRESS) : _gpio0(pin), _dev_i2c(i2c)
elab 0:0e577ce96b2f 50 { I2cDevAddr = dev_addr;
elab 0:0e577ce96b2f 51 comms_type = 1; // VL53L0X_COMMS_I2C
elab 0:0e577ce96b2f 52 comms_speed_khz = 400;
elab 0:0e577ce96b2f 53 if (pin_gpio1 != NC) { _gpio1Int = new InterruptIn(pin_gpio1); }
elab 0:0e577ce96b2f 54 else { _gpio1Int = NULL; }
elab 0:0e577ce96b2f 55 }
elab 0:0e577ce96b2f 56
elab 0:0e577ce96b2f 57 /** Destructor
elab 0:0e577ce96b2f 58 */
elab 0:0e577ce96b2f 59 virtual ~VL53L0X()
elab 0:0e577ce96b2f 60 { if (_gpio1Int != NULL) { delete _gpio1Int; } }
elab 0:0e577ce96b2f 61
elab 0:0e577ce96b2f 62 /*** Interface Methods High level API ***/
elab 0:0e577ce96b2f 63 /**
elab 0:0e577ce96b2f 64 * @brief PowerOn the sensor
elab 0:0e577ce96b2f 65 * @return void
elab 0:0e577ce96b2f 66 */
elab 0:0e577ce96b2f 67 /* turns on the sensor */
elab 0:0e577ce96b2f 68 void VL53L0X_on(void)
elab 0:0e577ce96b2f 69 {
elab 0:0e577ce96b2f 70 if (_gpio0) { *_gpio0 = 1; }
elab 0:0e577ce96b2f 71 wait_ms(10);
elab 0:0e577ce96b2f 72 }
elab 0:0e577ce96b2f 73
elab 0:0e577ce96b2f 74 /**
elab 0:0e577ce96b2f 75 * @brief PowerOff the sensor
elab 0:0e577ce96b2f 76 * @return void
elab 0:0e577ce96b2f 77 */
elab 0:0e577ce96b2f 78 /* turns off the sensor */
elab 0:0e577ce96b2f 79 void VL53L0X_off(void)
elab 0:0e577ce96b2f 80 {
elab 0:0e577ce96b2f 81 if (_gpio0) { *_gpio0 = 0; }
elab 0:0e577ce96b2f 82 wait_ms(10);
elab 0:0e577ce96b2f 83 }
elab 0:0e577ce96b2f 84
elab 0:0e577ce96b2f 85
elab 0:0e577ce96b2f 86 /**
elab 0:0e577ce96b2f 87 * @brief Initialize the sensor with default values
elab 0:0e577ce96b2f 88 * @return "0" on success
elab 0:0e577ce96b2f 89 */
elab 0:0e577ce96b2f 90 int init_sensor(uint8_t new_addr = VL53L0X_DEFAULT_ADDRESS);
elab 0:0e577ce96b2f 91
elab 0:0e577ce96b2f 92 /**
elab 0:0e577ce96b2f 93 * @brief Start the measure indicated by operating mode
elab 0:0e577ce96b2f 94 * @param[in] operating_mode specifies requested measure
elab 0:0e577ce96b2f 95 * @param[in] fptr specifies call back function must be !NULL in case of interrupt measure
elab 0:0e577ce96b2f 96 * @return "0" on success
elab 0:0e577ce96b2f 97 */
elab 0:0e577ce96b2f 98 int start_measurement(OperatingMode operating_mode, void (*fptr)(void),
elab 0:0e577ce96b2f 99 VL53L0X_RangingConfig rangingConfig );
elab 0:0e577ce96b2f 100
elab 0:0e577ce96b2f 101 /**
elab 0:0e577ce96b2f 102 * @brief Get results for the measure indicated by operating mode
elab 0:0e577ce96b2f 103 * @param[in] operating_mode specifies requested measure results
elab 0:0e577ce96b2f 104 * @param[out] p_data pointer to the MeasureData_t structure to read data in to
elab 0:0e577ce96b2f 105 * @return "0" on success
elab 0:0e577ce96b2f 106 */
elab 0:0e577ce96b2f 107 int get_measurement(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *p_data);
elab 0:0e577ce96b2f 108
elab 0:0e577ce96b2f 109 /**
elab 0:0e577ce96b2f 110 * @brief Stop the currently running measure indicate by operating_mode
elab 0:0e577ce96b2f 111 * @param[in] operating_mode specifies requested measure to stop
elab 0:0e577ce96b2f 112 * @return "0" on success
elab 0:0e577ce96b2f 113 */
elab 0:0e577ce96b2f 114 int stop_measurement(OperatingMode operating_mode);
elab 0:0e577ce96b2f 115
elab 0:0e577ce96b2f 116 /**
elab 0:0e577ce96b2f 117 * @brief Interrupt handling func to be called by user after an INT is occourred
elab 0:0e577ce96b2f 118 * @param[in] opeating_mode indicating the in progress measure
elab 0:0e577ce96b2f 119 * @param[out] Data pointer to the MeasureData_t structure to read data in to
elab 0:0e577ce96b2f 120 * @return "0" on success
elab 0:0e577ce96b2f 121 */
elab 0:0e577ce96b2f 122 int handle_irq(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *data);
elab 0:0e577ce96b2f 123
elab 0:0e577ce96b2f 124 /**
elab 0:0e577ce96b2f 125 * @brief Enable interrupt measure IRQ
elab 0:0e577ce96b2f 126 * @return "0" on success
elab 0:0e577ce96b2f 127 */
elab 0:0e577ce96b2f 128 void enable_interrupt_measure_detection_irq(void)
elab 0:0e577ce96b2f 129 { if (_gpio1Int != NULL) { _gpio1Int->enable_irq();} }
elab 0:0e577ce96b2f 130
elab 0:0e577ce96b2f 131 /**
elab 0:0e577ce96b2f 132 * @brief Disable interrupt measure IRQ
elab 0:0e577ce96b2f 133 * @return "0" on success
elab 0:0e577ce96b2f 134 */
elab 0:0e577ce96b2f 135 void disable_interrupt_measure_detection_irq(void)
elab 0:0e577ce96b2f 136 { if (_gpio1Int != NULL) { _gpio1Int->disable_irq(); } }
elab 0:0e577ce96b2f 137
elab 0:0e577ce96b2f 138 /**
elab 0:0e577ce96b2f 139 * @brief Attach a function to call when an interrupt is detected, i.e. measurement is ready
elab 0:0e577ce96b2f 140 * @param[in] fptr pointer to call back function to be called whenever an interrupt occours
elab 0:0e577ce96b2f 141 * @return "0" on success
elab 0:0e577ce96b2f 142 */
elab 0:0e577ce96b2f 143 void attach_interrupt_measure_detection_irq(void (*fptr)(void))
elab 0:0e577ce96b2f 144 { if (_gpio1Int != NULL) { _gpio1Int->rise(fptr); } }
elab 0:0e577ce96b2f 145
elab 0:0e577ce96b2f 146 /** Wrapper functions */
elab 0:0e577ce96b2f 147 /** @defgroup api_init Init functions
elab 0:0e577ce96b2f 148 * @brief API init functions
elab 0:0e577ce96b2f 149 * @ingroup api_hl
elab 0:0e577ce96b2f 150 * @{
elab 0:0e577ce96b2f 151 */
elab 0:0e577ce96b2f 152
elab 0:0e577ce96b2f 153 /**
elab 0:0e577ce96b2f 154 * @brief Prepare device for operation
elab 0:0e577ce96b2f 155 * @par Function Description
elab 0:0e577ce96b2f 156 * Does static initialization and reprogram common default settings \n
elab 0:0e577ce96b2f 157 * Device is prepared for new measure, ready single shot ranging or ALS typical polling operation\n
elab 0:0e577ce96b2f 158 * After prepare user can : \n
elab 0:0e577ce96b2f 159 * @li Call other API function to set other settings\n
elab 0:0e577ce96b2f 160 * @li Configure the interrupt pins, etc... \n
elab 0:0e577ce96b2f 161 * @li Then start ranging or ALS operations in single shot or continuous mode
elab 0:0e577ce96b2f 162 *
elab 0:0e577ce96b2f 163 * @param void
elab 0:0e577ce96b2f 164 * @return "0" on success
elab 0:0e577ce96b2f 165 */
elab 0:0e577ce96b2f 166 int prepare();
elab 0:0e577ce96b2f 167
elab 0:0e577ce96b2f 168 /**
elab 0:0e577ce96b2f 169 * @brief Start continuous ranging mode
elab 0:0e577ce96b2f 170 *
elab 0:0e577ce96b2f 171 * @details End user should ensure device is in idle state and not already running
elab 0:0e577ce96b2f 172 * @return "0" on success
elab 0:0e577ce96b2f 173 */
elab 0:0e577ce96b2f 174 int range_start_continuous_mode();
elab 0:0e577ce96b2f 175
elab 0:0e577ce96b2f 176 /**
elab 0:0e577ce96b2f 177 * @brief Get ranging result and only that
elab 0:0e577ce96b2f 178 *
elab 0:0e577ce96b2f 179 * @par Function Description
elab 0:0e577ce96b2f 180 * Unlike @a VL53L0X_get_ranging_measurement_data() this function only retrieves the range in _mm \n
elab 0:0e577ce96b2f 181 * It does any required up-scale translation\n
elab 0:0e577ce96b2f 182 * It can be called after success status polling or in interrupt mode \n
elab 0:0e577ce96b2f 183 * @warning these function is not doing wrap around filtering \n
elab 0:0e577ce96b2f 184 * This function doesn't perform any data ready check!
elab 0:0e577ce96b2f 185 *
elab 0:0e577ce96b2f 186 * @param p_data Pointer to range distance
elab 0:0e577ce96b2f 187 * @return "0" on success
elab 0:0e577ce96b2f 188 */
elab 0:0e577ce96b2f 189 int get_distance(uint32_t *p_data);
elab 0:0e577ce96b2f 190
elab 0:0e577ce96b2f 191 /** @} */
elab 0:0e577ce96b2f 192
elab 0:0e577ce96b2f 193 /** @brief Set new device i2c address
elab 0:0e577ce96b2f 194 *
elab 0:0e577ce96b2f 195 * After completion the device will answer to the new address programmed.
elab 0:0e577ce96b2f 196 *
elab 0:0e577ce96b2f 197 * @param new_addr The new i2c address (7bit)
elab 0:0e577ce96b2f 198 * @return "0" on success
elab 0:0e577ce96b2f 199 */
elab 0:0e577ce96b2f 200 int set_device_address(int new_addr)
elab 0:0e577ce96b2f 201 {
elab 0:0e577ce96b2f 202 int status;
elab 0:0e577ce96b2f 203
elab 0:0e577ce96b2f 204 status = VL53L0X_set_device_address(new_addr);
elab 0:0e577ce96b2f 205 if (!status) { I2cDevAddr = new_addr; }
elab 0:0e577ce96b2f 206 return status;
elab 0:0e577ce96b2f 207 }
elab 0:0e577ce96b2f 208
elab 0:0e577ce96b2f 209 /**
elab 0:0e577ce96b2f 210 * @brief Clear given system interrupt condition
elab 0:0e577ce96b2f 211 *
elab 0:0e577ce96b2f 212 * @par Function Description
elab 0:0e577ce96b2f 213 * Clear given interrupt cause by writing into register #SYSTEM_INTERRUPT_CLEAR register.
elab 0:0e577ce96b2f 214 * @param int_clear Which interrupt source to clear. Use any combinations of #INTERRUPT_CLEAR_RANGING , #INTERRUPT_CLEAR_ALS , #INTERRUPT_CLEAR_ERROR.
elab 0:0e577ce96b2f 215 * @return "0" on success
elab 0:0e577ce96b2f 216 */
elab 0:0e577ce96b2f 217 int clear_interrupt(uint8_t int_clear)
elab 0:0e577ce96b2f 218 { return VL53L0X_clear_interrupt_mask(int_clear); }
elab 0:0e577ce96b2f 219
elab 0:0e577ce96b2f 220 /** @brief One time device initialization
elab 0:0e577ce96b2f 221 *
elab 0:0e577ce96b2f 222 * To be called once and only once after device is brought out of reset
elab 0:0e577ce96b2f 223 * (Chip enable) and booted see @a VL53L0X_WaitDeviceBooted()
elab 0:0e577ce96b2f 224 *
elab 0:0e577ce96b2f 225 * @par Function Description
elab 0:0e577ce96b2f 226 * When not used after a fresh device "power up" or reset, it may return
elab 0:0e577ce96b2f 227 * @a #VL53L0X_ERROR_CALIBRATION_WARNING meaning wrong calibration data
elab 0:0e577ce96b2f 228 * may have been fetched from device that can result in ranging offset error\n
elab 0:0e577ce96b2f 229 * If application cannot execute device reset or need to run VL53L0X_DataInit
elab 0:0e577ce96b2f 230 * multiple time then it must ensure proper offset calibration saving and
elab 0:0e577ce96b2f 231 * restore on its own by using @a VL53L0X_GetOffsetCalibrationData() on first
elab 0:0e577ce96b2f 232 * power up and then @a VL53L0X_SetOffsetCalibrationData() in all subsequent init
elab 0:0e577ce96b2f 233 * This function will change the VL53L0X_State from VL53L0X_STATE_POWERDOWN to
elab 0:0e577ce96b2f 234 * VL53L0X_STATE_WAIT_STATICINIT.
elab 0:0e577ce96b2f 235 *
elab 0:0e577ce96b2f 236 * @note This function accesses to the device
elab 0:0e577ce96b2f 237 *
elab 0:0e577ce96b2f 238 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 239 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 240 */
elab 0:0e577ce96b2f 241 VL53L0X_Error VL53L0X_data_init(void);
elab 0:0e577ce96b2f 242
elab 0:0e577ce96b2f 243 /**
elab 0:0e577ce96b2f 244 * @brief Do basic device init (and eventually patch loading)
elab 0:0e577ce96b2f 245 * This function will change the VL53L0X_State from
elab 0:0e577ce96b2f 246 * VL53L0X_STATE_WAIT_STATICINIT to VL53L0X_STATE_IDLE.
elab 0:0e577ce96b2f 247 * In this stage all default setting will be applied.
elab 0:0e577ce96b2f 248 *
elab 0:0e577ce96b2f 249 * @note This function Access to the device
elab 0:0e577ce96b2f 250 *
elab 0:0e577ce96b2f 251 *
elab 0:0e577ce96b2f 252 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 253 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 254 */
elab 0:0e577ce96b2f 255 VL53L0X_Error VL53L0X_static_init(void);
elab 0:0e577ce96b2f 256
elab 0:0e577ce96b2f 257 /**
elab 0:0e577ce96b2f 258 * @brief Perform Reference Calibration
elab 0:0e577ce96b2f 259 *
elab 0:0e577ce96b2f 260 * @details Perform a reference calibration of the Device.
elab 0:0e577ce96b2f 261 * This function should be run from time to time before doing
elab 0:0e577ce96b2f 262 * a ranging measurement.
elab 0:0e577ce96b2f 263 * This function will launch a special ranging measurement, so
elab 0:0e577ce96b2f 264 * if interrupt are enable an interrupt will be done.
elab 0:0e577ce96b2f 265 * This function will clear the interrupt generated automatically.
elab 0:0e577ce96b2f 266 *
elab 0:0e577ce96b2f 267 * @warning This function is a blocking function
elab 0:0e577ce96b2f 268 *
elab 0:0e577ce96b2f 269 * @note This function Access to the device
elab 0:0e577ce96b2f 270 *
elab 0:0e577ce96b2f 271 *
elab 0:0e577ce96b2f 272 * @param p_vhv_settings Pointer to vhv settings parameter.
elab 0:0e577ce96b2f 273 * @param p_phase_cal Pointer to PhaseCal parameter.
elab 0:0e577ce96b2f 274 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 275 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 276 */
elab 0:0e577ce96b2f 277 VL53L0X_Error VL53L0X_perform_ref_calibration( uint8_t *p_vhv_settings,
elab 0:0e577ce96b2f 278 uint8_t *p_phase_cal);
elab 0:0e577ce96b2f 279
elab 0:0e577ce96b2f 280 /**
elab 0:0e577ce96b2f 281 * @brief Get Reference Calibration Parameters
elab 0:0e577ce96b2f 282 *
elab 0:0e577ce96b2f 283 * @par Function Description
elab 0:0e577ce96b2f 284 * Get Reference Calibration Parameters.
elab 0:0e577ce96b2f 285 *
elab 0:0e577ce96b2f 286 * @note This function Access to the device
elab 0:0e577ce96b2f 287 *
elab 0:0e577ce96b2f 288 *
elab 0:0e577ce96b2f 289 * @param p_vhv_settings Pointer to VHV parameter
elab 0:0e577ce96b2f 290 * @param p_phase_cal Pointer to PhaseCal Parameter
elab 0:0e577ce96b2f 291 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 292 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 293 */
elab 0:0e577ce96b2f 294 VL53L0X_Error VL53L0X_get_ref_calibration(
elab 0:0e577ce96b2f 295 uint8_t *p_vhv_settings, uint8_t *p_phase_cal);
elab 0:0e577ce96b2f 296
elab 0:0e577ce96b2f 297 VL53L0X_Error VL53L0X_set_ref_calibration(
elab 0:0e577ce96b2f 298 uint8_t vhv_settings, uint8_t phase_cal);
elab 0:0e577ce96b2f 299
elab 0:0e577ce96b2f 300 /**
elab 0:0e577ce96b2f 301 * @brief Performs Reference Spad Management
elab 0:0e577ce96b2f 302 *
elab 0:0e577ce96b2f 303 * @par Function Description
elab 0:0e577ce96b2f 304 * The reference SPAD initialization procedure determines the minimum amount
elab 0:0e577ce96b2f 305 * of reference spads to be enables to achieve a target reference signal rate
elab 0:0e577ce96b2f 306 * and should be performed once during initialization.
elab 0:0e577ce96b2f 307 *
elab 0:0e577ce96b2f 308 * @note This function Access to the device
elab 0:0e577ce96b2f 309 *
elab 0:0e577ce96b2f 310 * @note This function change the device mode to VL53L0X_DEVICEMODE_SINGLE_RANGING
elab 0:0e577ce96b2f 311 *
elab 0:0e577ce96b2f 312 * @param ref_spad_count Reports ref Spad Count
elab 0:0e577ce96b2f 313 * @param is_aperture_spads Reports if spads are of type
elab 0:0e577ce96b2f 314 * aperture or non-aperture.
elab 0:0e577ce96b2f 315 * 1:=aperture, 0:=Non-Aperture
elab 0:0e577ce96b2f 316 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 317 * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the Ref Spad procedure.
elab 0:0e577ce96b2f 318 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 319 */
elab 0:0e577ce96b2f 320 VL53L0X_Error VL53L0X_perform_ref_spad_management(
elab 0:0e577ce96b2f 321 uint32_t *ref_spad_count, uint8_t *is_aperture_spads);
elab 0:0e577ce96b2f 322
elab 0:0e577ce96b2f 323 /**
elab 0:0e577ce96b2f 324 * @brief Applies Reference SPAD configuration
elab 0:0e577ce96b2f 325 *
elab 0:0e577ce96b2f 326 * @par Function Description
elab 0:0e577ce96b2f 327 * This function applies a given number of reference spads, identified as
elab 0:0e577ce96b2f 328 * either Aperture or Non-Aperture.
elab 0:0e577ce96b2f 329 * The requested spad count and type are stored within the device specific
elab 0:0e577ce96b2f 330 * parameters data for access by the host.
elab 0:0e577ce96b2f 331 *
elab 0:0e577ce96b2f 332 * @note This function Access to the device
elab 0:0e577ce96b2f 333 *
elab 0:0e577ce96b2f 334 *
elab 0:0e577ce96b2f 335 * @param refSpadCount Number of ref spads.
elab 0:0e577ce96b2f 336 * @param is_aperture_spads Defines if spads are of type
elab 0:0e577ce96b2f 337 * aperture or non-aperture.
elab 0:0e577ce96b2f 338 * 1:=aperture, 0:=Non-Aperture
elab 0:0e577ce96b2f 339 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 340 * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the in the reference
elab 0:0e577ce96b2f 341 * spad configuration.
elab 0:0e577ce96b2f 342 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 343 */
elab 0:0e577ce96b2f 344 VL53L0X_Error VL53L0X_set_reference_spads(
elab 0:0e577ce96b2f 345 uint32_t refSpadCount, uint8_t is_aperture_spads);
elab 0:0e577ce96b2f 346
elab 0:0e577ce96b2f 347 /**
elab 0:0e577ce96b2f 348 * @brief Retrieves SPAD configuration
elab 0:0e577ce96b2f 349 *
elab 0:0e577ce96b2f 350 * @par Function Description
elab 0:0e577ce96b2f 351 * This function retrieves the current number of applied reference spads
elab 0:0e577ce96b2f 352 * and also their type : Aperture or Non-Aperture.
elab 0:0e577ce96b2f 353 *
elab 0:0e577ce96b2f 354 * @note This function Access to the device
elab 0:0e577ce96b2f 355 *
elab 0:0e577ce96b2f 356 *
elab 0:0e577ce96b2f 357 * @param p_spad_count Number ref Spad Count
elab 0:0e577ce96b2f 358 * @param p_is_aperture_spads Reports if spads are of type
elab 0:0e577ce96b2f 359 * aperture or non-aperture.
elab 0:0e577ce96b2f 360 * 1:=aperture, 0:=Non-Aperture
elab 0:0e577ce96b2f 361 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 362 * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the in the reference
elab 0:0e577ce96b2f 363 * spad configuration.
elab 0:0e577ce96b2f 364 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 365 */
elab 0:0e577ce96b2f 366 VL53L0X_Error VL53L0X_get_reference_spads(
elab 0:0e577ce96b2f 367 uint32_t *p_spad_count, uint8_t *p_is_aperture_spads);
elab 0:0e577ce96b2f 368
elab 0:0e577ce96b2f 369 /**
elab 0:0e577ce96b2f 370 * @brief Get part to part calibration offset
elab 0:0e577ce96b2f 371 *
elab 0:0e577ce96b2f 372 * @par Function Description
elab 0:0e577ce96b2f 373 * Should only be used after a successful call to @a VL53L0X_DataInit to backup
elab 0:0e577ce96b2f 374 * device NVM value
elab 0:0e577ce96b2f 375 *
elab 0:0e577ce96b2f 376 * @note This function Access to the device
elab 0:0e577ce96b2f 377 *
elab 0:0e577ce96b2f 378 * @param p_offset_calibration_data_micro_meter Return part to part
elab 0:0e577ce96b2f 379 * calibration offset from device (microns)
elab 0:0e577ce96b2f 380 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 381 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 382 */
elab 0:0e577ce96b2f 383 VL53L0X_Error VL53L0X_get_offset_calibration_data_micro_meter(
elab 0:0e577ce96b2f 384 int32_t *p_offset_calibration_data_micro_meter);
elab 0:0e577ce96b2f 385 /**
elab 0:0e577ce96b2f 386 * Set or over-hide part to part calibration offset
elab 0:0e577ce96b2f 387 * \sa VL53L0X_DataInit() VL53L0X_GetOffsetCalibrationData_um()
elab 0:0e577ce96b2f 388 *
elab 0:0e577ce96b2f 389 * @note This function Access to the device
elab 0:0e577ce96b2f 390 *
elab 0:0e577ce96b2f 391 * @param p_offset_calibration_data_micro_meter Offset (microns)
elab 0:0e577ce96b2f 392 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 393 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 394 */
elab 0:0e577ce96b2f 395 VL53L0X_Error VL53L0X_set_offset_calibration_data_micro_meter(
elab 0:0e577ce96b2f 396 int32_t offset_calibration_data_micro_meter);
elab 0:0e577ce96b2f 397
elab 0:0e577ce96b2f 398 VL53L0X_Error VL53L0X_perform_offset_calibration(
elab 0:0e577ce96b2f 399 FixPoint1616_t cal_distance_milli_meter,
elab 0:0e577ce96b2f 400 int32_t *p_offset_micro_meter);
elab 0:0e577ce96b2f 401
elab 0:0e577ce96b2f 402 VL53L0X_Error VL53L0X_perform_xtalk_calibration(
elab 0:0e577ce96b2f 403 FixPoint1616_t xtalk_cal_distance,
elab 0:0e577ce96b2f 404 FixPoint1616_t *p_xtalk_compensation_rate_MHz);
elab 0:0e577ce96b2f 405
elab 0:0e577ce96b2f 406 /**
elab 0:0e577ce96b2f 407 * @brief Set Cross talk compensation rate
elab 0:0e577ce96b2f 408 *
elab 0:0e577ce96b2f 409 * @par Function Description
elab 0:0e577ce96b2f 410 * Set Cross talk compensation rate.
elab 0:0e577ce96b2f 411 *
elab 0:0e577ce96b2f 412 * @note This function Access to the device
elab 0:0e577ce96b2f 413 *
elab 0:0e577ce96b2f 414 * @param x_talk_compensation_rate_MHz Compensation rate in
elab 0:0e577ce96b2f 415 * Mega counts per second
elab 0:0e577ce96b2f 416 * (16.16 fix point) see
elab 0:0e577ce96b2f 417 * datasheet for details
elab 0:0e577ce96b2f 418 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 419 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 420 */
elab 0:0e577ce96b2f 421 VL53L0X_Error VL53L0X_set_x_talk_compensation_rate_MHz(
elab 0:0e577ce96b2f 422 FixPoint1616_t x_talk_compensation_rate_MHz);
elab 0:0e577ce96b2f 423
elab 0:0e577ce96b2f 424 /**
elab 0:0e577ce96b2f 425 * @brief Get Cross talk compensation rate
elab 0:0e577ce96b2f 426 *
elab 0:0e577ce96b2f 427 * @par Function Description
elab 0:0e577ce96b2f 428 * Get Cross talk compensation rate.
elab 0:0e577ce96b2f 429 *
elab 0:0e577ce96b2f 430 * @note This function Access to the device
elab 0:0e577ce96b2f 431 *
elab 0:0e577ce96b2f 432 * @param p_xtalk_compensation_rate_MHz Pointer to Compensation rate
elab 0:0e577ce96b2f 433 * in Mega counts per second
elab 0:0e577ce96b2f 434 * (16.16 fix point) see
elab 0:0e577ce96b2f 435 * datasheet for details
elab 0:0e577ce96b2f 436 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 437 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 438 */
elab 0:0e577ce96b2f 439 VL53L0X_Error VL53L0X_get_x_talk_compensation_rate_MHz(
elab 0:0e577ce96b2f 440 FixPoint1616_t *p_xtalk_compensation_rate_MHz);
elab 0:0e577ce96b2f 441
elab 0:0e577ce96b2f 442 /**
elab 0:0e577ce96b2f 443 * @brief Get Cross talk enable
elab 0:0e577ce96b2f 444 *
elab 0:0e577ce96b2f 445 * Enable/Disable Cross Talk by set to zero the Cross Talk value by
elab 0:0e577ce96b2f 446 * using @a VL53L0X_SetXTalkCompensationRate_MHz().
elab 0:0e577ce96b2f 447 *
elab 0:0e577ce96b2f 448 * @param dev Device Handle
elab 0:0e577ce96b2f 449 * @param p_x_talk_compensation_enable Pointer to the Cross talk compensation
elab 0:0e577ce96b2f 450 * state 0=disabled or 1 = enabled
elab 0:0e577ce96b2f 451 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 452 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 453 */
elab 0:0e577ce96b2f 454 VL53L0X_Error VL53L0X_get_x_talk_compensation_enable(uint8_t *p_x_talk_compensation_enable);
elab 0:0e577ce96b2f 455
elab 0:0e577ce96b2f 456 /**
elab 0:0e577ce96b2f 457 * @brief Set a new device mode
elab 0:0e577ce96b2f 458 * @par Function Description
elab 0:0e577ce96b2f 459 * Set device to a new mode (ranging, histogram ...)
elab 0:0e577ce96b2f 460 *
elab 0:0e577ce96b2f 461 * @note This function doesn't Access to the device
elab 0:0e577ce96b2f 462 *
elab 0:0e577ce96b2f 463 * @param device_mode New device mode to apply
elab 0:0e577ce96b2f 464 * Valid values are:
elab 0:0e577ce96b2f 465 * VL53L0X_DEVICEMODE_SINGLE_RANGING
elab 0:0e577ce96b2f 466 * VL53L0X_DEVICEMODE_CONTINUOUS_RANGING
elab 0:0e577ce96b2f 467 * VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING
elab 0:0e577ce96b2f 468 *
elab 0:0e577ce96b2f 469 *
elab 0:0e577ce96b2f 470 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 471 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when
elab 0:0e577ce96b2f 472 * DeviceMode is not in the
elab 0:0e577ce96b2f 473 * supported list
elab 0:0e577ce96b2f 474 */
elab 0:0e577ce96b2f 475 VL53L0X_Error VL53L0X_set_device_mode( VL53L0X_DeviceModes device_mode);
elab 0:0e577ce96b2f 476
elab 0:0e577ce96b2f 477
elab 0:0e577ce96b2f 478 /**
elab 0:0e577ce96b2f 479 * @brief Get current configuration for GPIO pin for a given device
elab 0:0e577ce96b2f 480 *
elab 0:0e577ce96b2f 481 * @note This function Access to the device
elab 0:0e577ce96b2f 482 *
elab 0:0e577ce96b2f 483 *
elab 0:0e577ce96b2f 484 * @param pin ID of the GPIO Pin
elab 0:0e577ce96b2f 485 * @param p_device_mode Pointer to Device Mode associated to the Gpio.
elab 0:0e577ce96b2f 486 * @param p_functionality Pointer to Pin functionality.
elab 0:0e577ce96b2f 487 * Refer to ::VL53L0X_GpioFunctionality
elab 0:0e577ce96b2f 488 * @param p_polarity Pointer to interrupt polarity.
elab 0:0e577ce96b2f 489 * Active high or active low see
elab 0:0e577ce96b2f 490 * ::VL53L0X_InterruptPolarity
elab 0:0e577ce96b2f 491 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 492 * @return VL53L0X_ERROR_GPIO_NOT_EXISTING Only Pin=0 is accepted.
elab 0:0e577ce96b2f 493 * @return VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED
elab 0:0e577ce96b2f 494 * This error occurs
elab 0:0e577ce96b2f 495 * when Funcionality programmed is not in the supported list:
elab 0:0e577ce96b2f 496 * Supported value are:
elab 0:0e577ce96b2f 497 * VL53L0X_GPIOFUNCTIONALITY_OFF,
elab 0:0e577ce96b2f 498 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW,
elab 0:0e577ce96b2f 499 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH,
elab 0:0e577ce96b2f 500 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT,
elab 0:0e577ce96b2f 501 * VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY
elab 0:0e577ce96b2f 502 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 503 */
elab 0:0e577ce96b2f 504 VL53L0X_Error VL53L0X_get_gpio_config( uint8_t pin,
elab 0:0e577ce96b2f 505 VL53L0X_DeviceModes *p_device_mode,
elab 0:0e577ce96b2f 506 VL53L0X_GpioFunctionality *p_functionality,
elab 0:0e577ce96b2f 507 VL53L0X_InterruptPolarity *p_polarity);
elab 0:0e577ce96b2f 508
elab 0:0e577ce96b2f 509 /**
elab 0:0e577ce96b2f 510 * @brief Set the configuration of GPIO pin for a given device
elab 0:0e577ce96b2f 511 *
elab 0:0e577ce96b2f 512 * @note This function Access to the device
elab 0:0e577ce96b2f 513 *
elab 0:0e577ce96b2f 514 * @param pin ID of the GPIO Pin
elab 0:0e577ce96b2f 515 * @param functionality Select Pin functionality.
elab 0:0e577ce96b2f 516 * Refer to ::VL53L0X_GpioFunctionality
elab 0:0e577ce96b2f 517 * @param device_mode Device Mode associated to the Gpio.
elab 0:0e577ce96b2f 518 * @param polarity Set interrupt polarity. Active high
elab 0:0e577ce96b2f 519 * or active low see ::VL53L0X_InterruptPolarity
elab 0:0e577ce96b2f 520 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 521 * @return VL53L0X_ERROR_GPIO_NOT_EXISTING Only Pin=0 is accepted.
elab 0:0e577ce96b2f 522 * @return VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED This error occurs
elab 0:0e577ce96b2f 523 * when Functionality programmed is not in the supported list:
elab 0:0e577ce96b2f 524 * Supported value are:
elab 0:0e577ce96b2f 525 * VL53L0X_GPIOFUNCTIONALITY_OFF,
elab 0:0e577ce96b2f 526 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW,
elab 0:0e577ce96b2f 527 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH,
elab 0:0e577ce96b2f 528 VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT,
elab 0:0e577ce96b2f 529 * VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY
elab 0:0e577ce96b2f 530 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 531 */
elab 0:0e577ce96b2f 532 VL53L0X_Error VL53L0X_set_gpio_config( uint8_t pin,
elab 0:0e577ce96b2f 533 VL53L0X_DeviceModes device_mode, VL53L0X_GpioFunctionality functionality,
elab 0:0e577ce96b2f 534 VL53L0X_InterruptPolarity polarity);
elab 0:0e577ce96b2f 535
elab 0:0e577ce96b2f 536 /**
elab 0:0e577ce96b2f 537 * @brief Start device measurement
elab 0:0e577ce96b2f 538 *
elab 0:0e577ce96b2f 539 * @details Started measurement will depend on device parameters set through
elab 0:0e577ce96b2f 540 * @a VL53L0X_SetParameters()
elab 0:0e577ce96b2f 541 * This is a non-blocking function.
elab 0:0e577ce96b2f 542 * This function will change the VL53L0X_State from VL53L0X_STATE_IDLE to
elab 0:0e577ce96b2f 543 * VL53L0X_STATE_RUNNING.
elab 0:0e577ce96b2f 544 *
elab 0:0e577ce96b2f 545 * @note This function Access to the device
elab 0:0e577ce96b2f 546 *
elab 0:0e577ce96b2f 547 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 548 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when
elab 0:0e577ce96b2f 549 * DeviceMode programmed with @a VL53L0X_SetDeviceMode is not in the supported
elab 0:0e577ce96b2f 550 * list:
elab 0:0e577ce96b2f 551 * Supported mode are:
elab 0:0e577ce96b2f 552 * VL53L0X_DEVICEMODE_SINGLE_RANGING,
elab 0:0e577ce96b2f 553 * VL53L0X_DEVICEMODE_CONTINUOUS_RANGING,
elab 0:0e577ce96b2f 554 * VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING
elab 0:0e577ce96b2f 555 * @return VL53L0X_ERROR_TIME_OUT Time out on start measurement
elab 0:0e577ce96b2f 556 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 557 */
elab 0:0e577ce96b2f 558 VL53L0X_Error VL53L0X_start_measurement(void);
elab 0:0e577ce96b2f 559
elab 0:0e577ce96b2f 560 /**
elab 0:0e577ce96b2f 561 * @brief Stop device measurement
elab 0:0e577ce96b2f 562 *
elab 0:0e577ce96b2f 563 * @details Will set the device in standby mode at end of current measurement\n
elab 0:0e577ce96b2f 564 * Not necessary in single mode as device shall return automatically
elab 0:0e577ce96b2f 565 * in standby mode at end of measurement.
elab 0:0e577ce96b2f 566 * This function will change the VL53L0X_State from VL53L0X_STATE_RUNNING
elab 0:0e577ce96b2f 567 * to VL53L0X_STATE_IDLE.
elab 0:0e577ce96b2f 568 *
elab 0:0e577ce96b2f 569 * @note This function Access to the device
elab 0:0e577ce96b2f 570 *
elab 0:0e577ce96b2f 571 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 572 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 573 */
elab 0:0e577ce96b2f 574 VL53L0X_Error VL53L0X_stop_measurement(void);
elab 0:0e577ce96b2f 575
elab 0:0e577ce96b2f 576 /**
elab 0:0e577ce96b2f 577 * @brief Return device stop completion status
elab 0:0e577ce96b2f 578 *
elab 0:0e577ce96b2f 579 * @par Function Description
elab 0:0e577ce96b2f 580 * Returns stop completiob status.
elab 0:0e577ce96b2f 581 * User shall call this function after a stop command
elab 0:0e577ce96b2f 582 *
elab 0:0e577ce96b2f 583 * @note This function Access to the device
elab 0:0e577ce96b2f 584 *
elab 0:0e577ce96b2f 585 *
elab 0:0e577ce96b2f 586 * @param p_stop_status Pointer to status variable to update
elab 0:0e577ce96b2f 587 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 588 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 589 */
elab 0:0e577ce96b2f 590 VL53L0X_Error VL53L0X_get_stop_completed_status(
elab 0:0e577ce96b2f 591 uint32_t *p_stop_status);
elab 0:0e577ce96b2f 592
elab 0:0e577ce96b2f 593 /**
elab 0:0e577ce96b2f 594 * @brief Return Measurement Data Ready
elab 0:0e577ce96b2f 595 *
elab 0:0e577ce96b2f 596 * @par Function Description
elab 0:0e577ce96b2f 597 * This function indicate that a measurement data is ready.
elab 0:0e577ce96b2f 598 * This function check if interrupt mode is used then check is done accordingly.
elab 0:0e577ce96b2f 599 * If perform function clear the interrupt, this function will not work,
elab 0:0e577ce96b2f 600 * like in case of @a VL53L0X_PerformSingleRangingMeasurement().
elab 0:0e577ce96b2f 601 * The previous function is blocking function, VL53L0X_GetMeasurementDataReady
elab 0:0e577ce96b2f 602 * is used for non-blocking capture.
elab 0:0e577ce96b2f 603 *
elab 0:0e577ce96b2f 604 * @note This function Access to the device
elab 0:0e577ce96b2f 605 *
elab 0:0e577ce96b2f 606 *
elab 0:0e577ce96b2f 607 * @param p_measurement_data_ready Pointer to Measurement Data Ready.
elab 0:0e577ce96b2f 608 * 0=data not ready, 1 = data ready
elab 0:0e577ce96b2f 609 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 610 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 611 */
elab 0:0e577ce96b2f 612 VL53L0X_Error VL53L0X_get_measurement_data_ready(
elab 0:0e577ce96b2f 613 uint8_t *p_measurement_data_ready);
elab 0:0e577ce96b2f 614
elab 0:0e577ce96b2f 615 /**
elab 0:0e577ce96b2f 616 * @brief Retrieve the measurements from device for a given setup
elab 0:0e577ce96b2f 617 *
elab 0:0e577ce96b2f 618 * @par Function Description
elab 0:0e577ce96b2f 619 * Get data from last successful Ranging measurement
elab 0:0e577ce96b2f 620 * @warning USER should take care about @a VL53L0X_GetNumberOfROIZones()
elab 0:0e577ce96b2f 621 * before get data.
elab 0:0e577ce96b2f 622 * PAL will fill a NumberOfROIZones times the corresponding data
elab 0:0e577ce96b2f 623 * structure used in the measurement function.
elab 0:0e577ce96b2f 624 *
elab 0:0e577ce96b2f 625 * @note This function Access to the device
elab 0:0e577ce96b2f 626 *
elab 0:0e577ce96b2f 627 *
elab 0:0e577ce96b2f 628 * @param p_ranging_measurement_data Pointer to the data structure to fill up.
elab 0:0e577ce96b2f 629 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 630 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 631 */
elab 0:0e577ce96b2f 632 VL53L0X_Error VL53L0X_get_ranging_measurement_data(
elab 0:0e577ce96b2f 633 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data);
elab 0:0e577ce96b2f 634
elab 0:0e577ce96b2f 635 /**
elab 0:0e577ce96b2f 636 * @brief Clear given system interrupt condition
elab 0:0e577ce96b2f 637 *
elab 0:0e577ce96b2f 638 * @par Function Description
elab 0:0e577ce96b2f 639 * Clear given interrupt(s).
elab 0:0e577ce96b2f 640 *
elab 0:0e577ce96b2f 641 * @note This function Access to the device
elab 0:0e577ce96b2f 642 *
elab 0:0e577ce96b2f 643 *
elab 0:0e577ce96b2f 644 * @param interrupt_mask Mask of interrupts to clear
elab 0:0e577ce96b2f 645 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 646 * @return VL53L0X_ERROR_INTERRUPT_NOT_CLEARED Cannot clear interrupts
elab 0:0e577ce96b2f 647 *
elab 0:0e577ce96b2f 648 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 649 */
elab 0:0e577ce96b2f 650 VL53L0X_Error VL53L0X_clear_interrupt_mask( uint32_t interrupt_mask);
elab 0:0e577ce96b2f 651
elab 0:0e577ce96b2f 652 /**
elab 0:0e577ce96b2f 653 * @brief Return device interrupt status
elab 0:0e577ce96b2f 654 *
elab 0:0e577ce96b2f 655 * @par Function Description
elab 0:0e577ce96b2f 656 * Returns currently raised interrupts by the device.
elab 0:0e577ce96b2f 657 * User shall be able to activate/deactivate interrupts through
elab 0:0e577ce96b2f 658 * @a VL53L0X_SetGpioConfig()
elab 0:0e577ce96b2f 659 *
elab 0:0e577ce96b2f 660 * @note This function Access to the device
elab 0:0e577ce96b2f 661 *
elab 0:0e577ce96b2f 662 * @param p_interrupt_mask_status Pointer to status variable to update
elab 0:0e577ce96b2f 663 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 664 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 665 */
elab 0:0e577ce96b2f 666 VL53L0X_Error VL53L0X_get_interrupt_mask_status(
elab 0:0e577ce96b2f 667 uint32_t *p_interrupt_mask_status);
elab 0:0e577ce96b2f 668
elab 0:0e577ce96b2f 669 /**
elab 0:0e577ce96b2f 670 * @brief Performs a single ranging measurement and retrieve the ranging
elab 0:0e577ce96b2f 671 * measurement data
elab 0:0e577ce96b2f 672 *
elab 0:0e577ce96b2f 673 * @par Function Description
elab 0:0e577ce96b2f 674 * This function will change the device mode to VL53L0X_DEVICEMODE_SINGLE_RANGING
elab 0:0e577ce96b2f 675 * with @a VL53L0X_SetDeviceMode(),
elab 0:0e577ce96b2f 676 * It performs measurement with @a VL53L0X_PerformSingleMeasurement()
elab 0:0e577ce96b2f 677 * It get data from last successful Ranging measurement with
elab 0:0e577ce96b2f 678 * @a VL53L0X_GetRangingMeasurementData.
elab 0:0e577ce96b2f 679 * Finally it clear the interrupt with @a VL53L0X_ClearInterruptMask().
elab 0:0e577ce96b2f 680 *
elab 0:0e577ce96b2f 681 * @note This function Access to the device
elab 0:0e577ce96b2f 682 *
elab 0:0e577ce96b2f 683 * @param p_ranging_measurement_data Pointer to the data structure to fill up.
elab 0:0e577ce96b2f 684 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 685 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 686 */
elab 0:0e577ce96b2f 687 VL53L0X_Error VL53L0X_perform_single_ranging_measurement(
elab 0:0e577ce96b2f 688 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data);
elab 0:0e577ce96b2f 689
elab 0:0e577ce96b2f 690 /**
elab 0:0e577ce96b2f 691 * @brief Single shot measurement.
elab 0:0e577ce96b2f 692 *
elab 0:0e577ce96b2f 693 * @par Function Description
elab 0:0e577ce96b2f 694 * Perform simple measurement sequence (Start measure, Wait measure to end,
elab 0:0e577ce96b2f 695 * and returns when measurement is done).
elab 0:0e577ce96b2f 696 * Once function returns, user can get valid data by calling
elab 0:0e577ce96b2f 697 * VL53L0X_GetRangingMeasurement or VL53L0X_GetHistogramMeasurement
elab 0:0e577ce96b2f 698 * depending on defined measurement mode
elab 0:0e577ce96b2f 699 * User should Clear the interrupt in case this are enabled by using the
elab 0:0e577ce96b2f 700 * function VL53L0X_ClearInterruptMask().
elab 0:0e577ce96b2f 701 *
elab 0:0e577ce96b2f 702 * @warning This function is a blocking function
elab 0:0e577ce96b2f 703 *
elab 0:0e577ce96b2f 704 * @note This function Access to the device
elab 0:0e577ce96b2f 705 *
elab 0:0e577ce96b2f 706 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 707 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 708 */
elab 0:0e577ce96b2f 709 VL53L0X_Error VL53L0X_perform_single_measurement(void);
elab 0:0e577ce96b2f 710
elab 0:0e577ce96b2f 711 VL53L0X_Error VL53L0X_get_total_signal_rate(
elab 0:0e577ce96b2f 712 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
elab 0:0e577ce96b2f 713 FixPoint1616_t *p_total_signal_rate_MHz);
elab 0:0e577ce96b2f 714
elab 0:0e577ce96b2f 715 VL53L0X_Error VL53L0X_get_total_xtalk_rate(
elab 0:0e577ce96b2f 716 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
elab 0:0e577ce96b2f 717 FixPoint1616_t *p_total_xtalk_rate_MHz);
elab 0:0e577ce96b2f 718
elab 0:0e577ce96b2f 719 /**
elab 0:0e577ce96b2f 720 * @brief Get Ranging Timing Budget in us
elab 0:0e577ce96b2f 721 *
elab 0:0e577ce96b2f 722 * @par Function Description
elab 0:0e577ce96b2f 723 * Returns the programmed the maximum time allowed by the user to the
elab 0:0e577ce96b2f 724 * device to run a full ranging sequence for the current mode
elab 0:0e577ce96b2f 725 * (ranging, histogram, ASL ...)
elab 0:0e577ce96b2f 726 *
elab 0:0e577ce96b2f 727 * @note This function Access to the device
elab 0:0e577ce96b2f 728 *
elab 0:0e577ce96b2f 729 * @param p_measurement_timing_budget_us Max measurement time in
elab 0:0e577ce96b2f 730 *us.
elab 0:0e577ce96b2f 731 * Valid values are:
elab 0:0e577ce96b2f 732 * >= 17000us when wraparound enabled
elab 0:0e577ce96b2f 733 * >= 12000us when wraparound disabled
elab 0:0e577ce96b2f 734 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 735 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 736 */
elab 0:0e577ce96b2f 737 VL53L0X_Error VL53L0X_get_measurement_timing_budget_us(
elab 0:0e577ce96b2f 738 uint32_t *p_measurement_timing_budget_us);
elab 0:0e577ce96b2f 739
elab 0:0e577ce96b2f 740 /**
elab 0:0e577ce96b2f 741 * @brief Set Ranging Timing Budget in us
elab 0:0e577ce96b2f 742 *
elab 0:0e577ce96b2f 743 * @par Function Description
elab 0:0e577ce96b2f 744 * Defines the maximum time allowed by the user to the device to run a
elab 0:0e577ce96b2f 745 * full ranging sequence for the current mode (ranging, histogram, ASL ...)
elab 0:0e577ce96b2f 746 *
elab 0:0e577ce96b2f 747 * @note This function Access to the device
elab 0:0e577ce96b2f 748 *
elab 0:0e577ce96b2f 749 * @param measurement_timing_budget_us Max measurement time in us.
elab 0:0e577ce96b2f 750 * Valid values are:
elab 0:0e577ce96b2f 751 * >= 17000us when wraparound enabled
elab 0:0e577ce96b2f 752 * >= 12000us when wraparound disabled
elab 0:0e577ce96b2f 753 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 754 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned if
elab 0:0e577ce96b2f 755 MeasurementTimingBudget_us out of range
elab 0:0e577ce96b2f 756 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 757 */
elab 0:0e577ce96b2f 758 VL53L0X_Error VL53L0X_set_measurement_timing_budget_us(
elab 0:0e577ce96b2f 759 uint32_t measurement_timing_budget_us);
elab 0:0e577ce96b2f 760
elab 0:0e577ce96b2f 761 /**
elab 0:0e577ce96b2f 762 * @brief Get specific limit check enable state
elab 0:0e577ce96b2f 763 *
elab 0:0e577ce96b2f 764 * @par Function Description
elab 0:0e577ce96b2f 765 * This function get the enable state of a specific limit check.
elab 0:0e577ce96b2f 766 * The limit check is identified with the LimitCheckId.
elab 0:0e577ce96b2f 767 *
elab 0:0e577ce96b2f 768 * @note This function Access to the device
elab 0:0e577ce96b2f 769 *
elab 0:0e577ce96b2f 770 *
elab 0:0e577ce96b2f 771 * @param limit_check_id Limit Check ID
elab 0:0e577ce96b2f 772 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
elab 0:0e577ce96b2f 773 * @param p_limit_check_enable Pointer to the check limit enable
elab 0:0e577ce96b2f 774 * value.
elab 0:0e577ce96b2f 775 * if 1 the check limit
elab 0:0e577ce96b2f 776 * corresponding to LimitCheckId is Enabled
elab 0:0e577ce96b2f 777 * if 0 the check limit
elab 0:0e577ce96b2f 778 * corresponding to LimitCheckId is disabled
elab 0:0e577ce96b2f 779 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 780 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned
elab 0:0e577ce96b2f 781 * when LimitCheckId value is out of range.
elab 0:0e577ce96b2f 782 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 783 */
elab 0:0e577ce96b2f 784 VL53L0X_Error VL53L0X_get_limit_check_enable( uint16_t limit_check_id,
elab 0:0e577ce96b2f 785 uint8_t *p_limit_check_enable);
elab 0:0e577ce96b2f 786
elab 0:0e577ce96b2f 787 /**
elab 0:0e577ce96b2f 788 * @brief Enable/Disable a specific limit check
elab 0:0e577ce96b2f 789 *
elab 0:0e577ce96b2f 790 * @par Function Description
elab 0:0e577ce96b2f 791 * This function Enable/Disable a specific limit check.
elab 0:0e577ce96b2f 792 * The limit check is identified with the LimitCheckId.
elab 0:0e577ce96b2f 793 *
elab 0:0e577ce96b2f 794 * @note This function doesn't Access to the device
elab 0:0e577ce96b2f 795 *
elab 0:0e577ce96b2f 796 *
elab 0:0e577ce96b2f 797 * @param limit_check_id Limit Check ID
elab 0:0e577ce96b2f 798 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
elab 0:0e577ce96b2f 799 * @param limit_check_enable if 1 the check limit
elab 0:0e577ce96b2f 800 * corresponding to LimitCheckId is Enabled
elab 0:0e577ce96b2f 801 * if 0 the check limit
elab 0:0e577ce96b2f 802 * corresponding to LimitCheckId is disabled
elab 0:0e577ce96b2f 803 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 804 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned
elab 0:0e577ce96b2f 805 * when LimitCheckId value is out of range.
elab 0:0e577ce96b2f 806 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 807 */
elab 0:0e577ce96b2f 808 VL53L0X_Error VL53L0X_set_limit_check_enable( uint16_t limit_check_id,
elab 0:0e577ce96b2f 809 uint8_t limit_check_enable);
elab 0:0e577ce96b2f 810
elab 0:0e577ce96b2f 811 /**
elab 0:0e577ce96b2f 812 * @brief Get a specific limit check value
elab 0:0e577ce96b2f 813 *
elab 0:0e577ce96b2f 814 * @par Function Description
elab 0:0e577ce96b2f 815 * This function get a specific limit check value from device then it updates
elab 0:0e577ce96b2f 816 * internal values and check enables.
elab 0:0e577ce96b2f 817 * The limit check is identified with the LimitCheckId.
elab 0:0e577ce96b2f 818 *
elab 0:0e577ce96b2f 819 * @note This function Access to the device
elab 0:0e577ce96b2f 820 *
elab 0:0e577ce96b2f 821 *
elab 0:0e577ce96b2f 822 * @param limit_check_id Limit Check ID
elab 0:0e577ce96b2f 823 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
elab 0:0e577ce96b2f 824 * @param p_limit_check_value Pointer to Limit
elab 0:0e577ce96b2f 825 * check Value for a given LimitCheckId.
elab 0:0e577ce96b2f 826 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 827 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned
elab 0:0e577ce96b2f 828 * when LimitCheckId value is out of range.
elab 0:0e577ce96b2f 829 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 830 */
elab 0:0e577ce96b2f 831 VL53L0X_Error VL53L0X_get_limit_check_value( uint16_t limit_check_id,
elab 0:0e577ce96b2f 832 FixPoint1616_t *p_limit_check_value);
elab 0:0e577ce96b2f 833
elab 0:0e577ce96b2f 834 /**
elab 0:0e577ce96b2f 835 * @brief Set a specific limit check value
elab 0:0e577ce96b2f 836 *
elab 0:0e577ce96b2f 837 * @par Function Description
elab 0:0e577ce96b2f 838 * This function set a specific limit check value.
elab 0:0e577ce96b2f 839 * The limit check is identified with the LimitCheckId.
elab 0:0e577ce96b2f 840 *
elab 0:0e577ce96b2f 841 * @note This function Access to the device
elab 0:0e577ce96b2f 842 *
elab 0:0e577ce96b2f 843 *
elab 0:0e577ce96b2f 844 * @param limit_check_id Limit Check ID
elab 0:0e577ce96b2f 845 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
elab 0:0e577ce96b2f 846 * @param limit_check_value Limit check Value for a given
elab 0:0e577ce96b2f 847 * LimitCheckId
elab 0:0e577ce96b2f 848 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 849 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned when either
elab 0:0e577ce96b2f 850 * LimitCheckId or LimitCheckValue value is out of range.
elab 0:0e577ce96b2f 851 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 852 */
elab 0:0e577ce96b2f 853 VL53L0X_Error VL53L0X_set_limit_check_value( uint16_t limit_check_id,
elab 0:0e577ce96b2f 854 FixPoint1616_t limit_check_value);
elab 0:0e577ce96b2f 855
elab 0:0e577ce96b2f 856 /**
elab 0:0e577ce96b2f 857 * @brief Get the current value of the signal used for the limit check
elab 0:0e577ce96b2f 858 *
elab 0:0e577ce96b2f 859 * @par Function Description
elab 0:0e577ce96b2f 860 * This function get a the current value of the signal used for the limit check.
elab 0:0e577ce96b2f 861 * To obtain the latest value you should run a ranging before.
elab 0:0e577ce96b2f 862 * The value reported is linked to the limit check identified with the
elab 0:0e577ce96b2f 863 * LimitCheckId.
elab 0:0e577ce96b2f 864 *
elab 0:0e577ce96b2f 865 * @note This function Access to the device
elab 0:0e577ce96b2f 866 *
elab 0:0e577ce96b2f 867 *
elab 0:0e577ce96b2f 868 * @param limit_check_id Limit Check ID
elab 0:0e577ce96b2f 869 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
elab 0:0e577ce96b2f 870 * @param p_limit_check_current Pointer to current Value for a
elab 0:0e577ce96b2f 871 * given LimitCheckId.
elab 0:0e577ce96b2f 872 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 873 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned when
elab 0:0e577ce96b2f 874 * LimitCheckId value is out of range.
elab 0:0e577ce96b2f 875 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 876 */
elab 0:0e577ce96b2f 877 VL53L0X_Error VL53L0X_get_limit_check_current( uint16_t limit_check_id,
elab 0:0e577ce96b2f 878 FixPoint1616_t *p_limit_check_current);
elab 0:0e577ce96b2f 879
elab 0:0e577ce96b2f 880 /**
elab 0:0e577ce96b2f 881 * @brief Return a the Status of the specified check limit
elab 0:0e577ce96b2f 882 *
elab 0:0e577ce96b2f 883 * @par Function Description
elab 0:0e577ce96b2f 884 * This function returns the Status of the specified check limit.
elab 0:0e577ce96b2f 885 * The value indicate if the check is fail or not.
elab 0:0e577ce96b2f 886 * The limit check is identified with the LimitCheckId.
elab 0:0e577ce96b2f 887 *
elab 0:0e577ce96b2f 888 * @note This function doesn't Access to the device
elab 0:0e577ce96b2f 889 *
elab 0:0e577ce96b2f 890 *
elab 0:0e577ce96b2f 891 * @param limit_check_id Limit Check ID
elab 0:0e577ce96b2f 892 (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
elab 0:0e577ce96b2f 893 * @param p_limit_check_status Pointer to the
elab 0:0e577ce96b2f 894 Limit Check Status of the given check limit.
elab 0:0e577ce96b2f 895 * LimitCheckStatus :
elab 0:0e577ce96b2f 896 * 0 the check is not fail
elab 0:0e577ce96b2f 897 * 1 the check if fail or not enabled
elab 0:0e577ce96b2f 898 *
elab 0:0e577ce96b2f 899 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 900 * @return VL53L0X_ERROR_INVALID_PARAMS This error is
elab 0:0e577ce96b2f 901 returned when LimitCheckId value is out of range.
elab 0:0e577ce96b2f 902 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 903 */
elab 0:0e577ce96b2f 904 VL53L0X_Error VL53L0X_get_limit_check_status(
elab 0:0e577ce96b2f 905 uint16_t limit_check_id, uint8_t *p_limit_check_status);
elab 0:0e577ce96b2f 906
elab 0:0e577ce96b2f 907 /**
elab 0:0e577ce96b2f 908 * Get continuous mode Inter-Measurement period in _ms
elab 0:0e577ce96b2f 909 *
elab 0:0e577ce96b2f 910 * @par Function Description
elab 0:0e577ce96b2f 911 * When trying to set too short time return INVALID_PARAMS minimal value
elab 0:0e577ce96b2f 912 *
elab 0:0e577ce96b2f 913 * @note This function Access to the device
elab 0:0e577ce96b2f 914 *
elab 0:0e577ce96b2f 915 *
elab 0:0e577ce96b2f 916 * @param p_inter_measurement_period_ms Pointer to programmed
elab 0:0e577ce96b2f 917 * Inter-Measurement Period in _ms.
elab 0:0e577ce96b2f 918 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 919 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 920 */
elab 0:0e577ce96b2f 921 VL53L0X_Error VL53L0X_get_inter_measurement_period_ms(
elab 0:0e577ce96b2f 922 uint32_t *p_inter_measurement_period_ms);
elab 0:0e577ce96b2f 923
elab 0:0e577ce96b2f 924 /**
elab 0:0e577ce96b2f 925 * Program continuous mode Inter-Measurement period in _ms
elab 0:0e577ce96b2f 926 *
elab 0:0e577ce96b2f 927 * @par Function Description
elab 0:0e577ce96b2f 928 * When trying to set too short time return INVALID_PARAMS minimal value
elab 0:0e577ce96b2f 929 *
elab 0:0e577ce96b2f 930 * @note This function Access to the device
elab 0:0e577ce96b2f 931 *
elab 0:0e577ce96b2f 932 *
elab 0:0e577ce96b2f 933 * @param inter_measurement_period_ms Inter-Measurement Period in ms.
elab 0:0e577ce96b2f 934 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 935 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 936 */
elab 0:0e577ce96b2f 937 VL53L0X_Error VL53L0X_set_inter_measurement_period_ms(
elab 0:0e577ce96b2f 938 uint32_t inter_measurement_period_ms);
elab 0:0e577ce96b2f 939
elab 0:0e577ce96b2f 940 /**
elab 0:0e577ce96b2f 941 * @brief Set new device address
elab 0:0e577ce96b2f 942 *
elab 0:0e577ce96b2f 943 * After completion the device will answer to the new address programmed.
elab 0:0e577ce96b2f 944 * This function should be called when several devices are used in parallel
elab 0:0e577ce96b2f 945 * before start programming the sensor.
elab 0:0e577ce96b2f 946 * When a single device us used, there is no need to call this function.
elab 0:0e577ce96b2f 947 *
elab 0:0e577ce96b2f 948 * @note This function Access to the device
elab 0:0e577ce96b2f 949 *
elab 0:0e577ce96b2f 950 *
elab 0:0e577ce96b2f 951 * @param device_address The new Device address
elab 0:0e577ce96b2f 952 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 953 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 954 */
elab 0:0e577ce96b2f 955 VL53L0X_Error VL53L0X_set_device_address( uint8_t device_address);
elab 0:0e577ce96b2f 956
elab 0:0e577ce96b2f 957 /**
elab 0:0e577ce96b2f 958 * @brief Do an hard reset or soft reset (depending on implementation) of the
elab 0:0e577ce96b2f 959 * device \nAfter call of this function, device must be in same state as right
elab 0:0e577ce96b2f 960 * after a power-up sequence.This function will change the VL53L0X_State to
elab 0:0e577ce96b2f 961 * VL53L0X_STATE_POWERDOWN.
elab 0:0e577ce96b2f 962 *
elab 0:0e577ce96b2f 963 * @note This function Access to the device
elab 0:0e577ce96b2f 964 *
elab 0:0e577ce96b2f 965 *
elab 0:0e577ce96b2f 966 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 967 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 968 */
elab 0:0e577ce96b2f 969 VL53L0X_Error VL53L0X_reset_device(void);
elab 0:0e577ce96b2f 970
elab 0:0e577ce96b2f 971 /**
elab 0:0e577ce96b2f 972 * @brief Get setup of Wrap around Check
elab 0:0e577ce96b2f 973 *
elab 0:0e577ce96b2f 974 * @par Function Description
elab 0:0e577ce96b2f 975 * This function get the wrapAround check enable parameters
elab 0:0e577ce96b2f 976 *
elab 0:0e577ce96b2f 977 * @note This function Access to the device
elab 0:0e577ce96b2f 978 *
elab 0:0e577ce96b2f 979 *
elab 0:0e577ce96b2f 980 * @param p_wrap_around_check_enable Pointer to the Wrap around Check state
elab 0:0e577ce96b2f 981 * 0=disabled or 1 = enabled
elab 0:0e577ce96b2f 982 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 983 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 984 */
elab 0:0e577ce96b2f 985 VL53L0X_Error VL53L0X_get_wrap_around_check_enable(
elab 0:0e577ce96b2f 986 uint8_t *p_wrap_around_check_enable);
elab 0:0e577ce96b2f 987
elab 0:0e577ce96b2f 988 /**
elab 0:0e577ce96b2f 989 * @brief Enable (or disable) Wrap around Check
elab 0:0e577ce96b2f 990 *
elab 0:0e577ce96b2f 991 * @note This function Access to the device
elab 0:0e577ce96b2f 992 *
elab 0:0e577ce96b2f 993 *
elab 0:0e577ce96b2f 994 * @param wrap_around_check_enable Wrap around Check to be set
elab 0:0e577ce96b2f 995 * 0=disabled, other = enabled
elab 0:0e577ce96b2f 996 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 997 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 998 */
elab 0:0e577ce96b2f 999 VL53L0X_Error VL53L0X_set_wrap_around_check_enable(
elab 0:0e577ce96b2f 1000 uint8_t wrap_around_check_enable);
elab 0:0e577ce96b2f 1001
elab 0:0e577ce96b2f 1002 /**
elab 0:0e577ce96b2f 1003 * @brief Gets the VCSEL pulse period.
elab 0:0e577ce96b2f 1004 *
elab 0:0e577ce96b2f 1005 * @par Function Description
elab 0:0e577ce96b2f 1006 * This function retrieves the VCSEL pulse period for the given period type.
elab 0:0e577ce96b2f 1007 *
elab 0:0e577ce96b2f 1008 * @note This function Accesses the device
elab 0:0e577ce96b2f 1009 *
elab 0:0e577ce96b2f 1010 *
elab 0:0e577ce96b2f 1011 * @param vcsel_period_type VCSEL period identifier (pre-range|final).
elab 0:0e577ce96b2f 1012 * @param p_vcsel_pulse_period_pclk Pointer to VCSEL period value.
elab 0:0e577ce96b2f 1013 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1014 * @return VL53L0X_ERROR_INVALID_PARAMS Error VcselPeriodType parameter not
elab 0:0e577ce96b2f 1015 * supported.
elab 0:0e577ce96b2f 1016 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1017 */
elab 0:0e577ce96b2f 1018 VL53L0X_Error VL53L0X_get_vcsel_pulse_period(
elab 0:0e577ce96b2f 1019 VL53L0X_VcselPeriod vcsel_period_type, uint8_t *p_vcsel_pulse_period_pclk);
elab 0:0e577ce96b2f 1020
elab 0:0e577ce96b2f 1021 /**
elab 0:0e577ce96b2f 1022 * @brief Sets the VCSEL pulse period.
elab 0:0e577ce96b2f 1023 *
elab 0:0e577ce96b2f 1024 * @par Function Description
elab 0:0e577ce96b2f 1025 * This function retrieves the VCSEL pulse period for the given period type.
elab 0:0e577ce96b2f 1026 *
elab 0:0e577ce96b2f 1027 * @note This function Accesses the device
elab 0:0e577ce96b2f 1028 *
elab 0:0e577ce96b2f 1029 *
elab 0:0e577ce96b2f 1030 * @param vcsel_period_type VCSEL period identifier (pre-range|final).
elab 0:0e577ce96b2f 1031 * @param vcsel_pulse_period VCSEL period value
elab 0:0e577ce96b2f 1032 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1033 * @return VL53L0X_ERROR_INVALID_PARAMS Error VcselPeriodType parameter not
elab 0:0e577ce96b2f 1034 * supported.
elab 0:0e577ce96b2f 1035 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1036 */
elab 0:0e577ce96b2f 1037 VL53L0X_Error VL53L0X_set_vcsel_pulse_period(
elab 0:0e577ce96b2f 1038 VL53L0X_VcselPeriod vcsel_period_type, uint8_t vcsel_pulse_period);
elab 0:0e577ce96b2f 1039
elab 0:0e577ce96b2f 1040 /**
elab 0:0e577ce96b2f 1041 * @brief Set low and high Interrupt thresholds for a given mode
elab 0:0e577ce96b2f 1042 * (ranging, ALS, ...) for a given device
elab 0:0e577ce96b2f 1043 *
elab 0:0e577ce96b2f 1044 * @par Function Description
elab 0:0e577ce96b2f 1045 * Set low and high Interrupt thresholds for a given mode (ranging, ALS, ...)
elab 0:0e577ce96b2f 1046 * for a given device
elab 0:0e577ce96b2f 1047 *
elab 0:0e577ce96b2f 1048 * @note This function Access to the device
elab 0:0e577ce96b2f 1049 *
elab 0:0e577ce96b2f 1050 * @note DeviceMode is ignored for the current device
elab 0:0e577ce96b2f 1051 *
elab 0:0e577ce96b2f 1052 *
elab 0:0e577ce96b2f 1053 * @param device_mode Device Mode for which change thresholds
elab 0:0e577ce96b2f 1054 * @param threshold_low Low threshold (mm, lux ..., depending on the mode)
elab 0:0e577ce96b2f 1055 * @param threshold_high High threshold (mm, lux ..., depending on the mode)
elab 0:0e577ce96b2f 1056 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1057 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1058 */
elab 0:0e577ce96b2f 1059 VL53L0X_Error VL53L0X_set_interrupt_thresholds(
elab 0:0e577ce96b2f 1060 VL53L0X_DeviceModes device_mode, FixPoint1616_t threshold_low,
elab 0:0e577ce96b2f 1061 FixPoint1616_t threshold_high);
elab 0:0e577ce96b2f 1062
elab 0:0e577ce96b2f 1063 /**
elab 0:0e577ce96b2f 1064 * @brief Get high and low Interrupt thresholds for a given mode
elab 0:0e577ce96b2f 1065 * (ranging, ALS, ...) for a given device
elab 0:0e577ce96b2f 1066 *
elab 0:0e577ce96b2f 1067 * @par Function Description
elab 0:0e577ce96b2f 1068 * Get high and low Interrupt thresholds for a given mode (ranging, ALS, ...)
elab 0:0e577ce96b2f 1069 * for a given device
elab 0:0e577ce96b2f 1070 *
elab 0:0e577ce96b2f 1071 * @note This function Access to the device
elab 0:0e577ce96b2f 1072 *
elab 0:0e577ce96b2f 1073 * @note DeviceMode is ignored for the current device
elab 0:0e577ce96b2f 1074 *
elab 0:0e577ce96b2f 1075 *
elab 0:0e577ce96b2f 1076 * @param device_mode Device Mode from which read thresholds
elab 0:0e577ce96b2f 1077 * @param p_threshold_low Low threshold (mm, lux ..., depending on the mode)
elab 0:0e577ce96b2f 1078 * @param p_threshold_high High threshold (mm, lux ..., depending on the mode)
elab 0:0e577ce96b2f 1079 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1080 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1081 */
elab 0:0e577ce96b2f 1082 VL53L0X_Error VL53L0X_get_interrupt_thresholds(
elab 0:0e577ce96b2f 1083 VL53L0X_DeviceModes device_mode, FixPoint1616_t *p_threshold_low,
elab 0:0e577ce96b2f 1084 FixPoint1616_t *p_threshold_high);
elab 0:0e577ce96b2f 1085
elab 0:0e577ce96b2f 1086 /**
elab 0:0e577ce96b2f 1087 * @brief Reads the Device information for given Device
elab 0:0e577ce96b2f 1088 *
elab 0:0e577ce96b2f 1089 * @note This function Access to the device
elab 0:0e577ce96b2f 1090 * _device_info structure is directly filled
elab 0:0e577ce96b2f 1091 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1092 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1093 */
elab 0:0e577ce96b2f 1094 VL53L0X_Error VL53L0X_get_device_info( );
elab 0:0e577ce96b2f 1095
elab 0:0e577ce96b2f 1096 /**
elab 0:0e577ce96b2f 1097 * @brief Gets the (on/off) state of all sequence steps.
elab 0:0e577ce96b2f 1098 *
elab 0:0e577ce96b2f 1099 * @par Function Description
elab 0:0e577ce96b2f 1100 * This function retrieves the state of all sequence step in the scheduler.
elab 0:0e577ce96b2f 1101 *
elab 0:0e577ce96b2f 1102 * @note This function Accesses the device
elab 0:0e577ce96b2f 1103 *
elab 0:0e577ce96b2f 1104 *
elab 0:0e577ce96b2f 1105 * @param p_scheduler_sequence_steps Pointer to struct containing result.
elab 0:0e577ce96b2f 1106 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1107 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1108 */
elab 0:0e577ce96b2f 1109 VL53L0X_Error VL53L0X_get_sequence_step_enables(
elab 0:0e577ce96b2f 1110 VL53L0X_SchedulerSequenceSteps_t *p_scheduler_sequence_steps);
elab 0:0e577ce96b2f 1111
elab 0:0e577ce96b2f 1112 /**
elab 0:0e577ce96b2f 1113 * @brief Sets the (on/off) state of a requested sequence step.
elab 0:0e577ce96b2f 1114 *
elab 0:0e577ce96b2f 1115 * @par Function Description
elab 0:0e577ce96b2f 1116 * This function enables/disables a requested sequence step.
elab 0:0e577ce96b2f 1117 *
elab 0:0e577ce96b2f 1118 * @note This function Accesses the device
elab 0:0e577ce96b2f 1119 *
elab 0:0e577ce96b2f 1120 *
elab 0:0e577ce96b2f 1121 * @param sequence_step_id Sequence step identifier.
elab 0:0e577ce96b2f 1122 * @param sequence_step_enabled Demanded state {0=Off,1=On}
elab 0:0e577ce96b2f 1123 * is enabled.
elab 0:0e577ce96b2f 1124 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1125 * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not
elab 0:0e577ce96b2f 1126 * supported.
elab 0:0e577ce96b2f 1127 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1128 */
elab 0:0e577ce96b2f 1129 VL53L0X_Error VL53L0X_set_sequence_step_enable(
elab 0:0e577ce96b2f 1130 VL53L0X_SequenceStepId sequence_step_id, uint8_t sequence_step_enabled);
elab 0:0e577ce96b2f 1131
elab 0:0e577ce96b2f 1132 /**
elab 0:0e577ce96b2f 1133 * @brief Gets the fraction enable parameter indicating the resolution of
elab 0:0e577ce96b2f 1134 * range measurements.
elab 0:0e577ce96b2f 1135 *
elab 0:0e577ce96b2f 1136 * @par Function Description
elab 0:0e577ce96b2f 1137 * Gets the fraction enable state, which translates to the resolution of
elab 0:0e577ce96b2f 1138 * range measurements as follows :Enabled:=0.25mm resolution,
elab 0:0e577ce96b2f 1139 * Not Enabled:=1mm resolution.
elab 0:0e577ce96b2f 1140 *
elab 0:0e577ce96b2f 1141 * @note This function Accesses the device
elab 0:0e577ce96b2f 1142 *
elab 0:0e577ce96b2f 1143 *
elab 0:0e577ce96b2f 1144 * @param p_enabled Output Parameter reporting the fraction enable state.
elab 0:0e577ce96b2f 1145 *
elab 0:0e577ce96b2f 1146 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1147 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1148 */
elab 0:0e577ce96b2f 1149 VL53L0X_Error VL53L0X_get_fraction_enable( uint8_t *p_enabled);
elab 0:0e577ce96b2f 1150
elab 0:0e577ce96b2f 1151 /**
elab 0:0e577ce96b2f 1152 * @brief Sets the resolution of range measurements.
elab 0:0e577ce96b2f 1153 * @par Function Description
elab 0:0e577ce96b2f 1154 * Set resolution of range measurements to either 0.25mm if
elab 0:0e577ce96b2f 1155 * fraction enabled or 1mm if not enabled.
elab 0:0e577ce96b2f 1156 *
elab 0:0e577ce96b2f 1157 * @note This function Accesses the device
elab 0:0e577ce96b2f 1158 *
elab 0:0e577ce96b2f 1159 *
elab 0:0e577ce96b2f 1160 * @param enable Enable high resolution
elab 0:0e577ce96b2f 1161 *
elab 0:0e577ce96b2f 1162 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1163 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1164 */
elab 0:0e577ce96b2f 1165 VL53L0X_Error VL53L0X_set_range_fraction_enable(uint8_t enable);
elab 0:0e577ce96b2f 1166
elab 0:0e577ce96b2f 1167 /**
elab 0:0e577ce96b2f 1168 * @brief Retrieve current device parameters
elab 0:0e577ce96b2f 1169 * @par Function Description
elab 0:0e577ce96b2f 1170 * Get actual parameters of the device
elab 0:0e577ce96b2f 1171 * @li Then start ranging operation.
elab 0:0e577ce96b2f 1172 *
elab 0:0e577ce96b2f 1173 * @note This function Access to the device
elab 0:0e577ce96b2f 1174 *
elab 0:0e577ce96b2f 1175 *
elab 0:0e577ce96b2f 1176 * @param p_device_parameters Pointer to store current device parameters.
elab 0:0e577ce96b2f 1177 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1178 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1179 */
elab 0:0e577ce96b2f 1180 VL53L0X_Error VL53L0X_get_device_parameters(
elab 0:0e577ce96b2f 1181 VL53L0X_DeviceParameters_t *p_device_parameters);
elab 0:0e577ce96b2f 1182
elab 0:0e577ce96b2f 1183
elab 0:0e577ce96b2f 1184 /*** End High level API ***/
elab 0:0e577ce96b2f 1185 public:
elab 0:0e577ce96b2f 1186 /* api.h functions */
elab 0:0e577ce96b2f 1187
elab 0:0e577ce96b2f 1188 VL53L0X_Error sequence_step_enabled(VL53L0X_SequenceStepId sequence_step_id, uint8_t sequence_config,
elab 0:0e577ce96b2f 1189 uint8_t *p_sequence_step_enabled);
elab 0:0e577ce96b2f 1190
elab 0:0e577ce96b2f 1191 VL53L0X_Error VL53L0X_check_and_load_interrupt_settings(
elab 0:0e577ce96b2f 1192 uint8_t start_not_stopflag);
elab 0:0e577ce96b2f 1193
elab 0:0e577ce96b2f 1194
elab 0:0e577ce96b2f 1195 /* api_core.h functions */
elab 0:0e577ce96b2f 1196
elab 0:0e577ce96b2f 1197 VL53L0X_Error VL53L0X_get_info_from_device( uint8_t option);
elab 0:0e577ce96b2f 1198
elab 0:0e577ce96b2f 1199 VL53L0X_Error VL53L0X_device_read_strobe(void);
elab 0:0e577ce96b2f 1200
elab 0:0e577ce96b2f 1201 uint8_t VL53L0X_decode_vcsel_period(uint8_t vcsel_period_reg);
elab 0:0e577ce96b2f 1202
elab 0:0e577ce96b2f 1203 uint32_t VL53L0X_decode_timeout(uint16_t encoded_timeout);
elab 0:0e577ce96b2f 1204
elab 0:0e577ce96b2f 1205 uint32_t VL53L0X_calc_timeout_us(
elab 0:0e577ce96b2f 1206 uint16_t timeout_period_mclks,
elab 0:0e577ce96b2f 1207 uint8_t vcsel_period_pclks);
elab 0:0e577ce96b2f 1208
elab 0:0e577ce96b2f 1209 uint32_t VL53L0X_calc_macro_period_ps( uint8_t vcsel_period_pclks);
elab 0:0e577ce96b2f 1210
elab 0:0e577ce96b2f 1211 VL53L0X_Error VL53L0X_measurement_poll_for_completion(void);
elab 0:0e577ce96b2f 1212
elab 0:0e577ce96b2f 1213 VL53L0X_Error VL53L0X_load_tuning_settings(
elab 0:0e577ce96b2f 1214 uint8_t *p_tuning_setting_buffer);
elab 0:0e577ce96b2f 1215
elab 0:0e577ce96b2f 1216 VL53L0X_Error VL53L0X_get_pal_range_status( uint8_t device_range_status,
elab 0:0e577ce96b2f 1217 FixPoint1616_t signal_rate, uint16_t effective_spad_rtn_count,
elab 0:0e577ce96b2f 1218 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
elab 0:0e577ce96b2f 1219 uint8_t *p_pal_range_status);
elab 0:0e577ce96b2f 1220 VL53L0X_Error VL53L0X_calc_sigma_estimate(
elab 0:0e577ce96b2f 1221 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
elab 0:0e577ce96b2f 1222 FixPoint1616_t *p_sigma_estimate,
elab 0:0e577ce96b2f 1223 uint32_t *p_dmax_mm);
elab 0:0e577ce96b2f 1224 uint32_t VL53L0X_calc_timeout_mclks( uint32_t timeout_period_us,
elab 0:0e577ce96b2f 1225 uint8_t vcsel_period_pclks);
elab 0:0e577ce96b2f 1226 uint32_t VL53L0X_isqrt(uint32_t num);
elab 0:0e577ce96b2f 1227
elab 0:0e577ce96b2f 1228 uint32_t VL53L0X_quadrature_sum(uint32_t a, uint32_t b);
elab 0:0e577ce96b2f 1229
elab 0:0e577ce96b2f 1230 VL53L0X_Error VL53L0X_calc_dmax(
elab 0:0e577ce96b2f 1231 FixPoint1616_t total_signal_rate_MHz,
elab 0:0e577ce96b2f 1232 FixPoint1616_t total_corr_signal_rate_MHz,
elab 0:0e577ce96b2f 1233 FixPoint1616_t pw_mult,
elab 0:0e577ce96b2f 1234 uint32_t sigma_estimate_p1,
elab 0:0e577ce96b2f 1235 FixPoint1616_t sigma_estimate_p2,
elab 0:0e577ce96b2f 1236 uint32_t peak_vcsel_duration_us,
elab 0:0e577ce96b2f 1237 uint32_t *pd_max_mm);
elab 0:0e577ce96b2f 1238 VL53L0X_Error wrapped_VL53L0X_set_measurement_timing_budget_us(
elab 0:0e577ce96b2f 1239 uint32_t measurement_timing_budget_us);
elab 0:0e577ce96b2f 1240 VL53L0X_Error get_sequence_step_timeout(VL53L0X_SequenceStepId sequence_step_id,
elab 0:0e577ce96b2f 1241 uint32_t *p_time_out_micro_secs);
elab 0:0e577ce96b2f 1242 VL53L0X_Error set_sequence_step_timeout(VL53L0X_SequenceStepId sequence_step_id,
elab 0:0e577ce96b2f 1243 uint32_t timeout_micro_secs);
elab 0:0e577ce96b2f 1244 uint16_t VL53L0X_encode_timeout(uint32_t timeout_macro_clks);
elab 0:0e577ce96b2f 1245 VL53L0X_Error wrapped_VL53L0X_set_vcsel_pulse_period(
elab 0:0e577ce96b2f 1246 VL53L0X_VcselPeriod vcsel_period_type, uint8_t vcsel_pulse_period_pclk);
elab 0:0e577ce96b2f 1247 uint8_t lv53l0x_encode_vcsel_period(uint8_t vcsel_period_pclks);
elab 0:0e577ce96b2f 1248
elab 0:0e577ce96b2f 1249 /* api_calibration.h functions */
elab 0:0e577ce96b2f 1250 VL53L0X_Error VL53L0X_apply_offset_adjustment(void);
elab 0:0e577ce96b2f 1251 VL53L0X_Error wrapped_VL53L0X_perform_ref_spad_management(
elab 0:0e577ce96b2f 1252 uint32_t *ref_spad_count,
elab 0:0e577ce96b2f 1253 uint8_t *is_aperture_spads);
elab 0:0e577ce96b2f 1254 VL53L0X_Error VL53L0X_perform_ref_calibration(
elab 0:0e577ce96b2f 1255 uint8_t *p_vhv_settings, uint8_t *p_phase_cal, uint8_t get_data_enable);
elab 0:0e577ce96b2f 1256 VL53L0X_Error VL53L0X_perform_vhv_calibration(
elab 0:0e577ce96b2f 1257 uint8_t *p_vhv_settings, const uint8_t get_data_enable,
elab 0:0e577ce96b2f 1258 const uint8_t restore_config);
elab 0:0e577ce96b2f 1259 VL53L0X_Error VL53L0X_perform_single_ref_calibration(
elab 0:0e577ce96b2f 1260 uint8_t vhv_init_byte);
elab 0:0e577ce96b2f 1261 VL53L0X_Error VL53L0X_ref_calibration_io( uint8_t read_not_write,
elab 0:0e577ce96b2f 1262 uint8_t vhv_settings, uint8_t phase_cal,
elab 0:0e577ce96b2f 1263 uint8_t *p_vhv_settings, uint8_t *p_phase_cal,
elab 0:0e577ce96b2f 1264 const uint8_t vhv_enable, const uint8_t phase_enable);
elab 0:0e577ce96b2f 1265 VL53L0X_Error VL53L0X_perform_phase_calibration(
elab 0:0e577ce96b2f 1266 uint8_t *p_phase_cal, const uint8_t get_data_enable,
elab 0:0e577ce96b2f 1267 const uint8_t restore_config);
elab 0:0e577ce96b2f 1268 VL53L0X_Error enable_ref_spads(uint8_t aperture_spads,
elab 0:0e577ce96b2f 1269 uint8_t good_spad_array[],
elab 0:0e577ce96b2f 1270 uint8_t spad_array[],
elab 0:0e577ce96b2f 1271 uint32_t size,
elab 0:0e577ce96b2f 1272 uint32_t start,
elab 0:0e577ce96b2f 1273 uint32_t offset,
elab 0:0e577ce96b2f 1274 uint32_t spad_count,
elab 0:0e577ce96b2f 1275 uint32_t *p_last_spad);
elab 0:0e577ce96b2f 1276 void get_next_good_spad(uint8_t good_spad_array[], uint32_t size,
elab 0:0e577ce96b2f 1277 uint32_t curr, int32_t *p_next);
elab 0:0e577ce96b2f 1278 uint8_t is_aperture(uint32_t spad_index);
elab 0:0e577ce96b2f 1279 VL53L0X_Error enable_spad_bit(uint8_t spad_array[], uint32_t size,
elab 0:0e577ce96b2f 1280 uint32_t spad_index);
elab 0:0e577ce96b2f 1281 VL53L0X_Error set_ref_spad_map( uint8_t *p_ref_spad_array);
elab 0:0e577ce96b2f 1282 VL53L0X_Error get_ref_spad_map( uint8_t *p_ref_spad_array);
elab 0:0e577ce96b2f 1283 VL53L0X_Error perform_ref_signal_measurement(
elab 0:0e577ce96b2f 1284 uint16_t *p_ref_signal_rate);
elab 0:0e577ce96b2f 1285 VL53L0X_Error wrapped_VL53L0X_set_reference_spads(
elab 0:0e577ce96b2f 1286 uint32_t count, uint8_t is_aperture_spads);
elab 0:0e577ce96b2f 1287
elab 0:0e577ce96b2f 1288 /* api_strings.h functions */
elab 0:0e577ce96b2f 1289 VL53L0X_Error VL53L0X_check_part_used(uint8_t *revision);
elab 0:0e577ce96b2f 1290
elab 0:0e577ce96b2f 1291 /* Read function of the ID device */
elab 0:0e577ce96b2f 1292 // virtual int read_id();
elab 0:0e577ce96b2f 1293 virtual int read_id(uint8_t *id);
elab 0:0e577ce96b2f 1294
elab 0:0e577ce96b2f 1295 VL53L0X_Error wait_measurement_data_ready(void);
elab 0:0e577ce96b2f 1296
elab 0:0e577ce96b2f 1297 VL53L0X_Error wait_stop_completed(void);
elab 0:0e577ce96b2f 1298
elab 0:0e577ce96b2f 1299
elab 0:0e577ce96b2f 1300 /**
elab 0:0e577ce96b2f 1301 * @brief execute delay in all polling API call
elab 0:0e577ce96b2f 1302 *
elab 0:0e577ce96b2f 1303 * A typical multi-thread or RTOs implementation is to sleep the task for some 5ms (with 100Hz max rate faster polling is not needed)
elab 0:0e577ce96b2f 1304 * if nothing specific is need you can define it as an empty/void macro
elab 0:0e577ce96b2f 1305 * @code
elab 0:0e577ce96b2f 1306 * #define VL53L0X_PollingDelay(...) (void)0
elab 0:0e577ce96b2f 1307 * @endcode
elab 0:0e577ce96b2f 1308 *
elab 0:0e577ce96b2f 1309 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1310 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1311 */
elab 0:0e577ce96b2f 1312 VL53L0X_Error VL53L0X_polling_delay(void); /* usually best implemented as a real function */
elab 0:0e577ce96b2f 1313
elab 0:0e577ce96b2f 1314 ///////////////////////////////////////////////////////////////////////////////////////////////////////
elab 0:0e577ce96b2f 1315 //Added functions //
elab 0:0e577ce96b2f 1316 ///////////////////////////////////////////////////////////////////////////////////////////////////////
elab 0:0e577ce96b2f 1317
elab 0:0e577ce96b2f 1318 /**
elab 0:0e577ce96b2f 1319 * @brief Cycle Power to Device
elab 0:0e577ce96b2f 1320 *
elab 0:0e577ce96b2f 1321 * @return status - status 0 = ok, 1 = error
elab 0:0e577ce96b2f 1322 *
elab 0:0e577ce96b2f 1323 */
elab 0:0e577ce96b2f 1324 int32_t VL53L0X_cycle_power(void);
elab 0:0e577ce96b2f 1325
elab 0:0e577ce96b2f 1326 uint8_t VL53L0X_encode_vcsel_period(uint8_t vcsel_period_pclks);
elab 0:0e577ce96b2f 1327
elab 0:0e577ce96b2f 1328 VL53L0X_Error wrapped_VL53L0X_get_limit_check_info( uint16_t limit_check_id,
elab 0:0e577ce96b2f 1329 char *p_limit_check_string);
elab 0:0e577ce96b2f 1330
elab 0:0e577ce96b2f 1331 VL53L0X_Error wrapped_VL53L0X_get_ref_calibration(
elab 0:0e577ce96b2f 1332 uint8_t *p_vhv_settings, uint8_t *p_phase_cal);
elab 0:0e577ce96b2f 1333
elab 0:0e577ce96b2f 1334
elab 0:0e577ce96b2f 1335 VL53L0X_Error count_enabled_spads(uint8_t spad_array[],
elab 0:0e577ce96b2f 1336 uint32_t byte_count, uint32_t max_spads,
elab 0:0e577ce96b2f 1337 uint32_t *p_total_spads_enabled, uint8_t *p_is_aperture);
elab 0:0e577ce96b2f 1338
elab 0:0e577ce96b2f 1339 VL53L0X_Error wrapped_VL53L0X_get_sequence_steps_info(VL53L0X_SequenceStepId sequence_step_id,
elab 0:0e577ce96b2f 1340 char *p_sequence_steps_string);
elab 0:0e577ce96b2f 1341
elab 0:0e577ce96b2f 1342
elab 0:0e577ce96b2f 1343 /**
elab 0:0e577ce96b2f 1344 * @brief Gets the name of a given sequence step.
elab 0:0e577ce96b2f 1345 *
elab 0:0e577ce96b2f 1346 * @par Function Description
elab 0:0e577ce96b2f 1347 * This function retrieves the name of sequence steps corresponding to
elab 0:0e577ce96b2f 1348 * SequenceStepId.
elab 0:0e577ce96b2f 1349 *
elab 0:0e577ce96b2f 1350 * @note This function doesn't Accesses the device
elab 0:0e577ce96b2f 1351 *
elab 0:0e577ce96b2f 1352 * @param sequence_step_id Sequence step identifier.
elab 0:0e577ce96b2f 1353 * @param p_sequence_steps_string Pointer to Info string
elab 0:0e577ce96b2f 1354 *
elab 0:0e577ce96b2f 1355 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1356 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1357 */
elab 0:0e577ce96b2f 1358 VL53L0X_Error VL53L0X_get_sequence_steps_info(VL53L0X_SequenceStepId sequence_step_id,
elab 0:0e577ce96b2f 1359 char *p_sequence_steps_string);
elab 0:0e577ce96b2f 1360
elab 0:0e577ce96b2f 1361 /**
elab 0:0e577ce96b2f 1362 * @brief Get the frequency of the timer used for ranging results time stamps
elab 0:0e577ce96b2f 1363 *
elab 0:0e577ce96b2f 1364 * @param[out] p_timer_freq_hz : pointer for timer frequency
elab 0:0e577ce96b2f 1365 *
elab 0:0e577ce96b2f 1366 * @return status : 0 = ok, 1 = error
elab 0:0e577ce96b2f 1367 *
elab 0:0e577ce96b2f 1368 */
elab 0:0e577ce96b2f 1369 int32_t VL53L0X_get_timer_frequency(int32_t *p_timer_freq_hz);
elab 0:0e577ce96b2f 1370
elab 0:0e577ce96b2f 1371 /**
elab 0:0e577ce96b2f 1372 * @brief Get the timer value in units of timer_freq_hz (see VL53L0X_get_timestamp_frequency())
elab 0:0e577ce96b2f 1373 *
elab 0:0e577ce96b2f 1374 * @param[out] p_timer_count : pointer for timer count value
elab 0:0e577ce96b2f 1375 *
elab 0:0e577ce96b2f 1376 * @return status : 0 = ok, 1 = error
elab 0:0e577ce96b2f 1377 *
elab 0:0e577ce96b2f 1378 */
elab 0:0e577ce96b2f 1379 int32_t VL53L0X_get_timer_value(int32_t *p_timer_count);
elab 0:0e577ce96b2f 1380
elab 0:0e577ce96b2f 1381 /**
elab 0:0e577ce96b2f 1382 * @brief Get Dmax Calibration Parameters for a given device
elab 0:0e577ce96b2f 1383 *
elab 0:0e577ce96b2f 1384 * @note This function Access to the device
elab 0:0e577ce96b2f 1385 *
elab 0:0e577ce96b2f 1386 * @param p_range_milli_meter Pointer to Calibration Distance
elab 0:0e577ce96b2f 1387 * @param p_signal_rate_rtn_MHz Pointer to Signal rate return
elab 0:0e577ce96b2f 1388 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1389 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1390 */
elab 0:0e577ce96b2f 1391 VL53L0X_Error VL53L0X_get_dmax_cal_parameters(
elab 0:0e577ce96b2f 1392 uint16_t *p_range_milli_meter, FixPoint1616_t *p_signal_rate_rtn_MHz);
elab 0:0e577ce96b2f 1393
elab 0:0e577ce96b2f 1394 /**
elab 0:0e577ce96b2f 1395 * @brief Set Dmax Calibration Parameters for a given device
elab 0:0e577ce96b2f 1396 * When one of the parameter is zero, this function will get parameter
elab 0:0e577ce96b2f 1397 * from NVM.
elab 0:0e577ce96b2f 1398 * @note This function doesn't Access to the device
elab 0:0e577ce96b2f 1399 *
elab 0:0e577ce96b2f 1400 *
elab 0:0e577ce96b2f 1401 * @param range_milli_meter Calibration Distance
elab 0:0e577ce96b2f 1402 * @param signal_rate_rtn_MHz Signal rate return read at CalDistance
elab 0:0e577ce96b2f 1403 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1404 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1405 */
elab 0:0e577ce96b2f 1406 VL53L0X_Error VL53L0X_get_dmax_cal_parameters(
elab 0:0e577ce96b2f 1407 uint16_t range_milli_meter, FixPoint1616_t signal_rate_rtn_MHz);
elab 0:0e577ce96b2f 1408
elab 0:0e577ce96b2f 1409
elab 0:0e577ce96b2f 1410
elab 0:0e577ce96b2f 1411 /**
elab 0:0e577ce96b2f 1412 * @brief Return a description string for a given limit check number
elab 0:0e577ce96b2f 1413 *
elab 0:0e577ce96b2f 1414 * @par Function Description
elab 0:0e577ce96b2f 1415 * This function returns a description string for a given limit check number.
elab 0:0e577ce96b2f 1416 * The limit check is identified with the LimitCheckId.
elab 0:0e577ce96b2f 1417 *
elab 0:0e577ce96b2f 1418 * @note This function doesn't Access to the device
elab 0:0e577ce96b2f 1419 *
elab 0:0e577ce96b2f 1420 *
elab 0:0e577ce96b2f 1421 * @param limit_check_id Limit Check ID
elab 0:0e577ce96b2f 1422 (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
elab 0:0e577ce96b2f 1423 * @param p_limit_check_string Pointer to the
elab 0:0e577ce96b2f 1424 description string of the given check limit.
elab 0:0e577ce96b2f 1425 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1426 * @return VL53L0X_ERROR_INVALID_PARAMS This error is
elab 0:0e577ce96b2f 1427 returned when LimitCheckId value is out of range.
elab 0:0e577ce96b2f 1428 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1429 */
elab 0:0e577ce96b2f 1430 VL53L0X_Error VL53L0X_get_limit_check_info(
elab 0:0e577ce96b2f 1431 uint16_t limit_check_id, char *p_limit_check_string);
elab 0:0e577ce96b2f 1432
elab 0:0e577ce96b2f 1433 /**
elab 0:0e577ce96b2f 1434 * @brief Get the linearity corrective gain
elab 0:0e577ce96b2f 1435 *
elab 0:0e577ce96b2f 1436 * @par Function Description
elab 0:0e577ce96b2f 1437 * Should only be used after a successful call to @a VL53L0X_DataInit to backup
elab 0:0e577ce96b2f 1438 * device NVM value
elab 0:0e577ce96b2f 1439 *
elab 0:0e577ce96b2f 1440 * @note This function Access to the device
elab 0:0e577ce96b2f 1441 *
elab 0:0e577ce96b2f 1442 *
elab 0:0e577ce96b2f 1443 * @param p_linearity_corrective_gain Pointer to the linearity
elab 0:0e577ce96b2f 1444 * corrective gain in x1000
elab 0:0e577ce96b2f 1445 * if value is 1000 then no modification is applied.
elab 0:0e577ce96b2f 1446 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1447 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1448 */
elab 0:0e577ce96b2f 1449 VL53L0X_Error VL53L0X_get_linearity_corrective_gain(
elab 0:0e577ce96b2f 1450 uint16_t *p_linearity_corrective_gain);
elab 0:0e577ce96b2f 1451
elab 0:0e577ce96b2f 1452 /**
elab 0:0e577ce96b2f 1453 * Set the linearity corrective gain
elab 0:0e577ce96b2f 1454 *
elab 0:0e577ce96b2f 1455 * @note This function Access to the device
elab 0:0e577ce96b2f 1456 *
elab 0:0e577ce96b2f 1457 *
elab 0:0e577ce96b2f 1458 * @param linearity_corrective_gain Linearity corrective
elab 0:0e577ce96b2f 1459 * gain in x1000
elab 0:0e577ce96b2f 1460 * if value is 1000 then no modification is applied.
elab 0:0e577ce96b2f 1461 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1462 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1463 */
elab 0:0e577ce96b2f 1464 VL53L0X_Error VL53L0X_set_linearity_corrective_gain(
elab 0:0e577ce96b2f 1465 int16_t linearity_corrective_gain);
elab 0:0e577ce96b2f 1466
elab 0:0e577ce96b2f 1467 /**
elab 0:0e577ce96b2f 1468 * @brief Get the Maximum number of ROI Zones managed by the Device
elab 0:0e577ce96b2f 1469 *
elab 0:0e577ce96b2f 1470 * @par Function Description
elab 0:0e577ce96b2f 1471 * Get Maximum number of ROI Zones managed by the Device.
elab 0:0e577ce96b2f 1472 *
elab 0:0e577ce96b2f 1473 * @note This function doesn't Access to the device
elab 0:0e577ce96b2f 1474 *
elab 0:0e577ce96b2f 1475 *
elab 0:0e577ce96b2f 1476 * @param p_max_number_of_roi_zones Pointer to the Maximum Number
elab 0:0e577ce96b2f 1477 * of ROI Zones value.
elab 0:0e577ce96b2f 1478 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1479 */
elab 0:0e577ce96b2f 1480 VL53L0X_Error VL53L0X_get_max_number_of_roi_zones(
elab 0:0e577ce96b2f 1481 uint8_t *p_max_number_of_roi_zones);
elab 0:0e577ce96b2f 1482
elab 0:0e577ce96b2f 1483 /**
elab 0:0e577ce96b2f 1484 * @brief Retrieve the Reference Signal after a measurements
elab 0:0e577ce96b2f 1485 *
elab 0:0e577ce96b2f 1486 * @par Function Description
elab 0:0e577ce96b2f 1487 * Get Reference Signal from last successful Ranging measurement
elab 0:0e577ce96b2f 1488 * This function return a valid value after that you call the
elab 0:0e577ce96b2f 1489 * @a VL53L0X_GetRangingMeasurementData().
elab 0:0e577ce96b2f 1490 *
elab 0:0e577ce96b2f 1491 * @note This function Access to the device
elab 0:0e577ce96b2f 1492 *
elab 0:0e577ce96b2f 1493 *
elab 0:0e577ce96b2f 1494 * @param p_measurement_ref_signal Pointer to the Ref Signal to fill up.
elab 0:0e577ce96b2f 1495 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1496 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1497 */
elab 0:0e577ce96b2f 1498 VL53L0X_Error VL53L0X_get_measurement_ref_signal(
elab 0:0e577ce96b2f 1499 FixPoint1616_t *p_measurement_ref_signal);
elab 0:0e577ce96b2f 1500
elab 0:0e577ce96b2f 1501 /**
elab 0:0e577ce96b2f 1502 * @brief Get the number of the check limit managed by a given Device
elab 0:0e577ce96b2f 1503 *
elab 0:0e577ce96b2f 1504 * @par Function Description
elab 0:0e577ce96b2f 1505 * This function give the number of the check limit managed by the Device
elab 0:0e577ce96b2f 1506 *
elab 0:0e577ce96b2f 1507 * @note This function doesn't Access to the device
elab 0:0e577ce96b2f 1508 *
elab 0:0e577ce96b2f 1509 * @param p_number_of_limit_check Pointer to the number of check limit.
elab 0:0e577ce96b2f 1510 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1511 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1512 */
elab 0:0e577ce96b2f 1513 VL53L0X_Error VL53L0X_get_number_of_limit_check(
elab 0:0e577ce96b2f 1514 uint16_t *p_number_of_limit_check);
elab 0:0e577ce96b2f 1515
elab 0:0e577ce96b2f 1516 /**
elab 0:0e577ce96b2f 1517 * @brief Gets number of sequence steps managed by the API.
elab 0:0e577ce96b2f 1518 *
elab 0:0e577ce96b2f 1519 * @par Function Description
elab 0:0e577ce96b2f 1520 * This function retrieves the number of sequence steps currently managed
elab 0:0e577ce96b2f 1521 * by the API
elab 0:0e577ce96b2f 1522 *
elab 0:0e577ce96b2f 1523 * @note This function Accesses the device
elab 0:0e577ce96b2f 1524 *
elab 0:0e577ce96b2f 1525 * @param p_number_of_sequence_steps Out parameter reporting the number of
elab 0:0e577ce96b2f 1526 * sequence steps.
elab 0:0e577ce96b2f 1527 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1528 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1529 */
elab 0:0e577ce96b2f 1530 VL53L0X_Error VL53L0X_get_number_of_sequence_steps(
elab 0:0e577ce96b2f 1531 uint8_t *p_number_of_sequence_steps);
elab 0:0e577ce96b2f 1532 /**
elab 0:0e577ce96b2f 1533 * @brief Get the power mode for a given Device
elab 0:0e577ce96b2f 1534 *
elab 0:0e577ce96b2f 1535 * @note This function Access to the device
elab 0:0e577ce96b2f 1536 *
elab 0:0e577ce96b2f 1537 *
elab 0:0e577ce96b2f 1538 * @param p_power_mode Pointer to the current value of the power
elab 0:0e577ce96b2f 1539 * mode. see ::VL53L0X_PowerModes
elab 0:0e577ce96b2f 1540 * Valid values are:
elab 0:0e577ce96b2f 1541 * VL53L0X_POWERMODE_STANDBY_LEVEL1,
elab 0:0e577ce96b2f 1542 * VL53L0X_POWERMODE_IDLE_LEVEL1
elab 0:0e577ce96b2f 1543 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1544 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1545 */
elab 0:0e577ce96b2f 1546 VL53L0X_Error VL53L0X_get_power_mode(
elab 0:0e577ce96b2f 1547 VL53L0X_PowerModes *p_power_mode);
elab 0:0e577ce96b2f 1548
elab 0:0e577ce96b2f 1549 /**
elab 0:0e577ce96b2f 1550 * @brief Set the power mode for a given Device
elab 0:0e577ce96b2f 1551 * The power mode can be Standby or Idle. Different level of both Standby and
elab 0:0e577ce96b2f 1552 * Idle can exists.
elab 0:0e577ce96b2f 1553 * This function should not be used when device is in Ranging state.
elab 0:0e577ce96b2f 1554 *
elab 0:0e577ce96b2f 1555 * @note This function Access to the device
elab 0:0e577ce96b2f 1556 *
elab 0:0e577ce96b2f 1557 * @param power_mode The value of the power mode to set.
elab 0:0e577ce96b2f 1558 * see ::VL53L0X_PowerModes
elab 0:0e577ce96b2f 1559 * Valid values are:
elab 0:0e577ce96b2f 1560 * VL53L0X_POWERMODE_STANDBY_LEVEL1,
elab 0:0e577ce96b2f 1561 * VL53L0X_POWERMODE_IDLE_LEVEL1
elab 0:0e577ce96b2f 1562 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1563 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when PowerMode
elab 0:0e577ce96b2f 1564 * is not in the supported list
elab 0:0e577ce96b2f 1565 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1566 */
elab 0:0e577ce96b2f 1567 VL53L0X_Error VL53L0X_set_power_mode(VL53L0X_PowerModes power_mode);
elab 0:0e577ce96b2f 1568
elab 0:0e577ce96b2f 1569 /**
elab 0:0e577ce96b2f 1570 * @brief Retrieves SPAD configuration
elab 0:0e577ce96b2f 1571 *
elab 0:0e577ce96b2f 1572 * @par Function Description
elab 0:0e577ce96b2f 1573 * This function retrieves the current number of applied reference spads
elab 0:0e577ce96b2f 1574 * and also their type : Aperture or Non-Aperture.
elab 0:0e577ce96b2f 1575 *
elab 0:0e577ce96b2f 1576 * @note This function Access to the device
elab 0:0e577ce96b2f 1577 *
elab 0:0e577ce96b2f 1578 *
elab 0:0e577ce96b2f 1579 * @param p_spad_count Number ref Spad Count
elab 0:0e577ce96b2f 1580 * @param p_is_aperture_spads Reports if spads are of type
elab 0:0e577ce96b2f 1581 * aperture or non-aperture.
elab 0:0e577ce96b2f 1582 * 1:=aperture, 0:=Non-Aperture
elab 0:0e577ce96b2f 1583 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1584 * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the in the reference
elab 0:0e577ce96b2f 1585 * spad configuration.
elab 0:0e577ce96b2f 1586 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1587 */
elab 0:0e577ce96b2f 1588 VL53L0X_Error wrapped_VL53L0X_get_reference_spads(
elab 0:0e577ce96b2f 1589 uint32_t *p_spad_count, uint8_t *p_is_aperture_spads);
elab 0:0e577ce96b2f 1590
elab 0:0e577ce96b2f 1591 /**
elab 0:0e577ce96b2f 1592 * @brief Gets the (on/off) state of a requested sequence step.
elab 0:0e577ce96b2f 1593 *
elab 0:0e577ce96b2f 1594 * @par Function Description
elab 0:0e577ce96b2f 1595 * This function retrieves the state of a requested sequence step, i.e. on/off.
elab 0:0e577ce96b2f 1596 *
elab 0:0e577ce96b2f 1597 * @note This function Accesses the device
elab 0:0e577ce96b2f 1598 *
elab 0:0e577ce96b2f 1599 *
elab 0:0e577ce96b2f 1600 * @param sequence_step_id Sequence step identifier.
elab 0:0e577ce96b2f 1601 * @param p_sequence_step_enabled Out parameter reporting if the sequence step
elab 0:0e577ce96b2f 1602 * is enabled {0=Off,1=On}.
elab 0:0e577ce96b2f 1603 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1604 * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not
elab 0:0e577ce96b2f 1605 * supported.
elab 0:0e577ce96b2f 1606 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1607 */
elab 0:0e577ce96b2f 1608 VL53L0X_Error VL53L0X_get_sequence_step_enable(
elab 0:0e577ce96b2f 1609 VL53L0X_SequenceStepId sequence_step_id, uint8_t *p_sequence_step_enabled);
elab 0:0e577ce96b2f 1610
elab 0:0e577ce96b2f 1611 /**
elab 0:0e577ce96b2f 1612 * @brief Gets the timeout of a requested sequence step.
elab 0:0e577ce96b2f 1613 *
elab 0:0e577ce96b2f 1614 * @par Function Description
elab 0:0e577ce96b2f 1615 * This function retrieves the timeout of a requested sequence step.
elab 0:0e577ce96b2f 1616 *
elab 0:0e577ce96b2f 1617 * @note This function Accesses the device
elab 0:0e577ce96b2f 1618 *
elab 0:0e577ce96b2f 1619 * @param sequence_step_id Sequence step identifier.
elab 0:0e577ce96b2f 1620 * @param p_time_out_milli_secs Timeout value.
elab 0:0e577ce96b2f 1621 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1622 * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not
elab 0:0e577ce96b2f 1623 * supported.
elab 0:0e577ce96b2f 1624 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1625 */
elab 0:0e577ce96b2f 1626 VL53L0X_Error VL53L0X_get_sequence_step_timeout(VL53L0X_SequenceStepId sequence_step_id,
elab 0:0e577ce96b2f 1627 FixPoint1616_t *p_time_out_milli_secs);
elab 0:0e577ce96b2f 1628
elab 0:0e577ce96b2f 1629 /**
elab 0:0e577ce96b2f 1630 * @brief Sets the timeout of a requested sequence step.
elab 0:0e577ce96b2f 1631 *
elab 0:0e577ce96b2f 1632 * @par Function Description
elab 0:0e577ce96b2f 1633 * This function sets the timeout of a requested sequence step.
elab 0:0e577ce96b2f 1634 *
elab 0:0e577ce96b2f 1635 * @note This function Accesses the device
elab 0:0e577ce96b2f 1636 *
elab 0:0e577ce96b2f 1637 *
elab 0:0e577ce96b2f 1638 * @param sequence_step_id Sequence step identifier.
elab 0:0e577ce96b2f 1639 * @param time_out_milli_secs Demanded timeout
elab 0:0e577ce96b2f 1640 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1641 * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not
elab 0:0e577ce96b2f 1642 * supported.
elab 0:0e577ce96b2f 1643 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1644 */
elab 0:0e577ce96b2f 1645 VL53L0X_Error VL53L0X_set_sequence_step_timeout(
elab 0:0e577ce96b2f 1646 VL53L0X_SequenceStepId sequence_step_id, FixPoint1616_t time_out_milli_secs);
elab 0:0e577ce96b2f 1647
elab 0:0e577ce96b2f 1648 /**
elab 0:0e577ce96b2f 1649 * @brief Get the tuning settings pointer and the internal external switch
elab 0:0e577ce96b2f 1650 * value.
elab 0:0e577ce96b2f 1651 *
elab 0:0e577ce96b2f 1652 * This function is used to get the Tuning settings buffer pointer and the
elab 0:0e577ce96b2f 1653 * value.
elab 0:0e577ce96b2f 1654 * of the switch to select either external or internal tuning settings.
elab 0:0e577ce96b2f 1655 *
elab 0:0e577ce96b2f 1656 * @note This function Access to the device
elab 0:0e577ce96b2f 1657 *
elab 0:0e577ce96b2f 1658 *
elab 0:0e577ce96b2f 1659 * @param pp_tuning_setting_buffer Pointer to tuning settings buffer.
elab 0:0e577ce96b2f 1660 * @param p_use_internal_tuning_settings Pointer to store Use internal tuning
elab 0:0e577ce96b2f 1661 * settings value.
elab 0:0e577ce96b2f 1662 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1663 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1664 */
elab 0:0e577ce96b2f 1665 VL53L0X_Error VL53L0X_get_tuning_setting_buffer(
elab 0:0e577ce96b2f 1666 uint8_t **pp_tuning_setting_buffer, uint8_t *p_use_internal_tuning_settings);
elab 0:0e577ce96b2f 1667
elab 0:0e577ce96b2f 1668 /**
elab 0:0e577ce96b2f 1669 * @brief Set the tuning settings pointer
elab 0:0e577ce96b2f 1670 *
elab 0:0e577ce96b2f 1671 * This function is used to specify the Tuning settings buffer to be used
elab 0:0e577ce96b2f 1672 * for a given device. The buffer contains all the necessary data to permit
elab 0:0e577ce96b2f 1673 * the API to write tuning settings.
elab 0:0e577ce96b2f 1674 * This function permit to force the usage of either external or internal
elab 0:0e577ce96b2f 1675 * tuning settings.
elab 0:0e577ce96b2f 1676 *
elab 0:0e577ce96b2f 1677 * @note This function Access to the device
elab 0:0e577ce96b2f 1678 *
elab 0:0e577ce96b2f 1679 *
elab 0:0e577ce96b2f 1680 * @param p_tuning_setting_buffer Pointer to tuning settings buffer.
elab 0:0e577ce96b2f 1681 * @param use_internal_tuning_settings Use internal tuning settings value.
elab 0:0e577ce96b2f 1682 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1683 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1684 */
elab 0:0e577ce96b2f 1685 VL53L0X_Error VL53L0X_set_tuning_setting_buffer(
elab 0:0e577ce96b2f 1686 uint8_t *p_tuning_setting_buffer, uint8_t use_internal_tuning_settings);
elab 0:0e577ce96b2f 1687
elab 0:0e577ce96b2f 1688 /**
elab 0:0e577ce96b2f 1689 * @defgroup VL53L0X_registerAccess_group PAL Register Access Functions
elab 0:0e577ce96b2f 1690 * @brief PAL Register Access Functions
elab 0:0e577ce96b2f 1691 * @{
elab 0:0e577ce96b2f 1692 */
elab 0:0e577ce96b2f 1693
elab 0:0e577ce96b2f 1694 /**
elab 0:0e577ce96b2f 1695 * @brief Prepare device for operation
elab 0:0e577ce96b2f 1696 * @par Function Description
elab 0:0e577ce96b2f 1697 * Update device with provided parameters
elab 0:0e577ce96b2f 1698 * @li Then start ranging operation.
elab 0:0e577ce96b2f 1699 *
elab 0:0e577ce96b2f 1700 * @note This function Access to the device
elab 0:0e577ce96b2f 1701 *
elab 0:0e577ce96b2f 1702 *
elab 0:0e577ce96b2f 1703 * @param pDeviceParameters Pointer to store current device parameters.
elab 0:0e577ce96b2f 1704 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1705 * @return "Other error code" See ::VL53L0X_Error
elab 0:0e577ce96b2f 1706 */
elab 0:0e577ce96b2f 1707 VL53L0X_Error vl53L0x_set_device_parameters(
elab 0:0e577ce96b2f 1708 const VL53L0X_DeviceParameters_t *pDeviceParameters);
elab 0:0e577ce96b2f 1709
elab 0:0e577ce96b2f 1710 VL53L0X_Error VL53L0X_reverse_bytes(uint8_t *data, uint32_t size);
elab 0:0e577ce96b2f 1711
elab 0:0e577ce96b2f 1712 int range_meas_int_continuous_mode(void (*fptr)(void));
elab 0:0e577ce96b2f 1713
elab 0:0e577ce96b2f 1714 /* Digital out pin */
elab 0:0e577ce96b2f 1715 DigitalOut *_gpio0;
elab 0:0e577ce96b2f 1716 /* Measure detection IRQ */
elab 0:0e577ce96b2f 1717 InterruptIn *_gpio1Int;
elab 0:0e577ce96b2f 1718
elab 0:0e577ce96b2f 1719 VL53L0X_DevData_t Data;
elab 0:0e577ce96b2f 1720 VL53L0X_DeviceInfo_t Device_Info;
elab 0:0e577ce96b2f 1721 VL53L0X_DeviceParameters_t CurrentParameters; /*!< Current Device Parameter */
elab 0:0e577ce96b2f 1722 VL53L0X_RangingMeasurementData_t LastRangeMeasure; /*!< Last Performed Ranging Data */
elab 0:0e577ce96b2f 1723
elab 0:0e577ce96b2f 1724 public:
elab 0:0e577ce96b2f 1725 /* IO Device */
elab 0:0e577ce96b2f 1726 I2C *_dev_i2c;
elab 0:0e577ce96b2f 1727 uint8_t I2cDevAddr; /*!< i2c device address user specific field */
elab 0:0e577ce96b2f 1728 uint8_t comms_type; /*!< Type of comms : VL53L0X_COMMS_I2C or VL53L0X_COMMS_SPI */
elab 0:0e577ce96b2f 1729 uint16_t comms_speed_khz; /*!< Comms speed [kHz] : typically 400kHz for I2C */
elab 0:0e577ce96b2f 1730
elab 0:0e577ce96b2f 1731 /* Write and read functions from I2C */
elab 0:0e577ce96b2f 1732 /** Write single byte register
elab 0:0e577ce96b2f 1733 *
elab 0:0e577ce96b2f 1734 * @param index The register index
elab 0:0e577ce96b2f 1735 * @param data 8 bit register data
elab 0:0e577ce96b2f 1736 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1737 * @return "Other error code" See ::VL53L0X_Error */
elab 0:0e577ce96b2f 1738
elab 0:0e577ce96b2f 1739 VL53L0X_Error VL53L0X_write_byte( uint8_t index, uint8_t data);
elab 0:0e577ce96b2f 1740 /** Write word register
elab 0:0e577ce96b2f 1741 *
elab 0:0e577ce96b2f 1742 * @param index The register index
elab 0:0e577ce96b2f 1743 * @param data 16 bit register data
elab 0:0e577ce96b2f 1744 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1745 * @return "Other error code" See ::VL53L0X_Error */
elab 0:0e577ce96b2f 1746
elab 0:0e577ce96b2f 1747 VL53L0X_Error VL53L0X_write_word( uint8_t index, uint16_t data);
elab 0:0e577ce96b2f 1748 /** Write double word (4 byte) register
elab 0:0e577ce96b2f 1749 *
elab 0:0e577ce96b2f 1750 * @param index The register index
elab 0:0e577ce96b2f 1751 * @param data 32 bit register data
elab 0:0e577ce96b2f 1752 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1753 * @return "Other error code" See ::VL53L0X_Error */
elab 0:0e577ce96b2f 1754
elab 0:0e577ce96b2f 1755 VL53L0X_Error VL53L0X_write_dword( uint8_t index, uint32_t data);
elab 0:0e577ce96b2f 1756 /** Read single byte register
elab 0:0e577ce96b2f 1757 *
elab 0:0e577ce96b2f 1758 * @param index The register index
elab 0:0e577ce96b2f 1759 * @param data pointer to 8 bit data
elab 0:0e577ce96b2f 1760 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1761 * @return "Other error code" See ::VL53L0X_Error */
elab 0:0e577ce96b2f 1762
elab 0:0e577ce96b2f 1763 VL53L0X_Error VL53L0X_read_byte( uint8_t index, uint8_t *p_data);
elab 0:0e577ce96b2f 1764 /** Read word (2byte) register
elab 0:0e577ce96b2f 1765 *
elab 0:0e577ce96b2f 1766 * @param index The register index
elab 0:0e577ce96b2f 1767 * @param data pointer to 16 bit data
elab 0:0e577ce96b2f 1768 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1769 * @return "Other error code" See ::VL53L0X_Error */
elab 0:0e577ce96b2f 1770
elab 0:0e577ce96b2f 1771 VL53L0X_Error VL53L0X_read_word( uint8_t index, uint16_t *p_data);
elab 0:0e577ce96b2f 1772 /** Read dword (4byte) register
elab 0:0e577ce96b2f 1773 *
elab 0:0e577ce96b2f 1774 * @param index The register index
elab 0:0e577ce96b2f 1775 * @param data pointer to 32 bit data
elab 0:0e577ce96b2f 1776 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1777 * @return "Other error code" See ::VL53L0X_Error */
elab 0:0e577ce96b2f 1778 VL53L0X_Error VL53L0X_read_dword( uint8_t index, uint32_t *p_data);
elab 0:0e577ce96b2f 1779
elab 0:0e577ce96b2f 1780 /** Thread safe Update (read/modify/write) single byte register
elab 0:0e577ce96b2f 1781 *
elab 0:0e577ce96b2f 1782 * Final_reg = (Initial_reg & and_data) |or_data
elab 0:0e577ce96b2f 1783 *
elab 0:0e577ce96b2f 1784 * @param index The register index
elab 0:0e577ce96b2f 1785 * @param and_data 8 bit and data
elab 0:0e577ce96b2f 1786 * @param or_data 8 bit or data
elab 0:0e577ce96b2f 1787 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1788 * @return "Other error code" See ::VL53L0X_Error */
elab 0:0e577ce96b2f 1789 VL53L0X_Error VL53L0X_update_byte( uint8_t index, uint8_t and_data, uint8_t or_data);
elab 0:0e577ce96b2f 1790
elab 0:0e577ce96b2f 1791 /** Reads the requested number of bytes from the device
elab 0:0e577ce96b2f 1792 *
elab 0:0e577ce96b2f 1793 * @param index The register index
elab 0:0e577ce96b2f 1794 * @param p_data Pointer to the uint8_t buffer to store read data
elab 0:0e577ce96b2f 1795 * @param count Number of uint8_t's to read
elab 0:0e577ce96b2f 1796 * @return VL53L0X_ERROR_NONE Success
elab 0:0e577ce96b2f 1797 * @return "Other error code" See ::VL53L0X_Error */
elab 0:0e577ce96b2f 1798 VL53L0X_Error VL53L0X_read_multi( uint8_t index, uint8_t *p_data, uint32_t count);
elab 0:0e577ce96b2f 1799
elab 0:0e577ce96b2f 1800 /** @brief Writes a buffer towards the I2C peripheral device.
elab 0:0e577ce96b2f 1801 *
elab 0:0e577ce96b2f 1802 * @param p_data pointer to the byte-array data to send
elab 0:0e577ce96b2f 1803 * @param number_of_bytes number of bytes to be written.
elab 0:0e577ce96b2f 1804 * @retval 0 if ok,
elab 0:0e577ce96b2f 1805 * @retval -1 if an I2C error has occured
elab 0:0e577ce96b2f 1806 * @note On some devices if NumByteToWrite is greater
elab 0:0e577ce96b2f 1807 * than one, the RegisterAddr must be masked correctly! */
elab 0:0e577ce96b2f 1808 VL53L0X_Error VL53L0X_i2c_write(uint8_t index, uint8_t *p_data, uint16_t number_of_bytes);
elab 0:0e577ce96b2f 1809
elab 0:0e577ce96b2f 1810 /** @brief Reads a buffer from the I2C peripheral device.
elab 0:0e577ce96b2f 1811 *
elab 0:0e577ce96b2f 1812 * @param p_data pointer to the byte-array to read data in to
elab 0:0e577ce96b2f 1813 * @param number_of_bytes number of bytes to be read.
elab 0:0e577ce96b2f 1814 * @retval 0 if ok,
elab 0:0e577ce96b2f 1815 * @retval -1 if an I2C error has occured
elab 0:0e577ce96b2f 1816 * @note On some devices if NumByteToWrite is greater
elab 0:0e577ce96b2f 1817 * than one, the RegisterAddr must be masked correctly! */
elab 0:0e577ce96b2f 1818 VL53L0X_Error VL53L0X_i2c_read(uint8_t index, uint8_t *p_data, uint16_t number_of_bytes);
elab 0:0e577ce96b2f 1819 };
elab 0:0e577ce96b2f 1820
elab 0:0e577ce96b2f 1821 void Report_Deep_Infos (VL53L0X TOF1, Serial *aSerial);
elab 0:0e577ce96b2f 1822 void Report_Range_Infos(VL53L0X_RangingMeasurementData_t RangeResults, Serial *aSerial);
elab 0:0e577ce96b2f 1823
elab 0:0e577ce96b2f 1824 #endif /* _VL53L0X_CLASS_H_ */