The VL53L1CB proximity sensor, based on ST’s FlightSense™, Time-of-Flight technology.

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   VL53L1CB_noshield_1sensor_polls_auton VL53L1CB_noshield_1sensor_interrupt_auton X_NUCLEO_53L1A2

Based on VL53L1 library, this is a library for the VL53L1CB ToF chip.

Committer:
charlesmn
Date:
Fri Nov 06 10:06:37 2020 +0000
Revision:
0:3ac96e360672
Child:
18:0696efe39d08
Library for ST Vl53L1A1 time of flight sensor.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
charlesmn 0:3ac96e360672 1 /*******************************************************************************
charlesmn 0:3ac96e360672 2 Copyright (C) 2016, STMicroelectronics International N.V.
charlesmn 0:3ac96e360672 3 All rights reserved.
charlesmn 0:3ac96e360672 4
charlesmn 0:3ac96e360672 5 Redistribution and use in source and binary forms, with or without
charlesmn 0:3ac96e360672 6 modification, are permitted provided that the following conditions are met:
charlesmn 0:3ac96e360672 7 * Redistributions of source code must retain the above copyright
charlesmn 0:3ac96e360672 8 notice, this list of conditions and the following disclaimer.
charlesmn 0:3ac96e360672 9 * Redistributions in binary form must reproduce the above copyright
charlesmn 0:3ac96e360672 10 notice, this list of conditions and the following disclaimer in the
charlesmn 0:3ac96e360672 11 documentation and/or other materials provided with the distribution.
charlesmn 0:3ac96e360672 12 * Neither the name of STMicroelectronics nor the
charlesmn 0:3ac96e360672 13 names of its contributors may be used to endorse or promote products
charlesmn 0:3ac96e360672 14 derived from this software without specific prior written permission.
charlesmn 0:3ac96e360672 15
charlesmn 0:3ac96e360672 16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
charlesmn 0:3ac96e360672 17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
charlesmn 0:3ac96e360672 18 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
charlesmn 0:3ac96e360672 19 NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
charlesmn 0:3ac96e360672 20 IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
charlesmn 0:3ac96e360672 21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
charlesmn 0:3ac96e360672 22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
charlesmn 0:3ac96e360672 23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
charlesmn 0:3ac96e360672 24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
charlesmn 0:3ac96e360672 25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
charlesmn 0:3ac96e360672 26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
charlesmn 0:3ac96e360672 27 ******************************************************************************/
charlesmn 0:3ac96e360672 28
charlesmn 0:3ac96e360672 29
charlesmn 0:3ac96e360672 30 #ifndef _VL53L1_PLATFORM_H_
charlesmn 0:3ac96e360672 31 #define _VL53L1_PLATFORM_H_
charlesmn 0:3ac96e360672 32
charlesmn 0:3ac96e360672 33 #include "vl53l1_ll_def.h"
charlesmn 0:3ac96e360672 34 #include "vl53l1_platform_log.h"
charlesmn 0:3ac96e360672 35
charlesmn 0:3ac96e360672 36 #define VL53L1_IPP_API
charlesmn 0:3ac96e360672 37 #include "vl53l1_platform_ipp_imports.h"
charlesmn 0:3ac96e360672 38 #include "vl53l1_platform_user_data.h"
charlesmn 0:3ac96e360672 39
charlesmn 0:3ac96e360672 40 #ifdef __cplusplus
charlesmn 0:3ac96e360672 41 extern "C"
charlesmn 0:3ac96e360672 42 {
charlesmn 0:3ac96e360672 43 #endif
charlesmn 0:3ac96e360672 44
charlesmn 0:3ac96e360672 45 /**
charlesmn 0:3ac96e360672 46 * @file vl53l1_platform.h
charlesmn 0:3ac96e360672 47 *
charlesmn 0:3ac96e360672 48 * @brief All end user OS/platform/application porting
charlesmn 0:3ac96e360672 49 */
charlesmn 0:3ac96e360672 50
charlesmn 0:3ac96e360672 51
charlesmn 0:3ac96e360672 52
charlesmn 0:3ac96e360672 53 /**
charlesmn 0:3ac96e360672 54 * @brief Initialise platform comms.
charlesmn 0:3ac96e360672 55 *
charlesmn 0:3ac96e360672 56 * @param[in] pdev : pointer to device structure (device handle)
charlesmn 0:3ac96e360672 57 * @param[in] comms_type : selects between I2C and SPI
charlesmn 0:3ac96e360672 58 * @param[in] comms_speed_khz : unsigned short containing the I2C speed in kHz
charlesmn 0:3ac96e360672 59 *
charlesmn 0:3ac96e360672 60 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 61 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 62 */
charlesmn 0:3ac96e360672 63
charlesmn 0:3ac96e360672 64 VL53L1_Error VL53L1_CommsInitialise(
charlesmn 0:3ac96e360672 65 VL53L1_Dev_t *pdev,
charlesmn 0:3ac96e360672 66 uint8_t comms_type,
charlesmn 0:3ac96e360672 67 uint16_t comms_speed_khz);
charlesmn 0:3ac96e360672 68
charlesmn 0:3ac96e360672 69
charlesmn 0:3ac96e360672 70 /**
charlesmn 0:3ac96e360672 71 * @brief Close platform comms.
charlesmn 0:3ac96e360672 72 *
charlesmn 0:3ac96e360672 73 * @param[in] pdev : pointer to device structure (device handle)
charlesmn 0:3ac96e360672 74 *
charlesmn 0:3ac96e360672 75 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 76 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 77 */
charlesmn 0:3ac96e360672 78
charlesmn 0:3ac96e360672 79 VL53L1_Error VL53L1_CommsClose(
charlesmn 0:3ac96e360672 80 VL53L1_Dev_t *pdev);
charlesmn 0:3ac96e360672 81
charlesmn 0:3ac96e360672 82
charlesmn 0:3ac96e360672 83 /**
charlesmn 0:3ac96e360672 84 * @brief Writes the supplied byte buffer to the device
charlesmn 0:3ac96e360672 85 *
charlesmn 0:3ac96e360672 86 * @param[in] pdev : pointer to device structure (device handle)
charlesmn 0:3ac96e360672 87 * @param[in] index : uint16_t register index value
charlesmn 0:3ac96e360672 88 * @param[in] pdata : pointer to uint8_t (byte) buffer containing the data to be written
charlesmn 0:3ac96e360672 89 * @param[in] count : number of bytes in the supplied byte buffer
charlesmn 0:3ac96e360672 90 *
charlesmn 0:3ac96e360672 91 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 92 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 93 */
charlesmn 0:3ac96e360672 94
charlesmn 0:3ac96e360672 95 VL53L1_Error VL53L1_WriteMulti(
charlesmn 0:3ac96e360672 96 VL53L1_Dev_t *pdev,
charlesmn 0:3ac96e360672 97 uint16_t index,
charlesmn 0:3ac96e360672 98 uint8_t *pdata,
charlesmn 0:3ac96e360672 99 uint32_t count);
charlesmn 0:3ac96e360672 100
charlesmn 0:3ac96e360672 101
charlesmn 0:3ac96e360672 102 /**
charlesmn 0:3ac96e360672 103 * @brief Reads the requested number of bytes from the device
charlesmn 0:3ac96e360672 104 *
charlesmn 0:3ac96e360672 105 * @param[in] pdev : pointer to device structure (device handle)
charlesmn 0:3ac96e360672 106 * @param[in] index : uint16_t register index value
charlesmn 0:3ac96e360672 107 * @param[out] pdata : pointer to the uint8_t (byte) buffer to store read data
charlesmn 0:3ac96e360672 108 * @param[in] count : number of bytes to read
charlesmn 0:3ac96e360672 109 *
charlesmn 0:3ac96e360672 110 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 111 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 112 */
charlesmn 0:3ac96e360672 113
charlesmn 0:3ac96e360672 114 VL53L1_Error VL53L1_ReadMulti(
charlesmn 0:3ac96e360672 115 VL53L1_Dev_t *pdev,
charlesmn 0:3ac96e360672 116 uint16_t index,
charlesmn 0:3ac96e360672 117 uint8_t *pdata,
charlesmn 0:3ac96e360672 118 uint32_t count);
charlesmn 0:3ac96e360672 119
charlesmn 0:3ac96e360672 120
charlesmn 0:3ac96e360672 121 /**
charlesmn 0:3ac96e360672 122 * @brief Writes a single byte to the device
charlesmn 0:3ac96e360672 123 *
charlesmn 0:3ac96e360672 124 * @param[in] pdev : pointer to device structure (device handle)
charlesmn 0:3ac96e360672 125 * @param[in] index : uint16_t register index value
charlesmn 0:3ac96e360672 126 * @param[in] data : uint8_t data value to write
charlesmn 0:3ac96e360672 127 *
charlesmn 0:3ac96e360672 128 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 129 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 130 */
charlesmn 0:3ac96e360672 131
charlesmn 0:3ac96e360672 132 VL53L1_Error VL53L1_WrByte(
charlesmn 0:3ac96e360672 133 VL53L1_Dev_t *pdev,
charlesmn 0:3ac96e360672 134 uint16_t index,
charlesmn 0:3ac96e360672 135 uint8_t data);
charlesmn 0:3ac96e360672 136
charlesmn 0:3ac96e360672 137
charlesmn 0:3ac96e360672 138 /**
charlesmn 0:3ac96e360672 139 * @brief Writes a single word (16-bit unsigned) to the device
charlesmn 0:3ac96e360672 140 *
charlesmn 0:3ac96e360672 141 * Manages the big-endian nature of the device register map
charlesmn 0:3ac96e360672 142 * (first byte written is the MS byte).
charlesmn 0:3ac96e360672 143 *
charlesmn 0:3ac96e360672 144 * @param[in] pdev : pointer to device structure (device handle)
charlesmn 0:3ac96e360672 145 * @param[in] index : uint16_t register index value
charlesmn 0:3ac96e360672 146 * @param[in] data : uin16_t data value write
charlesmn 0:3ac96e360672 147 *
charlesmn 0:3ac96e360672 148 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 149 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 150 */
charlesmn 0:3ac96e360672 151
charlesmn 0:3ac96e360672 152 VL53L1_Error VL53L1_WrWord(
charlesmn 0:3ac96e360672 153 VL53L1_Dev_t *pdev,
charlesmn 0:3ac96e360672 154 uint16_t index,
charlesmn 0:3ac96e360672 155 uint16_t data);
charlesmn 0:3ac96e360672 156
charlesmn 0:3ac96e360672 157
charlesmn 0:3ac96e360672 158 /**
charlesmn 0:3ac96e360672 159 * @brief Writes a single dword (32-bit unsigned) to the device
charlesmn 0:3ac96e360672 160 *
charlesmn 0:3ac96e360672 161 * Manages the big-endian nature of the device register map
charlesmn 0:3ac96e360672 162 * (first byte written is the MS byte).
charlesmn 0:3ac96e360672 163 *
charlesmn 0:3ac96e360672 164 * @param[in] pdev : pointer to device structure (device handle)
charlesmn 0:3ac96e360672 165 * @param[in] index : uint16_t register index value
charlesmn 0:3ac96e360672 166 * @param[in] data : uint32_t data value to write
charlesmn 0:3ac96e360672 167 *
charlesmn 0:3ac96e360672 168 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 169 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 170 */
charlesmn 0:3ac96e360672 171
charlesmn 0:3ac96e360672 172 VL53L1_Error VL53L1_WrDWord(
charlesmn 0:3ac96e360672 173 VL53L1_Dev_t *pdev,
charlesmn 0:3ac96e360672 174 uint16_t index,
charlesmn 0:3ac96e360672 175 uint32_t data);
charlesmn 0:3ac96e360672 176
charlesmn 0:3ac96e360672 177
charlesmn 0:3ac96e360672 178
charlesmn 0:3ac96e360672 179 /**
charlesmn 0:3ac96e360672 180 * @brief Reads a single byte from the device
charlesmn 0:3ac96e360672 181 *
charlesmn 0:3ac96e360672 182 * @param[in] pdev : pointer to device structure (device handle)
charlesmn 0:3ac96e360672 183 * @param[in] index : uint16_t register index
charlesmn 0:3ac96e360672 184 * @param[out] pdata : pointer to uint8_t data value
charlesmn 0:3ac96e360672 185 *
charlesmn 0:3ac96e360672 186 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 187 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 188 *
charlesmn 0:3ac96e360672 189 */
charlesmn 0:3ac96e360672 190
charlesmn 0:3ac96e360672 191 VL53L1_Error VL53L1_RdByte(
charlesmn 0:3ac96e360672 192 VL53L1_Dev_t *pdev,
charlesmn 0:3ac96e360672 193 uint16_t index,
charlesmn 0:3ac96e360672 194 uint8_t *pdata);
charlesmn 0:3ac96e360672 195
charlesmn 0:3ac96e360672 196
charlesmn 0:3ac96e360672 197 /**
charlesmn 0:3ac96e360672 198 * @brief Reads a single word (16-bit unsigned) from the device
charlesmn 0:3ac96e360672 199 *
charlesmn 0:3ac96e360672 200 * Manages the big-endian nature of the device (first byte read is the MS byte).
charlesmn 0:3ac96e360672 201 *
charlesmn 0:3ac96e360672 202 * @param[in] pdev : pointer to device structure (device handle)
charlesmn 0:3ac96e360672 203 * @param[in] index : uint16_t register index value
charlesmn 0:3ac96e360672 204 * @param[out] pdata : pointer to uint16_t data value
charlesmn 0:3ac96e360672 205 *
charlesmn 0:3ac96e360672 206 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 207 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 208 */
charlesmn 0:3ac96e360672 209
charlesmn 0:3ac96e360672 210 VL53L1_Error VL53L1_RdWord(
charlesmn 0:3ac96e360672 211 VL53L1_Dev_t *pdev,
charlesmn 0:3ac96e360672 212 uint16_t index,
charlesmn 0:3ac96e360672 213 uint16_t *pdata);
charlesmn 0:3ac96e360672 214
charlesmn 0:3ac96e360672 215
charlesmn 0:3ac96e360672 216 /**
charlesmn 0:3ac96e360672 217 * @brief Reads a single dword (32-bit unsigned) from the device
charlesmn 0:3ac96e360672 218 *
charlesmn 0:3ac96e360672 219 * Manages the big-endian nature of the device (first byte read is the MS byte).
charlesmn 0:3ac96e360672 220 *
charlesmn 0:3ac96e360672 221 * @param[in] pdev : pointer to device structure (device handle)
charlesmn 0:3ac96e360672 222 * @param[in] index : uint16_t register index value
charlesmn 0:3ac96e360672 223 * @param[out] pdata : pointer to uint32_t data value
charlesmn 0:3ac96e360672 224 *
charlesmn 0:3ac96e360672 225 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 226 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 227 */
charlesmn 0:3ac96e360672 228
charlesmn 0:3ac96e360672 229 VL53L1_Error VL53L1_RdDWord(
charlesmn 0:3ac96e360672 230 VL53L1_Dev_t *pdev,
charlesmn 0:3ac96e360672 231 uint16_t index,
charlesmn 0:3ac96e360672 232 uint32_t *pdata);
charlesmn 0:3ac96e360672 233
charlesmn 0:3ac96e360672 234
charlesmn 0:3ac96e360672 235
charlesmn 0:3ac96e360672 236 /**
charlesmn 0:3ac96e360672 237 * @brief Implements a programmable wait in us
charlesmn 0:3ac96e360672 238 *
charlesmn 0:3ac96e360672 239 * @param[in] pdev : pointer to device structure (device handle)
charlesmn 0:3ac96e360672 240 * @param[in] wait_us : integer wait in micro seconds
charlesmn 0:3ac96e360672 241 *
charlesmn 0:3ac96e360672 242 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 243 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 244 */
charlesmn 0:3ac96e360672 245
charlesmn 0:3ac96e360672 246 VL53L1_Error VL53L1_WaitUs(
charlesmn 0:3ac96e360672 247 VL53L1_Dev_t *pdev,
charlesmn 0:3ac96e360672 248 int32_t wait_us);
charlesmn 0:3ac96e360672 249
charlesmn 0:3ac96e360672 250
charlesmn 0:3ac96e360672 251 /**
charlesmn 0:3ac96e360672 252 * @brief Implements a programmable wait in ms
charlesmn 0:3ac96e360672 253 *
charlesmn 0:3ac96e360672 254 * @param[in] pdev : pointer to device structure (device handle)
charlesmn 0:3ac96e360672 255 * @param[in] wait_ms : integer wait in milliseconds
charlesmn 0:3ac96e360672 256 *
charlesmn 0:3ac96e360672 257 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 258 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 259 */
charlesmn 0:3ac96e360672 260
charlesmn 0:3ac96e360672 261 VL53L1_Error VL53L1_WaitMs(
charlesmn 0:3ac96e360672 262 VL53L1_Dev_t *pdev,
charlesmn 0:3ac96e360672 263 int32_t wait_ms);
charlesmn 0:3ac96e360672 264
charlesmn 0:3ac96e360672 265
charlesmn 0:3ac96e360672 266 /**
charlesmn 0:3ac96e360672 267 * @brief Get the frequency of the timer used for ranging results time stamps
charlesmn 0:3ac96e360672 268 *
charlesmn 0:3ac96e360672 269 * @param[out] ptimer_freq_hz : pointer for timer frequency
charlesmn 0:3ac96e360672 270 *
charlesmn 0:3ac96e360672 271 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 272 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 273 */
charlesmn 0:3ac96e360672 274
charlesmn 0:3ac96e360672 275 VL53L1_Error VL53L1_GetTimerFrequency(int32_t *ptimer_freq_hz);
charlesmn 0:3ac96e360672 276
charlesmn 0:3ac96e360672 277 /**
charlesmn 0:3ac96e360672 278 * @brief Get the timer value in units of timer_freq_hz (see VL53L1_get_timestamp_frequency())
charlesmn 0:3ac96e360672 279 *
charlesmn 0:3ac96e360672 280 * @param[out] ptimer_count : pointer for timer count value
charlesmn 0:3ac96e360672 281 *
charlesmn 0:3ac96e360672 282 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 283 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 284 */
charlesmn 0:3ac96e360672 285
charlesmn 0:3ac96e360672 286 VL53L1_Error VL53L1_GetTimerValue(int32_t *ptimer_count);
charlesmn 0:3ac96e360672 287
charlesmn 0:3ac96e360672 288
charlesmn 0:3ac96e360672 289 /**
charlesmn 0:3ac96e360672 290 * @brief Set the mode of a specified GPIO pin
charlesmn 0:3ac96e360672 291 *
charlesmn 0:3ac96e360672 292 * @param pin - an identifier specifying the pin being modified - defined per platform
charlesmn 0:3ac96e360672 293 *
charlesmn 0:3ac96e360672 294 * @param mode - an identifier specifying the requested mode - defined per platform
charlesmn 0:3ac96e360672 295 *
charlesmn 0:3ac96e360672 296 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 297 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 298 */
charlesmn 0:3ac96e360672 299
charlesmn 0:3ac96e360672 300 VL53L1_Error VL53L1_GpioSetMode(uint8_t pin, uint8_t mode);
charlesmn 0:3ac96e360672 301
charlesmn 0:3ac96e360672 302
charlesmn 0:3ac96e360672 303 /**
charlesmn 0:3ac96e360672 304 * @brief Set the value of a specified GPIO pin
charlesmn 0:3ac96e360672 305 *
charlesmn 0:3ac96e360672 306 * @param pin - an identifier specifying the pin being modified - defined per platform
charlesmn 0:3ac96e360672 307 *
charlesmn 0:3ac96e360672 308 * @param value - a value to set on the GPIO pin - typically 0 or 1
charlesmn 0:3ac96e360672 309 *
charlesmn 0:3ac96e360672 310 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 311 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 312 */
charlesmn 0:3ac96e360672 313
charlesmn 0:3ac96e360672 314 VL53L1_Error VL53L1_GpioSetValue(uint8_t pin, uint8_t value);
charlesmn 0:3ac96e360672 315
charlesmn 0:3ac96e360672 316
charlesmn 0:3ac96e360672 317 /**
charlesmn 0:3ac96e360672 318 * @brief Get the value of a specified GPIO pin
charlesmn 0:3ac96e360672 319 *
charlesmn 0:3ac96e360672 320 * @param pin - an identifier specifying the pin being modified - defined per platform
charlesmn 0:3ac96e360672 321 *
charlesmn 0:3ac96e360672 322 * @param pvalue - a value retrieved from the GPIO pin - typically 0 or 1
charlesmn 0:3ac96e360672 323 *
charlesmn 0:3ac96e360672 324 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 325 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 326 */
charlesmn 0:3ac96e360672 327
charlesmn 0:3ac96e360672 328 VL53L1_Error VL53L1_GpioGetValue(uint8_t pin, uint8_t *pvalue);
charlesmn 0:3ac96e360672 329
charlesmn 0:3ac96e360672 330
charlesmn 0:3ac96e360672 331 /**
charlesmn 0:3ac96e360672 332 * @brief Sets and clears the XShutdown pin on the Ewok
charlesmn 0:3ac96e360672 333 *
charlesmn 0:3ac96e360672 334 * @param value - the value for xshutdown - 0 = in reset, 1 = operational
charlesmn 0:3ac96e360672 335 *
charlesmn 0:3ac96e360672 336 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 337 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 338 */
charlesmn 0:3ac96e360672 339
charlesmn 0:3ac96e360672 340 VL53L1_Error VL53L1_GpioXshutdown(uint8_t value);
charlesmn 0:3ac96e360672 341
charlesmn 0:3ac96e360672 342
charlesmn 0:3ac96e360672 343 /**
charlesmn 0:3ac96e360672 344 * @brief Sets and clears the Comms Mode pin (NCS) on the Ewok
charlesmn 0:3ac96e360672 345 *
charlesmn 0:3ac96e360672 346 * @param value - the value for comms select - 0 = I2C, 1 = SPI
charlesmn 0:3ac96e360672 347 *
charlesmn 0:3ac96e360672 348 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 349 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 350 */
charlesmn 0:3ac96e360672 351
charlesmn 0:3ac96e360672 352 VL53L1_Error VL53L1_GpioCommsSelect(uint8_t value);
charlesmn 0:3ac96e360672 353
charlesmn 0:3ac96e360672 354
charlesmn 0:3ac96e360672 355 /**
charlesmn 0:3ac96e360672 356 * @brief Enables and disables the power to the Ewok module
charlesmn 0:3ac96e360672 357 *
charlesmn 0:3ac96e360672 358 * @param value - the state of the power supply - 0 = power off, 1 = power on
charlesmn 0:3ac96e360672 359 *
charlesmn 0:3ac96e360672 360 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 361 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 362 */
charlesmn 0:3ac96e360672 363
charlesmn 0:3ac96e360672 364 VL53L1_Error VL53L1_GpioPowerEnable(uint8_t value);
charlesmn 0:3ac96e360672 365
charlesmn 0:3ac96e360672 366 /**
charlesmn 0:3ac96e360672 367 * @brief Enables callbacks to the supplied funtion pointer when Ewok interrupts ocurr
charlesmn 0:3ac96e360672 368 *
charlesmn 0:3ac96e360672 369 * @param function - a function callback supplies by the caller, for interrupt notification
charlesmn 0:3ac96e360672 370 * @param edge_type - falling edge or rising edge interrupt detection
charlesmn 0:3ac96e360672 371 *
charlesmn 0:3ac96e360672 372 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 373 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 374 */
charlesmn 0:3ac96e360672 375
charlesmn 0:3ac96e360672 376 VL53L1_Error VL53L1_GpioInterruptEnable(void (*function)(void), uint8_t edge_type);
charlesmn 0:3ac96e360672 377
charlesmn 0:3ac96e360672 378
charlesmn 0:3ac96e360672 379 /**
charlesmn 0:3ac96e360672 380 * @brief Disables the callback on Ewok interrupts
charlesmn 0:3ac96e360672 381 *
charlesmn 0:3ac96e360672 382 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 383 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 384 */
charlesmn 0:3ac96e360672 385
charlesmn 0:3ac96e360672 386 VL53L1_Error VL53L1_GpioInterruptDisable(void);
charlesmn 0:3ac96e360672 387
charlesmn 0:3ac96e360672 388
charlesmn 0:3ac96e360672 389 /*
charlesmn 0:3ac96e360672 390 * @brief Gets current system tick count in [ms]
charlesmn 0:3ac96e360672 391 *
charlesmn 0:3ac96e360672 392 * @return time_ms : current time in [ms]
charlesmn 0:3ac96e360672 393 *
charlesmn 0:3ac96e360672 394 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 395 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 396 */
charlesmn 0:3ac96e360672 397
charlesmn 0:3ac96e360672 398 VL53L1_Error VL53L1_GetTickCount(
charlesmn 0:3ac96e360672 399 uint32_t *ptime_ms);
charlesmn 0:3ac96e360672 400
charlesmn 0:3ac96e360672 401
charlesmn 0:3ac96e360672 402 /**
charlesmn 0:3ac96e360672 403 * @brief Register "wait for value" polling routine
charlesmn 0:3ac96e360672 404 *
charlesmn 0:3ac96e360672 405 * Port of the V2WReg Script function WaitValueMaskEx()
charlesmn 0:3ac96e360672 406 *
charlesmn 0:3ac96e360672 407 * @param[in] pdev : pointer to device structure (device handle)
charlesmn 0:3ac96e360672 408 * @param[in] timeout_ms : timeout in [ms]
charlesmn 0:3ac96e360672 409 * @param[in] index : uint16_t register index value
charlesmn 0:3ac96e360672 410 * @param[in] value : value to wait for
charlesmn 0:3ac96e360672 411 * @param[in] mask : mask to be applied before comparison with value
charlesmn 0:3ac96e360672 412 * @param[in] poll_delay_ms : polling delay been each read transaction in [ms]
charlesmn 0:3ac96e360672 413 *
charlesmn 0:3ac96e360672 414 * @return VL53L1_ERROR_NONE Success
charlesmn 0:3ac96e360672 415 * @return "Other error code" See ::VL53L1_Error
charlesmn 0:3ac96e360672 416 */
charlesmn 0:3ac96e360672 417
charlesmn 0:3ac96e360672 418 VL53L1_Error VL53L1_WaitValueMaskEx(
charlesmn 0:3ac96e360672 419 VL53L1_Dev_t *pdev,
charlesmn 0:3ac96e360672 420 uint32_t timeout_ms,
charlesmn 0:3ac96e360672 421 uint16_t index,
charlesmn 0:3ac96e360672 422 uint8_t value,
charlesmn 0:3ac96e360672 423 uint8_t mask,
charlesmn 0:3ac96e360672 424 uint32_t poll_delay_ms);
charlesmn 0:3ac96e360672 425
charlesmn 0:3ac96e360672 426 #ifdef __cplusplus
charlesmn 0:3ac96e360672 427 }
charlesmn 0:3ac96e360672 428 #endif
charlesmn 0:3ac96e360672 429
charlesmn 0:3ac96e360672 430 #endif
charlesmn 0:3ac96e360672 431
charlesmn 0:3ac96e360672 432