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:
Sat Jun 19 16:45:54 2021 +0100
Revision:
14:f06785b2a964
Parent:
11:be14e3591d65
Child:
16:27131f13570d
Fix the satellites not working issue.

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 10:3687b5e79f98 68 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetSWVersion(VL53L1_Version_t *pVersion)
Charles MacNeill 9:66969b9016ad 69 {
Charles MacNeill 10:3687b5e79f98 70 VL53L1CB_ERROR Status = 0;
Charles MacNeill 9:66969b9016ad 71
Charles MacNeill 14:f06785b2a964 72 pVersion->major = VL53L1_IMPLEMENTATION_VER_MAJOR;
Charles MacNeill 14:f06785b2a964 73 pVersion->minor = VL53L1_IMPLEMENTATION_VER_MINOR;
Charles MacNeill 14:f06785b2a964 74 pVersion->build = VL53L1_IMPLEMENTATION_VER_SUB;
Charles MacNeill 14:f06785b2a964 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 10:3687b5e79f98 79 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetI2CAddress(uint8_t new_address)
Charles MacNeill 9:66969b9016ad 80 {
Charles MacNeill 10:3687b5e79f98 81 VL53L1CB_ERROR status = 0;
Charles MacNeill 10:3687b5e79f98 82 // status = (VL53L1CB_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 14:f06785b2a964 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 10:3687b5e79f98 96 int VL53L1CB::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 10:3687b5e79f98 100 VL53L1CB_Off();
Charles MacNeill 10:3687b5e79f98 101 VL53L1CB_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 10:3687b5e79f98 112 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SensorInit()
Charles MacNeill 9:66969b9016ad 113 {
Charles MacNeill 10:3687b5e79f98 114 VL53L1CB_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 14:f06785b2a964 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 10:3687b5e79f98 129 status = VL53L1CB_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 10:3687b5e79f98 135 status = VL53L1CB_ClearInterrupt();
Charles MacNeill 10:3687b5e79f98 136 status = VL53L1CB_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 10:3687b5e79f98 143 VL53L1CB_ERROR VL53L1CB::VL53L1CB_ClearInterrupt()
Charles MacNeill 9:66969b9016ad 144 {
Charles MacNeill 10:3687b5e79f98 145 VL53L1CB_ERROR status = 0;
Charles MacNeill 9:66969b9016ad 146
Charles MacNeill 14:f06785b2a964 147 status = VL53L1_WrByte(Device, SYSTEM__INTERRUPT_CLEAR, 0x01);
Charles MacNeill 14:f06785b2a964 148 // printf("VL53L1CB::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 10:3687b5e79f98 156 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetInterruptPolarity(uint8_t *pInterruptPolarity)
Charles MacNeill 9:66969b9016ad 157 {
Charles MacNeill 9:66969b9016ad 158 uint8_t Temp;
Charles MacNeill 10:3687b5e79f98 159 VL53L1CB_ERROR status = 0;
Charles MacNeill 9:66969b9016ad 160
Charles MacNeill 14:f06785b2a964 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 10:3687b5e79f98 169 VL53L1CB_ERROR VL53L1CB::VL53L1CB_StartRanging()
Charles MacNeill 9:66969b9016ad 170 {
Charles MacNeill 10:3687b5e79f98 171 VL53L1CB_ERROR status = 0;
Charles MacNeill 9:66969b9016ad 172
Charles MacNeill 14:f06785b2a964 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 10:3687b5e79f98 178 VL53L1CB_ERROR VL53L1CB::VL53L1CB_StopRanging()
Charles MacNeill 9:66969b9016ad 179 {
Charles MacNeill 10:3687b5e79f98 180 VL53L1CB_ERROR status = 0;
Charles MacNeill 9:66969b9016ad 181
Charles MacNeill 14:f06785b2a964 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 10:3687b5e79f98 189 VL53L1CB_ERROR VL53L1CB::VL53L1CB_BootState(uint8_t *state)
Charles MacNeill 9:66969b9016ad 190 {
Charles MacNeill 10:3687b5e79f98 191 VL53L1CB_ERROR status = 0;
Charles MacNeill 9:66969b9016ad 192 uint8_t tmp = 0;
Charles MacNeill 9:66969b9016ad 193
Charles MacNeill 14:f06785b2a964 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 10:3687b5e79f98 200 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetDistance(uint16_t *distance)
Charles MacNeill 9:66969b9016ad 201 {
Charles MacNeill 10:3687b5e79f98 202 VL53L1CB_ERROR status = 0;
Charles MacNeill 9:66969b9016ad 203 uint16_t tmp;
Charles MacNeill 9:66969b9016ad 204
Charles MacNeill 14:f06785b2a964 205 status = (VL53L1_RdWord(Device,
Charles MacNeill 14:f06785b2a964 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 10:3687b5e79f98 215 VL53L1CB_ERROR VL53L1CB::VL53L1CB_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 10:3687b5e79f98 219 status = VL53L1CB_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 10:3687b5e79f98 223 VL53L1CB_ERROR VL53L1CB::VL53L1CB_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 10:3687b5e79f98 227 status = VL53L1CB_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 14:f06785b2a964 233 VL53L1CB_ERROR VL53L1CB::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 10:3687b5e79f98 237 status=VL53L1CB_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 14:f06785b2a964 241
Charles MacNeill 14:f06785b2a964 242 VL53L1CB_ERROR VL53L1CB::VL53L1_WrWord(VL53L1_DEV Dev, uint16_t index, uint16_t data)
Charles MacNeill 9:66969b9016ad 243 {
Charles MacNeill 9:66969b9016ad 244 int status;
Charles MacNeill 9:66969b9016ad 245 uint8_t buffer[2];
Charles MacNeill 9:66969b9016ad 246
Charles MacNeill 9:66969b9016ad 247 buffer[0] = data >> 8;
Charles MacNeill 9:66969b9016ad 248 buffer[1] = data & 0x00FF;
Charles MacNeill 10:3687b5e79f98 249 status=VL53L1CB_I2CWrite(Dev->i2c_slave_address, index, (uint8_t *)buffer, 2);
Charles MacNeill 9:66969b9016ad 250 return status;
Charles MacNeill 9:66969b9016ad 251 }
Charles MacNeill 9:66969b9016ad 252
Charles MacNeill 14:f06785b2a964 253 VL53L1CB_ERROR VL53L1CB::VL53L1_WrDWord(VL53L1_DEV Dev, uint16_t index, uint32_t data)
Charles MacNeill 9:66969b9016ad 254 {
Charles MacNeill 9:66969b9016ad 255 int status;
Charles MacNeill 9:66969b9016ad 256 uint8_t buffer[4];
Charles MacNeill 9:66969b9016ad 257
Charles MacNeill 9:66969b9016ad 258 buffer[0] = (data >> 24) & 0xFF;
Charles MacNeill 9:66969b9016ad 259 buffer[1] = (data >> 16) & 0xFF;
Charles MacNeill 9:66969b9016ad 260 buffer[2] = (data >> 8) & 0xFF;
Charles MacNeill 9:66969b9016ad 261 buffer[3] = (data >> 0) & 0xFF;
Charles MacNeill 10:3687b5e79f98 262 status=VL53L1CB_I2CWrite(Dev->i2c_slave_address, index, (uint8_t *)buffer, 4);
Charles MacNeill 9:66969b9016ad 263 return status;
Charles MacNeill 9:66969b9016ad 264 }
Charles MacNeill 9:66969b9016ad 265
Charles MacNeill 9:66969b9016ad 266
Charles MacNeill 14:f06785b2a964 267 VL53L1CB_ERROR VL53L1CB::VL53L1_RdByte(VL53L1_DEV Dev, uint16_t index, uint8_t *data)
Charles MacNeill 9:66969b9016ad 268 {
Charles MacNeill 9:66969b9016ad 269 int status;
Charles MacNeill 9:66969b9016ad 270
Charles MacNeill 10:3687b5e79f98 271 status = VL53L1CB_I2CRead(Dev->i2c_slave_address, index, data, 1);
Charles MacNeill 9:66969b9016ad 272
Charles MacNeill 9:66969b9016ad 273 if(status)
Charles MacNeill 9:66969b9016ad 274 return -1;
Charles MacNeill 9:66969b9016ad 275
Charles MacNeill 9:66969b9016ad 276 return 0;
Charles MacNeill 9:66969b9016ad 277 }
Charles MacNeill 9:66969b9016ad 278
Charles MacNeill 14:f06785b2a964 279 VL53L1CB_ERROR VL53L1CB::VL53L1_RdWord(VL53L1_DEV Dev, uint16_t index, uint16_t *data)
Charles MacNeill 9:66969b9016ad 280 {
Charles MacNeill 9:66969b9016ad 281 int status;
Charles MacNeill 9:66969b9016ad 282 uint8_t buffer[2] = {0,0};
Charles MacNeill 9:66969b9016ad 283
Charles MacNeill 10:3687b5e79f98 284 status = VL53L1CB_I2CRead(Dev->i2c_slave_address, index, buffer, 2);
Charles MacNeill 9:66969b9016ad 285 if (!status)
Charles MacNeill 9:66969b9016ad 286 {
Charles MacNeill 9:66969b9016ad 287 *data = (buffer[0] << 8) + buffer[1];
Charles MacNeill 9:66969b9016ad 288 }
Charles MacNeill 9:66969b9016ad 289 // printf("VL53L1_RdWord %d %d %d \n",Dev->i2c_slave_address,index,status);
Charles MacNeill 9:66969b9016ad 290 return status;
Charles MacNeill 9:66969b9016ad 291
Charles MacNeill 9:66969b9016ad 292 }
Charles MacNeill 9:66969b9016ad 293
Charles MacNeill 14:f06785b2a964 294 VL53L1CB_ERROR VL53L1CB::VL53L1_RdDWord(VL53L1_DEV Dev, uint16_t index, uint32_t *data)
Charles MacNeill 9:66969b9016ad 295 {
Charles MacNeill 9:66969b9016ad 296 int status;
Charles MacNeill 9:66969b9016ad 297 uint8_t buffer[4] = {0,0,0,0};
Charles MacNeill 9:66969b9016ad 298
Charles MacNeill 10:3687b5e79f98 299 status = VL53L1CB_I2CRead(Dev->i2c_slave_address, index, buffer, 4);
Charles MacNeill 9:66969b9016ad 300 if(!status)
Charles MacNeill 9:66969b9016ad 301 {
Charles MacNeill 9:66969b9016ad 302 *data = (buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3];
Charles MacNeill 9:66969b9016ad 303 }
Charles MacNeill 9:66969b9016ad 304 return status;
Charles MacNeill 9:66969b9016ad 305
Charles MacNeill 9:66969b9016ad 306 }
Charles MacNeill 9:66969b9016ad 307
Charles MacNeill 14:f06785b2a964 308 VL53L1CB_ERROR VL53L1CB::VL53L1_UpdateByte(VL53L1_DEV Dev, uint16_t index, uint8_t AndData, uint8_t OrData)
Charles MacNeill 9:66969b9016ad 309 {
Charles MacNeill 9:66969b9016ad 310 int status;
Charles MacNeill 9:66969b9016ad 311 uint8_t buffer = 0;
Charles MacNeill 9:66969b9016ad 312
Charles MacNeill 9:66969b9016ad 313 /* read data direct onto buffer */
Charles MacNeill 10:3687b5e79f98 314 status = VL53L1CB_I2CRead(Dev->i2c_slave_address, index, &buffer,1);
Charles MacNeill 9:66969b9016ad 315 if (!status)
Charles MacNeill 9:66969b9016ad 316 {
Charles MacNeill 9:66969b9016ad 317 buffer = (buffer & AndData) | OrData;
Charles MacNeill 10:3687b5e79f98 318 status = VL53L1CB_I2CWrite(Dev->i2c_slave_address, index, &buffer, (uint16_t)1);
Charles MacNeill 9:66969b9016ad 319 }
Charles MacNeill 9:66969b9016ad 320 return status;
Charles MacNeill 9:66969b9016ad 321 }
Charles MacNeill 9:66969b9016ad 322
Charles MacNeill 10:3687b5e79f98 323 VL53L1CB_ERROR VL53L1CB::VL53L1CB_I2CWrite(uint8_t DeviceAddr, uint16_t RegisterAddr, uint8_t* pBuffer, uint16_t NumByteToWrite)
Charles MacNeill 9:66969b9016ad 324 {
Charles MacNeill 9:66969b9016ad 325 int ret;
Charles MacNeill 9:66969b9016ad 326 ret = dev_i2c->ToF_i2c_write(pBuffer, DeviceAddr, RegisterAddr, NumByteToWrite);
Charles MacNeill 9:66969b9016ad 327 if (ret) {
Charles MacNeill 9:66969b9016ad 328 return -1;
Charles MacNeill 9:66969b9016ad 329 }
Charles MacNeill 9:66969b9016ad 330 return 0;
Charles MacNeill 9:66969b9016ad 331
Charles MacNeill 9:66969b9016ad 332 }
Charles MacNeill 9:66969b9016ad 333
Charles MacNeill 10:3687b5e79f98 334 VL53L1CB_ERROR VL53L1CB::VL53L1CB_I2CRead(uint8_t DeviceAddr, uint16_t RegisterAddr, uint8_t* pBuffer, uint16_t NumByteToRead)
Charles MacNeill 9:66969b9016ad 335 {
Charles MacNeill 9:66969b9016ad 336 int ret;
Charles MacNeill 9:66969b9016ad 337
Charles MacNeill 9:66969b9016ad 338 ret = dev_i2c->ToF_i2c_read(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead);
Charles MacNeill 9:66969b9016ad 339 //ret = dev_i2c->i2c_read(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead);
Charles MacNeill 9:66969b9016ad 340 if (ret) {
Charles MacNeill 9:66969b9016ad 341 return -1;
Charles MacNeill 9:66969b9016ad 342 }
Charles MacNeill 9:66969b9016ad 343 return 0;
Charles MacNeill 9:66969b9016ad 344 }
Charles MacNeill 9:66969b9016ad 345
Charles MacNeill 9:66969b9016ad 346
Charles MacNeill 10:3687b5e79f98 347 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetTickCount(
Charles MacNeill 9:66969b9016ad 348 uint32_t *ptick_count_ms)
Charles MacNeill 9:66969b9016ad 349 {
Charles MacNeill 9:66969b9016ad 350
Charles MacNeill 9:66969b9016ad 351 /* Returns current tick count in [ms] */
Charles MacNeill 9:66969b9016ad 352
Charles MacNeill 10:3687b5e79f98 353 VL53L1CB_ERROR status = VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 354
Charles MacNeill 9:66969b9016ad 355 //*ptick_count_ms = timeGetTime();
Charles MacNeill 9:66969b9016ad 356 *ptick_count_ms = us_ticker_read() / 1000;
Charles MacNeill 9:66969b9016ad 357
Charles MacNeill 9:66969b9016ad 358 return status;
Charles MacNeill 9:66969b9016ad 359 }
Charles MacNeill 9:66969b9016ad 360
Charles MacNeill 9:66969b9016ad 361
Charles MacNeill 9:66969b9016ad 362
Charles MacNeill 10:3687b5e79f98 363 VL53L1CB_ERROR VL53L1CB::VL53L1CB_WaitUs(VL53L1_Dev_t *pdev, int32_t wait_time)
Charles MacNeill 9:66969b9016ad 364 {
Charles MacNeill 9:66969b9016ad 365 //(void)pdev;
Charles MacNeill 9:66969b9016ad 366 wait_us(wait_time);
Charles MacNeill 9:66969b9016ad 367 return VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 368 }
Charles MacNeill 9:66969b9016ad 369
Charles MacNeill 9:66969b9016ad 370
Charles MacNeill 10:3687b5e79f98 371 VL53L1CB_ERROR VL53L1CB::VL53L1CB_WaitMs(VL53L1_Dev_t *pdev, int32_t wait_time)
Charles MacNeill 9:66969b9016ad 372 {
Charles MacNeill 9:66969b9016ad 373 //(void)pdev;
Charles MacNeill 9:66969b9016ad 374
Charles MacNeill 9:66969b9016ad 375 #if (MBED_VERSION > 60300)
Charles MacNeill 9:66969b9016ad 376 thread_sleep_for(wait_time);
Charles MacNeill 9:66969b9016ad 377 #else
Charles MacNeill 9:66969b9016ad 378 wait_ms(wait_time); // NEEDS A DELAY BETWEEN SENSORS
Charles MacNeill 9:66969b9016ad 379 #endif
Charles MacNeill 9:66969b9016ad 380 return VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 381 }
Charles MacNeill 9:66969b9016ad 382
Charles MacNeill 9:66969b9016ad 383
Charles MacNeill 10:3687b5e79f98 384 VL53L1CB_ERROR VL53L1CB::VL53L1CB_WaitValueMaskEx(
Charles MacNeill 9:66969b9016ad 385 VL53L1_Dev_t *pdev,
Charles MacNeill 9:66969b9016ad 386 uint32_t timeout_ms,
Charles MacNeill 9:66969b9016ad 387 uint16_t index,
Charles MacNeill 9:66969b9016ad 388 uint8_t value,
Charles MacNeill 9:66969b9016ad 389 uint8_t mask,
Charles MacNeill 9:66969b9016ad 390 uint32_t poll_delay_ms)
Charles MacNeill 9:66969b9016ad 391 {
Charles MacNeill 9:66969b9016ad 392
Charles MacNeill 9:66969b9016ad 393 /*
Charles MacNeill 9:66969b9016ad 394 * Platform implementation of WaitValueMaskEx V2WReg script command
Charles MacNeill 9:66969b9016ad 395 *
Charles MacNeill 9:66969b9016ad 396 * WaitValueMaskEx(
Charles MacNeill 9:66969b9016ad 397 * duration_ms,
Charles MacNeill 9:66969b9016ad 398 * index,
Charles MacNeill 9:66969b9016ad 399 * value,
Charles MacNeill 9:66969b9016ad 400 * mask,
Charles MacNeill 9:66969b9016ad 401 * poll_delay_ms);
Charles MacNeill 9:66969b9016ad 402 */
Charles MacNeill 9:66969b9016ad 403
Charles MacNeill 9:66969b9016ad 404
Charles MacNeill 9:66969b9016ad 405 return VL53L1_WaitValueMaskEx( pdev, timeout_ms,index, value, mask, poll_delay_ms);
Charles MacNeill 9:66969b9016ad 406 }
Charles MacNeill 9:66969b9016ad 407
Charles MacNeill 9:66969b9016ad 408
Charles MacNeill 9:66969b9016ad 409 /***************************************************************************/
Charles MacNeill 14:f06785b2a964 410 //VL53L1CB_ERROR VL53L1CB::VL53L1_WaitValueMaskEx(
Charles MacNeill 9:66969b9016ad 411
Charles MacNeill 10:3687b5e79f98 412 VL53L1CB_ERROR VL53L1CB::VL53L1CB_WaitDeviceBooted(VL53L1_DEV Dev)
Charles MacNeill 9:66969b9016ad 413 {
Charles MacNeill 9:66969b9016ad 414
Charles MacNeill 9:66969b9016ad 415 return VL53L1_WaitDeviceBooted(Dev);
Charles MacNeill 9:66969b9016ad 416 }
Charles MacNeill 9:66969b9016ad 417
Charles MacNeill 9:66969b9016ad 418
Charles MacNeill 9:66969b9016ad 419 static int32_t BDTable[VL53L1_TUNING_MAX_TUNABLE_KEY] = {
Charles MacNeill 9:66969b9016ad 420 TUNING_VERSION,
Charles MacNeill 9:66969b9016ad 421 TUNING_PROXY_MIN,
Charles MacNeill 9:66969b9016ad 422 TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM,
Charles MacNeill 9:66969b9016ad 423 TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER,
Charles MacNeill 9:66969b9016ad 424 TUNING_MIN_AMBIENT_DMAX_VALID,
Charles MacNeill 9:66969b9016ad 425 TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER,
Charles MacNeill 9:66969b9016ad 426 TUNING_XTALK_FULL_ROI_TARGET_DISTANCE_MM,
Charles MacNeill 9:66969b9016ad 427 TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT,
Charles MacNeill 9:66969b9016ad 428 TUNING_XTALK_FULL_ROI_BIN_SUM_MARGIN,
Charles MacNeill 9:66969b9016ad 429 TUNING_XTALK_FULL_ROI_DEFAULT_OFFSET,
Charles MacNeill 9:66969b9016ad 430 TUNING_ZERO_DISTANCE_OFFSET_NON_LINEAR_FACTOR_DEFAULT,
Charles MacNeill 9:66969b9016ad 431 };
Charles MacNeill 9:66969b9016ad 432
Charles MacNeill 9:66969b9016ad 433
Charles MacNeill 10:3687b5e79f98 434 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetVersion(VL53L1_Version_t *pVersion)
Charles MacNeill 9:66969b9016ad 435 {
Charles MacNeill 9:66969b9016ad 436
Charles MacNeill 9:66969b9016ad 437 return VL53L1_GetVersion(pVersion);
Charles MacNeill 9:66969b9016ad 438 }
Charles MacNeill 9:66969b9016ad 439
Charles MacNeill 9:66969b9016ad 440
Charles MacNeill 10:3687b5e79f98 441 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetProductRevision(
Charles MacNeill 9:66969b9016ad 442 uint8_t *pProductRevisionMajor, uint8_t *pProductRevisionMinor)
Charles MacNeill 9:66969b9016ad 443 {
Charles MacNeill 9:66969b9016ad 444 return VL53L1_GetProductRevision(Device,pProductRevisionMajor,pProductRevisionMinor);
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
Charles MacNeill 10:3687b5e79f98 450 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetDeviceInfo(
Charles MacNeill 9:66969b9016ad 451 VL53L1_DeviceInfo_t *pVL53L1_DeviceInfo)
Charles MacNeill 9:66969b9016ad 452 {
Charles MacNeill 9:66969b9016ad 453 return VL53L1_GetDeviceInfo(Device,pVL53L1_DeviceInfo);
Charles MacNeill 9:66969b9016ad 454 }
Charles MacNeill 9:66969b9016ad 455
Charles MacNeill 10:3687b5e79f98 456 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetUID( uint64_t *pUid)
Charles MacNeill 9:66969b9016ad 457 {
Charles MacNeill 9:66969b9016ad 458 return VL53L1_GetUID(Device,pUid);
Charles MacNeill 9:66969b9016ad 459 }
Charles MacNeill 9:66969b9016ad 460
Charles MacNeill 10:3687b5e79f98 461 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetRangeStatusString(uint8_t RangeStatus,
Charles MacNeill 9:66969b9016ad 462 char *pRangeStatusString)
Charles MacNeill 9:66969b9016ad 463 {
Charles MacNeill 9:66969b9016ad 464 return VL53L1_GetRangeStatusString(RangeStatus,
Charles MacNeill 9:66969b9016ad 465 pRangeStatusString);
Charles MacNeill 9:66969b9016ad 466 }
Charles MacNeill 9:66969b9016ad 467
Charles MacNeill 10:3687b5e79f98 468 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetPalErrorString(VL53L1CB_ERROR PalErrorCode,
Charles MacNeill 9:66969b9016ad 469 char *pPalErrorString)
Charles MacNeill 9:66969b9016ad 470 {
Charles MacNeill 9:66969b9016ad 471 return VL53L1_GetPalErrorString(PalErrorCode,pPalErrorString);
Charles MacNeill 9:66969b9016ad 472 }
Charles MacNeill 9:66969b9016ad 473
Charles MacNeill 10:3687b5e79f98 474 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetPalStateString(VL53L1_State PalStateCode,
Charles MacNeill 9:66969b9016ad 475 char *pPalStateString)
Charles MacNeill 9:66969b9016ad 476 {
Charles MacNeill 9:66969b9016ad 477 return VL53L1_GetPalStateString(PalStateCode, pPalStateString);
Charles MacNeill 9:66969b9016ad 478 }
Charles MacNeill 9:66969b9016ad 479
Charles MacNeill 10:3687b5e79f98 480 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetPalState(VL53L1_DEV Dev, VL53L1_State *pPalState)
Charles MacNeill 9:66969b9016ad 481 {
Charles MacNeill 9:66969b9016ad 482 return VL53L1_GetPalState(Dev,pPalState);
Charles MacNeill 9:66969b9016ad 483 }
Charles MacNeill 9:66969b9016ad 484
Charles MacNeill 9:66969b9016ad 485
Charles MacNeill 10:3687b5e79f98 486 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetDeviceAddress(VL53L1_DEV Dev, uint8_t DeviceAddress)
Charles MacNeill 9:66969b9016ad 487 {
Charles MacNeill 10:3687b5e79f98 488 VL53L1CB_ERROR Status = VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 489
Charles MacNeill 9:66969b9016ad 490 // LOG_FUNCTION_START("");
Charles MacNeill 9:66969b9016ad 491
Charles MacNeill 14:f06785b2a964 492 Status = VL53L1_WrByte(Dev, VL53L1_I2C_SLAVE__DEVICE_ADDRESS,
Charles MacNeill 9:66969b9016ad 493 DeviceAddress / 2);
Charles MacNeill 9:66969b9016ad 494
Charles MacNeill 9:66969b9016ad 495 // LOG_FUNCTION_END(Status);
Charles MacNeill 9:66969b9016ad 496 return Status;
Charles MacNeill 9:66969b9016ad 497 }
Charles MacNeill 9:66969b9016ad 498
Charles MacNeill 10:3687b5e79f98 499 VL53L1CB_ERROR VL53L1CB::VL53L1CB_DataInit()
Charles MacNeill 9:66969b9016ad 500 {
Charles MacNeill 9:66969b9016ad 501 printf("vl53L1_DataInit %d \n",Device->i2c_slave_address);
Charles MacNeill 9:66969b9016ad 502 return VL53L1_DataInit( Device);
Charles MacNeill 9:66969b9016ad 503 }
Charles MacNeill 9:66969b9016ad 504
Charles MacNeill 9:66969b9016ad 505
Charles MacNeill 10:3687b5e79f98 506 VL53L1CB_ERROR VL53L1CB::VL53L1CB_StaticInit()
Charles MacNeill 9:66969b9016ad 507 {
Charles MacNeill 9:66969b9016ad 508 return VL53L1_StaticInit( Device);
Charles MacNeill 9:66969b9016ad 509 }
Charles MacNeill 9:66969b9016ad 510
Charles MacNeill 9:66969b9016ad 511
Charles MacNeill 10:3687b5e79f98 512 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetPresetMode(VL53L1_PresetModes PresetMode)
Charles MacNeill 9:66969b9016ad 513 {
Charles MacNeill 9:66969b9016ad 514 return VL53L1_SetPresetMode(Device,PresetMode);
Charles MacNeill 9:66969b9016ad 515 }
Charles MacNeill 9:66969b9016ad 516
Charles MacNeill 9:66969b9016ad 517
Charles MacNeill 10:3687b5e79f98 518 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetPresetMode( VL53L1_PresetModes *pPresetMode)
Charles MacNeill 9:66969b9016ad 519 {
Charles MacNeill 9:66969b9016ad 520 return VL53L1_GetPresetMode(Device,pPresetMode);
Charles MacNeill 9:66969b9016ad 521 }
Charles MacNeill 9:66969b9016ad 522
Charles MacNeill 9:66969b9016ad 523
Charles MacNeill 10:3687b5e79f98 524 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetDistanceMode(VL53L1_DistanceModes DistanceMode)
Charles MacNeill 9:66969b9016ad 525 {
Charles MacNeill 9:66969b9016ad 526 return VL53L1_SetDistanceMode(Device,DistanceMode);
Charles MacNeill 9:66969b9016ad 527 }
Charles MacNeill 9:66969b9016ad 528
Charles MacNeill 10:3687b5e79f98 529 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetDistanceMode(VL53L1_DistanceModes *pDistanceMode)
Charles MacNeill 9:66969b9016ad 530 {
Charles MacNeill 9:66969b9016ad 531 return VL53L1_GetDistanceMode(Device,pDistanceMode);
Charles MacNeill 9:66969b9016ad 532 }
Charles MacNeill 9:66969b9016ad 533
Charles MacNeill 10:3687b5e79f98 534 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetOutputMode(VL53L1_OutputModes OutputMode)
Charles MacNeill 9:66969b9016ad 535 {
Charles MacNeill 9:66969b9016ad 536 return VL53L1_SetOutputMode(Device,OutputMode);
Charles MacNeill 9:66969b9016ad 537 }
Charles MacNeill 9:66969b9016ad 538
Charles MacNeill 10:3687b5e79f98 539 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetOutputMode(VL53L1_OutputModes *pOutputMode)
Charles MacNeill 9:66969b9016ad 540 {
Charles MacNeill 9:66969b9016ad 541 return VL53L1_GetOutputMode(Device,pOutputMode);
Charles MacNeill 9:66969b9016ad 542 }
Charles MacNeill 9:66969b9016ad 543
Charles MacNeill 9:66969b9016ad 544
Charles MacNeill 9:66969b9016ad 545
Charles MacNeill 10:3687b5e79f98 546 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetMeasurementTimingBudgetMicroSeconds(
Charles MacNeill 9:66969b9016ad 547 uint32_t MeasurementTimingBudgetMicroSeconds)
Charles MacNeill 9:66969b9016ad 548 {
Charles MacNeill 9:66969b9016ad 549 return VL53L1_SetMeasurementTimingBudgetMicroSeconds(Device,
Charles MacNeill 9:66969b9016ad 550 MeasurementTimingBudgetMicroSeconds);
Charles MacNeill 9:66969b9016ad 551 }
Charles MacNeill 9:66969b9016ad 552
Charles MacNeill 9:66969b9016ad 553
Charles MacNeill 10:3687b5e79f98 554 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetMeasurementTimingBudgetMicroSeconds(
Charles MacNeill 9:66969b9016ad 555 uint32_t *pMeasurementTimingBudgetMicroSeconds)
Charles MacNeill 9:66969b9016ad 556 {
Charles MacNeill 9:66969b9016ad 557 return VL53L1_GetMeasurementTimingBudgetMicroSeconds(Device,
Charles MacNeill 9:66969b9016ad 558 pMeasurementTimingBudgetMicroSeconds);
Charles MacNeill 9:66969b9016ad 559 }
Charles MacNeill 9:66969b9016ad 560
Charles MacNeill 9:66969b9016ad 561
Charles MacNeill 9:66969b9016ad 562
Charles MacNeill 10:3687b5e79f98 563 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetInterMeasurementPeriodMilliSeconds(
Charles MacNeill 9:66969b9016ad 564 uint32_t InterMeasurementPeriodMilliSeconds)
Charles MacNeill 9:66969b9016ad 565 {
Charles MacNeill 9:66969b9016ad 566 return VL53L1_SetInterMeasurementPeriodMilliSeconds(Device,InterMeasurementPeriodMilliSeconds);
Charles MacNeill 9:66969b9016ad 567 }
Charles MacNeill 9:66969b9016ad 568
Charles MacNeill 10:3687b5e79f98 569 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetInterMeasurementPeriodMilliSeconds(
Charles MacNeill 9:66969b9016ad 570 uint32_t *pInterMeasurementPeriodMilliSeconds)
Charles MacNeill 9:66969b9016ad 571 {
Charles MacNeill 9:66969b9016ad 572 return VL53L1_GetInterMeasurementPeriodMilliSeconds(Device,pInterMeasurementPeriodMilliSeconds);
Charles MacNeill 9:66969b9016ad 573 }
Charles MacNeill 9:66969b9016ad 574
Charles MacNeill 10:3687b5e79f98 575 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetDmaxReflectance(FixPoint1616_t DmaxReflectance)
Charles MacNeill 9:66969b9016ad 576 {
Charles MacNeill 9:66969b9016ad 577
Charles MacNeill 9:66969b9016ad 578 return VL53L1_SetDmaxReflectance(Device,DmaxReflectance);
Charles MacNeill 9:66969b9016ad 579 }
Charles MacNeill 9:66969b9016ad 580
Charles MacNeill 10:3687b5e79f98 581 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetDmaxReflectance(
Charles MacNeill 9:66969b9016ad 582 FixPoint1616_t *pDmaxReflectance)
Charles MacNeill 9:66969b9016ad 583 {
Charles MacNeill 9:66969b9016ad 584 return VL53L1_GetDmaxReflectance(Device,pDmaxReflectance);
Charles MacNeill 9:66969b9016ad 585 }
Charles MacNeill 9:66969b9016ad 586
Charles MacNeill 9:66969b9016ad 587
Charles MacNeill 10:3687b5e79f98 588 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetDmaxMode(VL53L1_DeviceDmaxModes DmaxMode)
Charles MacNeill 9:66969b9016ad 589 {
Charles MacNeill 9:66969b9016ad 590 return VL53L1_SetDmaxMode(Device,DmaxMode);
Charles MacNeill 9:66969b9016ad 591 }
Charles MacNeill 9:66969b9016ad 592
Charles MacNeill 9:66969b9016ad 593
Charles MacNeill 10:3687b5e79f98 594 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetDmaxMode(
Charles MacNeill 9:66969b9016ad 595 VL53L1_DeviceDmaxModes *pDmaxMode)
Charles MacNeill 9:66969b9016ad 596 {
Charles MacNeill 9:66969b9016ad 597 return VL53L1_GetDmaxMode(Device,pDmaxMode);
Charles MacNeill 9:66969b9016ad 598 }
Charles MacNeill 9:66969b9016ad 599
Charles MacNeill 9:66969b9016ad 600
Charles MacNeill 9:66969b9016ad 601
Charles MacNeill 10:3687b5e79f98 602 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetNumberOfLimitCheck(uint16_t *pNumberOfLimitCheck)
Charles MacNeill 9:66969b9016ad 603 {
Charles MacNeill 10:3687b5e79f98 604 VL53L1CB_ERROR Status = VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 605
Charles MacNeill 9:66969b9016ad 606 // LOG_FUNCTION_START("");
Charles MacNeill 9:66969b9016ad 607
Charles MacNeill 9:66969b9016ad 608 *pNumberOfLimitCheck = VL53L1_CHECKENABLE_NUMBER_OF_CHECKS;
Charles MacNeill 9:66969b9016ad 609
Charles MacNeill 9:66969b9016ad 610 // LOG_FUNCTION_END(Status);
Charles MacNeill 9:66969b9016ad 611 return Status;
Charles MacNeill 9:66969b9016ad 612 }
Charles MacNeill 9:66969b9016ad 613
Charles MacNeill 10:3687b5e79f98 614 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetLimitCheckInfo(uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 615 char *pLimitCheckString)
Charles MacNeill 9:66969b9016ad 616 {
Charles MacNeill 9:66969b9016ad 617 return VL53L1_GetLimitCheckInfo(LimitCheckId,
Charles MacNeill 9:66969b9016ad 618 pLimitCheckString);
Charles MacNeill 9:66969b9016ad 619
Charles MacNeill 9:66969b9016ad 620 }
Charles MacNeill 9:66969b9016ad 621
Charles MacNeill 10:3687b5e79f98 622 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetLimitCheckStatus(uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 623 uint8_t *pLimitCheckStatus)
Charles MacNeill 9:66969b9016ad 624 {
Charles MacNeill 9:66969b9016ad 625 return VL53L1_GetLimitCheckStatus(Device,LimitCheckId,pLimitCheckStatus);
Charles MacNeill 9:66969b9016ad 626 }
Charles MacNeill 9:66969b9016ad 627
Charles MacNeill 9:66969b9016ad 628
Charles MacNeill 10:3687b5e79f98 629 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetLimitCheckEnable(uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 630 uint8_t LimitCheckEnable)
Charles MacNeill 9:66969b9016ad 631 {
Charles MacNeill 9:66969b9016ad 632
Charles MacNeill 9:66969b9016ad 633 return VL53L1_SetLimitCheckEnable(Device,LimitCheckId,LimitCheckEnable);
Charles MacNeill 9:66969b9016ad 634 }
Charles MacNeill 9:66969b9016ad 635
Charles MacNeill 10:3687b5e79f98 636 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetLimitCheckEnable(uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 637 uint8_t *pLimitCheckEnable)
Charles MacNeill 9:66969b9016ad 638 {
Charles MacNeill 9:66969b9016ad 639 return VL53L1_GetLimitCheckEnable(Device,LimitCheckId,pLimitCheckEnable);
Charles MacNeill 9:66969b9016ad 640 }
Charles MacNeill 9:66969b9016ad 641
Charles MacNeill 10:3687b5e79f98 642 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetLimitCheckValue( uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 643 FixPoint1616_t LimitCheckValue)
Charles MacNeill 9:66969b9016ad 644 {
Charles MacNeill 9:66969b9016ad 645 return VL53L1_SetLimitCheckValue(Device,LimitCheckId,LimitCheckValue);
Charles MacNeill 9:66969b9016ad 646 }
Charles MacNeill 9:66969b9016ad 647
Charles MacNeill 10:3687b5e79f98 648 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetLimitCheckValue( uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 649 FixPoint1616_t *pLimitCheckValue)
Charles MacNeill 9:66969b9016ad 650 {
Charles MacNeill 9:66969b9016ad 651 return VL53L1_GetLimitCheckValue(Device,LimitCheckId,pLimitCheckValue);
Charles MacNeill 9:66969b9016ad 652 }
Charles MacNeill 9:66969b9016ad 653
Charles MacNeill 10:3687b5e79f98 654 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetLimitCheckCurrent( uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 655 FixPoint1616_t *pLimitCheckCurrent)
Charles MacNeill 9:66969b9016ad 656 {
Charles MacNeill 9:66969b9016ad 657 return VL53L1_GetLimitCheckCurrent(Device,LimitCheckId,pLimitCheckCurrent);
Charles MacNeill 9:66969b9016ad 658 }
Charles MacNeill 9:66969b9016ad 659
Charles MacNeill 9:66969b9016ad 660
Charles MacNeill 10:3687b5e79f98 661 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetMaxNumberOfROI( uint8_t *pMaxNumberOfROI)
Charles MacNeill 9:66969b9016ad 662 {
Charles MacNeill 9:66969b9016ad 663 return VL53L1_GetMaxNumberOfROI(Device,pMaxNumberOfROI);
Charles MacNeill 9:66969b9016ad 664 }
Charles MacNeill 9:66969b9016ad 665
Charles MacNeill 10:3687b5e79f98 666 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetROI( VL53L1_RoiConfig_t *pRoiConfig)
Charles MacNeill 9:66969b9016ad 667 {
Charles MacNeill 9:66969b9016ad 668
Charles MacNeill 9:66969b9016ad 669 return VL53L1_SetROI(Device,pRoiConfig);
Charles MacNeill 9:66969b9016ad 670 }
Charles MacNeill 9:66969b9016ad 671
Charles MacNeill 10:3687b5e79f98 672 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetROI(VL53L1_RoiConfig_t *pRoiConfig)
Charles MacNeill 9:66969b9016ad 673 {
Charles MacNeill 9:66969b9016ad 674 return VL53L1_GetROI(Device,pRoiConfig);
Charles MacNeill 9:66969b9016ad 675 }
Charles MacNeill 9:66969b9016ad 676
Charles MacNeill 14:f06785b2a964 677
Charles MacNeill 14:f06785b2a964 678
Charles MacNeill 14:f06785b2a964 679
Charles MacNeill 10:3687b5e79f98 680 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetNumberOfSequenceSteps(uint8_t *pNumberOfSequenceSteps)
Charles MacNeill 9:66969b9016ad 681 {
Charles MacNeill 10:3687b5e79f98 682 VL53L1CB_ERROR Status = VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 683
Charles MacNeill 9:66969b9016ad 684 // SUPPRESS_UNUSED_WARNING(Dev);
Charles MacNeill 9:66969b9016ad 685
Charles MacNeill 9:66969b9016ad 686 // LOG_FUNCTION_START("");
Charles MacNeill 9:66969b9016ad 687
Charles MacNeill 9:66969b9016ad 688 *pNumberOfSequenceSteps = VL53L1_SEQUENCESTEP_NUMBER_OF_ITEMS;
Charles MacNeill 9:66969b9016ad 689
Charles MacNeill 9:66969b9016ad 690 // LOG_FUNCTION_END(Status);
Charles MacNeill 9:66969b9016ad 691 return Status;
Charles MacNeill 9:66969b9016ad 692 }
Charles MacNeill 9:66969b9016ad 693
Charles MacNeill 10:3687b5e79f98 694 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetSequenceStepsInfo(VL53L1_SequenceStepId SequenceStepId,
Charles MacNeill 9:66969b9016ad 695 char *pSequenceStepsString)
Charles MacNeill 9:66969b9016ad 696 {
Charles MacNeill 9:66969b9016ad 697 return VL53L1_GetSequenceStepsInfo(SequenceStepId,pSequenceStepsString);
Charles MacNeill 9:66969b9016ad 698 }
Charles MacNeill 9:66969b9016ad 699
Charles MacNeill 10:3687b5e79f98 700 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetSequenceStepEnable(VL53L1_SequenceStepId SequenceStepId,
Charles MacNeill 9:66969b9016ad 701 uint8_t SequenceStepEnabled)
Charles MacNeill 9:66969b9016ad 702 {
Charles MacNeill 9:66969b9016ad 703
Charles MacNeill 9:66969b9016ad 704 return VL53L1_SetSequenceStepEnable(Device,SequenceStepId,SequenceStepEnabled);
Charles MacNeill 9:66969b9016ad 705 }
Charles MacNeill 9:66969b9016ad 706
Charles MacNeill 9:66969b9016ad 707
Charles MacNeill 10:3687b5e79f98 708 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetSequenceStepEnable(VL53L1_SequenceStepId SequenceStepId,
Charles MacNeill 9:66969b9016ad 709 uint8_t *pSequenceStepEnabled)
Charles MacNeill 9:66969b9016ad 710 {
Charles MacNeill 9:66969b9016ad 711 return VL53L1_GetSequenceStepEnable(Device,SequenceStepId,pSequenceStepEnabled);
Charles MacNeill 9:66969b9016ad 712 }
Charles MacNeill 9:66969b9016ad 713
Charles MacNeill 9:66969b9016ad 714
Charles MacNeill 9:66969b9016ad 715
Charles MacNeill 10:3687b5e79f98 716 VL53L1CB_ERROR VL53L1CB::VL53L1CB_StartMeasurement()
Charles MacNeill 9:66969b9016ad 717 {
Charles MacNeill 9:66969b9016ad 718 return VL53L1_StartMeasurement(Device);
Charles MacNeill 9:66969b9016ad 719 }
Charles MacNeill 9:66969b9016ad 720
Charles MacNeill 10:3687b5e79f98 721 VL53L1CB_ERROR VL53L1CB::VL53L1CB_StopMeasurement()
Charles MacNeill 9:66969b9016ad 722 {
Charles MacNeill 9:66969b9016ad 723 return VL53L1_StopMeasurement(Device);
Charles MacNeill 9:66969b9016ad 724 }
Charles MacNeill 9:66969b9016ad 725
Charles MacNeill 9:66969b9016ad 726
Charles MacNeill 14:f06785b2a964 727 VL53L1CB_ERROR VL53L1CB::VL53L1CB_learInterruptAndStartMeasurement()
Charles MacNeill 9:66969b9016ad 728 {
Charles MacNeill 9:66969b9016ad 729
Charles MacNeill 9:66969b9016ad 730 return VL53L1_ClearInterruptAndStartMeasurement(Device);
Charles MacNeill 9:66969b9016ad 731 }
Charles MacNeill 9:66969b9016ad 732
Charles MacNeill 9:66969b9016ad 733
Charles MacNeill 10:3687b5e79f98 734 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetMeasurementDataReady(uint8_t *pMeasurementDataReady)
Charles MacNeill 9:66969b9016ad 735 {
Charles MacNeill 9:66969b9016ad 736 return VL53L1_GetMeasurementDataReady(Device, pMeasurementDataReady);
Charles MacNeill 9:66969b9016ad 737 }
Charles MacNeill 9:66969b9016ad 738
Charles MacNeill 10:3687b5e79f98 739 VL53L1CB_ERROR VL53L1CB::VL53L1CB_WaitMeasurementDataReady()
Charles MacNeill 9:66969b9016ad 740 {
Charles MacNeill 9:66969b9016ad 741 return VL53L1_WaitMeasurementDataReady(Device);
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
Charles MacNeill 10:3687b5e79f98 749 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetCalibrationData(
Charles MacNeill 9:66969b9016ad 750 VL53L1_CalibrationData_t *pCalibrationData)
Charles MacNeill 9:66969b9016ad 751 {
Charles MacNeill 9:66969b9016ad 752
Charles MacNeill 10:3687b5e79f98 753 VL53L1CB_ERROR Status = VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 754 Status = VL53L1_GetCalibrationData(Device,pCalibrationData);
Charles MacNeill 9:66969b9016ad 755
Charles MacNeill 9:66969b9016ad 756 return Status;
Charles MacNeill 9:66969b9016ad 757 }
Charles MacNeill 9:66969b9016ad 758
Charles MacNeill 9:66969b9016ad 759
Charles MacNeill 10:3687b5e79f98 760 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetRangingMeasurementData(
Charles MacNeill 9:66969b9016ad 761 VL53L1_RangingMeasurementData_t *pRangingMeasurementData)
Charles MacNeill 9:66969b9016ad 762 {
Charles MacNeill 9:66969b9016ad 763 // printf(" VL53L1_GetRangingMeasurementData 000 \n");
Charles MacNeill 10:3687b5e79f98 764 VL53L1CB_ERROR Status = VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 765 Status = VL53L1_GetRangingMeasurementData(Device,pRangingMeasurementData);
Charles MacNeill 9:66969b9016ad 766
Charles MacNeill 9:66969b9016ad 767 return Status;
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
Charles MacNeill 10:3687b5e79f98 774 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetMultiRangingData(
Charles MacNeill 9:66969b9016ad 775 VL53L1_MultiRangingData_t *pMultiRangingData)
Charles MacNeill 9:66969b9016ad 776 {
Charles MacNeill 9:66969b9016ad 777 return VL53L1_GetMultiRangingData(Device,pMultiRangingData);
Charles MacNeill 9:66969b9016ad 778 }
Charles MacNeill 9:66969b9016ad 779
Charles MacNeill 10:3687b5e79f98 780 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetAdditionalData(
Charles MacNeill 9:66969b9016ad 781 VL53L1_AdditionalData_t *pAdditionalData)
Charles MacNeill 9:66969b9016ad 782 {
Charles MacNeill 9:66969b9016ad 783 return VL53L1_GetAdditionalData(Device, pAdditionalData);
Charles MacNeill 9:66969b9016ad 784 }
Charles MacNeill 9:66969b9016ad 785
Charles MacNeill 9:66969b9016ad 786
Charles MacNeill 9:66969b9016ad 787
Charles MacNeill 10:3687b5e79f98 788 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetTuningParameter(
Charles MacNeill 9:66969b9016ad 789 uint16_t TuningParameterId, int32_t TuningParameterValue)
Charles MacNeill 9:66969b9016ad 790 {
Charles MacNeill 9:66969b9016ad 791 return VL53L1_SetTuningParameter(Device,TuningParameterId,TuningParameterValue);
Charles MacNeill 9:66969b9016ad 792 }
Charles MacNeill 9:66969b9016ad 793
Charles MacNeill 10:3687b5e79f98 794 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetTuningParameter(
Charles MacNeill 9:66969b9016ad 795 uint16_t TuningParameterId, int32_t *pTuningParameterValue)
Charles MacNeill 9:66969b9016ad 796 {
Charles MacNeill 9:66969b9016ad 797
Charles MacNeill 9:66969b9016ad 798 return VL53L1_GetTuningParameter(Device,TuningParameterId,pTuningParameterValue);
Charles MacNeill 9:66969b9016ad 799 }
Charles MacNeill 9:66969b9016ad 800
Charles MacNeill 9:66969b9016ad 801
Charles MacNeill 10:3687b5e79f98 802 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetXTalkCompensationEnable(
Charles MacNeill 9:66969b9016ad 803 uint8_t XTalkCompensationEnable)
Charles MacNeill 9:66969b9016ad 804 {
Charles MacNeill 9:66969b9016ad 805
Charles MacNeill 9:66969b9016ad 806 return VL53L1_SetXTalkCompensationEnable(Device,XTalkCompensationEnable);
Charles MacNeill 9:66969b9016ad 807 }
Charles MacNeill 9:66969b9016ad 808
Charles MacNeill 9:66969b9016ad 809
Charles MacNeill 10:3687b5e79f98 810 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetXTalkCompensationEnable(
Charles MacNeill 9:66969b9016ad 811 uint8_t *pXTalkCompensationEnable)
Charles MacNeill 9:66969b9016ad 812 {
Charles MacNeill 10:3687b5e79f98 813 VL53L1CB_ERROR Status = VL53L1_ERROR_NONE;
Charles MacNeill 9:66969b9016ad 814
Charles MacNeill 9:66969b9016ad 815 // LOG_FUNCTION_START("");
Charles MacNeill 9:66969b9016ad 816
Charles MacNeill 9:66969b9016ad 817 VL53L1_GetXTalkCompensationEnable(
Charles MacNeill 9:66969b9016ad 818 Device,
Charles MacNeill 9:66969b9016ad 819 pXTalkCompensationEnable);
Charles MacNeill 9:66969b9016ad 820
Charles MacNeill 9:66969b9016ad 821 // LOG_FUNCTION_END(Status);
Charles MacNeill 9:66969b9016ad 822 return Status;
Charles MacNeill 9:66969b9016ad 823 }
Charles MacNeill 9:66969b9016ad 824
Charles MacNeill 9:66969b9016ad 825
Charles MacNeill 10:3687b5e79f98 826 VL53L1CB_ERROR VL53L1CB::VL53L1CB_PerformXTalkCalibration(
Charles MacNeill 9:66969b9016ad 827 uint8_t CalibrationOption)
Charles MacNeill 9:66969b9016ad 828 {
Charles MacNeill 9:66969b9016ad 829
Charles MacNeill 9:66969b9016ad 830 return VL53L1_PerformXTalkCalibration(Device,CalibrationOption);
Charles MacNeill 9:66969b9016ad 831 }
Charles MacNeill 9:66969b9016ad 832
Charles MacNeill 10:3687b5e79f98 833 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetOffsetCalibrationMode(
Charles MacNeill 9:66969b9016ad 834 VL53L1_OffsetCalibrationModes OffsetCalibrationMode)
Charles MacNeill 9:66969b9016ad 835 {
Charles MacNeill 9:66969b9016ad 836 return VL53L1_SetOffsetCalibrationMode(Device,OffsetCalibrationMode);
Charles MacNeill 9:66969b9016ad 837 }
Charles MacNeill 9:66969b9016ad 838
Charles MacNeill 10:3687b5e79f98 839 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetOffsetCorrectionMode(
Charles MacNeill 9:66969b9016ad 840 VL53L1_OffsetCorrectionModes OffsetCorrectionMode)
Charles MacNeill 9:66969b9016ad 841 {
Charles MacNeill 9:66969b9016ad 842 return VL53L1_SetOffsetCorrectionMode(Device,OffsetCorrectionMode);
Charles MacNeill 9:66969b9016ad 843 }
Charles MacNeill 9:66969b9016ad 844
Charles MacNeill 10:3687b5e79f98 845 VL53L1CB_ERROR VL53L1CB::VL53L1CB_PerformOffsetCalibration(
Charles MacNeill 9:66969b9016ad 846 int32_t CalDistanceMilliMeter, FixPoint1616_t CalReflectancePercent)
Charles MacNeill 9:66969b9016ad 847 {
Charles MacNeill 9:66969b9016ad 848 return VL53L1_PerformOffsetCalibration(Device,CalDistanceMilliMeter,CalReflectancePercent);
Charles MacNeill 9:66969b9016ad 849 }
Charles MacNeill 9:66969b9016ad 850
Charles MacNeill 10:3687b5e79f98 851 VL53L1CB_ERROR VL53L1CB::VL53L1CB_PerformOffsetSimpleCalibration(
Charles MacNeill 9:66969b9016ad 852 int32_t CalDistanceMilliMeter)
Charles MacNeill 9:66969b9016ad 853 {
Charles MacNeill 9:66969b9016ad 854 return VL53L1_PerformOffsetSimpleCalibration(Device,CalDistanceMilliMeter);
Charles MacNeill 9:66969b9016ad 855 }
Charles MacNeill 9:66969b9016ad 856
Charles MacNeill 10:3687b5e79f98 857 VL53L1CB_ERROR VL53L1CB::VL53L1CB_PerformOffsetZeroDistanceCalibration()
Charles MacNeill 9:66969b9016ad 858 {
Charles MacNeill 9:66969b9016ad 859 return VL53L1_PerformOffsetZeroDistanceCalibration(Device);
Charles MacNeill 9:66969b9016ad 860 }
Charles MacNeill 9:66969b9016ad 861
Charles MacNeill 10:3687b5e79f98 862 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetCalibrationData(
Charles MacNeill 9:66969b9016ad 863 VL53L1_CalibrationData_t *pCalibrationData)
Charles MacNeill 9:66969b9016ad 864 {
Charles MacNeill 9:66969b9016ad 865 return VL53L1_SetCalibrationData(Device,pCalibrationData);
Charles MacNeill 9:66969b9016ad 866 }
Charles MacNeill 9:66969b9016ad 867
Charles MacNeill 9:66969b9016ad 868
Charles MacNeill 10:3687b5e79f98 869 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetZoneCalibrationData(
Charles MacNeill 9:66969b9016ad 870 VL53L1_ZoneCalibrationData_t *pZoneCalibrationData)
Charles MacNeill 9:66969b9016ad 871 {
Charles MacNeill 9:66969b9016ad 872 return VL53L1_SetZoneCalibrationData(Device, pZoneCalibrationData);
Charles MacNeill 9:66969b9016ad 873 }
Charles MacNeill 9:66969b9016ad 874
Charles MacNeill 10:3687b5e79f98 875 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetZoneCalibrationData(
Charles MacNeill 9:66969b9016ad 876 VL53L1_ZoneCalibrationData_t *pZoneCalibrationData)
Charles MacNeill 9:66969b9016ad 877 {
Charles MacNeill 9:66969b9016ad 878 return VL53L1_GetZoneCalibrationData(Device, pZoneCalibrationData);
Charles MacNeill 9:66969b9016ad 879 }
Charles MacNeill 9:66969b9016ad 880
Charles MacNeill 10:3687b5e79f98 881 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SmudgeCorrectionEnable(
Charles MacNeill 9:66969b9016ad 882 VL53L1_SmudgeCorrectionModes Mode)
Charles MacNeill 9:66969b9016ad 883
Charles MacNeill 9:66969b9016ad 884 {
Charles MacNeill 9:66969b9016ad 885 return VL53L1_SmudgeCorrectionEnable(Device, Mode);
Charles MacNeill 9:66969b9016ad 886 }
Charles MacNeill 9:66969b9016ad 887
Charles MacNeill 10:3687b5e79f98 888 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetOpticalCenter(
Charles MacNeill 9:66969b9016ad 889 FixPoint1616_t *pOpticalCenterX,
Charles MacNeill 9:66969b9016ad 890 FixPoint1616_t *pOpticalCenterY)
Charles MacNeill 9:66969b9016ad 891 {
Charles MacNeill 9:66969b9016ad 892 return VL53L1_GetOpticalCenter(Device,pOpticalCenterX,pOpticalCenterY);
Charles MacNeill 9:66969b9016ad 893 }
Charles MacNeill 9:66969b9016ad 894
Charles MacNeill 14:f06785b2a964 895
Charles MacNeill 14:f06785b2a964 896
Charles MacNeill 14:f06785b2a964 897
Charles MacNeill 14:f06785b2a964 898
Charles MacNeill 14:f06785b2a964 899
Charles MacNeill 10:3687b5e79f98 900 VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetThresholdConfig(VL53L1_DetectionConfig_t *pConfig)
Charles MacNeill 9:66969b9016ad 901 {
Charles MacNeill 9:66969b9016ad 902 return VL53L1_SetThresholdConfig(Device,pConfig);
Charles MacNeill 9:66969b9016ad 903 }
Charles MacNeill 9:66969b9016ad 904
Charles MacNeill 9:66969b9016ad 905
Charles MacNeill 10:3687b5e79f98 906 VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetThresholdConfig(VL53L1_DetectionConfig_t *pConfig)
Charles MacNeill 9:66969b9016ad 907 {
Charles MacNeill 9:66969b9016ad 908 return VL53L1_GetThresholdConfig(Device,pConfig);
Charles MacNeill 9:66969b9016ad 909 }
Charles MacNeill 9:66969b9016ad 910
Charles MacNeill 14:f06785b2a964 911
Charles MacNeill 14:f06785b2a964 912
Charles MacNeill 14:f06785b2a964 913
Charles MacNeill 10:3687b5e79f98 914 VL53L1CB_ERROR VL53L1CB::VL53L1CB_PerformOffsetPerVcselCalibration(int32_t CalDistanceMilliMeter)
Charles MacNeill 9:66969b9016ad 915 {
Charles MacNeill 9:66969b9016ad 916 return VL53L1_PerformOffsetPerVcselCalibration(Device,CalDistanceMilliMeter);
Charles MacNeill 9:66969b9016ad 917 }
Charles MacNeill 9:66969b9016ad 918
Charles MacNeill 9:66969b9016ad 919
Charles MacNeill 9:66969b9016ad 920
Charles MacNeill 9:66969b9016ad 921 // from vl53l1_api_debug.c
Charles MacNeill 9:66969b9016ad 922
Charles MacNeill 9:66969b9016ad 923
Charles MacNeill 10:3687b5e79f98 924 VL53L1CB_ERROR VL53L1CB::VL53L1CB_get_additional_data(
Charles MacNeill 9:66969b9016ad 925 VL53L1_DEV Dev,
Charles MacNeill 9:66969b9016ad 926 VL53L1_additional_data_t *pdata)
Charles MacNeill 9:66969b9016ad 927 {
Charles MacNeill 9:66969b9016ad 928 return VL53L1_get_additional_data(Dev,pdata);
Charles MacNeill 9:66969b9016ad 929 }
Charles MacNeill 9:66969b9016ad 930
Charles MacNeill 9:66969b9016ad 931
Charles MacNeill 9:66969b9016ad 932
Charles MacNeill 10:3687b5e79f98 933 int VL53L1CB::handle_irq(uint16_t *distance)
Charles MacNeill 9:66969b9016ad 934 {
Charles MacNeill 9:66969b9016ad 935 int status;
Charles MacNeill 9:66969b9016ad 936 status = get_measurement(distance);
Charles MacNeill 9:66969b9016ad 937 enable_interrupt_measure_detection_irq();
Charles MacNeill 9:66969b9016ad 938 return status;
Charles MacNeill 9:66969b9016ad 939 }
Charles MacNeill 9:66969b9016ad 940
Charles MacNeill 10:3687b5e79f98 941 int VL53L1CB::get_measurement(uint16_t *distance)
Charles MacNeill 9:66969b9016ad 942 {
Charles MacNeill 9:66969b9016ad 943 int status = 0;
Charles MacNeill 9:66969b9016ad 944
Charles MacNeill 10:3687b5e79f98 945 status = VL53L1CB_GetDistance(distance);
Charles MacNeill 10:3687b5e79f98 946 status = VL53L1CB_ClearInterrupt();
Charles MacNeill 9:66969b9016ad 947
Charles MacNeill 9:66969b9016ad 948 return status;
Charles MacNeill 9:66969b9016ad 949 }
Charles MacNeill 9:66969b9016ad 950
Charles MacNeill 10:3687b5e79f98 951 int VL53L1CB::start_measurement(void (*fptr)(void))
Charles MacNeill 9:66969b9016ad 952 {
Charles MacNeill 9:66969b9016ad 953 int status = 0;
Charles MacNeill 9:66969b9016ad 954
Charles MacNeill 9:66969b9016ad 955 if (_gpio1Int == NULL) {
Charles MacNeill 9:66969b9016ad 956 printf("GPIO1 Error\r\n");
Charles MacNeill 9:66969b9016ad 957 return 1;
Charles MacNeill 9:66969b9016ad 958 }
Charles MacNeill 9:66969b9016ad 959
Charles MacNeill 10:3687b5e79f98 960 status = VL53L1CB_StopRanging(); // it is safer to do this while sensor is stopped
Charles MacNeill 9:66969b9016ad 961
Charles MacNeill 9:66969b9016ad 962 if (status == 0) {
Charles MacNeill 9:66969b9016ad 963 attach_interrupt_measure_detection_irq(fptr);
Charles MacNeill 9:66969b9016ad 964 enable_interrupt_measure_detection_irq();
Charles MacNeill 9:66969b9016ad 965 }
Charles MacNeill 9:66969b9016ad 966
Charles MacNeill 9:66969b9016ad 967 if (status == 0) {
Charles MacNeill 10:3687b5e79f98 968 status = VL53L1CB_StartRanging();
Charles MacNeill 9:66969b9016ad 969 }
Charles MacNeill 9:66969b9016ad 970
Charles MacNeill 9:66969b9016ad 971 return status;
Charles MacNeill 9:66969b9016ad 972 }
Charles MacNeill 9:66969b9016ad 973
Charles MacNeill 10:3687b5e79f98 974 int VL53L1CB::stop_measurement()
Charles MacNeill 9:66969b9016ad 975 {
Charles MacNeill 9:66969b9016ad 976 int status = 0;
Charles MacNeill 9:66969b9016ad 977
Charles MacNeill 9:66969b9016ad 978 if (status == 0) {
Charles MacNeill 9:66969b9016ad 979 printf("Call of VL53L1_StopMeasurement\n");
Charles MacNeill 10:3687b5e79f98 980 status = VL53L1CB_StopRanging();
Charles MacNeill 9:66969b9016ad 981 }
Charles MacNeill 9:66969b9016ad 982
Charles MacNeill 9:66969b9016ad 983 if (status == 0)
Charles MacNeill 10:3687b5e79f98 984 status = VL53L1CB_ClearInterrupt();
Charles MacNeill 9:66969b9016ad 985
Charles MacNeill 9:66969b9016ad 986 return status;
Charles MacNeill 9:66969b9016ad 987 }
Charles MacNeill 9:66969b9016ad 988
Charles MacNeill 9:66969b9016ad 989