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