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