VL53L0X World smallest Time-of-Flight (ToF) ranging sensor

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   HelloWorld_ST_Sensors mbed-os-mqtt-client Multi_VL53L0X DISCO-IOT01_HomeEnv ... more

Fork of VL53L0X by Nicola Capovilla

Committer:
johnAlexander
Date:
Thu Jun 06 09:21:39 2019 +0000
Revision:
6:8ac15bf6d635
Publish mbed-certified sensor class.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
johnAlexander 6:8ac15bf6d635 1 /*
johnAlexander 6:8ac15bf6d635 2 * COPYRIGHT (C) STMicroelectronics 2014. All rights reserved.
johnAlexander 6:8ac15bf6d635 3 *
johnAlexander 6:8ac15bf6d635 4 * This software is the confidential and proprietary information of
johnAlexander 6:8ac15bf6d635 5 * STMicroelectronics ("Confidential Information"). You shall not
johnAlexander 6:8ac15bf6d635 6 * disclose such Confidential Information and shall use it only in
johnAlexander 6:8ac15bf6d635 7 * accordance with the terms of the license agreement you entered into
johnAlexander 6:8ac15bf6d635 8 * with STMicroelectronics
johnAlexander 6:8ac15bf6d635 9 *
johnAlexander 6:8ac15bf6d635 10 * Programming Golden Rule: Keep it Simple!
johnAlexander 6:8ac15bf6d635 11 *
johnAlexander 6:8ac15bf6d635 12 */
johnAlexander 6:8ac15bf6d635 13
johnAlexander 6:8ac15bf6d635 14 /**
johnAlexander 6:8ac15bf6d635 15 * @file VL53L0X_platform.h
johnAlexander 6:8ac15bf6d635 16 * @brief Function prototype definitions for Ewok Platform layer.
johnAlexander 6:8ac15bf6d635 17 *
johnAlexander 6:8ac15bf6d635 18 */
johnAlexander 6:8ac15bf6d635 19
johnAlexander 6:8ac15bf6d635 20
johnAlexander 6:8ac15bf6d635 21 #ifndef _VL53L0X_I2C_PLATFORM_H_
johnAlexander 6:8ac15bf6d635 22 #define _VL53L0X_I2C_PLATFORM_H_
johnAlexander 6:8ac15bf6d635 23
johnAlexander 6:8ac15bf6d635 24 #include "VL53L0X_def.h"
johnAlexander 6:8ac15bf6d635 25
johnAlexander 6:8ac15bf6d635 26 #ifdef __cplusplus
johnAlexander 6:8ac15bf6d635 27 extern "C" {
johnAlexander 6:8ac15bf6d635 28 #endif
johnAlexander 6:8ac15bf6d635 29
johnAlexander 6:8ac15bf6d635 30 // Include uint8_t, unit16_t etc definitions
johnAlexander 6:8ac15bf6d635 31
johnAlexander 6:8ac15bf6d635 32 #include <stdint.h>
johnAlexander 6:8ac15bf6d635 33 #include <stdarg.h>
johnAlexander 6:8ac15bf6d635 34
johnAlexander 6:8ac15bf6d635 35
johnAlexander 6:8ac15bf6d635 36 /**
johnAlexander 6:8ac15bf6d635 37 * @brief Typedef defining .\n
johnAlexander 6:8ac15bf6d635 38 * The developer shoud modify this to suit the platform being deployed.
johnAlexander 6:8ac15bf6d635 39 *
johnAlexander 6:8ac15bf6d635 40 */
johnAlexander 6:8ac15bf6d635 41
johnAlexander 6:8ac15bf6d635 42 // enum {TRUE = true, FALSE = false};
johnAlexander 6:8ac15bf6d635 43
johnAlexander 6:8ac15bf6d635 44 /**
johnAlexander 6:8ac15bf6d635 45 * @brief Typedef defining 8 bit unsigned char type.\n
johnAlexander 6:8ac15bf6d635 46 * The developer shoud modify this to suit the platform being deployed.
johnAlexander 6:8ac15bf6d635 47 *
johnAlexander 6:8ac15bf6d635 48 */
johnAlexander 6:8ac15bf6d635 49
johnAlexander 6:8ac15bf6d635 50 #ifndef bool_t
johnAlexander 6:8ac15bf6d635 51 typedef unsigned char bool_t;
johnAlexander 6:8ac15bf6d635 52 #endif
johnAlexander 6:8ac15bf6d635 53
johnAlexander 6:8ac15bf6d635 54
johnAlexander 6:8ac15bf6d635 55 #define I2C 0x01
johnAlexander 6:8ac15bf6d635 56 #define SPI 0x00
johnAlexander 6:8ac15bf6d635 57
johnAlexander 6:8ac15bf6d635 58 #define COMMS_BUFFER_SIZE 64 // MUST be the same size as the SV task buffer
johnAlexander 6:8ac15bf6d635 59
johnAlexander 6:8ac15bf6d635 60 #define BYTES_PER_WORD 2
johnAlexander 6:8ac15bf6d635 61 #define BYTES_PER_DWORD 4
johnAlexander 6:8ac15bf6d635 62
johnAlexander 6:8ac15bf6d635 63 #define VL53L0X_MAX_STRING_LENGTH_PLT 256
johnAlexander 6:8ac15bf6d635 64
johnAlexander 6:8ac15bf6d635 65 /**
johnAlexander 6:8ac15bf6d635 66 * @brief Initialise platform comms.
johnAlexander 6:8ac15bf6d635 67 *
johnAlexander 6:8ac15bf6d635 68 * @param comms_type - selects between I2C and SPI
johnAlexander 6:8ac15bf6d635 69 * @param comms_speed_khz - unsigned short containing the I2C speed in kHz
johnAlexander 6:8ac15bf6d635 70 *
johnAlexander 6:8ac15bf6d635 71 * @return status - status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 72 *
johnAlexander 6:8ac15bf6d635 73 */
johnAlexander 6:8ac15bf6d635 74
johnAlexander 6:8ac15bf6d635 75 int32_t VL53L0X_comms_initialise(uint8_t comms_type,
johnAlexander 6:8ac15bf6d635 76 uint16_t comms_speed_khz);
johnAlexander 6:8ac15bf6d635 77
johnAlexander 6:8ac15bf6d635 78 /**
johnAlexander 6:8ac15bf6d635 79 * @brief Initialise platform serial comms.
johnAlexander 6:8ac15bf6d635 80 *
johnAlexander 6:8ac15bf6d635 81 * @param comPortStr - String to indicate the comm port
johnAlexander 6:8ac15bf6d635 82 * @param baudRate - Bau rate
johnAlexander 6:8ac15bf6d635 83 *
johnAlexander 6:8ac15bf6d635 84 * @return status - status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 85 *
johnAlexander 6:8ac15bf6d635 86 */
johnAlexander 6:8ac15bf6d635 87 int VL53L0_i2c_init(char *comPortStr, unsigned int baudRate);
johnAlexander 6:8ac15bf6d635 88
johnAlexander 6:8ac15bf6d635 89
johnAlexander 6:8ac15bf6d635 90 /**
johnAlexander 6:8ac15bf6d635 91 * @brief Close platform comms.
johnAlexander 6:8ac15bf6d635 92 *
johnAlexander 6:8ac15bf6d635 93 * @return status - status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 94 *
johnAlexander 6:8ac15bf6d635 95 */
johnAlexander 6:8ac15bf6d635 96
johnAlexander 6:8ac15bf6d635 97 int32_t VL53L0X_comms_close(void);
johnAlexander 6:8ac15bf6d635 98
johnAlexander 6:8ac15bf6d635 99 /**
johnAlexander 6:8ac15bf6d635 100 * @brief Cycle Power to Device
johnAlexander 6:8ac15bf6d635 101 *
johnAlexander 6:8ac15bf6d635 102 * @return status - status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 103 *
johnAlexander 6:8ac15bf6d635 104 */
johnAlexander 6:8ac15bf6d635 105
johnAlexander 6:8ac15bf6d635 106 int32_t VL53L0X_cycle_power(void);
johnAlexander 6:8ac15bf6d635 107
johnAlexander 6:8ac15bf6d635 108
johnAlexander 6:8ac15bf6d635 109 /**
johnAlexander 6:8ac15bf6d635 110 * @brief Writes the supplied byte buffer to the device
johnAlexander 6:8ac15bf6d635 111 *
johnAlexander 6:8ac15bf6d635 112 * Wrapper for SystemVerilog Write Multi task
johnAlexander 6:8ac15bf6d635 113 *
johnAlexander 6:8ac15bf6d635 114 * @code
johnAlexander 6:8ac15bf6d635 115 *
johnAlexander 6:8ac15bf6d635 116 * Example:
johnAlexander 6:8ac15bf6d635 117 *
johnAlexander 6:8ac15bf6d635 118 * uint8_t *spad_enables;
johnAlexander 6:8ac15bf6d635 119 *
johnAlexander 6:8ac15bf6d635 120 * int status = VL53L0X_write_multi(RET_SPAD_EN_0, spad_enables, 36);
johnAlexander 6:8ac15bf6d635 121 *
johnAlexander 6:8ac15bf6d635 122 * @endcode
johnAlexander 6:8ac15bf6d635 123 *
johnAlexander 6:8ac15bf6d635 124 * @param address - uint8_t device address value
johnAlexander 6:8ac15bf6d635 125 * @param index - uint8_t register index value
johnAlexander 6:8ac15bf6d635 126 * @param pdata - pointer to uint8_t buffer containing the data to be written
johnAlexander 6:8ac15bf6d635 127 * @param count - number of bytes in the supplied byte buffer
johnAlexander 6:8ac15bf6d635 128 *
johnAlexander 6:8ac15bf6d635 129 * @return status - SystemVerilog status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 130 *
johnAlexander 6:8ac15bf6d635 131 */
johnAlexander 6:8ac15bf6d635 132
johnAlexander 6:8ac15bf6d635 133 int32_t VL53L0X_write_multi(uint8_t address, uint8_t index, uint8_t *pdata, int32_t count);
johnAlexander 6:8ac15bf6d635 134
johnAlexander 6:8ac15bf6d635 135
johnAlexander 6:8ac15bf6d635 136 /**
johnAlexander 6:8ac15bf6d635 137 * @brief Reads the requested number of bytes from the device
johnAlexander 6:8ac15bf6d635 138 *
johnAlexander 6:8ac15bf6d635 139 * Wrapper for SystemVerilog Read Multi task
johnAlexander 6:8ac15bf6d635 140 *
johnAlexander 6:8ac15bf6d635 141 * @code
johnAlexander 6:8ac15bf6d635 142 *
johnAlexander 6:8ac15bf6d635 143 * Example:
johnAlexander 6:8ac15bf6d635 144 *
johnAlexander 6:8ac15bf6d635 145 * uint8_t buffer[COMMS_BUFFER_SIZE];
johnAlexander 6:8ac15bf6d635 146 *
johnAlexander 6:8ac15bf6d635 147 * int status = status = VL53L0X_read_multi(DEVICE_ID, buffer, 2)
johnAlexander 6:8ac15bf6d635 148 *
johnAlexander 6:8ac15bf6d635 149 * @endcode
johnAlexander 6:8ac15bf6d635 150 *
johnAlexander 6:8ac15bf6d635 151 * @param address - uint8_t device address value
johnAlexander 6:8ac15bf6d635 152 * @param index - uint8_t register index value
johnAlexander 6:8ac15bf6d635 153 * @param pdata - pointer to the uint8_t buffer to store read data
johnAlexander 6:8ac15bf6d635 154 * @param count - number of uint8_t's to read
johnAlexander 6:8ac15bf6d635 155 *
johnAlexander 6:8ac15bf6d635 156 * @return status - SystemVerilog status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 157 *
johnAlexander 6:8ac15bf6d635 158 */
johnAlexander 6:8ac15bf6d635 159
johnAlexander 6:8ac15bf6d635 160 int32_t VL53L0X_read_multi(uint8_t address, uint8_t index, uint8_t *pdata, int32_t count);
johnAlexander 6:8ac15bf6d635 161
johnAlexander 6:8ac15bf6d635 162
johnAlexander 6:8ac15bf6d635 163 /**
johnAlexander 6:8ac15bf6d635 164 * @brief Writes a single byte to the device
johnAlexander 6:8ac15bf6d635 165 *
johnAlexander 6:8ac15bf6d635 166 * Wrapper for SystemVerilog Write Byte task
johnAlexander 6:8ac15bf6d635 167 *
johnAlexander 6:8ac15bf6d635 168 * @code
johnAlexander 6:8ac15bf6d635 169 *
johnAlexander 6:8ac15bf6d635 170 * Example:
johnAlexander 6:8ac15bf6d635 171 *
johnAlexander 6:8ac15bf6d635 172 * uint8_t page_number = MAIN_SELECT_PAGE;
johnAlexander 6:8ac15bf6d635 173 *
johnAlexander 6:8ac15bf6d635 174 * int status = VL53L0X_write_byte(PAGE_SELECT, page_number);
johnAlexander 6:8ac15bf6d635 175 *
johnAlexander 6:8ac15bf6d635 176 * @endcode
johnAlexander 6:8ac15bf6d635 177 *
johnAlexander 6:8ac15bf6d635 178 * @param address - uint8_t device address value
johnAlexander 6:8ac15bf6d635 179 * @param index - uint8_t register index value
johnAlexander 6:8ac15bf6d635 180 * @param data - uint8_t data value to write
johnAlexander 6:8ac15bf6d635 181 *
johnAlexander 6:8ac15bf6d635 182 * @return status - SystemVerilog status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 183 *
johnAlexander 6:8ac15bf6d635 184 */
johnAlexander 6:8ac15bf6d635 185
johnAlexander 6:8ac15bf6d635 186 int32_t VL53L0X_write_byte(uint8_t address, uint8_t index, uint8_t data);
johnAlexander 6:8ac15bf6d635 187
johnAlexander 6:8ac15bf6d635 188
johnAlexander 6:8ac15bf6d635 189 /**
johnAlexander 6:8ac15bf6d635 190 * @brief Writes a single word (16-bit unsigned) to the device
johnAlexander 6:8ac15bf6d635 191 *
johnAlexander 6:8ac15bf6d635 192 * Manages the big-endian nature of the device (first byte written is the MS byte).
johnAlexander 6:8ac15bf6d635 193 * Uses SystemVerilog Write Multi task.
johnAlexander 6:8ac15bf6d635 194 *
johnAlexander 6:8ac15bf6d635 195 * @code
johnAlexander 6:8ac15bf6d635 196 *
johnAlexander 6:8ac15bf6d635 197 * Example:
johnAlexander 6:8ac15bf6d635 198 *
johnAlexander 6:8ac15bf6d635 199 * uint16_t nvm_ctrl_pulse_width = 0x0004;
johnAlexander 6:8ac15bf6d635 200 *
johnAlexander 6:8ac15bf6d635 201 * int status = VL53L0X_write_word(NVM_CTRL__PULSE_WIDTH_MSB, nvm_ctrl_pulse_width);
johnAlexander 6:8ac15bf6d635 202 *
johnAlexander 6:8ac15bf6d635 203 * @endcode
johnAlexander 6:8ac15bf6d635 204 *
johnAlexander 6:8ac15bf6d635 205 * @param address - uint8_t device address value
johnAlexander 6:8ac15bf6d635 206 * @param index - uint8_t register index value
johnAlexander 6:8ac15bf6d635 207 * @param data - uin16_t data value write
johnAlexander 6:8ac15bf6d635 208 *
johnAlexander 6:8ac15bf6d635 209 * @return status - SystemVerilog status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 210 *
johnAlexander 6:8ac15bf6d635 211 */
johnAlexander 6:8ac15bf6d635 212
johnAlexander 6:8ac15bf6d635 213 int32_t VL53L0X_write_word(uint8_t address, uint8_t index, uint16_t data);
johnAlexander 6:8ac15bf6d635 214
johnAlexander 6:8ac15bf6d635 215
johnAlexander 6:8ac15bf6d635 216 /**
johnAlexander 6:8ac15bf6d635 217 * @brief Writes a single dword (32-bit unsigned) to the device
johnAlexander 6:8ac15bf6d635 218 *
johnAlexander 6:8ac15bf6d635 219 * Manages the big-endian nature of the device (first byte written is the MS byte).
johnAlexander 6:8ac15bf6d635 220 * Uses SystemVerilog Write Multi task.
johnAlexander 6:8ac15bf6d635 221 *
johnAlexander 6:8ac15bf6d635 222 * @code
johnAlexander 6:8ac15bf6d635 223 *
johnAlexander 6:8ac15bf6d635 224 * Example:
johnAlexander 6:8ac15bf6d635 225 *
johnAlexander 6:8ac15bf6d635 226 * uint32_t nvm_data = 0x0004;
johnAlexander 6:8ac15bf6d635 227 *
johnAlexander 6:8ac15bf6d635 228 * int status = VL53L0X_write_dword(NVM_CTRL__DATAIN_MMM, nvm_data);
johnAlexander 6:8ac15bf6d635 229 *
johnAlexander 6:8ac15bf6d635 230 * @endcode
johnAlexander 6:8ac15bf6d635 231 *
johnAlexander 6:8ac15bf6d635 232 * @param address - uint8_t device address value
johnAlexander 6:8ac15bf6d635 233 * @param index - uint8_t register index value
johnAlexander 6:8ac15bf6d635 234 * @param data - uint32_t data value to write
johnAlexander 6:8ac15bf6d635 235 *
johnAlexander 6:8ac15bf6d635 236 * @return status - SystemVerilog status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 237 *
johnAlexander 6:8ac15bf6d635 238 */
johnAlexander 6:8ac15bf6d635 239
johnAlexander 6:8ac15bf6d635 240 int32_t VL53L0X_write_dword(uint8_t address, uint8_t index, uint32_t data);
johnAlexander 6:8ac15bf6d635 241
johnAlexander 6:8ac15bf6d635 242
johnAlexander 6:8ac15bf6d635 243
johnAlexander 6:8ac15bf6d635 244 /**
johnAlexander 6:8ac15bf6d635 245 * @brief Reads a single byte from the device
johnAlexander 6:8ac15bf6d635 246 *
johnAlexander 6:8ac15bf6d635 247 * Uses SystemVerilog Read Byte task.
johnAlexander 6:8ac15bf6d635 248 *
johnAlexander 6:8ac15bf6d635 249 * @code
johnAlexander 6:8ac15bf6d635 250 *
johnAlexander 6:8ac15bf6d635 251 * Example:
johnAlexander 6:8ac15bf6d635 252 *
johnAlexander 6:8ac15bf6d635 253 * uint8_t device_status = 0;
johnAlexander 6:8ac15bf6d635 254 *
johnAlexander 6:8ac15bf6d635 255 * int status = VL53L0X_read_byte(STATUS, &device_status);
johnAlexander 6:8ac15bf6d635 256 *
johnAlexander 6:8ac15bf6d635 257 * @endcode
johnAlexander 6:8ac15bf6d635 258 *
johnAlexander 6:8ac15bf6d635 259 * @param address - uint8_t device address value
johnAlexander 6:8ac15bf6d635 260 * @param index - uint8_t register index value
johnAlexander 6:8ac15bf6d635 261 * @param pdata - pointer to uint8_t data value
johnAlexander 6:8ac15bf6d635 262 *
johnAlexander 6:8ac15bf6d635 263 * @return status - SystemVerilog status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 264 *
johnAlexander 6:8ac15bf6d635 265 */
johnAlexander 6:8ac15bf6d635 266
johnAlexander 6:8ac15bf6d635 267 int32_t VL53L0X_read_byte(uint8_t address, uint8_t index, uint8_t *pdata);
johnAlexander 6:8ac15bf6d635 268
johnAlexander 6:8ac15bf6d635 269
johnAlexander 6:8ac15bf6d635 270 /**
johnAlexander 6:8ac15bf6d635 271 * @brief Reads a single word (16-bit unsigned) from the device
johnAlexander 6:8ac15bf6d635 272 *
johnAlexander 6:8ac15bf6d635 273 * Manages the big-endian nature of the device (first byte read is the MS byte).
johnAlexander 6:8ac15bf6d635 274 * Uses SystemVerilog Read Multi task.
johnAlexander 6:8ac15bf6d635 275 *
johnAlexander 6:8ac15bf6d635 276 * @code
johnAlexander 6:8ac15bf6d635 277 *
johnAlexander 6:8ac15bf6d635 278 * Example:
johnAlexander 6:8ac15bf6d635 279 *
johnAlexander 6:8ac15bf6d635 280 * uint16_t timeout = 0;
johnAlexander 6:8ac15bf6d635 281 *
johnAlexander 6:8ac15bf6d635 282 * int status = VL53L0X_read_word(TIMEOUT_OVERALL_PERIODS_MSB, &timeout);
johnAlexander 6:8ac15bf6d635 283 *
johnAlexander 6:8ac15bf6d635 284 * @endcode
johnAlexander 6:8ac15bf6d635 285 *
johnAlexander 6:8ac15bf6d635 286 * @param address - uint8_t device address value
johnAlexander 6:8ac15bf6d635 287 * @param index - uint8_t register index value
johnAlexander 6:8ac15bf6d635 288 * @param pdata - pointer to uint16_t data value
johnAlexander 6:8ac15bf6d635 289 *
johnAlexander 6:8ac15bf6d635 290 * @return status - SystemVerilog status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 291 *
johnAlexander 6:8ac15bf6d635 292 */
johnAlexander 6:8ac15bf6d635 293
johnAlexander 6:8ac15bf6d635 294 int32_t VL53L0X_read_word(uint8_t address, uint8_t index, uint16_t *pdata);
johnAlexander 6:8ac15bf6d635 295
johnAlexander 6:8ac15bf6d635 296
johnAlexander 6:8ac15bf6d635 297 /**
johnAlexander 6:8ac15bf6d635 298 * @brief Reads a single dword (32-bit unsigned) from the device
johnAlexander 6:8ac15bf6d635 299 *
johnAlexander 6:8ac15bf6d635 300 * Manages the big-endian nature of the device (first byte read is the MS byte).
johnAlexander 6:8ac15bf6d635 301 * Uses SystemVerilog Read Multi task.
johnAlexander 6:8ac15bf6d635 302 *
johnAlexander 6:8ac15bf6d635 303 * @code
johnAlexander 6:8ac15bf6d635 304 *
johnAlexander 6:8ac15bf6d635 305 * Example:
johnAlexander 6:8ac15bf6d635 306 *
johnAlexander 6:8ac15bf6d635 307 * uint32_t range_1 = 0;
johnAlexander 6:8ac15bf6d635 308 *
johnAlexander 6:8ac15bf6d635 309 * int status = VL53L0X_read_dword(RANGE_1_MMM, &range_1);
johnAlexander 6:8ac15bf6d635 310 *
johnAlexander 6:8ac15bf6d635 311 * @endcode
johnAlexander 6:8ac15bf6d635 312 *
johnAlexander 6:8ac15bf6d635 313 * @param address - uint8_t device address value
johnAlexander 6:8ac15bf6d635 314 * @param index - uint8_t register index value
johnAlexander 6:8ac15bf6d635 315 * @param pdata - pointer to uint32_t data value
johnAlexander 6:8ac15bf6d635 316 *
johnAlexander 6:8ac15bf6d635 317 * @return status - SystemVerilog status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 318 *
johnAlexander 6:8ac15bf6d635 319 */
johnAlexander 6:8ac15bf6d635 320
johnAlexander 6:8ac15bf6d635 321 int32_t VL53L0X_read_dword(uint8_t address, uint8_t index, uint32_t *pdata);
johnAlexander 6:8ac15bf6d635 322
johnAlexander 6:8ac15bf6d635 323
johnAlexander 6:8ac15bf6d635 324 /**
johnAlexander 6:8ac15bf6d635 325 * @brief Implements a programmable wait in us
johnAlexander 6:8ac15bf6d635 326 *
johnAlexander 6:8ac15bf6d635 327 * Wrapper for SystemVerilog Wait in micro seconds task
johnAlexander 6:8ac15bf6d635 328 *
johnAlexander 6:8ac15bf6d635 329 * @param wait_us - integer wait in micro seconds
johnAlexander 6:8ac15bf6d635 330 *
johnAlexander 6:8ac15bf6d635 331 * @return status - SystemVerilog status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 332 *
johnAlexander 6:8ac15bf6d635 333 */
johnAlexander 6:8ac15bf6d635 334
johnAlexander 6:8ac15bf6d635 335 int32_t VL53L0X_platform_wait_us(int32_t wait_us);
johnAlexander 6:8ac15bf6d635 336
johnAlexander 6:8ac15bf6d635 337
johnAlexander 6:8ac15bf6d635 338 /**
johnAlexander 6:8ac15bf6d635 339 * @brief Implements a programmable wait in ms
johnAlexander 6:8ac15bf6d635 340 *
johnAlexander 6:8ac15bf6d635 341 * Wrapper for SystemVerilog Wait in milli seconds task
johnAlexander 6:8ac15bf6d635 342 *
johnAlexander 6:8ac15bf6d635 343 * @param wait_ms - integer wait in milli seconds
johnAlexander 6:8ac15bf6d635 344 *
johnAlexander 6:8ac15bf6d635 345 * @return status - SystemVerilog status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 346 *
johnAlexander 6:8ac15bf6d635 347 */
johnAlexander 6:8ac15bf6d635 348
johnAlexander 6:8ac15bf6d635 349 int32_t VL53L0X_wait_ms(int32_t wait_ms);
johnAlexander 6:8ac15bf6d635 350
johnAlexander 6:8ac15bf6d635 351
johnAlexander 6:8ac15bf6d635 352 /**
johnAlexander 6:8ac15bf6d635 353 * @brief Set GPIO value
johnAlexander 6:8ac15bf6d635 354 *
johnAlexander 6:8ac15bf6d635 355 * @param level - input level - either 0 or 1
johnAlexander 6:8ac15bf6d635 356 *
johnAlexander 6:8ac15bf6d635 357 * @return status - SystemVerilog status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 358 *
johnAlexander 6:8ac15bf6d635 359 */
johnAlexander 6:8ac15bf6d635 360
johnAlexander 6:8ac15bf6d635 361 int32_t VL53L0X_set_gpio(uint8_t level);
johnAlexander 6:8ac15bf6d635 362
johnAlexander 6:8ac15bf6d635 363
johnAlexander 6:8ac15bf6d635 364 /**
johnAlexander 6:8ac15bf6d635 365 * @brief Get GPIO value
johnAlexander 6:8ac15bf6d635 366 *
johnAlexander 6:8ac15bf6d635 367 * @param plevel - uint8_t pointer to store GPIO level (0 or 1)
johnAlexander 6:8ac15bf6d635 368 *
johnAlexander 6:8ac15bf6d635 369 * @return status - SystemVerilog status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 370 *
johnAlexander 6:8ac15bf6d635 371 */
johnAlexander 6:8ac15bf6d635 372
johnAlexander 6:8ac15bf6d635 373 int32_t VL53L0X_get_gpio(uint8_t *plevel);
johnAlexander 6:8ac15bf6d635 374
johnAlexander 6:8ac15bf6d635 375 /**
johnAlexander 6:8ac15bf6d635 376 * @brief Release force on GPIO
johnAlexander 6:8ac15bf6d635 377 *
johnAlexander 6:8ac15bf6d635 378 * @return status - SystemVerilog status 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 379 *
johnAlexander 6:8ac15bf6d635 380 */
johnAlexander 6:8ac15bf6d635 381
johnAlexander 6:8ac15bf6d635 382 int32_t VL53L0X_release_gpio(void);
johnAlexander 6:8ac15bf6d635 383
johnAlexander 6:8ac15bf6d635 384
johnAlexander 6:8ac15bf6d635 385 /**
johnAlexander 6:8ac15bf6d635 386 * @brief Get the frequency of the timer used for ranging results time stamps
johnAlexander 6:8ac15bf6d635 387 *
johnAlexander 6:8ac15bf6d635 388 * @param[out] ptimer_freq_hz : pointer for timer frequency
johnAlexander 6:8ac15bf6d635 389 *
johnAlexander 6:8ac15bf6d635 390 * @return status : 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 391 *
johnAlexander 6:8ac15bf6d635 392 */
johnAlexander 6:8ac15bf6d635 393
johnAlexander 6:8ac15bf6d635 394 int32_t VL53L0X_get_timer_frequency(int32_t *ptimer_freq_hz);
johnAlexander 6:8ac15bf6d635 395
johnAlexander 6:8ac15bf6d635 396 /**
johnAlexander 6:8ac15bf6d635 397 * @brief Get the timer value in units of timer_freq_hz (see VL53L0X_get_timestamp_frequency())
johnAlexander 6:8ac15bf6d635 398 *
johnAlexander 6:8ac15bf6d635 399 * @param[out] ptimer_count : pointer for timer count value
johnAlexander 6:8ac15bf6d635 400 *
johnAlexander 6:8ac15bf6d635 401 * @return status : 0 = ok, 1 = error
johnAlexander 6:8ac15bf6d635 402 *
johnAlexander 6:8ac15bf6d635 403 */
johnAlexander 6:8ac15bf6d635 404
johnAlexander 6:8ac15bf6d635 405 int32_t VL53L0X_get_timer_value(int32_t *ptimer_count);
johnAlexander 6:8ac15bf6d635 406
johnAlexander 6:8ac15bf6d635 407
johnAlexander 6:8ac15bf6d635 408
johnAlexander 6:8ac15bf6d635 409
johnAlexander 6:8ac15bf6d635 410
johnAlexander 6:8ac15bf6d635 411 #ifdef __cplusplus
johnAlexander 6:8ac15bf6d635 412 }
johnAlexander 6:8ac15bf6d635 413 #endif
johnAlexander 6:8ac15bf6d635 414
johnAlexander 6:8ac15bf6d635 415 #endif //_VL53L0X_I2C_PLATFORM_H_
johnAlexander 6:8ac15bf6d635 416
johnAlexander 6:8ac15bf6d635 417