Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
vl53l1x_class.h
00001 /******************************************************************************* 00002 * @file vl53l1x_class.h 00003 * @author JS 00004 * @version V0.0.1 00005 * @date 15-January-2019 00006 * @brief Header file for VL53L1 sensor component 00007 ****************************************************************************** 00008 Copyright © 2019, STMicroelectronics International N.V. 00009 All rights reserved. 00010 Redistribution and use in source and binary forms, with or without 00011 modification, are permitted provided that the following conditions are met: 00012 * Redistributions of source code must retain the above copyright 00013 notice, this list of conditions and the following disclaimer. 00014 * Redistributions in binary form must reproduce the above copyright 00015 notice, this list of conditions and the following disclaimer in the 00016 documentation and/or other materials provided with the distribution. 00017 * Neither the name of STMicroelectronics nor the 00018 names of its contributors may be used to endorse or promote products 00019 derived from this software without specific prior written permission. 00020 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00021 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00022 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND 00023 NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED. 00024 IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY 00025 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00026 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00027 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00028 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00029 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 *****************************************************************************/ 00032 00033 #ifndef __VL53L1X_CLASS_H 00034 #define __VL53L1X_CLASS_H 00035 00036 00037 #ifdef _MSC_VER 00038 # ifdef VL53L1X_API_EXPORTS 00039 # define VL53L1X_API __declspec(dllexport) 00040 # else 00041 # define VL53L1X_API 00042 # endif 00043 #else 00044 # define VL53L1X_API 00045 #endif 00046 00047 00048 /* Includes ------------------------------------------------------------------*/ 00049 #include "mbed.h" 00050 #include "PinNames.h" 00051 #include "RangeSensor.h" 00052 #include "vl53l1x_error_codes.h" 00053 //#include "DevI2C.h" 00054 #include "vl53L1x_I2c.h" 00055 #include "Stmpe1600.h" 00056 00057 00058 #define VL53L1X_IMPLEMENTATION_VER_MAJOR 1 00059 #define VL53L1X_IMPLEMENTATION_VER_MINOR 0 00060 #define VL53L1X_IMPLEMENTATION_VER_SUB 1 00061 #define VL53L1X_IMPLEMENTATION_VER_REVISION 0000 00062 00063 typedef int8_t VL53L1X_ERROR; 00064 00065 //#define SOFT_RESET 0x0000 00066 #define VL53L1_I2C_SLAVE__DEVICE_ADDRESS 0x0001 00067 #define VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND 0x0008 00068 #define ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS 0x0016 00069 #define ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS 0x0018 00070 #define ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS 0x001A 00071 #define ALGO__PART_TO_PART_RANGE_OFFSET_MM 0x001E 00072 #define MM_CONFIG__INNER_OFFSET_MM 0x0020 00073 #define MM_CONFIG__OUTER_OFFSET_MM 0x0022 00074 #define GPIO_HV_MUX__CTRL 0x0030 00075 #define GPIO__TIO_HV_STATUS 0x0031 00076 #define SYSTEM__INTERRUPT_CONFIG_GPIO 0x0046 00077 #define PHASECAL_CONFIG__TIMEOUT_MACROP 0x004B 00078 #define RANGE_CONFIG__TIMEOUT_MACROP_A_HI 0x005E 00079 #define RANGE_CONFIG__VCSEL_PERIOD_A 0x0060 00080 #define RANGE_CONFIG__VCSEL_PERIOD_B 0x0063 00081 #define RANGE_CONFIG__TIMEOUT_MACROP_B_HI 0x0061 00082 #define RANGE_CONFIG__TIMEOUT_MACROP_B_LO 0x0062 00083 #define RANGE_CONFIG__SIGMA_THRESH 0x0064 00084 #define RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS 0x0066 00085 #define RANGE_CONFIG__VALID_PHASE_HIGH 0x0069 00086 #define VL53L1_SYSTEM__INTERMEASUREMENT_PERIOD 0x006C 00087 #define SYSTEM__THRESH_HIGH 0x0072 00088 #define SYSTEM__THRESH_LOW 0x0074 00089 #define SD_CONFIG__WOI_SD0 0x0078 00090 #define SD_CONFIG__INITIAL_PHASE_SD0 0x007A 00091 #define ROI_CONFIG__USER_ROI_CENTRE_SPAD 0x007F 00092 #define ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE 0x0080 00093 #define SYSTEM__SEQUENCE_CONFIG 0x0081 00094 #define VL53L1_SYSTEM__GROUPED_PARAMETER_HOLD 0x0082 00095 #define SYSTEM__INTERRUPT_CLEAR 0x0086 00096 #define SYSTEM__MODE_START 0x0087 00097 #define VL53L1_RESULT__RANGE_STATUS 0x0089 00098 #define VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0 0x008C 00099 #define RESULT__AMBIENT_COUNT_RATE_MCPS_SD 0x0090 00100 #define VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 0x0096 00101 #define VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0 0x0098 00102 #define VL53L1_RESULT__OSC_CALIBRATE_VAL 0x00DE 00103 #define VL53L1_FIRMWARE__SYSTEM_STATUS 0x00E5 00104 #define VL53L1_IDENTIFICATION__MODEL_ID 0x010F 00105 #define VL53L1_ROI_CONFIG__MODE_ROI_CENTRE_SPAD 0x013E 00106 00107 00108 #define VL53L1X_DEFAULT_DEVICE_ADDRESS 0x52 00109 00110 #define VL53L1X_REG_IDENTIFICATION_MODEL_ID 0x010F 00111 /**************************************** 00112 * PRIVATE define do not edit 00113 ****************************************/ 00114 00115 /** 00116 * @brief defines SW Version 00117 */ 00118 typedef struct { 00119 uint8_t major ; /*!< major number */ 00120 uint8_t minor ; /*!< minor number */ 00121 uint8_t build ; /*!< build number */ 00122 uint32_t revision ; /*!< revision number */ 00123 } VL53L1X_Version_t; 00124 00125 00126 typedef struct { 00127 00128 uint8_t I2cDevAddr; 00129 00130 } VL53L1_Dev_t; 00131 00132 typedef VL53L1_Dev_t *VL53L1_DEV; 00133 00134 00135 /* Classes -------------------------------------------------------------------*/ 00136 /** Class representing a VL53L1 sensor component 00137 */ 00138 class VL53L1X : public RangeSensor 00139 { 00140 public: 00141 /** Constructor 00142 * @param[in] &i2c device I2C to be used for communication 00143 * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT 00144 * @param[in] DevAddr device address, 0x52 by default 00145 */ 00146 VL53L1X(vl53L1X_DevI2C *i2c, DigitalOut *pin, PinName pin_gpio1, uint8_t dev_addr = VL53L1X_DEFAULT_DEVICE_ADDRESS) 00147 : RangeSensor(), dev_i2c(i2c), _gpio0(pin) 00148 { 00149 MyDevice.I2cDevAddr=dev_addr; 00150 Device = &MyDevice; 00151 00152 _expgpio0 = NULL; 00153 if (pin_gpio1 != NC) { 00154 _gpio1Int = new InterruptIn(pin_gpio1); 00155 } else { 00156 _gpio1Int = NULL; 00157 } 00158 } 00159 00160 /** Constructor 2 (STMPE1600DigiOut) 00161 * @param[in] i2c device I2C to be used for communication 00162 * @param[in] &pin Gpio Expander STMPE1600DigiOut pin to be used as component GPIO_0 CE 00163 * @param[in] pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT 00164 * @param[in] device address, 0x29 by default 00165 */ 00166 VL53L1X(vl53L1X_DevI2C *i2c, Stmpe1600DigiOut *pin, PinName pin_gpio1, 00167 uint8_t dev_addr = VL53L1X_DEFAULT_DEVICE_ADDRESS) 00168 : dev_i2c(i2c), _expgpio0(pin) 00169 { 00170 MyDevice.I2cDevAddr=dev_addr; 00171 Device = &MyDevice; 00172 00173 _gpio0 = NULL; 00174 if (pin_gpio1 != NC) { 00175 _gpio1Int = new InterruptIn(pin_gpio1); 00176 } else { 00177 _gpio1Int = NULL; 00178 } 00179 } 00180 00181 /** Destructor 00182 */ 00183 virtual ~VL53L1X() 00184 { 00185 if (_gpio1Int != NULL) { 00186 delete _gpio1Int; 00187 } 00188 } 00189 00190 00191 00192 VL53L1_DEV getDevicePtr() { return Device; } 00193 00194 00195 /* warning: VL53L1 class inherits from GenericSensor, RangeSensor and LightSensor, that haven`t a destructor. 00196 The warning should request to introduce a virtual destructor to make sure to delete the object */ 00197 00198 /*** Interface Methods ***/ 00199 /*** High level API ***/ 00200 /** 00201 * @brief PowerOn the sensor 00202 * @return void 00203 */ 00204 /* turns on the sensor */ 00205 virtual void VL53L1_On(void) 00206 { 00207 printf("VL53L1_On\r\n"); 00208 if (_gpio0) { 00209 *_gpio0 = 1; 00210 } else { 00211 if (_expgpio0) { 00212 *_expgpio0 = 1; 00213 } 00214 } 00215 wait_ms(10); 00216 } 00217 00218 /** 00219 * @brief PowerOff the sensor 00220 * @return void 00221 */ 00222 /* turns off the sensor */ 00223 virtual void VL53L1_Off(void) 00224 { 00225 printf("VL53L1_Off\r\n"); 00226 if (_gpio0) { 00227 *_gpio0 = 0; 00228 } else { 00229 if (_expgpio0) { 00230 *_expgpio0 = 0; 00231 } 00232 } 00233 wait_ms(10); 00234 } 00235 00236 int is_present() 00237 { 00238 int status; 00239 uint8_t id = 0; 00240 00241 status = read_id(&id); 00242 if (status) { 00243 printf("Failed to read ID device. Device not present!\n\r"); 00244 } 00245 return status; 00246 } 00247 00248 /** 00249 * @brief Initialize the sensor with default values 00250 * @return 0 on Success 00251 */ 00252 00253 VL53L1X_ERROR InitSensor(uint8_t address){ 00254 VL53L1X_ERROR status = 0; 00255 uint8_t sensorState = 0; 00256 VL53L1_Off(); 00257 VL53L1_On(); 00258 status = VL53L1X_SetI2CAddress(address); 00259 00260 if(!status){ 00261 status = VL53L1X_SensorInit(); 00262 } 00263 00264 while(!status && !sensorState) { 00265 status = VL53L1X_BootState(&sensorState); 00266 wait_ms(2); 00267 } 00268 00269 return status; 00270 } 00271 00272 00273 00274 /** 00275 * 00276 * @brief One time device initialization 00277 * @param void 00278 * @return 0 on success, @a #CALIBRATION_WARNING if failed 00279 */ 00280 virtual int init(void *init) 00281 { 00282 return VL53L1X_SensorInit(); 00283 } 00284 00285 00286 /** 00287 * @brief Initialize the sensor with default values 00288 * @return "0" on success 00289 */ 00290 int init_sensor(uint8_t new_addr); 00291 00292 /* Read function of the ID device */ 00293 virtual int read_id(uint8_t *id){ 00294 int status = 0; 00295 uint16_t rl_id = 0; 00296 00297 uint8_t ExpanderData[2]; 00298 00299 ExpanderData[0] = 0; 00300 ExpanderData[1] = 0; 00301 rl_id = 0; 00302 dev_i2c->v53l1x_i2c_read(&ExpanderData[0], Device->I2cDevAddr, VL53L1X_REG_IDENTIFICATION_MODEL_ID, 2); 00303 00304 rl_id = (ExpanderData[0] << 8) + ExpanderData[1]; 00305 printf("Model ID is: %d (%X) \r\n",rl_id, rl_id); 00306 00307 uint8_t tmp = 0; 00308 ExpanderData[0] = VL53L1_FIRMWARE__SYSTEM_STATUS >> 8; 00309 ExpanderData[1] = VL53L1_FIRMWARE__SYSTEM_STATUS & 0x0FF; 00310 dev_i2c->v53l1x_i2c_read(&tmp, Device->I2cDevAddr, VL53L1_FIRMWARE__SYSTEM_STATUS, 1); 00311 00312 printf("Firmware system is: %d\r\n",tmp); 00313 00314 if (rl_id == 0xEACC) { 00315 printf("Device is present %d:\r\n", rl_id); 00316 return status; 00317 } 00318 return -1; 00319 } 00320 00321 00322 00323 /** 00324 * @brief Get ranging result and only that 00325 * @param pRange_mm Pointer to range distance 00326 * @return 0 on success 00327 */ 00328 virtual int get_distance(uint32_t *piData) 00329 { 00330 int status; 00331 uint16_t distance; 00332 status = VL53L1X_GetDistance(&distance); 00333 *piData = (uint32_t) distance; 00334 return status; 00335 } 00336 00337 00338 /* VL53L1X_api.h functions */ 00339 00340 00341 00342 /** 00343 * @brief This function returns the SW driver version 00344 */ 00345 VL53L1X_ERROR VL53L1X_GetSWVersion(VL53L1X_Version_t *pVersion); 00346 00347 /** 00348 * @brief This function sets the sensor I2C address used in case multiple devices application, default address 0x52 00349 */ 00350 VL53L1X_ERROR VL53L1X_SetI2CAddress(uint8_t new_address); 00351 00352 /** 00353 * @brief This function loads the 135 bytes default values to initialize the sensor. 00354 * @param dev Device address 00355 * @return 0:success, != 0:failed 00356 */ 00357 VL53L1X_ERROR VL53L1X_SensorInit(); 00358 00359 /** 00360 * @brief This function clears the interrupt, to be called after a ranging data reading 00361 * to arm the interrupt for the next data ready event. 00362 */ 00363 VL53L1X_ERROR VL53L1X_ClearInterrupt(); 00364 00365 /** 00366 * @brief This function programs the interrupt polarity\n 00367 * 1=active high (default), 0=active low 00368 */ 00369 VL53L1X_ERROR VL53L1X_SetInterruptPolarity(uint8_t IntPol); 00370 00371 /** 00372 * @brief This function returns the current interrupt polarity\n 00373 * 1=active high (default), 0=active low 00374 */ 00375 VL53L1X_ERROR VL53L1X_GetInterruptPolarity(uint8_t *pIntPol); 00376 00377 /** 00378 * @brief This function starts the ranging distance operation\n 00379 * 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 00380 * 1=active high (default), 0=active low, use SetInterruptPolarity() to change the interrupt polarity if required. 00381 */ 00382 VL53L1X_ERROR VL53L1X_StartRanging(); 00383 00384 /** 00385 * @brief This function stops the ranging. 00386 */ 00387 VL53L1X_ERROR VL53L1X_StopRanging(); 00388 00389 /** 00390 * @brief This function checks if the new ranging data is available by polling the dedicated register. 00391 * @param : isDataReady==0 -> not ready; isDataReady==1 -> ready 00392 */ 00393 VL53L1X_ERROR VL53L1X_CheckForDataReady(uint8_t *isDataReady); 00394 00395 /** 00396 * @brief This function programs the timing budget in ms. 00397 * Predefined values = 15, 20, 33, 50, 100(default), 200, 500. 00398 */ 00399 VL53L1X_ERROR VL53L1X_SetTimingBudgetInMs(uint16_t TimingBudgetInMs); 00400 00401 /** 00402 * @brief This function returns the current timing budget in ms. 00403 */ 00404 VL53L1X_ERROR VL53L1X_GetTimingBudgetInMs(uint16_t *pTimingBudgetInMs); 00405 00406 /** 00407 * @brief This function programs the distance mode (1=short, 2=long(default)). 00408 * Short mode max distance is limited to 1.3 m but better ambient immunity.\n 00409 * Long mode can range up to 4 m in the dark with 200 ms timing budget. 00410 */ 00411 VL53L1X_ERROR VL53L1X_SetDistanceMode(uint16_t DistanceMode); 00412 00413 /** 00414 * @brief This function returns the current distance mode (1=short, 2=long). 00415 */ 00416 VL53L1X_ERROR VL53L1X_GetDistanceMode(uint16_t *pDistanceMode); 00417 00418 /** 00419 * @brief This function programs the Intermeasurement period in ms\n 00420 * Intermeasurement period must be >/= timing budget. This condition is not checked by the API, 00421 * the customer has the duty to check the condition. Default = 100 ms 00422 */ 00423 VL53L1X_ERROR VL53L1X_SetInterMeasurementInMs(uint16_t InterMeasurementInMs); 00424 00425 /** 00426 * @brief This function returns the Intermeasurement period in ms. 00427 */ 00428 VL53L1X_ERROR VL53L1X_GetInterMeasurementInMs(uint16_t * pIM); 00429 00430 /** 00431 * @brief This function returns the boot state of the device (1:booted, 0:not booted) 00432 */ 00433 VL53L1X_ERROR VL53L1X_BootState(uint8_t *state); 00434 00435 /** 00436 * @brief This function returns the sensor id, sensor Id must be 0xEEAC 00437 */ 00438 VL53L1X_ERROR VL53L1X_GetSensorId(uint16_t *id); 00439 00440 /** 00441 * @brief This function returns the distance measured by the sensor in mm 00442 */ 00443 VL53L1X_ERROR VL53L1X_GetDistance(uint16_t *distance); 00444 00445 /** 00446 * @brief This function returns the returned signal per SPAD in kcps/SPAD. 00447 * With kcps stands for Kilo Count Per Second 00448 */ 00449 VL53L1X_ERROR VL53L1X_GetSignalPerSpad(uint16_t *signalPerSp); 00450 00451 /** 00452 * @brief This function returns the ambient per SPAD in kcps/SPAD 00453 */ 00454 VL53L1X_ERROR VL53L1X_GetAmbientPerSpad(uint16_t *amb); 00455 00456 /** 00457 * @brief This function returns the returned signal in kcps. 00458 */ 00459 VL53L1X_ERROR VL53L1X_GetSignalRate(uint16_t *signalRate); 00460 00461 /** 00462 * @brief This function returns the current number of enabled SPADs 00463 */ 00464 VL53L1X_ERROR VL53L1X_GetSpadNb(uint16_t *spNb); 00465 00466 /** 00467 * @brief This function returns the ambient rate in kcps 00468 */ 00469 VL53L1X_ERROR VL53L1X_GetAmbientRate(uint16_t *ambRate); 00470 00471 /** 00472 * @brief This function returns the ranging status error \n 00473 * (0:no error, 1:sigma failed, 2:signal failed, ..., 7:wrap-around) 00474 */ 00475 VL53L1X_ERROR VL53L1X_GetRangeStatus(uint8_t *rangeStatus); 00476 00477 /** 00478 * @brief This function programs the offset correction in mm 00479 * @param OffsetValue:the offset correction value to program in mm 00480 */ 00481 VL53L1X_ERROR VL53L1X_SetOffset(int16_t OffsetValue); 00482 00483 /** 00484 * @brief This function returns the programmed offset correction value in mm 00485 */ 00486 VL53L1X_ERROR VL53L1X_GetOffset(int16_t *Offset); 00487 00488 /** 00489 * @brief This function programs the xtalk correction value in cps (Count Per Second).\n 00490 * This is the number of photons reflected back from the cover glass in cps. 00491 */ 00492 VL53L1X_ERROR VL53L1X_SetXtalk(uint16_t XtalkValue); 00493 00494 /** 00495 * @brief This function returns the current programmed xtalk correction value in cps 00496 */ 00497 VL53L1X_ERROR VL53L1X_GetXtalk(uint16_t *Xtalk); 00498 00499 /** 00500 * @brief This function programs the threshold detection mode\n 00501 * Example:\n 00502 * VL53L1X_SetDistanceThreshold(dev,100,300,0,1): Below 100 \n 00503 * VL53L1X_SetDistanceThreshold(dev,100,300,1,1): Above 300 \n 00504 * VL53L1X_SetDistanceThreshold(dev,100,300,2,1): Out of window \n 00505 * VL53L1X_SetDistanceThreshold(dev,100,300,3,1): In window \n 00506 * @param dev : device address 00507 * @param ThreshLow(in mm) : the threshold under which one the device raises an interrupt if Window = 0 00508 * @param ThreshHigh(in mm) : the threshold above which one the device raises an interrupt if Window = 1 00509 * @param Window detection mode : 0=below, 1=above, 2=out, 3=in 00510 * @param IntOnNoTarget = 1 (No longer used - just use 1) 00511 */ 00512 VL53L1X_ERROR VL53L1X_SetDistanceThreshold(uint16_t ThreshLow, 00513 uint16_t ThreshHigh, uint8_t Window, 00514 uint8_t IntOnNoTarget); 00515 00516 /** 00517 * @brief This function returns the window detection mode (0=below; 1=above; 2=out; 3=in) 00518 */ 00519 VL53L1X_ERROR VL53L1X_GetDistanceThresholdWindow(uint16_t *window); 00520 00521 /** 00522 * @brief This function returns the low threshold in mm 00523 */ 00524 VL53L1X_ERROR VL53L1X_GetDistanceThresholdLow(uint16_t *low); 00525 00526 /** 00527 * @brief This function returns the high threshold in mm 00528 */ 00529 VL53L1X_ERROR VL53L1X_GetDistanceThresholdHigh(uint16_t *high); 00530 00531 /** 00532 * @brief This function programs the ROI (Region of Interest)\n 00533 * The ROI position is centered, only the ROI size can be reprogrammed.\n 00534 * The smallest acceptable ROI size = 4\n 00535 * @param X:ROI Width; Y=ROI Height 00536 */ 00537 VL53L1X_ERROR VL53L1X_SetROI(uint16_t X, uint16_t Y); 00538 00539 /** 00540 *@brief This function returns width X and height Y 00541 */ 00542 VL53L1X_ERROR VL53L1X_GetROI_XY(uint16_t *ROI_X, uint16_t *ROI_Y); 00543 00544 /** 00545 * @brief This function programs a new signal threshold in kcps (default=1024 kcps\n 00546 */ 00547 VL53L1X_ERROR VL53L1X_SetSignalThreshold(uint16_t signal); 00548 00549 /** 00550 * @brief This function returns the current signal threshold in kcps 00551 */ 00552 VL53L1X_ERROR VL53L1X_GetSignalThreshold(uint16_t *signal); 00553 00554 /** 00555 * @brief This function programs a new sigma threshold in mm (default=15 mm) 00556 */ 00557 VL53L1X_ERROR VL53L1X_SetSigmaThreshold(uint16_t sigma); 00558 00559 /** 00560 * @brief This function returns the current sigma threshold in mm 00561 */ 00562 VL53L1X_ERROR VL53L1X_GetSigmaThreshold(uint16_t *signal); 00563 00564 /** 00565 * @brief This function performs the temperature calibration. 00566 * It is recommended to call this function any time the temperature might have changed by more than 8 deg C 00567 * without sensor ranging activity for an extended period. 00568 */ 00569 VL53L1X_ERROR VL53L1X_StartTemperatureUpdate(); 00570 00571 00572 /* VL53L1X_calibration.h functions */ 00573 00574 /** 00575 * @brief This function performs the offset calibration.\n 00576 * The function returns the offset value found and programs the offset compensation into the device. 00577 * @param TargetDistInMm target distance in mm, ST recommended 100 mm 00578 * Target reflectance = grey17% 00579 * @return 0:success, !=0: failed 00580 * @return offset pointer contains the offset found in mm 00581 */ 00582 int8_t VL53L1X_CalibrateOffset(uint16_t TargetDistInMm, int16_t *offset); 00583 00584 /** 00585 * @brief This function performs the xtalk calibration.\n 00586 * The function returns the xtalk value found and programs the xtalk compensation to the device 00587 * @param TargetDistInMm target distance in mm\n 00588 * The target distance : the distance where the sensor start to "under range"\n 00589 * due to the influence of the photons reflected back from the cover glass becoming strong\n 00590 * It's also called inflection point\n 00591 * Target reflectance = grey 17% 00592 * @return 0: success, !=0: failed 00593 * @return xtalk pointer contains the xtalk value found in cps (number of photons in count per second) 00594 */ 00595 int8_t VL53L1X_CalibrateXtalk(uint16_t TargetDistInMm, uint16_t *xtalk); 00596 00597 00598 /* Write and read functions from I2C */ 00599 00600 VL53L1X_ERROR VL53L1_WrByte(VL53L1_DEV dev, uint16_t index, uint8_t data); 00601 VL53L1X_ERROR VL53L1_WrWord(VL53L1_DEV dev, uint16_t index, uint16_t data); 00602 VL53L1X_ERROR VL53L1_WrDWord(VL53L1_DEV dev, uint16_t index, uint32_t data); 00603 VL53L1X_ERROR VL53L1_RdByte(VL53L1_DEV dev, uint16_t index, uint8_t *data); 00604 VL53L1X_ERROR VL53L1_RdWord(VL53L1_DEV dev, uint16_t index, uint16_t *data); 00605 VL53L1X_ERROR VL53L1_RdDWord(VL53L1_DEV dev, uint16_t index, uint32_t *data); 00606 VL53L1X_ERROR VL53L1_UpdateByte(VL53L1_DEV dev, uint16_t index, uint8_t AndData, uint8_t OrData); 00607 00608 VL53L1X_ERROR VL53L1_WriteMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count); 00609 VL53L1X_ERROR VL53L1_ReadMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count); 00610 00611 VL53L1X_ERROR VL53L1_I2CWrite(uint8_t dev, uint16_t index, uint8_t *data, uint16_t number_of_bytes); 00612 VL53L1X_ERROR VL53L1_I2CRead(uint8_t dev, uint16_t index, uint8_t *data, uint16_t number_of_bytes); 00613 VL53L1X_ERROR VL53L1_GetTickCount(uint32_t *ptick_count_ms); 00614 VL53L1X_ERROR VL53L1_WaitUs(VL53L1_Dev_t *pdev, int32_t wait_us); 00615 VL53L1X_ERROR VL53L1_WaitMs(VL53L1_Dev_t *pdev, int32_t wait_ms); 00616 00617 VL53L1X_ERROR VL53L1_WaitValueMaskEx(VL53L1_Dev_t *pdev, uint32_t timeout_ms, uint16_t index, uint8_t value, uint8_t mask, uint32_t poll_delay_ms); 00618 00619 protected: 00620 00621 /* IO Device */ 00622 vl53L1X_DevI2C *dev_i2c; 00623 00624 /* Digital out pin */ 00625 DigitalOut *_gpio0; 00626 /* GPIO expander */ 00627 Stmpe1600DigiOut *_expgpio0; 00628 /* Measure detection IRQ */ 00629 InterruptIn *_gpio1Int; 00630 00631 ///* Digital out pin */ 00632 //int gpio0; 00633 //int gpio1Int; 00634 /* Device data */ 00635 VL53L1_Dev_t MyDevice; 00636 VL53L1_DEV Device; 00637 }; 00638 00639 00640 #endif /* _VL53L1X_CLASS_H_ */
Generated on Thu Jul 21 2022 07:13:32 by
1.7.2