hh
Dependents: VL53L0X-mbedOS-master VL53L0X-mbedOS-masterbb
vl53l0x_def.h@0:e6fcdb78a136, 2016-08-23 (annotated)
- Committer:
- mjarvisal
- Date:
- Tue Aug 23 05:14:05 2016 +0000
- Revision:
- 0:e6fcdb78a136
Initial release
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mjarvisal | 0:e6fcdb78a136 | 1 | /******************************************************************************* |
mjarvisal | 0:e6fcdb78a136 | 2 | Copyright © 2016, STMicroelectronics International N.V. |
mjarvisal | 0:e6fcdb78a136 | 3 | All rights reserved. |
mjarvisal | 0:e6fcdb78a136 | 4 | |
mjarvisal | 0:e6fcdb78a136 | 5 | Redistribution and use in source and binary forms, with or without |
mjarvisal | 0:e6fcdb78a136 | 6 | modification, are permitted provided that the following conditions are met: |
mjarvisal | 0:e6fcdb78a136 | 7 | * Redistributions of source code must retain the above copyright |
mjarvisal | 0:e6fcdb78a136 | 8 | notice, this list of conditions and the following disclaimer. |
mjarvisal | 0:e6fcdb78a136 | 9 | * Redistributions in binary form must reproduce the above copyright |
mjarvisal | 0:e6fcdb78a136 | 10 | notice, this list of conditions and the following disclaimer in the |
mjarvisal | 0:e6fcdb78a136 | 11 | documentation and/or other materials provided with the distribution. |
mjarvisal | 0:e6fcdb78a136 | 12 | * Neither the name of STMicroelectronics nor the |
mjarvisal | 0:e6fcdb78a136 | 13 | names of its contributors may be used to endorse or promote products |
mjarvisal | 0:e6fcdb78a136 | 14 | derived from this software without specific prior written permission. |
mjarvisal | 0:e6fcdb78a136 | 15 | |
mjarvisal | 0:e6fcdb78a136 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
mjarvisal | 0:e6fcdb78a136 | 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
mjarvisal | 0:e6fcdb78a136 | 18 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND |
mjarvisal | 0:e6fcdb78a136 | 19 | NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED. |
mjarvisal | 0:e6fcdb78a136 | 20 | IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY |
mjarvisal | 0:e6fcdb78a136 | 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
mjarvisal | 0:e6fcdb78a136 | 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
mjarvisal | 0:e6fcdb78a136 | 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
mjarvisal | 0:e6fcdb78a136 | 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
mjarvisal | 0:e6fcdb78a136 | 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
mjarvisal | 0:e6fcdb78a136 | 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mjarvisal | 0:e6fcdb78a136 | 27 | *******************************************************************************/ |
mjarvisal | 0:e6fcdb78a136 | 28 | |
mjarvisal | 0:e6fcdb78a136 | 29 | /** |
mjarvisal | 0:e6fcdb78a136 | 30 | * @file VL53L0X_def.h |
mjarvisal | 0:e6fcdb78a136 | 31 | * |
mjarvisal | 0:e6fcdb78a136 | 32 | * @brief Type definitions for VL53L0X API. |
mjarvisal | 0:e6fcdb78a136 | 33 | * |
mjarvisal | 0:e6fcdb78a136 | 34 | */ |
mjarvisal | 0:e6fcdb78a136 | 35 | |
mjarvisal | 0:e6fcdb78a136 | 36 | |
mjarvisal | 0:e6fcdb78a136 | 37 | #ifndef _VL53L0X_DEF_H_ |
mjarvisal | 0:e6fcdb78a136 | 38 | #define _VL53L0X_DEF_H_ |
mjarvisal | 0:e6fcdb78a136 | 39 | |
mjarvisal | 0:e6fcdb78a136 | 40 | |
mjarvisal | 0:e6fcdb78a136 | 41 | #ifdef __cplusplus |
mjarvisal | 0:e6fcdb78a136 | 42 | extern "C" { |
mjarvisal | 0:e6fcdb78a136 | 43 | #endif |
mjarvisal | 0:e6fcdb78a136 | 44 | |
mjarvisal | 0:e6fcdb78a136 | 45 | /** @defgroup VL53L0X_globaldefine_group VL53L0X Defines |
mjarvisal | 0:e6fcdb78a136 | 46 | * @brief VL53L0X Defines |
mjarvisal | 0:e6fcdb78a136 | 47 | * @{ |
mjarvisal | 0:e6fcdb78a136 | 48 | */ |
mjarvisal | 0:e6fcdb78a136 | 49 | |
mjarvisal | 0:e6fcdb78a136 | 50 | |
mjarvisal | 0:e6fcdb78a136 | 51 | /** PAL SPECIFICATION major version */ |
mjarvisal | 0:e6fcdb78a136 | 52 | #define VL53L0X10_SPECIFICATION_VER_MAJOR 1 |
mjarvisal | 0:e6fcdb78a136 | 53 | /** PAL SPECIFICATION minor version */ |
mjarvisal | 0:e6fcdb78a136 | 54 | #define VL53L0X10_SPECIFICATION_VER_MINOR 2 |
mjarvisal | 0:e6fcdb78a136 | 55 | /** PAL SPECIFICATION sub version */ |
mjarvisal | 0:e6fcdb78a136 | 56 | #define VL53L0X10_SPECIFICATION_VER_SUB 7 |
mjarvisal | 0:e6fcdb78a136 | 57 | /** PAL SPECIFICATION sub version */ |
mjarvisal | 0:e6fcdb78a136 | 58 | #define VL53L0X10_SPECIFICATION_VER_REVISION 1440 |
mjarvisal | 0:e6fcdb78a136 | 59 | |
mjarvisal | 0:e6fcdb78a136 | 60 | /** VL53L0X PAL IMPLEMENTATION major version */ |
mjarvisal | 0:e6fcdb78a136 | 61 | #define VL53L0X10_IMPLEMENTATION_VER_MAJOR 1 |
mjarvisal | 0:e6fcdb78a136 | 62 | /** VL53L0X PAL IMPLEMENTATION minor version */ |
mjarvisal | 0:e6fcdb78a136 | 63 | #define VL53L0X10_IMPLEMENTATION_VER_MINOR 0 |
mjarvisal | 0:e6fcdb78a136 | 64 | /** VL53L0X PAL IMPLEMENTATION sub version */ |
mjarvisal | 0:e6fcdb78a136 | 65 | #define VL53L0X10_IMPLEMENTATION_VER_SUB 9 |
mjarvisal | 0:e6fcdb78a136 | 66 | /** VL53L0X PAL IMPLEMENTATION sub version */ |
mjarvisal | 0:e6fcdb78a136 | 67 | #define VL53L0X10_IMPLEMENTATION_VER_REVISION 3673 |
mjarvisal | 0:e6fcdb78a136 | 68 | |
mjarvisal | 0:e6fcdb78a136 | 69 | /** PAL SPECIFICATION major version */ |
mjarvisal | 0:e6fcdb78a136 | 70 | #define VL53L0X_SPECIFICATION_VER_MAJOR 1 |
mjarvisal | 0:e6fcdb78a136 | 71 | /** PAL SPECIFICATION minor version */ |
mjarvisal | 0:e6fcdb78a136 | 72 | #define VL53L0X_SPECIFICATION_VER_MINOR 2 |
mjarvisal | 0:e6fcdb78a136 | 73 | /** PAL SPECIFICATION sub version */ |
mjarvisal | 0:e6fcdb78a136 | 74 | #define VL53L0X_SPECIFICATION_VER_SUB 7 |
mjarvisal | 0:e6fcdb78a136 | 75 | /** PAL SPECIFICATION sub version */ |
mjarvisal | 0:e6fcdb78a136 | 76 | #define VL53L0X_SPECIFICATION_VER_REVISION 1440 |
mjarvisal | 0:e6fcdb78a136 | 77 | |
mjarvisal | 0:e6fcdb78a136 | 78 | /** VL53L0X PAL IMPLEMENTATION major version */ |
mjarvisal | 0:e6fcdb78a136 | 79 | #define VL53L0X_IMPLEMENTATION_VER_MAJOR 1 |
mjarvisal | 0:e6fcdb78a136 | 80 | /** VL53L0X PAL IMPLEMENTATION minor version */ |
mjarvisal | 0:e6fcdb78a136 | 81 | #define VL53L0X_IMPLEMENTATION_VER_MINOR 0 |
mjarvisal | 0:e6fcdb78a136 | 82 | /** VL53L0X PAL IMPLEMENTATION sub version */ |
mjarvisal | 0:e6fcdb78a136 | 83 | #define VL53L0X_IMPLEMENTATION_VER_SUB 1 |
mjarvisal | 0:e6fcdb78a136 | 84 | /** VL53L0X PAL IMPLEMENTATION sub version */ |
mjarvisal | 0:e6fcdb78a136 | 85 | #define VL53L0X_IMPLEMENTATION_VER_REVISION 4606 |
mjarvisal | 0:e6fcdb78a136 | 86 | #define VL53L0X_DEFAULT_MAX_LOOP 200 |
mjarvisal | 0:e6fcdb78a136 | 87 | #define VL53L0X_MAX_STRING_LENGTH 32 |
mjarvisal | 0:e6fcdb78a136 | 88 | |
mjarvisal | 0:e6fcdb78a136 | 89 | |
mjarvisal | 0:e6fcdb78a136 | 90 | #include "vl53l0x_device.h" |
mjarvisal | 0:e6fcdb78a136 | 91 | #include "vl53l0x_types.h" |
mjarvisal | 0:e6fcdb78a136 | 92 | |
mjarvisal | 0:e6fcdb78a136 | 93 | |
mjarvisal | 0:e6fcdb78a136 | 94 | /**************************************** |
mjarvisal | 0:e6fcdb78a136 | 95 | * PRIVATE define do not edit |
mjarvisal | 0:e6fcdb78a136 | 96 | ****************************************/ |
mjarvisal | 0:e6fcdb78a136 | 97 | |
mjarvisal | 0:e6fcdb78a136 | 98 | /** @brief Defines the parameters of the Get Version Functions |
mjarvisal | 0:e6fcdb78a136 | 99 | */ |
mjarvisal | 0:e6fcdb78a136 | 100 | typedef struct { |
mjarvisal | 0:e6fcdb78a136 | 101 | uint32_t revision; /*!< revision number */ |
mjarvisal | 0:e6fcdb78a136 | 102 | uint8_t major; /*!< major number */ |
mjarvisal | 0:e6fcdb78a136 | 103 | uint8_t minor; /*!< minor number */ |
mjarvisal | 0:e6fcdb78a136 | 104 | uint8_t build; /*!< build number */ |
mjarvisal | 0:e6fcdb78a136 | 105 | } VL53L0X_Version_t; |
mjarvisal | 0:e6fcdb78a136 | 106 | |
mjarvisal | 0:e6fcdb78a136 | 107 | |
mjarvisal | 0:e6fcdb78a136 | 108 | /** @brief Defines the parameters of the Get Device Info Functions |
mjarvisal | 0:e6fcdb78a136 | 109 | */ |
mjarvisal | 0:e6fcdb78a136 | 110 | typedef struct { |
mjarvisal | 0:e6fcdb78a136 | 111 | char Name[VL53L0X_MAX_STRING_LENGTH]; |
mjarvisal | 0:e6fcdb78a136 | 112 | /*!< Name of the Device e.g. Left_Distance */ |
mjarvisal | 0:e6fcdb78a136 | 113 | char Type[VL53L0X_MAX_STRING_LENGTH]; |
mjarvisal | 0:e6fcdb78a136 | 114 | /*!< Type of the Device e.g VL53L0X */ |
mjarvisal | 0:e6fcdb78a136 | 115 | char ProductId[VL53L0X_MAX_STRING_LENGTH]; |
mjarvisal | 0:e6fcdb78a136 | 116 | /*!< Product Identifier String */ |
mjarvisal | 0:e6fcdb78a136 | 117 | uint8_t ProductType; |
mjarvisal | 0:e6fcdb78a136 | 118 | /*!< Product Type, VL53L0X = 1, VL53L1 = 2 */ |
mjarvisal | 0:e6fcdb78a136 | 119 | uint8_t ProductRevisionMajor; |
mjarvisal | 0:e6fcdb78a136 | 120 | /*!< Product revision major */ |
mjarvisal | 0:e6fcdb78a136 | 121 | uint8_t ProductRevisionMinor; |
mjarvisal | 0:e6fcdb78a136 | 122 | /*!< Product revision minor */ |
mjarvisal | 0:e6fcdb78a136 | 123 | } VL53L0X_DeviceInfo_t; |
mjarvisal | 0:e6fcdb78a136 | 124 | |
mjarvisal | 0:e6fcdb78a136 | 125 | |
mjarvisal | 0:e6fcdb78a136 | 126 | /** @defgroup VL53L0X_define_Error_group Error and Warning code returned by API |
mjarvisal | 0:e6fcdb78a136 | 127 | * The following DEFINE are used to identify the PAL ERROR |
mjarvisal | 0:e6fcdb78a136 | 128 | * @{ |
mjarvisal | 0:e6fcdb78a136 | 129 | */ |
mjarvisal | 0:e6fcdb78a136 | 130 | |
mjarvisal | 0:e6fcdb78a136 | 131 | typedef int8_t VL53L0X_Error; |
mjarvisal | 0:e6fcdb78a136 | 132 | |
mjarvisal | 0:e6fcdb78a136 | 133 | #define VL53L0X_ERROR_NONE ((VL53L0X_Error) 0) |
mjarvisal | 0:e6fcdb78a136 | 134 | #define VL53L0X_ERROR_CALIBRATION_WARNING ((VL53L0X_Error) -1) |
mjarvisal | 0:e6fcdb78a136 | 135 | /*!< Warning invalid calibration data may be in used |
mjarvisal | 0:e6fcdb78a136 | 136 | \a VL53L0X_InitData() |
mjarvisal | 0:e6fcdb78a136 | 137 | \a VL53L0X_GetOffsetCalibrationData |
mjarvisal | 0:e6fcdb78a136 | 138 | \a VL53L0X_SetOffsetCalibrationData */ |
mjarvisal | 0:e6fcdb78a136 | 139 | #define VL53L0X_ERROR_MIN_CLIPPED ((VL53L0X_Error) -2) |
mjarvisal | 0:e6fcdb78a136 | 140 | /*!< Warning parameter passed was clipped to min before to be applied */ |
mjarvisal | 0:e6fcdb78a136 | 141 | |
mjarvisal | 0:e6fcdb78a136 | 142 | #define VL53L0X_ERROR_UNDEFINED ((VL53L0X_Error) -3) |
mjarvisal | 0:e6fcdb78a136 | 143 | /*!< Unqualified error */ |
mjarvisal | 0:e6fcdb78a136 | 144 | #define VL53L0X_ERROR_INVALID_PARAMS ((VL53L0X_Error) -4) |
mjarvisal | 0:e6fcdb78a136 | 145 | /*!< Parameter passed is invalid or out of range */ |
mjarvisal | 0:e6fcdb78a136 | 146 | #define VL53L0X_ERROR_NOT_SUPPORTED ((VL53L0X_Error) -5) |
mjarvisal | 0:e6fcdb78a136 | 147 | /*!< Function is not supported in current mode or configuration */ |
mjarvisal | 0:e6fcdb78a136 | 148 | #define VL53L0X_ERROR_RANGE_ERROR ((VL53L0X_Error) -6) |
mjarvisal | 0:e6fcdb78a136 | 149 | /*!< Device report a ranging error interrupt status */ |
mjarvisal | 0:e6fcdb78a136 | 150 | #define VL53L0X_ERROR_TIME_OUT ((VL53L0X_Error) -7) |
mjarvisal | 0:e6fcdb78a136 | 151 | /*!< Aborted due to time out */ |
mjarvisal | 0:e6fcdb78a136 | 152 | #define VL53L0X_ERROR_MODE_NOT_SUPPORTED ((VL53L0X_Error) -8) |
mjarvisal | 0:e6fcdb78a136 | 153 | /*!< Asked mode is not supported by the device */ |
mjarvisal | 0:e6fcdb78a136 | 154 | #define VL53L0X_ERROR_BUFFER_TOO_SMALL ((VL53L0X_Error) -9) |
mjarvisal | 0:e6fcdb78a136 | 155 | /*!< ... */ |
mjarvisal | 0:e6fcdb78a136 | 156 | #define VL53L0X_ERROR_GPIO_NOT_EXISTING ((VL53L0X_Error) -10) |
mjarvisal | 0:e6fcdb78a136 | 157 | /*!< User tried to setup a non-existing GPIO pin */ |
mjarvisal | 0:e6fcdb78a136 | 158 | #define VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED ((VL53L0X_Error) -11) |
mjarvisal | 0:e6fcdb78a136 | 159 | /*!< unsupported GPIO functionality */ |
mjarvisal | 0:e6fcdb78a136 | 160 | #define VL53L0X_ERROR_INTERRUPT_NOT_CLEARED ((VL53L0X_Error) -12) |
mjarvisal | 0:e6fcdb78a136 | 161 | /*!< Error during interrupt clear */ |
mjarvisal | 0:e6fcdb78a136 | 162 | #define VL53L0X_ERROR_CONTROL_INTERFACE ((VL53L0X_Error) -20) |
mjarvisal | 0:e6fcdb78a136 | 163 | /*!< error reported from IO functions */ |
mjarvisal | 0:e6fcdb78a136 | 164 | #define VL53L0X_ERROR_INVALID_COMMAND ((VL53L0X_Error) -30) |
mjarvisal | 0:e6fcdb78a136 | 165 | /*!< The command is not allowed in the current device state |
mjarvisal | 0:e6fcdb78a136 | 166 | * (power down) */ |
mjarvisal | 0:e6fcdb78a136 | 167 | #define VL53L0X_ERROR_DIVISION_BY_ZERO ((VL53L0X_Error) -40) |
mjarvisal | 0:e6fcdb78a136 | 168 | /*!< In the function a division by zero occurs */ |
mjarvisal | 0:e6fcdb78a136 | 169 | #define VL53L0X_ERROR_REF_SPAD_INIT ((VL53L0X_Error) -50) |
mjarvisal | 0:e6fcdb78a136 | 170 | /*!< Error during reference SPAD initialization */ |
mjarvisal | 0:e6fcdb78a136 | 171 | #define VL53L0X_ERROR_NOT_IMPLEMENTED ((VL53L0X_Error) -99) |
mjarvisal | 0:e6fcdb78a136 | 172 | /*!< Tells requested functionality has not been implemented yet or |
mjarvisal | 0:e6fcdb78a136 | 173 | * not compatible with the device */ |
mjarvisal | 0:e6fcdb78a136 | 174 | /** @} VL53L0X_define_Error_group */ |
mjarvisal | 0:e6fcdb78a136 | 175 | |
mjarvisal | 0:e6fcdb78a136 | 176 | |
mjarvisal | 0:e6fcdb78a136 | 177 | /** @defgroup VL53L0X_define_DeviceModes_group Defines Device modes |
mjarvisal | 0:e6fcdb78a136 | 178 | * Defines all possible modes for the device |
mjarvisal | 0:e6fcdb78a136 | 179 | * @{ |
mjarvisal | 0:e6fcdb78a136 | 180 | */ |
mjarvisal | 0:e6fcdb78a136 | 181 | typedef uint8_t VL53L0X_DeviceModes; |
mjarvisal | 0:e6fcdb78a136 | 182 | |
mjarvisal | 0:e6fcdb78a136 | 183 | #define VL53L0X_DEVICEMODE_SINGLE_RANGING ((VL53L0X_DeviceModes) 0) |
mjarvisal | 0:e6fcdb78a136 | 184 | #define VL53L0X_DEVICEMODE_CONTINUOUS_RANGING ((VL53L0X_DeviceModes) 1) |
mjarvisal | 0:e6fcdb78a136 | 185 | #define VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM ((VL53L0X_DeviceModes) 2) |
mjarvisal | 0:e6fcdb78a136 | 186 | #define VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING ((VL53L0X_DeviceModes) 3) |
mjarvisal | 0:e6fcdb78a136 | 187 | #define VL53L0X_DEVICEMODE_SINGLE_ALS ((VL53L0X_DeviceModes) 10) |
mjarvisal | 0:e6fcdb78a136 | 188 | #define VL53L0X_DEVICEMODE_GPIO_DRIVE ((VL53L0X_DeviceModes) 20) |
mjarvisal | 0:e6fcdb78a136 | 189 | #define VL53L0X_DEVICEMODE_GPIO_OSC ((VL53L0X_DeviceModes) 21) |
mjarvisal | 0:e6fcdb78a136 | 190 | /* ... Modes to be added depending on device */ |
mjarvisal | 0:e6fcdb78a136 | 191 | /** @} VL53L0X_define_DeviceModes_group */ |
mjarvisal | 0:e6fcdb78a136 | 192 | |
mjarvisal | 0:e6fcdb78a136 | 193 | |
mjarvisal | 0:e6fcdb78a136 | 194 | |
mjarvisal | 0:e6fcdb78a136 | 195 | /** @defgroup VL53L0X_define_HistogramModes_group Defines Histogram modes |
mjarvisal | 0:e6fcdb78a136 | 196 | * Defines all possible Histogram modes for the device |
mjarvisal | 0:e6fcdb78a136 | 197 | * @{ |
mjarvisal | 0:e6fcdb78a136 | 198 | */ |
mjarvisal | 0:e6fcdb78a136 | 199 | typedef uint8_t VL53L0X_HistogramModes; |
mjarvisal | 0:e6fcdb78a136 | 200 | |
mjarvisal | 0:e6fcdb78a136 | 201 | #define VL53L0X_HISTOGRAMMODE_DISABLED ((VL53L0X_HistogramModes) 0) |
mjarvisal | 0:e6fcdb78a136 | 202 | /*!< Histogram Disabled */ |
mjarvisal | 0:e6fcdb78a136 | 203 | #define VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY ((VL53L0X_HistogramModes) 1) |
mjarvisal | 0:e6fcdb78a136 | 204 | /*!< Histogram Reference array only */ |
mjarvisal | 0:e6fcdb78a136 | 205 | #define VL53L0X_HISTOGRAMMODE_RETURN_ONLY ((VL53L0X_HistogramModes) 2) |
mjarvisal | 0:e6fcdb78a136 | 206 | /*!< Histogram Return array only */ |
mjarvisal | 0:e6fcdb78a136 | 207 | #define VL53L0X_HISTOGRAMMODE_BOTH ((VL53L0X_HistogramModes) 3) |
mjarvisal | 0:e6fcdb78a136 | 208 | /*!< Histogram both Reference and Return Arrays */ |
mjarvisal | 0:e6fcdb78a136 | 209 | /* ... Modes to be added depending on device */ |
mjarvisal | 0:e6fcdb78a136 | 210 | /** @} VL53L0X_define_HistogramModes_group */ |
mjarvisal | 0:e6fcdb78a136 | 211 | |
mjarvisal | 0:e6fcdb78a136 | 212 | |
mjarvisal | 0:e6fcdb78a136 | 213 | /** @defgroup VL53L0X_define_PowerModes_group List of available Power Modes |
mjarvisal | 0:e6fcdb78a136 | 214 | * List of available Power Modes |
mjarvisal | 0:e6fcdb78a136 | 215 | * @{ |
mjarvisal | 0:e6fcdb78a136 | 216 | */ |
mjarvisal | 0:e6fcdb78a136 | 217 | |
mjarvisal | 0:e6fcdb78a136 | 218 | typedef uint8_t VL53L0X_PowerModes; |
mjarvisal | 0:e6fcdb78a136 | 219 | |
mjarvisal | 0:e6fcdb78a136 | 220 | #define VL53L0X_POWERMODE_STANDBY_LEVEL1 ((VL53L0X_PowerModes) 0) |
mjarvisal | 0:e6fcdb78a136 | 221 | /*!< Standby level 1 */ |
mjarvisal | 0:e6fcdb78a136 | 222 | #define VL53L0X_POWERMODE_STANDBY_LEVEL2 ((VL53L0X_PowerModes) 1) |
mjarvisal | 0:e6fcdb78a136 | 223 | /*!< Standby level 2 */ |
mjarvisal | 0:e6fcdb78a136 | 224 | #define VL53L0X_POWERMODE_IDLE_LEVEL1 ((VL53L0X_PowerModes) 2) |
mjarvisal | 0:e6fcdb78a136 | 225 | /*!< Idle level 1 */ |
mjarvisal | 0:e6fcdb78a136 | 226 | #define VL53L0X_POWERMODE_IDLE_LEVEL2 ((VL53L0X_PowerModes) 3) |
mjarvisal | 0:e6fcdb78a136 | 227 | /*!< Idle level 2 */ |
mjarvisal | 0:e6fcdb78a136 | 228 | |
mjarvisal | 0:e6fcdb78a136 | 229 | /** @} VL53L0X_define_PowerModes_group */ |
mjarvisal | 0:e6fcdb78a136 | 230 | |
mjarvisal | 0:e6fcdb78a136 | 231 | |
mjarvisal | 0:e6fcdb78a136 | 232 | /** @brief Defines all parameters for the device |
mjarvisal | 0:e6fcdb78a136 | 233 | */ |
mjarvisal | 0:e6fcdb78a136 | 234 | typedef struct { |
mjarvisal | 0:e6fcdb78a136 | 235 | VL53L0X_DeviceModes DeviceMode; |
mjarvisal | 0:e6fcdb78a136 | 236 | /*!< Defines type of measurement to be done for the next measure */ |
mjarvisal | 0:e6fcdb78a136 | 237 | VL53L0X_HistogramModes HistogramMode; |
mjarvisal | 0:e6fcdb78a136 | 238 | /*!< Defines type of histogram measurement to be done for the next |
mjarvisal | 0:e6fcdb78a136 | 239 | * measure */ |
mjarvisal | 0:e6fcdb78a136 | 240 | uint32_t MeasurementTimingBudgetMicroSeconds; |
mjarvisal | 0:e6fcdb78a136 | 241 | /*!< Defines the allowed total time for a single measurement */ |
mjarvisal | 0:e6fcdb78a136 | 242 | uint32_t InterMeasurementPeriodMilliSeconds; |
mjarvisal | 0:e6fcdb78a136 | 243 | /*!< Defines time between two consecutive measurements (between two |
mjarvisal | 0:e6fcdb78a136 | 244 | * measurement starts). If set to 0 means back-to-back mode */ |
mjarvisal | 0:e6fcdb78a136 | 245 | uint8_t XTalkCompensationEnable; |
mjarvisal | 0:e6fcdb78a136 | 246 | /*!< Tells if Crosstalk compensation shall be enable or not */ |
mjarvisal | 0:e6fcdb78a136 | 247 | uint16_t XTalkCompensationRangeMilliMeter; |
mjarvisal | 0:e6fcdb78a136 | 248 | /*!< CrossTalk compensation range in millimeter */ |
mjarvisal | 0:e6fcdb78a136 | 249 | FixPoint1616_t XTalkCompensationRateMegaCps; |
mjarvisal | 0:e6fcdb78a136 | 250 | /*!< CrossTalk compensation rate in Mega counts per seconds. |
mjarvisal | 0:e6fcdb78a136 | 251 | * Expressed in 16.16 fixed point format. */ |
mjarvisal | 0:e6fcdb78a136 | 252 | int32_t RangeOffsetMicroMeters; |
mjarvisal | 0:e6fcdb78a136 | 253 | /*!< Range offset adjustment (mm). */ |
mjarvisal | 0:e6fcdb78a136 | 254 | |
mjarvisal | 0:e6fcdb78a136 | 255 | uint8_t LimitChecksEnable[VL53L0X_CHECKENABLE_NUMBER_OF_CHECKS]; |
mjarvisal | 0:e6fcdb78a136 | 256 | /*!< This Array store all the Limit Check enable for this device. */ |
mjarvisal | 0:e6fcdb78a136 | 257 | uint8_t LimitChecksStatus[VL53L0X_CHECKENABLE_NUMBER_OF_CHECKS]; |
mjarvisal | 0:e6fcdb78a136 | 258 | /*!< This Array store all the Status of the check linked to last |
mjarvisal | 0:e6fcdb78a136 | 259 | * measurement. */ |
mjarvisal | 0:e6fcdb78a136 | 260 | FixPoint1616_t LimitChecksValue[VL53L0X_CHECKENABLE_NUMBER_OF_CHECKS]; |
mjarvisal | 0:e6fcdb78a136 | 261 | /*!< This Array store all the Limit Check value for this device */ |
mjarvisal | 0:e6fcdb78a136 | 262 | |
mjarvisal | 0:e6fcdb78a136 | 263 | uint8_t WrapAroundCheckEnable; |
mjarvisal | 0:e6fcdb78a136 | 264 | /*!< Tells if Wrap Around Check shall be enable or not */ |
mjarvisal | 0:e6fcdb78a136 | 265 | } VL53L0X_DeviceParameters_t; |
mjarvisal | 0:e6fcdb78a136 | 266 | |
mjarvisal | 0:e6fcdb78a136 | 267 | |
mjarvisal | 0:e6fcdb78a136 | 268 | /** @defgroup VL53L0X_define_State_group Defines the current status of the device |
mjarvisal | 0:e6fcdb78a136 | 269 | * Defines the current status of the device |
mjarvisal | 0:e6fcdb78a136 | 270 | * @{ |
mjarvisal | 0:e6fcdb78a136 | 271 | */ |
mjarvisal | 0:e6fcdb78a136 | 272 | |
mjarvisal | 0:e6fcdb78a136 | 273 | typedef uint8_t VL53L0X_State; |
mjarvisal | 0:e6fcdb78a136 | 274 | |
mjarvisal | 0:e6fcdb78a136 | 275 | #define VL53L0X_STATE_POWERDOWN ((VL53L0X_State) 0) |
mjarvisal | 0:e6fcdb78a136 | 276 | /*!< Device is in HW reset */ |
mjarvisal | 0:e6fcdb78a136 | 277 | #define VL53L0X_STATE_WAIT_STATICINIT ((VL53L0X_State) 1) |
mjarvisal | 0:e6fcdb78a136 | 278 | /*!< Device is initialized and wait for static initialization */ |
mjarvisal | 0:e6fcdb78a136 | 279 | #define VL53L0X_STATE_STANDBY ((VL53L0X_State) 2) |
mjarvisal | 0:e6fcdb78a136 | 280 | /*!< Device is in Low power Standby mode */ |
mjarvisal | 0:e6fcdb78a136 | 281 | #define VL53L0X_STATE_IDLE ((VL53L0X_State) 3) |
mjarvisal | 0:e6fcdb78a136 | 282 | /*!< Device has been initialized and ready to do measurements */ |
mjarvisal | 0:e6fcdb78a136 | 283 | #define VL53L0X_STATE_RUNNING ((VL53L0X_State) 4) |
mjarvisal | 0:e6fcdb78a136 | 284 | /*!< Device is performing measurement */ |
mjarvisal | 0:e6fcdb78a136 | 285 | #define VL53L0X_STATE_UNKNOWN ((VL53L0X_State) 98) |
mjarvisal | 0:e6fcdb78a136 | 286 | /*!< Device is in unknown state and need to be rebooted */ |
mjarvisal | 0:e6fcdb78a136 | 287 | #define VL53L0X_STATE_ERROR ((VL53L0X_State) 99) |
mjarvisal | 0:e6fcdb78a136 | 288 | /*!< Device is in error state and need to be rebooted */ |
mjarvisal | 0:e6fcdb78a136 | 289 | |
mjarvisal | 0:e6fcdb78a136 | 290 | /** @} VL53L0X_define_State_group */ |
mjarvisal | 0:e6fcdb78a136 | 291 | |
mjarvisal | 0:e6fcdb78a136 | 292 | |
mjarvisal | 0:e6fcdb78a136 | 293 | /** @brief Structure containing the Dmax computation parameters and data |
mjarvisal | 0:e6fcdb78a136 | 294 | */ |
mjarvisal | 0:e6fcdb78a136 | 295 | typedef struct { |
mjarvisal | 0:e6fcdb78a136 | 296 | int32_t AmbTuningWindowFactor_K; |
mjarvisal | 0:e6fcdb78a136 | 297 | /*!< internal algo tuning (*1000) */ |
mjarvisal | 0:e6fcdb78a136 | 298 | int32_t RetSignalAt0mm; |
mjarvisal | 0:e6fcdb78a136 | 299 | /*!< intermediate dmax computation value caching */ |
mjarvisal | 0:e6fcdb78a136 | 300 | } VL53L0X_DMaxData_t; |
mjarvisal | 0:e6fcdb78a136 | 301 | |
mjarvisal | 0:e6fcdb78a136 | 302 | /** |
mjarvisal | 0:e6fcdb78a136 | 303 | * @struct VL53L0X_RangeData_t |
mjarvisal | 0:e6fcdb78a136 | 304 | * @brief Range measurement data. |
mjarvisal | 0:e6fcdb78a136 | 305 | */ |
mjarvisal | 0:e6fcdb78a136 | 306 | typedef struct { |
mjarvisal | 0:e6fcdb78a136 | 307 | uint32_t TimeStamp; /*!< 32-bit time stamp. */ |
mjarvisal | 0:e6fcdb78a136 | 308 | uint32_t MeasurementTimeUsec; |
mjarvisal | 0:e6fcdb78a136 | 309 | /*!< Give the Measurement time needed by the device to do the |
mjarvisal | 0:e6fcdb78a136 | 310 | * measurement.*/ |
mjarvisal | 0:e6fcdb78a136 | 311 | |
mjarvisal | 0:e6fcdb78a136 | 312 | |
mjarvisal | 0:e6fcdb78a136 | 313 | uint16_t RangeMilliMeter; /*!< range distance in millimeter. */ |
mjarvisal | 0:e6fcdb78a136 | 314 | |
mjarvisal | 0:e6fcdb78a136 | 315 | uint16_t RangeDMaxMilliMeter; |
mjarvisal | 0:e6fcdb78a136 | 316 | /*!< Tells what is the maximum detection distance of the device |
mjarvisal | 0:e6fcdb78a136 | 317 | * in current setup and environment conditions (Filled when |
mjarvisal | 0:e6fcdb78a136 | 318 | * applicable) */ |
mjarvisal | 0:e6fcdb78a136 | 319 | |
mjarvisal | 0:e6fcdb78a136 | 320 | FixPoint1616_t SignalRateRtnMegaCps; |
mjarvisal | 0:e6fcdb78a136 | 321 | /*!< Return signal rate (MCPS)\n these is a 16.16 fix point |
mjarvisal | 0:e6fcdb78a136 | 322 | * value, which is effectively a measure of target |
mjarvisal | 0:e6fcdb78a136 | 323 | * reflectance.*/ |
mjarvisal | 0:e6fcdb78a136 | 324 | FixPoint1616_t AmbientRateRtnMegaCps; |
mjarvisal | 0:e6fcdb78a136 | 325 | /*!< Return ambient rate (MCPS)\n these is a 16.16 fix point |
mjarvisal | 0:e6fcdb78a136 | 326 | * value, which is effectively a measure of the ambien |
mjarvisal | 0:e6fcdb78a136 | 327 | * t light.*/ |
mjarvisal | 0:e6fcdb78a136 | 328 | |
mjarvisal | 0:e6fcdb78a136 | 329 | uint16_t EffectiveSpadRtnCount; |
mjarvisal | 0:e6fcdb78a136 | 330 | /*!< Return the effective SPAD count for the return signal. |
mjarvisal | 0:e6fcdb78a136 | 331 | * To obtain Real value it should be divided by 256 */ |
mjarvisal | 0:e6fcdb78a136 | 332 | |
mjarvisal | 0:e6fcdb78a136 | 333 | uint8_t ZoneId; |
mjarvisal | 0:e6fcdb78a136 | 334 | /*!< Denotes which zone and range scheduler stage the range |
mjarvisal | 0:e6fcdb78a136 | 335 | * data relates to. */ |
mjarvisal | 0:e6fcdb78a136 | 336 | uint8_t RangeFractionalPart; |
mjarvisal | 0:e6fcdb78a136 | 337 | /*!< Fractional part of range distance. Final value is a |
mjarvisal | 0:e6fcdb78a136 | 338 | * FixPoint168 value. */ |
mjarvisal | 0:e6fcdb78a136 | 339 | uint8_t RangeStatus; |
mjarvisal | 0:e6fcdb78a136 | 340 | /*!< Range Status for the current measurement. This is device |
mjarvisal | 0:e6fcdb78a136 | 341 | * dependent. Value = 0 means value is valid. |
mjarvisal | 0:e6fcdb78a136 | 342 | * See \ref RangeStatusPage */ |
mjarvisal | 0:e6fcdb78a136 | 343 | } VL53L0X_RangingMeasurementData_t; |
mjarvisal | 0:e6fcdb78a136 | 344 | |
mjarvisal | 0:e6fcdb78a136 | 345 | |
mjarvisal | 0:e6fcdb78a136 | 346 | #define VL53L0X_HISTOGRAM_BUFFER_SIZE 24 |
mjarvisal | 0:e6fcdb78a136 | 347 | |
mjarvisal | 0:e6fcdb78a136 | 348 | /** |
mjarvisal | 0:e6fcdb78a136 | 349 | * @struct VL53L0X_HistogramData_t |
mjarvisal | 0:e6fcdb78a136 | 350 | * @brief Histogram measurement data. |
mjarvisal | 0:e6fcdb78a136 | 351 | */ |
mjarvisal | 0:e6fcdb78a136 | 352 | typedef struct { |
mjarvisal | 0:e6fcdb78a136 | 353 | /* Histogram Measurement data */ |
mjarvisal | 0:e6fcdb78a136 | 354 | uint32_t HistogramData[VL53L0X_HISTOGRAM_BUFFER_SIZE]; |
mjarvisal | 0:e6fcdb78a136 | 355 | /*!< Histogram data */ |
mjarvisal | 0:e6fcdb78a136 | 356 | uint8_t HistogramType; /*!< Indicate the types of histogram data : |
mjarvisal | 0:e6fcdb78a136 | 357 | Return only, Reference only, both Return and Reference */ |
mjarvisal | 0:e6fcdb78a136 | 358 | uint8_t FirstBin; /*!< First Bin value */ |
mjarvisal | 0:e6fcdb78a136 | 359 | uint8_t BufferSize; /*!< Buffer Size - Set by the user.*/ |
mjarvisal | 0:e6fcdb78a136 | 360 | uint8_t NumberOfBins; |
mjarvisal | 0:e6fcdb78a136 | 361 | /*!< Number of bins filled by the histogram measurement */ |
mjarvisal | 0:e6fcdb78a136 | 362 | |
mjarvisal | 0:e6fcdb78a136 | 363 | VL53L0X_DeviceError ErrorStatus; |
mjarvisal | 0:e6fcdb78a136 | 364 | /*!< Error status of the current measurement. \n |
mjarvisal | 0:e6fcdb78a136 | 365 | see @a ::VL53L0X_DeviceError @a VL53L0X_GetStatusErrorString() */ |
mjarvisal | 0:e6fcdb78a136 | 366 | } VL53L0X_HistogramMeasurementData_t; |
mjarvisal | 0:e6fcdb78a136 | 367 | |
mjarvisal | 0:e6fcdb78a136 | 368 | #define VL53L0X_REF_SPAD_BUFFER_SIZE 6 |
mjarvisal | 0:e6fcdb78a136 | 369 | |
mjarvisal | 0:e6fcdb78a136 | 370 | /** |
mjarvisal | 0:e6fcdb78a136 | 371 | * @struct VL53L0X_SpadData_t |
mjarvisal | 0:e6fcdb78a136 | 372 | * @brief Spad Configuration Data. |
mjarvisal | 0:e6fcdb78a136 | 373 | */ |
mjarvisal | 0:e6fcdb78a136 | 374 | typedef struct { |
mjarvisal | 0:e6fcdb78a136 | 375 | uint8_t RefSpadEnables[VL53L0X_REF_SPAD_BUFFER_SIZE]; |
mjarvisal | 0:e6fcdb78a136 | 376 | /*!< Reference Spad Enables */ |
mjarvisal | 0:e6fcdb78a136 | 377 | uint8_t RefGoodSpadMap[VL53L0X_REF_SPAD_BUFFER_SIZE]; |
mjarvisal | 0:e6fcdb78a136 | 378 | /*!< Reference Spad Good Spad Map */ |
mjarvisal | 0:e6fcdb78a136 | 379 | } VL53L0X_SpadData_t; |
mjarvisal | 0:e6fcdb78a136 | 380 | |
mjarvisal | 0:e6fcdb78a136 | 381 | typedef struct { |
mjarvisal | 0:e6fcdb78a136 | 382 | FixPoint1616_t OscFrequencyMHz; /* Frequency used */ |
mjarvisal | 0:e6fcdb78a136 | 383 | |
mjarvisal | 0:e6fcdb78a136 | 384 | uint16_t LastEncodedTimeout; |
mjarvisal | 0:e6fcdb78a136 | 385 | /* last encoded Time out used for timing budget*/ |
mjarvisal | 0:e6fcdb78a136 | 386 | |
mjarvisal | 0:e6fcdb78a136 | 387 | VL53L0X_GpioFunctionality Pin0GpioFunctionality; |
mjarvisal | 0:e6fcdb78a136 | 388 | /* store the functionality of the GPIO: pin0 */ |
mjarvisal | 0:e6fcdb78a136 | 389 | |
mjarvisal | 0:e6fcdb78a136 | 390 | uint32_t FinalRangeTimeoutMicroSecs; |
mjarvisal | 0:e6fcdb78a136 | 391 | /*!< Execution time of the final range*/ |
mjarvisal | 0:e6fcdb78a136 | 392 | uint8_t FinalRangeVcselPulsePeriod; |
mjarvisal | 0:e6fcdb78a136 | 393 | /*!< Vcsel pulse period (pll clocks) for the final range measurement*/ |
mjarvisal | 0:e6fcdb78a136 | 394 | uint32_t PreRangeTimeoutMicroSecs; |
mjarvisal | 0:e6fcdb78a136 | 395 | /*!< Execution time of the final range*/ |
mjarvisal | 0:e6fcdb78a136 | 396 | uint8_t PreRangeVcselPulsePeriod; |
mjarvisal | 0:e6fcdb78a136 | 397 | /*!< Vcsel pulse period (pll clocks) for the pre-range measurement*/ |
mjarvisal | 0:e6fcdb78a136 | 398 | |
mjarvisal | 0:e6fcdb78a136 | 399 | uint16_t SigmaEstRefArray; |
mjarvisal | 0:e6fcdb78a136 | 400 | /*!< Reference array sigma value in 1/100th of [mm] e.g. 100 = 1mm */ |
mjarvisal | 0:e6fcdb78a136 | 401 | uint16_t SigmaEstEffPulseWidth; |
mjarvisal | 0:e6fcdb78a136 | 402 | /*!< Effective Pulse width for sigma estimate in 1/100th |
mjarvisal | 0:e6fcdb78a136 | 403 | * of ns e.g. 900 = 9.0ns */ |
mjarvisal | 0:e6fcdb78a136 | 404 | uint16_t SigmaEstEffAmbWidth; |
mjarvisal | 0:e6fcdb78a136 | 405 | /*!< Effective Ambient width for sigma estimate in 1/100th of ns |
mjarvisal | 0:e6fcdb78a136 | 406 | * e.g. 500 = 5.0ns */ |
mjarvisal | 0:e6fcdb78a136 | 407 | |
mjarvisal | 0:e6fcdb78a136 | 408 | |
mjarvisal | 0:e6fcdb78a136 | 409 | uint8_t ReadDataFromDeviceDone; /* Indicate if read from device has |
mjarvisal | 0:e6fcdb78a136 | 410 | been done (==1) or not (==0) */ |
mjarvisal | 0:e6fcdb78a136 | 411 | uint8_t ModuleId; /* Module ID */ |
mjarvisal | 0:e6fcdb78a136 | 412 | uint8_t Revision; /* test Revision */ |
mjarvisal | 0:e6fcdb78a136 | 413 | char ProductId[VL53L0X_MAX_STRING_LENGTH]; |
mjarvisal | 0:e6fcdb78a136 | 414 | /* Product Identifier String */ |
mjarvisal | 0:e6fcdb78a136 | 415 | uint8_t ReferenceSpadCount; /* used for ref spad management */ |
mjarvisal | 0:e6fcdb78a136 | 416 | uint8_t ReferenceSpadType; /* used for ref spad management */ |
mjarvisal | 0:e6fcdb78a136 | 417 | uint8_t RefSpadsInitialised; /* reports if ref spads are initialised. */ |
mjarvisal | 0:e6fcdb78a136 | 418 | uint32_t PartUIDUpper; /*!< Unique Part ID Upper */ |
mjarvisal | 0:e6fcdb78a136 | 419 | uint32_t PartUIDLower; /*!< Unique Part ID Lower */ |
mjarvisal | 0:e6fcdb78a136 | 420 | FixPoint1616_t SignalRateMeasFixed400mm; /*!< Peek Signal rate |
mjarvisal | 0:e6fcdb78a136 | 421 | at 400 mm*/ |
mjarvisal | 0:e6fcdb78a136 | 422 | |
mjarvisal | 0:e6fcdb78a136 | 423 | } VL53L0X_DeviceSpecificParameters_t; |
mjarvisal | 0:e6fcdb78a136 | 424 | |
mjarvisal | 0:e6fcdb78a136 | 425 | /** |
mjarvisal | 0:e6fcdb78a136 | 426 | * @struct VL53L0X_DevData_t |
mjarvisal | 0:e6fcdb78a136 | 427 | * |
mjarvisal | 0:e6fcdb78a136 | 428 | * @brief VL53L0X PAL device ST private data structure \n |
mjarvisal | 0:e6fcdb78a136 | 429 | * End user should never access any of these field directly |
mjarvisal | 0:e6fcdb78a136 | 430 | * |
mjarvisal | 0:e6fcdb78a136 | 431 | * These must never access directly but only via macro |
mjarvisal | 0:e6fcdb78a136 | 432 | */ |
mjarvisal | 0:e6fcdb78a136 | 433 | typedef struct { |
mjarvisal | 0:e6fcdb78a136 | 434 | VL53L0X_DMaxData_t DMaxData; |
mjarvisal | 0:e6fcdb78a136 | 435 | /*!< Dmax Data */ |
mjarvisal | 0:e6fcdb78a136 | 436 | int32_t Part2PartOffsetNVMMicroMeter; |
mjarvisal | 0:e6fcdb78a136 | 437 | /*!< backed up NVM value */ |
mjarvisal | 0:e6fcdb78a136 | 438 | int32_t Part2PartOffsetAdjustmentNVMMicroMeter; |
mjarvisal | 0:e6fcdb78a136 | 439 | /*!< backed up NVM value representing additional offset adjustment */ |
mjarvisal | 0:e6fcdb78a136 | 440 | VL53L0X_DeviceParameters_t CurrentParameters; |
mjarvisal | 0:e6fcdb78a136 | 441 | /*!< Current Device Parameter */ |
mjarvisal | 0:e6fcdb78a136 | 442 | VL53L0X_RangingMeasurementData_t LastRangeMeasure; |
mjarvisal | 0:e6fcdb78a136 | 443 | /*!< Ranging Data */ |
mjarvisal | 0:e6fcdb78a136 | 444 | VL53L0X_HistogramMeasurementData_t LastHistogramMeasure; |
mjarvisal | 0:e6fcdb78a136 | 445 | /*!< Histogram Data */ |
mjarvisal | 0:e6fcdb78a136 | 446 | VL53L0X_DeviceSpecificParameters_t DeviceSpecificParameters; |
mjarvisal | 0:e6fcdb78a136 | 447 | /*!< Parameters specific to the device */ |
mjarvisal | 0:e6fcdb78a136 | 448 | VL53L0X_SpadData_t SpadData; |
mjarvisal | 0:e6fcdb78a136 | 449 | /*!< Spad Data */ |
mjarvisal | 0:e6fcdb78a136 | 450 | uint8_t SequenceConfig; |
mjarvisal | 0:e6fcdb78a136 | 451 | /*!< Internal value for the sequence config */ |
mjarvisal | 0:e6fcdb78a136 | 452 | uint8_t RangeFractionalEnable; |
mjarvisal | 0:e6fcdb78a136 | 453 | /*!< Enable/Disable fractional part of ranging data */ |
mjarvisal | 0:e6fcdb78a136 | 454 | VL53L0X_State PalState; |
mjarvisal | 0:e6fcdb78a136 | 455 | /*!< Current state of the PAL for this device */ |
mjarvisal | 0:e6fcdb78a136 | 456 | VL53L0X_PowerModes PowerMode; |
mjarvisal | 0:e6fcdb78a136 | 457 | /*!< Current Power Mode */ |
mjarvisal | 0:e6fcdb78a136 | 458 | uint16_t SigmaEstRefArray; |
mjarvisal | 0:e6fcdb78a136 | 459 | /*!< Reference array sigma value in 1/100th of [mm] e.g. 100 = 1mm */ |
mjarvisal | 0:e6fcdb78a136 | 460 | uint16_t SigmaEstEffPulseWidth; |
mjarvisal | 0:e6fcdb78a136 | 461 | /*!< Effective Pulse width for sigma estimate in 1/100th |
mjarvisal | 0:e6fcdb78a136 | 462 | * of ns e.g. 900 = 9.0ns */ |
mjarvisal | 0:e6fcdb78a136 | 463 | uint16_t SigmaEstEffAmbWidth; |
mjarvisal | 0:e6fcdb78a136 | 464 | /*!< Effective Ambient width for sigma estimate in 1/100th of ns |
mjarvisal | 0:e6fcdb78a136 | 465 | * e.g. 500 = 5.0ns */ |
mjarvisal | 0:e6fcdb78a136 | 466 | uint8_t StopVariable; |
mjarvisal | 0:e6fcdb78a136 | 467 | /*!< StopVariable used during the stop sequence */ |
mjarvisal | 0:e6fcdb78a136 | 468 | uint16_t targetRefRate; |
mjarvisal | 0:e6fcdb78a136 | 469 | /*!< Target Ambient Rate for Ref spad management */ |
mjarvisal | 0:e6fcdb78a136 | 470 | FixPoint1616_t SigmaEstimate; |
mjarvisal | 0:e6fcdb78a136 | 471 | /*!< Sigma Estimate - based on ambient & VCSEL rates and |
mjarvisal | 0:e6fcdb78a136 | 472 | * signal_total_events */ |
mjarvisal | 0:e6fcdb78a136 | 473 | FixPoint1616_t SignalEstimate; |
mjarvisal | 0:e6fcdb78a136 | 474 | /*!< Signal Estimate - based on ambient & VCSEL rates and cross talk */ |
mjarvisal | 0:e6fcdb78a136 | 475 | FixPoint1616_t LastSignalRefMcps; |
mjarvisal | 0:e6fcdb78a136 | 476 | /*!< Latest Signal ref in Mcps */ |
mjarvisal | 0:e6fcdb78a136 | 477 | uint8_t *pTuningSettingsPointer; |
mjarvisal | 0:e6fcdb78a136 | 478 | /*!< Pointer for Tuning Settings table */ |
mjarvisal | 0:e6fcdb78a136 | 479 | uint8_t UseInternalTuningSettings; |
mjarvisal | 0:e6fcdb78a136 | 480 | /*!< Indicate if we use Tuning Settings table */ |
mjarvisal | 0:e6fcdb78a136 | 481 | uint16_t LinearityCorrectiveGain; |
mjarvisal | 0:e6fcdb78a136 | 482 | /*!< Linearity Corrective Gain value in x1000 */ |
mjarvisal | 0:e6fcdb78a136 | 483 | uint16_t DmaxCalRangeMilliMeter; |
mjarvisal | 0:e6fcdb78a136 | 484 | /*!< Dmax Calibration Range millimeter */ |
mjarvisal | 0:e6fcdb78a136 | 485 | FixPoint1616_t DmaxCalSignalRateRtnMegaCps; |
mjarvisal | 0:e6fcdb78a136 | 486 | /*!< Dmax Calibration Signal Rate Return MegaCps */ |
mjarvisal | 0:e6fcdb78a136 | 487 | |
mjarvisal | 0:e6fcdb78a136 | 488 | } VL53L0X_DevData_t; |
mjarvisal | 0:e6fcdb78a136 | 489 | |
mjarvisal | 0:e6fcdb78a136 | 490 | |
mjarvisal | 0:e6fcdb78a136 | 491 | /** @defgroup VL53L0X_define_InterruptPolarity_group Defines the Polarity |
mjarvisal | 0:e6fcdb78a136 | 492 | * of the Interrupt |
mjarvisal | 0:e6fcdb78a136 | 493 | * Defines the Polarity of the Interrupt |
mjarvisal | 0:e6fcdb78a136 | 494 | * @{ |
mjarvisal | 0:e6fcdb78a136 | 495 | */ |
mjarvisal | 0:e6fcdb78a136 | 496 | typedef uint8_t VL53L0X_InterruptPolarity; |
mjarvisal | 0:e6fcdb78a136 | 497 | |
mjarvisal | 0:e6fcdb78a136 | 498 | #define VL53L0X_INTERRUPTPOLARITY_LOW ((VL53L0X_InterruptPolarity) 0) |
mjarvisal | 0:e6fcdb78a136 | 499 | /*!< Set active low polarity best setup for falling edge. */ |
mjarvisal | 0:e6fcdb78a136 | 500 | #define VL53L0X_INTERRUPTPOLARITY_HIGH ((VL53L0X_InterruptPolarity) 1) |
mjarvisal | 0:e6fcdb78a136 | 501 | /*!< Set active high polarity best setup for rising edge. */ |
mjarvisal | 0:e6fcdb78a136 | 502 | |
mjarvisal | 0:e6fcdb78a136 | 503 | /** @} VL53L0X_define_InterruptPolarity_group */ |
mjarvisal | 0:e6fcdb78a136 | 504 | |
mjarvisal | 0:e6fcdb78a136 | 505 | |
mjarvisal | 0:e6fcdb78a136 | 506 | /** @defgroup VL53L0X_define_VcselPeriod_group Vcsel Period Defines |
mjarvisal | 0:e6fcdb78a136 | 507 | * Defines the range measurement for which to access the vcsel period. |
mjarvisal | 0:e6fcdb78a136 | 508 | * @{ |
mjarvisal | 0:e6fcdb78a136 | 509 | */ |
mjarvisal | 0:e6fcdb78a136 | 510 | typedef uint8_t VL53L0X_VcselPeriod; |
mjarvisal | 0:e6fcdb78a136 | 511 | |
mjarvisal | 0:e6fcdb78a136 | 512 | #define VL53L0X_VCSEL_PERIOD_PRE_RANGE ((VL53L0X_VcselPeriod) 0) |
mjarvisal | 0:e6fcdb78a136 | 513 | /*!<Identifies the pre-range vcsel period. */ |
mjarvisal | 0:e6fcdb78a136 | 514 | #define VL53L0X_VCSEL_PERIOD_FINAL_RANGE ((VL53L0X_VcselPeriod) 1) |
mjarvisal | 0:e6fcdb78a136 | 515 | /*!<Identifies the final range vcsel period. */ |
mjarvisal | 0:e6fcdb78a136 | 516 | |
mjarvisal | 0:e6fcdb78a136 | 517 | /** @} VL53L0X_define_VcselPeriod_group */ |
mjarvisal | 0:e6fcdb78a136 | 518 | |
mjarvisal | 0:e6fcdb78a136 | 519 | /** @defgroup VL53L0X_define_SchedulerSequence_group Defines the steps |
mjarvisal | 0:e6fcdb78a136 | 520 | * carried out by the scheduler during a range measurement. |
mjarvisal | 0:e6fcdb78a136 | 521 | * @{ |
mjarvisal | 0:e6fcdb78a136 | 522 | * Defines the states of all the steps in the scheduler |
mjarvisal | 0:e6fcdb78a136 | 523 | * i.e. enabled/disabled. |
mjarvisal | 0:e6fcdb78a136 | 524 | */ |
mjarvisal | 0:e6fcdb78a136 | 525 | typedef struct { |
mjarvisal | 0:e6fcdb78a136 | 526 | uint8_t TccOn; /*!<Reports if Target Centre Check On */ |
mjarvisal | 0:e6fcdb78a136 | 527 | uint8_t MsrcOn; /*!<Reports if MSRC On */ |
mjarvisal | 0:e6fcdb78a136 | 528 | uint8_t DssOn; /*!<Reports if DSS On */ |
mjarvisal | 0:e6fcdb78a136 | 529 | uint8_t PreRangeOn; /*!<Reports if Pre-Range On */ |
mjarvisal | 0:e6fcdb78a136 | 530 | uint8_t FinalRangeOn; /*!<Reports if Final-Range On */ |
mjarvisal | 0:e6fcdb78a136 | 531 | } VL53L0X_SchedulerSequenceSteps_t; |
mjarvisal | 0:e6fcdb78a136 | 532 | |
mjarvisal | 0:e6fcdb78a136 | 533 | /** @} VL53L0X_define_SchedulerSequence_group */ |
mjarvisal | 0:e6fcdb78a136 | 534 | |
mjarvisal | 0:e6fcdb78a136 | 535 | /** @defgroup VL53L0X_define_SequenceStepId_group Defines the Polarity |
mjarvisal | 0:e6fcdb78a136 | 536 | * of the Interrupt |
mjarvisal | 0:e6fcdb78a136 | 537 | * Defines the the sequence steps performed during ranging.. |
mjarvisal | 0:e6fcdb78a136 | 538 | * @{ |
mjarvisal | 0:e6fcdb78a136 | 539 | */ |
mjarvisal | 0:e6fcdb78a136 | 540 | typedef uint8_t VL53L0X_SequenceStepId; |
mjarvisal | 0:e6fcdb78a136 | 541 | |
mjarvisal | 0:e6fcdb78a136 | 542 | #define VL53L0X_SEQUENCESTEP_TCC ((VL53L0X_VcselPeriod) 0) |
mjarvisal | 0:e6fcdb78a136 | 543 | /*!<Target CentreCheck identifier. */ |
mjarvisal | 0:e6fcdb78a136 | 544 | #define VL53L0X_SEQUENCESTEP_DSS ((VL53L0X_VcselPeriod) 1) |
mjarvisal | 0:e6fcdb78a136 | 545 | /*!<Dynamic Spad Selection function Identifier. */ |
mjarvisal | 0:e6fcdb78a136 | 546 | #define VL53L0X_SEQUENCESTEP_MSRC ((VL53L0X_VcselPeriod) 2) |
mjarvisal | 0:e6fcdb78a136 | 547 | /*!<Minimum Signal Rate Check function Identifier. */ |
mjarvisal | 0:e6fcdb78a136 | 548 | #define VL53L0X_SEQUENCESTEP_PRE_RANGE ((VL53L0X_VcselPeriod) 3) |
mjarvisal | 0:e6fcdb78a136 | 549 | /*!<Pre-Range check Identifier. */ |
mjarvisal | 0:e6fcdb78a136 | 550 | #define VL53L0X_SEQUENCESTEP_FINAL_RANGE ((VL53L0X_VcselPeriod) 4) |
mjarvisal | 0:e6fcdb78a136 | 551 | /*!<Final Range Check Identifier. */ |
mjarvisal | 0:e6fcdb78a136 | 552 | |
mjarvisal | 0:e6fcdb78a136 | 553 | #define VL53L0X_SEQUENCESTEP_NUMBER_OF_CHECKS 5 |
mjarvisal | 0:e6fcdb78a136 | 554 | /*!<Number of Sequence Step Managed by the API. */ |
mjarvisal | 0:e6fcdb78a136 | 555 | |
mjarvisal | 0:e6fcdb78a136 | 556 | /** @} VL53L0X_define_SequenceStepId_group */ |
mjarvisal | 0:e6fcdb78a136 | 557 | |
mjarvisal | 0:e6fcdb78a136 | 558 | |
mjarvisal | 0:e6fcdb78a136 | 559 | /* MACRO Definitions */ |
mjarvisal | 0:e6fcdb78a136 | 560 | /** @defgroup VL53L0X_define_GeneralMacro_group General Macro Defines |
mjarvisal | 0:e6fcdb78a136 | 561 | * General Macro Defines |
mjarvisal | 0:e6fcdb78a136 | 562 | * @{ |
mjarvisal | 0:e6fcdb78a136 | 563 | */ |
mjarvisal | 0:e6fcdb78a136 | 564 | |
mjarvisal | 0:e6fcdb78a136 | 565 | /* Defines */ |
mjarvisal | 0:e6fcdb78a136 | 566 | #define VL53L0X_SETPARAMETERFIELD(Dev, field, value) \ |
mjarvisal | 0:e6fcdb78a136 | 567 | PALDevDataSet(Dev, CurrentParameters.field, value) |
mjarvisal | 0:e6fcdb78a136 | 568 | |
mjarvisal | 0:e6fcdb78a136 | 569 | #define VL53L0X_GETPARAMETERFIELD(Dev, field, variable) \ |
mjarvisal | 0:e6fcdb78a136 | 570 | variable = PALDevDataGet(Dev, CurrentParameters).field |
mjarvisal | 0:e6fcdb78a136 | 571 | |
mjarvisal | 0:e6fcdb78a136 | 572 | |
mjarvisal | 0:e6fcdb78a136 | 573 | #define VL53L0X_SETARRAYPARAMETERFIELD(Dev, field, index, value) \ |
mjarvisal | 0:e6fcdb78a136 | 574 | PALDevDataSet(Dev, CurrentParameters.field[index], value) |
mjarvisal | 0:e6fcdb78a136 | 575 | |
mjarvisal | 0:e6fcdb78a136 | 576 | #define VL53L0X_GETARRAYPARAMETERFIELD(Dev, field, index, variable) \ |
mjarvisal | 0:e6fcdb78a136 | 577 | variable = PALDevDataGet(Dev, CurrentParameters).field[index] |
mjarvisal | 0:e6fcdb78a136 | 578 | |
mjarvisal | 0:e6fcdb78a136 | 579 | |
mjarvisal | 0:e6fcdb78a136 | 580 | #define VL53L0X_SETDEVICESPECIFICPARAMETER(Dev, field, value) \ |
mjarvisal | 0:e6fcdb78a136 | 581 | PALDevDataSet(Dev, DeviceSpecificParameters.field, value) |
mjarvisal | 0:e6fcdb78a136 | 582 | |
mjarvisal | 0:e6fcdb78a136 | 583 | #define VL53L0X_GETDEVICESPECIFICPARAMETER(Dev, field) \ |
mjarvisal | 0:e6fcdb78a136 | 584 | PALDevDataGet(Dev, DeviceSpecificParameters).field |
mjarvisal | 0:e6fcdb78a136 | 585 | |
mjarvisal | 0:e6fcdb78a136 | 586 | |
mjarvisal | 0:e6fcdb78a136 | 587 | #define VL53L0X_FIXPOINT1616TOFIXPOINT97(Value) \ |
mjarvisal | 0:e6fcdb78a136 | 588 | (uint16_t)((Value>>9)&0xFFFF) |
mjarvisal | 0:e6fcdb78a136 | 589 | #define VL53L0X_FIXPOINT97TOFIXPOINT1616(Value) \ |
mjarvisal | 0:e6fcdb78a136 | 590 | (FixPoint1616_t)(Value<<9) |
mjarvisal | 0:e6fcdb78a136 | 591 | |
mjarvisal | 0:e6fcdb78a136 | 592 | #define VL53L0X_FIXPOINT1616TOFIXPOINT88(Value) \ |
mjarvisal | 0:e6fcdb78a136 | 593 | (uint16_t)((Value>>8)&0xFFFF) |
mjarvisal | 0:e6fcdb78a136 | 594 | #define VL53L0X_FIXPOINT88TOFIXPOINT1616(Value) \ |
mjarvisal | 0:e6fcdb78a136 | 595 | (FixPoint1616_t)(Value<<8) |
mjarvisal | 0:e6fcdb78a136 | 596 | |
mjarvisal | 0:e6fcdb78a136 | 597 | #define VL53L0X_FIXPOINT1616TOFIXPOINT412(Value) \ |
mjarvisal | 0:e6fcdb78a136 | 598 | (uint16_t)((Value>>4)&0xFFFF) |
mjarvisal | 0:e6fcdb78a136 | 599 | #define VL53L0X_FIXPOINT412TOFIXPOINT1616(Value) \ |
mjarvisal | 0:e6fcdb78a136 | 600 | (FixPoint1616_t)(Value<<4) |
mjarvisal | 0:e6fcdb78a136 | 601 | |
mjarvisal | 0:e6fcdb78a136 | 602 | #define VL53L0X_FIXPOINT1616TOFIXPOINT313(Value) \ |
mjarvisal | 0:e6fcdb78a136 | 603 | (uint16_t)((Value>>3)&0xFFFF) |
mjarvisal | 0:e6fcdb78a136 | 604 | #define VL53L0X_FIXPOINT313TOFIXPOINT1616(Value) \ |
mjarvisal | 0:e6fcdb78a136 | 605 | (FixPoint1616_t)(Value<<3) |
mjarvisal | 0:e6fcdb78a136 | 606 | |
mjarvisal | 0:e6fcdb78a136 | 607 | #define VL53L0X_FIXPOINT1616TOFIXPOINT08(Value) \ |
mjarvisal | 0:e6fcdb78a136 | 608 | (uint8_t)((Value>>8)&0x00FF) |
mjarvisal | 0:e6fcdb78a136 | 609 | #define VL53L0X_FIXPOINT08TOFIXPOINT1616(Value) \ |
mjarvisal | 0:e6fcdb78a136 | 610 | (FixPoint1616_t)(Value<<8) |
mjarvisal | 0:e6fcdb78a136 | 611 | |
mjarvisal | 0:e6fcdb78a136 | 612 | #define VL53L0X_FIXPOINT1616TOFIXPOINT53(Value) \ |
mjarvisal | 0:e6fcdb78a136 | 613 | (uint8_t)((Value>>13)&0x00FF) |
mjarvisal | 0:e6fcdb78a136 | 614 | #define VL53L0X_FIXPOINT53TOFIXPOINT1616(Value) \ |
mjarvisal | 0:e6fcdb78a136 | 615 | (FixPoint1616_t)(Value<<13) |
mjarvisal | 0:e6fcdb78a136 | 616 | |
mjarvisal | 0:e6fcdb78a136 | 617 | #define VL53L0X_FIXPOINT1616TOFIXPOINT102(Value) \ |
mjarvisal | 0:e6fcdb78a136 | 618 | (uint16_t)((Value>>14)&0x0FFF) |
mjarvisal | 0:e6fcdb78a136 | 619 | #define VL53L0X_FIXPOINT102TOFIXPOINT1616(Value) \ |
mjarvisal | 0:e6fcdb78a136 | 620 | (FixPoint1616_t)(Value<<12) |
mjarvisal | 0:e6fcdb78a136 | 621 | |
mjarvisal | 0:e6fcdb78a136 | 622 | #define VL53L0X_MAKEUINT16(lsb, msb) (uint16_t)((((uint16_t)msb)<<8) + \ |
mjarvisal | 0:e6fcdb78a136 | 623 | (uint16_t)lsb) |
mjarvisal | 0:e6fcdb78a136 | 624 | |
mjarvisal | 0:e6fcdb78a136 | 625 | /** @} VL53L0X_define_GeneralMacro_group */ |
mjarvisal | 0:e6fcdb78a136 | 626 | |
mjarvisal | 0:e6fcdb78a136 | 627 | /** @} VL53L0X_globaldefine_group */ |
mjarvisal | 0:e6fcdb78a136 | 628 | |
mjarvisal | 0:e6fcdb78a136 | 629 | |
mjarvisal | 0:e6fcdb78a136 | 630 | |
mjarvisal | 0:e6fcdb78a136 | 631 | |
mjarvisal | 0:e6fcdb78a136 | 632 | |
mjarvisal | 0:e6fcdb78a136 | 633 | |
mjarvisal | 0:e6fcdb78a136 | 634 | |
mjarvisal | 0:e6fcdb78a136 | 635 | #ifdef __cplusplus |
mjarvisal | 0:e6fcdb78a136 | 636 | } |
mjarvisal | 0:e6fcdb78a136 | 637 | #endif |
mjarvisal | 0:e6fcdb78a136 | 638 | |
mjarvisal | 0:e6fcdb78a136 | 639 | |
mjarvisal | 0:e6fcdb78a136 | 640 | #endif /* _VL53L0X_DEF_H_ */ |