Workshop example

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers VL53L0X_def.h Source File

VL53L0X_def.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 Copyright © 2016, STMicroelectronics International N.V.
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007     * Redistributions of source code must retain the above copyright
00008       notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright
00010       notice, this list of conditions and the following disclaimer in the
00011       documentation and/or other materials provided with the distribution.
00012     * Neither the name of STMicroelectronics nor the
00013       names of its contributors may be used to endorse or promote products
00014       derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
00019 NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
00020 IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
00021 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00022 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00023 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00024 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00026 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027 *******************************************************************************/
00028 
00029 /**
00030  * @file VL53L0X_def.h
00031  *
00032  * @brief Type definitions for VL53L0X API.
00033  *
00034  */
00035 
00036 
00037 #ifndef _VL53L0X_DEF_H_
00038 #define _VL53L0X_DEF_H_
00039 
00040 
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 
00045 /** @defgroup VL53L0X_globaldefine_group VL53L0X Defines
00046  *  @brief    VL53L0X Defines
00047  *  @{
00048  */
00049 
00050 
00051 /** PAL SPECIFICATION major version */
00052 #define VL53L0X10_SPECIFICATION_VER_MAJOR   1
00053 /** PAL SPECIFICATION minor version */
00054 #define VL53L0X10_SPECIFICATION_VER_MINOR   2
00055 /** PAL SPECIFICATION sub version */
00056 #define VL53L0X10_SPECIFICATION_VER_SUB    7
00057 /** PAL SPECIFICATION sub version */
00058 #define VL53L0X10_SPECIFICATION_VER_REVISION 1440
00059 
00060 /** VL53L0X PAL IMPLEMENTATION major version */
00061 #define VL53L0X10_IMPLEMENTATION_VER_MAJOR  1
00062 /** VL53L0X PAL IMPLEMENTATION minor version */
00063 #define VL53L0X10_IMPLEMENTATION_VER_MINOR  0
00064 /** VL53L0X PAL IMPLEMENTATION sub version */
00065 #define VL53L0X10_IMPLEMENTATION_VER_SUB        9
00066 /** VL53L0X PAL IMPLEMENTATION sub version */
00067 #define VL53L0X10_IMPLEMENTATION_VER_REVISION   3673
00068 
00069 /** PAL SPECIFICATION major version */
00070 #define VL53L0X_SPECIFICATION_VER_MAJOR  1
00071 /** PAL SPECIFICATION minor version */
00072 #define VL53L0X_SPECIFICATION_VER_MINOR  2
00073 /** PAL SPECIFICATION sub version */
00074 #define VL53L0X_SPECIFICATION_VER_SUB    7
00075 /** PAL SPECIFICATION sub version */
00076 #define VL53L0X_SPECIFICATION_VER_REVISION 1440
00077 
00078 /** VL53L0X PAL IMPLEMENTATION major version */
00079 #define VL53L0X_IMPLEMENTATION_VER_MAJOR      1
00080 /** VL53L0X PAL IMPLEMENTATION minor version */
00081 #define VL53L0X_IMPLEMENTATION_VER_MINOR      1
00082 /** VL53L0X PAL IMPLEMENTATION sub version */
00083 #define VL53L0X_IMPLEMENTATION_VER_SUB    21
00084 /** VL53L0X PAL IMPLEMENTATION sub version */
00085 #define VL53L0X_IMPLEMENTATION_VER_REVISION   4823
00086 #define VL53L0X_DEFAULT_MAX_LOOP 2000
00087 #define VL53L0X_MAX_STRING_LENGTH 32
00088 
00089 
00090 #include "VL53L0X_device.h"
00091 #include "VL53L0X_types.h"
00092 
00093 
00094 /****************************************
00095  * PRIVATE define do not edit
00096  ****************************************/
00097 
00098 /** @brief Defines the parameters of the Get Version Functions
00099  */
00100 typedef struct {
00101     uint32_t     revision ; /*!< revision number */
00102     uint8_t      major ;    /*!< major number */
00103     uint8_t      minor ;    /*!< minor number */
00104     uint8_t      build ;    /*!< build number */
00105 } VL53L0X_Version_t;
00106 
00107 
00108 /** @brief Defines the parameters of the Get Device Info Functions
00109  */
00110 typedef struct {
00111     char Name[VL53L0X_MAX_STRING_LENGTH];
00112     /*!< Name of the Device e.g. Left_Distance */
00113     char Type[VL53L0X_MAX_STRING_LENGTH];
00114     /*!< Type of the Device e.g VL53L0X */
00115     char ProductId[VL53L0X_MAX_STRING_LENGTH];
00116     /*!< Product Identifier String  */
00117     uint8_t ProductType;
00118     /*!< Product Type, VL53L0X = 1, VL53L1 = 2 */
00119     uint8_t ProductRevisionMajor;
00120     /*!< Product revision major */
00121     uint8_t ProductRevisionMinor;
00122     /*!< Product revision minor */
00123 } VL53L0X_DeviceInfo_t;
00124 
00125 
00126 /** @defgroup VL53L0X_define_Error_group Error and Warning code returned by API
00127  *  The following DEFINE are used to identify the PAL ERROR
00128  *  @{
00129  */
00130 
00131 typedef int8_t VL53L0X_Error;
00132 
00133 #define VL53L0X_ERROR_NONE      ((VL53L0X_Error)    0)
00134 #define VL53L0X_ERROR_CALIBRATION_WARNING   ((VL53L0X_Error) -1)
00135 /*!< Warning invalid calibration data may be in used
00136     \a  VL53L0X_InitData()
00137     \a VL53L0X_GetOffsetCalibrationData
00138     \a VL53L0X_SetOffsetCalibrationData */
00139 #define VL53L0X_ERROR_MIN_CLIPPED           ((VL53L0X_Error) -2)
00140 /*!< Warning parameter passed was clipped to min before to be applied */
00141 
00142 #define VL53L0X_ERROR_UNDEFINED             ((VL53L0X_Error) -3)
00143 /*!< Unqualified error */
00144 #define VL53L0X_ERROR_INVALID_PARAMS            ((VL53L0X_Error) -4)
00145 /*!< Parameter passed is invalid or out of range */
00146 #define VL53L0X_ERROR_NOT_SUPPORTED         ((VL53L0X_Error) -5)
00147 /*!< Function is not supported in current mode or configuration */
00148 #define VL53L0X_ERROR_RANGE_ERROR           ((VL53L0X_Error) -6)
00149 /*!< Device report a ranging error interrupt status */
00150 #define VL53L0X_ERROR_TIME_OUT              ((VL53L0X_Error) -7)
00151 /*!< Aborted due to time out */
00152 #define VL53L0X_ERROR_MODE_NOT_SUPPORTED            ((VL53L0X_Error) -8)
00153 /*!< Asked mode is not supported by the device */
00154 #define VL53L0X_ERROR_BUFFER_TOO_SMALL          ((VL53L0X_Error) -9)
00155 /*!< ... */
00156 #define VL53L0X_ERROR_GPIO_NOT_EXISTING         ((VL53L0X_Error) -10)
00157 /*!< User tried to setup a non-existing GPIO pin */
00158 #define VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED  ((VL53L0X_Error) -11)
00159 /*!< unsupported GPIO functionality */
00160 #define VL53L0X_ERROR_INTERRUPT_NOT_CLEARED     ((VL53L0X_Error) -12)
00161 /*!< Error during interrupt clear */
00162 #define VL53L0X_ERROR_CONTROL_INTERFACE         ((VL53L0X_Error) -20)
00163 /*!< error reported from IO functions */
00164 #define VL53L0X_ERROR_INVALID_COMMAND           ((VL53L0X_Error) -30)
00165 /*!< The command is not allowed in the current device state
00166  *  (power down) */
00167 #define VL53L0X_ERROR_DIVISION_BY_ZERO          ((VL53L0X_Error) -40)
00168 /*!< In the function a division by zero occurs */
00169 #define VL53L0X_ERROR_REF_SPAD_INIT         ((VL53L0X_Error) -50)
00170 /*!< Error during reference SPAD initialization */
00171 #define VL53L0X_ERROR_NOT_IMPLEMENTED           ((VL53L0X_Error) -99)
00172 /*!< Tells requested functionality has not been implemented yet or
00173  * not compatible with the device */
00174 /** @} VL53L0X_define_Error_group */
00175 
00176 
00177 /** @defgroup VL53L0X_define_DeviceModes_group Defines Device modes
00178  *  Defines all possible modes for the device
00179  *  @{
00180  */
00181 typedef uint8_t VL53L0X_DeviceModes;
00182 
00183 #define VL53L0X_DEVICEMODE_SINGLE_RANGING   ((VL53L0X_DeviceModes)  0)
00184 #define VL53L0X_DEVICEMODE_CONTINUOUS_RANGING   ((VL53L0X_DeviceModes)  1)
00185 #define VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM ((VL53L0X_DeviceModes)  2)
00186 #define VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING ((VL53L0X_DeviceModes) 3)
00187 #define VL53L0X_DEVICEMODE_SINGLE_ALS       ((VL53L0X_DeviceModes) 10)
00188 #define VL53L0X_DEVICEMODE_GPIO_DRIVE       ((VL53L0X_DeviceModes) 20)
00189 #define VL53L0X_DEVICEMODE_GPIO_OSC     ((VL53L0X_DeviceModes) 21)
00190 /* ... Modes to be added depending on device */
00191 /** @} VL53L0X_define_DeviceModes_group */
00192 
00193 
00194 
00195 /** @defgroup VL53L0X_define_HistogramModes_group Defines Histogram modes
00196  *  Defines all possible Histogram modes for the device
00197  *  @{
00198  */
00199 typedef uint8_t VL53L0X_HistogramModes;
00200 
00201 #define VL53L0X_HISTOGRAMMODE_DISABLED      ((VL53L0X_HistogramModes) 0)
00202 /*!< Histogram Disabled */
00203 #define VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY    ((VL53L0X_HistogramModes) 1)
00204 /*!< Histogram Reference array only */
00205 #define VL53L0X_HISTOGRAMMODE_RETURN_ONLY   ((VL53L0X_HistogramModes) 2)
00206 /*!< Histogram Return array only */
00207 #define VL53L0X_HISTOGRAMMODE_BOTH      ((VL53L0X_HistogramModes) 3)
00208 /*!< Histogram both Reference and Return Arrays */
00209 /* ... Modes to be added depending on device */
00210 /** @} VL53L0X_define_HistogramModes_group */
00211 
00212 
00213 /** @defgroup VL53L0X_define_PowerModes_group List of available Power Modes
00214  *  List of available Power Modes
00215  *  @{
00216  */
00217 
00218 typedef uint8_t VL53L0X_PowerModes;
00219 
00220 #define VL53L0X_POWERMODE_STANDBY_LEVEL1 ((VL53L0X_PowerModes) 0)
00221 /*!< Standby level 1 */
00222 #define VL53L0X_POWERMODE_STANDBY_LEVEL2 ((VL53L0X_PowerModes) 1)
00223 /*!< Standby level 2 */
00224 #define VL53L0X_POWERMODE_IDLE_LEVEL1   ((VL53L0X_PowerModes) 2)
00225 /*!< Idle level 1 */
00226 #define VL53L0X_POWERMODE_IDLE_LEVEL2   ((VL53L0X_PowerModes) 3)
00227 /*!< Idle level 2 */
00228 
00229 /** @} VL53L0X_define_PowerModes_group */
00230 
00231 
00232 /** @brief Defines all parameters for the device
00233  */
00234 typedef struct {
00235     VL53L0X_DeviceModes DeviceMode;
00236     /*!< Defines type of measurement to be done for the next measure */
00237     VL53L0X_HistogramModes HistogramMode;
00238     /*!< Defines type of histogram measurement to be done for the next
00239      *  measure */
00240     uint32_t MeasurementTimingBudgetMicroSeconds;
00241     /*!< Defines the allowed total time for a single measurement */
00242     uint32_t InterMeasurementPeriodMilliSeconds;
00243     /*!< Defines time between two consecutive measurements (between two
00244      *  measurement starts). If set to 0 means back-to-back mode */
00245     uint8_t XTalkCompensationEnable;
00246     /*!< Tells if Crosstalk compensation shall be enable or not  */
00247     uint16_t XTalkCompensationRangeMilliMeter;
00248     /*!< CrossTalk compensation range in millimeter  */
00249     FixPoint1616_t XTalkCompensationRateMegaCps;
00250     /*!< CrossTalk compensation rate in Mega counts per seconds.
00251      *  Expressed in 16.16 fixed point format.  */
00252     int32_t RangeOffsetMicroMeters;
00253     /*!< Range offset adjustment (mm).  */
00254 
00255     uint8_t LimitChecksEnable[VL53L0X_CHECKENABLE_NUMBER_OF_CHECKS];
00256     /*!< This Array store all the Limit Check enable for this device. */
00257     uint8_t LimitChecksStatus[VL53L0X_CHECKENABLE_NUMBER_OF_CHECKS];
00258     /*!< This Array store all the Status of the check linked to last
00259     * measurement. */
00260     FixPoint1616_t LimitChecksValue[VL53L0X_CHECKENABLE_NUMBER_OF_CHECKS];
00261     /*!< This Array store all the Limit Check value for this device */
00262 
00263     uint8_t WrapAroundCheckEnable;
00264     /*!< Tells if Wrap Around Check shall be enable or not */
00265 } VL53L0X_DeviceParameters_t;
00266 
00267 
00268 /** @defgroup VL53L0X_define_State_group Defines the current status of the device
00269  *  Defines the current status of the device
00270  *  @{
00271  */
00272 
00273 typedef uint8_t VL53L0X_State;
00274 
00275 #define VL53L0X_STATE_POWERDOWN      ((VL53L0X_State)  0)
00276 /*!< Device is in HW reset  */
00277 #define VL53L0X_STATE_WAIT_STATICINIT ((VL53L0X_State)  1)
00278 /*!< Device is initialized and wait for static initialization  */
00279 #define VL53L0X_STATE_STANDBY        ((VL53L0X_State)  2)
00280 /*!< Device is in Low power Standby mode   */
00281 #define VL53L0X_STATE_IDLE           ((VL53L0X_State)  3)
00282 /*!< Device has been initialized and ready to do measurements  */
00283 #define VL53L0X_STATE_RUNNING        ((VL53L0X_State)  4)
00284 /*!< Device is performing measurement */
00285 #define VL53L0X_STATE_UNKNOWN        ((VL53L0X_State)  98)
00286 /*!< Device is in unknown state and need to be rebooted  */
00287 #define VL53L0X_STATE_ERROR          ((VL53L0X_State)  99)
00288 /*!< Device is in error state and need to be rebooted  */
00289 
00290 /** @} VL53L0X_define_State_group */
00291 
00292 
00293 /** @brief Structure containing the Dmax computation parameters and data
00294  */
00295 typedef struct {
00296     int32_t AmbTuningWindowFactor_K;
00297     /*!<  internal algo tuning (*1000) */
00298     int32_t RetSignalAt0mm;
00299     /*!< intermediate dmax computation value caching */
00300 } VL53L0X_DMaxData_t;
00301 
00302 /**
00303  * @struct VL53L0X_RangeData_t
00304  * @brief Range measurement data.
00305  */
00306 typedef struct {
00307     uint32_t TimeStamp;     /*!< 32-bit time stamp. */
00308     uint32_t MeasurementTimeUsec;
00309     /*!< Give the Measurement time needed by the device to do the
00310      * measurement.*/
00311 
00312 
00313     uint16_t RangeMilliMeter;   /*!< range distance in millimeter. */
00314 
00315     uint16_t RangeDMaxMilliMeter;
00316     /*!< Tells what is the maximum detection distance of the device
00317      * in current setup and environment conditions (Filled when
00318      *  applicable) */
00319 
00320     FixPoint1616_t SignalRateRtnMegaCps;
00321     /*!< Return signal rate (MCPS)\n these is a 16.16 fix point
00322      *  value, which is effectively a measure of target
00323      *   reflectance.*/
00324     FixPoint1616_t AmbientRateRtnMegaCps;
00325     /*!< Return ambient rate (MCPS)\n these is a 16.16 fix point
00326      *  value, which is effectively a measure of the ambien
00327      *  t light.*/
00328 
00329     uint16_t EffectiveSpadRtnCount;
00330     /*!< Return the effective SPAD count for the return signal.
00331      *  To obtain Real value it should be divided by 256 */
00332 
00333     uint8_t ZoneId;
00334     /*!< Denotes which zone and range scheduler stage the range
00335      *  data relates to. */
00336     uint8_t RangeFractionalPart;
00337     /*!< Fractional part of range distance. Final value is a
00338      *  FixPoint168 value. */
00339     uint8_t RangeStatus;
00340     /*!< Range Status for the current measurement. This is device
00341      *  dependent. Value = 0 means value is valid.
00342      *  See \ref RangeStatusPage */
00343 } VL53L0X_RangingMeasurementData_t;
00344 
00345 
00346 #define VL53L0X_HISTOGRAM_BUFFER_SIZE 24
00347 
00348 /**
00349  * @struct VL53L0X_HistogramData_t
00350  * @brief Histogram measurement data.
00351  */
00352 typedef struct {
00353     /* Histogram Measurement data */
00354     uint32_t HistogramData[VL53L0X_HISTOGRAM_BUFFER_SIZE];
00355     /*!< Histogram data */
00356     uint8_t HistogramType; /*!< Indicate the types of histogram data :
00357     Return only, Reference only, both Return and Reference */
00358     uint8_t FirstBin; /*!< First Bin value */
00359     uint8_t BufferSize; /*!< Buffer Size - Set by the user.*/
00360     uint8_t NumberOfBins;
00361     /*!< Number of bins filled by the histogram measurement */
00362 
00363     VL53L0X_DeviceError ErrorStatus;
00364     /*!< Error status of the current measurement. \n
00365     see @a ::VL53L0X_DeviceError @a VL53L0X_GetStatusErrorString() */
00366 } VL53L0X_HistogramMeasurementData_t;
00367 
00368 #define VL53L0X_REF_SPAD_BUFFER_SIZE 6
00369 
00370 /**
00371  * @struct VL53L0X_SpadData_t
00372  * @brief Spad Configuration Data.
00373  */
00374 typedef struct {
00375     uint8_t RefSpadEnables[VL53L0X_REF_SPAD_BUFFER_SIZE];
00376     /*!< Reference Spad Enables */
00377     uint8_t RefGoodSpadMap[VL53L0X_REF_SPAD_BUFFER_SIZE];
00378     /*!< Reference Spad Good Spad Map */
00379 } VL53L0X_SpadData_t;
00380 
00381 typedef struct {
00382     FixPoint1616_t OscFrequencyMHz; /* Frequency used */
00383 
00384     uint16_t LastEncodedTimeout;
00385     /* last encoded Time out used for timing budget*/
00386 
00387     VL53L0X_GpioFunctionality Pin0GpioFunctionality;
00388     /* store the functionality of the GPIO: pin0 */
00389 
00390     uint32_t FinalRangeTimeoutMicroSecs;
00391     /*!< Execution time of the final range*/
00392     uint8_t FinalRangeVcselPulsePeriod;
00393     /*!< Vcsel pulse period (pll clocks) for the final range measurement*/
00394     uint32_t PreRangeTimeoutMicroSecs;
00395     /*!< Execution time of the final range*/
00396     uint8_t PreRangeVcselPulsePeriod;
00397     /*!< Vcsel pulse period (pll clocks) for the pre-range measurement*/
00398 
00399     uint16_t SigmaEstRefArray;
00400     /*!< Reference array sigma value in 1/100th of [mm] e.g. 100 = 1mm */
00401     uint16_t SigmaEstEffPulseWidth;
00402     /*!< Effective Pulse width for sigma estimate in 1/100th
00403      * of ns e.g. 900 = 9.0ns */
00404     uint16_t SigmaEstEffAmbWidth;
00405     /*!< Effective Ambient width for sigma estimate in 1/100th of ns
00406      * e.g. 500 = 5.0ns */
00407 
00408 
00409     uint8_t ReadDataFromDeviceDone; /* Indicate if read from device has
00410     been done (==1) or not (==0) */
00411     uint8_t ModuleId; /* Module ID */
00412     uint8_t Revision; /* test Revision */
00413     char ProductId[VL53L0X_MAX_STRING_LENGTH];
00414     /* Product Identifier String  */
00415     uint8_t ReferenceSpadCount; /* used for ref spad management */
00416     uint8_t ReferenceSpadType;  /* used for ref spad management */
00417     uint8_t RefSpadsInitialised; /* reports if ref spads are initialised. */
00418     uint32_t PartUIDUpper; /*!< Unique Part ID Upper */
00419     uint32_t PartUIDLower; /*!< Unique Part ID Lower */
00420     FixPoint1616_t SignalRateMeasFixed400mm; /*!< Peek Signal rate
00421     at 400 mm*/
00422 
00423 } VL53L0X_DeviceSpecificParameters_t;
00424 
00425 /**
00426  * @struct VL53L0X_DevData_t
00427  *
00428  * @brief VL53L0X PAL device ST private data structure \n
00429  * End user should never access any of these field directly
00430  *
00431  * These must never access directly but only via macro
00432  */
00433 typedef struct {
00434     VL53L0X_DMaxData_t DMaxData;
00435     /*!< Dmax Data */
00436     int32_t  Part2PartOffsetNVMMicroMeter;
00437     /*!< backed up NVM value */
00438     int32_t  Part2PartOffsetAdjustmentNVMMicroMeter;
00439     /*!< backed up NVM value representing additional offset adjustment */
00440     VL53L0X_DeviceParameters_t CurrentParameters;
00441     /*!< Current Device Parameter */
00442     VL53L0X_RangingMeasurementData_t LastRangeMeasure;
00443     /*!< Ranging Data */
00444     VL53L0X_HistogramMeasurementData_t LastHistogramMeasure;
00445     /*!< Histogram Data */
00446     VL53L0X_DeviceSpecificParameters_t DeviceSpecificParameters;
00447     /*!< Parameters specific to the device */
00448     VL53L0X_SpadData_t SpadData;
00449     /*!< Spad Data */
00450     uint8_t SequenceConfig;
00451     /*!< Internal value for the sequence config */
00452     uint8_t RangeFractionalEnable;
00453     /*!< Enable/Disable fractional part of ranging data */
00454     VL53L0X_State PalState;
00455     /*!< Current state of the PAL for this device */
00456     VL53L0X_PowerModes PowerMode;
00457     /*!< Current Power Mode  */
00458     uint16_t SigmaEstRefArray;
00459     /*!< Reference array sigma value in 1/100th of [mm] e.g. 100 = 1mm */
00460     uint16_t SigmaEstEffPulseWidth;
00461     /*!< Effective Pulse width for sigma estimate in 1/100th
00462     * of ns e.g. 900 = 9.0ns */
00463     uint16_t SigmaEstEffAmbWidth;
00464     /*!< Effective Ambient width for sigma estimate in 1/100th of ns
00465     * e.g. 500 = 5.0ns */
00466     uint8_t StopVariable;
00467     /*!< StopVariable used during the stop sequence */
00468     uint16_t targetRefRate;
00469     /*!< Target Ambient Rate for Ref spad management */
00470     FixPoint1616_t SigmaEstimate;
00471     /*!< Sigma Estimate - based on ambient & VCSEL rates and
00472     * signal_total_events */
00473     FixPoint1616_t SignalEstimate;
00474     /*!< Signal Estimate - based on ambient & VCSEL rates and cross talk */
00475     FixPoint1616_t LastSignalRefMcps;
00476     /*!< Latest Signal ref in Mcps */
00477     uint8_t *pTuningSettingsPointer;
00478     /*!< Pointer for Tuning Settings table */
00479     uint8_t UseInternalTuningSettings;
00480     /*!< Indicate if we use  Tuning Settings table */
00481     uint16_t LinearityCorrectiveGain;
00482     /*!< Linearity Corrective Gain value in x1000 */
00483     uint16_t DmaxCalRangeMilliMeter;
00484     /*!< Dmax Calibration Range millimeter */
00485     FixPoint1616_t DmaxCalSignalRateRtnMegaCps;
00486     /*!< Dmax Calibration Signal Rate Return MegaCps */
00487 
00488 } VL53L0X_DevData_t;
00489 
00490 
00491 /** @defgroup VL53L0X_define_InterruptPolarity_group Defines the Polarity
00492  * of the Interrupt
00493  *  Defines the Polarity of the Interrupt
00494  *  @{
00495  */
00496 typedef uint8_t VL53L0X_InterruptPolarity;
00497 
00498 #define VL53L0X_INTERRUPTPOLARITY_LOW      ((VL53L0X_InterruptPolarity) 0)
00499 /*!< Set active low polarity best setup for falling edge. */
00500 #define VL53L0X_INTERRUPTPOLARITY_HIGH     ((VL53L0X_InterruptPolarity) 1)
00501 /*!< Set active high polarity best setup for rising edge. */
00502 
00503 /** @} VL53L0X_define_InterruptPolarity_group */
00504 
00505 
00506 /** @defgroup VL53L0X_define_VcselPeriod_group Vcsel Period Defines
00507  *  Defines the range measurement for which to access the vcsel period.
00508  *  @{
00509  */
00510 typedef uint8_t VL53L0X_VcselPeriod;
00511 
00512 #define VL53L0X_VCSEL_PERIOD_PRE_RANGE  ((VL53L0X_VcselPeriod) 0)
00513 /*!<Identifies the pre-range vcsel period. */
00514 #define VL53L0X_VCSEL_PERIOD_FINAL_RANGE ((VL53L0X_VcselPeriod) 1)
00515 /*!<Identifies the final range vcsel period. */
00516 
00517 /** @} VL53L0X_define_VcselPeriod_group */
00518 
00519 /** @defgroup VL53L0X_define_SchedulerSequence_group Defines the steps
00520  * carried out by the scheduler during a range measurement.
00521  *  @{
00522  *  Defines the states of all the steps in the scheduler
00523  *  i.e. enabled/disabled.
00524  */
00525 typedef struct {
00526     uint8_t      TccOn;    /*!<Reports if Target Centre Check On  */
00527     uint8_t      MsrcOn;       /*!<Reports if MSRC On  */
00528     uint8_t      DssOn;        /*!<Reports if DSS On  */
00529     uint8_t      PreRangeOn;   /*!<Reports if Pre-Range On  */
00530     uint8_t      FinalRangeOn; /*!<Reports if Final-Range On  */
00531 } VL53L0X_SchedulerSequenceSteps_t;
00532 
00533 /** @} VL53L0X_define_SchedulerSequence_group */
00534 
00535 /** @defgroup VL53L0X_define_SequenceStepId_group Defines the Polarity
00536  *  of the Interrupt
00537  *  Defines the the sequence steps performed during ranging..
00538  *  @{
00539  */
00540 typedef uint8_t VL53L0X_SequenceStepId;
00541 
00542 #define  VL53L0X_SEQUENCESTEP_TCC        ((VL53L0X_VcselPeriod) 0)
00543 /*!<Target CentreCheck identifier. */
00544 #define  VL53L0X_SEQUENCESTEP_DSS        ((VL53L0X_VcselPeriod) 1)
00545 /*!<Dynamic Spad Selection function Identifier. */
00546 #define  VL53L0X_SEQUENCESTEP_MSRC       ((VL53L0X_VcselPeriod) 2)
00547 /*!<Minimum Signal Rate Check function Identifier. */
00548 #define  VL53L0X_SEQUENCESTEP_PRE_RANGE  ((VL53L0X_VcselPeriod) 3)
00549 /*!<Pre-Range check Identifier. */
00550 #define  VL53L0X_SEQUENCESTEP_FINAL_RANGE ((VL53L0X_VcselPeriod) 4)
00551 /*!<Final Range Check Identifier. */
00552 
00553 #define  VL53L0X_SEQUENCESTEP_NUMBER_OF_CHECKS           5
00554 /*!<Number of Sequence Step Managed by the API. */
00555 
00556 /** @} VL53L0X_define_SequenceStepId_group */
00557 
00558 
00559 /* MACRO Definitions */
00560 /** @defgroup VL53L0X_define_GeneralMacro_group General Macro Defines
00561  *  General Macro Defines
00562  *  @{
00563  */
00564 
00565 /* Defines */
00566 #define VL53L0X_SETPARAMETERFIELD(Dev, field, value) \
00567     PALDevDataSet(Dev, CurrentParameters.field, value)
00568 
00569 #define VL53L0X_GETPARAMETERFIELD(Dev, field, variable) \
00570     variable = PALDevDataGet(Dev, CurrentParameters).field
00571 
00572 
00573 #define VL53L0X_SETARRAYPARAMETERFIELD(Dev, field, index, value) \
00574     PALDevDataSet(Dev, CurrentParameters.field[index], value)
00575 
00576 #define VL53L0X_GETARRAYPARAMETERFIELD(Dev, field, index, variable) \
00577     variable = PALDevDataGet(Dev, CurrentParameters).field[index]
00578 
00579 
00580 #define VL53L0X_SETDEVICESPECIFICPARAMETER(Dev, field, value) \
00581         PALDevDataSet(Dev, DeviceSpecificParameters.field, value)
00582 
00583 #define VL53L0X_GETDEVICESPECIFICPARAMETER(Dev, field) \
00584         PALDevDataGet(Dev, DeviceSpecificParameters).field
00585 
00586 
00587 #define VL53L0X_FIXPOINT1616TOFIXPOINT97(Value) \
00588     (uint16_t)((Value>>9)&0xFFFF)
00589 #define VL53L0X_FIXPOINT97TOFIXPOINT1616(Value) \
00590     (FixPoint1616_t)(Value<<9)
00591 
00592 #define VL53L0X_FIXPOINT1616TOFIXPOINT88(Value) \
00593     (uint16_t)((Value>>8)&0xFFFF)
00594 #define VL53L0X_FIXPOINT88TOFIXPOINT1616(Value) \
00595     (FixPoint1616_t)(Value<<8)
00596 
00597 #define VL53L0X_FIXPOINT1616TOFIXPOINT412(Value) \
00598     (uint16_t)((Value>>4)&0xFFFF)
00599 #define VL53L0X_FIXPOINT412TOFIXPOINT1616(Value) \
00600     (FixPoint1616_t)(Value<<4)
00601 
00602 #define VL53L0X_FIXPOINT1616TOFIXPOINT313(Value) \
00603     (uint16_t)((Value>>3)&0xFFFF)
00604 #define VL53L0X_FIXPOINT313TOFIXPOINT1616(Value) \
00605     (FixPoint1616_t)(Value<<3)
00606 
00607 #define VL53L0X_FIXPOINT1616TOFIXPOINT08(Value) \
00608     (uint8_t)((Value>>8)&0x00FF)
00609 #define VL53L0X_FIXPOINT08TOFIXPOINT1616(Value) \
00610     (FixPoint1616_t)(Value<<8)
00611 
00612 #define VL53L0X_FIXPOINT1616TOFIXPOINT53(Value) \
00613     (uint8_t)((Value>>13)&0x00FF)
00614 #define VL53L0X_FIXPOINT53TOFIXPOINT1616(Value) \
00615     (FixPoint1616_t)(Value<<13)
00616 
00617 #define VL53L0X_FIXPOINT1616TOFIXPOINT102(Value) \
00618     (uint16_t)((Value>>14)&0x0FFF)
00619 #define VL53L0X_FIXPOINT102TOFIXPOINT1616(Value) \
00620     (FixPoint1616_t)(Value<<12)
00621 
00622 #define VL53L0X_MAKEUINT16(lsb, msb) (uint16_t)((((uint16_t)msb)<<8) + \
00623         (uint16_t)lsb)
00624 
00625 /** @} VL53L0X_define_GeneralMacro_group */
00626 
00627 /** @} VL53L0X_globaldefine_group */
00628 
00629 
00630 
00631 
00632 
00633 
00634 
00635 #ifdef __cplusplus
00636 }
00637 #endif
00638 
00639 
00640 #endif /* _VL53L0X_DEF_H_ */