Condensed Version of Public VL53L0X

Dependents:   ToF-Only-Tryout

Committer:
nikapov
Date:
Fri Sep 29 15:38:50 2017 +0000
Revision:
0:a1a69d32f310
Child:
2:d07edeaff6f1
First version.

Who changed what in which revision?

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