ST Expansion SW Team / VL53L1

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   X_NUCLEO_53L1CB

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers vl53l1_def.h Source File

vl53l1_def.h

Go to the documentation of this file.
00001 
00002 /* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
00003 /******************************************************************************
00004  * Copyright (c) 2020, STMicroelectronics - All Rights Reserved
00005 
00006  This file is part of VL53L1 and is dual licensed,
00007  either GPL-2.0+
00008  or 'BSD 3-clause "New" or "Revised" License' , at your option.
00009  ******************************************************************************
00010  */
00011 
00012 /**
00013  * @file vl53l1_def.h
00014  *
00015  * @brief Type definitions for VL53L1 API.
00016  *
00017  */
00018 
00019 
00020 #ifndef _VL53L1_DEF_H_
00021 #define _VL53L1_DEF_H_
00022 
00023 #include "vl53l1_ll_def.h"
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 /** @defgroup VL53L1_globaldefine_group VL53L1 Defines
00030  *  @brief    VL53L1 Defines
00031  *  @{
00032  */
00033 
00034 
00035 /** VL53L1 IMPLEMENTATION major version */
00036 #define VL53L1_IMPLEMENTATION_VER_MAJOR       6
00037 /** VL53L1 IMPLEMENTATION minor version */
00038 #define VL53L1_IMPLEMENTATION_VER_MINOR       6
00039 /** VL53L1 IMPLEMENTATION sub version */
00040 #define VL53L1_IMPLEMENTATION_VER_SUB         5
00041 /** VL53L1 IMPLEMENTATION sub version */
00042 #define VL53L1_IMPLEMENTATION_VER_REVISION  2496
00043 
00044 /****************************************
00045  * PRIVATE define do not edit
00046  ****************************************/
00047 
00048 /** @brief Defines the parameters of the Get Version Functions
00049  */
00050 typedef struct {
00051     uint32_t     revision ; /*!< revision number */
00052     uint8_t      major ;    /*!< major number */
00053     uint8_t      minor ;    /*!< minor number */
00054     uint8_t      build ;    /*!< build number */
00055 } VL53L1_Version_t;
00056 
00057 
00058 #define VL53L1_DEVINFO_STRLEN 32
00059 
00060 /** @brief Defines the parameters of the Get Device Info Functions
00061  */
00062 typedef struct {
00063     char Name[VL53L1_DEVINFO_STRLEN];
00064         /*!< Full Name of the Device e.g. VL53L1 cut1.1 */
00065     char Type[VL53L1_DEVINFO_STRLEN];
00066         /*!< Type of the Device e.g VL53L1 */
00067     char ProductId[VL53L1_DEVINFO_STRLEN];
00068         /*!< Product Identifier String
00069          * @warning Not yet implemented
00070          */
00071     uint8_t ProductType;
00072         /*!< Product Type, VL53L1 = 0xCC, VL53L3 = 0xAA
00073          * Stands as module_type in the datasheet
00074          */
00075     uint8_t ProductRevisionMajor;
00076         /*!< Product revision major */
00077     uint8_t ProductRevisionMinor;
00078         /*!< Product revision minor */
00079 } VL53L1_DeviceInfo_t;
00080 
00081 
00082 
00083 /** @defgroup VL53L1_define_PresetModes_group Defines Preset modes
00084  *  Defines all possible preset modes for the device
00085  *  @{
00086  */
00087 typedef uint8_t VL53L1_PresetModes;
00088 
00089 #define VL53L1_PRESETMODE_RANGING                   ((VL53L1_PresetModes)  1)
00090 #define VL53L1_PRESETMODE_MULTIZONES_SCANNING       ((VL53L1_PresetModes)  2)
00091 #define VL53L1_PRESETMODE_AUTONOMOUS                ((VL53L1_PresetModes)  3)
00092 #define VL53L1_PRESETMODE_LITE_RANGING              ((VL53L1_PresetModes)  4)
00093 #define VL53L1_PRESETMODE_OLT                       ((VL53L1_PresetModes)  7)
00094 #define VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS       ((VL53L1_PresetModes)  8)
00095 #define VL53L1_PRESETMODE_PROXY_RANGING_MODE        ((VL53L1_PresetModes)  9)
00096 
00097     /* ... Modes to be added depending on device */
00098 /** @} VL53L1_define_PresetModes_group */
00099 
00100 
00101 /** @defgroup VL53L1_define_DistanceModes_group Defines Distance modes
00102  *  Defines all possible Distance modes for the device
00103  *  @{
00104  */
00105 typedef uint8_t VL53L1_DistanceModes;
00106 
00107 #define VL53L1_DISTANCEMODE_SHORT             ((VL53L1_DistanceModes)  1)
00108 #define VL53L1_DISTANCEMODE_MEDIUM            ((VL53L1_DistanceModes)  2)
00109 #define VL53L1_DISTANCEMODE_LONG              ((VL53L1_DistanceModes)  3)
00110 /** @} VL53L1_define_DistanceModes_group */
00111 
00112 /** @defgroup VL53L1_define_OutputModes_group Defines Output modes
00113  *  Defines all possible Output modes for the device
00114  *  @{
00115  */
00116 typedef uint8_t VL53L1_OutputModes;
00117 
00118 #define VL53L1_OUTPUTMODE_NEAREST          ((VL53L1_OutputModes)  1)
00119 #define VL53L1_OUTPUTMODE_STRONGEST        ((VL53L1_OutputModes)  2)
00120 
00121 /** @} VL53L1_define_OutputModes_group */
00122 
00123 /** @defgroup VL53L1_define_XtalkCal_group Defines Xtalk Calibration modes
00124  *  Defines all possible Offset Calibration modes for the device
00125  *  @{
00126  */
00127 typedef uint8_t VL53L1_XtalkCalibrationModes;
00128 
00129 #define VL53L1_XTALKCALIBRATIONMODE_NO_TARGET \
00130     ((VL53L1_OffsetCalibrationModes) 0)
00131 /*!< To perform Xtalk calibration with no target below 80 cm */
00132 #define VL53L1_XTALKCALIBRATIONMODE_SINGLE_TARGET \
00133     ((VL53L1_OffsetCalibrationModes)  1)
00134 /*!< To perform Xtalk calibration with one target */
00135 #define VL53L1_XTALKCALIBRATIONMODE_FULL_ROI \
00136     ((VL53L1_OffsetCalibrationModes)  2)
00137 /*!< To perform Xtalk calibration based on histogram with full ROI */
00138 
00139 /** @} VL53L1_define_XtalkCal_group */
00140 
00141 /** @defgroup VL53L1_define_OffsetCal_group Defines Offset Calibration modes
00142  *  Defines all possible Offset Calibration modes for the device
00143  *  @{
00144  */
00145 typedef uint8_t VL53L1_OffsetCalibrationModes;
00146 
00147 #define VL53L1_OFFSETCALIBRATIONMODE_STANDARD \
00148     ((VL53L1_OffsetCalibrationModes)  1)
00149 #define VL53L1_OFFSETCALIBRATIONMODE_PRERANGE_ONLY  \
00150     ((VL53L1_OffsetCalibrationModes)  2)
00151 #define VL53L1_OFFSETCALIBRATIONMODE_MULTI_ZONE    \
00152     ((VL53L1_OffsetCalibrationModes)  3)
00153 
00154 /** @} VL53L1_define_OffsetCal_group */
00155 
00156 /** @defgroup VL53L1_define_DeviceDmaxModes_group Defines Dmax source modes
00157  *  Defines all possible sources for Dmax calibration for the device
00158  *  @{
00159  */
00160 typedef uint8_t VL53L1_DeviceDmaxModes;
00161 
00162 #define VL53L1_DMAXMODE_FMT_CAL_DATA      ((VL53L1_DeviceDmaxModes)  1)
00163 #define VL53L1_DMAXMODE_CUSTCAL_DATA      ((VL53L1_DeviceDmaxModes)  2)
00164 #define VL53L1_DMAXMODE_PER_ZONE_CAL_DATA ((VL53L1_DeviceDmaxModes)  3)
00165 
00166 /** @} VL53L1_define_DeviceDmaxModes_group */
00167 
00168 /** @defgroup VL53L1_define_OffsetCorrectionModesBD_group
00169  *  Device Offset Correction Mode
00170  *
00171  *  @brief Defines all possible offset correction modes for the device
00172  *  @{
00173  */
00174 typedef uint8_t VL53L1_OffsetCorrectionModes;
00175 
00176 #define VL53L1_OFFSETCORRECTIONMODE_STANDARD ((VL53L1_OffsetCorrectionMode)  1)
00177 #define VL53L1_OFFSETCORRECTIONMODE_PERZONE  ((VL53L1_OffsetCorrectionMode)  2)
00178 #define VL53L1_OFFSETCORRECTIONMODE_PERVCSEL ((VL53L1_OffsetCorrectionMode)  3)
00179 
00180 /** @} VL53L1_define_OffsetCorrectionModesBD_group */
00181 
00182 /** @defgroup VL53L1_define_RoiStatus_group Defines Roi Status
00183  *  Defines the read status mode
00184  *  @{
00185  */
00186 typedef uint8_t VL53L1_RoiStatus;
00187 
00188 #define VL53L1_ROISTATUS_NOT_VALID                 ((VL53L1_RoiStatus)  0)
00189 #define VL53L1_ROISTATUS_VALID_NOT_LAST            ((VL53L1_RoiStatus)  1)
00190 #define VL53L1_ROISTATUS_VALID_LAST                ((VL53L1_RoiStatus)  2)
00191 /** @} VL53L1_define_RoiStatus_group */
00192 
00193 
00194 /** @defgroup VL53L1_CheckEnable_group Check Enable list
00195  *  @brief Check Enable code
00196  *
00197  *  Define used to specify the LimitCheckId.
00198  *  Use @a VL53L1_GetLimitCheckInfo() to get the string.
00199  *  @{
00200  */
00201 
00202 #define VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE           0
00203 #define VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE     1
00204 
00205 #define VL53L1_CHECKENABLE_NUMBER_OF_CHECKS            2
00206 
00207 /** @}  end of VL53L1_CheckEnable_group */
00208 
00209 
00210 /** @defgroup VL53L1_ThresholdMode_gropup Detection Functionality
00211  *  @brief Defines the different functionalities for the detection feature
00212  *  @{
00213  */
00214 typedef uint8_t VL53L1_ThresholdMode;
00215 
00216 #define VL53L1_THRESHOLD_CROSSED_LOW   \
00217     ((VL53L1_ThresholdMode)  0)
00218     /*!< Trigger interrupt if value < thresh_low */
00219 #define VL53L1_THRESHOLD_CROSSED_HIGH   \
00220     ((VL53L1_ThresholdMode)  1)
00221     /*!< Trigger interrupt if value > thresh_high */
00222 #define VL53L1_THRESHOLD_OUT_OF_WINDOW    \
00223     ((VL53L1_ThresholdMode)  2)
00224     /*!< Trigger interrupt if value < thresh_low OR value > thresh_high */
00225 #define VL53L1_THRESHOLD_IN_WINDOW        \
00226     ((VL53L1_ThresholdMode)  3)
00227     /*!< Trigger interrupt if value > thresh_low AND value < thresh_high */
00228 
00229 /** @} end of VL53L1_ThresholdMode_gropup */
00230 
00231 /** @brief Defines parameters for Distance detection Thresholds configuration
00232  */
00233 typedef struct {
00234     VL53L1_ThresholdMode CrossMode;
00235     uint16_t High ; /*!< Distance threshold high limit in mm */
00236     uint16_t Low ;  /*!< Distance threshold low limit  in mm */
00237 } VL53L1_DistanceThreshold_t;
00238 
00239 /** @brief Defines parameters for Signal rate detection Thresholds configuration
00240  */
00241 typedef struct {
00242     VL53L1_ThresholdMode CrossMode;
00243     FixPoint1616_t High ; /*!< Signal rate threshold high limit */
00244     FixPoint1616_t Low ;  /*!< Signal rate threshold low limit */
00245 } VL53L1_RateThreshold_t;
00246 
00247 /** @defgroup VL53L1_DetectionMode_group Gpio Functionality
00248  *  @brief Defines conditions leading to device's IT on GPIO
00249  *  @{
00250  */
00251 typedef uint8_t VL53L1_DetectionMode;
00252 
00253 #define VL53L1_DETECTION_NORMAL_RUN   \
00254     ((VL53L1_DetectionMode)  0)
00255     /*!< Trigger interrupt on new measurement regardless of threshold
00256      * just like after a VL53L1_SetPresetMode() call
00257      */
00258 #define VL53L1_DETECTION_DISTANCE_ONLY   \
00259     ((VL53L1_DetectionMode)  1)
00260     /*!< Trigger interrupt if "threshold event" occurs on distance */
00261 #define VL53L1_DETECTION_RATE_ONLY   \
00262     ((VL53L1_DetectionMode)  2)
00263     /*!< Trigger interrupt if "threshold event" occurs on signal rate */
00264 #define VL53L1_DETECTION_DISTANCE_AND_RATE   \
00265     ((VL53L1_DetectionMode)  3)
00266     /*!< Trigger interrupt if "threshold event" occurs on distance AND rate
00267      */
00268 #define VL53L1_DETECTION_DISTANCE_OR_RATE   \
00269     ((VL53L1_DetectionMode)  4)
00270     /*!< Trigger interrupt if "threshold event" occurs on distance OR rate
00271      */
00272 
00273 /** @} end of VL53L1_DetectionMode_group */
00274 
00275 /** @brief Defines parameters for User/object Detection configuration
00276  */
00277 typedef struct {
00278     VL53L1_DetectionMode DetectionMode ; /*!< See #VL53L1_DetectionMode*/
00279     uint8_t IntrNoTarget ; /*!< 1 to trigger IT in case of no target found */
00280     VL53L1_DistanceThreshold_t Distance ; /*!< limits in mm */
00281     VL53L1_RateThreshold_t Rate ;/*!< limits in FixPoint1616_t */
00282 } VL53L1_DetectionConfig_t;
00283 
00284 
00285 /** @brief Defines all parameters for the device
00286  */
00287 typedef struct {
00288     VL53L1_PresetModes PresetMode;
00289     /*!< Defines the operating mode to be used for the next measure */
00290     VL53L1_OutputModes OutputMode;
00291     /*!< Defines the Output mode to be used for the next measure */
00292     VL53L1_DistanceModes DistanceMode;
00293     /*!< Defines the operating mode to be used for the next measure */
00294     uint32_t MeasurementTimingBudgetMicroSeconds;
00295     /*!< Defines the allowed total time for a single measurement */
00296     uint8_t LimitChecksEnable[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
00297     /*!< This Array store all the Limit Check enable for this device. */
00298     uint8_t LimitChecksStatus[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
00299     /*!< This Array stores all the Status of the check linked to last
00300      * measurement.
00301      */
00302     FixPoint1616_t LimitChecksValue[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
00303     /*!< This Array stores all the Limit Check value for this device */
00304     FixPoint1616_t LimitChecksCurrent[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
00305     /*!< This Array stores all the Limit Check current value from latest
00306      * ranging
00307      */
00308 } VL53L1_DeviceParameters_t;
00309 
00310 
00311 /** @defgroup VL53L1_define_State_group Defines the current status of the device
00312  *  Defines the current status of the device
00313  *  @{
00314  */
00315 
00316 typedef uint8_t VL53L1_State;
00317 
00318 #define VL53L1_STATE_POWERDOWN       ((VL53L1_State)  0)
00319     /*!< Device is in HW reset  */
00320 #define VL53L1_STATE_WAIT_STATICINIT ((VL53L1_State)  1)
00321     /*!< Device is initialized and wait for static initialization  */
00322 #define VL53L1_STATE_STANDBY         ((VL53L1_State)  2)
00323     /*!< Device is in Low power Standby mode   */
00324 #define VL53L1_STATE_IDLE            ((VL53L1_State)  3)
00325     /*!< Device has been initialized and ready to do measurements  */
00326 #define VL53L1_STATE_RUNNING         ((VL53L1_State)  4)
00327     /*!< Device is performing measurement */
00328 #define VL53L1_STATE_RESET           ((VL53L1_State)  5)
00329     /*!< Soft reset has been run on Device */
00330 #define VL53L1_STATE_UNKNOWN         ((VL53L1_State)  98)
00331     /*!< Device is in unknown state and need to be rebooted  */
00332 #define VL53L1_STATE_ERROR           ((VL53L1_State)  99)
00333     /*!< Device is in error state and need to be rebooted  */
00334 
00335 /** @} VL53L1_define_State_group */
00336 
00337 /** @defgroup VL53L1_define_Smudge_Mode_group Defines smudge correction modes
00338  *  Defines the smudge correction modes
00339  *  @{
00340  */
00341 
00342 typedef uint8_t VL53L1_SmudgeCorrectionModes;
00343 
00344 #define VL53L1_SMUDGE_CORRECTION_NONE       ((VL53L1_SmudgeCorrectionModes)  0)
00345     /*!< Smudge correction is applied continously accross the rangings */
00346 #define VL53L1_SMUDGE_CORRECTION_CONTINUOUS ((VL53L1_SmudgeCorrectionModes)  1)
00347     /*!< Smudge correction is applied continously accross the rangings */
00348 #define VL53L1_SMUDGE_CORRECTION_SINGLE     ((VL53L1_SmudgeCorrectionModes)  2)
00349     /*!< Smudge correction is applied only once accross the rangings */
00350 #define VL53L1_SMUDGE_CORRECTION_DEBUG      ((VL53L1_SmudgeCorrectionModes)  3)
00351     /*!< Smudge detection is applied continously but Xtalk values are not
00352      * updated automatically within the driver
00353      */
00354 
00355 /** @} VL53L1_define_Smudge_Correction_Mode_group */
00356 
00357 
00358 /**
00359  * @struct VL53L1_RangingMeasurementData_t
00360  * @brief Single Range measurement data.
00361  */
00362 typedef struct {
00363     uint32_t TimeStamp;
00364         /*!< 32-bit time stamp.
00365          * @warning Not yet implemented
00366          */
00367 
00368     uint8_t StreamCount;
00369         /*!< 8-bit Stream Count. */
00370 
00371     uint8_t RangeQualityLevel;
00372         /*!< indicate a quality level in percentage from 0 to 100
00373          * @warning Not yet implemented
00374          */
00375 
00376     FixPoint1616_t SignalRateRtnMegaCps;
00377         /*!< Return signal rate (MCPS)\n these is a 16.16 fix point
00378          *  value, which is effectively a measure of target
00379          *   reflectance.
00380          */
00381 
00382     FixPoint1616_t AmbientRateRtnMegaCps;
00383         /*!< Return ambient rate (MCPS)\n these is a 16.16 fix point
00384          *  value, which is effectively a measure of the ambien
00385          *  t light.
00386          */
00387 
00388     uint16_t EffectiveSpadRtnCount;
00389         /*!< Return the effective SPAD count for the return signal.
00390          *  To obtain Real value it should be divided by 256
00391          */
00392 
00393     FixPoint1616_t SigmaMilliMeter;
00394         /*!< Return the Sigma value in millimeter */
00395 
00396     int16_t RangeMilliMeter;
00397         /*!< range distance in millimeter. This should be between
00398          *  RangeMinMilliMeter and RangeMaxMilliMeter
00399          */
00400 
00401     uint8_t RangeFractionalPart;
00402         /*!< Fractional part of range distance. Final value is a
00403          *  RangeMilliMeter + RangeFractionalPart/256.
00404          *  @warning Not yet implemented
00405          */
00406 
00407     uint8_t RangeStatus;
00408         /*!< Range Status for the current measurement. This is device
00409          *  dependent. Value = 0 means value is valid.
00410          */
00411 } VL53L1_RangingMeasurementData_t;
00412 
00413 /**
00414  * @struct VL53L1_TargetRangeData_t
00415  * @brief One Range measurement data for each target.
00416  */
00417 typedef struct {
00418     uint8_t RangeQualityLevel;
00419         /*!< indicate a quality level in percentage from 0 to 100
00420          * @warning Not yet implemented
00421          */
00422 
00423     int16_t RangeMaxMilliMeter;
00424         /*!< Tells what is the maximum detection distance of the object
00425          * in current setup and environment conditions (Filled when
00426          *  applicable)
00427          */
00428 
00429     int16_t RangeMinMilliMeter;
00430         /*!< Tells what is the minimum detection distance of the object
00431          * in current setup and environment conditions (Filled when
00432          *  applicable)
00433          */
00434 
00435     FixPoint1616_t SignalRateRtnMegaCps;
00436         /*!< Return signal rate (MCPS)\n these is a 16.16 fix point
00437          *  value, which is effectively a measure of target
00438          *   reflectance.
00439          */
00440 
00441     FixPoint1616_t AmbientRateRtnMegaCps;
00442         /*!< Return ambient rate (MCPS)\n these is a 16.16 fix point
00443          *  value, which is effectively a measure of the ambien
00444          *  t light.
00445          */
00446 
00447     FixPoint1616_t SigmaMilliMeter;
00448         /*!< Return the Sigma value in millimeter */
00449 
00450     int16_t RangeMilliMeter;
00451         /*!< range distance in millimeter. This should be between
00452          *  RangeMinMilliMeter and RangeMaxMilliMeter
00453          */
00454 
00455     uint8_t RangeFractionalPart;
00456         /*!< Fractional part of range distance. Final value is a
00457          *  RangeMilliMeter + RangeFractionalPart/256.
00458          *  @warning Not yet implemented
00459          */
00460 
00461     uint8_t RangeStatus;
00462         /*!< Range Status for the current measurement. This is device
00463          *  dependent. Value = 0 means value is valid.
00464          */
00465 
00466     uint8_t ExtendedRange;
00467         /*!< Extended range flag for the current measurement.
00468          *  Value = 1 means timings A&B are combined to increase the
00469          *  maximum distance range.
00470          */
00471 } VL53L1_TargetRangeData_t;
00472 /**
00473  * @struct  VL53L1_MultiRangingData_t
00474  * @brief   Structure for storing the set of range results for a single ROI
00475  *
00476  */
00477 typedef struct {
00478     uint32_t TimeStamp;
00479         /*!< 32-bit time stamp.
00480          * @warning Not yet implemented
00481          */
00482 
00483     uint8_t StreamCount;
00484         /*!< 8-bit Stream Count. */
00485 
00486     uint8_t RoiNumber;
00487         /*!< Denotes on which ROI the range data is related to. */
00488     uint8_t NumberOfObjectsFound;
00489         /*!< Indicate the number of objects found in the current ROI.
00490          * This is used to know how many ranging data should be get.
00491          * NumberOfObjectsFound is in the range 0 to
00492          * VL53L1_MAX_RANGE_RESULTS.
00493          */
00494     VL53L1_RoiStatus RoiStatus;
00495         /*!< Indicate if the data read is valid or not or if this is
00496          * the last valid data in the ROI.
00497          */
00498     VL53L1_TargetRangeData_t RangeData[VL53L1_MAX_RANGE_RESULTS];
00499         /*!< Range data each target distance */
00500     uint8_t HasXtalkValueChanged;
00501         /*!< set to 1 if a new Xtalk value has been computed whilst
00502          * smudge correction mode enable by with
00503          * VL53L1_SmudgeCorrectionEnable() function is either
00504          * VL53L1_SMUDGE_CORRECTION_CONTINUOUS or
00505          * VL53L1_SMUDGE_CORRECTION_SINGLE.
00506          */
00507     uint16_t EffectiveSpadRtnCount;
00508         /*!< Return the effective SPAD count for the return signal.
00509          *  To obtain Real value it should be divided by 256
00510          */
00511     int16_t DmaxMilliMeter;
00512         /*!< range Dmax distance in millimeter.
00513          */
00514     VL53L1_DistanceModes RecommendedDistanceMode;
00515         /*!< suggestion for a better distance mode choice to improve
00516          *  range accuracy.
00517          */
00518 } VL53L1_MultiRangingData_t;
00519 
00520 
00521 /** @brief Defines User Zone(ROI) parameters
00522  *
00523  */
00524 typedef struct {
00525 
00526     uint8_t   TopLeftX;   /*!< Top Left x coordinate:  0-15 range */
00527     uint8_t   TopLeftY;   /*!< Top Left y coordinate:  0-15 range */
00528     uint8_t   BotRightX;  /*!< Bot Right x coordinate: 0-15 range */
00529     uint8_t   BotRightY;  /*!< Bot Right y coordinate: 0-15 range */
00530 
00531 } VL53L1_UserRoi_t;
00532 
00533 
00534 /** @brief Defines ROI configuration parameters
00535  *
00536  *  Support up a max of 16 zones, Each Zone has the same size
00537  *
00538  */
00539 typedef struct {
00540 
00541     uint8_t             NumberOfRoi;   /*!< Number of Rois defined*/
00542 
00543     VL53L1_UserRoi_t    UserRois[VL53L1_MAX_USER_ZONES];
00544         /*!< List of Rois */
00545 
00546 } VL53L1_RoiConfig_t;
00547 
00548 /**
00549  * @struct VL53L1_CustomerNvmManaged_t
00550  *
00551  */
00552 
00553 typedef struct {
00554     uint8_t   global_config__spad_enables_ref_0;
00555     uint8_t   global_config__spad_enables_ref_1;
00556     uint8_t   global_config__spad_enables_ref_2;
00557     uint8_t   global_config__spad_enables_ref_3;
00558     uint8_t   global_config__spad_enables_ref_4;
00559     uint8_t   global_config__spad_enables_ref_5;
00560     uint8_t   global_config__ref_en_start_select;
00561     uint8_t   ref_spad_man__num_requested_ref_spads;
00562     uint8_t   ref_spad_man__ref_location;
00563     uint32_t  algo__crosstalk_compensation_plane_offset_kcps;
00564     int16_t   algo__crosstalk_compensation_x_plane_gradient_kcps;
00565     int16_t   algo__crosstalk_compensation_y_plane_gradient_kcps;
00566     uint16_t  ref_spad_char__total_rate_target_mcps;
00567     int16_t   algo__part_to_part_range_offset_mm;
00568     int16_t   mm_config__inner_offset_mm;
00569     int16_t   mm_config__outer_offset_mm;
00570 } VL53L1_CustomerNvmManaged_t;
00571 
00572 /**
00573  * @struct  VL53L1_CalibrationData_t
00574  * @brief   Structure for storing the Calibration Data
00575  *
00576  */
00577 
00578 typedef struct {
00579 
00580     uint32_t                             struct_version;
00581     VL53L1_CustomerNvmManaged_t          customer;
00582     VL53L1_dmax_calibration_data_t       fmt_dmax_cal;
00583     VL53L1_dmax_calibration_data_t       cust_dmax_cal;
00584     VL53L1_additional_offset_cal_data_t  add_off_cal_data;
00585     VL53L1_optical_centre_t              optical_centre;
00586     VL53L1_xtalk_histogram_data_t        xtalkhisto;
00587     VL53L1_gain_calibration_data_t       gain_cal;
00588     VL53L1_cal_peak_rate_map_t           cal_peak_rate_map;
00589     VL53L1_per_vcsel_period_offset_cal_data_t per_vcsel_cal_data;
00590     uint32_t  algo__xtalk_cpo_HistoMerge_kcps[VL53L1_BIN_REC_SIZE];
00591 } VL53L1_CalibrationData_t;
00592 
00593 #define VL53L1_ADDITIONAL_CALIBRATION_DATA_STRUCT_VERSION  0x20
00594 /** VL53L1 additional Calibration Data struct version final struct version
00595  * is given by adding it to  VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION
00596  */
00597 
00598 #define VL53L1_CALIBRATION_DATA_STRUCT_VERSION \
00599         (VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION + \
00600         VL53L1_ADDITIONAL_CALIBRATION_DATA_STRUCT_VERSION)
00601 /* VL53L1 Calibration Data struct version */
00602 
00603 /**
00604  * @struct  VL53L1_AdditionalData_t
00605  * @brief   Structure for storing the Additional Data
00606  *
00607  */
00608 typedef VL53L1_additional_data_t VL53L1_AdditionalData_t;
00609 
00610 /**
00611  * @struct  VL53L1_ZoneCalibrationData_t
00612  * @brief   Structure for storing the Zone Calibration Data
00613  *
00614  */
00615 typedef VL53L1_zone_calibration_results_t VL53L1_ZoneCalibrationData_t;
00616 
00617 /** @defgroup VL53L1_define_SequenceStepId_group Defines the SequenceStep
00618  *  Defines the the sequence steps performed during ranging..
00619  *  @{
00620  */
00621 typedef uint8_t VL53L1_SequenceStepId;
00622 
00623 #define  VL53L1_SEQUENCESTEP_VHV         ((VL53L1_SequenceStepId) 0)
00624 /*!<VHV. */
00625 #define  VL53L1_SEQUENCESTEP_PHASECAL        ((VL53L1_SequenceStepId) 1)
00626 /*!<Phase Calibration. */
00627 #define  VL53L1_SEQUENCESTEP_REFPHASE        ((VL53L1_SequenceStepId) 2)
00628 /*!<Reference Phase. */
00629 #define  VL53L1_SEQUENCESTEP_DSS1        ((VL53L1_SequenceStepId) 3)
00630 /*!<DSS1. */
00631 #define  VL53L1_SEQUENCESTEP_DSS2        ((VL53L1_SequenceStepId) 4)
00632 /*!<DSS2. */
00633 #define  VL53L1_SEQUENCESTEP_MM1         ((VL53L1_SequenceStepId) 5)
00634 /*!<Mode Mitigation 1. */
00635 #define  VL53L1_SEQUENCESTEP_MM2         ((VL53L1_SequenceStepId) 6)
00636 /*!<Mode Mitigation 2. */
00637 #define  VL53L1_SEQUENCESTEP_RANGE       ((VL53L1_SequenceStepId) 7)
00638 /*!<Final Range step. */
00639 
00640 #define  VL53L1_SEQUENCESTEP_NUMBER_OF_ITEMS             8
00641 /*!<Number of Sequence Step Managed by the API. */
00642 
00643 /** @} VL53L1_define_SequenceStepId_group */
00644 
00645 /** @defgroup VL53L1_define_RangeStatus_group Defines the Range Status
00646  *  @{
00647  */
00648 #define  VL53L1_RANGESTATUS_RANGE_VALID             0
00649 /*!<The Range is valid. */
00650 #define  VL53L1_RANGESTATUS_SIGMA_FAIL              1
00651 /*!<Sigma Fail. */
00652 #define  VL53L1_RANGESTATUS_SIGNAL_FAIL             2
00653 /*!<Signal fail. */
00654 #define  VL53L1_RANGESTATUS_RANGE_VALID_MIN_RANGE_CLIPPED   3
00655 /*!<Target is below minimum detection threshold. */
00656 #define  VL53L1_RANGESTATUS_OUTOFBOUNDS_FAIL            4
00657 /*!<Phase out of valid limits -  different to a wrap exit. */
00658 #define  VL53L1_RANGESTATUS_HARDWARE_FAIL           5
00659 /*!<Hardware fail. */
00660 #define  VL53L1_RANGESTATUS_RANGE_VALID_NO_WRAP_CHECK_FAIL  6
00661 /*!<The Range is valid but the wraparound check has not been done. */
00662 #define VL53L1_RANGESTATUS_WRAP_TARGET_FAIL         7
00663 /*!<Wrapped target - no matching phase in other VCSEL period timing. */
00664 #define VL53L1_RANGESTATUS_PROCESSING_FAIL          8
00665 /*!<Internal algo underflow or overflow in lite ranging. */
00666 #define VL53L1_RANGESTATUS_XTALK_SIGNAL_FAIL            9
00667 /*!<Specific to lite ranging. */
00668 #define VL53L1_RANGESTATUS_SYNCRONISATION_INT           10
00669 /*!<1st interrupt when starting ranging in back to back mode. Ignore data. */
00670 #define VL53L1_RANGESTATUS_RANGE_VALID_MERGED_PULSE     11
00671 /*!<All Range ok but object is result of multiple pulses merging together.
00672  * Used by RQL for merged pulse detection
00673  */
00674 #define VL53L1_RANGESTATUS_TARGET_PRESENT_LACK_OF_SIGNAL    12
00675 /*!<Used  by RQL  as different to phase fail. */
00676 #define VL53L1_RANGESTATUS_MIN_RANGE_FAIL           13
00677 /*!<User ROI input is not valid e.g. beyond SPAD Array.*/
00678 #define VL53L1_RANGESTATUS_RANGE_INVALID            14
00679 /*!<lld returned valid range but negative value ! */
00680 #define  VL53L1_RANGESTATUS_NONE                255
00681 /*!<No Update. */
00682 
00683 /** @} VL53L1_define_RangeStatus_group */
00684 
00685 
00686 /** @brief  Contains the Internal data of the Bare Driver
00687  */
00688 
00689 typedef struct {
00690     VL53L1_LLDriverData_t   LLData;
00691     /*!< Low Level Driver data structure */
00692 
00693     VL53L1_LLDriverResults_t llresults;
00694     /*!< Low Level Driver data structure */
00695 
00696     VL53L1_State      PalState; /* Store the pal state */
00697     VL53L1_DeviceParameters_t CurrentParameters;
00698     /*!< Current Device Parameter */
00699 
00700 } VL53L1_DevData_t;
00701 
00702 
00703 /* MACRO Definitions */
00704 /** @defgroup VL53L1_define_GeneralMacro_group General Macro Defines
00705  *  General Macro Defines
00706  *  @{
00707  */
00708 
00709 /* Defines */
00710 #define VL53L1_SETPARAMETERFIELD(Dev, field, value) \
00711     (VL53L1DevDataSet(Dev, CurrentParameters.field, value))
00712 
00713 #define VL53L1_GETPARAMETERFIELD(Dev, field, variable) \
00714     (variable = VL53L1DevDataGet(Dev, CurrentParameters).field)
00715 
00716 
00717 #define VL53L1_SETARRAYPARAMETERFIELD(Dev, field, index, value) \
00718     (VL53L1DevDataSet(Dev, CurrentParameters.field[index], value))
00719 
00720 #define VL53L1_GETARRAYPARAMETERFIELD(Dev, field, index, variable) \
00721     (variable = VL53L1DevDataGet(Dev, CurrentParameters).field[index])
00722 
00723 
00724 #define VL53L1_SETDEVICESPECIFICPARAMETER(Dev, field, value) \
00725     (VL53L1DevDataSet(Dev, DeviceSpecificParameters.field, value))
00726 
00727 #define VL53L1_GETDEVICESPECIFICPARAMETER(Dev, field) \
00728     (VL53L1DevDataGet(Dev, DeviceSpecificParameters).field)
00729 
00730 
00731 #define VL53L1_FIXPOINT1616TOFIXPOINT44(Value) \
00732     (uint16_t)((Value>>12)&0xFFFF)
00733 #define VL53L1_FIXPOINT44TOFIXPOINT1616(Value) \
00734     (FixPoint1616_t)((uint32_t)Value<<12)
00735 
00736 #define VL53L1_FIXPOINT1616TOFIXPOINT72(Value) \
00737     (uint16_t)((Value>>14)&0xFFFF)
00738 #define VL53L1_FIXPOINT72TOFIXPOINT1616(Value) \
00739     (FixPoint1616_t)((uint32_t)Value<<14)
00740 
00741 #define VL53L1_FIXPOINT1616TOFIXPOINT97(Value) \
00742     (uint16_t)((Value>>9)&0xFFFF)
00743 #define VL53L1_FIXPOINT97TOFIXPOINT1616(Value) \
00744     (FixPoint1616_t)((uint32_t)Value<<9)
00745 
00746 #define VL53L1_FIXPOINT1616TOFIXPOINT88(Value) \
00747     (uint16_t)((Value>>8)&0xFFFF)
00748 #define VL53L1_FIXPOINT88TOFIXPOINT1616(Value) \
00749     (FixPoint1616_t)((uint32_t)Value<<8)
00750 
00751 #define VL53L1_FIXPOINT1616TOFIXPOINT412(Value) \
00752     (uint16_t)((Value>>4)&0xFFFF)
00753 #define VL53L1_FIXPOINT412TOFIXPOINT1616(Value) \
00754     (FixPoint1616_t)((uint32_t)Value<<4)
00755 
00756 #define VL53L1_FIXPOINT1616TOFIXPOINT313(Value) \
00757     (uint16_t)((Value>>3)&0xFFFF)
00758 #define VL53L1_FIXPOINT313TOFIXPOINT1616(Value) \
00759     (FixPoint1616_t)((uint32_t)Value<<3)
00760 
00761 #define VL53L1_FIXPOINT1616TOFIXPOINT08(Value) \
00762     (uint8_t)((Value>>8)&0x00FF)
00763 #define VL53L1_FIXPOINT08TOFIXPOINT1616(Value) \
00764     (FixPoint1616_t)((uint32_t)Value<<8)
00765 
00766 #define VL53L1_FIXPOINT1616TOFIXPOINT53(Value) \
00767     (uint8_t)((Value>>13)&0x00FF)
00768 #define VL53L1_FIXPOINT53TOFIXPOINT1616(Value) \
00769     (FixPoint1616_t)((uint32_t)Value<<13)
00770 
00771 #define VL53L1_FIXPOINT1616TOFIXPOINT102(Value) \
00772     (uint16_t)((Value>>14)&0x0FFF)
00773 #define VL53L1_FIXPOINT102TOFIXPOINT1616(Value) \
00774     (FixPoint1616_t)((uint32_t)Value<<14)
00775 
00776 #define VL53L1_FIXPOINT1616TOFIXPOINT142(Value) \
00777     (uint16_t)((Value>>14)&0xFFFF)
00778 #define VL53L1_FIXPOINT142TOFIXPOINT1616(Value) \
00779     (FixPoint1616_t)((uint32_t)Value<<14)
00780 
00781 #define VL53L1_FIXPOINT1616TOFIXPOINT160(Value) \
00782     (uint16_t)((Value>>16)&0xFFFF)
00783 #define VL53L1_FIXPOINT160TOFIXPOINT1616(Value) \
00784     (FixPoint1616_t)((uint32_t)Value<<16)
00785 
00786 #define VL53L1_MAKEUINT16(lsb, msb) (uint16_t)((((uint16_t)msb)<<8) + \
00787         (uint16_t)lsb)
00788 
00789 #ifndef SUPPRESS_UNUSED_WARNING
00790 #define SUPPRESS_UNUSED_WARNING(x) ((void) (x))
00791 #endif
00792 
00793 /** @} VL53L1_define_GeneralMacro_group */
00794 
00795 /** @} VL53L1_globaldefine_group */
00796 
00797 
00798 
00799 #ifdef __cplusplus
00800 }
00801 #endif
00802 
00803 
00804 #endif /* _VL53L1_DEF_H_ */