vl53l1_def.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  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. * @file vl53l1_def.h
  64. *
  65. * @brief Type definitions for VL53L1 API.
  66. *
  67. */
  68. #ifndef _VL53L1_DEF_H_
  69. #define _VL53L1_DEF_H_
  70. #include "vl53l1_ll_def.h"
  71. #ifdef __cplusplus
  72. extern "C" {
  73. #endif
  74. /** @defgroup VL53L1_globaldefine_group VL53L1 Defines
  75. * @brief VL53L1 Defines
  76. * @{
  77. */
  78. /** VL53L1 IMPLEMENTATION major version */
  79. #define VL53L1_IMPLEMENTATION_VER_MAJOR 2
  80. /** VL53L1 IMPLEMENTATION minor version */
  81. #define VL53L1_IMPLEMENTATION_VER_MINOR 3
  82. /** VL53L1 IMPLEMENTATION sub version */
  83. #define VL53L1_IMPLEMENTATION_VER_SUB 3
  84. /** VL53L1 IMPLEMENTATION sub version */
  85. #define VL53L1_IMPLEMENTATION_VER_REVISION 1885
  86. /****************************************
  87. * PRIVATE define do not edit
  88. ****************************************/
  89. /** @brief Defines the parameters of the Get Version Functions
  90. */
  91. typedef struct {
  92. uint32_t revision; /*!< revision number */
  93. uint8_t major; /*!< major number */
  94. uint8_t minor; /*!< minor number */
  95. uint8_t build; /*!< build number */
  96. } VL53L1_Version_t;
  97. #define VL53L1_DEVINFO_STRLEN 32
  98. /** @brief Defines the parameters of the Get Device Info Functions
  99. */
  100. typedef struct {
  101. char Name[VL53L1_DEVINFO_STRLEN];
  102. /*!< Name of the Device e.g. Left_Distance */
  103. char Type[VL53L1_DEVINFO_STRLEN];
  104. /*!< Type of the Device e.g VL53L1 */
  105. char ProductId[VL53L1_DEVINFO_STRLEN];
  106. /*!< Product Identifier String
  107. * @warning Not yet implemented
  108. */
  109. uint8_t ProductType;
  110. /*!< Product Type, VL53L1 = 1, VL53L1 = 2*/
  111. uint8_t ProductRevisionMajor;
  112. /*!< Product revision major */
  113. uint8_t ProductRevisionMinor;
  114. /*!< Product revision minor */
  115. } VL53L1_DeviceInfo_t;
  116. /** @defgroup VL53L1_define_PresetModes_group Defines Preset modes
  117. * Defines all possible preset modes for the device
  118. * @{
  119. */
  120. typedef uint8_t VL53L1_PresetModes;
  121. #define VL53L1_PRESETMODE_AUTONOMOUS ((VL53L1_PresetModes) 3)
  122. #define VL53L1_PRESETMODE_LITE_RANGING ((VL53L1_PresetModes) 4)
  123. #define VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS ((VL53L1_PresetModes) 8)
  124. /* ... Modes to be added depending on device */
  125. /** @} VL53L1_define_PresetModes_group */
  126. /** @defgroup VL53L1_define_DistanceModes_group Defines Distance modes
  127. * Defines all possible Distance modes for the device
  128. * @{
  129. */
  130. typedef uint8_t VL53L1_DistanceModes;
  131. #define VL53L1_DISTANCEMODE_SHORT ((VL53L1_DistanceModes) 1)
  132. #define VL53L1_DISTANCEMODE_MEDIUM ((VL53L1_DistanceModes) 2)
  133. #define VL53L1_DISTANCEMODE_LONG ((VL53L1_DistanceModes) 3)
  134. /** @} VL53L1_define_DistanceModes_group */
  135. /** @defgroup VL53L1_define_XtalkCal_group Defines Xtalk Calibration modes
  136. * Defines all possible Offset Calibration modes for the device
  137. * @{
  138. */
  139. typedef uint8_t VL53L1_XtalkCalibrationModes;
  140. #define VL53L1_XTALKCALIBRATIONMODE_NO_TARGET \
  141. ((VL53L1_OffsetCalibrationModes) 0)
  142. /*!< To perform Xtalk calibration with no target below 80 cm */
  143. #define VL53L1_XTALKCALIBRATIONMODE_SINGLE_TARGET \
  144. ((VL53L1_OffsetCalibrationModes) 1)
  145. /*!< To perform Xtalk calibration with one target */
  146. #define VL53L1_XTALKCALIBRATIONMODE_FULL_ROI \
  147. ((VL53L1_OffsetCalibrationModes) 2)
  148. /*!< To perform Xtalk calibration based on histogram with full ROI */
  149. /** @} VL53L1_define_XtalkCal_group */
  150. /** @defgroup VL53L1_define_OffsetCal_group Defines Offset Calibration modes
  151. * Defines all possible Offset Calibration modes for the device
  152. * @{
  153. */
  154. typedef uint8_t VL53L1_OffsetCalibrationModes;
  155. #define VL53L1_OFFSETCALIBRATIONMODE_STANDARD \
  156. ((VL53L1_OffsetCalibrationModes) 1)
  157. #define VL53L1_OFFSETCALIBRATIONMODE_PRERANGE_ONLY \
  158. ((VL53L1_OffsetCalibrationModes) 2)
  159. /** @} VL53L1_define_OffsetCal_group */
  160. /** @defgroup VL53L1_CheckEnable_group Check Enable list
  161. * @brief Check Enable code
  162. *
  163. * Define used to specify the LimitCheckId.
  164. * Use @a VL53L1_GetLimitCheckInfo() to get the string.
  165. * @{
  166. */
  167. #define VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE 0
  168. #define VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE 1
  169. #define VL53L1_CHECKENABLE_NUMBER_OF_CHECKS 2
  170. /** @} end of VL53L1_CheckEnable_group */
  171. /** @defgroup VL53L1_ThresholdMode_gropup Detection Functionality
  172. * @brief Defines the different functionalities for the detection feature
  173. * @{
  174. */
  175. typedef uint8_t VL53L1_ThresholdMode;
  176. #define VL53L1_THRESHOLD_CROSSED_LOW \
  177. ((VL53L1_ThresholdMode) 0)
  178. /*!< Trigger interrupt if value < thresh_low */
  179. #define VL53L1_THRESHOLD_CROSSED_HIGH \
  180. ((VL53L1_ThresholdMode) 1)
  181. /*!< Trigger interrupt if value > thresh_high */
  182. #define VL53L1_THRESHOLD_OUT_OF_WINDOW \
  183. ((VL53L1_ThresholdMode) 2)
  184. /*!< Trigger interrupt if value < thresh_low OR value > thresh_high */
  185. #define VL53L1_THRESHOLD_IN_WINDOW \
  186. ((VL53L1_ThresholdMode) 3)
  187. /*!< Trigger interrupt if value > thresh_low AND value < thresh_high */
  188. /** @} end of VL53L1_ThresholdMode_gropup */
  189. /** @brief Defines parameters for Distance detection Thresholds configuration
  190. */
  191. typedef struct {
  192. VL53L1_ThresholdMode CrossMode;
  193. uint16_t High; /*!< Distance threshold high limit in mm */
  194. uint16_t Low; /*!< Distance threshold low limit in mm */
  195. } VL53L1_DistanceThreshold_t;
  196. /** @brief Defines parameters for Signal rate detection Thresholds configuration
  197. */
  198. typedef struct {
  199. VL53L1_ThresholdMode CrossMode;
  200. FixPoint1616_t High; /*!< Signal rate threshold high limit */
  201. FixPoint1616_t Low; /*!< Signal rate threshold low limit */
  202. } VL53L1_RateThreshold_t;
  203. /** @defgroup VL53L1_DetectionMode_group Gpio Functionality
  204. * @brief Defines conditions leading to device's IT on GPIO
  205. * @{
  206. */
  207. typedef uint8_t VL53L1_DetectionMode;
  208. #define VL53L1_DETECTION_NORMAL_RUN \
  209. ((VL53L1_DetectionMode) 0)
  210. /*!< Trigger interrupt on new measurement regardless of threshold
  211. * just like after a VL53L1_SetPresetMode() call
  212. */
  213. #define VL53L1_DETECTION_DISTANCE_ONLY \
  214. ((VL53L1_DetectionMode) 1)
  215. /*!< Trigger interrupt if "threshold event" occurs on distance */
  216. #define VL53L1_DETECTION_RATE_ONLY \
  217. ((VL53L1_DetectionMode) 2)
  218. /*!< Trigger interrupt if "threshold event" occurs on signal rate */
  219. #define VL53L1_DETECTION_DISTANCE_AND_RATE \
  220. ((VL53L1_DetectionMode) 3)
  221. /*!< Trigger interrupt if "threshold event" occurs on distance AND rate
  222. */
  223. #define VL53L1_DETECTION_DISTANCE_OR_RATE \
  224. ((VL53L1_DetectionMode) 4)
  225. /*!< Trigger interrupt if "threshold event" occurs on distance OR rate
  226. */
  227. /** @} end of VL53L1_DetectionMode_group */
  228. /** @brief Defines parameters for User/object Detection configuration
  229. */
  230. typedef struct {
  231. VL53L1_DetectionMode DetectionMode; /*!< See #VL53L1_DetectionMode*/
  232. uint8_t IntrNoTarget; /*!< 1 to trigger IT in case of no target found */
  233. VL53L1_DistanceThreshold_t Distance; /*!< limits in mm */
  234. VL53L1_RateThreshold_t Rate;/*!< limits in FixPoint1616_t */
  235. } VL53L1_DetectionConfig_t;
  236. /** @brief Defines all parameters for the device
  237. */
  238. typedef struct {
  239. VL53L1_PresetModes PresetMode;
  240. /*!< Defines the operating mode to be used for the next measure */
  241. VL53L1_DistanceModes DistanceMode;
  242. /*!< Defines the operating mode to be used for the next measure */
  243. VL53L1_DistanceModes InternalDistanceMode;
  244. /*!< Defines the internal operating mode to be used for the next
  245. * measure
  246. */
  247. VL53L1_DistanceModes NewDistanceMode;
  248. /*!< Defines the new operating mode to be programmed for the next
  249. * measure
  250. */
  251. uint32_t MeasurementTimingBudgetMicroSeconds;
  252. /*!< Defines the allowed total time for a single measurement */
  253. uint8_t LimitChecksEnable[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
  254. /*!< This Array store all the Limit Check enable for this device. */
  255. uint8_t LimitChecksStatus[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
  256. /*!< This Array stores all the Status of the check linked to last
  257. * measurement.
  258. */
  259. FixPoint1616_t LimitChecksValue[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
  260. /*!< This Array stores all the Limit Check value for this device */
  261. FixPoint1616_t LimitChecksCurrent[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
  262. /*!< This Array stores all the Limit Check current value from latest
  263. * ranging
  264. */
  265. } VL53L1_DeviceParameters_t;
  266. /** @defgroup VL53L1_define_State_group Defines the current status of the device
  267. * Defines the current status of the device
  268. * @{
  269. */
  270. typedef uint8_t VL53L1_State;
  271. #define VL53L1_STATE_POWERDOWN ((VL53L1_State) 0)
  272. /*!< Device is in HW reset */
  273. #define VL53L1_STATE_WAIT_STATICINIT ((VL53L1_State) 1)
  274. /*!< Device is initialized and wait for static initialization */
  275. #define VL53L1_STATE_STANDBY ((VL53L1_State) 2)
  276. /*!< Device is in Low power Standby mode */
  277. #define VL53L1_STATE_IDLE ((VL53L1_State) 3)
  278. /*!< Device has been initialized and ready to do measurements */
  279. #define VL53L1_STATE_RUNNING ((VL53L1_State) 4)
  280. /*!< Device is performing measurement */
  281. #define VL53L1_STATE_RESET ((VL53L1_State) 5)
  282. /*!< Soft reset has been run on Device */
  283. #define VL53L1_STATE_UNKNOWN ((VL53L1_State) 98)
  284. /*!< Device is in unknown state and need to be rebooted */
  285. #define VL53L1_STATE_ERROR ((VL53L1_State) 99)
  286. /*!< Device is in error state and need to be rebooted */
  287. /** @} VL53L1_define_State_group */
  288. /**
  289. * @struct VL53L1_RangingMeasurementData_t
  290. * @brief Single Range measurement data.
  291. */
  292. typedef struct {
  293. uint32_t TimeStamp;
  294. /*!< 32-bit time stamp.
  295. * @warning Not yet implemented
  296. */
  297. uint8_t StreamCount;
  298. /*!< 8-bit Stream Count. */
  299. uint8_t RangeQualityLevel;
  300. /*!< indicate a quality level in percentage from 0 to 100
  301. * @warning Not yet implemented
  302. */
  303. FixPoint1616_t SignalRateRtnMegaCps;
  304. /*!< Return signal rate (MCPS)\n these is a 16.16 fix point
  305. * value, which is effectively a measure of target
  306. * reflectance.
  307. */
  308. FixPoint1616_t AmbientRateRtnMegaCps;
  309. /*!< Return ambient rate (MCPS)\n these is a 16.16 fix point
  310. * value, which is effectively a measure of the ambien
  311. * t light.
  312. */
  313. uint16_t EffectiveSpadRtnCount;
  314. /*!< Return the effective SPAD count for the return signal.
  315. * To obtain Real value it should be divided by 256
  316. */
  317. FixPoint1616_t SigmaMilliMeter;
  318. /*!< Return the Sigma value in millimeter */
  319. int16_t RangeMilliMeter;
  320. /*!< range distance in millimeter. This should be between
  321. * RangeMinMilliMeter and RangeMaxMilliMeter
  322. */
  323. uint8_t RangeFractionalPart;
  324. /*!< Fractional part of range distance. Final value is a
  325. * RangeMilliMeter + RangeFractionalPart/256.
  326. * @warning Not yet implemented
  327. */
  328. uint8_t RangeStatus;
  329. /*!< Range Status for the current measurement. This is device
  330. * dependent. Value = 0 means value is valid.
  331. */
  332. } VL53L1_RangingMeasurementData_t;
  333. /** @brief Defines User Zone(ROI) parameters
  334. *
  335. */
  336. typedef struct {
  337. uint8_t TopLeftX; /*!< Top Left x coordinate: 0-15 range */
  338. uint8_t TopLeftY; /*!< Top Left y coordinate: 0-15 range */
  339. uint8_t BotRightX; /*!< Bot Right x coordinate: 0-15 range */
  340. uint8_t BotRightY; /*!< Bot Right y coordinate: 0-15 range */
  341. } VL53L1_UserRoi_t;
  342. /** @brief Defines ROI configuration parameters
  343. *
  344. * Support up a max of 16 zones, Each Zone has the same size
  345. *
  346. */
  347. /**
  348. * @struct VL53L1_CustomerNvmManaged_t
  349. *
  350. */
  351. typedef struct {
  352. uint8_t global_config__spad_enables_ref_0;
  353. uint8_t global_config__spad_enables_ref_1;
  354. uint8_t global_config__spad_enables_ref_2;
  355. uint8_t global_config__spad_enables_ref_3;
  356. uint8_t global_config__spad_enables_ref_4;
  357. uint8_t global_config__spad_enables_ref_5;
  358. uint8_t global_config__ref_en_start_select;
  359. uint8_t ref_spad_man__num_requested_ref_spads;
  360. uint8_t ref_spad_man__ref_location;
  361. uint32_t algo__crosstalk_compensation_plane_offset_kcps;
  362. int16_t algo__crosstalk_compensation_x_plane_gradient_kcps;
  363. int16_t algo__crosstalk_compensation_y_plane_gradient_kcps;
  364. uint16_t ref_spad_char__total_rate_target_mcps;
  365. int16_t algo__part_to_part_range_offset_mm;
  366. int16_t mm_config__inner_offset_mm;
  367. int16_t mm_config__outer_offset_mm;
  368. } VL53L1_CustomerNvmManaged_t;
  369. /**
  370. * @struct VL53L1_CalibrationData_t
  371. * @brief Structure for storing the Calibration Data
  372. *
  373. */
  374. typedef struct {
  375. uint32_t struct_version;
  376. VL53L1_CustomerNvmManaged_t customer;
  377. VL53L1_additional_offset_cal_data_t add_off_cal_data;
  378. VL53L1_optical_centre_t optical_centre;
  379. VL53L1_gain_calibration_data_t gain_cal;
  380. VL53L1_cal_peak_rate_map_t cal_peak_rate_map;
  381. } VL53L1_CalibrationData_t;
  382. #define VL53L1_ADDITIONAL_CALIBRATION_DATA_STRUCT_VERSION 0x10
  383. /** VL53L1 additional Calibration Data struct version final struct version
  384. * is given by adding it to VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION
  385. */
  386. #define VL53L1_CALIBRATION_DATA_STRUCT_VERSION \
  387. (VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION + \
  388. VL53L1_ADDITIONAL_CALIBRATION_DATA_STRUCT_VERSION)
  389. /* VL53L1 Calibration Data struct version */
  390. /**
  391. * @struct VL53L1_AdditionalData_t
  392. * @brief Structure for storing the Additional Data
  393. *
  394. */
  395. typedef VL53L1_additional_data_t VL53L1_AdditionalData_t;
  396. typedef uint8_t VL53L1_SequenceStepId;
  397. #define VL53L1_SEQUENCESTEP_VHV ((VL53L1_SequenceStepId) 0)
  398. /*!<VHV. */
  399. #define VL53L1_SEQUENCESTEP_PHASECAL ((VL53L1_SequenceStepId) 1)
  400. /*!<Phase Calibration. */
  401. #define VL53L1_SEQUENCESTEP_REFPHASE ((VL53L1_SequenceStepId) 2)
  402. /*!<Reference Phase. */
  403. #define VL53L1_SEQUENCESTEP_DSS1 ((VL53L1_SequenceStepId) 3)
  404. /*!<DSS1. */
  405. #define VL53L1_SEQUENCESTEP_DSS2 ((VL53L1_SequenceStepId) 4)
  406. /*!<DSS2. */
  407. #define VL53L1_SEQUENCESTEP_MM1 ((VL53L1_SequenceStepId) 5)
  408. /*!<Mode Mitigation 1. */
  409. #define VL53L1_SEQUENCESTEP_MM2 ((VL53L1_SequenceStepId) 6)
  410. /*!<Mode Mitigation 2. */
  411. #define VL53L1_SEQUENCESTEP_RANGE ((VL53L1_SequenceStepId) 7)
  412. /*!<Final Range step. */
  413. #define VL53L1_SEQUENCESTEP_NUMBER_OF_ITEMS 8
  414. /*!<Number of Sequence Step Managed by the API. */
  415. /** @defgroup VL53L1_define_RangeStatus_group Defines the Range Status
  416. * @{
  417. */
  418. #define VL53L1_RANGESTATUS_RANGE_VALID 0
  419. /*!<The Range is valid. */
  420. #define VL53L1_RANGESTATUS_SIGMA_FAIL 1
  421. /*!<Sigma Fail. */
  422. #define VL53L1_RANGESTATUS_SIGNAL_FAIL 2
  423. /*!<Signal fail. */
  424. #define VL53L1_RANGESTATUS_RANGE_VALID_MIN_RANGE_CLIPPED 3
  425. /*!<Target is below minimum detection threshold. */
  426. #define VL53L1_RANGESTATUS_OUTOFBOUNDS_FAIL 4
  427. /*!<Phase out of valid limits - different to a wrap exit. */
  428. #define VL53L1_RANGESTATUS_HARDWARE_FAIL 5
  429. /*!<Hardware fail. */
  430. #define VL53L1_RANGESTATUS_RANGE_VALID_NO_WRAP_CHECK_FAIL 6
  431. /*!<The Range is valid but the wraparound check has not been done. */
  432. #define VL53L1_RANGESTATUS_WRAP_TARGET_FAIL 7
  433. /*!<Wrapped target - no matching phase in other VCSEL period timing. */
  434. #define VL53L1_RANGESTATUS_PROCESSING_FAIL 8
  435. /*!<Internal algo underflow or overflow in lite ranging. */
  436. #define VL53L1_RANGESTATUS_XTALK_SIGNAL_FAIL 9
  437. /*!<Specific to lite ranging. */
  438. #define VL53L1_RANGESTATUS_SYNCRONISATION_INT 10
  439. /*!<1st interrupt when starting ranging in back to back mode. Ignore data. */
  440. #define VL53L1_RANGESTATUS_RANGE_VALID_MERGED_PULSE 11
  441. /*!<All Range ok but object is result of multiple pulses merging together.
  442. * Used by RQL for merged pulse detection
  443. */
  444. #define VL53L1_RANGESTATUS_TARGET_PRESENT_LACK_OF_SIGNAL 12
  445. /*!<Used by RQL as different to phase fail. */
  446. #define VL53L1_RANGESTATUS_MIN_RANGE_FAIL 13
  447. /*!<User ROI input is not valid e.g. beyond SPAD Array.*/
  448. #define VL53L1_RANGESTATUS_RANGE_INVALID 14
  449. /*!<lld returned valid range but negative value ! */
  450. #define VL53L1_RANGESTATUS_NONE 255
  451. /*!<No Update. */
  452. /** @} VL53L1_define_RangeStatus_group */
  453. /** @brief Contains the Internal data of the Bare Driver
  454. */
  455. typedef struct {
  456. VL53L1_LLDriverData_t LLData;
  457. /*!< Low Level Driver data structure */
  458. VL53L1_LLDriverResults_t llresults;
  459. /*!< Low Level Driver data structure */
  460. VL53L1_State PalState; /* Store the pal state */
  461. VL53L1_DeviceParameters_t CurrentParameters;
  462. /*!< Current Device Parameter */
  463. } VL53L1_DevData_t;
  464. /* MACRO Definitions */
  465. /** @defgroup VL53L1_define_GeneralMacro_group General Macro Defines
  466. * General Macro Defines
  467. * @{
  468. */
  469. /* Defines */
  470. #define VL53L1_SETPARAMETERFIELD(Dev, field, value) \
  471. (VL53L1DevDataSet(Dev, CurrentParameters.field, value))
  472. #define VL53L1_GETPARAMETERFIELD(Dev, field, variable) \
  473. (variable = VL53L1DevDataGet(Dev, CurrentParameters).field)
  474. #define VL53L1_SETARRAYPARAMETERFIELD(Dev, field, index, value) \
  475. (VL53L1DevDataSet(Dev, CurrentParameters.field[index], value))
  476. #define VL53L1_GETARRAYPARAMETERFIELD(Dev, field, index, variable) \
  477. (variable = VL53L1DevDataGet(Dev, CurrentParameters).field[index])
  478. #define VL53L1_SETDEVICESPECIFICPARAMETER(Dev, field, value) \
  479. (VL53L1DevDataSet(Dev, DeviceSpecificParameters.field, value))
  480. #define VL53L1_GETDEVICESPECIFICPARAMETER(Dev, field) \
  481. (VL53L1DevDataGet(Dev, DeviceSpecificParameters).field)
  482. #define VL53L1_FIXPOINT1616TOFIXPOINT44(Value) \
  483. (uint16_t)((Value>>12)&0xFFFF)
  484. #define VL53L1_FIXPOINT44TOFIXPOINT1616(Value) \
  485. (FixPoint1616_t)((uint32_t)Value<<12)
  486. #define VL53L1_FIXPOINT1616TOFIXPOINT72(Value) \
  487. (uint16_t)((Value>>14)&0xFFFF)
  488. #define VL53L1_FIXPOINT72TOFIXPOINT1616(Value) \
  489. (FixPoint1616_t)((uint32_t)Value<<14)
  490. #define VL53L1_FIXPOINT1616TOFIXPOINT97(Value) \
  491. (uint16_t)((Value>>9)&0xFFFF)
  492. #define VL53L1_FIXPOINT97TOFIXPOINT1616(Value) \
  493. (FixPoint1616_t)((uint32_t)Value<<9)
  494. #define VL53L1_FIXPOINT1616TOFIXPOINT88(Value) \
  495. (uint16_t)((Value>>8)&0xFFFF)
  496. #define VL53L1_FIXPOINT88TOFIXPOINT1616(Value) \
  497. (FixPoint1616_t)((uint32_t)Value<<8)
  498. #define VL53L1_FIXPOINT1616TOFIXPOINT412(Value) \
  499. (uint16_t)((Value>>4)&0xFFFF)
  500. #define VL53L1_FIXPOINT412TOFIXPOINT1616(Value) \
  501. (FixPoint1616_t)((uint32_t)Value<<4)
  502. #define VL53L1_FIXPOINT1616TOFIXPOINT313(Value) \
  503. (uint16_t)((Value>>3)&0xFFFF)
  504. #define VL53L1_FIXPOINT313TOFIXPOINT1616(Value) \
  505. (FixPoint1616_t)((uint32_t)Value<<3)
  506. #define VL53L1_FIXPOINT1616TOFIXPOINT08(Value) \
  507. (uint8_t)((Value>>8)&0x00FF)
  508. #define VL53L1_FIXPOINT08TOFIXPOINT1616(Value) \
  509. (FixPoint1616_t)((uint32_t)Value<<8)
  510. #define VL53L1_FIXPOINT1616TOFIXPOINT53(Value) \
  511. (uint8_t)((Value>>13)&0x00FF)
  512. #define VL53L1_FIXPOINT53TOFIXPOINT1616(Value) \
  513. (FixPoint1616_t)((uint32_t)Value<<13)
  514. #define VL53L1_FIXPOINT1616TOFIXPOINT102(Value) \
  515. (uint16_t)((Value>>14)&0x0FFF)
  516. #define VL53L1_FIXPOINT102TOFIXPOINT1616(Value) \
  517. (FixPoint1616_t)((uint32_t)Value<<14)
  518. #define VL53L1_FIXPOINT1616TOFIXPOINT142(Value) \
  519. (uint16_t)((Value>>14)&0xFFFF)
  520. #define VL53L1_FIXPOINT142TOFIXPOINT1616(Value) \
  521. (FixPoint1616_t)((uint32_t)Value<<14)
  522. #define VL53L1_FIXPOINT1616TOFIXPOINT160(Value) \
  523. (uint16_t)((Value>>16)&0xFFFF)
  524. #define VL53L1_FIXPOINT160TOFIXPOINT1616(Value) \
  525. (FixPoint1616_t)((uint32_t)Value<<16)
  526. #define VL53L1_MAKEUINT16(lsb, msb) (uint16_t)((((uint16_t)msb)<<8) + \
  527. (uint16_t)lsb)
  528. #ifndef SUPPRESS_UNUSED_WARNING
  529. #define SUPPRESS_UNUSED_WARNING(x) ((void) (x))
  530. #endif
  531. #define CHECK_ERROR_GO_ENDFUNC do {\
  532. if (Status != VL53L1_ERROR_NONE) \
  533. goto ENDFUNC; \
  534. } while (0)
  535. /** @} VL53L1_define_GeneralMacro_group */
  536. /** @} VL53L1_globaldefine_group */
  537. #ifdef __cplusplus
  538. }
  539. #endif
  540. #endif /* _VL53L1_DEF_H_ */