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