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:
lugandc
Date:
Wed Jul 21 17:06:38 2021 +0200
Revision:
18:0696efe39d08
Parent:
17:ca0ce4daf573
Cleanup i2c functions, removed all bad references to L1X
Cleanup VL53L1CB class:
- i2c device object is passed in a consistent way in MyDevice structure
- removed useless functions
Updated VL53L1CB component driver with bare driver release 6.6.7 content

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Charles MacNeill 9:66969b9016ad 1 /*******************************************************************************
lugandc 18:0696efe39d08 2 * @file vl53l1cb_class.h
Charles MacNeill 9:66969b9016ad 3 * @author JS
Charles MacNeill 9:66969b9016ad 4 * @version V0.0.1
Charles MacNeill 9:66969b9016ad 5 * @date 15-January-2019
Charles MacNeill 9:66969b9016ad 6 * @brief Header file for VL53L1 sensor component
Charles MacNeill 9:66969b9016ad 7 ******************************************************************************
lugandc 18:0696efe39d08 8 Copyright © 2021, STMicroelectronics International N.V.
Charles MacNeill 9:66969b9016ad 9 All rights reserved.
Charles MacNeill 9:66969b9016ad 10 Redistribution and use in source and binary forms, with or without
Charles MacNeill 9:66969b9016ad 11 modification, are permitted provided that the following conditions are met:
Charles MacNeill 9:66969b9016ad 12 * Redistributions of source code must retain the above copyright
Charles MacNeill 9:66969b9016ad 13 notice, this list of conditions and the following disclaimer.
Charles MacNeill 9:66969b9016ad 14 * Redistributions in binary form must reproduce the above copyright
Charles MacNeill 9:66969b9016ad 15 notice, this list of conditions and the following disclaimer in the
Charles MacNeill 9:66969b9016ad 16 documentation and/or other materials provided with the distribution.
Charles MacNeill 9:66969b9016ad 17 * Neither the name of STMicroelectronics nor the
Charles MacNeill 9:66969b9016ad 18 names of its contributors may be used to endorse or promote products
Charles MacNeill 9:66969b9016ad 19 derived from this software without specific prior written permission.
Charles MacNeill 9:66969b9016ad 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
Charles MacNeill 9:66969b9016ad 21 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Charles MacNeill 9:66969b9016ad 22 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
Charles MacNeill 9:66969b9016ad 23 NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
Charles MacNeill 9:66969b9016ad 24 IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
Charles MacNeill 9:66969b9016ad 25 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Charles MacNeill 9:66969b9016ad 26 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Charles MacNeill 9:66969b9016ad 27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
Charles MacNeill 9:66969b9016ad 28 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Charles MacNeill 9:66969b9016ad 29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Charles MacNeill 9:66969b9016ad 30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Charles MacNeill 9:66969b9016ad 31 *****************************************************************************/
Charles MacNeill 9:66969b9016ad 32
Charles MacNeill 14:f06785b2a964 33 #ifndef __VL53L1CB_CLASS_H
Charles MacNeill 14:f06785b2a964 34 #define __VL53L1CB_CLASS_H
Charles MacNeill 14:f06785b2a964 35
Charles MacNeill 9:66969b9016ad 36
Charles MacNeill 14:f06785b2a964 37 #ifdef _MSC_VER
lugandc 18:0696efe39d08 38 # ifdef VL53L1CB_API_EXPORTS
lugandc 18:0696efe39d08 39 # define VL53L1CB_API __declspec(dllexport)
Charles MacNeill 14:f06785b2a964 40 # else
lugandc 18:0696efe39d08 41 # define VL53L1CB_API
Charles MacNeill 14:f06785b2a964 42 # endif
Charles MacNeill 14:f06785b2a964 43 #else
lugandc 18:0696efe39d08 44 # define VL53L1CB_API
Charles MacNeill 14:f06785b2a964 45 #endif
Charles MacNeill 9:66969b9016ad 46
Charles MacNeill 9:66969b9016ad 47
Charles MacNeill 9:66969b9016ad 48 /* Includes ------------------------------------------------------------------*/
Charles MacNeill 9:66969b9016ad 49
Charles MacNeill 9:66969b9016ad 50 #include "mbed.h"
Charles MacNeill 9:66969b9016ad 51 #include "PinNames.h"
Charles MacNeill 9:66969b9016ad 52
Charles MacNeill 9:66969b9016ad 53 #include "RangeSensor.h"
Charles MacNeill 9:66969b9016ad 54 #include "Stmpe1600.h"
Charles MacNeill 9:66969b9016ad 55
Charles MacNeill 9:66969b9016ad 56 #include "vl53l1_error_codes.h"
Charles MacNeill 9:66969b9016ad 57 #include "vl53l1_platform_user_data.h"
Charles MacNeill 9:66969b9016ad 58
Charles MacNeill 9:66969b9016ad 59 #include "ToF_I2C.h"
Charles MacNeill 9:66969b9016ad 60 /**********************************************************/
Charles MacNeill 9:66969b9016ad 61 #include "vl53l1_def.h"
Charles MacNeill 9:66969b9016ad 62 /***********************************************************/
Charles MacNeill 9:66969b9016ad 63
Charles MacNeill 9:66969b9016ad 64
lugandc 18:0696efe39d08 65 #define VL53L1CB_IMPLEMENTATION_VER_MAJOR 1
lugandc 18:0696efe39d08 66 #define VL53L1CB_IMPLEMENTATION_VER_MINOR 0
lugandc 18:0696efe39d08 67 #define VL53L1CB_IMPLEMENTATION_VER_SUB 2
lugandc 18:0696efe39d08 68 #define VL53L1CB_IMPLEMENTATION_VER_REVISION 0000
Charles MacNeill 9:66969b9016ad 69
Charles MacNeill 10:3687b5e79f98 70 typedef int8_t VL53L1CB_ERROR;
Charles MacNeill 9:66969b9016ad 71
lugandc 18:0696efe39d08 72 #define VL53L1_DEFAULT_DEVICE_ADDRESS 0x52
lugandc 18:0696efe39d08 73 #define VL53L1_REG_IDENTIFICATION_MODEL_ID 0x010F
Charles MacNeill 9:66969b9016ad 74
Charles MacNeill 9:66969b9016ad 75 /* Classes -------------------------------------------------------------------*/
Charles MacNeill 14:f06785b2a964 76 /** Class representing a VL53L1 sensor component
Charles MacNeill 9:66969b9016ad 77 */
Charles MacNeill 10:3687b5e79f98 78 class VL53L1CB : public RangeSensor
Charles MacNeill 9:66969b9016ad 79 {
Charles MacNeill 9:66969b9016ad 80 public:
Charles MacNeill 9:66969b9016ad 81
Charles MacNeill 9:66969b9016ad 82 #define VL53L1DevStructGetLLDriverHandle(Dev) (&Dev->Data.LLData)
Charles MacNeill 9:66969b9016ad 83 /** Constructor
Charles MacNeill 9:66969b9016ad 84 * @param[in] &i2c device I2C to be used for communication
Charles MacNeill 9:66969b9016ad 85 * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
Charles MacNeill 9:66969b9016ad 86 * @param[in] DevAddr device address, 0x52 by default
Charles MacNeill 9:66969b9016ad 87 */
johnAlexander 17:ca0ce4daf573 88
Charles MacNeill 14:f06785b2a964 89 VL53L1CB(ToF_DevI2C *i2c, DigitalOut *pin, PinName pin_gpio1, uint8_t dev_addr = VL53L1_DEFAULT_DEVICE_ADDRESS)
Charles MacNeill 9:66969b9016ad 90 : RangeSensor(), dev_i2c(i2c), _gpio0(pin)
Charles MacNeill 9:66969b9016ad 91 {
lugandc 18:0696efe39d08 92 MyDevice.i2c_slave_address = dev_addr;
lugandc 18:0696efe39d08 93 MyDevice.dev_i2c = (void*) i2c;
Charles MacNeill 9:66969b9016ad 94 Device = &MyDevice;
Charles MacNeill 9:66969b9016ad 95
Charles MacNeill 9:66969b9016ad 96 _expgpio0 = NULL;
Charles MacNeill 9:66969b9016ad 97 if (pin_gpio1 != NC) {
Charles MacNeill 9:66969b9016ad 98 _gpio1Int = new InterruptIn(pin_gpio1);
Charles MacNeill 9:66969b9016ad 99 } else {
Charles MacNeill 9:66969b9016ad 100 _gpio1Int = NULL;
Charles MacNeill 9:66969b9016ad 101 }
Charles MacNeill 9:66969b9016ad 102 }
johnAlexander 17:ca0ce4daf573 103
Charles MacNeill 9:66969b9016ad 104 /** Constructor 2 (STMPE1600DigiOut)
Charles MacNeill 9:66969b9016ad 105 * @param[in] i2c device I2C to be used for communication
Charles MacNeill 9:66969b9016ad 106 * @param[in] &pin Gpio Expander STMPE1600DigiOut pin to be used as component GPIO_0 CE
Charles MacNeill 9:66969b9016ad 107 * @param[in] pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
Charles MacNeill 9:66969b9016ad 108 * @param[in] device address, 0x29 by default
Charles MacNeill 9:66969b9016ad 109 */
Charles MacNeill 10:3687b5e79f98 110 VL53L1CB(ToF_DevI2C *i2c, Stmpe1600DigiOut *pin, PinName pin_gpio1,
Charles MacNeill 14:f06785b2a964 111 uint8_t dev_addr = VL53L1_DEFAULT_DEVICE_ADDRESS)
Charles MacNeill 9:66969b9016ad 112 : dev_i2c(i2c), _expgpio0(pin)
Charles MacNeill 9:66969b9016ad 113 {
lugandc 18:0696efe39d08 114 MyDevice.i2c_slave_address = dev_addr;
lugandc 18:0696efe39d08 115 MyDevice.dev_i2c = (void*) i2c;
Charles MacNeill 9:66969b9016ad 116 Device = &MyDevice;
Charles MacNeill 9:66969b9016ad 117
Charles MacNeill 9:66969b9016ad 118 _gpio0 = NULL;
Charles MacNeill 9:66969b9016ad 119 if (pin_gpio1 != NC) {
Charles MacNeill 9:66969b9016ad 120 _gpio1Int = new InterruptIn(pin_gpio1);
Charles MacNeill 9:66969b9016ad 121 } else {
Charles MacNeill 9:66969b9016ad 122 _gpio1Int = NULL;
Charles MacNeill 9:66969b9016ad 123 }
Charles MacNeill 9:66969b9016ad 124 }
Charles MacNeill 9:66969b9016ad 125
Charles MacNeill 9:66969b9016ad 126 /** Destructor
Charles MacNeill 9:66969b9016ad 127 */
Charles MacNeill 10:3687b5e79f98 128 virtual ~VL53L1CB()
Charles MacNeill 9:66969b9016ad 129 {
Charles MacNeill 9:66969b9016ad 130 if (_gpio1Int != NULL) {
Charles MacNeill 9:66969b9016ad 131 delete _gpio1Int;
Charles MacNeill 9:66969b9016ad 132 }
Charles MacNeill 9:66969b9016ad 133 }
Charles MacNeill 9:66969b9016ad 134
Charles MacNeill 9:66969b9016ad 135
Charles MacNeill 9:66969b9016ad 136
Charles MacNeill 9:66969b9016ad 137 VL53L1_DEV getDevicePtr() { return Device; }
Charles MacNeill 9:66969b9016ad 138
Charles MacNeill 9:66969b9016ad 139
Charles MacNeill 14:f06785b2a964 140 /* warning: VL53L1 class inherits from GenericSensor, RangeSensor and LightSensor, that haven`t a destructor.
Charles MacNeill 9:66969b9016ad 141 The warning should request to introduce a virtual destructor to make sure to delete the object */
Charles MacNeill 9:66969b9016ad 142
Charles MacNeill 9:66969b9016ad 143 /*** Interface Methods ***/
Charles MacNeill 9:66969b9016ad 144 /*** High level API ***/
Charles MacNeill 9:66969b9016ad 145 /**
Charles MacNeill 9:66969b9016ad 146 * @brief PowerOn the sensor
Charles MacNeill 9:66969b9016ad 147 * @return void
Charles MacNeill 9:66969b9016ad 148 */
Charles MacNeill 9:66969b9016ad 149 /* turns on the sensor */
Charles MacNeill 10:3687b5e79f98 150 virtual void VL53L1CB_On(void)
Charles MacNeill 9:66969b9016ad 151 {
Charles MacNeill 14:f06785b2a964 152 printf("VL53L1_On\r\n");
Charles MacNeill 9:66969b9016ad 153 if (_gpio0) {
Charles MacNeill 9:66969b9016ad 154 *_gpio0 = 1;
Charles MacNeill 9:66969b9016ad 155 } else {
Charles MacNeill 9:66969b9016ad 156 if (_expgpio0) {
Charles MacNeill 9:66969b9016ad 157 *_expgpio0 = 1;
Charles MacNeill 9:66969b9016ad 158 }
Charles MacNeill 9:66969b9016ad 159 }
lugandc 18:0696efe39d08 160 #if (MBED_VERSION > 60300)
Charles MacNeill 9:66969b9016ad 161 thread_sleep_for(100);
Charles MacNeill 9:66969b9016ad 162 #else
Charles MacNeill 9:66969b9016ad 163 wait_ms(100); // NEEDS A DELAY BETWEEN SENSORS
Charles MacNeill 9:66969b9016ad 164 #endif
Charles MacNeill 9:66969b9016ad 165 }
Charles MacNeill 9:66969b9016ad 166
Charles MacNeill 9:66969b9016ad 167 /**
Charles MacNeill 9:66969b9016ad 168 * @brief PowerOff the sensor
Charles MacNeill 9:66969b9016ad 169 * @return void
Charles MacNeill 9:66969b9016ad 170 */
Charles MacNeill 9:66969b9016ad 171 /* turns off the sensor */
Charles MacNeill 10:3687b5e79f98 172 virtual void VL53L1CB_Off(void)
Charles MacNeill 9:66969b9016ad 173 {
Charles MacNeill 9:66969b9016ad 174 printf("VL53L1_Off\r\n");
Charles MacNeill 9:66969b9016ad 175 if (_gpio0) {
Charles MacNeill 9:66969b9016ad 176 *_gpio0 = 0;
Charles MacNeill 9:66969b9016ad 177 } else {
Charles MacNeill 9:66969b9016ad 178 if (_expgpio0) {
Charles MacNeill 9:66969b9016ad 179 *_expgpio0 = 0;
Charles MacNeill 9:66969b9016ad 180 }
Charles MacNeill 9:66969b9016ad 181 }
lugandc 18:0696efe39d08 182 #if (MBED_VERSION > 60300)
Charles MacNeill 9:66969b9016ad 183 thread_sleep_for(100);
Charles MacNeill 9:66969b9016ad 184 #else
Charles MacNeill 9:66969b9016ad 185 wait_ms(100); // NEEDS A DELAY BETWEEN SENSORS
Charles MacNeill 9:66969b9016ad 186 #endif
Charles MacNeill 9:66969b9016ad 187 }
Charles MacNeill 9:66969b9016ad 188
Charles MacNeill 9:66969b9016ad 189 int is_present()
Charles MacNeill 9:66969b9016ad 190 {
Charles MacNeill 9:66969b9016ad 191 int status;
Charles MacNeill 9:66969b9016ad 192 uint8_t id = 0;
Charles MacNeill 9:66969b9016ad 193
Charles MacNeill 9:66969b9016ad 194 status = read_id(&id);
Charles MacNeill 9:66969b9016ad 195 if (status) {
Charles MacNeill 9:66969b9016ad 196 printf("Failed to read ID device. Device not present!\n\r");
Charles MacNeill 9:66969b9016ad 197 }
Charles MacNeill 9:66969b9016ad 198 return status;
Charles MacNeill 9:66969b9016ad 199 }
Charles MacNeill 9:66969b9016ad 200
Charles MacNeill 9:66969b9016ad 201 /**
Charles MacNeill 9:66969b9016ad 202 * @brief Initialize the sensor with default values
Charles MacNeill 9:66969b9016ad 203 * @return 0 on Success
Charles MacNeill 9:66969b9016ad 204 */
Charles MacNeill 9:66969b9016ad 205
Charles MacNeill 10:3687b5e79f98 206 VL53L1CB_ERROR InitSensor(uint8_t address){
Charles MacNeill 10:3687b5e79f98 207 VL53L1CB_ERROR status = 0;
Charles MacNeill 10:3687b5e79f98 208 VL53L1CB_Off();
Charles MacNeill 10:3687b5e79f98 209 VL53L1CB_On();
lugandc 18:0696efe39d08 210 status = VL53L1CB_WaitDeviceBooted();
lugandc 18:0696efe39d08 211 if(!status){
lugandc 18:0696efe39d08 212 status = VL53L1CB_SetI2CAddress(address);
lugandc 18:0696efe39d08 213 }
Charles MacNeill 9:66969b9016ad 214 if(!status){
Charles MacNeill 10:3687b5e79f98 215 status = VL53L1CB_SensorInit();
Charles MacNeill 9:66969b9016ad 216 }
Charles MacNeill 9:66969b9016ad 217 return status;
Charles MacNeill 9:66969b9016ad 218 }
Charles MacNeill 9:66969b9016ad 219
Charles MacNeill 9:66969b9016ad 220
Charles MacNeill 9:66969b9016ad 221
Charles MacNeill 9:66969b9016ad 222 /**
Charles MacNeill 9:66969b9016ad 223 *
Charles MacNeill 9:66969b9016ad 224 * @brief One time device initialization
Charles MacNeill 9:66969b9016ad 225 * @param void
Charles MacNeill 9:66969b9016ad 226 * @return 0 on success, @a #CALIBRATION_WARNING if failed
Charles MacNeill 9:66969b9016ad 227 */
Charles MacNeill 9:66969b9016ad 228 virtual int init(void *init)
Charles MacNeill 9:66969b9016ad 229 {
Charles MacNeill 10:3687b5e79f98 230 return VL53L1CB_SensorInit();
Charles MacNeill 9:66969b9016ad 231 return 0;
Charles MacNeill 9:66969b9016ad 232 }
Charles MacNeill 9:66969b9016ad 233
Charles MacNeill 9:66969b9016ad 234
Charles MacNeill 9:66969b9016ad 235 /**
Charles MacNeill 9:66969b9016ad 236 * @brief Initialize the sensor with default values
Charles MacNeill 9:66969b9016ad 237 * @return "0" on success
Charles MacNeill 9:66969b9016ad 238 */
Charles MacNeill 9:66969b9016ad 239 int init_sensor(uint8_t new_addr);
Charles MacNeill 9:66969b9016ad 240
Charles MacNeill 9:66969b9016ad 241 /* Read function of the ID device */
Charles MacNeill 9:66969b9016ad 242 virtual int read_id(uint8_t *id){
Charles MacNeill 9:66969b9016ad 243 int status = 0;
Charles MacNeill 9:66969b9016ad 244 uint16_t rl_id = 0;
Charles MacNeill 9:66969b9016ad 245
Charles MacNeill 9:66969b9016ad 246 uint8_t ExpanderData[2];
Charles MacNeill 9:66969b9016ad 247
Charles MacNeill 9:66969b9016ad 248 ExpanderData[0] = 0;
Charles MacNeill 9:66969b9016ad 249 ExpanderData[1] = 0;
Charles MacNeill 9:66969b9016ad 250 rl_id = 0;
Charles MacNeill 14:f06785b2a964 251 dev_i2c->ToF_i2c_read(&ExpanderData[0], Device->i2c_slave_address, VL53L1_REG_IDENTIFICATION_MODEL_ID, 2);
Charles MacNeill 9:66969b9016ad 252
Charles MacNeill 9:66969b9016ad 253 rl_id = (ExpanderData[0] << 8) + ExpanderData[1];
Charles MacNeill 9:66969b9016ad 254 printf("Model ID is: %d (%X) \r\n",rl_id, rl_id);
Charles MacNeill 9:66969b9016ad 255
Charles MacNeill 9:66969b9016ad 256 uint8_t tmp = 0;
Charles MacNeill 14:f06785b2a964 257 ExpanderData[0] = VL53L1_FIRMWARE__SYSTEM_STATUS >> 8;
Charles MacNeill 14:f06785b2a964 258 ExpanderData[1] = VL53L1_FIRMWARE__SYSTEM_STATUS & 0x0FF;
Charles MacNeill 14:f06785b2a964 259 dev_i2c->ToF_i2c_read(&tmp, Device->i2c_slave_address, VL53L1_FIRMWARE__SYSTEM_STATUS, 1);
Charles MacNeill 9:66969b9016ad 260
Charles MacNeill 9:66969b9016ad 261 printf("Firmware system is: %d\r\n",tmp);
Charles MacNeill 9:66969b9016ad 262
Charles MacNeill 9:66969b9016ad 263 if (rl_id == 0xEACC) {
Charles MacNeill 9:66969b9016ad 264 printf("Device is present %d:\r\n", rl_id);
Charles MacNeill 9:66969b9016ad 265 return status;
Charles MacNeill 9:66969b9016ad 266 }
Charles MacNeill 9:66969b9016ad 267 return -1;
Charles MacNeill 9:66969b9016ad 268 }
Charles MacNeill 9:66969b9016ad 269
Charles MacNeill 9:66969b9016ad 270
Charles MacNeill 9:66969b9016ad 271 /**
Charles MacNeill 9:66969b9016ad 272 * @brief Interrupt handling func to be called by user after an INT is occurred
Charles MacNeill 9:66969b9016ad 273 * @param[out] Data pointer to the distance to read data in to
Charles MacNeill 9:66969b9016ad 274 * @return 0 on Success
Charles MacNeill 9:66969b9016ad 275 */
Charles MacNeill 9:66969b9016ad 276 int handle_irq(uint16_t *distance);
Charles MacNeill 9:66969b9016ad 277
Charles MacNeill 9:66969b9016ad 278 /**
Charles MacNeill 9:66969b9016ad 279 * @brief Start the measure indicated by operating mode
Charles MacNeill 9:66969b9016ad 280 * @param[in] fptr specifies call back function must be !NULL in case of interrupt measure
Charles MacNeill 9:66969b9016ad 281 * @return 0 on Success
Charles MacNeill 9:66969b9016ad 282 */
Charles MacNeill 9:66969b9016ad 283 int start_measurement(void (*fptr)(void));
Charles MacNeill 9:66969b9016ad 284 /**
Charles MacNeill 9:66969b9016ad 285 * @brief Stop the currently running measure indicate by operating_mode
Charles MacNeill 9:66969b9016ad 286 * @return 0 on Success
Charles MacNeill 9:66969b9016ad 287 */
Charles MacNeill 9:66969b9016ad 288 int stop_measurement();
Charles MacNeill 9:66969b9016ad 289 /**
Charles MacNeill 9:66969b9016ad 290 * @brief Get results for the measure
Charles MacNeill 9:66969b9016ad 291 * @param[out] Data pointer to the distance_data to read data in to
Charles MacNeill 9:66969b9016ad 292 * @return 0 on Success
Charles MacNeill 9:66969b9016ad 293 */
Charles MacNeill 9:66969b9016ad 294 int get_measurement(uint16_t *distance);
Charles MacNeill 9:66969b9016ad 295 /**
Charles MacNeill 9:66969b9016ad 296 * @brief Enable interrupt measure IRQ
Charles MacNeill 9:66969b9016ad 297 * @return 0 on Success
Charles MacNeill 9:66969b9016ad 298 */
Charles MacNeill 9:66969b9016ad 299 void enable_interrupt_measure_detection_irq(void)
Charles MacNeill 9:66969b9016ad 300 {
Charles MacNeill 9:66969b9016ad 301 if (_gpio1Int != NULL)
Charles MacNeill 9:66969b9016ad 302 _gpio1Int->enable_irq();
Charles MacNeill 9:66969b9016ad 303 }
Charles MacNeill 9:66969b9016ad 304
Charles MacNeill 9:66969b9016ad 305 /**
Charles MacNeill 9:66969b9016ad 306 * @brief Disable interrupt measure IRQ
Charles MacNeill 9:66969b9016ad 307 * @return 0 on Success
Charles MacNeill 9:66969b9016ad 308 */
Charles MacNeill 9:66969b9016ad 309 void disable_interrupt_measure_detection_irq(void)
Charles MacNeill 9:66969b9016ad 310 {
Charles MacNeill 9:66969b9016ad 311 if (_gpio1Int != NULL)
Charles MacNeill 9:66969b9016ad 312 _gpio1Int->disable_irq();
Charles MacNeill 9:66969b9016ad 313 }
Charles MacNeill 9:66969b9016ad 314 /**
Charles MacNeill 9:66969b9016ad 315 * @brief Attach a function to call when an interrupt is detected, i.e. measurement is ready
Charles MacNeill 9:66969b9016ad 316 * @param[in] fptr pointer to call back function to be called whenever an interrupt occours
Charles MacNeill 9:66969b9016ad 317 * @return 0 on Success
Charles MacNeill 9:66969b9016ad 318 */
Charles MacNeill 9:66969b9016ad 319 void attach_interrupt_measure_detection_irq(void (*fptr)(void))
Charles MacNeill 9:66969b9016ad 320 {
Charles MacNeill 9:66969b9016ad 321 if (_gpio1Int != NULL)
Charles MacNeill 9:66969b9016ad 322 _gpio1Int->rise(fptr);
Charles MacNeill 9:66969b9016ad 323 }
Charles MacNeill 9:66969b9016ad 324
Charles MacNeill 9:66969b9016ad 325 /**
Charles MacNeill 9:66969b9016ad 326 * @brief Get ranging result and only that
Charles MacNeill 9:66969b9016ad 327 * @param pRange_mm Pointer to range distance
Charles MacNeill 9:66969b9016ad 328 * @return 0 on success
Charles MacNeill 9:66969b9016ad 329 */
Charles MacNeill 9:66969b9016ad 330 virtual int get_distance(uint32_t *piData)
Charles MacNeill 9:66969b9016ad 331 {
Charles MacNeill 9:66969b9016ad 332 int status;
Charles MacNeill 9:66969b9016ad 333 uint16_t distance;
lugandc 18:0696efe39d08 334 status = get_measurement(&distance);
Charles MacNeill 9:66969b9016ad 335 *piData = (uint32_t) distance;
Charles MacNeill 9:66969b9016ad 336 return status;
Charles MacNeill 9:66969b9016ad 337 }
Charles MacNeill 9:66969b9016ad 338
Charles MacNeill 9:66969b9016ad 339
lugandc 18:0696efe39d08 340 /* vl53l1_api.h functions */
Charles MacNeill 9:66969b9016ad 341
Charles MacNeill 9:66969b9016ad 342 /**
Charles MacNeill 9:66969b9016ad 343 * @brief This function returns the SW driver version
Charles MacNeill 9:66969b9016ad 344 */
Charles MacNeill 10:3687b5e79f98 345 VL53L1CB_ERROR VL53L1CB_GetSWVersion(VL53L1_Version_t *pVersion);
Charles MacNeill 9:66969b9016ad 346
Charles MacNeill 9:66969b9016ad 347 /**
Charles MacNeill 9:66969b9016ad 348 * @brief This function sets the sensor I2C address used in case multiple devices application, default address 0x52
Charles MacNeill 9:66969b9016ad 349 */
Charles MacNeill 10:3687b5e79f98 350 VL53L1CB_ERROR VL53L1CB_SetI2CAddress(uint8_t new_address);
Charles MacNeill 9:66969b9016ad 351
Charles MacNeill 9:66969b9016ad 352 /**
Charles MacNeill 9:66969b9016ad 353 * @brief This function loads the 135 bytes default values to initialize the sensor.
Charles MacNeill 9:66969b9016ad 354 * @param dev Device address
Charles MacNeill 9:66969b9016ad 355 * @return 0:success, != 0:failed
Charles MacNeill 9:66969b9016ad 356 */
Charles MacNeill 10:3687b5e79f98 357 VL53L1CB_ERROR VL53L1CB_SensorInit();
Charles MacNeill 9:66969b9016ad 358
Charles MacNeill 9:66969b9016ad 359 /**
Charles MacNeill 9:66969b9016ad 360 * @brief This function returns the boot state of the device (1:booted, 0:not booted)
Charles MacNeill 9:66969b9016ad 361 */
Charles MacNeill 10:3687b5e79f98 362 VL53L1CB_ERROR VL53L1CB_BootState(uint8_t *state);
Charles MacNeill 9:66969b9016ad 363
Charles MacNeill 9:66969b9016ad 364
Charles MacNeill 9:66969b9016ad 365 /**************************************************************************/
lugandc 18:0696efe39d08 366
lugandc 18:0696efe39d08 367 VL53L1CB_ERROR VL53L1CB_WaitDeviceBooted();
Charles MacNeill 9:66969b9016ad 368
Charles MacNeill 10:3687b5e79f98 369 VL53L1CB_ERROR VL53L1CB_GetCalibrationData(VL53L1_CalibrationData_t *pCalibrationData);
Charles MacNeill 9:66969b9016ad 370
Charles MacNeill 10:3687b5e79f98 371 VL53L1_GPIO_Interrupt_Mode ConvertModeToLLD(VL53L1CB_ERROR *pStatus,
Charles MacNeill 9:66969b9016ad 372 VL53L1_ThresholdMode CrossMode);
Charles MacNeill 9:66969b9016ad 373
Charles MacNeill 10:3687b5e79f98 374 VL53L1CB_ERROR VL53L1CB_GetVersion(VL53L1_Version_t *pVersion);
Charles MacNeill 9:66969b9016ad 375
Charles MacNeill 10:3687b5e79f98 376 VL53L1CB_ERROR VL53L1CB_GetProductRevision(
Charles MacNeill 9:66969b9016ad 377 uint8_t *pProductRevisionMajor, uint8_t *pProductRevisionMinor);
Charles MacNeill 9:66969b9016ad 378
Charles MacNeill 9:66969b9016ad 379
Charles MacNeill 10:3687b5e79f98 380 VL53L1CB_ERROR VL53L1CB_GetDeviceInfo(
Charles MacNeill 9:66969b9016ad 381 VL53L1_DeviceInfo_t *pVL53L1_DeviceInfo);
Charles MacNeill 9:66969b9016ad 382
Charles MacNeill 10:3687b5e79f98 383 VL53L1CB_ERROR VL53L1CB_GetUID( uint64_t *pUid);
Charles MacNeill 9:66969b9016ad 384
Charles MacNeill 10:3687b5e79f98 385 VL53L1CB_ERROR VL53L1CB_GetRangeStatusString(uint8_t RangeStatus,
Charles MacNeill 9:66969b9016ad 386 char *pRangeStatusString);
Charles MacNeill 9:66969b9016ad 387
Charles MacNeill 9:66969b9016ad 388
Charles MacNeill 10:3687b5e79f98 389 VL53L1CB_ERROR VL53L1CB_GetPalErrorString(VL53L1CB_ERROR PalErrorCode,
Charles MacNeill 9:66969b9016ad 390 char *pPalErrorString);
Charles MacNeill 9:66969b9016ad 391
Charles MacNeill 9:66969b9016ad 392
Charles MacNeill 10:3687b5e79f98 393 VL53L1CB_ERROR VL53L1CB_GetPalStateString(VL53L1_State PalStateCode,
Charles MacNeill 9:66969b9016ad 394 char *pPalStateString);
Charles MacNeill 9:66969b9016ad 395
Charles MacNeill 9:66969b9016ad 396
lugandc 18:0696efe39d08 397 VL53L1CB_ERROR VL53L1CB_GetPalState(VL53L1_State *pPalState);
Charles MacNeill 9:66969b9016ad 398
Charles MacNeill 10:3687b5e79f98 399 VL53L1CB_ERROR VL53L1CB_DataInit();
Charles MacNeill 9:66969b9016ad 400
Charles MacNeill 10:3687b5e79f98 401 VL53L1CB_ERROR VL53L1CB_StaticInit();
Charles MacNeill 9:66969b9016ad 402
charlesmn 16:27131f13570d 403 VL53L1CB_ERROR VL53L1CB_ClearInterruptAndStartMeasurement();
Charles MacNeill 9:66969b9016ad 404
Charles MacNeill 10:3687b5e79f98 405 VL53L1CB_ERROR VL53L1CB_GetRangingMeasurementData(
Charles MacNeill 9:66969b9016ad 406 VL53L1_RangingMeasurementData_t *pRangingMeasurementData);
Charles MacNeill 9:66969b9016ad 407
Charles MacNeill 10:3687b5e79f98 408 VL53L1CB_ERROR VL53L1CB_GetMultiRangingData(
Charles MacNeill 9:66969b9016ad 409 VL53L1_MultiRangingData_t *pMultiRangingData);
Charles MacNeill 9:66969b9016ad 410
Charles MacNeill 10:3687b5e79f98 411 VL53L1CB_ERROR VL53L1CB_GetAdditionalData(
Charles MacNeill 9:66969b9016ad 412 VL53L1_AdditionalData_t *pAdditionalData);
Charles MacNeill 9:66969b9016ad 413
Charles MacNeill 10:3687b5e79f98 414 VL53L1CB_ERROR VL53L1CB_SetTuningParameter(
Charles MacNeill 9:66969b9016ad 415 uint16_t TuningParameterId, int32_t TuningParameterValue);
Charles MacNeill 9:66969b9016ad 416
Charles MacNeill 10:3687b5e79f98 417 VL53L1CB_ERROR VL53L1CB_GetTuningParameter(
Charles MacNeill 9:66969b9016ad 418 uint16_t TuningParameterId, int32_t *pTuningParameterValue);
Charles MacNeill 9:66969b9016ad 419
Charles MacNeill 10:3687b5e79f98 420 VL53L1CB_ERROR VL53L1CB_SetXTalkCompensationEnable(
Charles MacNeill 9:66969b9016ad 421 uint8_t XTalkCompensationEnable);
Charles MacNeill 9:66969b9016ad 422
Charles MacNeill 9:66969b9016ad 423
Charles MacNeill 10:3687b5e79f98 424 VL53L1CB_ERROR VL53L1CB_GetXTalkCompensationEnable(
Charles MacNeill 9:66969b9016ad 425 uint8_t *pXTalkCompensationEnable);
Charles MacNeill 9:66969b9016ad 426
Charles MacNeill 10:3687b5e79f98 427 VL53L1CB_ERROR VL53L1CB_PerformXTalkCalibration(
Charles MacNeill 9:66969b9016ad 428 uint8_t CalibrationOption);
Charles MacNeill 9:66969b9016ad 429
Charles MacNeill 10:3687b5e79f98 430 VL53L1CB_ERROR VL53L1CB_SetOffsetCalibrationMode(
Charles MacNeill 9:66969b9016ad 431 VL53L1_OffsetCalibrationModes OffsetCalibrationMode);
Charles MacNeill 9:66969b9016ad 432
Charles MacNeill 9:66969b9016ad 433
Charles MacNeill 10:3687b5e79f98 434 VL53L1CB_ERROR VL53L1CB_SetOffsetCorrectionMode(
Charles MacNeill 9:66969b9016ad 435 VL53L1_OffsetCorrectionModes OffsetCorrectionMode);
Charles MacNeill 9:66969b9016ad 436
Charles MacNeill 10:3687b5e79f98 437 VL53L1CB_ERROR VL53L1CB_PerformOffsetCalibration(
Charles MacNeill 9:66969b9016ad 438 int32_t CalDistanceMilliMeter, FixPoint1616_t CalReflectancePercent);
Charles MacNeill 9:66969b9016ad 439
Charles MacNeill 10:3687b5e79f98 440 VL53L1CB_ERROR VL53L1CB_PerformOffsetSimpleCalibration(
Charles MacNeill 9:66969b9016ad 441 int32_t CalDistanceMilliMeter);
Charles MacNeill 9:66969b9016ad 442
Charles MacNeill 10:3687b5e79f98 443 VL53L1CB_ERROR VL53L1CB_PerformOffsetZeroDistanceCalibration();
Charles MacNeill 9:66969b9016ad 444
Charles MacNeill 10:3687b5e79f98 445 VL53L1CB_ERROR VL53L1CB_SetCalibrationData(
Charles MacNeill 9:66969b9016ad 446 VL53L1_CalibrationData_t *pCalibrationData);
Charles MacNeill 9:66969b9016ad 447
Charles MacNeill 10:3687b5e79f98 448 VL53L1CB_ERROR VL53L1CB_SetZoneCalibrationData(
Charles MacNeill 9:66969b9016ad 449 VL53L1_ZoneCalibrationData_t *pZoneCalibrationData);
Charles MacNeill 9:66969b9016ad 450
Charles MacNeill 10:3687b5e79f98 451 VL53L1CB_ERROR VL53L1CB_GetZoneCalibrationData(
Charles MacNeill 9:66969b9016ad 452 VL53L1_ZoneCalibrationData_t *pZoneCalibrationData);
Charles MacNeill 9:66969b9016ad 453
Charles MacNeill 10:3687b5e79f98 454 VL53L1CB_ERROR VL53L1CB_GetOpticalCenter(
Charles MacNeill 9:66969b9016ad 455 FixPoint1616_t *pOpticalCenterX,
Charles MacNeill 9:66969b9016ad 456 FixPoint1616_t *pOpticalCenterY);
Charles MacNeill 9:66969b9016ad 457
Charles MacNeill 10:3687b5e79f98 458 VL53L1CB_ERROR VL53L1CB_SetThresholdConfig(VL53L1_DetectionConfig_t *pConfig);
Charles MacNeill 9:66969b9016ad 459
Charles MacNeill 9:66969b9016ad 460
Charles MacNeill 10:3687b5e79f98 461 VL53L1CB_ERROR VL53L1CB_GetLimitCheckStatus( uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 462 uint8_t *pLimitCheckStatus);
Charles MacNeill 9:66969b9016ad 463
Charles MacNeill 9:66969b9016ad 464
Charles MacNeill 10:3687b5e79f98 465 VL53L1CB_ERROR VL53L1CB_SetLimitCheckEnable( uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 466 uint8_t LimitCheckEnable);
Charles MacNeill 9:66969b9016ad 467
Charles MacNeill 10:3687b5e79f98 468 VL53L1CB_ERROR VL53L1CB_GetLimitCheckEnable(uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 469 uint8_t *pLimitCheckEnable);
Charles MacNeill 9:66969b9016ad 470
Charles MacNeill 10:3687b5e79f98 471 VL53L1CB_ERROR VL53L1CB_GetThresholdConfig(VL53L1_DetectionConfig_t *pConfig);
Charles MacNeill 9:66969b9016ad 472
Charles MacNeill 9:66969b9016ad 473
Charles MacNeill 10:3687b5e79f98 474 VL53L1CB_ERROR VL53L1CB_PerformOffsetPerVcselCalibration(int32_t CalDistanceMilliMeter);
Charles MacNeill 9:66969b9016ad 475
Charles MacNeill 10:3687b5e79f98 476 VL53L1CB_ERROR VL53L1CB_GetNumberOfLimitCheck(uint16_t *pNumberOfLimitCheck);
Charles MacNeill 9:66969b9016ad 477
Charles MacNeill 10:3687b5e79f98 478 VL53L1CB_ERROR VL53L1CB_GetLimitCheckInfo(uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 479 char *pLimitCheckString);
Charles MacNeill 9:66969b9016ad 480
Charles MacNeill 10:3687b5e79f98 481 VL53L1CB_ERROR VL53L1CB_SetPresetMode(VL53L1_PresetModes PresetMode);
Charles MacNeill 9:66969b9016ad 482
Charles MacNeill 10:3687b5e79f98 483 VL53L1CB_ERROR VL53L1CB_GetPresetMode( VL53L1_PresetModes *pPresetMode);
Charles MacNeill 9:66969b9016ad 484
Charles MacNeill 10:3687b5e79f98 485 VL53L1CB_ERROR VL53L1CB_SetDistanceMode( VL53L1_DistanceModes DistanceMode);
Charles MacNeill 9:66969b9016ad 486
Charles MacNeill 10:3687b5e79f98 487 VL53L1CB_ERROR VL53L1CB_GetDistanceMode(VL53L1_DistanceModes *pDistanceMode);
Charles MacNeill 9:66969b9016ad 488
Charles MacNeill 10:3687b5e79f98 489 VL53L1CB_ERROR VL53L1CB_SetOutputMode(VL53L1_OutputModes OutputMode);
Charles MacNeill 9:66969b9016ad 490
Charles MacNeill 10:3687b5e79f98 491 VL53L1CB_ERROR VL53L1CB_GetOutputMode(VL53L1_OutputModes *pOutputMode);
Charles MacNeill 9:66969b9016ad 492
Charles MacNeill 10:3687b5e79f98 493 VL53L1CB_ERROR VL53L1CB_SetMeasurementTimingBudgetMicroSeconds(uint32_t MeasurementTimingBudgetMicroSeconds);
Charles MacNeill 9:66969b9016ad 494
Charles MacNeill 10:3687b5e79f98 495 VL53L1CB_ERROR VL53L1CB_SetInterMeasurementPeriodMilliSeconds(uint32_t InterMeasurementPeriodMilliSeconds);
Charles MacNeill 9:66969b9016ad 496
Charles MacNeill 9:66969b9016ad 497
Charles MacNeill 10:3687b5e79f98 498 VL53L1CB_ERROR VL53L1CB_GetInterMeasurementPeriodMilliSeconds(
Charles MacNeill 9:66969b9016ad 499 uint32_t *pInterMeasurementPeriodMilliSeconds);
Charles MacNeill 9:66969b9016ad 500
Charles MacNeill 9:66969b9016ad 501
Charles MacNeill 10:3687b5e79f98 502 VL53L1CB_ERROR VL53L1CB_SetDmaxReflectance( FixPoint1616_t DmaxReflectance);
Charles MacNeill 9:66969b9016ad 503
Charles MacNeill 10:3687b5e79f98 504 VL53L1CB_ERROR VL53L1CB_GetDmaxReflectance(FixPoint1616_t *pDmaxReflectance);
Charles MacNeill 9:66969b9016ad 505
Charles MacNeill 9:66969b9016ad 506
Charles MacNeill 10:3687b5e79f98 507 VL53L1CB_ERROR VL53L1CB_GetDmaxMode( VL53L1_DeviceDmaxModes *pDmaxMode);
Charles MacNeill 9:66969b9016ad 508
Charles MacNeill 10:3687b5e79f98 509 VL53L1CB_ERROR VL53L1CB_GetMeasurementTimingBudgetMicroSeconds(
Charles MacNeill 9:66969b9016ad 510 uint32_t *pMeasurementTimingBudgetMicroSeconds);
Charles MacNeill 9:66969b9016ad 511
Charles MacNeill 10:3687b5e79f98 512 VL53L1CB_ERROR VL53L1CB_SetDmaxMode(VL53L1_DeviceDmaxModes DmaxMode);
Charles MacNeill 9:66969b9016ad 513
Charles MacNeill 10:3687b5e79f98 514 VL53L1CB_ERROR VL53L1CB_SetLimitCheckValue( uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 515 FixPoint1616_t LimitCheckValue);
Charles MacNeill 9:66969b9016ad 516
Charles MacNeill 10:3687b5e79f98 517 VL53L1CB_ERROR VL53L1CB_GetLimitCheckValue(uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 518 FixPoint1616_t *pLimitCheckValue);
Charles MacNeill 9:66969b9016ad 519
Charles MacNeill 10:3687b5e79f98 520 VL53L1CB_ERROR VL53L1CB_GetLimitCheckCurrent( uint16_t LimitCheckId,
Charles MacNeill 9:66969b9016ad 521 FixPoint1616_t *pLimitCheckCurrent);
Charles MacNeill 9:66969b9016ad 522
Charles MacNeill 10:3687b5e79f98 523 VL53L1CB_ERROR VL53L1CB_GetMaxNumberOfROI( uint8_t *pMaxNumberOfROI);
Charles MacNeill 9:66969b9016ad 524
Charles MacNeill 10:3687b5e79f98 525 VL53L1CB_ERROR VL53L1CB_SetROI(VL53L1_RoiConfig_t *pRoiConfig);
Charles MacNeill 9:66969b9016ad 526
Charles MacNeill 14:f06785b2a964 527 VL53L1CB_ERROR VL53L1CB_GetROI(VL53L1_RoiConfig_t *pRoiConfig);
Charles MacNeill 9:66969b9016ad 528
Charles MacNeill 10:3687b5e79f98 529 VL53L1CB_ERROR VL53L1CB_GetNumberOfSequenceSteps(uint8_t *pNumberOfSequenceSteps);
Charles MacNeill 9:66969b9016ad 530
Charles MacNeill 10:3687b5e79f98 531 VL53L1CB_ERROR VL53L1CB_GetSequenceStepsInfo(VL53L1_SequenceStepId SequenceStepId,
Charles MacNeill 9:66969b9016ad 532 char *pSequenceStepsString);
Charles MacNeill 9:66969b9016ad 533
Charles MacNeill 9:66969b9016ad 534
Charles MacNeill 10:3687b5e79f98 535 VL53L1CB_ERROR VL53L1CB_SetSequenceStepEnable(VL53L1_SequenceStepId SequenceStepId, uint8_t SequenceStepEnabled);
Charles MacNeill 9:66969b9016ad 536
Charles MacNeill 9:66969b9016ad 537
Charles MacNeill 10:3687b5e79f98 538 VL53L1CB_ERROR VL53L1CB_GetSequenceStepEnable(VL53L1_SequenceStepId SequenceStepId, uint8_t *pSequenceStepEnabled);
Charles MacNeill 9:66969b9016ad 539
Charles MacNeill 9:66969b9016ad 540
Charles MacNeill 10:3687b5e79f98 541 VL53L1CB_ERROR VL53L1CB_StartMeasurement();
Charles MacNeill 9:66969b9016ad 542
Charles MacNeill 10:3687b5e79f98 543 VL53L1CB_ERROR VL53L1CB_StopMeasurement();
Charles MacNeill 9:66969b9016ad 544
Charles MacNeill 9:66969b9016ad 545
Charles MacNeill 10:3687b5e79f98 546 VL53L1CB_ERROR VL53L1CB_GetMeasurementDataReady(uint8_t *pMeasurementDataReady);
Charles MacNeill 9:66969b9016ad 547
Charles MacNeill 10:3687b5e79f98 548 VL53L1CB_ERROR VL53L1CB_WaitMeasurementDataReady();
Charles MacNeill 9:66969b9016ad 549
Charles MacNeill 10:3687b5e79f98 550 VL53L1CB_ERROR VL53L1CB_SmudgeCorrectionEnable(VL53L1_SmudgeCorrectionModes Mode);
Charles MacNeill 9:66969b9016ad 551 /***************************************************************************/
Charles MacNeill 9:66969b9016ad 552
Charles MacNeill 9:66969b9016ad 553
Charles MacNeill 9:66969b9016ad 554 /* Write and read functions from I2C */
Charles MacNeill 9:66969b9016ad 555
Charles MacNeill 14:f06785b2a964 556 VL53L1CB_ERROR VL53L1_WrByte(VL53L1_DEV dev, uint16_t index, uint8_t data); // DON'T CHANGE NAME, SATELLITES STOP WORKING
Charles MacNeill 14:f06785b2a964 557 VL53L1CB_ERROR VL53L1_WrWord(VL53L1_DEV dev, uint16_t index, uint16_t data); // DON'T CHANGE NAME, SATELLITES STOP WORKING
Charles MacNeill 14:f06785b2a964 558 VL53L1CB_ERROR VL53L1_WrDWord(VL53L1_DEV dev, uint16_t index, uint32_t data); // DON'T CHANGE NAME, SATELLITES STOP WORKING
Charles MacNeill 14:f06785b2a964 559 VL53L1CB_ERROR VL53L1_RdByte(VL53L1_DEV dev, uint16_t index, uint8_t *data); // DON'T CHANGE NAME, SATELLITES STOP WORKING
Charles MacNeill 14:f06785b2a964 560 VL53L1CB_ERROR VL53L1_RdWord(VL53L1_DEV dev, uint16_t index, uint16_t *data); // DON'T CHANGE NAME, SATELLITES STOP WORKING
Charles MacNeill 14:f06785b2a964 561 VL53L1CB_ERROR VL53L1_RdDWord(VL53L1_DEV dev, uint16_t index, uint32_t *data);// DON'T CHANGE NAME, SATELLITES STOP WORKING
Charles MacNeill 14:f06785b2a964 562 VL53L1CB_ERROR VL53L1_UpdateByte(VL53L1_DEV dev, uint16_t index, uint8_t AndData, uint8_t OrData); // DON'T CHANGE NAME, SATELLITES STOP WORKING
Charles MacNeill 9:66969b9016ad 563
Charles MacNeill 10:3687b5e79f98 564 VL53L1CB_ERROR VL53L1CB_WriteMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count);
Charles MacNeill 10:3687b5e79f98 565 VL53L1CB_ERROR VL53L1CB_ReadMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count);
Charles MacNeill 9:66969b9016ad 566
Charles MacNeill 10:3687b5e79f98 567 VL53L1CB_ERROR VL53L1CB_I2CWrite(uint8_t dev, uint16_t index, uint8_t *data, uint16_t number_of_bytes);
Charles MacNeill 10:3687b5e79f98 568 VL53L1CB_ERROR VL53L1CB_I2CRead(uint8_t dev, uint16_t index, uint8_t *data, uint16_t number_of_bytes);
Charles MacNeill 10:3687b5e79f98 569 VL53L1CB_ERROR VL53L1CB_GetTickCount(uint32_t *ptick_count_ms);
Charles MacNeill 10:3687b5e79f98 570 VL53L1CB_ERROR VL53L1CB_WaitUs(VL53L1_Dev_t *pdev, int32_t wait_us);
Charles MacNeill 10:3687b5e79f98 571 VL53L1CB_ERROR VL53L1CB_WaitMs(VL53L1_Dev_t *pdev, int32_t wait_ms);
Charles MacNeill 9:66969b9016ad 572
Charles MacNeill 10:3687b5e79f98 573 VL53L1CB_ERROR VL53L1CB_WaitValueMaskEx(VL53L1_Dev_t *pdev, uint32_t timeout_ms, uint16_t index, uint8_t value, uint8_t mask, uint32_t poll_delay_ms);
Charles MacNeill 10:3687b5e79f98 574 VL53L1CB_ERROR VL53L1CB_SetDeviceAddress(VL53L1_DEV Dev, uint8_t DeviceAddress);
Charles MacNeill 9:66969b9016ad 575
Charles MacNeill 9:66969b9016ad 576
Charles MacNeill 9:66969b9016ad 577 protected:
Charles MacNeill 9:66969b9016ad 578
Charles MacNeill 9:66969b9016ad 579 /* IO Device */
Charles MacNeill 9:66969b9016ad 580 ToF_DevI2C *dev_i2c;
Charles MacNeill 9:66969b9016ad 581
Charles MacNeill 9:66969b9016ad 582 /* Digital out pin */
Charles MacNeill 9:66969b9016ad 583 DigitalOut *_gpio0;
Charles MacNeill 9:66969b9016ad 584 /* GPIO expander */
Charles MacNeill 9:66969b9016ad 585 Stmpe1600DigiOut *_expgpio0;
Charles MacNeill 9:66969b9016ad 586 /* Measure detection IRQ */
Charles MacNeill 9:66969b9016ad 587 InterruptIn *_gpio1Int;
Charles MacNeill 9:66969b9016ad 588
Charles MacNeill 9:66969b9016ad 589 ///* Digital out pin */
Charles MacNeill 9:66969b9016ad 590 /* Device data */
Charles MacNeill 9:66969b9016ad 591 VL53L1_Dev_t MyDevice;
Charles MacNeill 9:66969b9016ad 592 VL53L1_DEV Device;
Charles MacNeill 9:66969b9016ad 593 };
Charles MacNeill 9:66969b9016ad 594
Charles MacNeill 9:66969b9016ad 595
lugandc 18:0696efe39d08 596 #endif /* _VL53L1CB_CLASS_H_ */