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