Fixed STMPE1600 writeSYS_CTRL, enabled multi sensors support

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON

Fork of X_NUCLEO_53L0A1 by ST

Committer:
johnAlexander
Date:
Mon Nov 28 11:25:33 2016 +0000
Revision:
0:c523920bcc09
Singleshot, polled ranging example using central VL53L0X sensor.; Compatible with mass-market v1.1 C API.

Who changed what in which revision?

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