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:
Charles MacNeill
Date:
Wed Jun 09 08:40:49 2021 +0100
Revision:
9:66969b9016ad
Child:
10:3687b5e79f98
created VL53L1CB.cpp/.h from VL53L1.cpp/.h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Charles MacNeill 9:66969b9016ad 1 /**
Charles MacNeill 9:66969b9016ad 2 ******************************************************************************
Charles MacNeill 9:66969b9016ad 3 * @file vl53l1x_class.cpp
Charles MacNeill 9:66969b9016ad 4 * @author JS
Charles MacNeill 9:66969b9016ad 5 * @version V0.0.1
Charles MacNeill 9:66969b9016ad 6 * @date 15-January-2019
Charles MacNeill 9:66969b9016ad 7 * @brief Implementation file for the VL53L1 sensor component driver class
Charles MacNeill 9:66969b9016ad 8 ******************************************************************************
Charles MacNeill 9:66969b9016ad 9 * @attention
Charles MacNeill 9:66969b9016ad 10 *
Charles MacNeill 9:66969b9016ad 11 * <h2><center>&copy; COPYRIGHT(c) 2018 STMicroelectronics</center></h2>
Charles MacNeill 9:66969b9016ad 12 *
Charles MacNeill 9:66969b9016ad 13 * Redistribution and use in source and binary forms, with or without modification,
Charles MacNeill 9:66969b9016ad 14 * are permitted provided that the following conditions are met:
Charles MacNeill 9:66969b9016ad 15 * 1. Redistributions of source code must retain the above copyright notice,
Charles MacNeill 9:66969b9016ad 16 * this list of conditions and the following disclaimer.
Charles MacNeill 9:66969b9016ad 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Charles MacNeill 9:66969b9016ad 18 * this list of conditions and the following disclaimer in the documentation
Charles MacNeill 9:66969b9016ad 19 * and/or other materials provided with the distribution.
Charles MacNeill 9:66969b9016ad 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Charles MacNeill 9:66969b9016ad 21 * may be used to endorse or promote products derived from this software
Charles MacNeill 9:66969b9016ad 22 * without specific prior written permission.
Charles MacNeill 9:66969b9016ad 23 *
Charles MacNeill 9:66969b9016ad 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Charles MacNeill 9:66969b9016ad 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Charles MacNeill 9:66969b9016ad 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Charles MacNeill 9:66969b9016ad 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Charles MacNeill 9:66969b9016ad 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Charles MacNeill 9:66969b9016ad 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Charles MacNeill 9:66969b9016ad 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Charles MacNeill 9:66969b9016ad 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Charles MacNeill 9:66969b9016ad 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Charles MacNeill 9:66969b9016ad 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Charles MacNeill 9:66969b9016ad 34 *
Charles MacNeill 9:66969b9016ad 35 ******************************************************************************
Charles MacNeill 9:66969b9016ad 36 */
Charles MacNeill 9:66969b9016ad 37
Charles MacNeill 9:66969b9016ad 38 /* Includes */
Charles MacNeill 9:66969b9016ad 39 #include <stdlib.h>
Charles MacNeill 9:66969b9016ad 40 #include "VL53L1CB.h"
Charles MacNeill 9:66969b9016ad 41 /************************************************/
Charles MacNeill 9:66969b9016ad 42 #include "vl53l1_platform_user_config.h"
Charles MacNeill 9:66969b9016ad 43 #include "vl53l1_def.h"
Charles MacNeill 9:66969b9016ad 44 #include "vl53l1_wait.h"
Charles MacNeill 9:66969b9016ad 45 #include "vl53l1_api.h"
Charles MacNeill 9:66969b9016ad 46 #include "vl53l1_api_debug.h"
Charles MacNeill 9:66969b9016ad 47 #include "vl53l1_api_strings.h"
Charles MacNeill 9:66969b9016ad 48 #include "vl53l1_preset_setup.h"
Charles MacNeill 9:66969b9016ad 49 #include "vl53l1_api_calibration.h"
Charles MacNeill 9:66969b9016ad 50 #include "vl53l1_nvm_structs.h"
Charles MacNeill 9:66969b9016ad 51 #include "vl53l1_nvm.h"
Charles MacNeill 9:66969b9016ad 52 #include "vl53l1_core.h"
Charles MacNeill 9:66969b9016ad 53 #include "vl53l1_register_funcs.h"
Charles MacNeill 9:66969b9016ad 54 /***********************************************************/
Charles MacNeill 9:66969b9016ad 55 #include "vl53l1_api_core.h"
Charles MacNeill 9:66969b9016ad 56
Charles MacNeill 9:66969b9016ad 57 #include "vl53l1_configuration.h"
Charles MacNeill 9:66969b9016ad 58
Charles MacNeill 9:66969b9016ad 59
Charles MacNeill 9:66969b9016ad 60 #ifndef MIN
Charles MacNeill 9:66969b9016ad 61 #define MIN(v1, v2) ((v1) < (v2) ? (v1) : (v2))
Charles MacNeill 9:66969b9016ad 62 #endif
Charles MacNeill 9:66969b9016ad 63 #ifndef MAX
Charles MacNeill 9:66969b9016ad 64 #define MAX(v1, v2) ((v1) < (v2) ? (v2) : (v1))
Charles MacNeill 9:66969b9016ad 65 #endif
Charles MacNeill 9:66969b9016ad 66
Charles MacNeill 9:66969b9016ad 67
Charles MacNeill 9:66969b9016ad 68 VL53L1_ERROR VL53L1::VL53L1_GetSWVersion(VL53L1_Version_t *pVersion)
Charles MacNeill 9:66969b9016ad 69 {
Charles MacNeill 9:66969b9016ad 70 VL53L1_ERROR Status = 0;
Charles MacNeill 9:66969b9016ad 71
Charles MacNeill 9:66969b9016ad 72 pVersion->major = VL53L1_IMPLEMENTATION_VER_MAJOR;
Charles MacNeill 9:66969b9016ad 73 pVersion->minor = VL53L1_IMPLEMENTATION_VER_MINOR;
Charles MacNeill 9:66969b9016ad 74 pVersion->build = VL53L1_IMPLEMENTATION_VER_SUB;
Charles MacNeill 9:66969b9016ad 75 pVersion->revision = VL53L1_IMPLEMENTATION_VER_REVISION;
Charles MacNeill 9:66969b9016ad 76 return Status;
Charles MacNeill 9:66969b9016ad 77 }
Charles MacNeill 9:66969b9016ad 78
Charles MacNeill 9:66969b9016ad 79 VL53L1_ERROR VL53L1::vl53L1_SetI2CAddress(uint8_t new_address)
Charles MacNeill 9:66969b9016ad 80 {
Charles MacNeill 9:66969b9016ad 81 VL53L1_ERROR status = 0;
Charles MacNeill 9:66969b9016ad 82 // status = (VL53L1_ERROR)VL53L1_SetDeviceAddress(Device,new_address);
Charles MacNeill 9:66969b9016ad 83
Charles MacNeill 9:66969b9016ad 84
Charles MacNeill 9:66969b9016ad 85 // Device->i2c_slave_address = new_address; //~~ was
Charles MacNeill 9:66969b9016ad 86 if ( Device->i2c_slave_address != new_address)
Charles MacNeill 9:66969b9016ad 87 {
Charles MacNeill 9:66969b9016ad 88 status = VL53L1_WrByte(Device, VL53L1_I2C_SLAVE__DEVICE_ADDRESS, new_address >> 1);
Charles MacNeill 9:66969b9016ad 89 printf("VL53L1_SetI2CAddress %d to %d status = %d\n", Device->i2c_slave_address,new_address,status);
Charles MacNeill 9:66969b9016ad 90 Device->i2c_slave_address = new_address;
Charles MacNeill 9:66969b9016ad 91
Charles MacNeill 9:66969b9016ad 92 }
Charles MacNeill 9:66969b9016ad 93 return status;
Charles MacNeill 9:66969b9016ad 94 }
Charles MacNeill 9:66969b9016ad 95
Charles MacNeill 9:66969b9016ad 96 int VL53L1::init_sensor(uint8_t new_addr)
Charles MacNeill 9:66969b9016ad 97 {
Charles MacNeill 9:66969b9016ad 98 Device->i2c_slave_address = new_addr;
Charles MacNeill 9:66969b9016ad 99 int status = 0;
Charles MacNeill 9:66969b9016ad 100 VL53L1_Off();
Charles MacNeill 9:66969b9016ad 101 VL53L1_On();
Charles MacNeill 9:66969b9016ad 102
Charles MacNeill 9:66969b9016ad 103 status = is_present();
Charles MacNeill 9:66969b9016ad 104 if (!status) {
Charles MacNeill 9:66969b9016ad 105 printf("Failed to init VL53L0X sensor!\n\r");
Charles MacNeill 9:66969b9016ad 106 return status;
Charles MacNeill 9:66969b9016ad 107 }
Charles MacNeill 9:66969b9016ad 108 return status;
Charles MacNeill 9:66969b9016ad 109 }
Charles MacNeill 9:66969b9016ad 110
Charles MacNeill 9:66969b9016ad 111
Charles MacNeill 9:66969b9016ad 112 VL53L1_ERROR VL53L1::VL53L1_SensorInit()
Charles MacNeill 9:66969b9016ad 113 {
Charles MacNeill 9:66969b9016ad 114 VL53L1_ERROR status = 0;
Charles MacNeill 9:66969b9016ad 115 uint8_t Addr = 0x00;
Charles MacNeill 9:66969b9016ad 116
Charles MacNeill 9:66969b9016ad 117 for (Addr = 0x2D; Addr <= 0x87; Addr++){
Charles MacNeill 9:66969b9016ad 118 status = VL53L1_WrByte(Device, Addr, VL51L1X_DEFAULT_CONFIGURATION[Addr - 0x2D]);
Charles MacNeill 9:66969b9016ad 119 if (status != 0)
Charles MacNeill 9:66969b9016ad 120 {
Charles MacNeill 9:66969b9016ad 121 printf("Writing config failed - %d\r\n", status);
Charles MacNeill 9:66969b9016ad 122 }
Charles MacNeill 9:66969b9016ad 123 }
Charles MacNeill 9:66969b9016ad 124
Charles MacNeill 9:66969b9016ad 125 // uint16_t sensorID= 0;
Charles MacNeill 9:66969b9016ad 126 // status = VL53L1X_GetSensorId(&sensorID);
Charles MacNeill 9:66969b9016ad 127 // printf("Sensor id is - %d (%X)\r\n", sensorID, sensorID);
Charles MacNeill 9:66969b9016ad 128
Charles MacNeill 9:66969b9016ad 129 status = VL53L1_StartRanging();
Charles MacNeill 9:66969b9016ad 130 if (status != 0)
Charles MacNeill 9:66969b9016ad 131 {
Charles MacNeill 9:66969b9016ad 132 printf("start ranging failed - %d\r\n", status);
Charles MacNeill 9:66969b9016ad 133 }
Charles MacNeill 9:66969b9016ad 134
Charles MacNeill 9:66969b9016ad 135 status = VL53L1_ClearInterrupt();
Charles MacNeill 9:66969b9016ad 136 status = VL53L1_StopRanging();
Charles MacNeill 9:66969b9016ad 137 status = VL53L1_WrByte(Device, VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND, 0x09); // two bounds VHV
Charles MacNeill 9:66969b9016ad 138 status = VL53L1_WrByte(Device, 0x0B, 0); // start VHV from the previous temperature
Charles MacNeill 9:66969b9016ad 139 return status;
Charles MacNeill 9:66969b9016ad 140 }
Charles MacNeill 9:66969b9016ad 141
Charles MacNeill 9:66969b9016ad 142
Charles MacNeill 9:66969b9016ad 143 VL53L1_ERROR VL53L1::VL53L1_ClearInterrupt()
Charles MacNeill 9:66969b9016ad 144 {
Charles MacNeill 9:66969b9016ad 145 VL53L1_ERROR status = 0;
Charles MacNeill 9:66969b9016ad 146
Charles MacNeill 9:66969b9016ad 147 status = VL53L1_WrByte(Device, SYSTEM__INTERRUPT_CLEAR, 0x01);
Charles MacNeill 9:66969b9016ad 148 // printf("VL53L1::VL53L1X_ClearInterrupt()\n");
Charles MacNeill 9:66969b9016ad 149 return status;
Charles MacNeill 9:66969b9016ad 150 }
Charles MacNeill 9:66969b9016ad 151
Charles MacNeill 9:66969b9016ad 152
Charles MacNeill 9:66969b9016ad 153
Charles MacNeill 9:66969b9016ad 154
Charles MacNeill 9:66969b9016ad 155
Charles MacNeill 9:66969b9016ad 156 VL53L1_ERROR VL53L1::VL53L1_GetInterruptPolarity(uint8_t *pInterruptPolarity)
Charles MacNeill 9:66969b9016ad 157 {
Charles MacNeill 9:66969b9016ad 158 uint8_t Temp;
Charles MacNeill 9:66969b9016ad 159 VL53L1_ERROR status = 0;
Charles MacNeill 9:66969b9016ad 160
Charles MacNeill 9:66969b9016ad 161 status = VL53L1_RdByte(Device, GPIO_HV_MUX__CTRL, &Temp);
Charles MacNeill 9:66969b9016ad 162 Temp = Temp & 0x10;
Charles MacNeill 9:66969b9016ad 163 *pInterruptPolarity = !(Temp>>4);
Charles MacNeill 9:66969b9016ad 164 return status;
Charles MacNeill 9:66969b9016ad 165 }
Charles MacNeill 9:66969b9016ad 166
Charles MacNeill 9:66969b9016ad 167
Charles MacNeill 9:66969b9016ad 168
Charles MacNeill 9:66969b9016ad 169 VL53L1_ERROR VL53L1::VL53L1_StartRanging()
Charles MacNeill 9:66969b9016ad 170 {
Charles MacNeill 9:66969b9016ad 171 VL53L1_ERROR status = 0;
Charles MacNeill 9:66969b9016ad 172
Charles MacNeill 9:66969b9016ad 173 status = VL53L1_WrByte(Device, SYSTEM__MODE_START, 0x40);
Charles MacNeill 9:66969b9016ad 174 return status;
Charles MacNeill 9:66969b9016ad 175 }
Charles MacNeill 9:66969b9016ad 176
Charles MacNeill 9:66969b9016ad 177
Charles MacNeill 9:66969b9016ad 178 VL53L1_ERROR VL53L1::VL53L1_StopRanging()
Charles MacNeill 9:66969b9016ad 179 {
Charles MacNeill 9:66969b9016ad 180 VL53L1_ERROR status = 0;
Charles MacNeill 9:66969b9016ad 181
Charles MacNeill 9:66969b9016ad 182 status = VL53L1_WrByte(Device, SYSTEM__MODE_START, 0x00);
Charles MacNeill 9:66969b9016ad 183 return status;
Charles MacNeill 9:66969b9016ad 184 }
Charles MacNeill 9:66969b9016ad 185
Charles MacNeill 9:66969b9016ad 186
Charles MacNeill 9:66969b9016ad 187
Charles MacNeill 9:66969b9016ad 188
Charles MacNeill 9:66969b9016ad 189 VL53L1_ERROR VL53L1::vl53L1_BootState(uint8_t *state)
Charles MacNeill 9:66969b9016ad 190 {
Charles MacNeill 9:66969b9016ad 191 VL53L1_ERROR status = 0;
Charles MacNeill 9:66969b9016ad 192 uint8_t tmp = 0;
Charles MacNeill 9:66969b9016ad 193
Charles MacNeill 9:66969b9016ad 194 status = VL53L1_RdByte(Device,VL53L1_FIRMWARE__SYSTEM_STATUS, &tmp);
Charles MacNeill 9:66969b9016ad 195 *state = tmp;
Charles MacNeill 9:66969b9016ad 196 return status;
Charles MacNeill 9:66969b9016ad 197 }
Charles MacNeill 9:66969b9016ad 198
Charles MacNeill 9:66969b9016ad 199
Charles MacNeill 9:66969b9016ad 200 VL53L1_ERROR VL53L1::VL53L1_GetDistance(uint16_t *distance)
Charles MacNeill 9:66969b9016ad 201 {
Charles MacNeill 9:66969b9016ad 202 VL53L1_ERROR status = 0;
Charles MacNeill 9:66969b9016ad 203 uint16_t tmp;
Charles MacNeill 9:66969b9016ad 204
Charles MacNeill 9:66969b9016ad 205 status = (VL53L1_RdWord(Device,
Charles MacNeill 9:66969b9016ad 206 VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0, &tmp));
Charles MacNeill 9:66969b9016ad 207 *distance = tmp;
Charles MacNeill 9:66969b9016ad 208 return status;
Charles MacNeill 9:66969b9016ad 209 }
Charles MacNeill 9:66969b9016ad 210
Charles MacNeill 9:66969b9016ad 211
Charles MacNeill 9:66969b9016ad 212 /* Write and read functions from I2C */
Charles MacNeill 9:66969b9016ad 213
Charles MacNeill 9:66969b9016ad 214
Charles MacNeill 9:66969b9016ad 215 VL53L1_ERROR VL53L1::VL53L1_WriteMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count)
Charles MacNeill 9:66969b9016ad 216 {
Charles MacNeill 9:66969b9016ad 217 int status;
Charles MacNeill 9:66969b9016ad 218 //printf(" class VL53L1_WriteMulti \n");
Charles MacNeill 9:66969b9016ad 219 status = VL53L1_I2CWrite(Dev->i2c_slave_address, index, pdata, (uint16_t)count);
Charles MacNeill 9:66969b9016ad 220 return status;
Charles MacNeill 9:66969b9016ad 221 }
Charles MacNeill 9:66969b9016ad 222
Charles MacNeill 9:66969b9016ad 223 VL53L1_ERROR VL53L1::VL53L1_ReadMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count)
Charles MacNeill 9:66969b9016ad 224 {
Charles MacNeill 9:66969b9016ad 225 int status;
Charles MacNeill 9:66969b9016ad 226
Charles MacNeill 9:66969b9016ad 227 status = VL53L1_I2CRead(Dev->i2c_slave_address, index, pdata, (uint16_t)count);
Charles MacNeill 9:66969b9016ad 228
Charles MacNeill 9:66969b9016ad 229 return status;
Charles MacNeill 9:66969b9016ad 230 }
Charles MacNeill 9:66969b9016ad 231
Charles MacNeill 9:66969b9016ad 232
Charles MacNeill 9:66969b9016ad 233 VL53L1_ERROR VL53L1::VL53L1_WrByte(VL53L1_DEV Dev, uint16_t index, uint8_t data)
Charles MacNeill 9:66969b9016ad 234 {
Charles MacNeill 9:66969b9016ad 235 int status;
Charles MacNeill 9:66969b9016ad 236
Charles MacNeill 9:66969b9016ad 237 status=VL53L1_I2CWrite(Dev->i2c_slave_address, index, &data, 1);
Charles MacNeill 9:66969b9016ad 238 return status;
Charles MacNeill 9:66969b9016ad 239 }
Charles MacNeill 9:66969b9016ad 240
Charles MacNeill 9:66969b9016ad 241 VL53L1_ERROR VL53L1::VL53L1_WrWord(VL53L1_DEV Dev, uint16_t index, uint16_t data)
Charles MacNeill 9:66969b9016ad 242 {
Charles MacNeill 9:66969b9016ad 243 int status;
Charles MacNeill 9:66969b9016ad 244 uint8_t buffer[2];
Charles MacNeill 9:66969b9016ad 245
Charles MacNeill 9:66969b9016ad 246 buffer[0] = data >> 8;
Charles MacNeill 9:66969b9016ad 247 buffer[1] = data & 0x00FF;
Charles MacNeill 9:66969b9016ad 248 status=VL53L1_I2CWrite(Dev->i2c_slave_address, index, (uint8_t *)buffer, 2);
Charles MacNeill 9:66969b9016ad 249 return status;
Charles MacNeill 9:66969b9016ad 250 }
Charles MacNeill 9:66969b9016ad 251
Charles MacNeill 9:66969b9016ad 252 VL53L1_ERROR VL53L1::VL53L1_WrDWord(VL53L1_DEV Dev, uint16_t index, uint32_t data)
Charles MacNeill 9:66969b9016ad 253 {
Charles MacNeill 9:66969b9016ad 254 int status;
Charles MacNeill 9:66969b9016ad 255 uint8_t buffer[4];
Charles MacNeill 9:66969b9016ad 256
Charles MacNeill 9:66969b9016ad 257 buffer[0] = (data >> 24) & 0xFF;
Charles MacNeill 9:66969b9016ad 258 buffer[1] = (data >> 16) & 0xFF;
Charles MacNeill 9:66969b9016ad 259 buffer[2] = (data >> 8) & 0xFF;
Charles MacNeill 9:66969b9016ad 260 buffer[3] = (data >> 0) & 0xFF;
Charles MacNeill 9:66969b9016ad 261 status=VL53L1_I2CWrite(Dev->i2c_slave_address, index, (uint8_t *)buffer, 4);
Charles MacNeill 9:66969b9016ad 262 return status;
Charles MacNeill 9:66969b9016ad 263 }
Charles MacNeill 9:66969b9016ad 264
Charles MacNeill 9:66969b9016ad 265
Charles MacNeill 9:66969b9016ad 266 VL53L1_ERROR VL53L1::VL53L1_RdByte(VL53L1_DEV Dev, uint16_t index, uint8_t *data)
Charles MacNeill 9:66969b9016ad 267 {
Charles MacNeill 9:66969b9016ad 268 int status;
Charles MacNeill 9:66969b9016ad 269
Charles MacNeill 9:66969b9016ad 270 status = VL53L1_I2CRead(Dev->i2c_slave_address, index, data, 1);
Charles MacNeill 9:66969b9016ad 271
Charles MacNeill 9:66969b9016ad 272 if(status)
Charles MacNeill 9:66969b9016ad 273 return -1;
Charles MacNeill 9:66969b9016ad 274
Charles MacNeill 9:66969b9016ad 275 return 0;
Charles MacNeill 9:66969b9016ad 276 }
Charles MacNeill 9:66969b9016ad 277
Charles MacNeill 9:66969b9016ad 278 VL53L1_ERROR VL53L1::VL53L1_RdWord(VL53L1_DEV Dev, uint16_t index, uint16_t *data)
Charles MacNeill 9:66969b9016ad 279 {
Charles MacNeill 9:66969b9016ad 280 int status;
Charles MacNeill 9:66969b9016ad 281 uint8_t buffer[2] = {0,0};
Charles MacNeill 9:66969b9016ad 282
Charles MacNeill 9:66969b9016ad 283 status = VL53L1_I2CRead(Dev->i2c_slave_address, index, buffer, 2);
Charles MacNeill 9:66969b9016ad 284 if (!status)
Charles MacNeill 9:66969b9016ad 285 {
Charles MacNeill 9:66969b9016ad 286 *data = (buffer[0] << 8) + buffer[1];
Charles MacNeill 9:66969b9016ad 287 }
Charles MacNeill 9:66969b9016ad 288 // printf("VL53L1_RdWord %d %d %d \n",Dev->i2c_slave_address,index,status);
Charles MacNeill 9:66969b9016ad 289 return status;
Charles MacNeill 9:66969b9016ad 290
Charles MacNeill 9:66969b9016ad 291 }
Charles MacNeill 9:66969b9016ad 292
Charles MacNeill 9:66969b9016ad 293 VL53L1_ERROR VL53L1::VL53L1_RdDWord(VL53L1_DEV Dev, uint16_t index, uint32_t *data)
Charles MacNeill 9:66969b9016ad 294 {
Charles MacNeill 9:66969b9016ad 295 int status;
Charles MacNeill 9:66969b9016ad 296 uint8_t buffer[4] = {0,0,0,0};
Charles MacNeill 9:66969b9016ad 297
Charles MacNeill 9:66969b9016ad 298 status = VL53L1_I2CRead(Dev->i2c_slave_address, index, buffer, 4);
Charles MacNeill 9:66969b9016ad 299 if(!status)
Charles MacNeill 9:66969b9016ad 300 {
Charles MacNeill 9:66969b9016ad 301 *data = (buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3];
Charles MacNeill 9:66969b9016ad 302 }
Charles MacNeill 9:66969b9016ad 303 return status;
Charles MacNeill 9:66969b9016ad 304
Charles MacNeill 9:66969b9016ad 305 }
Charles MacNeill 9:66969b9016ad 306
Charles MacNeill 9:66969b9016ad 307 VL53L1_ERROR VL53L1::VL53L1_UpdateByte(VL53L1_DEV Dev, uint16_t index, uint8_t AndData, uint8_t OrData)
Charles MacNeill 9:66969b9016ad 308 {
Charles MacNeill 9:66969b9016ad 309 int status;
Charles MacNeill 9:66969b9016ad 310 uint8_t buffer = 0;
Charles MacNeill 9:66969b9016ad 311
Charles MacNeill 9:66969b9016ad 312 /* read data direct onto buffer */
Charles MacNeill 9:66969b9016ad 313 status = VL53L1_I2CRead(Dev->i2c_slave_address, index, &buffer,1);
Charles MacNeill 9:66969b9016ad 314 if (!status)
Charles MacNeill 9:66969b9016ad 315 {
Charles MacNeill 9:66969b9016ad 316 buffer = (buffer & AndData) | OrData;
Charles MacNeill 9:66969b9016ad 317 status = VL53L1_I2CWrite(Dev->i2c_slave_address, index, &buffer, (uint16_t)1);
Charles MacNeill 9:66969b9016ad 318 }
Charles MacNeill 9:66969b9016ad 319 return status;
Charles MacNeill 9:66969b9016ad 320 }
Charles MacNeill 9:66969b9016ad 321
Charles MacNeill 9:66969b9016ad 322 VL53L1_ERROR VL53L1::VL53L1_I2CWrite(uint8_t DeviceAddr, uint16_t RegisterAddr, uint8_t* pBuffer, uint16_t NumByteToWrite)
Charles MacNeill 9:66969b9016ad 323 {
Charles MacNeill 9:66969b9016ad 324 int ret;
Charles MacNeill 9:66969b9016ad 325 ret = dev_i2c->ToF_i2c_write(pBuffer, DeviceAddr, RegisterAddr, NumByteToWrite);
Charles MacNeill 9:66969b9016ad 326 if (ret) {
Charles MacNeill 9:66969b9016ad 327 return -1;
Charles MacNeill 9:66969b9016ad 328 }
Charles MacNeill 9:66969b9016ad 329 return 0;
Charles MacNeill 9:66969b9016ad 330
Charles MacNeill 9:66969b9016ad 331 }
Charles MacNeill 9:66969b9016ad 332
Charles MacNeill 9:66969b9016ad 333 VL53L1_ERROR VL53L1::VL53L1_I2CRead(uint8_t DeviceAddr, uint16_t RegisterAddr, uint8_t* pBuffer, uint16_t NumByteToRead)
Charles MacNeill 9:66969b9016ad 334 {
Charles MacNeill 9:66969b9016ad 335 int ret;
Charles MacNeill 9:66969b9016ad 336
Charles MacNeill 9:66969b9016ad 337 ret = dev_i2c->ToF_i2c_read(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead);
Charles MacNeill 9:66969b9016ad 338 //ret = dev_i2c->i2c_read(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead);
Charles MacNeill 9:66969b9016ad 339 if (ret) {
Charles MacNeill 9:66969b9016ad 340 return -1;
Charles MacNeill 9:66969b9016ad 341 }
Charles MacNeill 9:66969b9016ad 342 return 0;
Charles MacNeill 9:66969b9016ad 343 }
Charles MacNeill 9:66969b9016ad 344
Charles MacNeill 9:66969b9016ad 345
Charles MacNeill 9:66969b9016ad 346 VL53L1_ERROR VL53L1::VL53L1_GetTickCount(
Charles MacNeill 9:66969b9016ad 347 uint32_t *ptick_count_ms)
Charles MacNeill 9:66969b9016ad 348 {
Charles MacNeill 9:66969b9016ad 349
Charles MacNeill 9:66969b9016ad 350 /* Returns current tick count in [ms] */
Charles MacNeill 9:66969b9016ad 351
Charles MacNeill 9:66969b9016ad 352 VL53L1_ERROR status = VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 353
Charles MacNeill 9:66969b9016ad 354 //*ptick_count_ms = timeGetTime();
Charles MacNeill 9:66969b9016ad 355 *ptick_count_ms = us_ticker_read() / 1000;
Charles MacNeill 9:66969b9016ad 356
Charles MacNeill 9:66969b9016ad 357 return status;
Charles MacNeill 9:66969b9016ad 358 }
Charles MacNeill 9:66969b9016ad 359
Charles MacNeill 9:66969b9016ad 360
Charles MacNeill 9:66969b9016ad 361
Charles MacNeill 9:66969b9016ad 362 VL53L1_ERROR VL53L1::VL53L1_WaitUs(VL53L1_Dev_t *pdev, int32_t wait_time)
Charles MacNeill 9:66969b9016ad 363 {
Charles MacNeill 9:66969b9016ad 364 //(void)pdev;
Charles MacNeill 9:66969b9016ad 365 wait_us(wait_time);
Charles MacNeill 9:66969b9016ad 366 return VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 367 }
Charles MacNeill 9:66969b9016ad 368
Charles MacNeill 9:66969b9016ad 369
Charles MacNeill 9:66969b9016ad 370 VL53L1_ERROR VL53L1::VL53L1_WaitMs(VL53L1_Dev_t *pdev, int32_t wait_time)
Charles MacNeill 9:66969b9016ad 371 {
Charles MacNeill 9:66969b9016ad 372 //(void)pdev;
Charles MacNeill 9:66969b9016ad 373
Charles MacNeill 9:66969b9016ad 374 #if (MBED_VERSION > 60300)
Charles MacNeill 9:66969b9016ad 375 thread_sleep_for(wait_time);
Charles MacNeill 9:66969b9016ad 376 #else
Charles MacNeill 9:66969b9016ad 377 wait_ms(wait_time); // NEEDS A DELAY BETWEEN SENSORS
Charles MacNeill 9:66969b9016ad 378 #endif
Charles MacNeill 9:66969b9016ad 379 return VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 380 }
Charles MacNeill 9:66969b9016ad 381
Charles MacNeill 9:66969b9016ad 382
Charles MacNeill 9:66969b9016ad 383 VL53L1_ERROR VL53L1::vl53L1_WaitValueMaskEx(
Charles MacNeill 9:66969b9016ad 384 VL53L1_Dev_t *pdev,
Charles MacNeill 9:66969b9016ad 385 uint32_t timeout_ms,
Charles MacNeill 9:66969b9016ad 386 uint16_t index,
Charles MacNeill 9:66969b9016ad 387 uint8_t value,
Charles MacNeill 9:66969b9016ad 388 uint8_t mask,
Charles MacNeill 9:66969b9016ad 389 uint32_t poll_delay_ms)
Charles MacNeill 9:66969b9016ad 390 {
Charles MacNeill 9:66969b9016ad 391
Charles MacNeill 9:66969b9016ad 392 /*
Charles MacNeill 9:66969b9016ad 393 * Platform implementation of WaitValueMaskEx V2WReg script command
Charles MacNeill 9:66969b9016ad 394 *
Charles MacNeill 9:66969b9016ad 395 * WaitValueMaskEx(
Charles MacNeill 9:66969b9016ad 396 * duration_ms,
Charles MacNeill 9:66969b9016ad 397 * index,
Charles MacNeill 9:66969b9016ad 398 * value,
Charles MacNeill 9:66969b9016ad 399 * mask,
Charles MacNeill 9:66969b9016ad 400 * poll_delay_ms);
Charles MacNeill 9:66969b9016ad 401 */
Charles MacNeill 9:66969b9016ad 402
Charles MacNeill 9:66969b9016ad 403
Charles MacNeill 9:66969b9016ad 404 return VL53L1_WaitValueMaskEx( pdev, timeout_ms,index, value, mask, poll_delay_ms);
Charles MacNeill 9:66969b9016ad 405 }
Charles MacNeill 9:66969b9016ad 406
Charles MacNeill 9:66969b9016ad 407
Charles MacNeill 9:66969b9016ad 408 /***************************************************************************/
Charles MacNeill 9:66969b9016ad 409 //VL53L1_ERROR VL53L1::VL53L1_WaitValueMaskEx(
Charles MacNeill 9:66969b9016ad 410
Charles MacNeill 9:66969b9016ad 411 VL53L1_ERROR VL53L1::vl53L1_WaitDeviceBooted(VL53L1_DEV Dev)
Charles MacNeill 9:66969b9016ad 412 {
Charles MacNeill 9:66969b9016ad 413
Charles MacNeill 9:66969b9016ad 414 return VL53L1_WaitDeviceBooted(Dev);
Charles MacNeill 9:66969b9016ad 415 }
Charles MacNeill 9:66969b9016ad 416
Charles MacNeill 9:66969b9016ad 417
Charles MacNeill 9:66969b9016ad 418 static int32_t BDTable[VL53L1_TUNING_MAX_TUNABLE_KEY] = {
Charles MacNeill 9:66969b9016ad 419 TUNING_VERSION,
Charles MacNeill 9:66969b9016ad 420 TUNING_PROXY_MIN,
Charles MacNeill 9:66969b9016ad 421 TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM,
Charles MacNeill 9:66969b9016ad 422 TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER,
Charles MacNeill 9:66969b9016ad 423 TUNING_MIN_AMBIENT_DMAX_VALID,
Charles MacNeill 9:66969b9016ad 424 TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER,
Charles MacNeill 9:66969b9016ad 425 TUNING_XTALK_FULL_ROI_TARGET_DISTANCE_MM,
Charles MacNeill 9:66969b9016ad 426 TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT,
Charles MacNeill 9:66969b9016ad 427 TUNING_XTALK_FULL_ROI_BIN_SUM_MARGIN,
Charles MacNeill 9:66969b9016ad 428 TUNING_XTALK_FULL_ROI_DEFAULT_OFFSET,
Charles MacNeill 9:66969b9016ad 429 TUNING_ZERO_DISTANCE_OFFSET_NON_LINEAR_FACTOR_DEFAULT,
Charles MacNeill 9:66969b9016ad 430 };
Charles MacNeill 9:66969b9016ad 431
Charles MacNeill 9:66969b9016ad 432
Charles MacNeill 9:66969b9016ad 433 VL53L1_ERROR VL53L1::vl53L1_GetVersion(VL53L1_Version_t *pVersion)
Charles MacNeill 9:66969b9016ad 434 {
Charles MacNeill 9:66969b9016ad 435
Charles MacNeill 9:66969b9016ad 436 return VL53L1_GetVersion(pVersion);
Charles MacNeill 9:66969b9016ad 437 }
Charles MacNeill 9:66969b9016ad 438
Charles MacNeill 9:66969b9016ad 439
Charles MacNeill 9:66969b9016ad 440 VL53L1_ERROR VL53L1::vl53L1_GetProductRevision(
Charles MacNeill 9:66969b9016ad 441 uint8_t *pProductRevisionMajor, uint8_t *pProductRevisionMinor)
Charles MacNeill 9:66969b9016ad 442 {
Charles MacNeill 9:66969b9016ad 443 return VL53L1_GetProductRevision(Device,pProductRevisionMajor,pProductRevisionMinor);
Charles MacNeill 9:66969b9016ad 444 }
Charles MacNeill 9:66969b9016ad 445
Charles MacNeill 9:66969b9016ad 446 //******************************************************************
Charles MacNeill 9:66969b9016ad 447
Charles MacNeill 9:66969b9016ad 448
Charles MacNeill 9:66969b9016ad 449 VL53L1_ERROR VL53L1::vl53L1_GetDeviceInfo(
Charles MacNeill 9:66969b9016ad 450 VL53L1_DeviceInfo_t *pVL53L1_DeviceInfo)
Charles MacNeill 9:66969b9016ad 451 {
Charles MacNeill 9:66969b9016ad 452 return VL53L1_GetDeviceInfo(Device,pVL53L1_DeviceInfo);
Charles MacNeill 9:66969b9016ad 453 }
Charles MacNeill 9:66969b9016ad 454
Charles MacNeill 9:66969b9016ad 455 VL53L1_ERROR VL53L1::vl53L1_GetUID( uint64_t *pUid)
Charles MacNeill 9:66969b9016ad 456 {
Charles MacNeill 9:66969b9016ad 457 return VL53L1_GetUID(Device,pUid);
Charles MacNeill 9:66969b9016ad 458 }
Charles MacNeill 9:66969b9016ad 459
Charles MacNeill 9:66969b9016ad 460 VL53L1_ERROR VL53L1::vl53L1_GetRangeStatusString(uint8_t RangeStatus,
Charles MacNeill 9:66969b9016ad 461 char *pRangeStatusString)
Charles MacNeill 9:66969b9016ad 462 {
Charles MacNeill 9:66969b9016ad 463 return VL53L1_GetRangeStatusString(RangeStatus,
Charles MacNeill 9:66969b9016ad 464 pRangeStatusString);
Charles MacNeill 9:66969b9016ad 465 }
Charles MacNeill 9:66969b9016ad 466
Charles MacNeill 9:66969b9016ad 467 VL53L1_ERROR VL53L1::vl53L1_GetPalErrorString(VL53L1_Error PalErrorCode,
Charles MacNeill 9:66969b9016ad 468 char *pPalErrorString)
Charles MacNeill 9:66969b9016ad 469 {
Charles MacNeill 9:66969b9016ad 470 return VL53L1_GetPalErrorString(PalErrorCode,pPalErrorString);
Charles MacNeill 9:66969b9016ad 471 }
Charles MacNeill 9:66969b9016ad 472
Charles MacNeill 9:66969b9016ad 473 VL53L1_ERROR VL53L1::vl53L1_GetPalStateString(VL53L1_State PalStateCode,
Charles MacNeill 9:66969b9016ad 474 char *pPalStateString)
Charles MacNeill 9:66969b9016ad 475 {
Charles MacNeill 9:66969b9016ad 476 return VL53L1_GetPalStateString(PalStateCode, pPalStateString);
Charles MacNeill 9:66969b9016ad 477 }
Charles MacNeill 9:66969b9016ad 478
Charles MacNeill 9:66969b9016ad 479 VL53L1_ERROR VL53L1::vl53L1_GetPalState(VL53L1_DEV Dev, VL53L1_State *pPalState)
Charles MacNeill 9:66969b9016ad 480 {
Charles MacNeill 9:66969b9016ad 481 return VL53L1_GetPalState(Dev,pPalState);
Charles MacNeill 9:66969b9016ad 482 }
Charles MacNeill 9:66969b9016ad 483
Charles MacNeill 9:66969b9016ad 484
Charles MacNeill 9:66969b9016ad 485 VL53L1_ERROR VL53L1::VL53L1_SetDeviceAddress(VL53L1_DEV Dev, uint8_t DeviceAddress)
Charles MacNeill 9:66969b9016ad 486 {
Charles MacNeill 9:66969b9016ad 487 VL53L1_Error Status = VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 488
Charles MacNeill 9:66969b9016ad 489 // LOG_FUNCTION_START("");
Charles MacNeill 9:66969b9016ad 490
Charles MacNeill 9:66969b9016ad 491 Status = VL53L1_WrByte(Dev, VL53L1_I2C_SLAVE__DEVICE_ADDRESS,
Charles MacNeill 9:66969b9016ad 492 DeviceAddress / 2);
Charles MacNeill 9:66969b9016ad 493
Charles MacNeill 9:66969b9016ad 494 // LOG_FUNCTION_END(Status);
Charles MacNeill 9:66969b9016ad 495 return Status;
Charles MacNeill 9:66969b9016ad 496 }
Charles MacNeill 9:66969b9016ad 497
Charles MacNeill 9:66969b9016ad 498 VL53L1_ERROR VL53L1::vl53L1_DataInit()
Charles MacNeill 9:66969b9016ad 499 {
Charles MacNeill 9:66969b9016ad 500 printf("vl53L1_DataInit %d \n",Device->i2c_slave_address);
Charles MacNeill 9:66969b9016ad 501 return VL53L1_DataInit( Device);
Charles MacNeill 9:66969b9016ad 502 }
Charles MacNeill 9:66969b9016ad 503
Charles MacNeill 9:66969b9016ad 504
Charles MacNeill 9:66969b9016ad 505 VL53L1_ERROR VL53L1::vl53L1_StaticInit()
Charles MacNeill 9:66969b9016ad 506 {
Charles MacNeill 9:66969b9016ad 507 return VL53L1_StaticInit( Device);
Charles MacNeill 9:66969b9016ad 508 }
Charles MacNeill 9:66969b9016ad 509
Charles MacNeill 9:66969b9016ad 510
Charles MacNeill 9:66969b9016ad 511 VL53L1_ERROR VL53L1::vl53L1_SetPresetMode(VL53L1_PresetModes PresetMode)
Charles MacNeill 9:66969b9016ad 512 {
Charles MacNeill 9:66969b9016ad 513 return VL53L1_SetPresetMode(Device,PresetMode);
Charles MacNeill 9:66969b9016ad 514 }
Charles MacNeill 9:66969b9016ad 515
Charles MacNeill 9:66969b9016ad 516
Charles MacNeill 9:66969b9016ad 517 VL53L1_ERROR VL53L1::vl53L1_GetPresetMode( VL53L1_PresetModes *pPresetMode)
Charles MacNeill 9:66969b9016ad 518 {
Charles MacNeill 9:66969b9016ad 519 return VL53L1_GetPresetMode(Device,pPresetMode);
Charles MacNeill 9:66969b9016ad 520 }
Charles MacNeill 9:66969b9016ad 521
Charles MacNeill 9:66969b9016ad 522
Charles MacNeill 9:66969b9016ad 523 VL53L1_ERROR VL53L1::vl53L1_SetDistanceMode(VL53L1_DistanceModes DistanceMode)
Charles MacNeill 9:66969b9016ad 524 {
Charles MacNeill 9:66969b9016ad 525 return VL53L1_SetDistanceMode(Device,DistanceMode);
Charles MacNeill 9:66969b9016ad 526 }
Charles MacNeill 9:66969b9016ad 527
Charles MacNeill 9:66969b9016ad 528 VL53L1_ERROR VL53L1::vl53L1_GetDistanceMode(VL53L1_DistanceModes *pDistanceMode)
Charles MacNeill 9:66969b9016ad 529 {
Charles MacNeill 9:66969b9016ad 530 return VL53L1_GetDistanceMode(Device,pDistanceMode);
Charles MacNeill 9:66969b9016ad 531 }
Charles MacNeill 9:66969b9016ad 532
Charles MacNeill 9:66969b9016ad 533 VL53L1_ERROR VL53L1::vl53L1_SetOutputMode(VL53L1_OutputModes OutputMode)
Charles MacNeill 9:66969b9016ad 534 {
Charles MacNeill 9:66969b9016ad 535 return VL53L1_SetOutputMode(Device,OutputMode);
Charles MacNeill 9:66969b9016ad 536 }
Charles MacNeill 9:66969b9016ad 537
Charles MacNeill 9:66969b9016ad 538 VL53L1_ERROR VL53L1::vl53L1_GetOutputMode(VL53L1_OutputModes *pOutputMode)
Charles MacNeill 9:66969b9016ad 539 {
Charles MacNeill 9:66969b9016ad 540 return VL53L1_GetOutputMode(Device,pOutputMode);
Charles MacNeill 9:66969b9016ad 541 }
Charles MacNeill 9:66969b9016ad 542
Charles MacNeill 9:66969b9016ad 543
Charles MacNeill 9:66969b9016ad 544
Charles MacNeill 9:66969b9016ad 545 VL53L1_ERROR VL53L1::vl53L1_SetMeasurementTimingBudgetMicroSeconds(
Charles MacNeill 9:66969b9016ad 546 uint32_t MeasurementTimingBudgetMicroSeconds)
Charles MacNeill 9:66969b9016ad 547 {
Charles MacNeill 9:66969b9016ad 548 return VL53L1_SetMeasurementTimingBudgetMicroSeconds(Device,
Charles MacNeill 9:66969b9016ad 549 MeasurementTimingBudgetMicroSeconds);
Charles MacNeill 9:66969b9016ad 550 }
Charles MacNeill 9:66969b9016ad 551
Charles MacNeill 9:66969b9016ad 552
Charles MacNeill 9:66969b9016ad 553 VL53L1_ERROR VL53L1::vl53L1_GetMeasurementTimingBudgetMicroSeconds(
Charles MacNeill 9:66969b9016ad 554 uint32_t *pMeasurementTimingBudgetMicroSeconds)
Charles MacNeill 9:66969b9016ad 555 {
Charles MacNeill 9:66969b9016ad 556 return VL53L1_GetMeasurementTimingBudgetMicroSeconds(Device,
Charles MacNeill 9:66969b9016ad 557 pMeasurementTimingBudgetMicroSeconds);
Charles MacNeill 9:66969b9016ad 558 }
Charles MacNeill 9:66969b9016ad 559
Charles MacNeill 9:66969b9016ad 560
Charles MacNeill 9:66969b9016ad 561
Charles MacNeill 9:66969b9016ad 562 VL53L1_ERROR VL53L1::vl53L1_SetInterMeasurementPeriodMilliSeconds(
Charles MacNeill 9:66969b9016ad 563 uint32_t InterMeasurementPeriodMilliSeconds)
Charles MacNeill 9:66969b9016ad 564 {
Charles MacNeill 9:66969b9016ad 565 return VL53L1_SetInterMeasurementPeriodMilliSeconds(Device,InterMeasurementPeriodMilliSeconds);
Charles MacNeill 9:66969b9016ad 566 }
Charles MacNeill 9:66969b9016ad 567
Charles MacNeill 9:66969b9016ad 568 VL53L1_ERROR VL53L1::vl53L1_GetInterMeasurementPeriodMilliSeconds(
Charles MacNeill 9:66969b9016ad 569 uint32_t *pInterMeasurementPeriodMilliSeconds)
Charles MacNeill 9:66969b9016ad 570 {
Charles MacNeill 9:66969b9016ad 571 return VL53L1_GetInterMeasurementPeriodMilliSeconds(Device,pInterMeasurementPeriodMilliSeconds);
Charles MacNeill 9:66969b9016ad 572 }
Charles MacNeill 9:66969b9016ad 573
Charles MacNeill 9:66969b9016ad 574 VL53L1_ERROR VL53L1::vl53L1_SetDmaxReflectance(FixPoint1616_t DmaxReflectance)
Charles MacNeill 9:66969b9016ad 575 {
Charles MacNeill 9:66969b9016ad 576
Charles MacNeill 9:66969b9016ad 577 return VL53L1_SetDmaxReflectance(Device,DmaxReflectance);
Charles MacNeill 9:66969b9016ad 578 }
Charles MacNeill 9:66969b9016ad 579
Charles MacNeill 9:66969b9016ad 580 VL53L1_ERROR VL53L1::vl53L1_GetDmaxReflectance(
Charles MacNeill 9:66969b9016ad 581 FixPoint1616_t *pDmaxReflectance)
Charles MacNeill 9:66969b9016ad 582 {
Charles MacNeill 9:66969b9016ad 583 return VL53L1_GetDmaxReflectance(Device,pDmaxReflectance);
Charles MacNeill 9:66969b9016ad 584 }
Charles MacNeill 9:66969b9016ad 585
Charles MacNeill 9:66969b9016ad 586
Charles MacNeill 9:66969b9016ad 587 VL53L1_ERROR VL53L1::vl53L1_SetDmaxMode(VL53L1_DeviceDmaxModes DmaxMode)
Charles MacNeill 9:66969b9016ad 588 {
Charles MacNeill 9:66969b9016ad 589 return VL53L1_SetDmaxMode(Device,DmaxMode);
Charles MacNeill 9:66969b9016ad 590 }
Charles MacNeill 9:66969b9016ad 591
Charles MacNeill 9:66969b9016ad 592
Charles MacNeill 9:66969b9016ad 593 VL53L1_ERROR VL53L1::vl53L1_GetDmaxMode(
Charles MacNeill 9:66969b9016ad 594 VL53L1_DeviceDmaxModes *pDmaxMode)
Charles MacNeill 9:66969b9016ad 595 {
Charles MacNeill 9:66969b9016ad 596 return VL53L1_GetDmaxMode(Device,pDmaxMode);
Charles MacNeill 9:66969b9016ad 597 }
Charles MacNeill 9:66969b9016ad 598
Charles MacNeill 9:66969b9016ad 599
Charles MacNeill 9:66969b9016ad 600
Charles MacNeill 9:66969b9016ad 601 VL53L1_ERROR VL53L1::vl53L1_GetNumberOfLimitCheck(uint16_t *pNumberOfLimitCheck)
Charles MacNeill 9:66969b9016ad 602 {
Charles MacNeill 9:66969b9016ad 603 VL53L1_Error Status = VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 604
Charles MacNeill 9:66969b9016ad 605 // LOG_FUNCTION_START("");
Charles MacNeill 9:66969b9016ad 606
Charles MacNeill 9:66969b9016ad 607 *pNumberOfLimitCheck = VL53L1_CHECKENABLE_NUMBER_OF_CHECKS;
Charles MacNeill 9:66969b9016ad 608
Charles MacNeill 9:66969b9016ad 609 // LOG_FUNCTION_END(Status);
Charles MacNeill 9:66969b9016ad 610 return Status;
Charles MacNeill 9:66969b9016ad 611 }
Charles MacNeill 9:66969b9016ad 612
Charles MacNeill 9:66969b9016ad 613 VL53L1_ERROR VL53L1::vl53L1_GetLimitCheckInfo(uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 614 char *pLimitCheckString)
Charles MacNeill 9:66969b9016ad 615 {
Charles MacNeill 9:66969b9016ad 616 return VL53L1_GetLimitCheckInfo(LimitCheckId,
Charles MacNeill 9:66969b9016ad 617 pLimitCheckString);
Charles MacNeill 9:66969b9016ad 618
Charles MacNeill 9:66969b9016ad 619 }
Charles MacNeill 9:66969b9016ad 620
Charles MacNeill 9:66969b9016ad 621 VL53L1_ERROR VL53L1::vl53L1_GetLimitCheckStatus(uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 622 uint8_t *pLimitCheckStatus)
Charles MacNeill 9:66969b9016ad 623 {
Charles MacNeill 9:66969b9016ad 624 return VL53L1_GetLimitCheckStatus(Device,LimitCheckId,pLimitCheckStatus);
Charles MacNeill 9:66969b9016ad 625 }
Charles MacNeill 9:66969b9016ad 626
Charles MacNeill 9:66969b9016ad 627
Charles MacNeill 9:66969b9016ad 628 VL53L1_ERROR VL53L1::vl53L1_SetLimitCheckEnable(uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 629 uint8_t LimitCheckEnable)
Charles MacNeill 9:66969b9016ad 630 {
Charles MacNeill 9:66969b9016ad 631
Charles MacNeill 9:66969b9016ad 632 return VL53L1_SetLimitCheckEnable(Device,LimitCheckId,LimitCheckEnable);
Charles MacNeill 9:66969b9016ad 633 }
Charles MacNeill 9:66969b9016ad 634
Charles MacNeill 9:66969b9016ad 635 VL53L1_ERROR VL53L1::vl53L1_GetLimitCheckEnable(uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 636 uint8_t *pLimitCheckEnable)
Charles MacNeill 9:66969b9016ad 637 {
Charles MacNeill 9:66969b9016ad 638 return VL53L1_GetLimitCheckEnable(Device,LimitCheckId,pLimitCheckEnable);
Charles MacNeill 9:66969b9016ad 639 }
Charles MacNeill 9:66969b9016ad 640
Charles MacNeill 9:66969b9016ad 641 VL53L1_ERROR VL53L1::vl53L1_SetLimitCheckValue( uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 642 FixPoint1616_t LimitCheckValue)
Charles MacNeill 9:66969b9016ad 643 {
Charles MacNeill 9:66969b9016ad 644 return VL53L1_SetLimitCheckValue(Device,LimitCheckId,LimitCheckValue);
Charles MacNeill 9:66969b9016ad 645 }
Charles MacNeill 9:66969b9016ad 646
Charles MacNeill 9:66969b9016ad 647 VL53L1_ERROR VL53L1::vl53L1_GetLimitCheckValue( uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 648 FixPoint1616_t *pLimitCheckValue)
Charles MacNeill 9:66969b9016ad 649 {
Charles MacNeill 9:66969b9016ad 650 return VL53L1_GetLimitCheckValue(Device,LimitCheckId,pLimitCheckValue);
Charles MacNeill 9:66969b9016ad 651 }
Charles MacNeill 9:66969b9016ad 652
Charles MacNeill 9:66969b9016ad 653 VL53L1_ERROR VL53L1::vl53L1_GetLimitCheckCurrent( uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 654 FixPoint1616_t *pLimitCheckCurrent)
Charles MacNeill 9:66969b9016ad 655 {
Charles MacNeill 9:66969b9016ad 656 return VL53L1_GetLimitCheckCurrent(Device,LimitCheckId,pLimitCheckCurrent);
Charles MacNeill 9:66969b9016ad 657 }
Charles MacNeill 9:66969b9016ad 658
Charles MacNeill 9:66969b9016ad 659
Charles MacNeill 9:66969b9016ad 660 VL53L1_ERROR VL53L1::vl53L1_GetMaxNumberOfROI( uint8_t *pMaxNumberOfROI)
Charles MacNeill 9:66969b9016ad 661 {
Charles MacNeill 9:66969b9016ad 662 return VL53L1_GetMaxNumberOfROI(Device,pMaxNumberOfROI);
Charles MacNeill 9:66969b9016ad 663 }
Charles MacNeill 9:66969b9016ad 664
Charles MacNeill 9:66969b9016ad 665 VL53L1_ERROR VL53L1::vl53L1_SetROI( VL53L1_RoiConfig_t *pRoiConfig)
Charles MacNeill 9:66969b9016ad 666 {
Charles MacNeill 9:66969b9016ad 667
Charles MacNeill 9:66969b9016ad 668 return VL53L1_SetROI(Device,pRoiConfig);
Charles MacNeill 9:66969b9016ad 669 }
Charles MacNeill 9:66969b9016ad 670
Charles MacNeill 9:66969b9016ad 671 VL53L1_ERROR VL53L1::vl53L1_GetROI(VL53L1_RoiConfig_t *pRoiConfig)
Charles MacNeill 9:66969b9016ad 672 {
Charles MacNeill 9:66969b9016ad 673 return VL53L1_GetROI(Device,pRoiConfig);
Charles MacNeill 9:66969b9016ad 674 }
Charles MacNeill 9:66969b9016ad 675
Charles MacNeill 9:66969b9016ad 676
Charles MacNeill 9:66969b9016ad 677
Charles MacNeill 9:66969b9016ad 678
Charles MacNeill 9:66969b9016ad 679 VL53L1_ERROR VL53L1::vl53L1_GetNumberOfSequenceSteps(uint8_t *pNumberOfSequenceSteps)
Charles MacNeill 9:66969b9016ad 680 {
Charles MacNeill 9:66969b9016ad 681 VL53L1_Error Status = VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 682
Charles MacNeill 9:66969b9016ad 683 // SUPPRESS_UNUSED_WARNING(Dev);
Charles MacNeill 9:66969b9016ad 684
Charles MacNeill 9:66969b9016ad 685 // LOG_FUNCTION_START("");
Charles MacNeill 9:66969b9016ad 686
Charles MacNeill 9:66969b9016ad 687 *pNumberOfSequenceSteps = VL53L1_SEQUENCESTEP_NUMBER_OF_ITEMS;
Charles MacNeill 9:66969b9016ad 688
Charles MacNeill 9:66969b9016ad 689 // LOG_FUNCTION_END(Status);
Charles MacNeill 9:66969b9016ad 690 return Status;
Charles MacNeill 9:66969b9016ad 691 }
Charles MacNeill 9:66969b9016ad 692
Charles MacNeill 9:66969b9016ad 693 VL53L1_ERROR VL53L1::vl53L1_GetSequenceStepsInfo(VL53L1_SequenceStepId SequenceStepId,
Charles MacNeill 9:66969b9016ad 694 char *pSequenceStepsString)
Charles MacNeill 9:66969b9016ad 695 {
Charles MacNeill 9:66969b9016ad 696 return VL53L1_GetSequenceStepsInfo(SequenceStepId,pSequenceStepsString);
Charles MacNeill 9:66969b9016ad 697 }
Charles MacNeill 9:66969b9016ad 698
Charles MacNeill 9:66969b9016ad 699 VL53L1_ERROR VL53L1::vl53L1_SetSequenceStepEnable(VL53L1_SequenceStepId SequenceStepId,
Charles MacNeill 9:66969b9016ad 700 uint8_t SequenceStepEnabled)
Charles MacNeill 9:66969b9016ad 701 {
Charles MacNeill 9:66969b9016ad 702
Charles MacNeill 9:66969b9016ad 703 return VL53L1_SetSequenceStepEnable(Device,SequenceStepId,SequenceStepEnabled);
Charles MacNeill 9:66969b9016ad 704 }
Charles MacNeill 9:66969b9016ad 705
Charles MacNeill 9:66969b9016ad 706
Charles MacNeill 9:66969b9016ad 707 VL53L1_ERROR VL53L1::vl53L1_GetSequenceStepEnable(VL53L1_SequenceStepId SequenceStepId,
Charles MacNeill 9:66969b9016ad 708 uint8_t *pSequenceStepEnabled)
Charles MacNeill 9:66969b9016ad 709 {
Charles MacNeill 9:66969b9016ad 710 return VL53L1_GetSequenceStepEnable(Device,SequenceStepId,pSequenceStepEnabled);
Charles MacNeill 9:66969b9016ad 711 }
Charles MacNeill 9:66969b9016ad 712
Charles MacNeill 9:66969b9016ad 713
Charles MacNeill 9:66969b9016ad 714
Charles MacNeill 9:66969b9016ad 715 VL53L1_ERROR VL53L1::vl53L1_StartMeasurement()
Charles MacNeill 9:66969b9016ad 716 {
Charles MacNeill 9:66969b9016ad 717 return VL53L1_StartMeasurement(Device);
Charles MacNeill 9:66969b9016ad 718 }
Charles MacNeill 9:66969b9016ad 719
Charles MacNeill 9:66969b9016ad 720 VL53L1_ERROR VL53L1::vl53L1_StopMeasurement()
Charles MacNeill 9:66969b9016ad 721 {
Charles MacNeill 9:66969b9016ad 722 return VL53L1_StopMeasurement(Device);
Charles MacNeill 9:66969b9016ad 723 }
Charles MacNeill 9:66969b9016ad 724
Charles MacNeill 9:66969b9016ad 725
Charles MacNeill 9:66969b9016ad 726 VL53L1_ERROR VL53L1::vl53L1_ClearInterruptAndStartMeasurement()
Charles MacNeill 9:66969b9016ad 727 {
Charles MacNeill 9:66969b9016ad 728
Charles MacNeill 9:66969b9016ad 729 return VL53L1_ClearInterruptAndStartMeasurement(Device);
Charles MacNeill 9:66969b9016ad 730 }
Charles MacNeill 9:66969b9016ad 731
Charles MacNeill 9:66969b9016ad 732
Charles MacNeill 9:66969b9016ad 733 VL53L1_ERROR VL53L1::vl53L1_GetMeasurementDataReady(uint8_t *pMeasurementDataReady)
Charles MacNeill 9:66969b9016ad 734 {
Charles MacNeill 9:66969b9016ad 735 return VL53L1_GetMeasurementDataReady(Device, pMeasurementDataReady);
Charles MacNeill 9:66969b9016ad 736 }
Charles MacNeill 9:66969b9016ad 737
Charles MacNeill 9:66969b9016ad 738 VL53L1_ERROR VL53L1::vl53L1_WaitMeasurementDataReady()
Charles MacNeill 9:66969b9016ad 739 {
Charles MacNeill 9:66969b9016ad 740 return VL53L1_WaitMeasurementDataReady(Device);
Charles MacNeill 9:66969b9016ad 741 }
Charles MacNeill 9:66969b9016ad 742
Charles MacNeill 9:66969b9016ad 743
Charles MacNeill 9:66969b9016ad 744 //******************************************************************
Charles MacNeill 9:66969b9016ad 745
Charles MacNeill 9:66969b9016ad 746
Charles MacNeill 9:66969b9016ad 747
Charles MacNeill 9:66969b9016ad 748 VL53L1_ERROR VL53L1::vl53L1_GetCalibrationData(
Charles MacNeill 9:66969b9016ad 749 VL53L1_CalibrationData_t *pCalibrationData)
Charles MacNeill 9:66969b9016ad 750 {
Charles MacNeill 9:66969b9016ad 751
Charles MacNeill 9:66969b9016ad 752 VL53L1_Error Status = VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 753 Status = VL53L1_GetCalibrationData(Device,pCalibrationData);
Charles MacNeill 9:66969b9016ad 754
Charles MacNeill 9:66969b9016ad 755 return Status;
Charles MacNeill 9:66969b9016ad 756 }
Charles MacNeill 9:66969b9016ad 757
Charles MacNeill 9:66969b9016ad 758
Charles MacNeill 9:66969b9016ad 759 VL53L1_ERROR VL53L1::vl53L1_GetRangingMeasurementData(
Charles MacNeill 9:66969b9016ad 760 VL53L1_RangingMeasurementData_t *pRangingMeasurementData)
Charles MacNeill 9:66969b9016ad 761 {
Charles MacNeill 9:66969b9016ad 762 // printf(" VL53L1_GetRangingMeasurementData 000 \n");
Charles MacNeill 9:66969b9016ad 763 VL53L1_Error Status = VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 764 Status = VL53L1_GetRangingMeasurementData(Device,pRangingMeasurementData);
Charles MacNeill 9:66969b9016ad 765
Charles MacNeill 9:66969b9016ad 766 return Status;
Charles MacNeill 9:66969b9016ad 767 }
Charles MacNeill 9:66969b9016ad 768
Charles MacNeill 9:66969b9016ad 769
Charles MacNeill 9:66969b9016ad 770
Charles MacNeill 9:66969b9016ad 771
Charles MacNeill 9:66969b9016ad 772
Charles MacNeill 9:66969b9016ad 773 VL53L1_ERROR VL53L1::vl53L1_GetMultiRangingData(
Charles MacNeill 9:66969b9016ad 774 VL53L1_MultiRangingData_t *pMultiRangingData)
Charles MacNeill 9:66969b9016ad 775 {
Charles MacNeill 9:66969b9016ad 776 return VL53L1_GetMultiRangingData(Device,pMultiRangingData);
Charles MacNeill 9:66969b9016ad 777 }
Charles MacNeill 9:66969b9016ad 778
Charles MacNeill 9:66969b9016ad 779 VL53L1_ERROR VL53L1::vl53L1_GetAdditionalData(
Charles MacNeill 9:66969b9016ad 780 VL53L1_AdditionalData_t *pAdditionalData)
Charles MacNeill 9:66969b9016ad 781 {
Charles MacNeill 9:66969b9016ad 782 return VL53L1_GetAdditionalData(Device, pAdditionalData);
Charles MacNeill 9:66969b9016ad 783 }
Charles MacNeill 9:66969b9016ad 784
Charles MacNeill 9:66969b9016ad 785
Charles MacNeill 9:66969b9016ad 786
Charles MacNeill 9:66969b9016ad 787 VL53L1_ERROR VL53L1::vl53L1_SetTuningParameter(
Charles MacNeill 9:66969b9016ad 788 uint16_t TuningParameterId, int32_t TuningParameterValue)
Charles MacNeill 9:66969b9016ad 789 {
Charles MacNeill 9:66969b9016ad 790 return VL53L1_SetTuningParameter(Device,TuningParameterId,TuningParameterValue);
Charles MacNeill 9:66969b9016ad 791 }
Charles MacNeill 9:66969b9016ad 792
Charles MacNeill 9:66969b9016ad 793 VL53L1_ERROR VL53L1::vl53L1_GetTuningParameter(
Charles MacNeill 9:66969b9016ad 794 uint16_t TuningParameterId, int32_t *pTuningParameterValue)
Charles MacNeill 9:66969b9016ad 795 {
Charles MacNeill 9:66969b9016ad 796
Charles MacNeill 9:66969b9016ad 797 return VL53L1_GetTuningParameter(Device,TuningParameterId,pTuningParameterValue);
Charles MacNeill 9:66969b9016ad 798 }
Charles MacNeill 9:66969b9016ad 799
Charles MacNeill 9:66969b9016ad 800
Charles MacNeill 9:66969b9016ad 801 VL53L1_ERROR VL53L1::vl53L1_SetXTalkCompensationEnable(
Charles MacNeill 9:66969b9016ad 802 uint8_t XTalkCompensationEnable)
Charles MacNeill 9:66969b9016ad 803 {
Charles MacNeill 9:66969b9016ad 804
Charles MacNeill 9:66969b9016ad 805 return VL53L1_SetXTalkCompensationEnable(Device,XTalkCompensationEnable);
Charles MacNeill 9:66969b9016ad 806 }
Charles MacNeill 9:66969b9016ad 807
Charles MacNeill 9:66969b9016ad 808
Charles MacNeill 9:66969b9016ad 809 VL53L1_ERROR VL53L1::vl53L1_GetXTalkCompensationEnable(
Charles MacNeill 9:66969b9016ad 810 uint8_t *pXTalkCompensationEnable)
Charles MacNeill 9:66969b9016ad 811 {
Charles MacNeill 9:66969b9016ad 812 VL53L1_Error Status = VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 813
Charles MacNeill 9:66969b9016ad 814 // LOG_FUNCTION_START("");
Charles MacNeill 9:66969b9016ad 815
Charles MacNeill 9:66969b9016ad 816 VL53L1_GetXTalkCompensationEnable(
Charles MacNeill 9:66969b9016ad 817 Device,
Charles MacNeill 9:66969b9016ad 818 pXTalkCompensationEnable);
Charles MacNeill 9:66969b9016ad 819
Charles MacNeill 9:66969b9016ad 820 // LOG_FUNCTION_END(Status);
Charles MacNeill 9:66969b9016ad 821 return Status;
Charles MacNeill 9:66969b9016ad 822 }
Charles MacNeill 9:66969b9016ad 823
Charles MacNeill 9:66969b9016ad 824
Charles MacNeill 9:66969b9016ad 825 VL53L1_ERROR VL53L1::vl53L1_PerformXTalkCalibration(
Charles MacNeill 9:66969b9016ad 826 uint8_t CalibrationOption)
Charles MacNeill 9:66969b9016ad 827 {
Charles MacNeill 9:66969b9016ad 828
Charles MacNeill 9:66969b9016ad 829 return VL53L1_PerformXTalkCalibration(Device,CalibrationOption);
Charles MacNeill 9:66969b9016ad 830 }
Charles MacNeill 9:66969b9016ad 831
Charles MacNeill 9:66969b9016ad 832 VL53L1_ERROR VL53L1::vl53L1_SetOffsetCalibrationMode(
Charles MacNeill 9:66969b9016ad 833 VL53L1_OffsetCalibrationModes OffsetCalibrationMode)
Charles MacNeill 9:66969b9016ad 834 {
Charles MacNeill 9:66969b9016ad 835 return VL53L1_SetOffsetCalibrationMode(Device,OffsetCalibrationMode);
Charles MacNeill 9:66969b9016ad 836 }
Charles MacNeill 9:66969b9016ad 837
Charles MacNeill 9:66969b9016ad 838 VL53L1_ERROR VL53L1::vl53L1_SetOffsetCorrectionMode(
Charles MacNeill 9:66969b9016ad 839 VL53L1_OffsetCorrectionModes OffsetCorrectionMode)
Charles MacNeill 9:66969b9016ad 840 {
Charles MacNeill 9:66969b9016ad 841 return VL53L1_SetOffsetCorrectionMode(Device,OffsetCorrectionMode);
Charles MacNeill 9:66969b9016ad 842 }
Charles MacNeill 9:66969b9016ad 843
Charles MacNeill 9:66969b9016ad 844 VL53L1_ERROR VL53L1::vl53L1_PerformOffsetCalibration(
Charles MacNeill 9:66969b9016ad 845 int32_t CalDistanceMilliMeter, FixPoint1616_t CalReflectancePercent)
Charles MacNeill 9:66969b9016ad 846 {
Charles MacNeill 9:66969b9016ad 847 return VL53L1_PerformOffsetCalibration(Device,CalDistanceMilliMeter,CalReflectancePercent);
Charles MacNeill 9:66969b9016ad 848 }
Charles MacNeill 9:66969b9016ad 849
Charles MacNeill 9:66969b9016ad 850 VL53L1_ERROR VL53L1::vl53L1_PerformOffsetSimpleCalibration(
Charles MacNeill 9:66969b9016ad 851 int32_t CalDistanceMilliMeter)
Charles MacNeill 9:66969b9016ad 852 {
Charles MacNeill 9:66969b9016ad 853 return VL53L1_PerformOffsetSimpleCalibration(Device,CalDistanceMilliMeter);
Charles MacNeill 9:66969b9016ad 854 }
Charles MacNeill 9:66969b9016ad 855
Charles MacNeill 9:66969b9016ad 856 VL53L1_ERROR VL53L1::vl53L1_PerformOffsetZeroDistanceCalibration()
Charles MacNeill 9:66969b9016ad 857 {
Charles MacNeill 9:66969b9016ad 858 return VL53L1_PerformOffsetZeroDistanceCalibration(Device);
Charles MacNeill 9:66969b9016ad 859 }
Charles MacNeill 9:66969b9016ad 860
Charles MacNeill 9:66969b9016ad 861 VL53L1_ERROR VL53L1::vl53L1_SetCalibrationData(
Charles MacNeill 9:66969b9016ad 862 VL53L1_CalibrationData_t *pCalibrationData)
Charles MacNeill 9:66969b9016ad 863 {
Charles MacNeill 9:66969b9016ad 864 return VL53L1_SetCalibrationData(Device,pCalibrationData);
Charles MacNeill 9:66969b9016ad 865 }
Charles MacNeill 9:66969b9016ad 866
Charles MacNeill 9:66969b9016ad 867
Charles MacNeill 9:66969b9016ad 868 VL53L1_ERROR VL53L1::vl53L1_SetZoneCalibrationData(
Charles MacNeill 9:66969b9016ad 869 VL53L1_ZoneCalibrationData_t *pZoneCalibrationData)
Charles MacNeill 9:66969b9016ad 870 {
Charles MacNeill 9:66969b9016ad 871 return VL53L1_SetZoneCalibrationData(Device, pZoneCalibrationData);
Charles MacNeill 9:66969b9016ad 872 }
Charles MacNeill 9:66969b9016ad 873
Charles MacNeill 9:66969b9016ad 874 VL53L1_ERROR VL53L1::vl53L1_GetZoneCalibrationData(
Charles MacNeill 9:66969b9016ad 875 VL53L1_ZoneCalibrationData_t *pZoneCalibrationData)
Charles MacNeill 9:66969b9016ad 876 {
Charles MacNeill 9:66969b9016ad 877 return VL53L1_GetZoneCalibrationData(Device, pZoneCalibrationData);
Charles MacNeill 9:66969b9016ad 878 }
Charles MacNeill 9:66969b9016ad 879
Charles MacNeill 9:66969b9016ad 880 VL53L1_Error VL53L1::vl53L1_SmudgeCorrectionEnable(
Charles MacNeill 9:66969b9016ad 881 VL53L1_SmudgeCorrectionModes Mode)
Charles MacNeill 9:66969b9016ad 882
Charles MacNeill 9:66969b9016ad 883 {
Charles MacNeill 9:66969b9016ad 884 return VL53L1_SmudgeCorrectionEnable(Device, Mode);
Charles MacNeill 9:66969b9016ad 885 }
Charles MacNeill 9:66969b9016ad 886
Charles MacNeill 9:66969b9016ad 887 VL53L1_ERROR VL53L1::vl53L1_GetOpticalCenter(
Charles MacNeill 9:66969b9016ad 888 FixPoint1616_t *pOpticalCenterX,
Charles MacNeill 9:66969b9016ad 889 FixPoint1616_t *pOpticalCenterY)
Charles MacNeill 9:66969b9016ad 890 {
Charles MacNeill 9:66969b9016ad 891 return VL53L1_GetOpticalCenter(Device,pOpticalCenterX,pOpticalCenterY);
Charles MacNeill 9:66969b9016ad 892 }
Charles MacNeill 9:66969b9016ad 893
Charles MacNeill 9:66969b9016ad 894
Charles MacNeill 9:66969b9016ad 895
Charles MacNeill 9:66969b9016ad 896
Charles MacNeill 9:66969b9016ad 897
Charles MacNeill 9:66969b9016ad 898
Charles MacNeill 9:66969b9016ad 899 VL53L1_ERROR VL53L1::vl53L1_SetThresholdConfig(VL53L1_DetectionConfig_t *pConfig)
Charles MacNeill 9:66969b9016ad 900 {
Charles MacNeill 9:66969b9016ad 901 return VL53L1_SetThresholdConfig(Device,pConfig);
Charles MacNeill 9:66969b9016ad 902 }
Charles MacNeill 9:66969b9016ad 903
Charles MacNeill 9:66969b9016ad 904
Charles MacNeill 9:66969b9016ad 905 VL53L1_ERROR VL53L1::vl53L1_GetThresholdConfig(VL53L1_DetectionConfig_t *pConfig)
Charles MacNeill 9:66969b9016ad 906 {
Charles MacNeill 9:66969b9016ad 907 return VL53L1_GetThresholdConfig(Device,pConfig);
Charles MacNeill 9:66969b9016ad 908 }
Charles MacNeill 9:66969b9016ad 909
Charles MacNeill 9:66969b9016ad 910
Charles MacNeill 9:66969b9016ad 911
Charles MacNeill 9:66969b9016ad 912
Charles MacNeill 9:66969b9016ad 913 VL53L1_ERROR VL53L1::vl53L1_PerformOffsetPerVcselCalibration(int32_t CalDistanceMilliMeter)
Charles MacNeill 9:66969b9016ad 914 {
Charles MacNeill 9:66969b9016ad 915 return VL53L1_PerformOffsetPerVcselCalibration(Device,CalDistanceMilliMeter);
Charles MacNeill 9:66969b9016ad 916 }
Charles MacNeill 9:66969b9016ad 917
Charles MacNeill 9:66969b9016ad 918
Charles MacNeill 9:66969b9016ad 919
Charles MacNeill 9:66969b9016ad 920 // from vl53l1_api_debug.c
Charles MacNeill 9:66969b9016ad 921
Charles MacNeill 9:66969b9016ad 922
Charles MacNeill 9:66969b9016ad 923 VL53L1_ERROR VL53L1::vl53L1_get_additional_data(
Charles MacNeill 9:66969b9016ad 924 VL53L1_DEV Dev,
Charles MacNeill 9:66969b9016ad 925 VL53L1_additional_data_t *pdata)
Charles MacNeill 9:66969b9016ad 926 {
Charles MacNeill 9:66969b9016ad 927 return VL53L1_get_additional_data(Dev,pdata);
Charles MacNeill 9:66969b9016ad 928 }
Charles MacNeill 9:66969b9016ad 929
Charles MacNeill 9:66969b9016ad 930
Charles MacNeill 9:66969b9016ad 931
Charles MacNeill 9:66969b9016ad 932 int VL53L1::handle_irq(uint16_t *distance)
Charles MacNeill 9:66969b9016ad 933 {
Charles MacNeill 9:66969b9016ad 934 int status;
Charles MacNeill 9:66969b9016ad 935 status = get_measurement(distance);
Charles MacNeill 9:66969b9016ad 936 enable_interrupt_measure_detection_irq();
Charles MacNeill 9:66969b9016ad 937 return status;
Charles MacNeill 9:66969b9016ad 938 }
Charles MacNeill 9:66969b9016ad 939
Charles MacNeill 9:66969b9016ad 940 int VL53L1::get_measurement(uint16_t *distance)
Charles MacNeill 9:66969b9016ad 941 {
Charles MacNeill 9:66969b9016ad 942 int status = 0;
Charles MacNeill 9:66969b9016ad 943
Charles MacNeill 9:66969b9016ad 944 status = VL53L1_GetDistance(distance);
Charles MacNeill 9:66969b9016ad 945 status = VL53L1_ClearInterrupt();
Charles MacNeill 9:66969b9016ad 946
Charles MacNeill 9:66969b9016ad 947 return status;
Charles MacNeill 9:66969b9016ad 948 }
Charles MacNeill 9:66969b9016ad 949
Charles MacNeill 9:66969b9016ad 950 int VL53L1::start_measurement(void (*fptr)(void))
Charles MacNeill 9:66969b9016ad 951 {
Charles MacNeill 9:66969b9016ad 952 int status = 0;
Charles MacNeill 9:66969b9016ad 953
Charles MacNeill 9:66969b9016ad 954 if (_gpio1Int == NULL) {
Charles MacNeill 9:66969b9016ad 955 printf("GPIO1 Error\r\n");
Charles MacNeill 9:66969b9016ad 956 return 1;
Charles MacNeill 9:66969b9016ad 957 }
Charles MacNeill 9:66969b9016ad 958
Charles MacNeill 9:66969b9016ad 959 status = VL53L1_StopRanging(); // it is safer to do this while sensor is stopped
Charles MacNeill 9:66969b9016ad 960
Charles MacNeill 9:66969b9016ad 961 if (status == 0) {
Charles MacNeill 9:66969b9016ad 962 attach_interrupt_measure_detection_irq(fptr);
Charles MacNeill 9:66969b9016ad 963 enable_interrupt_measure_detection_irq();
Charles MacNeill 9:66969b9016ad 964 }
Charles MacNeill 9:66969b9016ad 965
Charles MacNeill 9:66969b9016ad 966 if (status == 0) {
Charles MacNeill 9:66969b9016ad 967 status = VL53L1_StartRanging();
Charles MacNeill 9:66969b9016ad 968 }
Charles MacNeill 9:66969b9016ad 969
Charles MacNeill 9:66969b9016ad 970 return status;
Charles MacNeill 9:66969b9016ad 971 }
Charles MacNeill 9:66969b9016ad 972
Charles MacNeill 9:66969b9016ad 973 int VL53L1::stop_measurement()
Charles MacNeill 9:66969b9016ad 974 {
Charles MacNeill 9:66969b9016ad 975 int status = 0;
Charles MacNeill 9:66969b9016ad 976
Charles MacNeill 9:66969b9016ad 977 if (status == 0) {
Charles MacNeill 9:66969b9016ad 978 printf("Call of VL53L1_StopMeasurement\n");
Charles MacNeill 9:66969b9016ad 979 status = VL53L1_StopRanging();
Charles MacNeill 9:66969b9016ad 980 }
Charles MacNeill 9:66969b9016ad 981
Charles MacNeill 9:66969b9016ad 982 if (status == 0)
Charles MacNeill 9:66969b9016ad 983 status = VL53L1_ClearInterrupt();
Charles MacNeill 9:66969b9016ad 984
Charles MacNeill 9:66969b9016ad 985 return status;
Charles MacNeill 9:66969b9016ad 986 }
Charles MacNeill 9:66969b9016ad 987
Charles MacNeill 9:66969b9016ad 988