1 /*
2 * Copyright (c) 2017, STMicroelectronics - All Rights Reserved
3 *
4 * This file is part of VL53L1 Core and is dual licensed,
5 * either 'STMicroelectronics
6 * Proprietary license'
7 * or 'BSD 3-clause "New" or "Revised" License' , at your option.
8 *
9 ********************************************************************************
10 *
11 * 'STMicroelectronics Proprietary license'
12 *
13 ********************************************************************************
14 *
15 * License terms: STMicroelectronics Proprietary in accordance with licensing
16 * terms at www.st.com/sla0081
17 *
18 * STMicroelectronics confidential
19 * Reproduction and Communication of this document is strictly prohibited unless
20 * specifically authorized in writing by STMicroelectronics.
21 *
22 *
23 ********************************************************************************
24 *
25 * Alternatively, VL53L1 Core may be distributed under the terms of
26 * 'BSD 3-clause "New" or "Revised" License', in which case the following
27 * provisions apply instead of the ones mentioned above :
28 *
29 ********************************************************************************
30 *
31 * License terms: BSD 3-clause "New" or "Revised" License.
32 *
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions are met:
35 *
36 * 1. Redistributions of source code must retain the above copyright notice, this
37 * list of conditions and the following disclaimer.
38 *
39 * 2. Redistributions in binary form must reproduce the above copyright notice,
40 * this list of conditions and the following disclaimer in the documentation
41 * and/or other materials provided with the distribution.
42 *
43 * 3. Neither the name of the copyright holder nor the names of its contributors
44 * may be used to endorse or promote products derived from this software
45 * without specific prior written permission.
46 *
47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 *
58 *
59 ********************************************************************************
60 *
61 */
62 
63 /**
64  * @file vl53l1_def.h
65  *
66  * @brief Type definitions for VL53L1 API.
67  *
68  */
69 
70 
71 #ifndef _VL53L1_DEF_H_
72 #define _VL53L1_DEF_H_
73 
74 #include "vl53l1_ll_def.h"
75 
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79 
80 /** @defgroup VL53L1_globaldefine_group VL53L1 Defines
81  *  @brief    VL53L1 Defines
82  *  @{
83  */
84 
85 
86 /** VL53L1 IMPLEMENTATION major version */
87 #define VL53L1_IMPLEMENTATION_VER_MAJOR       2
88 /** VL53L1 IMPLEMENTATION minor version */
89 #define VL53L1_IMPLEMENTATION_VER_MINOR       3
90 /** VL53L1 IMPLEMENTATION sub version */
91 #define VL53L1_IMPLEMENTATION_VER_SUB         3
92 /** VL53L1 IMPLEMENTATION sub version */
93 #define VL53L1_IMPLEMENTATION_VER_REVISION  1885
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 	uint32_t     revision; /*!< revision number */
103 	uint8_t      major;    /*!< major number */
104 	uint8_t      minor;    /*!< minor number */
105 	uint8_t      build;    /*!< build number */
106 } VL53L1_Version_t;
107 
108 
109 #define VL53L1_DEVINFO_STRLEN 32
110 
111 /** @brief Defines the parameters of the Get Device Info Functions
112  */
113 typedef struct {
114 	char Name[VL53L1_DEVINFO_STRLEN];
115 		/*!< Name of the Device e.g. Left_Distance */
116 	char Type[VL53L1_DEVINFO_STRLEN];
117 		/*!< Type of the Device e.g VL53L1 */
118 	char ProductId[VL53L1_DEVINFO_STRLEN];
119 		/*!< Product Identifier String
120 		 * @warning Not yet implemented
121 		 */
122 	uint8_t ProductType;
123 		/*!< Product Type, VL53L1 = 1, VL53L1 = 2*/
124 	uint8_t ProductRevisionMajor;
125 		/*!< Product revision major */
126 	uint8_t ProductRevisionMinor;
127 		/*!< Product revision minor */
128 } VL53L1_DeviceInfo_t;
129 
130 
131 
132 /** @defgroup VL53L1_define_PresetModes_group Defines Preset modes
133  *  Defines all possible preset modes for the device
134  *  @{
135  */
136 typedef uint8_t VL53L1_PresetModes;
137 
138 #define VL53L1_PRESETMODE_AUTONOMOUS                ((VL53L1_PresetModes)  3)
139 #define VL53L1_PRESETMODE_LITE_RANGING              ((VL53L1_PresetModes)  4)
140 #define VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS       ((VL53L1_PresetModes)  8)
141 
142 	/* ... Modes to be added depending on device */
143 /** @} VL53L1_define_PresetModes_group */
144 
145 
146 /** @defgroup VL53L1_define_DistanceModes_group Defines Distance modes
147  *  Defines all possible Distance modes for the device
148  *  @{
149  */
150 typedef uint8_t VL53L1_DistanceModes;
151 
152 #define VL53L1_DISTANCEMODE_SHORT             ((VL53L1_DistanceModes)  1)
153 #define VL53L1_DISTANCEMODE_MEDIUM            ((VL53L1_DistanceModes)  2)
154 #define VL53L1_DISTANCEMODE_LONG              ((VL53L1_DistanceModes)  3)
155 /** @} VL53L1_define_DistanceModes_group */
156 
157 
158 /** @defgroup VL53L1_define_XtalkCal_group Defines Xtalk Calibration modes
159 *  Defines all possible Offset Calibration modes for the device
160 *  @{
161 */
162 typedef uint8_t VL53L1_XtalkCalibrationModes;
163 
164 #define VL53L1_XTALKCALIBRATIONMODE_NO_TARGET \
165 	((VL53L1_OffsetCalibrationModes) 0)
166 /*!< To perform Xtalk calibration with no target below 80 cm */
167 #define VL53L1_XTALKCALIBRATIONMODE_SINGLE_TARGET \
168 	((VL53L1_OffsetCalibrationModes)  1)
169 /*!< To perform Xtalk calibration with one target */
170 #define VL53L1_XTALKCALIBRATIONMODE_FULL_ROI \
171 	((VL53L1_OffsetCalibrationModes)  2)
172 /*!< To perform Xtalk calibration based on histogram with full ROI */
173 
174 /** @} VL53L1_define_XtalkCal_group */
175 
176 /** @defgroup VL53L1_define_OffsetCal_group Defines Offset Calibration modes
177 *  Defines all possible Offset Calibration modes for the device
178 *  @{
179 */
180 typedef uint8_t VL53L1_OffsetCalibrationModes;
181 
182 #define VL53L1_OFFSETCALIBRATIONMODE_STANDARD \
183 	((VL53L1_OffsetCalibrationModes)  1)
184 #define VL53L1_OFFSETCALIBRATIONMODE_PRERANGE_ONLY  \
185 	((VL53L1_OffsetCalibrationModes)  2)
186 
187 /** @} VL53L1_define_OffsetCal_group */
188 
189 
190 
191 
192 
193 /** @defgroup VL53L1_CheckEnable_group Check Enable list
194  *  @brief Check Enable code
195  *
196  *  Define used to specify the LimitCheckId.
197  *  Use @a VL53L1_GetLimitCheckInfo() to get the string.
198  *  @{
199  */
200 
201 #define VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE           0
202 #define VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE     1
203 
204 #define VL53L1_CHECKENABLE_NUMBER_OF_CHECKS            2
205 
206 /** @}  end of VL53L1_CheckEnable_group */
207 
208 
209 /** @defgroup VL53L1_ThresholdMode_gropup Detection Functionality
210  *  @brief Defines the different functionalities for the detection feature
211  *  @{
212  */
213 typedef uint8_t VL53L1_ThresholdMode;
214 
215 #define VL53L1_THRESHOLD_CROSSED_LOW   \
216 	((VL53L1_ThresholdMode)  0)
217 	/*!< Trigger interrupt if value < thresh_low */
218 #define VL53L1_THRESHOLD_CROSSED_HIGH   \
219 	((VL53L1_ThresholdMode)  1)
220 	/*!< Trigger interrupt if value > thresh_high */
221 #define VL53L1_THRESHOLD_OUT_OF_WINDOW    \
222 	((VL53L1_ThresholdMode)  2)
223 	/*!< Trigger interrupt if value < thresh_low OR value > thresh_high */
224 #define VL53L1_THRESHOLD_IN_WINDOW        \
225 	((VL53L1_ThresholdMode)  3)
226 	/*!< Trigger interrupt if value > thresh_low AND value < thresh_high */
227 
228 /** @} end of VL53L1_ThresholdMode_gropup */
229 
230 /** @brief Defines parameters for Distance detection Thresholds configuration
231  */
232 typedef struct {
233 	VL53L1_ThresholdMode CrossMode;
234 	uint16_t High; /*!< Distance threshold high limit in mm */
235 	uint16_t Low;  /*!< Distance threshold low limit  in mm */
236 } VL53L1_DistanceThreshold_t;
237 
238 /** @brief Defines parameters for Signal rate detection Thresholds configuration
239  */
240 typedef struct {
241 	VL53L1_ThresholdMode CrossMode;
242 	FixPoint1616_t High; /*!< Signal rate threshold high limit */
243 	FixPoint1616_t Low;  /*!< Signal rate threshold low limit */
244 } VL53L1_RateThreshold_t;
245 
246 /** @defgroup VL53L1_DetectionMode_group Gpio Functionality
247  *  @brief Defines conditions leading to device's IT on GPIO
248  *  @{
249  */
250 typedef uint8_t VL53L1_DetectionMode;
251 
252 #define VL53L1_DETECTION_NORMAL_RUN   \
253 	((VL53L1_DetectionMode)  0)
254 	/*!< Trigger interrupt on new measurement regardless of threshold
255 	 * just like after a VL53L1_SetPresetMode() call
256 	 */
257 #define VL53L1_DETECTION_DISTANCE_ONLY   \
258 	((VL53L1_DetectionMode)  1)
259 	/*!< Trigger interrupt if "threshold event" occurs on distance */
260 #define VL53L1_DETECTION_RATE_ONLY   \
261 	((VL53L1_DetectionMode)  2)
262 	/*!< Trigger interrupt if "threshold event" occurs on signal rate */
263 #define VL53L1_DETECTION_DISTANCE_AND_RATE   \
264 	((VL53L1_DetectionMode)  3)
265 	/*!< Trigger interrupt if "threshold event" occurs on distance AND rate
266 	 */
267 #define VL53L1_DETECTION_DISTANCE_OR_RATE   \
268 	((VL53L1_DetectionMode)  4)
269 	/*!< Trigger interrupt if "threshold event" occurs on distance OR rate
270 	*/
271 
272 /** @} end of VL53L1_DetectionMode_group */
273 
274 /** @brief Defines parameters for User/object Detection configuration
275  */
276 typedef struct {
277 	VL53L1_DetectionMode DetectionMode;	/*!< See #VL53L1_DetectionMode*/
278 	uint8_t IntrNoTarget; /*!< 1 to trigger IT in case of no target found */
279 	VL53L1_DistanceThreshold_t Distance; /*!< limits in mm */
280 	VL53L1_RateThreshold_t Rate;/*!< limits in FixPoint1616_t */
281 } VL53L1_DetectionConfig_t;
282 
283 
284 /** @brief Defines all parameters for the device
285  */
286 typedef struct {
287 	VL53L1_PresetModes PresetMode;
288 	/*!< Defines the operating mode to be used for the next measure */
289 	VL53L1_DistanceModes DistanceMode;
290 	/*!< Defines the operating mode to be used for the next measure */
291 	VL53L1_DistanceModes InternalDistanceMode;
292 	/*!< Defines the internal operating mode to be used for the next
293 	 * measure
294 	 */
295 	VL53L1_DistanceModes NewDistanceMode;
296 	/*!< Defines the new operating mode to be programmed for the next
297 	 * measure
298 	 */
299 	uint32_t MeasurementTimingBudgetMicroSeconds;
300 	/*!< Defines the allowed total time for a single measurement */
301 	uint8_t LimitChecksEnable[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
302 	/*!< This Array store all the Limit Check enable for this device. */
303 	uint8_t LimitChecksStatus[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
304 	/*!< This Array stores all the Status of the check linked to last
305 	* measurement.
306 	*/
307 	FixPoint1616_t LimitChecksValue[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
308 	/*!< This Array stores all the Limit Check value for this device */
309 	FixPoint1616_t LimitChecksCurrent[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
310 	/*!< This Array stores all the Limit Check current value from latest
311 	 * ranging
312 	 */
313 } VL53L1_DeviceParameters_t;
314 
315 
316 /** @defgroup VL53L1_define_State_group Defines the current status of the device
317  *  Defines the current status of the device
318  *  @{
319  */
320 
321 typedef uint8_t VL53L1_State;
322 
323 #define VL53L1_STATE_POWERDOWN       ((VL53L1_State)  0)
324 	/*!< Device is in HW reset  */
325 #define VL53L1_STATE_WAIT_STATICINIT ((VL53L1_State)  1)
326 	/*!< Device is initialized and wait for static initialization  */
327 #define VL53L1_STATE_STANDBY         ((VL53L1_State)  2)
328 	/*!< Device is in Low power Standby mode   */
329 #define VL53L1_STATE_IDLE            ((VL53L1_State)  3)
330 	/*!< Device has been initialized and ready to do measurements  */
331 #define VL53L1_STATE_RUNNING         ((VL53L1_State)  4)
332 	/*!< Device is performing measurement */
333 #define VL53L1_STATE_RESET           ((VL53L1_State)  5)
334 	/*!< Soft reset has been run on Device */
335 #define VL53L1_STATE_UNKNOWN         ((VL53L1_State)  98)
336 	/*!< Device is in unknown state and need to be rebooted  */
337 #define VL53L1_STATE_ERROR           ((VL53L1_State)  99)
338 	/*!< Device is in error state and need to be rebooted  */
339 
340 /** @} VL53L1_define_State_group */
341 
342 
343 
344 /**
345  * @struct VL53L1_RangingMeasurementData_t
346  * @brief Single Range measurement data.
347  */
348 typedef struct {
349 	uint32_t TimeStamp;
350 		/*!< 32-bit time stamp.
351 		 * @warning Not yet implemented
352 		 */
353 
354 	uint8_t StreamCount;
355 		/*!< 8-bit Stream Count. */
356 
357 	uint8_t RangeQualityLevel;
358 		/*!< indicate a quality level in percentage from 0 to 100
359 		 * @warning Not yet implemented
360 		 */
361 
362 	FixPoint1616_t SignalRateRtnMegaCps;
363 		/*!< Return signal rate (MCPS)\n these is a 16.16 fix point
364 		 *  value, which is effectively a measure of target
365 		 *   reflectance.
366 		 */
367 
368 	FixPoint1616_t AmbientRateRtnMegaCps;
369 		/*!< Return ambient rate (MCPS)\n these is a 16.16 fix point
370 		 *  value, which is effectively a measure of the ambien
371 		 *  t light.
372 		 */
373 
374 	uint16_t EffectiveSpadRtnCount;
375 		/*!< Return the effective SPAD count for the return signal.
376 		 *  To obtain Real value it should be divided by 256
377 		 */
378 
379 	FixPoint1616_t SigmaMilliMeter;
380 		/*!< Return the Sigma value in millimeter */
381 
382 	int16_t RangeMilliMeter;
383 		/*!< range distance in millimeter. This should be between
384 		 *  RangeMinMilliMeter and RangeMaxMilliMeter
385 		 */
386 
387 	uint8_t RangeFractionalPart;
388 		/*!< Fractional part of range distance. Final value is a
389 		 *  RangeMilliMeter + RangeFractionalPart/256.
390 		 *  @warning Not yet implemented
391 		 */
392 
393 	uint8_t RangeStatus;
394 		/*!< Range Status for the current measurement. This is device
395 		 *  dependent. Value = 0 means value is valid.
396 		 */
397 } VL53L1_RangingMeasurementData_t;
398 
399 
400 
401 /** @brief Defines User Zone(ROI) parameters
402  *
403  */
404 typedef struct {
405 
406 	uint8_t   TopLeftX;   /*!< Top Left x coordinate:  0-15 range */
407 	uint8_t   TopLeftY;   /*!< Top Left y coordinate:  0-15 range */
408 	uint8_t   BotRightX;  /*!< Bot Right x coordinate: 0-15 range */
409 	uint8_t   BotRightY;  /*!< Bot Right y coordinate: 0-15 range */
410 
411 } VL53L1_UserRoi_t;
412 
413 
414 /** @brief Defines ROI configuration parameters
415  *
416  *  Support up a max of 16 zones, Each Zone has the same size
417  *
418  */
419 
420 /**
421  * @struct VL53L1_CustomerNvmManaged_t
422  *
423  */
424 
425 typedef struct {
426 	uint8_t   global_config__spad_enables_ref_0;
427 	uint8_t   global_config__spad_enables_ref_1;
428 	uint8_t   global_config__spad_enables_ref_2;
429 	uint8_t   global_config__spad_enables_ref_3;
430 	uint8_t   global_config__spad_enables_ref_4;
431 	uint8_t   global_config__spad_enables_ref_5;
432 	uint8_t   global_config__ref_en_start_select;
433 	uint8_t   ref_spad_man__num_requested_ref_spads;
434 	uint8_t   ref_spad_man__ref_location;
435 	uint32_t  algo__crosstalk_compensation_plane_offset_kcps;
436 	int16_t   algo__crosstalk_compensation_x_plane_gradient_kcps;
437 	int16_t   algo__crosstalk_compensation_y_plane_gradient_kcps;
438 	uint16_t  ref_spad_char__total_rate_target_mcps;
439 	int16_t   algo__part_to_part_range_offset_mm;
440 	int16_t   mm_config__inner_offset_mm;
441 	int16_t   mm_config__outer_offset_mm;
442 } VL53L1_CustomerNvmManaged_t;
443 
444 /**
445  * @struct  VL53L1_CalibrationData_t
446  * @brief   Structure for storing the Calibration Data
447  *
448  */
449 
450 typedef struct {
451 
452 	uint32_t                             struct_version;
453 	VL53L1_CustomerNvmManaged_t          customer;
454 	VL53L1_additional_offset_cal_data_t  add_off_cal_data;
455 	VL53L1_optical_centre_t              optical_centre;
456 	VL53L1_gain_calibration_data_t       gain_cal;
457 	VL53L1_cal_peak_rate_map_t           cal_peak_rate_map;
458 
459 } VL53L1_CalibrationData_t;
460 
461 #define VL53L1_ADDITIONAL_CALIBRATION_DATA_STRUCT_VERSION  0x10
462 /** VL53L1 additional Calibration Data struct version final struct version
463  * is given by adding it to  VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION
464  */
465 
466 #define VL53L1_CALIBRATION_DATA_STRUCT_VERSION \
467 		(VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION + \
468 		VL53L1_ADDITIONAL_CALIBRATION_DATA_STRUCT_VERSION)
469 /* VL53L1 Calibration Data struct version */
470 
471 /**
472  * @struct  VL53L1_AdditionalData_t
473  * @brief   Structure for storing the Additional Data
474  *
475  */
476 typedef VL53L1_additional_data_t VL53L1_AdditionalData_t;
477 
478 
479 typedef uint8_t VL53L1_SequenceStepId;
480 
481 #define	 VL53L1_SEQUENCESTEP_VHV		 ((VL53L1_SequenceStepId) 0)
482 /*!<VHV. */
483 #define	 VL53L1_SEQUENCESTEP_PHASECAL		 ((VL53L1_SequenceStepId) 1)
484 /*!<Phase Calibration. */
485 #define	 VL53L1_SEQUENCESTEP_REFPHASE		 ((VL53L1_SequenceStepId) 2)
486 /*!<Reference Phase. */
487 #define	 VL53L1_SEQUENCESTEP_DSS1		 ((VL53L1_SequenceStepId) 3)
488 /*!<DSS1. */
489 #define	 VL53L1_SEQUENCESTEP_DSS2		 ((VL53L1_SequenceStepId) 4)
490 /*!<DSS2. */
491 #define	 VL53L1_SEQUENCESTEP_MM1		 ((VL53L1_SequenceStepId) 5)
492 /*!<Mode Mitigation 1. */
493 #define	 VL53L1_SEQUENCESTEP_MM2		 ((VL53L1_SequenceStepId) 6)
494 /*!<Mode Mitigation 2. */
495 #define	 VL53L1_SEQUENCESTEP_RANGE		 ((VL53L1_SequenceStepId) 7)
496 /*!<Final Range step. */
497 
498 #define	 VL53L1_SEQUENCESTEP_NUMBER_OF_ITEMS			 8
499 /*!<Number of Sequence Step Managed by the API. */
500 
501 
502 /** @defgroup VL53L1_define_RangeStatus_group Defines the Range Status
503  *	@{
504  */
505 #define	 VL53L1_RANGESTATUS_RANGE_VALID				0
506 /*!<The Range is valid. */
507 #define	 VL53L1_RANGESTATUS_SIGMA_FAIL				1
508 /*!<Sigma Fail. */
509 #define	 VL53L1_RANGESTATUS_SIGNAL_FAIL				2
510 /*!<Signal fail. */
511 #define	 VL53L1_RANGESTATUS_RANGE_VALID_MIN_RANGE_CLIPPED	3
512 /*!<Target is below minimum detection threshold. */
513 #define	 VL53L1_RANGESTATUS_OUTOFBOUNDS_FAIL			4
514 /*!<Phase out of valid limits -  different to a wrap exit. */
515 #define	 VL53L1_RANGESTATUS_HARDWARE_FAIL			5
516 /*!<Hardware fail. */
517 #define	 VL53L1_RANGESTATUS_RANGE_VALID_NO_WRAP_CHECK_FAIL	6
518 /*!<The Range is valid but the wraparound check has not been done. */
519 #define	VL53L1_RANGESTATUS_WRAP_TARGET_FAIL			7
520 /*!<Wrapped target - no matching phase in other VCSEL period timing. */
521 #define	VL53L1_RANGESTATUS_PROCESSING_FAIL			8
522 /*!<Internal algo underflow or overflow in lite ranging. */
523 #define	VL53L1_RANGESTATUS_XTALK_SIGNAL_FAIL			9
524 /*!<Specific to lite ranging. */
525 #define	VL53L1_RANGESTATUS_SYNCRONISATION_INT			10
526 /*!<1st interrupt when starting ranging in back to back mode. Ignore data. */
527 #define	VL53L1_RANGESTATUS_RANGE_VALID_MERGED_PULSE		11
528 /*!<All Range ok but object is result of multiple pulses merging together.
529  * Used by RQL for merged pulse detection
530  */
531 #define	VL53L1_RANGESTATUS_TARGET_PRESENT_LACK_OF_SIGNAL	12
532 /*!<Used  by RQL  as different to phase fail. */
533 #define	VL53L1_RANGESTATUS_MIN_RANGE_FAIL			13
534 /*!<User ROI input is not valid e.g. beyond SPAD Array.*/
535 #define	VL53L1_RANGESTATUS_RANGE_INVALID			14
536 /*!<lld returned valid range but negative value ! */
537 #define	 VL53L1_RANGESTATUS_NONE				255
538 /*!<No Update. */
539 
540 /** @} VL53L1_define_RangeStatus_group */
541 
542 
543 /** @brief  Contains the Internal data of the Bare Driver
544  */
545 
546 typedef struct {
547 	VL53L1_LLDriverData_t   LLData;
548 	/*!< Low Level Driver data structure */
549 
550 	VL53L1_LLDriverResults_t llresults;
551 	/*!< Low Level Driver data structure */
552 
553 	VL53L1_State      PalState; /* Store the pal state */
554 	VL53L1_DeviceParameters_t CurrentParameters;
555 	/*!< Current Device Parameter */
556 
557 } VL53L1_DevData_t;
558 
559 
560 /* MACRO Definitions */
561 /** @defgroup VL53L1_define_GeneralMacro_group General Macro Defines
562  *  General Macro Defines
563  *  @{
564  */
565 
566 /* Defines */
567 #define VL53L1_SETPARAMETERFIELD(Dev, field, value) \
568 	(VL53L1DevDataSet(Dev, CurrentParameters.field, value))
569 
570 #define VL53L1_GETPARAMETERFIELD(Dev, field, variable) \
571 	(variable = VL53L1DevDataGet(Dev, CurrentParameters).field)
572 
573 
574 #define VL53L1_SETARRAYPARAMETERFIELD(Dev, field, index, value) \
575 	(VL53L1DevDataSet(Dev, CurrentParameters.field[index], value))
576 
577 #define VL53L1_GETARRAYPARAMETERFIELD(Dev, field, index, variable) \
578 	(variable = VL53L1DevDataGet(Dev, CurrentParameters).field[index])
579 
580 
581 #define VL53L1_SETDEVICESPECIFICPARAMETER(Dev, field, value) \
582 	(VL53L1DevDataSet(Dev, DeviceSpecificParameters.field, value))
583 
584 #define VL53L1_GETDEVICESPECIFICPARAMETER(Dev, field) \
585 	(VL53L1DevDataGet(Dev, DeviceSpecificParameters).field)
586 
587 
588 #define VL53L1_FIXPOINT1616TOFIXPOINT44(Value) \
589 	(uint16_t)((Value>>12)&0xFFFF)
590 #define VL53L1_FIXPOINT44TOFIXPOINT1616(Value) \
591 	(FixPoint1616_t)((uint32_t)Value<<12)
592 
593 #define VL53L1_FIXPOINT1616TOFIXPOINT72(Value) \
594 	(uint16_t)((Value>>14)&0xFFFF)
595 #define VL53L1_FIXPOINT72TOFIXPOINT1616(Value) \
596 	(FixPoint1616_t)((uint32_t)Value<<14)
597 
598 #define VL53L1_FIXPOINT1616TOFIXPOINT97(Value) \
599 	(uint16_t)((Value>>9)&0xFFFF)
600 #define VL53L1_FIXPOINT97TOFIXPOINT1616(Value) \
601 	(FixPoint1616_t)((uint32_t)Value<<9)
602 
603 #define VL53L1_FIXPOINT1616TOFIXPOINT88(Value) \
604 	(uint16_t)((Value>>8)&0xFFFF)
605 #define VL53L1_FIXPOINT88TOFIXPOINT1616(Value) \
606 	(FixPoint1616_t)((uint32_t)Value<<8)
607 
608 #define VL53L1_FIXPOINT1616TOFIXPOINT412(Value) \
609 	(uint16_t)((Value>>4)&0xFFFF)
610 #define VL53L1_FIXPOINT412TOFIXPOINT1616(Value) \
611 	(FixPoint1616_t)((uint32_t)Value<<4)
612 
613 #define VL53L1_FIXPOINT1616TOFIXPOINT313(Value) \
614 	(uint16_t)((Value>>3)&0xFFFF)
615 #define VL53L1_FIXPOINT313TOFIXPOINT1616(Value) \
616 	(FixPoint1616_t)((uint32_t)Value<<3)
617 
618 #define VL53L1_FIXPOINT1616TOFIXPOINT08(Value) \
619 	(uint8_t)((Value>>8)&0x00FF)
620 #define VL53L1_FIXPOINT08TOFIXPOINT1616(Value) \
621 	(FixPoint1616_t)((uint32_t)Value<<8)
622 
623 #define VL53L1_FIXPOINT1616TOFIXPOINT53(Value) \
624 	(uint8_t)((Value>>13)&0x00FF)
625 #define VL53L1_FIXPOINT53TOFIXPOINT1616(Value) \
626 	(FixPoint1616_t)((uint32_t)Value<<13)
627 
628 #define VL53L1_FIXPOINT1616TOFIXPOINT102(Value) \
629 	(uint16_t)((Value>>14)&0x0FFF)
630 #define VL53L1_FIXPOINT102TOFIXPOINT1616(Value) \
631 	(FixPoint1616_t)((uint32_t)Value<<14)
632 
633 #define VL53L1_FIXPOINT1616TOFIXPOINT142(Value) \
634 	(uint16_t)((Value>>14)&0xFFFF)
635 #define VL53L1_FIXPOINT142TOFIXPOINT1616(Value) \
636 	(FixPoint1616_t)((uint32_t)Value<<14)
637 
638 #define VL53L1_FIXPOINT1616TOFIXPOINT160(Value) \
639 	(uint16_t)((Value>>16)&0xFFFF)
640 #define VL53L1_FIXPOINT160TOFIXPOINT1616(Value) \
641 	(FixPoint1616_t)((uint32_t)Value<<16)
642 
643 #define VL53L1_MAKEUINT16(lsb, msb) (uint16_t)((((uint16_t)msb)<<8) + \
644 		(uint16_t)lsb)
645 
646 #ifndef SUPPRESS_UNUSED_WARNING
647 #define SUPPRESS_UNUSED_WARNING(x) ((void) (x))
648 #endif
649 
650 #define CHECK_ERROR_GO_ENDFUNC do {\
651 		if (Status != VL53L1_ERROR_NONE) \
652 			goto ENDFUNC; \
653 	} while (0)
654 
655 /** @} VL53L1_define_GeneralMacro_group */
656 
657 /** @} VL53L1_globaldefine_group */
658 
659 
660 
661 #ifdef __cplusplus
662 }
663 #endif
664 
665 
666 #endif /* _VL53L1_DEF_H_ */
667