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 #endif 44 45 /** @defgroup VL53L0X_globaldefine_group VL53L0X Defines 46 * @brief VL53L0X Defines 47 * @{ 48 */ 49 50 51 /** PAL SPECIFICATION major version */ 52 #define VL53L0X10_SPECIFICATION_VER_MAJOR 1 53 /** PAL SPECIFICATION minor version */ 54 #define VL53L0X10_SPECIFICATION_VER_MINOR 2 55 /** PAL SPECIFICATION sub version */ 56 #define VL53L0X10_SPECIFICATION_VER_SUB 7 57 /** PAL SPECIFICATION sub version */ 58 #define VL53L0X10_SPECIFICATION_VER_REVISION 1440 59 60 /** VL53L0X PAL IMPLEMENTATION major version */ 61 #define VL53L0X10_IMPLEMENTATION_VER_MAJOR 1 62 /** VL53L0X PAL IMPLEMENTATION minor version */ 63 #define VL53L0X10_IMPLEMENTATION_VER_MINOR 0 64 /** VL53L0X PAL IMPLEMENTATION sub version */ 65 #define VL53L0X10_IMPLEMENTATION_VER_SUB 9 66 /** VL53L0X PAL IMPLEMENTATION sub version */ 67 #define VL53L0X10_IMPLEMENTATION_VER_REVISION 3673 68 69 /** PAL SPECIFICATION major version */ 70 #define VL53L0X_SPECIFICATION_VER_MAJOR 1 71 /** PAL SPECIFICATION minor version */ 72 #define VL53L0X_SPECIFICATION_VER_MINOR 2 73 /** PAL SPECIFICATION sub version */ 74 #define VL53L0X_SPECIFICATION_VER_SUB 7 75 /** PAL SPECIFICATION sub version */ 76 #define VL53L0X_SPECIFICATION_VER_REVISION 1440 77 78 /** VL53L0X PAL IMPLEMENTATION major version */ 79 #define VL53L0X_IMPLEMENTATION_VER_MAJOR 1 80 /** VL53L0X PAL IMPLEMENTATION minor version */ 81 #define VL53L0X_IMPLEMENTATION_VER_MINOR 0 82 /** VL53L0X PAL IMPLEMENTATION sub version */ 83 #define VL53L0X_IMPLEMENTATION_VER_SUB 2 84 /** VL53L0X PAL IMPLEMENTATION sub version */ 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 98 /** @brief Defines the parameters of the Get Version Functions 99 */ 100 typedef struct { 101 uint32_t revision; /*!< revision number */ 102 uint8_t major; /*!< major number */ 103 uint8_t minor; /*!< minor number */ 104 uint8_t build; /*!< build number */ 105 } VL53L0X_Version_t; 106 107 108 /** @brief Defines the parameters of the Get Device Info Functions 109 */ 110 typedef struct { 111 char Name[VL53L0X_MAX_STRING_LENGTH]; 112 /*!< Name of the Device e.g. Left_Distance */ 113 char Type[VL53L0X_MAX_STRING_LENGTH]; 114 /*!< Type of the Device e.g VL53L0X */ 115 char ProductId[VL53L0X_MAX_STRING_LENGTH]; 116 /*!< Product Identifier String */ 117 uint8_t ProductType; 118 /*!< Product Type, VL53L0X = 1, VL53L1 = 2 */ 119 uint8_t ProductRevisionMajor; 120 /*!< Product revision major */ 121 uint8_t ProductRevisionMinor; 122 /*!< Product revision minor */ 123 } VL53L0X_DeviceInfo_t; 124 125 126 /** @defgroup VL53L0X_define_Error_group Error and Warning code returned by API 127 * The following DEFINE are used to identify the PAL ERROR 128 * @{ 129 */ 130 131 typedef int8_t VL53L0X_Error; 132 133 #define VL53L0X_ERROR_NONE ((VL53L0X_Error) 0) 134 #define VL53L0X_ERROR_CALIBRATION_WARNING ((VL53L0X_Error) -1) 135 /*!< Warning invalid calibration data may be in used 136 \a VL53L0X_InitData() 137 \a VL53L0X_GetOffsetCalibrationData 138 \a VL53L0X_SetOffsetCalibrationData */ 139 #define VL53L0X_ERROR_MIN_CLIPPED ((VL53L0X_Error) -2) 140 /*!< Warning parameter passed was clipped to min before to be applied */ 141 142 #define VL53L0X_ERROR_UNDEFINED ((VL53L0X_Error) -3) 143 /*!< Unqualified error */ 144 #define VL53L0X_ERROR_INVALID_PARAMS ((VL53L0X_Error) -4) 145 /*!< Parameter passed is invalid or out of range */ 146 #define VL53L0X_ERROR_NOT_SUPPORTED ((VL53L0X_Error) -5) 147 /*!< Function is not supported in current mode or configuration */ 148 #define VL53L0X_ERROR_RANGE_ERROR ((VL53L0X_Error) -6) 149 /*!< Device report a ranging error interrupt status */ 150 #define VL53L0X_ERROR_TIME_OUT ((VL53L0X_Error) -7) 151 /*!< Aborted due to time out */ 152 #define VL53L0X_ERROR_MODE_NOT_SUPPORTED ((VL53L0X_Error) -8) 153 /*!< Asked mode is not supported by the device */ 154 #define VL53L0X_ERROR_BUFFER_TOO_SMALL ((VL53L0X_Error) -9) 155 /*!< ... */ 156 #define VL53L0X_ERROR_GPIO_NOT_EXISTING ((VL53L0X_Error) -10) 157 /*!< User tried to setup a non-existing GPIO pin */ 158 #define VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED ((VL53L0X_Error) -11) 159 /*!< unsupported GPIO functionality */ 160 #define VL53L0X_ERROR_INTERRUPT_NOT_CLEARED ((VL53L0X_Error) -12) 161 /*!< Error during interrupt clear */ 162 #define VL53L0X_ERROR_CONTROL_INTERFACE ((VL53L0X_Error) -20) 163 /*!< error reported from IO functions */ 164 #define VL53L0X_ERROR_INVALID_COMMAND ((VL53L0X_Error) -30) 165 /*!< The command is not allowed in the current device state 166 * (power down) */ 167 #define VL53L0X_ERROR_DIVISION_BY_ZERO ((VL53L0X_Error) -40) 168 /*!< In the function a division by zero occurs */ 169 #define VL53L0X_ERROR_REF_SPAD_INIT ((VL53L0X_Error) -50) 170 /*!< Error during reference SPAD initialization */ 171 #define VL53L0X_ERROR_NOT_IMPLEMENTED ((VL53L0X_Error) -99) 172 /*!< Tells requested functionality has not been implemented yet or 173 * not compatible with the device */ 174 /** @} VL53L0X_define_Error_group */ 175 176 177 /** @defgroup VL53L0X_define_DeviceModes_group Defines Device modes 178 * Defines all possible modes for the device 179 * @{ 180 */ 181 typedef uint8_t VL53L0X_DeviceModes; 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 */ 191 /** @} VL53L0X_define_DeviceModes_group */ 192 193 194 195 /** @defgroup VL53L0X_define_HistogramModes_group Defines Histogram modes 196 * Defines all possible Histogram modes for the device 197 * @{ 198 */ 199 typedef uint8_t VL53L0X_HistogramModes; 200 201 #define VL53L0X_HISTOGRAMMODE_DISABLED ((VL53L0X_HistogramModes) 0) 202 /*!< Histogram Disabled */ 203 #define VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY ((VL53L0X_HistogramModes) 1) 204 /*!< Histogram Reference array only */ 205 #define VL53L0X_HISTOGRAMMODE_RETURN_ONLY ((VL53L0X_HistogramModes) 2) 206 /*!< Histogram Return array only */ 207 #define VL53L0X_HISTOGRAMMODE_BOTH ((VL53L0X_HistogramModes) 3) 208 /*!< Histogram both Reference and Return Arrays */ 209 /* ... Modes to be added depending on device */ 210 /** @} VL53L0X_define_HistogramModes_group */ 211 212 213 /** @defgroup VL53L0X_define_PowerModes_group List of available Power Modes 214 * List of available Power Modes 215 * @{ 216 */ 217 218 typedef uint8_t VL53L0X_PowerModes; 219 220 #define VL53L0X_POWERMODE_STANDBY_LEVEL1 ((VL53L0X_PowerModes) 0) 221 /*!< Standby level 1 */ 222 #define VL53L0X_POWERMODE_STANDBY_LEVEL2 ((VL53L0X_PowerModes) 1) 223 /*!< Standby level 2 */ 224 #define VL53L0X_POWERMODE_IDLE_LEVEL1 ((VL53L0X_PowerModes) 2) 225 /*!< Idle level 1 */ 226 #define VL53L0X_POWERMODE_IDLE_LEVEL2 ((VL53L0X_PowerModes) 3) 227 /*!< Idle level 2 */ 228 229 /** @} VL53L0X_define_PowerModes_group */ 230 231 232 /** @brief Defines all parameters for the device 233 */ 234 typedef struct { 235 VL53L0X_DeviceModes DeviceMode; 236 /*!< Defines type of measurement to be done for the next measure */ 237 VL53L0X_HistogramModes HistogramMode; 238 /*!< Defines type of histogram measurement to be done for the next 239 * measure */ 240 uint32_t MeasurementTimingBudgetMicroSeconds; 241 /*!< Defines the allowed total time for a single measurement */ 242 uint32_t InterMeasurementPeriodMilliSeconds; 243 /*!< Defines time between two consecutive measurements (between two 244 * measurement starts). If set to 0 means back-to-back mode */ 245 uint8_t XTalkCompensationEnable; 246 /*!< Tells if Crosstalk compensation shall be enable or not */ 247 uint16_t XTalkCompensationRangeMilliMeter; 248 /*!< CrossTalk compensation range in millimeter */ 249 FixPoint1616_t XTalkCompensationRateMegaCps; 250 /*!< CrossTalk compensation rate in Mega counts per seconds. 251 * Expressed in 16.16 fixed point format. */ 252 int32_t RangeOffsetMicroMeters; 253 /*!< Range offset adjustment (mm). */ 254 255 uint8_t LimitChecksEnable[VL53L0X_CHECKENABLE_NUMBER_OF_CHECKS]; 256 /*!< This Array store all the Limit Check enable for this device. */ 257 uint8_t LimitChecksStatus[VL53L0X_CHECKENABLE_NUMBER_OF_CHECKS]; 258 /*!< This Array store all the Status of the check linked to last 259 * measurement. */ 260 FixPoint1616_t LimitChecksValue[VL53L0X_CHECKENABLE_NUMBER_OF_CHECKS]; 261 /*!< This Array store all the Limit Check value for this device */ 262 263 uint8_t WrapAroundCheckEnable; 264 /*!< Tells if Wrap Around Check shall be enable or not */ 265 } VL53L0X_DeviceParameters_t; 266 267 268 /** @defgroup VL53L0X_define_State_group Defines the current status of the device 269 * Defines the current status of the device 270 * @{ 271 */ 272 273 typedef uint8_t VL53L0X_State; 274 275 #define VL53L0X_STATE_POWERDOWN ((VL53L0X_State) 0) 276 /*!< Device is in HW reset */ 277 #define VL53L0X_STATE_WAIT_STATICINIT ((VL53L0X_State) 1) 278 /*!< Device is initialized and wait for static initialization */ 279 #define VL53L0X_STATE_STANDBY ((VL53L0X_State) 2) 280 /*!< Device is in Low power Standby mode */ 281 #define VL53L0X_STATE_IDLE ((VL53L0X_State) 3) 282 /*!< Device has been initialized and ready to do measurements */ 283 #define VL53L0X_STATE_RUNNING ((VL53L0X_State) 4) 284 /*!< Device is performing measurement */ 285 #define VL53L0X_STATE_UNKNOWN ((VL53L0X_State) 98) 286 /*!< Device is in unknown state and need to be rebooted */ 287 #define VL53L0X_STATE_ERROR ((VL53L0X_State) 99) 288 /*!< Device is in error state and need to be rebooted */ 289 290 /** @} VL53L0X_define_State_group */ 291 292 293 /** @brief Structure containing the Dmax computation parameters and data 294 */ 295 typedef struct { 296 int32_t AmbTuningWindowFactor_K; 297 /*!< internal algo tuning (*1000) */ 298 int32_t RetSignalAt0mm; 299 /*!< intermediate dmax computation value caching */ 300 } VL53L0X_DMaxData_t; 301 302 /** 303 * @struct VL53L0X_RangeData_t 304 * @brief Range measurement data. 305 */ 306 typedef struct { 307 uint32_t TimeStamp; /*!< 32-bit time stamp. */ 308 uint32_t MeasurementTimeUsec; 309 /*!< Give the Measurement time needed by the device to do the 310 * measurement.*/ 311 312 313 uint16_t RangeMilliMeter; /*!< range distance in millimeter. */ 314 315 uint16_t RangeDMaxMilliMeter; 316 /*!< Tells what is the maximum detection distance of the device 317 * in current setup and environment conditions (Filled when 318 * applicable) */ 319 320 FixPoint1616_t SignalRateRtnMegaCps; 321 /*!< Return signal rate (MCPS)\n these is a 16.16 fix point 322 * value, which is effectively a measure of target 323 * reflectance.*/ 324 FixPoint1616_t AmbientRateRtnMegaCps; 325 /*!< Return ambient rate (MCPS)\n these is a 16.16 fix point 326 * value, which is effectively a measure of the ambien 327 * t light.*/ 328 329 uint16_t EffectiveSpadRtnCount; 330 /*!< Return the effective SPAD count for the return signal. 331 * To obtain Real value it should be divided by 256 */ 332 333 uint8_t ZoneId; 334 /*!< Denotes which zone and range scheduler stage the range 335 * data relates to. */ 336 uint8_t RangeFractionalPart; 337 /*!< Fractional part of range distance. Final value is a 338 * FixPoint168 value. */ 339 uint8_t RangeStatus; 340 /*!< Range Status for the current measurement. This is device 341 * dependent. Value = 0 means value is valid. 342 * See \ref RangeStatusPage */ 343 } VL53L0X_RangingMeasurementData_t; 344 345 346 #define VL53L0X_HISTOGRAM_BUFFER_SIZE 24 347 348 /** 349 * @struct VL53L0X_HistogramData_t 350 * @brief Histogram measurement data. 351 */ 352 typedef struct { 353 /* Histogram Measurement data */ 354 uint32_t HistogramData[VL53L0X_HISTOGRAM_BUFFER_SIZE]; 355 /*!< Histogram data */ 356 uint8_t HistogramType; /*!< Indicate the types of histogram data : 357 Return only, Reference only, both Return and Reference */ 358 uint8_t FirstBin; /*!< First Bin value */ 359 uint8_t BufferSize; /*!< Buffer Size - Set by the user.*/ 360 uint8_t NumberOfBins; 361 /*!< Number of bins filled by the histogram measurement */ 362 363 VL53L0X_DeviceError ErrorStatus; 364 /*!< Error status of the current measurement. \n 365 see @a ::VL53L0X_DeviceError @a VL53L0X_GetStatusErrorString() */ 366 } VL53L0X_HistogramMeasurementData_t; 367 368 #define VL53L0X_REF_SPAD_BUFFER_SIZE 6 369 370 /** 371 * @struct VL53L0X_SpadData_t 372 * @brief Spad Configuration Data. 373 */ 374 typedef struct { 375 uint8_t RefSpadEnables[VL53L0X_REF_SPAD_BUFFER_SIZE]; 376 /*!< Reference Spad Enables */ 377 uint8_t RefGoodSpadMap[VL53L0X_REF_SPAD_BUFFER_SIZE]; 378 /*!< Reference Spad Good Spad Map */ 379 } VL53L0X_SpadData_t; 380 381 typedef struct { 382 FixPoint1616_t OscFrequencyMHz; /* Frequency used */ 383 384 uint16_t LastEncodedTimeout; 385 /* last encoded Time out used for timing budget*/ 386 387 VL53L0X_GpioFunctionality Pin0GpioFunctionality; 388 /* store the functionality of the GPIO: pin0 */ 389 390 uint32_t FinalRangeTimeoutMicroSecs; 391 /*!< Execution time of the final range*/ 392 uint8_t FinalRangeVcselPulsePeriod; 393 /*!< Vcsel pulse period (pll clocks) for the final range measurement*/ 394 uint32_t PreRangeTimeoutMicroSecs; 395 /*!< Execution time of the final range*/ 396 uint8_t PreRangeVcselPulsePeriod; 397 /*!< Vcsel pulse period (pll clocks) for the pre-range measurement*/ 398 399 uint16_t SigmaEstRefArray; 400 /*!< Reference array sigma value in 1/100th of [mm] e.g. 100 = 1mm */ 401 uint16_t SigmaEstEffPulseWidth; 402 /*!< Effective Pulse width for sigma estimate in 1/100th 403 * of ns e.g. 900 = 9.0ns */ 404 uint16_t SigmaEstEffAmbWidth; 405 /*!< Effective Ambient width for sigma estimate in 1/100th of ns 406 * e.g. 500 = 5.0ns */ 407 408 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. */ 418 uint32_t PartUIDUpper; /*!< Unique Part ID Upper */ 419 uint32_t PartUIDLower; /*!< Unique Part ID Lower */ 420 FixPoint1616_t SignalRateMeasFixed400mm; /*!< Peek Signal rate 421 at 400 mm*/ 422 423 } VL53L0X_DeviceSpecificParameters_t; 424 425 /** 426 * @struct VL53L0X_DevData_t 427 * 428 * @brief VL53L0X PAL device ST private data structure \n 429 * End user should never access any of these field directly 430 * 431 * These must never access directly but only via macro 432 */ 433 typedef struct { 434 VL53L0X_DMaxData_t DMaxData; 435 /*!< Dmax Data */ 436 int32_t Part2PartOffsetNVMMicroMeter; 437 /*!< backed up NVM value */ 438 int32_t Part2PartOffsetAdjustmentNVMMicroMeter; 439 /*!< backed up NVM value representing additional offset adjustment */ 440 VL53L0X_DeviceParameters_t CurrentParameters; 441 /*!< Current Device Parameter */ 442 VL53L0X_RangingMeasurementData_t LastRangeMeasure; 443 /*!< Ranging Data */ 444 VL53L0X_HistogramMeasurementData_t LastHistogramMeasure; 445 /*!< Histogram Data */ 446 VL53L0X_DeviceSpecificParameters_t DeviceSpecificParameters; 447 /*!< Parameters specific to the device */ 448 VL53L0X_SpadData_t SpadData; 449 /*!< Spad Data */ 450 uint8_t SequenceConfig; 451 /*!< Internal value for the sequence config */ 452 uint8_t RangeFractionalEnable; 453 /*!< Enable/Disable fractional part of ranging data */ 454 VL53L0X_State PalState; 455 /*!< Current state of the PAL for this device */ 456 VL53L0X_PowerModes PowerMode; 457 /*!< Current Power Mode */ 458 uint16_t SigmaEstRefArray; 459 /*!< Reference array sigma value in 1/100th of [mm] e.g. 100 = 1mm */ 460 uint16_t SigmaEstEffPulseWidth; 461 /*!< Effective Pulse width for sigma estimate in 1/100th 462 * of ns e.g. 900 = 9.0ns */ 463 uint16_t SigmaEstEffAmbWidth; 464 /*!< Effective Ambient width for sigma estimate in 1/100th of ns 465 * e.g. 500 = 5.0ns */ 466 uint8_t StopVariable; 467 /*!< StopVariable used during the stop sequence */ 468 uint16_t targetRefRate; 469 /*!< Target Ambient Rate for Ref spad management */ 470 FixPoint1616_t SigmaEstimate; 471 /*!< Sigma Estimate - based on ambient & VCSEL rates and 472 * signal_total_events */ 473 FixPoint1616_t SignalEstimate; 474 /*!< Signal Estimate - based on ambient & VCSEL rates and cross talk */ 475 FixPoint1616_t LastSignalRefMcps; 476 /*!< Latest Signal ref in Mcps */ 477 uint8_t *pTuningSettingsPointer; 478 /*!< Pointer for Tuning Settings table */ 479 uint8_t UseInternalTuningSettings; 480 /*!< Indicate if we use Tuning Settings table */ 481 uint16_t LinearityCorrectiveGain; 482 /*!< Linearity Corrective Gain value in x1000 */ 483 uint16_t DmaxCalRangeMilliMeter; 484 /*!< Dmax Calibration Range millimeter */ 485 FixPoint1616_t DmaxCalSignalRateRtnMegaCps; 486 /*!< Dmax Calibration Signal Rate Return MegaCps */ 487 488 } VL53L0X_DevData_t; 489 490 491 /** @defgroup VL53L0X_define_InterruptPolarity_group Defines the Polarity 492 * of the Interrupt 493 * Defines the Polarity of the Interrupt 494 * @{ 495 */ 496 typedef uint8_t VL53L0X_InterruptPolarity; 497 498 #define VL53L0X_INTERRUPTPOLARITY_LOW ((VL53L0X_InterruptPolarity) 0) 499 /*!< Set active low polarity best setup for falling edge. */ 500 #define VL53L0X_INTERRUPTPOLARITY_HIGH ((VL53L0X_InterruptPolarity) 1) 501 /*!< Set active high polarity best setup for rising edge. */ 502 503 /** @} VL53L0X_define_InterruptPolarity_group */ 504 505 506 /** @defgroup VL53L0X_define_VcselPeriod_group Vcsel Period Defines 507 * Defines the range measurement for which to access the vcsel period. 508 * @{ 509 */ 510 typedef uint8_t VL53L0X_VcselPeriod; 511 512 #define VL53L0X_VCSEL_PERIOD_PRE_RANGE ((VL53L0X_VcselPeriod) 0) 513 /*!<Identifies the pre-range vcsel period. */ 514 #define VL53L0X_VCSEL_PERIOD_FINAL_RANGE ((VL53L0X_VcselPeriod) 1) 515 /*!<Identifies the final range vcsel period. */ 516 517 /** @} VL53L0X_define_VcselPeriod_group */ 518 519 /** @defgroup VL53L0X_define_SchedulerSequence_group Defines the steps 520 * carried out by the scheduler during a range measurement. 521 * @{ 522 * Defines the states of all the steps in the scheduler 523 * i.e. enabled/disabled. 524 */ 525 typedef struct { 526 uint8_t TccOn; /*!<Reports if Target Centre Check On */ 527 uint8_t MsrcOn; /*!<Reports if MSRC On */ 528 uint8_t DssOn; /*!<Reports if DSS On */ 529 uint8_t PreRangeOn; /*!<Reports if Pre-Range On */ 530 uint8_t FinalRangeOn; /*!<Reports if Final-Range On */ 531 } VL53L0X_SchedulerSequenceSteps_t; 532 533 /** @} VL53L0X_define_SchedulerSequence_group */ 534 535 /** @defgroup VL53L0X_define_SequenceStepId_group Defines the Polarity 536 * of the Interrupt 537 * Defines the the sequence steps performed during ranging.. 538 * @{ 539 */ 540 typedef uint8_t VL53L0X_SequenceStepId; 541 542 #define VL53L0X_SEQUENCESTEP_TCC ((VL53L0X_VcselPeriod) 0) 543 /*!<Target CentreCheck identifier. */ 544 #define VL53L0X_SEQUENCESTEP_DSS ((VL53L0X_VcselPeriod) 1) 545 /*!<Dynamic Spad Selection function Identifier. */ 546 #define VL53L0X_SEQUENCESTEP_MSRC ((VL53L0X_VcselPeriod) 2) 547 /*!<Minimum Signal Rate Check function Identifier. */ 548 #define VL53L0X_SEQUENCESTEP_PRE_RANGE ((VL53L0X_VcselPeriod) 3) 549 /*!<Pre-Range check Identifier. */ 550 #define VL53L0X_SEQUENCESTEP_FINAL_RANGE ((VL53L0X_VcselPeriod) 4) 551 /*!<Final Range Check Identifier. */ 552 553 #define VL53L0X_SEQUENCESTEP_NUMBER_OF_CHECKS 5 554 /*!<Number of Sequence Step Managed by the API. */ 555 556 /** @} VL53L0X_define_SequenceStepId_group */ 557 558 559 /* MACRO Definitions */ 560 /** @defgroup VL53L0X_define_GeneralMacro_group General Macro Defines 561 * General Macro Defines 562 * @{ 563 */ 564 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 625 /** @} VL53L0X_define_GeneralMacro_group */ 626 627 /** @} VL53L0X_globaldefine_group */ 628 629 630 631 632 633 634 635 #ifdef __cplusplus 636 } 637 #endif 638 639 640 #endif /* _VL53L0X_DEF_H_ */ 641