Contains Ayoub's Ranging and Custom interfaces for the VL53L3CX
Diff: vl53l3cx_class.h
- Revision:
- 0:c1910e04fc6c
diff -r 000000000000 -r c1910e04fc6c vl53l3cx_class.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vl53l3cx_class.h Wed Jul 21 14:19:31 2021 +0000 @@ -0,0 +1,2644 @@ +/******************************************************************************* + Copyright © 2018, STMicroelectronics International N.V. + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of STMicroelectronics nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND + NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED. + IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +#ifndef __VL53LX_CLASS_H +#define __VL53LX_CLASS_H + +#ifdef _MSC_VER + #ifdef VL53LX_API_EXPORTS + #define VL53LX_API __declspec(dllexport) + #else + #define VL53LX_API + #endif +#else + #define VL53LX_API +#endif + +/* Includes ------------------------------------------------------------------*/ + +#include "mbed.h" +#include "RangeSensor.h" +#include "vl53lx_def.h" +#include "vl53L3_I2c.h" + + + +#include "PinNames.h" +#include "vl53lx_error_codes.h" +#include "vl53lx_platform_user_data.h" + +#include "vl53lx_nvm_structs.h"//cgm +#include "vl53lx_xtalk_private_structs.h" +#include "vl53lx_hist_private_structs.h" +#include "vl53lx_dmax_private_structs.h" +#include "vl53lx_api.h" + +#include "Stmpe1600.h" +/**********************************************************/ +#if (MBED_VERSION > 60300) +extern "C" void wait_ms(int ms); +#endif + + +#define VL53LX_DEFAULT_DEVICE_ADDRESS 0x52 + + + +#define VL53LX_MAX_I2C_XFER_SIZE 256 +#define CONT_CONTINUE 0 +#define CONT_NEXT_LOOP 1 +#define CONT_RESET 2 + + +/* vl53lx_api.c */ + +#ifndef MIN + #define MIN(v1, v2) ((v1) < (v2) ? (v1) : (v2)) +#endif +#ifndef MAX + #define MAX(v1, v2) ((v1) < (v2) ? (v2) : (v1)) +#endif + +#define DMAX_REFLECTANCE_IDX 2 + + + +#define LOWPOWER_AUTO_VHV_LOOP_DURATION_US 245 +#define LOWPOWER_AUTO_OVERHEAD_BEFORE_A_RANGING 1448 +#define LOWPOWER_AUTO_OVERHEAD_BETWEEN_A_B_RANGING 2100 + +#define FDA_MAX_TIMING_BUDGET_US 550000 + + +#define VL53LX_NVM_POWER_UP_DELAY_US 50 +#define VL53LX_NVM_READ_TRIGGER_DELAY_US 5 + + +#define VL53LX_D_002 0xFFFF +#define VL53LX_D_008 0xFFFF +#define VL53LX_D_003 0xFFFFFF +#define VL53LX_D_007 0xFFFFFFFF +#define VL53LX_D_005 0x7FFFFFFFFF +#define VL53LX_D_009 0xFFFFFFFFFF +#define VL53LX_D_010 0xFFFFFFFFFFFF +#define VL53LX_D_004 0xFFFFFFFFFFFFFF +#define VL53LX_D_006 0x7FFFFFFFFFFFFFFF +#define VL53LX_D_011 0xFFFFFFFFFFFFFFFF + +#define VL53L1X_DEFAULT_DEVICE_ADDRESS 0x52 +#define HIGH 1 + + +/* Classes -------------------------------------------------------------------*/ +/** Class representing a VL53L3CX sensor component + */ + +class VL53L3CX : public RangeSensor { + public: + /** Constructor + * @param[in] &i2c device I2C to be used for communication + * @param[in] &pin_gpio1 pin Mbed InterruptIn PinName to be used as component GPIO_1 INT + * @param[in] DevAddr device address, 0x52 by default + */ + + VL53L3CX(vl53L3_DevI2C *i2c, Stmpe1600DigiOut *pin, PinName pin_gpio1, uint8_t dev_addr = VL53LX_DEFAULT_DEVICE_ADDRESS) + : RangeSensor(), dev_i2c(i2c), _expgpio0(pin) + { + + Dev = new VL53L3CX_Object_t; + I2cDevAddr = dev_addr; + Dev->IO.Address = VL53LX_DEFAULT_DEVICE_ADDRESS; + + _gpio0 = NULL; + if (pin_gpio1 != NC) { + _gpio1Int = new InterruptIn(pin_gpio1); + } else { + _gpio1Int = NULL; + } + + i2c_inst = i2c; + + } + + + /** Destructor + */ + virtual ~VL53L3CX() {} + /* warning: VL53LX class inherits from GenericSensor, RangeSensor and LightSensor, that haven`t a destructor. + The warning should request to introduce a virtual destructor to make sure to delete the object */ + + /*** Interface Methods ***/ + /*** High level API ***/ + /** + * @brief PowerOn the sensor + * @return void + */ + + + /* turns on the sensor */ + virtual void VL53LX_On(void) + { + printf("VL53L1_On\r\n"); + if (_gpio0) { + *_gpio0 = 1; + } else { + if (_expgpio0) { + *_expgpio0 = 1; + } + } + wait_ms(100); + } + + /** + * @brief PowerOff the sensor + * @return void + */ + /* turns off the sensor */ + virtual void VL53LX_Off(void) + { + printf("VL53L1_Off\r\n"); + if (_gpio0) { + *_gpio0 = 0; + } else { + if (_expgpio0) { + *_expgpio0 = 0; + } + } + wait_ms(100); + } + + + + /** + * @brief Initialize the sensor with default values + * @return 0 on Success + */ + + VL53LX_Error InitSensor(uint8_t address) + { + + VL53LX_Error status = VL53LX_ERROR_NONE; + VL53LX_Off(); + VL53LX_On(); + Dev->IO.Address = VL53LX_DEFAULT_DEVICE_ADDRESS; + + status = VL53L3CX_SetDeviceAddress(address); + + wait_ms(100); + + if (status == VL53LX_ERROR_NONE) { + status = VL53L3CX_WaitDeviceBooted(); + printf("VL53L3CX_WaitDeviceBooted %d \n",status); + } + + if (status == VL53LX_ERROR_NONE) { + status = VL53L3CX_DataInit(); + printf("VL53L3CX_DataInit %d %d\n",status,Dev->IO.Address ); + } + + + return status; + } + + + + /** + * + * @brief One time device initialization + * @param void + * @return 0 on success + */ + virtual int Init() + { + return VL53L3CX_DataInit(); + } + + int init(void *init) + { + return VL53L3CX_DataInit(); + } + + /* Read function of the ID device */ + virtual int ReadID() + { + uint64_t Uid; + VL53L3CX_GetUID(&Uid); + if (Uid == 0x00FF000000FF) { + return 0; + } + return -1; + } + + + + /** + * @brief Get ranging result and only that + * @param pRange_mm Pointer to range distance + * @return 0 on success + */ + virtual int GetDistance(uint32_t *piData) + { + (void)piData; + return 0; + } + + + /* vl53lx_api.h */ + + /** @defgroup VL53LX_group VL53LX Function Definition + * @brief VL53LX Function Definition + * @{ + */ + + /** @defgroup VL53LX_general_group VL53LX General Functions + * @brief General functions and definitions + * @{ + */ + + /** + * @brief Return the VL53L3CX driver Version + * + * @note This function doesn't access to the device + * + * @param pVersion Rer to current driver Version + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_GetVersion(VL53LX_Version_t *pVersion); + + /** + * @brief Reads the Product Revision for a for given Device + * This function can be used to distinguish cut1.0 from cut1.1. + * + * @param Dev Device Handle + * @param pProductRevisionMajor Pointer to Product Revision Major + * for a given Device + * @param pProductRevisionMinor Pointer to Product Revision Minor + * for a given Device + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_GetProductRevision(uint8_t *pProductRevisionMajor, + uint8_t *pProductRevisionMinor); + + /** + * @brief Reads the Device information for given Device + * + * @note This function Access to the device + * + * @param Dev Device Handle + * @param pVL53LX_DeviceInfo Pointer to current device info for a given + * Device + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_GetDeviceInfo( + VL53LX_DeviceInfo_t *pVL53LX_DeviceInfo); + + /** + * @brief Reads the Device unique identifier + * + * @note This function Access to the device + * + * @param Dev Device Handle + * @param pUid Pointer to current device unique ID + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_GetUID(uint64_t *pUid); + + + /** @} VL53LX_general_group */ + + /** @defgroup VL53LX_init_group VL53LX Init Functions + * @brief VL53LX Init Functions + * @{ + */ + + /** + * @brief Set new device address + * + * After completion the device will answer to the new address programmed. + * This function should be called when several devices are used in parallel + * before start programming the sensor. + * When a single device us used, there is no need to call this function. + * + * When it is requested for multi devices system this function MUST be called + * prior to VL53LX_DataInit() + * + * @note This function Access to the device + * + * @param Dev Device Handle + * @param DeviceAddress The new Device address + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_SetDeviceAddress(uint8_t DeviceAddress); + + /** + * + * @brief One time device initialization + * + * To be called after device has been powered on and booted + * see @a VL53L3CX_WaitDeviceBooted() + * + * @par Function Description + * When not used after a fresh device "power up", it may return + * @a #VL53LX_Error_CALIBRATION_WARNING meaning wrong calibration data + * may have been fetched from device that can result in ranging offset error\n + * If VL53LX_DataInit is called several times then the application must restore + * calibration calling @a VL53LX_SetOffsetCalibrationData() + * It implies application has gathered calibration data thanks to + * @a VL53LX_GetOffsetCalibrationData() after an initial calibration stage. + * + * @note This function Access to the device + * + * @param Dev Device Handle + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_DataInit(); + + /** + * @brief Wait for device booted after chip enable (hardware standby) + * + * @param Dev Device Handle + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + * + */ + VL53LX_Error VL53L3CX_WaitDeviceBooted(); + + + /** @} VL53LX_init_group */ + + /** @defgroup VL53LX_parameters_group VL53LX Parameters Functions + * @brief Functions used to prepare and setup the device + * @{ + */ + + /** + * @brief Set the distance mode + * @par Function Description + * Set the distance mode to be used for the next ranging.<br> + * The modes Short, Medium and Long are used to optimize the ranging accuracy + * in a specific range of distance.<br> The user select one of these modes to + * select the distance range. + * @note This function doesn't Access to the device + * + * @warning This function should be called after @a VL53LX_DataInit(). + + * @param Dev Device Handle + * @param DistanceMode Distance mode to apply, valid values are: + * @li VL53LX_DISTANCEMODE_SHORT + * @li VL53LX_DISTANCEMODE_MEDIUM + * @li VL53LX_DISTANCEMODE_LONG + * @return VL53LX_Error_NONE Success + * @return VL53LX_Error_MODE_NOT_SUPPORTED This error occurs when DistanceMode + * is not in the supported list + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_SetDistanceMode( + VL53LX_DistanceModes DistanceMode); + + /** + * @brief Get the distance mode + * @par Function Description + * Get the distance mode used for the next ranging. + * + * @param Dev Device Handle + * @param *pDistanceMode Pointer to Distance mode + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_GetDistanceMode( + VL53LX_DistanceModes *pDistanceMode); + + + /** + * @brief Set Ranging Timing Budget in microseconds + * + * @par Function Description + * Defines the maximum time allowed by the user to the device to run a + * full ranging sequence for the current mode (ranging, histogram, ASL ...) + * + * @param Dev Device Handle + * @param MeasurementTimingBudgetMicroSeconds Max measurement time in + * microseconds. + * @return VL53LX_Error_NONE Success + * @return VL53LX_Error_INVALID_PARAMS Error timing parameter not + * supported. + * The maximum accepted value for the + * computed timing budget is 10 seconds + * the minimum value depends on the preset + * mode selected. + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_SetMeasurementTimingBudgetMicroSeconds(uint32_t MeasurementTimingBudgetMicroSeconds); + + /** + * @brief Get Ranging Timing Budget in microseconds + * + * @par Function Description + * Returns the programmed the maximum time allowed by the user to the + * device to run a full ranging sequence for the current mode + * (ranging, histogram, ...) + * + * @param Dev Device Handle + * @param pMeasurementTimingBudgetMicroSeconds Max measurement time in + * microseconds. + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_GetMeasurementTimingBudgetMicroSeconds(uint32_t *pMeasurementTimingBudgetMicroSeconds); + /** @} VL53LX_parameters_group */ + + + /** @defgroup VL53LX_measurement_group VL53LX Measurement Functions + * @brief Functions used for the measurements + * @{ + */ + + /** + * @brief Start device measurement + * + * @details Started measurement will depend on distance parameter set through + * @a VL53L3CX_SetDistanceMode() + * + * @note This function Access to the device + * + * @param Dev Device Handle + * @return VL53LX_Error_NONE Success + * @return VL53LX_Error_TIME_OUT Time out on start measurement + * @return VL53LX_Error_INVALID_PARAMS This error might occur in timed mode + * when inter measurement period is smaller or too close to the timing budget. + * In such case measurements are not started and user must correct the timings + * passed to @a VL53LX_SetMeasurementTimingBudgetMicroSeconds() and + * @a VL53LX_SetInterMeasurementPeriodMilliSeconds() functions. + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_StartMeasurement(); + + /** + * @brief Stop device measurement + * + * @details Will set the device in standby mode at end of current measurement\n + * Not necessary in single mode as device shall return automatically + * in standby mode at end of measurement. + * + * @note This function Access to the device + * + * @param Dev Device Handle + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_StopMeasurement(); + + /** + * @brief Clear the Interrupt flag and start new measurement + * * + * @note This function Access to the device + * + * @param Dev Device Handle + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_ClearInterruptAndStartMeasurement(); + + /** + * @brief Return Measurement Data Ready + * + * @par Function Description + * This function indicate that a measurement data is ready. + * This function is used for non-blocking capture. + * + * @note This function Access to the device + * + * @param Dev Device Handle + * @param pMeasurementDataReady Pointer to Measurement Data Ready. + * 0 = data not ready, 1 = data ready + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_GetMeasurementDataReady( + uint8_t *pMeasurementDataReady); + + /** + * @brief Wait for measurement data ready. + * Blocking function. + * Note that the timeout is given by: + * VL53LX_RANGE_COMPLETION_POLLING_TIMEOUT_MS defined in def.h + * + * + * @note This function Access to the device + * + * @param Dev Device Handle + * @return VL53LX_Error_NONE Success + * @return VL53LX_Error_TIME_OUT In case of timeout + */ + VL53LX_Error VL53L3CX_WaitMeasurementDataReady(); + + + /** + * @brief Retrieve all measurements from device with the current setup + * + * @par Function Description + * Get data from last successful Ranging measurement + * + * @warning USER must call @a VL53LX_ClearInterruptAndStartMeasurement() prior + * to call again this function + * + * @note This function Access to the device + * + * @note The first valid value returned by this function will have a range + * status equal to VL53LX_RANGESTATUS_RANGE_VALID_NO_WRAP_CHECK which means that + * the data is valid but no wrap around check have been done. User should take + * care about that. + * + * @param Dev Device Handle + * @param pMultiRangingData Pointer to the data structure to fill up. + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_GetMultiRangingData(VL53LX_MultiRangingData_t *pMultiRangingData); + + /** + * @brief Get Additional Data + * + * @par Function Description + * This function is used to get lld debugging data on the last histogram + * measurement. shall be called when a new measurement is ready (interrupt or + * positive VL53LX_GetMeasurementDataReady() polling) and before a call to + * VL53LX_ClearInterruptAndStartMeasurement(). + * + * @param Dev Device Handle + * @param pAdditionalData Pointer to Additional data + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_GetAdditionalData( VL53LX_AdditionalData_t *pAdditionalData); + + + /** @} VL53LX_measurement_group */ + + /** @defgroup VL53LX_Calibration_group VL53LX Calibration Functions + * @brief Functions used for Calibration + * @{ + */ + + + /** + * @brief Set Tuning Parameter value for a given parameter ID + * + * @par Function Description + * This function is used to improve the performance of the device. It permit to + * change a particular value used for a timeout or a threshold or a constant + * in an algorithm. The function will change the value of the parameter + * identified by an unique ID. + * + * @note This function doesn't Access to the device + * + * @param Dev Device Handle + * @param TuningParameterId Tuning Parameter ID + * @param TuningParameterValue Tuning Parameter Value + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_SetTuningParameter( + uint16_t TuningParameterId, int32_t TuningParameterValue); + + /** + * @brief Get Tuning Parameter value for a given parameter ID + * + * @par Function Description + * This function is used to get the value of the parameter + * identified by an unique ID. + * + * @note This function doesn't Access to the device + * + * @param Dev Device Handle + * @param TuningParameterId Tuning Parameter ID + * @param pTuningParameterValue Pointer to Tuning Parameter Value + * for a given TuningParameterId. + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_GetTuningParameter( + uint16_t TuningParameterId, int32_t *pTuningParameterValue); + + /** + * @brief Performs Reference Spad Management + * + * @par Function Description + * The reference SPAD initialization procedure determines the minimum amount + * of reference spads to be enables to achieve a target reference signal rate + * and should be performed once during initialization. + * + * @note This function Access to the device + * + * @param Dev Device Handle + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_PerformRefSpadManagement(); + + /** + * @brief Enable/Disable dynamic Xtalk compensation feature + * + * Enable/Disable dynamic Xtalk compensation (aka smudge correction). + * + * @param Dev Device Handle + * @param Mode Set the smudge correction mode + * See ::VL53LX_SmudgeCorrectionModes + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_SmudgeCorrectionEnable( + VL53LX_SmudgeCorrectionModes Mode); + + + /** + * @brief Enable/Disable Cross talk compensation feature + * + * Enable/Disable Cross Talk correction. + * + * @param Dev Device Handle + * @param XTalkCompensationEnable Cross talk compensation + * to be set 0 = disabled or 1 = enabled. + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_SetXTalkCompensationEnable( + uint8_t XTalkCompensationEnable); + + /** + * @brief Get Cross talk compensation rate enable + * + * Get if the Cross Talk is Enabled or Disabled. + * + * @note This function doesn't access to the device + * + * @param Dev Device Handle + * @param pXTalkCompensationEnable Pointer to the Cross talk compensation + * state 0=disabled or 1 = enabled + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_GetXTalkCompensationEnable( + uint8_t *pXTalkCompensationEnable); + + /** + * @brief Perform XTalk Calibration + * + * @details Perform a XTalk calibration of the Device. + * This function will launch a measurement, if interrupts + * are enabled an interrupt will be done. + * This function will clear the interrupt generated automatically. + * This function will program a new value for the XTalk compensation + * and it will enable the cross talk before exit. + * + * @warning This function is a blocking function + * + * @note This function Access to the device + * + * @param Dev Device Handle + * the calibration sets appropriate + * distance mode and thus override existing one<br> + * The calibration uses a target which should be located at least @60cm from the + * device. The actual location of the target shall be passed + * through the bare driver tuning parameters table + * + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_PerformXTalkCalibration(); + + + /** + * @brief Define the mode to be used for the offset correction + * + * Define the mode to be used for the offset correction. + * + * @param Dev Device Handle + * @param OffsetCorrectionMode Offset Correction Mode valid values are: + * @li VL53LX_OFFSETCORRECTIONMODE_STANDARD + * @li VL53LX_OFFSETCORRECTIONMODE_PERVCSEL + * + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_SetOffsetCorrectionMode( + VL53LX_OffsetCorrectionModes OffsetCorrectionMode); + + + /** + * @brief Perform Offset simple Calibration + * + * @details Perform a very simple offset calibration of the Device. + * This function will launch few ranging measurements and computes offset + * calibration. The preset mode and the distance mode MUST be set by the + * application before to call this function. + * + * @warning This function is a blocking function + * + * @note This function Access to the device + * + * @param Dev Device Handle + * @param CalDistanceMilliMeter Calibration distance value used for the + * offset compensation. + * + * @return VL53LX_Error_NONE + * @return VL53LX_Error_OFFSET_CAL_NO_SAMPLE_FAIL the calibration failed by + * lack of valid measurements + * @return VL53LX_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH means that the target + * distance combined to the number of loops performed in the calibration lead to + * an internal overflow. Try to reduce the distance of the target (140 mm) + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_PerformOffsetSimpleCalibration( + int32_t CalDistanceMilliMeter); + + /** + * @brief Perform Offset simple Calibration with a "zero distance" target + * + * @details Perform a simple offset calibration of the Device. + * This function will launch few ranging measurements and computes offset + * calibration. The preset mode and the distance mode MUST be set by the + * application before to call this function. + * A target must be place very close to the device. + * Ideally the target shall be touching the coverglass. + * + * @warning This function is a blocking function + * + * @note This function Access to the device + * + * @param Dev Device Handle + * + * @return VL53LX_Error_NONE + * @return VL53LX_Error_OFFSET_CAL_NO_SAMPLE_FAIL the calibration failed by + * lack of valid measurements + * @return VL53LX_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH means that the target + * distance is too large, try to put the target closer to the device + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_PerformOffsetZeroDistanceCalibration(); + + + /** + * @brief Perform Offset per Vcsel Calibration. i.e. per distance mode + * + * @details Perform offset calibration of the Device depending on the + * three distance mode settings: short, medium and long. + * This function will launch few ranging measurements and computes offset + * calibration in each of the three distance modes. + * The preset mode MUST be set by the application before to call this function. + * + * @warning This function is a blocking function + * + * @note This function Access to the device + * + * @param Dev Device Handle + * @param CalDistanceMilliMeter Distance of the target used for the + * offset compensation calibration. + * + * @return VL53LX_Error_NONE + * @return VL53LX_Error_OFFSET_CAL_NO_SAMPLE_FAIL the calibration failed by + * lack of valid measurements + * @return VL53LX_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH means that the target + * distance combined to the number of loops performed in the calibration lead to + * an internal overflow. Try to reduce the distance of the target (140 mm) + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_PerformOffsetPerVcselCalibration( + int32_t CalDistanceMilliMeter); + + + /** + * @brief Sets the Calibration Data. + * + * @par Function Description + * This function set all the Calibration Data issued from the functions + * @a VL53LX_PerformRefSpadManagement(), @a VL53LX_PerformXTalkCalibration, + * @a VL53LX_PerformOffsetCalibration() + * + * @note This function doesn't Accesses the device + * + * @param Dev Device Handle + * @param *pCalibrationData Pointer to Calibration data to be set. + * @return VL53LX_Error_NONE Success + * @return VL53LX_Error_INVALID_PARAMS pCalibrationData points to an older + * version of the inner structure. Need for support to convert its content. + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_SetCalibrationData( + VL53LX_CalibrationData_t *pCalibrationData); + + /** + * @brief Gets the Calibration Data. + * + * @par Function Description + * This function get all the Calibration Data issued from the functions + * @a VL53LX_PerformRefSpadManagement(), @a VL53LX_PerformXTalkCalibration, + * @a VL53LX_PerformOffsetCalibration() + * + * @note This function doesn't Accesses the device + * + * @param Dev Device Handle + * @param *pCalibrationData pointer where to store Calibration + * data. + * @return VL53LX_Error_NONE Success + * @return "Other error code" See ::VL53LX_Error + */ + VL53LX_Error VL53L3CX_GetCalibrationData( + VL53LX_CalibrationData_t *pCalibrationData); + + /** @} VL53LX_Calibration_group */ + + /** @} VL53LX_group */ + VL53LX_Error VL53L3CX_RdWord(VL53LX_DEV Dev, uint16_t index, uint16_t *data); + + // protected: + + /* vl53lx_api_core.h functions */ + + VL53LX_Error VL53L3CX_get_version(VL53LX_ll_version_t *pversion); + VL53LX_Error VL53L3CX_data_init(uint8_t read_p2p_data); + VL53LX_Error VL53L3CX_read_p2p_data(); + VL53LX_Error VL53L3CX_set_part_to_part_data(VL53LX_calibration_data_t *pcal_data); + VL53LX_Error VL53L3CX_get_part_to_part_data(VL53LX_calibration_data_t *pcal_data); + VL53LX_Error VL53L3CX_get_tuning_debug_data(VL53LX_tuning_parameters_t *ptun_data); + VL53LX_Error VL53L3CX_set_inter_measurement_period_ms(uint32_t inter_measurement_period_ms); + VL53LX_Error VL53L3CX_get_inter_measurement_period_ms(uint32_t *pinter_measurement_period_ms); + VL53LX_Error VL53L3CX_set_timeouts_us( + uint32_t phasecal_config_timeout_us, + uint32_t mm_config_timeout_us, + uint32_t range_config_timeout_us); + + VL53LX_Error VL53L3CX_get_timeouts_us( + uint32_t *pphasecal_config_timeout_us, + uint32_t *pmm_config_timeout_us, + uint32_t *prange_config_timeout_us); + + + + + VL53LX_Error VL53L3CX_set_user_zone( + VL53LX_user_zone_t *puser_zone); + + VL53LX_Error VL53L3CX_get_user_zone( + VL53LX_user_zone_t *puser_zone); + + + VL53LX_Error VL53L3CX_get_mode_mitigation_roi( + VL53LX_user_zone_t *pmm_roi); + + + VL53LX_Error VL53L3CX_set_zone_config( + VL53LX_zone_config_t *pzone_cfg); + + VL53LX_Error VL53L3CX_get_zone_config( + VL53LX_zone_config_t *pzone_cfg); + + + VL53LX_Error VL53L3CX_set_preset_mode( + VL53LX_DevicePresetModes device_preset_mode, + uint16_t dss_config__target_total_rate_mcps, + uint32_t phasecal_config_timeout_us, + uint32_t mm_config_timeout_us, + uint32_t range_config_timeout_us, + uint32_t inter_measurement_period_ms); + + VL53LX_Error VL53L3CX_get_preset_mode_timing_cfg( + VL53LX_DevicePresetModes device_preset_mode, + uint16_t *pdss_config__target_total_rate_mcps, + uint32_t *pphasecal_config_timeout_us, + uint32_t *pmm_config_timeout_us, + uint32_t *prange_config_timeout_us); + + + VL53LX_Error VL53L3CX_set_zone_preset( + VL53LX_DeviceZonePreset zone_preset); + + + VL53LX_Error VL53L3CX_enable_xtalk_compensation(); + + VL53LX_Error VL53L3CX_disable_xtalk_compensation(); + + + void VL53L3CX_get_xtalk_compensation_enable( + uint8_t *pcrosstalk_compensation_enable); + + + VL53LX_Error VL53L3CX_init_and_start_range( + uint8_t measurement_mode, + VL53LX_DeviceConfigLevel device_config_level); + + + VL53LX_Error VL53L3CX_stop_range(); // remove + + VL53LX_Error VL53L3CX_get_measurement_results( + VL53LX_DeviceResultsLevel device_result_level); + + + VL53LX_Error VL53L3CX_get_device_results( + VL53LX_DeviceResultsLevel device_result_level, + VL53LX_range_results_t *prange_results); + + + VL53LX_Error VL53L3CX_clear_interrupt_and_enable_next_range( + uint8_t measurement_mode); + + + VL53LX_Error VL53L3CX_get_histogram_bin_data( + VL53LX_histogram_bin_data_t *phist_data); + + void VL53L3CX_copy_sys_and_core_results_to_range_results( + int32_t gain_factor, + VL53LX_system_results_t *psys, + VL53LX_core_results_t *pcore, + VL53LX_range_results_t *presults); + + + + VL53LX_Error VL53L3CX_set_zone_dss_config( + VL53LX_zone_private_dyn_cfg_t *pzone_dyn_cfg); + + + VL53LX_Error VL53L3CX_set_dmax_mode( + VL53LX_DeviceDmaxMode dmax_mode); + + + VL53LX_Error VL53L3CX_get_dmax_mode( + VL53LX_DeviceDmaxMode *pdmax_mode); + + + VL53LX_Error VL53L3CX_set_dmax_calibration_data( + VL53LX_DeviceDmaxMode dmax_mode, + VL53LX_dmax_calibration_data_t *pdmax_cal); + + + VL53LX_Error VL53L3CX_get_dmax_calibration_data( + VL53LX_DeviceDmaxMode dmax_mode, + VL53LX_dmax_calibration_data_t *pdmax_cal); + + + VL53LX_Error VL53L3CX_set_offset_correction_mode( + VL53LX_OffsetCalibrationMode offset_cor_mode); + + + VL53LX_Error VL53L3CX_get_offset_correction_mode( + VL53LX_OffsetCorrectionMode *poffset_cor_mode); + + + VL53LX_Error VL53L3CX_et_zone_calibration_data( + VL53LX_zone_calibration_results_t *pzone_cal); + + + VL53LX_Error VL53L3CX_set_zone_calibration_data( + VL53LX_zone_calibration_results_t *pzone_cal); + + + + VL53LX_Error VL53L3CX_get_tuning_parm( + VL53LX_TuningParms tuning_parm_key, + int32_t *ptuning_parm_value); + + + + VL53LX_Error VL53L3CX_set_tuning_parm( + VL53LX_TuningParms tuning_parm_key, + int32_t tuning_parm_value); + + + + VL53LX_Error VL53L3CX_dynamic_xtalk_correction_enable(); + + + + VL53LX_Error VL53L3CX_dynamic_xtalk_correction_disable(); + + + + + VL53LX_Error VL53L3CX_dynamic_xtalk_correction_apply_enable(); + + + + VL53LX_Error VL53L3CX_dynamic_xtalk_correction_apply_disable(); + + + + VL53LX_Error VL53L3CX_dynamic_xtalk_correction_single_apply_enable(); + + + + VL53LX_Error VL53L3CX_dynamic_xtalk_correction_single_apply_disable(); + + + VL53LX_Error VL53L3CX_get_current_xtalk_settings( + + VL53LX_xtalk_calibration_results_t *pxtalk + ); + + + + VL53LX_Error VL53L3CX_set_current_xtalk_settings( + + VL53LX_xtalk_calibration_results_t *pxtalk + ); + + VL53LX_Error VL53L3CX_load_patch(); + + VL53LX_Error VL53L3CX_unload_patch(); + + + /* vl53lx_register_funcs.h */ + + + VL53LX_Error VL53L3CX_i2c_encode_static_nvm_managed( + VL53LX_static_nvm_managed_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_static_nvm_managed( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_static_nvm_managed_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_static_nvm_managed( + VL53LX_static_nvm_managed_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_static_nvm_managed( + VL53LX_static_nvm_managed_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_customer_nvm_managed( + VL53LX_customer_nvm_managed_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_customer_nvm_managed( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_customer_nvm_managed_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_customer_nvm_managed( + VL53LX_customer_nvm_managed_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_customer_nvm_managed( + VL53LX_customer_nvm_managed_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_static_config( + VL53LX_static_config_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_static_config( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_static_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_static_config( + VL53LX_static_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_static_config( + VL53LX_static_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_general_config( + VL53LX_general_config_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_general_config( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_general_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_general_config( + VL53LX_general_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_general_config( + VL53LX_general_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_timing_config( + VL53LX_timing_config_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_timing_config( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_timing_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_timing_config( + VL53LX_timing_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_timing_config( + VL53LX_timing_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_dynamic_config( + VL53LX_dynamic_config_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_dynamic_config( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_dynamic_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_dynamic_config( + VL53LX_dynamic_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_dynamic_config( + VL53LX_dynamic_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_system_control( + VL53LX_system_control_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_system_control( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_system_control_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_system_control( + VL53LX_system_control_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_system_control( + VL53LX_system_control_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_system_results( + VL53LX_system_results_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_system_results( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_system_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_system_results( + VL53LX_system_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_system_results( + VL53LX_system_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_core_results( + VL53LX_core_results_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_core_results( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_core_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_core_results( + VL53LX_core_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_core_results( + VL53LX_core_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_debug_results( + VL53LX_debug_results_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_debug_results( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_debug_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_debug_results( + VL53LX_debug_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_debug_results( + VL53LX_debug_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_nvm_copy_data( + VL53LX_nvm_copy_data_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_nvm_copy_data( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_nvm_copy_data_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_nvm_copy_data( + VL53LX_nvm_copy_data_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_nvm_copy_data( + VL53LX_nvm_copy_data_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_prev_shadow_system_results( + VL53LX_prev_shadow_system_results_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_prev_shadow_system_results( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_prev_shadow_system_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_prev_shadow_system_results( + VL53LX_prev_shadow_system_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_prev_shadow_system_results( + VL53LX_prev_shadow_system_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_prev_shadow_core_results( + VL53LX_prev_shadow_core_results_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_prev_shadow_core_results( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_prev_shadow_core_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_prev_shadow_core_results( + VL53LX_prev_shadow_core_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_prev_shadow_core_results( + VL53LX_prev_shadow_core_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_patch_debug( + VL53LX_patch_debug_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_patch_debug( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_patch_debug_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_patch_debug( + VL53LX_patch_debug_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_patch_debug( + VL53LX_patch_debug_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_gph_general_config( + VL53LX_gph_general_config_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_gph_general_config( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_gph_general_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_gph_general_config( + VL53LX_gph_general_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_gph_general_config( + VL53LX_gph_general_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_gph_static_config( + VL53LX_gph_static_config_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_gph_static_config( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_gph_static_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_gph_static_config( + VL53LX_gph_static_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_gph_static_config( + VL53LX_gph_static_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_gph_timing_config( + VL53LX_gph_timing_config_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_gph_timing_config( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_gph_timing_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_gph_timing_config( + VL53LX_gph_timing_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_gph_timing_config( + VL53LX_gph_timing_config_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_fw_internal( + VL53LX_fw_internal_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_fw_internal( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_fw_internal_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_fw_internal( + VL53LX_fw_internal_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_fw_internal( + VL53LX_fw_internal_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_patch_results( + VL53LX_patch_results_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_patch_results( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_patch_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_patch_results( + VL53LX_patch_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_patch_results( + VL53LX_patch_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_shadow_system_results( + VL53LX_shadow_system_results_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_shadow_system_results( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_shadow_system_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_shadow_system_results( + VL53LX_shadow_system_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_shadow_system_results( + VL53LX_shadow_system_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_i2c_encode_shadow_core_results( + VL53LX_shadow_core_results_t *pdata, + uint16_t buf_size, + uint8_t *pbuffer); + + + + + VL53LX_Error VL53L3CX_i2c_decode_shadow_core_results( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_shadow_core_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_set_shadow_core_results( + VL53LX_shadow_core_results_t *pdata); + + + + + VL53LX_Error VL53L3CX_get_shadow_core_results( + VL53LX_shadow_core_results_t *pdata); + + + + /* vl53lx_nvm.h */ + + + VL53LX_Error VL53L3CX_nvm_enable( + uint16_t nvm_ctrl_pulse_width, + int32_t nvm_power_up_delay_us); + + + + + VL53LX_Error VL53L3CX_nvm_read( + uint8_t start_address, + uint8_t count, + uint8_t *pdata); + + + + + VL53LX_Error VL53L3CX_nvm_disable(); + + + + + VL53LX_Error VL53L3CX_nvm_format_decode( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_decoded_nvm_data_t *pdata); + + + + + VL53LX_Error VL53L3CX_nvm_decode_optical_centre( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_optical_centre_t *pdata); + + + + + VL53LX_Error VL53L3CX_nvm_decode_cal_peak_rate_map( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_cal_peak_rate_map_t *pdata); + + + + + VL53LX_Error VL53L3CX_nvm_decode_additional_offset_cal_data( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_additional_offset_cal_data_t *pdata); + + + + + VL53LX_Error VL53L3CX_nvm_decode_fmt_range_results_data( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_decoded_nvm_fmt_range_data_t *pdata); + + + + + VL53LX_Error VL53L3CX_nvm_decode_fmt_info( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_decoded_nvm_fmt_info_t *pdata); + + + + + VL53LX_Error VL53L3CX_nvm_decode_ews_info( + uint16_t buf_size, + uint8_t *pbuffer, + VL53LX_decoded_nvm_ews_info_t *pdata); + + + + + void VL53L3CX_nvm_format_encode( + VL53LX_decoded_nvm_data_t *pnvm_info, + uint8_t *pnvm_data); + + + + + VL53LX_Error VL53L3CX_read_nvm_raw_data( + uint8_t start_address, + uint8_t count, + uint8_t *pnvm_raw_data); + + + + + VL53LX_Error VL53L3CX_read_nvm( + uint8_t nvm_format, + VL53LX_decoded_nvm_data_t *pnvm_info); + + + + + VL53LX_Error VL53L3CX_read_nvm_optical_centre( + VL53LX_optical_centre_t *pcentre); + + + + + VL53LX_Error VL53L3CX_read_nvm_cal_peak_rate_map( + VL53LX_cal_peak_rate_map_t *pcal_data); + + + + + VL53LX_Error VL53L3CX_read_nvm_additional_offset_cal_data( + VL53LX_additional_offset_cal_data_t *pcal_data); + + + + + VL53LX_Error VL53L3CX_read_nvm_fmt_range_results_data( + uint16_t range_results_select, + VL53LX_decoded_nvm_fmt_range_data_t *prange_data); + + + + /* vl53lx_platform_ipp.h */ + + VL53LX_Error VL53L3CX_ipp_hist_process_data( + VL53LX_dmax_calibration_data_t *pdmax_cal, + VL53LX_hist_gen3_dmax_config_t *pdmax_cfg, + VL53LX_hist_post_process_config_t *ppost_cfg, + VL53LX_histogram_bin_data_t *pbins, + VL53LX_xtalk_histogram_data_t *pxtalk, + uint8_t *pArea1, + uint8_t *pArea2, + uint8_t *phisto_merge_nb, + VL53LX_range_results_t *presults); + + VL53LX_Error VL53L3CX_ipp_hist_ambient_dmax( + uint16_t target_reflectance, + VL53LX_dmax_calibration_data_t *pdmax_cal, + VL53LX_hist_gen3_dmax_config_t *pdmax_cfg, + VL53LX_histogram_bin_data_t *pbins, + int16_t *pambient_dmax_mm); + + VL53LX_Error VL53L3CX_ipp_xtalk_calibration_process_data( + VL53LX_xtalk_range_results_t *pxtalk_ranges, + VL53LX_xtalk_histogram_data_t *pxtalk_shape, + VL53LX_xtalk_calibration_results_t *pxtalk_cal); + + + + + /* vl53lx_hist_funcs.h */ + + + VL53LX_Error VL53L3CX_hist_process_data( + VL53LX_dmax_calibration_data_t *pdmax_cal, + VL53LX_hist_gen3_dmax_config_t *pdmax_cfg, + VL53LX_hist_post_process_config_t *ppost_cfg, + VL53LX_histogram_bin_data_t *pbins, + VL53LX_xtalk_histogram_data_t *pxtalk, + uint8_t *pArea1, + uint8_t *pArea2, + VL53LX_range_results_t *presults, + uint8_t *HistMergeNumber); + + + VL53LX_Error VL53L3CX_hist_ambient_dmax( + uint16_t target_reflectance, + VL53LX_dmax_calibration_data_t *pdmax_cal, + VL53LX_hist_gen3_dmax_config_t *pdmax_cfg, + VL53LX_histogram_bin_data_t *pbins, + int16_t *pambient_dmax_mm); + + + /* vl53lx_core_support.h */ + + uint8_t VL53L3CX_decode_vcsel_period( uint8_t vcsel_period_reg); + + uint32_t VL53L3CX_events_per_spad_maths( + int32_t VL53LX_p_010, + uint16_t num_spads, + uint32_t duration); + + uint32_t VL53L3CX_isqrt( + uint32_t num); + + void VL53L3CX_hist_calc_zero_distance_phase( + VL53LX_histogram_bin_data_t *pdata); + + void VL53L3CX_hist_estimate_ambient_from_thresholded_bins( + int32_t ambient_threshold_sigma, + VL53LX_histogram_bin_data_t *pdata); + + void VL53L3CX_hist_remove_ambient_bins( + VL53LX_histogram_bin_data_t *pdata); + + uint32_t VL53L3CX_calc_pll_period_mm( + uint16_t fast_osc_frequency); + + uint16_t VL53L3CX_rate_maths( + int32_t VL53LX_p_018, + uint32_t time_us); + + uint16_t VL53L3CX_rate_per_spad_maths( + uint32_t frac_bits, + uint32_t peak_count_rate, + uint16_t num_spads, + uint32_t max_output_value); + + int32_t VL53L3CX_range_maths( + uint16_t fast_osc_frequency, + uint16_t VL53LX_p_014, + uint16_t zero_distance_phase, + uint8_t fractional_bits, + int32_t gain_factor, + int32_t range_offset_mm); + + + void VL53L3CX_copy_xtalk_bin_data_to_histogram_data_struct( + VL53LX_xtalk_histogram_shape_t *pxtalk, + VL53LX_histogram_bin_data_t *phist); + + void VL53L3CX_init_histogram_bin_data_struct( + int32_t bin_value, + uint16_t VL53LX_p_021, + VL53LX_histogram_bin_data_t *pdata); + + void VL53L3CX_decode_row_col( + uint8_t spad_number, + uint8_t *prow, + uint8_t *pcol); + + void VL53L3CX_hist_find_min_max_bin_values( + VL53LX_histogram_bin_data_t *pdata); + + void VL53L3CX_hist_estimate_ambient_from_ambient_bins( + VL53LX_histogram_bin_data_t *pdata); + + uint32_t VL53L3CX_calc_pll_period_us( + uint16_t fast_osc_frequency); + + uint32_t VL53L3CX_duration_maths( + uint32_t pll_period_us, + uint32_t vcsel_parm_pclks, + uint32_t window_vclks, + uint32_t periods_elapsed_mclks); + + + /* vl53lx_core.h */ + + void VL53L3CX_init_version(); + + void VL53L3CX_init_ll_driver_state( + VL53LX_DeviceState ll_state); + + VL53LX_Error VL53L3CX_update_ll_driver_rd_state(); + + VL53LX_Error VL53L3CX_check_ll_driver_rd_state(); + + VL53LX_Error VL53L3CX_update_ll_driver_cfg_state(); + + void VL53L3CX_copy_rtn_good_spads_to_buffer( + VL53LX_nvm_copy_data_t *pdata, + uint8_t *pbuffer); + + void VL53L3CX_init_system_results( + VL53LX_system_results_t *pdata); + + void VL53L3CX_init_zone_results_structure( + uint8_t active_zones, + VL53LX_zone_results_t *pdata); + + void VL53L3CX_init_zone_dss_configs(); + + void VL53L3CX_init_histogram_config_structure( + uint8_t even_bin0, + uint8_t even_bin1, + uint8_t even_bin2, + uint8_t even_bin3, + uint8_t even_bin4, + uint8_t even_bin5, + uint8_t odd_bin0, + uint8_t odd_bin1, + uint8_t odd_bin2, + uint8_t odd_bin3, + uint8_t odd_bin4, + uint8_t odd_bin5, + VL53LX_histogram_config_t *pdata); + + void VL53L3CX_init_histogram_multizone_config_structure( + uint8_t even_bin0, + uint8_t even_bin1, + uint8_t even_bin2, + uint8_t even_bin3, + uint8_t even_bin4, + uint8_t even_bin5, + uint8_t odd_bin0, + uint8_t odd_bin1, + uint8_t odd_bin2, + uint8_t odd_bin3, + uint8_t odd_bin4, + uint8_t odd_bin5, + VL53LX_histogram_config_t *pdata); + + void VL53L3CX_init_xtalk_bin_data_struct( + uint32_t bin_value, + uint16_t VL53LX_p_021, + VL53LX_xtalk_histogram_shape_t *pdata); + + void VL53L3CX_i2c_encode_uint16_t( + uint16_t ip_value, + uint16_t count, + uint8_t *pbuffer); + + uint16_t VL53L3CX_i2c_decode_uint16_t( + uint16_t count, + uint8_t *pbuffer); + + void VL53L3CX_i2c_encode_int16_t( + int16_t ip_value, + uint16_t count, + uint8_t *pbuffer); + + int16_t VL53L3CX_i2c_decode_int16_t( + uint16_t count, + uint8_t *pbuffer); + + void VL53L3CX_i2c_encode_uint32_t( + uint32_t ip_value, + uint16_t count, + uint8_t *pbuffer); + + uint32_t VL53L3CX_i2c_decode_uint32_t( + uint16_t count, + uint8_t *pbuffer); + + uint32_t VL53L3CX_i2c_decode_with_mask( + uint16_t count, + uint8_t *pbuffer, + uint32_t bit_mask, + uint32_t down_shift, + uint32_t offset); + + void VL53L3CX_i2c_encode_int32_t( + int32_t ip_value, + uint16_t count, + uint8_t *pbuffer); + + int32_t VL53L3CX_i2c_decode_int32_t( + uint16_t count, + uint8_t *pbuffer); + + VL53LX_Error VL53L3CX_start_test( + uint8_t test_mode__ctrl); + + VL53LX_Error VL53L3CX_set_firmware_enable_register(uint8_t value); + + VL53LX_Error VL53L3CX_enable_firmware(); + + VL53LX_Error VL53L3CX_disable_firmware(); + + VL53LX_Error VL53L3CX_set_powerforce_register( + uint8_t value); + + VL53LX_Error VL53L3CX_enable_powerforce(); + + VL53LX_Error VL53L3CX_disable_powerforce(); + + VL53LX_Error VL53L3CX_clear_interrupt(); + + VL53LX_Error VL53L3CX_force_shadow_stream_count_to_zero(); + + uint32_t VL53L3CX_calc_macro_period_us( + uint16_t fast_osc_frequency, + uint8_t VL53LX_p_005); + + uint16_t VL53L3CX_calc_range_ignore_threshold( + uint32_t central_rate, + int16_t x_gradient, + int16_t y_gradient, + uint8_t rate_mult); + + uint32_t VL53L3CX_calc_timeout_mclks( + uint32_t timeout_us, + uint32_t macro_period_us); + + uint16_t VL53L3CX_calc_encoded_timeout( + uint32_t timeout_us, + uint32_t macro_period_us); + + uint32_t VL53L3CX_calc_timeout_us( + uint32_t timeout_mclks, + uint32_t macro_period_us); + + uint32_t VL53L3CX_calc_decoded_timeout_us( + uint16_t timeout_encoded, + uint32_t macro_period_us); + + uint16_t VL53L3CX_encode_timeout( + uint32_t timeout_mclks); + + uint32_t VL53L3CX_decode_timeout( + uint16_t encoded_timeout); + + VL53LX_Error VL53L3CX_calc_timeout_register_values( + uint32_t phasecal_config_timeout_us, + uint32_t mm_config_timeout_us, + uint32_t range_config_timeout_us, + uint16_t fast_osc_frequency, + VL53LX_general_config_t *pgeneral, + VL53LX_timing_config_t *ptiming); + + uint8_t VL53L3CX_encode_vcsel_period( + uint8_t VL53LX_p_030); + + uint32_t VL53L3CX_decode_unsigned_integer( + uint8_t *pbuffer, + uint8_t no_of_bytes); + + void VL53L3CX_encode_unsigned_integer( + uint32_t ip_value, + uint8_t no_of_bytes, + uint8_t *pbuffer); + + VL53LX_Error VL53L3CX_hist_copy_and_scale_ambient_info( + VL53LX_zone_hist_info_t *pidata, + VL53LX_histogram_bin_data_t *podata); + + void VL53L3CX_hist_get_bin_sequence_config( + VL53LX_histogram_bin_data_t *pdata); + + VL53LX_Error VL53L3CX_hist_phase_consistency_check( + VL53LX_zone_hist_info_t *phist_prev, + VL53LX_zone_objects_t *prange_prev, + VL53LX_range_results_t *prange_curr); + + VL53LX_Error VL53L3CX_hist_events_consistency_check( + uint8_t event_sigma, + uint16_t min_effective_spad_count, + VL53LX_zone_hist_info_t *phist_prev, + VL53LX_object_data_t *prange_prev, + VL53LX_range_data_t *prange_curr, + int32_t *pevents_tolerance, + int32_t *pevents_delta, + VL53LX_DeviceError *prange_status); + + VL53LX_Error VL53L3CX_hist_merged_pulse_check( + int16_t min_max_tolerance_mm, + VL53LX_range_data_t *pdata, + VL53LX_DeviceError *prange_status); + + VL53LX_Error VL53L3CX_hist_xmonitor_consistency_check( + VL53LX_zone_hist_info_t *phist_prev, + VL53LX_zone_objects_t *prange_prev, + VL53LX_range_data_t *prange_curr); + + VL53LX_Error VL53L3CX_hist_wrap_dmax( + VL53LX_hist_post_process_config_t *phistpostprocess, + VL53LX_histogram_bin_data_t *pcurrent, + int16_t *pwrap_dmax_mm); + + void VL53L3CX_hist_combine_mm1_mm2_offsets( + int16_t mm1_offset_mm, + int16_t mm2_offset_mm, + uint8_t encoded_mm_roi_centre, + uint8_t encoded_mm_roi_size, + uint8_t encoded_zone_centre, + uint8_t encoded_zone_size, + VL53LX_additional_offset_cal_data_t *pcal_data, + uint8_t *pgood_spads, + uint16_t aperture_attenuation, + int16_t *prange_offset_mm); + + VL53LX_Error VL53L3CX_hist_xtalk_extract_calc_window( + int16_t target_distance_mm, + uint16_t target_width_oversize, + VL53LX_histogram_bin_data_t *phist_bins, + VL53LX_hist_xtalk_extract_data_t *pxtalk_data); + + VL53LX_Error VL53L3CX_hist_xtalk_extract_calc_event_sums( + VL53LX_histogram_bin_data_t *phist_bins, + VL53LX_hist_xtalk_extract_data_t *pxtalk_data); + + VL53LX_Error VL53L3CX_hist_xtalk_extract_calc_rate_per_spad( + VL53LX_hist_xtalk_extract_data_t *pxtalk_data); + + VL53LX_Error VL53L3CX_hist_xtalk_extract_calc_shape( + VL53LX_hist_xtalk_extract_data_t *pxtalk_data, + VL53LX_xtalk_histogram_shape_t *pxtalk_shape); + + VL53LX_Error VL53L3CX_hist_xtalk_shape_model( + uint16_t events_per_bin, + uint16_t pulse_centre, + uint16_t pulse_width, + VL53LX_xtalk_histogram_shape_t *pxtalk_shape); + + uint16_t VL53L3CX_hist_xtalk_shape_model_interp( + uint16_t events_per_bin, + uint32_t phase_delta); + + void VL53L3CX_spad_number_to_byte_bit_index( + uint8_t spad_number, + uint8_t *pbyte_index, + uint8_t *pbit_index, + uint8_t *pbit_mask); + + void VL53L3CX_encode_row_col( + uint8_t row, + uint8_t col, + uint8_t *pspad_number); + + void VL53L3CX_decode_zone_size( + uint8_t encoded_xy_size, + uint8_t *pwidth, + uint8_t *pheight); + + void VL53L3CX_encode_zone_size( + uint8_t width, + uint8_t height, + uint8_t *pencoded_xy_size); + + void VL53L3CX_decode_zone_limits( + uint8_t encoded_xy_centre, + uint8_t encoded_xy_size, + int16_t *px_ll, + int16_t *py_ll, + int16_t *px_ur, + int16_t *py_ur); + + uint8_t VL53L3CX_is_aperture_location( + uint8_t row, + uint8_t col); + + void VL53L3CX_calc_max_effective_spads( + uint8_t encoded_zone_centre, + uint8_t encoded_zone_size, + uint8_t *pgood_spads, + uint16_t aperture_attenuation, + uint16_t *pmax_effective_spads); + + void VL53L3CX_calc_mm_effective_spads( + uint8_t encoded_mm_roi_centre, + uint8_t encoded_mm_roi_size, + uint8_t encoded_zone_centre, + uint8_t encoded_zone_size, + uint8_t *pgood_spads, + uint16_t aperture_attenuation, + uint16_t *pmm_inner_effective_spads, + uint16_t *pmm_outer_effective_spads); + + void VL53L3CX_hist_copy_results_to_sys_and_core( + VL53LX_histogram_bin_data_t *pbins, + VL53LX_range_results_t *phist, + VL53LX_system_results_t *psys, + VL53LX_core_results_t *pcore); + + + + + VL53LX_Error VL53L3CX_save_cfg_data(); + + VL53LX_Error VL53L3CX_dynamic_zone_update( + VL53LX_range_results_t *presults); + + VL53LX_Error VL53L3CX_update_internal_stream_counters( + uint8_t external_stream_count, + uint8_t *pinternal_stream_count, + uint8_t *pinternal_stream_count_val + ); + + VL53LX_Error VL53L3CX_multizone_hist_bins_update(); + + VL53LX_Error VL53L3CX_set_histogram_multizone_initial_bin_config( + VL53LX_zone_config_t *pzone_cfg, + VL53LX_histogram_config_t *phist_cfg, + VL53LX_histogram_config_t *pmulti_hist + ); + + uint8_t VL53L3CX_encode_GPIO_interrupt_config( + VL53LX_GPIO_interrupt_config_t *pintconf); + + VL53LX_GPIO_interrupt_config_t VL53L3CX_decode_GPIO_interrupt_config( + uint8_t system__interrupt_config); + + VL53LX_Error VL53L3CX_set_GPIO_distance_threshold( + uint16_t threshold_high, + uint16_t threshold_low); + + VL53LX_Error VL53L3CX_set_GPIO_rate_threshold( + uint16_t threshold_high, + uint16_t threshold_low); + + VL53LX_Error VL53L3CX_set_GPIO_thresholds_from_struct( + VL53LX_GPIO_interrupt_config_t *pintconf); + + VL53LX_Error VL53L3CX_set_ref_spad_char_config( + uint8_t vcsel_period_a, + uint32_t phasecal_timeout_us, + uint16_t total_rate_target_mcps, + uint16_t max_count_rate_rtn_limit_mcps, + uint16_t min_count_rate_rtn_limit_mcps, + uint16_t fast_osc_frequency); + + VL53LX_Error VL53L3CX_set_ssc_config( + VL53LX_ssc_config_t *pssc_cfg, + uint16_t fast_osc_frequency); + + VL53LX_Error VL53L3CX_get_spad_rate_data( + VL53LX_spad_rate_data_t *pspad_rates); + + uint32_t VL53L3CX_calc_crosstalk_plane_offset_with_margin( + uint32_t plane_offset_kcps, + int16_t margin_offset_kcps); + + VL53LX_Error VL53L3CX_low_power_auto_data_init(); + + VL53LX_Error VL53L3CX_low_power_auto_data_stop_range(); + + VL53LX_Error VL53L3CX_dynamic_xtalk_correction_calc_required_samples(); + + VL53LX_Error VL53L3CX_dynamic_xtalk_correction_calc_new_xtalk( + uint32_t xtalk_offset_out, + VL53LX_smudge_corrector_config_t *pconfig, + VL53LX_smudge_corrector_data_t *pout, + uint8_t add_smudge, + uint8_t soft_update + ); + + VL53LX_Error VL53L3CX_dynamic_xtalk_correction_corrector(); + + VL53LX_Error VL53L3CX_dynamic_xtalk_correction_data_init(); + + VL53LX_Error VL53L3CX_dynamic_xtalk_correction_output_init( + VL53LX_LLDriverResults_t *pres + ); + + VL53LX_Error VL53L3CX_xtalk_cal_data_init(); + + VL53LX_Error VL53L3CX_config_low_power_auto_mode( + VL53LX_general_config_t *pgeneral, + VL53LX_dynamic_config_t *pdynamic, + VL53LX_low_power_auto_data_t *plpadata + ); + + VL53LX_Error VL53L3CX_low_power_auto_setup_manual_calibration(); + + VL53LX_Error VL53L3CX_low_power_auto_update_DSS(); + + VL53LX_Error VL53L3CX_compute_histo_merge_nb(uint8_t *histo_merge_nb); + + + + /* vl53lx_wait.h */ + + VL53LX_Error VL53L3CX_wait_for_boot_completion(); + + VL53LX_Error VL53L3CX_wait_for_firmware_ready(); + + VL53LX_Error VL53L3CX_wait_for_range_completion(); + + VL53LX_Error VL53L3CX_wait_for_test_completion(); + + VL53LX_Error VL53L3CX_is_boot_complete(uint8_t *pready); + + VL53LX_Error VL53L3CX_is_firmware_ready(uint8_t *pready); + + VL53LX_Error VL53L3CX_is_new_data_ready(uint8_t *pready); + + VL53LX_Error VL53L3CX_poll_for_boot_completion(uint32_t timeout_ms); + + VL53LX_Error VL53L3CX_poll_for_firmware_ready(uint32_t timeout_ms); + + VL53LX_Error VL53L3CX_poll_for_range_completion(uint32_t timeout_ms); + + + /* vl53lx_zone_presets.h */ + + VL53LX_Error VL53L3CX_init_zone_config_structure( + uint8_t x_off, + uint8_t x_inc, + uint8_t x_zones, + uint8_t y_off, + uint8_t y_inc, + uint8_t y_zones, + uint8_t width, + uint8_t height, + VL53LX_zone_config_t *pdata); + + + VL53LX_Error VL53L3CX_init_zone_config_histogram_bins( + VL53LX_zone_config_t *pdata); + + + /* vl53lx_api_preset_modes.h */ + + VL53LX_Error VL53L3CX_init_refspadchar_config_struct( + VL53LX_refspadchar_config_t *pdata); + + VL53LX_Error VL53L3CX_init_ssc_config_struct( + VL53LX_ssc_config_t *pdata); + + VL53LX_Error VL53L3CX_init_xtalk_config_struct( + VL53LX_customer_nvm_managed_t *pnvm, + VL53LX_xtalk_config_t *pdata); + + VL53LX_Error VL53L3CX_init_xtalk_extract_config_struct( + VL53LX_xtalkextract_config_t *pdata); + + VL53LX_Error VL53L3CX_init_offset_cal_config_struct( + VL53LX_offsetcal_config_t *pdata); + + VL53LX_Error VL53L3CX_init_zone_cal_config_struct( + VL53LX_zonecal_config_t *pdata); + + VL53LX_Error VL53L3CX_init_hist_post_process_config_struct( + uint8_t xtalk_compensation_enable, + VL53LX_hist_post_process_config_t *pdata); + + VL53LX_Error VL53L3CX_init_dmax_calibration_data_struct( + VL53LX_dmax_calibration_data_t *pdata); + + VL53LX_Error VL53L3CX_init_tuning_parm_storage_struct( + VL53LX_tuning_parm_storage_t *pdata); + + VL53LX_Error VL53L3CX_init_hist_gen3_dmax_config_struct( + VL53LX_hist_gen3_dmax_config_t *pdata); + + VL53LX_Error VL53L3CX_preset_mode_standard_ranging( + VL53LX_static_config_t *pstatic, + VL53LX_histogram_config_t *phistogram, + VL53LX_general_config_t *pgeneral, + VL53LX_timing_config_t *ptiming, + VL53LX_dynamic_config_t *pdynamic, + VL53LX_system_control_t *psystem, + VL53LX_tuning_parm_storage_t *ptuning_parms, + VL53LX_zone_config_t *pzone_cfg); + + + + VL53LX_Error VL53L3CX_preset_mode_histogram_ranging( + VL53LX_hist_post_process_config_t *phistpostprocess, + VL53LX_static_config_t *pstatic, + VL53LX_histogram_config_t *phistogram, + VL53LX_general_config_t *pgeneral, + VL53LX_timing_config_t *ptiming, + VL53LX_dynamic_config_t *pdynamic, + VL53LX_system_control_t *psystem, + VL53LX_tuning_parm_storage_t *ptuning_parms, + VL53LX_zone_config_t *pzone_cfg); + + + VL53LX_Error VL53L3CX_preset_mode_histogram_characterisation( + VL53LX_hist_post_process_config_t *phistpostprocess, + VL53LX_static_config_t *pstatic, + VL53LX_histogram_config_t *phistogram, + VL53LX_general_config_t *pgeneral, + VL53LX_timing_config_t *ptiming, + VL53LX_dynamic_config_t *pdynamic, + VL53LX_system_control_t *psystem, + VL53LX_tuning_parm_storage_t *ptuning_parms, + VL53LX_zone_config_t *pzone_cfg); + + VL53LX_Error VL53L3CX_preset_mode_histogram_xtalk_planar( + VL53LX_hist_post_process_config_t *phistpostprocess, + VL53LX_static_config_t *pstatic, + VL53LX_histogram_config_t *phistogram, + VL53LX_general_config_t *pgeneral, + VL53LX_timing_config_t *ptiming, + VL53LX_dynamic_config_t *pdynamic, + VL53LX_system_control_t *psystem, + VL53LX_tuning_parm_storage_t *ptuning_parms, + VL53LX_zone_config_t *pzone_cfg); + + + VL53LX_Error VL53L3CX_preset_mode_histogram_long_range( + VL53LX_hist_post_process_config_t *phistpostprocess, + VL53LX_static_config_t *pstatic, + VL53LX_histogram_config_t *phistogram, + VL53LX_general_config_t *pgeneral, + VL53LX_timing_config_t *ptiming, + VL53LX_dynamic_config_t *pdynamic, + VL53LX_system_control_t *psystem, + VL53LX_tuning_parm_storage_t *ptuning_parms, + VL53LX_zone_config_t *pzone_cfg); + + VL53LX_Error VL53L3CX_preset_mode_histogram_medium_range( + VL53LX_hist_post_process_config_t *phistpostprocess, + VL53LX_static_config_t *pstatic, + VL53LX_histogram_config_t *phistogram, + VL53LX_general_config_t *pgeneral, + VL53LX_timing_config_t *ptiming, + VL53LX_dynamic_config_t *pdynamic, + VL53LX_system_control_t *psystem, + VL53LX_tuning_parm_storage_t *ptuning_parms, + VL53LX_zone_config_t *pzone_cfg); + + VL53LX_Error VL53L3CX_preset_mode_histogram_short_range( + VL53LX_hist_post_process_config_t *phistpostprocess, + VL53LX_static_config_t *pstatic, + VL53LX_histogram_config_t *phistogram, + VL53LX_general_config_t *pgeneral, + VL53LX_timing_config_t *ptiming, + VL53LX_dynamic_config_t *pdynamic, + VL53LX_system_control_t *psystem, + VL53LX_tuning_parm_storage_t *ptuning_parms, + VL53LX_zone_config_t *pzone_cfg); + + + + + void VL53L3CX_copy_hist_cfg_to_static_cfg( + VL53LX_histogram_config_t *phistogram, + VL53LX_static_config_t *pstatic, + VL53LX_general_config_t *pgeneral, + VL53LX_timing_config_t *ptiming, + VL53LX_dynamic_config_t *pdynamic); + + void VL53L3CX_copy_hist_bins_to_static_cfg( + VL53LX_histogram_config_t *phistogram, + VL53LX_static_config_t *pstatic, + VL53LX_timing_config_t *ptiming); + + + /* vl53lx_silicon_core.h */ + VL53LX_Error VL53L3CX_is_firmware_ready_silicon( + uint8_t *pready); + + + + + /* vl53lx_xtalk.h */ + + VL53LX_Error VL53L3CX_xtalk_calibration_process_data( + VL53LX_xtalk_range_results_t *pxtalk_ranges, + VL53LX_xtalk_histogram_data_t *pxtalk_shape, + VL53LX_xtalk_calibration_results_t *pxtalk_cal); + + + + /* vl53lx_api_calibration.h */ + + VL53LX_Error VL53L3CX_run_ref_spad_char( + VL53LX_Error *pcal_status); + + + + + VL53LX_Error VL53L3CX_run_device_test( + VL53LX_DeviceTestMode device_test_mode); + + + + VL53LX_Error VL53L3CX_run_xtalk_extraction( + VL53LX_Error *pcal_status); + + + + VL53LX_Error VL53L3CX_get_and_avg_xtalk_samples( + uint8_t num_of_samples, + uint8_t measurement_mode, + int16_t xtalk_filter_thresh_max_mm, + int16_t xtalk_filter_thresh_min_mm, + uint16_t xtalk_max_valid_rate_kcps, + uint8_t xtalk_result_id, + uint8_t xtalk_histo_id, + VL53LX_xtalk_range_results_t *pxtalk_results, + VL53LX_histogram_bin_data_t *psum_histo, + VL53LX_histogram_bin_data_t *pavg_histo); + + + + VL53LX_Error VL53L3CX__run_phasecal_average( + uint8_t measurement_mode, + uint8_t phasecal_result__vcsel_start, + uint16_t phasecal_num_of_samples, + VL53LX_range_results_t *prange_results, + uint16_t *pphasecal_result__reference_phase, + uint16_t *pzero_distance_phase); + + + void VL53L3CX_hist_xtalk_extract_data_init( + VL53LX_hist_xtalk_extract_data_t *pxtalk_data); + + + + VL53LX_Error VL53L3CX_hist_xtalk_extract_update( + int16_t target_distance_mm, + uint16_t target_width_oversize, + VL53LX_histogram_bin_data_t *phist_bins, + VL53LX_hist_xtalk_extract_data_t *pxtalk_data); + + + + VL53LX_Error VL53L3CX_hist_xtalk_extract_fini( + VL53LX_histogram_bin_data_t *phist_bins, + VL53LX_hist_xtalk_extract_data_t *pxtalk_data, + VL53LX_xtalk_calibration_results_t *pxtalk_cal, + VL53LX_xtalk_histogram_shape_t *pxtalk_shape); + + + + + VL53LX_Error VL53L3CX_run_hist_xtalk_extraction( + int16_t cal_distance_mm, + VL53LX_Error *pcal_status); + + /* vl53lx_api_core.c static functions */ + void VL53L3CX_histo_merge(VL53LX_histogram_bin_data_t *pdata); + + /* vl53lx_api.c static functions */ + + int BDTable[11]; + + + + /* Write and read functions from I2C */ + + VL53LX_Error VL53L3CX_WrByte(VL53LX_DEV Dev, uint16_t index, uint8_t data); + VL53LX_Error VL53L3CX_WrWord(VL53LX_DEV Dev, uint16_t index, uint16_t data); + VL53LX_Error VL53L3CX_WrDWord(VL53LX_DEV Dev, uint16_t index, uint32_t data); + VL53LX_Error VL53L3CX_RdByte(VL53LX_DEV Dev, uint16_t index, uint8_t *data); + // VL53LX_Error VL53L3CX_RdWord(VL53LX_DEV Dev, uint16_t index, uint16_t *data); + VL53LX_Error VL53L3CX_RdDWord(VL53LX_DEV Dev, uint16_t index, uint32_t *data); + VL53LX_Error VL53L3CX_UpdateByte(VL53LX_DEV Dev, uint16_t index, uint8_t AndData, uint8_t OrData); + + VL53LX_Error VL53L3CX_WriteMulti(VL53LX_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count); + VL53LX_Error VL53L3CX_ReadMulti(VL53LX_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count); + + VL53LX_Error VL53L3CX_I2CWrite(uint8_t DeviceAddr, uint16_t RegisterAddr, uint8_t *pBuffer, uint16_t NumByteToWrite); + VL53LX_Error VL53L3CX_I2CRead(uint8_t DeviceAddr, uint16_t RegisterAddr, uint8_t *pBuffer, uint16_t NumByteToRead); + VL53LX_Error VL53L3CX_GetTickCount(uint32_t *ptick_count_ms); + VL53LX_Error VL53L3CX_WaitUs(VL53LX_Dev_t *pdev, int32_t wait_us); + VL53LX_Error VL53L3CX_WaitMs(VL53LX_DEV Dev, int32_t wait_ms); + + VL53LX_Error VL53L3CX_WaitValueMaskEx(VL53LX_DEV dev, uint32_t timeout_ms, uint16_t index, uint8_t value, uint8_t mask, uint32_t poll_delay_ms); + + // dummy routines needed for inherited functions + int read_id(uint8_t *id) + { + printf("dwwdji"); + return 26; + } + + + + int get_distance(uint32_t *pi_data) + { + return 43; + } + + + //protected: + + /* IO Device */ + vl53L3_DevI2C *dev_i2c; + /* Digital out pin */ + int gpio0; + + /* Device data */ + VL53LX_Dev_t MyDevice; + VL53LX_DEV Dev; + + vl53L3_DevI2C *i2c_inst; + + /* Digital out pin */ + DigitalOut *_gpio0; + /* GPIO expander */ + Stmpe1600DigiOut *_expgpio0; + /* Measure detection IRQ */ + InterruptIn *_gpio1Int; + int I2cDevAddr; +}; + +#endif /* _VL53LX_CLASS_H_ */ +