code for read VL53l0x sensor with CAN

Dependencies:   mbed

Committer:
pablo_bmxrp
Date:
Mon Mar 18 22:45:39 2019 +0000
Revision:
1:7bbfe329c62b
Parent:
STM32F103C8T6_MPA/VL53L0X_simple/VL53L0X_def.h@0:44429c0a71d4
V1.0

Who changed what in which revision?

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