VL53L0X API Specification: vl53l0x_def.h Source File

VL53L0X API

vl53l0x_def.h
Go to the documentation of this file.
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 
37 #ifndef _VL53L0X_DEF_H_
38 #define _VL53L0X_DEF_H_
39 
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
52 #define VL53L0X10_SPECIFICATION_VER_MAJOR 1
53 
54 #define VL53L0X10_SPECIFICATION_VER_MINOR 2
55 
56 #define VL53L0X10_SPECIFICATION_VER_SUB 7
57 
58 #define VL53L0X10_SPECIFICATION_VER_REVISION 1440
59 
61 #define VL53L0X10_IMPLEMENTATION_VER_MAJOR 1
62 
63 #define VL53L0X10_IMPLEMENTATION_VER_MINOR 0
64 
65 #define VL53L0X10_IMPLEMENTATION_VER_SUB 9
66 
67 #define VL53L0X10_IMPLEMENTATION_VER_REVISION 3673
68 
70 #define VL53L0X_SPECIFICATION_VER_MAJOR 1
71 
72 #define VL53L0X_SPECIFICATION_VER_MINOR 2
73 
74 #define VL53L0X_SPECIFICATION_VER_SUB 7
75 
76 #define VL53L0X_SPECIFICATION_VER_REVISION 1440
77 
79 #define VL53L0X_IMPLEMENTATION_VER_MAJOR 1
80 
81 #define VL53L0X_IMPLEMENTATION_VER_MINOR 0
82 
83 #define VL53L0X_IMPLEMENTATION_VER_SUB 2
84 
85 #define VL53L0X_IMPLEMENTATION_VER_REVISION 4823
86 #define VL53L0X_DEFAULT_MAX_LOOP 2000
87 #define VL53L0X_MAX_STRING_LENGTH 32
88 
89 
90 #include "vl53l0x_device.h"
91 #include "vl53l0x_types.h"
92 
93 
94 /****************************************
95  * PRIVATE define do not edit
96  ****************************************/
97 
100 typedef struct {
106 
107 
110 typedef struct {
115  char ProductId[VL53L0X_MAX_STRING_LENGTH];
124 
125 
132 
133 #define VL53L0X_ERROR_NONE ((VL53L0X_Error) 0)
134 #define VL53L0X_ERROR_CALIBRATION_WARNING ((VL53L0X_Error) -1)
135 
139 #define VL53L0X_ERROR_MIN_CLIPPED ((VL53L0X_Error) -2)
140 
142 #define VL53L0X_ERROR_UNDEFINED ((VL53L0X_Error) -3)
143 
144 #define VL53L0X_ERROR_INVALID_PARAMS ((VL53L0X_Error) -4)
145 
146 #define VL53L0X_ERROR_NOT_SUPPORTED ((VL53L0X_Error) -5)
147 
148 #define VL53L0X_ERROR_RANGE_ERROR ((VL53L0X_Error) -6)
149 
150 #define VL53L0X_ERROR_TIME_OUT ((VL53L0X_Error) -7)
151 
152 #define VL53L0X_ERROR_MODE_NOT_SUPPORTED ((VL53L0X_Error) -8)
153 
154 #define VL53L0X_ERROR_BUFFER_TOO_SMALL ((VL53L0X_Error) -9)
155 
156 #define VL53L0X_ERROR_GPIO_NOT_EXISTING ((VL53L0X_Error) -10)
157 
158 #define VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED ((VL53L0X_Error) -11)
159 
160 #define VL53L0X_ERROR_INTERRUPT_NOT_CLEARED ((VL53L0X_Error) -12)
161 
162 #define VL53L0X_ERROR_CONTROL_INTERFACE ((VL53L0X_Error) -20)
163 
164 #define VL53L0X_ERROR_INVALID_COMMAND ((VL53L0X_Error) -30)
165 
167 #define VL53L0X_ERROR_DIVISION_BY_ZERO ((VL53L0X_Error) -40)
168 
169 #define VL53L0X_ERROR_REF_SPAD_INIT ((VL53L0X_Error) -50)
170 
171 #define VL53L0X_ERROR_NOT_IMPLEMENTED ((VL53L0X_Error) -99)
172 
182 
183 #define VL53L0X_DEVICEMODE_SINGLE_RANGING ((VL53L0X_DeviceModes) 0)
184 #define VL53L0X_DEVICEMODE_CONTINUOUS_RANGING ((VL53L0X_DeviceModes) 1)
185 #define VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM ((VL53L0X_DeviceModes) 2)
186 #define VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING ((VL53L0X_DeviceModes) 3)
187 #define VL53L0X_DEVICEMODE_SINGLE_ALS ((VL53L0X_DeviceModes) 10)
188 #define VL53L0X_DEVICEMODE_GPIO_DRIVE ((VL53L0X_DeviceModes) 20)
189 #define VL53L0X_DEVICEMODE_GPIO_OSC ((VL53L0X_DeviceModes) 21)
190  /* ... Modes to be added depending on device */
200 
201 #define VL53L0X_HISTOGRAMMODE_DISABLED ((VL53L0X_HistogramModes) 0)
202 
203 #define VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY ((VL53L0X_HistogramModes) 1)
204 
205 #define VL53L0X_HISTOGRAMMODE_RETURN_ONLY ((VL53L0X_HistogramModes) 2)
206 
207 #define VL53L0X_HISTOGRAMMODE_BOTH ((VL53L0X_HistogramModes) 3)
208 
209  /* ... Modes to be added depending on device */
219 
220 #define VL53L0X_POWERMODE_STANDBY_LEVEL1 ((VL53L0X_PowerModes) 0)
221 
222 #define VL53L0X_POWERMODE_STANDBY_LEVEL2 ((VL53L0X_PowerModes) 1)
223 
224 #define VL53L0X_POWERMODE_IDLE_LEVEL1 ((VL53L0X_PowerModes) 2)
225 
226 #define VL53L0X_POWERMODE_IDLE_LEVEL2 ((VL53L0X_PowerModes) 3)
227 
234 typedef struct {
235  VL53L0X_DeviceModes DeviceMode;
237  VL53L0X_HistogramModes HistogramMode;
266 
267 
274 
275 #define VL53L0X_STATE_POWERDOWN ((VL53L0X_State) 0)
276 
277 #define VL53L0X_STATE_WAIT_STATICINIT ((VL53L0X_State) 1)
278 
279 #define VL53L0X_STATE_STANDBY ((VL53L0X_State) 2)
280 
281 #define VL53L0X_STATE_IDLE ((VL53L0X_State) 3)
282 
283 #define VL53L0X_STATE_RUNNING ((VL53L0X_State) 4)
284 
285 #define VL53L0X_STATE_UNKNOWN ((VL53L0X_State) 98)
286 
287 #define VL53L0X_STATE_ERROR ((VL53L0X_State) 99)
288 
295 typedef struct {
301 
306 typedef struct {
344 
345 
346 #define VL53L0X_HISTOGRAM_BUFFER_SIZE 24
347 
352 typedef struct {
353  /* Histogram Measurement data */
367 
368 #define VL53L0X_REF_SPAD_BUFFER_SIZE 6
369 
374 typedef struct {
380 
381 typedef struct {
382  FixPoint1616_t OscFrequencyMHz; /* Frequency used */
383 
385  /* last encoded Time out used for timing budget*/
386 
388  /* store the functionality of the GPIO: pin0 */
389 
409  uint8_t ReadDataFromDeviceDone; /* Indicate if read from device has
410  been done (==1) or not (==0) */
411  uint8_t ModuleId; /* Module ID */
412  uint8_t Revision; /* test Revision */
413  char ProductId[VL53L0X_MAX_STRING_LENGTH];
414  /* Product Identifier String */
415  uint8_t ReferenceSpadCount; /* used for ref spad management */
416  uint8_t ReferenceSpadType; /* used for ref spad management */
417  uint8_t RefSpadsInitialised; /* reports if ref spads are initialised. */
424 
433 typedef struct {
454  VL53L0X_State PalState;
456  VL53L0X_PowerModes PowerMode;
489 
490 
497 
498 #define VL53L0X_INTERRUPTPOLARITY_LOW ((VL53L0X_InterruptPolarity) 0)
499 
500 #define VL53L0X_INTERRUPTPOLARITY_HIGH ((VL53L0X_InterruptPolarity) 1)
501 
511 
512 #define VL53L0X_VCSEL_PERIOD_PRE_RANGE ((VL53L0X_VcselPeriod) 0)
513 
514 #define VL53L0X_VCSEL_PERIOD_FINAL_RANGE ((VL53L0X_VcselPeriod) 1)
515 
525 typedef struct {
532 
541 
542 #define VL53L0X_SEQUENCESTEP_TCC ((VL53L0X_VcselPeriod) 0)
543 
544 #define VL53L0X_SEQUENCESTEP_DSS ((VL53L0X_VcselPeriod) 1)
545 
546 #define VL53L0X_SEQUENCESTEP_MSRC ((VL53L0X_VcselPeriod) 2)
547 
548 #define VL53L0X_SEQUENCESTEP_PRE_RANGE ((VL53L0X_VcselPeriod) 3)
549 
550 #define VL53L0X_SEQUENCESTEP_FINAL_RANGE ((VL53L0X_VcselPeriod) 4)
551 
553 #define VL53L0X_SEQUENCESTEP_NUMBER_OF_CHECKS 5
554 
559 /* MACRO Definitions */
565 /* Defines */
566 #define VL53L0X_SETPARAMETERFIELD(Dev, field, value) \
567  PALDevDataSet(Dev, CurrentParameters.field, value)
568 
569 #define VL53L0X_GETPARAMETERFIELD(Dev, field, variable) \
570  variable = PALDevDataGet(Dev, CurrentParameters).field
571 
572 
573 #define VL53L0X_SETARRAYPARAMETERFIELD(Dev, field, index, value) \
574  PALDevDataSet(Dev, CurrentParameters.field[index], value)
575 
576 #define VL53L0X_GETARRAYPARAMETERFIELD(Dev, field, index, variable) \
577  variable = PALDevDataGet(Dev, CurrentParameters).field[index]
578 
579 
580 #define VL53L0X_SETDEVICESPECIFICPARAMETER(Dev, field, value) \
581  PALDevDataSet(Dev, DeviceSpecificParameters.field, value)
582 
583 #define VL53L0X_GETDEVICESPECIFICPARAMETER(Dev, field) \
584  PALDevDataGet(Dev, DeviceSpecificParameters).field
585 
586 
587 #define VL53L0X_FIXPOINT1616TOFIXPOINT97(Value) \
588  (uint16_t)((Value>>9)&0xFFFF)
589 #define VL53L0X_FIXPOINT97TOFIXPOINT1616(Value) \
590  (FixPoint1616_t)(Value<<9)
591 
592 #define VL53L0X_FIXPOINT1616TOFIXPOINT88(Value) \
593  (uint16_t)((Value>>8)&0xFFFF)
594 #define VL53L0X_FIXPOINT88TOFIXPOINT1616(Value) \
595  (FixPoint1616_t)(Value<<8)
596 
597 #define VL53L0X_FIXPOINT1616TOFIXPOINT412(Value) \
598  (uint16_t)((Value>>4)&0xFFFF)
599 #define VL53L0X_FIXPOINT412TOFIXPOINT1616(Value) \
600  (FixPoint1616_t)(Value<<4)
601 
602 #define VL53L0X_FIXPOINT1616TOFIXPOINT313(Value) \
603  (uint16_t)((Value>>3)&0xFFFF)
604 #define VL53L0X_FIXPOINT313TOFIXPOINT1616(Value) \
605  (FixPoint1616_t)(Value<<3)
606 
607 #define VL53L0X_FIXPOINT1616TOFIXPOINT08(Value) \
608  (uint8_t)((Value>>8)&0x00FF)
609 #define VL53L0X_FIXPOINT08TOFIXPOINT1616(Value) \
610  (FixPoint1616_t)(Value<<8)
611 
612 #define VL53L0X_FIXPOINT1616TOFIXPOINT53(Value) \
613  (uint8_t)((Value>>13)&0x00FF)
614 #define VL53L0X_FIXPOINT53TOFIXPOINT1616(Value) \
615  (FixPoint1616_t)(Value<<13)
616 
617 #define VL53L0X_FIXPOINT1616TOFIXPOINT102(Value) \
618  (uint16_t)((Value>>14)&0x0FFF)
619 #define VL53L0X_FIXPOINT102TOFIXPOINT1616(Value) \
620  (FixPoint1616_t)(Value<<12)
621 
622 #define VL53L0X_MAKEUINT16(lsb, msb) (uint16_t)((((uint16_t)msb)<<8) + \
623  (uint16_t)lsb)
624 
635 #ifdef __cplusplus
636 }
637 #endif
638 
639 
640 #endif /* _VL53L0X_DEF_H_ */
VL53L0X_SpadData_t SpadData
Definition: vl53l0x_def.h:448
VL53L0X_State PalState
Definition: vl53l0x_def.h:454
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l0x_types.h:80
#define VL53L0X_MAX_STRING_LENGTH
Definition: vl53l0x_def.h:87
Structure containing the Dmax computation parameters and data.
Definition: vl53l0x_def.h:295
uint8_t StopVariable
Definition: vl53l0x_def.h:466
uint8_t ProductRevisionMinor
Definition: vl53l0x_def.h:121
int32_t Part2PartOffsetNVMMicroMeter
Definition: vl53l0x_def.h:436
Defines all parameters for the device.
Definition: vl53l0x_def.h:234
uint8_t VL53L0X_SequenceStepId
Definition: vl53l0x_def.h:540
Defines the parameters of the Get Device Info Functions.
Definition: vl53l0x_def.h:110
uint16_t targetRefRate
Definition: vl53l0x_def.h:468
uint8_t VL53L0X_State
Definition: vl53l0x_def.h:273
VL53L0X_HistogramMeasurementData_t LastHistogramMeasure
Definition: vl53l0x_def.h:444
VL53L0X_GpioFunctionality Pin0GpioFunctionality
Definition: vl53l0x_def.h:387
Spad Configuration Data.
Definition: vl53l0x_def.h:374
uint8_t RangeFractionalEnable
Definition: vl53l0x_def.h:452
uint8_t UseInternalTuningSettings
Definition: vl53l0x_def.h:479
uint8_t * pTuningSettingsPointer
Definition: vl53l0x_def.h:477
uint32_t MeasurementTimingBudgetMicroSeconds
Definition: vl53l0x_def.h:240
uint16_t DmaxCalRangeMilliMeter
Definition: vl53l0x_def.h:483
VL53L0X_PowerModes PowerMode
Definition: vl53l0x_def.h:456
int32_t AmbTuningWindowFactor_K
Definition: vl53l0x_def.h:296
FixPoint1616_t SigmaEstimate
Definition: vl53l0x_def.h:470
int32_t Part2PartOffsetAdjustmentNVMMicroMeter
Definition: vl53l0x_def.h:438
uint8_t VL53L0X_InterruptPolarity
Definition: vl53l0x_def.h:496
#define VL53L0X_REF_SPAD_BUFFER_SIZE
Definition: vl53l0x_def.h:368
uint16_t LinearityCorrectiveGain
Definition: vl53l0x_def.h:481
uint16_t XTalkCompensationRangeMilliMeter
Definition: vl53l0x_def.h:247
VL53L0X_DeviceError ErrorStatus
Definition: vl53l0x_def.h:363
FixPoint1616_t XTalkCompensationRateMegaCps
Definition: vl53l0x_def.h:249
signed char int8_t
Typedef defining 8 bit char type.
uint8_t VL53L0X_GpioFunctionality
uint8_t VL53L0X_VcselPeriod
Definition: vl53l0x_def.h:510
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
Definition: vl53l0x_types.h:85
uint16_t SigmaEstEffAmbWidth
Definition: vl53l0x_def.h:463
FixPoint1616_t SignalEstimate
Definition: vl53l0x_def.h:473
Defines the parameters of the Get Version Functions.
Definition: vl53l0x_def.h:100
VL53L0X_DeviceSpecificParameters_t DeviceSpecificParameters
Definition: vl53l0x_def.h:446
VL53L0X PAL device ST private data structure End user should never access any of these field directl...
Definition: vl53l0x_def.h:433
FixPoint1616_t AmbientRateRtnMegaCps
Definition: vl53l0x_def.h:324
uint32_t InterMeasurementPeriodMilliSeconds
Definition: vl53l0x_def.h:242
uint16_t SigmaEstEffPulseWidth
Definition: vl53l0x_def.h:460
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l0x_types.h:75
uint8_t VL53L0X_DeviceError
VL53L0X_DMaxData_t DMaxData
Definition: vl53l0x_def.h:434
uint32_t FixPoint1616_t
use where fractional values are expected
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l0x_types.h:95
uint8_t ProductRevisionMajor
Definition: vl53l0x_def.h:119
uint8_t VL53L0X_PowerModes
Definition: vl53l0x_def.h:218
#define VL53L0X_HISTOGRAM_BUFFER_SIZE
Definition: vl53l0x_def.h:346
VL53L0X_HistogramModes HistogramMode
Definition: vl53l0x_def.h:237
#define VL53L0X_CHECKENABLE_NUMBER_OF_CHECKS
uint8_t VL53L0X_HistogramModes
Definition: vl53l0x_def.h:199
VL53L0X_DeviceModes DeviceMode
Definition: vl53l0x_def.h:235
uint16_t SigmaEstRefArray
Definition: vl53l0x_def.h:458
uint8_t SequenceConfig
Definition: vl53l0x_def.h:450
int32_t RetSignalAt0mm
Definition: vl53l0x_def.h:298
VL53L0X_RangingMeasurementData_t LastRangeMeasure
Definition: vl53l0x_def.h:442
uint8_t VL53L0X_DeviceModes
Definition: vl53l0x_def.h:181
int8_t VL53L0X_Error
Definition: vl53l0x_def.h:131
FixPoint1616_t DmaxCalSignalRateRtnMegaCps
Definition: vl53l0x_def.h:485
VL53L0X types definition.
FixPoint1616_t LastSignalRefMcps
Definition: vl53l0x_def.h:475
VL53L0X_DeviceParameters_t CurrentParameters
Definition: vl53l0x_def.h:440