Condensed Version of Public VL53L0X
VL53L0X.h@12:aa177f0e4c10, 2019-04-10 (annotated)
- Committer:
- sepp_nepp
- Date:
- Wed Apr 10 19:03:16 2019 +0000
- Revision:
- 12:aa177f0e4c10
- Parent:
- 11:c6f95a42d4d7
Troy a gain
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 | /* Includes ------------------------------------------------------------------*/ |
nikapov | 0:a1a69d32f310 | 33 | #include "mbed.h" |
sepp_nepp | 5:b95f6951f7d5 | 34 | #include "pinmap.h" |
nikapov | 0:a1a69d32f310 | 35 | #include "PinNames.h" |
nikapov | 0:a1a69d32f310 | 36 | #include "VL53L0X_def.h" |
nikapov | 0:a1a69d32f310 | 37 | |
nikapov | 0:a1a69d32f310 | 38 | /* Classes -------------------------------------------------------------------*/ |
nikapov | 0:a1a69d32f310 | 39 | /** Class representing a VL53L0 sensor component |
nikapov | 0:a1a69d32f310 | 40 | */ |
sepp_nepp | 5:b95f6951f7d5 | 41 | class VL53L0X |
nikapov | 0:a1a69d32f310 | 42 | { |
nikapov | 0:a1a69d32f310 | 43 | public: |
sepp_nepp | 11:c6f95a42d4d7 | 44 | /* Device data made accessible for further usage */ |
sepp_nepp | 11:c6f95a42d4d7 | 45 | TVL53L0X_DeviceInfo Device_Info; |
sepp_nepp | 11:c6f95a42d4d7 | 46 | |
sepp_nepp | 12:aa177f0e4c10 | 47 | /* all the fields previously hidden under DevSpecParams |
sepp_nepp | 12:aa177f0e4c10 | 48 | of type struct VL53L0X_DeviceSpecificParameters_t */ |
sepp_nepp | 12:aa177f0e4c10 | 49 | TFP1616 OscFrequencyMHz; |
sepp_nepp | 12:aa177f0e4c10 | 50 | /* Frequency used */ |
sepp_nepp | 12:aa177f0e4c10 | 51 | uint16_t LastEncodedTimeout; |
sepp_nepp | 12:aa177f0e4c10 | 52 | /* last encoded Time out used for timing budget*/ |
sepp_nepp | 12:aa177f0e4c10 | 53 | TGPIO_Func GpioFunctionality; |
sepp_nepp | 12:aa177f0e4c10 | 54 | /* store the functionality of the GPIO: pin0 */ |
sepp_nepp | 12:aa177f0e4c10 | 55 | uint32_t FinalRangeTimeoutMicroSecs; |
sepp_nepp | 12:aa177f0e4c10 | 56 | /*!< Execution time of the final range*/ |
sepp_nepp | 12:aa177f0e4c10 | 57 | uint8_t FinalRangeVcselPPeriod; |
sepp_nepp | 12:aa177f0e4c10 | 58 | /*!< Vcsel pulse period (pll clocks) for the final range measurement*/ |
sepp_nepp | 12:aa177f0e4c10 | 59 | uint32_t PreRangeTimeoutMicroSecs; |
sepp_nepp | 12:aa177f0e4c10 | 60 | /*!< Execution time of the final range*/ |
sepp_nepp | 12:aa177f0e4c10 | 61 | uint8_t PreRangeVcselPPeriod; |
sepp_nepp | 12:aa177f0e4c10 | 62 | /*!< Vcsel pulse period (pll clocks) for the pre-range measurement*/ |
sepp_nepp | 12:aa177f0e4c10 | 63 | uint16_t SigmaEstRefArray; |
sepp_nepp | 12:aa177f0e4c10 | 64 | /*!< Reference array sigma value in 1/100th of [mm] e.g. 100 = 1mm */ |
sepp_nepp | 12:aa177f0e4c10 | 65 | uint16_t SigmaEstEffPulseWidth; |
sepp_nepp | 12:aa177f0e4c10 | 66 | /*!< Effective Pulse width for sigma estimate in 1/100th of ns e.g. 900 = 9.0ns */ |
sepp_nepp | 12:aa177f0e4c10 | 67 | uint16_t SigmaEstEffAmbWidth; |
sepp_nepp | 12:aa177f0e4c10 | 68 | /*!< Effective Ambient width for sigma estimate in 1/100th of ns e.g. 500 = 5.0ns */ |
sepp_nepp | 12:aa177f0e4c10 | 69 | uint8_t ModuleId; /* Module ID */ |
sepp_nepp | 12:aa177f0e4c10 | 70 | uint8_t Revision; /* test Revision */ |
sepp_nepp | 12:aa177f0e4c10 | 71 | char ProductId[VL53L0X_MAX_STRING_LENGTH]; /* Product Identifier String */ |
sepp_nepp | 12:aa177f0e4c10 | 72 | uint8_t ReferenceSPADType; /* used for ref SPAD management */ |
sepp_nepp | 12:aa177f0e4c10 | 73 | uint8_t RefSPADSInitialised; /* reports if ref SPADS are initialised. */ |
sepp_nepp | 12:aa177f0e4c10 | 74 | uint32_t PartUIDUpper; /*!< Unique Part ID Upper */ |
sepp_nepp | 12:aa177f0e4c10 | 75 | uint32_t PartUIDLower; /*!< Unique Part ID Lower */ |
sepp_nepp | 12:aa177f0e4c10 | 76 | TFP1616 SignalRateMeasFixed400mm; /*!< Peek Signal rate at 400 mm*/ |
sepp_nepp | 12:aa177f0e4c10 | 77 | |
sepp_nepp | 11:c6f95a42d4d7 | 78 | public: |
sepp_nepp | 11:c6f95a42d4d7 | 79 | /******************************************************************************/ |
sepp_nepp | 11:c6f95a42d4d7 | 80 | /****************** Public Initialization Methods *************************/ |
sepp_nepp | 11:c6f95a42d4d7 | 81 | /******************************************************************************/ |
sepp_nepp | 11:c6f95a42d4d7 | 82 | |
nikapov | 0:a1a69d32f310 | 83 | /** Constructor |
nikapov | 0:a1a69d32f310 | 84 | * @param[in] &i2c device I2C to be used for communication |
nikapov | 0:a1a69d32f310 | 85 | * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT |
nikapov | 0:a1a69d32f310 | 86 | * @param[in] dev_addr device address, 0x29 by default |
nikapov | 0:a1a69d32f310 | 87 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 88 | VL53L0X(I2C *i2c, DigitalOut *pin, PinName pin_gpio1, |
sepp_nepp | 10:cd251e0fc2fd | 89 | uint8_t dev_addr = VL53L0X_DEFAULT_ADDRESS) : _dev_i2c(i2c), _gpio0(pin) |
sepp_nepp | 10:cd251e0fc2fd | 90 | { I2cDevAddr = dev_addr; |
sepp_nepp | 10:cd251e0fc2fd | 91 | if (pin_gpio1 != NC) { _gpio1Int = new InterruptIn(pin_gpio1); } |
sepp_nepp | 10:cd251e0fc2fd | 92 | else { _gpio1Int = NULL; } |
nikapov | 0:a1a69d32f310 | 93 | } |
nikapov | 0:a1a69d32f310 | 94 | |
sepp_nepp | 11:c6f95a42d4d7 | 95 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 96 | * @brief Turns on, checks the ID, Set new device address, |
sepp_nepp | 11:c6f95a42d4d7 | 97 | * Initialize the calss, and the sensor with default values |
sepp_nepp | 11:c6f95a42d4d7 | 98 | * |
sepp_nepp | 11:c6f95a42d4d7 | 99 | * After completion the device will answer to the address new_addr. |
sepp_nepp | 11:c6f95a42d4d7 | 100 | * This new_addr should be set to individual values when several devices are used in parallel |
sepp_nepp | 11:c6f95a42d4d7 | 101 | * before using the individual sensors. |
sepp_nepp | 11:c6f95a42d4d7 | 102 | * When a single device us used, there is no need to set new_addr. |
sepp_nepp | 11:c6f95a42d4d7 | 103 | * @return VL53L0X_Error = 0 on success |
sepp_nepp | 11:c6f95a42d4d7 | 104 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 105 | VL53L0X_Error Start_Sensor(uint8_t new_addr = VL53L0X_DEFAULT_ADDRESS); |
sepp_nepp | 11:c6f95a42d4d7 | 106 | |
sepp_nepp | 11:c6f95a42d4d7 | 107 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 108 | * @brief PowerOff the sensor with the XShutdown Pin |
sepp_nepp | 11:c6f95a42d4d7 | 109 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 110 | void Power_Off(void) |
sepp_nepp | 11:c6f95a42d4d7 | 111 | { if (_gpio0) { *_gpio0 = 0; } wait_ms(1); } |
sepp_nepp | 11:c6f95a42d4d7 | 112 | |
sepp_nepp | 11:c6f95a42d4d7 | 113 | |
sepp_nepp | 10:cd251e0fc2fd | 114 | /** Destructor */ |
nikapov | 0:a1a69d32f310 | 115 | virtual ~VL53L0X() |
sepp_nepp | 11:c6f95a42d4d7 | 116 | { if (_gpio1Int != NULL) { delete _gpio1Int; } } |
sepp_nepp | 11:c6f95a42d4d7 | 117 | |
nikapov | 0:a1a69d32f310 | 118 | |
sepp_nepp | 11:c6f95a42d4d7 | 119 | private: |
sepp_nepp | 11:c6f95a42d4d7 | 120 | /******************************************************************************/ |
sepp_nepp | 11:c6f95a42d4d7 | 121 | /****************** Private Initialization Methods *************************/ |
sepp_nepp | 11:c6f95a42d4d7 | 122 | /******************************************************************************/ |
nikapov | 0:a1a69d32f310 | 123 | |
nikapov | 0:a1a69d32f310 | 124 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 125 | * @brief One time device initialization |
sepp_nepp | 11:c6f95a42d4d7 | 126 | * |
sepp_nepp | 11:c6f95a42d4d7 | 127 | * To be called once and only once after device is brought out of reset |
sepp_nepp | 11:c6f95a42d4d7 | 128 | * (Chip enable) and booted see @a void WaitDeviceBooted() |
sepp_nepp | 11:c6f95a42d4d7 | 129 | * |
sepp_nepp | 11:c6f95a42d4d7 | 130 | * @par Function Description |
sepp_nepp | 11:c6f95a42d4d7 | 131 | * When not used after a fresh device "power up" or reset, it may return |
sepp_nepp | 11:c6f95a42d4d7 | 132 | * @a #VL53L0X_ERROR_CALIBRATION_WARNING meaning wrong calibration data |
sepp_nepp | 11:c6f95a42d4d7 | 133 | * may have been fetched from device that can result in ranging offset error\n |
sepp_nepp | 11:c6f95a42d4d7 | 134 | * If application cannot execute device reset or need to run VL53L0X_DataInit |
sepp_nepp | 11:c6f95a42d4d7 | 135 | * multiple time then it must ensure proper offset calibration saving and |
sepp_nepp | 11:c6f95a42d4d7 | 136 | * restore on its own by using @a VL53L0X_GetOffsetCalibrationData() on first |
sepp_nepp | 11:c6f95a42d4d7 | 137 | * power up and then @a VL53L0X_SetOffsetCalibrationData() in all subsequent init |
sepp_nepp | 11:c6f95a42d4d7 | 138 | * This function will change the VL53L0X_State from VL53L0X_STATE_POWERDOWN to |
sepp_nepp | 11:c6f95a42d4d7 | 139 | * VL53L0X_STATE_WAIT_STATICINIT. |
sepp_nepp | 11:c6f95a42d4d7 | 140 | * |
sepp_nepp | 11:c6f95a42d4d7 | 141 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 142 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 143 | void Data_init(); |
sepp_nepp | 11:c6f95a42d4d7 | 144 | |
nikapov | 0:a1a69d32f310 | 145 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 146 | * @brief Reads the Device information for given Device |
sepp_nepp | 11:c6f95a42d4d7 | 147 | * |
sepp_nepp | 11:c6f95a42d4d7 | 148 | * @note This function is called once at Sensor Init, then all device info |
sepp_nepp | 11:c6f95a42d4d7 | 149 | * available in the Device_Info Structure |
sepp_nepp | 11:c6f95a42d4d7 | 150 | * |
sepp_nepp | 11:c6f95a42d4d7 | 151 | * @return Device_Info Structure is filled with device info for the Device |
sepp_nepp | 11:c6f95a42d4d7 | 152 | * Also check and fix errors reported Field "ErrState" */ |
sepp_nepp | 11:c6f95a42d4d7 | 153 | void Fill_device_info(); |
sepp_nepp | 11:c6f95a42d4d7 | 154 | |
sepp_nepp | 12:aa177f0e4c10 | 155 | /* api_core.h functions */ |
sepp_nepp | 12:aa177f0e4c10 | 156 | void Get_all_NVM_info_from_device( uint8_t option); |
sepp_nepp | 12:aa177f0e4c10 | 157 | |
sepp_nepp | 12:aa177f0e4c10 | 158 | /* All the data that is read from the NVM and stored internally */ |
sepp_nepp | 12:aa177f0e4c10 | 159 | uint8_t ReadNVMDataFromDeviceDone; /* Indicate if read from device has been done (==1-4-7) or not (==0) */ |
sepp_nepp | 12:aa177f0e4c10 | 160 | uint8_t ReferenceSPADCount; /* used for ref SPAD management */ |
sepp_nepp | 12:aa177f0e4c10 | 161 | |
sepp_nepp | 11:c6f95a42d4d7 | 162 | public: |
nikapov | 0:a1a69d32f310 | 163 | /** |
nikapov | 0:a1a69d32f310 | 164 | * @brief Start the measure indicated by operating mode |
nikapov | 0:a1a69d32f310 | 165 | * @param[in] operating_mode specifies requested measure |
nikapov | 0:a1a69d32f310 | 166 | * @param[in] fptr specifies call back function must be !NULL in case of interrupt measure |
nikapov | 0:a1a69d32f310 | 167 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 168 | VL53L0X_Error Start_Measurement(TOperatingMode operating_mode, |
sepp_nepp | 11:c6f95a42d4d7 | 169 | void (*fptr)(void)); |
nikapov | 0:a1a69d32f310 | 170 | |
nikapov | 0:a1a69d32f310 | 171 | /** |
nikapov | 0:a1a69d32f310 | 172 | * @brief Get results for the measure indicated by operating mode |
nikapov | 0:a1a69d32f310 | 173 | * @param[in] operating_mode specifies requested measure results |
sepp_nepp | 11:c6f95a42d4d7 | 174 | * @result TRangeResults The MeasureData_t structure with all results |
nikapov | 0:a1a69d32f310 | 175 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 176 | TRangeResults Get_Measurement(TOperatingMode operating_mode); |
nikapov | 0:a1a69d32f310 | 177 | |
nikapov | 0:a1a69d32f310 | 178 | /** |
nikapov | 0:a1a69d32f310 | 179 | * @brief Stop the currently running measure indicate by operating_mode |
nikapov | 0:a1a69d32f310 | 180 | * @param[in] operating_mode specifies requested measure to stop |
sepp_nepp | 11:c6f95a42d4d7 | 181 | "0" on success |
nikapov | 0:a1a69d32f310 | 182 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 183 | VL53L0X_Error Stop_Measurement(TOperatingMode operating_mode); |
nikapov | 0:a1a69d32f310 | 184 | |
nikapov | 0:a1a69d32f310 | 185 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 186 | * @brief Interrupt handling func to be called by user after an INT is occourred |
sepp_nepp | 11:c6f95a42d4d7 | 187 | * @param[in] operating_mode Opeating_mode indicating the in progress measure |
sepp_nepp | 11:c6f95a42d4d7 | 188 | * @result TRangeResults The Measurement Data structure given back |
nikapov | 0:a1a69d32f310 | 189 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 190 | TRangeResults Handle_irq(TOperatingMode operating_mode); |
nikapov | 0:a1a69d32f310 | 191 | |
nikapov | 0:a1a69d32f310 | 192 | /** |
nikapov | 0:a1a69d32f310 | 193 | * @brief Enable interrupt measure IRQ |
nikapov | 0:a1a69d32f310 | 194 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 195 | void Enable_interrupt_measure_detection_irq(void) |
sepp_nepp | 11:c6f95a42d4d7 | 196 | { if (_gpio1Int != NULL) { _gpio1Int->enable_irq(); } } |
nikapov | 0:a1a69d32f310 | 197 | |
nikapov | 0:a1a69d32f310 | 198 | /** |
nikapov | 0:a1a69d32f310 | 199 | * @brief Disable interrupt measure IRQ |
sepp_nepp | 11:c6f95a42d4d7 | 200 | "0" on success |
nikapov | 0:a1a69d32f310 | 201 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 202 | void Disable_interrupt_measure_detection_irq(void) |
sepp_nepp | 11:c6f95a42d4d7 | 203 | { if (_gpio1Int != NULL) { _gpio1Int->disable_irq(); } } |
nikapov | 0:a1a69d32f310 | 204 | |
nikapov | 0:a1a69d32f310 | 205 | /** |
nikapov | 0:a1a69d32f310 | 206 | * @brief Attach a function to call when an interrupt is detected, i.e. measurement is ready |
nikapov | 0:a1a69d32f310 | 207 | * @param[in] fptr pointer to call back function to be called whenever an interrupt occours |
sepp_nepp | 11:c6f95a42d4d7 | 208 | "0" on success |
nikapov | 0:a1a69d32f310 | 209 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 210 | void Attach_interrupt_measure_detection_irq(void (*fptr)(void)) |
sepp_nepp | 11:c6f95a42d4d7 | 211 | { if (_gpio1Int != NULL) { _gpio1Int->rise(fptr); } } |
nikapov | 0:a1a69d32f310 | 212 | |
nikapov | 0:a1a69d32f310 | 213 | /** Wrapper functions */ |
nikapov | 0:a1a69d32f310 | 214 | /** @defgroup api_init Init functions |
nikapov | 0:a1a69d32f310 | 215 | * @brief API init functions |
nikapov | 0:a1a69d32f310 | 216 | * @ingroup api_hl |
nikapov | 0:a1a69d32f310 | 217 | * @{ |
nikapov | 0:a1a69d32f310 | 218 | */ |
nikapov | 0:a1a69d32f310 | 219 | |
nikapov | 0:a1a69d32f310 | 220 | /** |
nikapov | 0:a1a69d32f310 | 221 | * @brief Prepare device for operation |
nikapov | 0:a1a69d32f310 | 222 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 223 | * Does static initialization and reprogram common default settings \n |
nikapov | 0:a1a69d32f310 | 224 | * Device is prepared for new measure, ready single shot ranging or ALS typical polling operation\n |
nikapov | 0:a1a69d32f310 | 225 | * After prepare user can : \n |
nikapov | 0:a1a69d32f310 | 226 | * @li Call other API function to set other settings\n |
nikapov | 0:a1a69d32f310 | 227 | * @li Configure the interrupt pins, etc... \n |
nikapov | 0:a1a69d32f310 | 228 | * @li Then start ranging or ALS operations in single shot or continuous mode |
nikapov | 0:a1a69d32f310 | 229 | * |
nikapov | 0:a1a69d32f310 | 230 | * @param void |
nikapov | 0:a1a69d32f310 | 231 | * @return "0" on success |
nikapov | 0:a1a69d32f310 | 232 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 233 | VL53L0X_Error Prepare(); |
nikapov | 0:a1a69d32f310 | 234 | |
nikapov | 0:a1a69d32f310 | 235 | /** |
nikapov | 0:a1a69d32f310 | 236 | * @brief Start continuous ranging mode |
nikapov | 0:a1a69d32f310 | 237 | * |
nikapov | 0:a1a69d32f310 | 238 | * @details End user should ensure device is in idle state and not already running |
nikapov | 0:a1a69d32f310 | 239 | * @return "0" on success |
nikapov | 0:a1a69d32f310 | 240 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 241 | void Range_start_continuous_mode() |
sepp_nepp | 11:c6f95a42d4d7 | 242 | { Set_device_mode( VL53L0X_DEVICEMODE_CONTINUOUS_RANGING); |
sepp_nepp | 11:c6f95a42d4d7 | 243 | if (ErrState == VL53L0X_OK) { Start_Measurement(); } |
nikapov | 0:a1a69d32f310 | 244 | } |
nikapov | 0:a1a69d32f310 | 245 | |
nikapov | 0:a1a69d32f310 | 246 | /** |
nikapov | 0:a1a69d32f310 | 247 | * @brief Get ranging result and only that |
nikapov | 0:a1a69d32f310 | 248 | * |
nikapov | 0:a1a69d32f310 | 249 | * @par Function Description |
sepp_nepp | 11:c6f95a42d4d7 | 250 | * Unlike @a Get_ranging_results() this function only retrieves the range in millimeter \n |
nikapov | 0:a1a69d32f310 | 251 | * It does any required up-scale translation\n |
sepp_nepp | 11:c6f95a42d4d7 | 252 | * It can be called after success ErrState polling or in interrupt mode \n |
nikapov | 0:a1a69d32f310 | 253 | * @warning these function is not doing wrap around filtering \n |
nikapov | 0:a1a69d32f310 | 254 | * This function doesn't perform any data ready check! |
nikapov | 0:a1a69d32f310 | 255 | * |
nikapov | 0:a1a69d32f310 | 256 | * @param p_data Pointer to range distance |
sepp_nepp | 11:c6f95a42d4d7 | 257 | "0" on success |
nikapov | 0:a1a69d32f310 | 258 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 259 | uint32_t Get_distance(); |
nikapov | 0:a1a69d32f310 | 260 | |
nikapov | 0:a1a69d32f310 | 261 | /** @} */ |
nikapov | 0:a1a69d32f310 | 262 | |
nikapov | 0:a1a69d32f310 | 263 | |
nikapov | 0:a1a69d32f310 | 264 | |
nikapov | 0:a1a69d32f310 | 265 | /** |
nikapov | 0:a1a69d32f310 | 266 | * @brief Do basic device init (and eventually patch loading) |
nikapov | 0:a1a69d32f310 | 267 | * This function will change the VL53L0X_State from |
nikapov | 0:a1a69d32f310 | 268 | * VL53L0X_STATE_WAIT_STATICINIT to VL53L0X_STATE_IDLE. |
nikapov | 0:a1a69d32f310 | 269 | * In this stage all default setting will be applied. |
nikapov | 0:a1a69d32f310 | 270 | * |
nikapov | 0:a1a69d32f310 | 271 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 272 | * |
sepp_nepp | 11:c6f95a42d4d7 | 273 | * |
sepp_nepp | 11:c6f95a42d4d7 | 274 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 275 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 276 | void Static_init(); |
nikapov | 0:a1a69d32f310 | 277 | |
nikapov | 0:a1a69d32f310 | 278 | /** |
nikapov | 0:a1a69d32f310 | 279 | * @brief Perform Reference Calibration |
nikapov | 0:a1a69d32f310 | 280 | * |
nikapov | 0:a1a69d32f310 | 281 | * @details Perform a reference calibration of the Device. |
nikapov | 0:a1a69d32f310 | 282 | * This function should be run from time to time before doing |
nikapov | 0:a1a69d32f310 | 283 | * a ranging measurement. |
nikapov | 0:a1a69d32f310 | 284 | * This function will launch a special ranging measurement, so |
nikapov | 0:a1a69d32f310 | 285 | * if interrupt are enable an interrupt will be done. |
nikapov | 0:a1a69d32f310 | 286 | * This function will clear the interrupt generated automatically. |
nikapov | 0:a1a69d32f310 | 287 | * |
nikapov | 0:a1a69d32f310 | 288 | * @warning This function is a blocking function |
nikapov | 0:a1a69d32f310 | 289 | * |
nikapov | 0:a1a69d32f310 | 290 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 291 | * |
sepp_nepp | 11:c6f95a42d4d7 | 292 | * |
nikapov | 0:a1a69d32f310 | 293 | * @param p_vhv_settings Pointer to vhv settings parameter. |
nikapov | 0:a1a69d32f310 | 294 | * @param p_phase_cal Pointer to PhaseCal parameter. |
sepp_nepp | 10:cd251e0fc2fd | 295 | * @param get_data_enable 1 to enable to get the data |
sepp_nepp | 11:c6f95a42d4d7 | 296 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 297 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 298 | void Perf_Ref_calibration( |
sepp_nepp | 10:cd251e0fc2fd | 299 | uint8_t *p_vhv_settings, uint8_t *p_phase_cal, uint8_t get_data_enable); |
nikapov | 0:a1a69d32f310 | 300 | |
nikapov | 0:a1a69d32f310 | 301 | /** |
nikapov | 0:a1a69d32f310 | 302 | * @brief Get Reference Calibration Parameters |
nikapov | 0:a1a69d32f310 | 303 | * |
nikapov | 0:a1a69d32f310 | 304 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 305 | * Get Reference Calibration Parameters. |
nikapov | 0:a1a69d32f310 | 306 | * |
nikapov | 0:a1a69d32f310 | 307 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 308 | * |
sepp_nepp | 11:c6f95a42d4d7 | 309 | * |
nikapov | 0:a1a69d32f310 | 310 | * @param p_vhv_settings Pointer to VHV parameter |
nikapov | 0:a1a69d32f310 | 311 | * @param p_phase_cal Pointer to PhaseCal Parameter |
sepp_nepp | 11:c6f95a42d4d7 | 312 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 313 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 314 | void Get_Ref_calibration( |
nikapov | 0:a1a69d32f310 | 315 | uint8_t *p_vhv_settings, uint8_t *p_phase_cal); |
nikapov | 0:a1a69d32f310 | 316 | |
sepp_nepp | 11:c6f95a42d4d7 | 317 | void Set_Ref_calibration( |
nikapov | 0:a1a69d32f310 | 318 | uint8_t vhv_settings, uint8_t phase_cal); |
nikapov | 0:a1a69d32f310 | 319 | |
nikapov | 0:a1a69d32f310 | 320 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 321 | * @brief Performs Reference SPAD Management |
nikapov | 0:a1a69d32f310 | 322 | * |
nikapov | 0:a1a69d32f310 | 323 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 324 | * The reference SPAD initialization procedure determines the minimum amount |
sepp_nepp | 11:c6f95a42d4d7 | 325 | * of reference SPADS to be enables to achieve a target reference signal rate |
nikapov | 0:a1a69d32f310 | 326 | * and should be performed once during initialization. |
nikapov | 0:a1a69d32f310 | 327 | * |
nikapov | 0:a1a69d32f310 | 328 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 329 | * |
nikapov | 0:a1a69d32f310 | 330 | * @note This function change the device mode to |
nikapov | 0:a1a69d32f310 | 331 | * VL53L0X_DEVICEMODE_SINGLE_RANGING |
nikapov | 0:a1a69d32f310 | 332 | * |
sepp_nepp | 11:c6f95a42d4d7 | 333 | * |
sepp_nepp | 11:c6f95a42d4d7 | 334 | * @param ref_SPAD_count Reports ref SPAD Count |
sepp_nepp | 11:c6f95a42d4d7 | 335 | * @param is_aperture_SPADS Reports if SPADS are of type |
nikapov | 0:a1a69d32f310 | 336 | * aperture or non-aperture. |
nikapov | 0:a1a69d32f310 | 337 | * 1:=aperture, 0:=Non-Aperture |
sepp_nepp | 11:c6f95a42d4d7 | 338 | * @return None; instead check class Field "ErrState" |
sepp_nepp | 11:c6f95a42d4d7 | 339 | * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the Ref SPAD procedure. |
nikapov | 0:a1a69d32f310 | 340 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 341 | void Perf_Ref_SPAD_management( |
sepp_nepp | 11:c6f95a42d4d7 | 342 | uint32_t *ref_SPAD_count, uint8_t *is_aperture_SPADS); |
nikapov | 0:a1a69d32f310 | 343 | |
nikapov | 0:a1a69d32f310 | 344 | /** |
nikapov | 0:a1a69d32f310 | 345 | * @brief Applies Reference SPAD configuration |
nikapov | 0:a1a69d32f310 | 346 | * |
nikapov | 0:a1a69d32f310 | 347 | * @par Function Description |
sepp_nepp | 11:c6f95a42d4d7 | 348 | * This function applies a given number of reference SPADS, identified as |
nikapov | 0:a1a69d32f310 | 349 | * either Aperture or Non-Aperture. |
sepp_nepp | 11:c6f95a42d4d7 | 350 | * The requested SPAD count and type are stored within the device specific |
nikapov | 0:a1a69d32f310 | 351 | * parameters data for access by the host. |
nikapov | 0:a1a69d32f310 | 352 | * |
nikapov | 0:a1a69d32f310 | 353 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 354 | * |
sepp_nepp | 11:c6f95a42d4d7 | 355 | * |
sepp_nepp | 11:c6f95a42d4d7 | 356 | * @param refSPADCount Number of ref SPADS. |
sepp_nepp | 11:c6f95a42d4d7 | 357 | * @param is_aperture_SPADS Defines if SPADS are of type |
nikapov | 0:a1a69d32f310 | 358 | * aperture or non-aperture. |
nikapov | 0:a1a69d32f310 | 359 | * 1:=aperture, 0:=Non-Aperture |
sepp_nepp | 11:c6f95a42d4d7 | 360 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 361 | * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the in the reference |
sepp_nepp | 11:c6f95a42d4d7 | 362 | * SPAD configuration. |
nikapov | 0:a1a69d32f310 | 363 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 364 | void Set_Reference_SPADS( |
sepp_nepp | 11:c6f95a42d4d7 | 365 | uint32_t refSPADCount, uint8_t is_aperture_SPADS); |
nikapov | 0:a1a69d32f310 | 366 | |
nikapov | 0:a1a69d32f310 | 367 | /** |
nikapov | 0:a1a69d32f310 | 368 | * @brief Retrieves SPAD configuration |
nikapov | 0:a1a69d32f310 | 369 | * |
nikapov | 0:a1a69d32f310 | 370 | * @par Function Description |
sepp_nepp | 11:c6f95a42d4d7 | 371 | * This function retrieves the current number of applied reference SPADS |
nikapov | 0:a1a69d32f310 | 372 | * and also their type : Aperture or Non-Aperture. |
nikapov | 0:a1a69d32f310 | 373 | * |
nikapov | 0:a1a69d32f310 | 374 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 375 | * |
sepp_nepp | 11:c6f95a42d4d7 | 376 | * |
sepp_nepp | 11:c6f95a42d4d7 | 377 | * @param p_SPAD_count Number ref SPAD Count |
sepp_nepp | 11:c6f95a42d4d7 | 378 | * @param p_is_aperture_SPADS Reports if SPADS are of type |
nikapov | 0:a1a69d32f310 | 379 | * aperture or non-aperture. |
nikapov | 0:a1a69d32f310 | 380 | * 1:=aperture, 0:=Non-Aperture |
sepp_nepp | 11:c6f95a42d4d7 | 381 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 382 | * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the in the reference |
sepp_nepp | 11:c6f95a42d4d7 | 383 | * SPAD configuration. |
nikapov | 0:a1a69d32f310 | 384 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 385 | void Get_Reference_SPADS( |
sepp_nepp | 11:c6f95a42d4d7 | 386 | uint32_t *p_SPAD_count, uint8_t *p_is_aperture_SPADS); |
nikapov | 0:a1a69d32f310 | 387 | |
nikapov | 0:a1a69d32f310 | 388 | /** |
nikapov | 0:a1a69d32f310 | 389 | * @brief Get part to part calibration offset |
nikapov | 0:a1a69d32f310 | 390 | * |
nikapov | 0:a1a69d32f310 | 391 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 392 | * Should only be used after a successful call to @a VL53L0X_DataInit to backup |
nikapov | 0:a1a69d32f310 | 393 | * device NVM value |
nikapov | 0:a1a69d32f310 | 394 | * |
nikapov | 0:a1a69d32f310 | 395 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 396 | * |
sepp_nepp | 11:c6f95a42d4d7 | 397 | * @param p_Offset_Cal_um |
sepp_nepp | 11:c6f95a42d4d7 | 398 | * @return int32_t; Return part to part calibration offset from device (microns), also check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 399 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 400 | int32_t Get_Offset_Cal_um(); |
nikapov | 0:a1a69d32f310 | 401 | /** |
nikapov | 0:a1a69d32f310 | 402 | * Set or over-hide part to part calibration offset |
sepp_nepp | 11:c6f95a42d4d7 | 403 | * \sa VL53L0X_DataInit() VL53L0X_GetOffsetCalibrationData_um() |
nikapov | 0:a1a69d32f310 | 404 | * |
nikapov | 0:a1a69d32f310 | 405 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 406 | * |
sepp_nepp | 11:c6f95a42d4d7 | 407 | * @param p_Offset_Cal_um Offset (microns) |
sepp_nepp | 11:c6f95a42d4d7 | 408 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 409 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 410 | void Set_Offset_Cal_um( int32_t Offset_Cal_um ); |
nikapov | 0:a1a69d32f310 | 411 | |
sepp_nepp | 11:c6f95a42d4d7 | 412 | void Perf_offset_calibration( TFP1616 cal_distance_milli_meter, |
sepp_nepp | 10:cd251e0fc2fd | 413 | int32_t *p_offset_um); |
nikapov | 0:a1a69d32f310 | 414 | |
sepp_nepp | 11:c6f95a42d4d7 | 415 | void Perf_xtalk_calibration( TFP1616 xtalk_cal_distance, |
sepp_nepp | 11:c6f95a42d4d7 | 416 | TFP1616 *p_Xtalk_CompRate_MHz); |
nikapov | 0:a1a69d32f310 | 417 | |
nikapov | 0:a1a69d32f310 | 418 | /** |
nikapov | 0:a1a69d32f310 | 419 | * @brief Perform XTalk Measurement |
nikapov | 0:a1a69d32f310 | 420 | * |
nikapov | 0:a1a69d32f310 | 421 | * @details Measures the current cross talk from glass in front |
nikapov | 0:a1a69d32f310 | 422 | * of the sensor. |
nikapov | 0:a1a69d32f310 | 423 | * This functions performs a histogram measurement and uses the results |
nikapov | 0:a1a69d32f310 | 424 | * to measure the crosstalk. For the function to be successful, there |
nikapov | 0:a1a69d32f310 | 425 | * must be no target in front of the sensor. |
nikapov | 0:a1a69d32f310 | 426 | * |
nikapov | 0:a1a69d32f310 | 427 | * @warning This function is a blocking function |
nikapov | 0:a1a69d32f310 | 428 | * |
nikapov | 0:a1a69d32f310 | 429 | * @warning This function is not supported when the final range |
nikapov | 0:a1a69d32f310 | 430 | * vcsel clock period is set below 10 PCLKS. |
nikapov | 0:a1a69d32f310 | 431 | * |
nikapov | 0:a1a69d32f310 | 432 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 433 | * |
sepp_nepp | 11:c6f95a42d4d7 | 434 | * |
nikapov | 0:a1a69d32f310 | 435 | * @param timeout_ms Histogram measurement duration. |
sepp_nepp | 11:c6f95a42d4d7 | 436 | * @param p_xtalk_per_SPAD Output parameter containing the crosstalk |
sepp_nepp | 11:c6f95a42d4d7 | 437 | * measurement result, in MHz/SPAD. |
nikapov | 0:a1a69d32f310 | 438 | * Format fixpoint 16:16. |
nikapov | 0:a1a69d32f310 | 439 | * @param p_ambient_too_high Output parameter which indicate that |
sepp_nepp | 11:c6f95a42d4d7 | 440 | * pXtalkPerSPAD is not good if the Ambient |
nikapov | 0:a1a69d32f310 | 441 | * is too high. |
sepp_nepp | 11:c6f95a42d4d7 | 442 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 443 | * @return VL53L0X_ERROR_INVALID_PARAMS vcsel clock period not supported |
nikapov | 0:a1a69d32f310 | 444 | * for this operation. |
nikapov | 0:a1a69d32f310 | 445 | * Must not be less than 10PCLKS. |
nikapov | 0:a1a69d32f310 | 446 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 447 | void Perf_xtalk_measurement( |
sepp_nepp | 11:c6f95a42d4d7 | 448 | uint32_t timeout_ms, TFP1616 *p_xtalk_per_SPAD, |
nikapov | 0:a1a69d32f310 | 449 | uint8_t *p_ambient_too_high); |
nikapov | 0:a1a69d32f310 | 450 | |
nikapov | 0:a1a69d32f310 | 451 | /** |
nikapov | 0:a1a69d32f310 | 452 | * @brief Enable/Disable Cross talk compensation feature |
nikapov | 0:a1a69d32f310 | 453 | * |
nikapov | 0:a1a69d32f310 | 454 | * @note This function is not Implemented. |
nikapov | 0:a1a69d32f310 | 455 | * Enable/Disable Cross Talk by set to zero the Cross Talk value |
sepp_nepp | 11:c6f95a42d4d7 | 456 | * by using @a VL53L0X_SetXtalk_CompRate_MHz(). |
nikapov | 0:a1a69d32f310 | 457 | * |
sepp_nepp | 11:c6f95a42d4d7 | 458 | * |
sepp_nepp | 11:c6f95a42d4d7 | 459 | * @param xtalk_compensation_enable Cross talk compensation |
nikapov | 0:a1a69d32f310 | 460 | * to be set 0=disabled else = enabled |
nikapov | 0:a1a69d32f310 | 461 | * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented |
nikapov | 0:a1a69d32f310 | 462 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 463 | void Set_xtalk_compensation_enable( |
sepp_nepp | 11:c6f95a42d4d7 | 464 | uint8_t xtalk_compensation_enable); |
nikapov | 0:a1a69d32f310 | 465 | |
sepp_nepp | 11:c6f95a42d4d7 | 466 | /** |
nikapov | 0:a1a69d32f310 | 467 | * @brief Set Cross talk compensation rate |
nikapov | 0:a1a69d32f310 | 468 | * |
nikapov | 0:a1a69d32f310 | 469 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 470 | * Set Cross talk compensation rate. |
nikapov | 0:a1a69d32f310 | 471 | * |
nikapov | 0:a1a69d32f310 | 472 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 473 | * |
sepp_nepp | 11:c6f95a42d4d7 | 474 | * |
sepp_nepp | 11:c6f95a42d4d7 | 475 | * @param Xtalk_CompRate_MHz Compensation rate in |
nikapov | 0:a1a69d32f310 | 476 | * Mega counts per second |
nikapov | 0:a1a69d32f310 | 477 | * (16.16 fix point) see |
nikapov | 0:a1a69d32f310 | 478 | * datasheet for details |
sepp_nepp | 11:c6f95a42d4d7 | 479 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 480 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 481 | void Set_Xtalk_CompRate_MHz( TFP1616 Xtalk_CompRate_MHz ); |
nikapov | 0:a1a69d32f310 | 482 | |
nikapov | 0:a1a69d32f310 | 483 | /** |
nikapov | 0:a1a69d32f310 | 484 | * @brief Get Cross talk compensation rate |
nikapov | 0:a1a69d32f310 | 485 | * |
sepp_nepp | 11:c6f95a42d4d7 | 486 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 487 | * Get Cross talk compensation rate. |
nikapov | 0:a1a69d32f310 | 488 | * |
nikapov | 0:a1a69d32f310 | 489 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 490 | * |
sepp_nepp | 11:c6f95a42d4d7 | 491 | * |
sepp_nepp | 11:c6f95a42d4d7 | 492 | * @param p_Xtalk_CompRate_MHz Pointer to Compensation rate |
nikapov | 0:a1a69d32f310 | 493 | * in Mega counts per second |
nikapov | 0:a1a69d32f310 | 494 | * (16.16 fix point) see |
nikapov | 0:a1a69d32f310 | 495 | * datasheet for details |
sepp_nepp | 11:c6f95a42d4d7 | 496 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 497 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 498 | |
sepp_nepp | 11:c6f95a42d4d7 | 499 | void Get_Xtalk_CompRate_MHz( |
sepp_nepp | 11:c6f95a42d4d7 | 500 | TFP1616 *p_Xtalk_CompRate_MHz); |
nikapov | 0:a1a69d32f310 | 501 | |
nikapov | 0:a1a69d32f310 | 502 | /** |
nikapov | 0:a1a69d32f310 | 503 | * @brief Set a new device mode |
nikapov | 0:a1a69d32f310 | 504 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 505 | * Set device to a new mode (ranging, histogram ...) |
nikapov | 0:a1a69d32f310 | 506 | * |
nikapov | 0:a1a69d32f310 | 507 | * @note This function doesn't Access to the device |
nikapov | 0:a1a69d32f310 | 508 | * |
sepp_nepp | 11:c6f95a42d4d7 | 509 | * |
nikapov | 0:a1a69d32f310 | 510 | * @param device_mode New device mode to apply |
nikapov | 0:a1a69d32f310 | 511 | * Valid values are: |
nikapov | 0:a1a69d32f310 | 512 | * VL53L0X_DEVICEMODE_SINGLE_RANGING |
nikapov | 0:a1a69d32f310 | 513 | * VL53L0X_DEVICEMODE_CONTINUOUS_RANGING |
nikapov | 0:a1a69d32f310 | 514 | * VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING |
nikapov | 0:a1a69d32f310 | 515 | * VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM |
nikapov | 0:a1a69d32f310 | 516 | * VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY |
nikapov | 0:a1a69d32f310 | 517 | * VL53L0X_HISTOGRAMMODE_RETURN_ONLY |
nikapov | 0:a1a69d32f310 | 518 | * VL53L0X_HISTOGRAMMODE_BOTH |
nikapov | 0:a1a69d32f310 | 519 | * |
nikapov | 0:a1a69d32f310 | 520 | * |
sepp_nepp | 11:c6f95a42d4d7 | 521 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 522 | * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when |
nikapov | 0:a1a69d32f310 | 523 | * DeviceMode is not in the |
nikapov | 0:a1a69d32f310 | 524 | * supported list |
nikapov | 0:a1a69d32f310 | 525 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 526 | void Set_device_mode( VL53L0X_DeviceModes device_mode); |
nikapov | 0:a1a69d32f310 | 527 | |
nikapov | 0:a1a69d32f310 | 528 | /** |
nikapov | 0:a1a69d32f310 | 529 | * @brief Get current configuration for GPIO pin for a given device |
nikapov | 0:a1a69d32f310 | 530 | * |
nikapov | 0:a1a69d32f310 | 531 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 532 | * |
sepp_nepp | 11:c6f95a42d4d7 | 533 | * |
nikapov | 0:a1a69d32f310 | 534 | * @param pin ID of the GPIO Pin |
nikapov | 0:a1a69d32f310 | 535 | * @param p_device_mode Pointer to Device Mode associated to the Gpio. |
nikapov | 0:a1a69d32f310 | 536 | * @param p_functionality Pointer to Pin functionality. |
sepp_nepp | 11:c6f95a42d4d7 | 537 | * Refer to ::TGPIO_Func |
nikapov | 0:a1a69d32f310 | 538 | * @param p_polarity Pointer to interrupt polarity. |
nikapov | 0:a1a69d32f310 | 539 | * Active high or active low see |
nikapov | 0:a1a69d32f310 | 540 | * ::VL53L0X_InterruptPolarity |
sepp_nepp | 11:c6f95a42d4d7 | 541 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 542 | * @return VL53L0X_ERROR_GPIO_NOT_EXISTING Only Pin=0 is accepted. |
sepp_nepp | 11:c6f95a42d4d7 | 543 | * @return VL53L0X_ERROR_GPIO_FUNC_NOT_SUPPORTED |
nikapov | 0:a1a69d32f310 | 544 | * This error occurs |
nikapov | 0:a1a69d32f310 | 545 | * when Funcionality programmed is not in the supported list: |
nikapov | 0:a1a69d32f310 | 546 | * Supported value are: |
sepp_nepp | 11:c6f95a42d4d7 | 547 | * GPIO_FUNC_OFF, |
sepp_nepp | 11:c6f95a42d4d7 | 548 | * GPIO_FUNC_THRESHOLD_CROSSED_LOW, |
sepp_nepp | 11:c6f95a42d4d7 | 549 | * GPIO_FUNC_THRESHOLD_CROSSED_HIGH, |
sepp_nepp | 11:c6f95a42d4d7 | 550 | * GPIO_FUNC_THRESHOLD_CROSSED_OUT, |
sepp_nepp | 11:c6f95a42d4d7 | 551 | * GPIO_FUNC_NEW_MEASURE_READY |
nikapov | 0:a1a69d32f310 | 552 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 553 | void Get_gpio_config( uint8_t pin, VL53L0X_DeviceModes *p_device_mode, |
sepp_nepp | 11:c6f95a42d4d7 | 554 | TGPIO_Func *p_functionality, |
nikapov | 0:a1a69d32f310 | 555 | VL53L0X_InterruptPolarity *p_polarity); |
nikapov | 0:a1a69d32f310 | 556 | |
nikapov | 0:a1a69d32f310 | 557 | /** |
nikapov | 0:a1a69d32f310 | 558 | * @brief Set the configuration of GPIO pin for a given device |
nikapov | 0:a1a69d32f310 | 559 | * |
nikapov | 0:a1a69d32f310 | 560 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 561 | * |
nikapov | 0:a1a69d32f310 | 562 | * @param pin ID of the GPIO Pin |
nikapov | 0:a1a69d32f310 | 563 | * @param functionality Select Pin functionality. |
sepp_nepp | 11:c6f95a42d4d7 | 564 | * Refer to ::TGPIO_Func |
nikapov | 0:a1a69d32f310 | 565 | * @param device_mode Device Mode associated to the Gpio. |
nikapov | 0:a1a69d32f310 | 566 | * @param polarity Set interrupt polarity. Active high |
nikapov | 0:a1a69d32f310 | 567 | * or active low see ::VL53L0X_InterruptPolarity |
sepp_nepp | 11:c6f95a42d4d7 | 568 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 569 | * @return VL53L0X_ERROR_GPIO_NOT_EXISTING Only Pin=0 is accepted. |
sepp_nepp | 11:c6f95a42d4d7 | 570 | * @return VL53L0X_ERROR_GPIO_FUNC_NOT_SUPPORTED This error occurs |
nikapov | 0:a1a69d32f310 | 571 | * when Functionality programmed is not in the supported list: |
nikapov | 0:a1a69d32f310 | 572 | * Supported value are: |
sepp_nepp | 11:c6f95a42d4d7 | 573 | * GPIO_FUNC_OFF, |
sepp_nepp | 11:c6f95a42d4d7 | 574 | * GPIO_FUNC_THRESHOLD_CROSSED_LOW, |
sepp_nepp | 11:c6f95a42d4d7 | 575 | * GPIO_FUNC_THRESHOLD_CROSSED_HIGH, |
sepp_nepp | 11:c6f95a42d4d7 | 576 | * GPIO_FUNC_THRESHOLD_CROSSED_OUT, |
sepp_nepp | 11:c6f95a42d4d7 | 577 | * GPIO_FUNC_NEW_MEASURE_READY |
nikapov | 0:a1a69d32f310 | 578 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 579 | void Set_GPIO_config( VL53L0X_DeviceModes device_mode, |
sepp_nepp | 11:c6f95a42d4d7 | 580 | TGPIO_Func functionality, VL53L0X_InterruptPolarity polarity); |
nikapov | 0:a1a69d32f310 | 581 | |
nikapov | 0:a1a69d32f310 | 582 | /** |
nikapov | 0:a1a69d32f310 | 583 | * @brief Start device measurement |
nikapov | 0:a1a69d32f310 | 584 | * |
nikapov | 0:a1a69d32f310 | 585 | * @details Started measurement will depend on device parameters set through |
nikapov | 0:a1a69d32f310 | 586 | * @a VL53L0X_SetParameters() |
nikapov | 0:a1a69d32f310 | 587 | * This is a non-blocking function. |
nikapov | 0:a1a69d32f310 | 588 | * This function will change the VL53L0X_State from VL53L0X_STATE_IDLE to |
nikapov | 0:a1a69d32f310 | 589 | * VL53L0X_STATE_RUNNING. |
nikapov | 0:a1a69d32f310 | 590 | * |
nikapov | 0:a1a69d32f310 | 591 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 592 | * |
nikapov | 0:a1a69d32f310 | 593 | |
sepp_nepp | 11:c6f95a42d4d7 | 594 | * |
sepp_nepp | 11:c6f95a42d4d7 | 595 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 596 | * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when |
nikapov | 0:a1a69d32f310 | 597 | * DeviceMode programmed with @a VL53L0X_SetDeviceMode is not in the supported |
nikapov | 0:a1a69d32f310 | 598 | * list: |
nikapov | 0:a1a69d32f310 | 599 | * Supported mode are: |
nikapov | 0:a1a69d32f310 | 600 | * VL53L0X_DEVICEMODE_SINGLE_RANGING, |
nikapov | 0:a1a69d32f310 | 601 | * VL53L0X_DEVICEMODE_CONTINUOUS_RANGING, |
nikapov | 0:a1a69d32f310 | 602 | * VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING |
nikapov | 0:a1a69d32f310 | 603 | * @return VL53L0X_ERROR_TIME_OUT Time out on start measurement |
nikapov | 0:a1a69d32f310 | 604 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 605 | void Start_Measurement(); |
nikapov | 0:a1a69d32f310 | 606 | |
nikapov | 0:a1a69d32f310 | 607 | /** |
nikapov | 0:a1a69d32f310 | 608 | * @brief Stop device measurement |
nikapov | 0:a1a69d32f310 | 609 | * |
nikapov | 0:a1a69d32f310 | 610 | * @details Will set the device in standby mode at end of current measurement\n |
nikapov | 0:a1a69d32f310 | 611 | * Not necessary in single mode as device shall return automatically |
nikapov | 0:a1a69d32f310 | 612 | * in standby mode at end of measurement. |
nikapov | 0:a1a69d32f310 | 613 | * This function will change the VL53L0X_State from VL53L0X_STATE_RUNNING |
nikapov | 0:a1a69d32f310 | 614 | * to VL53L0X_STATE_IDLE. |
nikapov | 0:a1a69d32f310 | 615 | * |
nikapov | 0:a1a69d32f310 | 616 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 617 | * |
sepp_nepp | 11:c6f95a42d4d7 | 618 | * |
sepp_nepp | 11:c6f95a42d4d7 | 619 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 620 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 621 | void Stop_Measurement(); |
nikapov | 0:a1a69d32f310 | 622 | |
nikapov | 0:a1a69d32f310 | 623 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 624 | * @brief Return device stop completion ErrState |
nikapov | 0:a1a69d32f310 | 625 | * |
nikapov | 0:a1a69d32f310 | 626 | * @par Function Description |
sepp_nepp | 11:c6f95a42d4d7 | 627 | * Returns stop completiob ErrState. |
nikapov | 0:a1a69d32f310 | 628 | * User shall call this function after a stop command |
nikapov | 0:a1a69d32f310 | 629 | * |
nikapov | 0:a1a69d32f310 | 630 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 631 | * |
sepp_nepp | 11:c6f95a42d4d7 | 632 | * |
sepp_nepp | 11:c6f95a42d4d7 | 633 | * @return p_stop_status Pointer to ErrState variable to update |
sepp_nepp | 11:c6f95a42d4d7 | 634 | * Also instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 635 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 636 | uint8_t Get_Stop_Completed( ); |
nikapov | 0:a1a69d32f310 | 637 | |
nikapov | 0:a1a69d32f310 | 638 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 639 | * @brief Return Measurement is Ready |
nikapov | 0:a1a69d32f310 | 640 | * |
nikapov | 0:a1a69d32f310 | 641 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 642 | * This function indicate that a measurement data is ready. |
nikapov | 0:a1a69d32f310 | 643 | * This function check if interrupt mode is used then check is done accordingly. |
nikapov | 0:a1a69d32f310 | 644 | * If perform function clear the interrupt, this function will not work, |
nikapov | 0:a1a69d32f310 | 645 | * like in case of @a VL53L0X_PerformSingleRangingMeasurement(). |
nikapov | 0:a1a69d32f310 | 646 | * The previous function is blocking function, VL53L0X_GetMeasurementDataReady |
nikapov | 0:a1a69d32f310 | 647 | * is used for non-blocking capture. |
nikapov | 0:a1a69d32f310 | 648 | * |
nikapov | 0:a1a69d32f310 | 649 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 650 | * |
sepp_nepp | 11:c6f95a42d4d7 | 651 | * |
sepp_nepp | 11:c6f95a42d4d7 | 652 | * @return uint8_t Is Measurement Ready 0= not ready, 1 = ready |
sepp_nepp | 11:c6f95a42d4d7 | 653 | * Also check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 654 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 655 | uint8_t Get_Measurement_Ready(); |
nikapov | 0:a1a69d32f310 | 656 | |
nikapov | 0:a1a69d32f310 | 657 | /** |
nikapov | 0:a1a69d32f310 | 658 | * @brief Retrieve the measurements from device for a given setup |
nikapov | 0:a1a69d32f310 | 659 | * |
nikapov | 0:a1a69d32f310 | 660 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 661 | * Get data from last successful Ranging measurement |
nikapov | 0:a1a69d32f310 | 662 | * @warning USER should take care about @a VL53L0X_GetNumberOfROIZones() |
nikapov | 0:a1a69d32f310 | 663 | * before get data. |
sepp_nepp | 11:c6f95a42d4d7 | 664 | * Device will fill a NumberOfROIZones times the corresponding data |
nikapov | 0:a1a69d32f310 | 665 | * structure used in the measurement function. |
nikapov | 0:a1a69d32f310 | 666 | * |
nikapov | 0:a1a69d32f310 | 667 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 668 | * |
sepp_nepp | 11:c6f95a42d4d7 | 669 | * |
sepp_nepp | 11:c6f95a42d4d7 | 670 | * @param p_ranging_results Pointer to the data structure to fill up. |
sepp_nepp | 11:c6f95a42d4d7 | 671 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 672 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 673 | void Get_ranging_results( |
sepp_nepp | 11:c6f95a42d4d7 | 674 | TRangeResults *p_ranging_results); |
nikapov | 0:a1a69d32f310 | 675 | |
nikapov | 0:a1a69d32f310 | 676 | /** |
nikapov | 0:a1a69d32f310 | 677 | * @brief Clear given system interrupt condition |
nikapov | 0:a1a69d32f310 | 678 | * |
nikapov | 0:a1a69d32f310 | 679 | * @par Function Description |
sepp_nepp | 11:c6f95a42d4d7 | 680 | * Clear given interrupt(s) cause by writing into register #SYSINT_CLEAR register. |
nikapov | 0:a1a69d32f310 | 681 | * |
sepp_nepp | 11:c6f95a42d4d7 | 682 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 683 | * |
sepp_nepp | 11:c6f95a42d4d7 | 684 | * @param interrupt_mask Which interrupt source to clear. Use any combinations of #INTERRUPT_CLEAR_RANGING , #INTERRUPT_CLEAR_ALS , #INTERRUPT_CLEAR_ERROR. |
sepp_nepp | 11:c6f95a42d4d7 | 685 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 686 | * @return VL53L0X_ERROR_INTERRUPT_NOT_CLEARED Cannot clear interrupts |
nikapov | 0:a1a69d32f310 | 687 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 688 | void Clear_interrupt_mask( uint32_t interrupt_mask); |
nikapov | 0:a1a69d32f310 | 689 | |
nikapov | 0:a1a69d32f310 | 690 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 691 | * @brief Return device interrupt ErrState |
nikapov | 0:a1a69d32f310 | 692 | * |
nikapov | 0:a1a69d32f310 | 693 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 694 | * Returns currently raised interrupts by the device. |
nikapov | 0:a1a69d32f310 | 695 | * User shall be able to activate/deactivate interrupts through |
nikapov | 0:a1a69d32f310 | 696 | * @a VL53L0X_SetGpioConfig() |
nikapov | 0:a1a69d32f310 | 697 | * |
nikapov | 0:a1a69d32f310 | 698 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 699 | * |
sepp_nepp | 11:c6f95a42d4d7 | 700 | * |
sepp_nepp | 11:c6f95a42d4d7 | 701 | * @param p_interrupt_mask_status Pointer to ErrState variable to update |
sepp_nepp | 11:c6f95a42d4d7 | 702 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 703 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 704 | void Get_interrupt_mask_status( uint32_t *p_interrupt_mask_status); |
nikapov | 0:a1a69d32f310 | 705 | |
nikapov | 0:a1a69d32f310 | 706 | /** |
nikapov | 0:a1a69d32f310 | 707 | * @brief Performs a single ranging measurement and retrieve the ranging |
nikapov | 0:a1a69d32f310 | 708 | * measurement data |
nikapov | 0:a1a69d32f310 | 709 | * |
nikapov | 0:a1a69d32f310 | 710 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 711 | * This function will change the device mode to VL53L0X_DEVICEMODE_SINGLE_RANGING |
nikapov | 0:a1a69d32f310 | 712 | * with @a VL53L0X_SetDeviceMode(), |
nikapov | 0:a1a69d32f310 | 713 | * It performs measurement with @a VL53L0X_PerformSingleMeasurement() |
nikapov | 0:a1a69d32f310 | 714 | * It get data from last successful Ranging measurement with |
nikapov | 0:a1a69d32f310 | 715 | * @a VL53L0X_GetRangingMeasurementData. |
nikapov | 0:a1a69d32f310 | 716 | * Finally it clear the interrupt with @a VL53L0X_ClearInterruptMask(). |
nikapov | 0:a1a69d32f310 | 717 | * |
nikapov | 0:a1a69d32f310 | 718 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 719 | * |
nikapov | 0:a1a69d32f310 | 720 | * @note This function change the device mode to |
nikapov | 0:a1a69d32f310 | 721 | * VL53L0X_DEVICEMODE_SINGLE_RANGING |
nikapov | 0:a1a69d32f310 | 722 | * |
sepp_nepp | 11:c6f95a42d4d7 | 723 | * |
sepp_nepp | 11:c6f95a42d4d7 | 724 | * @param p_ranging_results Pointer to the data structure to fill up. |
sepp_nepp | 11:c6f95a42d4d7 | 725 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 726 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 727 | void Perf_single_ranging_measurement( |
sepp_nepp | 11:c6f95a42d4d7 | 728 | TRangeResults *p_ranging_results); |
nikapov | 0:a1a69d32f310 | 729 | |
nikapov | 0:a1a69d32f310 | 730 | /** |
nikapov | 0:a1a69d32f310 | 731 | * @brief Single shot measurement. |
nikapov | 0:a1a69d32f310 | 732 | * |
nikapov | 0:a1a69d32f310 | 733 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 734 | * Perform simple measurement sequence (Start measure, Wait measure to end, |
nikapov | 0:a1a69d32f310 | 735 | * and returns when measurement is done). |
nikapov | 0:a1a69d32f310 | 736 | * Once function returns, user can get valid data by calling |
nikapov | 0:a1a69d32f310 | 737 | * VL53L0X_GetRangingMeasurement or VL53L0X_GetHistogramMeasurement |
nikapov | 0:a1a69d32f310 | 738 | * depending on defined measurement mode |
nikapov | 0:a1a69d32f310 | 739 | * User should Clear the interrupt in case this are enabled by using the |
nikapov | 0:a1a69d32f310 | 740 | * function VL53L0X_ClearInterruptMask(). |
nikapov | 0:a1a69d32f310 | 741 | * |
nikapov | 0:a1a69d32f310 | 742 | * @warning This function is a blocking function |
nikapov | 0:a1a69d32f310 | 743 | * |
nikapov | 0:a1a69d32f310 | 744 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 745 | * |
sepp_nepp | 11:c6f95a42d4d7 | 746 | * |
sepp_nepp | 11:c6f95a42d4d7 | 747 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 748 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 749 | void Perf_single_measurement(); |
nikapov | 0:a1a69d32f310 | 750 | |
nikapov | 0:a1a69d32f310 | 751 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 752 | * @brief Read current ErrState of the error register for the selected device |
nikapov | 0:a1a69d32f310 | 753 | * |
nikapov | 0:a1a69d32f310 | 754 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 755 | * |
nikapov | 0:a1a69d32f310 | 756 | * @param p_device_error_status Pointer to current error code of the device |
sepp_nepp | 11:c6f95a42d4d7 | 757 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 758 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 759 | void Get_device_error_status(TDevError *p_device_error_status); |
nikapov | 0:a1a69d32f310 | 760 | |
nikapov | 0:a1a69d32f310 | 761 | /** |
nikapov | 0:a1a69d32f310 | 762 | * @brief Human readable error string for a given Error Code |
nikapov | 0:a1a69d32f310 | 763 | * |
nikapov | 0:a1a69d32f310 | 764 | * @note This function doesn't access to the device |
nikapov | 0:a1a69d32f310 | 765 | * |
sepp_nepp | 11:c6f95a42d4d7 | 766 | * @param error_code The error code as stored on ::TDevError |
nikapov | 0:a1a69d32f310 | 767 | * @param p_device_error_string The error string corresponding to the ErrorCode |
sepp_nepp | 11:c6f95a42d4d7 | 768 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 769 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 770 | void Get_device_error_string(TDevError error_code, char *p_device_error_string); |
nikapov | 0:a1a69d32f310 | 771 | |
sepp_nepp | 11:c6f95a42d4d7 | 772 | void Get_total_SIG_rate( TRangeResults *p_ranging_results, |
sepp_nepp | 11:c6f95a42d4d7 | 773 | TFP1616 *p_total_SIG_rate_mcps); |
nikapov | 0:a1a69d32f310 | 774 | |
sepp_nepp | 11:c6f95a42d4d7 | 775 | TFP1616 Get_total_xtalk_rate( TRangeResults *p_ranging_results); |
sepp_nepp | 11:c6f95a42d4d7 | 776 | |
nikapov | 0:a1a69d32f310 | 777 | /** |
nikapov | 0:a1a69d32f310 | 778 | * @brief Get Ranging Timing Budget in microseconds |
nikapov | 0:a1a69d32f310 | 779 | * |
nikapov | 0:a1a69d32f310 | 780 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 781 | * Returns the programmed the maximum time allowed by the user to the |
nikapov | 0:a1a69d32f310 | 782 | * device to run a full ranging sequence for the current mode |
nikapov | 0:a1a69d32f310 | 783 | * (ranging, histogram, ASL ...) |
nikapov | 0:a1a69d32f310 | 784 | * |
nikapov | 0:a1a69d32f310 | 785 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 786 | * |
sepp_nepp | 11:c6f95a42d4d7 | 787 | * |
sepp_nepp | 11:c6f95a42d4d7 | 788 | * @return uint32_t Max measurement time in microseconds. |
nikapov | 0:a1a69d32f310 | 789 | * Valid values are: |
nikapov | 0:a1a69d32f310 | 790 | * >= 17000 microsecs when wraparound enabled |
nikapov | 0:a1a69d32f310 | 791 | * >= 12000 microsecs when wraparound disabled |
sepp_nepp | 11:c6f95a42d4d7 | 792 | * Also check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 793 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 794 | uint32_t Get_Measure_Time_Budget_us(); |
nikapov | 0:a1a69d32f310 | 795 | |
nikapov | 0:a1a69d32f310 | 796 | /** |
nikapov | 0:a1a69d32f310 | 797 | * @brief Set Ranging Timing Budget in microseconds |
nikapov | 0:a1a69d32f310 | 798 | * |
nikapov | 0:a1a69d32f310 | 799 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 800 | * Defines the maximum time allowed by the user to the device to run a |
nikapov | 0:a1a69d32f310 | 801 | * full ranging sequence for the current mode (ranging, histogram, ASL ...) |
nikapov | 0:a1a69d32f310 | 802 | * |
nikapov | 0:a1a69d32f310 | 803 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 804 | * |
sepp_nepp | 11:c6f95a42d4d7 | 805 | * |
sepp_nepp | 11:c6f95a42d4d7 | 806 | * @param Measure_Time_Budget_us Max measurement time in |
nikapov | 0:a1a69d32f310 | 807 | * microseconds. |
nikapov | 0:a1a69d32f310 | 808 | * Valid values are: |
nikapov | 0:a1a69d32f310 | 809 | * >= 17000 microsecs when wraparound enabled |
nikapov | 0:a1a69d32f310 | 810 | * >= 12000 microsecs when wraparound disabled |
sepp_nepp | 11:c6f95a42d4d7 | 811 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 812 | * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned if |
nikapov | 0:a1a69d32f310 | 813 | MeasurementTimingBudgetMicroSeconds out of range |
nikapov | 0:a1a69d32f310 | 814 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 815 | void Set_Measure_Time_Budget_us( uint32_t Measure_Time_Budget_us); |
nikapov | 0:a1a69d32f310 | 816 | |
nikapov | 0:a1a69d32f310 | 817 | /** |
nikapov | 0:a1a69d32f310 | 818 | * @brief Get specific limit check enable state |
nikapov | 0:a1a69d32f310 | 819 | * |
nikapov | 0:a1a69d32f310 | 820 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 821 | * This function get the enable state of a specific limit check. |
sepp_nepp | 11:c6f95a42d4d7 | 822 | * The limit check is identified with the limit_check_id. |
nikapov | 0:a1a69d32f310 | 823 | * |
nikapov | 0:a1a69d32f310 | 824 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 825 | * |
sepp_nepp | 11:c6f95a42d4d7 | 826 | * |
nikapov | 0:a1a69d32f310 | 827 | * @param limit_check_id Limit Check ID |
sepp_nepp | 11:c6f95a42d4d7 | 828 | * (0<= limit_check_id < VL53L0X_GetNumberOfLimitCheck() ). |
sepp_nepp | 11:c6f95a42d4d7 | 829 | * @return uint8_t Check limit enable value. |
nikapov | 0:a1a69d32f310 | 830 | * if 1 the check limit |
sepp_nepp | 11:c6f95a42d4d7 | 831 | * corresponding to limit_check_id is Enabled |
nikapov | 0:a1a69d32f310 | 832 | * if 0 the check limit |
sepp_nepp | 11:c6f95a42d4d7 | 833 | * corresponding to limit_check_id is disabled |
sepp_nepp | 11:c6f95a42d4d7 | 834 | * @return also check class Field "ErrState" |
sepp_nepp | 11:c6f95a42d4d7 | 835 | * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned when limit_check_id value is out of range. |
nikapov | 0:a1a69d32f310 | 836 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 837 | uint8_t Get_limit_chk_en( uint16_t limit_check_id); |
nikapov | 0:a1a69d32f310 | 838 | |
nikapov | 0:a1a69d32f310 | 839 | /** |
nikapov | 0:a1a69d32f310 | 840 | * @brief Enable/Disable a specific limit check |
nikapov | 0:a1a69d32f310 | 841 | * |
nikapov | 0:a1a69d32f310 | 842 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 843 | * This function Enable/Disable a specific limit check. |
sepp_nepp | 11:c6f95a42d4d7 | 844 | * The limit check is identified with the limit_check_id. |
nikapov | 0:a1a69d32f310 | 845 | * |
nikapov | 0:a1a69d32f310 | 846 | * @note This function doesn't Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 847 | * |
sepp_nepp | 11:c6f95a42d4d7 | 848 | * @param limit_check_id Limit Check ID |
sepp_nepp | 11:c6f95a42d4d7 | 849 | * (0<= limit_check_id < VL53L0X_GetNumberOfLimitCheck() ). |
sepp_nepp | 11:c6f95a42d4d7 | 850 | * @param limit_chk_en if 1 the check limit corresponding to limit_check_id is Enabled |
sepp_nepp | 11:c6f95a42d4d7 | 851 | * if 0 the check limit corresponding to limit_check_id is disabled |
sepp_nepp | 11:c6f95a42d4d7 | 852 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 853 | * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned |
sepp_nepp | 11:c6f95a42d4d7 | 854 | * when limit_check_id value is out of range. |
nikapov | 0:a1a69d32f310 | 855 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 856 | void Set_limit_chk_en( uint16_t limit_check_id, uint8_t limit_chk_en); |
nikapov | 0:a1a69d32f310 | 857 | |
nikapov | 0:a1a69d32f310 | 858 | /** |
nikapov | 0:a1a69d32f310 | 859 | * @brief Get a specific limit check value |
nikapov | 0:a1a69d32f310 | 860 | * |
nikapov | 0:a1a69d32f310 | 861 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 862 | * This function get a specific limit check value from device then it updates |
nikapov | 0:a1a69d32f310 | 863 | * internal values and check enables. |
sepp_nepp | 11:c6f95a42d4d7 | 864 | * The limit check is identified with the limit_check_id. |
nikapov | 0:a1a69d32f310 | 865 | * |
nikapov | 0:a1a69d32f310 | 866 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 867 | * |
sepp_nepp | 11:c6f95a42d4d7 | 868 | * |
nikapov | 0:a1a69d32f310 | 869 | * @param limit_check_id Limit Check ID |
sepp_nepp | 11:c6f95a42d4d7 | 870 | * (0<= limit_check_id < VL53L0X_GetNumberOfLimitCheck() ). |
sepp_nepp | 11:c6f95a42d4d7 | 871 | * @return TFP1616 Limit check Value for a given limit_check_id. |
sepp_nepp | 11:c6f95a42d4d7 | 872 | * @return Also check class Field "ErrState";returned VL53L0X_ERROR_INVALID_PARAMS |
sepp_nepp | 11:c6f95a42d4d7 | 873 | * when limit_check_id value is out of range. |
nikapov | 0:a1a69d32f310 | 874 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 875 | TFP1616 Get_limit_chk_val( uint16_t limit_check_id); |
nikapov | 0:a1a69d32f310 | 876 | |
nikapov | 0:a1a69d32f310 | 877 | /** |
nikapov | 0:a1a69d32f310 | 878 | * @brief Set a specific limit check value |
nikapov | 0:a1a69d32f310 | 879 | * |
nikapov | 0:a1a69d32f310 | 880 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 881 | * This function set a specific limit check value. |
sepp_nepp | 11:c6f95a42d4d7 | 882 | * The limit check is identified with the limit_check_id. |
nikapov | 0:a1a69d32f310 | 883 | * |
nikapov | 0:a1a69d32f310 | 884 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 885 | * |
nikapov | 0:a1a69d32f310 | 886 | * @param limit_check_id Limit Check ID |
sepp_nepp | 11:c6f95a42d4d7 | 887 | * (0<= limit_check_id < VL53L0X_GetNumberOfLimitCheck() ). |
sepp_nepp | 11:c6f95a42d4d7 | 888 | * @param limit_chk_val Limit check Value for a given |
sepp_nepp | 11:c6f95a42d4d7 | 889 | * limit_check_id |
sepp_nepp | 11:c6f95a42d4d7 | 890 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 891 | * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned when either |
sepp_nepp | 11:c6f95a42d4d7 | 892 | * limit_check_id or LimitCheckValue value is out of range. |
nikapov | 0:a1a69d32f310 | 893 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 894 | void Set_limit_chk_val( uint16_t limit_check_id, TFP1616 limit_chk_val); |
nikapov | 0:a1a69d32f310 | 895 | |
nikapov | 0:a1a69d32f310 | 896 | /** |
nikapov | 0:a1a69d32f310 | 897 | * @brief Get the current value of the signal used for the limit check |
nikapov | 0:a1a69d32f310 | 898 | * |
nikapov | 0:a1a69d32f310 | 899 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 900 | * This function get a the current value of the signal used for the limit check. |
nikapov | 0:a1a69d32f310 | 901 | * To obtain the latest value you should run a ranging before. |
nikapov | 0:a1a69d32f310 | 902 | * The value reported is linked to the limit check identified with the |
sepp_nepp | 11:c6f95a42d4d7 | 903 | * limit_check_id. |
nikapov | 0:a1a69d32f310 | 904 | * |
nikapov | 0:a1a69d32f310 | 905 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 906 | * |
nikapov | 0:a1a69d32f310 | 907 | * @param limit_check_id Limit Check ID |
sepp_nepp | 11:c6f95a42d4d7 | 908 | * (0<= limit_check_id < VL53L0X_GetNumberOfLimitCheck() ). |
nikapov | 0:a1a69d32f310 | 909 | * @param p_limit_check_current Pointer to current Value for a |
sepp_nepp | 11:c6f95a42d4d7 | 910 | * given limit_check_id. |
sepp_nepp | 11:c6f95a42d4d7 | 911 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 912 | * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned when |
sepp_nepp | 11:c6f95a42d4d7 | 913 | * limit_check_id value is out of range. |
nikapov | 0:a1a69d32f310 | 914 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 915 | void Get_limit_check_current( uint16_t limit_check_id, |
sepp_nepp | 11:c6f95a42d4d7 | 916 | TFP1616 *p_limit_check_current); |
nikapov | 0:a1a69d32f310 | 917 | |
nikapov | 0:a1a69d32f310 | 918 | /** |
nikapov | 0:a1a69d32f310 | 919 | * @brief Return a the Status of the specified check limit |
nikapov | 0:a1a69d32f310 | 920 | * |
nikapov | 0:a1a69d32f310 | 921 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 922 | * This function returns the Status of the specified check limit. |
nikapov | 0:a1a69d32f310 | 923 | * The value indicate if the check is fail or not. |
sepp_nepp | 11:c6f95a42d4d7 | 924 | * The limit check is identified with the limit_check_id. |
nikapov | 0:a1a69d32f310 | 925 | * |
nikapov | 0:a1a69d32f310 | 926 | * @note This function doesn't Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 927 | * |
nikapov | 0:a1a69d32f310 | 928 | * @param limit_check_id Limit Check ID |
sepp_nepp | 11:c6f95a42d4d7 | 929 | (0<= limit_check_id < VL53L0X_GetNumberOfLimitCheck() ). |
nikapov | 0:a1a69d32f310 | 930 | * @param p_limit_check_status Pointer to the |
nikapov | 0:a1a69d32f310 | 931 | Limit Check Status of the given check limit. |
nikapov | 0:a1a69d32f310 | 932 | * LimitCheckStatus : |
nikapov | 0:a1a69d32f310 | 933 | * 0 the check is not fail |
nikapov | 0:a1a69d32f310 | 934 | * 1 the check if fail or not enabled |
nikapov | 0:a1a69d32f310 | 935 | * |
sepp_nepp | 11:c6f95a42d4d7 | 936 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 937 | * @return VL53L0X_ERROR_INVALID_PARAMS This error is |
sepp_nepp | 11:c6f95a42d4d7 | 938 | returned when limit_check_id value is out of range. |
nikapov | 0:a1a69d32f310 | 939 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 940 | void Get_limit_check_status(uint16_t limit_check_id, uint8_t *p_limit_check_status); |
nikapov | 0:a1a69d32f310 | 941 | |
nikapov | 0:a1a69d32f310 | 942 | /** |
nikapov | 0:a1a69d32f310 | 943 | * Get continuous mode Inter-Measurement period in milliseconds |
nikapov | 0:a1a69d32f310 | 944 | * |
nikapov | 0:a1a69d32f310 | 945 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 946 | * When trying to set too short time return INVALID_PARAMS minimal value |
nikapov | 0:a1a69d32f310 | 947 | * |
nikapov | 0:a1a69d32f310 | 948 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 949 | * |
sepp_nepp | 11:c6f95a42d4d7 | 950 | * @param p_measure_period_ms Pointer to programmed |
nikapov | 0:a1a69d32f310 | 951 | * Inter-Measurement Period in milliseconds. |
sepp_nepp | 11:c6f95a42d4d7 | 952 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 953 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 954 | void Get_measure_period_ms(uint32_t *p_measure_period_ms); |
nikapov | 0:a1a69d32f310 | 955 | |
nikapov | 0:a1a69d32f310 | 956 | /** |
nikapov | 0:a1a69d32f310 | 957 | * Program continuous mode Inter-Measurement period in milliseconds |
nikapov | 0:a1a69d32f310 | 958 | * |
nikapov | 0:a1a69d32f310 | 959 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 960 | * When trying to set too short time return INVALID_PARAMS minimal value |
nikapov | 0:a1a69d32f310 | 961 | * |
nikapov | 0:a1a69d32f310 | 962 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 963 | * |
sepp_nepp | 11:c6f95a42d4d7 | 964 | * @param measure_period_ms Inter-Measurement Period in ms. |
sepp_nepp | 11:c6f95a42d4d7 | 965 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 966 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 967 | void Set_measure_period_ms( uint32_t measure_period_ms ); |
nikapov | 0:a1a69d32f310 | 968 | |
nikapov | 0:a1a69d32f310 | 969 | /** |
nikapov | 0:a1a69d32f310 | 970 | * @brief Do an hard reset or soft reset (depending on implementation) of the |
nikapov | 0:a1a69d32f310 | 971 | * device \nAfter call of this function, device must be in same state as right |
nikapov | 0:a1a69d32f310 | 972 | * after a power-up sequence.This function will change the VL53L0X_State to |
nikapov | 0:a1a69d32f310 | 973 | * VL53L0X_STATE_POWERDOWN. |
nikapov | 0:a1a69d32f310 | 974 | * |
nikapov | 0:a1a69d32f310 | 975 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 976 | * |
sepp_nepp | 11:c6f95a42d4d7 | 977 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 978 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 979 | void Reset_device(); |
nikapov | 0:a1a69d32f310 | 980 | |
nikapov | 0:a1a69d32f310 | 981 | /** |
nikapov | 0:a1a69d32f310 | 982 | * @brief Get setup of Wrap around Check |
nikapov | 0:a1a69d32f310 | 983 | * |
nikapov | 0:a1a69d32f310 | 984 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 985 | * This function get the wrapAround check enable parameters |
nikapov | 0:a1a69d32f310 | 986 | * |
nikapov | 0:a1a69d32f310 | 987 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 988 | * |
sepp_nepp | 11:c6f95a42d4d7 | 989 | * @return uint8_t Wrap around Check state 0=disabled or 1 = enabled |
sepp_nepp | 11:c6f95a42d4d7 | 990 | * @return None Also check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 991 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 992 | uint8_t Get_Wrap_Around_Chk_En(); |
nikapov | 0:a1a69d32f310 | 993 | |
nikapov | 0:a1a69d32f310 | 994 | /** |
nikapov | 0:a1a69d32f310 | 995 | * @brief Enable (or disable) Wrap around Check |
nikapov | 0:a1a69d32f310 | 996 | * |
nikapov | 0:a1a69d32f310 | 997 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 998 | * |
sepp_nepp | 11:c6f95a42d4d7 | 999 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1000 | * @param wrap_around_Chk_En Wrap around Check to be set |
nikapov | 0:a1a69d32f310 | 1001 | * 0=disabled, other = enabled |
sepp_nepp | 11:c6f95a42d4d7 | 1002 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1003 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1004 | void Set_wrap_around_Chk_En( uint8_t wrap_around_Chk_En); |
nikapov | 0:a1a69d32f310 | 1005 | |
nikapov | 0:a1a69d32f310 | 1006 | /** |
nikapov | 0:a1a69d32f310 | 1007 | * @brief Sets the VCSEL pulse period. |
nikapov | 0:a1a69d32f310 | 1008 | * |
nikapov | 0:a1a69d32f310 | 1009 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1010 | * This function retrieves the VCSEL pulse period for the given period type. |
nikapov | 0:a1a69d32f310 | 1011 | * |
nikapov | 0:a1a69d32f310 | 1012 | * @note This function Accesses the device |
sepp_nepp | 11:c6f95a42d4d7 | 1013 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1014 | * @param Vcsel_Range_Phase VCSEL period identifier (pre-range|final). |
sepp_nepp | 11:c6f95a42d4d7 | 1015 | * @param vcsel_PPeriod VCSEL period value |
sepp_nepp | 11:c6f95a42d4d7 | 1016 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1017 | * @return VL53L0X_ERROR_INVALID_PARAMS Error VcselPeriodType parameter not |
nikapov | 0:a1a69d32f310 | 1018 | * supported. |
nikapov | 0:a1a69d32f310 | 1019 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1020 | void Set_vcsel_PPeriod( VL53L0X_Range_Phase Vcsel_Range_Phase, |
sepp_nepp | 11:c6f95a42d4d7 | 1021 | uint8_t vcsel_PPeriod); |
nikapov | 0:a1a69d32f310 | 1022 | |
nikapov | 0:a1a69d32f310 | 1023 | /** |
nikapov | 0:a1a69d32f310 | 1024 | * @brief Set low and high Interrupt thresholds for a given mode |
nikapov | 0:a1a69d32f310 | 1025 | * (ranging, ALS, ...) for a given device |
nikapov | 0:a1a69d32f310 | 1026 | * |
nikapov | 0:a1a69d32f310 | 1027 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1028 | * Set low and high Interrupt thresholds for a given mode (ranging, ALS, ...) |
nikapov | 0:a1a69d32f310 | 1029 | * for a given device |
nikapov | 0:a1a69d32f310 | 1030 | * |
nikapov | 0:a1a69d32f310 | 1031 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 1032 | * |
nikapov | 0:a1a69d32f310 | 1033 | * @note DeviceMode is ignored for the current device |
sepp_nepp | 11:c6f95a42d4d7 | 1034 | * |
nikapov | 0:a1a69d32f310 | 1035 | * @param device_mode Device Mode for which change thresholds |
nikapov | 0:a1a69d32f310 | 1036 | * @param threshold_low Low threshold (mm, lux ..., depending on the mode) |
nikapov | 0:a1a69d32f310 | 1037 | * @param threshold_high High threshold (mm, lux ..., depending on the mode) |
sepp_nepp | 11:c6f95a42d4d7 | 1038 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1039 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1040 | void Set_interrupt_thresholds( VL53L0X_DeviceModes device_mode, |
sepp_nepp | 11:c6f95a42d4d7 | 1041 | TFP1616 threshold_low, TFP1616 threshold_high); |
nikapov | 0:a1a69d32f310 | 1042 | |
nikapov | 0:a1a69d32f310 | 1043 | /** |
nikapov | 0:a1a69d32f310 | 1044 | * @brief Get high and low Interrupt thresholds for a given mode |
nikapov | 0:a1a69d32f310 | 1045 | * (ranging, ALS, ...) for a given device |
nikapov | 0:a1a69d32f310 | 1046 | * |
nikapov | 0:a1a69d32f310 | 1047 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1048 | * Get high and low Interrupt thresholds for a given mode (ranging, ALS, ...) |
nikapov | 0:a1a69d32f310 | 1049 | * for a given device |
nikapov | 0:a1a69d32f310 | 1050 | * |
nikapov | 0:a1a69d32f310 | 1051 | * @note This function Access to the device |
nikapov | 0:a1a69d32f310 | 1052 | * |
nikapov | 0:a1a69d32f310 | 1053 | * @note DeviceMode is ignored for the current device |
sepp_nepp | 11:c6f95a42d4d7 | 1054 | * |
nikapov | 0:a1a69d32f310 | 1055 | * @param device_mode Device Mode from which read thresholds |
nikapov | 0:a1a69d32f310 | 1056 | * @param p_threshold_low Low threshold (mm, lux ..., depending on the mode) |
nikapov | 0:a1a69d32f310 | 1057 | * @param p_threshold_high High threshold (mm, lux ..., depending on the mode) |
sepp_nepp | 11:c6f95a42d4d7 | 1058 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1059 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1060 | void Get_interrupt_thresholds( VL53L0X_DeviceModes device_mode, |
sepp_nepp | 11:c6f95a42d4d7 | 1061 | TFP1616 *p_threshold_low, TFP1616 *p_threshold_high); |
nikapov | 0:a1a69d32f310 | 1062 | |
nikapov | 0:a1a69d32f310 | 1063 | /** |
nikapov | 0:a1a69d32f310 | 1064 | * @brief Gets the (on/off) state of all sequence steps. |
nikapov | 0:a1a69d32f310 | 1065 | * |
nikapov | 0:a1a69d32f310 | 1066 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1067 | * This function retrieves the state of all sequence step in the scheduler. |
nikapov | 0:a1a69d32f310 | 1068 | * |
nikapov | 0:a1a69d32f310 | 1069 | * @note This function Accesses the device |
sepp_nepp | 11:c6f95a42d4d7 | 1070 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1071 | * @return VL53L0X_Sequence_Steps_t Struct containing result. |
sepp_nepp | 11:c6f95a42d4d7 | 1072 | * Also check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1073 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1074 | VL53L0X_Sequence_Steps_t Get_sequence_step_enables(); |
nikapov | 0:a1a69d32f310 | 1075 | |
nikapov | 0:a1a69d32f310 | 1076 | /** |
nikapov | 0:a1a69d32f310 | 1077 | * @brief Sets the (on/off) state of a requested sequence step. |
nikapov | 0:a1a69d32f310 | 1078 | * |
nikapov | 0:a1a69d32f310 | 1079 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1080 | * This function enables/disables a requested sequence step. |
nikapov | 0:a1a69d32f310 | 1081 | * |
nikapov | 0:a1a69d32f310 | 1082 | * @note This function Accesses the device |
sepp_nepp | 11:c6f95a42d4d7 | 1083 | * |
nikapov | 0:a1a69d32f310 | 1084 | * @param sequence_step_id Sequence step identifier. |
nikapov | 0:a1a69d32f310 | 1085 | * @param sequence_step_enabled Demanded state {0=Off,1=On} |
nikapov | 0:a1a69d32f310 | 1086 | * is enabled. |
sepp_nepp | 11:c6f95a42d4d7 | 1087 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1088 | * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not |
sepp_nepp | 11:c6f95a42d4d7 | 1089 | * supported. |
nikapov | 0:a1a69d32f310 | 1090 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1091 | void Set_sequence_step_enable(VL53L0X_SequenceStepId sequence_step_id, |
sepp_nepp | 11:c6f95a42d4d7 | 1092 | uint8_t sequence_step_enabled); |
nikapov | 0:a1a69d32f310 | 1093 | |
nikapov | 0:a1a69d32f310 | 1094 | /** |
nikapov | 0:a1a69d32f310 | 1095 | * @brief Gets the fraction enable parameter indicating the resolution of |
nikapov | 0:a1a69d32f310 | 1096 | * range measurements. |
nikapov | 0:a1a69d32f310 | 1097 | * |
nikapov | 0:a1a69d32f310 | 1098 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1099 | * Gets the fraction enable state, which translates to the resolution of |
nikapov | 0:a1a69d32f310 | 1100 | * range measurements as follows :Enabled:=0.25mm resolution, |
nikapov | 0:a1a69d32f310 | 1101 | * Not Enabled:=1mm resolution. |
nikapov | 0:a1a69d32f310 | 1102 | * |
nikapov | 0:a1a69d32f310 | 1103 | * @note This function Accesses the device |
sepp_nepp | 11:c6f95a42d4d7 | 1104 | * |
nikapov | 0:a1a69d32f310 | 1105 | * @param p_enabled Output Parameter reporting the fraction enable state. |
nikapov | 0:a1a69d32f310 | 1106 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1107 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1108 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1109 | void Get_fraction_enable( uint8_t *p_enabled); |
nikapov | 0:a1a69d32f310 | 1110 | |
nikapov | 0:a1a69d32f310 | 1111 | /** |
nikapov | 0:a1a69d32f310 | 1112 | * @brief Sets the resolution of range measurements. |
nikapov | 0:a1a69d32f310 | 1113 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1114 | * Set resolution of range measurements to either 0.25mm if |
nikapov | 0:a1a69d32f310 | 1115 | * fraction enabled or 1mm if not enabled. |
nikapov | 0:a1a69d32f310 | 1116 | * |
nikapov | 0:a1a69d32f310 | 1117 | * @note This function Accesses the device |
sepp_nepp | 11:c6f95a42d4d7 | 1118 | * |
nikapov | 0:a1a69d32f310 | 1119 | * @param enable Enable high resolution |
nikapov | 0:a1a69d32f310 | 1120 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1121 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1122 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1123 | void Set_range_fraction_enable( uint8_t enable); |
nikapov | 0:a1a69d32f310 | 1124 | |
nikapov | 0:a1a69d32f310 | 1125 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 1126 | * @brief Return the VL53L0X Device Implementation Version |
nikapov | 0:a1a69d32f310 | 1127 | * |
nikapov | 0:a1a69d32f310 | 1128 | * @note This function doesn't access to the device |
nikapov | 0:a1a69d32f310 | 1129 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1130 | * @param p_version Pointer to current Device Implementation Version |
sepp_nepp | 11:c6f95a42d4d7 | 1131 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1132 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1133 | void Get_version(VL53L0X_Version_t *p_version); |
nikapov | 0:a1a69d32f310 | 1134 | |
nikapov | 0:a1a69d32f310 | 1135 | /** |
nikapov | 0:a1a69d32f310 | 1136 | * @brief Reads the Product Revision for a for given Device |
nikapov | 0:a1a69d32f310 | 1137 | * This function can be used to distinguish cut1.0 from cut1.1. |
nikapov | 0:a1a69d32f310 | 1138 | * |
nikapov | 0:a1a69d32f310 | 1139 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1140 | * |
nikapov | 0:a1a69d32f310 | 1141 | * @param p_product_revision_major Pointer to Product Revision Major |
nikapov | 0:a1a69d32f310 | 1142 | * for a given Device |
nikapov | 0:a1a69d32f310 | 1143 | * @param p_product_revision_minor Pointer to Product Revision Minor |
nikapov | 0:a1a69d32f310 | 1144 | * for a given Device |
sepp_nepp | 11:c6f95a42d4d7 | 1145 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1146 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1147 | void Get_product_revision( uint8_t *p_product_revision_major, |
sepp_nepp | 11:c6f95a42d4d7 | 1148 | uint8_t *p_product_revision_minor); |
nikapov | 0:a1a69d32f310 | 1149 | |
nikapov | 0:a1a69d32f310 | 1150 | /** |
nikapov | 0:a1a69d32f310 | 1151 | * @brief Retrieve current device parameters |
nikapov | 0:a1a69d32f310 | 1152 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1153 | * Get actual parameters of the device |
nikapov | 0:a1a69d32f310 | 1154 | * @li Then start ranging operation. |
nikapov | 0:a1a69d32f310 | 1155 | * |
nikapov | 0:a1a69d32f310 | 1156 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1157 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1158 | * @return VL53L0X_DeviceParams_t Current device parameters. |
sepp_nepp | 11:c6f95a42d4d7 | 1159 | * Also check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1160 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1161 | VL53L0X_DeviceParams_t Get_device_parameters(); |
nikapov | 0:a1a69d32f310 | 1162 | |
nikapov | 0:a1a69d32f310 | 1163 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 1164 | * @brief Return the Device Specification Version used for the current |
nikapov | 0:a1a69d32f310 | 1165 | * implementation. |
nikapov | 0:a1a69d32f310 | 1166 | * |
nikapov | 0:a1a69d32f310 | 1167 | * @note This function doesn't access to the device |
nikapov | 0:a1a69d32f310 | 1168 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1169 | * @param p_Device_spec_version Pointer to current Device Specification Version |
sepp_nepp | 11:c6f95a42d4d7 | 1170 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1171 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1172 | void Get_Device_spec_version(VL53L0X_Version_t *p_Device_spec_version); |
nikapov | 0:a1a69d32f310 | 1173 | |
nikapov | 0:a1a69d32f310 | 1174 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 1175 | * @brief Reads the internal state of the Device for a given Device |
nikapov | 0:a1a69d32f310 | 1176 | * |
nikapov | 0:a1a69d32f310 | 1177 | * @note This function doesn't access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1178 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1179 | * @param p_Device_state Pointer to current state of the Device for a |
nikapov | 0:a1a69d32f310 | 1180 | * given Device |
sepp_nepp | 11:c6f95a42d4d7 | 1181 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1182 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1183 | void Get_Device_state(VL53L0X_State *p_Device_state); |
nikapov | 0:a1a69d32f310 | 1184 | |
sepp_nepp | 11:c6f95a42d4d7 | 1185 | /* New Strategy, Moving to a global variable to track error states: */ |
sepp_nepp | 11:c6f95a42d4d7 | 1186 | VL53L0X_Error ErrState; |
sepp_nepp | 11:c6f95a42d4d7 | 1187 | |
sepp_nepp | 11:c6f95a42d4d7 | 1188 | VL53L0X_State Current_State; /*!< Current state of this device; use Set_Current_State to change it */ |
nikapov | 0:a1a69d32f310 | 1189 | |
nikapov | 0:a1a69d32f310 | 1190 | /*** End High level API ***/ |
nikapov | 0:a1a69d32f310 | 1191 | private: |
sepp_nepp | 11:c6f95a42d4d7 | 1192 | void Wait_read_strobe(); |
nikapov | 0:a1a69d32f310 | 1193 | |
sepp_nepp | 11:c6f95a42d4d7 | 1194 | void Check_and_load_interrupt_settings( uint8_t start_not_stopflag); |
nikapov | 0:a1a69d32f310 | 1195 | |
sepp_nepp | 11:c6f95a42d4d7 | 1196 | uint32_t Decode_timeout(uint16_t encoded_timeout); |
nikapov | 0:a1a69d32f310 | 1197 | |
sepp_nepp | 11:c6f95a42d4d7 | 1198 | uint32_t Calc_timeout_us(uint16_t timeout_period_mclks, |
nikapov | 0:a1a69d32f310 | 1199 | uint8_t vcsel_period_pclks); |
nikapov | 0:a1a69d32f310 | 1200 | |
sepp_nepp | 11:c6f95a42d4d7 | 1201 | void Poll_Measure_Completion(); // was Measurement_poll_for_completion |
sepp_nepp | 11:c6f95a42d4d7 | 1202 | |
sepp_nepp | 11:c6f95a42d4d7 | 1203 | void Load_tuning_settings( uint8_t *p_tuning_setting_buffer ); |
nikapov | 0:a1a69d32f310 | 1204 | |
sepp_nepp | 11:c6f95a42d4d7 | 1205 | void Get_Device_range_status( uint8_t device_range_status, |
sepp_nepp | 11:c6f95a42d4d7 | 1206 | TFP1616 signal_rate, uint16_t effective_SPAD_rtn_count, |
sepp_nepp | 11:c6f95a42d4d7 | 1207 | TRangeResults *p_ranging_results, |
sepp_nepp | 11:c6f95a42d4d7 | 1208 | uint8_t *p_Device_range_status); |
nikapov | 0:a1a69d32f310 | 1209 | |
sepp_nepp | 11:c6f95a42d4d7 | 1210 | void Calc_sigma_estimate( |
sepp_nepp | 11:c6f95a42d4d7 | 1211 | TRangeResults *p_ranging_results, |
sepp_nepp | 11:c6f95a42d4d7 | 1212 | TFP1616 *p_sigma_estimate, uint32_t *p_dmax_mm); |
sepp_nepp | 11:c6f95a42d4d7 | 1213 | |
sepp_nepp | 11:c6f95a42d4d7 | 1214 | uint32_t Calc_timeout_mclks(uint32_t timeout_period_us, |
nikapov | 0:a1a69d32f310 | 1215 | uint8_t vcsel_period_pclks); |
sepp_nepp | 11:c6f95a42d4d7 | 1216 | |
sepp_nepp | 11:c6f95a42d4d7 | 1217 | void Calc_dmax( TFP1616 total_SIG_rate_mcps, |
sepp_nepp | 11:c6f95a42d4d7 | 1218 | TFP1616 total_corr_SIG_rate_mcps, |
sepp_nepp | 11:c6f95a42d4d7 | 1219 | TFP1616 pw_mult, uint32_t sigma_estimate_p1, |
sepp_nepp | 11:c6f95a42d4d7 | 1220 | TFP1616 sigma_estimate_p2, uint32_t peak_vcsel_duration_us, |
nikapov | 0:a1a69d32f310 | 1221 | uint32_t *pd_max_mm); |
sepp_nepp | 10:cd251e0fc2fd | 1222 | |
sepp_nepp | 11:c6f95a42d4d7 | 1223 | uint16_t Encode_timeout(uint32_t timeout_macro_clks); |
nikapov | 0:a1a69d32f310 | 1224 | |
nikapov | 0:a1a69d32f310 | 1225 | /* api_calibration.h functions */ |
sepp_nepp | 11:c6f95a42d4d7 | 1226 | void VL53L0X_Apply_Offset_Cal(); |
sepp_nepp | 11:c6f95a42d4d7 | 1227 | |
sepp_nepp | 11:c6f95a42d4d7 | 1228 | void Perf_vhv_calibration( uint8_t *p_vhv_settings, |
sepp_nepp | 11:c6f95a42d4d7 | 1229 | const uint8_t get_data_enable, const uint8_t restore_config); |
sepp_nepp | 11:c6f95a42d4d7 | 1230 | |
sepp_nepp | 11:c6f95a42d4d7 | 1231 | void Perf_single_Ref_calibration( uint8_t vhv_init_byte ); |
sepp_nepp | 11:c6f95a42d4d7 | 1232 | |
sepp_nepp | 11:c6f95a42d4d7 | 1233 | void Ref_calibration_io( uint8_t read_not_write, |
nikapov | 0:a1a69d32f310 | 1234 | uint8_t vhv_settings, uint8_t phase_cal, |
nikapov | 0:a1a69d32f310 | 1235 | uint8_t *p_vhv_settings, uint8_t *p_phase_cal, |
nikapov | 0:a1a69d32f310 | 1236 | const uint8_t vhv_enable, const uint8_t phase_enable); |
sepp_nepp | 11:c6f95a42d4d7 | 1237 | |
sepp_nepp | 11:c6f95a42d4d7 | 1238 | void Perf_phase_calibration( uint8_t *p_phase_cal, const uint8_t get_data_enable, |
nikapov | 0:a1a69d32f310 | 1239 | const uint8_t restore_config); |
sepp_nepp | 11:c6f95a42d4d7 | 1240 | |
sepp_nepp | 11:c6f95a42d4d7 | 1241 | void Enable_Ref_SPADS(uint8_t aperture_SPADS, uint8_t good_SPAD_array[], |
sepp_nepp | 11:c6f95a42d4d7 | 1242 | uint8_t SPAD_array[], uint32_t size, uint32_t start, |
sepp_nepp | 11:c6f95a42d4d7 | 1243 | uint32_t offset, uint32_t SPAD_count, uint32_t *p_last_SPAD); |
sepp_nepp | 11:c6f95a42d4d7 | 1244 | |
sepp_nepp | 11:c6f95a42d4d7 | 1245 | void Get_Next_Good_SPAD(uint8_t good_SPAD_array[], uint32_t size, |
nikapov | 0:a1a69d32f310 | 1246 | uint32_t curr, int32_t *p_next); |
sepp_nepp | 11:c6f95a42d4d7 | 1247 | |
sepp_nepp | 11:c6f95a42d4d7 | 1248 | void Enable_SPAD_bit( uint8_t SPAD_array[], uint32_t size, uint32_t SPAD_index); |
sepp_nepp | 11:c6f95a42d4d7 | 1249 | |
sepp_nepp | 11:c6f95a42d4d7 | 1250 | void Get_Ref_SPAD_map( uint8_t *p_Ref_SPAD_array ); |
sepp_nepp | 11:c6f95a42d4d7 | 1251 | |
sepp_nepp | 11:c6f95a42d4d7 | 1252 | uint16_t Get_Perf_Ref_SIG_measurement(); |
sepp_nepp | 11:c6f95a42d4d7 | 1253 | |
Davidroid | 2:d07edeaff6f1 | 1254 | |
Davidroid | 2:d07edeaff6f1 | 1255 | /* Read function of the ID device */ |
nikapov | 0:a1a69d32f310 | 1256 | virtual int read_id(uint8_t *id); |
sepp_nepp | 11:c6f95a42d4d7 | 1257 | |
sepp_nepp | 11:c6f95a42d4d7 | 1258 | void Wait_Measurement_Ready(); |
sepp_nepp | 10:cd251e0fc2fd | 1259 | |
sepp_nepp | 11:c6f95a42d4d7 | 1260 | void Wait_Stop_Completed(); |
nikapov | 0:a1a69d32f310 | 1261 | |
nikapov | 0:a1a69d32f310 | 1262 | /** |
nikapov | 0:a1a69d32f310 | 1263 | * @brief execute delay in all polling API call |
nikapov | 0:a1a69d32f310 | 1264 | * |
sepp_nepp | 10:cd251e0fc2fd | 1265 | * A typical multi-thread or RTOs implementation is to sleep the task for some |
sepp_nepp | 10:cd251e0fc2fd | 1266 | * 5ms (with 100Hz max rate faster polling is not needed) |
nikapov | 0:a1a69d32f310 | 1267 | * if nothing specific is need you can define it as an empty/void macro |
nikapov | 0:a1a69d32f310 | 1268 | * @code |
nikapov | 0:a1a69d32f310 | 1269 | * #define VL53L0X_PollingDelay(...) (void)0 |
nikapov | 0:a1a69d32f310 | 1270 | * @endcode |
sepp_nepp | 11:c6f95a42d4d7 | 1271 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1272 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1273 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1274 | void Polling_delay(); /* usually best implemented as a real function */ |
nikapov | 0:a1a69d32f310 | 1275 | |
nikapov | 0:a1a69d32f310 | 1276 | /////////////////////////////////////////////////////////////////////////////////////////////////////// |
nikapov | 0:a1a69d32f310 | 1277 | //Added functions // |
nikapov | 0:a1a69d32f310 | 1278 | /////////////////////////////////////////////////////////////////////////////////////////////////////// |
nikapov | 0:a1a69d32f310 | 1279 | |
nikapov | 0:a1a69d32f310 | 1280 | /** |
nikapov | 0:a1a69d32f310 | 1281 | * @brief Cycle Power to Device |
nikapov | 0:a1a69d32f310 | 1282 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1283 | * @return ErrState - ErrState 0 = ok, 1 = error |
nikapov | 0:a1a69d32f310 | 1284 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1285 | int32_t Cycle_power(void); |
nikapov | 0:a1a69d32f310 | 1286 | |
sepp_nepp | 11:c6f95a42d4d7 | 1287 | void count_enabled_SPADS(uint8_t SPAD_array[], uint32_t byte_count, |
sepp_nepp | 11:c6f95a42d4d7 | 1288 | uint32_t max_SPADS, uint32_t *p_total_SPADS_enabled, uint8_t *p_is_aperture); |
nikapov | 0:a1a69d32f310 | 1289 | |
sepp_nepp | 11:c6f95a42d4d7 | 1290 | /** |
nikapov | 0:a1a69d32f310 | 1291 | * @brief Gets the name of a given sequence step. |
nikapov | 0:a1a69d32f310 | 1292 | * |
nikapov | 0:a1a69d32f310 | 1293 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1294 | * This function retrieves the name of sequence steps corresponding to |
nikapov | 0:a1a69d32f310 | 1295 | * SequenceStepId. |
nikapov | 0:a1a69d32f310 | 1296 | * |
nikapov | 0:a1a69d32f310 | 1297 | * @note This function doesn't Accesses the device |
nikapov | 0:a1a69d32f310 | 1298 | * |
nikapov | 0:a1a69d32f310 | 1299 | * @param sequence_step_id Sequence step identifier. |
nikapov | 0:a1a69d32f310 | 1300 | * @param p_sequence_steps_string Pointer to Info string |
nikapov | 0:a1a69d32f310 | 1301 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1302 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1303 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1304 | void Get_sequence_steps_info(VL53L0X_SequenceStepId sequence_step_id, |
nikapov | 0:a1a69d32f310 | 1305 | char *p_sequence_steps_string); |
nikapov | 0:a1a69d32f310 | 1306 | |
nikapov | 0:a1a69d32f310 | 1307 | /** |
nikapov | 0:a1a69d32f310 | 1308 | * @brief Get the frequency of the timer used for ranging results time stamps |
nikapov | 0:a1a69d32f310 | 1309 | * |
nikapov | 0:a1a69d32f310 | 1310 | * @param[out] p_timer_freq_hz : pointer for timer frequency |
nikapov | 0:a1a69d32f310 | 1311 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1312 | * @return ErrState : 0 = ok, 1 = error |
nikapov | 0:a1a69d32f310 | 1313 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1314 | int32_t Get_timer_frequency(int32_t *p_timer_freq_hz); |
nikapov | 0:a1a69d32f310 | 1315 | |
nikapov | 0:a1a69d32f310 | 1316 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 1317 | * @brief Get the timer value in units of timer_freq_hz (see Get_timestamp_frequency()) |
nikapov | 0:a1a69d32f310 | 1318 | * |
nikapov | 0:a1a69d32f310 | 1319 | * @param[out] p_timer_count : pointer for timer count value |
nikapov | 0:a1a69d32f310 | 1320 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1321 | * @return ErrState : 0 = ok, 1 = error |
nikapov | 0:a1a69d32f310 | 1322 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1323 | int32_t Get_timer_value(int32_t *p_timer_count); |
nikapov | 0:a1a69d32f310 | 1324 | |
nikapov | 0:a1a69d32f310 | 1325 | /** |
nikapov | 0:a1a69d32f310 | 1326 | * @brief Configure ranging interrupt reported to system |
nikapov | 0:a1a69d32f310 | 1327 | * |
nikapov | 0:a1a69d32f310 | 1328 | * @note This function is not Implemented |
sepp_nepp | 11:c6f95a42d4d7 | 1329 | * |
nikapov | 0:a1a69d32f310 | 1330 | * @param interrupt_mask Mask of interrupt to Enable/disable |
nikapov | 0:a1a69d32f310 | 1331 | * (0:interrupt disabled or 1: interrupt enabled) |
nikapov | 0:a1a69d32f310 | 1332 | * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented |
nikapov | 0:a1a69d32f310 | 1333 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1334 | void Enable_interrupt_mask(uint32_t interrupt_mask); |
nikapov | 0:a1a69d32f310 | 1335 | |
nikapov | 0:a1a69d32f310 | 1336 | /** |
nikapov | 0:a1a69d32f310 | 1337 | * @brief Get Dmax Calibration Parameters for a given device |
nikapov | 0:a1a69d32f310 | 1338 | * |
nikapov | 0:a1a69d32f310 | 1339 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1340 | * |
nikapov | 0:a1a69d32f310 | 1341 | * @param p_range_milli_meter Pointer to Calibration Distance |
sepp_nepp | 11:c6f95a42d4d7 | 1342 | * @param p_SIG_rate_rtn_MHz Pointer to Signal rate return |
sepp_nepp | 11:c6f95a42d4d7 | 1343 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1344 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1345 | void Get_dmax_cal_parameters(uint16_t *p_range_milli_meter, |
sepp_nepp | 11:c6f95a42d4d7 | 1346 | TFP1616 *p_SIG_rate_rtn_MHz); |
nikapov | 0:a1a69d32f310 | 1347 | |
nikapov | 0:a1a69d32f310 | 1348 | /** |
nikapov | 0:a1a69d32f310 | 1349 | * @brief Set Dmax Calibration Parameters for a given device |
nikapov | 0:a1a69d32f310 | 1350 | * When one of the parameter is zero, this function will get parameter |
nikapov | 0:a1a69d32f310 | 1351 | * from NVM. |
nikapov | 0:a1a69d32f310 | 1352 | * @note This function doesn't Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1353 | * |
nikapov | 0:a1a69d32f310 | 1354 | * @param range_milli_meter Calibration Distance |
sepp_nepp | 11:c6f95a42d4d7 | 1355 | * @param signal_rate_rtn_MHz Signal rate return read at CalDistance |
sepp_nepp | 11:c6f95a42d4d7 | 1356 | * @return None; instead check class Field "ErrState" |
sepp_nepp | 11:c6f95a42d4d7 | 1357 | |
nikapov | 0:a1a69d32f310 | 1358 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1359 | void Get_dmax_cal_parameters(uint16_t range_milli_meter, |
sepp_nepp | 11:c6f95a42d4d7 | 1360 | TFP1616 signal_rate_rtn_MHz); |
nikapov | 0:a1a69d32f310 | 1361 | |
nikapov | 0:a1a69d32f310 | 1362 | /** |
nikapov | 0:a1a69d32f310 | 1363 | * @brief Retrieve the measurements from device for a given setup |
nikapov | 0:a1a69d32f310 | 1364 | * |
nikapov | 0:a1a69d32f310 | 1365 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1366 | * Get data from last successful Histogram measurement |
nikapov | 0:a1a69d32f310 | 1367 | * @warning USER should take care about @a VL53L0X_GetNumberOfROIZones() |
nikapov | 0:a1a69d32f310 | 1368 | * before get data. |
sepp_nepp | 11:c6f95a42d4d7 | 1369 | * Device will fill a NumberOfROIZones times the corresponding data structure |
nikapov | 0:a1a69d32f310 | 1370 | * used in the measurement function. |
nikapov | 0:a1a69d32f310 | 1371 | * |
nikapov | 0:a1a69d32f310 | 1372 | * @note This function is not Implemented |
sepp_nepp | 11:c6f95a42d4d7 | 1373 | * |
nikapov | 0:a1a69d32f310 | 1374 | * @param p_histogram_measurement_data Pointer to the histogram data structure. |
nikapov | 0:a1a69d32f310 | 1375 | * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented |
nikapov | 0:a1a69d32f310 | 1376 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1377 | void Get_histogram_measurement_data( |
nikapov | 0:a1a69d32f310 | 1378 | VL53L0X_HistogramMeasurementData_t *p_histogram_measurement_data); |
nikapov | 0:a1a69d32f310 | 1379 | |
nikapov | 0:a1a69d32f310 | 1380 | /** |
nikapov | 0:a1a69d32f310 | 1381 | * @brief Get current new device mode |
nikapov | 0:a1a69d32f310 | 1382 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1383 | * Get current Histogram mode of a Device |
nikapov | 0:a1a69d32f310 | 1384 | * |
nikapov | 0:a1a69d32f310 | 1385 | * @note This function doesn't Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1386 | * |
nikapov | 0:a1a69d32f310 | 1387 | * @param p_histogram_mode Pointer to current Histogram Mode value |
nikapov | 0:a1a69d32f310 | 1388 | * Valid values are: |
nikapov | 0:a1a69d32f310 | 1389 | * VL53L0X_HISTOGRAMMODE_DISABLED |
nikapov | 0:a1a69d32f310 | 1390 | * VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM |
nikapov | 0:a1a69d32f310 | 1391 | * VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY |
nikapov | 0:a1a69d32f310 | 1392 | * VL53L0X_HISTOGRAMMODE_RETURN_ONLY |
nikapov | 0:a1a69d32f310 | 1393 | * VL53L0X_HISTOGRAMMODE_BOTH |
sepp_nepp | 11:c6f95a42d4d7 | 1394 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1395 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1396 | void Get_histogram_mode( |
nikapov | 0:a1a69d32f310 | 1397 | VL53L0X_HistogramModes *p_histogram_mode); |
nikapov | 0:a1a69d32f310 | 1398 | |
nikapov | 0:a1a69d32f310 | 1399 | /** |
nikapov | 0:a1a69d32f310 | 1400 | * @brief Set a new Histogram mode |
nikapov | 0:a1a69d32f310 | 1401 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1402 | * Set device to a new Histogram mode |
nikapov | 0:a1a69d32f310 | 1403 | * |
nikapov | 0:a1a69d32f310 | 1404 | * @note This function doesn't Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1405 | * |
nikapov | 0:a1a69d32f310 | 1406 | * @param histogram_mode New device mode to apply |
nikapov | 0:a1a69d32f310 | 1407 | * Valid values are: |
nikapov | 0:a1a69d32f310 | 1408 | * VL53L0X_HISTOGRAMMODE_DISABLED |
nikapov | 0:a1a69d32f310 | 1409 | * VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM |
nikapov | 0:a1a69d32f310 | 1410 | * VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY |
nikapov | 0:a1a69d32f310 | 1411 | * VL53L0X_HISTOGRAMMODE_RETURN_ONLY |
nikapov | 0:a1a69d32f310 | 1412 | * VL53L0X_HISTOGRAMMODE_BOTH |
nikapov | 0:a1a69d32f310 | 1413 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1414 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1415 | * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when |
nikapov | 0:a1a69d32f310 | 1416 | * HistogramMode is not in the supported list |
nikapov | 0:a1a69d32f310 | 1417 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1418 | void Set_histogram_mode( |
nikapov | 0:a1a69d32f310 | 1419 | VL53L0X_HistogramModes histogram_mode); |
nikapov | 0:a1a69d32f310 | 1420 | |
nikapov | 0:a1a69d32f310 | 1421 | /** |
nikapov | 0:a1a69d32f310 | 1422 | * @brief Get the linearity corrective gain |
nikapov | 0:a1a69d32f310 | 1423 | * |
nikapov | 0:a1a69d32f310 | 1424 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1425 | * Should only be used after a successful call to @a VL53L0X_DataInit to backup |
nikapov | 0:a1a69d32f310 | 1426 | * device NVM value |
nikapov | 0:a1a69d32f310 | 1427 | * |
nikapov | 0:a1a69d32f310 | 1428 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1429 | * |
nikapov | 0:a1a69d32f310 | 1430 | * @param p_linearity_corrective_gain Pointer to the linearity |
nikapov | 0:a1a69d32f310 | 1431 | * corrective gain in x1000 |
nikapov | 0:a1a69d32f310 | 1432 | * if value is 1000 then no modification is applied. |
sepp_nepp | 11:c6f95a42d4d7 | 1433 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1434 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1435 | void Get_linearity_corrective_gain( |
nikapov | 0:a1a69d32f310 | 1436 | uint16_t *p_linearity_corrective_gain); |
nikapov | 0:a1a69d32f310 | 1437 | |
nikapov | 0:a1a69d32f310 | 1438 | /** |
nikapov | 0:a1a69d32f310 | 1439 | * Set the linearity corrective gain |
nikapov | 0:a1a69d32f310 | 1440 | * |
nikapov | 0:a1a69d32f310 | 1441 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1442 | * |
nikapov | 0:a1a69d32f310 | 1443 | * @param linearity_corrective_gain Linearity corrective |
nikapov | 0:a1a69d32f310 | 1444 | * gain in x1000 |
nikapov | 0:a1a69d32f310 | 1445 | * if value is 1000 then no modification is applied. |
sepp_nepp | 11:c6f95a42d4d7 | 1446 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1447 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1448 | void Set_linearity_corrective_gain( |
nikapov | 0:a1a69d32f310 | 1449 | int16_t linearity_corrective_gain); |
nikapov | 0:a1a69d32f310 | 1450 | |
nikapov | 0:a1a69d32f310 | 1451 | /** |
nikapov | 0:a1a69d32f310 | 1452 | * @brief Get the Maximum number of ROI Zones managed by the Device |
nikapov | 0:a1a69d32f310 | 1453 | * |
nikapov | 0:a1a69d32f310 | 1454 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1455 | * Get Maximum number of ROI Zones managed by the Device. |
nikapov | 0:a1a69d32f310 | 1456 | * |
nikapov | 0:a1a69d32f310 | 1457 | * @note This function doesn't Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1458 | * |
nikapov | 0:a1a69d32f310 | 1459 | * @param p_max_number_of_roi_zones Pointer to the Maximum Number |
nikapov | 0:a1a69d32f310 | 1460 | * of ROI Zones value. |
sepp_nepp | 11:c6f95a42d4d7 | 1461 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1462 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1463 | void Get_max_number_of_roi_zones( |
nikapov | 0:a1a69d32f310 | 1464 | uint8_t *p_max_number_of_roi_zones); |
nikapov | 0:a1a69d32f310 | 1465 | |
nikapov | 0:a1a69d32f310 | 1466 | /** |
nikapov | 0:a1a69d32f310 | 1467 | * @brief Retrieve the Reference Signal after a measurements |
nikapov | 0:a1a69d32f310 | 1468 | * |
nikapov | 0:a1a69d32f310 | 1469 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1470 | * Get Reference Signal from last successful Ranging measurement |
nikapov | 0:a1a69d32f310 | 1471 | * This function return a valid value after that you call the |
nikapov | 0:a1a69d32f310 | 1472 | * @a VL53L0X_GetRangingMeasurementData(). |
nikapov | 0:a1a69d32f310 | 1473 | * |
nikapov | 0:a1a69d32f310 | 1474 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1475 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1476 | * @param p_measurement_Ref_signal Pointer to the Ref Signal to fill up. |
sepp_nepp | 11:c6f95a42d4d7 | 1477 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1478 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1479 | void Get_Measurement_Ref_signal( |
sepp_nepp | 11:c6f95a42d4d7 | 1480 | TFP1616 *p_measurement_Ref_signal); |
nikapov | 0:a1a69d32f310 | 1481 | |
nikapov | 0:a1a69d32f310 | 1482 | /** |
nikapov | 0:a1a69d32f310 | 1483 | * @brief Get the number of the check limit managed by a given Device |
nikapov | 0:a1a69d32f310 | 1484 | * |
nikapov | 0:a1a69d32f310 | 1485 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1486 | * This function give the number of the check limit managed by the Device |
nikapov | 0:a1a69d32f310 | 1487 | * |
nikapov | 0:a1a69d32f310 | 1488 | * @note This function doesn't Access to the device |
nikapov | 0:a1a69d32f310 | 1489 | * |
nikapov | 0:a1a69d32f310 | 1490 | * @param p_number_of_limit_check Pointer to the number of check limit. |
sepp_nepp | 11:c6f95a42d4d7 | 1491 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1492 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1493 | void Get_number_of_limit_check( |
sepp_nepp | 10:cd251e0fc2fd | 1494 | uint16_t *p_number_of_limit_check); |
nikapov | 0:a1a69d32f310 | 1495 | |
nikapov | 0:a1a69d32f310 | 1496 | /** |
nikapov | 0:a1a69d32f310 | 1497 | * @brief Get the number of ROI Zones managed by the Device |
nikapov | 0:a1a69d32f310 | 1498 | * |
nikapov | 0:a1a69d32f310 | 1499 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1500 | * Get number of ROI Zones managed by the Device |
nikapov | 0:a1a69d32f310 | 1501 | * USER should take care about @a VL53L0X_GetNumberOfROIZones() |
nikapov | 0:a1a69d32f310 | 1502 | * before get data after a perform measurement. |
sepp_nepp | 11:c6f95a42d4d7 | 1503 | * Device will fill a NumberOfROIZones times the corresponding data |
nikapov | 0:a1a69d32f310 | 1504 | * structure used in the measurement function. |
nikapov | 0:a1a69d32f310 | 1505 | * |
nikapov | 0:a1a69d32f310 | 1506 | * @note This function doesn't Access to the device |
nikapov | 0:a1a69d32f310 | 1507 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1508 | * |
nikapov | 0:a1a69d32f310 | 1509 | * @param p_number_of_roi_zones Pointer to the Number of ROI Zones value. |
sepp_nepp | 11:c6f95a42d4d7 | 1510 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1511 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1512 | void Get_number_of_roi_zones( |
nikapov | 0:a1a69d32f310 | 1513 | uint8_t *p_number_of_roi_zones); |
nikapov | 0:a1a69d32f310 | 1514 | |
nikapov | 0:a1a69d32f310 | 1515 | /** |
nikapov | 0:a1a69d32f310 | 1516 | * @brief Set the number of ROI Zones to be used for a specific Device |
nikapov | 0:a1a69d32f310 | 1517 | * |
nikapov | 0:a1a69d32f310 | 1518 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1519 | * Set the number of ROI Zones to be used for a specific Device. |
nikapov | 0:a1a69d32f310 | 1520 | * The programmed value should be less than the max number of ROI Zones given |
nikapov | 0:a1a69d32f310 | 1521 | * with @a VL53L0X_GetMaxNumberOfROIZones(). |
sepp_nepp | 11:c6f95a42d4d7 | 1522 | * This version of API manages only one zone. |
sepp_nepp | 11:c6f95a42d4d7 | 1523 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1524 | * @param number_of_roi_zones Number of ROI Zones to be used |
sepp_nepp | 11:c6f95a42d4d7 | 1525 | * @return None; instead check class Field "ErrState" |
sepp_nepp | 11:c6f95a42d4d7 | 1526 | * @return VL53L0X_ERROR_INVALID_PARAMS This error is returned if NumberOfROIZones != 1 |
nikapov | 0:a1a69d32f310 | 1527 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1528 | void Set_number_of_roi_zones( uint8_t number_of_roi_zones); |
nikapov | 0:a1a69d32f310 | 1529 | |
nikapov | 0:a1a69d32f310 | 1530 | /** |
nikapov | 0:a1a69d32f310 | 1531 | * @brief Gets number of sequence steps managed by the API. |
nikapov | 0:a1a69d32f310 | 1532 | * |
nikapov | 0:a1a69d32f310 | 1533 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1534 | * This function retrieves the number of sequence steps currently managed |
nikapov | 0:a1a69d32f310 | 1535 | * by the API |
nikapov | 0:a1a69d32f310 | 1536 | * |
nikapov | 0:a1a69d32f310 | 1537 | * @note This function Accesses the device |
sepp_nepp | 11:c6f95a42d4d7 | 1538 | * |
nikapov | 0:a1a69d32f310 | 1539 | * @param p_number_of_sequence_steps Out parameter reporting the number of |
nikapov | 0:a1a69d32f310 | 1540 | * sequence steps. |
sepp_nepp | 11:c6f95a42d4d7 | 1541 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1542 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1543 | void Get_number_of_sequence_steps( uint8_t *p_number_of_sequence_steps); |
nikapov | 0:a1a69d32f310 | 1544 | /** |
nikapov | 0:a1a69d32f310 | 1545 | * @brief Get the power mode for a given Device |
nikapov | 0:a1a69d32f310 | 1546 | * |
nikapov | 0:a1a69d32f310 | 1547 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1548 | * |
nikapov | 0:a1a69d32f310 | 1549 | * @param p_power_mode Pointer to the current value of the power |
nikapov | 0:a1a69d32f310 | 1550 | * mode. see ::VL53L0X_PowerModes |
nikapov | 0:a1a69d32f310 | 1551 | * Valid values are: |
nikapov | 0:a1a69d32f310 | 1552 | * VL53L0X_POWERMODE_STANDBY_LEVEL1, |
nikapov | 0:a1a69d32f310 | 1553 | * VL53L0X_POWERMODE_IDLE_LEVEL1 |
sepp_nepp | 11:c6f95a42d4d7 | 1554 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1555 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1556 | void Get_power_mode( VL53L0X_PowerModes *p_power_mode); |
nikapov | 0:a1a69d32f310 | 1557 | |
nikapov | 0:a1a69d32f310 | 1558 | /** |
nikapov | 0:a1a69d32f310 | 1559 | * @brief Set the power mode for a given Device |
nikapov | 0:a1a69d32f310 | 1560 | * The power mode can be Standby or Idle. Different level of both Standby and |
nikapov | 0:a1a69d32f310 | 1561 | * Idle can exists. |
nikapov | 0:a1a69d32f310 | 1562 | * This function should not be used when device is in Ranging state. |
nikapov | 0:a1a69d32f310 | 1563 | * |
nikapov | 0:a1a69d32f310 | 1564 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1565 | * |
nikapov | 0:a1a69d32f310 | 1566 | * @param power_mode The value of the power mode to set. |
nikapov | 0:a1a69d32f310 | 1567 | * see ::VL53L0X_PowerModes |
nikapov | 0:a1a69d32f310 | 1568 | * Valid values are: |
nikapov | 0:a1a69d32f310 | 1569 | * VL53L0X_POWERMODE_STANDBY_LEVEL1, |
nikapov | 0:a1a69d32f310 | 1570 | * VL53L0X_POWERMODE_IDLE_LEVEL1 |
sepp_nepp | 11:c6f95a42d4d7 | 1571 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1572 | * @return VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when PowerMode |
nikapov | 0:a1a69d32f310 | 1573 | * is not in the supported list |
nikapov | 0:a1a69d32f310 | 1574 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1575 | void Set_power_mode(VL53L0X_PowerModes power_mode); |
nikapov | 0:a1a69d32f310 | 1576 | |
nikapov | 0:a1a69d32f310 | 1577 | /** |
nikapov | 0:a1a69d32f310 | 1578 | * @brief Retrieves SPAD configuration |
nikapov | 0:a1a69d32f310 | 1579 | * |
nikapov | 0:a1a69d32f310 | 1580 | * @par Function Description |
sepp_nepp | 11:c6f95a42d4d7 | 1581 | * This function retrieves the current number of applied reference SPADS |
nikapov | 0:a1a69d32f310 | 1582 | * and also their type : Aperture or Non-Aperture. |
nikapov | 0:a1a69d32f310 | 1583 | * |
nikapov | 0:a1a69d32f310 | 1584 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1585 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1586 | * @param p_SPAD_count Number ref SPAD Count |
sepp_nepp | 11:c6f95a42d4d7 | 1587 | * @param p_is_aperture_SPADS Reports if SPADS are of type |
nikapov | 0:a1a69d32f310 | 1588 | * aperture or non-aperture. |
nikapov | 0:a1a69d32f310 | 1589 | * 1:=aperture, 0:=Non-Aperture |
sepp_nepp | 11:c6f95a42d4d7 | 1590 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1591 | * @return VL53L0X_ERROR_REF_SPAD_INIT Error in the in the reference |
sepp_nepp | 11:c6f95a42d4d7 | 1592 | * SPAD configuration. |
nikapov | 0:a1a69d32f310 | 1593 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1594 | void wrapped_Get_Reference_SPADS( |
sepp_nepp | 11:c6f95a42d4d7 | 1595 | uint32_t *p_SPAD_count, uint8_t *p_is_aperture_SPADS); |
nikapov | 0:a1a69d32f310 | 1596 | |
nikapov | 0:a1a69d32f310 | 1597 | /** |
nikapov | 0:a1a69d32f310 | 1598 | * @brief Gets the (on/off) state of a requested sequence step. |
nikapov | 0:a1a69d32f310 | 1599 | * |
nikapov | 0:a1a69d32f310 | 1600 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1601 | * This function retrieves the state of a requested sequence step, i.e. on/off. |
nikapov | 0:a1a69d32f310 | 1602 | * |
nikapov | 0:a1a69d32f310 | 1603 | * @note This function Accesses the device |
nikapov | 0:a1a69d32f310 | 1604 | * |
nikapov | 0:a1a69d32f310 | 1605 | * @param sequence_step_id Sequence step identifier. |
nikapov | 0:a1a69d32f310 | 1606 | * @param p_sequence_step_enabled Out parameter reporting if the sequence step |
nikapov | 0:a1a69d32f310 | 1607 | * is enabled {0=Off,1=On}. |
sepp_nepp | 11:c6f95a42d4d7 | 1608 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1609 | * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not |
sepp_nepp | 11:c6f95a42d4d7 | 1610 | * supported. |
nikapov | 0:a1a69d32f310 | 1611 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1612 | void Get_sequence_step_enable( |
nikapov | 0:a1a69d32f310 | 1613 | VL53L0X_SequenceStepId sequence_step_id, uint8_t *p_sequence_step_enabled); |
nikapov | 0:a1a69d32f310 | 1614 | |
nikapov | 0:a1a69d32f310 | 1615 | |
nikapov | 0:a1a69d32f310 | 1616 | /** |
nikapov | 0:a1a69d32f310 | 1617 | * @brief Gets the timeout of a requested sequence step. |
nikapov | 0:a1a69d32f310 | 1618 | * |
nikapov | 0:a1a69d32f310 | 1619 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1620 | * This function retrieves the timeout of a requested sequence step. |
nikapov | 0:a1a69d32f310 | 1621 | * |
nikapov | 0:a1a69d32f310 | 1622 | * @note This function Accesses the device |
nikapov | 0:a1a69d32f310 | 1623 | * |
nikapov | 0:a1a69d32f310 | 1624 | * @param sequence_step_id Sequence step identifier. |
nikapov | 0:a1a69d32f310 | 1625 | * @param p_time_out_milli_secs Timeout value. |
sepp_nepp | 11:c6f95a42d4d7 | 1626 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1627 | * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not |
nikapov | 0:a1a69d32f310 | 1628 | * supported. |
nikapov | 0:a1a69d32f310 | 1629 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1630 | void Get_Sequence_Step_Timeout(VL53L0X_SequenceStepId sequence_step_id, |
sepp_nepp | 11:c6f95a42d4d7 | 1631 | uint32_t *p_time_out_micro_secs); |
nikapov | 0:a1a69d32f310 | 1632 | |
nikapov | 0:a1a69d32f310 | 1633 | /** |
nikapov | 0:a1a69d32f310 | 1634 | * @brief Sets the timeout of a requested sequence step. |
nikapov | 0:a1a69d32f310 | 1635 | * |
nikapov | 0:a1a69d32f310 | 1636 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1637 | * This function sets the timeout of a requested sequence step. |
nikapov | 0:a1a69d32f310 | 1638 | * |
nikapov | 0:a1a69d32f310 | 1639 | * @note This function Accesses the device |
sepp_nepp | 11:c6f95a42d4d7 | 1640 | * |
nikapov | 0:a1a69d32f310 | 1641 | * @param sequence_step_id Sequence step identifier. |
nikapov | 0:a1a69d32f310 | 1642 | * @param time_out_milli_secs Demanded timeout |
sepp_nepp | 11:c6f95a42d4d7 | 1643 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1644 | * @return VL53L0X_ERROR_INVALID_PARAMS Error SequenceStepId parameter not |
nikapov | 0:a1a69d32f310 | 1645 | * supported. |
nikapov | 0:a1a69d32f310 | 1646 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1647 | void Set_Sequence_Step_Timeout(VL53L0X_SequenceStepId sequence_step_id, |
sepp_nepp | 11:c6f95a42d4d7 | 1648 | uint32_t timeout_micro_secs); |
nikapov | 0:a1a69d32f310 | 1649 | |
nikapov | 0:a1a69d32f310 | 1650 | /** |
nikapov | 0:a1a69d32f310 | 1651 | * @brief Get the current SPAD Ambient Damper Factor value |
nikapov | 0:a1a69d32f310 | 1652 | * |
nikapov | 0:a1a69d32f310 | 1653 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1654 | * This function get the SPAD Ambient Damper Factor value |
nikapov | 0:a1a69d32f310 | 1655 | * |
nikapov | 0:a1a69d32f310 | 1656 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1657 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1658 | * @param p_SPAD_ambient_damper_factor Pointer to programmed SPAD Ambient |
nikapov | 0:a1a69d32f310 | 1659 | * Damper Factor value |
sepp_nepp | 11:c6f95a42d4d7 | 1660 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1661 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1662 | void Get_SPAD_ambient_damper_factor( |
sepp_nepp | 11:c6f95a42d4d7 | 1663 | uint16_t *p_SPAD_ambient_damper_factor); |
nikapov | 0:a1a69d32f310 | 1664 | /** |
nikapov | 0:a1a69d32f310 | 1665 | * @brief Set the SPAD Ambient Damper Factor value |
nikapov | 0:a1a69d32f310 | 1666 | * |
nikapov | 0:a1a69d32f310 | 1667 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1668 | * This function set the SPAD Ambient Damper Factor value |
nikapov | 0:a1a69d32f310 | 1669 | * |
nikapov | 0:a1a69d32f310 | 1670 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1671 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1672 | * @param SPAD_ambient_damper_factor SPAD Ambient Damper Factor value |
sepp_nepp | 11:c6f95a42d4d7 | 1673 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1674 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1675 | void Set_SPAD_ambient_damper_factor( |
sepp_nepp | 11:c6f95a42d4d7 | 1676 | uint16_t SPAD_ambient_damper_factor); |
nikapov | 0:a1a69d32f310 | 1677 | |
nikapov | 0:a1a69d32f310 | 1678 | /** |
nikapov | 0:a1a69d32f310 | 1679 | * @brief Get the current SPAD Ambient Damper Threshold value |
nikapov | 0:a1a69d32f310 | 1680 | * |
nikapov | 0:a1a69d32f310 | 1681 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1682 | * This function get the SPAD Ambient Damper Threshold value |
nikapov | 0:a1a69d32f310 | 1683 | * |
nikapov | 0:a1a69d32f310 | 1684 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1685 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1686 | * @param p_SPAD_ambient_damper_threshold Pointer to programmed |
nikapov | 0:a1a69d32f310 | 1687 | * SPAD Ambient Damper Threshold value |
sepp_nepp | 11:c6f95a42d4d7 | 1688 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1689 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1690 | void Get_SPAD_ambient_damper_threshold( |
sepp_nepp | 11:c6f95a42d4d7 | 1691 | uint16_t *p_SPAD_ambient_damper_threshold); |
nikapov | 0:a1a69d32f310 | 1692 | |
nikapov | 0:a1a69d32f310 | 1693 | /** |
nikapov | 0:a1a69d32f310 | 1694 | * @brief Set the SPAD Ambient Damper Threshold value |
nikapov | 0:a1a69d32f310 | 1695 | * |
nikapov | 0:a1a69d32f310 | 1696 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1697 | * This function set the SPAD Ambient Damper Threshold value |
nikapov | 0:a1a69d32f310 | 1698 | * |
nikapov | 0:a1a69d32f310 | 1699 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1700 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1701 | * @param SPAD_ambient_damper_threshold SPAD Ambient Damper Threshold value |
sepp_nepp | 11:c6f95a42d4d7 | 1702 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1703 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1704 | void Set_SPAD_ambient_damper_threshold( |
sepp_nepp | 11:c6f95a42d4d7 | 1705 | uint16_t SPAD_ambient_damper_threshold); |
nikapov | 0:a1a69d32f310 | 1706 | |
nikapov | 0:a1a69d32f310 | 1707 | /** |
nikapov | 0:a1a69d32f310 | 1708 | * @brief Get the maximal distance for actual setup |
nikapov | 0:a1a69d32f310 | 1709 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1710 | * Device must be initialized through @a VL53L0X_SetParameters() prior calling |
nikapov | 0:a1a69d32f310 | 1711 | * this function. |
nikapov | 0:a1a69d32f310 | 1712 | * |
nikapov | 0:a1a69d32f310 | 1713 | * Any range value more than the value returned is to be considered as |
nikapov | 0:a1a69d32f310 | 1714 | * "no target detected" or |
nikapov | 0:a1a69d32f310 | 1715 | * "no target in detectable range"\n |
nikapov | 0:a1a69d32f310 | 1716 | * @warning The maximal distance depends on the setup |
nikapov | 0:a1a69d32f310 | 1717 | * |
nikapov | 0:a1a69d32f310 | 1718 | * @note This function is not Implemented |
sepp_nepp | 11:c6f95a42d4d7 | 1719 | * |
nikapov | 0:a1a69d32f310 | 1720 | * @param p_upper_limit_milli_meter The maximal range limit for actual setup |
nikapov | 0:a1a69d32f310 | 1721 | * (in millimeter) |
nikapov | 0:a1a69d32f310 | 1722 | * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented |
nikapov | 0:a1a69d32f310 | 1723 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1724 | void Get_upper_limit_milli_meter( |
nikapov | 0:a1a69d32f310 | 1725 | uint16_t *p_upper_limit_milli_meter); |
nikapov | 0:a1a69d32f310 | 1726 | |
nikapov | 0:a1a69d32f310 | 1727 | /** |
nikapov | 0:a1a69d32f310 | 1728 | * @brief Get the tuning settings pointer and the internal external switch |
nikapov | 0:a1a69d32f310 | 1729 | * value. |
nikapov | 0:a1a69d32f310 | 1730 | * |
nikapov | 0:a1a69d32f310 | 1731 | * This function is used to get the Tuning settings buffer pointer and the |
nikapov | 0:a1a69d32f310 | 1732 | * value. |
nikapov | 0:a1a69d32f310 | 1733 | * of the switch to select either external or internal tuning settings. |
nikapov | 0:a1a69d32f310 | 1734 | * |
nikapov | 0:a1a69d32f310 | 1735 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1736 | * |
nikapov | 0:a1a69d32f310 | 1737 | * @param pp_tuning_setting_buffer Pointer to tuning settings buffer. |
nikapov | 0:a1a69d32f310 | 1738 | * @param p_use_internal_tuning_settings Pointer to store Use internal tuning |
nikapov | 0:a1a69d32f310 | 1739 | * settings value. |
sepp_nepp | 11:c6f95a42d4d7 | 1740 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1741 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1742 | void Get_tuning_setting_buffer( uint8_t **pp_tuning_setting_buffer, |
sepp_nepp | 11:c6f95a42d4d7 | 1743 | uint8_t *p_use_internal_tuning_settings); |
nikapov | 0:a1a69d32f310 | 1744 | |
nikapov | 0:a1a69d32f310 | 1745 | /** |
nikapov | 0:a1a69d32f310 | 1746 | * @brief Set the tuning settings pointer |
nikapov | 0:a1a69d32f310 | 1747 | * |
nikapov | 0:a1a69d32f310 | 1748 | * This function is used to specify the Tuning settings buffer to be used |
nikapov | 0:a1a69d32f310 | 1749 | * for a given device. The buffer contains all the necessary data to permit |
nikapov | 0:a1a69d32f310 | 1750 | * the API to write tuning settings. |
nikapov | 0:a1a69d32f310 | 1751 | * This function permit to force the usage of either external or internal |
nikapov | 0:a1a69d32f310 | 1752 | * tuning settings. |
nikapov | 0:a1a69d32f310 | 1753 | * |
nikapov | 0:a1a69d32f310 | 1754 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1755 | * |
nikapov | 0:a1a69d32f310 | 1756 | * @param p_tuning_setting_buffer Pointer to tuning settings buffer. |
nikapov | 0:a1a69d32f310 | 1757 | * @param use_internal_tuning_settings Use internal tuning settings value. |
sepp_nepp | 11:c6f95a42d4d7 | 1758 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1759 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1760 | void Set_tuning_setting_buffer( uint8_t *p_tuning_setting_buffer, |
sepp_nepp | 10:cd251e0fc2fd | 1761 | uint8_t use_internal_tuning_settings); |
nikapov | 0:a1a69d32f310 | 1762 | |
nikapov | 0:a1a69d32f310 | 1763 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 1764 | * @defgroup VL53L0X_registerAccess_group Device Register Access Functions |
sepp_nepp | 11:c6f95a42d4d7 | 1765 | * @brief Device Register Access Functions |
nikapov | 0:a1a69d32f310 | 1766 | * @{ |
nikapov | 0:a1a69d32f310 | 1767 | */ |
nikapov | 0:a1a69d32f310 | 1768 | |
nikapov | 0:a1a69d32f310 | 1769 | /** |
nikapov | 0:a1a69d32f310 | 1770 | * Lock comms interface to serialize all commands to a shared I2C interface for a specific device |
sepp_nepp | 11:c6f95a42d4d7 | 1771 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1772 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1773 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1774 | void VL53L0X_lock_sequence_access(); |
nikapov | 0:a1a69d32f310 | 1775 | |
nikapov | 0:a1a69d32f310 | 1776 | /** |
nikapov | 0:a1a69d32f310 | 1777 | * Unlock comms interface to serialize all commands to a shared I2C interface for a specific device |
sepp_nepp | 11:c6f95a42d4d7 | 1778 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1779 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1780 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1781 | void VL53L0X_unlock_sequence_access(); |
nikapov | 0:a1a69d32f310 | 1782 | |
nikapov | 0:a1a69d32f310 | 1783 | /** |
nikapov | 0:a1a69d32f310 | 1784 | * @brief Prepare device for operation |
nikapov | 0:a1a69d32f310 | 1785 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1786 | * Update device with provided parameters |
nikapov | 0:a1a69d32f310 | 1787 | * @li Then start ranging operation. |
nikapov | 0:a1a69d32f310 | 1788 | * |
nikapov | 0:a1a69d32f310 | 1789 | * @note This function Access to the device |
sepp_nepp | 11:c6f95a42d4d7 | 1790 | * |
nikapov | 0:a1a69d32f310 | 1791 | * @param pDeviceParameters Pointer to store current device parameters. |
sepp_nepp | 11:c6f95a42d4d7 | 1792 | * @return None; instead check class Field "ErrState" |
nikapov | 0:a1a69d32f310 | 1793 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1794 | void VL53L0x_set_device_parameters( |
sepp_nepp | 11:c6f95a42d4d7 | 1795 | const VL53L0X_DeviceParams_t *pDeviceParameters); |
nikapov | 0:a1a69d32f310 | 1796 | |
nikapov | 0:a1a69d32f310 | 1797 | /** |
nikapov | 0:a1a69d32f310 | 1798 | * Set Group parameter Hold state |
nikapov | 0:a1a69d32f310 | 1799 | * |
nikapov | 0:a1a69d32f310 | 1800 | * @par Function Description |
nikapov | 0:a1a69d32f310 | 1801 | * Set or remove device internal group parameter hold |
nikapov | 0:a1a69d32f310 | 1802 | * |
nikapov | 0:a1a69d32f310 | 1803 | * @note This function is not Implemented |
sepp_nepp | 11:c6f95a42d4d7 | 1804 | * |
nikapov | 0:a1a69d32f310 | 1805 | * @param group_param_hold Group parameter Hold state to be set (on/off) |
nikapov | 0:a1a69d32f310 | 1806 | * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented |
nikapov | 0:a1a69d32f310 | 1807 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1808 | void Set_group_param_hold(uint8_t group_param_hold); |
nikapov | 0:a1a69d32f310 | 1809 | |
nikapov | 0:a1a69d32f310 | 1810 | /** |
nikapov | 0:a1a69d32f310 | 1811 | * @brief Wait for device ready for a new measurement command. |
nikapov | 0:a1a69d32f310 | 1812 | * Blocking function. |
nikapov | 0:a1a69d32f310 | 1813 | * |
nikapov | 0:a1a69d32f310 | 1814 | * @note This function is not Implemented |
sepp_nepp | 11:c6f95a42d4d7 | 1815 | * |
nikapov | 0:a1a69d32f310 | 1816 | * @param max_loop Max Number of polling loop (timeout). |
nikapov | 0:a1a69d32f310 | 1817 | * @return VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented |
nikapov | 0:a1a69d32f310 | 1818 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1819 | void Wait_device_ready_for_new_measurement( uint32_t max_loop); |
sepp_nepp | 11:c6f95a42d4d7 | 1820 | |
sepp_nepp | 11:c6f95a42d4d7 | 1821 | private: |
sepp_nepp | 11:c6f95a42d4d7 | 1822 | /******************************************************************************/ |
sepp_nepp | 11:c6f95a42d4d7 | 1823 | /****************** Write and read functions from I2C *************************/ |
sepp_nepp | 11:c6f95a42d4d7 | 1824 | /******************************************************************************/ |
sepp_nepp | 12:aa177f0e4c10 | 1825 | uint32_t Get_NVM_DWord(uint8_t NVM_Address) |
sepp_nepp | 12:aa177f0e4c10 | 1826 | uint16_t Get_NVM_Word (uint8_t NVM_Address) |
sepp_nepp | 12:aa177f0e4c10 | 1827 | uint8_t Get_NVM_Byte (uint8_t NVM_Address) |
sepp_nepp | 12:aa177f0e4c10 | 1828 | |
sepp_nepp | 11:c6f95a42d4d7 | 1829 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 1830 | * Thread safe Update (read/modify/write) single byte register |
sepp_nepp | 11:c6f95a42d4d7 | 1831 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1832 | * Final_reg = (Initial_reg & and_mask) | or_mask |
sepp_nepp | 11:c6f95a42d4d7 | 1833 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1834 | * @param index The register index |
sepp_nepp | 11:c6f95a42d4d7 | 1835 | * @param and_mask 8 bit and data |
sepp_nepp | 11:c6f95a42d4d7 | 1836 | * @param or_mask 8 bit or data |
sepp_nepp | 11:c6f95a42d4d7 | 1837 | * @return None; instead check class Field "ErrState" |
sepp_nepp | 11:c6f95a42d4d7 | 1838 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1839 | void Register_BitMask(uint8_t index, uint8_t and_mask, uint8_t or_mask); |
sepp_nepp | 11:c6f95a42d4d7 | 1840 | |
sepp_nepp | 11:c6f95a42d4d7 | 1841 | /* Write and read functions from I2C */ |
sepp_nepp | 11:c6f95a42d4d7 | 1842 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 1843 | * Write single byte register |
sepp_nepp | 11:c6f95a42d4d7 | 1844 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1845 | * @param index The register index |
sepp_nepp | 11:c6f95a42d4d7 | 1846 | * @param data 8 bit register data |
sepp_nepp | 11:c6f95a42d4d7 | 1847 | * @return None; instead check class Field "ErrState" |
sepp_nepp | 11:c6f95a42d4d7 | 1848 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1849 | void Write_Byte( uint8_t index, uint8_t data); |
sepp_nepp | 11:c6f95a42d4d7 | 1850 | |
sepp_nepp | 11:c6f95a42d4d7 | 1851 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 1852 | * Write word register |
sepp_nepp | 11:c6f95a42d4d7 | 1853 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1854 | * @param index The register index |
sepp_nepp | 11:c6f95a42d4d7 | 1855 | * @param data 16 bit register data |
sepp_nepp | 11:c6f95a42d4d7 | 1856 | * @return None; instead check class Field "ErrState" |
sepp_nepp | 11:c6f95a42d4d7 | 1857 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1858 | void Write_Word( uint8_t index, uint16_t data); |
sepp_nepp | 11:c6f95a42d4d7 | 1859 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 1860 | * Write double word (4 byte) register |
sepp_nepp | 11:c6f95a42d4d7 | 1861 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1862 | * @param index The register index |
sepp_nepp | 11:c6f95a42d4d7 | 1863 | * @param data 32 bit register data |
sepp_nepp | 11:c6f95a42d4d7 | 1864 | * @return None; instead check class Field "ErrState" |
sepp_nepp | 11:c6f95a42d4d7 | 1865 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1866 | void Write_DWord( uint8_t index, uint32_t data); |
nikapov | 0:a1a69d32f310 | 1867 | |
sepp_nepp | 11:c6f95a42d4d7 | 1868 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 1869 | * Read single byte register |
sepp_nepp | 11:c6f95a42d4d7 | 1870 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1871 | * @param index The register index |
sepp_nepp | 11:c6f95a42d4d7 | 1872 | * @return uint8_t Returned 8 bit data; also check class Field "ErrState" |
sepp_nepp | 11:c6f95a42d4d7 | 1873 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1874 | uint8_t Read_Byte(uint8_t index); |
sepp_nepp | 11:c6f95a42d4d7 | 1875 | |
sepp_nepp | 11:c6f95a42d4d7 | 1876 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 1877 | * Read word (2byte) register |
sepp_nepp | 11:c6f95a42d4d7 | 1878 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1879 | * @param index The register index |
sepp_nepp | 11:c6f95a42d4d7 | 1880 | * @return uint16_t Returned 16 bit data; also check class Field "ErrState" |
sepp_nepp | 11:c6f95a42d4d7 | 1881 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1882 | uint16_t Read_Word( uint8_t index); |
sepp_nepp | 11:c6f95a42d4d7 | 1883 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 1884 | * Read dword (4byte) register |
sepp_nepp | 11:c6f95a42d4d7 | 1885 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1886 | * @param index The register index |
sepp_nepp | 11:c6f95a42d4d7 | 1887 | * @return uint32_t Returned 32 bit data; also check class Field "ErrState" |
sepp_nepp | 11:c6f95a42d4d7 | 1888 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1889 | uint32_t Read_DWord( uint8_t index); |
sepp_nepp | 11:c6f95a42d4d7 | 1890 | |
sepp_nepp | 11:c6f95a42d4d7 | 1891 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 1892 | * @brief Writes a buffer towards the I2C peripheral device. |
sepp_nepp | 11:c6f95a42d4d7 | 1893 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1894 | * @param RegisterAddr specifies the internal address register |
sepp_nepp | 11:c6f95a42d4d7 | 1895 | * @param p_data pointer to the byte-array data to send |
sepp_nepp | 11:c6f95a42d4d7 | 1896 | * where to start writing to (must be correctly masked). |
sepp_nepp | 11:c6f95a42d4d7 | 1897 | * @param NumByteToWrite number of bytes to be written. |
sepp_nepp | 11:c6f95a42d4d7 | 1898 | * @retval VL53L0X_OK if ok, |
sepp_nepp | 11:c6f95a42d4d7 | 1899 | * @retval VL53L0X_ERROR_CONTROL_INTERFACE if an I2C error has occured, or |
sepp_nepp | 11:c6f95a42d4d7 | 1900 | * @retval VL53L0X_ERROR_I2C_BUF_OVERFLOW on temporary buffer overflow (i.e. NumByteToWrite was too high) |
sepp_nepp | 11:c6f95a42d4d7 | 1901 | * @note On some devices if NumByteToWrite is greater |
sepp_nepp | 11:c6f95a42d4d7 | 1902 | * than one, the RegisterAddr must be masked correctly! |
sepp_nepp | 11:c6f95a42d4d7 | 1903 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1904 | void I2c_Write(uint8_t RegisterAddr, uint8_t *p_data, uint16_t NumByteToWrite); |
nikapov | 0:a1a69d32f310 | 1905 | |
sepp_nepp | 11:c6f95a42d4d7 | 1906 | /** |
sepp_nepp | 11:c6f95a42d4d7 | 1907 | * @brief Reads a buffer from the I2C peripheral device. |
sepp_nepp | 11:c6f95a42d4d7 | 1908 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1909 | * @param RegisterAddr specifies the internal address register |
sepp_nepp | 11:c6f95a42d4d7 | 1910 | * @param p_data pointer to the byte-array data to receive |
sepp_nepp | 11:c6f95a42d4d7 | 1911 | * where to start writing to (must be correctly masked). |
sepp_nepp | 11:c6f95a42d4d7 | 1912 | * @param NumByteToRead number of bytes to be read; maximum VL53L0X_MAX_I2C_XFER_SIZE |
sepp_nepp | 11:c6f95a42d4d7 | 1913 | * @retval 0 if ok, |
sepp_nepp | 11:c6f95a42d4d7 | 1914 | * @retval -1 if an I2C error has occured |
sepp_nepp | 11:c6f95a42d4d7 | 1915 | * @note On some devices if NumByteToRead is greater |
sepp_nepp | 11:c6f95a42d4d7 | 1916 | * than one, the RegisterAddr must be masked correctly! |
sepp_nepp | 11:c6f95a42d4d7 | 1917 | */ |
sepp_nepp | 11:c6f95a42d4d7 | 1918 | void I2c_Read(uint8_t RegisterAddr, uint8_t *p_data, uint16_t NumByteToRead); |
nikapov | 0:a1a69d32f310 | 1919 | |
nikapov | 0:a1a69d32f310 | 1920 | /* IO Device */ |
sepp_nepp | 11:c6f95a42d4d7 | 1921 | I2C *_dev_i2c; |
sepp_nepp | 11:c6f95a42d4d7 | 1922 | |
sepp_nepp | 11:c6f95a42d4d7 | 1923 | /*!< i2c device address user specific field */ |
sepp_nepp | 11:c6f95a42d4d7 | 1924 | uint8_t I2cDevAddr; |
sepp_nepp | 11:c6f95a42d4d7 | 1925 | |
sepp_nepp | 11:c6f95a42d4d7 | 1926 | private: |
sepp_nepp | 11:c6f95a42d4d7 | 1927 | uint8_t Is_ApertureSPAD(uint32_t SPAD_index); |
sepp_nepp | 11:c6f95a42d4d7 | 1928 | |
sepp_nepp | 11:c6f95a42d4d7 | 1929 | void Reverse_bytes(uint8_t *data, uint32_t size); |
sepp_nepp | 11:c6f95a42d4d7 | 1930 | |
sepp_nepp | 11:c6f95a42d4d7 | 1931 | void Range_meas_int_continuous_mode(void (*fptr)(void)); |
sepp_nepp | 11:c6f95a42d4d7 | 1932 | |
sepp_nepp | 11:c6f95a42d4d7 | 1933 | uint32_t ISQRT(uint32_t num); |
sepp_nepp | 11:c6f95a42d4d7 | 1934 | |
sepp_nepp | 11:c6f95a42d4d7 | 1935 | uint32_t Quadrature_sum(uint32_t a, uint32_t b); |
sepp_nepp | 11:c6f95a42d4d7 | 1936 | |
sepp_nepp | 11:c6f95a42d4d7 | 1937 | void Set_Current_State( VL53L0X_State NewState ) |
sepp_nepp | 11:c6f95a42d4d7 | 1938 | { if (ErrState == VL53L0X_OK) { Current_State = NewState; } |
sepp_nepp | 11:c6f95a42d4d7 | 1939 | else { Current_State = VL53L0X_STATE_ERROR; } |
sepp_nepp | 11:c6f95a42d4d7 | 1940 | } // end of Set_Current_State |
sepp_nepp | 11:c6f95a42d4d7 | 1941 | |
sepp_nepp | 11:c6f95a42d4d7 | 1942 | // NB: it seems that the state SequenceConfig is only written to never read from ;) |
sepp_nepp | 11:c6f95a42d4d7 | 1943 | void Set_SequenceConfig ( uint8_t NewSequenceConfig ) |
sepp_nepp | 11:c6f95a42d4d7 | 1944 | { Write_Byte(REG_SYSTEM_SEQUENCE_CONFIG, NewSequenceConfig); |
sepp_nepp | 11:c6f95a42d4d7 | 1945 | if (ErrState == VL53L0X_OK) { SequenceConfig = NewSequenceConfig; } } |
sepp_nepp | 11:c6f95a42d4d7 | 1946 | |
sepp_nepp | 11:c6f95a42d4d7 | 1947 | private: |
sepp_nepp | 11:c6f95a42d4d7 | 1948 | static const unsigned int TEMP_BUF_SIZE = 64; |
sepp_nepp | 11:c6f95a42d4d7 | 1949 | |
nikapov | 0:a1a69d32f310 | 1950 | /* Digital out pin */ |
nikapov | 0:a1a69d32f310 | 1951 | DigitalOut *_gpio0; |
sepp_nepp | 11:c6f95a42d4d7 | 1952 | |
nikapov | 0:a1a69d32f310 | 1953 | /* Measure detection IRQ */ |
nikapov | 0:a1a69d32f310 | 1954 | InterruptIn *_gpio1Int; |
sepp_nepp | 11:c6f95a42d4d7 | 1955 | |
sepp_nepp | 10:cd251e0fc2fd | 1956 | /** |
sepp_nepp | 10:cd251e0fc2fd | 1957 | * @brief was VL53L0X_Dev_t, Generic device information |
sepp_nepp | 10:cd251e0fc2fd | 1958 | * |
sepp_nepp | 11:c6f95a42d4d7 | 1959 | * merged with VL53L0X_DevData_t that embeds ST FlightSense devdata |
sepp_nepp | 11:c6f95a42d4d7 | 1960 | * VL53L0X Device device ST private data structure \n |
sepp_nepp | 10:cd251e0fc2fd | 1961 | * End user should never access any of these field directly \n |
sepp_nepp | 10:cd251e0fc2fd | 1962 | */ |
sepp_nepp | 10:cd251e0fc2fd | 1963 | VL53L0X_DMaxData_t DMaxData; |
sepp_nepp | 10:cd251e0fc2fd | 1964 | /*!< Dmax Data */ |
sepp_nepp | 11:c6f95a42d4d7 | 1965 | int32_t Last_Offset_Cal_um; |
sepp_nepp | 11:c6f95a42d4d7 | 1966 | /*!< backed up Offset_Cal value found last time, but never used !!!*/ |
sepp_nepp | 11:c6f95a42d4d7 | 1967 | int32_t NVM_Offset_Cal_um; |
sepp_nepp | 10:cd251e0fc2fd | 1968 | /*!< backed up NVM value representing additional offset adjustment */ |
sepp_nepp | 11:c6f95a42d4d7 | 1969 | VL53L0X_DeviceParams_t CurrParams; |
sepp_nepp | 10:cd251e0fc2fd | 1970 | /*!< Current Device Parameter */ |
sepp_nepp | 11:c6f95a42d4d7 | 1971 | TRangeResults LastRangeMeasure; |
sepp_nepp | 10:cd251e0fc2fd | 1972 | /*!< Ranging Data */ |
sepp_nepp | 10:cd251e0fc2fd | 1973 | VL53L0X_HistogramMeasurementData_t LastHistogramMeasure; |
sepp_nepp | 10:cd251e0fc2fd | 1974 | /*!< Histogram Data */ |
sepp_nepp | 11:c6f95a42d4d7 | 1975 | VL53L0X_SPADData_t SPADData; |
sepp_nepp | 11:c6f95a42d4d7 | 1976 | /*!< SPAD Data */ |
sepp_nepp | 10:cd251e0fc2fd | 1977 | uint8_t SequenceConfig; |
sepp_nepp | 10:cd251e0fc2fd | 1978 | /*!< Internal value for the sequence config */ |
sepp_nepp | 10:cd251e0fc2fd | 1979 | uint8_t RangeFractionalEnable; |
sepp_nepp | 10:cd251e0fc2fd | 1980 | /*!< Enable/Disable fractional part of ranging data */ |
sepp_nepp | 10:cd251e0fc2fd | 1981 | VL53L0X_PowerModes PowerMode; |
sepp_nepp | 10:cd251e0fc2fd | 1982 | /*!< Current Power Mode */ |
sepp_nepp | 10:cd251e0fc2fd | 1983 | uint16_t SigmaEstRefArray; |
sepp_nepp | 10:cd251e0fc2fd | 1984 | /*!< Reference array sigma value in 1/100th of [mm] e.g. 100 = 1mm */ |
sepp_nepp | 10:cd251e0fc2fd | 1985 | uint16_t SigmaEstEffPulseWidth; |
sepp_nepp | 10:cd251e0fc2fd | 1986 | /*!< Effective Pulse width for sigma estimate in 1/100th of ns e.g. 900 = 9.0ns */ |
sepp_nepp | 10:cd251e0fc2fd | 1987 | uint16_t SigmaEstEffAmbWidth; |
sepp_nepp | 10:cd251e0fc2fd | 1988 | /*!< Effective Ambient width for sigma estimate in 1/100th of ns |
sepp_nepp | 10:cd251e0fc2fd | 1989 | * e.g. 500 = 5.0ns */ |
sepp_nepp | 10:cd251e0fc2fd | 1990 | uint8_t StopVariable; |
sepp_nepp | 10:cd251e0fc2fd | 1991 | /*!< StopVariable used during the stop sequence */ |
sepp_nepp | 10:cd251e0fc2fd | 1992 | uint16_t targetRefRate; |
sepp_nepp | 11:c6f95a42d4d7 | 1993 | /*!< Target Ambient Rate for Ref SPAD management */ |
sepp_nepp | 11:c6f95a42d4d7 | 1994 | TFP1616 SigmaEstimate; |
sepp_nepp | 10:cd251e0fc2fd | 1995 | /*!< Sigma Estimate - based on ambient & VCSEL rates and signal_total_events */ |
sepp_nepp | 11:c6f95a42d4d7 | 1996 | TFP1616 SignalEstimate; |
sepp_nepp | 10:cd251e0fc2fd | 1997 | /*!< Signal Estimate - based on ambient & VCSEL rates and cross talk */ |
sepp_nepp | 11:c6f95a42d4d7 | 1998 | TFP1616 LastSignalRefMcps; |
sepp_nepp | 10:cd251e0fc2fd | 1999 | /*!< Latest Signal ref in Mcps */ |
sepp_nepp | 10:cd251e0fc2fd | 2000 | uint8_t *pTuningSettingsPointer; |
sepp_nepp | 10:cd251e0fc2fd | 2001 | /*!< Pointer for Tuning Settings table */ |
sepp_nepp | 10:cd251e0fc2fd | 2002 | uint8_t UseInternalTuningSettings; |
sepp_nepp | 10:cd251e0fc2fd | 2003 | /*!< Indicate if we use Tuning Settings table */ |
sepp_nepp | 10:cd251e0fc2fd | 2004 | uint16_t LinearityCorrectiveGain; |
sepp_nepp | 10:cd251e0fc2fd | 2005 | /*!< Linearity Corrective Gain value in x1000 */ |
sepp_nepp | 10:cd251e0fc2fd | 2006 | uint16_t DmaxCalRangeMilliMeter; |
sepp_nepp | 10:cd251e0fc2fd | 2007 | /*!< Dmax Calibration Range millimeter */ |
sepp_nepp | 11:c6f95a42d4d7 | 2008 | TFP1616 DmaxCalSignalRateRtnMHz; |
sepp_nepp | 11:c6f95a42d4d7 | 2009 | /*!< Dmax Calibration Signal Rate Return MHz */ |
nikapov | 0:a1a69d32f310 | 2010 | }; |
nikapov | 0:a1a69d32f310 | 2011 | |
nikapov | 0:a1a69d32f310 | 2012 | #endif /* _VL53L0X_CLASS_H_ */ |