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