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
VL53L1CB.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 00038 /* Includes ------------------------------------------------------------------*/ 00039 00040 #include "mbed.h" 00041 #include "PinNames.h" 00042 00043 #include "RangeSensor.h" 00044 #include "Stmpe1600.h" 00045 00046 #include "vl53l1_error_codes.h" 00047 #include "vl53l1_platform_user_data.h" 00048 00049 //#include "DevI2C.h" 00050 #include "ToF_I2C.h" 00051 /**********************************************************/ 00052 #include "vl53l1_def.h" 00053 /***********************************************************/ 00054 00055 00056 #define VL53L1CB_IMPLEMENTATION_VER_MAJOR 1 00057 #define VL53L1CB_IMPLEMENTATION_VER_MINOR 0 00058 #define VL53L1CB_IMPLEMENTATION_VER_SUB 1 00059 #define VL53L1CB_IMPLEMENTATION_VER_REVISION 0000 00060 00061 typedef int8_t VL53L1CB_ERROR; 00062 00063 //#define SOFT_RESET 0x0000 00064 #define VL53L1CB_I2C_SLAVE__DEVICE_ADDRESS 0x0001 00065 #define VL53L1CB_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND 0x0008 00066 #define ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS 0x0016 00067 #define ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS 0x0018 00068 #define ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS 0x001A 00069 #define ALGO__PART_TO_PART_RANGE_OFFSET_MM 0x001E 00070 #define MM_CONFIG__INNER_OFFSET_MM 0x0020 00071 #define MM_CONFIG__OUTER_OFFSET_MM 0x0022 00072 #define GPIO_HV_MUX__CTRL 0x0030 00073 #define GPIO__TIO_HV_STATUS 0x0031 00074 #define SYSTEM__INTERRUPT_CONFIG_GPIO 0x0046 00075 #define PHASECAL_CONFIG__TIMEOUT_MACROP 0x004B 00076 #define RANGE_CONFIG__TIMEOUT_MACROP_A_HI 0x005E 00077 #define RANGE_CONFIG__VCSEL_PERIOD_A 0x0060 00078 #define RANGE_CONFIG__VCSEL_PERIOD_B 0x0063 00079 #define RANGE_CONFIG__TIMEOUT_MACROP_B_HI 0x0061 00080 #define RANGE_CONFIG__TIMEOUT_MACROP_B_LO 0x0062 00081 #define RANGE_CONFIG__SIGMA_THRESH 0x0064 00082 #define RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS 0x0066 00083 #define RANGE_CONFIG__VALID_PHASE_HIGH 0x0069 00084 #define SYSTEM__THRESH_HIGH 0x0072 00085 #define SYSTEM__THRESH_LOW 0x0074 00086 #define SD_CONFIG__WOI_SD0 0x0078 00087 #define SD_CONFIG__INITIAL_PHASE_SD0 0x007A 00088 #define ROI_CONFIG__USER_ROI_CENTRE_SPAD 0x007F 00089 #define ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE 0x0080 00090 #define SYSTEM__SEQUENCE_CONFIG 0x0081 00091 #define SYSTEM__INTERRUPT_CLEAR 0x0086 00092 #define SYSTEM__MODE_START 0x0087 00093 #define RESULT__AMBIENT_COUNT_RATE_MCPS_SD 0x0090 00094 #define VL53L1CB_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 0x0096 00095 #define VL53L1CB_FIRMWARE__SYSTEM_STATUS 0x00E5 00096 00097 00098 00099 #define VL53L1CB_DEFAULT_DEVICE_ADDRESS 0x52 00100 00101 #define VL53L1CB_REG_IDENTIFICATION_MODEL_ID 0x010F 00102 00103 /**************************************** 00104 * PRIVATE define do not edit 00105 ****************************************/ 00106 00107 /** 00108 * @brief defines SW Version 00109 */ 00110 //typedef struct { 00111 // uint8_t major; /*!< major number */ 00112 // uint8_t minor; /*!< minor number */ 00113 // uint8_t build; /*!< build number */ 00114 // uint32_t revision; /*!< revision number */ 00115 //} VL53L1X_Version_t; 00116 00117 00118 /* Classes -------------------------------------------------------------------*/ 00119 /** Class representing a VL53L1CB sensor component 00120 */ 00121 class VL53L1CB : public RangeSensor 00122 { 00123 00124 00125 00126 public: 00127 00128 00129 #define VL53L1DevStructGetLLDriverHandle(Dev) (&Dev->Data.LLData) 00130 /** Constructor 00131 * @param[in] &i2c device I2C to be used for communication 00132 * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT 00133 * @param[in] DevAddr device address, 0x52 by default 00134 */ 00135 /* 00136 VL53L1CB(ToF_DevI2C *i2c, DigitalOut *pin, PinName pin_gpio1, uint8_t dev_addr = VL53L1CB_DEFAULT_DEVICE_ADDRESS) 00137 : RangeSensor(), dev_i2c(i2c), _gpio0(pin) 00138 { 00139 MyDevice.i2c_slave_address=dev_addr; 00140 Device = &MyDevice; 00141 00142 _expgpio0 = NULL; 00143 if (pin_gpio1 != NC) { 00144 _gpio1Int = new InterruptIn(pin_gpio1); 00145 } else { 00146 _gpio1Int = NULL; 00147 } 00148 } 00149 */ 00150 00151 /** Constructor 2 (STMPE1600DigiOut) 00152 * @param[in] i2c device I2C to be used for communication 00153 * @param[in] &pin Gpio Expander STMPE1600DigiOut pin to be used as component GPIO_0 CE 00154 * @param[in] pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT 00155 * @param[in] device address, 0x29 by default 00156 */ 00157 VL53L1CB(ToF_DevI2C *i2c, Stmpe1600DigiOut *pin, PinName pin_gpio1, 00158 uint8_t dev_addr = VL53L1CB_DEFAULT_DEVICE_ADDRESS) 00159 : dev_i2c(i2c), _expgpio0(pin) 00160 { 00161 MyDevice.i2c_slave_address=dev_addr; 00162 Device = &MyDevice; 00163 00164 _gpio0 = NULL; 00165 if (pin_gpio1 != NC) { 00166 _gpio1Int = new InterruptIn(pin_gpio1); 00167 } else { 00168 _gpio1Int = NULL; 00169 } 00170 } 00171 00172 /** Destructor 00173 */ 00174 virtual ~VL53L1CB() 00175 { 00176 if (_gpio1Int != NULL) { 00177 delete _gpio1Int; 00178 } 00179 } 00180 00181 00182 00183 VL53L1_DEV getDevicePtr() { return Device; } 00184 00185 00186 /* warning: VL53L1CB class inherits from GenericSensor, RangeSensor and LightSensor, that haven`t a destructor. 00187 The warning should request to introduce a virtual destructor to make sure to delete the object */ 00188 00189 /*** Interface Methods ***/ 00190 /*** High level API ***/ 00191 /** 00192 * @brief PowerOn the sensor 00193 * @return void 00194 */ 00195 /* turns on the sensor */ 00196 virtual void VL53L1CB_On(void) 00197 { 00198 printf("VL53L1CB_On\r\n"); 00199 if (_gpio0) { 00200 *_gpio0 = 1; 00201 } else { 00202 if (_expgpio0) { 00203 *_expgpio0 = 1; 00204 } 00205 } 00206 #if (MBED_VERSION > 60300) 00207 thread_sleep_for(100); 00208 #else 00209 wait_ms(100); // NEEDS A DELAY BETWEEN SENSORS 00210 #endif 00211 } 00212 00213 /** 00214 * @brief PowerOff the sensor 00215 * @return void 00216 */ 00217 /* turns off the sensor */ 00218 virtual void VL53L1CB_Off(void) 00219 { 00220 printf("VL53L1_Off\r\n"); 00221 if (_gpio0) { 00222 *_gpio0 = 0; 00223 } else { 00224 if (_expgpio0) { 00225 *_expgpio0 = 0; 00226 } 00227 } 00228 #if (MBED_VERSION > 60300) 00229 thread_sleep_for(100); 00230 #else 00231 wait_ms(100); // NEEDS A DELAY BETWEEN SENSORS 00232 #endif 00233 } 00234 00235 int is_present() 00236 { 00237 int status; 00238 uint8_t id = 0; 00239 00240 status = read_id(&id); 00241 if (status) { 00242 printf("Failed to read ID device. Device not present!\n\r"); 00243 } 00244 return status; 00245 } 00246 00247 /** 00248 * @brief Initialize the sensor with default values 00249 * @return 0 on Success 00250 */ 00251 00252 VL53L1CB_ERROR InitSensor(uint8_t address){ 00253 VL53L1CB_ERROR status = 0; 00254 uint8_t sensorState = 0; 00255 VL53L1CB_Off(); 00256 VL53L1CB_On(); 00257 status = VL53L1CB_SetI2CAddress(address); 00258 if(!status){ 00259 status = VL53L1CB_SensorInit(); 00260 } 00261 00262 while(!status && !sensorState) { 00263 status = VL53L1CB_BootState(&sensorState); 00264 00265 #if (MBED_VERSION > 60300) 00266 thread_sleep_for(2); 00267 #else 00268 wait_ms(2); // NEEDS A DELAY BETWEEN SENSORS 00269 #endif 00270 } 00271 return status; 00272 } 00273 00274 00275 00276 /** 00277 * 00278 * @brief One time device initialization 00279 * @param void 00280 * @return 0 on success, @a #CALIBRATION_WARNING if failed 00281 */ 00282 virtual int init(void *init) 00283 { 00284 return VL53L1CB_SensorInit(); 00285 return 0; 00286 } 00287 00288 00289 /** 00290 * @brief Initialize the sensor with default values 00291 * @return "0" on success 00292 */ 00293 int init_sensor(uint8_t new_addr); 00294 00295 /* Read function of the ID device */ 00296 virtual int read_id(uint8_t *id){ 00297 int status = 0; 00298 uint16_t rl_id = 0; 00299 00300 uint8_t ExpanderData[2]; 00301 00302 ExpanderData[0] = 0; 00303 ExpanderData[1] = 0; 00304 rl_id = 0; 00305 dev_i2c->ToF_i2c_read(&ExpanderData[0], Device->i2c_slave_address, VL53L1CB_REG_IDENTIFICATION_MODEL_ID, 2); 00306 00307 rl_id = (ExpanderData[0] << 8) + ExpanderData[1]; 00308 printf("Model ID is: %d (%X) \r\n",rl_id, rl_id); 00309 00310 uint8_t tmp = 0; 00311 ExpanderData[0] = VL53L1CB_FIRMWARE__SYSTEM_STATUS >> 8; 00312 ExpanderData[1] = VL53L1CB_FIRMWARE__SYSTEM_STATUS & 0x0FF; 00313 dev_i2c->ToF_i2c_read(&tmp, Device->i2c_slave_address, VL53L1CB_FIRMWARE__SYSTEM_STATUS, 1); 00314 00315 printf("Firmware system is: %d\r\n",tmp); 00316 00317 if (rl_id == 0xEACC) { 00318 printf("Device is present %d:\r\n", rl_id); 00319 return status; 00320 } 00321 return -1; 00322 } 00323 00324 00325 /** 00326 * @brief Interrupt handling func to be called by user after an INT is occurred 00327 * @param[out] Data pointer to the distance to read data in to 00328 * @return 0 on Success 00329 */ 00330 int handle_irq(uint16_t *distance); 00331 00332 /** 00333 * @brief Start the measure indicated by operating mode 00334 * @param[in] fptr specifies call back function must be !NULL in case of interrupt measure 00335 * @return 0 on Success 00336 */ 00337 int start_measurement(void (*fptr)(void)); 00338 /** 00339 * @brief Stop the currently running measure indicate by operating_mode 00340 * @return 0 on Success 00341 */ 00342 int stop_measurement(); 00343 /** 00344 * @brief Get results for the measure 00345 * @param[out] Data pointer to the distance_data to read data in to 00346 * @return 0 on Success 00347 */ 00348 int get_measurement(uint16_t *distance); 00349 /** 00350 * @brief Enable interrupt measure IRQ 00351 * @return 0 on Success 00352 */ 00353 void enable_interrupt_measure_detection_irq(void) 00354 { 00355 if (_gpio1Int != NULL) 00356 _gpio1Int->enable_irq(); 00357 } 00358 00359 /** 00360 * @brief Disable interrupt measure IRQ 00361 * @return 0 on Success 00362 */ 00363 void disable_interrupt_measure_detection_irq(void) 00364 { 00365 if (_gpio1Int != NULL) 00366 _gpio1Int->disable_irq(); 00367 } 00368 /** 00369 * @brief Attach a function to call when an interrupt is detected, i.e. measurement is ready 00370 * @param[in] fptr pointer to call back function to be called whenever an interrupt occours 00371 * @return 0 on Success 00372 */ 00373 void attach_interrupt_measure_detection_irq(void (*fptr)(void)) 00374 { 00375 if (_gpio1Int != NULL) 00376 _gpio1Int->rise(fptr); 00377 } 00378 00379 /** 00380 * @brief Get ranging result and only that 00381 * @param pRange_mm Pointer to range distance 00382 * @return 0 on success 00383 */ 00384 virtual int get_distance(uint32_t *piData) 00385 { 00386 int status; 00387 uint16_t distance; 00388 status = VL53L1CB_GetDistance(&distance); 00389 *piData = (uint32_t) distance; 00390 return status; 00391 } 00392 00393 00394 /* VL53L1X_api.h functions */ 00395 00396 00397 00398 /** 00399 * @brief This function returns the SW driver version 00400 */ 00401 VL53L1CB_ERROR VL53L1CB_GetSWVersion(VL53L1_Version_t *pVersion); 00402 00403 /** 00404 * @brief This function sets the sensor I2C address used in case multiple devices application, default address 0x52 00405 */ 00406 VL53L1CB_ERROR VL53L1CB_SetI2CAddress(uint8_t new_address); 00407 00408 /** 00409 * @brief This function loads the 135 bytes default values to initialize the sensor. 00410 * @param dev Device address 00411 * @return 0:success, != 0:failed 00412 */ 00413 VL53L1CB_ERROR VL53L1CB_SensorInit(); 00414 00415 /** 00416 * @brief This function clears the interrupt, to be called after a ranging data reading 00417 * to arm the interrupt for the next data ready event. 00418 */ 00419 VL53L1CB_ERROR VL53L1CB_ClearInterrupt(); 00420 00421 00422 /** 00423 * @brief This function returns the current interrupt polarity\n 00424 * 1=active high (default), 0=active low 00425 */ 00426 VL53L1CB_ERROR VL53L1CB_GetInterruptPolarity(uint8_t *pIntPol); 00427 00428 /** 00429 * @brief This function starts the ranging distance operation\n 00430 * 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 00431 * 1=active high (default), 0=active low, use SetInterruptPolarity() to change the interrupt polarity if required. 00432 */ 00433 VL53L1CB_ERROR VL53L1CB_StartRanging(); 00434 00435 /** 00436 * @brief This function stops the ranging. 00437 */ 00438 VL53L1CB_ERROR VL53L1CB_StopRanging(); 00439 00440 00441 00442 /** 00443 * @brief This function returns the boot state of the device (1:booted, 0:not booted) 00444 */ 00445 VL53L1CB_ERROR VL53L1CB_BootState(uint8_t *state); 00446 00447 /** 00448 * @brief This function returns the sensor id, sensor Id must be 0xEEAC 00449 */ 00450 // VL53L1CB_ERROR VL53L1X_GetSensorId(uint16_t *id); 00451 00452 /** 00453 * @brief This function returns the distance measured by the sensor in mm 00454 */ 00455 VL53L1CB_ERROR VL53L1CB_GetDistance(uint16_t *distance); 00456 00457 00458 00459 00460 /**************************************************************************/ 00461 VL53L1CB_ERROR VL53L1CB_WaitDeviceBooted(VL53L1_DEV Dev); 00462 00463 00464 VL53L1CB_ERROR VL53L1CB_GetCalibrationData(VL53L1_CalibrationData_t *pCalibrationData); 00465 00466 00467 00468 VL53L1_GPIO_Interrupt_Mode ConvertModeToLLD(VL53L1CB_ERROR *pStatus, 00469 VL53L1_ThresholdMode CrossMode); 00470 00471 VL53L1CB_ERROR VL53L1CB_GetVersion(VL53L1_Version_t *pVersion); 00472 00473 VL53L1CB_ERROR VL53L1CB_GetProductRevision( 00474 uint8_t *pProductRevisionMajor, uint8_t *pProductRevisionMinor); 00475 00476 00477 VL53L1CB_ERROR VL53L1CB_GetDeviceInfo( 00478 VL53L1_DeviceInfo_t *pVL53L1_DeviceInfo); 00479 00480 VL53L1CB_ERROR VL53L1CB_GetUID( uint64_t *pUid); 00481 00482 VL53L1CB_ERROR VL53L1CB_GetRangeStatusString(uint8_t RangeStatus, 00483 char *pRangeStatusString); 00484 00485 00486 VL53L1CB_ERROR VL53L1CB_GetPalErrorString(VL53L1CB_ERROR PalErrorCode, 00487 char *pPalErrorString); 00488 00489 00490 VL53L1CB_ERROR VL53L1CB_GetPalStateString(VL53L1_State PalStateCode, 00491 char *pPalStateString); 00492 00493 00494 VL53L1CB_ERROR VL53L1CB_GetPalState(VL53L1_DEV Dev, VL53L1_State *pPalState); 00495 00496 VL53L1CB_ERROR VL53L1CB_DataInit(); 00497 00498 VL53L1CB_ERROR VL53L1CB_StaticInit(); 00499 00500 VL53L1CB_ERROR VL53L1CB_ClearInterruptAndStartMeasurement(); 00501 00502 VL53L1CB_ERROR VL53L1CB_GetRangingMeasurementData( 00503 VL53L1_RangingMeasurementData_t *pRangingMeasurementData); 00504 00505 VL53L1CB_ERROR VL53L1CB_GetMultiRangingData( 00506 VL53L1_MultiRangingData_t *pMultiRangingData); 00507 00508 VL53L1CB_ERROR VL53L1CB_GetAdditionalData( 00509 VL53L1_AdditionalData_t *pAdditionalData); 00510 00511 VL53L1CB_ERROR VL53L1CB_SetTuningParameter( 00512 uint16_t TuningParameterId, int32_t TuningParameterValue); 00513 00514 VL53L1CB_ERROR VL53L1CB_GetTuningParameter( 00515 uint16_t TuningParameterId, int32_t *pTuningParameterValue); 00516 00517 VL53L1CB_ERROR VL53L1CB_SetXTalkCompensationEnable( 00518 uint8_t XTalkCompensationEnable); 00519 00520 00521 VL53L1CB_ERROR VL53L1CB_GetXTalkCompensationEnable( 00522 uint8_t *pXTalkCompensationEnable); 00523 00524 VL53L1CB_ERROR VL53L1CB_PerformXTalkCalibration( 00525 uint8_t CalibrationOption); 00526 00527 VL53L1CB_ERROR VL53L1CB_SetOffsetCalibrationMode( 00528 VL53L1_OffsetCalibrationModes OffsetCalibrationMode); 00529 00530 00531 VL53L1CB_ERROR VL53L1CB_SetOffsetCorrectionMode( 00532 VL53L1_OffsetCorrectionModes OffsetCorrectionMode); 00533 00534 VL53L1CB_ERROR VL53L1CB_PerformOffsetCalibration( 00535 int32_t CalDistanceMilliMeter, FixPoint1616_t CalReflectancePercent); 00536 00537 VL53L1CB_ERROR VL53L1CB_PerformOffsetSimpleCalibration( 00538 int32_t CalDistanceMilliMeter); 00539 00540 VL53L1CB_ERROR VL53L1CB_PerformOffsetZeroDistanceCalibration(); 00541 00542 VL53L1CB_ERROR VL53L1CB_SetCalibrationData( 00543 VL53L1_CalibrationData_t *pCalibrationData); 00544 00545 VL53L1CB_ERROR VL53L1CB_SetZoneCalibrationData( 00546 VL53L1_ZoneCalibrationData_t *pZoneCalibrationData); 00547 00548 VL53L1CB_ERROR VL53L1CB_GetZoneCalibrationData( 00549 VL53L1_ZoneCalibrationData_t *pZoneCalibrationData); 00550 00551 VL53L1CB_ERROR VL53L1CB_GetOpticalCenter( 00552 FixPoint1616_t *pOpticalCenterX, 00553 FixPoint1616_t *pOpticalCenterY); 00554 00555 VL53L1CB_ERROR VL53L1CB_SetThresholdConfig(VL53L1_DetectionConfig_t *pConfig); 00556 00557 00558 VL53L1CB_ERROR VL53L1CB_GetLimitCheckStatus( uint16_t LimitCheckId, 00559 uint8_t *pLimitCheckStatus); 00560 00561 00562 VL53L1CB_ERROR VL53L1CB_SetLimitCheckEnable( uint16_t LimitCheckId, 00563 uint8_t LimitCheckEnable); 00564 00565 VL53L1CB_ERROR VL53L1CB_GetLimitCheckEnable(uint16_t LimitCheckId, 00566 uint8_t *pLimitCheckEnable); 00567 00568 VL53L1CB_ERROR VL53L1CB_GetThresholdConfig(VL53L1_DetectionConfig_t *pConfig); 00569 00570 00571 VL53L1CB_ERROR VL53L1CB_PerformOffsetPerVcselCalibration(int32_t CalDistanceMilliMeter); 00572 00573 VL53L1CB_ERROR VL53L1CB_GetNumberOfLimitCheck(uint16_t *pNumberOfLimitCheck); 00574 00575 VL53L1CB_ERROR VL53L1CB_GetLimitCheckInfo(uint16_t LimitCheckId, 00576 char *pLimitCheckString); 00577 00578 VL53L1CB_ERROR VL53L1CB_SetPresetMode(VL53L1_PresetModes PresetMode); 00579 00580 VL53L1CB_ERROR VL53L1CB_GetPresetMode( VL53L1_PresetModes *pPresetMode); 00581 00582 VL53L1CB_ERROR VL53L1CB_SetDistanceMode( VL53L1_DistanceModes DistanceMode); 00583 00584 VL53L1CB_ERROR VL53L1CB_GetDistanceMode(VL53L1_DistanceModes *pDistanceMode); 00585 00586 VL53L1CB_ERROR VL53L1CB_SetOutputMode(VL53L1_OutputModes OutputMode); 00587 00588 VL53L1CB_ERROR VL53L1CB_GetOutputMode(VL53L1_OutputModes *pOutputMode); 00589 00590 VL53L1CB_ERROR VL53L1CB_SetMeasurementTimingBudgetMicroSeconds(uint32_t MeasurementTimingBudgetMicroSeconds); 00591 00592 VL53L1CB_ERROR VL53L1CB_SetInterMeasurementPeriodMilliSeconds(uint32_t InterMeasurementPeriodMilliSeconds); 00593 00594 00595 VL53L1CB_ERROR VL53L1CB_GetInterMeasurementPeriodMilliSeconds( 00596 uint32_t *pInterMeasurementPeriodMilliSeconds); 00597 00598 00599 VL53L1CB_ERROR VL53L1CB_SetDmaxReflectance( FixPoint1616_t DmaxReflectance); 00600 00601 VL53L1CB_ERROR VL53L1CB_GetDmaxReflectance(FixPoint1616_t *pDmaxReflectance); 00602 00603 00604 VL53L1CB_ERROR VL53L1CB_GetDmaxMode( VL53L1_DeviceDmaxModes *pDmaxMode); 00605 00606 VL53L1CB_ERROR VL53L1CB_GetMeasurementTimingBudgetMicroSeconds( 00607 uint32_t *pMeasurementTimingBudgetMicroSeconds); 00608 00609 VL53L1CB_ERROR VL53L1CB_SetDmaxMode(VL53L1_DeviceDmaxModes DmaxMode); 00610 00611 VL53L1CB_ERROR VL53L1CB_SetLimitCheckValue( uint16_t LimitCheckId, 00612 FixPoint1616_t LimitCheckValue); 00613 00614 VL53L1CB_ERROR VL53L1CB_GetLimitCheckValue(uint16_t LimitCheckId, 00615 FixPoint1616_t *pLimitCheckValue); 00616 00617 VL53L1CB_ERROR VL53L1CB_GetLimitCheckCurrent( uint16_t LimitCheckId, 00618 FixPoint1616_t *pLimitCheckCurrent); 00619 00620 VL53L1CB_ERROR VL53L1CB_GetMaxNumberOfROI( uint8_t *pMaxNumberOfROI); 00621 00622 VL53L1CB_ERROR VL53L1CB_SetROI(VL53L1_RoiConfig_t *pRoiConfig); 00623 00624 VL53L1CB_ERROR VL53L1CB_GetROI(VL53L1_RoiConfig_t *pRoiConfig); 00625 00626 VL53L1CB_ERROR VL53L1CB_GetNumberOfSequenceSteps(uint8_t *pNumberOfSequenceSteps); 00627 00628 VL53L1CB_ERROR VL53L1CB_GetSequenceStepsInfo(VL53L1_SequenceStepId SequenceStepId, 00629 char *pSequenceStepsString); 00630 00631 00632 VL53L1CB_ERROR VL53L1CB_SetSequenceStepEnable(VL53L1_SequenceStepId SequenceStepId, uint8_t SequenceStepEnabled); 00633 00634 00635 VL53L1CB_ERROR VL53L1CB_GetSequenceStepEnable(VL53L1_SequenceStepId SequenceStepId, uint8_t *pSequenceStepEnabled); 00636 00637 00638 VL53L1CB_ERROR VL53L1CB_StartMeasurement(); 00639 00640 VL53L1CB_ERROR VL53L1CB_StopMeasurement(); 00641 00642 00643 VL53L1CB_ERROR VL53L1CB_GetMeasurementDataReady(uint8_t *pMeasurementDataReady); 00644 00645 VL53L1CB_ERROR VL53L1CB_WaitMeasurementDataReady(); 00646 00647 VL53L1CB_ERROR VL53L1CB_SmudgeCorrectionEnable(VL53L1_SmudgeCorrectionModes Mode); 00648 /***************************************************************************/ 00649 00650 00651 /* Write and read functions from I2C */ 00652 00653 VL53L1CB_ERROR VL53L1CB_WrByte(VL53L1_DEV dev, uint16_t index, uint8_t data); 00654 VL53L1CB_ERROR VL53L1CB_WrWord(VL53L1_DEV dev, uint16_t index, uint16_t data); 00655 VL53L1CB_ERROR VL53L1CB_WrDWord(VL53L1_DEV dev, uint16_t index, uint32_t data); 00656 VL53L1CB_ERROR VL53L1CB_RdByte(VL53L1_DEV dev, uint16_t index, uint8_t *data); 00657 VL53L1CB_ERROR VL53L1CB_RdWord(VL53L1_DEV dev, uint16_t index, uint16_t *data); 00658 VL53L1CB_ERROR VL53L1CB_RdDWord(VL53L1_DEV dev, uint16_t index, uint32_t *data); 00659 VL53L1CB_ERROR VL53L1CB_UpdateByte(VL53L1_DEV dev, uint16_t index, uint8_t AndData, uint8_t OrData); 00660 00661 VL53L1CB_ERROR VL53L1CB_WriteMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count); 00662 VL53L1CB_ERROR VL53L1CB_ReadMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count); 00663 00664 VL53L1CB_ERROR VL53L1CB_I2CWrite(uint8_t dev, uint16_t index, uint8_t *data, uint16_t number_of_bytes); 00665 VL53L1CB_ERROR VL53L1CB_I2CRead(uint8_t dev, uint16_t index, uint8_t *data, uint16_t number_of_bytes); 00666 VL53L1CB_ERROR VL53L1CB_GetTickCount(uint32_t *ptick_count_ms); 00667 VL53L1CB_ERROR VL53L1CB_WaitUs(VL53L1_Dev_t *pdev, int32_t wait_us); 00668 VL53L1CB_ERROR VL53L1CB_WaitMs(VL53L1_Dev_t *pdev, int32_t wait_ms); 00669 00670 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); 00671 VL53L1CB_ERROR VL53L1CB_SetDeviceAddress(VL53L1_DEV Dev, uint8_t DeviceAddress); 00672 00673 // from vl53l1_api_debug.c 00674 00675 VL53L1CB_ERROR VL53L1CB_get_additional_data( 00676 VL53L1_DEV Dev, 00677 VL53L1_additional_data_t *pdata); 00678 00679 00680 protected: 00681 00682 /* IO Device */ 00683 ToF_DevI2C *dev_i2c; 00684 00685 /* Digital out pin */ 00686 DigitalOut *_gpio0; 00687 /* GPIO expander */ 00688 Stmpe1600DigiOut *_expgpio0; 00689 /* Measure detection IRQ */ 00690 InterruptIn *_gpio1Int; 00691 00692 ///* Digital out pin */ 00693 /* Device data */ 00694 VL53L1_Dev_t MyDevice; 00695 VL53L1_DEV Device; 00696 }; 00697 00698 00699 #endif /* _VL53L1X_CLASS_H_ */
Generated on Thu Jul 14 2022 10:20:22 by
1.7.2