vl53l1_platform.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. #ifndef _VL53L1_PLATFORM_H_
  63. #define _VL53L1_PLATFORM_H_
  64. #include "vl53l1_ll_def.h"
  65. #include "vl53l1_platform_log.h"
  66. #define VL53L1_IPP_API
  67. #include "vl53l1_platform_user_data.h"
  68. #ifdef __cplusplus
  69. extern "C"
  70. {
  71. #endif
  72. #include "nrf_delay.h"
  73. #include "bsp_time.h"
  74. #define HAL_Delay(x) nrf_delay_ms(x)
  75. #define HAL_GetTick() TIME_GetTicks()
  76. VL53L1_Error VL53L1_CommsInitialise(
  77. VL53L1_Dev_t *pdev,
  78. uint8_t comms_type,
  79. uint16_t comms_speed_khz);
  80. VL53L1_Error VL53L1_CommsClose(
  81. VL53L1_Dev_t *pdev);
  82. VL53L1_Error VL53L1_WriteMulti(
  83. VL53L1_Dev_t *pdev,
  84. uint16_t index,
  85. uint8_t *pdata,
  86. uint32_t count);
  87. VL53L1_Error VL53L1_ReadMulti(
  88. VL53L1_Dev_t *pdev,
  89. uint16_t index,
  90. uint8_t *pdata,
  91. uint32_t count);
  92. VL53L1_Error VL53L1_WrByte(
  93. VL53L1_Dev_t *pdev,
  94. uint16_t index,
  95. uint8_t VL53L1_PRM_00005);
  96. VL53L1_Error VL53L1_WrWord(
  97. VL53L1_Dev_t *pdev,
  98. uint16_t index,
  99. uint16_t VL53L1_PRM_00005);
  100. VL53L1_Error VL53L1_WrDWord(
  101. VL53L1_Dev_t *pdev,
  102. uint16_t index,
  103. uint32_t VL53L1_PRM_00005);
  104. VL53L1_Error VL53L1_RdByte(
  105. VL53L1_Dev_t *pdev,
  106. uint16_t index,
  107. uint8_t *pdata);
  108. VL53L1_Error VL53L1_RdWord(
  109. VL53L1_Dev_t *pdev,
  110. uint16_t index,
  111. uint16_t *pdata);
  112. VL53L1_Error VL53L1_RdDWord(
  113. VL53L1_Dev_t *pdev,
  114. uint16_t index,
  115. uint32_t *pdata);
  116. VL53L1_Error VL53L1_WaitUs(
  117. VL53L1_Dev_t *pdev,
  118. int32_t wait_us);
  119. VL53L1_Error VL53L1_WaitMs(
  120. VL53L1_Dev_t *pdev,
  121. int32_t wait_ms);
  122. VL53L1_Error VL53L1_GetTimerFrequency(int32_t *ptimer_freq_hz);
  123. VL53L1_Error VL53L1_GetTimerValue(int32_t *ptimer_count);
  124. VL53L1_Error VL53L1_GpioSetMode(uint8_t pin, uint8_t mode);
  125. VL53L1_Error VL53L1_GpioSetValue(uint8_t pin, uint8_t value);
  126. VL53L1_Error VL53L1_GpioGetValue(uint8_t pin, uint8_t *pvalue);
  127. VL53L1_Error VL53L1_GpioXshutdown(uint8_t value);
  128. VL53L1_Error VL53L1_GpioCommsSelect(uint8_t value);
  129. VL53L1_Error VL53L1_GpioPowerEnable(uint8_t value);
  130. VL53L1_Error VL53L1_GpioInterruptEnable(void (*function)(void), uint8_t edge_type);
  131. VL53L1_Error VL53L1_GpioInterruptDisable(void);
  132. VL53L1_Error VL53L1_GetTickCount(
  133. uint32_t *ptime_ms);
  134. VL53L1_Error VL53L1_WaitValueMaskEx(
  135. VL53L1_Dev_t *pdev,
  136. uint32_t timeout_ms,
  137. uint16_t index,
  138. uint8_t value,
  139. uint8_t mask,
  140. uint32_t poll_delay_ms);
  141. #ifdef __cplusplus
  142. }
  143. #endif
  144. #endif