vl53l1_wait.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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_wait.h
  64. *
  65. * @brief EwokPlus25 low level Driver wait function definitions
  66. */
  67. #ifndef _VL53L1_WAIT_H_
  68. #define _VL53L1_WAIT_H_
  69. #include "vl53l1_platform.h"
  70. #ifdef __cplusplus
  71. extern "C" {
  72. #endif
  73. /**
  74. * @brief Wait for initial firmware boot to finish
  75. *
  76. * Calls VL53L1_poll_for_boot_completion()
  77. *
  78. * @param[in] Dev : Device handle
  79. *
  80. * @return VL53L1_ERROR_NONE Success
  81. * @return "Other error code" See ::VL53L1_Error
  82. */
  83. VL53L1_Error VL53L1_wait_for_boot_completion(
  84. VL53L1_DEV Dev);
  85. /**
  86. * @brief Waits for initial firmware ready
  87. *
  88. * Only waits to see if the firmware is ready in timed and
  89. * single shot modes.
  90. *
  91. * Calls VL53L1_poll_for_firmware_ready()
  92. *
  93. * @param[in] Dev : Device handle
  94. *
  95. * @return VL53L1_ERROR_NONE Success
  96. * @return "Other error code" See ::VL53L1_Error
  97. */
  98. VL53L1_Error VL53L1_wait_for_firmware_ready(
  99. VL53L1_DEV Dev);
  100. /**
  101. * @brief Waits for the next ranging interrupt
  102. *
  103. * Calls VL53L1_poll_for_range_completion()
  104. *
  105. * @param[in] Dev : Device handle
  106. *
  107. * @return VL53L1_ERROR_NONE Success
  108. * @return "Other error code" See ::VL53L1_Error
  109. */
  110. VL53L1_Error VL53L1_wait_for_range_completion(
  111. VL53L1_DEV Dev);
  112. /**
  113. * @brief Waits for a device test mode to complete.
  114. * Calls VL53L1_poll_for_test_completion()
  115. *
  116. * @param[in] Dev : Device Handle
  117. *
  118. * @return VL53L1_ERROR_NONE Success
  119. * @return "Other error code" See ::VL53L1_Error
  120. */
  121. VL53L1_Error VL53L1_wait_for_test_completion(
  122. VL53L1_DEV Dev);
  123. /**
  124. * @brief Reads FIRMWARE__SYSTEM_STATUS register to detect if the
  125. * firmware was finished booting
  126. *
  127. * @param[in] Dev : Device handle
  128. * @param[out] pready : pointer to data ready flag \n
  129. * 0 = boot not complete \n
  130. * 1 = boot complete
  131. *
  132. * @return VL53L1_ERROR_NONE Success
  133. * @return "Other error code" See ::VL53L1_Error
  134. */
  135. VL53L1_Error VL53L1_is_boot_complete(
  136. VL53L1_DEV Dev,
  137. uint8_t *pready);
  138. /**
  139. * @brief Reads FIRMWARE__SYSTEM_STATUS register to detect if the
  140. * firmware is ready for ranging.
  141. *
  142. * @param[in] Dev : Device handle
  143. * @param[out] pready : pointer to data ready flag \n
  144. * 0 = firmware not ready \n
  145. * 1 = firmware ready
  146. *
  147. * @return VL53L1_ERROR_NONE Success
  148. * @return "Other error code" See ::VL53L1_Error
  149. */
  150. VL53L1_Error VL53L1_is_firmware_ready(
  151. VL53L1_DEV Dev,
  152. uint8_t *pready);
  153. /**
  154. * @brief Reads bit 0 of VL53L1_GPIO__TIO_HV_STATUS register to determine
  155. * if new range data is ready (available).
  156. *
  157. * Interrupt may be either active high or active low. The behaviour of bit 0
  158. * of the VL53L1_GPIO__TIO_HV_STATUS register is the same as the interrupt
  159. * signal generated on the GPIO pin.
  160. *
  161. * pdev->stat_cfg.gpio_hv_mux_ctrl bit 4 is used to select required check level
  162. *
  163. *
  164. * @param[in] Dev : Device handle
  165. * @param[out] pready : pointer to data ready flag \n
  166. * 0 = data not ready \n
  167. * 1 = new range data available
  168. *
  169. * @return VL53L1_ERROR_NONE Success
  170. * @return "Other error code" See ::VL53L1_Error
  171. */
  172. VL53L1_Error VL53L1_is_new_data_ready(
  173. VL53L1_DEV Dev,
  174. uint8_t *pready);
  175. /**
  176. * @brief Waits (polls) for initial firmware boot to finish
  177. *
  178. * After power on or a device reset via XSHUTDOWN EwokPlus25 firmware takes
  179. * about 2ms to boot. During this boot sequence elected NVM data is copied
  180. * to the device's Host & MCU G02 registers
  181. *
  182. * This function polls the FIRMWARE__SYSTEM_STATUS register to detect when
  183. * firmware is ready.
  184. *
  185. * Polling is implemented using VL53L1_WaitValueMaskEx()
  186. *
  187. * @param[in] Dev : Device handle
  188. * @param[in] timeout_ms : Wait timeout in [ms]
  189. *
  190. * @return VL53L1_ERROR_NONE Success
  191. * @return "Other error code" See ::VL53L1_Error
  192. */
  193. VL53L1_Error VL53L1_poll_for_boot_completion(
  194. VL53L1_DEV Dev,
  195. uint32_t timeout_ms);
  196. /**
  197. * @brief Waits (polls) for initial firmware ready
  198. *
  199. * Polling is implemented using VL53L1_WaitValueMaskEx()
  200. *
  201. * @param[in] Dev : Device handle
  202. * @param[in] timeout_ms : Wait timeout in [ms]
  203. *
  204. * @return VL53L1_ERROR_NONE Success
  205. * @return "Other error code" See ::VL53L1_Error
  206. */
  207. VL53L1_Error VL53L1_poll_for_firmware_ready(
  208. VL53L1_DEV Dev,
  209. uint32_t timeout_ms);
  210. /**
  211. * @brief Polls bit 0 of VL53L1_GPIO__TIO_HV_STATUS register to determine
  212. * the state of the GPIO (Interrupt) pin.
  213. *
  214. * Interrupt may be either active high or active low. The behaviour of bit 0
  215. * of the VL53L1_GPIO__TIO_HV_STATUS register is the same as the interrupt
  216. * signal generated on the GPIO pin.
  217. *
  218. * pdev->stat_cfg.gpio_hv_mux_ctrl bit 4 is used to select required check level
  219. *
  220. * Polling is implemented using VL53L1_WaitValueMaskEx()
  221. *
  222. * @param[in] Dev : Device handle
  223. * @param[in] timeout_ms : Wait timeout in [ms]
  224. *
  225. * @return VL53L1_ERROR_NONE Success
  226. * @return "Other error code" See ::VL53L1_Error
  227. */
  228. VL53L1_Error VL53L1_poll_for_range_completion(
  229. VL53L1_DEV Dev,
  230. uint32_t timeout_ms);
  231. #ifdef __cplusplus
  232. }
  233. #endif
  234. #endif /* _VL53L1_WAIT_H_ */