VL53L0X World smallest Time-of-Flight (ToF) ranging sensor

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   HelloWorld_ST_Sensors mbed-os-mqtt-client Multi_VL53L0X DISCO-IOT01_HomeEnv ... more

Fork of VL53L0X by Nicola Capovilla

Committer:
johnAlexander
Date:
Thu Jun 06 09:21:39 2019 +0000
Revision:
6:8ac15bf6d635
Publish mbed-certified sensor class.

Who changed what in which revision?

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