input: vl53l0: update TOF driver

- update vl53l0 driver to ver 1.1.23
- remove platform driver and cci depence

Change-Id: Ic71c3e59f2aeb9cb196e998c42824248700dca36
Signed-off-by: wangdw10 <wangdw10@lenovo.com>
Reviewed-on: https://gerrit.mot.com/1374391
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Chuanxin Guo <guocx4@motorola.com>
Reviewed-by: Bolei Shang <shangbl1@lenovo.com>
Reviewed-by: Dawei Wang <wangdw10@motorola.com>
Reviewed-by: Jianqi Yang <yangj@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
wangdw10 2019-06-21 11:35:04 +08:00 • committed by Dawei Wang
commit 8740f92e79
37 changed files with 3143 additions and 9744 deletions

View file

@ -3,28 +3,14 @@
#
# Each configuration option enables a list of files.
FEATURE_USE_CCI := false
ifeq ($(FEATURE_USE_CCI), true)
EXTRA_CFLAGS += -DCAMERA_CCI
else
EXTRA_CFLAGS += -DSTM_TEST
endif
EXTRA_CFLAGS += -Wall
EXTRA_CFLAGS += -I$(TOP)/motorola/kernel/modules/drivers/input/misc/vl53L0
EXTRA_CFLAGS += -I$(TOP)/motorola/kernel/modules/drivers/input/misc/vl53L0/inc
EXTRA_CFLAGS += -I$(TOP)/kernel/msm-4.14/drivers/media/platform/msm/camera_v2/sensor/io
EXTRA_CFLAGS += -I$(TOP)/kernel/msm-4.14/drivers/media/platform/msm/camera_v2
EXTRA_CFLAGS += -I$(TOP)/kernel/msm-4.14/drivers/media/platform/msm/camera_v2/sensor/cci
EXTRA_CFLAGS += -I$(TOP)/kernel/msm-4.14/drivers/media/platform/msm/camera_v2/common
obj-m += stmvl53l0.o
stmvl53l0-objs := stmvl53l0_module.o stmvl53l0_module-i2c.o
stmvl53l0-objs += src/vl53l0_api_calibration.o src/vl53l0_api_core.o
stmvl53l0-objs += src/vl53l0_api_histogram.o src/vl53l0_api_ranging.o
stmvl53l0-objs += src/vl53l0_api_strings.o src/vl53l0_api.o src/vl53l0_platform.o
stmvl53l0-objs += src/vl53l0_i2c_platform.o src/vl53l0_port_i2c.o
stmvl53l0-objs += src/vl53l010_api.o src/vl53l010_tuning.o

File diff suppressed because it is too large Load diff

View file

@ -1,231 +0,0 @@
/*******************************************************************************
Copyright © 2016, 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.
*******************************************************************************/
/**
* Device specific defines. To be adapted by implementer for the targeted
* device.
*/
#ifndef _VL53L010_DEVICE_H_
#define _VL53L010_DEVICE_H_
#include "vl53l0_types.h"
/** @defgroup VL53L010_SpecDefines_group VL53L010 cut1.0 Device Specific Defines
* @brief VL53L010 cut1.0 Device Specific Defines
* @{
*/
/** @defgroup VL53L010_DeviceError_group Device Error
* @brief Device Error code
*
* This enum is Device specific it should be updated in the implementation
* Use @a VL53L010_GetStatusErrorString() to get the string.
* It is related to Status Register of the Device.
* @{
*/
typedef uint8_t VL53L010_DeviceError;
#define VL53L010_DEVICEERROR_NONE ((VL53L010_DeviceError) 0)
#define VL53L010_DEVICEERROR_VCSELCONTINUITYTESTFAILURE ((VL53L010_DeviceError) 1)
#define VL53L010_DEVICEERROR_VCSELWATCHDOGTESTFAILURE ((VL53L010_DeviceError) 2)
#define VL53L010_DEVICEERROR_NOVHVVALUEFOUND ((VL53L010_DeviceError) 3)
#define VL53L010_DEVICEERROR_MSRCNOTARGET ((VL53L010_DeviceError) 4)
#define VL53L010_DEVICEERROR_MSRCMINIMUMSNR ((VL53L010_DeviceError) 5)
#define VL53L010_DEVICEERROR_MSRCWRAPAROUND ((VL53L010_DeviceError) 6)
#define VL53L010_DEVICEERROR_TCC ((VL53L010_DeviceError) 7)
#define VL53L010_DEVICEERROR_RANGEAWRAPAROUND ((VL53L010_DeviceError) 8)
#define VL53L010_DEVICEERROR_RANGEBWRAPAROUND ((VL53L010_DeviceError) 9)
#define VL53L010_DEVICEERROR_MINCLIP ((VL53L010_DeviceError) 10)
#define VL53L010_DEVICEERROR_RANGECOMPLETE ((VL53L010_DeviceError) 11)
#define VL53L010_DEVICEERROR_ALGOUNDERFLOW ((VL53L010_DeviceError) 12)
#define VL53L010_DEVICEERROR_ALGOOVERFLOW ((VL53L010_DeviceError) 13)
#define VL53L010_DEVICEERROR_FINALSNRLIMIT ((VL53L010_DeviceError) 14)
#define VL53L010_DEVICEERROR_NOTARGETIGNORE ((VL53L010_DeviceError) 15)
/** @} VL53L010_DeviceError_group */
/** @defgroup VL53L010_CheckEnable_group Check Enable list
* @brief Check Enable code
*
* Define used to specify the LimitCheckId.
* Use @a VL53L010_GetLimitCheckInfo() to get the string.
* @{
*/
#define VL53L010_CHECKENABLE_SIGMA_FINAL_RANGE 0
#define VL53L010_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE 1
#define VL53L010_CHECKENABLE_NUMBER_OF_CHECKS 2
/** @} VL53L010_CheckEnable_group */
/** @defgroup VL53L010_GpioFunctionality_group Gpio Functionality
* @brief Defines the different functionalities for the device GPIO(s)
* @{
*/
typedef uint8_t VL53L010_GpioFunctionality;
#define VL53L010_GPIOFUNCTIONALITY_OFF ((VL53L010_GpioFunctionality) 0) /*!< NO Interrupt */
#define VL53L010_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW ((VL53L010_GpioFunctionality) 1) /*!< Level Low (value < thresh_low) */
#define VL53L010_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH ((VL53L010_GpioFunctionality) 2) /*!< Level High (value > thresh_high) */
#define VL53L010_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT ((VL53L010_GpioFunctionality) 3) /*!< Out Of Window (value < thresh_low OR value > thresh_high) */
#define VL53L010_GPIOFUNCTIONALITY_NEW_MEASURE_READY ((VL53L010_GpioFunctionality) 4) /*!< New Sample Ready */
/** @} VL53L010_GpioFunctionality_group */
/* Device register map */
/** @defgroup VL53L010_DefineRegisters_group Define Registers
* @brief List of all the defined registers
* @{
*/
#define VL53L010_REG_SYSRANGE_START 0x000
/** mask existing bit in #VL53L010_REG_SYSRANGE_START*/
#define VL53L010_REG_SYSRANGE_MODE_MASK 0x0F
/** bit 0 in #VL53L010_REG_SYSRANGE_START write 1 toggle state in
continuous mode and arm next shot in single shot mode */
#define VL53L010_REG_SYSRANGE_MODE_START_STOP 0x01
/** bit 1 write 0 in #VL53L010_REG_SYSRANGE_START set single shot mode */
#define VL53L010_REG_SYSRANGE_MODE_SINGLESHOT 0x00
/** bit 1 write 1 in #VL53L010_REG_SYSRANGE_START set back-to-back
operation mode */
#define VL53L010_REG_SYSRANGE_MODE_BACKTOBACK 0x02
/** bit 2 write 1 in #VL53L010_REG_SYSRANGE_START set timed operation
mode */
#define VL53L010_REG_SYSRANGE_MODE_TIMED 0x04
/** bit 3 write 1 in #VL53L010_REG_SYSRANGE_START set histogram
operation mode */
#define VL53L010_REG_SYSRANGE_MODE_HISTOGRAM 0x08
#define VL53L010_REG_SYSTEM_THRESH_HIGH 0x000C /* NOSLC 2 bytes */
#define VL53L010_REG_SYSTEM_THRESH_LOW 0x000E /* NOSLC 2 bytes */
/* FPGA bitstream */
#define VL53L010_REG_SYSTEM_SEQUENCE_CONFIG 0x0001
#define VL53L010_REG_SYSTEM_INTERMEASUREMENT_PERIOD 0x0004
#define VL53L010_REG_SYSTEM_REPORT_REQUEST 0x0009
#define VL53L010_REG_SYSTEM_RANGEA_DATA 0x04
#define VL53L010_REG_SYSTEM_RANGEB_DATA 0x05
#define VL53L010_REG_SYSTEM_INTERRUPT_CONFIG_GPIO 0x000A
#define VL53L010_REG_SYSTEM_INTERRUPT_GPIO_DISABLED 0x00
#define VL53L010_REG_SYSTEM_INTERRUPT_GPIO_LEVEL_LOW 0x01
#define VL53L010_REG_SYSTEM_INTERRUPT_GPIO_LEVEL_HIGH 0x02
#define VL53L010_REG_SYSTEM_INTERRUPT_GPIO_OUT_OF_WINDOW 0x03
#define VL53L010_REG_SYSTEM_INTERRUPT_GPIO_NEW_SAMPLE_READY 0x04
#define VL53L010_REG_GPIO_HV_MUX_ACTIVE_HIGH 0x0084
#define VL53L010_REG_SYSTEM_INTERRUPT_CLEAR 0x000B
/* Result registers */
#define VL53L010_REG_RESULT_INTERRUPT_STATUS 0x0013
#define VL53L010_REG_RESULT_RANGE_STATUS 0x0014
#define VL53L010_REG_RESULT_SIGNAL_COUNT_RATE_RET 0x001A
#define VL53L010_REG_RESULT_AMBIENT_COUNT_RATE_RET 0x001C
#define VL53L010_REG_RESULT_FINAL_RANGE 0x001E
/* Algo register */
#define VL53L010_REG_ALGO_CROSSTALK_COMPENSATION_RATE 0x0020
#define VL53L010_REG_ALGO_RANGE_IGNORE_VALID_HEIGHT 0x0025
#define VL53L010_REG_ALGO_RANGE_IGNORE_THRESHOLD 0x0026
#define VL53L010_REG_ALGO_SNR_RATIO 0x0027
#define VL53L010_REG_ALGO_RANGE_CHECK_ENABLES 0x0028
#define VL53L010_REG_ALGO_PART_TO_PART_RANGE_OFFSET 0x0029
#define VL53L010_REG_I2C_SLAVE_DEVICE_ADDRESS 0x008a
/* MSRC registers */
#define VL53L010_REG_MSRC_CONFIG_COUNT 0x0044
#define VL53L010_REG_MSRC_CONFIG_TIMEOUT 0x0046
#define VL53L010_REG_MSRC_CONFIG_MIN_SNR 0x0055
#define VL53L010_REG_MSRC_CONFIG_VALID_PHASE_LOW 0x0047
#define VL53L010_REG_MSRC_CONFIG_VALID_PHASE_HIGH 0x0048
/* RANGE A registers */
#define VL53L010_REG_RNGA_CONFIG_VCSEL_PERIOD 0x0050
#define VL53L010_REG_RNGA_TIMEOUT_MSB 0x0051
#define VL53L010_REG_RNGA_TIMEOUT_LSB 0x0052
#define VL53L010_REG_RNGA_CONFIG_VALID_PHASE_LOW 0x0056
#define VL53L010_REG_RNGA_CONFIG_VALID_PHASE_HIGH 0x0057
/* RANGE B1 registers */
#define VL53L010_REG_RNGB1_CONFIG_VCSEL_PERIOD 0x0060
#define VL53L010_REG_RNGB1_TIMEOUT_MSB 0x0061
#define VL53L010_REG_RNGB1_TIMEOUT_LSB 0x0062
#define VL53L010_REG_RNGB1_CONFIG_VALID_PHASE_LOW 0x0066
#define VL53L010_REG_RNGB1_CONFIG_VALID_PHASE_HIGH 0x0067
/* RANGE B2 registers */
#define VL53L010_REG_RNGB2_CONFIG_VCSEL_PERIOD 0x0070
#define VL53L010_REG_RNGB2_TIMEOUT_MSB 0x0071
#define VL53L010_REG_RNGB2_TIMEOUT_LSB 0x0072
#define VL53L010_REG_RNGB2_CONFIG_VALID_PHASE_LOW 0x0076
#define VL53L010_REG_RNGB2_CONFIG_VALID_PHASE_HIGH 0x0077
#define VL53L010_REG_SOFT_RESET_GO2_SOFT_RESET_N 0x00bf
#define VL53L010_REG_IDENTIFICATION_MODEL_ID 0x00c0
#define VL53L010_REG_IDENTIFICATION_REVISION_ID 0x00c2
#define VL53L010_REG_IDENTIFICATION_MODULE_ID 0x00c3
#define VL53L010_REG_OSC_CALIBRATE_VAL 0x00f8
#define VL53L010_REG_FIRMWARE_MODE_STATUS 0x00C5
#define VL53L010_REG_DYNAMIC_SPAD_ACTUAL_RTN_SPADS_INT 0x0016
#define VL53L010_SIGMA_ESTIMATE_MAX_VALUE 65535
/*equivalent to a range sigma of 655.35mm */
/*
* Speed of light in um per 1E-10 Seconds
*/
#define VL53L010_SPEED_OF_LIGHT_IN_AIR 2997
/** @} VL53L010_DefineRegisters_group */
/** @} VL53L010_SpecDefines_group */
#endif
/* _VL53L010_DEVICE_H_ */

View file

@ -1,134 +0,0 @@
/*******************************************************************************
Copyright © 2016, 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 VL53L010_STRINGS_H_
#define VL53L010_STRINGS_H_
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L010_STRING_DEVICE_INFO_NAME \
"VL53L0 cut1.0"
#define VL53L010_STRING_DEVICE_INFO_NAME_TS0 \
"VL53L0 TS0"
#define VL53L010_STRING_DEVICE_INFO_NAME_TS1 \
"VL53L0 TS1"
#define VL53L010_STRING_DEVICE_INFO_NAME_TS2 \
"VL53L0 TS2"
#define VL53L010_STRING_DEVICE_INFO_NAME_ES1 \
"VL53L0 ES1 or later"
#define VL53L010_STRING_DEVICE_INFO_TYPE \
"VL53L0"
/* PAL ERROR strings */
#define VL53L010_STRING_ERROR_NONE \
"No Error"
#define VL53L010_STRING_ERROR_CALIBRATION_WARNING \
"Calibration Warning Error"
#define VL53L010_STRING_ERROR_MIN_CLIPPED \
"Min clipped error"
#define VL53L010_STRING_ERROR_UNDEFINED \
"Undefined error"
#define VL53L010_STRING_ERROR_INVALID_PARAMS \
"Invalid parameters error"
#define VL53L010_STRING_ERROR_NOT_SUPPORTED \
"Not supported error"
#define VL53L010_STRING_ERROR_RANGE_ERROR \
"Range error"
#define VL53L010_STRING_ERROR_TIME_OUT \
"Time out error"
#define VL53L010_STRING_ERROR_MODE_NOT_SUPPORTED \
"Mode not supported error"
#define VL53L010_STRING_ERROR_NOT_IMPLEMENTED \
"Not implemented error"
#define VL53L010_STRING_UNKNOW_ERROR_CODE \
"Unknow Error Code"
#define VL53L010_STRING_ERROR_BUFFER_TOO_SMALL \
"Buffer too small"
#define VL53L010_STRING_ERROR_GPIO_NOT_EXISTING \
"GPIO not existing"
#define VL53L010_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED \
"GPIO functionality not supported"
#define VL53L010_STRING_ERROR_CONTROL_INTERFACE \
"Control Interface Error"
/* Device Specific */
#define VL53L010_STRING_DEVICEERROR_NONE \
"No Update"
#define VL53L010_STRING_DEVICEERROR_VCSELCONTINUITYTESTFAILURE \
"VCSEL Continuity Test Failure"
#define VL53L010_STRING_DEVICEERROR_VCSELWATCHDOGTESTFAILURE \
"VCSEL Watchdog Test Failure"
#define VL53L010_STRING_DEVICEERROR_NOVHVVALUEFOUND \
"No VHV Value found"
#define VL53L010_STRING_DEVICEERROR_MSRCNOTARGET \
"MSRC No Target Error"
#define VL53L010_STRING_DEVICEERROR_MSRCMINIMUMSNR \
"MSRC Minimum SNR Error"
#define VL53L010_STRING_DEVICEERROR_MSRCWRAPAROUND \
"MSRC Wraparound Error"
#define VL53L010_STRING_DEVICEERROR_TCC \
"TCC Error"
#define VL53L010_STRING_DEVICEERROR_RANGEAWRAPAROUND \
"Range A Wraparound Error"
#define VL53L010_STRING_DEVICEERROR_RANGEBWRAPAROUND \
"Range B Wraparound Error"
#define VL53L010_STRING_DEVICEERROR_MINCLIP \
"Min Clip Error"
#define VL53L010_STRING_DEVICEERROR_RANGECOMPLETE \
"Range Complete"
#define VL53L010_STRING_DEVICEERROR_ALGOUNDERFLOW \
"Range Algo Underflow Error"
#define VL53L010_STRING_DEVICEERROR_ALGOOVERFLOW \
"Range Algo Overlow Error"
#define VL53L010_STRING_DEVICEERROR_FINALSNRLIMIT \
"Final Minimum SNR Error"
#define VL53L010_STRING_DEVICEERROR_NOTARGETIGNORE \
"No Target Ignore Error"
#define VL53L010_STRING_DEVICEERROR_UNKNOWN \
"Unknown error code"
/* Check Enable */
#define VL53L010_STRING_CHECKENABLE_SIGMA \
"SIGMA"
#define VL53L010_STRING_CHECKENABLE_SIGNAL_RATE \
"SIGNAL RATE"
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,58 +0,0 @@
/*******************************************************************************
Copyright © 2016, 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 _VL53L010_TUNING_H_
#define _VL53L010_TUNING_H_
#include "vl53l0_def.h"
#include "vl53l0_platform.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Internal function used to Program the default tuning settings
*
* @ingroup VL53L0_general_group
* @note This function access to the device
*
* @param Dev Device Handle
* @return VL53L0_ERROR_NONE Success
* @return "Other error code" See ::VL53L0_Error
*/
VL53L0_Error VL53L010_load_tuning_settings(VL53L0_DEV Dev);
#ifdef __cplusplus
}
#endif
#endif /* _VL53L010_TUNING_H_ */

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2016, STMicroelectronics International N.V.
* Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -124,7 +124,7 @@ VL53L0_API VL53L0_Error VL53L0_GetDeviceInfo(VL53L0_DEV Dev,
* @return "Other error code" See ::VL53L0_Error
*/
VL53L0_API VL53L0_Error VL53L0_GetDeviceErrorStatus(VL53L0_DEV Dev,
VL53L0_DeviceError *pDeviceErrorStatus);
VL53L0_DeviceError * pDeviceErrorStatus);
/**
* @brief Human readable Range Status string for a given RangeStatus
@ -193,7 +193,7 @@ VL53L0_API VL53L0_Error VL53L0_GetPalStateString(VL53L0_State PalStateCode,
* @return "Other error code" See ::VL53L0_Error
*/
VL53L0_API VL53L0_Error VL53L0_GetPalState(VL53L0_DEV Dev,
VL53L0_State *pPalState);
VL53L0_State * pPalState);
/**
* @brief Set the power mode for a given Device
@ -232,7 +232,7 @@ VL53L0_API VL53L0_Error VL53L0_SetPowerMode(VL53L0_DEV Dev,
* @return "Other error code" See ::VL53L0_Error
*/
VL53L0_API VL53L0_Error VL53L0_GetPowerMode(VL53L0_DEV Dev,
VL53L0_PowerModes *pPowerMode);
VL53L0_PowerModes * pPowerMode);
/**
* Set or over-hide part to part calibration offset
@ -571,7 +571,7 @@ VL53L0_API VL53L0_Error VL53L0_SetDeviceMode(VL53L0_DEV Dev,
* DeviceMode is not in the supported list
*/
VL53L0_API VL53L0_Error VL53L0_GetDeviceMode(VL53L0_DEV Dev,
VL53L0_DeviceModes *pDeviceMode);
VL53L0_DeviceModes * pDeviceMode);
/**
* @brief Sets the resolution of range measurements.
@ -601,8 +601,8 @@ VL53L0_API VL53L0_Error VL53L0_SetRangeFractionEnable(VL53L0_DEV Dev,
*
* @note This function Accesses the device
*
* @param Dev Device Handle
* @param pEnable Output Parameter reporting the fraction enable state.
* @param Dev Device Handle
* @param pEnable Output Parameter reporting the fraction enable state.
*
* @return VL53L0_ERROR_NONE Success
* @return "Other error code" See ::VL53L0_Error
@ -653,7 +653,7 @@ VL53L0_API VL53L0_Error VL53L0_SetHistogramMode(VL53L0_DEV Dev,
* @return "Other error code" See ::VL53L0_Error
*/
VL53L0_API VL53L0_Error VL53L0_GetHistogramMode(VL53L0_DEV Dev,
VL53L0_HistogramModes *pHistogramMode);
VL53L0_HistogramModes * pHistogramMode);
/**
* @brief Set Ranging Timing Budget in microseconds
@ -1214,36 +1214,6 @@ VL53L0_API VL53L0_Error VL53L0_SetWrapAroundCheckEnable(VL53L0_DEV Dev,
VL53L0_API VL53L0_Error VL53L0_GetWrapAroundCheckEnable(VL53L0_DEV Dev,
uint8_t *pWrapAroundCheckEnable);
/**
* @brief Set Dmax Calibration Parameters for a given device
* When one of the parameter is zero, this function will get parameter
* from NVM.
* @note This function doesn't Access to the device
*
* @param Dev Device Handle
* @param RangeMilliMeter Calibration Distance
* @param SignalRateRtnMegaCps Signal rate return read at CalDistance
* @return VL53L0_ERROR_NONE Success
* @return "Other error code" See ::VL53L0_Error
*/
VL53L0_API VL53L0_Error VL53L0_SetDmaxCalParameters(VL53L0_DEV Dev,
uint16_t RangeMilliMeter, FixPoint1616_t SignalRateRtnMegaCps);
/**
* @brief Get Dmax Calibration Parameters for a given device
*
*
* @note This function Access to the device
*
* @param Dev Device Handle
* @param pRangeMilliMeter Pointer to Calibration Distance
* @param pSignalRateRtnMegaCps Pointer to Signal rate return
* @return VL53L0_ERROR_NONE Success
* @return "Other error code" See ::VL53L0_Error
*/
VL53L0_API VL53L0_Error VL53L0_GetDmaxCalParameters(VL53L0_DEV Dev,
uint16_t *pRangeMilliMeter, FixPoint1616_t *pSignalRateRtnMegaCps);
/** @} VL53L0_parameters_group */
/** @defgroup VL53L0_measurement_group VL53L0 Measurement Functions
@ -1678,9 +1648,9 @@ VL53L0_API VL53L0_Error VL53L0_SetGpioConfig(VL53L0_DEV Dev, uint8_t Pin,
* @return "Other error code" See ::VL53L0_Error
*/
VL53L0_API VL53L0_Error VL53L0_GetGpioConfig(VL53L0_DEV Dev, uint8_t Pin,
VL53L0_DeviceModes *pDeviceMode,
VL53L0_GpioFunctionality *pFunctionality,
VL53L0_InterruptPolarity *pPolarity);
VL53L0_DeviceModes * pDeviceMode,
VL53L0_GpioFunctionality * pFunctionality,
VL53L0_InterruptPolarity * pPolarity);
/**
* @brief Set low and high Interrupt thresholds for a given mode
@ -1728,6 +1698,24 @@ VL53L0_API VL53L0_Error VL53L0_GetInterruptThresholds(VL53L0_DEV Dev,
VL53L0_DeviceModes DeviceMode, FixPoint1616_t *pThresholdLow,
FixPoint1616_t *pThresholdHigh);
/**
* @brief Return device stop completion status
*
* @par Function Description
* Returns stop completiob status.
* User shall call this function after a stop command
*
* @note This function Access to the device
*
* @param Dev Device Handle
* @param pStopStatus Pointer to status variable to update
* @return VL53L0_ERROR_NONE Success
* @return "Other error code" See ::VL53L0_Error
*/
VL53L0_API VL53L0_Error VL53L0_GetStopCompletedStatus(VL53L0_DEV Dev,
uint32_t *pStopStatus);
/**
* @brief Clear given system interrupt condition
*
@ -1739,6 +1727,8 @@ VL53L0_API VL53L0_Error VL53L0_GetInterruptThresholds(VL53L0_DEV Dev,
* @param Dev Device Handle
* @param InterruptMask Mask of interrupts to clear
* @return VL53L0_ERROR_NONE Success
* @return VL53L0_ERROR_INTERRUPT_NOT_CLEARED Cannot clear interrupts
*
* @return "Other error code" See ::VL53L0_Error
*/
VL53L0_API VL53L0_Error VL53L0_ClearInterruptMask(VL53L0_DEV Dev,

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2016, STMicroelectronics International N.V.
* Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2016, STMicroelectronics International N.V.
* Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -79,11 +79,14 @@ VL53L0_Error VL53L0_load_tuning_settings(VL53L0_DEV Dev,
VL53L0_Error VL53L0_calc_sigma_estimate(VL53L0_DEV Dev,
VL53L0_RangingMeasurementData_t *pRangingMeasurementData,
FixPoint1616_t *pSigmaEstimate, uint32_t *pDmax_mm);
FixPoint1616_t *pSigmaEstimate);
VL53L0_Error VL53L0_calc_dmax(
VL53L0_DEV Dev, FixPoint1616_t ambRateMeas, uint32_t *pdmax_mm);
VL53L0_Error VL53L0_get_total_xtalk_rate(VL53L0_DEV Dev,
VL53L0_RangingMeasurementData_t *pRangingMeasurementData,
FixPoint1616_t *ptotal_xtalk_rate_mcps);
FixPoint1616_t *ptotal_xtalk_rate_mcps);
VL53L0_Error VL53L0_get_total_signal_rate(VL53L0_DEV Dev,
VL53L0_RangingMeasurementData_t *pRangingMeasurementData,

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2016, STMicroelectronics International N.V.
* Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -44,7 +44,7 @@ VL53L0_Error VL53L0_set_histogram_mode(VL53L0_DEV Dev,
VL53L0_HistogramModes HistogramMode);
VL53L0_Error VL53L0_get_histogram_mode(VL53L0_DEV Dev,
VL53L0_HistogramModes *pHistogramMode);
VL53L0_HistogramModes * pHistogramMode);
VL53L0_Error VL53L0_start_histogram_measurement(VL53L0_DEV Dev,
VL53L0_HistogramModes histoMode,

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2016, STMicroelectronics International N.V.
* Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2016, STMicroelectronics International N.V.
* Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -174,6 +174,8 @@ VL53L0_Error VL53L0_get_limit_check_info(VL53L0_DEV Dev, uint16_t LimitCheckId,
"GPIO not existing"
#define VL53L0_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED \
"GPIO funct not supported"
#define VL53L0_STRING_ERROR_INTERRUPT_NOT_CLEARED \
"Interrupt not Cleared"
#define VL53L0_STRING_ERROR_CONTROL_INTERFACE \
"Control Interface Error"
#define VL53L0_STRING_ERROR_INVALID_COMMAND \
@ -253,6 +255,10 @@ VL53L0_Error VL53L0_get_limit_check_info(VL53L0_DEV Dev, uint16_t LimitCheckId,
"SIGNAL REF CLIP"
#define VL53L0_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD \
"RANGE IGNORE THRESHOLD"
#define VL53L0_STRING_CHECKENABLE_SIGNAL_RATE_MSRC \
"SIGNAL RATE MSRC"
#define VL53L0_STRING_CHECKENABLE_SIGNAL_RATE_PRE_RANGE \
"SIGNAL RATE PRE RANGE"
/* Sequence Step */
#define VL53L0_STRING_SEQUENCESTEP_TCC "TCC"

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2016, STMicroelectronics International N.V.
* Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -80,10 +80,10 @@ extern "C" {
/** VL53L0 PAL IMPLEMENTATION minor version */
#define VL53L0_IMPLEMENTATION_VER_MINOR 1
/** VL53L0 PAL IMPLEMENTATION sub version */
#define VL53L0_IMPLEMENTATION_VER_SUB 18
#define VL53L0_IMPLEMENTATION_VER_SUB 23
/** VL53L0 PAL IMPLEMENTATION sub version */
#define VL53L0_IMPLEMENTATION_VER_REVISION 4357
#define VL53L0_DEFAULT_MAX_LOOP 200
#define VL53L0_IMPLEMENTATION_VER_REVISION 4960
#define VL53L0_DEFAULT_MAX_LOOP 2000
#define VL53L0_MAX_STRING_LENGTH 32
@ -130,45 +130,50 @@ typedef struct {
typedef int8_t VL53L0_Error;
#define VL53L0_ERROR_NONE ((VL53L0_Error) 0)
#define VL53L0_ERROR_CALIBRATION_WARNING ((VL53L0_Error) - 1)
#define VL53L0_ERROR_NONE ((VL53L0_Error) 0)
#define VL53L0_ERROR_CALIBRATION_WARNING ((VL53L0_Error)-1)
/*!< Warning invalid calibration data may be in used
\a VL53L0_InitData()
\a VL53L0_GetOffsetCalibrationData
\a VL53L0_SetOffsetCalibrationData */
#define VL53L0_ERROR_MIN_CLIPPED ((VL53L0_Error) - 2)
* \a VL53L0_InitData()
* \a VL53L0_GetOffsetCalibrationData
* \a VL53L0_SetOffsetCalibrationData
*/
#define VL53L0_ERROR_MIN_CLIPPED ((VL53L0_Error)-2)
/*!< Warning parameter passed was clipped to min before to be applied */
#define VL53L0_ERROR_UNDEFINED ((VL53L0_Error) - 3)
#define VL53L0_ERROR_UNDEFINED ((VL53L0_Error)-3)
/*!< Unqualified error */
#define VL53L0_ERROR_INVALID_PARAMS ((VL53L0_Error) - 4)
#define VL53L0_ERROR_INVALID_PARAMS ((VL53L0_Error)-4)
/*!< Parameter passed is invalid or out of range */
#define VL53L0_ERROR_NOT_SUPPORTED ((VL53L0_Error) - 5)
#define VL53L0_ERROR_NOT_SUPPORTED ((VL53L0_Error)-5)
/*!< Function is not supported in current mode or configuration */
#define VL53L0_ERROR_RANGE_ERROR ((VL53L0_Error) - 6)
#define VL53L0_ERROR_RANGE_ERROR ((VL53L0_Error)-6)
/*!< Device report a ranging error interrupt status */
#define VL53L0_ERROR_TIME_OUT ((VL53L0_Error) - 7)
#define VL53L0_ERROR_TIME_OUT ((VL53L0_Error)-7)
/*!< Aborted due to time out */
#define VL53L0_ERROR_MODE_NOT_SUPPORTED ((VL53L0_Error) - 8)
#define VL53L0_ERROR_MODE_NOT_SUPPORTED ((VL53L0_Error)-8)
/*!< Asked mode is not supported by the device */
#define VL53L0_ERROR_BUFFER_TOO_SMALL ((VL53L0_Error) - 9)
#define VL53L0_ERROR_BUFFER_TOO_SMALL ((VL53L0_Error)-9)
/*!< ... */
#define VL53L0_ERROR_GPIO_NOT_EXISTING ((VL53L0_Error) - 10)
#define VL53L0_ERROR_GPIO_NOT_EXISTING ((VL53L0_Error)-10)
/*!< User tried to setup a non-existing GPIO pin */
#define VL53L0_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED ((VL53L0_Error) - 11)
#define VL53L0_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED ((VL53L0_Error)-11)
/*!< unsupported GPIO functionality */
#define VL53L0_ERROR_CONTROL_INTERFACE ((VL53L0_Error) - 20)
#define VL53L0_ERROR_INTERRUPT_NOT_CLEARED ((VL53L0_Error)-12)
/*!< Error during interrupt clear */
#define VL53L0_ERROR_CONTROL_INTERFACE ((VL53L0_Error)-20)
/*!< error reported from IO functions */
#define VL53L0_ERROR_INVALID_COMMAND ((VL53L0_Error) - 30)
#define VL53L0_ERROR_INVALID_COMMAND ((VL53L0_Error)-30)
/*!< The command is not allowed in the current device state
* (power down) */
#define VL53L0_ERROR_DIVISION_BY_ZERO ((VL53L0_Error) - 40)
* (power down)
*/
#define VL53L0_ERROR_DIVISION_BY_ZERO ((VL53L0_Error)-40)
/*!< In the function a division by zero occurs */
#define VL53L0_ERROR_REF_SPAD_INIT ((VL53L0_Error) - 50)
#define VL53L0_ERROR_REF_SPAD_INIT ((VL53L0_Error)-50)
/*!< Error during reference SPAD initialization */
#define VL53L0_ERROR_NOT_IMPLEMENTED ((VL53L0_Error) - 99)
#define VL53L0_ERROR_NOT_IMPLEMENTED ((VL53L0_Error)-99)
/*!< Tells requested functionality has not been implemented yet or
* not compatible with the device */
* not compatible with the device
*/
/** @} VL53L0_define_Error_group */
@ -178,13 +183,13 @@ typedef int8_t VL53L0_Error;
*/
typedef uint8_t VL53L0_DeviceModes;
#define VL53L0_DEVICEMODE_SINGLE_RANGING ((VL53L0_DeviceModes) 0)
#define VL53L0_DEVICEMODE_SINGLE_RANGING ((VL53L0_DeviceModes) 0)
#define VL53L0_DEVICEMODE_CONTINUOUS_RANGING ((VL53L0_DeviceModes) 1)
#define VL53L0_DEVICEMODE_SINGLE_HISTOGRAM ((VL53L0_DeviceModes) 2)
#define VL53L0_DEVICEMODE_SINGLE_HISTOGRAM ((VL53L0_DeviceModes) 2)
#define VL53L0_DEVICEMODE_CONTINUOUS_TIMED_RANGING ((VL53L0_DeviceModes) 3)
#define VL53L0_DEVICEMODE_SINGLE_ALS ((VL53L0_DeviceModes) 10)
#define VL53L0_DEVICEMODE_GPIO_DRIVE ((VL53L0_DeviceModes) 20)
#define VL53L0_DEVICEMODE_GPIO_OSC ((VL53L0_DeviceModes) 21)
#define VL53L0_DEVICEMODE_SINGLE_ALS ((VL53L0_DeviceModes) 10)
#define VL53L0_DEVICEMODE_GPIO_DRIVE ((VL53L0_DeviceModes) 20)
#define VL53L0_DEVICEMODE_GPIO_OSC ((VL53L0_DeviceModes) 21)
/* ... Modes to be added depending on device */
/** @} VL53L0_define_DeviceModes_group */
@ -196,13 +201,13 @@ typedef uint8_t VL53L0_DeviceModes;
*/
typedef uint8_t VL53L0_HistogramModes;
#define VL53L0_HISTOGRAMMODE_DISABLED ((VL53L0_HistogramModes) 0)
#define VL53L0_HISTOGRAMMODE_DISABLED ((VL53L0_HistogramModes) 0)
/*!< Histogram Disabled */
#define VL53L0_HISTOGRAMMODE_REFERENCE_ONLY ((VL53L0_HistogramModes) 1)
#define VL53L0_HISTOGRAMMODE_REFERENCE_ONLY ((VL53L0_HistogramModes) 1)
/*!< Histogram Reference array only */
#define VL53L0_HISTOGRAMMODE_RETURN_ONLY ((VL53L0_HistogramModes) 2)
#define VL53L0_HISTOGRAMMODE_RETURN_ONLY ((VL53L0_HistogramModes) 2)
/*!< Histogram Return array only */
#define VL53L0_HISTOGRAMMODE_BOTH ((VL53L0_HistogramModes) 3)
#define VL53L0_HISTOGRAMMODE_BOTH ((VL53L0_HistogramModes) 3)
/*!< Histogram both Reference and Return Arrays */
/* ... Modes to be added depending on device */
/** @} VL53L0_define_HistogramModes_group */
@ -227,6 +232,18 @@ typedef uint8_t VL53L0_PowerModes;
/** @} VL53L0_define_PowerModes_group */
#define VL53L0_DMAX_LUT_SIZE 7
/*!< Defines the number of items in the DMAX lookup table */
/** @brief Structure defining data pair that makes up the DMAX Lookup table.
*/
typedef struct {
FixPoint1616_t ambRate_mcps[VL53L0_DMAX_LUT_SIZE];
/*!< Ambient rate (mcps) */
FixPoint1616_t dmax_mm[VL53L0_DMAX_LUT_SIZE];
/*!< DMAX Value (mm) */
} VL53L0_DMaxLUT_t;
/** @brief Defines all parameters for the device
*/
typedef struct {
@ -234,19 +251,22 @@ typedef struct {
/*!< Defines type of measurement to be done for the next measure */
VL53L0_HistogramModes HistogramMode;
/*!< Defines type of histogram measurement to be done for the next
* measure */
* measure
*/
uint32_t MeasurementTimingBudgetMicroSeconds;
/*!< Defines the allowed total time for a single measurement */
uint32_t InterMeasurementPeriodMilliSeconds;
/*!< Defines time between two consecutive measurements (between two
* measurement starts). If set to 0 means back-to-back mode */
* measurement starts). If set to 0 means back-to-back mode
*/
uint8_t XTalkCompensationEnable;
/*!< Tells if Crosstalk compensation shall be enable or not */
uint16_t XTalkCompensationRangeMilliMeter;
/*!< CrossTalk compensation range in millimeter */
FixPoint1616_t XTalkCompensationRateMegaCps;
/*!< CrossTalk compensation rate in Mega counts per seconds.
* Expressed in 16.16 fixed point format. */
* Expressed in 16.16 fixed point format.
*/
int32_t RangeOffsetMicroMeters;
/*!< Range offset adjustment (mm). */
@ -254,10 +274,16 @@ typedef struct {
/*!< This Array store all the Limit Check enable for this device. */
uint8_t LimitChecksStatus[VL53L0_CHECKENABLE_NUMBER_OF_CHECKS];
/*!< This Array store all the Status of the check linked to last
* measurement. */
* measurement.
*/
FixPoint1616_t LimitChecksValue[VL53L0_CHECKENABLE_NUMBER_OF_CHECKS];
/*!< This Array store all the Limit Check value for this device */
VL53L0_DMaxLUT_t dmax_lut;
/*!< Lookup table defining ambient rates and associated
* dmax values.
*/
uint8_t WrapAroundCheckEnable;
/*!< Tells if Wrap Around Check shall be enable or not */
} VL53L0_DeviceParameters_t;
@ -288,57 +314,55 @@ typedef uint8_t VL53L0_State;
/** @} VL53L0_define_State_group */
/** @brief Structure containing the Dmax computation parameters and data
*/
typedef struct {
int32_t AmbTuningWindowFactor_K;
/*!< internal algo tuning (*1000) */
int32_t RetSignalAt0mm;
/*!< intermediate dmax computation value caching */
} VL53L0_DMaxData_t;
/**
* @struct VL53L0_RangeData_t
* @brief Range measurement data.
*/
typedef struct {
uint32_t TimeStamp; /*!< 32-bit time stamp. */
uint32_t TimeStamp; /*!< 32-bit time stamp. */
uint32_t MeasurementTimeUsec;
/*!< Give the Measurement time needed by the device to do the
* measurement.*/
* measurement.
*/
uint16_t RangeMilliMeter; /*!< range distance in millimeter. */
uint16_t RangeMilliMeter; /*!< range distance in millimeter. */
uint16_t RangeDMaxMilliMeter;
/*!< Tells what is the maximum detection distance of the device
* in current setup and environment conditions (Filled when
* applicable) */
* applicable)
*/
FixPoint1616_t SignalRateRtnMegaCps;
/*!< Return signal rate (MCPS)\n these is a 16.16 fix point
* value, which is effectively a measure of target
* reflectance.*/
* reflectance.
*/
FixPoint1616_t AmbientRateRtnMegaCps;
/*!< Return ambient rate (MCPS)\n these is a 16.16 fix point
* value, which is effectively a measure of the ambien
* t light.*/
* t light.
*/
uint16_t EffectiveSpadRtnCount;
/*!< Return the effective SPAD count for the return signal.
* To obtain Real value it should be divided by 256 */
* To obtain Real value it should be divided by 256
*/
uint8_t ZoneId;
/*!< Denotes which zone and range scheduler stage the range
* data relates to. */
* data relates to.
*/
uint8_t RangeFractionalPart;
/*!< Fractional part of range distance. Final value is a
* FixPoint168 value. */
* FixPoint168 value.
*/
uint8_t RangeStatus;
/*!< Range Status for the current measurement. This is device
* dependent. Value = 0 means value is valid.
* See \ref RangeStatusPage */
FixPoint1616_t SigmaEstimate;
* See \ref RangeStatusPage
*/
} VL53L0_RangingMeasurementData_t;
@ -352,8 +376,10 @@ typedef struct {
/* Histogram Measurement data */
uint32_t HistogramData[VL53L0_HISTOGRAM_BUFFER_SIZE];
/*!< Histogram data */
uint8_t HistogramType; /*!< Indicate the types of histogram data :
Return only, Reference only, both Return and Reference */
/*!< Indicate the types of histogram data :
*Return only, Reference only, both Return and Reference
*/
uint8_t HistogramType;
uint8_t FirstBin; /*!< First Bin value */
uint8_t BufferSize; /*!< Buffer Size - Set by the user.*/
uint8_t NumberOfBins;
@ -361,7 +387,8 @@ typedef struct {
VL53L0_DeviceError ErrorStatus;
/*!< Error status of the current measurement. \n
see @a ::VL53L0_DeviceError @a VL53L0_GetStatusErrorString() */
* see @a ::VL53L0_DeviceError @a VL53L0_GetStatusErrorString()
*/
} VL53L0_HistogramMeasurementData_t;
#define VL53L0_REF_SPAD_BUFFER_SIZE 6
@ -399,14 +426,16 @@ typedef struct {
/*!< Reference array sigma value in 1/100th of [mm] e.g. 100 = 1mm */
uint16_t SigmaEstEffPulseWidth;
/*!< Effective Pulse width for sigma estimate in 1/100th
* of ns e.g. 900 = 9.0ns */
* of ns e.g. 900 = 9.0ns
*/
uint16_t SigmaEstEffAmbWidth;
/*!< Effective Ambient width for sigma estimate in 1/100th of ns
* e.g. 500 = 5.0ns */
* e.g. 500 = 5.0ns
*/
uint8_t ReadDataFromDeviceDone; /* Indicate if read from device has
been done (==1) or not (==0) */
/* Indicate if read from device has been done (==1) or not (==0) */
uint8_t ReadDataFromDeviceDone;
uint8_t ModuleId; /* Module ID */
uint8_t Revision; /* test Revision */
char ProductId[VL53L0_MAX_STRING_LENGTH];
@ -416,8 +445,8 @@ typedef struct {
uint8_t RefSpadsInitialised; /* reports if ref spads are initialised. */
uint32_t PartUIDUpper; /*!< Unique Part ID Upper */
uint32_t PartUIDLower; /*!< Unique Part ID Lower */
FixPoint1616_t SignalRateMeasFixed400mm; /*!< Peek Signal rate
at 400 mm*/
/*!< Peek Signal rate at 400 mm*/
FixPoint1616_t SignalRateMeasFixed400mm;
} VL53L0_DeviceSpecificParameters_t;
@ -430,8 +459,6 @@ typedef struct {
* These must never access directly but only via macro
*/
typedef struct {
VL53L0_DMaxData_t DMaxData;
/*!< Dmax Data */
int32_t Part2PartOffsetNVMMicroMeter;
/*!< backed up NVM value */
int32_t Part2PartOffsetAdjustmentNVMMicroMeter;
@ -458,15 +485,20 @@ typedef struct {
/*!< Reference array sigma value in 1/100th of [mm] e.g. 100 = 1mm */
uint16_t SigmaEstEffPulseWidth;
/*!< Effective Pulse width for sigma estimate in 1/100th
* of ns e.g. 900 = 9.0ns */
* of ns e.g. 900 = 9.0ns
*/
uint16_t SigmaEstEffAmbWidth;
/*!< Effective Ambient width for sigma estimate in 1/100th of ns
* e.g. 500 = 5.0ns */
* e.g. 500 = 5.0ns
*/
uint8_t StopVariable;
/*!< StopVariable used during the stop sequence */
uint16_t targetRefRate;
/*!< Target Ambient Rate for Ref spad management */
FixPoint1616_t SigmaEstimate;
/*!< Sigma Estimate - based on ambient & VCSEL rates and
* signal_total_events */
* signal_total_events
*/
FixPoint1616_t SignalEstimate;
/*!< Signal Estimate - based on ambient & VCSEL rates and cross talk */
FixPoint1616_t LastSignalRefMcps;
@ -477,11 +509,6 @@ typedef struct {
/*!< Indicate if we use Tuning Settings table */
uint16_t LinearityCorrectiveGain;
/*!< Linearity Corrective Gain value in x1000 */
uint16_t DmaxCalRangeMilliMeter;
/*!< Dmax Calibration Range millimeter */
FixPoint1616_t DmaxCalSignalRateRtnMegaCps;
/*!< Dmax Calibration Signal Rate Return MegaCps */
} VL53L0_DevData_t;
@ -520,7 +547,7 @@ typedef uint8_t VL53L0_VcselPeriod;
* i.e. enabled/disabled.
*/
typedef struct {
uint8_t TccOn; /*!<Reports if Target Centre Check On */
uint8_t TccOn; /*!<Reports if Target Centre Check On */
uint8_t MsrcOn; /*!<Reports if MSRC On */
uint8_t DssOn; /*!<Reports if DSS On */
uint8_t PreRangeOn; /*!<Reports if Pre-Range On */
@ -564,15 +591,14 @@ typedef uint8_t VL53L0_SequenceStepId;
PALDevDataSet(Dev, CurrentParameters.field, value)
#define VL53L0_GETPARAMETERFIELD(Dev, field, variable) \
variable = PALDevDataGet(Dev, CurrentParameters).field
(variable = ((PALDevDataGet(Dev, CurrentParameters)).field))
#define VL53L0_SETARRAYPARAMETERFIELD(Dev, field, index, value) \
PALDevDataSet(Dev, CurrentParameters.field[index], value)
#define VL53L0_GETARRAYPARAMETERFIELD(Dev, field, index, variable) \
variable = PALDevDataGet(Dev, CurrentParameters).field[index]
(variable = (PALDevDataGet(Dev, CurrentParameters)).field[index])
#define VL53L0_SETDEVICESPECIFICPARAMETER(Dev, field, value) \
PALDevDataSet(Dev, DeviceSpecificParameters.field, value)

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2016, STMicroelectronics International N.V.
* Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -85,8 +85,10 @@ typedef uint8_t VL53L0_DeviceError;
#define VL53L0_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE 1
#define VL53L0_CHECKENABLE_SIGNAL_REF_CLIP 2
#define VL53L0_CHECKENABLE_RANGE_IGNORE_THRESHOLD 3
#define VL53L0_CHECKENABLE_SIGNAL_RATE_MSRC 4
#define VL53L0_CHECKENABLE_SIGNAL_RATE_PRE_RANGE 5
#define VL53L0_CHECKENABLE_NUMBER_OF_CHECKS 4
#define VL53L0_CHECKENABLE_NUMBER_OF_CHECKS 6
/** @} end of VL53L0_CheckEnable_group */
@ -122,18 +124,22 @@ typedef uint8_t VL53L0_GpioFunctionality;
/** mask existing bit in #VL53L0_REG_SYSRANGE_START*/
#define VL53L0_REG_SYSRANGE_MODE_MASK 0x0F
/** bit 0 in #VL53L0_REG_SYSRANGE_START write 1 toggle state in
* continuous mode and arm next shot in single shot mode */
* continuous mode and arm next shot in single shot mode
*/
#define VL53L0_REG_SYSRANGE_MODE_START_STOP 0x01
/** bit 1 write 0 in #VL53L0_REG_SYSRANGE_START set single shot mode */
#define VL53L0_REG_SYSRANGE_MODE_SINGLESHOT 0x00
/** bit 1 write 1 in #VL53L0_REG_SYSRANGE_START set back-to-back
* operation mode */
* operation mode
*/
#define VL53L0_REG_SYSRANGE_MODE_BACKTOBACK 0x02
/** bit 2 write 1 in #VL53L0_REG_SYSRANGE_START set timed operation
* mode */
* mode
*/
#define VL53L0_REG_SYSRANGE_MODE_TIMED 0x04
/** bit 3 write 1 in #VL53L0_REG_SYSRANGE_START set histogram operation
* mode */
* mode
*/
#define VL53L0_REG_SYSRANGE_MODE_HISTOGRAM 0x08
@ -181,7 +187,7 @@ typedef uint8_t VL53L0_GpioFunctionality;
#define VL53L0_REG_PRE_RANGE_CONFIG_MIN_SNR 0X0027
#define VL53L0_REG_PRE_RANGE_CONFIG_VALID_PHASE_LOW 0x0056
#define VL53L0_REG_PRE_RANGE_CONFIG_VALID_PHASE_HIGH 0x0057
#define VL53L0_REG_PRE_RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT 0x0064
#define VL53L0_REG_PRE_RANGE_MIN_COUNT_RATE_RTN_LIMIT 0x0064
#define VL53L0_REG_FINAL_RANGE_CONFIG_MIN_SNR 0X0067
#define VL53L0_REG_FINAL_RANGE_CONFIG_VALID_PHASE_LOW 0x0047

View file

@ -0,0 +1,194 @@
/*******************************************************************************
* Copyright © 2016, 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 _VL53L0_INTERRUPT_THRESHOLD_SETTINGS_H_
#define _VL53L0_INTERRUPT_THRESHOLD_SETTINGS_H_
#ifdef __cplusplus
extern "C" {
#endif
uint8_t InterruptThresholdSettings[] = {
/* Start of Interrupt Threshold Settings */
0x1, 0xff, 0x00,
0x1, 0x80, 0x01,
0x1, 0xff, 0x01,
0x1, 0x00, 0x00,
0x1, 0xff, 0x01,
0x1, 0x4f, 0x02,
0x1, 0xFF, 0x0E,
0x1, 0x00, 0x03,
0x1, 0x01, 0x84,
0x1, 0x02, 0x0A,
0x1, 0x03, 0x03,
0x1, 0x04, 0x08,
0x1, 0x05, 0xC8,
0x1, 0x06, 0x03,
0x1, 0x07, 0x8D,
0x1, 0x08, 0x08,
0x1, 0x09, 0xC6,
0x1, 0x0A, 0x01,
0x1, 0x0B, 0x02,
0x1, 0x0C, 0x00,
0x1, 0x0D, 0xD5,
0x1, 0x0E, 0x18,
0x1, 0x0F, 0x12,
0x1, 0x10, 0x01,
0x1, 0x11, 0x82,
0x1, 0x12, 0x00,
0x1, 0x13, 0xD5,
0x1, 0x14, 0x18,
0x1, 0x15, 0x13,
0x1, 0x16, 0x03,
0x1, 0x17, 0x86,
0x1, 0x18, 0x0A,
0x1, 0x19, 0x09,
0x1, 0x1A, 0x08,
0x1, 0x1B, 0xC2,
0x1, 0x1C, 0x03,
0x1, 0x1D, 0x8F,
0x1, 0x1E, 0x0A,
0x1, 0x1F, 0x06,
0x1, 0x20, 0x01,
0x1, 0x21, 0x02,
0x1, 0x22, 0x00,
0x1, 0x23, 0xD5,
0x1, 0x24, 0x18,
0x1, 0x25, 0x22,
0x1, 0x26, 0x01,
0x1, 0x27, 0x82,
0x1, 0x28, 0x00,
0x1, 0x29, 0xD5,
0x1, 0x2A, 0x18,
0x1, 0x2B, 0x0B,
0x1, 0x2C, 0x28,
0x1, 0x2D, 0x78,
0x1, 0x2E, 0x28,
0x1, 0x2F, 0x91,
0x1, 0x30, 0x00,
0x1, 0x31, 0x0B,
0x1, 0x32, 0x00,
0x1, 0x33, 0x0B,
0x1, 0x34, 0x00,
0x1, 0x35, 0xA1,
0x1, 0x36, 0x00,
0x1, 0x37, 0xA0,
0x1, 0x38, 0x00,
0x1, 0x39, 0x04,
0x1, 0x3A, 0x28,
0x1, 0x3B, 0x30,
0x1, 0x3C, 0x0C,
0x1, 0x3D, 0x04,
0x1, 0x3E, 0x0F,
0x1, 0x3F, 0x79,
0x1, 0x40, 0x28,
0x1, 0x41, 0x1E,
0x1, 0x42, 0x2F,
0x1, 0x43, 0x87,
0x1, 0x44, 0x00,
0x1, 0x45, 0x0B,
0x1, 0x46, 0x00,
0x1, 0x47, 0x0B,
0x1, 0x48, 0x00,
0x1, 0x49, 0xA7,
0x1, 0x4A, 0x00,
0x1, 0x4B, 0xA6,
0x1, 0x4C, 0x00,
0x1, 0x4D, 0x04,
0x1, 0x4E, 0x01,
0x1, 0x4F, 0x00,
0x1, 0x50, 0x00,
0x1, 0x51, 0x80,
0x1, 0x52, 0x09,
0x1, 0x53, 0x08,
0x1, 0x54, 0x01,
0x1, 0x55, 0x00,
0x1, 0x56, 0x0F,
0x1, 0x57, 0x79,
0x1, 0x58, 0x09,
0x1, 0x59, 0x05,
0x1, 0x5A, 0x00,
0x1, 0x5B, 0x60,
0x1, 0x5C, 0x05,
0x1, 0x5D, 0xD1,
0x1, 0x5E, 0x0C,
0x1, 0x5F, 0x3C,
0x1, 0x60, 0x00,
0x1, 0x61, 0xD0,
0x1, 0x62, 0x0B,
0x1, 0x63, 0x03,
0x1, 0x64, 0x28,
0x1, 0x65, 0x10,
0x1, 0x66, 0x2A,
0x1, 0x67, 0x39,
0x1, 0x68, 0x0B,
0x1, 0x69, 0x02,
0x1, 0x6A, 0x28,
0x1, 0x6B, 0x10,
0x1, 0x6C, 0x2A,
0x1, 0x6D, 0x61,
0x1, 0x6E, 0x0C,
0x1, 0x6F, 0x00,
0x1, 0x70, 0x0F,
0x1, 0x71, 0x79,
0x1, 0x72, 0x00,
0x1, 0x73, 0x0B,
0x1, 0x74, 0x00,
0x1, 0x75, 0x0B,
0x1, 0x76, 0x00,
0x1, 0x77, 0xA1,
0x1, 0x78, 0x00,
0x1, 0x79, 0xA0,
0x1, 0x7A, 0x00,
0x1, 0x7B, 0x04,
0x1, 0xFF, 0x04,
0x1, 0x79, 0x1D,
0x1, 0x7B, 0x27,
0x1, 0x96, 0x0E,
0x1, 0x97, 0xFE,
0x1, 0x98, 0x03,
0x1, 0x99, 0xEF,
0x1, 0x9A, 0x02,
0x1, 0x9B, 0x44,
0x1, 0x73, 0x07,
0x1, 0x70, 0x01,
0x1, 0xff, 0x01,
0x1, 0x00, 0x01,
0x1, 0xff, 0x00,
0x00, 0x00, 0x00
};
#ifdef __cplusplus
}
#endif
#endif /* _VL53L0_INTERRUPT_THRESHOLD_SETTINGS_H_ */

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2015, STMicroelectronics International N.V.
* Copyright © 2015, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -35,7 +35,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vl53l0_platform_log.h"
#include "stmvl53l0-i2c.h"
#include "stmvl53l0-cci.h"
#include "stmvl53l0.h"
/**
@ -52,7 +51,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/**
* @struct VL53L0_Dev_t
* @brief Generic PAL device type that does link between API and platform abstraction layer
* @brief Generic PAL device type that does link between API and platform
* abstraction layer
*
*/
typedef struct stmvl53l0_data *VL53L0_DEV;
@ -86,7 +86,8 @@ typedef struct stmvl53l0_data *VL53L0_DEV;
*/
/**
* Lock comms interface to serialize all commands to a shared I2C interface for a specific device
* Lock comms interface to serialize all commands to a shared I2C interface
* for a specific device
* @param Dev Device Handle
* @return VL53L0_ERROR_NONE Success
* @return "Other error code" See ::VL53L0_Error
@ -94,7 +95,8 @@ typedef struct stmvl53l0_data *VL53L0_DEV;
VL53L0_Error VL53L0_LockSequenceAccess(VL53L0_DEV Dev);
/**
* Unlock comms interface to serialize all commands to a shared I2C interface for a specific device
* Unlock comms interface to serialize all commands to a shared I2C interface
* for a specific device
* @param Dev Device Handle
* @return VL53L0_ERROR_NONE Success
* @return "Other error code" See ::VL53L0_Error
@ -106,7 +108,7 @@ VL53L0_Error VL53L0_UnlockSequenceAccess(VL53L0_DEV Dev);
* Writes the supplied byte buffer to the device
* @param Dev Device Handle
* @param index The register index
* @param pdata Pointer to uint8_t buffer containing the data to be written
* @param pdata Pointer to uint8_t buffer containing the data to be written
* @param count Number of bytes in the supplied byte buffer
* @return VL53L0_ERROR_NONE Success
* @return "Other error code" See ::VL53L0_Error

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2015, STMicroelectronics International N.V.
* Copyright © 2015, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -40,7 +40,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @brief platform log function definition
*/
/*#define VL53L0_LOG_ENABLE 0*/
/* #define VL53L0_LOG_ENABLE */
enum {
TRACE_LEVEL_NONE,
@ -78,21 +78,24 @@ extern uint32_t _trace_level;
int32_t VL53L0_trace_config(char *filename, uint32_t modules,
uint32_t level, uint32_t functions);
#if 0
void trace_print_module_function(uint32_t module, uint32_t level,
uint32_t function, const char *format, ...);
#else
#define trace_print_module_function(...)
#endif
#define LOG_GET_TIME() (int)0
/*
#define _LOG_FUNCTION_START(module, fmt, ...) \
* #define _LOG_FUNCTION_START(module, fmt, ...) \
printk(KERN_INFO"beg %s start @%d\t" fmt "\n", \
__func__, LOG_GET_TIME(), ##__VA_ARGS__)
#define _LOG_FUNCTION_END(module, status, ...)\
* #define _LOG_FUNCTION_END(module, status, ...)\
printk(KERN_INFO"end %s @%d %d\n", \
__func__, LOG_GET_TIME(), (int)status)
#define _LOG_FUNCTION_END_FMT(module, status, fmt, ...)\
* #define _LOG_FUNCTION_END_FMT(module, status, fmt, ...)\
printk(KERN_INFO"End %s @%d %d\t"fmt"\n" , \
__func__, LOG_GET_TIME(), (int)status, ##__VA_ARGS__)
*/
@ -101,11 +104,11 @@ void trace_print_module_function(uint32_t module, uint32_t level,
__func__, LOG_GET_TIME(), ##__VA_ARGS__)
#define _LOG_FUNCTION_END(module, status, ...)\
pr_err("end %s start @%d\t" fmt "\n", \
pr_err("end %s start @%d Status %d\n", \
__func__, LOG_GET_TIME(), (int)status)
#define _LOG_FUNCTION_END_FMT(module, status, fmt, ...)\
pr_err("End %s @%d %d\t"fmt"\n" , \
pr_err("End %s @%d %d\t"fmt"\n", \
__func__, LOG_GET_TIME(), (int)status, ##__VA_ARGS__)

View file

@ -1,211 +0,0 @@
/*******************************************************************************
Copyright © 2016, 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.
********************************************************************************/
/*
* @file vl53l0_string.h
* $Date: 2014-12-04 16:15:06 +0100 (Thu, 04 Dec 2014) $
* $Revision: 1906 $
*/
#ifndef VL53L0_STRINGS_H_
#define VL53L0_STRINGS_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifdef USE_EMPTY_STRING
#define VL53L0_STRING_DEVICE_INFO_NAME ""
#define VL53L0_STRING_DEVICE_INFO_NAME_TS0 ""
#define VL53L0_STRING_DEVICE_INFO_NAME_TS1 ""
#define VL53L0_STRING_DEVICE_INFO_NAME_TS2 ""
#define VL53L0_STRING_DEVICE_INFO_NAME_ES1 ""
#define VL53L0_STRING_DEVICE_INFO_TYPE ""
/* PAL ERROR strings */
#define VL53L0_STRING_ERROR_NONE ""
#define VL53L0_STRING_ERROR_CALIBRATION_WARNING ""
#define VL53L0_STRING_ERROR_MIN_CLIPPED ""
#define VL53L0_STRING_ERROR_UNDEFINED ""
#define VL53L0_STRING_ERROR_INVALID_PARAMS ""
#define VL53L0_STRING_ERROR_NOT_SUPPORTED ""
#define VL53L0_STRING_ERROR_RANGE_ERROR ""
#define VL53L0_STRING_ERROR_TIME_OUT ""
#define VL53L0_STRING_ERROR_MODE_NOT_SUPPORTED ""
#define VL53L0_STRING_ERROR_BUFFER_TOO_SMALL ""
#define VL53L0_STRING_ERROR_GPIO_NOT_EXISTING ""
#define VL53L0_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED ""
#define VL53L0_STRING_ERROR_CONTROL_INTERFACE ""
#define VL53L0_STRING_ERROR_INVALID_COMMAND ""
#define VL53L0_STRING_ERROR_DIVISION_BY_ZERO ""
#define VL53L0_STRING_ERROR_REF_SPAD_INIT ""
#define VL53L0_STRING_ERROR_NOT_IMPLEMENTED ""
#define VL53L0_STRING_UNKNOW_ERROR_CODE ""
/* Range Status */
#define VL53L0_STRING_RANGESTATUS_NONE ""
#define VL53L0_STRING_RANGESTATUS_RANGEVALID ""
#define VL53L0_STRING_RANGESTATUS_SIGMA ""
#define VL53L0_STRING_RANGESTATUS_SIGNAL ""
#define VL53L0_STRING_RANGESTATUS_MINRANGE ""
#define VL53L0_STRING_RANGESTATUS_PHASE ""
#define VL53L0_STRING_RANGESTATUS_HW ""
/* Range Status */
#define VL53L0_STRING_STATE_POWERDOWN ""
#define VL53L0_STRING_STATE_WAIT_STATICINIT ""
#define VL53L0_STRING_STATE_STANDBY ""
#define VL53L0_STRING_STATE_IDLE ""
#define VL53L0_STRING_STATE_RUNNING ""
#define VL53L0_STRING_STATE_UNKNOWN ""
#define VL53L0_STRING_STATE_ERROR ""
/* Device Specific */
#define VL53L0_STRING_DEVICEERROR_NONE ""
#define VL53L0_STRING_DEVICEERROR_VCSELCONTINUITYTESTFAILURE ""
#define VL53L0_STRING_DEVICEERROR_VCSELWATCHDOGTESTFAILURE ""
#define VL53L0_STRING_DEVICEERROR_NOVHVVALUEFOUND ""
#define VL53L0_STRING_DEVICEERROR_MSRCNOTARGET ""
#define VL53L0_STRING_DEVICEERROR_SNRCHECK ""
#define VL53L0_STRING_DEVICEERROR_RANGEPHASECHECK ""
#define VL53L0_STRING_DEVICEERROR_SIGMATHRESHOLDCHECK ""
#define VL53L0_STRING_DEVICEERROR_TCC ""
#define VL53L0_STRING_DEVICEERROR_PHASECONSISTENCY ""
#define VL53L0_STRING_DEVICEERROR_MINCLIP ""
#define VL53L0_STRING_DEVICEERROR_RANGECOMPLETE ""
#define VL53L0_STRING_DEVICEERROR_ALGOUNDERFLOW ""
#define VL53L0_STRING_DEVICEERROR_ALGOOVERFLOW ""
#define VL53L0_STRING_DEVICEERROR_RANGEIGNORETHRESHOLD ""
#define VL53L0_STRING_DEVICEERROR_UNKNOWN ""
/* Check Enable */
#define VL53L0_STRING_CHECKENABLE_SIGMA_FINAL_RANGE ""
#define VL53L0_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE ""
#define VL53L0_STRING_CHECKENABLE_SIGNAL_REF_CLIP ""
#define VL53L0_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD ""
/* Sequence Step */
#define VL53L0_STRING_SEQUENCESTEP_TCC ""
#define VL53L0_STRING_SEQUENCESTEP_DSS ""
#define VL53L0_STRING_SEQUENCESTEP_MSRC ""
#define VL53L0_STRING_SEQUENCESTEP_PRE_RANGE ""
#define VL53L0_STRING_SEQUENCESTEP_FINAL_RANGE ""
#else
#define VL53L0_STRING_DEVICE_INFO_NAME "VL53L0 cut1.0"
#define VL53L0_STRING_DEVICE_INFO_NAME_TS0 "VL53L0 TS0"
#define VL53L0_STRING_DEVICE_INFO_NAME_TS1 "VL53L0 TS1"
#define VL53L0_STRING_DEVICE_INFO_NAME_TS2 "VL53L0 TS2"
#define VL53L0_STRING_DEVICE_INFO_NAME_ES1 "VL53L0 ES1 or later"
#define VL53L0_STRING_DEVICE_INFO_TYPE "VL53L0"
/* PAL ERROR strings */
#define VL53L0_STRING_ERROR_NONE "No Error"
#define VL53L0_STRING_ERROR_CALIBRATION_WARNING "Calibration Warning Error"
#define VL53L0_STRING_ERROR_MIN_CLIPPED "Min clipped error"
#define VL53L0_STRING_ERROR_UNDEFINED "Undefined error"
#define VL53L0_STRING_ERROR_INVALID_PARAMS "Invalid parameters error"
#define VL53L0_STRING_ERROR_NOT_SUPPORTED "Not supported error"
#define VL53L0_STRING_ERROR_RANGE_ERROR "Range error"
#define VL53L0_STRING_ERROR_TIME_OUT "Time out error"
#define VL53L0_STRING_ERROR_MODE_NOT_SUPPORTED "Mode not supported error"
#define VL53L0_STRING_ERROR_BUFFER_TOO_SMALL "Buffer too small"
#define VL53L0_STRING_ERROR_GPIO_NOT_EXISTING "GPIO not existing"
#define VL53L0_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED "GPIO funct not supported"
#define VL53L0_STRING_ERROR_CONTROL_INTERFACE "Control Interface Error"
#define VL53L0_STRING_ERROR_INVALID_COMMAND "Invalid Command Error"
#define VL53L0_STRING_ERROR_DIVISION_BY_ZERO "Division by zero Error"
#define VL53L0_STRING_ERROR_REF_SPAD_INIT "Reference Spad Init Error"
#define VL53L0_STRING_ERROR_NOT_IMPLEMENTED "Not implemented error"
#define VL53L0_STRING_UNKNOW_ERROR_CODE "Unknown Error Code"
/* Range Status */
#define VL53L0_STRING_RANGESTATUS_NONE "No Update"
#define VL53L0_STRING_RANGESTATUS_RANGEVALID "Range Valid"
#define VL53L0_STRING_RANGESTATUS_SIGMA "Sigma Fail"
#define VL53L0_STRING_RANGESTATUS_SIGNAL "Signal Fail"
#define VL53L0_STRING_RANGESTATUS_MINRANGE "Min Range Fail"
#define VL53L0_STRING_RANGESTATUS_PHASE "Phase Fail"
#define VL53L0_STRING_RANGESTATUS_HW "Hardware Fail"
/* Range Status */
#define VL53L0_STRING_STATE_POWERDOWN "POWERDOWN State"
#define VL53L0_STRING_STATE_WAIT_STATICINIT "Wait for staticinit State"
#define VL53L0_STRING_STATE_STANDBY "STANDBY State"
#define VL53L0_STRING_STATE_IDLE "IDLE State"
#define VL53L0_STRING_STATE_RUNNING "RUNNING State"
#define VL53L0_STRING_STATE_UNKNOWN "UNKNOWN State"
#define VL53L0_STRING_STATE_ERROR "ERROR State"
/* Device Specific */
#define VL53L0_STRING_DEVICEERROR_NONE "No Update"
#define VL53L0_STRING_DEVICEERROR_VCSELCONTINUITYTESTFAILURE "VCSEL Continuity Test Failure"
#define VL53L0_STRING_DEVICEERROR_VCSELWATCHDOGTESTFAILURE "VCSEL Watchdog Test Failure"
#define VL53L0_STRING_DEVICEERROR_NOVHVVALUEFOUND "No VHV Value found"
#define VL53L0_STRING_DEVICEERROR_MSRCNOTARGET "MSRC No Target Error"
#define VL53L0_STRING_DEVICEERROR_SNRCHECK "SNR Check Exit"
#define VL53L0_STRING_DEVICEERROR_RANGEPHASECHECK "Range Phase Check Error"
#define VL53L0_STRING_DEVICEERROR_SIGMATHRESHOLDCHECK "Sigma Threshold Check Error"
#define VL53L0_STRING_DEVICEERROR_TCC "TCC Error"
#define VL53L0_STRING_DEVICEERROR_PHASECONSISTENCY "Phase Consistency Error"
#define VL53L0_STRING_DEVICEERROR_MINCLIP "Min Clip Error"
#define VL53L0_STRING_DEVICEERROR_RANGECOMPLETE "Range Complete"
#define VL53L0_STRING_DEVICEERROR_ALGOUNDERFLOW "Range Algo Underflow Error"
#define VL53L0_STRING_DEVICEERROR_ALGOOVERFLOW "Range Algo Overlow Error"
#define VL53L0_STRING_DEVICEERROR_RANGEIGNORETHRESHOLD "Range Ignore Threshold Error"
#define VL53L0_STRING_DEVICEERROR_UNKNOWN "Unknown error code"
/* Check Enable */
#define VL53L0_STRING_CHECKENABLE_SIGMA_FINAL_RANGE "SIGMA FINAL RANGE"
#define VL53L0_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE "SIGNAL RATE FINAL RANGE"
#define VL53L0_STRING_CHECKENABLE_SIGNAL_REF_CLIP "SIGNAL REF CLIP"
#define VL53L0_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD "RANGE IGNORE THRESHOLD"
/* Sequence Step */
#define VL53L0_STRING_SEQUENCESTEP_TCC "TCC"
#define VL53L0_STRING_SEQUENCESTEP_DSS "DSS"
#define VL53L0_STRING_SEQUENCESTEP_MSRC "MSRC"
#define VL53L0_STRING_SEQUENCESTEP_PRE_RANGE "PRE RANGE"
#define VL53L0_STRING_SEQUENCESTEP_FINAL_RANGE "FINAL RANGE"
#endif //USE_EMPTY_STRING
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2016, STMicroelectronics International N.V.
* Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -134,6 +134,7 @@ uint8_t DefaultTuningSettings[] = {
0x01, 0x8e, 0x01,
0x01, 0x00, 0x01,
0x01, 0xFF, 0x00,
0x01, 0x80, 0x00,
0x00, 0x00, 0x00
};

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2016, STMicroelectronics International N.V.
* Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -37,14 +37,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif
/** use where fractional values are expected
*
* Given a floating point value f it's .16 bit point is (int)(f*(1<<16))*/
* Given a floating point value f it's .16 bit point is (int)(f*(1<<16))
*/
typedef unsigned int FixPoint1616_t;
#if !defined(STDINT_H) && !defined(_GCC_STDINT_H) \
&& !defined(_STDINT_H) && !defined(_LINUX_TYPES_H)
#pragma message("Please review type definition of STDINT define for your \
platform and add to list above ")
#pragma message("Please review type definition of STDINT define for your" \
"platform and add to list above ")
/*
* target platform do not provide stdint or use a different #define than above

File diff suppressed because it is too large Load diff

View file

@ -1,138 +0,0 @@
/*******************************************************************************
Copyright © 2016, 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.
******************************************************************************/
#include "vl53l010_tuning.h"
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START(TRACE_MODULE_API, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END(TRACE_MODULE_API, status, ##__VA_ARGS__)
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
_LOG_FUNCTION_END_FMT(TRACE_MODULE_API, status, fmt, ##__VA_ARGS__)
#ifdef VL53L0_LOG_ENABLE
#define trace_print(level, ...) \
trace_print_module_function(TRACE_MODULE_API,\
level, TRACE_FUNCTION_NONE, ##__VA_ARGS__)
#endif
/*
//////////////////////////////////////////////////////
//// DEFAULT TUNING SETTINGS ////
//////////////////////////////////////////////////////
*/
VL53L0_Error VL53L010_load_tuning_settings(VL53L0_DEV Dev)
{
VL53L0_Error Status = VL53L0_ERROR_NONE;
LOG_FUNCTION_START("");
/* update 14_12_15_v11 */
Status |= VL53L0_WrByte(Dev, 0xFF, 0x01);
Status |= VL53L0_WrByte(Dev, 0x00, 0x00);
Status |= VL53L0_WrByte(Dev, 0x91, 0x3C);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x00);
Status |= VL53L0_WrByte(Dev, 0x54, 0x01);
Status |= VL53L0_WrByte(Dev, 0x33, 0x05);
Status |= VL53L0_WrByte(Dev, 0x32, 0x03);
Status |= VL53L0_WrByte(Dev, 0x30, 0x05);
Status |= VL53L0_WrByte(Dev, 0x50, 0x05);
Status |= VL53L0_WrByte(Dev, 0x60, 0x04);
Status |= VL53L0_WrByte(Dev, 0x70, 0x06);
Status |= VL53L0_WrByte(Dev, 0x46, 0x1a);
Status |= VL53L0_WrWord(Dev, 0x51, 0x01a3);
Status |= VL53L0_WrWord(Dev, 0x61, 0x01c4);
Status |= VL53L0_WrWord(Dev, 0x71, 0x018c);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x01);
Status |= VL53L0_WrByte(Dev, 0x31, 0x0f);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x00);
Status |= VL53L0_WrByte(Dev, 0x66, 0x38);
Status |= VL53L0_WrByte(Dev, 0x47, 0x00);
Status |= VL53L0_WrByte(Dev, 0x48, 0xff);
Status |= VL53L0_WrByte(Dev, 0x57, 0x4c);
Status |= VL53L0_WrByte(Dev, 0x67, 0x3c);
Status |= VL53L0_WrByte(Dev, 0x77, 0x5c);
Status |= VL53L0_WrWord(Dev, 0x44, 0x0000);
Status |= VL53L0_WrByte(Dev, 0x27, 0x00);
Status |= VL53L0_WrByte(Dev, 0x55, 0x00);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x01);
Status |= VL53L0_WrByte(Dev, 0x30, 0x28);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x00);
Status |= VL53L0_WrByte(Dev, 0x10, 0x0f);
Status |= VL53L0_WrByte(Dev, 0x11, 0xff);
Status |= VL53L0_WrByte(Dev, 0x40, 0x82);
Status |= VL53L0_WrByte(Dev, 0x41, 0xff);
Status |= VL53L0_WrByte(Dev, 0x42, 0x07);
Status |= VL53L0_WrByte(Dev, 0x43, 0x12);
Status |= VL53L0_WrByte(Dev, 0x20, 0x00);
Status |= VL53L0_WrByte(Dev, 0x21, 0x00);
Status |= VL53L0_WrByte(Dev, 0x28, 0x06);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x01);
Status |= VL53L0_WrByte(Dev, 0x48, 0x28);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x00);
Status |= VL53L0_WrByte(Dev, 0x7a, 0x0a);
Status |= VL53L0_WrByte(Dev, 0x7b, 0x00);
Status |= VL53L0_WrByte(Dev, 0x78, 0x00);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x01);
Status |= VL53L0_WrByte(Dev, 0x44, 0xff);
Status |= VL53L0_WrByte(Dev, 0x45, 0x00);
Status |= VL53L0_WrByte(Dev, 0x46, 0x10);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x00);
Status |= VL53L0_WrByte(Dev, 0x04, 0x00);
Status |= VL53L0_WrByte(Dev, 0x05, 0x04);
Status |= VL53L0_WrByte(Dev, 0x06, 0x00);
Status |= VL53L0_WrByte(Dev, 0x07, 0x00);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x01);
Status |= VL53L0_WrByte(Dev, 0x0d, 0x01);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x00);
Status |= VL53L0_WrByte(Dev, 0x80, 0x01);
Status |= VL53L0_WrByte(Dev, 0x01, 0xF8);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x01);
Status |= VL53L0_WrByte(Dev, 0x8e, 0x01);
Status |= VL53L0_WrByte(Dev, 0x00, 0x01);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x00);
if (Status != 0)
Status = VL53L0_ERROR_CONTROL_INTERFACE;
LOG_FUNCTION_END(Status);
return Status;
}

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2016, STMicroelectronics International N.V.
* Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -137,7 +137,8 @@ VL53L0_Error VL53L0_perform_xtalk_calibration(VL53L0_DEV Dev,
/* Round Cal Distance to Whole Number.
* Note that the cal distance is in mm, therefore no resolution
* is lost.*/
* is lost.
*/
xTalkCalDistanceAsInt = (XTalkCalDistance + 0x8000) >> 16;
if (xTalkStoredMeanRtnSpadsAsInt == 0 ||
@ -146,15 +147,17 @@ VL53L0_Error VL53L0_perform_xtalk_calibration(VL53L0_DEV Dev,
XTalkCompensationRateMegaCps = 0;
} else {
/* Round Cal Distance to Whole Number.
Note that the cal distance is in mm, therefore no
resolution is lost.*/
* Note that the cal distance is in mm, therefore no
* resolution is lost.
*/
xTalkCalDistanceAsInt = (XTalkCalDistance +
0x8000) >> 16;
/* Apply division by mean spad count early in the
* calculation to keep the numbers small.
* This ensures we can maintain a 32bit calculation.
* Fixed1616 / int := Fixed1616 */
* Fixed1616 / int := Fixed1616
*/
signalXTalkTotalPerSpad = (xTalkStoredMeanSignalRate) /
xTalkStoredMeanRtnSpadsAsInt;
@ -169,9 +172,6 @@ VL53L0_Error VL53L0_perform_xtalk_calibration(VL53L0_DEV Dev,
/* Round from 2^16 * Fixed1616, to Fixed1616. */
XTalkCompensationRateMegaCps = (signalXTalkTotalPerSpad
+ 0x8000) >> 16;
if (XTalkCompensationRateMegaCps < 0)
XTalkCompensationRateMegaCps = 0;
}
*pXTalkCompensationRateMegaCps = XTalkCompensationRateMegaCps;
@ -262,7 +262,8 @@ VL53L0_Error VL53L0_perform_offset_calibration(VL53L0_DEV Dev,
/* Round Cal Distance to Whole Number.
* Note that the cal distance is in mm, therefore no resolution
* is lost.*/
* is lost.
*/
CalDistanceAsInt_mm = (CalDistanceMilliMeter + 0x8000) >> 16;
*pOffsetMicroMeter = (CalDistanceAsInt_mm -
@ -365,7 +366,8 @@ VL53L0_Error VL53L0_apply_offset_adjustment(VL53L0_DEV Dev)
int32_t CurrentOffsetMicroMeters;
/* if we run on this function we can read all the NVM info
* used by the API */
* used by the API
*/
Status = VL53L0_get_info_from_device(Dev, 7);
/* Read back current device offset */
@ -429,7 +431,8 @@ void get_next_good_spad(uint8_t goodSpadArray[], uint32_t size,
if (coarseIndex == startIndex) {
/* locate the bit position of the provided current
* spad bit before iterating */
* spad bit before iterating
*/
dataByte >>= fineOffset;
fineIndex = fineOffset;
}
@ -455,6 +458,7 @@ uint8_t is_aperture(uint32_t spadIndex)
*/
uint32_t quadrant;
uint8_t isAperture = 1;
quadrant = spadIndex >> 6;
if (refArrayQuadrants[quadrant] == REF_ARRAY_SPAD_0)
isAperture = 0;
@ -518,7 +522,7 @@ VL53L0_Error count_enabled_spads(uint8_t spadArray[],
if (!spadTypeIdentified) {
*pIsAperture = 1;
if ((byteIndex < 2) && (bitIndex < 4))
*pIsAperture = 0;
*pIsAperture = 0;
spadTypeIdentified = 1;
}
}
@ -734,9 +738,9 @@ VL53L0_Error VL53L0_perform_ref_spad_management(VL53L0_DEV Dev,
* Note that there are 6 bytes. Only the first 44 bits will be used to
* represent spads.
*/
for (index = 0; index < spadArraySize; index++) {
for (index = 0; index < spadArraySize; index++)
Dev->Data.SpadData.RefSpadEnables[index] = 0;
}
Status = VL53L0_WrByte(Dev, 0xFF, 0x01);
@ -790,7 +794,8 @@ VL53L0_Error VL53L0_perform_ref_spad_management(VL53L0_DEV Dev,
if ((Status == VL53L0_ERROR_NONE) &&
(peakSignalRateRef > targetRefRate)) {
/* Signal rate measurement too high,
* switch to APERTURE SPADs */
* switch to APERTURE SPADs
*/
for (index = 0; index < spadArraySize; index++)
Dev->Data.SpadData.RefSpadEnables[index] = 0;
@ -823,10 +828,12 @@ VL53L0_Error VL53L0_perform_ref_spad_management(VL53L0_DEV Dev,
(peakSignalRateRef > targetRefRate)) {
/* Signal rate still too high after
* setting the minimum number of
* APERTURE spads. Can do no more.
* APERTURE spads. Can do no more
* therefore set the min number of
* aperture spads as the result.
*/
Status = VL53L0_ERROR_REF_SPAD_INIT;
needAptSpads = 0;
isApertureSpads_int = 1;
refSpadCount_int = minimumSpadCount;
}
}
} else {
@ -861,17 +868,20 @@ VL53L0_Error VL53L0_perform_ref_spad_management(VL53L0_DEV Dev,
break;
}
(refSpadCount_int)++;
/* Cannot combine Aperture and Non-Aperture spads, so
* ensure the current spad is of the correct type.
*/
if (is_aperture((uint32_t)startSelect + nextGoodSpad) !=
needAptSpads) {
Status = VL53L0_ERROR_REF_SPAD_INIT;
/* At this point we have enabled the maximum
* number of Aperture spads.
*/
complete = 1;
break;
}
(refSpadCount_int)++;
currentSpadIndex = nextGoodSpad;
Status = enable_spad_bit(
Dev->Data.SpadData.RefSpadEnables,
@ -880,7 +890,8 @@ VL53L0_Error VL53L0_perform_ref_spad_management(VL53L0_DEV Dev,
if (Status == VL53L0_ERROR_NONE) {
currentSpadIndex++;
/* Proceed to apply the additional spad and
* perform measurement. */
* perform measurement.
*/
Status = set_ref_spad_map(Dev,
Dev->Data.SpadData.RefSpadEnables);
}
@ -903,7 +914,8 @@ VL53L0_Error VL53L0_perform_ref_spad_management(VL53L0_DEV Dev,
*/
if (signalRateDiff > lastSignalRateDiff) {
/* Previous spad map produced a closer
* measurement, so choose this. */
* measurement, so choose this.
*/
Status = set_ref_spad_map(Dev,
lastSpadArray);
memcpy(
@ -974,9 +986,8 @@ VL53L0_Error VL53L0_set_reference_spads(VL53L0_DEV Dev,
VL53L0_REG_GLOBAL_CONFIG_REF_EN_START_SELECT,
startSelect);
for (index = 0; index < spadArraySize; index++) {
for (index = 0; index < spadArraySize; index++)
Dev->Data.SpadData.RefSpadEnables[index] = 0;
}
if (isApertureSpads) {
/* Increment to the first APERTURE spad */
@ -1022,7 +1033,7 @@ VL53L0_Error VL53L0_get_reference_spads(VL53L0_DEV Dev,
if (refSpadsInitialised == 1) {
*pSpadCount = (uint32_t)VL53L0_GETDEVICESPECIFICPARAMETER(Dev,
*pSpadCount = (uint32_t)VL53L0_GETDEVICESPECIFICPARAMETER(Dev,
ReferenceSpadCount);
*pIsApertureSpads = VL53L0_GETDEVICESPECIFICPARAMETER(Dev,
ReferenceSpadType);
@ -1222,7 +1233,8 @@ VL53L0_Error VL53L0_perform_ref_calibration(VL53L0_DEV Dev,
SequenceConfig = PALDevDataGet(Dev, SequenceConfig);
/* In the following function we don't save the config to optimize
* writes on device. Config is saved and restored only once. */
* writes on device. Config is saved and restored only once.
*/
Status = VL53L0_perform_vhv_calibration(
Dev, pVhvSettings, get_data_enable, 0);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2016, STMicroelectronics International N.V.
* Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -30,10 +30,10 @@
#include "vl53l0_api_core.h"
#include "vl53l0_api_calibration.h"
#ifndef __KERNEL__
#include <stdlib.h>
#endif
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START(TRACE_MODULE_API, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
@ -78,7 +78,7 @@ VL53L0_Error VL53L0_measurement_poll_for_completion(VL53L0_DEV Dev)
LoopNb++;
if (LoopNb >= VL53L0_DEFAULT_MAX_LOOP) {
Status = VL53L0_ERROR_TIME_OUT;
Status = VL53L0_ERROR_TIME_OUT;
break;
}
@ -131,7 +131,8 @@ uint32_t VL53L0_isqrt(uint32_t num)
uint32_t res = 0;
uint32_t bit = 1 << 30;
/* The second-to-top bit is set:
* 1 << 14 for 16-bits, 1 << 30 for 32 bits */
* 1 << 14 for 16-bits, 1 << 30 for 32 bits
*/
/* "bit" starts at the highest power of four <= the argument. */
while (bit > num)
@ -180,18 +181,20 @@ VL53L0_Error VL53L0_device_read_strobe(VL53L0_DEV Dev)
VL53L0_Error Status = VL53L0_ERROR_NONE;
uint8_t strobe;
uint32_t LoopNb;
LOG_FUNCTION_START("");
Status |= VL53L0_WrByte(Dev, 0x83, 0x00);
/* polling
* use timeout to avoid deadlock*/
* use timeout to avoid deadlock
*/
if (Status == VL53L0_ERROR_NONE) {
LoopNb = 0;
do {
Status = VL53L0_RdByte(Dev, 0x83, &strobe);
if ((strobe != 0x00) || Status != VL53L0_ERROR_NONE)
break;
break;
LoopNb = LoopNb + 1;
} while (LoopNb < VL53L0_DEFAULT_MAX_LOOP);
@ -239,7 +242,8 @@ VL53L0_Error VL53L0_get_info_from_device(VL53L0_DEV Dev, uint8_t option)
ReadDataFromDeviceDone);
/* This access is done only once after that a GetDeviceInfo or
* datainit is done*/
* datainit is done
*/
if (ReadDataFromDeviceDone != 7) {
Status |= VL53L0_WrByte(Dev, 0x80, 0x01);
@ -415,7 +419,7 @@ VL53L0_Error VL53L0_get_info_from_device(VL53L0_DEV Dev, uint8_t option)
VL53L0_SETDEVICESPECIFICPARAMETER(Dev,
ReferenceSpadType, ReferenceSpadType);
for(i = 0; i < VL53L0_REF_SPAD_BUFFER_SIZE; i++){
for (i = 0; i < VL53L0_REF_SPAD_BUFFER_SIZE; i++) {
Dev->Data.SpadData.RefGoodSpadMap[i] =
NvmRefGoodSpadMap[i];
}
@ -453,12 +457,12 @@ VL53L0_Error VL53L0_get_info_from_device(VL53L0_DEV Dev, uint8_t option)
OffsetMicroMeters = 0;
if (DistMeasFixed1104_400_mm != 0) {
OffsetFixed1104_mm =
DistMeasFixed1104_400_mm -
DistMeasTgtFixed1104_mm;
OffsetMicroMeters = (OffsetFixed1104_mm
OffsetFixed1104_mm =
DistMeasFixed1104_400_mm -
DistMeasTgtFixed1104_mm;
OffsetMicroMeters = (OffsetFixed1104_mm
* 1000) >> 4;
OffsetMicroMeters *= -1;
OffsetMicroMeters *= -1;
}
PALDevDataSet(Dev,
@ -484,8 +488,8 @@ uint32_t VL53L0_calc_macro_period_ps(VL53L0_DEV Dev, uint8_t vcsel_period_pclks)
LOG_FUNCTION_START("");
/* The above calculation will produce rounding errors,
therefore set fixed value
*/
* therefore set fixed value
*/
PLL_period_ps = 1655;
macro_period_vclks = 2304;
@ -569,8 +573,7 @@ uint32_t VL53L0_calc_timeout_us(VL53L0_DEV Dev,
macro_period_ns = (macro_period_ps + 500) / 1000;
actual_timeout_period_us =
((timeout_period_mclks * macro_period_ns)
+ (macro_period_ns / 2)) / 1000;
((timeout_period_mclks * macro_period_ns) + 500) / 1000;
return actual_timeout_period_us;
}
@ -647,7 +650,8 @@ VL53L0_Error get_sequence_step_timeout(VL53L0_DEV Dev,
&CurrentVCSELPulsePeriodPClk);
/* Retrieve PRE-RANGE Timeout in Macro periods
* (MCLKS) */
* (MCLKS)
*/
if (Status == VL53L0_ERROR_NONE) {
Status = VL53L0_RdWord(Dev,
VL53L0_REG_PRE_RANGE_CONFIG_TIMEOUT_MACROP_HI,
@ -695,7 +699,7 @@ VL53L0_Error set_sequence_step_timeout(VL53L0_DEV Dev,
uint16_t PreRangeEncodedTimeOut;
uint16_t PreRangeTimeOutMClks;
uint16_t MsrcRangeTimeOutMClks;
uint16_t FinalRangeTimeOutMClks;
uint32_t FinalRangeTimeOutMClks;
uint16_t FinalRangeEncodedTimeOut;
VL53L0_SchedulerSequenceSteps_t SchedulerSequenceSteps;
@ -779,7 +783,8 @@ VL53L0_Error set_sequence_step_timeout(VL53L0_DEV Dev,
&CurrentVCSELPulsePeriodPClk);
/* Retrieve PRE-RANGE Timeout in Macro periods
* (MCLKS) */
* (MCLKS)
*/
if (Status == VL53L0_ERROR_NONE) {
Status = VL53L0_RdWord(Dev, 0x51,
&PreRangeEncodedTimeOut);
@ -1070,7 +1075,8 @@ VL53L0_Error VL53L0_set_vcsel_pulse_period(VL53L0_DEV Dev,
/* Perform the phase calibration. This is needed after changing on
* vcsel period.
* get_data_enable = 0, restore_config = 1 */
* get_data_enable = 0, restore_config = 1
*/
if (Status == VL53L0_ERROR_NONE)
Status = VL53L0_perform_phase_calibration(
Dev, &PhaseCalInt, 0, 1);
@ -1115,7 +1121,7 @@ VL53L0_Error VL53L0_set_measurement_timing_budget_micro_seconds(VL53L0_DEV Dev,
uint32_t FinalRangeTimingBudgetMicroSeconds;
VL53L0_SchedulerSequenceSteps_t SchedulerSequenceSteps;
uint32_t MsrcDccTccTimeoutMicroSeconds = 2000;
uint32_t StartOverheadMicroSeconds = 1320;
uint32_t StartOverheadMicroSeconds = 1910;
uint32_t EndOverheadMicroSeconds = 960;
uint32_t MsrcOverheadMicroSeconds = 660;
uint32_t TccOverheadMicroSeconds = 590;
@ -1123,17 +1129,10 @@ VL53L0_Error VL53L0_set_measurement_timing_budget_micro_seconds(VL53L0_DEV Dev,
uint32_t PreRangeOverheadMicroSeconds = 660;
uint32_t FinalRangeOverheadMicroSeconds = 550;
uint32_t PreRangeTimeoutMicroSeconds = 0;
uint32_t cMinTimingBudgetMicroSeconds = 20000;
uint32_t SubTimeout = 0;
LOG_FUNCTION_START("");
if (MeasurementTimingBudgetMicroSeconds
< cMinTimingBudgetMicroSeconds) {
Status = VL53L0_ERROR_INVALID_PARAMS;
return Status;
}
FinalRangeTimingBudgetMicroSeconds =
MeasurementTimingBudgetMicroSeconds -
(StartOverheadMicroSeconds + EndOverheadMicroSeconds);
@ -1151,7 +1150,8 @@ VL53L0_Error VL53L0_set_measurement_timing_budget_micro_seconds(VL53L0_DEV Dev,
&MsrcDccTccTimeoutMicroSeconds);
/* Subtract the TCC, MSRC and DSS timeouts if they are
* enabled. */
* enabled.
*/
if (Status != VL53L0_ERROR_NONE)
return Status;
@ -1238,19 +1238,19 @@ VL53L0_Error VL53L0_set_measurement_timing_budget_micro_seconds(VL53L0_DEV Dev,
FinalRangeOverheadMicroSeconds;
/* Final Range Timeout
* Note that the final range timeout is determined by the timing
* budget and the sum of all other timeouts within the sequence.
* If there is no room for the final range timeout, then an error
* will be set. Otherwise the remaining time will be applied to
* the final range.
*/
* Note that the final range timeout is determined by the timing
* budget and the sum of all other timeouts within the sequence.
* If there is no room for the final range timeout, then an
* error will be set. Otherwise the remaining time will be
* applied to the final range.
*/
Status = set_sequence_step_timeout(Dev,
VL53L0_SEQUENCESTEP_FINAL_RANGE,
FinalRangeTimingBudgetMicroSeconds);
VL53L0_SEQUENCESTEP_FINAL_RANGE,
FinalRangeTimingBudgetMicroSeconds);
VL53L0_SETPARAMETERFIELD(Dev,
MeasurementTimingBudgetMicroSeconds,
MeasurementTimingBudgetMicroSeconds);
MeasurementTimingBudgetMicroSeconds,
MeasurementTimingBudgetMicroSeconds);
}
LOG_FUNCTION_END(Status);
@ -1431,14 +1431,6 @@ VL53L0_Error VL53L0_load_tuning_settings(VL53L0_DEV Dev,
}
}
/* Set Pulse Width Offset. This duplicates the previous setting
* applied in the tuning list, however is required because the
* register value appears to have not been set.
*/
Status |= VL53L0_WrByte(Dev, 0xff, 0x01);
Status |= VL53L0_WrByte(Dev, 0x50, 0x06);
Status |= VL53L0_WrByte(Dev, 0xff, 0x00);
LOG_FUNCTION_END(Status);
return Status;
}
@ -1456,9 +1448,9 @@ VL53L0_Error VL53L0_get_total_xtalk_rate(VL53L0_DEV Dev,
*ptotal_xtalk_rate_mcps = 0;
Status = VL53L0_GetXTalkCompensationEnable(Dev, &xtalkCompEnable);
if(Status == VL53L0_ERROR_NONE) {
if (Status == VL53L0_ERROR_NONE) {
if(xtalkCompEnable) {
if (xtalkCompEnable) {
VL53L0_GETPARAMETERFIELD(
Dev,
@ -1471,7 +1463,8 @@ VL53L0_Error VL53L0_get_total_xtalk_rate(VL53L0_DEV Dev,
xtalkPerSpadMegaCps;
/* FixPoint0824 >> 8 = FixPoint1616 */
*ptotal_xtalk_rate_mcps = (totalXtalkMegaCps + 0x80) >> 8;
*ptotal_xtalk_rate_mcps =
(totalXtalkMegaCps + 0x80) >> 8;
}
}
@ -1493,199 +1486,112 @@ VL53L0_Error VL53L0_get_total_signal_rate(VL53L0_DEV Dev,
Status = VL53L0_get_total_xtalk_rate(
Dev, pRangingMeasurementData, &totalXtalkMegaCps);
if(Status == VL53L0_ERROR_NONE)
if (Status == VL53L0_ERROR_NONE)
*ptotal_signal_rate_mcps += totalXtalkMegaCps;
return Status;
}
VL53L0_Error VL53L0_calc_dmax(
VL53L0_DEV Dev,
FixPoint1616_t totalSignalRate_mcps,
FixPoint1616_t totalCorrSignalRate_mcps,
FixPoint1616_t pwMult,
uint32_t sigmaEstimateP1,
FixPoint1616_t sigmaEstimateP2,
uint32_t peakVcselDuration_us,
uint32_t *pdmax_mm)
{
const uint32_t cSigmaLimit = 18;
const FixPoint1616_t cSignalLimit = 0x4000; /* 0.25 */
const FixPoint1616_t cSigmaEstRef = 0x00000042; /* 0.001 */
const uint32_t cAmbEffWidthSigmaEst_ns = 6;
const uint32_t cAmbEffWidthDMax_ns = 7;
uint32_t dmaxCalRange_mm;
FixPoint1616_t dmaxCalSignalRateRtn_mcps;
FixPoint1616_t minSignalNeeded;
FixPoint1616_t minSignalNeeded_p1;
FixPoint1616_t minSignalNeeded_p2;
FixPoint1616_t minSignalNeeded_p3;
FixPoint1616_t minSignalNeeded_p4;
FixPoint1616_t sigmaLimitTmp;
FixPoint1616_t sigmaEstSqTmp;
FixPoint1616_t signalLimitTmp;
FixPoint1616_t SignalAt0mm;
FixPoint1616_t dmaxDark;
FixPoint1616_t dmaxAmbient;
FixPoint1616_t dmaxDarkTmp;
uint32_t signalRateTemp_mcps;
VL53L0_Error get_dmax_lut_points(VL53L0_DMaxLUT_t data, uint32_t lut_size,
FixPoint1616_t input, int32_t *index0, int32_t *index1){
VL53L0_Error Status = VL53L0_ERROR_NONE;
FixPoint1616_t index0_tmp = 0;
FixPoint1616_t index1_tmp = 0;
int index = 0;
for (index = 0; index < lut_size; index++) {
if (input <= data.ambRate_mcps[index]) {
index1_tmp = index;
break;
}
}
if (index == lut_size) {
/* input is higher than last x point */
index0_tmp = index1_tmp = lut_size - 1;
} else if (index1_tmp == 0) {
/* input is lower than first x point */
index0_tmp = 0;
} else{
/* input is in between 2 points */
index0_tmp = index1_tmp - 1;
}
*index0 = index0_tmp;
*index1 = index1_tmp;
return Status;
}
VL53L0_Error VL53L0_calc_dmax(
VL53L0_DEV Dev, FixPoint1616_t ambRateMeas, uint32_t *pdmax_mm){
VL53L0_Error Status = VL53L0_ERROR_NONE;
VL53L0_DeviceParameters_t CurrentParameters;
int32_t index0 = 0;
int32_t index1 = 0;
FixPoint1616_t amb0, amb1, dmax0, dmax1;
FixPoint1616_t dmax_mm;
FixPoint1616_t linearSlope;
LOG_FUNCTION_START("");
dmaxCalRange_mm =
PALDevDataGet(Dev, DmaxCalRangeMilliMeter);
Status = VL53L0_GetDeviceParameters(Dev, &CurrentParameters);
dmaxCalSignalRateRtn_mcps =
PALDevDataGet(Dev, DmaxCalSignalRateRtnMegaCps);
if (ambRateMeas <= CurrentParameters.dmax_lut.ambRate_mcps[0]) {
dmax_mm = CurrentParameters.dmax_lut.dmax_mm[0];
} else if (ambRateMeas >=
CurrentParameters.dmax_lut.
ambRate_mcps[VL53L0_DMAX_LUT_SIZE - 1]) {
dmax_mm =
CurrentParameters.dmax_lut.dmax_mm[VL53L0_DMAX_LUT_SIZE -
1];
} else{
get_dmax_lut_points(CurrentParameters.dmax_lut,
VL53L0_DMAX_LUT_SIZE, ambRateMeas, &index0, &index1);
/* uint32 * FixPoint1616 = FixPoint1616 */
SignalAt0mm = dmaxCalRange_mm * dmaxCalSignalRateRtn_mcps;
if (index0 == index1) {
dmax_mm = CurrentParameters.dmax_lut.dmax_mm[index0];
} else {
amb0 = CurrentParameters.dmax_lut.ambRate_mcps[index0];
amb1 = CurrentParameters.dmax_lut.ambRate_mcps[index1];
dmax0 = CurrentParameters.dmax_lut.dmax_mm[index0];
dmax1 = CurrentParameters.dmax_lut.dmax_mm[index1];
if ((amb1 - amb0) != 0) {
/* Fix16:16/Fix16:8 => Fix16:8 */
linearSlope = (dmax0-dmax1)/((amb1-amb0) >> 8);
/* FixPoint1616 >> 8 = FixPoint2408 */
SignalAt0mm = (SignalAt0mm + 0x80) >> 8;
SignalAt0mm *= dmaxCalRange_mm;
minSignalNeeded_p1 = 0;
if(totalCorrSignalRate_mcps > 0) {
/* Shift by 10 bits to increase resolution prior to the
* division */
signalRateTemp_mcps = totalSignalRate_mcps << 10;
/* Add rounding value prior to division */
minSignalNeeded_p1 = signalRateTemp_mcps +
(totalCorrSignalRate_mcps/2);
/* FixPoint0626/FixPoint1616 = FixPoint2210 */
minSignalNeeded_p1 /= totalCorrSignalRate_mcps;
/* Apply a factored version of the speed of light.
Correction to be applied at the end */
minSignalNeeded_p1 *= 3;
/* FixPoint2210 * FixPoint2210 = FixPoint1220 */
minSignalNeeded_p1 *= minSignalNeeded_p1;
/* FixPoint1220 >> 16 = FixPoint2804 */
minSignalNeeded_p1 = (minSignalNeeded_p1 + 0x8000) >> 16;
/* Fix16:8 * Fix16:8 => Fix16:16 */
dmax_mm =
(((amb1 -
ambRateMeas) >> 8) * linearSlope) +
dmax1;
} else{
dmax_mm = dmax0;
}
}
}
minSignalNeeded_p2 = pwMult * sigmaEstimateP1;
/* FixPoint1616 >> 16 = uint32 */
minSignalNeeded_p2 = (minSignalNeeded_p2 + 0x8000) >> 16;
/* uint32 * uint32 = uint32 */
minSignalNeeded_p2 *= minSignalNeeded_p2;
/* DMAX uses a different ambient width from sigma, so apply
* correction.
* Perform division before multiplication to prevent overflow.
*/
sigmaEstimateP2 = (sigmaEstimateP2 + cAmbEffWidthSigmaEst_ns/2)/
cAmbEffWidthSigmaEst_ns;
sigmaEstimateP2 *= cAmbEffWidthDMax_ns;
/* FixPoint1616 >> 16 = uint32 */
minSignalNeeded_p3 = (sigmaEstimateP2 + 0x8000) >> 16;
minSignalNeeded_p3 *= minSignalNeeded_p3;
/* FixPoint2012 / uint32 = FixPoint2012 */
sigmaLimitTmp = ((cSigmaLimit << 12) + 500) / 1000;
/* FixPoint2012 * FixPoint2012 = FixPoint4420 := FixPoint0824 */
sigmaLimitTmp *= sigmaLimitTmp;
/* FixPoint1616 * FixPoint1616 = FixPoint3232 */
sigmaEstSqTmp = cSigmaEstRef * cSigmaEstRef;
/* FixPoint3232 >> 8 = FixPoint0824 */
sigmaEstSqTmp = (sigmaEstSqTmp + 0x80) >> 8;
/* FixPoint0824 - FixPoint0824 = FixPoint0824 */
sigmaLimitTmp -= sigmaEstSqTmp;
/* uint32_t * FixPoint0824 = FixPoint0824 */
minSignalNeeded_p4 = 4 * 12 * sigmaLimitTmp;
/* FixPoint0824 >> 12 = FixPoint2012 */
minSignalNeeded_p4 = (minSignalNeeded_p4 + 0x800) >> 12;
/* uint32 + uint32 = uint32 */
minSignalNeeded = (minSignalNeeded_p2 + minSignalNeeded_p3);
/* uint32 / uint32 = uint32 */
minSignalNeeded += (peakVcselDuration_us/2);
minSignalNeeded /= peakVcselDuration_us;
/* uint32 << 12 = FixPoint2012 */
minSignalNeeded <<= 12;
/* FixPoint2012 / FixPoint2012 = uint32 */
minSignalNeeded += (minSignalNeeded_p4/2);
minSignalNeeded /= minSignalNeeded_p4;
/* FixPoint3200 * FixPoint2804 := FixPoint2804*/
minSignalNeeded *= minSignalNeeded_p1;
/* Apply correction by dividing by 1000000.
* This assumes 10E16 on the numerator of the equation
* and 10E-22 on the denominator.
* We do this because 32bit fix point calculation can't
* handle the larger and smaller elements of this equation,
* i.e. speed of light and pulse widths.
*/
minSignalNeeded = (minSignalNeeded + 500) / 1000;
minSignalNeeded <<= 4;
minSignalNeeded = (minSignalNeeded + 500) / 1000;
/* FixPoint1616 >> 8 = FixPoint2408 */
signalLimitTmp = (cSignalLimit + 0x80) >> 8;
/* FixPoint2408/FixPoint2408 = uint32 */
if (signalLimitTmp != 0)
dmaxDarkTmp = (SignalAt0mm + (signalLimitTmp / 2))
/ signalLimitTmp;
else
dmaxDarkTmp = 0;
dmaxDark = VL53L0_isqrt(dmaxDarkTmp);
/* FixPoint2408/FixPoint2408 = uint32 */
if (minSignalNeeded != 0)
dmaxAmbient = (SignalAt0mm + minSignalNeeded/2)
/ minSignalNeeded;
else
dmaxAmbient = 0;
dmaxAmbient = VL53L0_isqrt(dmaxAmbient);
*pdmax_mm = dmaxDark;
if(dmaxDark > dmaxAmbient)
*pdmax_mm = dmaxAmbient;
*pdmax_mm = (uint32_t)(dmax_mm >> 16);
LOG_FUNCTION_END(Status);
return Status;
}
VL53L0_Error VL53L0_calc_sigma_estimate(VL53L0_DEV Dev,
VL53L0_RangingMeasurementData_t *pRangingMeasurementData,
FixPoint1616_t *pSigmaEstimate,
uint32_t *pDmax_mm)
FixPoint1616_t *pSigmaEstimate)
{
/* Expressed in 100ths of a ns, i.e. centi-ns */
const uint32_t cPulseEffectiveWidth_centi_ns = 800;
/* Expressed in 100ths of a ns, i.e. centi-ns */
const uint32_t cAmbientEffectiveWidth_centi_ns = 600;
const FixPoint1616_t cSigmaEstRef = 0x00000042; /* 0.001 */
const uint32_t cVcselPulseWidth_ps = 4700; /* pico secs */
const FixPoint1616_t cSigmaEstMax = 0x028F87AE;
const FixPoint1616_t cDfltFinalRangeIntegrationTimeMilliSecs =
0x00190000; /* 25ms */
const uint32_t cVcselPulseWidth_ps = 4700; /* pico secs */
const FixPoint1616_t cSigmaEstMax = 0x028F87AE;
const FixPoint1616_t cSigmaEstRtnMax = 0xF000;
const FixPoint1616_t cAmbToSignalRatioMax = 0xF0000000/
cAmbientEffectiveWidth_centi_ns;
/* Time Of Flight per mm (6.6 pico secs) */
const FixPoint1616_t cTOF_per_mm_ps = 0x0006999A;
const uint32_t c16BitRoundingParam = 0x00008000;
@ -1695,6 +1601,7 @@ VL53L0_Error VL53L0_calc_sigma_estimate(VL53L0_DEV Dev,
uint32_t vcselTotalEventsRtn;
uint32_t finalRangeTimeoutMicroSecs;
uint32_t preRangeTimeoutMicroSecs;
uint32_t finalRangeIntegrationTimeMilliSecs;
FixPoint1616_t sigmaEstimateP1;
FixPoint1616_t sigmaEstimateP2;
FixPoint1616_t sigmaEstimateP3;
@ -1716,7 +1623,7 @@ VL53L0_Error VL53L0_calc_sigma_estimate(VL53L0_DEV Dev,
FixPoint1616_t sqrtResult_centi_ns;
FixPoint1616_t sqrtResult;
FixPoint1616_t totalSignalRate_mcps;
FixPoint1616_t correctedSignalRate_mcps;
FixPoint1616_t sigmaEstRef;
uint32_t vcselWidth;
uint32_t finalRangeMacroPCLKS;
uint32_t preRangeMacroPCLKS;
@ -1726,18 +1633,7 @@ VL53L0_Error VL53L0_calc_sigma_estimate(VL53L0_DEV Dev,
/*! \addtogroup calc_sigma_estimate
* @{
*
* Estimates the range sigma based on the
*
* - vcsel_rate_kcps
* - ambient_rate_kcps
* - signal_total_events
* - xtalk_rate
*
* and the following parameters
*
* - SigmaEstRefArray
* - SigmaEstEffPulseWidth
* - SigmaEstEffAmbWidth
* Estimates the range sigma
*/
LOG_FUNCTION_START("");
@ -1753,10 +1649,6 @@ VL53L0_Error VL53L0_calc_sigma_estimate(VL53L0_DEV Dev,
ambientRate_kcps =
(pRangingMeasurementData->AmbientRateRtnMegaCps * 1000) >> 16;
correctedSignalRate_mcps =
pRangingMeasurementData->SignalRateRtnMegaCps;
Status = VL53L0_get_total_signal_rate(
Dev, pRangingMeasurementData, &totalSignalRate_mcps);
Status = VL53L0_get_total_xtalk_rate(
@ -1767,14 +1659,14 @@ VL53L0_Error VL53L0_calc_sigma_estimate(VL53L0_DEV Dev,
* peak signal rate, not average.
*/
peakSignalRate_kcps = (totalSignalRate_mcps * 1000);
peakSignalRate_kcps = (peakSignalRate_kcps + 0x8000) >> 16;
peakSignalRate_kcps = (peakSignalRate_kcps + 0x8000) >> 16;
xTalkCompRate_kcps = xTalkCompRate_mcps * 1000;
if (xTalkCompRate_kcps > cMaxXTalk_kcps)
xTalkCompRate_kcps = cMaxXTalk_kcps;
if(Status == VL53L0_ERROR_NONE){
if (Status == VL53L0_ERROR_NONE) {
/* Calculate final range macro periods */
finalRangeTimeoutMicroSecs = VL53L0_GETDEVICESPECIFICPARAMETER(
@ -1797,9 +1689,9 @@ VL53L0_Error VL53L0_calc_sigma_estimate(VL53L0_DEV Dev,
Dev, preRangeTimeoutMicroSecs, preRangeVcselPCLKS);
vcselWidth = 3;
if(finalRangeVcselPCLKS == 8) {
if (finalRangeVcselPCLKS == 8)
vcselWidth = 2;
}
peakVcselDuration_us = vcselWidth * 2048 *
(preRangeMacroPCLKS + finalRangeMacroPCLKS);
@ -1807,9 +1699,18 @@ VL53L0_Error VL53L0_calc_sigma_estimate(VL53L0_DEV Dev,
peakVcselDuration_us *= cPllPeriod_ps;
peakVcselDuration_us = (peakVcselDuration_us + 500)/1000;
/* Fix1616 >> 8 = Fix2408 */
totalSignalRate_mcps = (totalSignalRate_mcps + 0x80) >> 8;
/* Fix2408 * uint32 = Fix2408 */
vcselTotalEventsRtn = totalSignalRate_mcps *
peakVcselDuration_us;
vcselTotalEventsRtn = (vcselTotalEventsRtn + 0x8000) >> 16;
/* Fix2408 >> 8 = uint32 */
vcselTotalEventsRtn = (vcselTotalEventsRtn + 0x80) >> 8;
/* Fix2408 << 8 = Fix1616 = */
totalSignalRate_mcps <<= 8;
}
if (Status != VL53L0_ERROR_NONE) {
@ -1818,41 +1719,22 @@ VL53L0_Error VL53L0_calc_sigma_estimate(VL53L0_DEV Dev,
}
if (peakSignalRate_kcps == 0) {
*pSigmaEstimate = 0;
PALDevDataSet(Dev, SigmaEstimate, 0);
*pDmax_mm = 0;
*pSigmaEstimate = cSigmaEstMax;
PALDevDataSet(Dev, SigmaEstimate, cSigmaEstMax);
} else {
if (vcselTotalEventsRtn < 1)
vcselTotalEventsRtn = 1;
/*
* Calculate individual components of the main equation -
* replicating the equation implemented in the script
* OpenAll_Ewok_ranging_data.jsl.
*
* sigmaEstimateP1 represents the effective pulse width, which
* is a tuning parameter, rather than a real value.
*
* sigmaEstimateP2 represents the ambient/signal rate ratio
* expressed as a multiple of the effective ambient width
* (tuning parameter).
*
* sigmaEstimateP3 provides the signal event component, with the
* knowledge that
* - Noise of a square pulse is 1/sqrt(12) of the pulse
* width.
* - at 0Lux, sigma is proportional to
* effectiveVcselPulseWidth/sqrt(12 * signalTotalEvents)
*
* deltaT_ps represents the time of flight in pico secs for the
* current range measurement, using the "TOF per mm" constant
* (in ps).
*/
sigmaEstimateP1 = cPulseEffectiveWidth_centi_ns;
/* ((FixPoint1616 << 16)* uint32)/uint32 = FixPoint1616 */
sigmaEstimateP2 = (ambientRate_kcps << 16)/peakSignalRate_kcps;
if (sigmaEstimateP2 > cAmbToSignalRatioMax) {
/* Clip to prevent overflow. Will ensure safe
* max result.
*/
sigmaEstimateP2 = cAmbToSignalRatioMax;
}
sigmaEstimateP2 *= cAmbientEffectiveWidth_centi_ns;
sigmaEstimateP3 = 2 * VL53L0_isqrt(vcselTotalEventsRtn * 12);
@ -1869,75 +1751,81 @@ VL53L0_Error VL53L0_calc_sigma_estimate(VL53L0_DEV Dev,
* truncates.
*/
diff1_mcps = (((peakSignalRate_kcps << 16) -
xTalkCompRate_kcps) + 500)/1000;
2 * xTalkCompRate_kcps) + 500)/1000;
/* vcselRate + xtalkCompRate */
diff2_mcps = (((peakSignalRate_kcps << 16) +
xTalkCompRate_kcps) + 500)/1000;
diff2_mcps = ((peakSignalRate_kcps << 16) + 500)/1000;
/* Shift by 12 bits to increase resolution prior to the
* division */
diff1_mcps <<= 12;
/* Shift by 8 bits to increase resolution prior to the
* division
*/
diff1_mcps <<= 8;
/* FixPoint0428/FixPoint1616 = FixPoint2012 */
/* FixPoint0824/FixPoint1616 = FixPoint2408 */
xTalkCorrection = abs(diff1_mcps/diff2_mcps);
/* FixPoint2012 << 4 = FixPoint1616 */
xTalkCorrection <<= 4;
/* FixPoint2408 << 8 = FixPoint1616 */
xTalkCorrection <<= 8;
/* FixPoint1616/uint32 = FixPoint1616 */
pwMult = deltaT_ps/cVcselPulseWidth_ps; /* smaller than 1.0f */
if (pRangingMeasurementData->RangeStatus != 0) {
pwMult = 1 << 16;
} else {
/* FixPoint1616/uint32 = FixPoint1616 */
/* smaller than 1.0f */
pwMult = deltaT_ps/cVcselPulseWidth_ps;
/*
* FixPoint1616 * FixPoint1616 = FixPoint3232, however both
* values are small enough such that32 bits will not be
* exceeded.
*/
pwMult *= ((1 << 16) - xTalkCorrection);
/*
* FixPoint1616 * FixPoint1616 = FixPoint3232, however
* both values are small enough such that32 bits will
* not be exceeded.
*/
pwMult *= ((1 << 16) - xTalkCorrection);
/* (FixPoint3232 >> 16) = FixPoint1616 */
pwMult = (pwMult + c16BitRoundingParam) >> 16;
/* (FixPoint3232 >> 16) = FixPoint1616 */
pwMult = (pwMult + c16BitRoundingParam) >> 16;
/* FixPoint1616 + FixPoint1616 = FixPoint1616 */
pwMult += (1 << 16);
/* FixPoint1616 + FixPoint1616 = FixPoint1616 */
pwMult += (1 << 16);
/*
* At this point the value will be 1.xx, therefore if we square
* the value this will exceed 32 bits. To address this perform
* a single shift to the right before the multiplication.
*/
pwMult >>= 1;
/* FixPoint1715 * FixPoint1715 = FixPoint3430 */
pwMult = pwMult * pwMult;
/*
* At this point the value will be 1.xx, therefore if we
* square the value this will exceed 32 bits. To address
* this perform a single shift to the right before the
* multiplication.
*/
pwMult >>= 1;
/* FixPoint1715 * FixPoint1715 = FixPoint3430 */
pwMult = pwMult * pwMult;
/* (FixPoint3430 >> 14) = Fix1616 */
pwMult >>= 14;
/* (FixPoint3430 >> 14) = Fix1616 */
pwMult >>= 14;
}
/* FixPoint1616 * uint32 = FixPoint1616 */
sqr1 = pwMult * sigmaEstimateP1;
/* (FixPoint1616 >> 12) = FixPoint2804 */
sqr1 = (sqr1 + 0x800) >> 12;
/* (FixPoint1616 >> 16) = FixPoint3200 */
sqr1 = (sqr1 + 0x8000) >> 16;
/* FixPoint2804 * FixPoint2804 = FixPoint5608 */
/* FixPoint3200 * FixPoint3200 = FixPoint6400 */
sqr1 *= sqr1;
sqr2 = sigmaEstimateP2;
/* (FixPoint1616 >> 12) = FixPoint2804 */
sqr2 = (sqr2 + 0x800) >> 12;
/* (FixPoint1616 >> 16) = FixPoint3200 */
sqr2 = (sqr2 + 0x8000) >> 16;
/* FixPoint2804 * FixPoint2804 = FixPoint5608 */
/* FixPoint3200 * FixPoint3200 = FixPoint6400 */
sqr2 *= sqr2;
/* FixPoint5608 + FixPoint5608 = FixPoint5608 */
/* FixPoint64000 + FixPoint6400 = FixPoint6400 */
sqrSum = sqr1 + sqr2;
/* SQRT(FixPoint5608) = FixPoint2804 */
/* SQRT(FixPoin6400) = FixPoint3200 */
sqrtResult_centi_ns = VL53L0_isqrt(sqrSum);
/* (FixPoint2804 << 12) = FixPoint1616 */
sqrtResult_centi_ns <<= 12;
/* (FixPoint3200 << 16) = FixPoint1616 */
sqrtResult_centi_ns <<= 16;
/*
* Note that the Speed Of Light is expressed in um per 1E-10
@ -1952,17 +1840,39 @@ VL53L0_Error VL53L0_calc_sigma_estimate(VL53L0_DEV Dev,
sigmaEstRtn += 5000;
sigmaEstRtn /= 10000;
if (sigmaEstRtn > cSigmaEstRtnMax) {
/* Clip to prevent overflow. Will ensure safe
* max result.
*/
sigmaEstRtn = cSigmaEstRtnMax;
}
finalRangeIntegrationTimeMilliSecs =
(finalRangeTimeoutMicroSecs + preRangeTimeoutMicroSecs +
500) / 1000;
/* sigmaEstRef = 1mm * 25ms/final range integration time
* (inc pre-range)
* sqrt(FixPoint1616/int) = FixPoint2408)
*/
sigmaEstRef =
VL53L0_isqrt((cDfltFinalRangeIntegrationTimeMilliSecs +
finalRangeIntegrationTimeMilliSecs/2)/
finalRangeIntegrationTimeMilliSecs);
/* FixPoint2408 << 8 = FixPoint1616 */
sigmaEstRef <<= 8;
sigmaEstRef = (sigmaEstRef + 500)/1000;
/* FixPoint1616 * FixPoint1616 = FixPoint3232 */
sqr1 = sigmaEstRtn * sigmaEstRtn;
/* FixPoint1616 * FixPoint1616 = FixPoint3232 */
sqr2 = cSigmaEstRef * cSigmaEstRef;
sqr2 = sigmaEstRef * sigmaEstRef;
/* sqrt(FixPoint3232 << 8) = sqrt(FixPoint4024) =FixPoint2012 */
sqrtResult = VL53L0_isqrt((sqr1 + sqr2) << 8);
sqrtResult = (sqrtResult + 0x08) >> 4;
/* sqrt(FixPoint3232) = FixPoint1616 */
sqrtResult = VL53L0_isqrt((sqr1 + sqr2));
/*
* Note that the Shift by 12bits increases resolution prior to
* the sqrt, therefore the result must be shifted by 6bits to
* Note that the Shift by 4 bits increases resolution prior to
* the sqrt, therefore the result must be shifted by 2 bits to
* the right to revert back to the FixPoint1616 format.
*/
@ -1970,21 +1880,11 @@ VL53L0_Error VL53L0_calc_sigma_estimate(VL53L0_DEV Dev,
if ((peakSignalRate_kcps < 1) || (vcselTotalEventsRtn < 1) ||
(sigmaEstimate > cSigmaEstMax)) {
sigmaEstimate = cSigmaEstMax;
sigmaEstimate = cSigmaEstMax;
}
*pSigmaEstimate = (uint32_t)(sigmaEstimate);
PALDevDataSet(Dev, SigmaEstimate, *pSigmaEstimate);
Status = VL53L0_calc_dmax(
Dev,
totalSignalRate_mcps,
correctedSignalRate_mcps,
pwMult,
sigmaEstimateP1,
sigmaEstimateP2,
peakVcselDuration_us,
pDmax_mm);
}
LOG_FUNCTION_END(Status);
@ -2044,22 +1944,6 @@ VL53L0_Error VL53L0_get_pal_range_status(VL53L0_DEV Dev,
NoneFlag = 0;
}
/* LastSignalRefMcps */
if (Status == VL53L0_ERROR_NONE)
Status = VL53L0_WrByte(Dev, 0xFF, 0x01);
if (Status == VL53L0_ERROR_NONE)
Status = VL53L0_RdWord(Dev,
VL53L0_REG_RESULT_PEAK_SIGNAL_RATE_REF,
&tmpWord);
LastSignalRefMcps = VL53L0_FIXPOINT97TOFIXPOINT1616(tmpWord);
if (Status == VL53L0_ERROR_NONE)
Status = VL53L0_WrByte(Dev, 0xFF, 0x00);
PALDevDataSet(Dev, LastSignalRefMcps, LastSignalRefMcps);
/*
* Check if Sigma limit is enabled, if yes then do comparison with limit
* value and put the result back into pPalRangeStatus.
@ -2068,17 +1952,6 @@ VL53L0_Error VL53L0_get_pal_range_status(VL53L0_DEV Dev,
Status = VL53L0_GetLimitCheckEnable(Dev,
VL53L0_CHECKENABLE_SIGMA_FINAL_RANGE,
&SigmaLimitCheckEnable);
/*
* compute the Sigma and check with limit
*/
Status = VL53L0_calc_sigma_estimate(
Dev,
pRangingMeasurementData,
&SigmaEstimate,
&Dmax_mm);
pRangingMeasurementData->SigmaEstimate = SigmaEstimate;
if (Status == VL53L0_ERROR_NONE)
pRangingMeasurementData->RangeDMaxMilliMeter = Dmax_mm;
if ((SigmaLimitCheckEnable != 0) && (Status == VL53L0_ERROR_NONE)) {
/*
@ -2087,9 +1960,12 @@ VL53L0_Error VL53L0_get_pal_range_status(VL53L0_DEV Dev,
Status = VL53L0_calc_sigma_estimate(
Dev,
pRangingMeasurementData,
&SigmaEstimate,
&Dmax_mm);
&SigmaEstimate);
if (Status == VL53L0_ERROR_NONE)
Status = VL53L0_calc_dmax(
Dev,
pRangingMeasurementData->AmbientRateRtnMegaCps,
&Dmax_mm);
if (Status == VL53L0_ERROR_NONE)
pRangingMeasurementData->RangeDMaxMilliMeter = Dmax_mm;
@ -2101,7 +1977,7 @@ VL53L0_Error VL53L0_get_pal_range_status(VL53L0_DEV Dev,
if ((SigmaLimitValue > 0) &&
(SigmaEstimate > SigmaLimitValue))
/* Limit Fail */
SigmaLimitflag = 1;
SigmaLimitflag = 1;
}
}
@ -2121,6 +1997,21 @@ VL53L0_Error VL53L0_get_pal_range_status(VL53L0_DEV Dev,
VL53L0_CHECKENABLE_SIGNAL_REF_CLIP,
&SignalRefClipValue);
/* Read LastSignalRefMcps from device */
if (Status == VL53L0_ERROR_NONE)
Status = VL53L0_WrByte(Dev, 0xFF, 0x01);
if (Status == VL53L0_ERROR_NONE)
Status = VL53L0_RdWord(Dev,
VL53L0_REG_RESULT_PEAK_SIGNAL_RATE_REF,
&tmpWord);
if (Status == VL53L0_ERROR_NONE)
Status = VL53L0_WrByte(Dev, 0xFF, 0x00);
LastSignalRefMcps = VL53L0_FIXPOINT97TOFIXPOINT1616(tmpWord);
PALDevDataSet(Dev, LastSignalRefMcps, LastSignalRefMcps);
if ((SignalRefClipValue > 0) &&
(LastSignalRefMcps > SignalRefClipValue)) {
/* Limit Fail */

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2016, STMicroelectronics International N.V.
* Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -55,6 +55,7 @@ VL53L0_Error VL53L0_start_histogram_measurement(VL53L0_DEV Dev,
{
VL53L0_Error Status = VL53L0_ERROR_NONE;
uint8_t dataByte;
LOG_FUNCTION_START("");
@ -104,7 +105,7 @@ VL53L0_Error VL53L0_confirm_measurement_start(VL53L0_DEV Dev)
do {
Status = VL53L0_GetMeasurementDataReady(Dev, &NewDataReady);
if ((NewDataReady == 0x01) || Status != VL53L0_ERROR_NONE)
break;
break;
LoopNb = LoopNb + 1;
VL53L0_PollingDelay(Dev);
@ -271,6 +272,7 @@ VL53L0_Error VL53L0_get_histogram_measurement_data(VL53L0_DEV Dev,
VL53L0_HistogramMeasurementData_t *pHistogramMeasurementData)
{
VL53L0_Error Status = VL53L0_ERROR_NOT_IMPLEMENTED;
LOG_FUNCTION_START("");
LOG_FUNCTION_END(Status);
@ -402,13 +404,14 @@ VL53L0_Error VL53L0_get_max_spads(VL53L0_DEV Dev,
if (Status == VL53L0_ERROR_NONE) {
if (max_spads <= 0) {
*pambient_too_high = 1;
return VL53L0_ERROR_DIVISION_BY_ZERO;
Status = VL53L0_ERROR_DIVISION_BY_ZERO;
} else {
ratio = RangingMeasurementData.AmbientRateRtnMegaCps /
max_spads;
/* ratio is given in mega count per second and
* FixPoint1616_t */
* FixPoint1616_t
*/
if (ratio > 65536/100)
*pambient_too_high = 1;
else
@ -519,6 +522,7 @@ uint32_t bytes_to_int(uint8_t *data_bytes)
/* Convert an array of 4 bytes to an integer.
*/
uint32_t data = (uint32_t)data_bytes[0] << 24;
data += ((uint32_t)data_bytes[1] << 16);
data += ((uint32_t)data_bytes[2] << 8);
data += ((uint32_t)data_bytes[3]);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2016, STMicroelectronics International N.V.
* Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2016, STMicroelectronics International N.V.
* Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -273,6 +273,10 @@ VL53L0_Error VL53L0_get_pal_error_string(VL53L0_Error PalErrorCode,
VL53L0_COPYSTRING(pPalErrorString,
VL53L0_STRING_ERROR_NOT_SUPPORTED);
break;
case VL53L0_ERROR_INTERRUPT_NOT_CLEARED:
VL53L0_COPYSTRING(pPalErrorString,
VL53L0_STRING_ERROR_INTERRUPT_NOT_CLEARED);
break;
case VL53L0_ERROR_RANGE_ERROR:
VL53L0_COPYSTRING(pPalErrorString,
VL53L0_STRING_ERROR_RANGE_ERROR);
@ -378,6 +382,7 @@ VL53L0_Error VL53L0_get_sequence_steps_info(
char *pSequenceStepsString)
{
VL53L0_Error Status = VL53L0_ERROR_NONE;
LOG_FUNCTION_START("");
switch (SequenceStepId) {
@ -437,6 +442,16 @@ VL53L0_Error VL53L0_get_limit_check_info(VL53L0_DEV Dev, uint16_t LimitCheckId,
VL53L0_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD);
break;
case VL53L0_CHECKENABLE_SIGNAL_RATE_MSRC:
VL53L0_COPYSTRING(pLimitCheckString,
VL53L0_STRING_CHECKENABLE_SIGNAL_RATE_MSRC);
break;
case VL53L0_CHECKENABLE_SIGNAL_RATE_PRE_RANGE:
VL53L0_COPYSTRING(pLimitCheckString,
VL53L0_STRING_CHECKENABLE_SIGNAL_RATE_PRE_RANGE);
break;
default:
VL53L0_COPYSTRING(pLimitCheckString,
VL53L0_STRING_UNKNOW_ERROR_CODE);

View file

@ -22,8 +22,6 @@
#include <linux/module.h>
#include <linux/delay.h>
#include "stmvl53l0-i2c.h"
#include "stmvl53l0-cci.h"
#include "vl53l0_platform.h"
#include "vl53l0_i2c_platform.h"
#include "vl53l0_def.h"
@ -75,15 +73,18 @@
#define VL53L0_GetLocalBuffer(Dev, n_byte) LocBuffer
#elif I2C_BUFFER_CONFIG == 2
/* user define buffer type declare DECL_I2C_BUFFER as access via
VL53L0_GetLocalBuffer */
* VL53L0_GetLocalBuffer
*/
#define DECL_I2C_BUFFER
#else
#error "invalid I2C_BUFFER_CONFIG "
#endif
#define VL53L0_I2C_USER_VAR /* none but could be for a flag var to
get/pass to mutex interruptible return flags and try again */
/* none but could be for a flag var to
* get/pass to mutex interruptible return flags and try again
*/
#define VL53L0_I2C_USER_VAR
#define VL53L0_GetI2CAccess(Dev) /* todo mutex acquire */
#define VL53L0_DoneI2CAcces(Dev) /* todo mutex release */

View file

@ -1,5 +1,5 @@
/*******************************************************************************
Copyright © 2016, STMicroelectronics International N.V.
* Copyright © 2016, STMicroelectronics International N.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -236,7 +236,7 @@ VL53L0_Error VL53L0_PollingDelay(VL53L0_DEV Dev)
VL53L0_Error status = VL53L0_ERROR_NONE;
LOG_FUNCTION_START("");
udelay(1000);
usleep_range(950, 1000);
LOG_FUNCTION_END(status);
return status;
}

View file

@ -8,7 +8,6 @@
#include <linux/i2c.h>
#include <linux/module.h>
#include "stmvl53l0-i2c.h"
#include "stmvl53l0-cci.h"
#include "vl53l0_platform.h"
#include "vl53l0_i2c_platform.h"
#include "stmvl53l0.h"
@ -25,58 +24,16 @@
*/
int VL53L0_I2CWrite(VL53L0_DEV dev, uint8_t *buff, uint8_t len)
{
int err = 0;
if (dev->bus_type == CCI_BUS) {
#ifdef CAMERA_CCI
uint16_t index;
struct cci_data *cci_client_obj =
(struct cci_data *)dev->client_object;
struct msm_camera_i2c_client *client = cci_client_obj->client;
index = buff[0];
/*pr_err("%s: index: %d len: %d\n", __func__, index, len); */
if (len == 2) {
uint8_t data;
data = buff[1];
/* for byte access */
err = client->i2c_func_tbl->i2c_write(client, index,
data, MSM_CAMERA_I2C_BYTE_DATA);
if (err < 0) {
pr_err("%s:%d failed status=%d\n",
__func__, __LINE__, err);
return err;
}
} else if (len == 3) {
uint16_t data;
data = ((uint16_t)buff[1] << 8) | (uint16_t)buff[2];
err = client->i2c_func_tbl->i2c_write(client, index,
data, MSM_CAMERA_I2C_WORD_DATA);
if (err < 0) {
pr_err("%s:%d failed status=%d\n",
__func__, __LINE__, err);
return err;
}
} else if (len >= 5) {
err = client->i2c_func_tbl->i2c_write_seq(client,
index, &buff[1], (len-1));
if (err < 0) {
pr_err("%s:%d failed status=%d\n",
__func__, __LINE__, err);
return err;
}
}
#endif
} else {
struct i2c_msg msg[1];
struct i2c_data *i2c_client_obj =
(struct i2c_data *)dev->client_object;
struct i2c_client *client = (struct i2c_client*)i2c_client_obj->client;
(struct i2c_data *)dev->client_object;
struct i2c_client *client =
(struct i2c_client *)i2c_client_obj->client;
msg[0].addr = client->addr;
msg[0].flags = I2C_M_WR;
@ -110,27 +67,12 @@ int VL53L0_I2CRead(VL53L0_DEV dev, uint8_t *buff, uint8_t len)
int err = 0;
if (dev->bus_type == CCI_BUS) {
#ifdef CAMERA_CCI
uint16_t index;
struct cci_data *cci_client_obj =
(struct cci_data *)dev->client_object;
struct msm_camera_i2c_client *client = cci_client_obj->client;
index = buff[0];
/* pr_err("%s: index: %d\n", __func__, index); */
err = client->i2c_func_tbl->i2c_read_seq(client,
index, buff, len);
if (err < 0) {
pr_err("%s:%d failed status=%d\n",
__func__, __LINE__, err);
return err;
}
#endif
} else {
struct i2c_msg msg[1];
struct i2c_data *i2c_client_obj =
(struct i2c_data *)dev->client_object;
struct i2c_client *client = (struct i2c_client*) i2c_client_obj->client;
(struct i2c_data *)dev->client_object;
struct i2c_client *client =
(struct i2c_client *) i2c_client_obj->client;
msg[0].addr = client->addr;
msg[0].flags = I2C_M_RD|client->flags;
@ -138,7 +80,6 @@ int VL53L0_I2CRead(VL53L0_DEV dev, uint8_t *buff, uint8_t len)
msg[0].len = len;
err = i2c_transfer(client->adapter, &msg[0], 1);
/* return the actual mesage transfer */
if (err != 1) {
pr_err("%s: Read i2c_transfer err:%d, addr:0x%x\n",
__func__, err, client->addr);

View file

@ -1,137 +0,0 @@
/*******************************************************************************
Copyright © 2015, 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.
******************************************************************************/
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START(TRACE_MODULE_API, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END(TRACE_MODULE_API, status, ##__VA_ARGS__)
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
_LOG_FUNCTION_END_FMT(TRACE_MODULE_API, status, fmt, ##__VA_ARGS__)
#ifdef VL53L0_LOG_ENABLE
#define trace_print(level, ...) \
trace_print_module_function(TRACE_MODULE_API,\
level, TRACE_FUNCTION_NONE, ##__VA_ARGS__)
#endif
/*
//////////////////////////////////////////////////////
//// DEFAULT TUNING SETTINGS ////
//////////////////////////////////////////////////////
*/
/*VL53L0_Error VL53L0_load_tuning_settings(VL53L0_DEV Dev)
{
VL53L0_Error Status = VL53L0_ERROR_NONE;
LOG_FUNCTION_START("");
Status |= VL53L0_WrByte(Dev, 0xFF, 0x01);
Status |= VL53L0_WrByte(Dev, 0x00, 0x00);
Status |= VL53L0_WrByte(Dev, 0x91, 0x3C);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x00);
Status |= VL53L0_WrByte(Dev, 0x54, 0x01);
Status |= VL53L0_WrByte(Dev, 0x33, 0x05);
Status |= VL53L0_WrByte(Dev, 0x32, 0x03);
Status |= VL53L0_WrByte(Dev, 0x30, 0x05);
Status |= VL53L0_WrByte(Dev, 0x50, 0x05);
Status |= VL53L0_WrByte(Dev, 0x60, 0x04);
Status |= VL53L0_WrByte(Dev, 0x70, 0x06);
Status |= VL53L0_WrByte(Dev, 0x46, 0x1a);
Status |= VL53L0_WrWord(Dev, 0x51, 0x01a3);
Status |= VL53L0_WrWord(Dev, 0x61, 0x01c4);
Status |= VL53L0_WrWord(Dev, 0x71, 0x018c);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x01);
Status |= VL53L0_WrByte(Dev, 0x31, 0x0f);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x00);
Status |= VL53L0_WrByte(Dev, 0x66, 0x38);
Status |= VL53L0_WrByte(Dev, 0x47, 0x00);
Status |= VL53L0_WrByte(Dev, 0x48, 0xff);
Status |= VL53L0_WrByte(Dev, 0x57, 0x4c);
Status |= VL53L0_WrByte(Dev, 0x67, 0x3c);
Status |= VL53L0_WrByte(Dev, 0x77, 0x5c);
Status |= VL53L0_WrWord(Dev, 0x44, 0x0000);
Status |= VL53L0_WrByte(Dev, 0x27, 0x00);
Status |= VL53L0_WrByte(Dev, 0x55, 0x00);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x01);
Status |= VL53L0_WrByte(Dev, 0x30, 0x28);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x00);
Status |= VL53L0_WrByte(Dev, 0x10, 0x0f);
Status |= VL53L0_WrByte(Dev, 0x11, 0xff);
Status |= VL53L0_WrByte(Dev, 0x41, 0xff);
Status |= VL53L0_WrByte(Dev, 0x42, 0x07);
Status |= VL53L0_WrByte(Dev, 0x43, 0x12);
Status |= VL53L0_WrByte(Dev, 0x20, 0x00);
Status |= VL53L0_WrByte(Dev, 0x21, 0x00);
Status |= VL53L0_WrByte(Dev, 0x28, 0x06);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x01);
Status |= VL53L0_WrByte(Dev, 0x48, 0x28);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x00);
Status |= VL53L0_WrByte(Dev, 0x7a, 0x0a);
Status |= VL53L0_WrByte(Dev, 0x7b, 0x00);
Status |= VL53L0_WrByte(Dev, 0x78, 0x00);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x01);
Status |= VL53L0_WrByte(Dev, 0x44, 0xff);
Status |= VL53L0_WrByte(Dev, 0x45, 0x00);
Status |= VL53L0_WrByte(Dev, 0x46, 0x10);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x00);
Status |= VL53L0_WrByte(Dev, 0x04, 0x00);
Status |= VL53L0_WrByte(Dev, 0x05, 0x04);
Status |= VL53L0_WrByte(Dev, 0x06, 0x00);
Status |= VL53L0_WrByte(Dev, 0x07, 0x00);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x01);
Status |= VL53L0_WrByte(Dev, 0x0d, 0x01);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x00);
Status |= VL53L0_WrByte(Dev, 0x80, 0x01);
Status |= VL53L0_WrByte(Dev, 0x01, 0xF8);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x01);
Status |= VL53L0_WrByte(Dev, 0x8e, 0x01);
Status |= VL53L0_WrByte(Dev, 0x00, 0x01);
Status |= VL53L0_WrByte(Dev, 0xFF, 0x00);
if (Status != 0)
Status = VL53L0_ERROR_CONTROL_INTERFACE;
LOG_FUNCTION_END(Status);
return Status;
}
*/

View file

@ -1,65 +0,0 @@
/*
* stmvl53l0-cci.h - Linux kernel modules for STM VL53L0 FlightSense TOF sensor
*
* Copyright (C) 2015 STMicroelectronics Imaging Division
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Defines
*/
#ifndef STMVL53L0_CCI_H
#define STMVL53L0_CCI_H
#include <linux/types.h>
#include <soc/qcom/camera2.h>
#include "msm_camera_i2c.h"
#include "msm_camera_dt_util.h"
#include "msm_camera_io_util.h"
#include "msm_cci.h"
#define MSM_TOF_MAX_VREGS (10)
struct msm_tof_vreg {
struct camera_vreg_t *cam_vreg;
void *data[MSM_TOF_MAX_VREGS];
int num_vreg;
};
struct cci_data {
struct msm_camera_i2c_client g_client;
struct msm_camera_i2c_client *client;
struct platform_device *pdev;
enum msm_camera_device_type_t device_type;
enum cci_i2c_master_t cci_master;
struct msm_tof_vreg vreg_cfg;
struct msm_sd_subdev msm_sd;
struct v4l2_subdev sdev;
struct v4l2_subdev_ops *subdev_ops;
char subdev_initialized;
uint32_t subdev_id;
uint8_t power_up;
uint32_t lowv;
uint32_t highv;
uint32_t xtalk;
struct msm_camera_gpio_conf gconf;
struct msm_pinctrl_info pinctrl_info;
};
int stmvl53l0_init_cci(void);
void stmvl53l0_exit_cci(void *);
int stmvl53l0_power_down_cci(void *);
int stmvl53l0_power_up_cci(void *, unsigned int *);
#endif /* STMVL53L0_CCI_H */

View file

@ -1,7 +1,7 @@
/*
* stmvl53l0-i2c.h - Linux kernel modules for STM VL53L0 FlightSense TOF sensor
*
* Copyright (C) 2015 STMicroelectronics Imaging Division
* Copyright (C) 2016 STMicroelectronics Imaging Division
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -12,10 +12,6 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Defines
@ -24,17 +20,11 @@
#define STMVL53L0_I2C_H
#include <linux/types.h>
#include <soc/qcom/camera2.h>
#include "msm_camera_i2c.h"
#include "msm_camera_dt_util.h"
#include "msm_camera_io_util.h"
#include "msm_cci.h"
struct i2c_data {
struct i2c_client *client;
struct regulator *vana;
uint8_t power_up;
uint32_t lowv;
uint32_t highv;
uint32_t xtalk;
struct msm_camera_gpio_conf gconf;
struct msm_pinctrl_info pinctrl_info;
@ -43,5 +33,4 @@ int stmvl53l0_init_i2c(void);
void stmvl53l0_exit_i2c(void *);
int stmvl53l0_power_up_i2c(void *, unsigned int *);
int stmvl53l0_power_down_i2c(void *);
#endif /* STMVL53L0_I2C_H */

View file

@ -1,7 +1,7 @@
/*
* stmvl53l0.h - Linux kernel modules for STM VL53L0 FlightSense TOF sensor
*
* Copyright (C) 2015 STMicroelectronics Imaging Division
* Copyright (C) 2016 STMicroelectronics Imaging Division
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -12,10 +12,6 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Defines
@ -27,70 +23,59 @@
#include <linux/mutex.h>
#include <linux/workqueue.h>
#include <linux/miscdevice.h>
#include <linux/wait.h>
#define STMVL53L0_DRV_NAME "stmvl53l0"
#define STMVL53L0_SLAVE_ADDR (0x52>>1)
#define DRIVER_VERSION "1.1.18"
#define DRIVER_VERSION_NUM 18
#define DRIVER_VERSION "1.1.23"
#define I2C_M_WR 0x00
/* #define INT_POLLING_DELAY 20 */
/* if don't want to have output from vl6180_dbgmsg, comment out #DEBUG macro */
/*#define DEBUG*/
/* #define vl6180_dbgmsg(str, args...) pr_debug("%s: " str, __func__, ##args) */
#define vl53l0_dbgmsg_en(str, args...) \
/* if don't want to have output from vl53l0_dbgmsg, comment out #DEBUG macro */
//#define DEBUG
#ifdef DEBUG
#define vl53l0_dbgmsg(str, args...) \
pr_err("%s: " str, __func__, ##args)
#else
#define vl53l0_dbgmsg(str, args...) \
pr_debug("%s: " str, __func__, ##args)
#define vl53l0_dbgmsg(str, args...) \
pr_debug("%s: " str, __func__, ##args)
/* #define vl6180_errmsg(str, args...) pr_err("%s: " str, __func__, ##args) */
#endif
#define vl53l0_errmsg(str, args...) \
printk(KERN_ERR "%s: " str, __func__, ##args)
pr_err("%s: " str, __func__, ##args)
#define VL53L0_VDD_MIN 2850000
#define VL53L0_VDD_MAX 2850000
/*driver working mode*/
#define OFF_MODE 0
#define CAM_MODE 1
#define SAR_MODE 2
#define SUPER_MODE 3
#define XTALKCAL_MODE 4
#define OFFSETCAL_MODE 5
#define VL53L0_VDD_MIN 2600000
#define VL53L0_VDD_MAX 3000000
/*user actions*/
#define CAM_ON 0
#define CAM_OFF 1
#define SAR_ON 2
#define SAR_OFF 3
#define XTALKCAL_ON 4
#define OFFSETCAL_ON 5
#define CAL_OFF 6
#define RESET 7
/*parameter types*/
#define OFFSET_PAR 0
#define XTALKRATE_PAR 1
#define XTALKENABLE_PAR 2
#define SIGMAVAL_PRA 3
#define SIGMACTL_PRA 4
#define WRAPAROUNDCTL_PRA 5
#define INTERMEASUREMENTPERIOD_PAR 6
#define MEASUREMENTTIMINGBUDGET_PAR 7
#define SGLVAL_PRA 8
#define SGLCTL_PRA 9
#define CUTV_PRA 10
#define DRVV_PRA 11
#define PLLPRE_PRA 12
#define PLLFINAL_PRA 13
#define CCI_BUS 0
#define I2C_BUS 1
typedef enum {
NORMAL_MODE = 0,
OFFSETCALIB_MODE = 1,
XTALKCALIB_MODE = 2,
} init_mode_e;
typedef enum {
OFFSET_PAR = 0,
XTALKRATE_PAR = 1,
XTALKENABLE_PAR = 2,
GPIOFUNC_PAR = 3,
LOWTHRESH_PAR = 4,
HIGHTHRESH_PAR = 5,
DEVICEMODE_PAR = 6,
INTERMEASUREMENT_PAR = 7,
REFERENCESPADS_PAR = 8,
REFCALIBRATION_PAR = 9,
} parameter_name_e;
enum {
CCI_BUS = 0,
I2C_BUS = 1,
};
/*
* IOCTL register data structs
*/
struct stmvl53l0_register {
uint32_t is_read; /*1: read 0: #define write*/
uint32_t is_read; /*1: read 0: write*/
uint32_t reg_index;
uint32_t reg_bytes;
uint32_t reg_data;
@ -102,34 +87,48 @@ struct stmvl53l0_register {
*/
struct stmvl53l0_parameter {
uint32_t is_read; /*1: Get 0: Set*/
uint32_t name;
parameter_name_e name;
int32_t value;
int32_t value2;
int32_t status;
};
/*
* IOCTL Custom Use Case
*/
struct stmvl53l0_custom_use_case {
FixPoint1616_t signalRateLimit;
FixPoint1616_t sigmaLimit;
uint32_t preRangePulsePeriod;
uint32_t finalRangePulsePeriod;
uint32_t timingBudget;
};
/*
* driver data structs
*/
struct stmvl53l0_data {
/* embed ST VL53L0 Dev data as "dev_data" */
VL53L0_DevData_t Data;
/* i2c device address user specific field */
uint8_t I2cDevAddr;
uint8_t comms_type;
uint16_t comms_speed_khz;
struct cci_data cci_client_object;
struct i2c_data i2c_client_object;
void *client_object;
/* !<embed ST VL53L0 Dev data as "dev_data" */
VL53L0_DevData_t Data;
/*!< i2c device address user specific field*/
uint8_t I2cDevAddr;
/*!< Type of comms : VL53L0_COMMS_I2C or VL53L0_COMMS_SPI */
uint8_t comms_type;
/*!< Comms speed [kHz] : typically 400kHz for I2C */
uint16_t comms_speed_khz;
/* CCI_BUS; I2C_BUS */
uint8_t bus_type;
void *client_object; /* cci or i2c client */
struct mutex update_lock;
struct delayed_work dwork; /* for PS work handler */
struct delayed_work initwork;
struct delayed_work resetwork;
struct delayed_work checkwork;
struct input_dev *input_dev_ps;
struct kobject *range_kobj;
const char *dev_name;
/* function pointer */
/* misc device */
struct miscdevice miscdev;
@ -141,48 +140,71 @@ struct stmvl53l0_data {
unsigned int enable_ps_sensor;
/* PS parameters */
unsigned int ps_is_singleshot;
unsigned int ps_is_started;
unsigned int ps_data; /* to store PS data */
/* Calibration parameters */
unsigned int offsetCalDistance;
unsigned int xtalkCalDistance;
/* Calibration values */
uint32_t refSpadCount;
uint8_t isApertureSpads;
uint8_t VhvSettings;
uint8_t PhaseCal;
int32_t OffsetMicroMeter;
FixPoint1616_t XTalkCompensationRateMegaCps;
uint32_t setCalibratedValue;
/* Custom values set by app */
FixPoint1616_t signalRateLimit;
FixPoint1616_t sigmaLimit;
uint32_t preRangePulsePeriod;
uint32_t finalRangePulsePeriod;
/* Range Data */
VL53L0_RangingMeasurementData_t rangeData;
int offset;
int xtalk;
/* Device parameters */
VL53L0_DeviceModes deviceMode;
uint32_t interMeasurems;
VL53L0_GpioFunctionality gpio_function;
VL53L0_InterruptPolarity gpio_polarity;
FixPoint1616_t low_threshold;
FixPoint1616_t high_threshold;
/* delay time in miniseconds*/
unsigned int delay_ms;
uint8_t delay_ms;
/* Timing Budget */
uint32_t timingBudget;
/* Use this threshold to force restart ranging */
uint32_t noInterruptCount;
/* Use this flag to denote use case*/
uint8_t useCase;
/* Use this flag to indicate an update of use case */
uint8_t updateUseCase;
/* Polling thread */
struct task_struct *poll_thread;
/* Wait Queue on which the poll thread blocks */
wait_queue_head_t poll_thread_wq;
/* Recent interrupt status */
uint32_t interruptStatus;
struct mutex work_mutex;
struct timer_list timer;
uint32_t flushCount;
/* Debug */
unsigned int enableDebug;
uint8_t interrupt_received;
int d_mode;
uint8_t w_mode;
/*for SAR mode indicate low range interrupt*/
uint8_t lowint;
uint8_t bus_type;
uint32_t lowv;
uint32_t highv;
wait_queue_head_t range_data_wait;
uint8_t d_ready;
uint8_t cut_v;
unsigned int xtalkCalDistance;
unsigned int offsetCalDistance;
unsigned int xtalkcalval;
VL53L0_GpioFunctionality gpio_function;
uint8_t c_suspend;
uint8_t c_stopped;
uint32_t refSpadCount;
uint8_t isApertureSpads;
uint8_t VhvSettings;
uint8_t PhaseCal;
uint8_t pll_p;
uint8_t pll_f;
};
/*
* funtion pointer structs
* function pointer structs
*/
struct stmvl53l0_module_fn_t {
int (*init)(void);
@ -191,11 +213,9 @@ struct stmvl53l0_module_fn_t {
int (*power_down)(void *);
};
struct stmvl53l0_data *stmvl53l0_getobject(void);
int stmvl53l0_setup(struct stmvl53l0_data *data, uint8_t type);
int stmvl53l0_setup(struct stmvl53l0_data *data);
void stmvl53l0_cleanup(struct stmvl53l0_data *data);
int stmvl53l0_checkmoduleid(struct stmvl53l0_data *data,
void *client, uint8_t type);
int stmvl53l0_livechecking(struct stmvl53l0_data *data);
void i2c_setclient(void *client, uint8_t type);
#endif /* STMVL53L0_H */

View file

@ -1,475 +0,0 @@
/*
* stmvl53l0_module-cci.c - Linux kernel modules for STM VL53L0 FlightSense TOF
* sensor
*
* Copyright (C) 2015 STMicroelectronics Imaging Division.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program;
*/
#include <linux/uaccess.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/mutex.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/gpio.h>
#include <linux/input.h>
#include <linux/miscdevice.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/time.h>
#include <linux/platform_device.h>
/*
* power specific includes
*/
#include <linux/pwm.h>
#include <linux/regulator/consumer.h>
#include <linux/pinctrl/consumer.h>
#include <linux/clk.h>
#include <linux/of_gpio.h>
/*
* API includes
*/
#include "vl53l0_api.h"
#include "vl53l0_def.h"
#include "vl53l0_platform.h"
#include "stmvl53l0-cci.h"
#include "stmvl53l0-i2c.h"
#include "stmvl53l0.h"
#define LASER_SENSOR_PINCTRL_STATE_SLEEP "laser_suspend"
#define LASER_SENSOR_PINCTRL_STATE_DEFAULT "laser_default"
#ifdef CAMERA_CCI
/*
* Global data
*/
static struct v4l2_file_operations msm_tof_v4l2_subdev_fops;
static struct msm_camera_i2c_fn_t msm_sensor_cci_func_tbl = {
.i2c_read = msm_camera_cci_i2c_read,
.i2c_read_seq = msm_camera_cci_i2c_read_seq,
.i2c_write = msm_camera_cci_i2c_write,
.i2c_write_seq = msm_camera_cci_i2c_write_seq,
.i2c_write_table = msm_camera_cci_i2c_write_table,
.i2c_write_seq_table = msm_camera_cci_i2c_write_seq_table,
.i2c_write_table_w_microdelay =
msm_camera_cci_i2c_write_table_w_microdelay,
.i2c_util = msm_sensor_cci_i2c_util,
.i2c_poll = msm_camera_cci_i2c_poll,
};
int vl53l0_get_dt_xtalk_data(struct device_node *of_node, int *xtalk)
{
int rc = 0;
uint32_t count = 0;
uint32_t v_array[1];
count = of_property_count_strings(of_node, "st,xtalkval");
if (!count)
return 0;
rc = of_property_read_u32_array(of_node, "st,xtalkval",
v_array, 1);
if (rc != -EINVAL) {
if (rc < 0)
pr_err("%s failed %d\n", __func__, __LINE__);
else
*xtalk = v_array[0];
} else
rc = 0;
return rc;
}
static int stmvl53l0_get_dt_data(struct device *dev, struct cci_data *data);
/*
* QCOM specific functions
*/
static int stmvl53l0_get_dt_data(struct device *dev, struct cci_data *data)
{
int rc = 0;
struct msm_camera_gpio_conf *gconf = NULL;
uint16_t *gpio_array = NULL;
uint16_t gpio_array_size = 0;
int i;
struct msm_pinctrl_info *sensor_pctrl = NULL;
struct msm_tof_vreg *vreg_cfg = NULL;
vl53l0_dbgmsg("Enter\n");
sensor_pctrl = &data->pinctrl_info;
sensor_pctrl->pinctrl = devm_pinctrl_get(dev);
if (IS_ERR_OR_NULL(sensor_pctrl->pinctrl)) {
pr_err("%s:%d Getting pinctrl handle failed\n",
__func__, __LINE__);
return -EINVAL;
}
sensor_pctrl->gpio_state_active =
pinctrl_lookup_state(sensor_pctrl->pinctrl,
LASER_SENSOR_PINCTRL_STATE_DEFAULT);
sensor_pctrl->gpio_state_suspend
= pinctrl_lookup_state(sensor_pctrl->pinctrl,
LASER_SENSOR_PINCTRL_STATE_SLEEP);
if (dev->of_node) {
struct device_node *of_node = dev->of_node;
if (!of_node) {
vl53l0_errmsg("failed %d\n", __LINE__);
return -EINVAL;
}
rc = of_property_read_u32(of_node,
"cell-index", &data->pdev->id);
if (rc < 0) {
vl53l0_errmsg("failed %d\n", __LINE__);
return rc;
}
vl53l0_dbgmsg("cell-index: %d\n", data->pdev->id);
rc = of_property_read_u32(of_node,
"qcom,cci-master", &data->cci_master);
if (rc < 0) {
vl53l0_errmsg("failed %d\n", __LINE__);
/* Set default master 0 */
data->cci_master = MASTER_0;
rc = 0;
}
vl53l0_dbgmsg("cci_master: %d\n", data->cci_master);
if (of_find_property(of_node,
"qcom,cam-vreg-name", NULL)) {
vl53l0_dbgmsg("vreg setting is found");
vreg_cfg = &data->vreg_cfg;
rc = msm_camera_get_dt_vreg_data(of_node,
&vreg_cfg->cam_vreg, &vreg_cfg->num_vreg);
if (rc < 0) {
vl53l0_errmsg("failed %d\n", __LINE__);
rc = 0;
}
}
vl53l0_dbgmsg("vreg num: %d\n", vreg_cfg->num_vreg);
gpio_array_size = of_gpio_count(of_node);
gconf = &data->gconf;
if (gpio_array_size) {
gpio_array = kcalloc(gpio_array_size, sizeof(uint16_t),
GFP_KERNEL);
for (i = 0; i < gpio_array_size; i++) {
gpio_array[i] = of_get_gpio(of_node, i);
pr_err("%s gpio_array[%d] = %d\n", __func__, i,
gpio_array[i]);
}
rc = msm_camera_get_dt_gpio_req_tbl(of_node, gconf,
gpio_array, gpio_array_size);
if (rc < 0) {
pr_err("%s failed %d\n", __func__, __LINE__);
return rc;
}
rc = msm_camera_init_gpio_pin_tbl(of_node, gconf,
gpio_array, gpio_array_size);
if (rc < 0) {
pr_err("%s failed %d\n", __func__, __LINE__);
return rc;
}
}
rc = vl53l0_get_dt_xtalk_data(of_node,
&(data->xtalk));
}
vl53l0_dbgmsg("End rc =%d\n", rc);
return rc;
}
static int32_t stmvl53l0_vreg_control(struct cci_data *data, int config)
{
int rc = 0, i, cnt;
struct msm_tof_vreg *vreg_cfg;
vl53l0_dbgmsg("Enter with config %d\n", config);
vreg_cfg = &data->vreg_cfg;
cnt = vreg_cfg->num_vreg;
if (!cnt) {
vl53l0_errmsg("failed %d\n", __LINE__);
return 0;
}
if (cnt >= MSM_TOF_MAX_VREGS) {
vl53l0_errmsg("failed %d cnt %d\n", __LINE__, cnt);
return -EINVAL;
}
for (i = 0; i < cnt; i++) {
rc = msm_camera_config_single_vreg(&(data->pdev->dev),
&vreg_cfg->cam_vreg[i],
(struct regulator **)&vreg_cfg->data[i],
config);
}
vl53l0_dbgmsg("EXIT rc =%d\n", rc);
return rc;
}
static int msm_tof_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
{
int rc = 0;
return rc;
}
static const struct v4l2_subdev_internal_ops msm_tof_internal_ops = {
.close = msm_tof_close,
};
static long msm_tof_subdev_ioctl(struct v4l2_subdev *sd,
unsigned int cmd, void *arg)
{
vl53l0_dbgmsg("Subdev_ioctl not handled\n");
return 0;
}
static int32_t msm_tof_power(struct v4l2_subdev *sd, int on)
{
vl53l0_dbgmsg("TOF power called\n");
return 0;
}
static struct v4l2_subdev_core_ops msm_tof_subdev_core_ops = {
.ioctl = msm_tof_subdev_ioctl,
.s_power = msm_tof_power,
};
static struct v4l2_subdev_ops msm_tof_subdev_ops = {
.core = &msm_tof_subdev_core_ops,
};
static int stmvl53l0_cci_init(struct cci_data *data)
{
int rc = 0;
struct msm_camera_cci_client *cci_client = data->client->cci_client;
if (FALSE == data->subdev_initialized) {
data->client->i2c_func_tbl = &msm_sensor_cci_func_tbl;
data->client->cci_client =
kzalloc(sizeof(struct msm_camera_cci_client),
GFP_KERNEL);
if (!data->client->cci_client) {
vl53l0_errmsg("%d, failed no memory\n", __LINE__);
return -ENOMEM;
}
cci_client = data->client->cci_client;
cci_client->cci_subdev = msm_cci_get_subdev();
cci_client->cci_i2c_master = data->cci_master;
v4l2_subdev_init(&data->msm_sd.sd, data->subdev_ops);
v4l2_set_subdevdata(&data->msm_sd.sd, data);
data->msm_sd.sd.internal_ops = &msm_tof_internal_ops;
data->msm_sd.sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
snprintf(data->msm_sd.sd.name,
ARRAY_SIZE(data->msm_sd.sd.name), "msm_tof");
media_entity_init(&data->msm_sd.sd.entity, 0, NULL, 0);
data->msm_sd.sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
data->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_TOF;
data->msm_sd.close_seq = MSM_SD_CLOSE_2ND_CATEGORY | 0x2;
msm_sd_register(&data->msm_sd);
msm_tof_v4l2_subdev_fops = v4l2_subdev_fops;
data->msm_sd.sd.devnode->fops = &msm_tof_v4l2_subdev_fops;
data->subdev_initialized = TRUE;
}
vl53l0_dbgmsg("inited\n");
cci_client->sid = 0x29;
cci_client->retries = 3;
cci_client->id_map = 0;
cci_client->cci_i2c_master = data->cci_master;
cci_client->i2c_freq_mode = I2C_FAST_MODE;
rc = data->client->i2c_func_tbl->i2c_util(data->client, MSM_CCI_INIT);
if (rc < 0) {
vl53l0_errmsg("%d: CCI Init failed\n", __LINE__);
return rc;
}
vl53l0_dbgmsg("CCI Init Succeeded\n");
data->client->addr_type = MSM_CAMERA_I2C_BYTE_ADDR;
return 0;
}
static int32_t stmvl53l0_platform_probe(struct platform_device *pdev)
{
struct stmvl53l0_data *vl53l0_data = NULL;
struct cci_data *data = NULL;
unsigned int present = 0;
int32_t rc = 0;
vl53l0_dbgmsg("Enter\n");
if (!pdev->dev.of_node) {
vl53l0_errmsg("%d,of_node NULL\n", __LINE__);
return -EINVAL;
}
vl53l0_data = stmvl53l0_getobject();
if (NULL == vl53l0_data) {
vl53l0_errmsg("%d,Object not found!\n", __LINE__);
return -EINVAL;
}
data = &(vl53l0_data->cci_client_object);
if (!data) {
vl53l0_errmsg("%d,data NULL\n", __LINE__);
return -EINVAL;
}
/* Set platform device handle */
data->subdev_ops = &msm_tof_subdev_ops;
data->pdev = pdev;
stmvl53l0_get_dt_data(&pdev->dev, data);
data->subdev_id = pdev->id;
/* Set device type as platform device */
data->device_type = MSM_CAMERA_PLATFORM_DEVICE;
data->subdev_initialized = FALSE;
data->client = (struct msm_camera_i2c_client *)&data->g_client;
rc = stmvl53l0_power_up_cci(data, &present);
if (rc) {
vl53l0_errmsg("%d,error rc %d\n", __LINE__, rc);
return rc;
}
rc = stmvl53l0_checkmoduleid(vl53l0_data, data->client, CCI_BUS);
if (rc != 0) {
vl53l0_errmsg("%d,error rc %d\n", __LINE__, rc);
stmvl53l0_power_down_cci(data);
return rc;
}
stmvl53l0_power_down_cci(data);
stmvl53l0_setup(vl53l0_data, CCI_BUS);
vl53l0_dbgmsg("End\n");
return rc;
}
static const struct of_device_id st_stmvl53l0_dt_match[] = {
{ .compatible = "st,stmvl53l0", },
{ },
};
static struct platform_driver stmvl53l0_platform_driver = {
.probe = stmvl53l0_platform_probe,
.driver = {
.name = STMVL53L0_DRV_NAME,
.owner = THIS_MODULE,
.of_match_table = st_stmvl53l0_dt_match,
},
};
int stmvl53l0_power_up_cci(void *cci_object, unsigned int *preset_flag)
{
int ret = 0;
struct cci_data *data = (struct cci_data *)cci_object;
vl53l0_dbgmsg("Enter");
pinctrl_select_state(data->pinctrl_info.pinctrl,
data->pinctrl_info.gpio_state_active);
stmvl53l0_vreg_control(data, 1);
msleep(20);
/* need to init cci first */
ret = stmvl53l0_cci_init(data);
if (ret) {
vl53l0_errmsg("stmvl53l0_cci_init failed %d\n", __LINE__);
return ret;
}
msm_camera_request_gpio_table(
data->gconf.cam_gpio_req_tbl,
data->gconf.cam_gpio_req_tbl_size, 1);
gpio_set_value_cansleep(data->gconf.cam_gpio_req_tbl[0].gpio, 1);
data->power_up = 1;
*preset_flag = 1;
vl53l0_dbgmsg("End\n");
msleep(20);
return ret;
}
int stmvl53l0_power_down_cci(void *cci_object)
{
int ret = 0;
struct cci_data *data = (struct cci_data *)cci_object;
vl53l0_dbgmsg("Enter\n");
if (data->power_up) {
/* need to release cci first */
ret = data->client->i2c_func_tbl->i2c_util(data->client,
MSM_CCI_RELEASE);
if (ret < 0)
vl53l0_errmsg("%d,CCI Release failed rc %d\n",
__LINE__, ret);
pinctrl_select_state(data->pinctrl_info.pinctrl,
data->pinctrl_info.gpio_state_suspend);
msm_camera_request_gpio_table(
data->gconf.cam_gpio_req_tbl,
data->gconf.cam_gpio_req_tbl_size, 0);
gpio_set_value_cansleep(
data->gconf.cam_gpio_req_tbl[0].gpio, 0);
stmvl53l0_vreg_control(data, 0);
}
data->power_up = 0;
vl53l0_dbgmsg("End\n");
return ret;
}
int stmvl53l0_init_cci(void)
{
int ret = 0;
vl53l0_dbgmsg("Enter\n");
/* register as a platform device */
ret = platform_driver_register(&stmvl53l0_platform_driver);
if (ret)
vl53l0_errmsg("%d, error ret:%d\n", __LINE__, ret);
vl53l0_dbgmsg("End\n");
return ret;
}
void stmvl53l0_exit_cci(void *cci_object)
{
struct cci_data *data = (struct cci_data *)cci_object;
vl53l0_dbgmsg("Enter\n");
if (data && data->client->cci_client)
kfree(data->client->cci_client);
vl53l0_dbgmsg("End\n");
}
#endif /* end of CAMERA_CCI */

View file

@ -1,22 +1,19 @@
/*
* stmvl53l0_module-i2c.c - Linux kernel modules for STM VL53L0 FlightSense TOF
* sensor
*
* Copyright (C) 2015 STMicroelectronics Imaging Division.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program;
*/
* stmvl53l0_module-i2c.c - Linux kernel modules for STM VL53L0 FlightSense TOF
* sensor
*
* Copyright (C) 2016 STMicroelectronics Imaging Division.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/uaccess.h>
#include <linux/module.h>
#include <linux/init.h>
@ -48,7 +45,6 @@
#include "vl53l0_def.h"
#include "vl53l0_platform.h"
#include "stmvl53l0-i2c.h"
#include "stmvl53l0-cci.h"
#include "stmvl53l0.h"
#define LASER_SENSOR_PINCTRL_STATE_SLEEP "laser_suspend"
@ -65,13 +61,13 @@ static int stmvl53l0_parse_vdd(struct device *dev, struct i2c_data *data);
static int stmvl53l0_parse_vdd(struct device *dev, struct i2c_data *data)
{
int ret = 0;
vl53l0_dbgmsg("Enter\n");
if (dev->of_node) {
data->vana = regulator_get_optional(dev, "vdd");
if (IS_ERR(data->vana)) {
vl53l0_dbgmsg("%d,vdd supply is not provided\n",
__LINE__);
vl53l0_errmsg("vdd supply is not provided\n");
ret = -1;
}
}
@ -103,33 +99,6 @@ int get_dt_xtalk_data(struct device_node *of_node, int *xtalk)
return rc;
}
int get_dt_threshold_data(struct device_node *of_node, int *lowv, int *highv)
{
int rc = 0;
uint32_t count = 0;
uint32_t v_array[2];
count = of_property_count_strings(of_node, "st,sensorthreshold");
if (!count)
return 0;
rc = of_property_read_u32_array(of_node, "st,sensorthreshold",
v_array, 2);
if (rc != -EINVAL) {
if (rc < 0) {
pr_err("%s failed %d\n", __func__, __LINE__);
} else {
*lowv = v_array[0];
*highv = v_array[1];
}
} else {
rc = 0;
}
return rc;
}
static int stmvl53l0_get_dt_gpio_req_tbl(struct device_node *of_node,
struct msm_camera_gpio_conf *gconf, uint16_t *gpio_array,
@ -375,8 +344,6 @@ static int stmvl53l0_get_dt_data(struct device *dev, struct i2c_data *data)
}
kfree(gpio_array);
}
rc = get_dt_threshold_data(of_node,
&(data->lowv), &(data->highv));
rc = get_dt_xtalk_data(of_node,
&(data->xtalk));
}
@ -384,32 +351,36 @@ static int stmvl53l0_get_dt_data(struct device *dev, struct i2c_data *data)
return rc;
}
static int stmvl53l0_probe(struct i2c_client *client,
const struct i2c_device_id *id)
const struct i2c_device_id *id)
{
int rc = 0, i = 0;
struct stmvl53l0_data *vl53l0_data = NULL;
struct i2c_data *i2c_object = NULL;
int present;
vl53l0_dbgmsg("Enter\n");
vl53l0_errmsg("Enter\n");
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) {
rc = -EIO;
return rc;
}
vl53l0_data = stmvl53l0_getobject();
vl53l0_data = kzalloc(sizeof(struct stmvl53l0_data), GFP_KERNEL);
if (!vl53l0_data) {
vl53l0_errmsg("%d,data NULL\n", __LINE__);
return -EINVAL;
rc = -ENOMEM;
return rc;
}
if (vl53l0_data) {
vl53l0_data->client_object =
kzalloc(sizeof(struct i2c_data), GFP_KERNEL);
i2c_object = (struct i2c_data *)vl53l0_data->client_object;
}
if (vl53l0_data)
i2c_object = &(vl53l0_data->i2c_client_object);
i2c_object->client = client;
/* setup bus type */
vl53l0_data->bus_type = I2C_BUS;
/* setup regulator */
stmvl53l0_parse_vdd(&i2c_object->client->dev, i2c_object);
@ -423,6 +394,10 @@ static int stmvl53l0_probe(struct i2c_client *client,
i2c_set_clientdata(client, vl53l0_data);
stmvl53l0_get_dt_data(&client->dev, i2c_object);
/* fill xtalk data */
vl53l0_data->xtalk= i2c_object->xtalk;
rc = stmvl53l0_power_up_i2c(i2c_object, &present);
if (rc) {
vl53l0_errmsg("%d,error rc %d\n", __LINE__, rc);
@ -454,29 +429,36 @@ static int stmvl53l0_probe(struct i2c_client *client,
stmvl53l0_power_down_i2c(i2c_object);
rc = stmvl53l0_setup(vl53l0_data, I2C_BUS);
/* setup other stuff */
rc = stmvl53l0_setup(vl53l0_data);
vl53l0_dbgmsg("End\n");
/* init default value */
i2c_object->power_up = 0;
vl53l0_errmsg("End\n");
return rc;
}
static int stmvl53l0_remove(struct i2c_client *client)
{
struct stmvl53l0_data *data = stmvl53l0_getobject();
struct stmvl53l0_data *data = i2c_get_clientdata(client);
vl53l0_dbgmsg("Enter\n");
/* Power down the device */
stmvl53l0_power_down_i2c((void *)data->client_object);
stmvl53l0_power_down_i2c(data->client_object);
stmvl53l0_cleanup(data);
kfree(data->client_object);
kfree(data);
vl53l0_dbgmsg("End\n");
return 0;
}
static const struct i2c_device_id stmvl53l0_id[] = {
{ STMVL53L0_DRV_NAME, 0 },
{ },
{STMVL53L0_DRV_NAME, 0},
{},
};
MODULE_DEVICE_TABLE(i2c, stmvl53l0_id);
static const struct of_device_id st_stmvl53l0_dt_match[] = {
@ -484,27 +466,14 @@ static const struct of_device_id st_stmvl53l0_dt_match[] = {
{ },
};
/*
int stmv153l0_resume(struct i2c_client *clt)
{
struct stmvl53l0_data *vl53l0_data = NULL;
vl53l0_dbgmsg("Enter\n");
vl53l0_data = stmvl53l0_getobject();
stmvl53l0_livechecking(vl53l0_data);
return 0;
}
*/
static struct i2c_driver stmvl53l0_driver = {
.driver = {
.name = STMVL53L0_DRV_NAME,
.owner = THIS_MODULE,
.name = STMVL53L0_DRV_NAME,
.owner = THIS_MODULE,
.of_match_table = st_stmvl53l0_dt_match,
},
.probe = stmvl53l0_probe,
.remove = stmvl53l0_remove,
/* .resume = stmv153l0_resume, */
.probe = stmvl53l0_probe,
.remove = stmvl53l0_remove,
.id_table = stmvl53l0_id,
};
@ -608,7 +577,7 @@ int stmvl53l0_init_i2c(void)
if (ret)
vl53l0_errmsg("%d erro ret:%d\n", __LINE__, ret);
vl53l0_dbgmsg("End with rc:%d\n", ret);
vl53l0_errmsg("End with rc:%d\n", ret);
return ret;
}
@ -620,4 +589,3 @@ void stmvl53l0_exit_i2c(void *i2c_object)
vl53l0_dbgmsg("End\n");
}

File diff suppressed because it is too large Load diff