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.
inc/VL53L1CB.h@16:27131f13570d, 2021-06-20 (annotated)
- Committer:
- charlesmn
- Date:
- Sun Jun 20 13:31:49 2021 +0000
- Revision:
- 16:27131f13570d
- Parent:
- 15:c0d8d300479f
- Child:
- 17:ca0ce4daf573
correct function name
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Charles MacNeill |
9:66969b9016ad | 1 | /******************************************************************************* |
Charles MacNeill |
9:66969b9016ad | 2 | * @file vl53l1x_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 | ****************************************************************************** |
Charles MacNeill |
9:66969b9016ad | 8 | Copyright © 2019, 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 |
Charles MacNeill |
14:f06785b2a964 | 38 | # ifdef VL53L1X_API_EXPORTS |
Charles MacNeill |
14:f06785b2a964 | 39 | # define VL53L1X_API __declspec(dllexport) |
Charles MacNeill |
14:f06785b2a964 | 40 | # else |
Charles MacNeill |
14:f06785b2a964 | 41 | # define VL53L1X_API |
Charles MacNeill |
14:f06785b2a964 | 42 | # endif |
Charles MacNeill |
14:f06785b2a964 | 43 | #else |
Charles MacNeill |
14:f06785b2a964 | 44 | # define VL53L1X_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 "DevI2C.h" |
Charles MacNeill |
9:66969b9016ad | 60 | #include "ToF_I2C.h" |
Charles MacNeill |
9:66969b9016ad | 61 | /**********************************************************/ |
Charles MacNeill |
9:66969b9016ad | 62 | #include "vl53l1_def.h" |
Charles MacNeill |
9:66969b9016ad | 63 | /***********************************************************/ |
Charles MacNeill |
9:66969b9016ad | 64 | |
Charles MacNeill |
9:66969b9016ad | 65 | |
Charles MacNeill |
14:f06785b2a964 | 66 | #define VL53L1_IMPLEMENTATION_VER_MAJOR 1 |
Charles MacNeill |
14:f06785b2a964 | 67 | #define VL53L1_IMPLEMENTATION_VER_MINOR 0 |
Charles MacNeill |
14:f06785b2a964 | 68 | #define VL53L1_IMPLEMENTATION_VER_SUB 1 |
Charles MacNeill |
14:f06785b2a964 | 69 | #define VL53L1_IMPLEMENTATION_VER_REVISION 0000 |
Charles MacNeill |
9:66969b9016ad | 70 | |
Charles MacNeill |
10:3687b5e79f98 | 71 | typedef int8_t VL53L1CB_ERROR; |
Charles MacNeill |
9:66969b9016ad | 72 | |
Charles MacNeill |
9:66969b9016ad | 73 | //#define SOFT_RESET 0x0000 |
Charles MacNeill |
14:f06785b2a964 | 74 | #define VL53L1_I2C_SLAVE__DEVICE_ADDRESS 0x0001 |
Charles MacNeill |
14:f06785b2a964 | 75 | #define VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND 0x0008 |
Charles MacNeill |
9:66969b9016ad | 76 | #define ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS 0x0016 |
Charles MacNeill |
9:66969b9016ad | 77 | #define ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS 0x0018 |
Charles MacNeill |
9:66969b9016ad | 78 | #define ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS 0x001A |
Charles MacNeill |
9:66969b9016ad | 79 | #define ALGO__PART_TO_PART_RANGE_OFFSET_MM 0x001E |
Charles MacNeill |
9:66969b9016ad | 80 | #define MM_CONFIG__INNER_OFFSET_MM 0x0020 |
Charles MacNeill |
9:66969b9016ad | 81 | #define MM_CONFIG__OUTER_OFFSET_MM 0x0022 |
Charles MacNeill |
9:66969b9016ad | 82 | #define GPIO_HV_MUX__CTRL 0x0030 |
Charles MacNeill |
9:66969b9016ad | 83 | #define GPIO__TIO_HV_STATUS 0x0031 |
Charles MacNeill |
9:66969b9016ad | 84 | #define SYSTEM__INTERRUPT_CONFIG_GPIO 0x0046 |
Charles MacNeill |
9:66969b9016ad | 85 | #define PHASECAL_CONFIG__TIMEOUT_MACROP 0x004B |
Charles MacNeill |
9:66969b9016ad | 86 | #define RANGE_CONFIG__TIMEOUT_MACROP_A_HI 0x005E |
Charles MacNeill |
9:66969b9016ad | 87 | #define RANGE_CONFIG__VCSEL_PERIOD_A 0x0060 |
Charles MacNeill |
9:66969b9016ad | 88 | #define RANGE_CONFIG__VCSEL_PERIOD_B 0x0063 |
Charles MacNeill |
9:66969b9016ad | 89 | #define RANGE_CONFIG__TIMEOUT_MACROP_B_HI 0x0061 |
Charles MacNeill |
9:66969b9016ad | 90 | #define RANGE_CONFIG__TIMEOUT_MACROP_B_LO 0x0062 |
Charles MacNeill |
9:66969b9016ad | 91 | #define RANGE_CONFIG__SIGMA_THRESH 0x0064 |
Charles MacNeill |
9:66969b9016ad | 92 | #define RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS 0x0066 |
Charles MacNeill |
9:66969b9016ad | 93 | #define RANGE_CONFIG__VALID_PHASE_HIGH 0x0069 |
Charles MacNeill |
14:f06785b2a964 | 94 | #define VL53L1_SYSTEM__INTERMEASUREMENT_PERIOD 0x006C |
Charles MacNeill |
9:66969b9016ad | 95 | #define SYSTEM__THRESH_HIGH 0x0072 |
Charles MacNeill |
9:66969b9016ad | 96 | #define SYSTEM__THRESH_LOW 0x0074 |
Charles MacNeill |
9:66969b9016ad | 97 | #define SD_CONFIG__WOI_SD0 0x0078 |
Charles MacNeill |
9:66969b9016ad | 98 | #define SD_CONFIG__INITIAL_PHASE_SD0 0x007A |
Charles MacNeill |
9:66969b9016ad | 99 | #define ROI_CONFIG__USER_ROI_CENTRE_SPAD 0x007F |
Charles MacNeill |
9:66969b9016ad | 100 | #define ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE 0x0080 |
Charles MacNeill |
9:66969b9016ad | 101 | #define SYSTEM__SEQUENCE_CONFIG 0x0081 |
Charles MacNeill |
14:f06785b2a964 | 102 | #define VL53L1_SYSTEM__GROUPED_PARAMETER_HOLD 0x0082 |
Charles MacNeill |
9:66969b9016ad | 103 | #define SYSTEM__INTERRUPT_CLEAR 0x0086 |
Charles MacNeill |
9:66969b9016ad | 104 | #define SYSTEM__MODE_START 0x0087 |
Charles MacNeill |
14:f06785b2a964 | 105 | #define VL53L1_RESULT__RANGE_STATUS 0x0089 |
Charles MacNeill |
14:f06785b2a964 | 106 | #define VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0 0x008C |
Charles MacNeill |
9:66969b9016ad | 107 | #define RESULT__AMBIENT_COUNT_RATE_MCPS_SD 0x0090 |
Charles MacNeill |
14:f06785b2a964 | 108 | #define VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 0x0096 |
Charles MacNeill |
14:f06785b2a964 | 109 | #define VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0 0x0098 |
Charles MacNeill |
14:f06785b2a964 | 110 | #define VL53L1_RESULT__OSC_CALIBRATE_VAL 0x00DE |
Charles MacNeill |
14:f06785b2a964 | 111 | #define VL53L1_FIRMWARE__SYSTEM_STATUS 0x00E5 |
Charles MacNeill |
14:f06785b2a964 | 112 | #define VL53L1_IDENTIFICATION__MODEL_ID 0x010F |
Charles MacNeill |
14:f06785b2a964 | 113 | #define VL53L1_ROI_CONFIG__MODE_ROI_CENTRE_SPAD 0x013E |
Charles MacNeill |
9:66969b9016ad | 114 | |
Charles MacNeill |
9:66969b9016ad | 115 | |
Charles MacNeill |
14:f06785b2a964 | 116 | #define VL53L1_DEFAULT_DEVICE_ADDRESS 0x52 |
Charles MacNeill |
9:66969b9016ad | 117 | |
Charles MacNeill |
14:f06785b2a964 | 118 | #define VL53L1_REG_IDENTIFICATION_MODEL_ID 0x010F |
Charles MacNeill |
9:66969b9016ad | 119 | |
Charles MacNeill |
9:66969b9016ad | 120 | /**************************************** |
Charles MacNeill |
9:66969b9016ad | 121 | * PRIVATE define do not edit |
Charles MacNeill |
9:66969b9016ad | 122 | ****************************************/ |
Charles MacNeill |
9:66969b9016ad | 123 | |
Charles MacNeill |
9:66969b9016ad | 124 | /** |
Charles MacNeill |
9:66969b9016ad | 125 | * @brief defines SW Version |
Charles MacNeill |
9:66969b9016ad | 126 | */ |
Charles MacNeill |
9:66969b9016ad | 127 | //typedef struct { |
Charles MacNeill |
9:66969b9016ad | 128 | // uint8_t major; /*!< major number */ |
Charles MacNeill |
9:66969b9016ad | 129 | // uint8_t minor; /*!< minor number */ |
Charles MacNeill |
9:66969b9016ad | 130 | // uint8_t build; /*!< build number */ |
Charles MacNeill |
9:66969b9016ad | 131 | // uint32_t revision; /*!< revision number */ |
Charles MacNeill |
9:66969b9016ad | 132 | //} VL53L1X_Version_t; |
Charles MacNeill |
9:66969b9016ad | 133 | |
Charles MacNeill |
9:66969b9016ad | 134 | |
Charles MacNeill |
9:66969b9016ad | 135 | /* Classes -------------------------------------------------------------------*/ |
Charles MacNeill |
14:f06785b2a964 | 136 | /** Class representing a VL53L1 sensor component |
Charles MacNeill |
9:66969b9016ad | 137 | */ |
Charles MacNeill |
10:3687b5e79f98 | 138 | class VL53L1CB : public RangeSensor |
Charles MacNeill |
9:66969b9016ad | 139 | { |
Charles MacNeill |
9:66969b9016ad | 140 | |
Charles MacNeill |
9:66969b9016ad | 141 | |
Charles MacNeill |
9:66969b9016ad | 142 | |
Charles MacNeill |
9:66969b9016ad | 143 | public: |
Charles MacNeill |
9:66969b9016ad | 144 | |
Charles MacNeill |
9:66969b9016ad | 145 | |
Charles MacNeill |
9:66969b9016ad | 146 | #define VL53L1DevStructGetLLDriverHandle(Dev) (&Dev->Data.LLData) |
Charles MacNeill |
9:66969b9016ad | 147 | /** Constructor |
Charles MacNeill |
9:66969b9016ad | 148 | * @param[in] &i2c device I2C to be used for communication |
Charles MacNeill |
9:66969b9016ad | 149 | * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT |
Charles MacNeill |
9:66969b9016ad | 150 | * @param[in] DevAddr device address, 0x52 by default |
Charles MacNeill |
9:66969b9016ad | 151 | */ |
Charles MacNeill |
15:c0d8d300479f | 152 | /* confuses the compiler |
Charles MacNeill |
14:f06785b2a964 | 153 | VL53L1CB(ToF_DevI2C *i2c, DigitalOut *pin, PinName pin_gpio1, uint8_t dev_addr = VL53L1_DEFAULT_DEVICE_ADDRESS) |
Charles MacNeill |
9:66969b9016ad | 154 | : RangeSensor(), dev_i2c(i2c), _gpio0(pin) |
Charles MacNeill |
9:66969b9016ad | 155 | { |
Charles MacNeill |
9:66969b9016ad | 156 | MyDevice.i2c_slave_address=dev_addr; |
Charles MacNeill |
9:66969b9016ad | 157 | Device = &MyDevice; |
Charles MacNeill |
9:66969b9016ad | 158 | |
Charles MacNeill |
9:66969b9016ad | 159 | _expgpio0 = NULL; |
Charles MacNeill |
9:66969b9016ad | 160 | if (pin_gpio1 != NC) { |
Charles MacNeill |
9:66969b9016ad | 161 | _gpio1Int = new InterruptIn(pin_gpio1); |
Charles MacNeill |
9:66969b9016ad | 162 | } else { |
Charles MacNeill |
9:66969b9016ad | 163 | _gpio1Int = NULL; |
Charles MacNeill |
9:66969b9016ad | 164 | } |
Charles MacNeill |
9:66969b9016ad | 165 | } |
Charles MacNeill |
14:f06785b2a964 | 166 | |
Charles MacNeill |
15:c0d8d300479f | 167 | */ |
Charles MacNeill |
9:66969b9016ad | 168 | /** Constructor 2 (STMPE1600DigiOut) |
Charles MacNeill |
9:66969b9016ad | 169 | * @param[in] i2c device I2C to be used for communication |
Charles MacNeill |
9:66969b9016ad | 170 | * @param[in] &pin Gpio Expander STMPE1600DigiOut pin to be used as component GPIO_0 CE |
Charles MacNeill |
9:66969b9016ad | 171 | * @param[in] pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT |
Charles MacNeill |
9:66969b9016ad | 172 | * @param[in] device address, 0x29 by default |
Charles MacNeill |
9:66969b9016ad | 173 | */ |
Charles MacNeill |
10:3687b5e79f98 | 174 | VL53L1CB(ToF_DevI2C *i2c, Stmpe1600DigiOut *pin, PinName pin_gpio1, |
Charles MacNeill |
14:f06785b2a964 | 175 | uint8_t dev_addr = VL53L1_DEFAULT_DEVICE_ADDRESS) |
Charles MacNeill |
9:66969b9016ad | 176 | : dev_i2c(i2c), _expgpio0(pin) |
Charles MacNeill |
9:66969b9016ad | 177 | { |
Charles MacNeill |
9:66969b9016ad | 178 | MyDevice.i2c_slave_address=dev_addr; |
Charles MacNeill |
9:66969b9016ad | 179 | Device = &MyDevice; |
Charles MacNeill |
9:66969b9016ad | 180 | |
Charles MacNeill |
9:66969b9016ad | 181 | _gpio0 = NULL; |
Charles MacNeill |
9:66969b9016ad | 182 | if (pin_gpio1 != NC) { |
Charles MacNeill |
9:66969b9016ad | 183 | _gpio1Int = new InterruptIn(pin_gpio1); |
Charles MacNeill |
9:66969b9016ad | 184 | } else { |
Charles MacNeill |
9:66969b9016ad | 185 | _gpio1Int = NULL; |
Charles MacNeill |
9:66969b9016ad | 186 | } |
Charles MacNeill |
9:66969b9016ad | 187 | } |
Charles MacNeill |
9:66969b9016ad | 188 | |
Charles MacNeill |
9:66969b9016ad | 189 | /** Destructor |
Charles MacNeill |
9:66969b9016ad | 190 | */ |
Charles MacNeill |
10:3687b5e79f98 | 191 | virtual ~VL53L1CB() |
Charles MacNeill |
9:66969b9016ad | 192 | { |
Charles MacNeill |
9:66969b9016ad | 193 | if (_gpio1Int != NULL) { |
Charles MacNeill |
9:66969b9016ad | 194 | delete _gpio1Int; |
Charles MacNeill |
9:66969b9016ad | 195 | } |
Charles MacNeill |
9:66969b9016ad | 196 | } |
Charles MacNeill |
9:66969b9016ad | 197 | |
Charles MacNeill |
9:66969b9016ad | 198 | |
Charles MacNeill |
9:66969b9016ad | 199 | |
Charles MacNeill |
9:66969b9016ad | 200 | VL53L1_DEV getDevicePtr() { return Device; } |
Charles MacNeill |
9:66969b9016ad | 201 | |
Charles MacNeill |
9:66969b9016ad | 202 | |
Charles MacNeill |
14:f06785b2a964 | 203 | /* warning: VL53L1 class inherits from GenericSensor, RangeSensor and LightSensor, that haven`t a destructor. |
Charles MacNeill |
9:66969b9016ad | 204 | The warning should request to introduce a virtual destructor to make sure to delete the object */ |
Charles MacNeill |
9:66969b9016ad | 205 | |
Charles MacNeill |
9:66969b9016ad | 206 | /*** Interface Methods ***/ |
Charles MacNeill |
9:66969b9016ad | 207 | /*** High level API ***/ |
Charles MacNeill |
9:66969b9016ad | 208 | /** |
Charles MacNeill |
9:66969b9016ad | 209 | * @brief PowerOn the sensor |
Charles MacNeill |
9:66969b9016ad | 210 | * @return void |
Charles MacNeill |
9:66969b9016ad | 211 | */ |
Charles MacNeill |
9:66969b9016ad | 212 | /* turns on the sensor */ |
Charles MacNeill |
10:3687b5e79f98 | 213 | virtual void VL53L1CB_On(void) |
Charles MacNeill |
9:66969b9016ad | 214 | { |
Charles MacNeill |
14:f06785b2a964 | 215 | printf("VL53L1_On\r\n"); |
Charles MacNeill |
9:66969b9016ad | 216 | if (_gpio0) { |
Charles MacNeill |
9:66969b9016ad | 217 | *_gpio0 = 1; |
Charles MacNeill |
9:66969b9016ad | 218 | } else { |
Charles MacNeill |
9:66969b9016ad | 219 | if (_expgpio0) { |
Charles MacNeill |
9:66969b9016ad | 220 | *_expgpio0 = 1; |
Charles MacNeill |
9:66969b9016ad | 221 | } |
Charles MacNeill |
9:66969b9016ad | 222 | } |
Charles MacNeill |
9:66969b9016ad | 223 | #if (MBED_VERSION > 60300) |
Charles MacNeill |
9:66969b9016ad | 224 | thread_sleep_for(100); |
Charles MacNeill |
9:66969b9016ad | 225 | #else |
Charles MacNeill |
9:66969b9016ad | 226 | wait_ms(100); // NEEDS A DELAY BETWEEN SENSORS |
Charles MacNeill |
9:66969b9016ad | 227 | #endif |
Charles MacNeill |
9:66969b9016ad | 228 | } |
Charles MacNeill |
9:66969b9016ad | 229 | |
Charles MacNeill |
9:66969b9016ad | 230 | /** |
Charles MacNeill |
9:66969b9016ad | 231 | * @brief PowerOff the sensor |
Charles MacNeill |
9:66969b9016ad | 232 | * @return void |
Charles MacNeill |
9:66969b9016ad | 233 | */ |
Charles MacNeill |
9:66969b9016ad | 234 | /* turns off the sensor */ |
Charles MacNeill |
10:3687b5e79f98 | 235 | virtual void VL53L1CB_Off(void) |
Charles MacNeill |
9:66969b9016ad | 236 | { |
Charles MacNeill |
9:66969b9016ad | 237 | printf("VL53L1_Off\r\n"); |
Charles MacNeill |
9:66969b9016ad | 238 | if (_gpio0) { |
Charles MacNeill |
9:66969b9016ad | 239 | *_gpio0 = 0; |
Charles MacNeill |
9:66969b9016ad | 240 | } else { |
Charles MacNeill |
9:66969b9016ad | 241 | if (_expgpio0) { |
Charles MacNeill |
9:66969b9016ad | 242 | *_expgpio0 = 0; |
Charles MacNeill |
9:66969b9016ad | 243 | } |
Charles MacNeill |
9:66969b9016ad | 244 | } |
Charles MacNeill |
9:66969b9016ad | 245 | #if (MBED_VERSION > 60300) |
Charles MacNeill |
9:66969b9016ad | 246 | thread_sleep_for(100); |
Charles MacNeill |
9:66969b9016ad | 247 | #else |
Charles MacNeill |
9:66969b9016ad | 248 | wait_ms(100); // NEEDS A DELAY BETWEEN SENSORS |
Charles MacNeill |
9:66969b9016ad | 249 | #endif |
Charles MacNeill |
9:66969b9016ad | 250 | } |
Charles MacNeill |
9:66969b9016ad | 251 | |
Charles MacNeill |
9:66969b9016ad | 252 | int is_present() |
Charles MacNeill |
9:66969b9016ad | 253 | { |
Charles MacNeill |
9:66969b9016ad | 254 | int status; |
Charles MacNeill |
9:66969b9016ad | 255 | uint8_t id = 0; |
Charles MacNeill |
9:66969b9016ad | 256 | |
Charles MacNeill |
9:66969b9016ad | 257 | status = read_id(&id); |
Charles MacNeill |
9:66969b9016ad | 258 | if (status) { |
Charles MacNeill |
9:66969b9016ad | 259 | printf("Failed to read ID device. Device not present!\n\r"); |
Charles MacNeill |
9:66969b9016ad | 260 | } |
Charles MacNeill |
9:66969b9016ad | 261 | return status; |
Charles MacNeill |
9:66969b9016ad | 262 | } |
Charles MacNeill |
9:66969b9016ad | 263 | |
Charles MacNeill |
9:66969b9016ad | 264 | /** |
Charles MacNeill |
9:66969b9016ad | 265 | * @brief Initialize the sensor with default values |
Charles MacNeill |
9:66969b9016ad | 266 | * @return 0 on Success |
Charles MacNeill |
9:66969b9016ad | 267 | */ |
Charles MacNeill |
9:66969b9016ad | 268 | |
Charles MacNeill |
10:3687b5e79f98 | 269 | VL53L1CB_ERROR InitSensor(uint8_t address){ |
Charles MacNeill |
10:3687b5e79f98 | 270 | VL53L1CB_ERROR status = 0; |
Charles MacNeill |
9:66969b9016ad | 271 | uint8_t sensorState = 0; |
Charles MacNeill |
10:3687b5e79f98 | 272 | VL53L1CB_Off(); |
Charles MacNeill |
10:3687b5e79f98 | 273 | VL53L1CB_On(); |
Charles MacNeill |
10:3687b5e79f98 | 274 | status = VL53L1CB_SetI2CAddress(address); |
Charles MacNeill |
9:66969b9016ad | 275 | if(!status){ |
Charles MacNeill |
10:3687b5e79f98 | 276 | status = VL53L1CB_SensorInit(); |
Charles MacNeill |
9:66969b9016ad | 277 | } |
Charles MacNeill |
9:66969b9016ad | 278 | |
Charles MacNeill |
9:66969b9016ad | 279 | while(!status && !sensorState) { |
Charles MacNeill |
10:3687b5e79f98 | 280 | status = VL53L1CB_BootState(&sensorState); |
Charles MacNeill |
9:66969b9016ad | 281 | |
Charles MacNeill |
9:66969b9016ad | 282 | #if (MBED_VERSION > 60300) |
Charles MacNeill |
9:66969b9016ad | 283 | thread_sleep_for(2); |
Charles MacNeill |
9:66969b9016ad | 284 | #else |
Charles MacNeill |
9:66969b9016ad | 285 | wait_ms(2); // NEEDS A DELAY BETWEEN SENSORS |
Charles MacNeill |
9:66969b9016ad | 286 | #endif |
Charles MacNeill |
9:66969b9016ad | 287 | } |
Charles MacNeill |
9:66969b9016ad | 288 | return status; |
Charles MacNeill |
9:66969b9016ad | 289 | } |
Charles MacNeill |
9:66969b9016ad | 290 | |
Charles MacNeill |
9:66969b9016ad | 291 | |
Charles MacNeill |
9:66969b9016ad | 292 | |
Charles MacNeill |
9:66969b9016ad | 293 | /** |
Charles MacNeill |
9:66969b9016ad | 294 | * |
Charles MacNeill |
9:66969b9016ad | 295 | * @brief One time device initialization |
Charles MacNeill |
9:66969b9016ad | 296 | * @param void |
Charles MacNeill |
9:66969b9016ad | 297 | * @return 0 on success, @a #CALIBRATION_WARNING if failed |
Charles MacNeill |
9:66969b9016ad | 298 | */ |
Charles MacNeill |
9:66969b9016ad | 299 | virtual int init(void *init) |
Charles MacNeill |
9:66969b9016ad | 300 | { |
Charles MacNeill |
10:3687b5e79f98 | 301 | return VL53L1CB_SensorInit(); |
Charles MacNeill |
9:66969b9016ad | 302 | return 0; |
Charles MacNeill |
9:66969b9016ad | 303 | } |
Charles MacNeill |
9:66969b9016ad | 304 | |
Charles MacNeill |
9:66969b9016ad | 305 | |
Charles MacNeill |
9:66969b9016ad | 306 | /** |
Charles MacNeill |
9:66969b9016ad | 307 | * @brief Initialize the sensor with default values |
Charles MacNeill |
9:66969b9016ad | 308 | * @return "0" on success |
Charles MacNeill |
9:66969b9016ad | 309 | */ |
Charles MacNeill |
9:66969b9016ad | 310 | int init_sensor(uint8_t new_addr); |
Charles MacNeill |
9:66969b9016ad | 311 | |
Charles MacNeill |
9:66969b9016ad | 312 | /* Read function of the ID device */ |
Charles MacNeill |
9:66969b9016ad | 313 | virtual int read_id(uint8_t *id){ |
Charles MacNeill |
9:66969b9016ad | 314 | int status = 0; |
Charles MacNeill |
9:66969b9016ad | 315 | uint16_t rl_id = 0; |
Charles MacNeill |
9:66969b9016ad | 316 | |
Charles MacNeill |
9:66969b9016ad | 317 | uint8_t ExpanderData[2]; |
Charles MacNeill |
9:66969b9016ad | 318 | |
Charles MacNeill |
9:66969b9016ad | 319 | ExpanderData[0] = 0; |
Charles MacNeill |
9:66969b9016ad | 320 | ExpanderData[1] = 0; |
Charles MacNeill |
9:66969b9016ad | 321 | rl_id = 0; |
Charles MacNeill |
14:f06785b2a964 | 322 | dev_i2c->ToF_i2c_read(&ExpanderData[0], Device->i2c_slave_address, VL53L1_REG_IDENTIFICATION_MODEL_ID, 2); |
Charles MacNeill |
9:66969b9016ad | 323 | |
Charles MacNeill |
9:66969b9016ad | 324 | rl_id = (ExpanderData[0] << 8) + ExpanderData[1]; |
Charles MacNeill |
9:66969b9016ad | 325 | printf("Model ID is: %d (%X) \r\n",rl_id, rl_id); |
Charles MacNeill |
9:66969b9016ad | 326 | |
Charles MacNeill |
9:66969b9016ad | 327 | uint8_t tmp = 0; |
Charles MacNeill |
14:f06785b2a964 | 328 | ExpanderData[0] = VL53L1_FIRMWARE__SYSTEM_STATUS >> 8; |
Charles MacNeill |
14:f06785b2a964 | 329 | ExpanderData[1] = VL53L1_FIRMWARE__SYSTEM_STATUS & 0x0FF; |
Charles MacNeill |
14:f06785b2a964 | 330 | dev_i2c->ToF_i2c_read(&tmp, Device->i2c_slave_address, VL53L1_FIRMWARE__SYSTEM_STATUS, 1); |
Charles MacNeill |
9:66969b9016ad | 331 | |
Charles MacNeill |
9:66969b9016ad | 332 | printf("Firmware system is: %d\r\n",tmp); |
Charles MacNeill |
9:66969b9016ad | 333 | |
Charles MacNeill |
9:66969b9016ad | 334 | if (rl_id == 0xEACC) { |
Charles MacNeill |
9:66969b9016ad | 335 | printf("Device is present %d:\r\n", rl_id); |
Charles MacNeill |
9:66969b9016ad | 336 | return status; |
Charles MacNeill |
9:66969b9016ad | 337 | } |
Charles MacNeill |
9:66969b9016ad | 338 | return -1; |
Charles MacNeill |
9:66969b9016ad | 339 | } |
Charles MacNeill |
9:66969b9016ad | 340 | |
Charles MacNeill |
9:66969b9016ad | 341 | |
Charles MacNeill |
9:66969b9016ad | 342 | /** |
Charles MacNeill |
9:66969b9016ad | 343 | * @brief Interrupt handling func to be called by user after an INT is occurred |
Charles MacNeill |
9:66969b9016ad | 344 | * @param[out] Data pointer to the distance to read data in to |
Charles MacNeill |
9:66969b9016ad | 345 | * @return 0 on Success |
Charles MacNeill |
9:66969b9016ad | 346 | */ |
Charles MacNeill |
9:66969b9016ad | 347 | int handle_irq(uint16_t *distance); |
Charles MacNeill |
9:66969b9016ad | 348 | |
Charles MacNeill |
9:66969b9016ad | 349 | /** |
Charles MacNeill |
9:66969b9016ad | 350 | * @brief Start the measure indicated by operating mode |
Charles MacNeill |
9:66969b9016ad | 351 | * @param[in] fptr specifies call back function must be !NULL in case of interrupt measure |
Charles MacNeill |
9:66969b9016ad | 352 | * @return 0 on Success |
Charles MacNeill |
9:66969b9016ad | 353 | */ |
Charles MacNeill |
9:66969b9016ad | 354 | int start_measurement(void (*fptr)(void)); |
Charles MacNeill |
9:66969b9016ad | 355 | /** |
Charles MacNeill |
9:66969b9016ad | 356 | * @brief Stop the currently running measure indicate by operating_mode |
Charles MacNeill |
9:66969b9016ad | 357 | * @return 0 on Success |
Charles MacNeill |
9:66969b9016ad | 358 | */ |
Charles MacNeill |
9:66969b9016ad | 359 | int stop_measurement(); |
Charles MacNeill |
9:66969b9016ad | 360 | /** |
Charles MacNeill |
9:66969b9016ad | 361 | * @brief Get results for the measure |
Charles MacNeill |
9:66969b9016ad | 362 | * @param[out] Data pointer to the distance_data to read data in to |
Charles MacNeill |
9:66969b9016ad | 363 | * @return 0 on Success |
Charles MacNeill |
9:66969b9016ad | 364 | */ |
Charles MacNeill |
9:66969b9016ad | 365 | int get_measurement(uint16_t *distance); |
Charles MacNeill |
9:66969b9016ad | 366 | /** |
Charles MacNeill |
9:66969b9016ad | 367 | * @brief Enable interrupt measure IRQ |
Charles MacNeill |
9:66969b9016ad | 368 | * @return 0 on Success |
Charles MacNeill |
9:66969b9016ad | 369 | */ |
Charles MacNeill |
9:66969b9016ad | 370 | void enable_interrupt_measure_detection_irq(void) |
Charles MacNeill |
9:66969b9016ad | 371 | { |
Charles MacNeill |
9:66969b9016ad | 372 | if (_gpio1Int != NULL) |
Charles MacNeill |
9:66969b9016ad | 373 | _gpio1Int->enable_irq(); |
Charles MacNeill |
9:66969b9016ad | 374 | } |
Charles MacNeill |
9:66969b9016ad | 375 | |
Charles MacNeill |
9:66969b9016ad | 376 | /** |
Charles MacNeill |
9:66969b9016ad | 377 | * @brief Disable interrupt measure IRQ |
Charles MacNeill |
9:66969b9016ad | 378 | * @return 0 on Success |
Charles MacNeill |
9:66969b9016ad | 379 | */ |
Charles MacNeill |
9:66969b9016ad | 380 | void disable_interrupt_measure_detection_irq(void) |
Charles MacNeill |
9:66969b9016ad | 381 | { |
Charles MacNeill |
9:66969b9016ad | 382 | if (_gpio1Int != NULL) |
Charles MacNeill |
9:66969b9016ad | 383 | _gpio1Int->disable_irq(); |
Charles MacNeill |
9:66969b9016ad | 384 | } |
Charles MacNeill |
9:66969b9016ad | 385 | /** |
Charles MacNeill |
9:66969b9016ad | 386 | * @brief Attach a function to call when an interrupt is detected, i.e. measurement is ready |
Charles MacNeill |
9:66969b9016ad | 387 | * @param[in] fptr pointer to call back function to be called whenever an interrupt occours |
Charles MacNeill |
9:66969b9016ad | 388 | * @return 0 on Success |
Charles MacNeill |
9:66969b9016ad | 389 | */ |
Charles MacNeill |
9:66969b9016ad | 390 | void attach_interrupt_measure_detection_irq(void (*fptr)(void)) |
Charles MacNeill |
9:66969b9016ad | 391 | { |
Charles MacNeill |
9:66969b9016ad | 392 | if (_gpio1Int != NULL) |
Charles MacNeill |
9:66969b9016ad | 393 | _gpio1Int->rise(fptr); |
Charles MacNeill |
9:66969b9016ad | 394 | } |
Charles MacNeill |
9:66969b9016ad | 395 | |
Charles MacNeill |
9:66969b9016ad | 396 | /** |
Charles MacNeill |
9:66969b9016ad | 397 | * @brief Get ranging result and only that |
Charles MacNeill |
9:66969b9016ad | 398 | * @param pRange_mm Pointer to range distance |
Charles MacNeill |
9:66969b9016ad | 399 | * @return 0 on success |
Charles MacNeill |
9:66969b9016ad | 400 | */ |
Charles MacNeill |
9:66969b9016ad | 401 | virtual int get_distance(uint32_t *piData) |
Charles MacNeill |
9:66969b9016ad | 402 | { |
Charles MacNeill |
9:66969b9016ad | 403 | int status; |
Charles MacNeill |
9:66969b9016ad | 404 | uint16_t distance; |
Charles MacNeill |
10:3687b5e79f98 | 405 | status = VL53L1CB_GetDistance(&distance); |
Charles MacNeill |
9:66969b9016ad | 406 | *piData = (uint32_t) distance; |
Charles MacNeill |
9:66969b9016ad | 407 | return status; |
Charles MacNeill |
9:66969b9016ad | 408 | } |
Charles MacNeill |
9:66969b9016ad | 409 | |
Charles MacNeill |
9:66969b9016ad | 410 | |
Charles MacNeill |
9:66969b9016ad | 411 | /* VL53L1X_api.h functions */ |
Charles MacNeill |
9:66969b9016ad | 412 | |
Charles MacNeill |
9:66969b9016ad | 413 | |
Charles MacNeill |
9:66969b9016ad | 414 | |
Charles MacNeill |
9:66969b9016ad | 415 | /** |
Charles MacNeill |
9:66969b9016ad | 416 | * @brief This function returns the SW driver version |
Charles MacNeill |
9:66969b9016ad | 417 | */ |
Charles MacNeill |
10:3687b5e79f98 | 418 | VL53L1CB_ERROR VL53L1CB_GetSWVersion(VL53L1_Version_t *pVersion); |
Charles MacNeill |
9:66969b9016ad | 419 | |
Charles MacNeill |
9:66969b9016ad | 420 | /** |
Charles MacNeill |
9:66969b9016ad | 421 | * @brief This function sets the sensor I2C address used in case multiple devices application, default address 0x52 |
Charles MacNeill |
9:66969b9016ad | 422 | */ |
Charles MacNeill |
10:3687b5e79f98 | 423 | VL53L1CB_ERROR VL53L1CB_SetI2CAddress(uint8_t new_address); |
Charles MacNeill |
9:66969b9016ad | 424 | |
Charles MacNeill |
9:66969b9016ad | 425 | /** |
Charles MacNeill |
9:66969b9016ad | 426 | * @brief This function loads the 135 bytes default values to initialize the sensor. |
Charles MacNeill |
9:66969b9016ad | 427 | * @param dev Device address |
Charles MacNeill |
9:66969b9016ad | 428 | * @return 0:success, != 0:failed |
Charles MacNeill |
9:66969b9016ad | 429 | */ |
Charles MacNeill |
10:3687b5e79f98 | 430 | VL53L1CB_ERROR VL53L1CB_SensorInit(); |
Charles MacNeill |
9:66969b9016ad | 431 | |
Charles MacNeill |
9:66969b9016ad | 432 | /** |
Charles MacNeill |
9:66969b9016ad | 433 | * @brief This function clears the interrupt, to be called after a ranging data reading |
Charles MacNeill |
9:66969b9016ad | 434 | * to arm the interrupt for the next data ready event. |
Charles MacNeill |
9:66969b9016ad | 435 | */ |
Charles MacNeill |
10:3687b5e79f98 | 436 | VL53L1CB_ERROR VL53L1CB_ClearInterrupt(); |
Charles MacNeill |
9:66969b9016ad | 437 | |
Charles MacNeill |
9:66969b9016ad | 438 | |
Charles MacNeill |
9:66969b9016ad | 439 | /** |
Charles MacNeill |
9:66969b9016ad | 440 | * @brief This function returns the current interrupt polarity\n |
Charles MacNeill |
9:66969b9016ad | 441 | * 1=active high (default), 0=active low |
Charles MacNeill |
9:66969b9016ad | 442 | */ |
Charles MacNeill |
10:3687b5e79f98 | 443 | VL53L1CB_ERROR VL53L1CB_GetInterruptPolarity(uint8_t *pIntPol); |
Charles MacNeill |
9:66969b9016ad | 444 | |
Charles MacNeill |
9:66969b9016ad | 445 | /** |
Charles MacNeill |
9:66969b9016ad | 446 | * @brief This function starts the ranging distance operation\n |
Charles MacNeill |
9:66969b9016ad | 447 | * The ranging operation is continuous. The clear interrupt has to be done after each get data to allow the interrupt to raise when the next data is ready\n |
Charles MacNeill |
9:66969b9016ad | 448 | * 1=active high (default), 0=active low, use SetInterruptPolarity() to change the interrupt polarity if required. |
Charles MacNeill |
9:66969b9016ad | 449 | */ |
Charles MacNeill |
10:3687b5e79f98 | 450 | VL53L1CB_ERROR VL53L1CB_StartRanging(); |
Charles MacNeill |
9:66969b9016ad | 451 | |
Charles MacNeill |
9:66969b9016ad | 452 | /** |
Charles MacNeill |
9:66969b9016ad | 453 | * @brief This function stops the ranging. |
Charles MacNeill |
9:66969b9016ad | 454 | */ |
Charles MacNeill |
10:3687b5e79f98 | 455 | VL53L1CB_ERROR VL53L1CB_StopRanging(); |
Charles MacNeill |
9:66969b9016ad | 456 | |
Charles MacNeill |
9:66969b9016ad | 457 | |
Charles MacNeill |
9:66969b9016ad | 458 | |
Charles MacNeill |
9:66969b9016ad | 459 | /** |
Charles MacNeill |
9:66969b9016ad | 460 | * @brief This function returns the boot state of the device (1:booted, 0:not booted) |
Charles MacNeill |
9:66969b9016ad | 461 | */ |
Charles MacNeill |
10:3687b5e79f98 | 462 | VL53L1CB_ERROR VL53L1CB_BootState(uint8_t *state); |
Charles MacNeill |
9:66969b9016ad | 463 | |
Charles MacNeill |
9:66969b9016ad | 464 | /** |
Charles MacNeill |
9:66969b9016ad | 465 | * @brief This function returns the sensor id, sensor Id must be 0xEEAC |
Charles MacNeill |
9:66969b9016ad | 466 | */ |
Charles MacNeill |
10:3687b5e79f98 | 467 | // VL53L1CB_ERROR VL53L1X_GetSensorId(uint16_t *id); |
Charles MacNeill |
9:66969b9016ad | 468 | |
Charles MacNeill |
9:66969b9016ad | 469 | /** |
Charles MacNeill |
9:66969b9016ad | 470 | * @brief This function returns the distance measured by the sensor in mm |
Charles MacNeill |
9:66969b9016ad | 471 | */ |
Charles MacNeill |
10:3687b5e79f98 | 472 | VL53L1CB_ERROR VL53L1CB_GetDistance(uint16_t *distance); |
Charles MacNeill |
9:66969b9016ad | 473 | |
Charles MacNeill |
9:66969b9016ad | 474 | |
Charles MacNeill |
9:66969b9016ad | 475 | |
Charles MacNeill |
9:66969b9016ad | 476 | |
Charles MacNeill |
9:66969b9016ad | 477 | /**************************************************************************/ |
Charles MacNeill |
10:3687b5e79f98 | 478 | VL53L1CB_ERROR VL53L1CB_WaitDeviceBooted(VL53L1_DEV Dev); |
Charles MacNeill |
9:66969b9016ad | 479 | |
Charles MacNeill |
9:66969b9016ad | 480 | |
Charles MacNeill |
10:3687b5e79f98 | 481 | VL53L1CB_ERROR VL53L1CB_GetCalibrationData(VL53L1_CalibrationData_t *pCalibrationData); |
Charles MacNeill |
9:66969b9016ad | 482 | |
Charles MacNeill |
9:66969b9016ad | 483 | |
Charles MacNeill |
9:66969b9016ad | 484 | |
Charles MacNeill |
10:3687b5e79f98 | 485 | VL53L1_GPIO_Interrupt_Mode ConvertModeToLLD(VL53L1CB_ERROR *pStatus, |
Charles MacNeill |
9:66969b9016ad | 486 | VL53L1_ThresholdMode CrossMode); |
Charles MacNeill |
9:66969b9016ad | 487 | |
Charles MacNeill |
10:3687b5e79f98 | 488 | VL53L1CB_ERROR VL53L1CB_GetVersion(VL53L1_Version_t *pVersion); |
Charles MacNeill |
9:66969b9016ad | 489 | |
Charles MacNeill |
10:3687b5e79f98 | 490 | VL53L1CB_ERROR VL53L1CB_GetProductRevision( |
Charles MacNeill |
9:66969b9016ad | 491 | uint8_t *pProductRevisionMajor, uint8_t *pProductRevisionMinor); |
Charles MacNeill |
9:66969b9016ad | 492 | |
Charles MacNeill |
9:66969b9016ad | 493 | |
Charles MacNeill |
10:3687b5e79f98 | 494 | VL53L1CB_ERROR VL53L1CB_GetDeviceInfo( |
Charles MacNeill |
9:66969b9016ad | 495 | VL53L1_DeviceInfo_t *pVL53L1_DeviceInfo); |
Charles MacNeill |
9:66969b9016ad | 496 | |
Charles MacNeill |
10:3687b5e79f98 | 497 | VL53L1CB_ERROR VL53L1CB_GetUID( uint64_t *pUid); |
Charles MacNeill |
9:66969b9016ad | 498 | |
Charles MacNeill |
10:3687b5e79f98 | 499 | VL53L1CB_ERROR VL53L1CB_GetRangeStatusString(uint8_t RangeStatus, |
Charles MacNeill |
9:66969b9016ad | 500 | char *pRangeStatusString); |
Charles MacNeill |
9:66969b9016ad | 501 | |
Charles MacNeill |
9:66969b9016ad | 502 | |
Charles MacNeill |
10:3687b5e79f98 | 503 | VL53L1CB_ERROR VL53L1CB_GetPalErrorString(VL53L1CB_ERROR PalErrorCode, |
Charles MacNeill |
9:66969b9016ad | 504 | char *pPalErrorString); |
Charles MacNeill |
9:66969b9016ad | 505 | |
Charles MacNeill |
9:66969b9016ad | 506 | |
Charles MacNeill |
10:3687b5e79f98 | 507 | VL53L1CB_ERROR VL53L1CB_GetPalStateString(VL53L1_State PalStateCode, |
Charles MacNeill |
9:66969b9016ad | 508 | char *pPalStateString); |
Charles MacNeill |
9:66969b9016ad | 509 | |
Charles MacNeill |
9:66969b9016ad | 510 | |
Charles MacNeill |
10:3687b5e79f98 | 511 | VL53L1CB_ERROR VL53L1CB_GetPalState(VL53L1_DEV Dev, VL53L1_State *pPalState); |
Charles MacNeill |
9:66969b9016ad | 512 | |
Charles MacNeill |
10:3687b5e79f98 | 513 | VL53L1CB_ERROR VL53L1CB_DataInit(); |
Charles MacNeill |
9:66969b9016ad | 514 | |
Charles MacNeill |
10:3687b5e79f98 | 515 | VL53L1CB_ERROR VL53L1CB_StaticInit(); |
Charles MacNeill |
9:66969b9016ad | 516 | |
charlesmn | 16:27131f13570d | 517 | VL53L1CB_ERROR VL53L1CB_ClearInterruptAndStartMeasurement(); |
Charles MacNeill |
9:66969b9016ad | 518 | |
Charles MacNeill |
10:3687b5e79f98 | 519 | VL53L1CB_ERROR VL53L1CB_GetRangingMeasurementData( |
Charles MacNeill |
9:66969b9016ad | 520 | VL53L1_RangingMeasurementData_t *pRangingMeasurementData); |
Charles MacNeill |
9:66969b9016ad | 521 | |
Charles MacNeill |
10:3687b5e79f98 | 522 | VL53L1CB_ERROR VL53L1CB_GetMultiRangingData( |
Charles MacNeill |
9:66969b9016ad | 523 | VL53L1_MultiRangingData_t *pMultiRangingData); |
Charles MacNeill |
9:66969b9016ad | 524 | |
Charles MacNeill |
10:3687b5e79f98 | 525 | VL53L1CB_ERROR VL53L1CB_GetAdditionalData( |
Charles MacNeill |
9:66969b9016ad | 526 | VL53L1_AdditionalData_t *pAdditionalData); |
Charles MacNeill |
9:66969b9016ad | 527 | |
Charles MacNeill |
10:3687b5e79f98 | 528 | VL53L1CB_ERROR VL53L1CB_SetTuningParameter( |
Charles MacNeill |
9:66969b9016ad | 529 | uint16_t TuningParameterId, int32_t TuningParameterValue); |
Charles MacNeill |
9:66969b9016ad | 530 | |
Charles MacNeill |
10:3687b5e79f98 | 531 | VL53L1CB_ERROR VL53L1CB_GetTuningParameter( |
Charles MacNeill |
9:66969b9016ad | 532 | uint16_t TuningParameterId, int32_t *pTuningParameterValue); |
Charles MacNeill |
9:66969b9016ad | 533 | |
Charles MacNeill |
10:3687b5e79f98 | 534 | VL53L1CB_ERROR VL53L1CB_SetXTalkCompensationEnable( |
Charles MacNeill |
9:66969b9016ad | 535 | uint8_t XTalkCompensationEnable); |
Charles MacNeill |
9:66969b9016ad | 536 | |
Charles MacNeill |
9:66969b9016ad | 537 | |
Charles MacNeill |
10:3687b5e79f98 | 538 | VL53L1CB_ERROR VL53L1CB_GetXTalkCompensationEnable( |
Charles MacNeill |
9:66969b9016ad | 539 | uint8_t *pXTalkCompensationEnable); |
Charles MacNeill |
9:66969b9016ad | 540 | |
Charles MacNeill |
10:3687b5e79f98 | 541 | VL53L1CB_ERROR VL53L1CB_PerformXTalkCalibration( |
Charles MacNeill |
9:66969b9016ad | 542 | uint8_t CalibrationOption); |
Charles MacNeill |
9:66969b9016ad | 543 | |
Charles MacNeill |
10:3687b5e79f98 | 544 | VL53L1CB_ERROR VL53L1CB_SetOffsetCalibrationMode( |
Charles MacNeill |
9:66969b9016ad | 545 | VL53L1_OffsetCalibrationModes OffsetCalibrationMode); |
Charles MacNeill |
9:66969b9016ad | 546 | |
Charles MacNeill |
9:66969b9016ad | 547 | |
Charles MacNeill |
10:3687b5e79f98 | 548 | VL53L1CB_ERROR VL53L1CB_SetOffsetCorrectionMode( |
Charles MacNeill |
9:66969b9016ad | 549 | VL53L1_OffsetCorrectionModes OffsetCorrectionMode); |
Charles MacNeill |
9:66969b9016ad | 550 | |
Charles MacNeill |
10:3687b5e79f98 | 551 | VL53L1CB_ERROR VL53L1CB_PerformOffsetCalibration( |
Charles MacNeill |
9:66969b9016ad | 552 | int32_t CalDistanceMilliMeter, FixPoint1616_t CalReflectancePercent); |
Charles MacNeill |
9:66969b9016ad | 553 | |
Charles MacNeill |
10:3687b5e79f98 | 554 | VL53L1CB_ERROR VL53L1CB_PerformOffsetSimpleCalibration( |
Charles MacNeill |
9:66969b9016ad | 555 | int32_t CalDistanceMilliMeter); |
Charles MacNeill |
9:66969b9016ad | 556 | |
Charles MacNeill |
10:3687b5e79f98 | 557 | VL53L1CB_ERROR VL53L1CB_PerformOffsetZeroDistanceCalibration(); |
Charles MacNeill |
9:66969b9016ad | 558 | |
Charles MacNeill |
10:3687b5e79f98 | 559 | VL53L1CB_ERROR VL53L1CB_SetCalibrationData( |
Charles MacNeill |
9:66969b9016ad | 560 | VL53L1_CalibrationData_t *pCalibrationData); |
Charles MacNeill |
9:66969b9016ad | 561 | |
Charles MacNeill |
10:3687b5e79f98 | 562 | VL53L1CB_ERROR VL53L1CB_SetZoneCalibrationData( |
Charles MacNeill |
9:66969b9016ad | 563 | VL53L1_ZoneCalibrationData_t *pZoneCalibrationData); |
Charles MacNeill |
9:66969b9016ad | 564 | |
Charles MacNeill |
10:3687b5e79f98 | 565 | VL53L1CB_ERROR VL53L1CB_GetZoneCalibrationData( |
Charles MacNeill |
9:66969b9016ad | 566 | VL53L1_ZoneCalibrationData_t *pZoneCalibrationData); |
Charles MacNeill |
9:66969b9016ad | 567 | |
Charles MacNeill |
10:3687b5e79f98 | 568 | VL53L1CB_ERROR VL53L1CB_GetOpticalCenter( |
Charles MacNeill |
9:66969b9016ad | 569 | FixPoint1616_t *pOpticalCenterX, |
Charles MacNeill |
9:66969b9016ad | 570 | FixPoint1616_t *pOpticalCenterY); |
Charles MacNeill |
9:66969b9016ad | 571 | |
Charles MacNeill |
10:3687b5e79f98 | 572 | VL53L1CB_ERROR VL53L1CB_SetThresholdConfig(VL53L1_DetectionConfig_t *pConfig); |
Charles MacNeill |
9:66969b9016ad | 573 | |
Charles MacNeill |
9:66969b9016ad | 574 | |
Charles MacNeill |
10:3687b5e79f98 | 575 | VL53L1CB_ERROR VL53L1CB_GetLimitCheckStatus( uint16_t LimitCheckId, |
Charles MacNeill |
9:66969b9016ad | 576 | uint8_t *pLimitCheckStatus); |
Charles MacNeill |
9:66969b9016ad | 577 | |
Charles MacNeill |
9:66969b9016ad | 578 | |
Charles MacNeill |
10:3687b5e79f98 | 579 | VL53L1CB_ERROR VL53L1CB_SetLimitCheckEnable( uint16_t LimitCheckId, |
Charles MacNeill |
9:66969b9016ad | 580 | uint8_t LimitCheckEnable); |
Charles MacNeill |
9:66969b9016ad | 581 | |
Charles MacNeill |
10:3687b5e79f98 | 582 | VL53L1CB_ERROR VL53L1CB_GetLimitCheckEnable(uint16_t LimitCheckId, |
Charles MacNeill |
9:66969b9016ad | 583 | uint8_t *pLimitCheckEnable); |
Charles MacNeill |
9:66969b9016ad | 584 | |
Charles MacNeill |
10:3687b5e79f98 | 585 | VL53L1CB_ERROR VL53L1CB_GetThresholdConfig(VL53L1_DetectionConfig_t *pConfig); |
Charles MacNeill |
9:66969b9016ad | 586 | |
Charles MacNeill |
9:66969b9016ad | 587 | |
Charles MacNeill |
10:3687b5e79f98 | 588 | VL53L1CB_ERROR VL53L1CB_PerformOffsetPerVcselCalibration(int32_t CalDistanceMilliMeter); |
Charles MacNeill |
9:66969b9016ad | 589 | |
Charles MacNeill |
10:3687b5e79f98 | 590 | VL53L1CB_ERROR VL53L1CB_GetNumberOfLimitCheck(uint16_t *pNumberOfLimitCheck); |
Charles MacNeill |
9:66969b9016ad | 591 | |
Charles MacNeill |
10:3687b5e79f98 | 592 | VL53L1CB_ERROR VL53L1CB_GetLimitCheckInfo(uint16_t LimitCheckId, |
Charles MacNeill |
9:66969b9016ad | 593 | char *pLimitCheckString); |
Charles MacNeill |
9:66969b9016ad | 594 | |
Charles MacNeill |
10:3687b5e79f98 | 595 | VL53L1CB_ERROR VL53L1CB_SetPresetMode(VL53L1_PresetModes PresetMode); |
Charles MacNeill |
9:66969b9016ad | 596 | |
Charles MacNeill |
10:3687b5e79f98 | 597 | VL53L1CB_ERROR VL53L1CB_GetPresetMode( VL53L1_PresetModes *pPresetMode); |
Charles MacNeill |
9:66969b9016ad | 598 | |
Charles MacNeill |
10:3687b5e79f98 | 599 | VL53L1CB_ERROR VL53L1CB_SetDistanceMode( VL53L1_DistanceModes DistanceMode); |
Charles MacNeill |
9:66969b9016ad | 600 | |
Charles MacNeill |
10:3687b5e79f98 | 601 | VL53L1CB_ERROR VL53L1CB_GetDistanceMode(VL53L1_DistanceModes *pDistanceMode); |
Charles MacNeill |
9:66969b9016ad | 602 | |
Charles MacNeill |
10:3687b5e79f98 | 603 | VL53L1CB_ERROR VL53L1CB_SetOutputMode(VL53L1_OutputModes OutputMode); |
Charles MacNeill |
9:66969b9016ad | 604 | |
Charles MacNeill |
10:3687b5e79f98 | 605 | VL53L1CB_ERROR VL53L1CB_GetOutputMode(VL53L1_OutputModes *pOutputMode); |
Charles MacNeill |
9:66969b9016ad | 606 | |
Charles MacNeill |
10:3687b5e79f98 | 607 | VL53L1CB_ERROR VL53L1CB_SetMeasurementTimingBudgetMicroSeconds(uint32_t MeasurementTimingBudgetMicroSeconds); |
Charles MacNeill |
9:66969b9016ad | 608 | |
Charles MacNeill |
10:3687b5e79f98 | 609 | VL53L1CB_ERROR VL53L1CB_SetInterMeasurementPeriodMilliSeconds(uint32_t InterMeasurementPeriodMilliSeconds); |
Charles MacNeill |
9:66969b9016ad | 610 | |
Charles MacNeill |
9:66969b9016ad | 611 | |
Charles MacNeill |
10:3687b5e79f98 | 612 | VL53L1CB_ERROR VL53L1CB_GetInterMeasurementPeriodMilliSeconds( |
Charles MacNeill |
9:66969b9016ad | 613 | uint32_t *pInterMeasurementPeriodMilliSeconds); |
Charles MacNeill |
9:66969b9016ad | 614 | |
Charles MacNeill |
9:66969b9016ad | 615 | |
Charles MacNeill |
10:3687b5e79f98 | 616 | VL53L1CB_ERROR VL53L1CB_SetDmaxReflectance( FixPoint1616_t DmaxReflectance); |
Charles MacNeill |
9:66969b9016ad | 617 | |
Charles MacNeill |
10:3687b5e79f98 | 618 | VL53L1CB_ERROR VL53L1CB_GetDmaxReflectance(FixPoint1616_t *pDmaxReflectance); |
Charles MacNeill |
9:66969b9016ad | 619 | |
Charles MacNeill |
9:66969b9016ad | 620 | |
Charles MacNeill |
10:3687b5e79f98 | 621 | VL53L1CB_ERROR VL53L1CB_GetDmaxMode( VL53L1_DeviceDmaxModes *pDmaxMode); |
Charles MacNeill |
9:66969b9016ad | 622 | |
Charles MacNeill |
10:3687b5e79f98 | 623 | VL53L1CB_ERROR VL53L1CB_GetMeasurementTimingBudgetMicroSeconds( |
Charles MacNeill |
9:66969b9016ad | 624 | uint32_t *pMeasurementTimingBudgetMicroSeconds); |
Charles MacNeill |
9:66969b9016ad | 625 | |
Charles MacNeill |
10:3687b5e79f98 | 626 | VL53L1CB_ERROR VL53L1CB_SetDmaxMode(VL53L1_DeviceDmaxModes DmaxMode); |
Charles MacNeill |
9:66969b9016ad | 627 | |
Charles MacNeill |
10:3687b5e79f98 | 628 | VL53L1CB_ERROR VL53L1CB_SetLimitCheckValue( uint16_t LimitCheckId, |
Charles MacNeill |
9:66969b9016ad | 629 | FixPoint1616_t LimitCheckValue); |
Charles MacNeill |
9:66969b9016ad | 630 | |
Charles MacNeill |
10:3687b5e79f98 | 631 | VL53L1CB_ERROR VL53L1CB_GetLimitCheckValue(uint16_t LimitCheckId, |
Charles MacNeill |
9:66969b9016ad | 632 | FixPoint1616_t *pLimitCheckValue); |
Charles MacNeill |
9:66969b9016ad | 633 | |
Charles MacNeill |
10:3687b5e79f98 | 634 | VL53L1CB_ERROR VL53L1CB_GetLimitCheckCurrent( uint16_t LimitCheckId, |
Charles MacNeill |
9:66969b9016ad | 635 | FixPoint1616_t *pLimitCheckCurrent); |
Charles MacNeill |
9:66969b9016ad | 636 | |
Charles MacNeill |
10:3687b5e79f98 | 637 | VL53L1CB_ERROR VL53L1CB_GetMaxNumberOfROI( uint8_t *pMaxNumberOfROI); |
Charles MacNeill |
9:66969b9016ad | 638 | |
Charles MacNeill |
10:3687b5e79f98 | 639 | VL53L1CB_ERROR VL53L1CB_SetROI(VL53L1_RoiConfig_t *pRoiConfig); |
Charles MacNeill |
9:66969b9016ad | 640 | |
Charles MacNeill |
14:f06785b2a964 | 641 | VL53L1CB_ERROR VL53L1CB_GetROI(VL53L1_RoiConfig_t *pRoiConfig); |
Charles MacNeill |
9:66969b9016ad | 642 | |
Charles MacNeill |
10:3687b5e79f98 | 643 | VL53L1CB_ERROR VL53L1CB_GetNumberOfSequenceSteps(uint8_t *pNumberOfSequenceSteps); |
Charles MacNeill |
9:66969b9016ad | 644 | |
Charles MacNeill |
10:3687b5e79f98 | 645 | VL53L1CB_ERROR VL53L1CB_GetSequenceStepsInfo(VL53L1_SequenceStepId SequenceStepId, |
Charles MacNeill |
9:66969b9016ad | 646 | char *pSequenceStepsString); |
Charles MacNeill |
9:66969b9016ad | 647 | |
Charles MacNeill |
9:66969b9016ad | 648 | |
Charles MacNeill |
10:3687b5e79f98 | 649 | VL53L1CB_ERROR VL53L1CB_SetSequenceStepEnable(VL53L1_SequenceStepId SequenceStepId, uint8_t SequenceStepEnabled); |
Charles MacNeill |
9:66969b9016ad | 650 | |
Charles MacNeill |
9:66969b9016ad | 651 | |
Charles MacNeill |
10:3687b5e79f98 | 652 | VL53L1CB_ERROR VL53L1CB_GetSequenceStepEnable(VL53L1_SequenceStepId SequenceStepId, uint8_t *pSequenceStepEnabled); |
Charles MacNeill |
9:66969b9016ad | 653 | |
Charles MacNeill |
9:66969b9016ad | 654 | |
Charles MacNeill |
10:3687b5e79f98 | 655 | VL53L1CB_ERROR VL53L1CB_StartMeasurement(); |
Charles MacNeill |
9:66969b9016ad | 656 | |
Charles MacNeill |
10:3687b5e79f98 | 657 | VL53L1CB_ERROR VL53L1CB_StopMeasurement(); |
Charles MacNeill |
9:66969b9016ad | 658 | |
Charles MacNeill |
9:66969b9016ad | 659 | |
Charles MacNeill |
10:3687b5e79f98 | 660 | VL53L1CB_ERROR VL53L1CB_GetMeasurementDataReady(uint8_t *pMeasurementDataReady); |
Charles MacNeill |
9:66969b9016ad | 661 | |
Charles MacNeill |
10:3687b5e79f98 | 662 | VL53L1CB_ERROR VL53L1CB_WaitMeasurementDataReady(); |
Charles MacNeill |
9:66969b9016ad | 663 | |
Charles MacNeill |
10:3687b5e79f98 | 664 | VL53L1CB_ERROR VL53L1CB_SmudgeCorrectionEnable(VL53L1_SmudgeCorrectionModes Mode); |
Charles MacNeill |
9:66969b9016ad | 665 | /***************************************************************************/ |
Charles MacNeill |
9:66969b9016ad | 666 | |
Charles MacNeill |
9:66969b9016ad | 667 | |
Charles MacNeill |
9:66969b9016ad | 668 | /* Write and read functions from I2C */ |
Charles MacNeill |
9:66969b9016ad | 669 | |
Charles MacNeill |
14:f06785b2a964 | 670 | VL53L1CB_ERROR VL53L1_WrByte(VL53L1_DEV dev, uint16_t index, uint8_t data); // DON'T CHANGE NAME, SATELLITES STOP WORKING |
Charles MacNeill |
14:f06785b2a964 | 671 | VL53L1CB_ERROR VL53L1_WrWord(VL53L1_DEV dev, uint16_t index, uint16_t data); // DON'T CHANGE NAME, SATELLITES STOP WORKING |
Charles MacNeill |
14:f06785b2a964 | 672 | VL53L1CB_ERROR VL53L1_WrDWord(VL53L1_DEV dev, uint16_t index, uint32_t data); // DON'T CHANGE NAME, SATELLITES STOP WORKING |
Charles MacNeill |
14:f06785b2a964 | 673 | VL53L1CB_ERROR VL53L1_RdByte(VL53L1_DEV dev, uint16_t index, uint8_t *data); // DON'T CHANGE NAME, SATELLITES STOP WORKING |
Charles MacNeill |
14:f06785b2a964 | 674 | VL53L1CB_ERROR VL53L1_RdWord(VL53L1_DEV dev, uint16_t index, uint16_t *data); // DON'T CHANGE NAME, SATELLITES STOP WORKING |
Charles MacNeill |
14:f06785b2a964 | 675 | VL53L1CB_ERROR VL53L1_RdDWord(VL53L1_DEV dev, uint16_t index, uint32_t *data);// DON'T CHANGE NAME, SATELLITES STOP WORKING |
Charles MacNeill |
14:f06785b2a964 | 676 | 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 | 677 | |
Charles MacNeill |
10:3687b5e79f98 | 678 | VL53L1CB_ERROR VL53L1CB_WriteMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count); |
Charles MacNeill |
10:3687b5e79f98 | 679 | VL53L1CB_ERROR VL53L1CB_ReadMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count); |
Charles MacNeill |
9:66969b9016ad | 680 | |
Charles MacNeill |
10:3687b5e79f98 | 681 | VL53L1CB_ERROR VL53L1CB_I2CWrite(uint8_t dev, uint16_t index, uint8_t *data, uint16_t number_of_bytes); |
Charles MacNeill |
10:3687b5e79f98 | 682 | VL53L1CB_ERROR VL53L1CB_I2CRead(uint8_t dev, uint16_t index, uint8_t *data, uint16_t number_of_bytes); |
Charles MacNeill |
10:3687b5e79f98 | 683 | VL53L1CB_ERROR VL53L1CB_GetTickCount(uint32_t *ptick_count_ms); |
Charles MacNeill |
10:3687b5e79f98 | 684 | VL53L1CB_ERROR VL53L1CB_WaitUs(VL53L1_Dev_t *pdev, int32_t wait_us); |
Charles MacNeill |
10:3687b5e79f98 | 685 | VL53L1CB_ERROR VL53L1CB_WaitMs(VL53L1_Dev_t *pdev, int32_t wait_ms); |
Charles MacNeill |
9:66969b9016ad | 686 | |
Charles MacNeill |
10:3687b5e79f98 | 687 | 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 | 688 | VL53L1CB_ERROR VL53L1CB_SetDeviceAddress(VL53L1_DEV Dev, uint8_t DeviceAddress); |
Charles MacNeill |
9:66969b9016ad | 689 | |
Charles MacNeill |
9:66969b9016ad | 690 | // from vl53l1_api_debug.c |
Charles MacNeill |
9:66969b9016ad | 691 | |
Charles MacNeill |
10:3687b5e79f98 | 692 | VL53L1CB_ERROR VL53L1CB_get_additional_data( |
Charles MacNeill |
9:66969b9016ad | 693 | VL53L1_DEV Dev, |
Charles MacNeill |
9:66969b9016ad | 694 | VL53L1_additional_data_t *pdata); |
Charles MacNeill |
9:66969b9016ad | 695 | |
Charles MacNeill |
9:66969b9016ad | 696 | |
Charles MacNeill |
9:66969b9016ad | 697 | protected: |
Charles MacNeill |
9:66969b9016ad | 698 | |
Charles MacNeill |
9:66969b9016ad | 699 | /* IO Device */ |
Charles MacNeill |
9:66969b9016ad | 700 | ToF_DevI2C *dev_i2c; |
Charles MacNeill |
9:66969b9016ad | 701 | |
Charles MacNeill |
9:66969b9016ad | 702 | /* Digital out pin */ |
Charles MacNeill |
9:66969b9016ad | 703 | DigitalOut *_gpio0; |
Charles MacNeill |
9:66969b9016ad | 704 | /* GPIO expander */ |
Charles MacNeill |
9:66969b9016ad | 705 | Stmpe1600DigiOut *_expgpio0; |
Charles MacNeill |
9:66969b9016ad | 706 | /* Measure detection IRQ */ |
Charles MacNeill |
9:66969b9016ad | 707 | InterruptIn *_gpio1Int; |
Charles MacNeill |
9:66969b9016ad | 708 | |
Charles MacNeill |
9:66969b9016ad | 709 | ///* Digital out pin */ |
Charles MacNeill |
9:66969b9016ad | 710 | /* Device data */ |
Charles MacNeill |
9:66969b9016ad | 711 | VL53L1_Dev_t MyDevice; |
Charles MacNeill |
9:66969b9016ad | 712 | VL53L1_DEV Device; |
Charles MacNeill |
9:66969b9016ad | 713 | }; |
Charles MacNeill |
9:66969b9016ad | 714 | |
Charles MacNeill |
9:66969b9016ad | 715 | |
Charles MacNeill |
9:66969b9016ad | 716 | #endif /* _VL53L1X_CLASS_H_ */ |