Condensed Version of Public VL53L0X

Dependents:   ToF-Only-Tryout

Committer:
sepp_nepp
Date:
Sat Mar 23 21:28:30 2019 +0000
Revision:
5:b95f6951f7d5
Parent:
4:d25c4fa216af
Child:
7:41cbc431e1f4
First Version of My Variant of VL53L0X

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nikapov 0:a1a69d32f310 1 /*******************************************************************************
nikapov 0:a1a69d32f310 2 Copyright © 2016, STMicroelectronics International N.V.
nikapov 0:a1a69d32f310 3 All rights reserved.
nikapov 0:a1a69d32f310 4
nikapov 0:a1a69d32f310 5 Redistribution and use in source and binary forms, with or without
nikapov 0:a1a69d32f310 6 modification, are permitted provided that the following conditions are met:
nikapov 0:a1a69d32f310 7 * Redistributions of source code must retain the above copyright
nikapov 0:a1a69d32f310 8 notice, this list of conditions and the following disclaimer.
nikapov 0:a1a69d32f310 9 * Redistributions in binary form must reproduce the above copyright
nikapov 0:a1a69d32f310 10 notice, this list of conditions and the following disclaimer in the
nikapov 0:a1a69d32f310 11 documentation and/or other materials provided with the distribution.
nikapov 0:a1a69d32f310 12 * Neither the name of STMicroelectronics nor the
nikapov 0:a1a69d32f310 13 names of its contributors may be used to endorse or promote products
nikapov 0:a1a69d32f310 14 derived from this software without specific prior written permission.
nikapov 0:a1a69d32f310 15
nikapov 0:a1a69d32f310 16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
nikapov 0:a1a69d32f310 17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
nikapov 0:a1a69d32f310 18 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
nikapov 0:a1a69d32f310 19 NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
nikapov 0:a1a69d32f310 20 IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
nikapov 0:a1a69d32f310 21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
nikapov 0:a1a69d32f310 22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
nikapov 0:a1a69d32f310 23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
nikapov 0:a1a69d32f310 24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
nikapov 0:a1a69d32f310 25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
nikapov 0:a1a69d32f310 26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
nikapov 0:a1a69d32f310 27 *****************************************************************************/
nikapov 0:a1a69d32f310 28
nikapov 0:a1a69d32f310 29 #ifndef __VL53L0X_CLASS_H
nikapov 0:a1a69d32f310 30 #define __VL53L0X_CLASS_H
nikapov 0:a1a69d32f310 31
nikapov 0:a1a69d32f310 32
nikapov 0:a1a69d32f310 33 #ifdef _MSC_VER
nikapov 0:a1a69d32f310 34 # ifdef VL53L0X_API_EXPORTS
nikapov 0:a1a69d32f310 35 # define VL53L0X_API __declspec(dllexport)
nikapov 0:a1a69d32f310 36 # else
nikapov 0:a1a69d32f310 37 # define VL53L0X_API
nikapov 0:a1a69d32f310 38 # endif
nikapov 0:a1a69d32f310 39 #else
nikapov 0:a1a69d32f310 40 # define VL53L0X_API
nikapov 0:a1a69d32f310 41 #endif
nikapov 0:a1a69d32f310 42
nikapov 0:a1a69d32f310 43
nikapov 0:a1a69d32f310 44 /* Includes ------------------------------------------------------------------*/
nikapov 0:a1a69d32f310 45 #include "mbed.h"
sepp_nepp 5:b95f6951f7d5 46 #include "pinmap.h"
nikapov 0:a1a69d32f310 47 #include "PinNames.h"
nikapov 0:a1a69d32f310 48 #include "VL53L0X_def.h"
nikapov 0:a1a69d32f310 49
nikapov 0:a1a69d32f310 50 /**
nikapov 0:a1a69d32f310 51 * The device model ID
nikapov 0:a1a69d32f310 52 */
sepp_nepp 5:b95f6951f7d5 53 #define IDENTIFICATION_MODEL_ID 0x000
sepp_nepp 5:b95f6951f7d5 54 #define STATUS_OK 0x00
sepp_nepp 5:b95f6951f7d5 55 #define STATUS_FAIL 0x01
nikapov 0:a1a69d32f310 56
sepp_nepp 5:b95f6951f7d5 57 /** default device address */
sepp_nepp 5:b95f6951f7d5 58 #define VL53L0X_DEFAULT_ADDRESS 0x52 /* (8-bit) */
nikapov 0:a1a69d32f310 59
nikapov 0:a1a69d32f310 60 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS0 "VL53L0X TS0"
nikapov 0:a1a69d32f310 61 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS1 "VL53L0X TS1"
nikapov 0:a1a69d32f310 62 #define VL53L0X_STRING_DEVICE_INFO_NAME_TS2 "VL53L0X TS2"
nikapov 0:a1a69d32f310 63 #define VL53L0X_STRING_DEVICE_INFO_NAME_ES1 "VL53L0X ES1 or later"
nikapov 0:a1a69d32f310 64 #define VL53L0X_STRING_DEVICE_INFO_TYPE "VL53L0X"
nikapov 0:a1a69d32f310 65
sepp_nepp 5:b95f6951f7d5 66
sepp_nepp 5:b95f6951f7d5 67 /* Classes -------------------------------------------------------------------*/
sepp_nepp 5:b95f6951f7d5 68 /** Helper class DevI2C providing functions for multi-register I2C communication
sepp_nepp 5:b95f6951f7d5 69 * common for a series of I2C devices
sepp_nepp 5:b95f6951f7d5 70 */
sepp_nepp 5:b95f6951f7d5 71 class DevI2C : public I2C
sepp_nepp 5:b95f6951f7d5 72 {
sepp_nepp 5:b95f6951f7d5 73 private:
sepp_nepp 5:b95f6951f7d5 74 static const unsigned int TEMP_BUF_SIZE = 64;
nikapov 0:a1a69d32f310 75
sepp_nepp 5:b95f6951f7d5 76 public:
sepp_nepp 5:b95f6951f7d5 77 /** Create a DevI2C Master interface, connected to the specified pins
sepp_nepp 5:b95f6951f7d5 78 *
sepp_nepp 5:b95f6951f7d5 79 * @param sda I2C data line pin
sepp_nepp 5:b95f6951f7d5 80 * @param scl I2C clock line pin
sepp_nepp 5:b95f6951f7d5 81 */
sepp_nepp 5:b95f6951f7d5 82 DevI2C(PinName sda, PinName scl) : I2C(sda, scl) {}
sepp_nepp 5:b95f6951f7d5 83
sepp_nepp 5:b95f6951f7d5 84 /**
sepp_nepp 5:b95f6951f7d5 85 * @brief Writes a buffer towards the I2C peripheral device.
sepp_nepp 5:b95f6951f7d5 86 * @param pBuffer pointer to the byte-array data to send
sepp_nepp 5:b95f6951f7d5 87 * @param DeviceAddr specifies the peripheral device slave address.
sepp_nepp 5:b95f6951f7d5 88 * @param RegisterAddr specifies the internal address register
sepp_nepp 5:b95f6951f7d5 89 * where to start writing to (must be correctly masked).
sepp_nepp 5:b95f6951f7d5 90 * @param NumByteToWrite number of bytes to be written.
sepp_nepp 5:b95f6951f7d5 91 * @retval 0 if ok,
sepp_nepp 5:b95f6951f7d5 92 * @retval -1 if an I2C error has occured, or
sepp_nepp 5:b95f6951f7d5 93 * @retval -2 on temporary buffer overflow (i.e. NumByteToWrite was too high)
sepp_nepp 5:b95f6951f7d5 94 * @note On some devices if NumByteToWrite is greater
sepp_nepp 5:b95f6951f7d5 95 * than one, the RegisterAddr must be masked correctly!
sepp_nepp 5:b95f6951f7d5 96 */
sepp_nepp 5:b95f6951f7d5 97 int i2c_write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
sepp_nepp 5:b95f6951f7d5 98 uint16_t NumByteToWrite) {
sepp_nepp 5:b95f6951f7d5 99 int ret;
sepp_nepp 5:b95f6951f7d5 100 uint8_t tmp[TEMP_BUF_SIZE];
nikapov 0:a1a69d32f310 101
sepp_nepp 5:b95f6951f7d5 102 if(NumByteToWrite >= TEMP_BUF_SIZE) return -2;
nikapov 0:a1a69d32f310 103
sepp_nepp 5:b95f6951f7d5 104 /* First, send device address. Then, send data and STOP condition */
sepp_nepp 5:b95f6951f7d5 105 tmp[0] = RegisterAddr;
sepp_nepp 5:b95f6951f7d5 106 memcpy(tmp+1, pBuffer, NumByteToWrite);
nikapov 0:a1a69d32f310 107
sepp_nepp 5:b95f6951f7d5 108 ret = write(DeviceAddr, (const char*)tmp, NumByteToWrite+1, false);
sepp_nepp 5:b95f6951f7d5 109
sepp_nepp 5:b95f6951f7d5 110 if(ret) return -1;
sepp_nepp 5:b95f6951f7d5 111 return 0;
sepp_nepp 5:b95f6951f7d5 112 }
nikapov 0:a1a69d32f310 113
sepp_nepp 5:b95f6951f7d5 114 /**
sepp_nepp 5:b95f6951f7d5 115 * @brief Reads a buffer from the I2C peripheral device.
sepp_nepp 5:b95f6951f7d5 116 * @param pBuffer pointer to the byte-array to read data in to
sepp_nepp 5:b95f6951f7d5 117 * @param DeviceAddr specifies the peripheral device slave address.
sepp_nepp 5:b95f6951f7d5 118 * @param RegisterAddr specifies the internal address register
sepp_nepp 5:b95f6951f7d5 119 * where to start reading from (must be correctly masked).
sepp_nepp 5:b95f6951f7d5 120 * @param NumByteToRead number of bytes to be read.
sepp_nepp 5:b95f6951f7d5 121 * @retval 0 if ok,
sepp_nepp 5:b95f6951f7d5 122 * @retval -1 if an I2C error has occured
sepp_nepp 5:b95f6951f7d5 123 * @note On some devices if NumByteToWrite is greater
sepp_nepp 5:b95f6951f7d5 124 * than one, the RegisterAddr must be masked correctly!
sepp_nepp 5:b95f6951f7d5 125 */
sepp_nepp 5:b95f6951f7d5 126 int i2c_read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
sepp_nepp 5:b95f6951f7d5 127 uint16_t NumByteToRead) {
sepp_nepp 5:b95f6951f7d5 128 int ret;
nikapov 0:a1a69d32f310 129
sepp_nepp 5:b95f6951f7d5 130 /* Send device address, with no STOP condition */
sepp_nepp 5:b95f6951f7d5 131 ret = write(DeviceAddr, (const char*)&RegisterAddr, 1, true);
sepp_nepp 5:b95f6951f7d5 132 if(!ret) {
sepp_nepp 5:b95f6951f7d5 133 /* Read data, with STOP condition */
sepp_nepp 5:b95f6951f7d5 134 ret = read(DeviceAddr, (char*)pBuffer, NumByteToRead, false);
sepp_nepp 5:b95f6951f7d5 135 }
nikapov 0:a1a69d32f310 136
sepp_nepp 5:b95f6951f7d5 137 if(ret) return -1;
sepp_nepp 5:b95f6951f7d5 138 return 0;
sepp_nepp 5:b95f6951f7d5 139 }
sepp_nepp 5:b95f6951f7d5 140
sepp_nepp 5:b95f6951f7d5 141 };
nikapov 0:a1a69d32f310 142
nikapov 0:a1a69d32f310 143 /* sensor operating modes */
nikapov 0:a1a69d32f310 144 typedef enum {
nikapov 0:a1a69d32f310 145 range_single_shot_polling = 1,
nikapov 0:a1a69d32f310 146 range_continuous_polling,
nikapov 0:a1a69d32f310 147 range_continuous_interrupt,
nikapov 0:a1a69d32f310 148 range_continuous_polling_low_threshold,
nikapov 0:a1a69d32f310 149 range_continuous_polling_high_threshold,
nikapov 0:a1a69d32f310 150 range_continuous_polling_out_of_window,
nikapov 0:a1a69d32f310 151 range_continuous_interrupt_low_threshold,
nikapov 0:a1a69d32f310 152 range_continuous_interrupt_high_threshold,
nikapov 0:a1a69d32f310 153 range_continuous_interrupt_out_of_window,
nikapov 0:a1a69d32f310 154 } OperatingMode;
nikapov 0:a1a69d32f310 155
nikapov 0:a1a69d32f310 156 /* Classes -------------------------------------------------------------------*/
nikapov 0:a1a69d32f310 157 /** Class representing a VL53L0 sensor component
nikapov 0:a1a69d32f310 158 */
sepp_nepp 5:b95f6951f7d5 159 class VL53L0X
nikapov 0:a1a69d32f310 160 {
nikapov 0:a1a69d32f310 161 public:
nikapov 0:a1a69d32f310 162 /** Constructor
nikapov 0:a1a69d32f310 163 * @param[in] &i2c device I2C to be used for communication
nikapov 0:a1a69d32f310 164 * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
nikapov 0:a1a69d32f310 165 * @param[in] dev_addr device address, 0x29 by default
nikapov 0:a1a69d32f310 166 */
nikapov 1:834986cdde0a 167 VL53L0X(DevI2C *i2c, DigitalOut *pin, PinName pin_gpio1, uint8_t dev_addr = VL53L0X_DEFAULT_ADDRESS) : _dev_i2c(i2c),
nikapov 0:a1a69d32f310 168 _gpio0(pin)
nikapov 0:a1a69d32f310 169 {
nikapov 0:a1a69d32f310 170 _my_device.I2cDevAddr = dev_addr;
nikapov 0:a1a69d32f310 171 _my_device.comms_type = 1; // VL53L0X_COMMS_I2C
nikapov 0:a1a69d32f310 172 _my_device.comms_speed_khz = 400;
nikapov 0:a1a69d32f310 173 _device = &_my_device;
nikapov 0:a1a69d32f310 174 if (pin_gpio1 != NC) {
nikapov 0:a1a69d32f310 175 _gpio1Int = new InterruptIn(pin_gpio1);
nikapov 0:a1a69d32f310 176 } else {
nikapov 0:a1a69d32f310 177 _gpio1Int = NULL;
nikapov 0:a1a69d32f310 178 }
nikapov 0:a1a69d32f310 179 }
nikapov 0:a1a69d32f310 180
nikapov 0:a1a69d32f310 181
nikapov 0:a1a69d32f310 182 /** Destructor
nikapov 0:a1a69d32f310 183 */
nikapov 0:a1a69d32f310 184 virtual ~VL53L0X()
sepp_nepp 5:b95f6951f7d5 185 { if (_gpio1Int != NULL) { delete _gpio1Int; }
nikapov 0:a1a69d32f310 186 }
nikapov 0:a1a69d32f310 187
nikapov 0:a1a69d32f310 188 /*** Interface Methods ***/
nikapov 0:a1a69d32f310 189 /*** High level API ***/
nikapov 0:a1a69d32f310 190 /**
nikapov 0:a1a69d32f310 191 * @brief PowerOn the sensor
nikapov 0:a1a69d32f310 192 * @return void
nikapov 0:a1a69d32f310 193 */
nikapov 0:a1a69d32f310 194 /* turns on the sensor */
nikapov 0:a1a69d32f310 195 void VL53L0X_on(void)
nikapov 0:a1a69d32f310 196 {
sepp_nepp 5:b95f6951f7d5 197 if (_gpio0) { *_gpio0 = 1; }
nikapov 0:a1a69d32f310 198 wait_ms(10);
nikapov 0:a1a69d32f310 199 }
nikapov 0:a1a69d32f310 200
nikapov 0:a1a69d32f310 201 /**
nikapov 0:a1a69d32f310 202 * @brief PowerOff the sensor
nikapov 0:a1a69d32f310 203 * @return void
nikapov 0:a1a69d32f310 204 */
nikapov 0:a1a69d32f310 205 /* turns off the sensor */
nikapov 0:a1a69d32f310 206 void VL53L0X_off(void)
nikapov 0:a1a69d32f310 207 {
sepp_nepp 5:b95f6951f7d5 208 if (_gpio0) { *_gpio0 = 0; }
nikapov 0:a1a69d32f310 209 wait_ms(10);
nikapov 0:a1a69d32f310 210 }
Davidroid 2:d07edeaff6f1 211
nikapov 0:a1a69d32f310 212 /**
nikapov 0:a1a69d32f310 213 * @brief Initialize the sensor with default values
nikapov 0:a1a69d32f310 214 * @return "0" on success
nikapov 0:a1a69d32f310 215 */
nikapov 0:a1a69d32f310 216 int init_sensor(uint8_t new_addr);
nikapov 0:a1a69d32f310 217
nikapov 0:a1a69d32f310 218 /**
nikapov 0:a1a69d32f310 219 * @brief Start the measure indicated by operating mode
nikapov 0:a1a69d32f310 220 * @param[in] operating_mode specifies requested measure
nikapov 0:a1a69d32f310 221 * @param[in] fptr specifies call back function must be !NULL in case of interrupt measure
nikapov 0:a1a69d32f310 222 * @return "0" on success
nikapov 0:a1a69d32f310 223 */
nikapov 0:a1a69d32f310 224 int start_measurement(OperatingMode operating_mode, void (*fptr)(void));
nikapov 0:a1a69d32f310 225
nikapov 0:a1a69d32f310 226 /**
nikapov 0:a1a69d32f310 227 * @brief Get results for the measure indicated by operating mode
nikapov 0:a1a69d32f310 228 * @param[in] operating_mode specifies requested measure results
nikapov 0:a1a69d32f310 229 * @param[out] p_data pointer to the MeasureData_t structure to read data in to
nikapov 0:a1a69d32f310 230 * @return "0" on success
nikapov 0:a1a69d32f310 231 */
nikapov 0:a1a69d32f310 232 int get_measurement(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *p_data);
nikapov 0:a1a69d32f310 233
nikapov 0:a1a69d32f310 234 /**
nikapov 0:a1a69d32f310 235 * @brief Stop the currently running measure indicate by operating_mode
nikapov 0:a1a69d32f310 236 * @param[in] operating_mode specifies requested measure to stop
nikapov 0:a1a69d32f310 237 * @return "0" on success
nikapov 0:a1a69d32f310 238 */
nikapov 0:a1a69d32f310 239 int stop_measurement(OperatingMode operating_mode);
nikapov 0:a1a69d32f310 240
nikapov 0:a1a69d32f310 241 /**
nikapov 0:a1a69d32f310 242 * @brief Interrupt handling func to be called by user after an INT is occourred
nikapov 0:a1a69d32f310 243 * @param[in] opeating_mode indicating the in progress measure
nikapov 0:a1a69d32f310 244 * @param[out] Data pointer to the MeasureData_t structure to read data in to
nikapov 0:a1a69d32f310 245 * @return "0" on success
nikapov 0:a1a69d32f310 246 */
nikapov 0:a1a69d32f310 247 int handle_irq(OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *data);
nikapov 0:a1a69d32f310 248
nikapov 0:a1a69d32f310 249 /**
nikapov 0:a1a69d32f310 250 * @brief Enable interrupt measure IRQ
nikapov 0:a1a69d32f310 251 * @return "0" on success
nikapov 0:a1a69d32f310 252 */
nikapov 0:a1a69d32f310 253 void enable_interrupt_measure_detection_irq(void)
nikapov 0:a1a69d32f310 254 {
nikapov 0:a1a69d32f310 255 if (_gpio1Int != NULL) {
nikapov 0:a1a69d32f310 256 _gpio1Int->enable_irq();
nikapov 0:a1a69d32f310 257 }
nikapov 0:a1a69d32f310 258 }
nikapov 0:a1a69d32f310 259
nikapov 0:a1a69d32f310 260 /**
nikapov 0:a1a69d32f310 261 * @brief Disable interrupt measure IRQ
nikapov 0:a1a69d32f310 262 * @return "0" on success
nikapov 0:a1a69d32f310 263 */
nikapov 0:a1a69d32f310 264 void disable_interrupt_measure_detection_irq(void)
nikapov 0:a1a69d32f310 265 {
nikapov 0:a1a69d32f310 266 if (_gpio1Int != NULL) {
nikapov 0:a1a69d32f310 267 _gpio1Int->disable_irq();
nikapov 0:a1a69d32f310 268 }
nikapov 0:a1a69d32f310 269 }
nikapov 0:a1a69d32f310 270
nikapov 0:a1a69d32f310 271 /**
nikapov 0:a1a69d32f310 272 * @brief Attach a function to call when an interrupt is detected, i.e. measurement is ready
nikapov 0:a1a69d32f310 273 * @param[in] fptr pointer to call back function to be called whenever an interrupt occours
nikapov 0:a1a69d32f310 274 * @return "0" on success
nikapov 0:a1a69d32f310 275 */
nikapov 0:a1a69d32f310 276 void attach_interrupt_measure_detection_irq(void (*fptr)(void))
nikapov 0:a1a69d32f310 277 {
nikapov 0:a1a69d32f310 278 if (_gpio1Int != NULL) {
nikapov 0:a1a69d32f310 279 _gpio1Int->rise(fptr);
nikapov 0:a1a69d32f310 280 }
nikapov 0:a1a69d32f310 281 }
nikapov 0:a1a69d32f310 282
nikapov 0:a1a69d32f310 283 /** Wrapper functions */
nikapov 0:a1a69d32f310 284 /** @defgroup api_init Init functions
nikapov 0:a1a69d32f310 285 * @brief API init functions
nikapov 0:a1a69d32f310 286 * @ingroup api_hl
nikapov 0:a1a69d32f310 287 * @{
nikapov 0:a1a69d32f310 288 */
nikapov 0:a1a69d32f310 289
nikapov 0:a1a69d32f310 290 /**
nikapov 0:a1a69d32f310 291 *
nikapov 0:a1a69d32f310 292 * @brief One time device initialization
nikapov 0:a1a69d32f310 293 *
nikapov 0:a1a69d32f310 294 * To be called once and only once after device is brought out of reset (Chip enable) and booted.
nikapov 0:a1a69d32f310 295 *
nikapov 0:a1a69d32f310 296 * @par Function Description
nikapov 0:a1a69d32f310 297 * When not used after a fresh device "power up" or reset, it may return @a #CALIBRATION_WARNING
nikapov 0:a1a69d32f310 298 * meaning wrong calibration data may have been fetched from device that can result in ranging offset error\n
nikapov 0:a1a69d32f310 299 * If application cannot execute device reset or need to run VL53L0X_data_init multiple time
nikapov 0:a1a69d32f310 300 * then it must ensure proper offset calibration saving and restore on its own
nikapov 0:a1a69d32f310 301 * by using @a VL53L0X_get_offset_calibration_data_micro_meter() on first power up and then @a VL53L0X_set_offset_calibration_data_micro_meter() all all subsequent init
nikapov 0:a1a69d32f310 302 *
nikapov 0:a1a69d32f310 303 * @param void
nikapov 0:a1a69d32f310 304 * @return "0" on success, @a #CALIBRATION_WARNING if failed
nikapov 0:a1a69d32f310 305 */
nikapov 0:a1a69d32f310 306 virtual int init(void *init)
nikapov 0:a1a69d32f310 307 {
nikapov 0:a1a69d32f310 308 return VL53L0X_data_init(_device);
nikapov 0:a1a69d32f310 309 }
nikapov 0:a1a69d32f310 310
nikapov 0:a1a69d32f310 311 /**
nikapov 0:a1a69d32f310 312 * @brief Prepare device for operation
nikapov 0:a1a69d32f310 313 * @par Function Description
nikapov 0:a1a69d32f310 314 * Does static initialization and reprogram common default settings \n
nikapov 0:a1a69d32f310 315 * Device is prepared for new measure, ready single shot ranging or ALS typical polling operation\n
nikapov 0:a1a69d32f310 316 * After prepare user can : \n
nikapov 0:a1a69d32f310 317 * @li Call other API function to set other settings\n
nikapov 0:a1a69d32f310 318 * @li Configure the interrupt pins, etc... \n
nikapov 0:a1a69d32f310 319 * @li Then start ranging or ALS operations in single shot or continuous mode
nikapov 0:a1a69d32f310 320 *
nikapov 0:a1a69d32f310 321 * @param void
nikapov 0:a1a69d32f310 322 * @return "0" on success
nikapov 0:a1a69d32f310 323 */
nikapov 0:a1a69d32f310 324 int prepare()
nikapov 0:a1a69d32f310 325 {
nikapov 0:a1a69d32f310 326 VL53L0X_Error status = VL53L0X_ERROR_NONE;
nikapov 0:a1a69d32f310 327 uint32_t ref_spad_count;
nikapov 0:a1a69d32f310 328 uint8_t is_aperture_spads;
nikapov 0:a1a69d32f310 329 uint8_t vhv_settings;
nikapov 0:a1a69d32f310 330 uint8_t phase_cal;
nikapov 0:a1a69d32f310 331
nikapov 0:a1a69d32f310 332 if (status == VL53L0X_ERROR_NONE) {
nikapov 1:834986cdde0a 333 //printf("Call of VL53L0X_StaticInit\r\n");
nikapov 0:a1a69d32f310 334 status = VL53L0X_static_init(_device); // Device Initialization
nikapov 0:a1a69d32f310 335 }
nikapov 0:a1a69d32f310 336
nikapov 0:a1a69d32f310 337 if (status == VL53L0X_ERROR_NONE) {
nikapov 1:834986cdde0a 338 //printf("Call of VL53L0X_PerformRefCalibration\r\n");
nikapov 0:a1a69d32f310 339 status = VL53L0X_perform_ref_calibration(_device,
nikapov 0:a1a69d32f310 340 &vhv_settings, &phase_cal); // Device Initialization
nikapov 0:a1a69d32f310 341 }
nikapov 0:a1a69d32f310 342
nikapov 0:a1a69d32f310 343 if (status == VL53L0X_ERROR_NONE) {
nikapov 1:834986cdde0a 344 //printf("Call of VL53L0X_PerformRefSpadManagement\r\n");
nikapov 0:a1a69d32f310 345 status = VL53L0X_perform_ref_spad_management(_device,
nikapov 0:a1a69d32f310 346 &ref_spad_count, &is_aperture_spads); // Device Initialization
nikapov 0:a1a69d32f310 347 // printf ("refSpadCount = %d, isApertureSpads = %d\r\n", refSpadCount, isApertureSpads);
nikapov 0:a1a69d32f310 348 }
nikapov 0:a1a69d32f310 349
nikapov 0:a1a69d32f310 350 return status;
nikapov 0:a1a69d32f310 351 }
nikapov 0:a1a69d32f310 352
nikapov 0:a1a69d32f310 353 /**
nikapov 0:a1a69d32f310 354 * @brief Start continuous ranging mode
nikapov 0:a1a69d32f310 355 *
nikapov 0:a1a69d32f310 356 * @details End user should ensure device is in idle state and not already running
nikapov 0:a1a69d32f310 357 * @return "0" on success
nikapov 0:a1a69d32f310 358 */
nikapov 0:a1a69d32f310 359 int range_start_continuous_mode()
nikapov 0:a1a69d32f310 360 {
nikapov 0:a1a69d32f310 361 int status;
nikapov 0:a1a69d32f310 362 status = VL53L0X_set_device_mode(_device, VL53L0X_DEVICEMODE_CONTINUOUS_RANGING);
nikapov 0:a1a69d32f310 363
nikapov 0:a1a69d32f310 364 if (status == VL53L0X_ERROR_NONE) {
nikapov 1:834986cdde0a 365 //printf ("Call of VL53L0X_StartMeasurement\r\n");
nikapov 0:a1a69d32f310 366 status = VL53L0X_start_measurement(_device);
nikapov 0:a1a69d32f310 367 }
nikapov 0:a1a69d32f310 368
nikapov 0:a1a69d32f310 369 return status;
nikapov 0:a1a69d32f310 370 }
nikapov 0:a1a69d32f310 371
nikapov 0:a1a69d32f310 372 /**
nikapov 0:a1a69d32f310 373 * @brief Get ranging result and only that
nikapov 0:a1a69d32f310 374 *
nikapov 0:a1a69d32f310 375 * @par Function Description
nikapov 0:a1a69d32f310 376 * Unlike @a VL53L0X_get_ranging_measurement_data() this function only retrieves the range in millimeter \n
nikapov 0:a1a69d32f310 377 * It does any required up-scale translation\n
nikapov 0:a1a69d32f310 378 * It can be called after success status polling or in interrupt mode \n
nikapov 0:a1a69d32f310 379 * @warning these function is not doing wrap around filtering \n
nikapov 0:a1a69d32f310 380 * This function doesn't perform any data ready check!
nikapov 0:a1a69d32f310 381 *
nikapov 0:a1a69d32f310 382 * @param p_data Pointer to range distance
nikapov 0:a1a69d32f310 383 * @return "0" on success
nikapov 0:a1a69d32f310 384 */
nikapov 0:a1a69d32f310 385 virtual int get_distance(uint32_t *p_data)
nikapov 0:a1a69d32f310 386 {
nikapov 0:a1a69d32f310 387 int status = 0;
nikapov 0:a1a69d32f310 388 VL53L0X_RangingMeasurementData_t p_ranging_measurement_data;
nikapov 0:a1a69d32f310 389
nikapov 0:a1a69d32f310 390 status = start_measurement(range_single_shot_polling, NULL);
nikapov 0:a1a69d32f310 391 if (!status) {
nikapov 0:a1a69d32f310 392 status = get_measurement(range_single_shot_polling, &p_ranging_measurement_data);
nikapov 0:a1a69d32f310 393 }
nikapov 0:a1a69d32f310 394 if (p_ranging_measurement_data.RangeStatus == 0) {
nikapov 0:a1a69d32f310 395 // we have a valid range.
nikapov 0:a1a69d32f310 396 *p_data = p_ranging_measurement_data.RangeMilliMeter;
nikapov 0:a1a69d32f310 397 } else {
nikapov 0:a1a69d32f310 398 *p_data = 0;
nikapov 0:a1a69d32f310 399 status = VL53L0X_ERROR_RANGE_ERROR;
nikapov 0:a1a69d32f310 400 }
nikapov 0:a1a69d32f310 401 stop_measurement(range_single_shot_polling);
nikapov 0:a1a69d32f310 402 return status;
nikapov 0:a1a69d32f310 403 }
nikapov 0:a1a69d32f310 404
nikapov 0:a1a69d32f310 405 /** @} */
nikapov 0:a1a69d32f310 406
nikapov 0:a1a69d32f310 407 /**
nikapov 0:a1a69d32f310 408 * @brief Set new device i2c address
nikapov 0:a1a69d32f310 409 *
nikapov 0:a1a69d32f310 410 * After completion the device will answer to the new address programmed.
nikapov 0:a1a69d32f310 411 *
nikapov 0:a1a69d32f310 412 * @param new_addr The new i2c address (7bit)
nikapov 0:a1a69d32f310 413 * @return "0" on success
nikapov 0:a1a69d32f310 414 */
nikapov 0:a1a69d32f310 415 int set_device_address(int new_addr)
nikapov 0:a1a69d32f310 416 {
nikapov 0:a1a69d32f310 417 int status;
nikapov 0:a1a69d32f310 418
nikapov 0:a1a69d32f310 419 status = VL53L0X_set_device_address(_device, new_addr);
nikapov 0:a1a69d32f310 420 if (!status) {
nikapov 0:a1a69d32f310 421 _device->I2cDevAddr = new_addr;
nikapov 0:a1a69d32f310 422 }
nikapov 0:a1a69d32f310 423 return status;
nikapov 0:a1a69d32f310 424
nikapov 0:a1a69d32f310 425 }
nikapov 0:a1a69d32f310 426
nikapov 0:a1a69d32f310 427 /**
nikapov 0:a1a69d32f310 428 * @brief Clear given system interrupt condition
nikapov 0:a1a69d32f310 429 *
nikapov 0:a1a69d32f310 430 * @par Function Description
nikapov 0:a1a69d32f310 431 * Clear given interrupt cause by writing into register #SYSTEM_INTERRUPT_CLEAR register.
nikapov 0:a1a69d32f310 432 * @param dev The device
nikapov 0:a1a69d32f310 433 * @param int_clear Which interrupt source to clear. Use any combinations of #INTERRUPT_CLEAR_RANGING , #INTERRUPT_CLEAR_ALS , #INTERRUPT_CLEAR_ERROR.
nikapov 0:a1a69d32f310 434 * @return "0" on success
nikapov 0:a1a69d32f310 435 */
nikapov 0:a1a69d32f310 436 int clear_interrupt(uint8_t int_clear)
nikapov 0:a1a69d32f310 437 {
nikapov 0:a1a69d32f310 438 return VL53L0X_clear_interrupt_mask(_device, int_clear);
nikapov 0:a1a69d32f310 439 }
nikapov 0:a1a69d32f310 440
nikapov 0:a1a69d32f310 441 /**
nikapov 0:a1a69d32f310 442 *
mapellil 4:d25c4fa216af 443 * @brief Get the 53L0 device
mapellil 4:d25c4fa216af 444 *
mapellil 4:d25c4fa216af 445 * To be called to retrive the internal device descriptor to allow usage of
mapellil 4:d25c4fa216af 446 * low level API having device as parameter. To be called after set_device_address()
mapellil 4:d25c4fa216af 447 * (if any).
mapellil 4:d25c4fa216af 448 *
mapellil 4:d25c4fa216af 449 * @par Function Description
mapellil 4:d25c4fa216af 450 * To be called if low level API usage is needed as those functions requires
mapellil 4:d25c4fa216af 451 * device as a parameter.TICINIT.
mapellil 4:d25c4fa216af 452 *
mapellil 4:d25c4fa216af 453 * @note This function return a pointer to an object internal structure
mapellil 4:d25c4fa216af 454 *
mapellil 4:d25c4fa216af 455 * @param dev ptr to ptr to Device Handle
mapellil 4:d25c4fa216af 456 * @return VL53L0X_ERROR_NONE Success
mapellil 4:d25c4fa216af 457 * @return "Other error code" See ::VL53L0X_Error
mapellil 4:d25c4fa216af 458 */
mapellil 4:d25c4fa216af 459 VL53L0X_Error vl53l0x_get_device(VL53L0X_DEV *dev)
mapellil 4:d25c4fa216af 460 {
mapellil 4:d25c4fa216af 461 *dev = _device;
mapellil 4:d25c4fa216af 462 return VL53L0X_ERROR_NONE;
mapellil 4:d25c4fa216af 463 }
mapellil 4:d25c4fa216af 464
mapellil 4:d25c4fa216af 465 /**
mapellil 4:d25c4fa216af 466 *
nikapov 0:a1a69d32f310 467 * @brief One time device initialization
nikapov 0:a1a69d32f310 468 *
nikapov 0:a1a69d32f310 469 * To be called once and only once after device is brought out of reset
nikapov 0:a1a69d32f310 470 * (Chip enable) and booted see @a VL53L0X_WaitDeviceBooted()
nikapov 0:a1a69d32f310 471 *
nikapov 0:a1a69d32f310 472 * @par Function Description
nikapov 0:a1a69d32f310 473 * When not used after a fresh device "power up" or reset, it may return
nikapov 0:a1a69d32f310 474 * @a #VL53L0X_ERROR_CALIBRATION_WARNING meaning wrong calibration data
nikapov 0:a1a69d32f310 475 * may have been fetched from device that can result in ranging offset error\n
nikapov 0:a1a69d32f310 476 * If application cannot execute device reset or need to run VL53L0X_DataInit
nikapov 0:a1a69d32f310 477 * multiple time then it must ensure proper offset calibration saving and
nikapov 0:a1a69d32f310 478 * restore on its own by using @a VL53L0X_GetOffsetCalibrationData() on first
nikapov 0:a1a69d32f310 479 * power up and then @a VL53L0X_SetOffsetCalibrationData() in all subsequent init
nikapov 0:a1a69d32f310 480 * This function will change the VL53L0X_State from VL53L0X_STATE_POWERDOWN to
nikapov 0:a1a69d32f310 481 * VL53L0X_STATE_WAIT_STATICINIT.
nikapov 0:a1a69d32f310 482 *
nikapov 0:a1a69d32f310 483 * @note This function accesses to the device
nikapov 0:a1a69d32f310 484 *
nikapov 0:a1a69d32f310 485 * @param dev Device Handle
nikapov 0:a1a69d32f310 486 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 487 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 488 */
nikapov 0:a1a69d32f310 489 VL53L0X_Error VL53L0X_data_init(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 490
nikapov 0:a1a69d32f310 491 /**
nikapov 0:a1a69d32f310 492 * @brief Do basic device init (and eventually patch loading)
nikapov 0:a1a69d32f310 493 * This function will change the VL53L0X_State from
nikapov 0:a1a69d32f310 494 * VL53L0X_STATE_WAIT_STATICINIT to VL53L0X_STATE_IDLE.
nikapov 0:a1a69d32f310 495 * In this stage all default setting will be applied.
nikapov 0:a1a69d32f310 496 *
nikapov 0:a1a69d32f310 497 * @note This function Access to the device
nikapov 0:a1a69d32f310 498 *
nikapov 0:a1a69d32f310 499 * @param dev Device Handle
nikapov 0:a1a69d32f310 500 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 501 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 502 */
nikapov 0:a1a69d32f310 503 VL53L0X_Error VL53L0X_static_init(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 504
nikapov 0:a1a69d32f310 505 /**
nikapov 0:a1a69d32f310 506 * @brief Perform Reference Calibration
nikapov 0:a1a69d32f310 507 *
nikapov 0:a1a69d32f310 508 * @details Perform a reference calibration of the Device.
nikapov 0:a1a69d32f310 509 * This function should be run from time to time before doing
nikapov 0:a1a69d32f310 510 * a ranging measurement.
nikapov 0:a1a69d32f310 511 * This function will launch a special ranging measurement, so
nikapov 0:a1a69d32f310 512 * if interrupt are enable an interrupt will be done.
nikapov 0:a1a69d32f310 513 * This function will clear the interrupt generated automatically.
nikapov 0:a1a69d32f310 514 *
nikapov 0:a1a69d32f310 515 * @warning This function is a blocking function
nikapov 0:a1a69d32f310 516 *
nikapov 0:a1a69d32f310 517 * @note This function Access to the device
nikapov 0:a1a69d32f310 518 *
nikapov 0:a1a69d32f310 519 * @param dev Device Handle
nikapov 0:a1a69d32f310 520 * @param p_vhv_settings Pointer to vhv settings parameter.
nikapov 0:a1a69d32f310 521 * @param p_phase_cal Pointer to PhaseCal parameter.
nikapov 0:a1a69d32f310 522 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 523 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 524 */
nikapov 0:a1a69d32f310 525 VL53L0X_Error VL53L0X_perform_ref_calibration(VL53L0X_DEV dev, uint8_t *p_vhv_settings,
nikapov 0:a1a69d32f310 526 uint8_t *p_phase_cal);
nikapov 0:a1a69d32f310 527
nikapov 0:a1a69d32f310 528 /**
nikapov 0:a1a69d32f310 529 * @brief Get Reference Calibration Parameters
nikapov 0:a1a69d32f310 530 *
nikapov 0:a1a69d32f310 531 * @par Function Description
nikapov 0:a1a69d32f310 532 * Get Reference Calibration Parameters.
nikapov 0:a1a69d32f310 533 *
nikapov 0:a1a69d32f310 534 * @note This function Access to the device
nikapov 0:a1a69d32f310 535 *
nikapov 0:a1a69d32f310 536 * @param dev Device Handle
nikapov 0:a1a69d32f310 537 * @param p_vhv_settings Pointer to VHV parameter
nikapov 0:a1a69d32f310 538 * @param p_phase_cal Pointer to PhaseCal Parameter
nikapov 0:a1a69d32f310 539 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 540 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 541 */
nikapov 0:a1a69d32f310 542 VL53L0X_Error VL53L0X_get_ref_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 543 uint8_t *p_vhv_settings, uint8_t *p_phase_cal);
nikapov 0:a1a69d32f310 544
nikapov 0:a1a69d32f310 545 VL53L0X_Error VL53L0X_set_ref_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 546 uint8_t vhv_settings, uint8_t phase_cal);
nikapov 0:a1a69d32f310 547
nikapov 0:a1a69d32f310 548 /**
nikapov 0:a1a69d32f310 549 * @brief Performs Reference Spad Management
nikapov 0:a1a69d32f310 550 *
nikapov 0:a1a69d32f310 551 * @par Function Description
nikapov 0:a1a69d32f310 552 * The reference SPAD initialization procedure determines the minimum amount
nikapov 0:a1a69d32f310 553 * of reference spads to be enables to achieve a target reference signal rate
nikapov 0:a1a69d32f310 554 * and should be performed once during initialization.
nikapov 0:a1a69d32f310 555 *
nikapov 0:a1a69d32f310 556 * @note This function Access to the device
nikapov 0:a1a69d32f310 557 *
nikapov 0:a1a69d32f310 558 * @note This function change the device mode to
nikapov 0:a1a69d32f310 559 * VL53L0X_DEVICEMODE_SINGLE_RANGING
nikapov 0:a1a69d32f310 560 *
nikapov 0:a1a69d32f310 561 * @param dev Device Handle
nikapov 0:a1a69d32f310 562 * @param ref_spad_count Reports ref Spad Count
nikapov 0:a1a69d32f310 563 * @param is_aperture_spads Reports if spads are of type
nikapov 0:a1a69d32f310 564 * aperture or non-aperture.
nikapov 0:a1a69d32f310 565 * 1:=aperture, 0:=Non-Aperture
nikapov 0:a1a69d32f310 566 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 567 * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the Ref Spad procedure.
nikapov 0:a1a69d32f310 568 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 569 */
nikapov 0:a1a69d32f310 570 VL53L0X_Error VL53L0X_perform_ref_spad_management(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 571 uint32_t *ref_spad_count, uint8_t *is_aperture_spads);
nikapov 0:a1a69d32f310 572
nikapov 0:a1a69d32f310 573 /**
nikapov 0:a1a69d32f310 574 * @brief Applies Reference SPAD configuration
nikapov 0:a1a69d32f310 575 *
nikapov 0:a1a69d32f310 576 * @par Function Description
nikapov 0:a1a69d32f310 577 * This function applies a given number of reference spads, identified as
nikapov 0:a1a69d32f310 578 * either Aperture or Non-Aperture.
nikapov 0:a1a69d32f310 579 * The requested spad count and type are stored within the device specific
nikapov 0:a1a69d32f310 580 * parameters data for access by the host.
nikapov 0:a1a69d32f310 581 *
nikapov 0:a1a69d32f310 582 * @note This function Access to the device
nikapov 0:a1a69d32f310 583 *
nikapov 0:a1a69d32f310 584 * @param dev Device Handle
nikapov 0:a1a69d32f310 585 * @param refSpadCount Number of ref spads.
nikapov 0:a1a69d32f310 586 * @param is_aperture_spads Defines if spads are of type
nikapov 0:a1a69d32f310 587 * aperture or non-aperture.
nikapov 0:a1a69d32f310 588 * 1:=aperture, 0:=Non-Aperture
nikapov 0:a1a69d32f310 589 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 590 * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the in the reference
nikapov 0:a1a69d32f310 591 * spad configuration.
nikapov 0:a1a69d32f310 592 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 593 */
nikapov 0:a1a69d32f310 594 VL53L0X_Error VL53L0X_set_reference_spads(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 595 uint32_t refSpadCount, uint8_t is_aperture_spads);
nikapov 0:a1a69d32f310 596
nikapov 0:a1a69d32f310 597 /**
nikapov 0:a1a69d32f310 598 * @brief Retrieves SPAD configuration
nikapov 0:a1a69d32f310 599 *
nikapov 0:a1a69d32f310 600 * @par Function Description
nikapov 0:a1a69d32f310 601 * This function retrieves the current number of applied reference spads
nikapov 0:a1a69d32f310 602 * and also their type : Aperture or Non-Aperture.
nikapov 0:a1a69d32f310 603 *
nikapov 0:a1a69d32f310 604 * @note This function Access to the device
nikapov 0:a1a69d32f310 605 *
nikapov 0:a1a69d32f310 606 * @param dev Device Handle
nikapov 0:a1a69d32f310 607 * @param p_spad_count Number ref Spad Count
nikapov 0:a1a69d32f310 608 * @param p_is_aperture_spads Reports if spads are of type
nikapov 0:a1a69d32f310 609 * aperture or non-aperture.
nikapov 0:a1a69d32f310 610 * 1:=aperture, 0:=Non-Aperture
nikapov 0:a1a69d32f310 611 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 612 * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the in the reference
nikapov 0:a1a69d32f310 613 * spad configuration.
nikapov 0:a1a69d32f310 614 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 615 */
nikapov 0:a1a69d32f310 616 VL53L0X_Error VL53L0X_get_reference_spads(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 617 uint32_t *p_spad_count, uint8_t *p_is_aperture_spads);
nikapov 0:a1a69d32f310 618
nikapov 0:a1a69d32f310 619 /**
nikapov 0:a1a69d32f310 620 * @brief Get part to part calibration offset
nikapov 0:a1a69d32f310 621 *
nikapov 0:a1a69d32f310 622 * @par Function Description
nikapov 0:a1a69d32f310 623 * Should only be used after a successful call to @a VL53L0X_DataInit to backup
nikapov 0:a1a69d32f310 624 * device NVM value
nikapov 0:a1a69d32f310 625 *
nikapov 0:a1a69d32f310 626 * @note This function Access to the device
nikapov 0:a1a69d32f310 627 *
nikapov 0:a1a69d32f310 628 * @param dev Device Handle
nikapov 0:a1a69d32f310 629 * @param p_offset_calibration_data_micro_meter Return part to part
nikapov 0:a1a69d32f310 630 * calibration offset from device (microns)
nikapov 0:a1a69d32f310 631 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 632 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 633 */
nikapov 0:a1a69d32f310 634 VL53L0X_Error VL53L0X_get_offset_calibration_data_micro_meter(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 635 int32_t *p_offset_calibration_data_micro_meter);
nikapov 0:a1a69d32f310 636 /**
nikapov 0:a1a69d32f310 637 * Set or over-hide part to part calibration offset
nikapov 0:a1a69d32f310 638 * \sa VL53L0X_DataInit() VL53L0X_GetOffsetCalibrationDataMicroMeter()
nikapov 0:a1a69d32f310 639 *
nikapov 0:a1a69d32f310 640 * @note This function Access to the device
nikapov 0:a1a69d32f310 641 *
nikapov 0:a1a69d32f310 642 * @param dev Device Handle
nikapov 0:a1a69d32f310 643 * @param p_offset_calibration_data_micro_meter Offset (microns)
nikapov 0:a1a69d32f310 644 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 645 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 646 */
nikapov 0:a1a69d32f310 647 VL53L0X_Error VL53L0X_set_offset_calibration_data_micro_meter(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 648 int32_t offset_calibration_data_micro_meter);
nikapov 0:a1a69d32f310 649
nikapov 0:a1a69d32f310 650 VL53L0X_Error VL53L0X_perform_offset_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 651 FixPoint1616_t cal_distance_milli_meter,
nikapov 0:a1a69d32f310 652 int32_t *p_offset_micro_meter);
nikapov 0:a1a69d32f310 653
nikapov 0:a1a69d32f310 654 VL53L0X_Error VL53L0X_perform_xtalk_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 655 FixPoint1616_t xtalk_cal_distance,
nikapov 0:a1a69d32f310 656 FixPoint1616_t *p_xtalk_compensation_rate_mega_cps);
nikapov 0:a1a69d32f310 657
nikapov 0:a1a69d32f310 658 /**
nikapov 0:a1a69d32f310 659 * @brief Perform XTalk Measurement
nikapov 0:a1a69d32f310 660 *
nikapov 0:a1a69d32f310 661 * @details Measures the current cross talk from glass in front
nikapov 0:a1a69d32f310 662 * of the sensor.
nikapov 0:a1a69d32f310 663 * This functions performs a histogram measurement and uses the results
nikapov 0:a1a69d32f310 664 * to measure the crosstalk. For the function to be successful, there
nikapov 0:a1a69d32f310 665 * must be no target in front of the sensor.
nikapov 0:a1a69d32f310 666 *
nikapov 0:a1a69d32f310 667 * @warning This function is a blocking function
nikapov 0:a1a69d32f310 668 *
nikapov 0:a1a69d32f310 669 * @warning This function is not supported when the final range
nikapov 0:a1a69d32f310 670 * vcsel clock period is set below 10 PCLKS.
nikapov 0:a1a69d32f310 671 *
nikapov 0:a1a69d32f310 672 * @note This function Access to the device
nikapov 0:a1a69d32f310 673 *
nikapov 0:a1a69d32f310 674 * @param dev Device Handle
nikapov 0:a1a69d32f310 675 * @param timeout_ms Histogram measurement duration.
nikapov 0:a1a69d32f310 676 * @param p_xtalk_per_spad Output parameter containing the crosstalk
nikapov 0:a1a69d32f310 677 * measurement result, in MCPS/Spad.
nikapov 0:a1a69d32f310 678 * Format fixpoint 16:16.
nikapov 0:a1a69d32f310 679 * @param p_ambient_too_high Output parameter which indicate that
nikapov 0:a1a69d32f310 680 * pXtalkPerSpad is not good if the Ambient
nikapov 0:a1a69d32f310 681 * is too high.
nikapov 0:a1a69d32f310 682 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 683 * @return VL53L0X_ERROR_INVALID_PARAMS vcsel clock period not supported
nikapov 0:a1a69d32f310 684 * for this operation.
nikapov 0:a1a69d32f310 685 * Must not be less than 10PCLKS.
nikapov 0:a1a69d32f310 686 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 687 */
nikapov 0:a1a69d32f310 688 VL53L0X_Error VL53L0X_perform_xtalk_measurement(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 689 uint32_t timeout_ms, FixPoint1616_t *p_xtalk_per_spad,
nikapov 0:a1a69d32f310 690 uint8_t *p_ambient_too_high);
nikapov 0:a1a69d32f310 691
nikapov 0:a1a69d32f310 692 /**
nikapov 0:a1a69d32f310 693 * @brief Enable/Disable Cross talk compensation feature
nikapov 0:a1a69d32f310 694 *
nikapov 0:a1a69d32f310 695 * @note This function is not Implemented.
nikapov 0:a1a69d32f310 696 * Enable/Disable Cross Talk by set to zero the Cross Talk value
nikapov 0:a1a69d32f310 697 * by using @a VL53L0X_SetXTalkCompensationRateMegaCps().
nikapov 0:a1a69d32f310 698 *
nikapov 0:a1a69d32f310 699 * @param dev Device Handle
nikapov 0:a1a69d32f310 700 * @param x_talk_compensation_enable Cross talk compensation
nikapov 0:a1a69d32f310 701 * to be set 0=disabled else = enabled
nikapov 0:a1a69d32f310 702 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
nikapov 0:a1a69d32f310 703 */
nikapov 0:a1a69d32f310 704 VL53L0X_Error VL53L0X_set_x_talk_compensation_enable(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 705 uint8_t x_talk_compensation_enable);
nikapov 0:a1a69d32f310 706
nikapov 0:a1a69d32f310 707 /**
nikapov 0:a1a69d32f310 708 * @brief Get Cross talk compensation rate
nikapov 0:a1a69d32f310 709 *
nikapov 0:a1a69d32f310 710 * @note This function is not Implemented.
nikapov 0:a1a69d32f310 711 * Enable/Disable Cross Talk by set to zero the Cross Talk value by
nikapov 0:a1a69d32f310 712 * using @a VL53L0X_SetXTalkCompensationRateMegaCps().
nikapov 0:a1a69d32f310 713 *
nikapov 0:a1a69d32f310 714 * @param dev Device Handle
nikapov 0:a1a69d32f310 715 * @param p_x_talk_compensation_enable Pointer to the Cross talk compensation
nikapov 0:a1a69d32f310 716 * state 0=disabled or 1 = enabled
nikapov 0:a1a69d32f310 717 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
nikapov 0:a1a69d32f310 718 */
nikapov 0:a1a69d32f310 719 VL53L0X_Error VL53L0X_get_x_talk_compensation_enable(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 720 uint8_t *p_x_talk_compensation_enable);
nikapov 0:a1a69d32f310 721 /**
nikapov 0:a1a69d32f310 722 * @brief Set Cross talk compensation rate
nikapov 0:a1a69d32f310 723 *
nikapov 0:a1a69d32f310 724 * @par Function Description
nikapov 0:a1a69d32f310 725 * Set Cross talk compensation rate.
nikapov 0:a1a69d32f310 726 *
nikapov 0:a1a69d32f310 727 * @note This function Access to the device
nikapov 0:a1a69d32f310 728 *
nikapov 0:a1a69d32f310 729 * @param dev Device Handle
nikapov 0:a1a69d32f310 730 * @param x_talk_compensation_rate_mega_cps Compensation rate in
nikapov 0:a1a69d32f310 731 * Mega counts per second
nikapov 0:a1a69d32f310 732 * (16.16 fix point) see
nikapov 0:a1a69d32f310 733 * datasheet for details
nikapov 0:a1a69d32f310 734 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 735 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 736 */
nikapov 0:a1a69d32f310 737 VL53L0X_Error VL53L0X_set_x_talk_compensation_rate_mega_cps(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 738 FixPoint1616_t x_talk_compensation_rate_mega_cps);
nikapov 0:a1a69d32f310 739
nikapov 0:a1a69d32f310 740 /**
nikapov 0:a1a69d32f310 741 * @brief Get Cross talk compensation rate
nikapov 0:a1a69d32f310 742 *
nikapov 0:a1a69d32f310 743 * @par Function Description
nikapov 0:a1a69d32f310 744 * Get Cross talk compensation rate.
nikapov 0:a1a69d32f310 745 *
nikapov 0:a1a69d32f310 746 * @note This function Access to the device
nikapov 0:a1a69d32f310 747 *
nikapov 0:a1a69d32f310 748 * @param dev Device Handle
nikapov 0:a1a69d32f310 749 * @param p_xtalk_compensation_rate_mega_cps Pointer to Compensation rate
nikapov 0:a1a69d32f310 750 * in Mega counts per second
nikapov 0:a1a69d32f310 751 * (16.16 fix point) see
nikapov 0:a1a69d32f310 752 * datasheet for details
nikapov 0:a1a69d32f310 753 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 754 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 755 */
nikapov 0:a1a69d32f310 756 VL53L0X_Error VL53L0X_get_x_talk_compensation_rate_mega_cps(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 757 FixPoint1616_t *p_xtalk_compensation_rate_mega_cps);
nikapov 0:a1a69d32f310 758
nikapov 0:a1a69d32f310 759 /**
nikapov 0:a1a69d32f310 760 * @brief Set a new device mode
nikapov 0:a1a69d32f310 761 * @par Function Description
nikapov 0:a1a69d32f310 762 * Set device to a new mode (ranging, histogram ...)
nikapov 0:a1a69d32f310 763 *
nikapov 0:a1a69d32f310 764 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 765 *
nikapov 0:a1a69d32f310 766 * @param dev Device Handle
nikapov 0:a1a69d32f310 767 * @param device_mode New device mode to apply
nikapov 0:a1a69d32f310 768 * Valid values are:
nikapov 0:a1a69d32f310 769 * VL53L0X_DEVICEMODE_SINGLE_RANGING
nikapov 0:a1a69d32f310 770 * VL53L0X_DEVICEMODE_CONTINUOUS_RANGING
nikapov 0:a1a69d32f310 771 * VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING
nikapov 0:a1a69d32f310 772 * VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM
nikapov 0:a1a69d32f310 773 * VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY
nikapov 0:a1a69d32f310 774 * VL53L0X_HISTOGRAMMODE_RETURN_ONLY
nikapov 0:a1a69d32f310 775 * VL53L0X_HISTOGRAMMODE_BOTH
nikapov 0:a1a69d32f310 776 *
nikapov 0:a1a69d32f310 777 *
nikapov 0:a1a69d32f310 778 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 779 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when
nikapov 0:a1a69d32f310 780 * DeviceMode is not in the
nikapov 0:a1a69d32f310 781 * supported list
nikapov 0:a1a69d32f310 782 */
nikapov 0:a1a69d32f310 783 VL53L0X_Error VL53L0X_set_device_mode(VL53L0X_DEV dev, VL53L0X_DeviceModes device_mode);
nikapov 0:a1a69d32f310 784
nikapov 0:a1a69d32f310 785 /**
nikapov 0:a1a69d32f310 786 * @brief Get current new device mode
nikapov 0:a1a69d32f310 787 * @par Function Description
nikapov 0:a1a69d32f310 788 * Get actual mode of the device(ranging, histogram ...)
nikapov 0:a1a69d32f310 789 *
nikapov 0:a1a69d32f310 790 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 791 *
nikapov 0:a1a69d32f310 792 * @param dev Device Handle
nikapov 0:a1a69d32f310 793 * @param p_device_mode Pointer to current apply mode value
nikapov 0:a1a69d32f310 794 * Valid values are:
nikapov 0:a1a69d32f310 795 * VL53L0X_DEVICEMODE_SINGLE_RANGING
nikapov 0:a1a69d32f310 796 * VL53L0X_DEVICEMODE_CONTINUOUS_RANGING
nikapov 0:a1a69d32f310 797 * VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING
nikapov 0:a1a69d32f310 798 * VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM
nikapov 0:a1a69d32f310 799 * VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY
nikapov 0:a1a69d32f310 800 * VL53L0X_HISTOGRAMMODE_RETURN_ONLY
nikapov 0:a1a69d32f310 801 * VL53L0X_HISTOGRAMMODE_BOTH
nikapov 0:a1a69d32f310 802 *
nikapov 0:a1a69d32f310 803 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 804 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when
nikapov 0:a1a69d32f310 805 * DeviceMode is not in the
nikapov 0:a1a69d32f310 806 * supported list
nikapov 0:a1a69d32f310 807 */
nikapov 0:a1a69d32f310 808 VL53L0X_Error VL53L0X_get_device_mode(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 809 VL53L0X_DeviceModes *p_device_mode);
nikapov 0:a1a69d32f310 810
nikapov 0:a1a69d32f310 811 /**
nikapov 0:a1a69d32f310 812 * @brief Get current configuration for GPIO pin for a given device
nikapov 0:a1a69d32f310 813 *
nikapov 0:a1a69d32f310 814 * @note This function Access to the device
nikapov 0:a1a69d32f310 815 *
nikapov 0:a1a69d32f310 816 * @param dev Device Handle
nikapov 0:a1a69d32f310 817 * @param pin ID of the GPIO Pin
nikapov 0:a1a69d32f310 818 * @param p_device_mode Pointer to Device Mode associated to the Gpio.
nikapov 0:a1a69d32f310 819 * @param p_functionality Pointer to Pin functionality.
nikapov 0:a1a69d32f310 820 * Refer to ::VL53L0X_GpioFunctionality
nikapov 0:a1a69d32f310 821 * @param p_polarity Pointer to interrupt polarity.
nikapov 0:a1a69d32f310 822 * Active high or active low see
nikapov 0:a1a69d32f310 823 * ::VL53L0X_InterruptPolarity
nikapov 0:a1a69d32f310 824 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 825 * @return VL53L0X_ERROR_GPIO_NOT_EXISTING Only Pin=0 is accepted.
nikapov 0:a1a69d32f310 826 * @return VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED
nikapov 0:a1a69d32f310 827 * This error occurs
nikapov 0:a1a69d32f310 828 * when Funcionality programmed is not in the supported list:
nikapov 0:a1a69d32f310 829 * Supported value are:
nikapov 0:a1a69d32f310 830 * VL53L0X_GPIOFUNCTIONALITY_OFF,
nikapov 0:a1a69d32f310 831 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW,
nikapov 0:a1a69d32f310 832 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH,
nikapov 0:a1a69d32f310 833 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT,
nikapov 0:a1a69d32f310 834 * VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY
nikapov 0:a1a69d32f310 835 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 836 */
nikapov 0:a1a69d32f310 837 VL53L0X_Error VL53L0X_get_gpio_config(VL53L0X_DEV dev, uint8_t pin,
nikapov 0:a1a69d32f310 838 VL53L0X_DeviceModes *p_device_mode,
nikapov 0:a1a69d32f310 839 VL53L0X_GpioFunctionality *p_functionality,
nikapov 0:a1a69d32f310 840 VL53L0X_InterruptPolarity *p_polarity);
nikapov 0:a1a69d32f310 841
nikapov 0:a1a69d32f310 842 /**
nikapov 0:a1a69d32f310 843 * @brief Set the configuration of GPIO pin for a given device
nikapov 0:a1a69d32f310 844 *
nikapov 0:a1a69d32f310 845 * @note This function Access to the device
nikapov 0:a1a69d32f310 846 *
nikapov 0:a1a69d32f310 847 * @param dev Device Handle
nikapov 0:a1a69d32f310 848 * @param pin ID of the GPIO Pin
nikapov 0:a1a69d32f310 849 * @param functionality Select Pin functionality.
nikapov 0:a1a69d32f310 850 * Refer to ::VL53L0X_GpioFunctionality
nikapov 0:a1a69d32f310 851 * @param device_mode Device Mode associated to the Gpio.
nikapov 0:a1a69d32f310 852 * @param polarity Set interrupt polarity. Active high
nikapov 0:a1a69d32f310 853 * or active low see ::VL53L0X_InterruptPolarity
nikapov 0:a1a69d32f310 854 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 855 * @return VL53L0X_ERROR_GPIO_NOT_EXISTING Only Pin=0 is accepted.
nikapov 0:a1a69d32f310 856 * @return VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED This error occurs
nikapov 0:a1a69d32f310 857 * when Functionality programmed is not in the supported list:
nikapov 0:a1a69d32f310 858 * Supported value are:
nikapov 0:a1a69d32f310 859 * VL53L0X_GPIOFUNCTIONALITY_OFF,
nikapov 0:a1a69d32f310 860 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW,
nikapov 0:a1a69d32f310 861 * VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH,
nikapov 0:a1a69d32f310 862 VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT,
nikapov 0:a1a69d32f310 863 * VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY
nikapov 0:a1a69d32f310 864 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 865 */
nikapov 0:a1a69d32f310 866 VL53L0X_Error VL53L0X_set_gpio_config(VL53L0X_DEV dev, uint8_t pin,
nikapov 0:a1a69d32f310 867 VL53L0X_DeviceModes device_mode, VL53L0X_GpioFunctionality functionality,
nikapov 0:a1a69d32f310 868 VL53L0X_InterruptPolarity polarity);
nikapov 0:a1a69d32f310 869
nikapov 0:a1a69d32f310 870 /**
nikapov 0:a1a69d32f310 871 * @brief Start device measurement
nikapov 0:a1a69d32f310 872 *
nikapov 0:a1a69d32f310 873 * @details Started measurement will depend on device parameters set through
nikapov 0:a1a69d32f310 874 * @a VL53L0X_SetParameters()
nikapov 0:a1a69d32f310 875 * This is a non-blocking function.
nikapov 0:a1a69d32f310 876 * This function will change the VL53L0X_State from VL53L0X_STATE_IDLE to
nikapov 0:a1a69d32f310 877 * VL53L0X_STATE_RUNNING.
nikapov 0:a1a69d32f310 878 *
nikapov 0:a1a69d32f310 879 * @note This function Access to the device
nikapov 0:a1a69d32f310 880 *
nikapov 0:a1a69d32f310 881
nikapov 0:a1a69d32f310 882 * @param dev Device Handle
nikapov 0:a1a69d32f310 883 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 884 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when
nikapov 0:a1a69d32f310 885 * DeviceMode programmed with @a VL53L0X_SetDeviceMode is not in the supported
nikapov 0:a1a69d32f310 886 * list:
nikapov 0:a1a69d32f310 887 * Supported mode are:
nikapov 0:a1a69d32f310 888 * VL53L0X_DEVICEMODE_SINGLE_RANGING,
nikapov 0:a1a69d32f310 889 * VL53L0X_DEVICEMODE_CONTINUOUS_RANGING,
nikapov 0:a1a69d32f310 890 * VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING
nikapov 0:a1a69d32f310 891 * @return VL53L0X_ERROR_TIME_OUT Time out on start measurement
nikapov 0:a1a69d32f310 892 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 893 */
nikapov 0:a1a69d32f310 894 VL53L0X_Error VL53L0X_start_measurement(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 895
nikapov 0:a1a69d32f310 896 /**
nikapov 0:a1a69d32f310 897 * @brief Stop device measurement
nikapov 0:a1a69d32f310 898 *
nikapov 0:a1a69d32f310 899 * @details Will set the device in standby mode at end of current measurement\n
nikapov 0:a1a69d32f310 900 * Not necessary in single mode as device shall return automatically
nikapov 0:a1a69d32f310 901 * in standby mode at end of measurement.
nikapov 0:a1a69d32f310 902 * This function will change the VL53L0X_State from VL53L0X_STATE_RUNNING
nikapov 0:a1a69d32f310 903 * to VL53L0X_STATE_IDLE.
nikapov 0:a1a69d32f310 904 *
nikapov 0:a1a69d32f310 905 * @note This function Access to the device
nikapov 0:a1a69d32f310 906 *
nikapov 0:a1a69d32f310 907 * @param dev Device Handle
nikapov 0:a1a69d32f310 908 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 909 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 910 */
nikapov 0:a1a69d32f310 911 VL53L0X_Error VL53L0X_stop_measurement(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 912
nikapov 0:a1a69d32f310 913 /**
nikapov 0:a1a69d32f310 914 * @brief Return device stop completion status
nikapov 0:a1a69d32f310 915 *
nikapov 0:a1a69d32f310 916 * @par Function Description
nikapov 0:a1a69d32f310 917 * Returns stop completiob status.
nikapov 0:a1a69d32f310 918 * User shall call this function after a stop command
nikapov 0:a1a69d32f310 919 *
nikapov 0:a1a69d32f310 920 * @note This function Access to the device
nikapov 0:a1a69d32f310 921 *
nikapov 0:a1a69d32f310 922 * @param dev Device Handle
nikapov 0:a1a69d32f310 923 * @param p_stop_status Pointer to status variable to update
nikapov 0:a1a69d32f310 924 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 925 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 926 */
nikapov 0:a1a69d32f310 927 VL53L0X_Error VL53L0X_get_stop_completed_status(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 928 uint32_t *p_stop_status);
nikapov 0:a1a69d32f310 929
nikapov 0:a1a69d32f310 930 /**
nikapov 0:a1a69d32f310 931 * @brief Return Measurement Data Ready
nikapov 0:a1a69d32f310 932 *
nikapov 0:a1a69d32f310 933 * @par Function Description
nikapov 0:a1a69d32f310 934 * This function indicate that a measurement data is ready.
nikapov 0:a1a69d32f310 935 * This function check if interrupt mode is used then check is done accordingly.
nikapov 0:a1a69d32f310 936 * If perform function clear the interrupt, this function will not work,
nikapov 0:a1a69d32f310 937 * like in case of @a VL53L0X_PerformSingleRangingMeasurement().
nikapov 0:a1a69d32f310 938 * The previous function is blocking function, VL53L0X_GetMeasurementDataReady
nikapov 0:a1a69d32f310 939 * is used for non-blocking capture.
nikapov 0:a1a69d32f310 940 *
nikapov 0:a1a69d32f310 941 * @note This function Access to the device
nikapov 0:a1a69d32f310 942 *
nikapov 0:a1a69d32f310 943 * @param dev Device Handle
nikapov 0:a1a69d32f310 944 * @param p_measurement_data_ready Pointer to Measurement Data Ready.
nikapov 0:a1a69d32f310 945 * 0=data not ready, 1 = data ready
nikapov 0:a1a69d32f310 946 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 947 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 948 */
nikapov 0:a1a69d32f310 949 VL53L0X_Error VL53L0X_get_measurement_data_ready(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 950 uint8_t *p_measurement_data_ready);
nikapov 0:a1a69d32f310 951
nikapov 0:a1a69d32f310 952 /**
nikapov 0:a1a69d32f310 953 * @brief Retrieve the measurements from device for a given setup
nikapov 0:a1a69d32f310 954 *
nikapov 0:a1a69d32f310 955 * @par Function Description
nikapov 0:a1a69d32f310 956 * Get data from last successful Ranging measurement
nikapov 0:a1a69d32f310 957 * @warning USER should take care about @a VL53L0X_GetNumberOfROIZones()
nikapov 0:a1a69d32f310 958 * before get data.
nikapov 0:a1a69d32f310 959 * PAL will fill a NumberOfROIZones times the corresponding data
nikapov 0:a1a69d32f310 960 * structure used in the measurement function.
nikapov 0:a1a69d32f310 961 *
nikapov 0:a1a69d32f310 962 * @note This function Access to the device
nikapov 0:a1a69d32f310 963 *
nikapov 0:a1a69d32f310 964 * @param dev Device Handle
nikapov 0:a1a69d32f310 965 * @param p_ranging_measurement_data Pointer to the data structure to fill up.
nikapov 0:a1a69d32f310 966 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 967 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 968 */
nikapov 0:a1a69d32f310 969 VL53L0X_Error VL53L0X_get_ranging_measurement_data(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 970 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data);
nikapov 0:a1a69d32f310 971
nikapov 0:a1a69d32f310 972 /**
nikapov 0:a1a69d32f310 973 * @brief Clear given system interrupt condition
nikapov 0:a1a69d32f310 974 *
nikapov 0:a1a69d32f310 975 * @par Function Description
nikapov 0:a1a69d32f310 976 * Clear given interrupt(s).
nikapov 0:a1a69d32f310 977 *
nikapov 0:a1a69d32f310 978 * @note This function Access to the device
nikapov 0:a1a69d32f310 979 *
nikapov 0:a1a69d32f310 980 * @param dev Device Handle
nikapov 0:a1a69d32f310 981 * @param interrupt_mask Mask of interrupts to clear
nikapov 0:a1a69d32f310 982 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 983 * @return VL53L0X_ERROR_INTERRUPT_NOT_CLEARED Cannot clear interrupts
nikapov 0:a1a69d32f310 984 *
nikapov 0:a1a69d32f310 985 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 986 */
nikapov 0:a1a69d32f310 987 VL53L0X_Error VL53L0X_clear_interrupt_mask(VL53L0X_DEV dev, uint32_t interrupt_mask);
nikapov 0:a1a69d32f310 988
nikapov 0:a1a69d32f310 989 /**
nikapov 0:a1a69d32f310 990 * @brief Return device interrupt status
nikapov 0:a1a69d32f310 991 *
nikapov 0:a1a69d32f310 992 * @par Function Description
nikapov 0:a1a69d32f310 993 * Returns currently raised interrupts by the device.
nikapov 0:a1a69d32f310 994 * User shall be able to activate/deactivate interrupts through
nikapov 0:a1a69d32f310 995 * @a VL53L0X_SetGpioConfig()
nikapov 0:a1a69d32f310 996 *
nikapov 0:a1a69d32f310 997 * @note This function Access to the device
nikapov 0:a1a69d32f310 998 *
nikapov 0:a1a69d32f310 999 * @param dev Device Handle
nikapov 0:a1a69d32f310 1000 * @param p_interrupt_mask_status Pointer to status variable to update
nikapov 0:a1a69d32f310 1001 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1002 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1003 */
nikapov 0:a1a69d32f310 1004 VL53L0X_Error VL53L0X_get_interrupt_mask_status(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1005 uint32_t *p_interrupt_mask_status);
nikapov 0:a1a69d32f310 1006
nikapov 0:a1a69d32f310 1007 /**
nikapov 0:a1a69d32f310 1008 * @brief Performs a single ranging measurement and retrieve the ranging
nikapov 0:a1a69d32f310 1009 * measurement data
nikapov 0:a1a69d32f310 1010 *
nikapov 0:a1a69d32f310 1011 * @par Function Description
nikapov 0:a1a69d32f310 1012 * This function will change the device mode to VL53L0X_DEVICEMODE_SINGLE_RANGING
nikapov 0:a1a69d32f310 1013 * with @a VL53L0X_SetDeviceMode(),
nikapov 0:a1a69d32f310 1014 * It performs measurement with @a VL53L0X_PerformSingleMeasurement()
nikapov 0:a1a69d32f310 1015 * It get data from last successful Ranging measurement with
nikapov 0:a1a69d32f310 1016 * @a VL53L0X_GetRangingMeasurementData.
nikapov 0:a1a69d32f310 1017 * Finally it clear the interrupt with @a VL53L0X_ClearInterruptMask().
nikapov 0:a1a69d32f310 1018 *
nikapov 0:a1a69d32f310 1019 * @note This function Access to the device
nikapov 0:a1a69d32f310 1020 *
nikapov 0:a1a69d32f310 1021 * @note This function change the device mode to
nikapov 0:a1a69d32f310 1022 * VL53L0X_DEVICEMODE_SINGLE_RANGING
nikapov 0:a1a69d32f310 1023 *
nikapov 0:a1a69d32f310 1024 * @param dev Device Handle
nikapov 0:a1a69d32f310 1025 * @param p_ranging_measurement_data Pointer to the data structure to fill up.
nikapov 0:a1a69d32f310 1026 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1027 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1028 */
nikapov 0:a1a69d32f310 1029 VL53L0X_Error VL53L0X_perform_single_ranging_measurement(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1030 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data);
nikapov 0:a1a69d32f310 1031
nikapov 0:a1a69d32f310 1032 /**
nikapov 0:a1a69d32f310 1033 * @brief Single shot measurement.
nikapov 0:a1a69d32f310 1034 *
nikapov 0:a1a69d32f310 1035 * @par Function Description
nikapov 0:a1a69d32f310 1036 * Perform simple measurement sequence (Start measure, Wait measure to end,
nikapov 0:a1a69d32f310 1037 * and returns when measurement is done).
nikapov 0:a1a69d32f310 1038 * Once function returns, user can get valid data by calling
nikapov 0:a1a69d32f310 1039 * VL53L0X_GetRangingMeasurement or VL53L0X_GetHistogramMeasurement
nikapov 0:a1a69d32f310 1040 * depending on defined measurement mode
nikapov 0:a1a69d32f310 1041 * User should Clear the interrupt in case this are enabled by using the
nikapov 0:a1a69d32f310 1042 * function VL53L0X_ClearInterruptMask().
nikapov 0:a1a69d32f310 1043 *
nikapov 0:a1a69d32f310 1044 * @warning This function is a blocking function
nikapov 0:a1a69d32f310 1045 *
nikapov 0:a1a69d32f310 1046 * @note This function Access to the device
nikapov 0:a1a69d32f310 1047 *
nikapov 0:a1a69d32f310 1048 * @param dev Device Handle
nikapov 0:a1a69d32f310 1049 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1050 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1051 */
nikapov 0:a1a69d32f310 1052 VL53L0X_Error VL53L0X_perform_single_measurement(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1053
nikapov 0:a1a69d32f310 1054 /**
nikapov 0:a1a69d32f310 1055 * @brief Read current status of the error register for the selected device
nikapov 0:a1a69d32f310 1056 *
nikapov 0:a1a69d32f310 1057 * @note This function Access to the device
nikapov 0:a1a69d32f310 1058 *
nikapov 0:a1a69d32f310 1059 * @param dev Device Handle
nikapov 0:a1a69d32f310 1060 * @param p_device_error_status Pointer to current error code of the device
nikapov 0:a1a69d32f310 1061 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1062 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1063 */
nikapov 0:a1a69d32f310 1064 VL53L0X_Error VL53L0X_get_device_error_status(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1065 VL53L0X_DeviceError *p_device_error_status);
nikapov 0:a1a69d32f310 1066
nikapov 0:a1a69d32f310 1067 /**
nikapov 0:a1a69d32f310 1068 * @brief Human readable error string for a given Error Code
nikapov 0:a1a69d32f310 1069 *
nikapov 0:a1a69d32f310 1070 * @note This function doesn't access to the device
nikapov 0:a1a69d32f310 1071 *
nikapov 0:a1a69d32f310 1072 * @param error_code The error code as stored on ::VL53L0X_DeviceError
nikapov 0:a1a69d32f310 1073 * @param p_device_error_string The error string corresponding to the ErrorCode
nikapov 0:a1a69d32f310 1074 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1075 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1076 */
nikapov 0:a1a69d32f310 1077 VL53L0X_Error VL53L0X_get_device_error_string(
nikapov 0:a1a69d32f310 1078 VL53L0X_DeviceError error_code, char *p_device_error_string);
nikapov 0:a1a69d32f310 1079
nikapov 0:a1a69d32f310 1080 /**
nikapov 0:a1a69d32f310 1081 * @brief Human readable Range Status string for a given RangeStatus
nikapov 0:a1a69d32f310 1082 *
nikapov 0:a1a69d32f310 1083 * @note This function doesn't access to the device
nikapov 0:a1a69d32f310 1084 *
nikapov 0:a1a69d32f310 1085 * @param range_status The RangeStatus code as stored on
nikapov 0:a1a69d32f310 1086 * @a VL53L0X_RangingMeasurementData_t
nikapov 0:a1a69d32f310 1087 * @param p_range_status_string The returned RangeStatus string.
nikapov 0:a1a69d32f310 1088 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1089 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1090 */
nikapov 0:a1a69d32f310 1091 VL53L0X_Error VL53L0X_get_range_status_string(uint8_t range_status,
nikapov 0:a1a69d32f310 1092 char *p_range_status_string);
nikapov 0:a1a69d32f310 1093
nikapov 0:a1a69d32f310 1094 VL53L0X_Error VL53L0X_get_total_signal_rate(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1095 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
nikapov 0:a1a69d32f310 1096 FixPoint1616_t *p_total_signal_rate_mcps);
nikapov 0:a1a69d32f310 1097
nikapov 0:a1a69d32f310 1098 VL53L0X_Error VL53L0X_get_total_xtalk_rate(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1099 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
nikapov 0:a1a69d32f310 1100 FixPoint1616_t *p_total_xtalk_rate_mcps);
nikapov 0:a1a69d32f310 1101
nikapov 0:a1a69d32f310 1102 /**
nikapov 0:a1a69d32f310 1103 * @brief Get Ranging Timing Budget in microseconds
nikapov 0:a1a69d32f310 1104 *
nikapov 0:a1a69d32f310 1105 * @par Function Description
nikapov 0:a1a69d32f310 1106 * Returns the programmed the maximum time allowed by the user to the
nikapov 0:a1a69d32f310 1107 * device to run a full ranging sequence for the current mode
nikapov 0:a1a69d32f310 1108 * (ranging, histogram, ASL ...)
nikapov 0:a1a69d32f310 1109 *
nikapov 0:a1a69d32f310 1110 * @note This function Access to the device
nikapov 0:a1a69d32f310 1111 *
nikapov 0:a1a69d32f310 1112 * @param dev Device Handle
nikapov 0:a1a69d32f310 1113 * @param p_measurement_timing_budget_micro_seconds Max measurement time in
nikapov 0:a1a69d32f310 1114 * microseconds.
nikapov 0:a1a69d32f310 1115 * Valid values are:
nikapov 0:a1a69d32f310 1116 * >= 17000 microsecs when wraparound enabled
nikapov 0:a1a69d32f310 1117 * >= 12000 microsecs when wraparound disabled
nikapov 0:a1a69d32f310 1118 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1119 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1120 */
nikapov 0:a1a69d32f310 1121 VL53L0X_Error VL53L0X_get_measurement_timing_budget_micro_seconds(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1122 uint32_t *p_measurement_timing_budget_micro_seconds);
nikapov 0:a1a69d32f310 1123
nikapov 0:a1a69d32f310 1124 /**
nikapov 0:a1a69d32f310 1125 * @brief Set Ranging Timing Budget in microseconds
nikapov 0:a1a69d32f310 1126 *
nikapov 0:a1a69d32f310 1127 * @par Function Description
nikapov 0:a1a69d32f310 1128 * Defines the maximum time allowed by the user to the device to run a
nikapov 0:a1a69d32f310 1129 * full ranging sequence for the current mode (ranging, histogram, ASL ...)
nikapov 0:a1a69d32f310 1130 *
nikapov 0:a1a69d32f310 1131 * @note This function Access to the device
nikapov 0:a1a69d32f310 1132 *
nikapov 0:a1a69d32f310 1133 * @param dev Device Handle
nikapov 0:a1a69d32f310 1134 * @param measurement_timing_budget_micro_seconds Max measurement time in
nikapov 0:a1a69d32f310 1135 * microseconds.
nikapov 0:a1a69d32f310 1136 * Valid values are:
nikapov 0:a1a69d32f310 1137 * >= 17000 microsecs when wraparound enabled
nikapov 0:a1a69d32f310 1138 * >= 12000 microsecs when wraparound disabled
nikapov 0:a1a69d32f310 1139 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1140 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned if
nikapov 0:a1a69d32f310 1141 MeasurementTimingBudgetMicroSeconds out of range
nikapov 0:a1a69d32f310 1142 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1143 */
nikapov 0:a1a69d32f310 1144 VL53L0X_Error VL53L0X_set_measurement_timing_budget_micro_seconds(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1145 uint32_t measurement_timing_budget_micro_seconds);
nikapov 0:a1a69d32f310 1146
nikapov 0:a1a69d32f310 1147 /**
nikapov 0:a1a69d32f310 1148 * @brief Get specific limit check enable state
nikapov 0:a1a69d32f310 1149 *
nikapov 0:a1a69d32f310 1150 * @par Function Description
nikapov 0:a1a69d32f310 1151 * This function get the enable state of a specific limit check.
nikapov 0:a1a69d32f310 1152 * The limit check is identified with the LimitCheckId.
nikapov 0:a1a69d32f310 1153 *
nikapov 0:a1a69d32f310 1154 * @note This function Access to the device
nikapov 0:a1a69d32f310 1155 *
nikapov 0:a1a69d32f310 1156 * @param dev Device Handle
nikapov 0:a1a69d32f310 1157 * @param limit_check_id Limit Check ID
nikapov 0:a1a69d32f310 1158 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
nikapov 0:a1a69d32f310 1159 * @param p_limit_check_enable Pointer to the check limit enable
nikapov 0:a1a69d32f310 1160 * value.
nikapov 0:a1a69d32f310 1161 * if 1 the check limit
nikapov 0:a1a69d32f310 1162 * corresponding to LimitCheckId is Enabled
nikapov 0:a1a69d32f310 1163 * if 0 the check limit
nikapov 0:a1a69d32f310 1164 * corresponding to LimitCheckId is disabled
nikapov 0:a1a69d32f310 1165 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1166 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned
nikapov 0:a1a69d32f310 1167 * when LimitCheckId value is out of range.
nikapov 0:a1a69d32f310 1168 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1169 */
nikapov 0:a1a69d32f310 1170 VL53L0X_Error VL53L0X_get_limit_check_enable(VL53L0X_DEV dev, uint16_t limit_check_id,
nikapov 0:a1a69d32f310 1171 uint8_t *p_limit_check_enable);
nikapov 0:a1a69d32f310 1172
nikapov 0:a1a69d32f310 1173 /**
nikapov 0:a1a69d32f310 1174 * @brief Enable/Disable a specific limit check
nikapov 0:a1a69d32f310 1175 *
nikapov 0:a1a69d32f310 1176 * @par Function Description
nikapov 0:a1a69d32f310 1177 * This function Enable/Disable a specific limit check.
nikapov 0:a1a69d32f310 1178 * The limit check is identified with the LimitCheckId.
nikapov 0:a1a69d32f310 1179 *
nikapov 0:a1a69d32f310 1180 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 1181 *
nikapov 0:a1a69d32f310 1182 * @param dev Device Handle
nikapov 0:a1a69d32f310 1183 * @param limit_check_id Limit Check ID
nikapov 0:a1a69d32f310 1184 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
nikapov 0:a1a69d32f310 1185 * @param limit_check_enable if 1 the check limit
nikapov 0:a1a69d32f310 1186 * corresponding to LimitCheckId is Enabled
nikapov 0:a1a69d32f310 1187 * if 0 the check limit
nikapov 0:a1a69d32f310 1188 * corresponding to LimitCheckId is disabled
nikapov 0:a1a69d32f310 1189 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1190 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned
nikapov 0:a1a69d32f310 1191 * when LimitCheckId value is out of range.
nikapov 0:a1a69d32f310 1192 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1193 */
nikapov 0:a1a69d32f310 1194 VL53L0X_Error VL53L0X_set_limit_check_enable(VL53L0X_DEV dev, uint16_t limit_check_id,
nikapov 0:a1a69d32f310 1195 uint8_t limit_check_enable);
nikapov 0:a1a69d32f310 1196
nikapov 0:a1a69d32f310 1197 /**
nikapov 0:a1a69d32f310 1198 * @brief Get a specific limit check value
nikapov 0:a1a69d32f310 1199 *
nikapov 0:a1a69d32f310 1200 * @par Function Description
nikapov 0:a1a69d32f310 1201 * This function get a specific limit check value from device then it updates
nikapov 0:a1a69d32f310 1202 * internal values and check enables.
nikapov 0:a1a69d32f310 1203 * The limit check is identified with the LimitCheckId.
nikapov 0:a1a69d32f310 1204 *
nikapov 0:a1a69d32f310 1205 * @note This function Access to the device
nikapov 0:a1a69d32f310 1206 *
nikapov 0:a1a69d32f310 1207 * @param dev Device Handle
nikapov 0:a1a69d32f310 1208 * @param limit_check_id Limit Check ID
nikapov 0:a1a69d32f310 1209 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
nikapov 0:a1a69d32f310 1210 * @param p_limit_check_value Pointer to Limit
nikapov 0:a1a69d32f310 1211 * check Value for a given LimitCheckId.
nikapov 0:a1a69d32f310 1212 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1213 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned
nikapov 0:a1a69d32f310 1214 * when LimitCheckId value is out of range.
nikapov 0:a1a69d32f310 1215 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1216 */
nikapov 0:a1a69d32f310 1217 VL53L0X_Error VL53L0X_get_limit_check_value(VL53L0X_DEV dev, uint16_t limit_check_id,
nikapov 0:a1a69d32f310 1218 FixPoint1616_t *p_limit_check_value);
nikapov 0:a1a69d32f310 1219
nikapov 0:a1a69d32f310 1220 /**
nikapov 0:a1a69d32f310 1221 * @brief Set a specific limit check value
nikapov 0:a1a69d32f310 1222 *
nikapov 0:a1a69d32f310 1223 * @par Function Description
nikapov 0:a1a69d32f310 1224 * This function set a specific limit check value.
nikapov 0:a1a69d32f310 1225 * The limit check is identified with the LimitCheckId.
nikapov 0:a1a69d32f310 1226 *
nikapov 0:a1a69d32f310 1227 * @note This function Access to the device
nikapov 0:a1a69d32f310 1228 *
nikapov 0:a1a69d32f310 1229 * @param dev Device Handle
nikapov 0:a1a69d32f310 1230 * @param limit_check_id Limit Check ID
nikapov 0:a1a69d32f310 1231 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
nikapov 0:a1a69d32f310 1232 * @param limit_check_value Limit check Value for a given
nikapov 0:a1a69d32f310 1233 * LimitCheckId
nikapov 0:a1a69d32f310 1234 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1235 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned when either
nikapov 0:a1a69d32f310 1236 * LimitCheckId or LimitCheckValue value is out of range.
nikapov 0:a1a69d32f310 1237 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1238 */
nikapov 0:a1a69d32f310 1239 VL53L0X_Error VL53L0X_set_limit_check_value(VL53L0X_DEV dev, uint16_t limit_check_id,
nikapov 0:a1a69d32f310 1240 FixPoint1616_t limit_check_value);
nikapov 0:a1a69d32f310 1241
nikapov 0:a1a69d32f310 1242 /**
nikapov 0:a1a69d32f310 1243 * @brief Get the current value of the signal used for the limit check
nikapov 0:a1a69d32f310 1244 *
nikapov 0:a1a69d32f310 1245 * @par Function Description
nikapov 0:a1a69d32f310 1246 * This function get a the current value of the signal used for the limit check.
nikapov 0:a1a69d32f310 1247 * To obtain the latest value you should run a ranging before.
nikapov 0:a1a69d32f310 1248 * The value reported is linked to the limit check identified with the
nikapov 0:a1a69d32f310 1249 * LimitCheckId.
nikapov 0:a1a69d32f310 1250 *
nikapov 0:a1a69d32f310 1251 * @note This function Access to the device
nikapov 0:a1a69d32f310 1252 *
nikapov 0:a1a69d32f310 1253 * @param dev Device Handle
nikapov 0:a1a69d32f310 1254 * @param limit_check_id Limit Check ID
nikapov 0:a1a69d32f310 1255 * (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
nikapov 0:a1a69d32f310 1256 * @param p_limit_check_current Pointer to current Value for a
nikapov 0:a1a69d32f310 1257 * given LimitCheckId.
nikapov 0:a1a69d32f310 1258 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1259 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned when
nikapov 0:a1a69d32f310 1260 * LimitCheckId value is out of range.
nikapov 0:a1a69d32f310 1261 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1262 */
nikapov 0:a1a69d32f310 1263 VL53L0X_Error VL53L0X_get_limit_check_current(VL53L0X_DEV dev, uint16_t limit_check_id,
nikapov 0:a1a69d32f310 1264 FixPoint1616_t *p_limit_check_current);
nikapov 0:a1a69d32f310 1265
nikapov 0:a1a69d32f310 1266 /**
nikapov 0:a1a69d32f310 1267 * @brief Return a the Status of the specified check limit
nikapov 0:a1a69d32f310 1268 *
nikapov 0:a1a69d32f310 1269 * @par Function Description
nikapov 0:a1a69d32f310 1270 * This function returns the Status of the specified check limit.
nikapov 0:a1a69d32f310 1271 * The value indicate if the check is fail or not.
nikapov 0:a1a69d32f310 1272 * The limit check is identified with the LimitCheckId.
nikapov 0:a1a69d32f310 1273 *
nikapov 0:a1a69d32f310 1274 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 1275 *
nikapov 0:a1a69d32f310 1276 * @param dev Device Handle
nikapov 0:a1a69d32f310 1277 * @param limit_check_id Limit Check ID
nikapov 0:a1a69d32f310 1278 (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
nikapov 0:a1a69d32f310 1279 * @param p_limit_check_status Pointer to the
nikapov 0:a1a69d32f310 1280 Limit Check Status of the given check limit.
nikapov 0:a1a69d32f310 1281 * LimitCheckStatus :
nikapov 0:a1a69d32f310 1282 * 0 the check is not fail
nikapov 0:a1a69d32f310 1283 * 1 the check if fail or not enabled
nikapov 0:a1a69d32f310 1284 *
nikapov 0:a1a69d32f310 1285 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1286 * @return VL53L0X_ERROR_INVALID_PARAMS This error is
nikapov 0:a1a69d32f310 1287 returned when LimitCheckId value is out of range.
nikapov 0:a1a69d32f310 1288 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1289 */
nikapov 0:a1a69d32f310 1290 VL53L0X_Error VL53L0X_get_limit_check_status(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1291 uint16_t limit_check_id, uint8_t *p_limit_check_status);
nikapov 0:a1a69d32f310 1292
nikapov 0:a1a69d32f310 1293 /**
nikapov 0:a1a69d32f310 1294 * Get continuous mode Inter-Measurement period in milliseconds
nikapov 0:a1a69d32f310 1295 *
nikapov 0:a1a69d32f310 1296 * @par Function Description
nikapov 0:a1a69d32f310 1297 * When trying to set too short time return INVALID_PARAMS minimal value
nikapov 0:a1a69d32f310 1298 *
nikapov 0:a1a69d32f310 1299 * @note This function Access to the device
nikapov 0:a1a69d32f310 1300 *
nikapov 0:a1a69d32f310 1301 * @param dev Device Handle
nikapov 0:a1a69d32f310 1302 * @param p_inter_measurement_period_milli_seconds Pointer to programmed
nikapov 0:a1a69d32f310 1303 * Inter-Measurement Period in milliseconds.
nikapov 0:a1a69d32f310 1304 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1305 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1306 */
nikapov 0:a1a69d32f310 1307 VL53L0X_Error VL53L0X_get_inter_measurement_period_milli_seconds(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1308 uint32_t *p_inter_measurement_period_milli_seconds);
nikapov 0:a1a69d32f310 1309
nikapov 0:a1a69d32f310 1310 /**
nikapov 0:a1a69d32f310 1311 * Program continuous mode Inter-Measurement period in milliseconds
nikapov 0:a1a69d32f310 1312 *
nikapov 0:a1a69d32f310 1313 * @par Function Description
nikapov 0:a1a69d32f310 1314 * When trying to set too short time return INVALID_PARAMS minimal value
nikapov 0:a1a69d32f310 1315 *
nikapov 0:a1a69d32f310 1316 * @note This function Access to the device
nikapov 0:a1a69d32f310 1317 *
nikapov 0:a1a69d32f310 1318 * @param dev Device Handle
nikapov 0:a1a69d32f310 1319 * @param inter_measurement_period_milli_seconds Inter-Measurement Period in ms.
nikapov 0:a1a69d32f310 1320 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1321 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1322 */
nikapov 0:a1a69d32f310 1323 VL53L0X_Error VL53L0X_set_inter_measurement_period_milli_seconds(
nikapov 0:a1a69d32f310 1324 VL53L0X_DEV dev, uint32_t inter_measurement_period_milli_seconds);
nikapov 0:a1a69d32f310 1325
nikapov 0:a1a69d32f310 1326 /**
nikapov 0:a1a69d32f310 1327 * @brief Set new device address
nikapov 0:a1a69d32f310 1328 *
nikapov 0:a1a69d32f310 1329 * After completion the device will answer to the new address programmed.
nikapov 0:a1a69d32f310 1330 * This function should be called when several devices are used in parallel
nikapov 0:a1a69d32f310 1331 * before start programming the sensor.
nikapov 0:a1a69d32f310 1332 * When a single device us used, there is no need to call this function.
nikapov 0:a1a69d32f310 1333 *
nikapov 0:a1a69d32f310 1334 * @note This function Access to the device
nikapov 0:a1a69d32f310 1335 *
nikapov 0:a1a69d32f310 1336 * @param dev Device Handle
nikapov 0:a1a69d32f310 1337 * @param device_address The new Device address
nikapov 0:a1a69d32f310 1338 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1339 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1340 */
nikapov 0:a1a69d32f310 1341 VL53L0X_Error VL53L0X_set_device_address(VL53L0X_DEV dev, uint8_t device_address);
nikapov 0:a1a69d32f310 1342
nikapov 0:a1a69d32f310 1343 /**
nikapov 0:a1a69d32f310 1344 * @brief Do an hard reset or soft reset (depending on implementation) of the
nikapov 0:a1a69d32f310 1345 * device \nAfter call of this function, device must be in same state as right
nikapov 0:a1a69d32f310 1346 * after a power-up sequence.This function will change the VL53L0X_State to
nikapov 0:a1a69d32f310 1347 * VL53L0X_STATE_POWERDOWN.
nikapov 0:a1a69d32f310 1348 *
nikapov 0:a1a69d32f310 1349 * @note This function Access to the device
nikapov 0:a1a69d32f310 1350 *
nikapov 0:a1a69d32f310 1351 * @param dev Device Handle
nikapov 0:a1a69d32f310 1352 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1353 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1354 */
nikapov 0:a1a69d32f310 1355 VL53L0X_Error VL53L0X_reset_device(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1356
nikapov 0:a1a69d32f310 1357 /**
nikapov 0:a1a69d32f310 1358 * @brief Get setup of Wrap around Check
nikapov 0:a1a69d32f310 1359 *
nikapov 0:a1a69d32f310 1360 * @par Function Description
nikapov 0:a1a69d32f310 1361 * This function get the wrapAround check enable parameters
nikapov 0:a1a69d32f310 1362 *
nikapov 0:a1a69d32f310 1363 * @note This function Access to the device
nikapov 0:a1a69d32f310 1364 *
nikapov 0:a1a69d32f310 1365 * @param dev Device Handle
nikapov 0:a1a69d32f310 1366 * @param p_wrap_around_check_enable Pointer to the Wrap around Check state
nikapov 0:a1a69d32f310 1367 * 0=disabled or 1 = enabled
nikapov 0:a1a69d32f310 1368 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1369 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1370 */
nikapov 0:a1a69d32f310 1371 VL53L0X_Error VL53L0X_get_wrap_around_check_enable(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1372 uint8_t *p_wrap_around_check_enable);
nikapov 0:a1a69d32f310 1373
nikapov 0:a1a69d32f310 1374 /**
nikapov 0:a1a69d32f310 1375 * @brief Enable (or disable) Wrap around Check
nikapov 0:a1a69d32f310 1376 *
nikapov 0:a1a69d32f310 1377 * @note This function Access to the device
nikapov 0:a1a69d32f310 1378 *
nikapov 0:a1a69d32f310 1379 * @param dev Device Handle
nikapov 0:a1a69d32f310 1380 * @param wrap_around_check_enable Wrap around Check to be set
nikapov 0:a1a69d32f310 1381 * 0=disabled, other = enabled
nikapov 0:a1a69d32f310 1382 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1383 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1384 */
nikapov 0:a1a69d32f310 1385 VL53L0X_Error VL53L0X_set_wrap_around_check_enable(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1386 uint8_t wrap_around_check_enable);
nikapov 0:a1a69d32f310 1387
nikapov 0:a1a69d32f310 1388 /**
nikapov 0:a1a69d32f310 1389 * @brief Gets the VCSEL pulse period.
nikapov 0:a1a69d32f310 1390 *
nikapov 0:a1a69d32f310 1391 * @par Function Description
nikapov 0:a1a69d32f310 1392 * This function retrieves the VCSEL pulse period for the given period type.
nikapov 0:a1a69d32f310 1393 *
nikapov 0:a1a69d32f310 1394 * @note This function Accesses the device
nikapov 0:a1a69d32f310 1395 *
nikapov 0:a1a69d32f310 1396 * @param dev Device Handle
nikapov 0:a1a69d32f310 1397 * @param vcsel_period_type VCSEL period identifier (pre-range|final).
nikapov 0:a1a69d32f310 1398 * @param p_vcsel_pulse_period_pclk Pointer to VCSEL period value.
nikapov 0:a1a69d32f310 1399 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1400 * @return VL53L0X_ERROR_INVALID_PARAMS Error VcselPeriodType parameter not
nikapov 0:a1a69d32f310 1401 * supported.
nikapov 0:a1a69d32f310 1402 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1403 */
nikapov 0:a1a69d32f310 1404 VL53L0X_Error VL53L0X_get_vcsel_pulse_period(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1405 VL53L0X_VcselPeriod vcsel_period_type, uint8_t *p_vcsel_pulse_period_pclk);
nikapov 0:a1a69d32f310 1406
nikapov 0:a1a69d32f310 1407 /**
nikapov 0:a1a69d32f310 1408 * @brief Sets the VCSEL pulse period.
nikapov 0:a1a69d32f310 1409 *
nikapov 0:a1a69d32f310 1410 * @par Function Description
nikapov 0:a1a69d32f310 1411 * This function retrieves the VCSEL pulse period for the given period type.
nikapov 0:a1a69d32f310 1412 *
nikapov 0:a1a69d32f310 1413 * @note This function Accesses the device
nikapov 0:a1a69d32f310 1414 *
nikapov 0:a1a69d32f310 1415 * @param dev Device Handle
nikapov 0:a1a69d32f310 1416 * @param vcsel_period_type VCSEL period identifier (pre-range|final).
nikapov 0:a1a69d32f310 1417 * @param vcsel_pulse_period VCSEL period value
nikapov 0:a1a69d32f310 1418 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1419 * @return VL53L0X_ERROR_INVALID_PARAMS Error VcselPeriodType parameter not
nikapov 0:a1a69d32f310 1420 * supported.
nikapov 0:a1a69d32f310 1421 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1422 */
nikapov 0:a1a69d32f310 1423 VL53L0X_Error VL53L0X_set_vcsel_pulse_period(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1424 VL53L0X_VcselPeriod vcsel_period_type, uint8_t vcsel_pulse_period);
nikapov 0:a1a69d32f310 1425
nikapov 0:a1a69d32f310 1426 /**
nikapov 0:a1a69d32f310 1427 * @brief Set low and high Interrupt thresholds for a given mode
nikapov 0:a1a69d32f310 1428 * (ranging, ALS, ...) for a given device
nikapov 0:a1a69d32f310 1429 *
nikapov 0:a1a69d32f310 1430 * @par Function Description
nikapov 0:a1a69d32f310 1431 * Set low and high Interrupt thresholds for a given mode (ranging, ALS, ...)
nikapov 0:a1a69d32f310 1432 * for a given device
nikapov 0:a1a69d32f310 1433 *
nikapov 0:a1a69d32f310 1434 * @note This function Access to the device
nikapov 0:a1a69d32f310 1435 *
nikapov 0:a1a69d32f310 1436 * @note DeviceMode is ignored for the current device
nikapov 0:a1a69d32f310 1437 *
nikapov 0:a1a69d32f310 1438 * @param dev Device Handle
nikapov 0:a1a69d32f310 1439 * @param device_mode Device Mode for which change thresholds
nikapov 0:a1a69d32f310 1440 * @param threshold_low Low threshold (mm, lux ..., depending on the mode)
nikapov 0:a1a69d32f310 1441 * @param threshold_high High threshold (mm, lux ..., depending on the mode)
nikapov 0:a1a69d32f310 1442 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1443 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1444 */
nikapov 0:a1a69d32f310 1445 VL53L0X_Error VL53L0X_set_interrupt_thresholds(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1446 VL53L0X_DeviceModes device_mode, FixPoint1616_t threshold_low,
nikapov 0:a1a69d32f310 1447 FixPoint1616_t threshold_high);
nikapov 0:a1a69d32f310 1448
nikapov 0:a1a69d32f310 1449 /**
nikapov 0:a1a69d32f310 1450 * @brief Get high and low Interrupt thresholds for a given mode
nikapov 0:a1a69d32f310 1451 * (ranging, ALS, ...) for a given device
nikapov 0:a1a69d32f310 1452 *
nikapov 0:a1a69d32f310 1453 * @par Function Description
nikapov 0:a1a69d32f310 1454 * Get high and low Interrupt thresholds for a given mode (ranging, ALS, ...)
nikapov 0:a1a69d32f310 1455 * for a given device
nikapov 0:a1a69d32f310 1456 *
nikapov 0:a1a69d32f310 1457 * @note This function Access to the device
nikapov 0:a1a69d32f310 1458 *
nikapov 0:a1a69d32f310 1459 * @note DeviceMode is ignored for the current device
nikapov 0:a1a69d32f310 1460 *
nikapov 0:a1a69d32f310 1461 * @param dev Device Handle
nikapov 0:a1a69d32f310 1462 * @param device_mode Device Mode from which read thresholds
nikapov 0:a1a69d32f310 1463 * @param p_threshold_low Low threshold (mm, lux ..., depending on the mode)
nikapov 0:a1a69d32f310 1464 * @param p_threshold_high High threshold (mm, lux ..., depending on the mode)
nikapov 0:a1a69d32f310 1465 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1466 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1467 */
nikapov 0:a1a69d32f310 1468 VL53L0X_Error VL53L0X_get_interrupt_thresholds(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1469 VL53L0X_DeviceModes device_mode, FixPoint1616_t *p_threshold_low,
nikapov 0:a1a69d32f310 1470 FixPoint1616_t *p_threshold_high);
nikapov 0:a1a69d32f310 1471
nikapov 0:a1a69d32f310 1472 /**
nikapov 0:a1a69d32f310 1473 * @brief Reads the Device information for given Device
nikapov 0:a1a69d32f310 1474 *
nikapov 0:a1a69d32f310 1475 * @note This function Access to the device
nikapov 0:a1a69d32f310 1476 *
nikapov 0:a1a69d32f310 1477 * @param dev Device Handle
nikapov 0:a1a69d32f310 1478 * @param p_VL53L0X_device_info Pointer to current device info for a given
nikapov 0:a1a69d32f310 1479 * Device
nikapov 0:a1a69d32f310 1480 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1481 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1482 */
nikapov 0:a1a69d32f310 1483 VL53L0X_Error VL53L0X_get_device_info(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1484 VL53L0X_DeviceInfo_t *p_VL53L0X_device_info);
nikapov 0:a1a69d32f310 1485
nikapov 0:a1a69d32f310 1486 /**
nikapov 0:a1a69d32f310 1487 * @brief Gets the (on/off) state of all sequence steps.
nikapov 0:a1a69d32f310 1488 *
nikapov 0:a1a69d32f310 1489 * @par Function Description
nikapov 0:a1a69d32f310 1490 * This function retrieves the state of all sequence step in the scheduler.
nikapov 0:a1a69d32f310 1491 *
nikapov 0:a1a69d32f310 1492 * @note This function Accesses the device
nikapov 0:a1a69d32f310 1493 *
nikapov 0:a1a69d32f310 1494 * @param dev Device Handle
nikapov 0:a1a69d32f310 1495 * @param p_scheduler_sequence_steps Pointer to struct containing result.
nikapov 0:a1a69d32f310 1496 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1497 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1498 */
nikapov 0:a1a69d32f310 1499 VL53L0X_Error VL53L0X_get_sequence_step_enables(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1500 VL53L0X_SchedulerSequenceSteps_t *p_scheduler_sequence_steps);
nikapov 0:a1a69d32f310 1501
nikapov 0:a1a69d32f310 1502 /**
nikapov 0:a1a69d32f310 1503 * @brief Sets the (on/off) state of a requested sequence step.
nikapov 0:a1a69d32f310 1504 *
nikapov 0:a1a69d32f310 1505 * @par Function Description
nikapov 0:a1a69d32f310 1506 * This function enables/disables a requested sequence step.
nikapov 0:a1a69d32f310 1507 *
nikapov 0:a1a69d32f310 1508 * @note This function Accesses the device
nikapov 0:a1a69d32f310 1509 *
nikapov 0:a1a69d32f310 1510 * @param dev Device Handle
nikapov 0:a1a69d32f310 1511 * @param sequence_step_id Sequence step identifier.
nikapov 0:a1a69d32f310 1512 * @param sequence_step_enabled Demanded state {0=Off,1=On}
nikapov 0:a1a69d32f310 1513 * is enabled.
nikapov 0:a1a69d32f310 1514 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1515 * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not
nikapov 0:a1a69d32f310 1516 * supported.
nikapov 0:a1a69d32f310 1517 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1518 */
nikapov 0:a1a69d32f310 1519 VL53L0X_Error VL53L0X_set_sequence_step_enable(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1520 VL53L0X_SequenceStepId sequence_step_id, uint8_t sequence_step_enabled);
nikapov 0:a1a69d32f310 1521
nikapov 0:a1a69d32f310 1522 /**
nikapov 0:a1a69d32f310 1523 * @brief Gets the fraction enable parameter indicating the resolution of
nikapov 0:a1a69d32f310 1524 * range measurements.
nikapov 0:a1a69d32f310 1525 *
nikapov 0:a1a69d32f310 1526 * @par Function Description
nikapov 0:a1a69d32f310 1527 * Gets the fraction enable state, which translates to the resolution of
nikapov 0:a1a69d32f310 1528 * range measurements as follows :Enabled:=0.25mm resolution,
nikapov 0:a1a69d32f310 1529 * Not Enabled:=1mm resolution.
nikapov 0:a1a69d32f310 1530 *
nikapov 0:a1a69d32f310 1531 * @note This function Accesses the device
nikapov 0:a1a69d32f310 1532 *
nikapov 0:a1a69d32f310 1533 * @param dev Device Handle
nikapov 0:a1a69d32f310 1534 * @param p_enabled Output Parameter reporting the fraction enable state.
nikapov 0:a1a69d32f310 1535 *
nikapov 0:a1a69d32f310 1536 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1537 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1538 */
nikapov 0:a1a69d32f310 1539 VL53L0X_Error VL53L0X_get_fraction_enable(VL53L0X_DEV dev, uint8_t *p_enabled);
nikapov 0:a1a69d32f310 1540
nikapov 0:a1a69d32f310 1541 /**
nikapov 0:a1a69d32f310 1542 * @brief Sets the resolution of range measurements.
nikapov 0:a1a69d32f310 1543 * @par Function Description
nikapov 0:a1a69d32f310 1544 * Set resolution of range measurements to either 0.25mm if
nikapov 0:a1a69d32f310 1545 * fraction enabled or 1mm if not enabled.
nikapov 0:a1a69d32f310 1546 *
nikapov 0:a1a69d32f310 1547 * @note This function Accesses the device
nikapov 0:a1a69d32f310 1548 *
nikapov 0:a1a69d32f310 1549 * @param dev Device Handle
nikapov 0:a1a69d32f310 1550 * @param enable Enable high resolution
nikapov 0:a1a69d32f310 1551 *
nikapov 0:a1a69d32f310 1552 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1553 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1554 */
nikapov 0:a1a69d32f310 1555 VL53L0X_Error VL53L0X_set_range_fraction_enable(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1556 uint8_t enable);
nikapov 0:a1a69d32f310 1557
nikapov 0:a1a69d32f310 1558 /**
nikapov 0:a1a69d32f310 1559 * @brief Return the VL53L0X PAL Implementation Version
nikapov 0:a1a69d32f310 1560 *
nikapov 0:a1a69d32f310 1561 * @note This function doesn't access to the device
nikapov 0:a1a69d32f310 1562 *
nikapov 0:a1a69d32f310 1563 * @param p_version Pointer to current PAL Implementation Version
nikapov 0:a1a69d32f310 1564 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1565 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1566 */
nikapov 0:a1a69d32f310 1567 VL53L0X_Error VL53L0X_get_version(VL53L0X_Version_t *p_version);
nikapov 0:a1a69d32f310 1568
nikapov 0:a1a69d32f310 1569 /**
nikapov 0:a1a69d32f310 1570 * @brief Reads the Product Revision for a for given Device
nikapov 0:a1a69d32f310 1571 * This function can be used to distinguish cut1.0 from cut1.1.
nikapov 0:a1a69d32f310 1572 *
nikapov 0:a1a69d32f310 1573 * @note This function Access to the device
nikapov 0:a1a69d32f310 1574 *
nikapov 0:a1a69d32f310 1575 * @param dev Device Handle
nikapov 0:a1a69d32f310 1576 * @param p_product_revision_major Pointer to Product Revision Major
nikapov 0:a1a69d32f310 1577 * for a given Device
nikapov 0:a1a69d32f310 1578 * @param p_product_revision_minor Pointer to Product Revision Minor
nikapov 0:a1a69d32f310 1579 * for a given Device
nikapov 0:a1a69d32f310 1580 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1581 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1582 */
nikapov 0:a1a69d32f310 1583 VL53L0X_Error VL53L0X_get_product_revision(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1584 uint8_t *p_product_revision_major, uint8_t *p_product_revision_minor);
nikapov 0:a1a69d32f310 1585
nikapov 0:a1a69d32f310 1586 /**
nikapov 0:a1a69d32f310 1587 * @brief Retrieve current device parameters
nikapov 0:a1a69d32f310 1588 * @par Function Description
nikapov 0:a1a69d32f310 1589 * Get actual parameters of the device
nikapov 0:a1a69d32f310 1590 * @li Then start ranging operation.
nikapov 0:a1a69d32f310 1591 *
nikapov 0:a1a69d32f310 1592 * @note This function Access to the device
nikapov 0:a1a69d32f310 1593 *
nikapov 0:a1a69d32f310 1594 * @param dev Device Handle
nikapov 0:a1a69d32f310 1595 * @param p_device_parameters Pointer to store current device parameters.
nikapov 0:a1a69d32f310 1596 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1597 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1598 */
nikapov 0:a1a69d32f310 1599 VL53L0X_Error VL53L0X_get_device_parameters(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1600 VL53L0X_DeviceParameters_t *p_device_parameters);
nikapov 0:a1a69d32f310 1601
nikapov 0:a1a69d32f310 1602 /**
nikapov 0:a1a69d32f310 1603 * @brief Human readable error string for current PAL error status
nikapov 0:a1a69d32f310 1604 *
nikapov 0:a1a69d32f310 1605 * @note This function doesn't access to the device
nikapov 0:a1a69d32f310 1606 *
nikapov 0:a1a69d32f310 1607 * @param pal_error_code The error code as stored on @a VL53L0X_Error
nikapov 0:a1a69d32f310 1608 * @param p_pal_error_string The error string corresponding to the
nikapov 0:a1a69d32f310 1609 * PalErrorCode
nikapov 0:a1a69d32f310 1610 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1611 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1612 */
nikapov 0:a1a69d32f310 1613 VL53L0X_Error VL53L0X_get_pal_error_string(VL53L0X_Error pal_error_code,
nikapov 0:a1a69d32f310 1614 char *p_pal_error_string);
nikapov 0:a1a69d32f310 1615
nikapov 0:a1a69d32f310 1616 /**
nikapov 0:a1a69d32f310 1617 * @brief Return the PAL Specification Version used for the current
nikapov 0:a1a69d32f310 1618 * implementation.
nikapov 0:a1a69d32f310 1619 *
nikapov 0:a1a69d32f310 1620 * @note This function doesn't access to the device
nikapov 0:a1a69d32f310 1621 *
nikapov 0:a1a69d32f310 1622 * @param p_pal_spec_version Pointer to current PAL Specification Version
nikapov 0:a1a69d32f310 1623 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1624 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1625 */
nikapov 0:a1a69d32f310 1626 VL53L0X_Error VL53L0X_get_pal_spec_version(
nikapov 0:a1a69d32f310 1627 VL53L0X_Version_t *p_pal_spec_version);
nikapov 0:a1a69d32f310 1628
nikapov 0:a1a69d32f310 1629 /**
nikapov 0:a1a69d32f310 1630 * @brief Reads the internal state of the PAL for a given Device
nikapov 0:a1a69d32f310 1631 *
nikapov 0:a1a69d32f310 1632 * @note This function doesn't access to the device
nikapov 0:a1a69d32f310 1633 *
nikapov 0:a1a69d32f310 1634 * @param dev Device Handle
nikapov 0:a1a69d32f310 1635 * @param p_pal_state Pointer to current state of the PAL for a
nikapov 0:a1a69d32f310 1636 * given Device
nikapov 0:a1a69d32f310 1637 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1638 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1639 */
nikapov 0:a1a69d32f310 1640 VL53L0X_Error VL53L0X_get_pal_state(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1641 VL53L0X_State *p_pal_state);
nikapov 0:a1a69d32f310 1642
nikapov 0:a1a69d32f310 1643 /**
nikapov 0:a1a69d32f310 1644 * @brief Human readable PAL State string
nikapov 0:a1a69d32f310 1645 *
nikapov 0:a1a69d32f310 1646 * @note This function doesn't access to the device
nikapov 0:a1a69d32f310 1647 *
nikapov 0:a1a69d32f310 1648 * @param pal_state_code The State code as stored on @a VL53L0X_State
nikapov 0:a1a69d32f310 1649 * @param p_pal_state_string The State string corresponding to the
nikapov 0:a1a69d32f310 1650 * PalStateCode
nikapov 0:a1a69d32f310 1651 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1652 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1653 */
nikapov 0:a1a69d32f310 1654 VL53L0X_Error VL53L0X_get_pal_state_string(VL53L0X_State pal_state_code,
nikapov 0:a1a69d32f310 1655 char *p_pal_state_string);
nikapov 0:a1a69d32f310 1656
nikapov 0:a1a69d32f310 1657 /*** End High level API ***/
nikapov 0:a1a69d32f310 1658 private:
nikapov 0:a1a69d32f310 1659 /* api.h functions */
nikapov 0:a1a69d32f310 1660
nikapov 0:a1a69d32f310 1661 /**
nikapov 0:a1a69d32f310 1662 * @brief Wait for device booted after chip enable (hardware standby)
nikapov 0:a1a69d32f310 1663 * This function can be run only when VL53L0X_State is VL53L0X_STATE_POWERDOWN.
nikapov 0:a1a69d32f310 1664 *
nikapov 0:a1a69d32f310 1665 * @note This function is not Implemented
nikapov 0:a1a69d32f310 1666 *
nikapov 0:a1a69d32f310 1667 * @param dev Device Handle
nikapov 0:a1a69d32f310 1668 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
nikapov 0:a1a69d32f310 1669 *
nikapov 0:a1a69d32f310 1670 */
nikapov 0:a1a69d32f310 1671 VL53L0X_Error VL53L0X_wait_device_booted(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1672
nikapov 0:a1a69d32f310 1673
nikapov 0:a1a69d32f310 1674 VL53L0X_Error sequence_step_enabled(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1675 VL53L0X_SequenceStepId sequence_step_id, uint8_t sequence_config,
nikapov 0:a1a69d32f310 1676 uint8_t *p_sequence_step_enabled);
nikapov 0:a1a69d32f310 1677
nikapov 0:a1a69d32f310 1678 VL53L0X_Error VL53L0X_check_and_load_interrupt_settings(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1679 uint8_t start_not_stopflag);
nikapov 0:a1a69d32f310 1680
nikapov 0:a1a69d32f310 1681
nikapov 0:a1a69d32f310 1682 /* api_core.h functions */
nikapov 0:a1a69d32f310 1683
nikapov 0:a1a69d32f310 1684 VL53L0X_Error VL53L0X_get_info_from_device(VL53L0X_DEV dev, uint8_t option);
nikapov 0:a1a69d32f310 1685
nikapov 0:a1a69d32f310 1686 VL53L0X_Error VL53L0X_device_read_strobe(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1687
nikapov 0:a1a69d32f310 1688 VL53L0X_Error wrapped_VL53L0X_get_measurement_timing_budget_micro_seconds(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1689 uint32_t *p_measurement_timing_budget_micro_seconds);
nikapov 0:a1a69d32f310 1690
nikapov 0:a1a69d32f310 1691 VL53L0X_Error wrapped_VL53L0X_get_vcsel_pulse_period(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1692 VL53L0X_VcselPeriod vcsel_period_type, uint8_t *p_vcsel_pulse_period_pclk);
nikapov 0:a1a69d32f310 1693
nikapov 0:a1a69d32f310 1694 uint8_t VL53L0X_decode_vcsel_period(uint8_t vcsel_period_reg);
nikapov 0:a1a69d32f310 1695
nikapov 0:a1a69d32f310 1696 uint32_t VL53L0X_decode_timeout(uint16_t encoded_timeout);
nikapov 0:a1a69d32f310 1697
nikapov 0:a1a69d32f310 1698 uint32_t VL53L0X_calc_timeout_us(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1699 uint16_t timeout_period_mclks,
nikapov 0:a1a69d32f310 1700 uint8_t vcsel_period_pclks);
nikapov 0:a1a69d32f310 1701
nikapov 0:a1a69d32f310 1702 uint32_t VL53L0X_calc_macro_period_ps(VL53L0X_DEV dev, uint8_t vcsel_period_pclks);
nikapov 0:a1a69d32f310 1703
nikapov 0:a1a69d32f310 1704 VL53L0X_Error VL53L0X_measurement_poll_for_completion(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1705
nikapov 0:a1a69d32f310 1706 VL53L0X_Error VL53L0X_load_tuning_settings(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1707 uint8_t *p_tuning_setting_buffer);
nikapov 0:a1a69d32f310 1708
nikapov 0:a1a69d32f310 1709 VL53L0X_Error VL53L0X_get_pal_range_status(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1710 uint8_t device_range_status,
nikapov 0:a1a69d32f310 1711 FixPoint1616_t signal_rate,
nikapov 0:a1a69d32f310 1712 uint16_t effective_spad_rtn_count,
nikapov 0:a1a69d32f310 1713 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
nikapov 0:a1a69d32f310 1714 uint8_t *p_pal_range_status);
nikapov 0:a1a69d32f310 1715 VL53L0X_Error VL53L0X_calc_sigma_estimate(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1716 VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data,
nikapov 0:a1a69d32f310 1717 FixPoint1616_t *p_sigma_estimate,
nikapov 0:a1a69d32f310 1718 uint32_t *p_dmax_mm);
nikapov 0:a1a69d32f310 1719 uint32_t VL53L0X_calc_timeout_mclks(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1720 uint32_t timeout_period_us,
nikapov 0:a1a69d32f310 1721 uint8_t vcsel_period_pclks);
nikapov 0:a1a69d32f310 1722 uint32_t VL53L0X_isqrt(uint32_t num);
nikapov 0:a1a69d32f310 1723
nikapov 0:a1a69d32f310 1724 uint32_t VL53L0X_quadrature_sum(uint32_t a, uint32_t b);
nikapov 0:a1a69d32f310 1725
nikapov 0:a1a69d32f310 1726 VL53L0X_Error VL53L0X_calc_dmax(
nikapov 0:a1a69d32f310 1727 VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1728 FixPoint1616_t total_signal_rate_mcps,
nikapov 0:a1a69d32f310 1729 FixPoint1616_t total_corr_signal_rate_mcps,
nikapov 0:a1a69d32f310 1730 FixPoint1616_t pw_mult,
nikapov 0:a1a69d32f310 1731 uint32_t sigma_estimate_p1,
nikapov 0:a1a69d32f310 1732 FixPoint1616_t sigma_estimate_p2,
nikapov 0:a1a69d32f310 1733 uint32_t peak_vcsel_duration_us,
nikapov 0:a1a69d32f310 1734 uint32_t *pd_max_mm);
nikapov 0:a1a69d32f310 1735 VL53L0X_Error wrapped_VL53L0X_set_measurement_timing_budget_micro_seconds(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1736 uint32_t measurement_timing_budget_micro_seconds);
nikapov 0:a1a69d32f310 1737 VL53L0X_Error get_sequence_step_timeout(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1738 VL53L0X_SequenceStepId sequence_step_id,
nikapov 0:a1a69d32f310 1739 uint32_t *p_time_out_micro_secs);
nikapov 0:a1a69d32f310 1740 VL53L0X_Error set_sequence_step_timeout(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1741 VL53L0X_SequenceStepId sequence_step_id,
nikapov 0:a1a69d32f310 1742 uint32_t timeout_micro_secs);
nikapov 0:a1a69d32f310 1743 uint16_t VL53L0X_encode_timeout(uint32_t timeout_macro_clks);
nikapov 0:a1a69d32f310 1744 VL53L0X_Error wrapped_VL53L0X_set_vcsel_pulse_period(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1745 VL53L0X_VcselPeriod vcsel_period_type, uint8_t vcsel_pulse_period_pclk);
nikapov 0:a1a69d32f310 1746 uint8_t lv53l0x_encode_vcsel_period(uint8_t vcsel_period_pclks);
nikapov 0:a1a69d32f310 1747
nikapov 0:a1a69d32f310 1748 /* api_calibration.h functions */
nikapov 0:a1a69d32f310 1749 VL53L0X_Error VL53L0X_apply_offset_adjustment(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1750 VL53L0X_Error wrapped_VL53L0X_get_offset_calibration_data_micro_meter(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1751 int32_t *p_offset_calibration_data_micro_meter);
nikapov 0:a1a69d32f310 1752 VL53L0X_Error wrapped_VL53L0X_set_offset_calibration_data_micro_meter(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1753 int32_t offset_calibration_data_micro_meter);
nikapov 0:a1a69d32f310 1754 VL53L0X_Error wrapped_VL53L0X_perform_ref_spad_management(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1755 uint32_t *ref_spad_count,
nikapov 0:a1a69d32f310 1756 uint8_t *is_aperture_spads);
nikapov 0:a1a69d32f310 1757 VL53L0X_Error VL53L0X_perform_ref_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1758 uint8_t *p_vhv_settings, uint8_t *p_phase_cal, uint8_t get_data_enable);
nikapov 0:a1a69d32f310 1759 VL53L0X_Error VL53L0X_perform_vhv_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1760 uint8_t *p_vhv_settings, const uint8_t get_data_enable,
nikapov 0:a1a69d32f310 1761 const uint8_t restore_config);
nikapov 0:a1a69d32f310 1762 VL53L0X_Error VL53L0X_perform_single_ref_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1763 uint8_t vhv_init_byte);
nikapov 0:a1a69d32f310 1764 VL53L0X_Error VL53L0X_ref_calibration_io(VL53L0X_DEV dev, uint8_t read_not_write,
nikapov 0:a1a69d32f310 1765 uint8_t vhv_settings, uint8_t phase_cal,
nikapov 0:a1a69d32f310 1766 uint8_t *p_vhv_settings, uint8_t *p_phase_cal,
nikapov 0:a1a69d32f310 1767 const uint8_t vhv_enable, const uint8_t phase_enable);
nikapov 0:a1a69d32f310 1768 VL53L0X_Error VL53L0X_perform_phase_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1769 uint8_t *p_phase_cal, const uint8_t get_data_enable,
nikapov 0:a1a69d32f310 1770 const uint8_t restore_config);
nikapov 0:a1a69d32f310 1771 VL53L0X_Error enable_ref_spads(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1772 uint8_t aperture_spads,
nikapov 0:a1a69d32f310 1773 uint8_t good_spad_array[],
nikapov 0:a1a69d32f310 1774 uint8_t spad_array[],
nikapov 0:a1a69d32f310 1775 uint32_t size,
nikapov 0:a1a69d32f310 1776 uint32_t start,
nikapov 0:a1a69d32f310 1777 uint32_t offset,
nikapov 0:a1a69d32f310 1778 uint32_t spad_count,
nikapov 0:a1a69d32f310 1779 uint32_t *p_last_spad);
nikapov 0:a1a69d32f310 1780 void get_next_good_spad(uint8_t good_spad_array[], uint32_t size,
nikapov 0:a1a69d32f310 1781 uint32_t curr, int32_t *p_next);
nikapov 0:a1a69d32f310 1782 uint8_t is_aperture(uint32_t spad_index);
nikapov 0:a1a69d32f310 1783 VL53L0X_Error enable_spad_bit(uint8_t spad_array[], uint32_t size,
nikapov 0:a1a69d32f310 1784 uint32_t spad_index);
nikapov 0:a1a69d32f310 1785 VL53L0X_Error set_ref_spad_map(VL53L0X_DEV dev, uint8_t *p_ref_spad_array);
nikapov 0:a1a69d32f310 1786 VL53L0X_Error get_ref_spad_map(VL53L0X_DEV dev, uint8_t *p_ref_spad_array);
nikapov 0:a1a69d32f310 1787 VL53L0X_Error perform_ref_signal_measurement(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1788 uint16_t *p_ref_signal_rate);
nikapov 0:a1a69d32f310 1789 VL53L0X_Error wrapped_VL53L0X_set_reference_spads(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1790 uint32_t count, uint8_t is_aperture_spads);
nikapov 0:a1a69d32f310 1791
nikapov 0:a1a69d32f310 1792 /* api_strings.h functions */
nikapov 0:a1a69d32f310 1793 VL53L0X_Error wrapped_VL53L0X_get_device_info(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1794 VL53L0X_DeviceInfo_t *p_VL53L0X_device_info);
nikapov 0:a1a69d32f310 1795 VL53L0X_Error VL53L0X_check_part_used(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1796 uint8_t *revision,
nikapov 0:a1a69d32f310 1797 VL53L0X_DeviceInfo_t *p_VL53L0X_device_info);
Davidroid 2:d07edeaff6f1 1798
Davidroid 2:d07edeaff6f1 1799 /* Read function of the ID device */
nikapov 0:a1a69d32f310 1800 // virtual int read_id();
nikapov 0:a1a69d32f310 1801 virtual int read_id(uint8_t *id);
nikapov 0:a1a69d32f310 1802
nikapov 0:a1a69d32f310 1803 VL53L0X_Error wait_measurement_data_ready(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1804
nikapov 0:a1a69d32f310 1805 VL53L0X_Error wait_stop_completed(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 1806
nikapov 0:a1a69d32f310 1807 /* Write and read functions from I2C */
nikapov 0:a1a69d32f310 1808 /**
nikapov 0:a1a69d32f310 1809 * Write single byte register
nikapov 0:a1a69d32f310 1810 * @param dev Device Handle
nikapov 0:a1a69d32f310 1811 * @param index The register index
nikapov 0:a1a69d32f310 1812 * @param data 8 bit register data
nikapov 0:a1a69d32f310 1813 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1814 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1815 */
nikapov 0:a1a69d32f310 1816 VL53L0X_Error VL53L0X_write_byte(VL53L0X_DEV dev, uint8_t index, uint8_t data);
nikapov 0:a1a69d32f310 1817 /**
nikapov 0:a1a69d32f310 1818 * Write word register
nikapov 0:a1a69d32f310 1819 * @param dev Device Handle
nikapov 0:a1a69d32f310 1820 * @param index The register index
nikapov 0:a1a69d32f310 1821 * @param data 16 bit register data
nikapov 0:a1a69d32f310 1822 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1823 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1824 */
nikapov 0:a1a69d32f310 1825 VL53L0X_Error VL53L0X_write_word(VL53L0X_DEV dev, uint8_t index, uint16_t data);
nikapov 0:a1a69d32f310 1826 /**
nikapov 0:a1a69d32f310 1827 * Write double word (4 byte) register
nikapov 0:a1a69d32f310 1828 * @param dev Device Handle
nikapov 0:a1a69d32f310 1829 * @param index The register index
nikapov 0:a1a69d32f310 1830 * @param data 32 bit register data
nikapov 0:a1a69d32f310 1831 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1832 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1833 */
nikapov 0:a1a69d32f310 1834 VL53L0X_Error VL53L0X_write_dword(VL53L0X_DEV dev, uint8_t index, uint32_t data);
nikapov 0:a1a69d32f310 1835 /**
nikapov 0:a1a69d32f310 1836 * Read single byte register
nikapov 0:a1a69d32f310 1837 * @param dev Device Handle
nikapov 0:a1a69d32f310 1838 * @param index The register index
nikapov 0:a1a69d32f310 1839 * @param data pointer to 8 bit data
nikapov 0:a1a69d32f310 1840 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1841 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1842 */
nikapov 0:a1a69d32f310 1843 VL53L0X_Error VL53L0X_read_byte(VL53L0X_DEV dev, uint8_t index, uint8_t *p_data);
nikapov 0:a1a69d32f310 1844 /**
nikapov 0:a1a69d32f310 1845 * Read word (2byte) register
nikapov 0:a1a69d32f310 1846 * @param dev Device Handle
nikapov 0:a1a69d32f310 1847 * @param index The register index
nikapov 0:a1a69d32f310 1848 * @param data pointer to 16 bit data
nikapov 0:a1a69d32f310 1849 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1850 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1851 */
nikapov 0:a1a69d32f310 1852 VL53L0X_Error VL53L0X_read_word(VL53L0X_DEV dev, uint8_t index, uint16_t *p_data);
nikapov 0:a1a69d32f310 1853 /**
nikapov 0:a1a69d32f310 1854 * Read dword (4byte) register
nikapov 0:a1a69d32f310 1855 * @param dev Device Handle
nikapov 0:a1a69d32f310 1856 * @param index The register index
nikapov 0:a1a69d32f310 1857 * @param data pointer to 32 bit data
nikapov 0:a1a69d32f310 1858 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1859 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1860 */
nikapov 0:a1a69d32f310 1861 VL53L0X_Error VL53L0X_read_dword(VL53L0X_DEV dev, uint8_t index, uint32_t *p_data);
nikapov 0:a1a69d32f310 1862 /**
nikapov 0:a1a69d32f310 1863 * Threat safe Update (read/modify/write) single byte register
nikapov 0:a1a69d32f310 1864 *
nikapov 0:a1a69d32f310 1865 * Final_reg = (Initial_reg & and_data) |or_data
nikapov 0:a1a69d32f310 1866 *
nikapov 0:a1a69d32f310 1867 * @param dev Device Handle
nikapov 0:a1a69d32f310 1868 * @param index The register index
nikapov 0:a1a69d32f310 1869 * @param and_data 8 bit and data
nikapov 0:a1a69d32f310 1870 * @param or_data 8 bit or data
nikapov 0:a1a69d32f310 1871 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1872 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1873 */
nikapov 0:a1a69d32f310 1874 VL53L0X_Error VL53L0X_update_byte(VL53L0X_DEV dev, uint8_t index, uint8_t and_data, uint8_t or_data);
nikapov 0:a1a69d32f310 1875 /**
nikapov 0:a1a69d32f310 1876 * Writes the supplied byte buffer to the device
nikapov 0:a1a69d32f310 1877 * @param dev Device Handle
nikapov 0:a1a69d32f310 1878 * @param index The register index
nikapov 0:a1a69d32f310 1879 * @param p_data Pointer to uint8_t buffer containing the data to be written
nikapov 0:a1a69d32f310 1880 * @param count Number of bytes in the supplied byte buffer
nikapov 0:a1a69d32f310 1881 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1882 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1883 */
nikapov 0:a1a69d32f310 1884 VL53L0X_Error VL53L0X_write_multi(VL53L0X_DEV dev, uint8_t index, uint8_t *p_data, uint32_t count);
nikapov 0:a1a69d32f310 1885 /**
nikapov 0:a1a69d32f310 1886 * Reads the requested number of bytes from the device
nikapov 0:a1a69d32f310 1887 * @param dev Device Handle
nikapov 0:a1a69d32f310 1888 * @param index The register index
nikapov 0:a1a69d32f310 1889 * @param p_data Pointer to the uint8_t buffer to store read data
nikapov 0:a1a69d32f310 1890 * @param count Number of uint8_t's to read
nikapov 0:a1a69d32f310 1891 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1892 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1893 */
nikapov 0:a1a69d32f310 1894 VL53L0X_Error VL53L0X_read_multi(VL53L0X_DEV dev, uint8_t index, uint8_t *p_data, uint32_t count);
nikapov 0:a1a69d32f310 1895
nikapov 0:a1a69d32f310 1896 /**
nikapov 0:a1a69d32f310 1897 * @brief Writes a buffer towards the I2C peripheral device.
nikapov 0:a1a69d32f310 1898 * @param dev Device Handle
nikapov 0:a1a69d32f310 1899 * @param p_data pointer to the byte-array data to send
nikapov 0:a1a69d32f310 1900 * @param number_of_bytes number of bytes to be written.
nikapov 0:a1a69d32f310 1901 * @retval 0 if ok,
nikapov 0:a1a69d32f310 1902 * @retval -1 if an I2C error has occured
nikapov 0:a1a69d32f310 1903 * @note On some devices if NumByteToWrite is greater
nikapov 0:a1a69d32f310 1904 * than one, the RegisterAddr must be masked correctly!
nikapov 0:a1a69d32f310 1905 */
nikapov 0:a1a69d32f310 1906 VL53L0X_Error VL53L0X_i2c_write(uint8_t dev, uint8_t index, uint8_t *p_data, uint16_t number_of_bytes);
nikapov 0:a1a69d32f310 1907
nikapov 0:a1a69d32f310 1908 /**
nikapov 0:a1a69d32f310 1909 * @brief Reads a buffer from the I2C peripheral device.
nikapov 0:a1a69d32f310 1910 * @param dev Device Handle
nikapov 0:a1a69d32f310 1911 * @param p_data pointer to the byte-array to read data in to
nikapov 0:a1a69d32f310 1912 * @param number_of_bytes number of bytes to be read.
nikapov 0:a1a69d32f310 1913 * @retval 0 if ok,
nikapov 0:a1a69d32f310 1914 * @retval -1 if an I2C error has occured
nikapov 0:a1a69d32f310 1915 * @note On some devices if NumByteToWrite is greater
nikapov 0:a1a69d32f310 1916 * than one, the RegisterAddr must be masked correctly!
nikapov 0:a1a69d32f310 1917 */
nikapov 0:a1a69d32f310 1918 VL53L0X_Error VL53L0X_i2c_read(uint8_t dev, uint8_t index, uint8_t *p_data, uint16_t number_of_bytes);
nikapov 0:a1a69d32f310 1919
nikapov 0:a1a69d32f310 1920 /**
nikapov 0:a1a69d32f310 1921 * @brief execute delay in all polling API call
nikapov 0:a1a69d32f310 1922 *
nikapov 0:a1a69d32f310 1923 * A typical multi-thread or RTOs implementation is to sleep the task for some 5ms (with 100Hz max rate faster polling is not needed)
nikapov 0:a1a69d32f310 1924 * if nothing specific is need you can define it as an empty/void macro
nikapov 0:a1a69d32f310 1925 * @code
nikapov 0:a1a69d32f310 1926 * #define VL53L0X_PollingDelay(...) (void)0
nikapov 0:a1a69d32f310 1927 * @endcode
nikapov 0:a1a69d32f310 1928 * @param dev Device Handle
nikapov 0:a1a69d32f310 1929 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1930 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1931 */
nikapov 0:a1a69d32f310 1932 VL53L0X_Error VL53L0X_polling_delay(VL53L0X_DEV dev); /* usually best implemented as a real function */
nikapov 0:a1a69d32f310 1933
nikapov 0:a1a69d32f310 1934 int is_present()
nikapov 0:a1a69d32f310 1935 {
nikapov 0:a1a69d32f310 1936 int status;
nikapov 0:a1a69d32f310 1937 uint8_t id = 0;
nikapov 0:a1a69d32f310 1938
nikapov 0:a1a69d32f310 1939 status = read_id(&id);
sepp_nepp 5:b95f6951f7d5 1940
nikapov 0:a1a69d32f310 1941 return status;
nikapov 0:a1a69d32f310 1942 }
nikapov 0:a1a69d32f310 1943
nikapov 0:a1a69d32f310 1944 ///////////////////////////////////////////////////////////////////////////////////////////////////////
nikapov 0:a1a69d32f310 1945 //Added functions //
nikapov 0:a1a69d32f310 1946 ///////////////////////////////////////////////////////////////////////////////////////////////////////
nikapov 0:a1a69d32f310 1947
nikapov 0:a1a69d32f310 1948 /**
nikapov 0:a1a69d32f310 1949 * @brief Cycle Power to Device
nikapov 0:a1a69d32f310 1950 *
nikapov 0:a1a69d32f310 1951 * @return status - status 0 = ok, 1 = error
nikapov 0:a1a69d32f310 1952 *
nikapov 0:a1a69d32f310 1953 */
nikapov 0:a1a69d32f310 1954 int32_t VL53L0X_cycle_power(void);
nikapov 0:a1a69d32f310 1955
nikapov 0:a1a69d32f310 1956 uint8_t VL53L0X_encode_vcsel_period(uint8_t vcsel_period_pclks);
nikapov 0:a1a69d32f310 1957
nikapov 0:a1a69d32f310 1958 VL53L0X_Error wrapped_VL53L0X_get_device_error_string(VL53L0X_DeviceError error_code,
nikapov 0:a1a69d32f310 1959 char *p_device_error_string);
nikapov 0:a1a69d32f310 1960
nikapov 0:a1a69d32f310 1961 VL53L0X_Error wrapped_VL53L0X_get_limit_check_info(VL53L0X_DEV dev, uint16_t limit_check_id,
nikapov 0:a1a69d32f310 1962 char *p_limit_check_string);
nikapov 0:a1a69d32f310 1963
nikapov 0:a1a69d32f310 1964 VL53L0X_Error wrapped_VL53L0X_get_pal_error_string(VL53L0X_Error pal_error_code,
nikapov 0:a1a69d32f310 1965 char *p_pal_error_string);
nikapov 0:a1a69d32f310 1966
nikapov 0:a1a69d32f310 1967 VL53L0X_Error wrapped_VL53L0X_get_pal_state_string(VL53L0X_State pal_state_code,
nikapov 0:a1a69d32f310 1968 char *p_pal_state_string);
nikapov 0:a1a69d32f310 1969
nikapov 0:a1a69d32f310 1970 VL53L0X_Error wrapped_VL53L0X_get_range_status_string(uint8_t range_status,
nikapov 0:a1a69d32f310 1971 char *p_range_status_string);
nikapov 0:a1a69d32f310 1972
nikapov 0:a1a69d32f310 1973 VL53L0X_Error wrapped_VL53L0X_get_ref_calibration(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 1974 uint8_t *p_vhv_settings, uint8_t *p_phase_cal);
nikapov 0:a1a69d32f310 1975
nikapov 0:a1a69d32f310 1976
nikapov 0:a1a69d32f310 1977 VL53L0X_Error count_enabled_spads(uint8_t spad_array[],
nikapov 0:a1a69d32f310 1978 uint32_t byte_count, uint32_t max_spads,
nikapov 0:a1a69d32f310 1979 uint32_t *p_total_spads_enabled, uint8_t *p_is_aperture);
nikapov 0:a1a69d32f310 1980
nikapov 0:a1a69d32f310 1981 VL53L0X_Error wrapped_VL53L0X_get_sequence_steps_info(VL53L0X_SequenceStepId sequence_step_id,
nikapov 0:a1a69d32f310 1982 char *p_sequence_steps_string);
nikapov 0:a1a69d32f310 1983
nikapov 0:a1a69d32f310 1984
nikapov 0:a1a69d32f310 1985 /**
nikapov 0:a1a69d32f310 1986 * @brief Gets the name of a given sequence step.
nikapov 0:a1a69d32f310 1987 *
nikapov 0:a1a69d32f310 1988 * @par Function Description
nikapov 0:a1a69d32f310 1989 * This function retrieves the name of sequence steps corresponding to
nikapov 0:a1a69d32f310 1990 * SequenceStepId.
nikapov 0:a1a69d32f310 1991 *
nikapov 0:a1a69d32f310 1992 * @note This function doesn't Accesses the device
nikapov 0:a1a69d32f310 1993 *
nikapov 0:a1a69d32f310 1994 * @param sequence_step_id Sequence step identifier.
nikapov 0:a1a69d32f310 1995 * @param p_sequence_steps_string Pointer to Info string
nikapov 0:a1a69d32f310 1996 *
nikapov 0:a1a69d32f310 1997 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 1998 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 1999 */
nikapov 0:a1a69d32f310 2000 VL53L0X_Error VL53L0X_get_sequence_steps_info(VL53L0X_SequenceStepId sequence_step_id,
nikapov 0:a1a69d32f310 2001 char *p_sequence_steps_string);
nikapov 0:a1a69d32f310 2002
nikapov 0:a1a69d32f310 2003 /**
nikapov 0:a1a69d32f310 2004 * @brief Get the frequency of the timer used for ranging results time stamps
nikapov 0:a1a69d32f310 2005 *
nikapov 0:a1a69d32f310 2006 * @param[out] p_timer_freq_hz : pointer for timer frequency
nikapov 0:a1a69d32f310 2007 *
nikapov 0:a1a69d32f310 2008 * @return status : 0 = ok, 1 = error
nikapov 0:a1a69d32f310 2009 *
nikapov 0:a1a69d32f310 2010 */
nikapov 0:a1a69d32f310 2011 int32_t VL53L0X_get_timer_frequency(int32_t *p_timer_freq_hz);
nikapov 0:a1a69d32f310 2012
nikapov 0:a1a69d32f310 2013 /**
nikapov 0:a1a69d32f310 2014 * @brief Get the timer value in units of timer_freq_hz (see VL53L0X_get_timestamp_frequency())
nikapov 0:a1a69d32f310 2015 *
nikapov 0:a1a69d32f310 2016 * @param[out] p_timer_count : pointer for timer count value
nikapov 0:a1a69d32f310 2017 *
nikapov 0:a1a69d32f310 2018 * @return status : 0 = ok, 1 = error
nikapov 0:a1a69d32f310 2019 *
nikapov 0:a1a69d32f310 2020 */
nikapov 0:a1a69d32f310 2021 int32_t VL53L0X_get_timer_value(int32_t *p_timer_count);
nikapov 0:a1a69d32f310 2022
nikapov 0:a1a69d32f310 2023 /**
nikapov 0:a1a69d32f310 2024 * @brief Configure ranging interrupt reported to system
nikapov 0:a1a69d32f310 2025 *
nikapov 0:a1a69d32f310 2026 * @note This function is not Implemented
nikapov 0:a1a69d32f310 2027 *
nikapov 0:a1a69d32f310 2028 * @param dev Device Handle
nikapov 0:a1a69d32f310 2029 * @param interrupt_mask Mask of interrupt to Enable/disable
nikapov 0:a1a69d32f310 2030 * (0:interrupt disabled or 1: interrupt enabled)
nikapov 0:a1a69d32f310 2031 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
nikapov 0:a1a69d32f310 2032 */
nikapov 0:a1a69d32f310 2033 VL53L0X_Error VL53L0X_enable_interrupt_mask(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2034 uint32_t interrupt_mask);
nikapov 0:a1a69d32f310 2035
nikapov 0:a1a69d32f310 2036 /**
nikapov 0:a1a69d32f310 2037 * @brief Get Dmax Calibration Parameters for a given device
nikapov 0:a1a69d32f310 2038 *
nikapov 0:a1a69d32f310 2039 *
nikapov 0:a1a69d32f310 2040 * @note This function Access to the device
nikapov 0:a1a69d32f310 2041 *
nikapov 0:a1a69d32f310 2042 * @param dev Device Handle
nikapov 0:a1a69d32f310 2043 * @param p_range_milli_meter Pointer to Calibration Distance
nikapov 0:a1a69d32f310 2044 * @param p_signal_rate_rtn_mega_cps Pointer to Signal rate return
nikapov 0:a1a69d32f310 2045 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2046 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2047 */
nikapov 0:a1a69d32f310 2048 VL53L0X_Error VL53L0X_get_dmax_cal_parameters(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2049 uint16_t *p_range_milli_meter, FixPoint1616_t *p_signal_rate_rtn_mega_cps);
nikapov 0:a1a69d32f310 2050
nikapov 0:a1a69d32f310 2051 /**
nikapov 0:a1a69d32f310 2052 * @brief Set Dmax Calibration Parameters for a given device
nikapov 0:a1a69d32f310 2053 * When one of the parameter is zero, this function will get parameter
nikapov 0:a1a69d32f310 2054 * from NVM.
nikapov 0:a1a69d32f310 2055 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 2056 *
nikapov 0:a1a69d32f310 2057 * @param dev Device Handle
nikapov 0:a1a69d32f310 2058 * @param range_milli_meter Calibration Distance
nikapov 0:a1a69d32f310 2059 * @param signal_rate_rtn_mega_cps Signal rate return read at CalDistance
nikapov 0:a1a69d32f310 2060 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2061 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2062 */
nikapov 0:a1a69d32f310 2063 VL53L0X_Error VL53L0X_get_dmax_cal_parameters(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2064 uint16_t range_milli_meter, FixPoint1616_t signal_rate_rtn_mega_cps);
nikapov 0:a1a69d32f310 2065
nikapov 0:a1a69d32f310 2066 /**
nikapov 0:a1a69d32f310 2067 * @brief Retrieve the measurements from device for a given setup
nikapov 0:a1a69d32f310 2068 *
nikapov 0:a1a69d32f310 2069 * @par Function Description
nikapov 0:a1a69d32f310 2070 * Get data from last successful Histogram measurement
nikapov 0:a1a69d32f310 2071 * @warning USER should take care about @a VL53L0X_GetNumberOfROIZones()
nikapov 0:a1a69d32f310 2072 * before get data.
nikapov 0:a1a69d32f310 2073 * PAL will fill a NumberOfROIZones times the corresponding data structure
nikapov 0:a1a69d32f310 2074 * used in the measurement function.
nikapov 0:a1a69d32f310 2075 *
nikapov 0:a1a69d32f310 2076 * @note This function is not Implemented
nikapov 0:a1a69d32f310 2077 *
nikapov 0:a1a69d32f310 2078 * @param dev Device Handle
nikapov 0:a1a69d32f310 2079 * @param p_histogram_measurement_data Pointer to the histogram data structure.
nikapov 0:a1a69d32f310 2080 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
nikapov 0:a1a69d32f310 2081 */
nikapov 0:a1a69d32f310 2082 VL53L0X_Error VL53L0X_get_histogram_measurement_data(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2083 VL53L0X_HistogramMeasurementData_t *p_histogram_measurement_data);
nikapov 0:a1a69d32f310 2084
nikapov 0:a1a69d32f310 2085 /**
nikapov 0:a1a69d32f310 2086 * @brief Get current new device mode
nikapov 0:a1a69d32f310 2087 * @par Function Description
nikapov 0:a1a69d32f310 2088 * Get current Histogram mode of a Device
nikapov 0:a1a69d32f310 2089 *
nikapov 0:a1a69d32f310 2090 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 2091 *
nikapov 0:a1a69d32f310 2092 * @param dev Device Handle
nikapov 0:a1a69d32f310 2093 * @param p_histogram_mode Pointer to current Histogram Mode value
nikapov 0:a1a69d32f310 2094 * Valid values are:
nikapov 0:a1a69d32f310 2095 * VL53L0X_HISTOGRAMMODE_DISABLED
nikapov 0:a1a69d32f310 2096 * VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM
nikapov 0:a1a69d32f310 2097 * VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY
nikapov 0:a1a69d32f310 2098 * VL53L0X_HISTOGRAMMODE_RETURN_ONLY
nikapov 0:a1a69d32f310 2099 * VL53L0X_HISTOGRAMMODE_BOTH
nikapov 0:a1a69d32f310 2100 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2101 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2102 */
nikapov 0:a1a69d32f310 2103 VL53L0X_Error VL53L0X_get_histogram_mode(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2104 VL53L0X_HistogramModes *p_histogram_mode);
nikapov 0:a1a69d32f310 2105
nikapov 0:a1a69d32f310 2106 /**
nikapov 0:a1a69d32f310 2107 * @brief Set a new Histogram mode
nikapov 0:a1a69d32f310 2108 * @par Function Description
nikapov 0:a1a69d32f310 2109 * Set device to a new Histogram mode
nikapov 0:a1a69d32f310 2110 *
nikapov 0:a1a69d32f310 2111 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 2112 *
nikapov 0:a1a69d32f310 2113 * @param dev Device Handle
nikapov 0:a1a69d32f310 2114 * @param histogram_mode New device mode to apply
nikapov 0:a1a69d32f310 2115 * Valid values are:
nikapov 0:a1a69d32f310 2116 * VL53L0X_HISTOGRAMMODE_DISABLED
nikapov 0:a1a69d32f310 2117 * VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM
nikapov 0:a1a69d32f310 2118 * VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY
nikapov 0:a1a69d32f310 2119 * VL53L0X_HISTOGRAMMODE_RETURN_ONLY
nikapov 0:a1a69d32f310 2120 * VL53L0X_HISTOGRAMMODE_BOTH
nikapov 0:a1a69d32f310 2121 *
nikapov 0:a1a69d32f310 2122 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2123 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when
nikapov 0:a1a69d32f310 2124 * HistogramMode is not in the supported list
nikapov 0:a1a69d32f310 2125 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2126 */
nikapov 0:a1a69d32f310 2127 VL53L0X_Error VL53L0X_set_histogram_mode(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2128 VL53L0X_HistogramModes histogram_mode);
nikapov 0:a1a69d32f310 2129
nikapov 0:a1a69d32f310 2130 /**
nikapov 0:a1a69d32f310 2131 * @brief Return a description string for a given limit check number
nikapov 0:a1a69d32f310 2132 *
nikapov 0:a1a69d32f310 2133 * @par Function Description
nikapov 0:a1a69d32f310 2134 * This function returns a description string for a given limit check number.
nikapov 0:a1a69d32f310 2135 * The limit check is identified with the LimitCheckId.
nikapov 0:a1a69d32f310 2136 *
nikapov 0:a1a69d32f310 2137 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 2138 *
nikapov 0:a1a69d32f310 2139 * @param dev Device Handle
nikapov 0:a1a69d32f310 2140 * @param limit_check_id Limit Check ID
nikapov 0:a1a69d32f310 2141 (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
nikapov 0:a1a69d32f310 2142 * @param p_limit_check_string Pointer to the
nikapov 0:a1a69d32f310 2143 description string of the given check limit.
nikapov 0:a1a69d32f310 2144 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2145 * @return VL53L0X_ERROR_INVALID_PARAMS This error is
nikapov 0:a1a69d32f310 2146 returned when LimitCheckId value is out of range.
nikapov 0:a1a69d32f310 2147 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2148 */
nikapov 0:a1a69d32f310 2149 VL53L0X_Error VL53L0X_get_limit_check_info(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2150 uint16_t limit_check_id, char *p_limit_check_string);
nikapov 0:a1a69d32f310 2151
nikapov 0:a1a69d32f310 2152 /**
nikapov 0:a1a69d32f310 2153 * @brief Get the linearity corrective gain
nikapov 0:a1a69d32f310 2154 *
nikapov 0:a1a69d32f310 2155 * @par Function Description
nikapov 0:a1a69d32f310 2156 * Should only be used after a successful call to @a VL53L0X_DataInit to backup
nikapov 0:a1a69d32f310 2157 * device NVM value
nikapov 0:a1a69d32f310 2158 *
nikapov 0:a1a69d32f310 2159 * @note This function Access to the device
nikapov 0:a1a69d32f310 2160 *
nikapov 0:a1a69d32f310 2161 * @param dev Device Handle
nikapov 0:a1a69d32f310 2162 * @param p_linearity_corrective_gain Pointer to the linearity
nikapov 0:a1a69d32f310 2163 * corrective gain in x1000
nikapov 0:a1a69d32f310 2164 * if value is 1000 then no modification is applied.
nikapov 0:a1a69d32f310 2165 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2166 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2167 */
nikapov 0:a1a69d32f310 2168 VL53L0X_Error VL53L0X_get_linearity_corrective_gain(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2169 uint16_t *p_linearity_corrective_gain);
nikapov 0:a1a69d32f310 2170
nikapov 0:a1a69d32f310 2171 /**
nikapov 0:a1a69d32f310 2172 * Set the linearity corrective gain
nikapov 0:a1a69d32f310 2173 *
nikapov 0:a1a69d32f310 2174 * @note This function Access to the device
nikapov 0:a1a69d32f310 2175 *
nikapov 0:a1a69d32f310 2176 * @param dev Device Handle
nikapov 0:a1a69d32f310 2177 * @param linearity_corrective_gain Linearity corrective
nikapov 0:a1a69d32f310 2178 * gain in x1000
nikapov 0:a1a69d32f310 2179 * if value is 1000 then no modification is applied.
nikapov 0:a1a69d32f310 2180 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2181 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2182 */
nikapov 0:a1a69d32f310 2183 VL53L0X_Error VL53L0X_set_linearity_corrective_gain(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2184 int16_t linearity_corrective_gain);
nikapov 0:a1a69d32f310 2185
nikapov 0:a1a69d32f310 2186 /**
nikapov 0:a1a69d32f310 2187 * @brief Get the Maximum number of ROI Zones managed by the Device
nikapov 0:a1a69d32f310 2188 *
nikapov 0:a1a69d32f310 2189 * @par Function Description
nikapov 0:a1a69d32f310 2190 * Get Maximum number of ROI Zones managed by the Device.
nikapov 0:a1a69d32f310 2191 *
nikapov 0:a1a69d32f310 2192 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 2193 *
nikapov 0:a1a69d32f310 2194 * @param dev Device Handle
nikapov 0:a1a69d32f310 2195 * @param p_max_number_of_roi_zones Pointer to the Maximum Number
nikapov 0:a1a69d32f310 2196 * of ROI Zones value.
nikapov 0:a1a69d32f310 2197 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2198 */
nikapov 0:a1a69d32f310 2199 VL53L0X_Error VL53L0X_get_max_number_of_roi_zones(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2200 uint8_t *p_max_number_of_roi_zones);
nikapov 0:a1a69d32f310 2201
nikapov 0:a1a69d32f310 2202 /**
nikapov 0:a1a69d32f310 2203 * @brief Retrieve the Reference Signal after a measurements
nikapov 0:a1a69d32f310 2204 *
nikapov 0:a1a69d32f310 2205 * @par Function Description
nikapov 0:a1a69d32f310 2206 * Get Reference Signal from last successful Ranging measurement
nikapov 0:a1a69d32f310 2207 * This function return a valid value after that you call the
nikapov 0:a1a69d32f310 2208 * @a VL53L0X_GetRangingMeasurementData().
nikapov 0:a1a69d32f310 2209 *
nikapov 0:a1a69d32f310 2210 * @note This function Access to the device
nikapov 0:a1a69d32f310 2211 *
nikapov 0:a1a69d32f310 2212 * @param dev Device Handle
nikapov 0:a1a69d32f310 2213 * @param p_measurement_ref_signal Pointer to the Ref Signal to fill up.
nikapov 0:a1a69d32f310 2214 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2215 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2216 */
nikapov 0:a1a69d32f310 2217 VL53L0X_Error VL53L0X_get_measurement_ref_signal(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2218 FixPoint1616_t *p_measurement_ref_signal);
nikapov 0:a1a69d32f310 2219
nikapov 0:a1a69d32f310 2220 /**
nikapov 0:a1a69d32f310 2221 * @brief Get the number of the check limit managed by a given Device
nikapov 0:a1a69d32f310 2222 *
nikapov 0:a1a69d32f310 2223 * @par Function Description
nikapov 0:a1a69d32f310 2224 * This function give the number of the check limit managed by the Device
nikapov 0:a1a69d32f310 2225 *
nikapov 0:a1a69d32f310 2226 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 2227 *
nikapov 0:a1a69d32f310 2228 * @param p_number_of_limit_check Pointer to the number of check limit.
nikapov 0:a1a69d32f310 2229 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2230 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2231 */
nikapov 0:a1a69d32f310 2232 VL53L0X_Error VL53L0X_get_number_of_limit_check(
nikapov 0:a1a69d32f310 2233 uint16_t *p_number_of_limit_check);
nikapov 0:a1a69d32f310 2234
nikapov 0:a1a69d32f310 2235 /**
nikapov 0:a1a69d32f310 2236 * @brief Get the number of ROI Zones managed by the Device
nikapov 0:a1a69d32f310 2237 *
nikapov 0:a1a69d32f310 2238 * @par Function Description
nikapov 0:a1a69d32f310 2239 * Get number of ROI Zones managed by the Device
nikapov 0:a1a69d32f310 2240 * USER should take care about @a VL53L0X_GetNumberOfROIZones()
nikapov 0:a1a69d32f310 2241 * before get data after a perform measurement.
nikapov 0:a1a69d32f310 2242 * PAL will fill a NumberOfROIZones times the corresponding data
nikapov 0:a1a69d32f310 2243 * structure used in the measurement function.
nikapov 0:a1a69d32f310 2244 *
nikapov 0:a1a69d32f310 2245 * @note This function doesn't Access to the device
nikapov 0:a1a69d32f310 2246 *
nikapov 0:a1a69d32f310 2247 * @param dev Device Handle
nikapov 0:a1a69d32f310 2248 * @param p_number_of_roi_zones Pointer to the Number of ROI Zones value.
nikapov 0:a1a69d32f310 2249 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2250 */
nikapov 0:a1a69d32f310 2251 VL53L0X_Error VL53L0X_get_number_of_roi_zones(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2252 uint8_t *p_number_of_roi_zones);
nikapov 0:a1a69d32f310 2253
nikapov 0:a1a69d32f310 2254 /**
nikapov 0:a1a69d32f310 2255 * @brief Set the number of ROI Zones to be used for a specific Device
nikapov 0:a1a69d32f310 2256 *
nikapov 0:a1a69d32f310 2257 * @par Function Description
nikapov 0:a1a69d32f310 2258 * Set the number of ROI Zones to be used for a specific Device.
nikapov 0:a1a69d32f310 2259 * The programmed value should be less than the max number of ROI Zones given
nikapov 0:a1a69d32f310 2260 * with @a VL53L0X_GetMaxNumberOfROIZones().
nikapov 0:a1a69d32f310 2261 * This version of API manage only one zone.
nikapov 0:a1a69d32f310 2262 *
nikapov 0:a1a69d32f310 2263 * @param dev Device Handle
nikapov 0:a1a69d32f310 2264 * @param number_of_roi_zones Number of ROI Zones to be used for a
nikapov 0:a1a69d32f310 2265 * specific Device.
nikapov 0:a1a69d32f310 2266 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2267 * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned if
nikapov 0:a1a69d32f310 2268 * NumberOfROIZones != 1
nikapov 0:a1a69d32f310 2269 */
nikapov 0:a1a69d32f310 2270 VL53L0X_Error VL53L0X_set_number_of_roi_zones(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2271 uint8_t number_of_roi_zones);
nikapov 0:a1a69d32f310 2272
nikapov 0:a1a69d32f310 2273 /**
nikapov 0:a1a69d32f310 2274 * @brief Gets number of sequence steps managed by the API.
nikapov 0:a1a69d32f310 2275 *
nikapov 0:a1a69d32f310 2276 * @par Function Description
nikapov 0:a1a69d32f310 2277 * This function retrieves the number of sequence steps currently managed
nikapov 0:a1a69d32f310 2278 * by the API
nikapov 0:a1a69d32f310 2279 *
nikapov 0:a1a69d32f310 2280 * @note This function Accesses the device
nikapov 0:a1a69d32f310 2281 *
nikapov 0:a1a69d32f310 2282 * @param dev Device Handle
nikapov 0:a1a69d32f310 2283 * @param p_number_of_sequence_steps Out parameter reporting the number of
nikapov 0:a1a69d32f310 2284 * sequence steps.
nikapov 0:a1a69d32f310 2285 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2286 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2287 */
nikapov 0:a1a69d32f310 2288 VL53L0X_Error VL53L0X_get_number_of_sequence_steps(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2289 uint8_t *p_number_of_sequence_steps);
nikapov 0:a1a69d32f310 2290 /**
nikapov 0:a1a69d32f310 2291 * @brief Get the power mode for a given Device
nikapov 0:a1a69d32f310 2292 *
nikapov 0:a1a69d32f310 2293 * @note This function Access to the device
nikapov 0:a1a69d32f310 2294 *
nikapov 0:a1a69d32f310 2295 * @param dev Device Handle
nikapov 0:a1a69d32f310 2296 * @param p_power_mode Pointer to the current value of the power
nikapov 0:a1a69d32f310 2297 * mode. see ::VL53L0X_PowerModes
nikapov 0:a1a69d32f310 2298 * Valid values are:
nikapov 0:a1a69d32f310 2299 * VL53L0X_POWERMODE_STANDBY_LEVEL1,
nikapov 0:a1a69d32f310 2300 * VL53L0X_POWERMODE_IDLE_LEVEL1
nikapov 0:a1a69d32f310 2301 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2302 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2303 */
nikapov 0:a1a69d32f310 2304 VL53L0X_Error VL53L0X_get_power_mode(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2305 VL53L0X_PowerModes *p_power_mode);
nikapov 0:a1a69d32f310 2306
nikapov 0:a1a69d32f310 2307 /**
nikapov 0:a1a69d32f310 2308 * @brief Set the power mode for a given Device
nikapov 0:a1a69d32f310 2309 * The power mode can be Standby or Idle. Different level of both Standby and
nikapov 0:a1a69d32f310 2310 * Idle can exists.
nikapov 0:a1a69d32f310 2311 * This function should not be used when device is in Ranging state.
nikapov 0:a1a69d32f310 2312 *
nikapov 0:a1a69d32f310 2313 * @note This function Access to the device
nikapov 0:a1a69d32f310 2314 *
nikapov 0:a1a69d32f310 2315 * @param dev Device Handle
nikapov 0:a1a69d32f310 2316 * @param power_mode The value of the power mode to set.
nikapov 0:a1a69d32f310 2317 * see ::VL53L0X_PowerModes
nikapov 0:a1a69d32f310 2318 * Valid values are:
nikapov 0:a1a69d32f310 2319 * VL53L0X_POWERMODE_STANDBY_LEVEL1,
nikapov 0:a1a69d32f310 2320 * VL53L0X_POWERMODE_IDLE_LEVEL1
nikapov 0:a1a69d32f310 2321 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2322 * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when PowerMode
nikapov 0:a1a69d32f310 2323 * is not in the supported list
nikapov 0:a1a69d32f310 2324 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2325 */
nikapov 0:a1a69d32f310 2326 VL53L0X_Error VL53L0X_set_power_mode(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2327 VL53L0X_PowerModes power_mode);
nikapov 0:a1a69d32f310 2328
nikapov 0:a1a69d32f310 2329 /**
nikapov 0:a1a69d32f310 2330 * @brief Retrieves SPAD configuration
nikapov 0:a1a69d32f310 2331 *
nikapov 0:a1a69d32f310 2332 * @par Function Description
nikapov 0:a1a69d32f310 2333 * This function retrieves the current number of applied reference spads
nikapov 0:a1a69d32f310 2334 * and also their type : Aperture or Non-Aperture.
nikapov 0:a1a69d32f310 2335 *
nikapov 0:a1a69d32f310 2336 * @note This function Access to the device
nikapov 0:a1a69d32f310 2337 *
nikapov 0:a1a69d32f310 2338 * @param dev Device Handle
nikapov 0:a1a69d32f310 2339 * @param p_spad_count Number ref Spad Count
nikapov 0:a1a69d32f310 2340 * @param p_is_aperture_spads Reports if spads are of type
nikapov 0:a1a69d32f310 2341 * aperture or non-aperture.
nikapov 0:a1a69d32f310 2342 * 1:=aperture, 0:=Non-Aperture
nikapov 0:a1a69d32f310 2343 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2344 * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the in the reference
nikapov 0:a1a69d32f310 2345 * spad configuration.
nikapov 0:a1a69d32f310 2346 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2347 */
nikapov 0:a1a69d32f310 2348 VL53L0X_Error wrapped_VL53L0X_get_reference_spads(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2349 uint32_t *p_spad_count, uint8_t *p_is_aperture_spads);
nikapov 0:a1a69d32f310 2350
nikapov 0:a1a69d32f310 2351 /**
nikapov 0:a1a69d32f310 2352 * @brief Gets the (on/off) state of a requested sequence step.
nikapov 0:a1a69d32f310 2353 *
nikapov 0:a1a69d32f310 2354 * @par Function Description
nikapov 0:a1a69d32f310 2355 * This function retrieves the state of a requested sequence step, i.e. on/off.
nikapov 0:a1a69d32f310 2356 *
nikapov 0:a1a69d32f310 2357 * @note This function Accesses the device
nikapov 0:a1a69d32f310 2358 *
nikapov 0:a1a69d32f310 2359 * @param dev Device Handle
nikapov 0:a1a69d32f310 2360 * @param sequence_step_id Sequence step identifier.
nikapov 0:a1a69d32f310 2361 * @param p_sequence_step_enabled Out parameter reporting if the sequence step
nikapov 0:a1a69d32f310 2362 * is enabled {0=Off,1=On}.
nikapov 0:a1a69d32f310 2363 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2364 * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not
nikapov 0:a1a69d32f310 2365 * supported.
nikapov 0:a1a69d32f310 2366 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2367 */
nikapov 0:a1a69d32f310 2368 VL53L0X_Error VL53L0X_get_sequence_step_enable(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2369 VL53L0X_SequenceStepId sequence_step_id, uint8_t *p_sequence_step_enabled);
nikapov 0:a1a69d32f310 2370
nikapov 0:a1a69d32f310 2371
nikapov 0:a1a69d32f310 2372 /**
nikapov 0:a1a69d32f310 2373 * @brief Gets the timeout of a requested sequence step.
nikapov 0:a1a69d32f310 2374 *
nikapov 0:a1a69d32f310 2375 * @par Function Description
nikapov 0:a1a69d32f310 2376 * This function retrieves the timeout of a requested sequence step.
nikapov 0:a1a69d32f310 2377 *
nikapov 0:a1a69d32f310 2378 * @note This function Accesses the device
nikapov 0:a1a69d32f310 2379 *
nikapov 0:a1a69d32f310 2380 * @param dev Device Handle
nikapov 0:a1a69d32f310 2381 * @param sequence_step_id Sequence step identifier.
nikapov 0:a1a69d32f310 2382 * @param p_time_out_milli_secs Timeout value.
nikapov 0:a1a69d32f310 2383 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2384 * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not
nikapov 0:a1a69d32f310 2385 * supported.
nikapov 0:a1a69d32f310 2386 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2387 */
nikapov 0:a1a69d32f310 2388 VL53L0X_Error VL53L0X_get_sequence_step_timeout(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2389 VL53L0X_SequenceStepId sequence_step_id,
nikapov 0:a1a69d32f310 2390 FixPoint1616_t *p_time_out_milli_secs);
nikapov 0:a1a69d32f310 2391
nikapov 0:a1a69d32f310 2392 /**
nikapov 0:a1a69d32f310 2393 * @brief Sets the timeout of a requested sequence step.
nikapov 0:a1a69d32f310 2394 *
nikapov 0:a1a69d32f310 2395 * @par Function Description
nikapov 0:a1a69d32f310 2396 * This function sets the timeout of a requested sequence step.
nikapov 0:a1a69d32f310 2397 *
nikapov 0:a1a69d32f310 2398 * @note This function Accesses the device
nikapov 0:a1a69d32f310 2399 *
nikapov 0:a1a69d32f310 2400 * @param dev Device Handle
nikapov 0:a1a69d32f310 2401 * @param sequence_step_id Sequence step identifier.
nikapov 0:a1a69d32f310 2402 * @param time_out_milli_secs Demanded timeout
nikapov 0:a1a69d32f310 2403 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2404 * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not
nikapov 0:a1a69d32f310 2405 * supported.
nikapov 0:a1a69d32f310 2406 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2407 */
nikapov 0:a1a69d32f310 2408 VL53L0X_Error VL53L0X_set_sequence_step_timeout(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2409 VL53L0X_SequenceStepId sequence_step_id, FixPoint1616_t time_out_milli_secs);
nikapov 0:a1a69d32f310 2410
nikapov 0:a1a69d32f310 2411 /**
nikapov 0:a1a69d32f310 2412 * @brief Get the current SPAD Ambient Damper Factor value
nikapov 0:a1a69d32f310 2413 *
nikapov 0:a1a69d32f310 2414 * @par Function Description
nikapov 0:a1a69d32f310 2415 * This function get the SPAD Ambient Damper Factor value
nikapov 0:a1a69d32f310 2416 *
nikapov 0:a1a69d32f310 2417 * @note This function Access to the device
nikapov 0:a1a69d32f310 2418 *
nikapov 0:a1a69d32f310 2419 * @param dev Device Handle
nikapov 0:a1a69d32f310 2420 * @param p_spad_ambient_damper_factor Pointer to programmed SPAD Ambient
nikapov 0:a1a69d32f310 2421 * Damper Factor value
nikapov 0:a1a69d32f310 2422 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2423 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2424 */
nikapov 0:a1a69d32f310 2425 VL53L0X_Error VL53L0X_get_spad_ambient_damper_factor(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2426 uint16_t *p_spad_ambient_damper_factor);
nikapov 0:a1a69d32f310 2427 /**
nikapov 0:a1a69d32f310 2428 * @brief Set the SPAD Ambient Damper Factor value
nikapov 0:a1a69d32f310 2429 *
nikapov 0:a1a69d32f310 2430 * @par Function Description
nikapov 0:a1a69d32f310 2431 * This function set the SPAD Ambient Damper Factor value
nikapov 0:a1a69d32f310 2432 *
nikapov 0:a1a69d32f310 2433 * @note This function Access to the device
nikapov 0:a1a69d32f310 2434 *
nikapov 0:a1a69d32f310 2435 * @param dev Device Handle
nikapov 0:a1a69d32f310 2436 * @param spad_ambient_damper_factor SPAD Ambient Damper Factor value
nikapov 0:a1a69d32f310 2437 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2438 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2439 */
nikapov 0:a1a69d32f310 2440 VL53L0X_Error VL53L0X_set_spad_ambient_damper_factor(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2441 uint16_t spad_ambient_damper_factor);
nikapov 0:a1a69d32f310 2442
nikapov 0:a1a69d32f310 2443 /**
nikapov 0:a1a69d32f310 2444 * @brief Get the current SPAD Ambient Damper Threshold value
nikapov 0:a1a69d32f310 2445 *
nikapov 0:a1a69d32f310 2446 * @par Function Description
nikapov 0:a1a69d32f310 2447 * This function get the SPAD Ambient Damper Threshold value
nikapov 0:a1a69d32f310 2448 *
nikapov 0:a1a69d32f310 2449 * @note This function Access to the device
nikapov 0:a1a69d32f310 2450 *
nikapov 0:a1a69d32f310 2451 * @param dev Device Handle
nikapov 0:a1a69d32f310 2452 * @param p_spad_ambient_damper_threshold Pointer to programmed
nikapov 0:a1a69d32f310 2453 * SPAD Ambient Damper Threshold value
nikapov 0:a1a69d32f310 2454 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2455 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2456 */
nikapov 0:a1a69d32f310 2457 VL53L0X_Error VL53L0X_get_spad_ambient_damper_threshold(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2458 uint16_t *p_spad_ambient_damper_threshold);
nikapov 0:a1a69d32f310 2459
nikapov 0:a1a69d32f310 2460 /**
nikapov 0:a1a69d32f310 2461 * @brief Set the SPAD Ambient Damper Threshold value
nikapov 0:a1a69d32f310 2462 *
nikapov 0:a1a69d32f310 2463 * @par Function Description
nikapov 0:a1a69d32f310 2464 * This function set the SPAD Ambient Damper Threshold value
nikapov 0:a1a69d32f310 2465 *
nikapov 0:a1a69d32f310 2466 * @note This function Access to the device
nikapov 0:a1a69d32f310 2467 *
nikapov 0:a1a69d32f310 2468 * @param dev Device Handle
nikapov 0:a1a69d32f310 2469 * @param spad_ambient_damper_threshold SPAD Ambient Damper Threshold value
nikapov 0:a1a69d32f310 2470 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2471 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2472 */
nikapov 0:a1a69d32f310 2473 VL53L0X_Error VL53L0X_set_spad_ambient_damper_threshold(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2474 uint16_t spad_ambient_damper_threshold);
nikapov 0:a1a69d32f310 2475
nikapov 0:a1a69d32f310 2476 /**
nikapov 0:a1a69d32f310 2477 * @brief Get the maximal distance for actual setup
nikapov 0:a1a69d32f310 2478 * @par Function Description
nikapov 0:a1a69d32f310 2479 * Device must be initialized through @a VL53L0X_SetParameters() prior calling
nikapov 0:a1a69d32f310 2480 * this function.
nikapov 0:a1a69d32f310 2481 *
nikapov 0:a1a69d32f310 2482 * Any range value more than the value returned is to be considered as
nikapov 0:a1a69d32f310 2483 * "no target detected" or
nikapov 0:a1a69d32f310 2484 * "no target in detectable range"\n
nikapov 0:a1a69d32f310 2485 * @warning The maximal distance depends on the setup
nikapov 0:a1a69d32f310 2486 *
nikapov 0:a1a69d32f310 2487 * @note This function is not Implemented
nikapov 0:a1a69d32f310 2488 *
nikapov 0:a1a69d32f310 2489 * @param dev Device Handle
nikapov 0:a1a69d32f310 2490 * @param p_upper_limit_milli_meter The maximal range limit for actual setup
nikapov 0:a1a69d32f310 2491 * (in millimeter)
nikapov 0:a1a69d32f310 2492 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
nikapov 0:a1a69d32f310 2493 */
nikapov 0:a1a69d32f310 2494 VL53L0X_Error VL53L0X_get_upper_limit_milli_meter(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2495 uint16_t *p_upper_limit_milli_meter);
nikapov 0:a1a69d32f310 2496
nikapov 0:a1a69d32f310 2497 /**
nikapov 0:a1a69d32f310 2498 * @brief Get the tuning settings pointer and the internal external switch
nikapov 0:a1a69d32f310 2499 * value.
nikapov 0:a1a69d32f310 2500 *
nikapov 0:a1a69d32f310 2501 * This function is used to get the Tuning settings buffer pointer and the
nikapov 0:a1a69d32f310 2502 * value.
nikapov 0:a1a69d32f310 2503 * of the switch to select either external or internal tuning settings.
nikapov 0:a1a69d32f310 2504 *
nikapov 0:a1a69d32f310 2505 * @note This function Access to the device
nikapov 0:a1a69d32f310 2506 *
nikapov 0:a1a69d32f310 2507 * @param dev Device Handle
nikapov 0:a1a69d32f310 2508 * @param pp_tuning_setting_buffer Pointer to tuning settings buffer.
nikapov 0:a1a69d32f310 2509 * @param p_use_internal_tuning_settings Pointer to store Use internal tuning
nikapov 0:a1a69d32f310 2510 * settings value.
nikapov 0:a1a69d32f310 2511 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2512 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2513 */
nikapov 0:a1a69d32f310 2514 VL53L0X_Error VL53L0X_get_tuning_setting_buffer(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2515 uint8_t **pp_tuning_setting_buffer, uint8_t *p_use_internal_tuning_settings);
nikapov 0:a1a69d32f310 2516
nikapov 0:a1a69d32f310 2517 /**
nikapov 0:a1a69d32f310 2518 * @brief Set the tuning settings pointer
nikapov 0:a1a69d32f310 2519 *
nikapov 0:a1a69d32f310 2520 * This function is used to specify the Tuning settings buffer to be used
nikapov 0:a1a69d32f310 2521 * for a given device. The buffer contains all the necessary data to permit
nikapov 0:a1a69d32f310 2522 * the API to write tuning settings.
nikapov 0:a1a69d32f310 2523 * This function permit to force the usage of either external or internal
nikapov 0:a1a69d32f310 2524 * tuning settings.
nikapov 0:a1a69d32f310 2525 *
nikapov 0:a1a69d32f310 2526 * @note This function Access to the device
nikapov 0:a1a69d32f310 2527 *
nikapov 0:a1a69d32f310 2528 * @param dev Device Handle
nikapov 0:a1a69d32f310 2529 * @param p_tuning_setting_buffer Pointer to tuning settings buffer.
nikapov 0:a1a69d32f310 2530 * @param use_internal_tuning_settings Use internal tuning settings value.
nikapov 0:a1a69d32f310 2531 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2532 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2533 */
nikapov 0:a1a69d32f310 2534 VL53L0X_Error VL53L0X_set_tuning_setting_buffer(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2535 uint8_t *p_tuning_setting_buffer, uint8_t use_internal_tuning_settings);
nikapov 0:a1a69d32f310 2536
nikapov 0:a1a69d32f310 2537 /**
nikapov 0:a1a69d32f310 2538 * @defgroup VL53L0X_registerAccess_group PAL Register Access Functions
nikapov 0:a1a69d32f310 2539 * @brief PAL Register Access Functions
nikapov 0:a1a69d32f310 2540 * @{
nikapov 0:a1a69d32f310 2541 */
nikapov 0:a1a69d32f310 2542
nikapov 0:a1a69d32f310 2543 /**
nikapov 0:a1a69d32f310 2544 * Lock comms interface to serialize all commands to a shared I2C interface for a specific device
nikapov 0:a1a69d32f310 2545 * @param dev Device Handle
nikapov 0:a1a69d32f310 2546 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2547 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2548 */
nikapov 0:a1a69d32f310 2549 VL53L0X_Error VL53L0X_lock_sequence_access(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 2550
nikapov 0:a1a69d32f310 2551 /**
nikapov 0:a1a69d32f310 2552 * Unlock comms interface to serialize all commands to a shared I2C interface for a specific device
nikapov 0:a1a69d32f310 2553 * @param dev Device Handle
nikapov 0:a1a69d32f310 2554 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2555 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2556 */
nikapov 0:a1a69d32f310 2557 VL53L0X_Error VL53L0X_unlock_sequence_access(VL53L0X_DEV dev);
nikapov 0:a1a69d32f310 2558
nikapov 0:a1a69d32f310 2559 /**
nikapov 0:a1a69d32f310 2560 * @brief Prepare device for operation
nikapov 0:a1a69d32f310 2561 * @par Function Description
nikapov 0:a1a69d32f310 2562 * Update device with provided parameters
nikapov 0:a1a69d32f310 2563 * @li Then start ranging operation.
nikapov 0:a1a69d32f310 2564 *
nikapov 0:a1a69d32f310 2565 * @note This function Access to the device
nikapov 0:a1a69d32f310 2566 *
nikapov 0:a1a69d32f310 2567 * @param Dev Device Handle
nikapov 0:a1a69d32f310 2568 * @param pDeviceParameters Pointer to store current device parameters.
nikapov 0:a1a69d32f310 2569 * @return VL53L0X_ERROR_NONE Success
nikapov 0:a1a69d32f310 2570 * @return "Other error code" See ::VL53L0X_Error
nikapov 0:a1a69d32f310 2571 */
nikapov 0:a1a69d32f310 2572 VL53L0X_Error vl53L0x_set_device_parameters(VL53L0X_DEV Dev,
nikapov 0:a1a69d32f310 2573 const VL53L0X_DeviceParameters_t *pDeviceParameters);
nikapov 0:a1a69d32f310 2574
nikapov 0:a1a69d32f310 2575 /**
nikapov 0:a1a69d32f310 2576 * Set Group parameter Hold state
nikapov 0:a1a69d32f310 2577 *
nikapov 0:a1a69d32f310 2578 * @par Function Description
nikapov 0:a1a69d32f310 2579 * Set or remove device internal group parameter hold
nikapov 0:a1a69d32f310 2580 *
nikapov 0:a1a69d32f310 2581 * @note This function is not Implemented
nikapov 0:a1a69d32f310 2582 *
nikapov 0:a1a69d32f310 2583 * @param dev Device Handle
nikapov 0:a1a69d32f310 2584 * @param group_param_hold Group parameter Hold state to be set (on/off)
nikapov 0:a1a69d32f310 2585 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
nikapov 0:a1a69d32f310 2586 */
nikapov 0:a1a69d32f310 2587 VL53L0X_Error VL53L0X_set_group_param_hold(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2588 uint8_t group_param_hold);
nikapov 0:a1a69d32f310 2589
nikapov 0:a1a69d32f310 2590
nikapov 0:a1a69d32f310 2591 /**
nikapov 0:a1a69d32f310 2592 * @brief Wait for device ready for a new measurement command.
nikapov 0:a1a69d32f310 2593 * Blocking function.
nikapov 0:a1a69d32f310 2594 *
nikapov 0:a1a69d32f310 2595 * @note This function is not Implemented
nikapov 0:a1a69d32f310 2596 *
nikapov 0:a1a69d32f310 2597 * @param dev Device Handle
nikapov 0:a1a69d32f310 2598 * @param max_loop Max Number of polling loop (timeout).
nikapov 0:a1a69d32f310 2599 * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
nikapov 0:a1a69d32f310 2600 */
nikapov 0:a1a69d32f310 2601 VL53L0X_Error VL53L0X_wait_device_ready_for_new_measurement(VL53L0X_DEV dev,
nikapov 0:a1a69d32f310 2602 uint32_t max_loop);
nikapov 0:a1a69d32f310 2603
nikapov 0:a1a69d32f310 2604 VL53L0X_Error VL53L0X_reverse_bytes(uint8_t *data, uint32_t size);
nikapov 0:a1a69d32f310 2605
nikapov 0:a1a69d32f310 2606 int range_meas_int_continuous_mode(void (*fptr)(void));
nikapov 0:a1a69d32f310 2607
nikapov 0:a1a69d32f310 2608
nikapov 0:a1a69d32f310 2609 VL53L0X_DeviceInfo_t _device_info;
nikapov 0:a1a69d32f310 2610
nikapov 0:a1a69d32f310 2611 /* IO Device */
nikapov 0:a1a69d32f310 2612 DevI2C *_dev_i2c;
nikapov 0:a1a69d32f310 2613 /* Digital out pin */
nikapov 0:a1a69d32f310 2614 DigitalOut *_gpio0;
nikapov 0:a1a69d32f310 2615 /* Measure detection IRQ */
nikapov 0:a1a69d32f310 2616 InterruptIn *_gpio1Int;
nikapov 0:a1a69d32f310 2617 /* Device data */
nikapov 0:a1a69d32f310 2618 VL53L0X_Dev_t _my_device;
nikapov 0:a1a69d32f310 2619 VL53L0X_DEV _device;
nikapov 0:a1a69d32f310 2620 };
nikapov 0:a1a69d32f310 2621
nikapov 0:a1a69d32f310 2622
nikapov 0:a1a69d32f310 2623 #endif /* _VL53L0X_CLASS_H_ */