mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 13:49:24 -04:00
lynkco: update TOF kernel version
Details: Update kernel version to 14.1.2 bare 6.6.11 Change-Id: Ic65d6e8b6848feaf1cf2b0449442ae99386b6b04 Signed-off-by: wangdp11 <wangdp11@motorola.com> Reviewed-on: https://gerrit.mot.com/2514456 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Wang Liu <liuwang2@lenovo.com> Reviewed-by: <liuzy55@motorola.com> Reviewed-by: Zhichao Chen <chenzc2@motorola.com> Reviewed-by: Zhenxin Xi <xizx@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
740dcf283c
commit
d4d13c7043
88 changed files with 63400 additions and 0 deletions
17
drivers/input/misc/vl53L1_14_1_2/Android.mk
Normal file
17
drivers/input/misc/vl53L1_14_1_2/Android.mk
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
DLKM_DIR := motorola/kernel/modules
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
ifeq ($(PRODUCT_USE_TOF_vl53l3),true)
|
||||
KERNEL_CFLAGS += CONFIG_INPUT_MISC_TOF_USE_VL53L3=y
|
||||
endif
|
||||
|
||||
ifeq ($(PRODUCT_USE_PMIC_WL2864C),true)
|
||||
KERNEL_CFLAGS += CONFIG_INPUT_MISC_PMIC_WL2864C=y
|
||||
endif
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := stmvl53l3.ko
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
|
||||
include $(DLKM_DIR)/AndroidKernelModule.mk
|
||||
|
||||
51
drivers/input/misc/vl53L1_14_1_2/Kbuild
Normal file
51
drivers/input/misc/vl53L1_14_1_2/Kbuild
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#
|
||||
# Kbuild for the vl53L1 drivers.
|
||||
#
|
||||
|
||||
EXTRA_CFLAGS += -Wall
|
||||
EXTRA_CFLAGS += -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/include
|
||||
EXTRA_CFLAGS += -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/drivers/input/misc/vl53L1_14_1_2/inc \
|
||||
-I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/drivers/input/misc/vl53L1_14_1_2/ipp \
|
||||
-I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/drivers/input/misc/vl53L1_14_1_2 \
|
||||
-I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/drivers/input/misc/vl53L1_14_1_2/protected/inc
|
||||
|
||||
# define this environment variable if you want to compile driver for an old
|
||||
# kernel
|
||||
ifdef OLD_NETLINK_API
|
||||
EXTRA_CFLAGS += -DOLD_NETLINK_API
|
||||
endif
|
||||
|
||||
ifdef VL53L1_LOG_ENABLE
|
||||
EXTRA_CFLAGS += -DVL53L1_LOG_ENABLE
|
||||
endif
|
||||
|
||||
obj-m += stmvl53l3.o
|
||||
stmvl53l3-objs := stmvl53l1_module.o stmvl53l1_module-i2c.o
|
||||
stmvl53l3-objs += vl53l1_platform_ipp.o
|
||||
stmvl53l3-objs += protected/src/vl53l1_hist_funcs.o
|
||||
stmvl53l3-objs += protected/src/vl53l1_xtalk.o
|
||||
stmvl53l3-objs += protected/src/vl53l1_hist_algos_gen3.o
|
||||
stmvl53l3-objs += protected/src/vl53l1_hist_core.o
|
||||
stmvl53l3-objs += protected/src/vl53l1_sigma_estimate.o
|
||||
stmvl53l3-objs += protected/src/vl53l1_dmax.o
|
||||
stmvl53l3-objs += protected/src/vl53l1_hist_algos_gen4.o
|
||||
stmvl53l3-objs += stmvl53l1_i2c.o stmvl53l1_log.o
|
||||
stmvl53l3-objs += src/vl53l1_api.o src/vl53l1_api_core.o
|
||||
stmvl53l3-objs += src/vl53l1_api_strings.o src/vl53l1_error_strings.o
|
||||
stmvl53l3-objs += src/vl53l1_core.o src/vl53l1_register_funcs.o
|
||||
stmvl53l3-objs += src/vl53l1_api_preset_modes.o
|
||||
stmvl53l3-objs += src/vl53l1_api_calibration.o
|
||||
stmvl53l3-objs += src/vl53l1_silicon_core.o
|
||||
stmvl53l3-objs += src/vl53l1_zone_presets.o src/vl53l1_nvm.o
|
||||
stmvl53l3-objs += src/vl53l1_api_debug.o src/vl53l1_core_support.o
|
||||
stmvl53l3-objs += src/vl53l1_wait.o
|
||||
stmvl53l3-objs += src/vl53l1_nvm_debug.o
|
||||
|
||||
ifneq ($(filter m y,$(CONFIG_INPUT_MISC_TOF_USE_VL53L3)),)
|
||||
EXTRA_CFLAGS += -DTOF_USE_VL53L3_EN
|
||||
endif
|
||||
|
||||
|
||||
ifneq ($(filter m y,$(CONFIG_INPUT_MISC_PMIC_WL2864C)),)
|
||||
EXTRA_CFLAGS += -DTOF_USE_PMIC_WL2864C
|
||||
endif
|
||||
14
drivers/input/misc/vl53L1_14_1_2/Makefile
Normal file
14
drivers/input/misc/vl53L1_14_1_2/Makefile
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
all: modules
|
||||
|
||||
modules:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(M) modules $(KBUILD_OPTIONS)
|
||||
|
||||
modules_install:
|
||||
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(M) modules_install
|
||||
|
||||
%:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(M) $@ $(KBUILD_OPTIONS)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.ko *.mod.c *.mod.o *~ .*.cmd Module.symvers
|
||||
rm -rf .tmp_versions
|
||||
1433
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_api.h
Normal file
1433
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_api.h
Normal file
File diff suppressed because it is too large
Load diff
137
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_api_calibration.h
Normal file
137
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_api_calibration.h
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_API_CALIBRATION_H_
|
||||
#define _VL53L1_API_CALIBRATION_H_
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_run_ref_spad_char(VL53L1_DEV Dev,
|
||||
VL53L1_Error * pcal_status);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_run_device_test(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DeviceTestMode device_test_mode);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_run_spad_rate_map(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DeviceTestMode device_test_mode,
|
||||
VL53L1_DeviceSscArray array_select,
|
||||
uint32_t ssc_config_timeout_us,
|
||||
VL53L1_spad_rate_data_t *pspad_rate_data);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_run_xtalk_extraction(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_Error *pcal_status);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_and_avg_xtalk_samples(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t num_of_samples,
|
||||
uint8_t measurement_mode,
|
||||
int16_t xtalk_filter_thresh_max_mm,
|
||||
int16_t xtalk_filter_thresh_min_mm,
|
||||
uint16_t xtalk_max_valid_rate_kcps,
|
||||
uint8_t xtalk_result_id,
|
||||
uint8_t xtalk_histo_id,
|
||||
VL53L1_xtalk_range_results_t *pxtalk_results,
|
||||
VL53L1_histogram_bin_data_t *psum_histo,
|
||||
VL53L1_histogram_bin_data_t *pavg_histo);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_run_offset_calibration(
|
||||
VL53L1_DEV Dev,
|
||||
int16_t cal_distance_mm,
|
||||
uint16_t cal_reflectance_pc,
|
||||
VL53L1_Error *pcal_status);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_run_phasecal_average(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t measurement_mode,
|
||||
uint8_t phasecal_result__vcsel_start,
|
||||
uint16_t phasecal_num_of_samples,
|
||||
VL53L1_range_results_t *prange_results,
|
||||
uint16_t *pphasecal_result__reference_phase,
|
||||
uint16_t *pzero_distance_phase);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_run_zone_calibration(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DevicePresetModes device_preset_mode,
|
||||
VL53L1_DeviceZonePreset zone_preset,
|
||||
VL53L1_zone_config_t *pzone_cfg,
|
||||
int16_t cal_distance_mm,
|
||||
uint16_t cal_reflectance_pc,
|
||||
VL53L1_Error *pcal_status);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_hist_xtalk_extract_data_init(
|
||||
VL53L1_hist_xtalk_extract_data_t *pxtalk_data);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_xtalk_extract_update(
|
||||
int16_t target_distance_mm,
|
||||
uint16_t target_width_oversize,
|
||||
VL53L1_histogram_bin_data_t *phist_bins,
|
||||
VL53L1_hist_xtalk_extract_data_t *pxtalk_data);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_xtalk_extract_fini(
|
||||
VL53L1_histogram_bin_data_t *phist_bins,
|
||||
VL53L1_hist_xtalk_extract_data_t *pxtalk_data,
|
||||
VL53L1_xtalk_calibration_results_t *pxtalk_cal,
|
||||
VL53L1_xtalk_histogram_shape_t *pxtalk_shape);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_run_hist_xtalk_extraction(
|
||||
VL53L1_DEV Dev,
|
||||
int16_t cal_distance_mm,
|
||||
VL53L1_Error *pcal_status);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
680
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_api_core.h
Normal file
680
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_api_core.h
Normal file
|
|
@ -0,0 +1,680 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_API_CORE_H_
|
||||
#define _VL53L1_API_CORE_H_
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_version(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_ll_version_t *pversion);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_device_firmware_version(
|
||||
VL53L1_DEV Dev,
|
||||
uint16_t *pfw_version);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_data_init(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t read_p2p_data);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_read_p2p_data(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_software_reset(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_part_to_part_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_calibration_data_t *pcal_data);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_part_to_part_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_calibration_data_t *pcal_data);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_tuning_debug_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_tuning_parameters_t *ptun_data);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_inter_measurement_period_ms(
|
||||
VL53L1_DEV Dev,
|
||||
uint32_t inter_measurement_period_ms);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_inter_measurement_period_ms(
|
||||
VL53L1_DEV Dev,
|
||||
uint32_t *pinter_measurement_period_ms);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_timeouts_us(
|
||||
VL53L1_DEV Dev,
|
||||
uint32_t phasecal_config_timeout_us,
|
||||
uint32_t mm_config_timeout_us,
|
||||
uint32_t range_config_timeout_us);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_timeouts_us(
|
||||
VL53L1_DEV Dev,
|
||||
uint32_t *pphasecal_config_timeout_us,
|
||||
uint32_t *pmm_config_timeout_us,
|
||||
uint32_t *prange_config_timeout_us);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_calibration_repeat_period(
|
||||
VL53L1_DEV Dev,
|
||||
uint16_t cal_config__repeat_period);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_calibration_repeat_period(
|
||||
VL53L1_DEV Dev,
|
||||
uint16_t *pcal_config__repeat_period);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_sequence_config_bit(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DeviceSequenceConfig bit_id,
|
||||
uint8_t value);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_sequence_config_bit(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DeviceSequenceConfig bit_id,
|
||||
uint8_t *pvalue);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_interrupt_polarity(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DeviceInterruptPolarity interrupt_polarity);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_interrupt_polarity(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DeviceInterruptPolarity *pinterrupt_polarity);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_refspadchar_config_struct(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_refspadchar_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_refspadchar_config_struct(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_refspadchar_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_range_ignore_threshold(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t range_ignore_thresh_mult,
|
||||
uint16_t range_ignore_threshold_mcps);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_range_ignore_threshold(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *prange_ignore_thresh_mult,
|
||||
uint16_t *prange_ignore_threshold_mcps_internal,
|
||||
uint16_t *prange_ignore_threshold_mcps_current);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_user_zone(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_user_zone_t *puser_zone);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_user_zone(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_user_zone_t *puser_zone);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_mode_mitigation_roi(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_user_zone_t *pmm_roi);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_zone_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_zone_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_preset_mode(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DevicePresetModes device_preset_mode,
|
||||
uint16_t dss_config__target_total_rate_mcps,
|
||||
uint32_t phasecal_config_timeout_us,
|
||||
uint32_t mm_config_timeout_us,
|
||||
uint32_t range_config_timeout_us,
|
||||
uint32_t inter_measurement_period_ms);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_preset_mode_timing_cfg(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DevicePresetModes device_preset_mode,
|
||||
uint16_t *pdss_config__target_total_rate_mcps,
|
||||
uint32_t *pphasecal_config_timeout_us,
|
||||
uint32_t *pmm_config_timeout_us,
|
||||
uint32_t *prange_config_timeout_us);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_zone_preset(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DeviceZonePreset zone_preset);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_enable_xtalk_compensation(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_disable_xtalk_compensation(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_get_xtalk_compensation_enable(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pcrosstalk_compensation_enable);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_init_and_start_range(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t measurement_mode,
|
||||
VL53L1_DeviceConfigLevel device_config_level);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_stop_range(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_measurement_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DeviceResultsLevel device_result_level);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_device_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DeviceResultsLevel device_result_level,
|
||||
VL53L1_range_results_t *prange_results);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_clear_interrupt_and_enable_next_range(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t measurement_mode);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_histogram_bin_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_histogram_bin_data_t *phist_data);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_copy_sys_and_core_results_to_range_results(
|
||||
int32_t gain_factor,
|
||||
VL53L1_system_results_t *psys,
|
||||
VL53L1_core_results_t *pcore,
|
||||
VL53L1_range_results_t *presults);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_zone_dss_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_zone_private_dyn_cfg_t *pzone_dyn_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_calc_ambient_dmax(
|
||||
VL53L1_DEV Dev,
|
||||
uint16_t target_reflectance,
|
||||
int16_t *pambient_dmax_mm);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_GPIO_interrupt_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_GPIO_Interrupt_Mode intr_mode_distance,
|
||||
VL53L1_GPIO_Interrupt_Mode intr_mode_rate,
|
||||
uint8_t intr_new_measure_ready,
|
||||
uint8_t intr_no_target,
|
||||
uint8_t intr_combined_mode,
|
||||
uint16_t thresh_distance_high,
|
||||
uint16_t thresh_distance_low,
|
||||
uint16_t thresh_rate_high,
|
||||
uint16_t thresh_rate_low
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_GPIO_interrupt_config_struct(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_GPIO_interrupt_config_t intconf);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_GPIO_interrupt_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_GPIO_interrupt_config_t *pintconf);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_dmax_mode(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DeviceDmaxMode dmax_mode);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_dmax_mode(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DeviceDmaxMode *pdmax_mode);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_dmax_calibration_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DeviceDmaxMode dmax_mode,
|
||||
uint8_t zone_id,
|
||||
VL53L1_dmax_calibration_data_t *pdmax_cal);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_hist_dmax_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_hist_gen3_dmax_config_t *pdmax_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_hist_dmax_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_hist_gen3_dmax_config_t *pdmax_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_offset_calibration_mode(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_OffsetCalibrationMode offset_cal_mode);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_offset_calibration_mode(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_OffsetCalibrationMode *poffset_cal_mode);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_offset_correction_mode(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_OffsetCalibrationMode offset_cor_mode);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_offset_correction_mode(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_OffsetCorrectionMode *poffset_cor_mode);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_zone_calibration_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_zone_calibration_results_t *pzone_cal);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_zone_calibration_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_zone_calibration_results_t *pzone_cal);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_lite_xtalk_margin_kcps(
|
||||
VL53L1_DEV Dev,
|
||||
int16_t *pxtalk_margin);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_lite_xtalk_margin_kcps(
|
||||
VL53L1_DEV Dev,
|
||||
int16_t xtalk_margin);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_histogram_xtalk_margin_kcps(
|
||||
VL53L1_DEV Dev,
|
||||
int16_t *pxtalk_margin);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_histogram_xtalk_margin_kcps(
|
||||
VL53L1_DEV Dev,
|
||||
int16_t xtalk_margin);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_histogram_phase_consistency(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pphase_consistency);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_histogram_phase_consistency(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t phase_consistency);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_histogram_event_consistency(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pevent_consistency);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_histogram_event_consistency(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t event_consistency);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_histogram_ambient_threshold_sigma(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pamb_thresh_sigma);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_histogram_ambient_threshold_sigma(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t amb_thresh_sigma);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_lite_min_count_rate(
|
||||
VL53L1_DEV Dev,
|
||||
uint16_t *plite_mincountrate);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_lite_min_count_rate(
|
||||
VL53L1_DEV Dev,
|
||||
uint16_t lite_mincountrate);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_lite_sigma_threshold(
|
||||
VL53L1_DEV Dev,
|
||||
uint16_t *plite_sigma);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_lite_sigma_threshold(
|
||||
VL53L1_DEV Dev,
|
||||
uint16_t lite_sigma);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_restore_xtalk_nvm_default(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_xtalk_detect_config(
|
||||
VL53L1_DEV Dev,
|
||||
int16_t *pmax_valid_range_mm,
|
||||
int16_t *pmin_valid_range_mm,
|
||||
uint16_t *pmax_valid_rate_kcps,
|
||||
uint16_t *pmax_sigma_mm);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_xtalk_detect_config(
|
||||
VL53L1_DEV Dev,
|
||||
int16_t max_valid_range_mm,
|
||||
int16_t min_valid_range_mm,
|
||||
uint16_t max_valid_rate_kcps,
|
||||
uint16_t max_sigma_mm);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_target_order_mode(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_HistTargetOrder *phist_target_order);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_target_order_mode(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_HistTargetOrder hist_target_order);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_dmax_reflectance_values(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_dmax_reflectance_array_t *pdmax_reflectances);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_dmax_reflectance_values(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_dmax_reflectance_array_t *pdmax_reflectances);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_vhv_config(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t vhv_init_en,
|
||||
uint8_t vhv_init_value);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_vhv_config(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pvhv_init_en,
|
||||
uint8_t *pvhv_init_value);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_vhv_loopbound(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t vhv_loopbound);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_vhv_loopbound(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pvhv_loopbound);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_tuning_parm(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_TuningParms tuning_parm_key,
|
||||
int32_t *ptuning_parm_value);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_tuning_parm(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_TuningParms tuning_parm_key,
|
||||
int32_t tuning_parm_value);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_dynamic_xtalk_correction_enable(
|
||||
VL53L1_DEV Dev
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_dynamic_xtalk_correction_disable(
|
||||
VL53L1_DEV Dev
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_dynamic_xtalk_correction_apply_enable(
|
||||
VL53L1_DEV Dev
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_dynamic_xtalk_correction_apply_disable(
|
||||
VL53L1_DEV Dev
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_dynamic_xtalk_correction_single_apply_enable(
|
||||
VL53L1_DEV Dev
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_dynamic_xtalk_correction_single_apply_disable(
|
||||
VL53L1_DEV Dev
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_dynamic_xtalk_correction_set_scalers(
|
||||
VL53L1_DEV Dev,
|
||||
int16_t x_scaler_in,
|
||||
int16_t y_scaler_in,
|
||||
uint8_t user_scaler_set_in
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_current_xtalk_settings(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_xtalk_calibration_results_t *pxtalk
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_current_xtalk_settings(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_xtalk_calibration_results_t *pxtalk
|
||||
);
|
||||
|
||||
VL53L1_Error VL53L1_load_patch(VL53L1_DEV Dev);
|
||||
|
||||
VL53L1_Error VL53L1_unload_patch(VL53L1_DEV Dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
341
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_api_debug.h
Normal file
341
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_api_debug.h
Normal file
|
|
@ -0,0 +1,341 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_API_DEBUG_H_
|
||||
#define _VL53L1_API_DEBUG_H_
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
#include "vl53l1_nvm_structs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_decode_calibration_data_buffer(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_calibration_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_nvm_debug_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_decoded_nvm_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_histogram_debug_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_histogram_bin_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_additional_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_additional_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_xtalk_debug_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_xtalk_debug_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_offset_debug_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_offset_debug_data_t *pdata);
|
||||
|
||||
#ifdef VL53L1_LOG_ENABLE
|
||||
|
||||
|
||||
|
||||
void VL53L1_signed_fixed_point_sprintf(
|
||||
int32_t fp_value,
|
||||
uint8_t frac_bits,
|
||||
uint16_t buf_size,
|
||||
char *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_static_nvm_managed(
|
||||
VL53L1_static_nvm_managed_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_customer_nvm_managed(
|
||||
VL53L1_customer_nvm_managed_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_nvm_copy_data(
|
||||
VL53L1_nvm_copy_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_histogram_bin_data(
|
||||
VL53L1_histogram_bin_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_xtalk_histogram_data(
|
||||
VL53L1_xtalk_histogram_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_xtalk_histogram_shape_data(
|
||||
VL53L1_xtalk_histogram_shape_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_range_results(
|
||||
VL53L1_range_results_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_range_data(
|
||||
VL53L1_range_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_offset_range_results(
|
||||
VL53L1_offset_range_results_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_offset_range_data(
|
||||
VL53L1_offset_range_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_cal_peak_rate_map(
|
||||
VL53L1_cal_peak_rate_map_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_additional_offset_cal_data(
|
||||
VL53L1_additional_offset_cal_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_additional_data(
|
||||
VL53L1_additional_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_gain_calibration_data(
|
||||
VL53L1_gain_calibration_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_zone_calibration_data(
|
||||
VL53L1_zone_calibration_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_zone_calibration_results(
|
||||
VL53L1_zone_calibration_results_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_xtalk_range_results(
|
||||
VL53L1_xtalk_range_results_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_xtalk_range_data(
|
||||
VL53L1_xtalk_range_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_xtalk_calibration_results(
|
||||
VL53L1_xtalk_calibration_results_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_xtalk_config(
|
||||
VL53L1_xtalk_config_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_xtalk_extract_config(
|
||||
VL53L1_xtalkextract_config_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_zone_cal_config(
|
||||
VL53L1_zonecal_config_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_offset_cal_config(
|
||||
VL53L1_offsetcal_config_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_dmax_calibration_data(
|
||||
VL53L1_dmax_calibration_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_calibration_data(
|
||||
VL53L1_calibration_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_xtalk_debug_data(
|
||||
VL53L1_xtalk_debug_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_offset_debug_data(
|
||||
VL53L1_offset_debug_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_optical_centre(
|
||||
VL53L1_optical_centre_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_user_zone(
|
||||
VL53L1_user_zone_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_zone_config(
|
||||
VL53L1_zone_config_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_spad_rate_data(
|
||||
VL53L1_spad_rate_data_t *pspad_rates,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_spad_rate_map(
|
||||
VL53L1_spad_rate_data_t *pspad_rates,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
595
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_api_preset_modes.h
Normal file
595
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_api_preset_modes.h
Normal file
|
|
@ -0,0 +1,595 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_API_PRESET_MODES_H_
|
||||
#define _VL53L1_API_PRESET_MODES_H_
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_dmax_structs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_init_refspadchar_config_struct(
|
||||
VL53L1_refspadchar_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_init_ssc_config_struct(
|
||||
VL53L1_ssc_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_init_xtalk_config_struct(
|
||||
VL53L1_customer_nvm_managed_t *pnvm,
|
||||
VL53L1_xtalk_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_init_xtalk_extract_config_struct(
|
||||
VL53L1_xtalkextract_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_init_offset_cal_config_struct(
|
||||
VL53L1_offsetcal_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_init_zone_cal_config_struct(
|
||||
VL53L1_zonecal_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_init_hist_post_process_config_struct(
|
||||
uint8_t xtalk_compensation_enable,
|
||||
VL53L1_hist_post_process_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_init_dmax_calibration_data_struct(
|
||||
VL53L1_dmax_calibration_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_init_tuning_parm_storage_struct(
|
||||
VL53L1_tuning_parm_storage_t *pdata);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_init_hist_gen3_dmax_config_struct(
|
||||
VL53L1_hist_gen3_dmax_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_standard_ranging(
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_standard_ranging_short_range(
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_standard_ranging_long_range(
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_standard_ranging_mm1_cal(
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_standard_ranging_mm2_cal(
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_timed_ranging(
|
||||
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_timed_ranging_short_range(
|
||||
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_timed_ranging_long_range(
|
||||
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_low_power_auto_ranging(
|
||||
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg,
|
||||
VL53L1_low_power_auto_data_t *plpadata);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_low_power_auto_short_ranging(
|
||||
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg,
|
||||
VL53L1_low_power_auto_data_t *plpadata);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_low_power_auto_long_ranging(
|
||||
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg,
|
||||
VL53L1_low_power_auto_data_t *plpadata);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_ranging(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_ranging_with_mm1(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_ranging_with_mm2(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_ranging_mm1_cal(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_ranging_mm2_cal(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_ranging_ref(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_characterisation(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_xtalk_planar(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_xtalk_mm1(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_xtalk_mm2(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_multizone(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_multizone_short_range(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_multizone_long_range(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_ranging_short_timing(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_long_range(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_medium_range(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_short_range(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_special_histogram_short_range(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_long_range_mm1(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_long_range_mm2(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_medium_range_mm1(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_medium_range_mm2(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_short_range_mm1(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_histogram_short_range_mm2(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_olt(
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_singleshot_ranging(
|
||||
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_copy_hist_cfg_to_static_cfg(
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic);
|
||||
|
||||
|
||||
|
||||
void VL53L1_copy_hist_bins_to_static_cfg(
|
||||
VL53L1_histogram_config_t *phistogram,
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_timing_config_t *ptiming);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
159
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_api_strings.h
Normal file
159
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_api_strings.h
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file vl53l1_api_strings.h
|
||||
* @brief VL53L1 API function declarations for decoding error codes to a
|
||||
* text strings
|
||||
*/
|
||||
|
||||
|
||||
#ifndef VL53L1_API_STRINGS_H_
|
||||
#define VL53L1_API_STRINGS_H_
|
||||
|
||||
#include "vl53l1_def.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Generates a string for the input device range status code
|
||||
*
|
||||
* @param[in] RangeStatus : Device Range AStatus Code
|
||||
* @param[out] pRangeStatusString : pointer to character buffer
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_get_range_status_string(
|
||||
uint8_t RangeStatus,
|
||||
char *pRangeStatusString);
|
||||
|
||||
/**
|
||||
* @brief Generates an error string for the input PAL error code
|
||||
*
|
||||
* @param[in] PalErrorCode : PAL Error Code
|
||||
* @param[out] pPalErrorString : pointer to character buffer
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_get_pal_error_string(
|
||||
VL53L1_Error PalErrorCode,
|
||||
char *pPalErrorString);
|
||||
|
||||
/**
|
||||
* @brief Generates a string for the input PAL State code
|
||||
*
|
||||
* @param[in] PalStateCode : PAL State Code
|
||||
* @param[out] pPalStateString : pointer to character buffer
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_get_pal_state_string(
|
||||
VL53L1_State PalStateCode,
|
||||
char *pPalStateString);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Generates a string for the sequence step Id
|
||||
*
|
||||
* @param[in] SequenceStepId : Sequence Step Id
|
||||
* @param[out] pSequenceStepsString : pointer to character buffer
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
VL53L1_Error VL53L1_get_sequence_steps_info(
|
||||
VL53L1_SequenceStepId SequenceStepId,
|
||||
char *pSequenceStepsString);
|
||||
|
||||
/**
|
||||
* @brief Generates a string for the limit check Id
|
||||
*
|
||||
* @param[in] LimitCheckId : Limit check Id
|
||||
* @param[out] pLimitCheckString : pointer to character buffer
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
VL53L1_Error VL53L1_get_limit_check_info(uint16_t LimitCheckId,
|
||||
char *pLimitCheckString);
|
||||
|
||||
#ifndef VL53L1_USE_EMPTY_STRING
|
||||
#define VL53L1_STRING_DEVICE_INFO_NAME0 "VL53L1 cut1.0"
|
||||
#define VL53L1_STRING_DEVICE_INFO_NAME1 "VL53L1 cut1.1"
|
||||
#define VL53L1_STRING_DEVICE_INFO_TYPE "VL53L1"
|
||||
|
||||
/* Range Status */
|
||||
#define VL53L1_STRING_RANGESTATUS_NONE "No Update"
|
||||
#define VL53L1_STRING_RANGESTATUS_RANGEVALID "Range Valid"
|
||||
#define VL53L1_STRING_RANGESTATUS_SIGMA "Sigma Fail"
|
||||
#define VL53L1_STRING_RANGESTATUS_SIGNAL "Signal Fail"
|
||||
#define VL53L1_STRING_RANGESTATUS_MINRANGE "Min Range Fail"
|
||||
#define VL53L1_STRING_RANGESTATUS_PHASE "Phase Fail"
|
||||
#define VL53L1_STRING_RANGESTATUS_HW "Hardware Fail"
|
||||
|
||||
|
||||
/* Range Status */
|
||||
#define VL53L1_STRING_STATE_POWERDOWN "POWERDOWN State"
|
||||
#define VL53L1_STRING_STATE_WAIT_STATICINIT \
|
||||
"Wait for staticinit State"
|
||||
#define VL53L1_STRING_STATE_STANDBY "STANDBY State"
|
||||
#define VL53L1_STRING_STATE_IDLE "IDLE State"
|
||||
#define VL53L1_STRING_STATE_RUNNING "RUNNING State"
|
||||
#define VL53L1_STRING_STATE_RESET "RESET State"
|
||||
#define VL53L1_STRING_STATE_UNKNOWN "UNKNOWN State"
|
||||
#define VL53L1_STRING_STATE_ERROR "ERROR State"
|
||||
|
||||
|
||||
|
||||
/* Check Enable */
|
||||
#define VL53L1_STRING_CHECKENABLE_SIGMA_FINAL_RANGE \
|
||||
"SIGMA FINAL RANGE"
|
||||
#define VL53L1_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE \
|
||||
"SIGNAL RATE FINAL RANGE"
|
||||
#define VL53L1_STRING_CHECKENABLE_SIGNAL_MIN_CLIP \
|
||||
"SIGNAL MIN CLIP"
|
||||
#define VL53L1_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD \
|
||||
"RANGE IGNORE THRESHOLD"
|
||||
#define VL53L1_STRING_CHECKENABLE_RANGE_PHASE_HIGH \
|
||||
"RANGE PHASE HIGH"
|
||||
#define VL53L1_STRING_CHECKENABLE_RANGE_PHASE_LOW \
|
||||
"RANGE PHASE LOW"
|
||||
#define VL53L1_STRING_CHECKENABLE_RANGE_PHASE_CONSISTENCY \
|
||||
"RANGE PHASE CONSISTENCY"
|
||||
|
||||
/* Sequence Step */
|
||||
#define VL53L1_STRING_SEQUENCESTEP_VHV "VHV"
|
||||
#define VL53L1_STRING_SEQUENCESTEP_PHASECAL "PHASE CAL"
|
||||
#define VL53L1_STRING_SEQUENCESTEP_REFPHASE "REF PHASE"
|
||||
#define VL53L1_STRING_SEQUENCESTEP_DSS1 "DSS1"
|
||||
#define VL53L1_STRING_SEQUENCESTEP_DSS2 "DSS2"
|
||||
#define VL53L1_STRING_SEQUENCESTEP_MM1 "MM1"
|
||||
#define VL53L1_STRING_SEQUENCESTEP_MM2 "MM2"
|
||||
#define VL53L1_STRING_SEQUENCESTEP_RANGE "RANGE"
|
||||
#endif /* VL53L1_USE_EMPTY_STRING */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
748
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_core.h
Normal file
748
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_core.h
Normal file
|
|
@ -0,0 +1,748 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_CORE_H_
|
||||
#define _VL53L1_CORE_H_
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
#include "vl53l1_core_support.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_init_version(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_init_ll_driver_state(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DeviceState ll_state);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_update_ll_driver_rd_state(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_check_ll_driver_rd_state(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_update_ll_driver_cfg_state(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_copy_rtn_good_spads_to_buffer(
|
||||
VL53L1_nvm_copy_data_t *pdata,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_init_system_results(
|
||||
VL53L1_system_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
void V53L1_init_zone_results_structure(
|
||||
uint8_t active_zones,
|
||||
VL53L1_zone_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
void V53L1_init_zone_dss_configs(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_init_histogram_config_structure(
|
||||
uint8_t even_bin0,
|
||||
uint8_t even_bin1,
|
||||
uint8_t even_bin2,
|
||||
uint8_t even_bin3,
|
||||
uint8_t even_bin4,
|
||||
uint8_t even_bin5,
|
||||
uint8_t odd_bin0,
|
||||
uint8_t odd_bin1,
|
||||
uint8_t odd_bin2,
|
||||
uint8_t odd_bin3,
|
||||
uint8_t odd_bin4,
|
||||
uint8_t odd_bin5,
|
||||
VL53L1_histogram_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
void VL53L1_init_histogram_multizone_config_structure(
|
||||
uint8_t even_bin0,
|
||||
uint8_t even_bin1,
|
||||
uint8_t even_bin2,
|
||||
uint8_t even_bin3,
|
||||
uint8_t even_bin4,
|
||||
uint8_t even_bin5,
|
||||
uint8_t odd_bin0,
|
||||
uint8_t odd_bin1,
|
||||
uint8_t odd_bin2,
|
||||
uint8_t odd_bin3,
|
||||
uint8_t odd_bin4,
|
||||
uint8_t odd_bin5,
|
||||
VL53L1_histogram_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_init_xtalk_bin_data_struct(
|
||||
uint32_t bin_value,
|
||||
uint16_t VL53L1_p_024,
|
||||
VL53L1_xtalk_histogram_shape_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_i2c_encode_uint16_t(
|
||||
uint16_t ip_value,
|
||||
uint16_t count,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
uint16_t VL53L1_i2c_decode_uint16_t(
|
||||
uint16_t count,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_i2c_encode_int16_t(
|
||||
int16_t ip_value,
|
||||
uint16_t count,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
int16_t VL53L1_i2c_decode_int16_t(
|
||||
uint16_t count,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_i2c_encode_uint32_t(
|
||||
uint32_t ip_value,
|
||||
uint16_t count,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_i2c_decode_uint32_t(
|
||||
uint16_t count,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_i2c_decode_with_mask(
|
||||
uint16_t count,
|
||||
uint8_t *pbuffer,
|
||||
uint32_t bit_mask,
|
||||
uint32_t down_shift,
|
||||
uint32_t offset);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_i2c_encode_int32_t(
|
||||
int32_t ip_value,
|
||||
uint16_t count,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
int32_t VL53L1_i2c_decode_int32_t(
|
||||
uint16_t count,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_start_test(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t test_mode__ctrl);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_firmware_enable_register(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t value);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_enable_firmware(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_disable_firmware(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_powerforce_register(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t value);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_enable_powerforce(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_disable_powerforce(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_clear_interrupt(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_force_shadow_stream_count_to_zero(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_calc_macro_period_us(
|
||||
uint16_t fast_osc_frequency,
|
||||
uint8_t VL53L1_p_009);
|
||||
|
||||
|
||||
|
||||
|
||||
uint16_t VL53L1_calc_range_ignore_threshold(
|
||||
uint32_t central_rate,
|
||||
int16_t x_gradient,
|
||||
int16_t y_gradient,
|
||||
uint8_t rate_mult);
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_calc_timeout_mclks(
|
||||
uint32_t timeout_us,
|
||||
uint32_t macro_period_us);
|
||||
|
||||
|
||||
|
||||
uint16_t VL53L1_calc_encoded_timeout(
|
||||
uint32_t timeout_us,
|
||||
uint32_t macro_period_us);
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_calc_timeout_us(
|
||||
uint32_t timeout_mclks,
|
||||
uint32_t macro_period_us);
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_calc_decoded_timeout_us(
|
||||
uint16_t timeout_encoded,
|
||||
uint32_t macro_period_us);
|
||||
|
||||
|
||||
|
||||
|
||||
uint16_t VL53L1_encode_timeout(
|
||||
uint32_t timeout_mclks);
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_decode_timeout(
|
||||
uint16_t encoded_timeout);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_calc_timeout_register_values(
|
||||
uint32_t phasecal_config_timeout_us,
|
||||
uint32_t mm_config_timeout_us,
|
||||
uint32_t range_config_timeout_us,
|
||||
uint16_t fast_osc_frequency,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming);
|
||||
|
||||
|
||||
|
||||
|
||||
uint8_t VL53L1_encode_vcsel_period(
|
||||
uint8_t VL53L1_p_031);
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_decode_unsigned_integer(
|
||||
uint8_t *pbuffer,
|
||||
uint8_t no_of_bytes);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_encode_unsigned_integer(
|
||||
uint32_t ip_value,
|
||||
uint8_t no_of_bytes,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_copy_and_scale_ambient_info(
|
||||
VL53L1_zone_hist_info_t *pidata,
|
||||
VL53L1_histogram_bin_data_t *podata);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_hist_get_bin_sequence_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_histogram_bin_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_phase_consistency_check(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_zone_hist_info_t *phist_prev,
|
||||
VL53L1_zone_objects_t *prange_prev,
|
||||
VL53L1_range_results_t *prange_curr);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_events_consistency_check(
|
||||
uint8_t event_sigma,
|
||||
uint16_t min_effective_spad_count,
|
||||
VL53L1_zone_hist_info_t *phist_prev,
|
||||
VL53L1_object_data_t *prange_prev,
|
||||
VL53L1_range_data_t *prange_curr,
|
||||
int32_t *pevents_tolerance,
|
||||
int32_t *pevents_delta,
|
||||
VL53L1_DeviceError *prange_status);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_merged_pulse_check(
|
||||
int16_t min_max_tolerance_mm,
|
||||
VL53L1_range_data_t *pdata,
|
||||
VL53L1_DeviceError *prange_status);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_xmonitor_consistency_check(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_zone_hist_info_t *phist_prev,
|
||||
VL53L1_zone_objects_t *prange_prev,
|
||||
VL53L1_range_data_t *prange_curr);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_wrap_dmax(
|
||||
VL53L1_hist_post_process_config_t *phistpostprocess,
|
||||
VL53L1_histogram_bin_data_t *pcurrent,
|
||||
int16_t *pwrap_dmax_mm);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_hist_combine_mm1_mm2_offsets(
|
||||
int16_t mm1_offset_mm,
|
||||
int16_t mm2_offset_mm,
|
||||
uint8_t encoded_mm_roi_centre,
|
||||
uint8_t encoded_mm_roi_size,
|
||||
uint8_t encoded_zone_centre,
|
||||
uint8_t encoded_zone_size,
|
||||
VL53L1_additional_offset_cal_data_t *pcal_data,
|
||||
uint8_t *pgood_spads,
|
||||
uint16_t aperture_attenuation,
|
||||
int16_t *prange_offset_mm);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_xtalk_extract_calc_window(
|
||||
int16_t target_distance_mm,
|
||||
uint16_t target_width_oversize,
|
||||
VL53L1_histogram_bin_data_t *phist_bins,
|
||||
VL53L1_hist_xtalk_extract_data_t *pxtalk_data);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_xtalk_extract_calc_event_sums(
|
||||
VL53L1_histogram_bin_data_t *phist_bins,
|
||||
VL53L1_hist_xtalk_extract_data_t *pxtalk_data);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_xtalk_extract_calc_rate_per_spad(
|
||||
VL53L1_hist_xtalk_extract_data_t *pxtalk_data);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_xtalk_extract_calc_shape(
|
||||
VL53L1_hist_xtalk_extract_data_t *pxtalk_data,
|
||||
VL53L1_xtalk_histogram_shape_t *pxtalk_shape);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_xtalk_shape_model(
|
||||
uint16_t events_per_bin,
|
||||
uint16_t pulse_centre,
|
||||
uint16_t pulse_width,
|
||||
VL53L1_xtalk_histogram_shape_t *pxtalk_shape);
|
||||
|
||||
|
||||
|
||||
|
||||
uint16_t VL53L1_hist_xtalk_shape_model_interp(
|
||||
uint16_t events_per_bin,
|
||||
uint32_t phase_delta);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_spad_number_to_byte_bit_index(
|
||||
uint8_t spad_number,
|
||||
uint8_t *pbyte_index,
|
||||
uint8_t *pbit_index,
|
||||
uint8_t *pbit_mask);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_encode_row_col(
|
||||
uint8_t row,
|
||||
uint8_t col,
|
||||
uint8_t *pspad_number);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_decode_zone_size(
|
||||
uint8_t encoded_xy_size,
|
||||
uint8_t *pwidth,
|
||||
uint8_t *pheight);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_encode_zone_size(
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
uint8_t *pencoded_xy_size);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_decode_zone_limits(
|
||||
uint8_t encoded_xy_centre,
|
||||
uint8_t encoded_xy_size,
|
||||
int16_t *px_ll,
|
||||
int16_t *py_ll,
|
||||
int16_t *px_ur,
|
||||
int16_t *py_ur);
|
||||
|
||||
|
||||
|
||||
|
||||
uint8_t VL53L1_is_aperture_location(
|
||||
uint8_t row,
|
||||
uint8_t col);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_calc_max_effective_spads(
|
||||
uint8_t encoded_zone_centre,
|
||||
uint8_t encoded_zone_size,
|
||||
uint8_t *pgood_spads,
|
||||
uint16_t aperture_attenuation,
|
||||
uint16_t *pmax_effective_spads);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_calc_mm_effective_spads(
|
||||
uint8_t encoded_mm_roi_centre,
|
||||
uint8_t encoded_mm_roi_size,
|
||||
uint8_t encoded_zone_centre,
|
||||
uint8_t encoded_zone_size,
|
||||
uint8_t *pgood_spads,
|
||||
uint16_t aperture_attenuation,
|
||||
uint16_t *pmm_inner_effective_spads,
|
||||
uint16_t *pmm_outer_effective_spads);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_hist_copy_results_to_sys_and_core(
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_range_results_t *phist,
|
||||
VL53L1_system_results_t *psys,
|
||||
VL53L1_core_results_t *pcore);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_sum_histogram_data(
|
||||
VL53L1_histogram_bin_data_t *phist_input,
|
||||
VL53L1_histogram_bin_data_t *phist_output);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_avg_histogram_data(
|
||||
uint8_t no_of_samples,
|
||||
VL53L1_histogram_bin_data_t *phist_sum,
|
||||
VL53L1_histogram_bin_data_t *phist_avg);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_save_cfg_data(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_dynamic_zone_update(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_range_results_t *presults);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_update_internal_stream_counters(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t external_stream_count,
|
||||
uint8_t *pinternal_stream_count,
|
||||
uint8_t *pinternal_stream_count_val
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_multizone_hist_bins_update(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_histogram_multizone_initial_bin_config(
|
||||
VL53L1_zone_config_t *pzone_cfg,
|
||||
VL53L1_histogram_config_t *phist_cfg,
|
||||
VL53L1_histogram_config_t *pmulti_hist
|
||||
);
|
||||
|
||||
|
||||
|
||||
uint8_t VL53L1_encode_GPIO_interrupt_config(
|
||||
VL53L1_GPIO_interrupt_config_t *pintconf);
|
||||
|
||||
|
||||
|
||||
VL53L1_GPIO_interrupt_config_t VL53L1_decode_GPIO_interrupt_config(
|
||||
uint8_t system__interrupt_config);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_GPIO_distance_threshold(
|
||||
VL53L1_DEV Dev,
|
||||
uint16_t threshold_high,
|
||||
uint16_t threshold_low);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_GPIO_rate_threshold(
|
||||
VL53L1_DEV Dev,
|
||||
uint16_t threshold_high,
|
||||
uint16_t threshold_low);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_GPIO_thresholds_from_struct(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_GPIO_interrupt_config_t *pintconf);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_ref_spad_char_config(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t vcsel_period_a,
|
||||
uint32_t phasecal_timeout_us,
|
||||
uint16_t total_rate_target_mcps,
|
||||
uint16_t max_count_rate_rtn_limit_mcps,
|
||||
uint16_t min_count_rate_rtn_limit_mcps,
|
||||
uint16_t fast_osc_frequency);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_ssc_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_ssc_config_t *pssc_cfg,
|
||||
uint16_t fast_osc_frequency);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_spad_rate_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_spad_rate_data_t *pspad_rates);
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_calc_crosstalk_plane_offset_with_margin(
|
||||
uint32_t plane_offset_kcps,
|
||||
int16_t margin_offset_kcps);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_low_power_auto_data_init(
|
||||
VL53L1_DEV Dev
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_low_power_auto_data_stop_range(
|
||||
VL53L1_DEV Dev
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_dynamic_xtalk_correction_calc_required_samples(
|
||||
VL53L1_DEV Dev
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_dynamic_xtalk_correction_calc_new_xtalk(
|
||||
VL53L1_DEV Dev,
|
||||
uint32_t xtalk_offset_out,
|
||||
VL53L1_smudge_corrector_config_t *pconfig,
|
||||
VL53L1_smudge_corrector_data_t *pout,
|
||||
uint8_t add_smudge,
|
||||
uint8_t soft_update
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_dynamic_xtalk_correction_corrector(
|
||||
VL53L1_DEV Dev
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_dynamic_xtalk_correction_data_init(
|
||||
VL53L1_DEV Dev
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_dynamic_xtalk_correction_output_init(
|
||||
VL53L1_LLDriverResults_t *pres
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_xtalk_cal_data_init(
|
||||
VL53L1_DEV Dev
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_config_low_power_auto_mode(
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_low_power_auto_data_t *plpadata
|
||||
);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_low_power_auto_setup_manual_calibration(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_low_power_auto_update_DSS(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_compute_histo_merge_nb(
|
||||
VL53L1_DEV Dev, uint8_t *histo_merge_nb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
152
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_core_support.h
Normal file
152
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_core_support.h
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_CORE_SUPPORT_H_
|
||||
#define _VL53L1_CORE_SUPPORT_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_hist_structs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_calc_pll_period_us(
|
||||
uint16_t fast_osc_frequency);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_duration_maths(
|
||||
uint32_t pll_period_us,
|
||||
uint32_t vcsel_parm_pclks,
|
||||
uint32_t window_vclks,
|
||||
uint32_t periods_elapsed_mclks);
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_events_per_spad_maths(
|
||||
int32_t VL53L1_p_013,
|
||||
uint16_t num_spads,
|
||||
uint32_t duration);
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_isqrt(
|
||||
uint32_t num);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_hist_calc_zero_distance_phase(
|
||||
VL53L1_histogram_bin_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_hist_estimate_ambient_from_thresholded_bins(
|
||||
int32_t ambient_threshold_sigma,
|
||||
VL53L1_histogram_bin_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_hist_remove_ambient_bins(
|
||||
VL53L1_histogram_bin_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_calc_pll_period_mm(
|
||||
uint16_t fast_osc_frequency);
|
||||
|
||||
|
||||
|
||||
|
||||
uint16_t VL53L1_rate_maths(
|
||||
int32_t VL53L1_p_008,
|
||||
uint32_t time_us);
|
||||
|
||||
|
||||
|
||||
|
||||
uint16_t VL53L1_rate_per_spad_maths(
|
||||
uint32_t frac_bits,
|
||||
uint32_t peak_count_rate,
|
||||
uint16_t num_spads,
|
||||
uint32_t max_output_value);
|
||||
|
||||
|
||||
|
||||
|
||||
int32_t VL53L1_range_maths(
|
||||
uint16_t fast_osc_frequency,
|
||||
uint16_t VL53L1_p_017,
|
||||
uint16_t zero_distance_phase,
|
||||
uint8_t fractional_bits,
|
||||
int32_t gain_factor,
|
||||
int32_t range_offset_mm);
|
||||
|
||||
|
||||
|
||||
|
||||
uint8_t VL53L1_decode_vcsel_period(
|
||||
uint8_t vcsel_period_reg);
|
||||
|
||||
|
||||
|
||||
void VL53L1_copy_xtalk_bin_data_to_histogram_data_struct(
|
||||
VL53L1_xtalk_histogram_shape_t *pxtalk,
|
||||
VL53L1_histogram_bin_data_t *phist);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_init_histogram_bin_data_struct(
|
||||
int32_t bin_value,
|
||||
uint16_t VL53L1_p_024,
|
||||
VL53L1_histogram_bin_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_decode_row_col(
|
||||
uint8_t spad_number,
|
||||
uint8_t *prow,
|
||||
uint8_t *pcol);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_hist_find_min_max_bin_values(
|
||||
VL53L1_histogram_bin_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_hist_estimate_ambient_from_ambient_bins(
|
||||
VL53L1_histogram_bin_data_t *pdata);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
802
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_def.h
Normal file
802
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_def.h
Normal file
|
|
@ -0,0 +1,802 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file vl53l1_def.h
|
||||
*
|
||||
* @brief Type definitions for VL53L1 API.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VL53L1_DEF_H_
|
||||
#define _VL53L1_DEF_H_
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @defgroup VL53L1_globaldefine_group VL53L1 Defines
|
||||
* @brief VL53L1 Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** VL53L1 IMPLEMENTATION major version */
|
||||
#define VL53L1_IMPLEMENTATION_VER_MAJOR 6
|
||||
/** VL53L1 IMPLEMENTATION minor version */
|
||||
#define VL53L1_IMPLEMENTATION_VER_MINOR 6
|
||||
/** VL53L1 IMPLEMENTATION sub version */
|
||||
#define VL53L1_IMPLEMENTATION_VER_SUB 11
|
||||
/** VL53L1 IMPLEMENTATION sub version */
|
||||
#define VL53L1_IMPLEMENTATION_VER_REVISION 2576
|
||||
|
||||
/****************************************
|
||||
* PRIVATE define do not edit
|
||||
****************************************/
|
||||
|
||||
/** @brief Defines the parameters of the Get Version Functions
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t revision; /*!< revision number */
|
||||
uint8_t major; /*!< major number */
|
||||
uint8_t minor; /*!< minor number */
|
||||
uint8_t build; /*!< build number */
|
||||
} VL53L1_Version_t;
|
||||
|
||||
|
||||
#define VL53L1_DEVINFO_STRLEN 32
|
||||
|
||||
/** @brief Defines the parameters of the Get Device Info Functions
|
||||
*/
|
||||
typedef struct {
|
||||
char Name[VL53L1_DEVINFO_STRLEN];
|
||||
/*!< Full Name of the Device e.g. VL53L1 cut1.1 */
|
||||
char Type[VL53L1_DEVINFO_STRLEN];
|
||||
/*!< Type of the Device e.g VL53L1 */
|
||||
char ProductId[VL53L1_DEVINFO_STRLEN];
|
||||
/*!< Product Identifier String
|
||||
* @warning Not yet implemented
|
||||
*/
|
||||
uint8_t ProductType;
|
||||
/*!< Product Type, VL53L1 = 0xCC, VL53L3 = 0xAA
|
||||
* Stands as module_type in the datasheet
|
||||
*/
|
||||
uint8_t ProductRevisionMajor;
|
||||
/*!< Product revision major */
|
||||
uint8_t ProductRevisionMinor;
|
||||
/*!< Product revision minor */
|
||||
} VL53L1_DeviceInfo_t;
|
||||
|
||||
|
||||
|
||||
/** @defgroup VL53L1_define_PresetModes_group Defines Preset modes
|
||||
* Defines all possible preset modes for the device
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_PresetModes;
|
||||
|
||||
#define VL53L1_PRESETMODE_RANGING ((VL53L1_PresetModes) 1)
|
||||
#define VL53L1_PRESETMODE_MULTIZONES_SCANNING ((VL53L1_PresetModes) 2)
|
||||
#define VL53L1_PRESETMODE_AUTONOMOUS ((VL53L1_PresetModes) 3)
|
||||
#define VL53L1_PRESETMODE_LITE_RANGING ((VL53L1_PresetModes) 4)
|
||||
#define VL53L1_PRESETMODE_OLT ((VL53L1_PresetModes) 7)
|
||||
#define VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS ((VL53L1_PresetModes) 8)
|
||||
#define VL53L1_PRESETMODE_PROXY_RANGING_MODE ((VL53L1_PresetModes) 9)
|
||||
|
||||
/* ... Modes to be added depending on device */
|
||||
/** @} VL53L1_define_PresetModes_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_define_DistanceModes_group Defines Distance modes
|
||||
* Defines all possible Distance modes for the device
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_DistanceModes;
|
||||
|
||||
#define VL53L1_DISTANCEMODE_SHORT ((VL53L1_DistanceModes) 1)
|
||||
#define VL53L1_DISTANCEMODE_MEDIUM ((VL53L1_DistanceModes) 2)
|
||||
#define VL53L1_DISTANCEMODE_LONG ((VL53L1_DistanceModes) 3)
|
||||
/** @} VL53L1_define_DistanceModes_group */
|
||||
|
||||
/** @defgroup VL53L1_define_OutputModes_group Defines Output modes
|
||||
* Defines all possible Output modes for the device
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_OutputModes;
|
||||
|
||||
#define VL53L1_OUTPUTMODE_NEAREST ((VL53L1_OutputModes) 1)
|
||||
#define VL53L1_OUTPUTMODE_STRONGEST ((VL53L1_OutputModes) 2)
|
||||
|
||||
/** @} VL53L1_define_OutputModes_group */
|
||||
|
||||
/** @defgroup VL53L1_define_XtalkCal_group Defines Xtalk Calibration modes
|
||||
* Defines all possible Offset Calibration modes for the device
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_XtalkCalibrationModes;
|
||||
|
||||
#define VL53L1_XTALKCALIBRATIONMODE_NO_TARGET \
|
||||
((VL53L1_OffsetCalibrationModes) 0)
|
||||
/*!< To perform Xtalk calibration with no target below 80 cm */
|
||||
#define VL53L1_XTALKCALIBRATIONMODE_SINGLE_TARGET \
|
||||
((VL53L1_OffsetCalibrationModes) 1)
|
||||
/*!< To perform Xtalk calibration with one target */
|
||||
#define VL53L1_XTALKCALIBRATIONMODE_FULL_ROI \
|
||||
((VL53L1_OffsetCalibrationModes) 2)
|
||||
/*!< To perform Xtalk calibration based on histogram with full ROI */
|
||||
|
||||
/** @} VL53L1_define_XtalkCal_group */
|
||||
|
||||
/** @defgroup VL53L1_define_OffsetCal_group Defines Offset Calibration modes
|
||||
* Defines all possible Offset Calibration modes for the device
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_OffsetCalibrationModes;
|
||||
|
||||
#define VL53L1_OFFSETCALIBRATIONMODE_STANDARD \
|
||||
((VL53L1_OffsetCalibrationModes) 1)
|
||||
#define VL53L1_OFFSETCALIBRATIONMODE_PRERANGE_ONLY \
|
||||
((VL53L1_OffsetCalibrationModes) 2)
|
||||
#define VL53L1_OFFSETCALIBRATIONMODE_MULTI_ZONE \
|
||||
((VL53L1_OffsetCalibrationModes) 3)
|
||||
|
||||
/** @} VL53L1_define_OffsetCal_group */
|
||||
|
||||
/** @defgroup VL53L1_define_DeviceDmaxModes_group Defines Dmax source modes
|
||||
* Defines all possible sources for Dmax calibration for the device
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_DeviceDmaxModes;
|
||||
|
||||
#define VL53L1_DMAXMODE_FMT_CAL_DATA ((VL53L1_DeviceDmaxModes) 1)
|
||||
#define VL53L1_DMAXMODE_CUSTCAL_DATA ((VL53L1_DeviceDmaxModes) 2)
|
||||
#define VL53L1_DMAXMODE_PER_ZONE_CAL_DATA ((VL53L1_DeviceDmaxModes) 3)
|
||||
|
||||
/** @} VL53L1_define_DeviceDmaxModes_group */
|
||||
|
||||
/** @defgroup VL53L1_define_OffsetCorrectionModesBD_group Defines offset Mode
|
||||
* @brief Defines all possible offset correction modes for the device
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_OffsetCorrectionModes;
|
||||
|
||||
#define VL53L1_OFFSETCORRECTIONMODE_STANDARD ((VL53L1_OffsetCorrectionMode) 1)
|
||||
#define VL53L1_OFFSETCORRECTIONMODE_PERZONE ((VL53L1_OffsetCorrectionMode) 2)
|
||||
#define VL53L1_OFFSETCORRECTIONMODE_PERVCSEL ((VL53L1_OffsetCorrectionMode) 3)
|
||||
|
||||
/** @} VL53L1_define_OffsetCorrectionModesBD_group */
|
||||
|
||||
/** @defgroup VL53L1_define_RoiStatus_group Defines Roi Status
|
||||
* Defines the read status mode
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_RoiStatus;
|
||||
|
||||
#define VL53L1_ROISTATUS_NOT_VALID ((VL53L1_RoiStatus) 0)
|
||||
#define VL53L1_ROISTATUS_VALID_NOT_LAST ((VL53L1_RoiStatus) 1)
|
||||
#define VL53L1_ROISTATUS_VALID_LAST ((VL53L1_RoiStatus) 2)
|
||||
/** @} VL53L1_define_RoiStatus_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_CheckEnable_group Check Enable list
|
||||
* @brief Check Enable code
|
||||
*
|
||||
* Define used to specify the LimitCheckId.
|
||||
* Use @a VL53L1_GetLimitCheckInfo() to get the string.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE 0
|
||||
#define VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE 1
|
||||
|
||||
#define VL53L1_CHECKENABLE_NUMBER_OF_CHECKS 2
|
||||
|
||||
/** @} end of VL53L1_CheckEnable_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_ThresholdMode_gropup Detection Functionality
|
||||
* @brief Defines the different functionalities for the detection feature
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_ThresholdMode;
|
||||
|
||||
#define VL53L1_THRESHOLD_CROSSED_LOW \
|
||||
((VL53L1_ThresholdMode) 0)
|
||||
/*!< Trigger interrupt if value < thresh_low */
|
||||
#define VL53L1_THRESHOLD_CROSSED_HIGH \
|
||||
((VL53L1_ThresholdMode) 1)
|
||||
/*!< Trigger interrupt if value > thresh_high */
|
||||
#define VL53L1_THRESHOLD_OUT_OF_WINDOW \
|
||||
((VL53L1_ThresholdMode) 2)
|
||||
/*!< Trigger interrupt if value < thresh_low OR value > thresh_high */
|
||||
#define VL53L1_THRESHOLD_IN_WINDOW \
|
||||
((VL53L1_ThresholdMode) 3)
|
||||
/*!< Trigger interrupt if value > thresh_low AND value < thresh_high */
|
||||
|
||||
/** @} end of VL53L1_ThresholdMode_gropup */
|
||||
|
||||
/** @brief Defines parameters for Distance detection Thresholds configuration
|
||||
*/
|
||||
typedef struct {
|
||||
VL53L1_ThresholdMode CrossMode;
|
||||
uint16_t High; /*!< Distance threshold high limit in mm */
|
||||
uint16_t Low; /*!< Distance threshold low limit in mm */
|
||||
} VL53L1_DistanceThreshold_t;
|
||||
|
||||
/** @brief Defines parameters for Signal rate detection Thresholds configuration
|
||||
*/
|
||||
typedef struct {
|
||||
VL53L1_ThresholdMode CrossMode;
|
||||
FixPoint1616_t High; /*!< Signal rate threshold high limit */
|
||||
FixPoint1616_t Low; /*!< Signal rate threshold low limit */
|
||||
} VL53L1_RateThreshold_t;
|
||||
|
||||
/** @defgroup VL53L1_DetectionMode_group Gpio Functionality
|
||||
* @brief Defines conditions leading to device's IT on GPIO
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_DetectionMode;
|
||||
|
||||
#define VL53L1_DETECTION_NORMAL_RUN \
|
||||
((VL53L1_DetectionMode) 0)
|
||||
/*!< Trigger interrupt on new measurement regardless of threshold
|
||||
* just like after a VL53L1_SetPresetMode() call
|
||||
*/
|
||||
#define VL53L1_DETECTION_DISTANCE_ONLY \
|
||||
((VL53L1_DetectionMode) 1)
|
||||
/*!< Trigger interrupt if "threshold event" occurs on distance */
|
||||
#define VL53L1_DETECTION_RATE_ONLY \
|
||||
((VL53L1_DetectionMode) 2)
|
||||
/*!< Trigger interrupt if "threshold event" occurs on signal rate */
|
||||
#define VL53L1_DETECTION_DISTANCE_AND_RATE \
|
||||
((VL53L1_DetectionMode) 3)
|
||||
/*!< Trigger interrupt if "threshold event" occurs on distance AND rate
|
||||
*/
|
||||
#define VL53L1_DETECTION_DISTANCE_OR_RATE \
|
||||
((VL53L1_DetectionMode) 4)
|
||||
/*!< Trigger interrupt if "threshold event" occurs on distance OR rate
|
||||
*/
|
||||
|
||||
/** @} end of VL53L1_DetectionMode_group */
|
||||
|
||||
/** @brief Defines parameters for User/object Detection configuration
|
||||
*/
|
||||
typedef struct {
|
||||
VL53L1_DetectionMode DetectionMode; /*!< See #VL53L1_DetectionMode*/
|
||||
uint8_t IntrNoTarget; /*!< 1 to trigger IT in case of no target found */
|
||||
VL53L1_DistanceThreshold_t Distance; /*!< limits in mm */
|
||||
VL53L1_RateThreshold_t Rate;/*!< limits in FixPoint1616_t */
|
||||
} VL53L1_DetectionConfig_t;
|
||||
|
||||
|
||||
/** @brief Defines all parameters for the device
|
||||
*/
|
||||
typedef struct {
|
||||
VL53L1_PresetModes PresetMode;
|
||||
/*!< Defines the operating mode to be used for the next measure */
|
||||
VL53L1_OutputModes OutputMode;
|
||||
/*!< Defines the Output mode to be used for the next measure */
|
||||
VL53L1_DistanceModes DistanceMode;
|
||||
/*!< Defines the operating mode to be used for the next measure */
|
||||
uint32_t MeasurementTimingBudgetMicroSeconds;
|
||||
/*!< Defines the allowed total time for a single measurement */
|
||||
uint8_t LimitChecksEnable[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
|
||||
/*!< This Array store all the Limit Check enable for this device. */
|
||||
uint8_t LimitChecksStatus[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
|
||||
/*!< This Array stores all the Status of the check linked to last
|
||||
* measurement.
|
||||
*/
|
||||
FixPoint1616_t LimitChecksValue[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
|
||||
/*!< This Array stores all the Limit Check value for this device */
|
||||
FixPoint1616_t LimitChecksCurrent[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
|
||||
/*!< This Array stores all the Limit Check current value from latest
|
||||
* ranging
|
||||
*/
|
||||
} VL53L1_DeviceParameters_t;
|
||||
|
||||
|
||||
/** @defgroup VL53L1_define_State_group Defines the current status of the device
|
||||
* Defines the current status of the device
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef uint8_t VL53L1_State;
|
||||
|
||||
#define VL53L1_STATE_POWERDOWN ((VL53L1_State) 0)
|
||||
/*!< Device is in HW reset */
|
||||
#define VL53L1_STATE_WAIT_STATICINIT ((VL53L1_State) 1)
|
||||
/*!< Device is initialized and wait for static initialization */
|
||||
#define VL53L1_STATE_STANDBY ((VL53L1_State) 2)
|
||||
/*!< Device is in Low power Standby mode */
|
||||
#define VL53L1_STATE_IDLE ((VL53L1_State) 3)
|
||||
/*!< Device has been initialized and ready to do measurements */
|
||||
#define VL53L1_STATE_RUNNING ((VL53L1_State) 4)
|
||||
/*!< Device is performing measurement */
|
||||
#define VL53L1_STATE_RESET ((VL53L1_State) 5)
|
||||
/*!< Soft reset has been run on Device */
|
||||
#define VL53L1_STATE_UNKNOWN ((VL53L1_State) 98)
|
||||
/*!< Device is in unknown state and need to be rebooted */
|
||||
#define VL53L1_STATE_ERROR ((VL53L1_State) 99)
|
||||
/*!< Device is in error state and need to be rebooted */
|
||||
|
||||
/** @} VL53L1_define_State_group */
|
||||
|
||||
/** @defgroup VL53L1_define_Smudge_Mode_group Defines smudge correction modes
|
||||
* Defines the smudge correction modes
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef uint8_t VL53L1_SmudgeCorrectionModes;
|
||||
|
||||
#define VL53L1_SMUDGE_CORRECTION_NONE ((VL53L1_SmudgeCorrectionModes) 0)
|
||||
/*!< Smudge correction is disabled */
|
||||
#define VL53L1_SMUDGE_CORRECTION_CONTINUOUS ((VL53L1_SmudgeCorrectionModes) 1)
|
||||
/*!< Smudge correction is applied continuously across the rangings */
|
||||
#define VL53L1_SMUDGE_CORRECTION_SINGLE ((VL53L1_SmudgeCorrectionModes) 2)
|
||||
/*!< Smudge correction is applied only once across the rangings */
|
||||
#define VL53L1_SMUDGE_CORRECTION_DEBUG ((VL53L1_SmudgeCorrectionModes) 3)
|
||||
/*!< Smudge detection is applied continuously but Xtalk values are not
|
||||
* updated automatically within the driver
|
||||
*/
|
||||
|
||||
/** @} VL53L1_define_Smudge_Correction_Mode_group */
|
||||
|
||||
|
||||
/**
|
||||
* @struct VL53L1_RangingMeasurementData_t
|
||||
* @brief Single Range measurement data.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t TimeStamp;
|
||||
/*!< 32-bit time stamp.
|
||||
* @warning Not yet implemented
|
||||
*/
|
||||
|
||||
uint8_t StreamCount;
|
||||
/*!< 8-bit Stream Count. */
|
||||
|
||||
uint8_t RangeQualityLevel;
|
||||
/*!< indicate a quality level in percentage from 0 to 100
|
||||
* @warning Not yet implemented
|
||||
*/
|
||||
|
||||
FixPoint1616_t SignalRateRtnMegaCps;
|
||||
/*!< Return signal rate (MCPS)\n these is a 16.16 fix point
|
||||
* value, which is effectively a measure of target
|
||||
* reflectance.
|
||||
*/
|
||||
|
||||
FixPoint1616_t AmbientRateRtnMegaCps;
|
||||
/*!< Return ambient rate (MCPS)\n these is a 16.16 fix point
|
||||
* value, which is effectively a measure of the ambient
|
||||
* light.
|
||||
*/
|
||||
|
||||
uint16_t EffectiveSpadRtnCount;
|
||||
/*!< Return the effective SPAD count for the return signal.
|
||||
* To obtain Real value it should be divided by 256
|
||||
*/
|
||||
|
||||
FixPoint1616_t SigmaMilliMeter;
|
||||
/*!< Return the Sigma value in millimeter */
|
||||
|
||||
int16_t RangeMilliMeter;
|
||||
/*!< range distance in millimeter. This should be between
|
||||
* RangeMinMilliMeter and RangeMaxMilliMeter
|
||||
*/
|
||||
|
||||
uint8_t RangeFractionalPart;
|
||||
/*!< Fractional part of range distance. Final value is a
|
||||
* RangeMilliMeter + RangeFractionalPart/256.
|
||||
* @warning Not yet implemented
|
||||
*/
|
||||
|
||||
uint8_t RangeStatus;
|
||||
/*!< Range Status for the current measurement. This is device
|
||||
* dependent. Value = 0 means value is valid.
|
||||
*/
|
||||
} VL53L1_RangingMeasurementData_t;
|
||||
|
||||
/**
|
||||
* @struct VL53L1_TargetRangeData_t
|
||||
* @brief One Range measurement data for each target.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t RangeQualityLevel;
|
||||
/*!< indicate a quality level in percentage from 0 to 100
|
||||
* @warning Not yet implemented
|
||||
*/
|
||||
|
||||
int16_t RangeMaxMilliMeter;
|
||||
/*!< Tells what is the maximum detection distance of the object
|
||||
* in current setup and environment conditions (Filled when
|
||||
* applicable)
|
||||
*/
|
||||
|
||||
int16_t RangeMinMilliMeter;
|
||||
/*!< Tells what is the minimum detection distance of the object
|
||||
* in current setup and environment conditions (Filled when
|
||||
* 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.
|
||||
*/
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
FixPoint1616_t SigmaMilliMeter;
|
||||
/*!< Return the Sigma value in millimeter */
|
||||
|
||||
int16_t RangeMilliMeter;
|
||||
/*!< range distance in millimeter. This should be between
|
||||
* RangeMinMilliMeter and RangeMaxMilliMeter
|
||||
*/
|
||||
|
||||
uint8_t RangeFractionalPart;
|
||||
/*!< Fractional part of range distance. Final value is a
|
||||
* RangeMilliMeter + RangeFractionalPart/256.
|
||||
* @warning Not yet implemented
|
||||
*/
|
||||
|
||||
uint8_t RangeStatus;
|
||||
/*!< Range Status for the current measurement. This is device
|
||||
* dependent. Value = 0 means value is valid.
|
||||
*/
|
||||
|
||||
uint8_t ExtendedRange;
|
||||
/*!< Extended range flag for the current measurement.
|
||||
* Value = 1 means timings A&B are combined to increase the
|
||||
* maximum distance range.
|
||||
*/
|
||||
} VL53L1_TargetRangeData_t;
|
||||
/**
|
||||
* @struct VL53L1_MultiRangingData_t
|
||||
* @brief Structure for storing the set of range results for a single ROI
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t TimeStamp;
|
||||
/*!< 32-bit time stamp.
|
||||
* @warning Not yet implemented
|
||||
*/
|
||||
|
||||
uint8_t StreamCount;
|
||||
/*!< 8-bit Stream Count. */
|
||||
|
||||
uint8_t RoiNumber;
|
||||
/*!< Denotes on which ROI the range data is related to. */
|
||||
uint8_t NumberOfObjectsFound;
|
||||
/*!< Indicate the number of objects found in the current ROI.
|
||||
* This is used to know how many ranging data should be get.
|
||||
* NumberOfObjectsFound is in the range 0 to
|
||||
* VL53L1_MAX_RANGE_RESULTS.
|
||||
*/
|
||||
VL53L1_RoiStatus RoiStatus;
|
||||
/*!< Indicate if the data read is valid or not or if this is
|
||||
* the last valid data in the ROI.
|
||||
*/
|
||||
VL53L1_TargetRangeData_t RangeData[VL53L1_MAX_RANGE_RESULTS];
|
||||
/*!< Range data each target distance */
|
||||
uint8_t HasXtalkValueChanged;
|
||||
/*!< set to 1 if a new Xtalk value has been computed whilst
|
||||
* smudge correction mode enable by with
|
||||
* VL53L1_SmudgeCorrectionEnable() function is either
|
||||
* VL53L1_SMUDGE_CORRECTION_CONTINUOUS or
|
||||
* VL53L1_SMUDGE_CORRECTION_SINGLE.
|
||||
*/
|
||||
uint16_t EffectiveSpadRtnCount;
|
||||
/*!< Return the effective SPAD count for the return signal.
|
||||
* To obtain Real value it should be divided by 256
|
||||
*/
|
||||
int16_t DmaxMilliMeter;
|
||||
/*!< range Dmax distance in millimeter.
|
||||
*/
|
||||
VL53L1_DistanceModes RecommendedDistanceMode;
|
||||
/*!< suggestion for a better distance mode choice to improve
|
||||
* range accuracy.
|
||||
*/
|
||||
} VL53L1_MultiRangingData_t;
|
||||
|
||||
|
||||
/** @brief Defines User Zone(ROI) parameters
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
uint8_t TopLeftX; /*!< Top Left x coordinate: 0-15 range */
|
||||
uint8_t TopLeftY; /*!< Top Left y coordinate: 0-15 range */
|
||||
uint8_t BotRightX; /*!< Bot Right x coordinate: 0-15 range */
|
||||
uint8_t BotRightY; /*!< Bot Right y coordinate: 0-15 range */
|
||||
|
||||
} VL53L1_UserRoi_t;
|
||||
|
||||
|
||||
/** @brief Defines ROI configuration parameters
|
||||
*
|
||||
* Support up a max of 16 zones, Each Zone has the same size
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
uint8_t NumberOfRoi; /*!< Number of Rois defined*/
|
||||
|
||||
VL53L1_UserRoi_t UserRois[VL53L1_MAX_USER_ZONES];
|
||||
/*!< List of Rois */
|
||||
|
||||
} VL53L1_RoiConfig_t;
|
||||
|
||||
/**
|
||||
* @struct VL53L1_CustomerNvmManaged_t
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
uint8_t global_config__spad_enables_ref_0;
|
||||
uint8_t global_config__spad_enables_ref_1;
|
||||
uint8_t global_config__spad_enables_ref_2;
|
||||
uint8_t global_config__spad_enables_ref_3;
|
||||
uint8_t global_config__spad_enables_ref_4;
|
||||
uint8_t global_config__spad_enables_ref_5;
|
||||
uint8_t global_config__ref_en_start_select;
|
||||
uint8_t ref_spad_man__num_requested_ref_spads;
|
||||
uint8_t ref_spad_man__ref_location;
|
||||
uint32_t algo__crosstalk_compensation_plane_offset_kcps;
|
||||
int16_t algo__crosstalk_compensation_x_plane_gradient_kcps;
|
||||
int16_t algo__crosstalk_compensation_y_plane_gradient_kcps;
|
||||
uint16_t ref_spad_char__total_rate_target_mcps;
|
||||
int16_t algo__part_to_part_range_offset_mm;
|
||||
int16_t mm_config__inner_offset_mm;
|
||||
int16_t mm_config__outer_offset_mm;
|
||||
} VL53L1_CustomerNvmManaged_t;
|
||||
|
||||
/**
|
||||
* @struct VL53L1_CalibrationData_t
|
||||
* @brief Structure for storing the Calibration Data
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint32_t struct_version;
|
||||
VL53L1_CustomerNvmManaged_t customer;
|
||||
VL53L1_dmax_calibration_data_t fmt_dmax_cal;
|
||||
VL53L1_dmax_calibration_data_t cust_dmax_cal;
|
||||
VL53L1_additional_offset_cal_data_t add_off_cal_data;
|
||||
VL53L1_optical_centre_t optical_centre;
|
||||
VL53L1_xtalk_histogram_data_t xtalkhisto;
|
||||
VL53L1_gain_calibration_data_t gain_cal;
|
||||
VL53L1_cal_peak_rate_map_t cal_peak_rate_map;
|
||||
VL53L1_per_vcsel_period_offset_cal_data_t per_vcsel_cal_data;
|
||||
uint32_t algo__xtalk_cpo_HistoMerge_kcps[VL53L1_BIN_REC_SIZE];
|
||||
} VL53L1_CalibrationData_t;
|
||||
|
||||
#define VL53L1_ADDITIONAL_CALIBRATION_DATA_STRUCT_VERSION 0x20
|
||||
/** VL53L1 additional Calibration Data struct version final struct version
|
||||
* is given by adding it to VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION
|
||||
*/
|
||||
|
||||
#define VL53L1_CALIBRATION_DATA_STRUCT_VERSION \
|
||||
(VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION + \
|
||||
VL53L1_ADDITIONAL_CALIBRATION_DATA_STRUCT_VERSION)
|
||||
/* VL53L1 Calibration Data struct version */
|
||||
|
||||
/**
|
||||
* @struct VL53L1_AdditionalData_t
|
||||
* @brief Structure for storing the Additional Data
|
||||
*
|
||||
*/
|
||||
typedef VL53L1_additional_data_t VL53L1_AdditionalData_t;
|
||||
|
||||
/**
|
||||
* @struct VL53L1_ZoneCalibrationData_t
|
||||
* @brief Structure for storing the Zone Calibration Data
|
||||
*
|
||||
*/
|
||||
typedef VL53L1_zone_calibration_results_t VL53L1_ZoneCalibrationData_t;
|
||||
|
||||
/** @defgroup VL53L1_define_SequenceStepId_group Defines the SequenceStep
|
||||
* Configure the sequence steps performed during ranging
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_SequenceStepId;
|
||||
|
||||
#define VL53L1_SEQUENCESTEP_VHV ((VL53L1_SequenceStepId) 0)
|
||||
/*!<VHV. */
|
||||
#define VL53L1_SEQUENCESTEP_PHASECAL ((VL53L1_SequenceStepId) 1)
|
||||
/*!<Phase Calibration. */
|
||||
#define VL53L1_SEQUENCESTEP_REFPHASE ((VL53L1_SequenceStepId) 2)
|
||||
/*!<Reference Phase. */
|
||||
#define VL53L1_SEQUENCESTEP_DSS1 ((VL53L1_SequenceStepId) 3)
|
||||
/*!<DSS1. */
|
||||
#define VL53L1_SEQUENCESTEP_DSS2 ((VL53L1_SequenceStepId) 4)
|
||||
/*!<DSS2. */
|
||||
#define VL53L1_SEQUENCESTEP_MM1 ((VL53L1_SequenceStepId) 5)
|
||||
/*!<Mode Mitigation 1. */
|
||||
#define VL53L1_SEQUENCESTEP_MM2 ((VL53L1_SequenceStepId) 6)
|
||||
/*!<Mode Mitigation 2. */
|
||||
#define VL53L1_SEQUENCESTEP_RANGE ((VL53L1_SequenceStepId) 7)
|
||||
/*!<Final Range step. */
|
||||
|
||||
#define VL53L1_SEQUENCESTEP_NUMBER_OF_ITEMS 8
|
||||
/*!<Number of Sequence Step Managed by the API. */
|
||||
|
||||
/** @} VL53L1_define_SequenceStepId_group */
|
||||
|
||||
/** @defgroup VL53L1_define_RangeStatus_group Defines the Range Status
|
||||
* @{
|
||||
*/
|
||||
#define VL53L1_RANGESTATUS_RANGE_VALID 0
|
||||
/*!<The Range is valid. */
|
||||
#define VL53L1_RANGESTATUS_SIGMA_FAIL 1
|
||||
/*!<Sigma Fail. */
|
||||
#define VL53L1_RANGESTATUS_SIGNAL_FAIL 2
|
||||
/*!<Signal fail. */
|
||||
#define VL53L1_RANGESTATUS_RANGE_VALID_MIN_RANGE_CLIPPED 3
|
||||
/*!<Target is below minimum detection threshold. */
|
||||
#define VL53L1_RANGESTATUS_OUTOFBOUNDS_FAIL 4
|
||||
/*!<Phase out of valid limits - different to a wrap exit. */
|
||||
#define VL53L1_RANGESTATUS_HARDWARE_FAIL 5
|
||||
/*!<Hardware fail. */
|
||||
#define VL53L1_RANGESTATUS_RANGE_VALID_NO_WRAP_CHECK_FAIL 6
|
||||
/*!<The Range is valid but the wraparound check has not been done. */
|
||||
#define VL53L1_RANGESTATUS_WRAP_TARGET_FAIL 7
|
||||
/*!<Wrapped target - no matching phase in other VCSEL period timing. */
|
||||
#define VL53L1_RANGESTATUS_PROCESSING_FAIL 8
|
||||
/*!<Internal algo underflow or overflow in lite ranging. */
|
||||
#define VL53L1_RANGESTATUS_XTALK_SIGNAL_FAIL 9
|
||||
/*!<Specific to lite ranging. */
|
||||
#define VL53L1_RANGESTATUS_SYNCRONISATION_INT 10
|
||||
/*!<1st interrupt when starting ranging in back to back mode. Ignore data. */
|
||||
#define VL53L1_RANGESTATUS_RANGE_VALID_MERGED_PULSE 11
|
||||
/*!<All Range ok but object is result of multiple pulses merging together.
|
||||
* Used by RQL for merged pulse detection
|
||||
*/
|
||||
#define VL53L1_RANGESTATUS_TARGET_PRESENT_LACK_OF_SIGNAL 12
|
||||
/*!<Used by RQL as different to phase fail. */
|
||||
#define VL53L1_RANGESTATUS_MIN_RANGE_FAIL 13
|
||||
/*!<User ROI input is not valid e.g. beyond SPAD Array.*/
|
||||
#define VL53L1_RANGESTATUS_RANGE_INVALID 14
|
||||
/*!<lld returned valid range but negative value ! */
|
||||
#define VL53L1_RANGESTATUS_NONE 255
|
||||
/*!<No Update. */
|
||||
|
||||
/** @} VL53L1_define_RangeStatus_group */
|
||||
|
||||
|
||||
/** @brief Contains the Internal data of the Bare Driver
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
VL53L1_LLDriverData_t LLData;
|
||||
/*!< Low Level Driver data structure */
|
||||
|
||||
VL53L1_LLDriverResults_t llresults;
|
||||
/*!< Low Level Driver data structure */
|
||||
|
||||
VL53L1_State PalState; /* Store the pal state */
|
||||
VL53L1_DeviceParameters_t CurrentParameters;
|
||||
/*!< Current Device Parameter */
|
||||
|
||||
} VL53L1_DevData_t;
|
||||
|
||||
|
||||
/* MACRO Definitions */
|
||||
/** @defgroup VL53L1_define_GeneralMacro_group General Macro Defines
|
||||
* General Macro Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Defines */
|
||||
#define VL53L1_SETPARAMETERFIELD(Dev, field, value) \
|
||||
(VL53L1DevDataSet(Dev, CurrentParameters.field, value))
|
||||
|
||||
#define VL53L1_GETPARAMETERFIELD(Dev, field, variable) \
|
||||
(variable = VL53L1DevDataGet(Dev, CurrentParameters).field)
|
||||
|
||||
|
||||
#define VL53L1_SETARRAYPARAMETERFIELD(Dev, field, index, value) \
|
||||
(VL53L1DevDataSet(Dev, CurrentParameters.field[index], value))
|
||||
|
||||
#define VL53L1_GETARRAYPARAMETERFIELD(Dev, field, index, variable) \
|
||||
(variable = VL53L1DevDataGet(Dev, CurrentParameters).field[index])
|
||||
|
||||
|
||||
#define VL53L1_SETDEVICESPECIFICPARAMETER(Dev, field, value) \
|
||||
(VL53L1DevDataSet(Dev, DeviceSpecificParameters.field, value))
|
||||
|
||||
#define VL53L1_GETDEVICESPECIFICPARAMETER(Dev, field) \
|
||||
(VL53L1DevDataGet(Dev, DeviceSpecificParameters).field)
|
||||
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT44(Value) \
|
||||
(uint16_t)((Value>>12)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT44TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<12)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT72(Value) \
|
||||
(uint16_t)((Value>>14)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT72TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<14)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT97(Value) \
|
||||
(uint16_t)((Value>>9)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT97TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<9)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT88(Value) \
|
||||
(uint16_t)((Value>>8)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT88TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<8)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT412(Value) \
|
||||
(uint16_t)((Value>>4)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT412TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<4)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT313(Value) \
|
||||
(uint16_t)((Value>>3)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT313TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<3)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT08(Value) \
|
||||
(uint8_t)((Value>>8)&0x00FF)
|
||||
#define VL53L1_FIXPOINT08TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<8)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT53(Value) \
|
||||
(uint8_t)((Value>>13)&0x00FF)
|
||||
#define VL53L1_FIXPOINT53TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<13)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT102(Value) \
|
||||
(uint16_t)((Value>>14)&0x0FFF)
|
||||
#define VL53L1_FIXPOINT102TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<14)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT142(Value) \
|
||||
(uint16_t)((Value>>14)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT142TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<14)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT160(Value) \
|
||||
(uint16_t)((Value>>16)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT160TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<16)
|
||||
|
||||
#define VL53L1_MAKEUINT16(lsb, msb) (uint16_t)((((uint16_t)msb)<<8) + \
|
||||
(uint16_t)lsb)
|
||||
|
||||
#ifndef SUPPRESS_UNUSED_WARNING
|
||||
#define SUPPRESS_UNUSED_WARNING(x) ((void) (x))
|
||||
#endif
|
||||
|
||||
/** @} VL53L1_define_GeneralMacro_group */
|
||||
|
||||
/** @} VL53L1_globaldefine_group */
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _VL53L1_DEF_H_ */
|
||||
92
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_dmax_structs.h
Normal file
92
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_dmax_structs.h
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_DMAX_STRUCTS_H_
|
||||
#define _VL53L1_DMAX_STRUCTS_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
#define VL53L1_MAX_AMBIENT_DMAX_VALUES 5
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
|
||||
|
||||
uint16_t ref__actual_effective_spads;
|
||||
|
||||
uint16_t ref__peak_signal_count_rate_mcps;
|
||||
|
||||
uint16_t ref__distance_mm;
|
||||
|
||||
uint16_t ref_reflectance_pc;
|
||||
|
||||
|
||||
|
||||
|
||||
uint16_t coverglass_transmission;
|
||||
|
||||
|
||||
} VL53L1_dmax_calibration_data_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
|
||||
|
||||
uint8_t signal_thresh_sigma;
|
||||
|
||||
uint8_t ambient_thresh_sigma;
|
||||
|
||||
int32_t min_ambient_thresh_events;
|
||||
|
||||
int32_t signal_total_events_limit;
|
||||
|
||||
|
||||
uint16_t target_reflectance_for_dmax_calc[
|
||||
VL53L1_MAX_AMBIENT_DMAX_VALUES];
|
||||
|
||||
uint16_t max_effective_spads;
|
||||
|
||||
|
||||
|
||||
|
||||
uint16_t dss_config__target_total_rate_mcps;
|
||||
|
||||
uint8_t dss_config__aperture_attenuation;
|
||||
|
||||
|
||||
} VL53L1_hist_gen3_dmax_config_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
223
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_error_codes.h
Normal file
223
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_error_codes.h
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file vl53l1_error_codes.h
|
||||
*
|
||||
* @brief Error Code definitions for VL53L1 API.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_ERROR_CODES_H_
|
||||
#define _VL53L1_ERROR_CODES_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************
|
||||
* PRIVATE define do not edit
|
||||
***************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup VL53L1_define_Error_group Error and Warning code returned by API
|
||||
* The following DEFINE are used to identify the TOF device ERROR
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef int8_t VL53L1_Error;
|
||||
|
||||
#define VL53L1_ERROR_NONE ((VL53L1_Error) 0)
|
||||
#define VL53L1_ERROR_CALIBRATION_WARNING ((VL53L1_Error) - 1)
|
||||
/*!< Warning invalid calibration data may be in used
|
||||
* \a VL53L1_InitData()
|
||||
* \a VL53L1_GetOffsetCalibrationData
|
||||
* \a VL53L1_SetOffsetCalibrationData
|
||||
*/
|
||||
#define VL53L1_ERROR_MIN_CLIPPED ((VL53L1_Error) - 2)
|
||||
/*!< Warning parameter passed was clipped to min before to be applied */
|
||||
|
||||
#define VL53L1_ERROR_UNDEFINED ((VL53L1_Error) - 3)
|
||||
/*!< Unqualified error */
|
||||
#define VL53L1_ERROR_INVALID_PARAMS ((VL53L1_Error) - 4)
|
||||
/*!< Parameter passed is invalid or out of range */
|
||||
#define VL53L1_ERROR_NOT_SUPPORTED ((VL53L1_Error) - 5)
|
||||
/*!< Function is not supported in current mode or configuration */
|
||||
#define VL53L1_ERROR_RANGE_ERROR ((VL53L1_Error) - 6)
|
||||
/*!< Device report a ranging error interrupt status */
|
||||
#define VL53L1_ERROR_TIME_OUT ((VL53L1_Error) - 7)
|
||||
/*!< Aborted due to time out */
|
||||
#define VL53L1_ERROR_MODE_NOT_SUPPORTED ((VL53L1_Error) - 8)
|
||||
/*!< Asked mode is not supported by the device */
|
||||
#define VL53L1_ERROR_BUFFER_TOO_SMALL ((VL53L1_Error) - 9)
|
||||
/*!< ... */
|
||||
#define VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL ((VL53L1_Error) - 10)
|
||||
/*!< Supplied buffer is larger than I2C supports */
|
||||
#define VL53L1_ERROR_GPIO_NOT_EXISTING ((VL53L1_Error) - 11)
|
||||
/*!< User tried to setup a non-existing GPIO pin */
|
||||
#define VL53L1_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED ((VL53L1_Error) - 12)
|
||||
/*!< unsupported GPIO functionality */
|
||||
#define VL53L1_ERROR_CONTROL_INTERFACE ((VL53L1_Error) - 13)
|
||||
/*!< error reported from IO functions */
|
||||
#define VL53L1_ERROR_INVALID_COMMAND ((VL53L1_Error) - 14)
|
||||
/*!< The command is not allowed in the current device state
|
||||
* (power down)
|
||||
*/
|
||||
#define VL53L1_ERROR_DIVISION_BY_ZERO ((VL53L1_Error) - 15)
|
||||
/*!< In the function a division by zero occurs */
|
||||
#define VL53L1_ERROR_REF_SPAD_INIT ((VL53L1_Error) - 16)
|
||||
/*!< Error during reference SPAD initialization */
|
||||
#define VL53L1_ERROR_GPH_SYNC_CHECK_FAIL ((VL53L1_Error) - 17)
|
||||
/*!< GPH sync interrupt check fail - API out of sync with device*/
|
||||
#define VL53L1_ERROR_STREAM_COUNT_CHECK_FAIL ((VL53L1_Error) - 18)
|
||||
/*!< Stream count check fail - API out of sync with device */
|
||||
#define VL53L1_ERROR_GPH_ID_CHECK_FAIL ((VL53L1_Error) - 19)
|
||||
/*!< GPH ID check fail - API out of sync with device */
|
||||
#define VL53L1_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL ((VL53L1_Error) - 20)
|
||||
/*!< Zone dynamic config stream count check failed - API out of sync */
|
||||
#define VL53L1_ERROR_ZONE_GPH_ID_CHECK_FAIL ((VL53L1_Error) - 21)
|
||||
/*!< Zone dynamic config GPH ID check failed - API out of sync */
|
||||
|
||||
#define VL53L1_ERROR_XTALK_EXTRACTION_NO_SAMPLE_FAIL ((VL53L1_Error) - 22)
|
||||
/*!< Thrown when run_xtalk_extraction fn has 0 successful samples
|
||||
* when using the full array to sample the xtalk. In this case there is
|
||||
* not enough information to generate new Xtalk parm info. The function
|
||||
* will exit and leave the current xtalk parameters unaltered
|
||||
*/
|
||||
#define VL53L1_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL ((VL53L1_Error) - 23)
|
||||
/*!< Thrown when run_xtalk_extraction fn has found that the
|
||||
* avg sigma estimate of the full array xtalk sample is > than the
|
||||
* maximal limit allowed. In this case the xtalk sample is too noisy for
|
||||
* measurement. The function will exit and leave the current xtalk
|
||||
* parameters unaltered.
|
||||
*/
|
||||
|
||||
|
||||
#define VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL ((VL53L1_Error) - 24)
|
||||
/*!< Thrown if there one of stages has no valid offset calibration
|
||||
* samples. A fatal error calibration not valid
|
||||
*/
|
||||
#define VL53L1_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL ((VL53L1_Error) - 25)
|
||||
/*!< Thrown if there one of stages has zero effective SPADS
|
||||
* Traps the case when MM1 SPADs is zero.
|
||||
* A fatal error calibration not valid
|
||||
*/
|
||||
#define VL53L1_ERROR_ZONE_CAL_NO_SAMPLE_FAIL ((VL53L1_Error) - 26)
|
||||
/*!< Thrown if then some of the zones have no valid samples
|
||||
* A fatal error calibration not valid
|
||||
*/
|
||||
|
||||
#define VL53L1_ERROR_TUNING_PARM_KEY_MISMATCH ((VL53L1_Error) - 27)
|
||||
/*!< Thrown if the tuning file key table version does not match with
|
||||
* expected value. The driver expects the key table version to match
|
||||
* the compiled default version number in the define
|
||||
* VL53L1_TUNINGPARM_KEY_TABLE_VERSION_DEFAULT
|
||||
*/
|
||||
|
||||
#define VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS ((VL53L1_Error) - 28)
|
||||
/*!< Thrown if there are less than 5 good SPADs are available. */
|
||||
#define VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH ((VL53L1_Error) - 29)
|
||||
/*!< Thrown if the final reference rate is greater than
|
||||
* the upper reference rate limit - default is 40 Mcps.
|
||||
* Implies a minimum Q3 (x10) SPAD (5) selected
|
||||
*/
|
||||
#define VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW ((VL53L1_Error) - 30)
|
||||
/*!< Thrown if the final reference rate is less than
|
||||
* the lower reference rate limit - default is 10 Mcps.
|
||||
* Implies maximum Q1 (x1) SPADs selected
|
||||
*/
|
||||
|
||||
|
||||
#define VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES ((VL53L1_Error) - 31)
|
||||
/*!< Thrown if there is less than the requested number of
|
||||
* valid samples.
|
||||
*/
|
||||
#define VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH ((VL53L1_Error) - 32)
|
||||
/*!< Thrown if the offset calibration range sigma estimate is greater
|
||||
* than 8.0 mm. This is the recommended min value to yield a stable
|
||||
* offset measurement
|
||||
*/
|
||||
#define VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH ((VL53L1_Error) - 33)
|
||||
/*!< Thrown when VL53L1_run_offset_calibration() peak rate is greater
|
||||
* than that 50.0Mcps. This is the recommended max rate to avoid
|
||||
* pile-up influencing the offset measurement
|
||||
*/
|
||||
#define VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW ((VL53L1_Error) - 34)
|
||||
/*!< Thrown when VL53L1_run_offset_calibration() when one of stages
|
||||
* range has less that 5.0 effective SPADS. This is the recommended
|
||||
* min value to yield a stable offset
|
||||
*/
|
||||
|
||||
|
||||
#define VL53L1_WARNING_ZONE_CAL_MISSING_SAMPLES ((VL53L1_Error) - 35)
|
||||
/*!< Thrown if one of more of the zones have less than
|
||||
* the requested number of valid samples
|
||||
*/
|
||||
#define VL53L1_WARNING_ZONE_CAL_SIGMA_TOO_HIGH ((VL53L1_Error) - 36)
|
||||
/*!< Thrown if one or more zones have sigma estimate value greater
|
||||
* than 8.0 mm. This is the recommended min value to yield a stable
|
||||
* offset measurement
|
||||
*/
|
||||
#define VL53L1_WARNING_ZONE_CAL_RATE_TOO_HIGH ((VL53L1_Error) - 37)
|
||||
/*!< Thrown if one of more zones have peak rate higher than
|
||||
* that 50.0Mcps. This is the recommended max rate to avoid
|
||||
* pile-up influencing the offset measurement
|
||||
*/
|
||||
|
||||
|
||||
#define VL53L1_WARNING_XTALK_MISSING_SAMPLES ((VL53L1_Error) - 38)
|
||||
/*!< Thrown to notify that some of the xtalk samples did not yield
|
||||
* valid ranging pulse data while attempting to measure
|
||||
* the xtalk signal in vl53l1_run_xtalk_extract(). This can signify any
|
||||
* of the zones are missing samples, for further debug information the
|
||||
* xtalk_results struct should be referred to. This warning is for
|
||||
* notification only, xtalk pulse and shape have still been generated
|
||||
*/
|
||||
#define VL53L1_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT ((VL53L1_Error) - 39)
|
||||
/*!< Thrown to notify that some of the xtalk samples used for gradient
|
||||
* generation did not yield valid ranging pulse data while attempting to
|
||||
* measure the xtalk signal in vl53l1_run_xtalk_extract(). This can
|
||||
* signify that any one of the zones 0-3 yielded no successful samples.
|
||||
* xtalk_results struct should be referred to for further debug info.
|
||||
* This warning is for notification only, the xtalk pulse and shape
|
||||
* have still been generated.
|
||||
*/
|
||||
#define VL53L1_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT ((VL53L1_Error) - 40)
|
||||
/*!< Thrown to notify that some of the xtalk samples used for gradient
|
||||
* generation did not pass the sigma limit check while attempting to
|
||||
* measure the xtalk signal in vl53l1_run_xtalk_extract(). This can
|
||||
* signify that any one of the zones 0-3 yielded an avg sigma_mm
|
||||
* value > the limit. The xtalk_results struct should be referred to for
|
||||
* further debug info.
|
||||
* This warning is for notification only, the xtalk pulse and shape
|
||||
* have still been generated.
|
||||
*/
|
||||
|
||||
#define VL53L1_ERROR_NOT_IMPLEMENTED ((VL53L1_Error) - 41)
|
||||
/*!< Tells requested functionality has not been implemented yet or
|
||||
* not compatible with the device
|
||||
*/
|
||||
#define VL53L1_ERROR_PLATFORM_SPECIFIC_START ((VL53L1_Error) - 60)
|
||||
/*!< Tells the starting code for platform */
|
||||
/** @} VL53L1_define_Error_group */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _VL53L1_ERROR_CODES_H_ */
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_ERROR_EXCEPTIONS_H_
|
||||
#define _VL53L1_ERROR_EXCEPTIONS_H_
|
||||
|
||||
#define IGNORE_DIVISION_BY_ZERO 0
|
||||
|
||||
#define IGNORE_XTALK_EXTRACTION_NO_SAMPLE_FAIL 0
|
||||
#define IGNORE_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL 0
|
||||
#define IGNORE_XTALK_EXTRACTION_NO_SAMPLE_FOR_GRADIENT_WARN 0
|
||||
#define IGNORE_XTALK_EXTRACTION_SIGMA_LIMIT_FOR_GRADIENT_WARN 0
|
||||
#define IGNORE_XTALK_EXTRACTION_MISSING_SAMPLES_WARN 0
|
||||
|
||||
#define IGNORE_REF_SPAD_CHAR_NOT_ENOUGH_SPADS 0
|
||||
#define IGNORE_REF_SPAD_CHAR_RATE_TOO_HIGH 0
|
||||
#define IGNORE_REF_SPAD_CHAR_RATE_TOO_LOW 0
|
||||
|
||||
#define IGNORE_OFFSET_CAL_MISSING_SAMPLES 0
|
||||
#define IGNORE_OFFSET_CAL_SIGMA_TOO_HIGH 0
|
||||
#define IGNORE_OFFSET_CAL_RATE_TOO_HIGH 0
|
||||
#define IGNORE_OFFSET_CAL_SPAD_COUNT_TOO_LOW 0
|
||||
|
||||
#define IGNORE_ZONE_CAL_MISSING_SAMPLES 0
|
||||
#define IGNORE_ZONE_CAL_SIGMA_TOO_HIGH 0
|
||||
#define IGNORE_ZONE_CAL_RATE_TOO_HIGH 0
|
||||
|
||||
#endif
|
||||
|
||||
148
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_error_strings.h
Normal file
148
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_error_strings.h
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef VL53L1_ERROR_STRINGS_H_
|
||||
#define VL53L1_ERROR_STRINGS_H_
|
||||
|
||||
#include "vl53l1_error_codes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_pal_error_string(
|
||||
VL53L1_Error PalErrorCode,
|
||||
char *pPalErrorString);
|
||||
|
||||
|
||||
#ifndef VL53L1_USE_EMPTY_STRING
|
||||
|
||||
|
||||
#define VL53L1_STRING_ERROR_NONE \
|
||||
"No Error"
|
||||
#define VL53L1_STRING_ERROR_CALIBRATION_WARNING \
|
||||
"Calibration Warning Error"
|
||||
#define VL53L1_STRING_ERROR_MIN_CLIPPED \
|
||||
"Min clipped error"
|
||||
#define VL53L1_STRING_ERROR_UNDEFINED \
|
||||
"Undefined error"
|
||||
#define VL53L1_STRING_ERROR_INVALID_PARAMS \
|
||||
"Invalid parameters error"
|
||||
#define VL53L1_STRING_ERROR_NOT_SUPPORTED \
|
||||
"Not supported error"
|
||||
#define VL53L1_STRING_ERROR_RANGE_ERROR \
|
||||
"Range error"
|
||||
#define VL53L1_STRING_ERROR_TIME_OUT \
|
||||
"Time out error"
|
||||
#define VL53L1_STRING_ERROR_MODE_NOT_SUPPORTED \
|
||||
"Mode not supported error"
|
||||
#define VL53L1_STRING_ERROR_BUFFER_TOO_SMALL \
|
||||
"Buffer too small"
|
||||
#define VL53L1_STRING_ERROR_COMMS_BUFFER_TOO_SMALL \
|
||||
"Comms Buffer too small"
|
||||
#define VL53L1_STRING_ERROR_GPIO_NOT_EXISTING \
|
||||
"GPIO not existing"
|
||||
#define VL53L1_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED \
|
||||
"GPIO funct not supported"
|
||||
#define VL53L1_STRING_ERROR_CONTROL_INTERFACE \
|
||||
"Control Interface Error"
|
||||
#define VL53L1_STRING_ERROR_INVALID_COMMAND \
|
||||
"Invalid Command Error"
|
||||
#define VL53L1_STRING_ERROR_DIVISION_BY_ZERO \
|
||||
"Division by zero Error"
|
||||
#define VL53L1_STRING_ERROR_REF_SPAD_INIT \
|
||||
"Reference Spad Init Error"
|
||||
#define VL53L1_STRING_ERROR_GPH_SYNC_CHECK_FAIL \
|
||||
"GPH Sync Check Fail - API out of sync"
|
||||
#define VL53L1_STRING_ERROR_STREAM_COUNT_CHECK_FAIL \
|
||||
"Stream Count Check Fail - API out of sync"
|
||||
#define VL53L1_STRING_ERROR_GPH_ID_CHECK_FAIL \
|
||||
"GPH ID Check Fail - API out of sync"
|
||||
#define VL53L1_STRING_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL \
|
||||
"Zone Stream Count Check Fail - API out of sync"
|
||||
#define VL53L1_STRING_ERROR_ZONE_GPH_ID_CHECK_FAIL \
|
||||
"Zone GPH ID Check Fail - API out of sync"
|
||||
|
||||
#define VL53L1_STRING_ERROR_XTALK_EXTRACTION_NO_SAMPLES_FAIL \
|
||||
"No Xtalk using full array - Xtalk Extract Fail"
|
||||
#define VL53L1_STRING_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL \
|
||||
"Xtalk does not meet required VL53L1_p_011 limit - Xtalk Extract Fail"
|
||||
|
||||
#define VL53L1_STRING_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL \
|
||||
"Offset Cal - one of more stages with no valid samples - fatal"
|
||||
#define VL53L1_STRING_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL \
|
||||
"Offset Cal - one of more stages with no SPADS enables - fatal"
|
||||
#define VL53L1_STRING_ERROR_ZONE_CAL_NO_SAMPLE_FAIL \
|
||||
"Zone Cal - one of more zones with no valid samples - fatal"
|
||||
|
||||
#define VL53L1_STRING_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS \
|
||||
"Ref SPAD Char - Not Enough Good SPADs"
|
||||
#define VL53L1_STRING_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH \
|
||||
"Ref SPAD Char - Final Ref Rate too high"
|
||||
#define VL53L1_STRING_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW \
|
||||
"Ref SPAD Char - Final Ref Rate too low"
|
||||
|
||||
#define VL53L1_STRING_WARNING_OFFSET_CAL_MISSING_SAMPLES \
|
||||
"Offset Cal - Less than the requested number of valid samples"
|
||||
#define VL53L1_STRING_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH \
|
||||
"Offset Cal - Sigma estimate value too high - offset not stable"
|
||||
#define VL53L1_STRING_WARNING_OFFSET_CAL_RATE_TOO_HIGH \
|
||||
"Offset Cal - Rate too high - in pile up"
|
||||
#define VL53L1_STRING_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW \
|
||||
"Offset Cal - Insufficient SPADs - offset may not be stable"
|
||||
|
||||
#define VL53L1_STRING_WARNING_ZONE_CAL_MISSING_SAMPLES \
|
||||
"Zone Cal - One or more zone with less than requested valid samples"
|
||||
#define VL53L1_STRING_WARNING_ZONE_CAL_SIGMA_TOO_HIGH \
|
||||
"Zone Cal - One of more zones the VL53L1_p_011 estimate too high"
|
||||
#define VL53L1_STRING_WARNING_ZONE_CAL_RATE_TOO_HIGH \
|
||||
"Zone Cal - One of more zones with rate too high - in pile up"
|
||||
|
||||
#define VL53L1_STRING_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT \
|
||||
"Xtalk - Gradient sample num = 0"
|
||||
#define VL53L1_STRING_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT \
|
||||
"Xtalk - Gradient Sigma > Limit"
|
||||
#define VL53L1_STRING_WARNING_XTALK_MISSING_SAMPLES \
|
||||
"Xtalk - Some missing and invalid samples"
|
||||
|
||||
#define VL53L1_STRING_ERROR_DEVICE_FIRMWARE_TOO_OLD \
|
||||
"Device Firmware too old"
|
||||
#define VL53L1_STRING_ERROR_DEVICE_FIRMWARE_TOO_NEW \
|
||||
"Device Firmware too new"
|
||||
#define VL53L1_STRING_ERROR_UNIT_TEST_FAIL \
|
||||
"Unit Test Fail"
|
||||
#define VL53L1_STRING_ERROR_FILE_READ_FAIL \
|
||||
"File Read Fail"
|
||||
#define VL53L1_STRING_ERROR_FILE_WRITE_FAIL \
|
||||
"File Write Fail"
|
||||
|
||||
#define VL53L1_STRING_ERROR_NOT_IMPLEMENTED \
|
||||
"Not implemented error"
|
||||
#define VL53L1_STRING_UNKNOW_ERROR_CODE \
|
||||
"Unknown Error Code"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
57
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_hist_char.h
Normal file
57
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_hist_char.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_HIST_CHAR_H_
|
||||
#define _VL53L1_HIST_CHAR_H_
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_calib_config(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t vcsel_delay__a0,
|
||||
uint8_t calib_1,
|
||||
uint8_t calib_2,
|
||||
uint8_t calib_3,
|
||||
uint8_t calib_2__a0,
|
||||
uint8_t spad_readout);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_hist_calib_pulse_delay(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t calib_delay);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_disable_calib_pulse_delay(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
68
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_hist_map.h
Normal file
68
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_hist_map.h
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_HIST_MAP_H_
|
||||
#define _VL53L1_HIST_MAP_H_
|
||||
|
||||
#include "vl53l1_register_map.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_HISTOGRAM_CONFIG__OPCODE_SEQUENCE_0 \
|
||||
VL53L1_SIGMA_ESTIMATOR__EFFECTIVE_PULSE_WIDTH_NS
|
||||
|
||||
#define VL53L1_HISTOGRAM_CONFIG__OPCODE_SEQUENCE_1 \
|
||||
VL53L1_SIGMA_ESTIMATOR__EFFECTIVE_AMBIENT_WIDTH_NS
|
||||
|
||||
#define VL53L1_HISTOGRAM_CONFIG__OPCODE_SEQUENCE_2 \
|
||||
VL53L1_SIGMA_ESTIMATOR__SIGMA_REF_MM
|
||||
|
||||
#define VL53L1_HISTOGRAM_CONFIG__AMB_THRESH_HIGH \
|
||||
VL53L1_ALGO__RANGE_IGNORE_THRESHOLD_MCPS
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_RESULT__HISTOGRAM_BIN_0_2 0x008E
|
||||
#define VL53L1_RESULT__HISTOGRAM_BIN_0_1 0x008F
|
||||
#define VL53L1_RESULT__HISTOGRAM_BIN_0_0 0x0090
|
||||
|
||||
#define VL53L1_RESULT__HISTOGRAM_BIN_23_2 0x00D3
|
||||
#define VL53L1_RESULT__HISTOGRAM_BIN_23_1 0x00D4
|
||||
#define VL53L1_RESULT__HISTOGRAM_BIN_23_0 0x00D5
|
||||
|
||||
#define VL53L1_RESULT__HISTOGRAM_BIN_23_0_MSB 0x00D9
|
||||
#define VL53L1_RESULT__HISTOGRAM_BIN_23_0_LSB 0x00DA
|
||||
|
||||
|
||||
|
||||
#define VL53L1_HISTOGRAM_BIN_DATA_I2C_INDEX \
|
||||
VL53L1_RESULT__INTERRUPT_STATUS
|
||||
#define VL53L1_HISTOGRAM_BIN_DATA_I2C_SIZE_BYTES \
|
||||
(VL53L1_RESULT__HISTOGRAM_BIN_23_0_LSB - \
|
||||
VL53L1_RESULT__INTERRUPT_STATUS + 1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
299
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_hist_structs.h
Normal file
299
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_hist_structs.h
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_HIST_STRUCTS_H_
|
||||
#define _VL53L1_HIST_STRUCTS_H_
|
||||
|
||||
#include "vl53l1_ll_device.h"
|
||||
#include "vl53l1_dmax_structs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define VL53L1_MAX_BIN_SEQUENCE_LENGTH 6
|
||||
#define VL53L1_MAX_BIN_SEQUENCE_CODE 15
|
||||
#define VL53L1_HISTOGRAM_BUFFER_SIZE 24
|
||||
#define VL53L1_XTALK_HISTO_BINS 12
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint8_t histogram_config__spad_array_selection;
|
||||
|
||||
uint8_t histogram_config__low_amb_even_bin_0_1;
|
||||
uint8_t histogram_config__low_amb_even_bin_2_3;
|
||||
uint8_t histogram_config__low_amb_even_bin_4_5;
|
||||
|
||||
uint8_t histogram_config__low_amb_odd_bin_0_1;
|
||||
uint8_t histogram_config__low_amb_odd_bin_2_3;
|
||||
uint8_t histogram_config__low_amb_odd_bin_4_5;
|
||||
|
||||
uint8_t histogram_config__mid_amb_even_bin_0_1;
|
||||
uint8_t histogram_config__mid_amb_even_bin_2_3;
|
||||
uint8_t histogram_config__mid_amb_even_bin_4_5;
|
||||
|
||||
uint8_t histogram_config__mid_amb_odd_bin_0_1;
|
||||
uint8_t histogram_config__mid_amb_odd_bin_2;
|
||||
uint8_t histogram_config__mid_amb_odd_bin_3_4;
|
||||
uint8_t histogram_config__mid_amb_odd_bin_5;
|
||||
|
||||
uint8_t histogram_config__user_bin_offset;
|
||||
|
||||
uint8_t histogram_config__high_amb_even_bin_0_1;
|
||||
uint8_t histogram_config__high_amb_even_bin_2_3;
|
||||
uint8_t histogram_config__high_amb_even_bin_4_5;
|
||||
|
||||
uint8_t histogram_config__high_amb_odd_bin_0_1;
|
||||
uint8_t histogram_config__high_amb_odd_bin_2_3;
|
||||
uint8_t histogram_config__high_amb_odd_bin_4_5;
|
||||
|
||||
uint16_t histogram_config__amb_thresh_low;
|
||||
|
||||
uint16_t histogram_config__amb_thresh_high;
|
||||
|
||||
|
||||
} VL53L1_histogram_config_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
VL53L1_HistAlgoSelect hist_algo_select;
|
||||
|
||||
|
||||
VL53L1_HistTargetOrder hist_target_order;
|
||||
|
||||
|
||||
uint8_t filter_woi0;
|
||||
|
||||
uint8_t filter_woi1;
|
||||
|
||||
|
||||
VL53L1_HistAmbEstMethod hist_amb_est_method;
|
||||
|
||||
uint8_t ambient_thresh_sigma0;
|
||||
|
||||
uint8_t ambient_thresh_sigma1;
|
||||
|
||||
|
||||
|
||||
uint16_t ambient_thresh_events_scaler;
|
||||
|
||||
|
||||
|
||||
int32_t min_ambient_thresh_events;
|
||||
|
||||
uint16_t noise_threshold;
|
||||
|
||||
|
||||
int32_t signal_total_events_limit;
|
||||
|
||||
uint8_t sigma_estimator__sigma_ref_mm;
|
||||
|
||||
uint16_t sigma_thresh;
|
||||
|
||||
int16_t range_offset_mm;
|
||||
|
||||
uint16_t gain_factor;
|
||||
|
||||
|
||||
uint8_t valid_phase_low;
|
||||
|
||||
uint8_t valid_phase_high;
|
||||
|
||||
uint8_t algo__consistency_check__phase_tolerance;
|
||||
|
||||
uint8_t algo__consistency_check__event_sigma;
|
||||
|
||||
|
||||
|
||||
uint16_t algo__consistency_check__event_min_spad_count;
|
||||
|
||||
|
||||
|
||||
uint16_t algo__consistency_check__min_max_tolerance;
|
||||
|
||||
|
||||
uint8_t algo__crosstalk_compensation_enable;
|
||||
|
||||
uint32_t algo__crosstalk_compensation_plane_offset_kcps;
|
||||
|
||||
int16_t algo__crosstalk_compensation_x_plane_gradient_kcps;
|
||||
|
||||
int16_t algo__crosstalk_compensation_y_plane_gradient_kcps;
|
||||
|
||||
|
||||
int16_t algo__crosstalk_detect_min_valid_range_mm;
|
||||
|
||||
int16_t algo__crosstalk_detect_max_valid_range_mm;
|
||||
|
||||
uint16_t algo__crosstalk_detect_max_valid_rate_kcps;
|
||||
|
||||
uint16_t algo__crosstalk_detect_max_sigma_mm;
|
||||
|
||||
|
||||
|
||||
uint8_t algo__crosstalk_detect_event_sigma;
|
||||
|
||||
|
||||
|
||||
uint16_t algo__crosstalk_detect_min_max_tolerance;
|
||||
|
||||
|
||||
} VL53L1_hist_post_process_config_t;
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
|
||||
VL53L1_DeviceState cfg_device_state;
|
||||
|
||||
VL53L1_DeviceState rd_device_state;
|
||||
|
||||
|
||||
uint8_t zone_id;
|
||||
|
||||
uint32_t time_stamp;
|
||||
|
||||
|
||||
uint8_t VL53L1_p_022;
|
||||
|
||||
uint8_t VL53L1_p_023;
|
||||
|
||||
uint8_t VL53L1_p_024;
|
||||
|
||||
uint8_t number_of_ambient_bins;
|
||||
|
||||
uint8_t bin_seq[VL53L1_MAX_BIN_SEQUENCE_LENGTH];
|
||||
|
||||
uint8_t bin_rep[VL53L1_MAX_BIN_SEQUENCE_LENGTH];
|
||||
|
||||
int32_t bin_data[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
|
||||
uint8_t result__interrupt_status;
|
||||
|
||||
uint8_t result__range_status;
|
||||
|
||||
uint8_t result__report_status;
|
||||
|
||||
uint8_t result__stream_count;
|
||||
|
||||
uint16_t result__dss_actual_effective_spads;
|
||||
|
||||
|
||||
uint16_t phasecal_result__reference_phase;
|
||||
|
||||
uint8_t phasecal_result__vcsel_start;
|
||||
|
||||
uint8_t cal_config__vcsel_start;
|
||||
|
||||
uint16_t vcsel_width;
|
||||
|
||||
uint8_t VL53L1_p_009;
|
||||
|
||||
uint16_t VL53L1_p_019;
|
||||
|
||||
uint32_t total_periods_elapsed;
|
||||
|
||||
|
||||
uint32_t peak_duration_us;
|
||||
|
||||
uint32_t woi_duration_us;
|
||||
|
||||
|
||||
int32_t min_bin_value;
|
||||
|
||||
int32_t max_bin_value;
|
||||
|
||||
|
||||
uint16_t zero_distance_phase;
|
||||
|
||||
uint8_t number_of_ambient_samples;
|
||||
|
||||
int32_t ambient_events_sum;
|
||||
|
||||
int32_t VL53L1_p_004;
|
||||
|
||||
|
||||
uint8_t roi_config__user_roi_centre_spad;
|
||||
|
||||
uint8_t roi_config__user_roi_requested_global_xy_size;
|
||||
|
||||
|
||||
} VL53L1_histogram_bin_data_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
|
||||
uint8_t zone_id;
|
||||
|
||||
uint32_t time_stamp;
|
||||
|
||||
|
||||
uint8_t VL53L1_p_022;
|
||||
|
||||
uint8_t VL53L1_p_023;
|
||||
|
||||
uint8_t VL53L1_p_024;
|
||||
|
||||
uint32_t bin_data[VL53L1_XTALK_HISTO_BINS];
|
||||
|
||||
|
||||
|
||||
uint16_t phasecal_result__reference_phase;
|
||||
|
||||
uint8_t phasecal_result__vcsel_start;
|
||||
|
||||
uint8_t cal_config__vcsel_start;
|
||||
|
||||
uint16_t vcsel_width;
|
||||
|
||||
uint16_t VL53L1_p_019;
|
||||
|
||||
uint16_t zero_distance_phase;
|
||||
|
||||
|
||||
} VL53L1_xtalk_histogram_shape_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
|
||||
VL53L1_xtalk_histogram_shape_t xtalk_shape;
|
||||
|
||||
VL53L1_histogram_bin_data_t xtalk_hist_removed;
|
||||
|
||||
} VL53L1_xtalk_histogram_data_t;
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
1756
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_ll_def.h
Normal file
1756
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_ll_def.h
Normal file
File diff suppressed because it is too large
Load diff
1065
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_ll_device.h
Normal file
1065
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_ll_device.h
Normal file
File diff suppressed because it is too large
Load diff
169
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_nvm.h
Normal file
169
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_nvm.h
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_NVM_H_
|
||||
#define _VL53L1_NVM_H_
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define VL53L1_NVM_POWER_UP_DELAY_US 50
|
||||
#define VL53L1_NVM_READ_TRIGGER_DELAY_US 5
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_nvm_enable(
|
||||
VL53L1_DEV Dev,
|
||||
uint16_t nvm_ctrl_pulse_width,
|
||||
int32_t nvm_power_up_delay_us);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_nvm_read(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t start_address,
|
||||
uint8_t count,
|
||||
uint8_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_nvm_disable(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_nvm_format_decode(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_decoded_nvm_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_nvm_decode_optical_centre(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_optical_centre_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_nvm_decode_cal_peak_rate_map(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_cal_peak_rate_map_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_nvm_decode_additional_offset_cal_data(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_additional_offset_cal_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_nvm_decode_fmt_range_results_data(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_decoded_nvm_fmt_range_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_nvm_decode_fmt_info(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_decoded_nvm_fmt_info_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_nvm_decode_ews_info(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_decoded_nvm_ews_info_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_nvm_format_encode(
|
||||
VL53L1_decoded_nvm_data_t *pnvm_info,
|
||||
uint8_t *pnvm_data);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_read_nvm_raw_data(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t start_address,
|
||||
uint8_t count,
|
||||
uint8_t *pnvm_raw_data);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_read_nvm(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t nvm_format,
|
||||
VL53L1_decoded_nvm_data_t *pnvm_info);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_read_nvm_optical_centre(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_optical_centre_t *pcentre);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_read_nvm_cal_peak_rate_map(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_cal_peak_rate_map_t *pcal_data);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_read_nvm_additional_offset_cal_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_additional_offset_cal_data_t *pcal_data);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_read_nvm_fmt_range_results_data(
|
||||
VL53L1_DEV Dev,
|
||||
uint16_t range_results_select,
|
||||
VL53L1_decoded_nvm_fmt_range_data_t *prange_data);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
75
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_nvm_debug.h
Normal file
75
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_nvm_debug.h
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_NVM_DEBUG_H_
|
||||
#define _VL53L1_NVM_DEBUG_H_
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_nvm_structs.h"
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef VL53L1_LOG_ENABLE
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_nvm_raw_data(
|
||||
uint8_t *pnvm_raw_data,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_decoded_nvm_data(
|
||||
VL53L1_decoded_nvm_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_decoded_nvm_fmt_range_data(
|
||||
VL53L1_decoded_nvm_fmt_range_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_decoded_nvm_fmt_info(
|
||||
VL53L1_decoded_nvm_fmt_info_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
|
||||
void VL53L1_print_decoded_nvm_ews_info(
|
||||
VL53L1_decoded_nvm_ews_info_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
447
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_nvm_map.h
Normal file
447
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_nvm_map.h
Normal file
|
|
@ -0,0 +1,447 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_NVM_MAP_H_
|
||||
#define _VL53L1_NVM_MAP_H_
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_NVM__IDENTIFICATION__MODEL_ID 0x0008
|
||||
|
||||
#define VL53L1_NVM__IDENTIFICATION__MODULE_TYPE 0x000C
|
||||
|
||||
#define VL53L1_NVM__IDENTIFICATION__REVISION_ID 0x000D
|
||||
|
||||
#define VL53L1_NVM__IDENTIFICATION__MODULE_ID 0x000E
|
||||
|
||||
#define VL53L1_NVM__I2C_VALID 0x0010
|
||||
|
||||
#define VL53L1_NVM__I2C_SLAVE__DEVICE_ADDRESS 0x0011
|
||||
|
||||
#define VL53L1_NVM__EWS__OSC_MEASURED__FAST_OSC_FREQUENCY 0x0014
|
||||
|
||||
#define VL53L1_NVM__EWS__FAST_OSC_TRIM_MAX 0x0016
|
||||
|
||||
#define VL53L1_NVM__EWS__FAST_OSC_FREQ_SET 0x0017
|
||||
|
||||
#define VL53L1_NVM__EWS__SLOW_OSC_CALIBRATION 0x0018
|
||||
|
||||
#define VL53L1_NVM__FMT__OSC_MEASURED__FAST_OSC_FREQUENCY 0x001C
|
||||
|
||||
#define VL53L1_NVM__FMT__FAST_OSC_TRIM_MAX 0x001E
|
||||
|
||||
#define VL53L1_NVM__FMT__FAST_OSC_FREQ_SET 0x001F
|
||||
|
||||
#define VL53L1_NVM__FMT__SLOW_OSC_CALIBRATION 0x0020
|
||||
|
||||
#define VL53L1_NVM__VHV_CONFIG_UNLOCK 0x0028
|
||||
|
||||
#define VL53L1_NVM__REF_SELVDDPIX 0x0029
|
||||
|
||||
#define VL53L1_NVM__REF_SELVQUENCH 0x002A
|
||||
|
||||
#define VL53L1_NVM__REGAVDD1V2_SEL_REGDVDD1V2_SEL 0x002B
|
||||
|
||||
#define VL53L1_NVM__VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND 0x002C
|
||||
|
||||
#define VL53L1_NVM__VHV_CONFIG__COUNT_THRESH 0x002D
|
||||
|
||||
#define VL53L1_NVM__VHV_CONFIG__OFFSET 0x002E
|
||||
|
||||
#define VL53L1_NVM__VHV_CONFIG__INIT 0x002F
|
||||
|
||||
#define VL53L1_NVM__LASER_SAFETY__VCSEL_TRIM_LL 0x0030
|
||||
|
||||
#define VL53L1_NVM__LASER_SAFETY__VCSEL_SELION_LL 0x0031
|
||||
|
||||
#define VL53L1_NVM__LASER_SAFETY__VCSEL_SELION_MAX_LL 0x0032
|
||||
|
||||
#define VL53L1_NVM__LASER_SAFETY__MULT_LL 0x0034
|
||||
|
||||
#define VL53L1_NVM__LASER_SAFETY__CLIP_LL 0x0035
|
||||
|
||||
#define VL53L1_NVM__LASER_SAFETY__VCSEL_TRIM_LD 0x0038
|
||||
|
||||
#define VL53L1_NVM__LASER_SAFETY__VCSEL_SELION_LD 0x0039
|
||||
|
||||
#define VL53L1_NVM__LASER_SAFETY__VCSEL_SELION_MAX_LD 0x003A
|
||||
|
||||
#define VL53L1_NVM__LASER_SAFETY__MULT_LD 0x003C
|
||||
|
||||
#define VL53L1_NVM__LASER_SAFETY__CLIP_LD 0x003D
|
||||
|
||||
#define VL53L1_NVM__LASER_SAFETY_LOCK_BYTE 0x0040
|
||||
|
||||
#define VL53L1_NVM__LASER_SAFETY_UNLOCK_BYTE 0x0044
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_0_ 0x0048
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_1_ 0x0049
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_2_ 0x004A
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_3_ 0x004B
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_4_ 0x004C
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_5_ 0x004D
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_6_ 0x004E
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_7_ 0x004F
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_8_ 0x0050
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_9_ 0x0051
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_10_ 0x0052
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_11_ 0x0053
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_12_ 0x0054
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_13_ 0x0055
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_14_ 0x0056
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_15_ 0x0057
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_16_ 0x0058
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_17_ 0x0059
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_18_ 0x005A
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_19_ 0x005B
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_20_ 0x005C
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_21_ 0x005D
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_22_ 0x005E
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_23_ 0x005F
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_24_ 0x0060
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_25_ 0x0061
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_26_ 0x0062
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_27_ 0x0063
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_28_ 0x0064
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_29_ 0x0065
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_30_ 0x0066
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_31_ 0x0067
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC1_0_ 0x0068
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC1_1_ 0x0069
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC1_2_ 0x006A
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC1_3_ 0x006B
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC1_4_ 0x006C
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC1_5_ 0x006D
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC2_0_ 0x0070
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC2_1_ 0x0071
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC2_2_ 0x0072
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC2_3_ 0x0073
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC2_4_ 0x0074
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC2_5_ 0x0075
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC3_0_ 0x0078
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC3_1_ 0x0079
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC3_2_ 0x007A
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC3_3_ 0x007B
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC3_4_ 0x007C
|
||||
|
||||
#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC3_5_ 0x007D
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_0_ 0x0080
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_1_ 0x0081
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_2_ 0x0082
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_3_ 0x0083
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_4_ 0x0084
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_5_ 0x0085
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_6_ 0x0086
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_7_ 0x0087
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_8_ 0x0088
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_9_ 0x0089
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_10_ 0x008A
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_11_ 0x008B
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_12_ 0x008C
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_13_ 0x008D
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_14_ 0x008E
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_15_ 0x008F
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_16_ 0x0090
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_17_ 0x0091
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_18_ 0x0092
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_19_ 0x0093
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_20_ 0x0094
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_21_ 0x0095
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_22_ 0x0096
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_23_ 0x0097
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_24_ 0x0098
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_25_ 0x0099
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_26_ 0x009A
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_27_ 0x009B
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_28_ 0x009C
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_29_ 0x009D
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_30_ 0x009E
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_31_ 0x009F
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC1_0_ 0x00A0
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC1_1_ 0x00A1
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC1_2_ 0x00A2
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC1_3_ 0x00A3
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC1_4_ 0x00A4
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC1_5_ 0x00A5
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC2_0_ 0x00A8
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC2_1_ 0x00A9
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC2_2_ 0x00AA
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC2_3_ 0x00AB
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC2_4_ 0x00AC
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC2_5_ 0x00AD
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC3_0_ 0x00B0
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC3_1_ 0x00B1
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC3_2_ 0x00B2
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC3_3_ 0x00B3
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC3_4_ 0x00B4
|
||||
|
||||
#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC3_5_ 0x00B5
|
||||
|
||||
#define VL53L1_NVM__FMT__ROI_CONFIG__MODE_ROI_CENTRE_SPAD 0x00B8
|
||||
|
||||
#define VL53L1_NVM__FMT__ROI_CONFIG__MODE_ROI_XY_SIZE 0x00B9
|
||||
|
||||
#define VL53L1_NVM__FMT__REF_SPAD_APPLY__NUM_REQUESTED_REF_SPAD 0x00BC
|
||||
|
||||
#define VL53L1_NVM__FMT__REF_SPAD_MAN__REF_LOCATION 0x00BD
|
||||
|
||||
#define VL53L1_NVM__FMT__MM_CONFIG__INNER_OFFSET_MM 0x00C0
|
||||
|
||||
#define VL53L1_NVM__FMT__MM_CONFIG__OUTER_OFFSET_MM 0x00C2
|
||||
|
||||
#define VL53L1_NVM__FMT__ALGO__PART_TO_PART_RANGE_OFFSET_MM 0x00C4
|
||||
|
||||
#define VL53L1_NVM__FMT__ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS 0x00C8
|
||||
|
||||
#define VL53L1_NVM__FMT__ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS \
|
||||
0x00CA
|
||||
|
||||
#define VL53L1_NVM__FMT__ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS \
|
||||
0x00CC
|
||||
|
||||
#define VL53L1_NVM__FMT__SPARE_HOST_CONFIG__NVM_CONFIG_SPARE_0 0x00CE
|
||||
|
||||
#define VL53L1_NVM__FMT__SPARE_HOST_CONFIG__NVM_CONFIG_SPARE_1 0x00CF
|
||||
|
||||
#define VL53L1_NVM__CUSTOMER_NVM_SPACE_PROGRAMMED 0x00E0
|
||||
|
||||
#define VL53L1_NVM__CUST__I2C_SLAVE__DEVICE_ADDRESS 0x00E4
|
||||
|
||||
#define VL53L1_NVM__CUST__REF_SPAD_APPLY__NUM_REQUESTED_REF_SPAD 0x00E8
|
||||
|
||||
#define VL53L1_NVM__CUST__REF_SPAD_MAN__REF_LOCATION 0x00E9
|
||||
|
||||
#define VL53L1_NVM__CUST__MM_CONFIG__INNER_OFFSET_MM 0x00EC
|
||||
|
||||
#define VL53L1_NVM__CUST__MM_CONFIG__OUTER_OFFSET_MM 0x00EE
|
||||
|
||||
#define VL53L1_NVM__CUST__ALGO__PART_TO_PART_RANGE_OFFSET_MM 0x00F0
|
||||
|
||||
#define VL53L1_NVM__CUST__ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS 0x00F4
|
||||
|
||||
#define VL53L1_NVM__CUST__ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS \
|
||||
0x00F6
|
||||
|
||||
#define VL53L1_NVM__CUST__ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS \
|
||||
0x00F8
|
||||
|
||||
#define VL53L1_NVM__CUST__SPARE_HOST_CONFIG__NVM_CONFIG_SPARE_0 0x00FA
|
||||
|
||||
#define VL53L1_NVM__CUST__SPARE_HOST_CONFIG__NVM_CONFIG_SPARE_1 0x00FB
|
||||
|
||||
#define VL53L1_NVM__FMT__FGC__BYTE_0 0x01DC
|
||||
|
||||
#define VL53L1_NVM__FMT__FGC__BYTE_1 0x01DD
|
||||
|
||||
#define VL53L1_NVM__FMT__FGC__BYTE_2 0x01DE
|
||||
|
||||
#define VL53L1_NVM__FMT__FGC__BYTE_3 0x01DF
|
||||
|
||||
#define VL53L1_NVM__FMT__FGC__BYTE_4 0x01E0
|
||||
|
||||
#define VL53L1_NVM__FMT__FGC__BYTE_5 0x01E1
|
||||
|
||||
#define VL53L1_NVM__FMT__FGC__BYTE_6 0x01E2
|
||||
|
||||
#define VL53L1_NVM__FMT__FGC__BYTE_7 0x01E3
|
||||
|
||||
#define VL53L1_NVM__FMT__FGC__BYTE_8 0x01E4
|
||||
|
||||
#define VL53L1_NVM__FMT__FGC__BYTE_9 0x01E5
|
||||
|
||||
#define VL53L1_NVM__FMT__FGC__BYTE_10 0x01E6
|
||||
|
||||
#define VL53L1_NVM__FMT__FGC__BYTE_11 0x01E7
|
||||
|
||||
#define VL53L1_NVM__FMT__FGC__BYTE_12 0x01E8
|
||||
|
||||
#define VL53L1_NVM__FMT__FGC__BYTE_13 0x01E9
|
||||
|
||||
#define VL53L1_NVM__FMT__FGC__BYTE_14 0x01EA
|
||||
|
||||
#define VL53L1_NVM__FMT__FGC__BYTE_15 0x01EB
|
||||
|
||||
#define VL53L1_NVM__FMT__TEST_PROGRAM_MAJOR_MINOR 0x01EC
|
||||
|
||||
#define VL53L1_NVM__FMT__MAP_MAJOR_MINOR 0x01ED
|
||||
|
||||
#define VL53L1_NVM__FMT__YEAR_MONTH 0x01EE
|
||||
|
||||
#define VL53L1_NVM__FMT__DAY_MODULE_DATE_PHASE 0x01EF
|
||||
|
||||
#define VL53L1_NVM__FMT__TIME 0x01F0
|
||||
|
||||
#define VL53L1_NVM__FMT__TESTER_ID 0x01F2
|
||||
|
||||
#define VL53L1_NVM__FMT__SITE_ID 0x01F3
|
||||
|
||||
#define VL53L1_NVM__EWS__TEST_PROGRAM_MAJOR_MINOR 0x01F4
|
||||
|
||||
#define VL53L1_NVM__EWS__PROBE_CARD_MAJOR_MINOR 0x01F5
|
||||
|
||||
#define VL53L1_NVM__EWS__TESTER_ID 0x01F6
|
||||
|
||||
#define VL53L1_NVM__EWS__LOT__BYTE_0 0x01F8
|
||||
|
||||
#define VL53L1_NVM__EWS__LOT__BYTE_1 0x01F9
|
||||
|
||||
#define VL53L1_NVM__EWS__LOT__BYTE_2 0x01FA
|
||||
|
||||
#define VL53L1_NVM__EWS__LOT__BYTE_3 0x01FB
|
||||
|
||||
#define VL53L1_NVM__EWS__LOT__BYTE_4 0x01FC
|
||||
|
||||
#define VL53L1_NVM__EWS__LOT__BYTE_5 0x01FD
|
||||
|
||||
#define VL53L1_NVM__EWS__WAFER 0x01FD
|
||||
|
||||
#define VL53L1_NVM__EWS__XCOORD 0x01FE
|
||||
|
||||
#define VL53L1_NVM__EWS__YCOORD 0x01FF
|
||||
|
||||
|
||||
#define VL53L1_NVM__FMT__OPTICAL_CENTRE_DATA_INDEX 0x00B8
|
||||
#define VL53L1_NVM__FMT__OPTICAL_CENTRE_DATA_SIZE 4
|
||||
|
||||
#define VL53L1_NVM__FMT__CAL_PEAK_RATE_MAP_DATA_INDEX 0x015C
|
||||
#define VL53L1_NVM__FMT__CAL_PEAK_RATE_MAP_DATA_SIZE 56
|
||||
|
||||
#define VL53L1_NVM__FMT__ADDITIONAL_OFFSET_CAL_DATA_INDEX 0x0194
|
||||
#define VL53L1_NVM__FMT__ADDITIONAL_OFFSET_CAL_DATA_SIZE 8
|
||||
|
||||
#define VL53L1_NVM__FMT__RANGE_RESULTS__140MM_MM_PRE_RANGE 0x019C
|
||||
#define VL53L1_NVM__FMT__RANGE_RESULTS__140MM_DARK 0x01AC
|
||||
#define VL53L1_NVM__FMT__RANGE_RESULTS__400MM_DARK 0x01BC
|
||||
#define VL53L1_NVM__FMT__RANGE_RESULTS__400MM_AMBIENT 0x01CC
|
||||
#define VL53L1_NVM__FMT__RANGE_RESULTS__SIZE_BYTES 16
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
297
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_nvm_structs.h
Normal file
297
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_nvm_structs.h
Normal file
|
|
@ -0,0 +1,297 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_NVM_STRUCTS_H_
|
||||
#define _VL53L1_NVM_STRUCTS_H_
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
#include "vl53l1_ll_def.h"
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint16_t result__actual_effective_rtn_spads;
|
||||
|
||||
uint8_t ref_spad_array__num_requested_ref_spads;
|
||||
|
||||
uint8_t ref_spad_array__ref_location;
|
||||
|
||||
uint16_t result__peak_signal_count_rate_rtn_mcps;
|
||||
|
||||
uint16_t result__ambient_count_rate_rtn_mcps;
|
||||
|
||||
uint16_t result__peak_signal_count_rate_ref_mcps;
|
||||
|
||||
uint16_t result__ambient_count_rate_ref_mcps;
|
||||
|
||||
uint16_t measured_distance_mm;
|
||||
|
||||
uint16_t measured_distance_stdev_mm;
|
||||
|
||||
|
||||
} VL53L1_decoded_nvm_fmt_range_data_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
char nvm__fmt__fgc[19];
|
||||
|
||||
uint8_t nvm__fmt__test_program_major;
|
||||
|
||||
uint8_t nvm__fmt__test_program_minor;
|
||||
|
||||
uint8_t nvm__fmt__map_major;
|
||||
|
||||
uint8_t nvm__fmt__map_minor;
|
||||
|
||||
uint8_t nvm__fmt__year;
|
||||
|
||||
uint8_t nvm__fmt__month;
|
||||
|
||||
uint8_t nvm__fmt__day;
|
||||
|
||||
uint8_t nvm__fmt__module_date_phase;
|
||||
|
||||
uint16_t nvm__fmt__time;
|
||||
|
||||
uint8_t nvm__fmt__tester_id;
|
||||
|
||||
uint8_t nvm__fmt__site_id;
|
||||
|
||||
uint8_t nvm__ews__test_program_major;
|
||||
|
||||
uint8_t nvm__ews__test_program_minor;
|
||||
|
||||
uint8_t nvm__ews__probe_card_major;
|
||||
|
||||
uint8_t nvm__ews__probe_card_minor;
|
||||
|
||||
uint8_t nvm__ews__tester_id;
|
||||
|
||||
|
||||
char nvm__ews__lot[8];
|
||||
|
||||
uint8_t nvm__ews__wafer;
|
||||
|
||||
uint8_t nvm__ews__xcoord;
|
||||
|
||||
uint8_t nvm__ews__ycoord;
|
||||
|
||||
} VL53L1_decoded_nvm_fmt_info_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint8_t nvm__ews__test_program_major;
|
||||
|
||||
uint8_t nvm__ews__test_program_minor;
|
||||
|
||||
uint8_t nvm__ews__probe_card_major;
|
||||
|
||||
uint8_t nvm__ews__probe_card_minor;
|
||||
|
||||
uint8_t nvm__ews__tester_id;
|
||||
|
||||
|
||||
char nvm__ews__lot[8];
|
||||
|
||||
uint8_t nvm__ews__wafer;
|
||||
|
||||
uint8_t nvm__ews__xcoord;
|
||||
|
||||
uint8_t nvm__ews__ycoord;
|
||||
|
||||
|
||||
} VL53L1_decoded_nvm_ews_info_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t nvm__identification_model_id;
|
||||
|
||||
uint8_t nvm__identification_module_type;
|
||||
|
||||
uint8_t nvm__identification_revision_id;
|
||||
|
||||
uint16_t nvm__identification_module_id;
|
||||
|
||||
uint8_t nvm__i2c_valid;
|
||||
|
||||
uint8_t nvm__i2c_device_address_ews;
|
||||
|
||||
uint16_t nvm__ews__fast_osc_frequency;
|
||||
|
||||
uint8_t nvm__ews__fast_osc_trim_max;
|
||||
|
||||
uint8_t nvm__ews__fast_osc_freq_set;
|
||||
|
||||
uint16_t nvm__ews__slow_osc_calibration;
|
||||
|
||||
uint16_t nvm__fmt__fast_osc_frequency;
|
||||
|
||||
uint8_t nvm__fmt__fast_osc_trim_max;
|
||||
|
||||
uint8_t nvm__fmt__fast_osc_freq_set;
|
||||
|
||||
uint16_t nvm__fmt__slow_osc_calibration;
|
||||
|
||||
uint8_t nvm__vhv_config_unlock;
|
||||
|
||||
uint8_t nvm__ref_selvddpix;
|
||||
|
||||
uint8_t nvm__ref_selvquench;
|
||||
|
||||
uint8_t nvm__regavdd1v2_sel;
|
||||
|
||||
uint8_t nvm__regdvdd1v2_sel;
|
||||
|
||||
uint8_t nvm__vhv_timeout__macrop;
|
||||
|
||||
uint8_t nvm__vhv_loop_bound;
|
||||
|
||||
uint8_t nvm__vhv_count_threshold;
|
||||
|
||||
uint8_t nvm__vhv_offset;
|
||||
|
||||
uint8_t nvm__vhv_init_enable;
|
||||
|
||||
uint8_t nvm__vhv_init_value;
|
||||
|
||||
uint8_t nvm__laser_safety_vcsel_trim_ll;
|
||||
|
||||
uint8_t nvm__laser_safety_vcsel_selion_ll;
|
||||
|
||||
uint8_t nvm__laser_safety_vcsel_selion_max_ll;
|
||||
|
||||
uint8_t nvm__laser_safety_mult_ll;
|
||||
|
||||
uint8_t nvm__laser_safety_clip_ll;
|
||||
|
||||
uint8_t nvm__laser_safety_vcsel_trim_ld;
|
||||
|
||||
uint8_t nvm__laser_safety_vcsel_selion_ld;
|
||||
|
||||
uint8_t nvm__laser_safety_vcsel_selion_max_ld;
|
||||
|
||||
uint8_t nvm__laser_safety_mult_ld;
|
||||
|
||||
uint8_t nvm__laser_safety_clip_ld;
|
||||
|
||||
uint8_t nvm__laser_safety_lock_byte;
|
||||
|
||||
uint8_t nvm__laser_safety_unlock_byte;
|
||||
|
||||
uint8_t nvm__ews__spad_enables_rtn[VL53L1_RTN_SPAD_BUFFER_SIZE];
|
||||
|
||||
uint8_t nvm__ews__spad_enables_ref__loc1[VL53L1_REF_SPAD_BUFFER_SIZE];
|
||||
|
||||
uint8_t nvm__ews__spad_enables_ref__loc2[VL53L1_REF_SPAD_BUFFER_SIZE];
|
||||
|
||||
uint8_t nvm__ews__spad_enables_ref__loc3[VL53L1_REF_SPAD_BUFFER_SIZE];
|
||||
|
||||
uint8_t nvm__fmt__spad_enables_rtn[VL53L1_RTN_SPAD_BUFFER_SIZE];
|
||||
|
||||
uint8_t nvm__fmt__spad_enables_ref__loc1[VL53L1_REF_SPAD_BUFFER_SIZE];
|
||||
|
||||
uint8_t nvm__fmt__spad_enables_ref__loc2[VL53L1_REF_SPAD_BUFFER_SIZE];
|
||||
|
||||
uint8_t nvm__fmt__spad_enables_ref__loc3[VL53L1_REF_SPAD_BUFFER_SIZE];
|
||||
|
||||
uint8_t nvm__fmt__roi_config__mode_roi_centre_spad;
|
||||
|
||||
uint8_t nvm__fmt__roi_config__mode_roi_x_size;
|
||||
|
||||
uint8_t nvm__fmt__roi_config__mode_roi_y_size;
|
||||
|
||||
uint8_t nvm__fmt__ref_spad_apply__num_requested_ref_spad;
|
||||
|
||||
uint8_t nvm__fmt__ref_spad_man__ref_location;
|
||||
|
||||
uint16_t nvm__fmt__mm_config__inner_offset_mm;
|
||||
|
||||
uint16_t nvm__fmt__mm_config__outer_offset_mm;
|
||||
|
||||
uint16_t nvm__fmt__algo_part_to_part_range_offset_mm;
|
||||
|
||||
uint16_t nvm__fmt__algo__crosstalk_compensation_plane_offset_kcps;
|
||||
|
||||
uint16_t nvm__fmt__algo__crosstalk_compensation_x_plane_gradient_kcps;
|
||||
|
||||
uint16_t nvm__fmt__algo__crosstalk_compensation_y_plane_gradient_kcps;
|
||||
|
||||
uint8_t nvm__fmt__spare__host_config__nvm_config_spare_0;
|
||||
|
||||
uint8_t nvm__fmt__spare__host_config__nvm_config_spare_1;
|
||||
|
||||
uint8_t nvm__customer_space_programmed;
|
||||
|
||||
uint8_t nvm__cust__i2c_device_address;
|
||||
|
||||
uint8_t nvm__cust__ref_spad_apply__num_requested_ref_spad;
|
||||
|
||||
uint8_t nvm__cust__ref_spad_man__ref_location;
|
||||
|
||||
uint16_t nvm__cust__mm_config__inner_offset_mm;
|
||||
|
||||
uint16_t nvm__cust__mm_config__outer_offset_mm;
|
||||
|
||||
uint16_t nvm__cust__algo_part_to_part_range_offset_mm;
|
||||
|
||||
uint16_t nvm__cust__algo__crosstalk_compensation_plane_offset_kcps;
|
||||
|
||||
uint16_t nvm__cust__algo__crosstalk_compensation_x_plane_gradient_kcps;
|
||||
|
||||
uint16_t nvm__cust__algo__crosstalk_compensation_y_plane_gradient_kcps;
|
||||
|
||||
uint8_t nvm__cust__spare__host_config__nvm_config_spare_0;
|
||||
|
||||
uint8_t nvm__cust__spare__host_config__nvm_config_spare_1;
|
||||
|
||||
|
||||
VL53L1_optical_centre_t fmt_optical_centre;
|
||||
VL53L1_cal_peak_rate_map_t fmt_peak_rate_map;
|
||||
VL53L1_additional_offset_cal_data_t fmt_add_offset_data;
|
||||
|
||||
VL53L1_decoded_nvm_fmt_range_data_t
|
||||
fmt_range_data[VL53L1_NVM_MAX_FMT_RANGE_DATA];
|
||||
|
||||
VL53L1_decoded_nvm_fmt_info_t fmt_info;
|
||||
VL53L1_decoded_nvm_ews_info_t ews_info;
|
||||
|
||||
} VL53L1_decoded_nvm_data_t;
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
67
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_preset_setup.h
Normal file
67
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_preset_setup.h
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_PRESET_SETUP_H_
|
||||
#define _VL53L1_PRESET_SETUP_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* indexes for the bare driver tuning setting API function */
|
||||
enum VL53L1_Tuning_t {
|
||||
VL53L1_TUNING_VERSION = 0,
|
||||
VL53L1_TUNING_PROXY_MIN,
|
||||
VL53L1_TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM,
|
||||
VL53L1_TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER,
|
||||
VL53L1_TUNING_MIN_AMBIENT_DMAX_VALID,
|
||||
VL53L1_TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER,
|
||||
VL53L1_TUNING_XTALK_FULL_ROI_TARGET_DISTANCE_MM,
|
||||
VL53L1_TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT,
|
||||
VL53L1_TUNING_XTALK_FULL_ROI_BIN_SUM_MARGIN,
|
||||
VL53L1_TUNING_XTALK_FULL_ROI_DEFAULT_OFFSET,
|
||||
VL53L1_TUNING_ZERO_DISTANCE_OFFSET_NON_LINEAR_FACTOR,
|
||||
VL53L1_TUNING_MAX_TUNABLE_KEY
|
||||
};
|
||||
|
||||
/* default values for the tuning settings parameters */
|
||||
#define TUNING_VERSION 0x0007
|
||||
|
||||
#define TUNING_PROXY_MIN -30 /* min distance in mm */
|
||||
#define TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM 600
|
||||
/* Target distance in mm for single target Xtalk */
|
||||
#define TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER 50
|
||||
/* Number of sample used for single target Xtalk */
|
||||
#define TUNING_MIN_AMBIENT_DMAX_VALID 8
|
||||
/* Minimum ambient level to state the Dmax returned by the device is valid */
|
||||
#define TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER 10
|
||||
/* Maximum loops to perform simple offset calibration */
|
||||
#define TUNING_XTALK_FULL_ROI_TARGET_DISTANCE_MM 600
|
||||
/* Target distance in mm for target Xtalk from Bins method*/
|
||||
#define TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT 3
|
||||
/* Number of loops done during the simple offset calibration*/
|
||||
#define TUNING_ZERO_DISTANCE_OFFSET_NON_LINEAR_FACTOR_DEFAULT 9
|
||||
/* zero distance offset calibration non linear compensation default value */
|
||||
|
||||
/* The following settings are related to the fix for ticket EwokP #558410 */
|
||||
#define TUNING_XTALK_FULL_ROI_BIN_SUM_MARGIN 24
|
||||
/* Acceptance margin for the xtalk_shape bin_data sum computation */
|
||||
#define TUNING_XTALK_FULL_ROI_DEFAULT_OFFSET 50
|
||||
/* Recovery value for Xtalk compensation plane offset in kcps */
|
||||
/* 50 stands for ~0.10 kcps cover glass in 7.9 format */
|
||||
/* End of settings related to the fix for ticket EwokP #558410 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _VL53L1_PRESET_SETUP_H_ */
|
||||
662
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_register_funcs.h
Normal file
662
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_register_funcs.h
Normal file
|
|
@ -0,0 +1,662 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_REGISTER_FUNCS_H_
|
||||
#define _VL53L1_REGISTER_FUNCS_H_
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_static_nvm_managed(
|
||||
VL53L1_static_nvm_managed_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_static_nvm_managed(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_static_nvm_managed_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_static_nvm_managed(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_static_nvm_managed_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_static_nvm_managed(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_static_nvm_managed_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_customer_nvm_managed(
|
||||
VL53L1_customer_nvm_managed_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_customer_nvm_managed(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_customer_nvm_managed_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_customer_nvm_managed(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_customer_nvm_managed_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_customer_nvm_managed(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_customer_nvm_managed_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_static_config(
|
||||
VL53L1_static_config_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_static_config(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_static_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_static_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_static_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_static_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_static_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_general_config(
|
||||
VL53L1_general_config_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_general_config(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_general_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_general_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_general_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_general_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_general_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_timing_config(
|
||||
VL53L1_timing_config_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_timing_config(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_timing_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_timing_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_timing_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_timing_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_timing_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_dynamic_config(
|
||||
VL53L1_dynamic_config_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_dynamic_config(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_dynamic_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_dynamic_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_dynamic_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_dynamic_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_dynamic_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_system_control(
|
||||
VL53L1_system_control_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_system_control(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_system_control_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_system_control(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_system_control_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_system_control(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_system_control_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_system_results(
|
||||
VL53L1_system_results_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_system_results(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_system_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_system_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_system_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_system_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_system_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_core_results(
|
||||
VL53L1_core_results_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_core_results(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_core_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_core_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_core_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_core_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_core_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_debug_results(
|
||||
VL53L1_debug_results_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_debug_results(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_debug_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_debug_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_debug_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_debug_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_debug_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_nvm_copy_data(
|
||||
VL53L1_nvm_copy_data_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_nvm_copy_data(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_nvm_copy_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_nvm_copy_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_nvm_copy_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_nvm_copy_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_nvm_copy_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_prev_shadow_system_results(
|
||||
VL53L1_prev_shadow_system_results_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_prev_shadow_system_results(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_prev_shadow_system_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_prev_shadow_system_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_prev_shadow_system_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_prev_shadow_system_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_prev_shadow_system_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_prev_shadow_core_results(
|
||||
VL53L1_prev_shadow_core_results_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_prev_shadow_core_results(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_prev_shadow_core_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_prev_shadow_core_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_prev_shadow_core_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_prev_shadow_core_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_prev_shadow_core_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_patch_debug(
|
||||
VL53L1_patch_debug_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_patch_debug(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_patch_debug_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_patch_debug(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_patch_debug_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_patch_debug(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_patch_debug_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_gph_general_config(
|
||||
VL53L1_gph_general_config_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_gph_general_config(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_gph_general_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_gph_general_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_gph_general_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_gph_general_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_gph_general_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_gph_static_config(
|
||||
VL53L1_gph_static_config_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_gph_static_config(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_gph_static_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_gph_static_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_gph_static_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_gph_static_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_gph_static_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_gph_timing_config(
|
||||
VL53L1_gph_timing_config_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_gph_timing_config(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_gph_timing_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_gph_timing_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_gph_timing_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_gph_timing_config(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_gph_timing_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_fw_internal(
|
||||
VL53L1_fw_internal_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_fw_internal(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_fw_internal_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_fw_internal(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_fw_internal_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_fw_internal(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_fw_internal_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_patch_results(
|
||||
VL53L1_patch_results_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_patch_results(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_patch_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_patch_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_patch_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_patch_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_patch_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_shadow_system_results(
|
||||
VL53L1_shadow_system_results_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_shadow_system_results(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_shadow_system_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_shadow_system_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_shadow_system_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_shadow_system_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_shadow_system_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_encode_shadow_core_results(
|
||||
VL53L1_shadow_core_results_t *pdata,
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_i2c_decode_shadow_core_results(
|
||||
uint16_t buf_size,
|
||||
uint8_t *pbuffer,
|
||||
VL53L1_shadow_core_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_shadow_core_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_shadow_core_results_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_shadow_core_results(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_shadow_core_results_t *pdata);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
2390
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_register_map.h
Normal file
2390
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_register_map.h
Normal file
File diff suppressed because it is too large
Load diff
130
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_register_settings.h
Normal file
130
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_register_settings.h
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_REGISTER_SETTINGS_H_
|
||||
#define _VL53L1_REGISTER_SETTINGS_H_
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_DEVICESCHEDULERMODE_PSEUDO_SOLO 0x00
|
||||
#define VL53L1_DEVICESCHEDULERMODE_STREAMING 0x01
|
||||
#define VL53L1_DEVICESCHEDULERMODE_HISTOGRAM 0x02
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_DEVICEREADOUTMODE_SINGLE_SD (0x00 << 2)
|
||||
#define VL53L1_DEVICEREADOUTMODE_DUAL_SD (0x01 << 2)
|
||||
#define VL53L1_DEVICEREADOUTMODE_SPLIT_READOUT (0x02 << 2)
|
||||
#define VL53L1_DEVICEREADOUTMODE_SPLIT_MANUAL (0x03 << 2)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_DEVICEMEASUREMENTMODE_MODE_MASK 0xF0
|
||||
#define VL53L1_DEVICEMEASUREMENTMODE_STOP_MASK 0x0F
|
||||
|
||||
#define VL53L1_GROUPEDPARAMETERHOLD_ID_MASK 0x02
|
||||
|
||||
|
||||
|
||||
#define VL53L1_EWOK_I2C_DEV_ADDR_DEFAULT 0x29
|
||||
|
||||
#define VL53L1_OSC_FREQUENCY 0x00
|
||||
#define VL53L1_OSC_TRIM_DEFAULT 0x00
|
||||
#define VL53L1_OSC_FREQ_SET_DEFAULT 0x00
|
||||
|
||||
#define VL53L1_RANGE_HISTOGRAM_REF 0x08
|
||||
#define VL53L1_RANGE_HISTOGRAM_RET 0x10
|
||||
#define VL53L1_RANGE_HISTOGRAM_BOTH 0x18
|
||||
#define VL53L1_RANGE_HISTOGRAM_INIT 0x20
|
||||
#define VL53L1_RANGE_VHV_INIT 0x40
|
||||
|
||||
|
||||
#define VL53L1_RESULT_RANGE_STATUS 0x1F
|
||||
|
||||
|
||||
#define VL53L1_SYSTEM__SEED_CONFIG__MANUAL 0x00
|
||||
#define VL53L1_SYSTEM__SEED_CONFIG__STANDARD 0x01
|
||||
#define VL53L1_SYSTEM__SEED_CONFIG__EVEN_UPDATE_ONLY 0x02
|
||||
|
||||
|
||||
#define VL53L1_INTERRUPT_CONFIG_LEVEL_LOW 0x00
|
||||
#define VL53L1_INTERRUPT_CONFIG_LEVEL_HIGH 0x01
|
||||
#define VL53L1_INTERRUPT_CONFIG_OUT_OF_WINDOW 0x02
|
||||
#define VL53L1_INTERRUPT_CONFIG_IN_WINDOW 0x03
|
||||
#define VL53L1_INTERRUPT_CONFIG_NEW_SAMPLE_READY 0x20
|
||||
|
||||
|
||||
#define VL53L1_CLEAR_RANGE_INT 0x01
|
||||
#define VL53L1_CLEAR_ERROR_INT 0x02
|
||||
|
||||
|
||||
#define VL53L1_SEQUENCE_VHV_EN 0x01
|
||||
#define VL53L1_SEQUENCE_PHASECAL_EN 0x02
|
||||
#define VL53L1_SEQUENCE_REFERENCE_PHASE_EN 0x04
|
||||
#define VL53L1_SEQUENCE_DSS1_EN 0x08
|
||||
#define VL53L1_SEQUENCE_DSS2_EN 0x10
|
||||
#define VL53L1_SEQUENCE_MM1_EN 0x20
|
||||
#define VL53L1_SEQUENCE_MM2_EN 0x40
|
||||
#define VL53L1_SEQUENCE_RANGE_EN 0x80
|
||||
|
||||
|
||||
#define VL53L1_DSS_CONTROL__ROI_SUBTRACT 0x20
|
||||
#define VL53L1_DSS_CONTROL__ROI_INTERSECT 0x10
|
||||
|
||||
#define VL53L1_DSS_CONTROL__MODE_DISABLED 0x00
|
||||
#define VL53L1_DSS_CONTROL__MODE_TARGET_RATE 0x01
|
||||
#define VL53L1_DSS_CONTROL__MODE_EFFSPADS 0x02
|
||||
#define VL53L1_DSS_CONTROL__MODE_BLOCKSELECT 0x03
|
||||
|
||||
|
||||
|
||||
#define VL53L1_RANGING_CORE__SPAD_READOUT__STANDARD 0x45
|
||||
#define VL53L1_RANGING_CORE__SPAD_READOUT__RETURN_ARRAY_ONLY 0x05
|
||||
#define VL53L1_RANGING_CORE__SPAD_READOUT__REFERENCE_ARRAY_ONLY 0x55
|
||||
#define VL53L1_RANGING_CORE__SPAD_READOUT__RETURN_SPLIT_ARRAY 0x25
|
||||
#define VL53L1_RANGING_CORE__SPAD_READOUT__CALIB_PULSES 0xF5
|
||||
|
||||
|
||||
#define VL53L1_LASER_SAFETY__KEY_VALUE 0x6C
|
||||
|
||||
|
||||
|
||||
#define VL53L1_RANGE_STATUS__RANGE_STATUS_MASK 0x1F
|
||||
#define VL53L1_RANGE_STATUS__MAX_THRESHOLD_HIT_MASK 0x20
|
||||
#define VL53L1_RANGE_STATUS__MIN_THRESHOLD_HIT_MASK 0x40
|
||||
#define VL53L1_RANGE_STATUS__GPH_ID_RANGE_STATUS_MASK 0x80
|
||||
|
||||
|
||||
|
||||
#define VL53L1_INTERRUPT_STATUS__INT_STATUS_MASK 0x07
|
||||
#define VL53L1_INTERRUPT_STATUS__INT_ERROR_STATUS_MASK 0x18
|
||||
#define VL53L1_INTERRUPT_STATUS__GPH_ID_INT_STATUS_MASK 0x20
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
999
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_register_structs.h
Normal file
999
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_register_structs.h
Normal file
|
|
@ -0,0 +1,999 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_REGISTER_STRUCTS_H_
|
||||
#define _VL53L1_REGISTER_STRUCTS_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_register_map.h"
|
||||
|
||||
#define VL53L1_STATIC_NVM_MANAGED_I2C_INDEX \
|
||||
VL53L1_I2C_SLAVE__DEVICE_ADDRESS
|
||||
#define VL53L1_CUSTOMER_NVM_MANAGED_I2C_INDEX \
|
||||
VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_REF_0
|
||||
#define VL53L1_STATIC_CONFIG_I2C_INDEX \
|
||||
VL53L1_DSS_CONFIG__TARGET_TOTAL_RATE_MCPS
|
||||
#define VL53L1_GENERAL_CONFIG_I2C_INDEX \
|
||||
VL53L1_GPH_CONFIG__STREAM_COUNT_UPDATE_VALUE
|
||||
#define VL53L1_TIMING_CONFIG_I2C_INDEX \
|
||||
VL53L1_MM_CONFIG__TIMEOUT_MACROP_A_HI
|
||||
#define VL53L1_DYNAMIC_CONFIG_I2C_INDEX \
|
||||
VL53L1_SYSTEM__GROUPED_PARAMETER_HOLD_0
|
||||
#define VL53L1_SYSTEM_CONTROL_I2C_INDEX \
|
||||
VL53L1_POWER_MANAGEMENT__GO1_POWER_FORCE
|
||||
#define VL53L1_SYSTEM_RESULTS_I2C_INDEX \
|
||||
VL53L1_RESULT__INTERRUPT_STATUS
|
||||
#define VL53L1_CORE_RESULTS_I2C_INDEX \
|
||||
VL53L1_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0
|
||||
#define VL53L1_DEBUG_RESULTS_I2C_INDEX \
|
||||
VL53L1_PHASECAL_RESULT__REFERENCE_PHASE
|
||||
#define VL53L1_NVM_COPY_DATA_I2C_INDEX \
|
||||
VL53L1_IDENTIFICATION__MODEL_ID
|
||||
#define VL53L1_PREV_SHADOW_SYSTEM_RESULTS_I2C_INDEX \
|
||||
VL53L1_PREV_SHADOW_RESULT__INTERRUPT_STATUS
|
||||
#define VL53L1_PREV_SHADOW_CORE_RESULTS_I2C_INDEX \
|
||||
VL53L1_PREV_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0
|
||||
#define VL53L1_PATCH_DEBUG_I2C_INDEX \
|
||||
VL53L1_RESULT__DEBUG_STATUS
|
||||
#define VL53L1_GPH_GENERAL_CONFIG_I2C_INDEX \
|
||||
VL53L1_GPH__SYSTEM__THRESH_RATE_HIGH
|
||||
#define VL53L1_GPH_STATIC_CONFIG_I2C_INDEX \
|
||||
VL53L1_GPH__DSS_CONFIG__ROI_MODE_CONTROL
|
||||
#define VL53L1_GPH_TIMING_CONFIG_I2C_INDEX \
|
||||
VL53L1_GPH__MM_CONFIG__TIMEOUT_MACROP_A_HI
|
||||
#define VL53L1_FW_INTERNAL_I2C_INDEX \
|
||||
VL53L1_FIRMWARE__INTERNAL_STREAM_COUNT_DIV
|
||||
#define VL53L1_PATCH_RESULTS_I2C_INDEX \
|
||||
VL53L1_DSS_CALC__ROI_CTRL
|
||||
#define VL53L1_SHADOW_SYSTEM_RESULTS_I2C_INDEX \
|
||||
VL53L1_SHADOW_PHASECAL_RESULT__VCSEL_START
|
||||
#define VL53L1_SHADOW_CORE_RESULTS_I2C_INDEX \
|
||||
VL53L1_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0
|
||||
|
||||
#define VL53L1_STATIC_NVM_MANAGED_I2C_SIZE_BYTES 11
|
||||
#define VL53L1_CUSTOMER_NVM_MANAGED_I2C_SIZE_BYTES 23
|
||||
#define VL53L1_STATIC_CONFIG_I2C_SIZE_BYTES 32
|
||||
#define VL53L1_GENERAL_CONFIG_I2C_SIZE_BYTES 22
|
||||
#define VL53L1_TIMING_CONFIG_I2C_SIZE_BYTES 23
|
||||
#define VL53L1_DYNAMIC_CONFIG_I2C_SIZE_BYTES 18
|
||||
#define VL53L1_SYSTEM_CONTROL_I2C_SIZE_BYTES 5
|
||||
#define VL53L1_SYSTEM_RESULTS_I2C_SIZE_BYTES 44
|
||||
#define VL53L1_CORE_RESULTS_I2C_SIZE_BYTES 33
|
||||
#define VL53L1_DEBUG_RESULTS_I2C_SIZE_BYTES 56
|
||||
#define VL53L1_NVM_COPY_DATA_I2C_SIZE_BYTES 49
|
||||
#define VL53L1_PREV_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES 44
|
||||
#define VL53L1_PREV_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES 33
|
||||
#define VL53L1_PATCH_DEBUG_I2C_SIZE_BYTES 2
|
||||
#define VL53L1_GPH_GENERAL_CONFIG_I2C_SIZE_BYTES 5
|
||||
#define VL53L1_GPH_STATIC_CONFIG_I2C_SIZE_BYTES 6
|
||||
#define VL53L1_GPH_TIMING_CONFIG_I2C_SIZE_BYTES 16
|
||||
#define VL53L1_FW_INTERNAL_I2C_SIZE_BYTES 2
|
||||
#define VL53L1_PATCH_RESULTS_I2C_SIZE_BYTES 90
|
||||
#define VL53L1_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES 82
|
||||
#define VL53L1_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES 33
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t i2c_slave__device_address;
|
||||
|
||||
uint8_t ana_config__vhv_ref_sel_vddpix;
|
||||
|
||||
uint8_t ana_config__vhv_ref_sel_vquench;
|
||||
|
||||
uint8_t ana_config__reg_avdd1v2_sel;
|
||||
|
||||
uint8_t ana_config__fast_osc__trim;
|
||||
|
||||
uint16_t osc_measured__fast_osc__frequency;
|
||||
|
||||
uint8_t vhv_config__timeout_macrop_loop_bound;
|
||||
|
||||
uint8_t vhv_config__count_thresh;
|
||||
|
||||
uint8_t vhv_config__offset;
|
||||
|
||||
uint8_t vhv_config__init;
|
||||
|
||||
} VL53L1_static_nvm_managed_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t global_config__spad_enables_ref_0;
|
||||
|
||||
uint8_t global_config__spad_enables_ref_1;
|
||||
|
||||
uint8_t global_config__spad_enables_ref_2;
|
||||
|
||||
uint8_t global_config__spad_enables_ref_3;
|
||||
|
||||
uint8_t global_config__spad_enables_ref_4;
|
||||
|
||||
uint8_t global_config__spad_enables_ref_5;
|
||||
|
||||
uint8_t global_config__ref_en_start_select;
|
||||
|
||||
uint8_t ref_spad_man__num_requested_ref_spads;
|
||||
|
||||
uint8_t ref_spad_man__ref_location;
|
||||
|
||||
uint16_t algo__crosstalk_compensation_plane_offset_kcps;
|
||||
|
||||
int16_t algo__crosstalk_compensation_x_plane_gradient_kcps;
|
||||
|
||||
int16_t algo__crosstalk_compensation_y_plane_gradient_kcps;
|
||||
|
||||
uint16_t ref_spad_char__total_rate_target_mcps;
|
||||
|
||||
int16_t algo__part_to_part_range_offset_mm;
|
||||
|
||||
int16_t mm_config__inner_offset_mm;
|
||||
|
||||
int16_t mm_config__outer_offset_mm;
|
||||
|
||||
} VL53L1_customer_nvm_managed_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint16_t dss_config__target_total_rate_mcps;
|
||||
|
||||
uint8_t debug__ctrl;
|
||||
|
||||
uint8_t test_mode__ctrl;
|
||||
|
||||
uint8_t clk_gating__ctrl;
|
||||
|
||||
uint8_t nvm_bist__ctrl;
|
||||
|
||||
uint8_t nvm_bist__num_nvm_words;
|
||||
|
||||
uint8_t nvm_bist__start_address;
|
||||
|
||||
uint8_t host_if__status;
|
||||
|
||||
uint8_t pad_i2c_hv__config;
|
||||
|
||||
uint8_t pad_i2c_hv__extsup_config;
|
||||
|
||||
uint8_t gpio_hv_pad__ctrl;
|
||||
|
||||
uint8_t gpio_hv_mux__ctrl;
|
||||
|
||||
uint8_t gpio__tio_hv_status;
|
||||
|
||||
uint8_t gpio__fio_hv_status;
|
||||
|
||||
uint8_t ana_config__spad_sel_pswidth;
|
||||
|
||||
uint8_t ana_config__vcsel_pulse_width_offset;
|
||||
|
||||
uint8_t ana_config__fast_osc__config_ctrl;
|
||||
|
||||
uint8_t sigma_estimator__effective_pulse_width_ns;
|
||||
|
||||
uint8_t sigma_estimator__effective_ambient_width_ns;
|
||||
|
||||
uint8_t sigma_estimator__sigma_ref_mm;
|
||||
|
||||
uint8_t algo__crosstalk_compensation_valid_height_mm;
|
||||
|
||||
uint8_t spare_host_config__static_config_spare_0;
|
||||
|
||||
uint8_t spare_host_config__static_config_spare_1;
|
||||
|
||||
uint16_t algo__range_ignore_threshold_mcps;
|
||||
|
||||
uint8_t algo__range_ignore_valid_height_mm;
|
||||
|
||||
uint8_t algo__range_min_clip;
|
||||
|
||||
uint8_t algo__consistency_check__tolerance;
|
||||
|
||||
uint8_t spare_host_config__static_config_spare_2;
|
||||
|
||||
uint8_t sd_config__reset_stages_msb;
|
||||
|
||||
uint8_t sd_config__reset_stages_lsb;
|
||||
|
||||
} VL53L1_static_config_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t gph_config__stream_count_update_value;
|
||||
|
||||
uint8_t global_config__stream_divider;
|
||||
|
||||
uint8_t system__interrupt_config_gpio;
|
||||
|
||||
uint8_t cal_config__vcsel_start;
|
||||
|
||||
uint16_t cal_config__repeat_rate;
|
||||
|
||||
uint8_t global_config__vcsel_width;
|
||||
|
||||
uint8_t phasecal_config__timeout_macrop;
|
||||
|
||||
uint8_t phasecal_config__target;
|
||||
|
||||
uint8_t phasecal_config__override;
|
||||
|
||||
uint8_t dss_config__roi_mode_control;
|
||||
|
||||
uint16_t system__thresh_rate_high;
|
||||
|
||||
uint16_t system__thresh_rate_low;
|
||||
|
||||
uint16_t dss_config__manual_effective_spads_select;
|
||||
|
||||
uint8_t dss_config__manual_block_select;
|
||||
|
||||
uint8_t dss_config__aperture_attenuation;
|
||||
|
||||
uint8_t dss_config__max_spads_limit;
|
||||
|
||||
uint8_t dss_config__min_spads_limit;
|
||||
|
||||
} VL53L1_general_config_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t mm_config__timeout_macrop_a_hi;
|
||||
|
||||
uint8_t mm_config__timeout_macrop_a_lo;
|
||||
|
||||
uint8_t mm_config__timeout_macrop_b_hi;
|
||||
|
||||
uint8_t mm_config__timeout_macrop_b_lo;
|
||||
|
||||
uint8_t range_config__timeout_macrop_a_hi;
|
||||
|
||||
uint8_t range_config__timeout_macrop_a_lo;
|
||||
|
||||
uint8_t range_config__vcsel_period_a;
|
||||
|
||||
uint8_t range_config__timeout_macrop_b_hi;
|
||||
|
||||
uint8_t range_config__timeout_macrop_b_lo;
|
||||
|
||||
uint8_t range_config__vcsel_period_b;
|
||||
|
||||
uint16_t range_config__sigma_thresh;
|
||||
|
||||
uint16_t range_config__min_count_rate_rtn_limit_mcps;
|
||||
|
||||
uint8_t range_config__valid_phase_low;
|
||||
|
||||
uint8_t range_config__valid_phase_high;
|
||||
|
||||
uint32_t system__intermeasurement_period;
|
||||
|
||||
uint8_t system__fractional_enable;
|
||||
|
||||
} VL53L1_timing_config_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t system__grouped_parameter_hold_0;
|
||||
|
||||
uint16_t system__thresh_high;
|
||||
|
||||
uint16_t system__thresh_low;
|
||||
|
||||
uint8_t system__enable_xtalk_per_quadrant;
|
||||
|
||||
uint8_t system__seed_config;
|
||||
|
||||
uint8_t sd_config__woi_sd0;
|
||||
|
||||
uint8_t sd_config__woi_sd1;
|
||||
|
||||
uint8_t sd_config__initial_phase_sd0;
|
||||
|
||||
uint8_t sd_config__initial_phase_sd1;
|
||||
|
||||
uint8_t system__grouped_parameter_hold_1;
|
||||
|
||||
uint8_t sd_config__first_order_select;
|
||||
|
||||
uint8_t sd_config__quantifier;
|
||||
|
||||
uint8_t roi_config__user_roi_centre_spad;
|
||||
|
||||
uint8_t roi_config__user_roi_requested_global_xy_size;
|
||||
|
||||
uint8_t system__sequence_config;
|
||||
|
||||
uint8_t system__grouped_parameter_hold;
|
||||
|
||||
} VL53L1_dynamic_config_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t power_management__go1_power_force;
|
||||
|
||||
uint8_t system__stream_count_ctrl;
|
||||
|
||||
uint8_t firmware__enable;
|
||||
|
||||
uint8_t system__interrupt_clear;
|
||||
|
||||
uint8_t system__mode_start;
|
||||
|
||||
} VL53L1_system_control_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t result__interrupt_status;
|
||||
|
||||
uint8_t result__range_status;
|
||||
|
||||
uint8_t result__report_status;
|
||||
|
||||
uint8_t result__stream_count;
|
||||
|
||||
uint16_t result__dss_actual_effective_spads_sd0;
|
||||
|
||||
uint16_t result__peak_signal_count_rate_mcps_sd0;
|
||||
|
||||
uint16_t result__ambient_count_rate_mcps_sd0;
|
||||
|
||||
uint16_t result__sigma_sd0;
|
||||
|
||||
uint16_t result__phase_sd0;
|
||||
|
||||
uint16_t result__final_crosstalk_corrected_range_mm_sd0;
|
||||
|
||||
uint16_t result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0;
|
||||
|
||||
uint16_t result__mm_inner_actual_effective_spads_sd0;
|
||||
|
||||
uint16_t result__mm_outer_actual_effective_spads_sd0;
|
||||
|
||||
uint16_t result__avg_signal_count_rate_mcps_sd0;
|
||||
|
||||
uint16_t result__dss_actual_effective_spads_sd1;
|
||||
|
||||
uint16_t result__peak_signal_count_rate_mcps_sd1;
|
||||
|
||||
uint16_t result__ambient_count_rate_mcps_sd1;
|
||||
|
||||
uint16_t result__sigma_sd1;
|
||||
|
||||
uint16_t result__phase_sd1;
|
||||
|
||||
uint16_t result__final_crosstalk_corrected_range_mm_sd1;
|
||||
|
||||
uint16_t result__spare_0_sd1;
|
||||
|
||||
uint16_t result__spare_1_sd1;
|
||||
|
||||
uint16_t result__spare_2_sd1;
|
||||
|
||||
uint8_t result__spare_3_sd1;
|
||||
|
||||
uint8_t result__thresh_info;
|
||||
|
||||
} VL53L1_system_results_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t result_core__ambient_window_events_sd0;
|
||||
|
||||
uint32_t result_core__ranging_total_events_sd0;
|
||||
|
||||
int32_t result_core__signal_total_events_sd0;
|
||||
|
||||
uint32_t result_core__total_periods_elapsed_sd0;
|
||||
|
||||
uint32_t result_core__ambient_window_events_sd1;
|
||||
|
||||
uint32_t result_core__ranging_total_events_sd1;
|
||||
|
||||
int32_t result_core__signal_total_events_sd1;
|
||||
|
||||
uint32_t result_core__total_periods_elapsed_sd1;
|
||||
|
||||
uint8_t result_core__spare_0;
|
||||
|
||||
} VL53L1_core_results_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint16_t phasecal_result__reference_phase;
|
||||
|
||||
uint8_t phasecal_result__vcsel_start;
|
||||
|
||||
uint8_t ref_spad_char_result__num_actual_ref_spads;
|
||||
|
||||
uint8_t ref_spad_char_result__ref_location;
|
||||
|
||||
uint8_t vhv_result__coldboot_status;
|
||||
|
||||
uint8_t vhv_result__search_result;
|
||||
|
||||
uint8_t vhv_result__latest_setting;
|
||||
|
||||
uint16_t result__osc_calibrate_val;
|
||||
|
||||
uint8_t ana_config__powerdown_go1;
|
||||
|
||||
uint8_t ana_config__ref_bg_ctrl;
|
||||
|
||||
uint8_t ana_config__regdvdd1v2_ctrl;
|
||||
|
||||
uint8_t ana_config__osc_slow_ctrl;
|
||||
|
||||
uint8_t test_mode__status;
|
||||
|
||||
uint8_t firmware__system_status;
|
||||
|
||||
uint8_t firmware__mode_status;
|
||||
|
||||
uint8_t firmware__secondary_mode_status;
|
||||
|
||||
uint16_t firmware__cal_repeat_rate_counter;
|
||||
|
||||
uint16_t gph__system__thresh_high;
|
||||
|
||||
uint16_t gph__system__thresh_low;
|
||||
|
||||
uint8_t gph__system__enable_xtalk_per_quadrant;
|
||||
|
||||
uint8_t gph__spare_0;
|
||||
|
||||
uint8_t gph__sd_config__woi_sd0;
|
||||
|
||||
uint8_t gph__sd_config__woi_sd1;
|
||||
|
||||
uint8_t gph__sd_config__initial_phase_sd0;
|
||||
|
||||
uint8_t gph__sd_config__initial_phase_sd1;
|
||||
|
||||
uint8_t gph__sd_config__first_order_select;
|
||||
|
||||
uint8_t gph__sd_config__quantifier;
|
||||
|
||||
uint8_t gph__roi_config__user_roi_centre_spad;
|
||||
|
||||
uint8_t gph__roi_config__user_roi_requested_global_xy_size;
|
||||
|
||||
uint8_t gph__system__sequence_config;
|
||||
|
||||
uint8_t gph__gph_id;
|
||||
|
||||
uint8_t system__interrupt_set;
|
||||
|
||||
uint8_t interrupt_manager__enables;
|
||||
|
||||
uint8_t interrupt_manager__clear;
|
||||
|
||||
uint8_t interrupt_manager__status;
|
||||
|
||||
uint8_t mcu_to_host_bank__wr_access_en;
|
||||
|
||||
uint8_t power_management__go1_reset_status;
|
||||
|
||||
uint8_t pad_startup_mode__value_ro;
|
||||
|
||||
uint8_t pad_startup_mode__value_ctrl;
|
||||
|
||||
uint32_t pll_period_us;
|
||||
|
||||
uint32_t interrupt_scheduler__data_out;
|
||||
|
||||
uint8_t nvm_bist__complete;
|
||||
|
||||
uint8_t nvm_bist__status;
|
||||
|
||||
} VL53L1_debug_results_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t identification__model_id;
|
||||
|
||||
uint8_t identification__module_type;
|
||||
|
||||
uint8_t identification__revision_id;
|
||||
|
||||
uint16_t identification__module_id;
|
||||
|
||||
uint8_t ana_config__fast_osc__trim_max;
|
||||
|
||||
uint8_t ana_config__fast_osc__freq_set;
|
||||
|
||||
uint8_t ana_config__vcsel_trim;
|
||||
|
||||
uint8_t ana_config__vcsel_selion;
|
||||
|
||||
uint8_t ana_config__vcsel_selion_max;
|
||||
|
||||
uint8_t protected_laser_safety__lock_bit;
|
||||
|
||||
uint8_t laser_safety__key;
|
||||
|
||||
uint8_t laser_safety__key_ro;
|
||||
|
||||
uint8_t laser_safety__clip;
|
||||
|
||||
uint8_t laser_safety__mult;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_0;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_1;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_2;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_3;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_4;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_5;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_6;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_7;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_8;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_9;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_10;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_11;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_12;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_13;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_14;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_15;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_16;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_17;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_18;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_19;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_20;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_21;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_22;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_23;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_24;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_25;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_26;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_27;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_28;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_29;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_30;
|
||||
|
||||
uint8_t global_config__spad_enables_rtn_31;
|
||||
|
||||
uint8_t roi_config__mode_roi_centre_spad;
|
||||
|
||||
uint8_t roi_config__mode_roi_xy_size;
|
||||
|
||||
} VL53L1_nvm_copy_data_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t prev_shadow_result__interrupt_status;
|
||||
|
||||
uint8_t prev_shadow_result__range_status;
|
||||
|
||||
uint8_t prev_shadow_result__report_status;
|
||||
|
||||
uint8_t prev_shadow_result__stream_count;
|
||||
|
||||
uint16_t prev_shadow_result__dss_actual_effective_spads_sd0;
|
||||
|
||||
uint16_t prev_shadow_result__peak_signal_count_rate_mcps_sd0;
|
||||
|
||||
uint16_t prev_shadow_result__ambient_count_rate_mcps_sd0;
|
||||
|
||||
uint16_t prev_shadow_result__sigma_sd0;
|
||||
|
||||
uint16_t prev_shadow_result__phase_sd0;
|
||||
|
||||
uint16_t prev_shadow_result__final_crosstalk_corrected_range_mm_sd0;
|
||||
|
||||
uint16_t
|
||||
psr__peak_signal_count_rate_crosstalk_corrected_mcps_sd0;
|
||||
|
||||
uint16_t prev_shadow_result__mm_inner_actual_effective_spads_sd0;
|
||||
|
||||
uint16_t prev_shadow_result__mm_outer_actual_effective_spads_sd0;
|
||||
|
||||
uint16_t prev_shadow_result__avg_signal_count_rate_mcps_sd0;
|
||||
|
||||
uint16_t prev_shadow_result__dss_actual_effective_spads_sd1;
|
||||
|
||||
uint16_t prev_shadow_result__peak_signal_count_rate_mcps_sd1;
|
||||
|
||||
uint16_t prev_shadow_result__ambient_count_rate_mcps_sd1;
|
||||
|
||||
uint16_t prev_shadow_result__sigma_sd1;
|
||||
|
||||
uint16_t prev_shadow_result__phase_sd1;
|
||||
|
||||
uint16_t prev_shadow_result__final_crosstalk_corrected_range_mm_sd1;
|
||||
|
||||
uint16_t prev_shadow_result__spare_0_sd1;
|
||||
|
||||
uint16_t prev_shadow_result__spare_1_sd1;
|
||||
|
||||
uint16_t prev_shadow_result__spare_2_sd1;
|
||||
|
||||
uint16_t prev_shadow_result__spare_3_sd1;
|
||||
|
||||
} VL53L1_prev_shadow_system_results_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t prev_shadow_result_core__ambient_window_events_sd0;
|
||||
|
||||
uint32_t prev_shadow_result_core__ranging_total_events_sd0;
|
||||
|
||||
int32_t prev_shadow_result_core__signal_total_events_sd0;
|
||||
|
||||
uint32_t prev_shadow_result_core__total_periods_elapsed_sd0;
|
||||
|
||||
uint32_t prev_shadow_result_core__ambient_window_events_sd1;
|
||||
|
||||
uint32_t prev_shadow_result_core__ranging_total_events_sd1;
|
||||
|
||||
int32_t prev_shadow_result_core__signal_total_events_sd1;
|
||||
|
||||
uint32_t prev_shadow_result_core__total_periods_elapsed_sd1;
|
||||
|
||||
uint8_t prev_shadow_result_core__spare_0;
|
||||
|
||||
} VL53L1_prev_shadow_core_results_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t result__debug_status;
|
||||
|
||||
uint8_t result__debug_stage;
|
||||
|
||||
} VL53L1_patch_debug_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint16_t gph__system__thresh_rate_high;
|
||||
|
||||
uint16_t gph__system__thresh_rate_low;
|
||||
|
||||
uint8_t gph__system__interrupt_config_gpio;
|
||||
|
||||
} VL53L1_gph_general_config_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t gph__dss_config__roi_mode_control;
|
||||
|
||||
uint16_t gph__dss_config__manual_effective_spads_select;
|
||||
|
||||
uint8_t gph__dss_config__manual_block_select;
|
||||
|
||||
uint8_t gph__dss_config__max_spads_limit;
|
||||
|
||||
uint8_t gph__dss_config__min_spads_limit;
|
||||
|
||||
} VL53L1_gph_static_config_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t gph__mm_config__timeout_macrop_a_hi;
|
||||
|
||||
uint8_t gph__mm_config__timeout_macrop_a_lo;
|
||||
|
||||
uint8_t gph__mm_config__timeout_macrop_b_hi;
|
||||
|
||||
uint8_t gph__mm_config__timeout_macrop_b_lo;
|
||||
|
||||
uint8_t gph__range_config__timeout_macrop_a_hi;
|
||||
|
||||
uint8_t gph__range_config__timeout_macrop_a_lo;
|
||||
|
||||
uint8_t gph__range_config__vcsel_period_a;
|
||||
|
||||
uint8_t gph__range_config__vcsel_period_b;
|
||||
|
||||
uint8_t gph__range_config__timeout_macrop_b_hi;
|
||||
|
||||
uint8_t gph__range_config__timeout_macrop_b_lo;
|
||||
|
||||
uint16_t gph__range_config__sigma_thresh;
|
||||
|
||||
uint16_t gph__range_config__min_count_rate_rtn_limit_mcps;
|
||||
|
||||
uint8_t gph__range_config__valid_phase_low;
|
||||
|
||||
uint8_t gph__range_config__valid_phase_high;
|
||||
|
||||
} VL53L1_gph_timing_config_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t firmware__internal_stream_count_div;
|
||||
|
||||
uint8_t firmware__internal_stream_counter_val;
|
||||
|
||||
} VL53L1_fw_internal_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t dss_calc__roi_ctrl;
|
||||
|
||||
uint8_t dss_calc__spare_1;
|
||||
|
||||
uint8_t dss_calc__spare_2;
|
||||
|
||||
uint8_t dss_calc__spare_3;
|
||||
|
||||
uint8_t dss_calc__spare_4;
|
||||
|
||||
uint8_t dss_calc__spare_5;
|
||||
|
||||
uint8_t dss_calc__spare_6;
|
||||
|
||||
uint8_t dss_calc__spare_7;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_0;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_1;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_2;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_3;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_4;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_5;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_6;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_7;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_8;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_9;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_10;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_11;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_12;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_13;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_14;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_15;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_16;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_17;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_18;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_19;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_20;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_21;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_22;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_23;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_24;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_25;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_26;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_27;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_28;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_29;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_30;
|
||||
|
||||
uint8_t dss_calc__user_roi_spad_en_31;
|
||||
|
||||
uint8_t dss_calc__user_roi_0;
|
||||
|
||||
uint8_t dss_calc__user_roi_1;
|
||||
|
||||
uint8_t dss_calc__mode_roi_0;
|
||||
|
||||
uint8_t dss_calc__mode_roi_1;
|
||||
|
||||
uint8_t sigma_estimator_calc__spare_0;
|
||||
|
||||
uint16_t vhv_result__peak_signal_rate_mcps;
|
||||
|
||||
uint32_t vhv_result__signal_total_events_ref;
|
||||
|
||||
uint16_t phasecal_result__phase_output_ref;
|
||||
|
||||
uint16_t dss_result__total_rate_per_spad;
|
||||
|
||||
uint8_t dss_result__enabled_blocks;
|
||||
|
||||
uint16_t dss_result__num_requested_spads;
|
||||
|
||||
uint16_t mm_result__inner_intersection_rate;
|
||||
|
||||
uint16_t mm_result__outer_complement_rate;
|
||||
|
||||
uint16_t mm_result__total_offset;
|
||||
|
||||
uint32_t xtalk_calc__xtalk_for_enabled_spads;
|
||||
|
||||
uint32_t xtalk_result__avg_xtalk_user_roi_kcps;
|
||||
|
||||
uint32_t xtalk_result__avg_xtalk_mm_inner_roi_kcps;
|
||||
|
||||
uint32_t xtalk_result__avg_xtalk_mm_outer_roi_kcps;
|
||||
|
||||
uint32_t range_result__accum_phase;
|
||||
|
||||
uint16_t range_result__offset_corrected_range;
|
||||
|
||||
} VL53L1_patch_results_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t shadow_phasecal_result__vcsel_start;
|
||||
|
||||
uint8_t shadow_result__interrupt_status;
|
||||
|
||||
uint8_t shadow_result__range_status;
|
||||
|
||||
uint8_t shadow_result__report_status;
|
||||
|
||||
uint8_t shadow_result__stream_count;
|
||||
|
||||
uint16_t shadow_result__dss_actual_effective_spads_sd0;
|
||||
|
||||
uint16_t shadow_result__peak_signal_count_rate_mcps_sd0;
|
||||
|
||||
uint16_t shadow_result__ambient_count_rate_mcps_sd0;
|
||||
|
||||
uint16_t shadow_result__sigma_sd0;
|
||||
|
||||
uint16_t shadow_result__phase_sd0;
|
||||
|
||||
uint16_t shadow_result__final_crosstalk_corrected_range_mm_sd0;
|
||||
|
||||
uint16_t
|
||||
shr__peak_signal_count_rate_crosstalk_corrected_mcps_sd0;
|
||||
|
||||
uint16_t shadow_result__mm_inner_actual_effective_spads_sd0;
|
||||
|
||||
uint16_t shadow_result__mm_outer_actual_effective_spads_sd0;
|
||||
|
||||
uint16_t shadow_result__avg_signal_count_rate_mcps_sd0;
|
||||
|
||||
uint16_t shadow_result__dss_actual_effective_spads_sd1;
|
||||
|
||||
uint16_t shadow_result__peak_signal_count_rate_mcps_sd1;
|
||||
|
||||
uint16_t shadow_result__ambient_count_rate_mcps_sd1;
|
||||
|
||||
uint16_t shadow_result__sigma_sd1;
|
||||
|
||||
uint16_t shadow_result__phase_sd1;
|
||||
|
||||
uint16_t shadow_result__final_crosstalk_corrected_range_mm_sd1;
|
||||
|
||||
uint16_t shadow_result__spare_0_sd1;
|
||||
|
||||
uint16_t shadow_result__spare_1_sd1;
|
||||
|
||||
uint16_t shadow_result__spare_2_sd1;
|
||||
|
||||
uint8_t shadow_result__spare_3_sd1;
|
||||
|
||||
uint8_t shadow_result__thresh_info;
|
||||
|
||||
uint8_t shadow_phasecal_result__reference_phase_hi;
|
||||
|
||||
uint8_t shadow_phasecal_result__reference_phase_lo;
|
||||
|
||||
} VL53L1_shadow_system_results_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t shadow_result_core__ambient_window_events_sd0;
|
||||
|
||||
uint32_t shadow_result_core__ranging_total_events_sd0;
|
||||
|
||||
int32_t shadow_result_core__signal_total_events_sd0;
|
||||
|
||||
uint32_t shadow_result_core__total_periods_elapsed_sd0;
|
||||
|
||||
uint32_t shadow_result_core__ambient_window_events_sd1;
|
||||
|
||||
uint32_t shadow_result_core__ranging_total_events_sd1;
|
||||
|
||||
int32_t shadow_result_core__signal_total_events_sd1;
|
||||
|
||||
uint32_t shadow_result_core__total_periods_elapsed_sd1;
|
||||
|
||||
uint8_t shadow_result_core__spare_0;
|
||||
|
||||
} VL53L1_shadow_core_results_t;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
37
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_silicon_core.h
Normal file
37
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_silicon_core.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_SILICON_CORE_H_
|
||||
#define _VL53L1_SILICON_CORE_H_
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_is_firmware_ready_silicon(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pready);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,395 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#define VL53L1_TUNINGPARM_VERSION_DEFAULT \
|
||||
((uint16_t) 32)
|
||||
#define VL53L1_TUNINGPARM_KEY_TABLE_VERSION_DEFAULT \
|
||||
((uint16_t) 14)
|
||||
#define VL53L1_TUNINGPARM_LLD_VERSION_DEFAULT \
|
||||
((uint16_t) 12180)
|
||||
#define VL53L1_TUNINGPARM_HIST_ALGO_SELECT_DEFAULT \
|
||||
((uint8_t) 4)
|
||||
#define VL53L1_TUNINGPARM_HIST_TARGET_ORDER_DEFAULT \
|
||||
((uint8_t) 1)
|
||||
#define VL53L1_TUNINGPARM_HIST_FILTER_WOI_0_DEFAULT \
|
||||
((uint8_t) 1)
|
||||
#define VL53L1_TUNINGPARM_HIST_FILTER_WOI_1_DEFAULT \
|
||||
((uint8_t) 2)
|
||||
#define VL53L1_TUNINGPARM_HIST_AMB_EST_METHOD_DEFAULT \
|
||||
((uint8_t) 1)
|
||||
#define VL53L1_TUNINGPARM_HIST_AMB_THRESH_SIGMA_0_DEFAULT \
|
||||
((uint8_t) 80)
|
||||
#define VL53L1_TUNINGPARM_HIST_AMB_THRESH_SIGMA_1_DEFAULT \
|
||||
((uint8_t) 100)
|
||||
#define VL53L1_TUNINGPARM_HIST_MIN_AMB_THRESH_EVENTS_DEFAULT \
|
||||
((int32_t) 16)
|
||||
#define VL53L1_TUNINGPARM_HIST_AMB_EVENTS_SCALER_DEFAULT \
|
||||
((uint16_t) 4157)
|
||||
#define VL53L1_TUNINGPARM_HIST_NOISE_THRESHOLD_DEFAULT \
|
||||
((uint16_t) 50)
|
||||
#define VL53L1_TUNINGPARM_HIST_SIGNAL_TOTAL_EVENTS_LIMIT_DEFAULT \
|
||||
((int32_t) 100)
|
||||
#define VL53L1_TUNINGPARM_HIST_SIGMA_EST_REF_MM_DEFAULT \
|
||||
((uint8_t) 1)
|
||||
#define VL53L1_TUNINGPARM_HIST_SIGMA_THRESH_MM_DEFAULT \
|
||||
((uint16_t) 180)
|
||||
#define VL53L1_TUNINGPARM_HIST_GAIN_FACTOR_DEFAULT \
|
||||
((uint16_t) 1987)
|
||||
#define VL53L1_TUNINGPARM_CONSISTENCY_HIST_PHASE_TOLERANCE_DEFAULT \
|
||||
((uint8_t) 8)
|
||||
#define VL53L1_TUNINGPARM_CONSISTENCY_HIST_MIN_MAX_TOLERANCE_MM_DEFAULT \
|
||||
((uint16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_CONSISTENCY_HIST_EVENT_SIGMA_DEFAULT \
|
||||
((uint8_t) 0)
|
||||
#define VL53L1_TUNINGPARM_CONSISTENCY_HIST_EVENT_SIGMA_MIN_SPAD_LIMIT_DEFAULT \
|
||||
((uint16_t) 2048)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_HISTO_LONG_RANGE_DEFAULT \
|
||||
((uint8_t) 9)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_HISTO_MED_RANGE_DEFAULT \
|
||||
((uint8_t) 5)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_HISTO_SHORT_RANGE_DEFAULT \
|
||||
((uint8_t) 3)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_HISTO_LONG_RANGE_DEFAULT \
|
||||
((uint8_t) 6)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_HISTO_MED_RANGE_DEFAULT \
|
||||
((uint8_t) 6)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_HISTO_SHORT_RANGE_DEFAULT \
|
||||
((uint8_t) 6)
|
||||
#define VL53L1_TUNINGPARM_XTALK_DETECT_MIN_VALID_RANGE_MM_DEFAULT \
|
||||
((int16_t) -50)
|
||||
#define VL53L1_TUNINGPARM_XTALK_DETECT_MAX_VALID_RANGE_MM_DEFAULT \
|
||||
((int16_t) 50)
|
||||
#define VL53L1_TUNINGPARM_XTALK_DETECT_MAX_SIGMA_MM_DEFAULT \
|
||||
((uint16_t) 140)
|
||||
#define VL53L1_TUNINGPARM_XTALK_DETECT_MIN_MAX_TOLERANCE_DEFAULT \
|
||||
((uint16_t) 50)
|
||||
#define VL53L1_TUNINGPARM_XTALK_DETECT_MAX_VALID_RATE_KCPS_DEFAULT \
|
||||
((uint16_t) 400)
|
||||
#define VL53L1_TUNINGPARM_XTALK_DETECT_EVENT_SIGMA_DEFAULT \
|
||||
((uint8_t) 80)
|
||||
#define VL53L1_TUNINGPARM_HIST_XTALK_MARGIN_KCPS_DEFAULT \
|
||||
((int16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_CONSISTENCY_LITE_PHASE_TOLERANCE_DEFAULT \
|
||||
((uint8_t) 2)
|
||||
#define VL53L1_TUNINGPARM_PHASECAL_TARGET_DEFAULT \
|
||||
((uint8_t) 33)
|
||||
#define VL53L1_TUNINGPARM_LITE_CAL_REPEAT_RATE_DEFAULT \
|
||||
((uint16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_LITE_RANGING_GAIN_FACTOR_DEFAULT \
|
||||
((uint16_t) 2011)
|
||||
#define VL53L1_TUNINGPARM_LITE_MIN_CLIP_MM_DEFAULT \
|
||||
((uint8_t) 0)
|
||||
#define VL53L1_TUNINGPARM_LITE_LONG_SIGMA_THRESH_MM_DEFAULT \
|
||||
((uint16_t) 60)
|
||||
#define VL53L1_TUNINGPARM_LITE_MED_SIGMA_THRESH_MM_DEFAULT \
|
||||
((uint16_t) 60)
|
||||
#define VL53L1_TUNINGPARM_LITE_SHORT_SIGMA_THRESH_MM_DEFAULT \
|
||||
((uint16_t) 60)
|
||||
#define VL53L1_TUNINGPARM_LITE_LONG_MIN_COUNT_RATE_RTN_MCPS_DEFAULT \
|
||||
((uint16_t) 128)
|
||||
#define VL53L1_TUNINGPARM_LITE_MED_MIN_COUNT_RATE_RTN_MCPS_DEFAULT \
|
||||
((uint16_t) 128)
|
||||
#define VL53L1_TUNINGPARM_LITE_SHORT_MIN_COUNT_RATE_RTN_MCPS_DEFAULT \
|
||||
((uint16_t) 128)
|
||||
#define VL53L1_TUNINGPARM_LITE_SIGMA_EST_PULSE_WIDTH_DEFAULT \
|
||||
((uint8_t) 8)
|
||||
#define VL53L1_TUNINGPARM_LITE_SIGMA_EST_AMB_WIDTH_NS_DEFAULT \
|
||||
((uint8_t) 16)
|
||||
#define VL53L1_TUNINGPARM_LITE_SIGMA_REF_MM_DEFAULT \
|
||||
((uint8_t) 1)
|
||||
#define VL53L1_TUNINGPARM_LITE_RIT_MULT_DEFAULT \
|
||||
((uint8_t) 64)
|
||||
#define VL53L1_TUNINGPARM_LITE_SEED_CONFIG_DEFAULT \
|
||||
((uint8_t) 2)
|
||||
#define VL53L1_TUNINGPARM_LITE_QUANTIFIER_DEFAULT \
|
||||
((uint8_t) 2)
|
||||
#define VL53L1_TUNINGPARM_LITE_FIRST_ORDER_SELECT_DEFAULT \
|
||||
((uint8_t) 0)
|
||||
#define VL53L1_TUNINGPARM_LITE_XTALK_MARGIN_KCPS_DEFAULT \
|
||||
((int16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_LONG_RANGE_DEFAULT \
|
||||
((uint8_t) 14)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_MED_RANGE_DEFAULT \
|
||||
((uint8_t) 10)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_SHORT_RANGE_DEFAULT \
|
||||
((uint8_t) 6)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_LONG_RANGE_DEFAULT \
|
||||
((uint8_t) 14)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_MED_RANGE_DEFAULT \
|
||||
((uint8_t) 10)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_SHORT_RANGE_DEFAULT \
|
||||
((uint8_t) 6)
|
||||
#define VL53L1_TUNINGPARM_TIMED_SEED_CONFIG_DEFAULT \
|
||||
((uint8_t) 1)
|
||||
#define VL53L1_TUNINGPARM_DMAX_CFG_SIGNAL_THRESH_SIGMA_DEFAULT \
|
||||
((uint8_t) 32)
|
||||
#define VL53L1_TUNINGPARM_DMAX_CFG_REFLECTANCE_ARRAY_0_DEFAULT \
|
||||
((uint16_t) 15)
|
||||
#define VL53L1_TUNINGPARM_DMAX_CFG_REFLECTANCE_ARRAY_1_DEFAULT \
|
||||
((uint16_t) 52)
|
||||
#define VL53L1_TUNINGPARM_DMAX_CFG_REFLECTANCE_ARRAY_2_DEFAULT \
|
||||
((uint16_t) 200)
|
||||
#define VL53L1_TUNINGPARM_DMAX_CFG_REFLECTANCE_ARRAY_3_DEFAULT \
|
||||
((uint16_t) 364)
|
||||
#define VL53L1_TUNINGPARM_DMAX_CFG_REFLECTANCE_ARRAY_4_DEFAULT \
|
||||
((uint16_t) 400)
|
||||
#define VL53L1_TUNINGPARM_VHV_LOOPBOUND_DEFAULT \
|
||||
((uint8_t) 129)
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_DEVICE_TEST_MODE_DEFAULT \
|
||||
((uint8_t) 8)
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_VCSEL_PERIOD_DEFAULT \
|
||||
((uint8_t) 11)
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_PHASECAL_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 1000)
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_TARGET_COUNT_RATE_MCPS_DEFAULT \
|
||||
((uint16_t) 2560)
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_MIN_COUNTRATE_LIMIT_MCPS_DEFAULT \
|
||||
((uint16_t) 1280)
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_MAX_COUNTRATE_LIMIT_MCPS_DEFAULT \
|
||||
((uint16_t) 5120)
|
||||
#define VL53L1_TUNINGPARM_XTALK_EXTRACT_NUM_OF_SAMPLES_DEFAULT \
|
||||
((uint8_t) 7)
|
||||
#define VL53L1_TUNINGPARM_XTALK_EXTRACT_MIN_FILTER_THRESH_MM_DEFAULT \
|
||||
((int16_t) -70)
|
||||
#define VL53L1_TUNINGPARM_XTALK_EXTRACT_MAX_FILTER_THRESH_MM_DEFAULT \
|
||||
((int16_t) 70)
|
||||
#define VL53L1_TUNINGPARM_XTALK_EXTRACT_DSS_RATE_MCPS_DEFAULT \
|
||||
((uint16_t) 5120)
|
||||
#define VL53L1_TUNINGPARM_XTALK_EXTRACT_PHASECAL_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 15000)
|
||||
#define VL53L1_TUNINGPARM_XTALK_EXTRACT_MAX_VALID_RATE_KCPS_DEFAULT \
|
||||
((uint16_t) 640)
|
||||
#define VL53L1_TUNINGPARM_XTALK_EXTRACT_SIGMA_THRESHOLD_MM_DEFAULT \
|
||||
((uint16_t) 140)
|
||||
#define VL53L1_TUNINGPARM_XTALK_EXTRACT_DSS_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 2000)
|
||||
#define VL53L1_TUNINGPARM_XTALK_EXTRACT_BIN_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 10000)
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_DSS_RATE_MCPS_DEFAULT \
|
||||
((uint16_t) 2560)
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_PHASECAL_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 15000)
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_MM_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 13000)
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_RANGE_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 13000)
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_PRE_SAMPLES_DEFAULT \
|
||||
((uint8_t) 8)
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_MM1_SAMPLES_DEFAULT \
|
||||
((uint8_t) 40)
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_MM2_SAMPLES_DEFAULT \
|
||||
((uint8_t) 9)
|
||||
#define VL53L1_TUNINGPARM_ZONE_CAL_DSS_RATE_MCPS_DEFAULT \
|
||||
((uint16_t) 5120)
|
||||
#define VL53L1_TUNINGPARM_ZONE_CAL_PHASECAL_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 15000)
|
||||
#define VL53L1_TUNINGPARM_ZONE_CAL_DSS_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 2000)
|
||||
#define VL53L1_TUNINGPARM_ZONE_CAL_PHASECAL_NUM_SAMPLES_DEFAULT \
|
||||
((uint16_t) 16)
|
||||
#define VL53L1_TUNINGPARM_ZONE_CAL_RANGE_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 1000)
|
||||
#define VL53L1_TUNINGPARM_ZONE_CAL_ZONE_NUM_SAMPLES_DEFAULT \
|
||||
((uint16_t) 8)
|
||||
#define VL53L1_TUNINGPARM_SPADMAP_VCSEL_PERIOD_DEFAULT \
|
||||
((uint8_t) 18)
|
||||
#define VL53L1_TUNINGPARM_SPADMAP_VCSEL_START_DEFAULT \
|
||||
((uint8_t) 15)
|
||||
#define VL53L1_TUNINGPARM_SPADMAP_RATE_LIMIT_MCPS_DEFAULT \
|
||||
((uint16_t) 12)
|
||||
#define VL53L1_TUNINGPARM_LITE_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS_DEFAULT \
|
||||
((uint16_t) 2560)
|
||||
#define VL53L1_TUNINGPARM_RANGING_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS_DEFAULT \
|
||||
((uint16_t) 5120)
|
||||
#define VL53L1_TUNINGPARM_MZ_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS_DEFAULT \
|
||||
((uint16_t) 5120)
|
||||
#define VL53L1_TUNINGPARM_TIMED_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS_DEFAULT \
|
||||
((uint16_t) 2560)
|
||||
#define VL53L1_TUNINGPARM_LITE_PHASECAL_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 1000)
|
||||
#define VL53L1_TUNINGPARM_RANGING_LONG_PHASECAL_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 15000)
|
||||
#define VL53L1_TUNINGPARM_RANGING_MED_PHASECAL_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 9000)
|
||||
#define VL53L1_TUNINGPARM_RANGING_SHORT_PHASECAL_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 6000)
|
||||
#define VL53L1_TUNINGPARM_MZ_LONG_PHASECAL_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 15000)
|
||||
#define VL53L1_TUNINGPARM_MZ_MED_PHASECAL_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 9000)
|
||||
#define VL53L1_TUNINGPARM_MZ_SHORT_PHASECAL_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 6000)
|
||||
#define VL53L1_TUNINGPARM_TIMED_PHASECAL_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 1000)
|
||||
#define VL53L1_TUNINGPARM_LITE_MM_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 2000)
|
||||
#define VL53L1_TUNINGPARM_RANGING_MM_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 2000)
|
||||
#define VL53L1_TUNINGPARM_MZ_MM_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 2000)
|
||||
#define VL53L1_TUNINGPARM_TIMED_MM_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 2000)
|
||||
#define VL53L1_TUNINGPARM_LITE_RANGE_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 63000)
|
||||
#define VL53L1_TUNINGPARM_RANGING_RANGE_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 2500)
|
||||
#define VL53L1_TUNINGPARM_MZ_RANGE_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 2500)
|
||||
#define VL53L1_TUNINGPARM_TIMED_RANGE_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 13000)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_SMUDGE_MARGIN_DEFAULT \
|
||||
((uint16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_NOISE_MARGIN_DEFAULT \
|
||||
((uint32_t) 100)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_XTALK_OFFSET_LIMIT_DEFAULT \
|
||||
((uint32_t) 0)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_XTALK_OFFSET_LIMIT_HI_DEFAULT \
|
||||
((uint8_t) 0)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_SAMPLE_LIMIT_DEFAULT \
|
||||
((uint32_t) 200)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_SINGLE_XTALK_DELTA_DEFAULT \
|
||||
((uint32_t) 2048)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_AVERAGED_XTALK_DELTA_DEFAULT \
|
||||
((uint32_t) 308)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_CLIP_LIMIT_DEFAULT \
|
||||
((uint32_t) 10240)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_SCALER_CALC_METHOD_DEFAULT \
|
||||
((uint8_t) 0)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_XGRADIENT_SCALER_DEFAULT \
|
||||
((int16_t) 256)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_YGRADIENT_SCALER_DEFAULT \
|
||||
((int16_t) 256)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_USER_SCALER_SET_DEFAULT \
|
||||
((uint8_t) 0)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_SMUDGE_COR_SINGLE_APPLY_DEFAULT \
|
||||
((uint8_t) 0)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_XTALK_AMB_THRESHOLD_DEFAULT \
|
||||
((uint32_t) 128)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_NODETECT_AMB_THRESHOLD_KCPS_DEFAULT \
|
||||
((uint32_t) 57671680)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_NODETECT_SAMPLE_LIMIT_DEFAULT \
|
||||
((uint32_t) 40)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_NODETECT_XTALK_OFFSET_KCPS_DEFAULT \
|
||||
((uint32_t) 410)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_NODETECT_MIN_RANGE_MM_DEFAULT \
|
||||
((uint16_t) 900)
|
||||
#define VL53L1_TUNINGPARM_LOWPOWERAUTO_VHV_LOOP_BOUND_DEFAULT \
|
||||
((uint8_t) 3)
|
||||
#define VL53L1_TUNINGPARM_LOWPOWERAUTO_MM_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 1)
|
||||
#define VL53L1_TUNINGPARM_LOWPOWERAUTO_RANGE_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 8000)
|
||||
#define VL53L1_TUNINGPARM_VERY_SHORT_DSS_RATE_MCPS_DEFAULT \
|
||||
((uint16_t) 10240)
|
||||
#define VL53L1_TUNINGPARM_PHASECAL_PATCH_POWER_DEFAULT \
|
||||
((uint32_t) 0)
|
||||
#define VL53L1_TUNINGPARM_HIST_MERGE_DEFAULT \
|
||||
((uint8_t) 1)
|
||||
#define VL53L1_TUNINGPARM_RESET_MERGE_THRESHOLD_DEFAULT \
|
||||
((uint32_t) 15000)
|
||||
#define VL53L1_TUNINGPARM_HIST_MERGE_MAX_SIZE_DEFAULT \
|
||||
((uint8_t) 6)
|
||||
#define VL53L1_TUNINGPARM_DYNXTALK_MAX_SMUDGE_FACTOR_DEFAULT \
|
||||
((uint32_t) 2000)
|
||||
#define VL53L1_TUNINGPARM_UWR_ENABLE_DEFAULT \
|
||||
((uint8_t) 1)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_ZONE_1_MIN_DEFAULT \
|
||||
((int16_t) 2000)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_ZONE_1_MAX_DEFAULT \
|
||||
((int16_t) 2750)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_ZONE_2_MIN_DEFAULT \
|
||||
((int16_t) 250)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_ZONE_2_MAX_DEFAULT \
|
||||
((int16_t) 1000)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_ZONE_3_MIN_DEFAULT \
|
||||
((int16_t) 1250)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_ZONE_3_MAX_DEFAULT \
|
||||
((int16_t) 1750)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_ZONE_4_MIN_DEFAULT \
|
||||
((int16_t) 1250)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_ZONE_4_MAX_DEFAULT \
|
||||
((int16_t) 1750)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_ZONE_5_MIN_DEFAULT \
|
||||
((int16_t) -200)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_ZONE_5_MAX_DEFAULT \
|
||||
((int16_t) 200)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_ZONE_6_MIN_DEFAULT \
|
||||
((int16_t) 250)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_ZONE_6_MAX_DEFAULT \
|
||||
((int16_t) 1250)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_CORRECTION_ZONE_1_RANGEA_DEFAULT \
|
||||
((int16_t) 2300)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_CORRECTION_ZONE_1_RANGEB_DEFAULT \
|
||||
((int16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_CORRECTION_ZONE_2_RANGEA_DEFAULT \
|
||||
((int16_t) 2300)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_CORRECTION_ZONE_2_RANGEB_DEFAULT \
|
||||
((int16_t) 3050)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_CORRECTION_ZONE_3_RANGEA_DEFAULT \
|
||||
((int16_t) 4600)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_CORRECTION_ZONE_3_RANGEB_DEFAULT \
|
||||
((int16_t) 3050)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_CORRECTION_ZONE_4_RANGEA_DEFAULT \
|
||||
((int16_t) 4600)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_CORRECTION_ZONE_4_RANGEB_DEFAULT \
|
||||
((int16_t) 6200)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_CORRECTION_ZONE_5_RANGEA_DEFAULT \
|
||||
((int16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_CORRECTION_ZONE_5_RANGEB_DEFAULT \
|
||||
((int16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_CORRECTION_ZONE_6_RANGEA_DEFAULT \
|
||||
((int16_t) 6960)
|
||||
#define VL53L1_TUNINGPARM_UWR_MEDIUM_CORRECTION_ZONE_6_RANGEB_DEFAULT \
|
||||
((int16_t) 6190)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_ZONE_1_MIN_DEFAULT \
|
||||
((int16_t) 250)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_ZONE_1_MAX_DEFAULT \
|
||||
((int16_t) 1250)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_ZONE_2_MIN_DEFAULT \
|
||||
((int16_t) 3250)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_ZONE_2_MAX_DEFAULT \
|
||||
((int16_t) 4500)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_ZONE_3_MIN_DEFAULT \
|
||||
((int16_t) -200)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_ZONE_3_MAX_DEFAULT \
|
||||
((int16_t) 200)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_ZONE_4_MIN_DEFAULT \
|
||||
((int16_t) 2850)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_ZONE_4_MAX_DEFAULT \
|
||||
((int16_t) 3300)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_ZONE_5_MIN_DEFAULT \
|
||||
((int16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_ZONE_5_MAX_DEFAULT \
|
||||
((int16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_CORRECTION_ZONE_1_RANGEA_DEFAULT \
|
||||
((int16_t) 3850)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_CORRECTION_ZONE_1_RANGEB_DEFAULT \
|
||||
((int16_t) 4600)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_CORRECTION_ZONE_2_RANGEA_DEFAULT \
|
||||
((int16_t) 3850)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_CORRECTION_ZONE_2_RANGEB_DEFAULT \
|
||||
((int16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_CORRECTION_ZONE_3_RANGEA_DEFAULT \
|
||||
((int16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_CORRECTION_ZONE_3_RANGEB_DEFAULT \
|
||||
((int16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_CORRECTION_ZONE_4_RANGEA_DEFAULT \
|
||||
((int16_t) 7700)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_CORRECTION_ZONE_4_RANGEB_DEFAULT \
|
||||
((int16_t) 4640)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_CORRECTION_ZONE_5_RANGEA_DEFAULT \
|
||||
((int16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_UWR_LONG_CORRECTION_ZONE_5_RANGEB_DEFAULT \
|
||||
((int16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_MIN_SIGNAL_SECONDARY_TARGETS_DEFAULT \
|
||||
((uint32_t) 0)
|
||||
|
||||
100
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_wait.h
Normal file
100
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_wait.h
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_WAIT_H_
|
||||
#define _VL53L1_WAIT_H_
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_wait_for_boot_completion(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_wait_for_firmware_ready(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_wait_for_range_completion(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_wait_for_test_completion(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_is_boot_complete(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pready);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_is_firmware_ready(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pready);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_is_new_data_ready(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pready);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_poll_for_boot_completion(
|
||||
VL53L1_DEV Dev,
|
||||
uint32_t timeout_ms);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_poll_for_firmware_ready(
|
||||
VL53L1_DEV Dev,
|
||||
uint32_t timeout_ms);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_poll_for_range_completion(
|
||||
VL53L1_DEV Dev,
|
||||
uint32_t timeout_ms);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
55
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_zone_presets.h
Normal file
55
drivers/input/misc/vl53L1_14_1_2/inc/vl53l1_zone_presets.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_ZONE_PRESETS_H_
|
||||
#define _VL53L1_ZONE_PRESETS_H_
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_init_zone_config_structure(
|
||||
uint8_t x_off,
|
||||
uint8_t x_inc,
|
||||
uint8_t x_zones,
|
||||
uint8_t y_off,
|
||||
uint8_t y_inc,
|
||||
uint8_t y_zones,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
VL53L1_zone_config_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_zone_preset_xtalk_planar(
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_zone_config_t *pzone_cfg);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_init_zone_config_histogram_bins(
|
||||
VL53L1_zone_config_t *pdata);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
336
drivers/input/misc/vl53L1_14_1_2/ipp/ipp_linux.c
Normal file
336
drivers/input/misc/vl53L1_14_1_2/ipp/ipp_linux.c
Normal file
|
|
@ -0,0 +1,336 @@
|
|||
|
||||
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ipp_linux.c kernel side implementation of vl53l1 protected processing
|
||||
*
|
||||
* @date Sep 1, 2016
|
||||
* @author : imaging
|
||||
*
|
||||
* @ingroup ipp_dev
|
||||
*/
|
||||
|
||||
#include "stmvl53l1.h"
|
||||
|
||||
#define IPP_ERR_CODE (VL53L1_ERROR_PLATFORM_SPECIFIC_START-1)
|
||||
|
||||
static int stmvl53l1_ipp_do_wrapper(struct stmvl53l1_data *data,
|
||||
struct ipp_work_t *pin, struct ipp_work_t *pout, int payload_out)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (data->ipp.buzy) {
|
||||
vl53l1_errmsg("try exec new ipp but still buzy on previous");
|
||||
/* TODO shall we discard it and push new ? */
|
||||
rc = IPP_ERR_CODE;
|
||||
goto done;
|
||||
}
|
||||
WARN_ON(pin->payload > IPP_WORK_MAX_PAYLOAD);
|
||||
stmvl531_ipp_tim_start(data);
|
||||
rc = stmvl53l1_ipp_do(data, pin, pout);
|
||||
if (rc != 0) {
|
||||
vl53l1_errmsg("stmvl53l1_ipp_do err %d\n", rc);
|
||||
rc = IPP_ERR_CODE;
|
||||
goto done;
|
||||
}
|
||||
vl53l1_dbgmsg("ipp ok \n");
|
||||
/* check what we got back if valid answer error etc */
|
||||
if (pout->status) {
|
||||
vl53l1_errmsg("ipp error status %d from user", pout->status);
|
||||
if (pout->status >= stmvl53l1_ipp_status_proc_code)
|
||||
rc = pout->status & (stmvl53l1_ipp_status_proc_code-1);
|
||||
else
|
||||
rc = IPP_ERR_CODE;
|
||||
goto done;
|
||||
}
|
||||
WARN_ON(pout->payload > IPP_WORK_MAX_PAYLOAD);
|
||||
if (pout->payload != payload_out) {
|
||||
/* bad formated answer */
|
||||
vl53l1_errmsg("bad payload %d != %d in ipp work back",
|
||||
pout->payload, payload_out);
|
||||
rc = IPP_ERR_CODE;
|
||||
goto done;
|
||||
}
|
||||
stmvl531_ipp_tim_stop(data);
|
||||
stmvl531_ipp_stat(data, "ipp #%5x to=%3d fm=%3d in %5ld us",
|
||||
pin->xfer_id, pin->payload,
|
||||
pout->payload,
|
||||
stmvl531_ipp_time(data));
|
||||
|
||||
rc = 0;
|
||||
done:
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @file vl53l1_platform_ipp.h
|
||||
*
|
||||
* @brief EwokPlus25 IPP Wrapper Functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief IPP Wrapper call for histogram post processing
|
||||
*
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[in] pdmax_cal : DMAX calibration data
|
||||
* @param[in] pdmax_cfg : DMAX configuration data
|
||||
* @param[in] ppost_cfg : VL53L1_hist_post_process_config_t
|
||||
* @param[in] pbins : Input histogram raw bin data
|
||||
* @param[in] pxtalk : Cross talk histogram data
|
||||
* @param[in] pArea1 : Extern. allocated to save stack
|
||||
* @param[in] pArea1 : Extern. allocated to save stack
|
||||
* @param[out] presults : Output VL53L1_range_results_t
|
||||
* structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
VL53L1_Error VL53L1_ipp_hist_process_data(
|
||||
VL53L1_DEV dev,
|
||||
VL53L1_dmax_calibration_data_t *pdmax_cal,
|
||||
VL53L1_hist_gen3_dmax_config_t *pdmax_cfg,
|
||||
VL53L1_hist_post_process_config_t *ppost_cfg,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_xtalk_histogram_data_t *pxtalk,
|
||||
uint8_t *pArea1,
|
||||
uint8_t *pArea2,
|
||||
uint8_t *phisto_merge_nb,
|
||||
VL53L1_range_results_t *presults)
|
||||
{
|
||||
struct stmvl53l1_data *data = (struct stmvl53l1_data *)
|
||||
container_of(dev, struct stmvl53l1_data, stdev);
|
||||
struct ipp_work_t *pout = &data->ipp.work_out;
|
||||
struct ipp_work_t *pin = &data->ipp.work;
|
||||
int rc;
|
||||
VL53L1_range_results_t *presults_ipp;
|
||||
|
||||
IPP_SERIALIZE_VAR;
|
||||
|
||||
/* These external workspace input params are useless with IPP managed in
|
||||
* the daemon because the histogram processing function is actually
|
||||
* allocating its data in USER stack within the daemon not the kernel one
|
||||
*/
|
||||
(void)pArea1;
|
||||
(void)pArea2;
|
||||
|
||||
/* setup pin */
|
||||
IPP_SERIALIZE_START(pin->data, 6);
|
||||
IPP_SET_ARG_PTR(pin->data, 0, pdmax_cal);
|
||||
IPP_SET_ARG_PTR(pin->data, 1, pdmax_cfg);
|
||||
IPP_SET_ARG_PTR(pin->data, 2, ppost_cfg);
|
||||
IPP_SET_ARG_PTR(pin->data, 3, pbins);
|
||||
IPP_SET_ARG_PTR(pin->data, 4, pxtalk);
|
||||
IPP_SET_ARG_PTR(pin->data, 5, phisto_merge_nb);
|
||||
pin->payload = IPP_SERIALIZE_PAYLAOD();
|
||||
pin->process_no = stmvl53l1_ipp_cal_hist;
|
||||
|
||||
/* setup pout */
|
||||
IPP_SERIALIZE_START(pout->data, 1);
|
||||
IPP_OUT_ARG_PTR(pout->data, 0, presults_ipp);
|
||||
|
||||
/* do ipp */
|
||||
rc = stmvl53l1_ipp_do_wrapper(data, pin, pout, IPP_SERIALIZE_PAYLAOD());
|
||||
if (rc)
|
||||
goto done;
|
||||
|
||||
/* copy output */
|
||||
memcpy(presults, presults_ipp, sizeof(*presults));
|
||||
|
||||
rc = 0;
|
||||
done:
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief IPP Wrapper call for histogram ambient dmax calc
|
||||
*
|
||||
* The target reflectance in percent for the DMAX calculation
|
||||
* is set by target_reflectance input
|
||||
*
|
||||
* The fixed point format is 7.2
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[in] target_reflectance : target reflectance to report ambient DMAX
|
||||
* Percentage in 7.2 fixed point format
|
||||
* @param[in] pdmax_cal : DMAX calibration data
|
||||
* @param[in] pdmax_cfg : DMAX configuration data
|
||||
* @param[in] pbins : Input histogram raw bin data
|
||||
* @param[out] pambient_dmax_mm : Output ambient DMAX distance in [mm]
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
VL53L1_Error VL53L1_ipp_hist_ambient_dmax(
|
||||
VL53L1_DEV dev,
|
||||
uint16_t target_reflectance,
|
||||
VL53L1_dmax_calibration_data_t *pdmax_cal,
|
||||
VL53L1_hist_gen3_dmax_config_t *pdmax_cfg,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
int16_t *pambient_dmax_mm)
|
||||
{
|
||||
struct stmvl53l1_data *data = (struct stmvl53l1_data *)
|
||||
container_of(dev, struct stmvl53l1_data, stdev);
|
||||
struct ipp_work_t *pout = &data->ipp.work_out;
|
||||
struct ipp_work_t *pin = &data->ipp.work;
|
||||
int rc;
|
||||
int16_t *pambient_dmax_mm_ipp;
|
||||
|
||||
IPP_SERIALIZE_VAR;
|
||||
|
||||
/* setup pin */
|
||||
IPP_SERIALIZE_START(pin->data, 4);
|
||||
IPP_SET_ARG(pin->data, 0, target_reflectance);
|
||||
IPP_SET_ARG_PTR(pin->data, 1, pdmax_cal);
|
||||
IPP_SET_ARG_PTR(pin->data, 2, pdmax_cfg);
|
||||
IPP_SET_ARG_PTR(pin->data, 3, pbins);
|
||||
pin->payload = IPP_SERIALIZE_PAYLAOD();
|
||||
pin->process_no = stmvl53l1_ipp_hist_ambient_dmax;
|
||||
|
||||
/* setup pout */
|
||||
IPP_SERIALIZE_START(pout->data, 1);
|
||||
IPP_OUT_ARG_PTR(pout->data, 0, pambient_dmax_mm_ipp);
|
||||
|
||||
/* do ipp */
|
||||
rc = stmvl53l1_ipp_do_wrapper(data, pin, pout, IPP_SERIALIZE_PAYLAOD());
|
||||
if (rc)
|
||||
goto done;
|
||||
|
||||
/* copy output */
|
||||
memcpy(pambient_dmax_mm, pambient_dmax_mm_ipp,
|
||||
sizeof(*pambient_dmax_mm));
|
||||
|
||||
rc = 0;
|
||||
done:
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief IPP Wrapper call for xtalk calibration post processing
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[in] pxtalk_ranges : Input VL53L1_xtalk_range_results_t
|
||||
* Must contain 5 ranges, 4 quadrants + 1
|
||||
* full FoV
|
||||
* @param[out] pxtalk_shape : Output normalised Cross talk histogram
|
||||
* shape
|
||||
* @param[out] pxtalk_cal : Output VL53L1_xtalk_calibration_results_t
|
||||
* structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
VL53L1_Error VL53L1_ipp_xtalk_calibration_process_data(
|
||||
VL53L1_DEV dev,
|
||||
VL53L1_xtalk_range_results_t *pxtalk_ranges,
|
||||
VL53L1_xtalk_histogram_data_t *pxtalk_shape,
|
||||
VL53L1_xtalk_calibration_results_t *pxtalk_cal)
|
||||
{
|
||||
struct stmvl53l1_data *data = (struct stmvl53l1_data *)
|
||||
container_of(dev, struct stmvl53l1_data, stdev);
|
||||
struct ipp_work_t *pout = &data->ipp.work_out;
|
||||
struct ipp_work_t *pin = &data->ipp.work;
|
||||
int rc;
|
||||
VL53L1_xtalk_histogram_data_t *pxtalk_shape_ipp;
|
||||
VL53L1_xtalk_calibration_results_t *pxtalk_cal_ipp;
|
||||
|
||||
IPP_SERIALIZE_VAR;
|
||||
|
||||
/* setup pin */
|
||||
IPP_SERIALIZE_START(pin->data, 1);
|
||||
IPP_SET_ARG_PTR(pin->data, 0, pxtalk_ranges);
|
||||
pin->payload = IPP_SERIALIZE_PAYLAOD();
|
||||
pin->process_no = stmvl53l1_ipp_xtalk_calibration;
|
||||
|
||||
/* setup pout */
|
||||
IPP_SERIALIZE_START(pout->data, 2);
|
||||
IPP_OUT_ARG_PTR(pout->data, 0, pxtalk_shape_ipp);
|
||||
IPP_OUT_ARG_PTR(pout->data, 1, pxtalk_cal_ipp);
|
||||
|
||||
/* do ipp */
|
||||
rc = stmvl53l1_ipp_do_wrapper(data, pin, pout, IPP_SERIALIZE_PAYLAOD());
|
||||
if (rc)
|
||||
goto done;
|
||||
|
||||
/* copy output */
|
||||
memcpy(pxtalk_shape, pxtalk_shape_ipp, sizeof(*pxtalk_shape));
|
||||
memcpy(pxtalk_cal, pxtalk_cal_ipp, sizeof(*pxtalk_cal));
|
||||
|
||||
rc = 0;
|
||||
done:
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief IPP Wrapper call for Generating Xtalk data from dual reflectance
|
||||
* histogram data
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[in] pxtalk_results : Pointer to xtalk_results structure
|
||||
* containing dual reflectance
|
||||
* histogram data
|
||||
* @param[in] expected_target_distance_mm : User input of true target distance
|
||||
* @param[in] higher_reflectance : User input detailing which
|
||||
* histogram data 1 or 2 has the
|
||||
* highest reflectance.
|
||||
* @param[out] pxtalk_avg_samples : Pointer to output xtalk histogram
|
||||
* data
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_ipp_generate_dual_reflectance_xtalk_samples(
|
||||
VL53L1_DEV dev,
|
||||
VL53L1_xtalk_range_results_t *pxtalk_results,
|
||||
uint16_t expected_target_distance_mm,
|
||||
uint8_t higher_reflectance,
|
||||
VL53L1_histogram_bin_data_t *pxtalk_avg_samples)
|
||||
{
|
||||
struct stmvl53l1_data *data = (struct stmvl53l1_data *)
|
||||
container_of(dev, struct stmvl53l1_data, stdev);
|
||||
struct ipp_work_t *pout = &data->ipp.work_out;
|
||||
struct ipp_work_t *pin = &data->ipp.work;
|
||||
int rc;
|
||||
VL53L1_histogram_bin_data_t *pxtalk_avg_samples_ipp;
|
||||
|
||||
IPP_SERIALIZE_VAR;
|
||||
|
||||
/* setup pin */
|
||||
IPP_SERIALIZE_START(pin->data, 3);
|
||||
IPP_SET_ARG_PTR(pin->data, 0, pxtalk_results);
|
||||
IPP_SET_ARG(pin->data, 1, expected_target_distance_mm);
|
||||
IPP_SET_ARG(pin->data, 2, higher_reflectance);
|
||||
pin->payload = IPP_SERIALIZE_PAYLAOD();
|
||||
pin->process_no = stmvl53l1_ipp_generate_dual_reflectance_xtalk_samples;
|
||||
|
||||
/* setup pout */
|
||||
IPP_SERIALIZE_START(pout->data, 1);
|
||||
IPP_OUT_ARG_PTR(pout->data, 0, pxtalk_avg_samples_ipp);
|
||||
|
||||
/* do ipp */
|
||||
rc = stmvl53l1_ipp_do_wrapper(data, pin, pout, IPP_SERIALIZE_PAYLAOD());
|
||||
if (rc)
|
||||
goto done;
|
||||
|
||||
/* copy output */
|
||||
memcpy(pxtalk_avg_samples, pxtalk_avg_samples_ipp,
|
||||
sizeof(*pxtalk_avg_samples));
|
||||
|
||||
rc = 0;
|
||||
done:
|
||||
|
||||
return rc;
|
||||
}
|
||||
63
drivers/input/misc/vl53L1_14_1_2/protected/inc/vl53l1_dmax.h
Normal file
63
drivers/input/misc/vl53L1_14_1_2/protected/inc/vl53l1_dmax.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 Protected and is dual licensed,
|
||||
either 'STMicroelectronics Proprietary license'
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
|
||||
******************************************************************************
|
||||
|
||||
'STMicroelectronics Proprietary license'
|
||||
|
||||
******************************************************************************
|
||||
|
||||
License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
terms at www.st.com/sla0081
|
||||
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_DMAX_H_
|
||||
#define _VL53L1_DMAX_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_hist_structs.h"
|
||||
#include "vl53l1_dmax_private_structs.h"
|
||||
#include "vl53l1_error_codes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_001(
|
||||
uint16_t target_reflectance,
|
||||
VL53L1_dmax_calibration_data_t *pcal,
|
||||
VL53L1_hist_gen3_dmax_config_t *pcfg,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_hist_gen3_dmax_private_data_t *pdata,
|
||||
int16_t *pambient_dmax_mm);
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_f_002(
|
||||
uint32_t events_threshold,
|
||||
uint32_t ref_signal_events,
|
||||
uint32_t ref_distance_mm,
|
||||
uint32_t signal_thresh_sigma);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 Protected and is dual licensed,
|
||||
either 'STMicroelectronics Proprietary license'
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
|
||||
******************************************************************************
|
||||
|
||||
'STMicroelectronics Proprietary license'
|
||||
|
||||
******************************************************************************
|
||||
|
||||
License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
terms at www.st.com/sla0081
|
||||
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_DMAX_PRIVATE_STRUCTS_H_
|
||||
#define _VL53L1_DMAX_PRIVATE_STRUCTS_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint32_t VL53L1_p_036;
|
||||
|
||||
|
||||
uint8_t VL53L1_p_064;
|
||||
|
||||
uint8_t VL53L1_p_065;
|
||||
|
||||
|
||||
uint16_t VL53L1_p_066;
|
||||
|
||||
uint16_t VL53L1_p_067;
|
||||
|
||||
uint16_t VL53L1_p_068;
|
||||
|
||||
uint16_t VL53L1_p_037;
|
||||
|
||||
|
||||
uint32_t VL53L1_p_012;
|
||||
|
||||
uint32_t VL53L1_p_033;
|
||||
|
||||
|
||||
uint16_t VL53L1_p_001;
|
||||
|
||||
|
||||
uint16_t VL53L1_p_006;
|
||||
|
||||
|
||||
uint32_t VL53L1_p_004;
|
||||
|
||||
uint32_t VL53L1_p_034;
|
||||
|
||||
|
||||
int16_t VL53L1_p_035;
|
||||
|
||||
int16_t VL53L1_p_007;
|
||||
|
||||
|
||||
} VL53L1_hist_gen3_dmax_private_data_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 Protected and is dual licensed,
|
||||
either 'STMicroelectronics Proprietary license'
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
|
||||
******************************************************************************
|
||||
|
||||
'STMicroelectronics Proprietary license'
|
||||
|
||||
******************************************************************************
|
||||
|
||||
License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
terms at www.st.com/sla0081
|
||||
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_HIST_ALGOS_GEN3_H_
|
||||
#define _VL53L1_HIST_ALGOS_GEN3_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_ll_def.h"
|
||||
|
||||
#include "vl53l1_hist_private_structs.h"
|
||||
#include "vl53l1_dmax_private_structs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_f_016(
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_018(
|
||||
uint16_t ambient_threshold_events_scaler,
|
||||
int32_t ambient_threshold_sigma,
|
||||
int32_t min_ambient_threshold_events,
|
||||
uint8_t algo__crosstalk_compensation_enable,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_histogram_bin_data_t *pxtalk,
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_019(
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_020(
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_021(
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_028(
|
||||
VL53L1_HistTargetOrder target_order,
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_022(
|
||||
uint8_t pulse_no,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_027(
|
||||
uint8_t pulse_no,
|
||||
uint8_t clip_events,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_030(
|
||||
int16_t VL53L1_p_022,
|
||||
int16_t VL53L1_p_026,
|
||||
uint8_t VL53L1_p_031,
|
||||
uint8_t clip_events,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
uint32_t *pphase);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_023(
|
||||
uint8_t pulse_no,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo,
|
||||
int32_t pad_value,
|
||||
VL53L1_histogram_bin_data_t *ppulse);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_026(
|
||||
uint8_t bin,
|
||||
uint8_t sigma_estimator__sigma_ref_mm,
|
||||
uint8_t VL53L1_p_031,
|
||||
uint8_t VL53L1_p_055,
|
||||
uint8_t crosstalk_compensation_enable,
|
||||
VL53L1_histogram_bin_data_t *phist_data_ap,
|
||||
VL53L1_histogram_bin_data_t *phist_data_zp,
|
||||
VL53L1_histogram_bin_data_t *pxtalk_hist,
|
||||
uint16_t *psigma_est);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_f_029(
|
||||
uint8_t range_id,
|
||||
uint8_t valid_phase_low,
|
||||
uint8_t valid_phase_high,
|
||||
uint16_t sigma_thres,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_hist_pulse_data_t *ppulse,
|
||||
VL53L1_range_data_t *pdata);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 Protected and is dual licensed,
|
||||
either 'STMicroelectronics Proprietary license'
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
|
||||
******************************************************************************
|
||||
|
||||
'STMicroelectronics Proprietary license'
|
||||
|
||||
******************************************************************************
|
||||
|
||||
License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
terms at www.st.com/sla0081
|
||||
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_HIST_ALGOS_GEN4_H_
|
||||
#define _VL53L1_HIST_ALGOS_GEN4_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_ll_def.h"
|
||||
|
||||
#include "vl53l1_hist_private_structs.h"
|
||||
#include "vl53l1_dmax_private_structs.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_f_032(
|
||||
VL53L1_hist_gen4_algo_filtered_data_t *palgo);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_033(
|
||||
VL53L1_dmax_calibration_data_t *pdmax_cal,
|
||||
VL53L1_hist_gen3_dmax_config_t *pdmax_cfg,
|
||||
VL53L1_hist_post_process_config_t *ppost_cfg,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_histogram_bin_data_t *pxtalk,
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo,
|
||||
VL53L1_hist_gen4_algo_filtered_data_t *pfiltered,
|
||||
VL53L1_hist_gen3_dmax_private_data_t *pdmax_algo,
|
||||
VL53L1_range_results_t *presults,
|
||||
uint8_t histo_merge_nb);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_034(
|
||||
uint8_t pulse_no,
|
||||
VL53L1_histogram_bin_data_t *ppulse,
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo,
|
||||
VL53L1_hist_gen4_algo_filtered_data_t *pfiltered);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_035(
|
||||
uint8_t pulse_no,
|
||||
uint16_t noise_threshold,
|
||||
VL53L1_hist_gen4_algo_filtered_data_t *pfiltered,
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_036(
|
||||
uint8_t bin,
|
||||
int32_t VL53L1_p_003,
|
||||
int32_t VL53L1_p_018,
|
||||
int32_t VL53L1_p_001,
|
||||
int32_t ax,
|
||||
int32_t bx,
|
||||
int32_t cx,
|
||||
int32_t VL53L1_p_004,
|
||||
uint8_t VL53L1_p_031,
|
||||
uint32_t *pmedian_phase);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 Protected and is dual licensed,
|
||||
either 'STMicroelectronics Proprietary license'
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
|
||||
******************************************************************************
|
||||
|
||||
'STMicroelectronics Proprietary license'
|
||||
|
||||
******************************************************************************
|
||||
|
||||
License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
terms at www.st.com/sla0081
|
||||
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_HIST_CORE_H_
|
||||
#define _VL53L1_HIST_CORE_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_hist_private_structs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_f_013(
|
||||
uint8_t VL53L1_p_018,
|
||||
uint8_t filter_woi,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
int32_t *pa,
|
||||
int32_t *pb,
|
||||
int32_t *pc);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_011(
|
||||
uint16_t vcsel_width,
|
||||
uint16_t fast_osc_frequency,
|
||||
uint32_t total_periods_elapsed,
|
||||
uint16_t VL53L1_p_006,
|
||||
VL53L1_range_data_t *pdata,
|
||||
uint8_t histo_merge_nb);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_f_012(
|
||||
uint16_t gain_factor,
|
||||
int16_t range_offset_mm,
|
||||
VL53L1_range_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_f_037(
|
||||
VL53L1_histogram_bin_data_t *pdata,
|
||||
int32_t ambient_estimate_counts_per_bin);
|
||||
|
||||
|
||||
|
||||
|
||||
void VL53L1_f_004(
|
||||
VL53L1_histogram_bin_data_t *pxtalk,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_histogram_bin_data_t *pxtalk_realigned);
|
||||
|
||||
|
||||
|
||||
int8_t VL53L1_f_038(
|
||||
VL53L1_histogram_bin_data_t *pdata1,
|
||||
VL53L1_histogram_bin_data_t *pdata2);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_039(
|
||||
VL53L1_histogram_bin_data_t *pidata,
|
||||
VL53L1_histogram_bin_data_t *podata);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 Protected and is dual licensed,
|
||||
either 'STMicroelectronics Proprietary license'
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
|
||||
******************************************************************************
|
||||
|
||||
'STMicroelectronics Proprietary license'
|
||||
|
||||
******************************************************************************
|
||||
|
||||
License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
terms at www.st.com/sla0081
|
||||
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_HIST_FUNCS_H_
|
||||
#define _VL53L1_HIST_FUNCS_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_ll_def.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_process_data(
|
||||
VL53L1_dmax_calibration_data_t *pdmax_cal,
|
||||
VL53L1_hist_gen3_dmax_config_t *pdmax_cfg,
|
||||
VL53L1_hist_post_process_config_t *ppost_cfg,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_xtalk_histogram_data_t *pxtalk,
|
||||
uint8_t *pArea1,
|
||||
uint8_t *pArea2,
|
||||
VL53L1_range_results_t *presults,
|
||||
uint8_t *HistMergeNumber);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_ambient_dmax(
|
||||
uint16_t target_reflectance,
|
||||
VL53L1_dmax_calibration_data_t *pdmax_cal,
|
||||
VL53L1_hist_gen3_dmax_config_t *pdmax_cfg,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
int16_t *pambient_dmax_mm);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,269 @@
|
|||
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 Protected and is dual licensed,
|
||||
either 'STMicroelectronics Proprietary license'
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
|
||||
******************************************************************************
|
||||
|
||||
'STMicroelectronics Proprietary license'
|
||||
|
||||
******************************************************************************
|
||||
|
||||
License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
terms at www.st.com/sla0081
|
||||
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_HIST_PRIVATE_STRUCTS_H_
|
||||
#define _VL53L1_HIST_PRIVATE_STRUCTS_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_hist_structs.h"
|
||||
|
||||
#define VL53L1_D_001 8
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint8_t VL53L1_p_022;
|
||||
|
||||
uint8_t VL53L1_p_023;
|
||||
|
||||
uint8_t VL53L1_p_024;
|
||||
|
||||
uint8_t VL53L1_p_030;
|
||||
|
||||
int32_t VL53L1_p_020;
|
||||
|
||||
|
||||
int32_t VL53L1_p_048[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
int32_t VL53L1_p_069[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
uint8_t VL53L1_p_043[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
int32_t VL53L1_p_008[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
uint16_t VL53L1_p_017[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
uint16_t VL53L1_p_011[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
} VL53L1_hist_gen1_algo_private_data_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint8_t VL53L1_p_022;
|
||||
|
||||
uint8_t VL53L1_p_023;
|
||||
|
||||
uint8_t VL53L1_p_024;
|
||||
|
||||
uint16_t VL53L1_p_019;
|
||||
|
||||
uint8_t VL53L1_p_009;
|
||||
|
||||
uint8_t VL53L1_p_030;
|
||||
|
||||
int32_t VL53L1_p_004;
|
||||
|
||||
int32_t VL53L1_p_020;
|
||||
|
||||
|
||||
int32_t VL53L1_p_003[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
int32_t VL53L1_p_018[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
int32_t VL53L1_p_001[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
|
||||
int32_t VL53L1_p_008[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
int32_t VL53L1_p_041[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
int32_t VL53L1_p_039[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
int32_t VL53L1_p_040[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
|
||||
} VL53L1_hist_gen2_algo_filtered_data_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint8_t VL53L1_p_022;
|
||||
|
||||
uint8_t VL53L1_p_023;
|
||||
|
||||
uint8_t VL53L1_p_024;
|
||||
|
||||
int32_t VL53L1_p_032;
|
||||
|
||||
|
||||
uint8_t VL53L1_p_042[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
uint8_t VL53L1_p_044[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
|
||||
uint32_t VL53L1_p_017[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
uint16_t VL53L1_p_011[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
|
||||
uint8_t VL53L1_p_043[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
|
||||
} VL53L1_hist_gen2_algo_detection_data_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint8_t VL53L1_p_015;
|
||||
|
||||
uint8_t VL53L1_p_022;
|
||||
|
||||
uint8_t VL53L1_p_025;
|
||||
|
||||
uint8_t VL53L1_p_026;
|
||||
|
||||
uint8_t VL53L1_p_016;
|
||||
|
||||
|
||||
uint8_t VL53L1_p_027;
|
||||
|
||||
uint8_t VL53L1_p_055;
|
||||
|
||||
|
||||
int32_t VL53L1_p_020;
|
||||
|
||||
int32_t VL53L1_p_021;
|
||||
|
||||
int32_t VL53L1_p_013;
|
||||
|
||||
|
||||
uint32_t VL53L1_p_028;
|
||||
|
||||
uint32_t VL53L1_p_014;
|
||||
|
||||
uint32_t VL53L1_p_029;
|
||||
|
||||
|
||||
uint16_t VL53L1_p_005;
|
||||
|
||||
|
||||
} VL53L1_hist_pulse_data_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint8_t VL53L1_p_022;
|
||||
|
||||
uint8_t VL53L1_p_023;
|
||||
|
||||
uint8_t VL53L1_p_024;
|
||||
|
||||
uint8_t VL53L1_p_031;
|
||||
|
||||
uint8_t VL53L1_p_045;
|
||||
|
||||
int32_t VL53L1_p_004;
|
||||
|
||||
int32_t VL53L1_p_032;
|
||||
|
||||
|
||||
uint8_t VL53L1_p_043[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
uint8_t VL53L1_p_046[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
uint8_t VL53L1_p_047[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
|
||||
int32_t VL53L1_p_056[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
int32_t VL53L1_p_048[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
int32_t VL53L1_p_008[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
|
||||
uint8_t VL53L1_p_049;
|
||||
|
||||
uint8_t VL53L1_p_050;
|
||||
|
||||
uint8_t VL53L1_p_051;
|
||||
|
||||
|
||||
VL53L1_hist_pulse_data_t VL53L1_p_002[VL53L1_D_001];
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_histogram_bin_data_t VL53L1_p_010;
|
||||
|
||||
VL53L1_histogram_bin_data_t VL53L1_p_038;
|
||||
|
||||
VL53L1_histogram_bin_data_t VL53L1_p_052;
|
||||
|
||||
VL53L1_histogram_bin_data_t VL53L1_p_053;
|
||||
|
||||
VL53L1_histogram_bin_data_t VL53L1_p_054;
|
||||
|
||||
|
||||
|
||||
|
||||
} VL53L1_hist_gen3_algo_private_data_t;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint8_t VL53L1_p_022;
|
||||
|
||||
uint8_t VL53L1_p_023;
|
||||
|
||||
uint8_t VL53L1_p_024;
|
||||
|
||||
|
||||
int32_t VL53L1_p_003[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
int32_t VL53L1_p_018[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
int32_t VL53L1_p_001[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
|
||||
int32_t VL53L1_p_039[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
int32_t VL53L1_p_040[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
|
||||
uint8_t VL53L1_p_043[VL53L1_HISTOGRAM_BUFFER_SIZE];
|
||||
|
||||
|
||||
} VL53L1_hist_gen4_algo_filtered_data_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 Protected and is dual licensed,
|
||||
either 'STMicroelectronics Proprietary license'
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
|
||||
******************************************************************************
|
||||
|
||||
'STMicroelectronics Proprietary license'
|
||||
|
||||
******************************************************************************
|
||||
|
||||
License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
terms at www.st.com/sla0081
|
||||
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_SIGMA_ESTIMATE_H_
|
||||
#define _VL53L1_SIGMA_ESTIMATE_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_ll_def.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define VL53L1_D_002 0xFFFF
|
||||
|
||||
|
||||
#define VL53L1_D_008 0xFFFF
|
||||
#define VL53L1_D_003 0xFFFFFF
|
||||
#define VL53L1_D_007 0xFFFFFFFF
|
||||
#define VL53L1_D_005 0x7FFFFFFFFF
|
||||
#define VL53L1_D_009 0xFFFFFFFFFF
|
||||
#define VL53L1_D_010 0xFFFFFFFFFFFF
|
||||
#define VL53L1_D_004 0xFFFFFFFFFFFFFF
|
||||
#define VL53L1_D_006 0x7FFFFFFFFFFFFFFF
|
||||
#define VL53L1_D_011 0xFFFFFFFFFFFFFFFF
|
||||
|
||||
|
||||
|
||||
|
||||
uint16_t VL53L1_f_042(
|
||||
uint8_t sigma_estimator__effective_pulse_width_ns,
|
||||
uint8_t sigma_estimator__effective_ambient_width_ns,
|
||||
uint8_t sigma_estimator__sigma_ref_mm,
|
||||
VL53L1_range_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
uint16_t VL53L1_f_044(
|
||||
uint8_t sigma_estimator__effective_pulse_width_ns,
|
||||
uint8_t sigma_estimator__effective_ambient_width_ns,
|
||||
uint8_t sigma_estimator__sigma_ref_mm,
|
||||
VL53L1_range_data_t *pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_045(
|
||||
uint8_t sigma_estimator__sigma_ref_mm,
|
||||
uint32_t VL53L1_p_003,
|
||||
uint32_t VL53L1_p_018,
|
||||
uint32_t VL53L1_p_001,
|
||||
uint32_t a_zp,
|
||||
uint32_t c_zp,
|
||||
uint32_t bx,
|
||||
uint32_t ax_zp,
|
||||
uint32_t cx_zp,
|
||||
uint32_t VL53L1_p_004,
|
||||
uint16_t fast_osc_frequency,
|
||||
uint16_t *psigma_est);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_014(
|
||||
uint8_t sigma_estimator__sigma_ref_mm,
|
||||
uint32_t VL53L1_p_003,
|
||||
uint32_t VL53L1_p_018,
|
||||
uint32_t VL53L1_p_001,
|
||||
uint32_t a_zp,
|
||||
uint32_t c_zp,
|
||||
uint32_t bx,
|
||||
uint32_t ax_zp,
|
||||
uint32_t cx_zp,
|
||||
uint32_t VL53L1_p_004,
|
||||
uint16_t fast_osc_frequency,
|
||||
uint16_t *psigma_est);
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_f_046(
|
||||
uint64_t VL53L1_p_003,
|
||||
uint32_t size
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_f_043(
|
||||
uint32_t VL53L1_p_003,
|
||||
uint32_t VL53L1_p_018);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
168
drivers/input/misc/vl53L1_14_1_2/protected/inc/vl53l1_xtalk.h
Normal file
168
drivers/input/misc/vl53L1_14_1_2/protected/inc/vl53l1_xtalk.h
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 Protected and is dual licensed,
|
||||
either 'STMicroelectronics Proprietary license'
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
|
||||
******************************************************************************
|
||||
|
||||
'STMicroelectronics Proprietary license'
|
||||
|
||||
******************************************************************************
|
||||
|
||||
License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
terms at www.st.com/sla0081
|
||||
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_XTALK_H_
|
||||
#define _VL53L1_XTALK_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_xtalk_private_structs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_xtalk_calibration_process_data(
|
||||
VL53L1_xtalk_range_results_t *pxtalk_ranges,
|
||||
VL53L1_xtalk_histogram_data_t *pxtalk_shape,
|
||||
VL53L1_xtalk_calibration_results_t *pxtalk_cal);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_049(
|
||||
VL53L1_histogram_bin_data_t *pavg_bins,
|
||||
VL53L1_xtalk_algo_data_t *pdebug,
|
||||
VL53L1_xtalk_range_data_t *pxtalk_data,
|
||||
uint8_t histogram__window_start,
|
||||
uint8_t histogram__window_end,
|
||||
VL53L1_xtalk_histogram_shape_t *pxtalk_shape);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_047(
|
||||
VL53L1_xtalk_range_results_t *pxtalk_results,
|
||||
VL53L1_xtalk_algo_data_t *pdebug,
|
||||
int16_t *xgradient,
|
||||
int16_t *ygradient);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_048(
|
||||
VL53L1_xtalk_range_data_t *pxtalk_data,
|
||||
VL53L1_xtalk_algo_data_t *pdebug,
|
||||
uint32_t *xtalk_mean_offset_kcps);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_053(
|
||||
VL53L1_histogram_bin_data_t *phist_data,
|
||||
VL53L1_xtalk_range_data_t *pxtalk_data,
|
||||
VL53L1_xtalk_algo_data_t *pdebug,
|
||||
VL53L1_xtalk_histogram_shape_t *pxtalk_histo);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_040(
|
||||
uint32_t mean_offset,
|
||||
int16_t xgradient,
|
||||
int16_t ygradient,
|
||||
int8_t centre_offset_x,
|
||||
int8_t centre_offset_y,
|
||||
uint16_t roi_effective_spads,
|
||||
uint8_t roi_centre_spad,
|
||||
uint8_t roi_xy_size,
|
||||
uint32_t *xtalk_rate_kcps);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_041(
|
||||
VL53L1_histogram_bin_data_t *phist_data,
|
||||
VL53L1_xtalk_histogram_shape_t *pxtalk_data,
|
||||
uint32_t xtalk_rate_kcps,
|
||||
VL53L1_histogram_bin_data_t *pxtalkcount_data);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_055(
|
||||
VL53L1_histogram_bin_data_t *phist_data,
|
||||
VL53L1_histogram_bin_data_t *pxtalk_data,
|
||||
uint8_t xtalk_bin_offset);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_052(
|
||||
VL53L1_histogram_bin_data_t *pxtalk_data,
|
||||
uint32_t amb_threshold,
|
||||
uint8_t VL53L1_p_022,
|
||||
uint8_t VL53L1_p_026);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_054(
|
||||
VL53L1_customer_nvm_managed_t *pcustomer,
|
||||
VL53L1_dynamic_config_t *pdyn_cfg,
|
||||
VL53L1_xtalk_histogram_data_t *pxtalk_shape,
|
||||
VL53L1_histogram_bin_data_t *pip_hist_data,
|
||||
VL53L1_histogram_bin_data_t *pop_hist_data,
|
||||
VL53L1_histogram_bin_data_t *pxtalk_count_data);
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_051(
|
||||
uint8_t sigma_mult,
|
||||
int32_t VL53L1_p_004,
|
||||
uint32_t *ambient_noise);
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_generate_dual_reflectance_xtalk_samples(
|
||||
VL53L1_xtalk_range_results_t *pxtalk_results,
|
||||
uint16_t expected_target_distance_mm,
|
||||
uint8_t higher_reflectance,
|
||||
VL53L1_histogram_bin_data_t *pxtalk_avg_samples
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_050(
|
||||
VL53L1_histogram_bin_data_t *pzone_avg_1,
|
||||
VL53L1_histogram_bin_data_t *pzone_avg_2,
|
||||
uint16_t expected_target_distance,
|
||||
uint8_t subtract_amb,
|
||||
uint8_t higher_reflectance,
|
||||
VL53L1_histogram_bin_data_t *pxtalk_output
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 Protected and is dual licensed,
|
||||
either 'STMicroelectronics Proprietary license'
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
|
||||
******************************************************************************
|
||||
|
||||
'STMicroelectronics Proprietary license'
|
||||
|
||||
******************************************************************************
|
||||
|
||||
License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
terms at www.st.com/sla0081
|
||||
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_XTALK_PRIVATE_STRUCTS_H_
|
||||
#define _VL53L1_XTALK_PRIVATE_STRUCTS_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_hist_structs.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define VL53L1_D_012 4
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_p_062[VL53L1_D_012];
|
||||
|
||||
|
||||
int16_t VL53L1_p_060;
|
||||
|
||||
int16_t VL53L1_p_061;
|
||||
|
||||
|
||||
VL53L1_histogram_bin_data_t VL53L1_p_057;
|
||||
|
||||
VL53L1_histogram_bin_data_t VL53L1_p_058;
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_p_059;
|
||||
|
||||
|
||||
uint32_t VL53L1_p_063[VL53L1_XTALK_HISTO_BINS];
|
||||
|
||||
|
||||
} VL53L1_xtalk_algo_data_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
299
drivers/input/misc/vl53L1_14_1_2/protected/src/vl53l1_dmax.c
Normal file
299
drivers/input/misc/vl53L1_14_1_2/protected/src/vl53l1_dmax.c
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 Protected and is dual licensed,
|
||||
either 'STMicroelectronics Proprietary license'
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
|
||||
******************************************************************************
|
||||
|
||||
'STMicroelectronics Proprietary license'
|
||||
|
||||
******************************************************************************
|
||||
|
||||
License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
terms at www.st.com/sla0081
|
||||
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_platform_log.h"
|
||||
#include "vl53l1_platform_user_defines.h"
|
||||
#include "vl53l1_core_support.h"
|
||||
#include "vl53l1_error_codes.h"
|
||||
|
||||
#include "vl53l1_dmax.h"
|
||||
|
||||
|
||||
#define LOG_FUNCTION_START(fmt, ...) \
|
||||
_LOG_FUNCTION_START(VL53L1_TRACE_MODULE_PROTECTED, fmt, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END(status, ...) \
|
||||
_LOG_FUNCTION_END(VL53L1_TRACE_MODULE_PROTECTED, status, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
|
||||
_LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_PROTECTED, \
|
||||
status, fmt, ##__VA_ARGS__)
|
||||
|
||||
#define trace_print(level, ...) \
|
||||
_LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_PROTECTED, \
|
||||
level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_001(
|
||||
uint16_t target_reflectance,
|
||||
VL53L1_dmax_calibration_data_t *pcal,
|
||||
VL53L1_hist_gen3_dmax_config_t *pcfg,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_hist_gen3_dmax_private_data_t *pdata,
|
||||
int16_t *pambient_dmax_mm)
|
||||
{
|
||||
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
uint32_t pll_period_us = 0;
|
||||
uint32_t periods_elapsed = 0;
|
||||
|
||||
uint32_t tmp32 = 0;
|
||||
uint64_t tmp64 = 0;
|
||||
|
||||
uint32_t amb_thres_delta = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
pdata->VL53L1_p_006 = 0x0000;
|
||||
pdata->VL53L1_p_033 = 0x0000;
|
||||
pdata->VL53L1_p_001 = 0x0000;
|
||||
pdata->VL53L1_p_012 = 0x0000;
|
||||
pdata->VL53L1_p_004 = 0x0000;
|
||||
pdata->VL53L1_p_034 = 0x0000;
|
||||
pdata->VL53L1_p_035 = 0;
|
||||
pdata->VL53L1_p_007 = 0;
|
||||
|
||||
*pambient_dmax_mm = 0;
|
||||
|
||||
|
||||
if ((pbins->VL53L1_p_019 != 0) &&
|
||||
(pbins->total_periods_elapsed != 0)) {
|
||||
|
||||
|
||||
|
||||
pll_period_us =
|
||||
VL53L1_calc_pll_period_us(pbins->VL53L1_p_019);
|
||||
|
||||
|
||||
|
||||
periods_elapsed = pbins->total_periods_elapsed + 1;
|
||||
|
||||
|
||||
|
||||
pdata->VL53L1_p_036 =
|
||||
VL53L1_duration_maths(
|
||||
pll_period_us,
|
||||
1<<4,
|
||||
VL53L1_RANGING_WINDOW_VCSEL_PERIODS,
|
||||
periods_elapsed);
|
||||
|
||||
|
||||
pdata->VL53L1_p_001 =
|
||||
VL53L1_rate_maths(
|
||||
pbins->VL53L1_p_004,
|
||||
pdata->VL53L1_p_036);
|
||||
|
||||
|
||||
|
||||
pdata->VL53L1_p_033 =
|
||||
VL53L1_events_per_spad_maths(
|
||||
pbins->VL53L1_p_004,
|
||||
pbins->result__dss_actual_effective_spads,
|
||||
pdata->VL53L1_p_036);
|
||||
|
||||
|
||||
|
||||
pdata->VL53L1_p_037 = pcfg->max_effective_spads;
|
||||
pdata->VL53L1_p_006 = pcfg->max_effective_spads;
|
||||
|
||||
if (pdata->VL53L1_p_033 > 0) {
|
||||
tmp64 =
|
||||
(uint64_t)pcfg->dss_config__target_total_rate_mcps;
|
||||
tmp64 *= 1000;
|
||||
tmp64 <<= (11+1);
|
||||
tmp32 = pdata->VL53L1_p_033/2;
|
||||
tmp64 += (uint64_t)tmp32;
|
||||
tmp64 = do_division_u(tmp64,
|
||||
(uint64_t)pdata->VL53L1_p_033);
|
||||
|
||||
if (tmp64 < (uint64_t)pcfg->max_effective_spads)
|
||||
pdata->VL53L1_p_006 = (uint16_t)tmp64;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ((pcal->ref__actual_effective_spads != 0) &&
|
||||
(pbins->VL53L1_p_019 != 0) &&
|
||||
(pcal->ref_reflectance_pc != 0) &&
|
||||
(pbins->total_periods_elapsed != 0)) {
|
||||
|
||||
|
||||
|
||||
tmp64 = (uint64_t)pcal->ref__peak_signal_count_rate_mcps;
|
||||
tmp64 *= (1000 * 256);
|
||||
tmp32 = pcal->ref__actual_effective_spads/2;
|
||||
tmp64 += (uint64_t)tmp32;
|
||||
tmp64 = do_division_u(tmp64,
|
||||
(uint64_t)pcal->ref__actual_effective_spads);
|
||||
|
||||
pdata->VL53L1_p_012 = (uint32_t)tmp64;
|
||||
pdata->VL53L1_p_012 <<= 4;
|
||||
|
||||
|
||||
|
||||
tmp64 = (uint64_t)pdata->VL53L1_p_036;
|
||||
tmp64 *= (uint64_t)pdata->VL53L1_p_033;
|
||||
tmp64 *= (uint64_t)pdata->VL53L1_p_006;
|
||||
tmp64 += (1<<(11+7));
|
||||
tmp64 >>= (11+8);
|
||||
tmp64 += 500;
|
||||
tmp64 = do_division_u(tmp64, 1000);
|
||||
|
||||
|
||||
if (tmp64 > 0x00FFFFFF)
|
||||
tmp64 = 0x00FFFFFF;
|
||||
|
||||
pdata->VL53L1_p_004 = (uint32_t)tmp64;
|
||||
|
||||
|
||||
|
||||
tmp64 = (uint64_t)pdata->VL53L1_p_036;
|
||||
tmp64 *= (uint64_t)pdata->VL53L1_p_012;
|
||||
tmp64 *= (uint64_t)pdata->VL53L1_p_006;
|
||||
tmp64 += (1<<(11+7));
|
||||
tmp64 >>= (11+8);
|
||||
|
||||
|
||||
|
||||
tmp64 *= ((uint64_t)target_reflectance *
|
||||
(uint64_t)pcal->coverglass_transmission);
|
||||
|
||||
tmp64 += ((uint64_t)pcal->ref_reflectance_pc * 128);
|
||||
tmp64 = do_division_u(tmp64,
|
||||
((uint64_t)pcal->ref_reflectance_pc * 256));
|
||||
|
||||
tmp64 += 500;
|
||||
tmp64 = do_division_u(tmp64, 1000);
|
||||
|
||||
|
||||
if (tmp64 > 0x00FFFFFF)
|
||||
tmp64 = 0x00FFFFFF;
|
||||
|
||||
pdata->VL53L1_p_034 = (uint32_t)tmp64;
|
||||
|
||||
|
||||
|
||||
tmp32 = VL53L1_isqrt(pdata->VL53L1_p_004 << 8);
|
||||
tmp32 *= (uint32_t)pcfg->ambient_thresh_sigma;
|
||||
|
||||
|
||||
|
||||
if (pdata->VL53L1_p_004 <
|
||||
(uint32_t)pcfg->min_ambient_thresh_events) {
|
||||
|
||||
amb_thres_delta =
|
||||
pcfg->min_ambient_thresh_events -
|
||||
(uint32_t)pdata->VL53L1_p_004;
|
||||
|
||||
|
||||
amb_thres_delta <<= 8;
|
||||
|
||||
if (tmp32 < amb_thres_delta)
|
||||
tmp32 = amb_thres_delta;
|
||||
}
|
||||
|
||||
|
||||
|
||||
pdata->VL53L1_p_007 =
|
||||
(int16_t)VL53L1_f_002(
|
||||
tmp32,
|
||||
pdata->VL53L1_p_034,
|
||||
(uint32_t)pcal->ref__distance_mm,
|
||||
(uint32_t)pcfg->signal_thresh_sigma);
|
||||
|
||||
|
||||
|
||||
tmp32 = (uint32_t)pdata->VL53L1_p_034;
|
||||
tmp32 *= (uint32_t)pbins->vcsel_width;
|
||||
tmp32 += (1 << 3);
|
||||
tmp32 /= (1 << 4);
|
||||
|
||||
pdata->VL53L1_p_035 =
|
||||
(int16_t)VL53L1_f_002(
|
||||
256 * (uint32_t)pcfg->signal_total_events_limit,
|
||||
tmp32,
|
||||
(uint32_t)pcal->ref__distance_mm,
|
||||
(uint32_t)pcfg->signal_thresh_sigma);
|
||||
|
||||
|
||||
|
||||
|
||||
if (pdata->VL53L1_p_035 < pdata->VL53L1_p_007)
|
||||
*pambient_dmax_mm = pdata->VL53L1_p_035;
|
||||
else
|
||||
*pambient_dmax_mm = pdata->VL53L1_p_007;
|
||||
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
|
||||
uint32_t VL53L1_f_002(
|
||||
uint32_t events_threshold,
|
||||
uint32_t ref_signal_events,
|
||||
uint32_t ref_distance_mm,
|
||||
uint32_t signal_thresh_sigma)
|
||||
{
|
||||
|
||||
|
||||
|
||||
uint32_t tmp32 = 0;
|
||||
uint32_t range_mm = 0;
|
||||
|
||||
tmp32 = 4 * events_threshold;
|
||||
|
||||
|
||||
|
||||
tmp32 += ((uint32_t)signal_thresh_sigma *
|
||||
(uint32_t)signal_thresh_sigma);
|
||||
|
||||
|
||||
|
||||
tmp32 = VL53L1_isqrt(tmp32);
|
||||
tmp32 += (uint32_t)signal_thresh_sigma;
|
||||
|
||||
|
||||
|
||||
range_mm =
|
||||
(uint32_t)VL53L1_isqrt(ref_signal_events << 4);
|
||||
range_mm *= ref_distance_mm;
|
||||
|
||||
if (tmp32 > 0) {
|
||||
range_mm += (tmp32);
|
||||
range_mm /= (2*tmp32);
|
||||
}
|
||||
|
||||
return range_mm;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,857 @@
|
|||
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 Protected and is dual licensed,
|
||||
either 'STMicroelectronics Proprietary license'
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
|
||||
******************************************************************************
|
||||
|
||||
'STMicroelectronics Proprietary license'
|
||||
|
||||
******************************************************************************
|
||||
|
||||
License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
terms at www.st.com/sla0081
|
||||
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_platform_log.h"
|
||||
|
||||
#include "vl53l1_core_support.h"
|
||||
#include "vl53l1_error_codes.h"
|
||||
|
||||
#include "vl53l1_hist_core.h"
|
||||
#include "vl53l1_hist_algos_gen3.h"
|
||||
#include "vl53l1_sigma_estimate.h"
|
||||
#include "vl53l1_dmax.h"
|
||||
|
||||
|
||||
|
||||
#define LOG_FUNCTION_START(fmt, ...) \
|
||||
_LOG_FUNCTION_START(VL53L1_TRACE_MODULE_HISTOGRAM, fmt, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END(status, ...) \
|
||||
_LOG_FUNCTION_END(VL53L1_TRACE_MODULE_HISTOGRAM, status, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
|
||||
_LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_HISTOGRAM,\
|
||||
status, fmt, ##__VA_ARGS__)
|
||||
|
||||
#define trace_print(level, ...) \
|
||||
_LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_HISTOGRAM, \
|
||||
level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
|
||||
|
||||
|
||||
void VL53L1_f_016(
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo)
|
||||
{
|
||||
|
||||
|
||||
uint8_t lb = 0;
|
||||
|
||||
palgo->VL53L1_p_023 = VL53L1_HISTOGRAM_BUFFER_SIZE;
|
||||
palgo->VL53L1_p_022 = 0;
|
||||
palgo->VL53L1_p_024 = 0;
|
||||
palgo->VL53L1_p_045 = 0;
|
||||
palgo->VL53L1_p_004 = 0;
|
||||
palgo->VL53L1_p_032 = 0;
|
||||
|
||||
for (lb = palgo->VL53L1_p_022; lb < palgo->VL53L1_p_023; lb++) {
|
||||
palgo->VL53L1_p_043[lb] = 0;
|
||||
palgo->VL53L1_p_046[lb] = 0;
|
||||
palgo->VL53L1_p_047[lb] = 0;
|
||||
palgo->VL53L1_p_048[lb] = 0;
|
||||
palgo->VL53L1_p_008[lb] = 0;
|
||||
}
|
||||
|
||||
palgo->VL53L1_p_049 = 0;
|
||||
palgo->VL53L1_p_050 = VL53L1_D_001;
|
||||
palgo->VL53L1_p_051 = 0;
|
||||
|
||||
|
||||
|
||||
VL53L1_init_histogram_bin_data_struct(
|
||||
0,
|
||||
VL53L1_HISTOGRAM_BUFFER_SIZE,
|
||||
&(palgo->VL53L1_p_010));
|
||||
VL53L1_init_histogram_bin_data_struct(
|
||||
0,
|
||||
VL53L1_HISTOGRAM_BUFFER_SIZE,
|
||||
&(palgo->VL53L1_p_038));
|
||||
VL53L1_init_histogram_bin_data_struct(
|
||||
0,
|
||||
VL53L1_HISTOGRAM_BUFFER_SIZE,
|
||||
&(palgo->VL53L1_p_052));
|
||||
VL53L1_init_histogram_bin_data_struct(
|
||||
0,
|
||||
VL53L1_HISTOGRAM_BUFFER_SIZE,
|
||||
&(palgo->VL53L1_p_053));
|
||||
VL53L1_init_histogram_bin_data_struct(
|
||||
0,
|
||||
VL53L1_HISTOGRAM_BUFFER_SIZE,
|
||||
&(palgo->VL53L1_p_054));
|
||||
}
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_018(
|
||||
uint16_t ambient_threshold_events_scaler,
|
||||
int32_t ambient_threshold_sigma,
|
||||
int32_t min_ambient_threshold_events,
|
||||
uint8_t algo__crosstalk_compensation_enable,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_histogram_bin_data_t *pxtalk,
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo)
|
||||
{
|
||||
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
uint8_t lb = 0;
|
||||
uint8_t VL53L1_p_001 = 0;
|
||||
int64_t tmp = 0;
|
||||
int32_t amb_events = 0;
|
||||
int32_t VL53L1_p_008 = 0;
|
||||
int32_t samples = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
palgo->VL53L1_p_023 = pbins->VL53L1_p_023;
|
||||
palgo->VL53L1_p_022 = pbins->VL53L1_p_022;
|
||||
palgo->VL53L1_p_024 = pbins->VL53L1_p_024;
|
||||
palgo->VL53L1_p_004 = pbins->VL53L1_p_004;
|
||||
|
||||
|
||||
|
||||
palgo->VL53L1_p_031 =
|
||||
VL53L1_decode_vcsel_period(pbins->VL53L1_p_009);
|
||||
|
||||
|
||||
|
||||
tmp = (int64_t)pbins->VL53L1_p_004;
|
||||
tmp *= (int64_t)ambient_threshold_events_scaler;
|
||||
tmp += 2048;
|
||||
tmp = do_division_s(tmp, 4096);
|
||||
amb_events = (int32_t)tmp;
|
||||
|
||||
|
||||
|
||||
for (lb = 0; lb < pbins->VL53L1_p_024; lb++) {
|
||||
|
||||
VL53L1_p_001 = lb >> 2;
|
||||
samples = (int32_t)pbins->bin_rep[VL53L1_p_001];
|
||||
|
||||
if (samples > 0) {
|
||||
|
||||
if (lb < pxtalk->VL53L1_p_024 &&
|
||||
algo__crosstalk_compensation_enable > 0)
|
||||
VL53L1_p_008 = samples * (amb_events +
|
||||
pxtalk->bin_data[lb]);
|
||||
else
|
||||
VL53L1_p_008 = samples * amb_events;
|
||||
|
||||
VL53L1_p_008 = VL53L1_isqrt(VL53L1_p_008);
|
||||
|
||||
VL53L1_p_008 += (samples/2);
|
||||
VL53L1_p_008 /= samples;
|
||||
VL53L1_p_008 *= ambient_threshold_sigma;
|
||||
VL53L1_p_008 += 8;
|
||||
VL53L1_p_008 /= 16;
|
||||
VL53L1_p_008 += amb_events;
|
||||
|
||||
if (VL53L1_p_008 < min_ambient_threshold_events)
|
||||
VL53L1_p_008 = min_ambient_threshold_events;
|
||||
|
||||
palgo->VL53L1_p_056[lb] = VL53L1_p_008;
|
||||
palgo->VL53L1_p_032 = VL53L1_p_008;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
palgo->VL53L1_p_045 = 0;
|
||||
|
||||
for (lb = pbins->VL53L1_p_022; lb < pbins->VL53L1_p_024; lb++) {
|
||||
|
||||
if (pbins->bin_data[lb] > palgo->VL53L1_p_056[lb]) {
|
||||
palgo->VL53L1_p_043[lb] = 1;
|
||||
palgo->VL53L1_p_046[lb] = 1;
|
||||
palgo->VL53L1_p_045++;
|
||||
} else {
|
||||
palgo->VL53L1_p_043[lb] = 0;
|
||||
palgo->VL53L1_p_046[lb] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_019(
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo)
|
||||
{
|
||||
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
uint8_t i = 0;
|
||||
uint8_t j = 0;
|
||||
uint8_t found = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
palgo->VL53L1_p_049 = 0;
|
||||
|
||||
for (i = 0; i < palgo->VL53L1_p_031; i++) {
|
||||
|
||||
j = (i + 1) % palgo->VL53L1_p_031;
|
||||
|
||||
|
||||
|
||||
if (i < palgo->VL53L1_p_024 && j < palgo->VL53L1_p_024) {
|
||||
if (palgo->VL53L1_p_046[i] == 0 &&
|
||||
palgo->VL53L1_p_046[j] == 1 &&
|
||||
found == 0) {
|
||||
palgo->VL53L1_p_049 = i;
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_020(
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo)
|
||||
{
|
||||
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
uint8_t i = 0;
|
||||
uint8_t j = 0;
|
||||
uint8_t lb = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
for (lb = palgo->VL53L1_p_049;
|
||||
lb < (palgo->VL53L1_p_049 +
|
||||
palgo->VL53L1_p_031);
|
||||
lb++) {
|
||||
|
||||
|
||||
|
||||
i = lb % palgo->VL53L1_p_031;
|
||||
j = (lb + 1) % palgo->VL53L1_p_031;
|
||||
|
||||
|
||||
|
||||
if (i < palgo->VL53L1_p_024 && j < palgo->VL53L1_p_024) {
|
||||
|
||||
if (palgo->VL53L1_p_046[i] == 0 &&
|
||||
palgo->VL53L1_p_046[j] == 1)
|
||||
palgo->VL53L1_p_051++;
|
||||
|
||||
if (palgo->VL53L1_p_051 > palgo->VL53L1_p_050)
|
||||
palgo->VL53L1_p_051 = palgo->VL53L1_p_050;
|
||||
|
||||
if (palgo->VL53L1_p_046[i] > 0)
|
||||
palgo->VL53L1_p_047[i] = palgo->VL53L1_p_051;
|
||||
else
|
||||
palgo->VL53L1_p_047[i] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_021(
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo)
|
||||
{
|
||||
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
uint8_t i = 0;
|
||||
uint8_t j = 0;
|
||||
uint8_t blb = 0;
|
||||
uint8_t pulse_no = 0;
|
||||
|
||||
uint8_t max_filter_half_width = 0;
|
||||
|
||||
VL53L1_hist_pulse_data_t *pdata;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
max_filter_half_width = palgo->VL53L1_p_031 - 1;
|
||||
max_filter_half_width = max_filter_half_width >> 1;
|
||||
|
||||
for (blb = palgo->VL53L1_p_049;
|
||||
blb < (palgo->VL53L1_p_049 +
|
||||
palgo->VL53L1_p_031);
|
||||
blb++) {
|
||||
|
||||
|
||||
|
||||
i = blb % palgo->VL53L1_p_031;
|
||||
j = (blb + 1) % palgo->VL53L1_p_031;
|
||||
|
||||
|
||||
|
||||
if (i < palgo->VL53L1_p_024 &&
|
||||
j < palgo->VL53L1_p_024) {
|
||||
|
||||
|
||||
|
||||
if (palgo->VL53L1_p_047[i] == 0 &&
|
||||
palgo->VL53L1_p_047[j] > 0) {
|
||||
|
||||
pulse_no = palgo->VL53L1_p_047[j] - 1;
|
||||
|
||||
if (pulse_no < palgo->VL53L1_p_050) {
|
||||
pdata = &(palgo->VL53L1_p_002[pulse_no]);
|
||||
pdata->VL53L1_p_015 = blb;
|
||||
pdata->VL53L1_p_022 = blb + 1;
|
||||
pdata->VL53L1_p_025 = 0xFF;
|
||||
pdata->VL53L1_p_026 = 0;
|
||||
pdata->VL53L1_p_016 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (palgo->VL53L1_p_047[i] > 0
|
||||
&& palgo->VL53L1_p_047[j] == 0) {
|
||||
|
||||
pulse_no = palgo->VL53L1_p_047[i] - 1;
|
||||
|
||||
if (pulse_no < palgo->VL53L1_p_050) {
|
||||
pdata = &(palgo->VL53L1_p_002[pulse_no]);
|
||||
pdata->VL53L1_p_026 = blb;
|
||||
pdata->VL53L1_p_016 = blb + 1;
|
||||
|
||||
pdata->VL53L1_p_027 =
|
||||
(pdata->VL53L1_p_026 + 1) -
|
||||
pdata->VL53L1_p_022;
|
||||
pdata->VL53L1_p_055 =
|
||||
(pdata->VL53L1_p_016 + 1) -
|
||||
pdata->VL53L1_p_015;
|
||||
|
||||
if (pdata->VL53L1_p_055 >
|
||||
max_filter_half_width)
|
||||
pdata->VL53L1_p_055 =
|
||||
max_filter_half_width;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_028(
|
||||
VL53L1_HistTargetOrder target_order,
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo)
|
||||
{
|
||||
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
VL53L1_hist_pulse_data_t tmp;
|
||||
VL53L1_hist_pulse_data_t *ptmp = &tmp;
|
||||
VL53L1_hist_pulse_data_t *p0;
|
||||
VL53L1_hist_pulse_data_t *p1;
|
||||
|
||||
uint8_t i = 0;
|
||||
uint8_t swapped = 1;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
if (!(palgo->VL53L1_p_051 > 1))
|
||||
goto ENDFUNC;
|
||||
|
||||
while (swapped > 0) {
|
||||
|
||||
swapped = 0;
|
||||
|
||||
for (i = 1; i < palgo->VL53L1_p_051; i++) {
|
||||
|
||||
p0 = &(palgo->VL53L1_p_002[i-1]);
|
||||
p1 = &(palgo->VL53L1_p_002[i]);
|
||||
|
||||
|
||||
|
||||
if (target_order
|
||||
== VL53L1_HIST_TARGET_ORDER__STRONGEST_FIRST) {
|
||||
|
||||
if (p0->VL53L1_p_013 <
|
||||
p1->VL53L1_p_013) {
|
||||
|
||||
|
||||
|
||||
memcpy(ptmp,
|
||||
p1, sizeof(VL53L1_hist_pulse_data_t));
|
||||
memcpy(p1,
|
||||
p0, sizeof(VL53L1_hist_pulse_data_t));
|
||||
memcpy(p0,
|
||||
ptmp, sizeof(VL53L1_hist_pulse_data_t));
|
||||
|
||||
swapped = 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (p0->VL53L1_p_014 > p1->VL53L1_p_014) {
|
||||
|
||||
|
||||
|
||||
memcpy(ptmp,
|
||||
p1, sizeof(VL53L1_hist_pulse_data_t));
|
||||
memcpy(p1,
|
||||
p0, sizeof(VL53L1_hist_pulse_data_t));
|
||||
memcpy(p0,
|
||||
ptmp, sizeof(VL53L1_hist_pulse_data_t));
|
||||
|
||||
swapped = 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ENDFUNC:
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_022(
|
||||
uint8_t pulse_no,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
uint8_t i = 0;
|
||||
uint8_t lb = 0;
|
||||
|
||||
VL53L1_hist_pulse_data_t *pdata = &(palgo->VL53L1_p_002[pulse_no]);
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
pdata->VL53L1_p_021 = 0;
|
||||
pdata->VL53L1_p_020 = 0;
|
||||
|
||||
for (lb = pdata->VL53L1_p_015; lb <= pdata->VL53L1_p_016; lb++) {
|
||||
i = lb % palgo->VL53L1_p_031;
|
||||
pdata->VL53L1_p_021 += pbins->bin_data[i];
|
||||
pdata->VL53L1_p_020 += palgo->VL53L1_p_004;
|
||||
}
|
||||
|
||||
|
||||
|
||||
pdata->VL53L1_p_013 =
|
||||
pdata->VL53L1_p_021 - pdata->VL53L1_p_020;
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_027(
|
||||
uint8_t pulse_no,
|
||||
uint8_t clip_events,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
uint8_t i = 0;
|
||||
int16_t VL53L1_p_015 = 0;
|
||||
int16_t VL53L1_p_016 = 0;
|
||||
int16_t window_width = 0;
|
||||
uint32_t tmp_phase = 0;
|
||||
|
||||
VL53L1_hist_pulse_data_t *pdata = &(palgo->VL53L1_p_002[pulse_no]);
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
if (pdata->VL53L1_p_025 == 0xFF)
|
||||
pdata->VL53L1_p_025 = 1;
|
||||
|
||||
i = pdata->VL53L1_p_025 % palgo->VL53L1_p_031;
|
||||
|
||||
VL53L1_p_015 = (int16_t)i;
|
||||
VL53L1_p_015 += (int16_t)pdata->VL53L1_p_015;
|
||||
VL53L1_p_015 -= (int16_t)pdata->VL53L1_p_025;
|
||||
|
||||
VL53L1_p_016 = (int16_t)i;
|
||||
VL53L1_p_016 += (int16_t)pdata->VL53L1_p_016;
|
||||
VL53L1_p_016 -= (int16_t)pdata->VL53L1_p_025;
|
||||
|
||||
|
||||
window_width = VL53L1_p_016 - VL53L1_p_015;
|
||||
if (window_width > 3)
|
||||
window_width = 3;
|
||||
|
||||
status =
|
||||
VL53L1_f_030(
|
||||
VL53L1_p_015,
|
||||
VL53L1_p_015 + window_width,
|
||||
palgo->VL53L1_p_031,
|
||||
clip_events,
|
||||
pbins,
|
||||
&(pdata->VL53L1_p_028));
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_f_030(
|
||||
VL53L1_p_016 - window_width,
|
||||
VL53L1_p_016,
|
||||
palgo->VL53L1_p_031,
|
||||
clip_events,
|
||||
pbins,
|
||||
&(pdata->VL53L1_p_029));
|
||||
|
||||
|
||||
if (pdata->VL53L1_p_028 > pdata->VL53L1_p_029) {
|
||||
tmp_phase = pdata->VL53L1_p_028;
|
||||
pdata->VL53L1_p_028 = pdata->VL53L1_p_029;
|
||||
pdata->VL53L1_p_029 = tmp_phase;
|
||||
}
|
||||
|
||||
|
||||
if (pdata->VL53L1_p_014 < pdata->VL53L1_p_028)
|
||||
pdata->VL53L1_p_028 = pdata->VL53L1_p_014;
|
||||
|
||||
|
||||
if (pdata->VL53L1_p_014 > pdata->VL53L1_p_029)
|
||||
pdata->VL53L1_p_029 = pdata->VL53L1_p_014;
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_030(
|
||||
int16_t VL53L1_p_022,
|
||||
int16_t VL53L1_p_026,
|
||||
uint8_t VL53L1_p_031,
|
||||
uint8_t clip_events,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
uint32_t *pphase)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
int16_t i = 0;
|
||||
int16_t lb = 0;
|
||||
|
||||
int64_t VL53L1_p_008 = 0;
|
||||
int64_t event_sum = 0;
|
||||
int64_t weighted_sum = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
*pphase = VL53L1_MAX_ALLOWED_PHASE;
|
||||
|
||||
if (VL53L1_p_031 != 0)
|
||||
for (lb = VL53L1_p_022; lb <= VL53L1_p_026; lb++) {
|
||||
|
||||
if (lb < 0)
|
||||
i = lb + (int16_t)VL53L1_p_031;
|
||||
else
|
||||
i = lb % (int16_t)VL53L1_p_031;
|
||||
|
||||
if ((i >= 0) && (i < VL53L1_HISTOGRAM_BUFFER_SIZE)) {
|
||||
VL53L1_p_008 =
|
||||
(int64_t)pbins->bin_data[i] -
|
||||
(int64_t)pbins->VL53L1_p_004;
|
||||
|
||||
if (clip_events > 0 && VL53L1_p_008 < 0)
|
||||
VL53L1_p_008 = 0;
|
||||
event_sum += VL53L1_p_008;
|
||||
weighted_sum +=
|
||||
(VL53L1_p_008 * (1024 + (2048*(int64_t)lb)));
|
||||
}
|
||||
|
||||
trace_print(
|
||||
VL53L1_TRACE_LEVEL_INFO,
|
||||
"\tb = %5d : i = %5d : VL53L1_p_008 = %8d,",
|
||||
lb, i, VL53L1_p_008);
|
||||
|
||||
trace_print(
|
||||
VL53L1_TRACE_LEVEL_INFO,
|
||||
" event_sum = %8d, weighted_sum = %8d\n",
|
||||
event_sum, weighted_sum);
|
||||
}
|
||||
|
||||
if (event_sum > 0) {
|
||||
weighted_sum += do_division_s(event_sum, 2);
|
||||
weighted_sum = do_division_s(weighted_sum, event_sum);
|
||||
if (weighted_sum < 0)
|
||||
weighted_sum = 0;
|
||||
*pphase = (uint32_t)weighted_sum;
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_023(
|
||||
uint8_t pulse_no,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo,
|
||||
int32_t pad_value,
|
||||
VL53L1_histogram_bin_data_t *ppulse)
|
||||
{
|
||||
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
uint8_t i = 0;
|
||||
uint8_t lb = 0;
|
||||
|
||||
VL53L1_hist_pulse_data_t *pdata = &(palgo->VL53L1_p_002[pulse_no]);
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
memcpy(ppulse, pbins, sizeof(VL53L1_histogram_bin_data_t));
|
||||
|
||||
|
||||
|
||||
for (lb = palgo->VL53L1_p_049;
|
||||
lb < (palgo->VL53L1_p_049 +
|
||||
palgo->VL53L1_p_031);
|
||||
lb++) {
|
||||
|
||||
if (lb < pdata->VL53L1_p_015 || lb > pdata->VL53L1_p_016) {
|
||||
i = lb % palgo->VL53L1_p_031;
|
||||
if (i < ppulse->VL53L1_p_024)
|
||||
ppulse->bin_data[i] = pad_value;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_026(
|
||||
uint8_t bin,
|
||||
uint8_t sigma_estimator__sigma_ref_mm,
|
||||
uint8_t VL53L1_p_031,
|
||||
uint8_t VL53L1_p_055,
|
||||
uint8_t crosstalk_compensation_enable,
|
||||
VL53L1_histogram_bin_data_t *phist_data_ap,
|
||||
VL53L1_histogram_bin_data_t *phist_data_zp,
|
||||
VL53L1_histogram_bin_data_t *pxtalk_hist,
|
||||
uint16_t *psigma_est)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
VL53L1_Error func_status = VL53L1_ERROR_NONE;
|
||||
|
||||
uint8_t i = 0;
|
||||
int32_t VL53L1_p_003 = 0;
|
||||
int32_t VL53L1_p_018 = 0;
|
||||
int32_t VL53L1_p_001 = 0;
|
||||
int32_t a_zp = 0;
|
||||
int32_t c_zp = 0;
|
||||
int32_t ax = 0;
|
||||
int32_t bx = 0;
|
||||
int32_t cx = 0;
|
||||
|
||||
|
||||
if (VL53L1_p_031 == 0) {
|
||||
*psigma_est = 0xFFFF;
|
||||
return VL53L1_ERROR_DIVISION_BY_ZERO;
|
||||
}
|
||||
i = bin % VL53L1_p_031;
|
||||
|
||||
|
||||
|
||||
VL53L1_f_013(
|
||||
i,
|
||||
VL53L1_p_055,
|
||||
phist_data_zp,
|
||||
&a_zp,
|
||||
&VL53L1_p_018,
|
||||
&c_zp);
|
||||
|
||||
|
||||
|
||||
VL53L1_f_013(
|
||||
i,
|
||||
VL53L1_p_055,
|
||||
phist_data_ap,
|
||||
&VL53L1_p_003,
|
||||
&VL53L1_p_018,
|
||||
&VL53L1_p_001);
|
||||
|
||||
if (crosstalk_compensation_enable > 0)
|
||||
VL53L1_f_013(
|
||||
i,
|
||||
VL53L1_p_055,
|
||||
pxtalk_hist,
|
||||
&ax,
|
||||
&bx,
|
||||
&cx);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func_status =
|
||||
VL53L1_f_014(
|
||||
sigma_estimator__sigma_ref_mm,
|
||||
(uint32_t)VL53L1_p_003,
|
||||
(uint32_t)VL53L1_p_018,
|
||||
(uint32_t)VL53L1_p_001,
|
||||
(uint32_t)a_zp,
|
||||
(uint32_t)c_zp,
|
||||
(uint32_t)bx,
|
||||
(uint32_t)ax,
|
||||
(uint32_t)cx,
|
||||
(uint32_t)phist_data_ap->VL53L1_p_004,
|
||||
phist_data_ap->VL53L1_p_019,
|
||||
psigma_est);
|
||||
|
||||
|
||||
|
||||
|
||||
if (func_status == VL53L1_ERROR_DIVISION_BY_ZERO)
|
||||
*psigma_est = 0xFFFF;
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
void VL53L1_f_029(
|
||||
uint8_t range_id,
|
||||
uint8_t valid_phase_low,
|
||||
uint8_t valid_phase_high,
|
||||
uint16_t sigma_thres,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_hist_pulse_data_t *ppulse,
|
||||
VL53L1_range_data_t *pdata)
|
||||
{
|
||||
|
||||
uint16_t lower_phase_limit = 0;
|
||||
uint16_t upper_phase_limit = 0;
|
||||
|
||||
|
||||
|
||||
pdata->range_id = range_id;
|
||||
pdata->time_stamp = 0;
|
||||
|
||||
pdata->VL53L1_p_015 = ppulse->VL53L1_p_015;
|
||||
pdata->VL53L1_p_022 = ppulse->VL53L1_p_022;
|
||||
pdata->VL53L1_p_025 = ppulse->VL53L1_p_025;
|
||||
pdata->VL53L1_p_026 = ppulse->VL53L1_p_026;
|
||||
pdata->VL53L1_p_016 = ppulse->VL53L1_p_016;
|
||||
pdata->VL53L1_p_027 = ppulse->VL53L1_p_027;
|
||||
|
||||
|
||||
|
||||
pdata->VL53L1_p_030 =
|
||||
(ppulse->VL53L1_p_016 + 1) - ppulse->VL53L1_p_015;
|
||||
|
||||
|
||||
|
||||
pdata->zero_distance_phase = pbins->zero_distance_phase;
|
||||
pdata->VL53L1_p_005 = ppulse->VL53L1_p_005;
|
||||
pdata->VL53L1_p_028 = (uint16_t)ppulse->VL53L1_p_028;
|
||||
pdata->VL53L1_p_014 = (uint16_t)ppulse->VL53L1_p_014;
|
||||
pdata->VL53L1_p_029 = (uint16_t)ppulse->VL53L1_p_029;
|
||||
pdata->VL53L1_p_021 = (uint32_t)ppulse->VL53L1_p_021;
|
||||
pdata->VL53L1_p_013 = ppulse->VL53L1_p_013;
|
||||
pdata->VL53L1_p_020 = (uint32_t)ppulse->VL53L1_p_020;
|
||||
pdata->total_periods_elapsed = pbins->total_periods_elapsed;
|
||||
|
||||
|
||||
|
||||
pdata->range_status = VL53L1_DEVICEERROR_RANGECOMPLETE_NO_WRAP_CHECK;
|
||||
|
||||
|
||||
if (sigma_thres > 0 &&
|
||||
(uint32_t)ppulse->VL53L1_p_005 > ((uint32_t)sigma_thres << 5))
|
||||
pdata->range_status = VL53L1_DEVICEERROR_SIGMATHRESHOLDCHECK;
|
||||
|
||||
|
||||
|
||||
lower_phase_limit = (uint8_t)valid_phase_low << 8;
|
||||
if (lower_phase_limit < pdata->zero_distance_phase)
|
||||
lower_phase_limit =
|
||||
pdata->zero_distance_phase -
|
||||
lower_phase_limit;
|
||||
else
|
||||
lower_phase_limit = 0;
|
||||
|
||||
upper_phase_limit = (uint8_t)valid_phase_high << 8;
|
||||
upper_phase_limit += pbins->zero_distance_phase;
|
||||
|
||||
if (pdata->VL53L1_p_014 < lower_phase_limit ||
|
||||
pdata->VL53L1_p_014 > upper_phase_limit)
|
||||
pdata->range_status = VL53L1_DEVICEERROR_RANGEPHASECHECK;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,558 @@
|
|||
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 Protected and is dual licensed,
|
||||
either 'STMicroelectronics Proprietary license'
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
|
||||
******************************************************************************
|
||||
|
||||
'STMicroelectronics Proprietary license'
|
||||
|
||||
******************************************************************************
|
||||
|
||||
License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
terms at www.st.com/sla0081
|
||||
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_platform_log.h"
|
||||
|
||||
#include "vl53l1_core_support.h"
|
||||
#include "vl53l1_error_codes.h"
|
||||
|
||||
#include "vl53l1_hist_core.h"
|
||||
#include "vl53l1_hist_algos_gen3.h"
|
||||
#include "vl53l1_hist_algos_gen4.h"
|
||||
#include "vl53l1_sigma_estimate.h"
|
||||
#include "vl53l1_dmax.h"
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/math64.h>
|
||||
#include <linux/kernel.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define LOG_FUNCTION_START(fmt, ...) \
|
||||
_LOG_FUNCTION_START(VL53L1_TRACE_MODULE_HISTOGRAM, fmt, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END(status, ...) \
|
||||
_LOG_FUNCTION_END(VL53L1_TRACE_MODULE_HISTOGRAM, status, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
|
||||
_LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_HISTOGRAM, \
|
||||
status, fmt, ##__VA_ARGS__)
|
||||
|
||||
#define trace_print(level, ...) \
|
||||
_LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_HISTOGRAM, \
|
||||
level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
|
||||
|
||||
|
||||
void VL53L1_f_032(
|
||||
VL53L1_hist_gen4_algo_filtered_data_t *palgo)
|
||||
{
|
||||
|
||||
|
||||
uint8_t lb = 0;
|
||||
|
||||
palgo->VL53L1_p_023 = VL53L1_HISTOGRAM_BUFFER_SIZE;
|
||||
palgo->VL53L1_p_022 = 0;
|
||||
palgo->VL53L1_p_024 = 0;
|
||||
|
||||
for (lb = palgo->VL53L1_p_022; lb < palgo->VL53L1_p_023; lb++) {
|
||||
palgo->VL53L1_p_003[lb] = 0;
|
||||
palgo->VL53L1_p_018[lb] = 0;
|
||||
palgo->VL53L1_p_001[lb] = 0;
|
||||
palgo->VL53L1_p_039[lb] = 0;
|
||||
palgo->VL53L1_p_040[lb] = 0;
|
||||
palgo->VL53L1_p_043[lb] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_033(
|
||||
VL53L1_dmax_calibration_data_t *pdmax_cal,
|
||||
VL53L1_hist_gen3_dmax_config_t *pdmax_cfg,
|
||||
VL53L1_hist_post_process_config_t *ppost_cfg,
|
||||
VL53L1_histogram_bin_data_t *pbins_input,
|
||||
VL53L1_histogram_bin_data_t *pxtalk,
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo3,
|
||||
VL53L1_hist_gen4_algo_filtered_data_t *pfiltered,
|
||||
VL53L1_hist_gen3_dmax_private_data_t *pdmax_algo,
|
||||
VL53L1_range_results_t *presults,
|
||||
uint8_t histo_merge_nb)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
VL53L1_hist_pulse_data_t *ppulse_data;
|
||||
VL53L1_range_data_t *prange_data;
|
||||
|
||||
uint8_t p = 0;
|
||||
VL53L1_histogram_bin_data_t *pB = &(palgo3->VL53L1_p_010);
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_f_016(palgo3);
|
||||
|
||||
|
||||
|
||||
memcpy(
|
||||
&(palgo3->VL53L1_p_010),
|
||||
pbins_input,
|
||||
sizeof(VL53L1_histogram_bin_data_t));
|
||||
|
||||
|
||||
|
||||
presults->cfg_device_state = pbins_input->cfg_device_state;
|
||||
presults->rd_device_state = pbins_input->rd_device_state;
|
||||
presults->zone_id = pbins_input->zone_id;
|
||||
presults->stream_count = pbins_input->result__stream_count;
|
||||
presults->wrap_dmax_mm = 0;
|
||||
presults->max_results = VL53L1_MAX_RANGE_RESULTS;
|
||||
presults->active_results = 0;
|
||||
|
||||
for (p = 0; p < VL53L1_MAX_AMBIENT_DMAX_VALUES; p++)
|
||||
presults->VL53L1_p_007[p] = 0;
|
||||
|
||||
|
||||
|
||||
VL53L1_hist_calc_zero_distance_phase(&(palgo3->VL53L1_p_010));
|
||||
|
||||
|
||||
|
||||
VL53L1_hist_estimate_ambient_from_thresholded_bins(
|
||||
(int32_t)ppost_cfg->ambient_thresh_sigma0,
|
||||
&(palgo3->VL53L1_p_010));
|
||||
|
||||
VL53L1_hist_estimate_ambient_from_ambient_bins(
|
||||
&(palgo3->VL53L1_p_010));
|
||||
|
||||
|
||||
VL53L1_hist_remove_ambient_bins(&(palgo3->VL53L1_p_010));
|
||||
|
||||
|
||||
if (ppost_cfg->algo__crosstalk_compensation_enable > 0)
|
||||
VL53L1_f_004(
|
||||
pxtalk,
|
||||
&(palgo3->VL53L1_p_010),
|
||||
&(palgo3->VL53L1_p_038));
|
||||
|
||||
|
||||
pdmax_cfg->ambient_thresh_sigma =
|
||||
ppost_cfg->ambient_thresh_sigma1;
|
||||
|
||||
for (p = 0; p < VL53L1_MAX_AMBIENT_DMAX_VALUES; p++) {
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
status =
|
||||
VL53L1_f_001(
|
||||
pdmax_cfg->target_reflectance_for_dmax_calc[p],
|
||||
pdmax_cal,
|
||||
pdmax_cfg,
|
||||
&(palgo3->VL53L1_p_010),
|
||||
pdmax_algo,
|
||||
&(presults->VL53L1_p_007[p]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_f_018(
|
||||
ppost_cfg->ambient_thresh_events_scaler,
|
||||
(int32_t)pdmax_cfg->ambient_thresh_sigma,
|
||||
(int32_t)ppost_cfg->min_ambient_thresh_events,
|
||||
ppost_cfg->algo__crosstalk_compensation_enable,
|
||||
&(palgo3->VL53L1_p_010),
|
||||
&(palgo3->VL53L1_p_038),
|
||||
palgo3);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_f_019(palgo3);
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_f_020(palgo3);
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_f_021(palgo3);
|
||||
|
||||
|
||||
|
||||
for (p = 0; p < palgo3->VL53L1_p_051; p++) {
|
||||
|
||||
ppulse_data = &(palgo3->VL53L1_p_002[p]);
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_f_022(
|
||||
p,
|
||||
&(palgo3->VL53L1_p_010),
|
||||
palgo3);
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_f_023(
|
||||
p,
|
||||
&(palgo3->VL53L1_p_010),
|
||||
palgo3,
|
||||
pB->VL53L1_p_004,
|
||||
&(palgo3->VL53L1_p_052));
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
status =
|
||||
VL53L1_f_023(
|
||||
p,
|
||||
&(palgo3->VL53L1_p_010),
|
||||
palgo3,
|
||||
0,
|
||||
&(palgo3->VL53L1_p_053));
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
status =
|
||||
VL53L1_f_023(
|
||||
p,
|
||||
&(palgo3->VL53L1_p_038),
|
||||
palgo3,
|
||||
0,
|
||||
&(palgo3->VL53L1_p_054));
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_f_034(
|
||||
p,
|
||||
&(palgo3->VL53L1_p_052),
|
||||
palgo3,
|
||||
pfiltered);
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_f_035(
|
||||
p,
|
||||
ppost_cfg->noise_threshold,
|
||||
pfiltered,
|
||||
palgo3);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_f_026(
|
||||
ppulse_data->VL53L1_p_025,
|
||||
ppost_cfg->sigma_estimator__sigma_ref_mm,
|
||||
palgo3->VL53L1_p_031,
|
||||
ppulse_data->VL53L1_p_055,
|
||||
ppost_cfg->algo__crosstalk_compensation_enable,
|
||||
&(palgo3->VL53L1_p_052),
|
||||
&(palgo3->VL53L1_p_053),
|
||||
&(palgo3->VL53L1_p_054),
|
||||
&(ppulse_data->VL53L1_p_005));
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_f_027(
|
||||
p,
|
||||
1,
|
||||
&(palgo3->VL53L1_p_010),
|
||||
palgo3);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_f_028(
|
||||
ppost_cfg->hist_target_order,
|
||||
palgo3);
|
||||
|
||||
|
||||
|
||||
for (p = 0; p < palgo3->VL53L1_p_051; p++) {
|
||||
|
||||
ppulse_data = &(palgo3->VL53L1_p_002[p]);
|
||||
|
||||
|
||||
if (!(presults->active_results < presults->max_results))
|
||||
continue;
|
||||
|
||||
|
||||
|
||||
|
||||
if (ppulse_data->VL53L1_p_013 >
|
||||
ppost_cfg->signal_total_events_limit &&
|
||||
ppulse_data->VL53L1_p_025 < 0xFF) {
|
||||
|
||||
prange_data =
|
||||
&(presults->VL53L1_p_002[presults->active_results]);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
VL53L1_f_029(
|
||||
presults->active_results,
|
||||
ppost_cfg->valid_phase_low,
|
||||
ppost_cfg->valid_phase_high,
|
||||
ppost_cfg->sigma_thresh,
|
||||
&(palgo3->VL53L1_p_010),
|
||||
ppulse_data,
|
||||
prange_data);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_f_011(
|
||||
pB->vcsel_width,
|
||||
pB->VL53L1_p_019,
|
||||
pB->total_periods_elapsed,
|
||||
pB->result__dss_actual_effective_spads,
|
||||
prange_data,
|
||||
histo_merge_nb);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
VL53L1_f_012(
|
||||
ppost_cfg->gain_factor,
|
||||
ppost_cfg->range_offset_mm,
|
||||
prange_data);
|
||||
|
||||
presults->active_results++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_034(
|
||||
uint8_t pulse_no,
|
||||
VL53L1_histogram_bin_data_t *ppulse,
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo3,
|
||||
VL53L1_hist_gen4_algo_filtered_data_t *pfiltered)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
VL53L1_hist_pulse_data_t *pdata = &(palgo3->VL53L1_p_002[pulse_no]);
|
||||
|
||||
uint8_t lb = 0;
|
||||
uint8_t i = 0;
|
||||
int32_t suma = 0;
|
||||
int32_t sumb = 0;
|
||||
int32_t sumc = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
pfiltered->VL53L1_p_023 = palgo3->VL53L1_p_023;
|
||||
pfiltered->VL53L1_p_022 = palgo3->VL53L1_p_022;
|
||||
pfiltered->VL53L1_p_024 = palgo3->VL53L1_p_024;
|
||||
|
||||
|
||||
|
||||
for (lb = pdata->VL53L1_p_015; lb <= pdata->VL53L1_p_016; lb++) {
|
||||
|
||||
i = lb % palgo3->VL53L1_p_031;
|
||||
|
||||
|
||||
VL53L1_f_013(
|
||||
i,
|
||||
pdata->VL53L1_p_055,
|
||||
ppulse,
|
||||
&suma,
|
||||
&sumb,
|
||||
&sumc);
|
||||
|
||||
|
||||
pfiltered->VL53L1_p_003[i] = suma;
|
||||
pfiltered->VL53L1_p_018[i] = sumb;
|
||||
pfiltered->VL53L1_p_001[i] = sumc;
|
||||
|
||||
|
||||
|
||||
pfiltered->VL53L1_p_039[i] =
|
||||
(suma + sumb) -
|
||||
(sumc + palgo3->VL53L1_p_004);
|
||||
|
||||
|
||||
|
||||
pfiltered->VL53L1_p_040[i] =
|
||||
(sumb + sumc) -
|
||||
(suma + palgo3->VL53L1_p_004);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_035(
|
||||
uint8_t pulse_no,
|
||||
uint16_t noise_threshold,
|
||||
VL53L1_hist_gen4_algo_filtered_data_t *pfiltered,
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo3)
|
||||
{
|
||||
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
VL53L1_Error func_status = VL53L1_ERROR_NONE;
|
||||
|
||||
VL53L1_hist_pulse_data_t *pdata = &(palgo3->VL53L1_p_002[pulse_no]);
|
||||
|
||||
uint8_t lb = 0;
|
||||
uint8_t i = 0;
|
||||
uint8_t j = 0;
|
||||
|
||||
SUPPRESS_UNUSED_WARNING(noise_threshold);
|
||||
|
||||
for (lb = pdata->VL53L1_p_015; lb < pdata->VL53L1_p_016; lb++) {
|
||||
|
||||
i = lb % palgo3->VL53L1_p_031;
|
||||
j = (lb+1) % palgo3->VL53L1_p_031;
|
||||
|
||||
if (i < palgo3->VL53L1_p_024 &&
|
||||
j < palgo3->VL53L1_p_024) {
|
||||
|
||||
if (pfiltered->VL53L1_p_039[i] == 0 &&
|
||||
pfiltered->VL53L1_p_040[i] == 0)
|
||||
|
||||
pfiltered->VL53L1_p_043[i] = 0;
|
||||
|
||||
else if (pfiltered->VL53L1_p_039[i] >= 0 &&
|
||||
pfiltered->VL53L1_p_040[i] >= 0)
|
||||
pfiltered->VL53L1_p_043[i] = 1;
|
||||
|
||||
else if (pfiltered->VL53L1_p_039[i] < 0 &&
|
||||
pfiltered->VL53L1_p_040[i] >= 0 &&
|
||||
pfiltered->VL53L1_p_039[j] >= 0 &&
|
||||
pfiltered->VL53L1_p_040[j] < 0)
|
||||
pfiltered->VL53L1_p_043[i] = 1;
|
||||
|
||||
else
|
||||
pfiltered->VL53L1_p_043[i] = 0;
|
||||
|
||||
|
||||
if (pfiltered->VL53L1_p_043[i] > 0) {
|
||||
|
||||
pdata->VL53L1_p_025 = lb;
|
||||
|
||||
func_status =
|
||||
VL53L1_f_036(
|
||||
lb,
|
||||
pfiltered->VL53L1_p_003[i],
|
||||
pfiltered->VL53L1_p_018[i],
|
||||
pfiltered->VL53L1_p_001[i],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
palgo3->VL53L1_p_004,
|
||||
palgo3->VL53L1_p_031,
|
||||
&(pdata->VL53L1_p_014));
|
||||
|
||||
if (func_status ==
|
||||
VL53L1_ERROR_DIVISION_BY_ZERO)
|
||||
pfiltered->VL53L1_p_043[i] = 0;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_036(
|
||||
uint8_t bin,
|
||||
int32_t VL53L1_p_003,
|
||||
int32_t VL53L1_p_018,
|
||||
int32_t VL53L1_p_001,
|
||||
int32_t ax,
|
||||
int32_t bx,
|
||||
int32_t cx,
|
||||
int32_t VL53L1_p_004,
|
||||
uint8_t VL53L1_p_031,
|
||||
uint32_t *pmean_phase)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_DIVISION_BY_ZERO;
|
||||
|
||||
int64_t mean_phase = VL53L1_MAX_ALLOWED_PHASE;
|
||||
int32_t mean_phase32;
|
||||
int64_t VL53L1_p_041 = 0;
|
||||
int64_t half_b_minus_amb = 0;
|
||||
|
||||
|
||||
VL53L1_p_041 = 4096 * ((int64_t)VL53L1_p_001 -
|
||||
(int64_t)cx - (int64_t)VL53L1_p_003 - (int64_t)ax);
|
||||
half_b_minus_amb = 4096 * ((int64_t)VL53L1_p_018 -
|
||||
(int64_t)bx - (int64_t)VL53L1_p_004);
|
||||
|
||||
if (half_b_minus_amb != 0) {
|
||||
mean_phase = (4096 * VL53L1_p_041) + half_b_minus_amb;
|
||||
mean_phase = do_division_s(mean_phase, (half_b_minus_amb * 2));
|
||||
mean_phase += 2048;
|
||||
mean_phase += (4096 * (int64_t)bin);
|
||||
|
||||
mean_phase = do_division_s((mean_phase + 1), 2);
|
||||
|
||||
if (mean_phase < 0)
|
||||
mean_phase = 0;
|
||||
if (mean_phase > VL53L1_MAX_ALLOWED_PHASE)
|
||||
mean_phase = VL53L1_MAX_ALLOWED_PHASE;
|
||||
|
||||
mean_phase32 = (int32_t)mean_phase;
|
||||
mean_phase32 = mean_phase32 %
|
||||
((int32_t)VL53L1_p_031 * 2048);
|
||||
mean_phase = mean_phase32;
|
||||
|
||||
status = VL53L1_ERROR_NONE;
|
||||
}
|
||||
|
||||
*pmean_phase = (uint32_t)mean_phase;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,522 @@
|
|||
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 Protected and is dual licensed,
|
||||
either 'STMicroelectronics Proprietary license'
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
|
||||
******************************************************************************
|
||||
|
||||
'STMicroelectronics Proprietary license'
|
||||
|
||||
******************************************************************************
|
||||
|
||||
License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
terms at www.st.com/sla0081
|
||||
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "vl53l1_platform_log.h"
|
||||
|
||||
#include "vl53l1_core_support.h"
|
||||
#include "vl53l1_hist_structs.h"
|
||||
|
||||
#include "vl53l1_xtalk.h"
|
||||
#include "vl53l1_sigma_estimate.h"
|
||||
|
||||
#include "vl53l1_hist_core.h"
|
||||
|
||||
|
||||
|
||||
#define LOG_FUNCTION_START(fmt, ...) \
|
||||
_LOG_FUNCTION_START(VL53L1_TRACE_MODULE_HISTOGRAM, fmt, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END(status, ...) \
|
||||
_LOG_FUNCTION_END(VL53L1_TRACE_MODULE_HISTOGRAM, status, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
|
||||
_LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_HISTOGRAM, \
|
||||
status, fmt, ##__VA_ARGS__)
|
||||
|
||||
#define trace_print(level, ...) \
|
||||
_LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_HISTOGRAM, \
|
||||
level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
|
||||
|
||||
|
||||
void VL53L1_f_013(
|
||||
uint8_t VL53L1_p_018,
|
||||
uint8_t filter_woi,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
int32_t *pa,
|
||||
int32_t *pb,
|
||||
int32_t *pc)
|
||||
{
|
||||
|
||||
|
||||
uint8_t w = 0;
|
||||
uint8_t j = 0;
|
||||
|
||||
*pa = 0;
|
||||
*pb = pbins->bin_data[VL53L1_p_018];
|
||||
*pc = 0;
|
||||
|
||||
for (w = 0 ; w < ((filter_woi << 1)+1) ; w++) {
|
||||
|
||||
|
||||
j = ((VL53L1_p_018 + w + pbins->VL53L1_p_024) -
|
||||
filter_woi) % pbins->VL53L1_p_024;
|
||||
|
||||
|
||||
if (w < filter_woi)
|
||||
*pa += pbins->bin_data[j];
|
||||
else if (w > filter_woi)
|
||||
*pc += pbins->bin_data[j];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_011(
|
||||
uint16_t vcsel_width,
|
||||
uint16_t fast_osc_frequency,
|
||||
uint32_t total_periods_elapsed,
|
||||
uint16_t VL53L1_p_006,
|
||||
VL53L1_range_data_t *pdata,
|
||||
uint8_t histo_merge_nb)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
uint32_t pll_period_us = 0;
|
||||
uint32_t periods_elapsed = 0;
|
||||
uint32_t count_rate_total = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
pdata->width = vcsel_width;
|
||||
pdata->fast_osc_frequency = fast_osc_frequency;
|
||||
pdata->total_periods_elapsed = total_periods_elapsed;
|
||||
pdata->VL53L1_p_006 = VL53L1_p_006;
|
||||
|
||||
|
||||
|
||||
if (pdata->fast_osc_frequency == 0)
|
||||
status = VL53L1_ERROR_DIVISION_BY_ZERO;
|
||||
|
||||
if (pdata->total_periods_elapsed == 0)
|
||||
status = VL53L1_ERROR_DIVISION_BY_ZERO;
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
|
||||
|
||||
|
||||
pll_period_us =
|
||||
VL53L1_calc_pll_period_us(pdata->fast_osc_frequency);
|
||||
|
||||
|
||||
|
||||
periods_elapsed = pdata->total_periods_elapsed + 1;
|
||||
|
||||
|
||||
|
||||
pdata->peak_duration_us = VL53L1_duration_maths(
|
||||
pll_period_us,
|
||||
(uint32_t)pdata->width,
|
||||
VL53L1_RANGING_WINDOW_VCSEL_PERIODS,
|
||||
periods_elapsed);
|
||||
|
||||
pdata->woi_duration_us = VL53L1_duration_maths(
|
||||
pll_period_us,
|
||||
((uint32_t)pdata->VL53L1_p_030) << 4,
|
||||
VL53L1_RANGING_WINDOW_VCSEL_PERIODS,
|
||||
periods_elapsed);
|
||||
|
||||
|
||||
|
||||
pdata->peak_signal_count_rate_mcps = VL53L1_rate_maths(
|
||||
(int32_t)pdata->VL53L1_p_013,
|
||||
pdata->peak_duration_us);
|
||||
|
||||
pdata->avg_signal_count_rate_mcps = VL53L1_rate_maths(
|
||||
(int32_t)pdata->VL53L1_p_013,
|
||||
pdata->woi_duration_us);
|
||||
|
||||
pdata->ambient_count_rate_mcps = VL53L1_rate_maths(
|
||||
(int32_t)pdata->VL53L1_p_020,
|
||||
pdata->woi_duration_us);
|
||||
|
||||
|
||||
|
||||
count_rate_total =
|
||||
(uint32_t)pdata->peak_signal_count_rate_mcps +
|
||||
(uint32_t)pdata->ambient_count_rate_mcps;
|
||||
|
||||
if (histo_merge_nb > 1)
|
||||
count_rate_total /= histo_merge_nb;
|
||||
|
||||
pdata->total_rate_per_spad_mcps =
|
||||
VL53L1_rate_per_spad_maths(
|
||||
0x06,
|
||||
count_rate_total,
|
||||
pdata->VL53L1_p_006,
|
||||
0xFFFF);
|
||||
|
||||
|
||||
|
||||
pdata->VL53L1_p_012 =
|
||||
VL53L1_events_per_spad_maths(
|
||||
pdata->VL53L1_p_013,
|
||||
pdata->VL53L1_p_006,
|
||||
pdata->peak_duration_us);
|
||||
|
||||
|
||||
|
||||
|
||||
trace_print(
|
||||
VL53L1_TRACE_LEVEL_DEBUG,
|
||||
" %d:%-46s : %10d\n",
|
||||
pdata->range_id, "peak_duration_us",
|
||||
pdata->peak_duration_us);
|
||||
trace_print(
|
||||
VL53L1_TRACE_LEVEL_DEBUG,
|
||||
" %d:%-46s : %10d\n",
|
||||
pdata->range_id, "woi_duration_us",
|
||||
pdata->woi_duration_us);
|
||||
trace_print(
|
||||
VL53L1_TRACE_LEVEL_DEBUG,
|
||||
" %d:%-46s : %10u\n",
|
||||
pdata->range_id, "peak_signal_count_rate_mcps",
|
||||
pdata->peak_signal_count_rate_mcps);
|
||||
trace_print(
|
||||
VL53L1_TRACE_LEVEL_DEBUG,
|
||||
" %d:%-46s : %10u\n",
|
||||
pdata->range_id, "ambient_count_rate_mcps",
|
||||
pdata->ambient_count_rate_mcps);
|
||||
trace_print(
|
||||
VL53L1_TRACE_LEVEL_DEBUG,
|
||||
" %d:%-46s : %10u\n",
|
||||
pdata->range_id, "total_rate_per_spad_mcps",
|
||||
pdata->total_rate_per_spad_mcps);
|
||||
trace_print(
|
||||
VL53L1_TRACE_LEVEL_DEBUG,
|
||||
" %d:%-46s : %10u\n",
|
||||
pdata->range_id, "VL53L1_p_012",
|
||||
pdata->VL53L1_p_012);
|
||||
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
void VL53L1_f_012(
|
||||
uint16_t gain_factor,
|
||||
int16_t range_offset_mm,
|
||||
VL53L1_range_data_t *pdata)
|
||||
{
|
||||
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
pdata->min_range_mm =
|
||||
(int16_t)VL53L1_range_maths(
|
||||
pdata->fast_osc_frequency,
|
||||
pdata->VL53L1_p_028,
|
||||
pdata->zero_distance_phase,
|
||||
0,
|
||||
(int32_t)gain_factor,
|
||||
(int32_t)range_offset_mm);
|
||||
|
||||
pdata->median_range_mm =
|
||||
(int16_t)VL53L1_range_maths(
|
||||
pdata->fast_osc_frequency,
|
||||
pdata->VL53L1_p_014,
|
||||
pdata->zero_distance_phase,
|
||||
0,
|
||||
(int32_t)gain_factor,
|
||||
(int32_t)range_offset_mm);
|
||||
|
||||
pdata->max_range_mm =
|
||||
(int16_t)VL53L1_range_maths(
|
||||
pdata->fast_osc_frequency,
|
||||
pdata->VL53L1_p_029,
|
||||
pdata->zero_distance_phase,
|
||||
0,
|
||||
(int32_t)gain_factor,
|
||||
(int32_t)range_offset_mm);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
LOG_FUNCTION_END(0);
|
||||
}
|
||||
|
||||
|
||||
void VL53L1_f_037(
|
||||
VL53L1_histogram_bin_data_t *pdata,
|
||||
int32_t ambient_estimate_counts_per_bin)
|
||||
{
|
||||
|
||||
|
||||
uint8_t i = 0;
|
||||
|
||||
for (i = 0 ; i < pdata->VL53L1_p_024 ; i++)
|
||||
pdata->bin_data[i] = pdata->bin_data[i] -
|
||||
ambient_estimate_counts_per_bin;
|
||||
}
|
||||
|
||||
|
||||
void VL53L1_f_004(
|
||||
VL53L1_histogram_bin_data_t *pxtalk,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_histogram_bin_data_t *pxtalk_realigned)
|
||||
{
|
||||
|
||||
|
||||
uint8_t i = 0;
|
||||
uint8_t min_bins = 0;
|
||||
int8_t bin_offset = 0;
|
||||
int8_t bin_access = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
memcpy(
|
||||
pxtalk_realigned,
|
||||
pbins,
|
||||
sizeof(VL53L1_histogram_bin_data_t));
|
||||
|
||||
for (i = 0 ; i < pxtalk_realigned->VL53L1_p_023 ; i++)
|
||||
pxtalk_realigned->bin_data[i] = 0;
|
||||
|
||||
|
||||
|
||||
bin_offset = VL53L1_f_038(
|
||||
pbins,
|
||||
pxtalk);
|
||||
|
||||
|
||||
|
||||
if (pxtalk->VL53L1_p_024 < pbins->VL53L1_p_024)
|
||||
min_bins = pxtalk->VL53L1_p_024;
|
||||
else
|
||||
min_bins = pbins->VL53L1_p_024;
|
||||
|
||||
|
||||
for (i = 0 ; i < min_bins ; i++) {
|
||||
|
||||
|
||||
|
||||
if (bin_offset >= 0)
|
||||
bin_access = ((int8_t)i + (int8_t)bin_offset)
|
||||
% (int8_t)pbins->VL53L1_p_024;
|
||||
else
|
||||
bin_access = ((int8_t)pbins->VL53L1_p_024 +
|
||||
((int8_t)i + (int8_t)bin_offset))
|
||||
% (int8_t)pbins->VL53L1_p_024;
|
||||
|
||||
trace_print(
|
||||
VL53L1_TRACE_LEVEL_DEBUG,
|
||||
"Subtract: %8d : %8d : %8d : %8d : %8d : %8d\n",
|
||||
i, bin_access, bin_offset, pbins->VL53L1_p_024,
|
||||
pbins->bin_data[(uint8_t)bin_access],
|
||||
pxtalk->bin_data[i]);
|
||||
|
||||
|
||||
|
||||
if (pbins->bin_data[(uint8_t)bin_access] >
|
||||
pxtalk->bin_data[i]) {
|
||||
|
||||
pbins->bin_data[(uint8_t)bin_access] =
|
||||
pbins->bin_data[(uint8_t)bin_access]
|
||||
- pxtalk->bin_data[i];
|
||||
|
||||
} else {
|
||||
pbins->bin_data[(uint8_t)bin_access] = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
pxtalk_realigned->bin_data[(uint8_t)bin_access] =
|
||||
pxtalk->bin_data[i];
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
LOG_FUNCTION_END(0);
|
||||
}
|
||||
|
||||
|
||||
int8_t VL53L1_f_038(
|
||||
VL53L1_histogram_bin_data_t *pdata1,
|
||||
VL53L1_histogram_bin_data_t *pdata2)
|
||||
{
|
||||
|
||||
|
||||
int32_t phase_delta = 0;
|
||||
int8_t bin_offset = 0;
|
||||
uint32_t period = 0;
|
||||
uint32_t remapped_phase = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
period = 2048 *
|
||||
(uint32_t)VL53L1_decode_vcsel_period(pdata1->VL53L1_p_009);
|
||||
|
||||
if (period != 0)
|
||||
remapped_phase =
|
||||
(uint32_t)pdata2->zero_distance_phase % period;
|
||||
|
||||
|
||||
phase_delta = (int32_t)pdata1->zero_distance_phase
|
||||
- (int32_t)remapped_phase;
|
||||
|
||||
|
||||
|
||||
if (phase_delta > 0)
|
||||
bin_offset = (int8_t)((phase_delta + 1024) / 2048);
|
||||
else
|
||||
bin_offset = (int8_t)((phase_delta - 1024) / 2048);
|
||||
|
||||
LOG_FUNCTION_END(0);
|
||||
|
||||
return bin_offset;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_039(
|
||||
VL53L1_histogram_bin_data_t *pidata,
|
||||
VL53L1_histogram_bin_data_t *podata)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
uint8_t bin_initial_index[VL53L1_MAX_BIN_SEQUENCE_CODE+1];
|
||||
uint8_t bin_repeat_count[VL53L1_MAX_BIN_SEQUENCE_CODE+1];
|
||||
|
||||
uint8_t bin_cfg = 0;
|
||||
uint8_t bin_seq_length = 0;
|
||||
int32_t repeat_count = 0;
|
||||
|
||||
uint8_t VL53L1_p_018 = 0;
|
||||
uint8_t lc = 0;
|
||||
uint8_t i = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
memcpy(podata, pidata, sizeof(VL53L1_histogram_bin_data_t));
|
||||
|
||||
|
||||
podata->VL53L1_p_024 = 0;
|
||||
|
||||
for (lc = 0 ; lc < VL53L1_MAX_BIN_SEQUENCE_LENGTH ; lc++)
|
||||
podata->bin_seq[lc] = VL53L1_MAX_BIN_SEQUENCE_CODE+1;
|
||||
|
||||
for (lc = 0 ; lc < podata->VL53L1_p_023 ; lc++)
|
||||
podata->bin_data[lc] = 0;
|
||||
|
||||
|
||||
|
||||
for (lc = 0 ; lc <= VL53L1_MAX_BIN_SEQUENCE_CODE ; lc++) {
|
||||
bin_initial_index[lc] = 0x00;
|
||||
bin_repeat_count[lc] = 0x00;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bin_seq_length = 0x00;
|
||||
|
||||
for (lc = 0 ; lc < VL53L1_MAX_BIN_SEQUENCE_LENGTH ; lc++) {
|
||||
|
||||
bin_cfg = pidata->bin_seq[lc];
|
||||
|
||||
|
||||
|
||||
if (bin_repeat_count[bin_cfg] == 0) {
|
||||
bin_initial_index[bin_cfg] = bin_seq_length * 4;
|
||||
podata->bin_seq[bin_seq_length] = bin_cfg;
|
||||
bin_seq_length++;
|
||||
}
|
||||
|
||||
bin_repeat_count[bin_cfg]++;
|
||||
|
||||
|
||||
|
||||
VL53L1_p_018 = bin_initial_index[bin_cfg];
|
||||
|
||||
for (i = 0 ; i < 4 ; i++)
|
||||
podata->bin_data[VL53L1_p_018+i] +=
|
||||
pidata->bin_data[lc*4+i];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (lc = 0 ; lc < VL53L1_MAX_BIN_SEQUENCE_LENGTH ; lc++) {
|
||||
|
||||
bin_cfg = podata->bin_seq[lc];
|
||||
|
||||
if (bin_cfg <= VL53L1_MAX_BIN_SEQUENCE_CODE)
|
||||
podata->bin_rep[lc] =
|
||||
bin_repeat_count[bin_cfg];
|
||||
else
|
||||
podata->bin_rep[lc] = 0;
|
||||
}
|
||||
|
||||
podata->VL53L1_p_024 = bin_seq_length * 4;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (lc = 0 ; lc <= VL53L1_MAX_BIN_SEQUENCE_CODE ; lc++) {
|
||||
|
||||
repeat_count = (int32_t)bin_repeat_count[lc];
|
||||
|
||||
if (repeat_count > 0) {
|
||||
|
||||
VL53L1_p_018 = bin_initial_index[lc];
|
||||
|
||||
for (i = 0 ; i < 4 ; i++) {
|
||||
podata->bin_data[VL53L1_p_018+i] +=
|
||||
(repeat_count/2);
|
||||
podata->bin_data[VL53L1_p_018+i] /=
|
||||
repeat_count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
podata->number_of_ambient_bins = 0;
|
||||
if ((bin_repeat_count[7] > 0) ||
|
||||
(bin_repeat_count[15] > 0))
|
||||
podata->number_of_ambient_bins = 4;
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,293 @@
|
|||
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 Protected and is dual licensed,
|
||||
either 'STMicroelectronics Proprietary license'
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
|
||||
******************************************************************************
|
||||
|
||||
'STMicroelectronics Proprietary license'
|
||||
|
||||
******************************************************************************
|
||||
|
||||
License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
terms at www.st.com/sla0081
|
||||
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_platform_log.h"
|
||||
|
||||
#include "vl53l1_core_support.h"
|
||||
#include "vl53l1_error_codes.h"
|
||||
#include "vl53l1_ll_def.h"
|
||||
|
||||
#include "vl53l1_hist_funcs.h"
|
||||
#include "vl53l1_hist_core.h"
|
||||
#include "vl53l1_hist_private_structs.h"
|
||||
#include "vl53l1_dmax_private_structs.h"
|
||||
#include "vl53l1_xtalk.h"
|
||||
#include "vl53l1_hist_algos_gen3.h"
|
||||
#include "vl53l1_hist_algos_gen4.h"
|
||||
#include "vl53l1_dmax.h"
|
||||
|
||||
|
||||
|
||||
#define LOG_FUNCTION_START(fmt, ...) \
|
||||
_LOG_FUNCTION_START(VL53L1_TRACE_MODULE_HISTOGRAM, fmt, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END(status, ...) \
|
||||
_LOG_FUNCTION_END(VL53L1_TRACE_MODULE_HISTOGRAM, status, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
|
||||
_LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_HISTOGRAM, \
|
||||
status, fmt, ##__VA_ARGS__)
|
||||
|
||||
#define trace_print(level, ...) \
|
||||
_LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_HISTOGRAM, \
|
||||
level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_process_data(
|
||||
VL53L1_dmax_calibration_data_t *pdmax_cal,
|
||||
VL53L1_hist_gen3_dmax_config_t *pdmax_cfg,
|
||||
VL53L1_hist_post_process_config_t *ppost_cfg,
|
||||
VL53L1_histogram_bin_data_t *pbins_input,
|
||||
VL53L1_xtalk_histogram_data_t *pxtalk_shape,
|
||||
uint8_t *pArea1,
|
||||
uint8_t *pArea2,
|
||||
VL53L1_range_results_t *presults,
|
||||
uint8_t *HistMergeNumber)
|
||||
{
|
||||
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
VL53L1_hist_gen3_algo_private_data_t *palgo_gen3 =
|
||||
(VL53L1_hist_gen3_algo_private_data_t *) pArea1;
|
||||
VL53L1_hist_gen4_algo_filtered_data_t *pfiltered4 =
|
||||
(VL53L1_hist_gen4_algo_filtered_data_t *) pArea2;
|
||||
|
||||
VL53L1_hist_gen3_dmax_private_data_t dmax_algo_gen3;
|
||||
VL53L1_hist_gen3_dmax_private_data_t *pdmax_algo_gen3 =
|
||||
&dmax_algo_gen3;
|
||||
|
||||
VL53L1_histogram_bin_data_t bins_averaged;
|
||||
VL53L1_histogram_bin_data_t *pbins_averaged = &bins_averaged;
|
||||
|
||||
VL53L1_range_data_t *pdata;
|
||||
|
||||
uint32_t xtalk_rate_kcps = 0;
|
||||
uint32_t max_xtalk_rate_per_spad_kcps = 0;
|
||||
uint8_t xtalk_enable = 0;
|
||||
uint8_t r = 0;
|
||||
uint8_t t = 0;
|
||||
uint32_t XtalkDetectMaxSigma = 0;
|
||||
|
||||
|
||||
int16_t delta_mm = 0;
|
||||
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
VL53L1_f_039(
|
||||
pbins_input,
|
||||
pbins_averaged);
|
||||
|
||||
|
||||
|
||||
VL53L1_init_histogram_bin_data_struct(
|
||||
0,
|
||||
pxtalk_shape->xtalk_shape.VL53L1_p_024,
|
||||
&(pxtalk_shape->xtalk_hist_removed));
|
||||
|
||||
|
||||
|
||||
VL53L1_copy_xtalk_bin_data_to_histogram_data_struct(
|
||||
&(pxtalk_shape->xtalk_shape),
|
||||
&(pxtalk_shape->xtalk_hist_removed));
|
||||
|
||||
|
||||
|
||||
if ((status == VL53L1_ERROR_NONE) &&
|
||||
(ppost_cfg->algo__crosstalk_compensation_enable > 0))
|
||||
status =
|
||||
VL53L1_f_040(
|
||||
ppost_cfg->algo__crosstalk_compensation_plane_offset_kcps,
|
||||
ppost_cfg->algo__crosstalk_compensation_x_plane_gradient_kcps,
|
||||
ppost_cfg->algo__crosstalk_compensation_y_plane_gradient_kcps,
|
||||
0,
|
||||
0,
|
||||
pbins_input->result__dss_actual_effective_spads,
|
||||
pbins_input->roi_config__user_roi_centre_spad,
|
||||
pbins_input->roi_config__user_roi_requested_global_xy_size,
|
||||
&(xtalk_rate_kcps));
|
||||
|
||||
|
||||
|
||||
if ((status == VL53L1_ERROR_NONE) &&
|
||||
(ppost_cfg->algo__crosstalk_compensation_enable > 0))
|
||||
status =
|
||||
VL53L1_f_041(
|
||||
pbins_averaged,
|
||||
&(pxtalk_shape->xtalk_shape),
|
||||
xtalk_rate_kcps,
|
||||
&(pxtalk_shape->xtalk_hist_removed));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
presults->xmonitor.total_periods_elapsed =
|
||||
pbins_averaged->total_periods_elapsed;
|
||||
presults->xmonitor.VL53L1_p_006 =
|
||||
pbins_averaged->result__dss_actual_effective_spads;
|
||||
|
||||
presults->xmonitor.peak_signal_count_rate_mcps = 0;
|
||||
presults->xmonitor.VL53L1_p_012 = 0;
|
||||
|
||||
presults->xmonitor.range_id = 0;
|
||||
presults->xmonitor.range_status = VL53L1_DEVICEERROR_NOUPDATE;
|
||||
|
||||
|
||||
|
||||
xtalk_enable = 0;
|
||||
if (ppost_cfg->algo__crosstalk_compensation_enable > 0)
|
||||
xtalk_enable = 1;
|
||||
|
||||
|
||||
|
||||
for (r = 0 ; r <= xtalk_enable ; r++) {
|
||||
|
||||
|
||||
ppost_cfg->algo__crosstalk_compensation_enable = r;
|
||||
|
||||
|
||||
|
||||
status =
|
||||
VL53L1_f_033(
|
||||
pdmax_cal,
|
||||
pdmax_cfg,
|
||||
ppost_cfg,
|
||||
pbins_averaged,
|
||||
&(pxtalk_shape->xtalk_hist_removed),
|
||||
palgo_gen3,
|
||||
pfiltered4,
|
||||
pdmax_algo_gen3,
|
||||
presults,
|
||||
*HistMergeNumber);
|
||||
|
||||
|
||||
if (!(status == VL53L1_ERROR_NONE && r == 0))
|
||||
continue;
|
||||
|
||||
|
||||
|
||||
if (presults->active_results == 0) {
|
||||
pdata = &(presults->VL53L1_p_002[0]);
|
||||
pdata->ambient_count_rate_mcps =
|
||||
pdmax_algo_gen3->VL53L1_p_001;
|
||||
pdata->VL53L1_p_006 =
|
||||
pdmax_algo_gen3->VL53L1_p_006;
|
||||
}
|
||||
|
||||
|
||||
|
||||
max_xtalk_rate_per_spad_kcps = (uint32_t)(
|
||||
ppost_cfg->algo__crosstalk_detect_max_valid_rate_kcps);
|
||||
max_xtalk_rate_per_spad_kcps *= (uint32_t)(*HistMergeNumber);
|
||||
max_xtalk_rate_per_spad_kcps <<= 4;
|
||||
|
||||
for (t = 0 ; t < presults->active_results ; t++) {
|
||||
|
||||
pdata = &(presults->VL53L1_p_002[t]);
|
||||
|
||||
|
||||
|
||||
if (pdata->max_range_mm > pdata->min_range_mm)
|
||||
delta_mm =
|
||||
pdata->max_range_mm -
|
||||
pdata->min_range_mm;
|
||||
else
|
||||
delta_mm =
|
||||
pdata->min_range_mm -
|
||||
pdata->max_range_mm;
|
||||
|
||||
XtalkDetectMaxSigma =
|
||||
ppost_cfg->algo__crosstalk_detect_max_sigma_mm;
|
||||
XtalkDetectMaxSigma *= (uint32_t)(*HistMergeNumber);
|
||||
XtalkDetectMaxSigma <<= 5;
|
||||
if (pdata->median_range_mm >
|
||||
ppost_cfg->algo__crosstalk_detect_min_valid_range_mm &&
|
||||
pdata->median_range_mm <
|
||||
ppost_cfg->algo__crosstalk_detect_max_valid_range_mm &&
|
||||
pdata->VL53L1_p_012 <
|
||||
max_xtalk_rate_per_spad_kcps &&
|
||||
pdata->VL53L1_p_005 < XtalkDetectMaxSigma &&
|
||||
delta_mm <
|
||||
ppost_cfg->algo__crosstalk_detect_min_max_tolerance) {
|
||||
|
||||
|
||||
|
||||
memcpy(
|
||||
&(presults->xmonitor),
|
||||
pdata,
|
||||
sizeof(VL53L1_range_data_t));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
ppost_cfg->algo__crosstalk_compensation_enable = xtalk_enable;
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_hist_ambient_dmax(
|
||||
uint16_t target_reflectance,
|
||||
VL53L1_dmax_calibration_data_t *pdmax_cal,
|
||||
VL53L1_hist_gen3_dmax_config_t *pdmax_cfg,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
int16_t *pambient_dmax_mm)
|
||||
{
|
||||
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
VL53L1_hist_gen3_dmax_private_data_t dmax_algo;
|
||||
VL53L1_hist_gen3_dmax_private_data_t *pdmax_algo = &dmax_algo;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
status =
|
||||
VL53L1_f_001(
|
||||
target_reflectance,
|
||||
pdmax_cal,
|
||||
pdmax_cfg,
|
||||
pbins,
|
||||
pdmax_algo,
|
||||
pambient_dmax_mm);
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,550 @@
|
|||
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 Protected and is dual licensed,
|
||||
either 'STMicroelectronics Proprietary license'
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
|
||||
******************************************************************************
|
||||
|
||||
'STMicroelectronics Proprietary license'
|
||||
|
||||
******************************************************************************
|
||||
|
||||
License terms: STMicroelectronics Proprietary in accordance with licensing
|
||||
terms at www.st.com/sla0081
|
||||
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_platform_log.h"
|
||||
|
||||
#include "vl53l1_core_support.h"
|
||||
#include "vl53l1_error_codes.h"
|
||||
|
||||
#include "vl53l1_sigma_estimate.h"
|
||||
|
||||
|
||||
#define LOG_FUNCTION_START(fmt, ...) \
|
||||
_LOG_FUNCTION_START(VL53L1_TRACE_MODULE_PROTECTED, fmt, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END(status, ...) \
|
||||
_LOG_FUNCTION_END(VL53L1_TRACE_MODULE_PROTECTED, status, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
|
||||
_LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_PROTECTED, \
|
||||
status, fmt, ##__VA_ARGS__)
|
||||
|
||||
#define trace_print(level, ...) \
|
||||
_LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_PROTECTED, \
|
||||
level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
|
||||
|
||||
|
||||
uint16_t VL53L1_f_042(
|
||||
uint8_t sigma_estimator__effective_pulse_width_ns,
|
||||
uint8_t sigma_estimator__effective_ambient_width_ns,
|
||||
uint8_t sigma_estimator__sigma_ref_mm,
|
||||
VL53L1_range_data_t *pdata)
|
||||
{
|
||||
|
||||
|
||||
|
||||
uint16_t sigma_est = VL53L1_D_002;
|
||||
|
||||
uint32_t tmp0 = 0;
|
||||
uint32_t tmp1 = 0;
|
||||
uint32_t tmp2 = 0;
|
||||
|
||||
uint32_t sigma_est__rtn_array = 0;
|
||||
uint32_t sigma_est__ref_array = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
if (pdata->peak_signal_count_rate_mcps > 0 &&
|
||||
pdata->VL53L1_p_013 > 0) {
|
||||
|
||||
|
||||
|
||||
tmp0 = 100 *
|
||||
(uint32_t)sigma_estimator__effective_pulse_width_ns;
|
||||
|
||||
|
||||
|
||||
tmp1 = ((uint32_t)sigma_estimator__effective_pulse_width_ns *
|
||||
100 *
|
||||
(uint32_t)sigma_estimator__effective_ambient_width_ns);
|
||||
|
||||
tmp1 = (tmp1 +
|
||||
(uint32_t)pdata->peak_signal_count_rate_mcps/2) /
|
||||
(uint32_t)pdata->peak_signal_count_rate_mcps;
|
||||
|
||||
|
||||
|
||||
sigma_est__rtn_array =
|
||||
VL53L1_f_043(tmp0, tmp1);
|
||||
|
||||
|
||||
|
||||
sigma_est__rtn_array =
|
||||
((VL53L1_SPEED_OF_LIGHT_IN_AIR + 1000) / 2000) *
|
||||
sigma_est__rtn_array;
|
||||
|
||||
|
||||
|
||||
tmp2 =
|
||||
VL53L1_isqrt(12 * (uint32_t)pdata->VL53L1_p_013);
|
||||
|
||||
if (tmp2 > 0) {
|
||||
|
||||
sigma_est__rtn_array =
|
||||
(sigma_est__rtn_array + tmp2/2) / tmp2;
|
||||
|
||||
|
||||
|
||||
sigma_est__ref_array =
|
||||
100 * (uint32_t)sigma_estimator__sigma_ref_mm;
|
||||
|
||||
sigma_est =
|
||||
(uint16_t)VL53L1_f_043(
|
||||
(uint32_t)sigma_est__ref_array,
|
||||
sigma_est__rtn_array);
|
||||
|
||||
} else {
|
||||
sigma_est = VL53L1_D_002;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pdata->VL53L1_p_005 = sigma_est;
|
||||
|
||||
LOG_FUNCTION_END(0);
|
||||
|
||||
return sigma_est;
|
||||
|
||||
}
|
||||
|
||||
|
||||
uint16_t VL53L1_f_044(
|
||||
uint8_t sigma_estimator__effective_pulse_width_ns,
|
||||
uint8_t sigma_estimator__effective_ambient_width_ns,
|
||||
uint8_t sigma_estimator__sigma_ref_mm,
|
||||
VL53L1_range_data_t *pdata)
|
||||
{
|
||||
|
||||
|
||||
uint16_t sigma_est = VL53L1_D_002;
|
||||
|
||||
uint32_t eqn7 = 0;
|
||||
uint32_t sigma_est__ref_sq = 0;
|
||||
uint32_t sigma_est__rtn_sq = 0;
|
||||
|
||||
uint64_t tmp0 = 0;
|
||||
uint64_t tmp1 = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
if (pdata->peak_signal_count_rate_mcps > 0 &&
|
||||
pdata->VL53L1_p_013 > 0) {
|
||||
|
||||
|
||||
|
||||
eqn7 = 4573 * 4573;
|
||||
eqn7 = eqn7 / (3 * (uint32_t)pdata->VL53L1_p_013);
|
||||
|
||||
|
||||
|
||||
tmp0 = ((uint64_t)sigma_estimator__effective_pulse_width_ns)
|
||||
<< 8;
|
||||
|
||||
|
||||
|
||||
tmp1 = ((uint64_t)pdata->ambient_count_rate_mcps *
|
||||
(uint64_t)sigma_estimator__effective_ambient_width_ns)
|
||||
<< 8;
|
||||
|
||||
tmp1 = do_division_u(tmp1,
|
||||
(uint64_t)pdata->peak_signal_count_rate_mcps);
|
||||
|
||||
|
||||
|
||||
tmp1 = 16 * (uint64_t)eqn7 * (tmp0 * tmp0 + tmp1 * tmp1);
|
||||
tmp1 = do_division_u(tmp1, (15625 * 15625));
|
||||
sigma_est__rtn_sq = (uint32_t)tmp1;
|
||||
|
||||
|
||||
|
||||
sigma_est__ref_sq = ((uint32_t)sigma_estimator__sigma_ref_mm)
|
||||
<< 2;
|
||||
|
||||
sigma_est__ref_sq = sigma_est__ref_sq * sigma_est__ref_sq;
|
||||
|
||||
|
||||
|
||||
sigma_est = (uint16_t)VL53L1_isqrt(sigma_est__ref_sq +
|
||||
sigma_est__rtn_sq);
|
||||
|
||||
}
|
||||
|
||||
pdata->VL53L1_p_005 = sigma_est;
|
||||
|
||||
LOG_FUNCTION_END(0);
|
||||
|
||||
return sigma_est;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_045(
|
||||
uint8_t sigma_estimator__sigma_ref_mm,
|
||||
uint32_t VL53L1_p_003,
|
||||
uint32_t VL53L1_p_018,
|
||||
uint32_t VL53L1_p_001,
|
||||
uint32_t a_zp,
|
||||
uint32_t c_zp,
|
||||
uint32_t bx,
|
||||
uint32_t ax_zp,
|
||||
uint32_t cx_zp,
|
||||
uint32_t VL53L1_p_004,
|
||||
uint16_t fast_osc_frequency,
|
||||
uint16_t *psigma_est)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_DIVISION_BY_ZERO;
|
||||
uint32_t sigma_int = VL53L1_D_002;
|
||||
|
||||
uint32_t pll_period_mm = 0;
|
||||
|
||||
uint64_t tmp0 = 0;
|
||||
uint64_t tmp1 = 0;
|
||||
uint64_t b_minus_amb = 0;
|
||||
uint64_t VL53L1_p_041 = 0;
|
||||
|
||||
*psigma_est = VL53L1_D_002;
|
||||
|
||||
|
||||
|
||||
if (fast_osc_frequency != 0) {
|
||||
|
||||
|
||||
|
||||
pll_period_mm = VL53L1_calc_pll_period_mm(fast_osc_frequency);
|
||||
|
||||
|
||||
pll_period_mm = (pll_period_mm + 0x02) >> 2;
|
||||
|
||||
|
||||
|
||||
if (VL53L1_p_004 > VL53L1_p_018)
|
||||
b_minus_amb = (uint64_t)VL53L1_p_004 -
|
||||
(uint64_t)VL53L1_p_018;
|
||||
else
|
||||
b_minus_amb = (uint64_t)VL53L1_p_018 -
|
||||
(uint64_t)VL53L1_p_004;
|
||||
|
||||
|
||||
|
||||
if (VL53L1_p_003 > VL53L1_p_001)
|
||||
VL53L1_p_041 = (uint64_t)VL53L1_p_003 -
|
||||
(uint64_t)VL53L1_p_001;
|
||||
else
|
||||
VL53L1_p_041 = (uint64_t)VL53L1_p_001 -
|
||||
(uint64_t)VL53L1_p_003;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (b_minus_amb != 0) {
|
||||
|
||||
|
||||
|
||||
tmp0 = (uint64_t)pll_period_mm *
|
||||
(uint64_t)pll_period_mm;
|
||||
tmp0 = tmp0 * ((uint64_t)c_zp +
|
||||
(uint64_t)cx_zp + (uint64_t)a_zp +
|
||||
(uint64_t)ax_zp);
|
||||
tmp0 = do_division_u((tmp0 + (b_minus_amb >> 1)),
|
||||
b_minus_amb);
|
||||
|
||||
|
||||
|
||||
tmp1 = (uint64_t)pll_period_mm *
|
||||
(uint64_t)pll_period_mm * VL53L1_p_041;
|
||||
tmp1 = do_division_u((tmp1 + (b_minus_amb >> 1)),
|
||||
b_minus_amb);
|
||||
|
||||
tmp1 = tmp1 * VL53L1_p_041;
|
||||
tmp1 = do_division_u((tmp1 + (b_minus_amb >> 1)),
|
||||
b_minus_amb);
|
||||
|
||||
tmp1 = tmp1 * ((uint64_t)VL53L1_p_018 + (uint64_t)bx +
|
||||
(uint64_t)VL53L1_p_004);
|
||||
tmp1 = do_division_u((tmp1 + (b_minus_amb >> 1)),
|
||||
b_minus_amb);
|
||||
|
||||
|
||||
|
||||
tmp0 = tmp0 + tmp1;
|
||||
tmp0 = do_division_u((tmp0 + (b_minus_amb >> 1)),
|
||||
b_minus_amb);
|
||||
tmp0 = (tmp0 + 0x01) >> 2;
|
||||
|
||||
|
||||
|
||||
tmp1 = (uint64_t)sigma_estimator__sigma_ref_mm << 2;
|
||||
tmp1 = tmp1 * tmp1;
|
||||
tmp0 = tmp0 + tmp1;
|
||||
|
||||
|
||||
|
||||
if (tmp0 > 0xFFFFFFFF)
|
||||
tmp0 = 0xFFFFFFFF;
|
||||
|
||||
sigma_int = VL53L1_isqrt((uint32_t)tmp0);
|
||||
|
||||
|
||||
|
||||
if (sigma_int > VL53L1_D_002)
|
||||
*psigma_est =
|
||||
(uint16_t)VL53L1_D_002;
|
||||
else
|
||||
*psigma_est = (uint16_t)sigma_int;
|
||||
|
||||
status = VL53L1_ERROR_NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_f_014(
|
||||
uint8_t sigma_estimator__sigma_ref_mm,
|
||||
uint32_t VL53L1_p_003,
|
||||
uint32_t VL53L1_p_018,
|
||||
uint32_t VL53L1_p_001,
|
||||
uint32_t a_zp,
|
||||
uint32_t c_zp,
|
||||
uint32_t bx,
|
||||
uint32_t ax_zp,
|
||||
uint32_t cx_zp,
|
||||
uint32_t VL53L1_p_004,
|
||||
uint16_t fast_osc_frequency,
|
||||
uint16_t *psigma_est)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_DIVISION_BY_ZERO;
|
||||
uint32_t sigma_int = VL53L1_D_002;
|
||||
|
||||
uint32_t pll_period_mm = 0;
|
||||
|
||||
uint64_t tmp0 = 0;
|
||||
uint64_t tmp1 = 0;
|
||||
uint64_t b_minus_amb = 0;
|
||||
uint64_t VL53L1_p_041 = 0;
|
||||
|
||||
*psigma_est = VL53L1_D_002;
|
||||
|
||||
|
||||
|
||||
if (fast_osc_frequency != 0) {
|
||||
|
||||
|
||||
|
||||
pll_period_mm = VL53L1_calc_pll_period_mm(fast_osc_frequency);
|
||||
|
||||
|
||||
|
||||
if (VL53L1_p_004 > VL53L1_p_018)
|
||||
b_minus_amb = (uint64_t)VL53L1_p_004 -
|
||||
(uint64_t)VL53L1_p_018;
|
||||
else
|
||||
b_minus_amb = (uint64_t)VL53L1_p_018 -
|
||||
(uint64_t)VL53L1_p_004;
|
||||
|
||||
|
||||
|
||||
if (VL53L1_p_003 > VL53L1_p_001)
|
||||
VL53L1_p_041 = (uint64_t)VL53L1_p_003 -
|
||||
(uint64_t)VL53L1_p_001;
|
||||
else
|
||||
VL53L1_p_041 = (uint64_t)VL53L1_p_001 -
|
||||
(uint64_t)VL53L1_p_003;
|
||||
|
||||
|
||||
|
||||
if (b_minus_amb != 0) {
|
||||
|
||||
|
||||
|
||||
|
||||
tmp0 = (uint64_t)VL53L1_p_018 + (uint64_t)bx +
|
||||
(uint64_t)VL53L1_p_004;
|
||||
if (tmp0 > VL53L1_D_003)
|
||||
tmp0 = VL53L1_D_003;
|
||||
|
||||
|
||||
|
||||
tmp1 = (uint64_t)VL53L1_p_041 * (uint64_t)VL53L1_p_041;
|
||||
tmp1 = tmp1 << 8;
|
||||
|
||||
|
||||
if (tmp1 > VL53L1_D_004)
|
||||
tmp1 = VL53L1_D_004;
|
||||
|
||||
|
||||
tmp1 = do_division_u(tmp1, b_minus_amb);
|
||||
tmp1 = do_division_u(tmp1, b_minus_amb);
|
||||
|
||||
|
||||
if (tmp1 > (uint64_t)VL53L1_D_005)
|
||||
tmp1 = (uint64_t)VL53L1_D_005;
|
||||
|
||||
|
||||
tmp0 = tmp1 * tmp0;
|
||||
|
||||
|
||||
tmp1 = (uint64_t)c_zp + (uint64_t)cx_zp +
|
||||
(uint64_t)a_zp + (uint64_t)ax_zp;
|
||||
|
||||
|
||||
if (tmp1 > (uint64_t)VL53L1_D_003)
|
||||
tmp1 = (uint64_t)VL53L1_D_003;
|
||||
|
||||
tmp1 = tmp1 << 8;
|
||||
|
||||
|
||||
tmp0 = tmp1 + tmp0;
|
||||
if (tmp0 > (uint64_t)VL53L1_D_006)
|
||||
tmp0 = (uint64_t)VL53L1_D_006;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (tmp0 > (uint64_t)VL53L1_D_007) {
|
||||
tmp0 = do_division_u(tmp0, b_minus_amb);
|
||||
tmp0 = tmp0 * pll_period_mm;
|
||||
} else {
|
||||
tmp0 = tmp0 * pll_period_mm;
|
||||
tmp0 = do_division_u(tmp0, b_minus_amb);
|
||||
}
|
||||
|
||||
|
||||
if (tmp0 > (uint64_t)VL53L1_D_006)
|
||||
tmp0 = (uint64_t)VL53L1_D_006;
|
||||
|
||||
|
||||
|
||||
if (tmp0 > (uint64_t)VL53L1_D_007) {
|
||||
tmp0 = do_division_u(tmp0, b_minus_amb);
|
||||
tmp0 = do_division_u(tmp0, 4);
|
||||
tmp0 = tmp0 * pll_period_mm;
|
||||
} else {
|
||||
tmp0 = tmp0 * pll_period_mm;
|
||||
tmp0 = do_division_u(tmp0, b_minus_amb);
|
||||
tmp0 = do_division_u(tmp0, 4);
|
||||
}
|
||||
|
||||
|
||||
if (tmp0 > (uint64_t)VL53L1_D_006)
|
||||
tmp0 = (uint64_t)VL53L1_D_006;
|
||||
|
||||
|
||||
tmp0 = tmp0 >> 2;
|
||||
|
||||
|
||||
if (tmp0 > (uint64_t)VL53L1_D_007)
|
||||
tmp0 = (uint64_t)VL53L1_D_007;
|
||||
|
||||
|
||||
tmp1 = (uint64_t)sigma_estimator__sigma_ref_mm << 7;
|
||||
tmp1 = tmp1 * tmp1;
|
||||
tmp0 = tmp0 + tmp1;
|
||||
|
||||
|
||||
if (tmp0 > (uint64_t)VL53L1_D_007)
|
||||
tmp0 = (uint64_t)VL53L1_D_007;
|
||||
|
||||
|
||||
sigma_int = VL53L1_isqrt((uint32_t)tmp0);
|
||||
|
||||
*psigma_est = (uint16_t)sigma_int;
|
||||
|
||||
status = VL53L1_ERROR_NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
uint32_t VL53L1_f_046(
|
||||
uint64_t VL53L1_p_003,
|
||||
uint32_t size
|
||||
)
|
||||
{
|
||||
|
||||
|
||||
uint64_t next;
|
||||
uint64_t upper;
|
||||
uint64_t lower;
|
||||
uint32_t stepsize;
|
||||
uint32_t count;
|
||||
|
||||
|
||||
next = VL53L1_p_003;
|
||||
upper = 0;
|
||||
lower = 0;
|
||||
stepsize = size/2;
|
||||
count = 0;
|
||||
|
||||
while (1) {
|
||||
upper = next >> stepsize;
|
||||
lower = next & ((1 << stepsize) - 1);
|
||||
|
||||
if (upper != 0) {
|
||||
count += stepsize;
|
||||
next = upper;
|
||||
} else {
|
||||
next = lower;
|
||||
}
|
||||
|
||||
stepsize = stepsize / 2;
|
||||
if (stepsize == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t VL53L1_f_043(
|
||||
uint32_t VL53L1_p_003,
|
||||
uint32_t VL53L1_p_018)
|
||||
{
|
||||
|
||||
|
||||
uint32_t res = 0;
|
||||
|
||||
if (VL53L1_p_003 > 65535 || VL53L1_p_018 > 65535)
|
||||
res = 65535;
|
||||
else
|
||||
res = VL53L1_isqrt(VL53L1_p_003*VL53L1_p_003 +
|
||||
VL53L1_p_018*VL53L1_p_018);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
1195
drivers/input/misc/vl53L1_14_1_2/protected/src/vl53l1_xtalk.c
Normal file
1195
drivers/input/misc/vl53L1_14_1_2/protected/src/vl53l1_xtalk.c
Normal file
File diff suppressed because it is too large
Load diff
3999
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_api.c
Normal file
3999
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_api.c
Normal file
File diff suppressed because it is too large
Load diff
2176
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_api_calibration.c
Normal file
2176
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_api_calibration.c
Normal file
File diff suppressed because it is too large
Load diff
7295
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_api_core.c
Normal file
7295
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_api_core.c
Normal file
File diff suppressed because it is too large
Load diff
3399
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_api_debug.c
Normal file
3399
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_api_debug.c
Normal file
File diff suppressed because it is too large
Load diff
3681
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_api_preset_modes.c
Normal file
3681
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_api_preset_modes.c
Normal file
File diff suppressed because it is too large
Load diff
221
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_api_strings.c
Normal file
221
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_api_strings.c
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
|
||||
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "vl53l1_api_core.h"
|
||||
#include "vl53l1_api_strings.h"
|
||||
#include "vl53l1_error_codes.h"
|
||||
#include "vl53l1_error_strings.h"
|
||||
|
||||
#define LOG_FUNCTION_START(fmt, ...) \
|
||||
_LOG_FUNCTION_START(VL53L1_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END(status, ...) \
|
||||
_LOG_FUNCTION_END(VL53L1_TRACE_MODULE_API, status, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
|
||||
_LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_API, status, fmt, \
|
||||
##__VA_ARGS__)
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_range_status_string(
|
||||
uint8_t RangeStatus,
|
||||
char *pRangeStatusString)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
#ifdef VL53L1_USE_EMPTY_STRING
|
||||
SUPPRESS_UNUSED_WARNING(RangeStatus);
|
||||
VL53L1_COPYSTRING(pRangeStatusString, "");
|
||||
#else
|
||||
switch (RangeStatus) {
|
||||
case 0:
|
||||
VL53L1_COPYSTRING(pRangeStatusString,
|
||||
VL53L1_STRING_RANGESTATUS_RANGEVALID);
|
||||
break;
|
||||
case 1:
|
||||
VL53L1_COPYSTRING(pRangeStatusString,
|
||||
VL53L1_STRING_RANGESTATUS_SIGMA);
|
||||
break;
|
||||
case 2:
|
||||
VL53L1_COPYSTRING(pRangeStatusString,
|
||||
VL53L1_STRING_RANGESTATUS_SIGNAL);
|
||||
break;
|
||||
case 3:
|
||||
VL53L1_COPYSTRING(pRangeStatusString,
|
||||
VL53L1_STRING_RANGESTATUS_MINRANGE);
|
||||
break;
|
||||
case 4:
|
||||
VL53L1_COPYSTRING(pRangeStatusString,
|
||||
VL53L1_STRING_RANGESTATUS_PHASE);
|
||||
break;
|
||||
case 5:
|
||||
VL53L1_COPYSTRING(pRangeStatusString,
|
||||
VL53L1_STRING_RANGESTATUS_HW);
|
||||
break;
|
||||
|
||||
default:
|
||||
VL53L1_COPYSTRING(pRangeStatusString,
|
||||
VL53L1_STRING_RANGESTATUS_NONE);
|
||||
}
|
||||
#endif
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_pal_state_string(
|
||||
VL53L1_State PalStateCode,
|
||||
char *pPalStateString)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
#ifdef VL53L1_USE_EMPTY_STRING
|
||||
SUPPRESS_UNUSED_WARNING(PalStateCode);
|
||||
VL53L1_COPYSTRING(pPalStateString, "");
|
||||
#else
|
||||
switch (PalStateCode) {
|
||||
case VL53L1_STATE_POWERDOWN:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_POWERDOWN);
|
||||
break;
|
||||
case VL53L1_STATE_WAIT_STATICINIT:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_WAIT_STATICINIT);
|
||||
break;
|
||||
case VL53L1_STATE_STANDBY:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_STANDBY);
|
||||
break;
|
||||
case VL53L1_STATE_IDLE:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_IDLE);
|
||||
break;
|
||||
case VL53L1_STATE_RUNNING:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_RUNNING);
|
||||
break;
|
||||
case VL53L1_STATE_RESET:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_RESET);
|
||||
break;
|
||||
case VL53L1_STATE_UNKNOWN:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_UNKNOWN);
|
||||
break;
|
||||
case VL53L1_STATE_ERROR:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_ERROR);
|
||||
break;
|
||||
|
||||
default:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_UNKNOWN);
|
||||
}
|
||||
#endif
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
VL53L1_Error VL53L1_get_sequence_steps_info(
|
||||
VL53L1_SequenceStepId SequenceStepId,
|
||||
char *pSequenceStepsString)
|
||||
{
|
||||
VL53L1_Error Status = VL53L1_ERROR_NONE;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
#ifdef VL53L1_USE_EMPTY_STRING
|
||||
SUPPRESS_UNUSED_WARNING(SequenceStepId);
|
||||
VL53L1_COPYSTRING(pSequenceStepsString, "");
|
||||
#else
|
||||
switch (SequenceStepId) {
|
||||
case VL53L1_SEQUENCESTEP_VHV:
|
||||
VL53L1_COPYSTRING(pSequenceStepsString,
|
||||
VL53L1_STRING_SEQUENCESTEP_VHV);
|
||||
break;
|
||||
case VL53L1_SEQUENCESTEP_PHASECAL:
|
||||
VL53L1_COPYSTRING(pSequenceStepsString,
|
||||
VL53L1_STRING_SEQUENCESTEP_PHASECAL);
|
||||
break;
|
||||
case VL53L1_SEQUENCESTEP_REFPHASE:
|
||||
VL53L1_COPYSTRING(pSequenceStepsString,
|
||||
VL53L1_STRING_SEQUENCESTEP_DSS1);
|
||||
break;
|
||||
case VL53L1_SEQUENCESTEP_DSS1:
|
||||
VL53L1_COPYSTRING(pSequenceStepsString,
|
||||
VL53L1_STRING_SEQUENCESTEP_DSS1);
|
||||
break;
|
||||
case VL53L1_SEQUENCESTEP_DSS2:
|
||||
VL53L1_COPYSTRING(pSequenceStepsString,
|
||||
VL53L1_STRING_SEQUENCESTEP_DSS2);
|
||||
break;
|
||||
case VL53L1_SEQUENCESTEP_MM1:
|
||||
VL53L1_COPYSTRING(pSequenceStepsString,
|
||||
VL53L1_STRING_SEQUENCESTEP_MM1);
|
||||
break;
|
||||
case VL53L1_SEQUENCESTEP_MM2:
|
||||
VL53L1_COPYSTRING(pSequenceStepsString,
|
||||
VL53L1_STRING_SEQUENCESTEP_MM2);
|
||||
break;
|
||||
case VL53L1_SEQUENCESTEP_RANGE:
|
||||
VL53L1_COPYSTRING(pSequenceStepsString,
|
||||
VL53L1_STRING_SEQUENCESTEP_RANGE);
|
||||
break;
|
||||
default:
|
||||
Status = VL53L1_ERROR_INVALID_PARAMS;
|
||||
}
|
||||
#endif
|
||||
|
||||
LOG_FUNCTION_END(Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
VL53L1_Error VL53L1_get_limit_check_info(uint16_t LimitCheckId,
|
||||
char *pLimitCheckString)
|
||||
{
|
||||
VL53L1_Error Status = VL53L1_ERROR_NONE;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
#ifdef VL53L1_USE_EMPTY_STRING
|
||||
SUPPRESS_UNUSED_WARNING(LimitCheckId);
|
||||
VL53L1_COPYSTRING(pLimitCheckString, "");
|
||||
#else
|
||||
switch (LimitCheckId) {
|
||||
case VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE:
|
||||
VL53L1_COPYSTRING(pLimitCheckString,
|
||||
VL53L1_STRING_CHECKENABLE_SIGMA_FINAL_RANGE);
|
||||
break;
|
||||
case VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE:
|
||||
VL53L1_COPYSTRING(pLimitCheckString,
|
||||
VL53L1_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE);
|
||||
break;
|
||||
default:
|
||||
VL53L1_COPYSTRING(pLimitCheckString,
|
||||
VL53L1_STRING_UNKNOW_ERROR_CODE);
|
||||
}
|
||||
#endif
|
||||
|
||||
LOG_FUNCTION_END(Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
4838
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_core.c
Normal file
4838
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_core.c
Normal file
File diff suppressed because it is too large
Load diff
640
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_core_support.c
Normal file
640
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_core_support.c
Normal file
|
|
@ -0,0 +1,640 @@
|
|||
|
||||
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_ll_device.h"
|
||||
#include "vl53l1_platform_log.h"
|
||||
#include "vl53l1_core_support.h"
|
||||
#include "vl53l1_platform_user_data.h"
|
||||
#include "vl53l1_platform_user_defines.h"
|
||||
|
||||
|
||||
|
||||
#define LOG_FUNCTION_START(fmt, ...) \
|
||||
_LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END(status, ...) \
|
||||
_LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
|
||||
_LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE, \
|
||||
status, fmt, ##__VA_ARGS__)
|
||||
|
||||
#define trace_print(level, ...) \
|
||||
_LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_CORE, \
|
||||
level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
|
||||
|
||||
|
||||
uint32_t VL53L1_calc_pll_period_us(
|
||||
uint16_t fast_osc_frequency)
|
||||
{
|
||||
|
||||
|
||||
uint32_t pll_period_us = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
if (fast_osc_frequency > 0)
|
||||
pll_period_us = (0x01 << 30) / fast_osc_frequency;
|
||||
|
||||
|
||||
|
||||
LOG_FUNCTION_END(0);
|
||||
|
||||
return pll_period_us;
|
||||
}
|
||||
|
||||
|
||||
uint32_t VL53L1_duration_maths(
|
||||
uint32_t pll_period_us,
|
||||
uint32_t vcsel_parm_pclks,
|
||||
uint32_t window_vclks,
|
||||
uint32_t elapsed_mclks)
|
||||
{
|
||||
|
||||
|
||||
uint64_t tmp_long_int = 0;
|
||||
uint32_t duration_us = 0;
|
||||
|
||||
|
||||
duration_us = window_vclks * pll_period_us;
|
||||
|
||||
|
||||
duration_us = duration_us >> 12;
|
||||
|
||||
|
||||
tmp_long_int = (uint64_t)duration_us;
|
||||
|
||||
|
||||
duration_us = elapsed_mclks * vcsel_parm_pclks;
|
||||
|
||||
|
||||
duration_us = duration_us >> 4;
|
||||
|
||||
|
||||
tmp_long_int = tmp_long_int * (uint64_t)duration_us;
|
||||
|
||||
|
||||
tmp_long_int = tmp_long_int >> 12;
|
||||
|
||||
|
||||
if (tmp_long_int > 0xFFFFFFFF)
|
||||
tmp_long_int = 0xFFFFFFFF;
|
||||
|
||||
duration_us = (uint32_t)tmp_long_int;
|
||||
|
||||
return duration_us;
|
||||
}
|
||||
|
||||
|
||||
uint32_t VL53L1_events_per_spad_maths(
|
||||
int32_t VL53L1_p_013,
|
||||
uint16_t num_spads,
|
||||
uint32_t duration)
|
||||
{
|
||||
uint64_t total_hist_counts = 0;
|
||||
uint64_t xtalk_per_spad = 0;
|
||||
uint32_t rate_per_spad_kcps = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint64_t dividend = ((uint64_t)VL53L1_p_013
|
||||
* 1000 * 256);
|
||||
|
||||
if (num_spads != 0)
|
||||
total_hist_counts = do_division_u(
|
||||
dividend, (uint64_t)num_spads);
|
||||
|
||||
|
||||
|
||||
if (duration > 0) {
|
||||
|
||||
|
||||
uint64_t dividend = (((uint64_t)(total_hist_counts << 11))
|
||||
+ ((uint64_t)duration / 2));
|
||||
|
||||
xtalk_per_spad = do_division_u(dividend, (uint64_t)duration);
|
||||
} else {
|
||||
xtalk_per_spad = (uint64_t)(total_hist_counts << 11);
|
||||
}
|
||||
|
||||
rate_per_spad_kcps = (uint32_t)xtalk_per_spad;
|
||||
|
||||
return rate_per_spad_kcps;
|
||||
}
|
||||
|
||||
|
||||
uint32_t VL53L1_isqrt(uint32_t num)
|
||||
{
|
||||
|
||||
|
||||
|
||||
uint32_t res = 0;
|
||||
uint32_t bit = 1 << 30;
|
||||
|
||||
|
||||
while (bit > num)
|
||||
bit >>= 2;
|
||||
|
||||
while (bit != 0) {
|
||||
if (num >= res + bit) {
|
||||
num -= res + bit;
|
||||
res = (res >> 1) + bit;
|
||||
} else {
|
||||
res >>= 1;
|
||||
}
|
||||
bit >>= 2;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
void VL53L1_hist_calc_zero_distance_phase(
|
||||
VL53L1_histogram_bin_data_t *pdata)
|
||||
{
|
||||
|
||||
|
||||
uint32_t period = 0;
|
||||
uint32_t VL53L1_p_017 = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
period = 2048 *
|
||||
(uint32_t)VL53L1_decode_vcsel_period(pdata->VL53L1_p_009);
|
||||
|
||||
VL53L1_p_017 = period;
|
||||
VL53L1_p_017 += (uint32_t)pdata->phasecal_result__reference_phase;
|
||||
VL53L1_p_017 += (2048 * (uint32_t)pdata->phasecal_result__vcsel_start);
|
||||
VL53L1_p_017 -= (2048 * (uint32_t)pdata->cal_config__vcsel_start);
|
||||
|
||||
if (period != 0)
|
||||
VL53L1_p_017 = VL53L1_p_017 % period;
|
||||
else
|
||||
VL53L1_p_017 = 0;
|
||||
|
||||
pdata->zero_distance_phase = (uint16_t)VL53L1_p_017;
|
||||
|
||||
LOG_FUNCTION_END(0);
|
||||
}
|
||||
|
||||
|
||||
void VL53L1_hist_estimate_ambient_from_thresholded_bins(
|
||||
int32_t ambient_threshold_sigma,
|
||||
VL53L1_histogram_bin_data_t *pdata)
|
||||
{
|
||||
|
||||
|
||||
uint8_t bin = 0;
|
||||
int32_t VL53L1_p_032 = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
VL53L1_hist_find_min_max_bin_values(pdata);
|
||||
|
||||
|
||||
|
||||
VL53L1_p_032 =
|
||||
(int32_t)VL53L1_isqrt((uint32_t)pdata->min_bin_value);
|
||||
VL53L1_p_032 *= ambient_threshold_sigma;
|
||||
VL53L1_p_032 += 0x07;
|
||||
VL53L1_p_032 = VL53L1_p_032 >> 4;
|
||||
VL53L1_p_032 += pdata->min_bin_value;
|
||||
|
||||
|
||||
|
||||
pdata->number_of_ambient_samples = 0;
|
||||
pdata->ambient_events_sum = 0;
|
||||
|
||||
for (bin = 0; bin < pdata->VL53L1_p_024; bin++)
|
||||
if (pdata->bin_data[bin] < VL53L1_p_032) {
|
||||
pdata->ambient_events_sum += pdata->bin_data[bin];
|
||||
pdata->number_of_ambient_samples++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (pdata->number_of_ambient_samples > 0) {
|
||||
pdata->VL53L1_p_004 =
|
||||
pdata->ambient_events_sum;
|
||||
pdata->VL53L1_p_004 +=
|
||||
((int32_t)pdata->number_of_ambient_samples/2);
|
||||
pdata->VL53L1_p_004 /=
|
||||
(int32_t)pdata->number_of_ambient_samples;
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(0);
|
||||
}
|
||||
|
||||
|
||||
void VL53L1_hist_remove_ambient_bins(
|
||||
VL53L1_histogram_bin_data_t *pdata)
|
||||
{
|
||||
|
||||
|
||||
|
||||
uint8_t bin = 0;
|
||||
uint8_t lc = 0;
|
||||
uint8_t i = 0;
|
||||
|
||||
|
||||
|
||||
if ((pdata->bin_seq[0] & 0x07) == 0x07) {
|
||||
|
||||
i = 0;
|
||||
for (lc = 0; lc < VL53L1_MAX_BIN_SEQUENCE_LENGTH; lc++) {
|
||||
if ((pdata->bin_seq[lc] & 0x07) != 0x07) {
|
||||
pdata->bin_seq[i] = pdata->bin_seq[lc];
|
||||
pdata->bin_rep[i] = pdata->bin_rep[lc];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (lc = i; lc < VL53L1_MAX_BIN_SEQUENCE_LENGTH; lc++) {
|
||||
pdata->bin_seq[lc] = VL53L1_MAX_BIN_SEQUENCE_CODE + 1;
|
||||
pdata->bin_rep[lc] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (pdata->number_of_ambient_bins > 0) {
|
||||
|
||||
|
||||
for (bin = pdata->number_of_ambient_bins;
|
||||
bin < pdata->VL53L1_p_023; bin++) {
|
||||
pdata->bin_data[bin-pdata->number_of_ambient_bins] =
|
||||
pdata->bin_data[bin];
|
||||
}
|
||||
|
||||
|
||||
pdata->VL53L1_p_024 =
|
||||
pdata->VL53L1_p_024 -
|
||||
pdata->number_of_ambient_bins;
|
||||
pdata->number_of_ambient_bins = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32_t VL53L1_calc_pll_period_mm(
|
||||
uint16_t fast_osc_frequency)
|
||||
{
|
||||
|
||||
|
||||
uint32_t pll_period_us = 0;
|
||||
uint32_t pll_period_mm = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
pll_period_us = VL53L1_calc_pll_period_us(fast_osc_frequency);
|
||||
|
||||
|
||||
|
||||
|
||||
pll_period_mm =
|
||||
VL53L1_SPEED_OF_LIGHT_IN_AIR_DIV_8 *
|
||||
(pll_period_us >> 2);
|
||||
|
||||
|
||||
pll_period_mm = (pll_period_mm + (0x01<<15)) >> 16;
|
||||
|
||||
LOG_FUNCTION_END(0);
|
||||
|
||||
return pll_period_mm;
|
||||
}
|
||||
|
||||
|
||||
uint16_t VL53L1_rate_maths(
|
||||
int32_t VL53L1_p_008,
|
||||
uint32_t time_us)
|
||||
{
|
||||
|
||||
|
||||
uint32_t tmp_int = 0;
|
||||
uint32_t frac_bits = 7;
|
||||
uint16_t rate_mcps = 0;
|
||||
|
||||
|
||||
|
||||
if (VL53L1_p_008 > VL53L1_SPAD_TOTAL_COUNT_MAX)
|
||||
tmp_int = VL53L1_SPAD_TOTAL_COUNT_MAX;
|
||||
else if (VL53L1_p_008 > 0)
|
||||
tmp_int = (uint32_t)VL53L1_p_008;
|
||||
|
||||
|
||||
|
||||
|
||||
if (VL53L1_p_008 > VL53L1_SPAD_TOTAL_COUNT_RES_THRES)
|
||||
frac_bits = 3;
|
||||
else
|
||||
frac_bits = 7;
|
||||
|
||||
|
||||
if (time_us > 0)
|
||||
tmp_int = ((tmp_int << frac_bits) + (time_us / 2)) / time_us;
|
||||
|
||||
|
||||
if (VL53L1_p_008 > VL53L1_SPAD_TOTAL_COUNT_RES_THRES)
|
||||
tmp_int = tmp_int << 4;
|
||||
|
||||
|
||||
|
||||
if (tmp_int > 0xFFFF)
|
||||
tmp_int = 0xFFFF;
|
||||
|
||||
rate_mcps = (uint16_t)tmp_int;
|
||||
|
||||
return rate_mcps;
|
||||
}
|
||||
|
||||
|
||||
uint16_t VL53L1_rate_per_spad_maths(
|
||||
uint32_t frac_bits,
|
||||
uint32_t peak_count_rate,
|
||||
uint16_t num_spads,
|
||||
uint32_t max_output_value)
|
||||
{
|
||||
|
||||
uint32_t tmp_int = 0;
|
||||
|
||||
|
||||
uint16_t rate_per_spad = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (num_spads > 0) {
|
||||
tmp_int = (peak_count_rate << 8) << frac_bits;
|
||||
tmp_int = (tmp_int +
|
||||
((uint32_t)num_spads / 2)) /
|
||||
(uint32_t)num_spads;
|
||||
} else {
|
||||
tmp_int = ((peak_count_rate) << frac_bits);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (tmp_int > max_output_value)
|
||||
tmp_int = max_output_value;
|
||||
|
||||
rate_per_spad = (uint16_t)tmp_int;
|
||||
|
||||
return rate_per_spad;
|
||||
}
|
||||
|
||||
|
||||
int32_t VL53L1_range_maths(
|
||||
uint16_t fast_osc_frequency,
|
||||
uint16_t VL53L1_p_017,
|
||||
uint16_t zero_distance_phase,
|
||||
uint8_t fractional_bits,
|
||||
int32_t gain_factor,
|
||||
int32_t range_offset_mm)
|
||||
{
|
||||
|
||||
|
||||
uint32_t pll_period_us = 0;
|
||||
int64_t tmp_long_int = 0;
|
||||
int32_t range_mm = 0;
|
||||
int32_t range_mm_10 = 0;
|
||||
|
||||
|
||||
|
||||
pll_period_us = VL53L1_calc_pll_period_us(fast_osc_frequency);
|
||||
|
||||
|
||||
|
||||
tmp_long_int = (int64_t)VL53L1_p_017 - (int64_t)zero_distance_phase;
|
||||
|
||||
|
||||
|
||||
tmp_long_int = tmp_long_int * (int64_t)pll_period_us;
|
||||
|
||||
|
||||
|
||||
tmp_long_int = tmp_long_int / (0x01 << 9);
|
||||
|
||||
|
||||
|
||||
tmp_long_int = tmp_long_int * VL53L1_SPEED_OF_LIGHT_IN_AIR_DIV_8;
|
||||
|
||||
|
||||
|
||||
tmp_long_int = tmp_long_int / (0x01 << 22);
|
||||
|
||||
|
||||
range_mm = (int32_t)tmp_long_int + range_offset_mm;
|
||||
|
||||
|
||||
range_mm *= gain_factor;
|
||||
range_mm += 0x0400;
|
||||
range_mm /= 0x0800;
|
||||
|
||||
|
||||
if (fractional_bits == 0) {
|
||||
range_mm_10 = range_mm * 10;
|
||||
range_mm_10 = range_mm_10 / (0x01 << 2);
|
||||
if ((range_mm_10 % 10) < 5)
|
||||
range_mm = (int16_t)(range_mm_10 / 10);
|
||||
else
|
||||
range_mm = (int16_t)(range_mm_10 / 10 + 1);
|
||||
} else if (fractional_bits == 1)
|
||||
range_mm = range_mm / (0x01 << 1);
|
||||
|
||||
return range_mm;
|
||||
}
|
||||
|
||||
|
||||
uint8_t VL53L1_decode_vcsel_period(uint8_t vcsel_period_reg)
|
||||
{
|
||||
|
||||
|
||||
uint8_t VL53L1_p_031 = 0;
|
||||
|
||||
VL53L1_p_031 = (vcsel_period_reg + 1) << 1;
|
||||
|
||||
return VL53L1_p_031;
|
||||
}
|
||||
|
||||
|
||||
void VL53L1_copy_xtalk_bin_data_to_histogram_data_struct(
|
||||
VL53L1_xtalk_histogram_shape_t *pxtalk,
|
||||
VL53L1_histogram_bin_data_t *phist)
|
||||
{
|
||||
|
||||
|
||||
phist->cal_config__vcsel_start =
|
||||
pxtalk->cal_config__vcsel_start;
|
||||
phist->VL53L1_p_019 =
|
||||
pxtalk->VL53L1_p_019;
|
||||
phist->VL53L1_p_022 =
|
||||
pxtalk->VL53L1_p_022;
|
||||
|
||||
phist->phasecal_result__reference_phase =
|
||||
pxtalk->phasecal_result__reference_phase;
|
||||
phist->phasecal_result__vcsel_start =
|
||||
pxtalk->phasecal_result__vcsel_start;
|
||||
|
||||
phist->vcsel_width =
|
||||
pxtalk->vcsel_width;
|
||||
phist->zero_distance_phase =
|
||||
pxtalk->zero_distance_phase;
|
||||
|
||||
phist->zone_id = pxtalk->zone_id;
|
||||
phist->VL53L1_p_023 = pxtalk->VL53L1_p_023;
|
||||
phist->time_stamp = pxtalk->time_stamp;
|
||||
}
|
||||
|
||||
|
||||
void VL53L1_init_histogram_bin_data_struct(
|
||||
int32_t bin_value,
|
||||
uint16_t VL53L1_p_024,
|
||||
VL53L1_histogram_bin_data_t *pdata)
|
||||
{
|
||||
|
||||
|
||||
|
||||
uint16_t i = 0;
|
||||
|
||||
pdata->cfg_device_state = VL53L1_DEVICESTATE_SW_STANDBY;
|
||||
pdata->rd_device_state = VL53L1_DEVICESTATE_SW_STANDBY;
|
||||
|
||||
pdata->zone_id = 0;
|
||||
pdata->time_stamp = 0;
|
||||
|
||||
pdata->VL53L1_p_022 = 0;
|
||||
pdata->VL53L1_p_023 = VL53L1_HISTOGRAM_BUFFER_SIZE;
|
||||
pdata->VL53L1_p_024 = (uint8_t)VL53L1_p_024;
|
||||
pdata->number_of_ambient_bins = 0;
|
||||
|
||||
pdata->result__interrupt_status = 0;
|
||||
pdata->result__range_status = 0;
|
||||
pdata->result__report_status = 0;
|
||||
pdata->result__stream_count = 0;
|
||||
|
||||
pdata->result__dss_actual_effective_spads = 0;
|
||||
pdata->phasecal_result__reference_phase = 0;
|
||||
pdata->phasecal_result__vcsel_start = 0;
|
||||
pdata->cal_config__vcsel_start = 0;
|
||||
|
||||
pdata->vcsel_width = 0;
|
||||
pdata->VL53L1_p_009 = 0;
|
||||
pdata->VL53L1_p_019 = 0;
|
||||
pdata->total_periods_elapsed = 0;
|
||||
|
||||
pdata->min_bin_value = 0;
|
||||
pdata->max_bin_value = 0;
|
||||
|
||||
pdata->zero_distance_phase = 0;
|
||||
pdata->number_of_ambient_samples = 0;
|
||||
pdata->ambient_events_sum = 0;
|
||||
pdata->VL53L1_p_004 = 0;
|
||||
|
||||
for (i = 0; i < VL53L1_MAX_BIN_SEQUENCE_LENGTH; i++)
|
||||
pdata->bin_seq[i] = (uint8_t)i;
|
||||
|
||||
for (i = 0; i < VL53L1_MAX_BIN_SEQUENCE_LENGTH; i++)
|
||||
pdata->bin_rep[i] = 1;
|
||||
|
||||
|
||||
for (i = 0; i < VL53L1_HISTOGRAM_BUFFER_SIZE; i++)
|
||||
if (i < VL53L1_p_024)
|
||||
pdata->bin_data[i] = bin_value;
|
||||
else
|
||||
pdata->bin_data[i] = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void VL53L1_decode_row_col(
|
||||
uint8_t spad_number,
|
||||
uint8_t *prow,
|
||||
uint8_t *pcol)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (spad_number > 127) {
|
||||
*prow = 8 + ((255-spad_number) & 0x07);
|
||||
*pcol = (spad_number-128) >> 3;
|
||||
} else {
|
||||
*prow = spad_number & 0x07;
|
||||
*pcol = (127-spad_number) >> 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void VL53L1_hist_find_min_max_bin_values(
|
||||
VL53L1_histogram_bin_data_t *pdata)
|
||||
{
|
||||
|
||||
|
||||
uint8_t bin = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
for (bin = 0; bin < pdata->VL53L1_p_024; bin++) {
|
||||
|
||||
if (bin == 0 || pdata->min_bin_value >= pdata->bin_data[bin])
|
||||
pdata->min_bin_value = pdata->bin_data[bin];
|
||||
|
||||
if (bin == 0 || pdata->max_bin_value <= pdata->bin_data[bin])
|
||||
pdata->max_bin_value = pdata->bin_data[bin];
|
||||
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void VL53L1_hist_estimate_ambient_from_ambient_bins(
|
||||
VL53L1_histogram_bin_data_t *pdata)
|
||||
{
|
||||
|
||||
|
||||
uint8_t bin = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
if (pdata->number_of_ambient_bins > 0) {
|
||||
|
||||
pdata->number_of_ambient_samples =
|
||||
pdata->number_of_ambient_bins;
|
||||
|
||||
|
||||
|
||||
pdata->ambient_events_sum = 0;
|
||||
for (bin = 0; bin < pdata->number_of_ambient_bins; bin++)
|
||||
pdata->ambient_events_sum += pdata->bin_data[bin];
|
||||
|
||||
pdata->VL53L1_p_004 = pdata->ambient_events_sum;
|
||||
pdata->VL53L1_p_004 +=
|
||||
((int32_t)pdata->number_of_ambient_bins / 2);
|
||||
pdata->VL53L1_p_004 /=
|
||||
(int32_t)pdata->number_of_ambient_bins;
|
||||
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(0);
|
||||
}
|
||||
|
||||
|
||||
248
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_error_strings.c
Normal file
248
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_error_strings.c
Normal file
|
|
@ -0,0 +1,248 @@
|
|||
|
||||
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "vl53l1_error_codes.h"
|
||||
#include "vl53l1_error_strings.h"
|
||||
#include "vl53l1_platform_log.h"
|
||||
#include "vl53l1_ll_def.h"
|
||||
|
||||
#define LOG_FUNCTION_START(fmt, ...) \
|
||||
_LOG_FUNCTION_START(VL53L1_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END(status, ...) \
|
||||
_LOG_FUNCTION_END(VL53L1_TRACE_MODULE_API, status, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
|
||||
_LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_API, \
|
||||
status, fmt, ##__VA_ARGS__)
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_pal_error_string(
|
||||
VL53L1_Error PalErrorCode,
|
||||
char *pPalErrorString)
|
||||
{
|
||||
VL53L1_Error Status = VL53L1_ERROR_NONE;
|
||||
|
||||
#ifdef VL53L1_USE_EMPTY_STRING
|
||||
SUPPRESS_UNUSED_WARNING(PalErrorCode);
|
||||
#endif
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
#ifdef VL53L1_USE_EMPTY_STRING
|
||||
VL53L1_COPYSTRING(pPalErrorString, "");
|
||||
#else
|
||||
|
||||
switch (PalErrorCode) {
|
||||
case VL53L1_ERROR_NONE:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_NONE);
|
||||
break;
|
||||
case VL53L1_ERROR_CALIBRATION_WARNING:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_CALIBRATION_WARNING);
|
||||
break;
|
||||
case VL53L1_ERROR_MIN_CLIPPED:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_MIN_CLIPPED);
|
||||
break;
|
||||
case VL53L1_ERROR_UNDEFINED:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_UNDEFINED);
|
||||
break;
|
||||
case VL53L1_ERROR_INVALID_PARAMS:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_INVALID_PARAMS);
|
||||
break;
|
||||
case VL53L1_ERROR_NOT_SUPPORTED:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_NOT_SUPPORTED);
|
||||
break;
|
||||
case VL53L1_ERROR_RANGE_ERROR:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_RANGE_ERROR);
|
||||
break;
|
||||
case VL53L1_ERROR_TIME_OUT:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_TIME_OUT);
|
||||
break;
|
||||
case VL53L1_ERROR_MODE_NOT_SUPPORTED:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_MODE_NOT_SUPPORTED);
|
||||
break;
|
||||
case VL53L1_ERROR_BUFFER_TOO_SMALL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_BUFFER_TOO_SMALL);
|
||||
break;
|
||||
case VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_COMMS_BUFFER_TOO_SMALL);
|
||||
break;
|
||||
case VL53L1_ERROR_GPIO_NOT_EXISTING:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_GPIO_NOT_EXISTING);
|
||||
break;
|
||||
case VL53L1_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED);
|
||||
break;
|
||||
case VL53L1_ERROR_CONTROL_INTERFACE:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_CONTROL_INTERFACE);
|
||||
break;
|
||||
case VL53L1_ERROR_INVALID_COMMAND:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_INVALID_COMMAND);
|
||||
break;
|
||||
case VL53L1_ERROR_DIVISION_BY_ZERO:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_DIVISION_BY_ZERO);
|
||||
break;
|
||||
case VL53L1_ERROR_REF_SPAD_INIT:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_REF_SPAD_INIT);
|
||||
break;
|
||||
case VL53L1_ERROR_GPH_SYNC_CHECK_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_GPH_SYNC_CHECK_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_STREAM_COUNT_CHECK_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_STREAM_COUNT_CHECK_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_GPH_ID_CHECK_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_GPH_ID_CHECK_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_ZONE_GPH_ID_CHECK_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_ZONE_GPH_ID_CHECK_FAIL);
|
||||
break;
|
||||
|
||||
case VL53L1_ERROR_XTALK_EXTRACTION_NO_SAMPLE_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_XTALK_EXTRACTION_NO_SAMPLES_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL);
|
||||
break;
|
||||
|
||||
case VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_ZONE_CAL_NO_SAMPLE_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_ZONE_CAL_NO_SAMPLE_FAIL);
|
||||
break;
|
||||
|
||||
case VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_OFFSET_CAL_MISSING_SAMPLES);
|
||||
break;
|
||||
case VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH);
|
||||
break;
|
||||
case VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_OFFSET_CAL_RATE_TOO_HIGH);
|
||||
break;
|
||||
case VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW);
|
||||
break;
|
||||
|
||||
case VL53L1_WARNING_ZONE_CAL_MISSING_SAMPLES:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_ZONE_CAL_MISSING_SAMPLES);
|
||||
break;
|
||||
case VL53L1_WARNING_ZONE_CAL_SIGMA_TOO_HIGH:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_ZONE_CAL_SIGMA_TOO_HIGH);
|
||||
break;
|
||||
case VL53L1_WARNING_ZONE_CAL_RATE_TOO_HIGH:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_ZONE_CAL_RATE_TOO_HIGH);
|
||||
break;
|
||||
|
||||
case VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS);
|
||||
break;
|
||||
case VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH);
|
||||
break;
|
||||
case VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW);
|
||||
break;
|
||||
|
||||
case VL53L1_WARNING_XTALK_MISSING_SAMPLES:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_XTALK_MISSING_SAMPLES);
|
||||
break;
|
||||
case VL53L1_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT);
|
||||
break;
|
||||
case VL53L1_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT);
|
||||
break;
|
||||
|
||||
case VL53L1_ERROR_DEVICE_FIRMWARE_TOO_OLD:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_DEVICE_FIRMWARE_TOO_OLD);
|
||||
break;
|
||||
case VL53L1_ERROR_DEVICE_FIRMWARE_TOO_NEW:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_DEVICE_FIRMWARE_TOO_NEW);
|
||||
break;
|
||||
case VL53L1_ERROR_UNIT_TEST_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_UNIT_TEST_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_FILE_READ_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_FILE_READ_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_FILE_WRITE_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_FILE_WRITE_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_NOT_IMPLEMENTED:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_NOT_IMPLEMENTED);
|
||||
break;
|
||||
default:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_UNKNOW_ERROR_CODE);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
LOG_FUNCTION_END(Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
162
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_hist_char.c
Normal file
162
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_hist_char.c
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
|
||||
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
#include "vl53l1_core.h"
|
||||
#include "vl53l1_register_settings.h"
|
||||
#include "vl53l1_hist_char.h"
|
||||
|
||||
#define LOG_FUNCTION_START(fmt, ...) \
|
||||
_LOG_FUNCTION_START(VL53L1_TRACE_MODULE_HISTOGRAM, fmt, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END(status, ...) \
|
||||
_LOG_FUNCTION_END(VL53L1_TRACE_MODULE_HISTOGRAM, status, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
|
||||
_LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_HISTOGRAM,\
|
||||
status, fmt, ##__VA_ARGS__)
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_calib_config(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t vcsel_delay__a0,
|
||||
uint8_t calib_1,
|
||||
uint8_t calib_2,
|
||||
uint8_t calib_3,
|
||||
uint8_t calib_2__a0,
|
||||
uint8_t spad_readout)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
uint8_t comms_buffer[3];
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
status = VL53L1_enable_powerforce(Dev);
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_disable_firmware(Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
status = VL53L1_WrByte(
|
||||
Dev,
|
||||
VL53L1_RANGING_CORE__VCSEL_DELAY__A0,
|
||||
vcsel_delay__a0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
|
||||
|
||||
comms_buffer[0] = calib_1;
|
||||
comms_buffer[1] = calib_2;
|
||||
comms_buffer[2] = calib_3;
|
||||
|
||||
status = VL53L1_WriteMulti(
|
||||
Dev,
|
||||
VL53L1_RANGING_CORE__CALIB_1,
|
||||
comms_buffer,
|
||||
3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_WrByte(
|
||||
Dev,
|
||||
VL53L1_RANGING_CORE__CALIB_2__A0,
|
||||
calib_2__a0);
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_WrByte(
|
||||
Dev,
|
||||
VL53L1_RANGING_CORE__SPAD_READOUT,
|
||||
spad_readout);
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_enable_firmware(Dev);
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_set_hist_calib_pulse_delay(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t calib_delay)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
status =
|
||||
VL53L1_set_calib_config(
|
||||
Dev,
|
||||
0x01,
|
||||
calib_delay,
|
||||
0x04,
|
||||
0x08,
|
||||
0x14,
|
||||
VL53L1_RANGING_CORE__SPAD_READOUT__CALIB_PULSES);
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_disable_calib_pulse_delay(
|
||||
VL53L1_DEV Dev)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
status =
|
||||
VL53L1_set_calib_config(
|
||||
Dev,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
VL53L1_RANGING_CORE__SPAD_READOUT__STANDARD);
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
1540
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_nvm.c
Normal file
1540
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_nvm.c
Normal file
File diff suppressed because it is too large
Load diff
1032
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_nvm_debug.c
Normal file
1032
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_nvm_debug.c
Normal file
File diff suppressed because it is too large
Load diff
4131
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_register_funcs.c
Normal file
4131
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_register_funcs.c
Normal file
File diff suppressed because it is too large
Load diff
94
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_silicon_core.c
Normal file
94
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_silicon_core.c
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
|
||||
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_platform.h"
|
||||
#include "vl53l1_register_map.h"
|
||||
#include "vl53l1_core.h"
|
||||
#include "vl53l1_silicon_core.h"
|
||||
|
||||
|
||||
#define LOG_FUNCTION_START(fmt, ...) \
|
||||
_LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END(status, ...) \
|
||||
_LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
|
||||
_LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE,\
|
||||
status, fmt, ##__VA_ARGS__)
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_is_firmware_ready_silicon(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pready)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
|
||||
|
||||
uint8_t comms_buffer[5];
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
status = VL53L1_ReadMulti(
|
||||
Dev,
|
||||
VL53L1_INTERRUPT_MANAGER__ENABLES,
|
||||
comms_buffer,
|
||||
5);
|
||||
|
||||
if (status != VL53L1_ERROR_NONE)
|
||||
goto ENDFUNC;
|
||||
|
||||
pdev->dbg_results.interrupt_manager__enables =
|
||||
comms_buffer[0];
|
||||
pdev->dbg_results.interrupt_manager__clear =
|
||||
comms_buffer[1];
|
||||
pdev->dbg_results.interrupt_manager__status =
|
||||
comms_buffer[2];
|
||||
pdev->dbg_results.mcu_to_host_bank__wr_access_en =
|
||||
comms_buffer[3];
|
||||
pdev->dbg_results.power_management__go1_reset_status =
|
||||
comms_buffer[4];
|
||||
|
||||
if ((pdev->sys_ctrl.power_management__go1_power_force & 0x01)
|
||||
== 0x01) {
|
||||
|
||||
if (((pdev->dbg_results.interrupt_manager__enables &
|
||||
0x1F) == 0x1F) &&
|
||||
((pdev->dbg_results.interrupt_manager__clear
|
||||
& 0x1F) == 0x1F))
|
||||
*pready = 0x01;
|
||||
else
|
||||
*pready = 0x00;
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
if ((pdev->dbg_results.power_management__go1_reset_status
|
||||
& 0x01) == 0x00)
|
||||
*pready = 0x01;
|
||||
else
|
||||
*pready = 0x00;
|
||||
}
|
||||
|
||||
|
||||
ENDFUNC:
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
466
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_wait.c
Normal file
466
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_wait.c
Normal file
|
|
@ -0,0 +1,466 @@
|
|||
|
||||
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_ll_device.h"
|
||||
#include "vl53l1_platform.h"
|
||||
#include "vl53l1_core.h"
|
||||
#include "vl53l1_silicon_core.h"
|
||||
#include "vl53l1_wait.h"
|
||||
#include "vl53l1_register_settings.h"
|
||||
|
||||
|
||||
#define LOG_FUNCTION_START(fmt, ...) \
|
||||
_LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END(status, ...) \
|
||||
_LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
|
||||
_LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE, status, \
|
||||
fmt, ##__VA_ARGS__)
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_wait_for_boot_completion(
|
||||
VL53L1_DEV Dev)
|
||||
{
|
||||
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
|
||||
|
||||
uint8_t fw_ready = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
if (pdev->wait_method == VL53L1_WAIT_METHOD_BLOCKING) {
|
||||
|
||||
|
||||
|
||||
status =
|
||||
VL53L1_poll_for_boot_completion(
|
||||
Dev,
|
||||
VL53L1_BOOT_COMPLETION_POLLING_TIMEOUT_MS);
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
fw_ready = 0;
|
||||
while (fw_ready == 0x00 && status == VL53L1_ERROR_NONE) {
|
||||
status = VL53L1_is_boot_complete(
|
||||
Dev,
|
||||
&fw_ready);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
status = VL53L1_WaitMs(
|
||||
Dev,
|
||||
VL53L1_POLLING_DELAY_MS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_wait_for_firmware_ready(
|
||||
VL53L1_DEV Dev)
|
||||
{
|
||||
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
|
||||
|
||||
uint8_t fw_ready = 0;
|
||||
uint8_t mode_start = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
mode_start =
|
||||
pdev->sys_ctrl.system__mode_start &
|
||||
VL53L1_DEVICEMEASUREMENTMODE_MODE_MASK;
|
||||
|
||||
|
||||
|
||||
if ((mode_start == VL53L1_DEVICEMEASUREMENTMODE_TIMED) ||
|
||||
(mode_start == VL53L1_DEVICEMEASUREMENTMODE_SINGLESHOT)) {
|
||||
|
||||
if (pdev->wait_method == VL53L1_WAIT_METHOD_BLOCKING) {
|
||||
|
||||
|
||||
|
||||
status =
|
||||
VL53L1_poll_for_firmware_ready(
|
||||
Dev,
|
||||
VL53L1_RANGE_COMPLETION_POLLING_TIMEOUT_MS);
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
fw_ready = 0;
|
||||
while (fw_ready == 0x00 && status ==
|
||||
VL53L1_ERROR_NONE) {
|
||||
status = VL53L1_is_firmware_ready(
|
||||
Dev,
|
||||
&fw_ready);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
status = VL53L1_WaitMs(
|
||||
Dev,
|
||||
VL53L1_POLLING_DELAY_MS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_wait_for_range_completion(
|
||||
VL53L1_DEV Dev)
|
||||
{
|
||||
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
|
||||
|
||||
uint8_t data_ready = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
if (pdev->wait_method == VL53L1_WAIT_METHOD_BLOCKING) {
|
||||
|
||||
|
||||
|
||||
status =
|
||||
VL53L1_poll_for_range_completion(
|
||||
Dev,
|
||||
VL53L1_RANGE_COMPLETION_POLLING_TIMEOUT_MS);
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
data_ready = 0;
|
||||
while (data_ready == 0x00 && status == VL53L1_ERROR_NONE) {
|
||||
status = VL53L1_is_new_data_ready(
|
||||
Dev,
|
||||
&data_ready);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
status = VL53L1_WaitMs(
|
||||
Dev,
|
||||
VL53L1_POLLING_DELAY_MS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_wait_for_test_completion(
|
||||
VL53L1_DEV Dev)
|
||||
{
|
||||
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
|
||||
|
||||
uint8_t data_ready = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
if (pdev->wait_method == VL53L1_WAIT_METHOD_BLOCKING) {
|
||||
|
||||
|
||||
|
||||
status =
|
||||
VL53L1_poll_for_range_completion(
|
||||
Dev,
|
||||
VL53L1_TEST_COMPLETION_POLLING_TIMEOUT_MS);
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
data_ready = 0;
|
||||
while (data_ready == 0x00 && status == VL53L1_ERROR_NONE) {
|
||||
status = VL53L1_is_new_data_ready(
|
||||
Dev,
|
||||
&data_ready);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
status = VL53L1_WaitMs(
|
||||
Dev,
|
||||
VL53L1_POLLING_DELAY_MS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_is_boot_complete(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pready)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
uint8_t firmware__system_status = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
status =
|
||||
VL53L1_RdByte(
|
||||
Dev,
|
||||
VL53L1_FIRMWARE__SYSTEM_STATUS,
|
||||
&firmware__system_status);
|
||||
|
||||
|
||||
|
||||
if ((firmware__system_status & 0x01) == 0x01) {
|
||||
*pready = 0x01;
|
||||
VL53L1_init_ll_driver_state(
|
||||
Dev,
|
||||
VL53L1_DEVICESTATE_SW_STANDBY);
|
||||
} else {
|
||||
*pready = 0x00;
|
||||
VL53L1_init_ll_driver_state(
|
||||
Dev,
|
||||
VL53L1_DEVICESTATE_FW_COLDBOOT);
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_is_firmware_ready(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pready)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
status = VL53L1_is_firmware_ready_silicon(
|
||||
Dev,
|
||||
pready);
|
||||
|
||||
pdev->fw_ready = *pready;
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_is_new_data_ready(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pready)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
|
||||
|
||||
uint8_t gpio__mux_active_high_hv = 0;
|
||||
uint8_t gpio__tio_hv_status = 0;
|
||||
uint8_t interrupt_ready = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
gpio__mux_active_high_hv =
|
||||
pdev->stat_cfg.gpio_hv_mux__ctrl &
|
||||
VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_MASK;
|
||||
|
||||
if (gpio__mux_active_high_hv == VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_HIGH)
|
||||
interrupt_ready = 0x01;
|
||||
else
|
||||
interrupt_ready = 0x00;
|
||||
|
||||
|
||||
|
||||
status = VL53L1_RdByte(
|
||||
Dev,
|
||||
VL53L1_GPIO__TIO_HV_STATUS,
|
||||
&gpio__tio_hv_status);
|
||||
|
||||
|
||||
|
||||
if ((gpio__tio_hv_status & 0x01) == interrupt_ready)
|
||||
*pready = 0x01;
|
||||
else
|
||||
*pready = 0x00;
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_poll_for_boot_completion(
|
||||
VL53L1_DEV Dev,
|
||||
uint32_t timeout_ms)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
status = VL53L1_WaitUs(
|
||||
Dev,
|
||||
VL53L1_FIRMWARE_BOOT_TIME_US);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_WaitValueMaskEx(
|
||||
Dev,
|
||||
timeout_ms,
|
||||
VL53L1_FIRMWARE__SYSTEM_STATUS,
|
||||
0x01,
|
||||
0x01,
|
||||
VL53L1_POLLING_DELAY_MS);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
VL53L1_init_ll_driver_state(Dev, VL53L1_DEVICESTATE_SW_STANDBY);
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_poll_for_firmware_ready(
|
||||
VL53L1_DEV Dev,
|
||||
uint32_t timeout_ms)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
|
||||
|
||||
uint32_t start_time_ms = 0;
|
||||
uint32_t current_time_ms = 0;
|
||||
int32_t poll_delay_ms = VL53L1_POLLING_DELAY_MS;
|
||||
uint8_t fw_ready = 0;
|
||||
|
||||
|
||||
|
||||
VL53L1_GetTickCount(Dev, &start_time_ms);
|
||||
pdev->fw_ready_poll_duration_ms = 0;
|
||||
|
||||
|
||||
|
||||
while ((status == VL53L1_ERROR_NONE) &&
|
||||
(pdev->fw_ready_poll_duration_ms < timeout_ms) &&
|
||||
(fw_ready == 0)) {
|
||||
|
||||
status = VL53L1_is_firmware_ready(
|
||||
Dev,
|
||||
&fw_ready);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE &&
|
||||
fw_ready == 0 &&
|
||||
poll_delay_ms > 0) {
|
||||
status = VL53L1_WaitMs(
|
||||
Dev,
|
||||
poll_delay_ms);
|
||||
}
|
||||
|
||||
|
||||
VL53L1_GetTickCount(Dev, ¤t_time_ms);
|
||||
pdev->fw_ready_poll_duration_ms =
|
||||
current_time_ms - start_time_ms;
|
||||
}
|
||||
|
||||
if (fw_ready == 0 && status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_ERROR_TIME_OUT;
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_poll_for_range_completion(
|
||||
VL53L1_DEV Dev,
|
||||
uint32_t timeout_ms)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
|
||||
|
||||
uint8_t gpio__mux_active_high_hv = 0;
|
||||
uint8_t interrupt_ready = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
gpio__mux_active_high_hv =
|
||||
pdev->stat_cfg.gpio_hv_mux__ctrl &
|
||||
VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_MASK;
|
||||
|
||||
if (gpio__mux_active_high_hv == VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_HIGH)
|
||||
interrupt_ready = 0x01;
|
||||
else
|
||||
interrupt_ready = 0x00;
|
||||
|
||||
status =
|
||||
VL53L1_WaitValueMaskEx(
|
||||
Dev,
|
||||
timeout_ms,
|
||||
VL53L1_GPIO__TIO_HV_STATUS,
|
||||
interrupt_ready,
|
||||
0x01,
|
||||
VL53L1_POLLING_DELAY_MS);
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
152
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_zone_presets.c
Normal file
152
drivers/input/misc/vl53L1_14_1_2/src/vl53l1_zone_presets.c
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
|
||||
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_ll_device.h"
|
||||
#include "vl53l1_platform_log.h"
|
||||
#include "vl53l1_zone_presets.h"
|
||||
|
||||
|
||||
#define LOG_FUNCTION_START(fmt, ...) \
|
||||
_LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END(status, ...) \
|
||||
_LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
|
||||
_LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE,\
|
||||
status, fmt, ##__VA_ARGS__)
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_init_zone_config_structure(
|
||||
uint8_t x_off,
|
||||
uint8_t x_inc,
|
||||
uint8_t x_zones,
|
||||
uint8_t y_off,
|
||||
uint8_t y_inc,
|
||||
uint8_t y_zones,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
VL53L1_zone_config_t *pdata)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
uint8_t x = 0;
|
||||
uint8_t y = 0;
|
||||
uint16_t i = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
pdata->max_zones = VL53L1_MAX_USER_ZONES;
|
||||
|
||||
i = 0;
|
||||
|
||||
for (x = 0 ; x < x_zones ; x++) {
|
||||
for (y = 0 ; y < y_zones ; y++) {
|
||||
|
||||
if (i < VL53L1_MAX_USER_ZONES) {
|
||||
|
||||
pdata->active_zones = (uint8_t)i;
|
||||
pdata->user_zones[i].height = height;
|
||||
pdata->user_zones[i].width = width;
|
||||
pdata->user_zones[i].x_centre =
|
||||
x_off + (x * x_inc);
|
||||
pdata->user_zones[i].y_centre =
|
||||
y_off + (y * y_inc);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
status = VL53L1_init_zone_config_histogram_bins(pdata);
|
||||
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_zone_preset_xtalk_planar(
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_zone_config_t *pzone_cfg)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
pgeneral->global_config__stream_divider = 0x05;
|
||||
|
||||
|
||||
pzone_cfg->active_zones = 0x04;
|
||||
|
||||
pzone_cfg->user_zones[0].height = 15;
|
||||
pzone_cfg->user_zones[0].width = 7;
|
||||
pzone_cfg->user_zones[0].x_centre = 4;
|
||||
pzone_cfg->user_zones[0].y_centre = 8;
|
||||
|
||||
pzone_cfg->user_zones[1].height = 15;
|
||||
pzone_cfg->user_zones[1].width = 7;
|
||||
pzone_cfg->user_zones[1].x_centre = 12;
|
||||
pzone_cfg->user_zones[1].y_centre = 8;
|
||||
|
||||
pzone_cfg->user_zones[2].height = 7;
|
||||
pzone_cfg->user_zones[2].width = 15;
|
||||
pzone_cfg->user_zones[2].x_centre = 8;
|
||||
pzone_cfg->user_zones[2].y_centre = 4;
|
||||
|
||||
pzone_cfg->user_zones[3].height = 7;
|
||||
pzone_cfg->user_zones[3].width = 15;
|
||||
pzone_cfg->user_zones[3].x_centre = 8;
|
||||
pzone_cfg->user_zones[3].y_centre = 12;
|
||||
|
||||
|
||||
|
||||
pzone_cfg->user_zones[4].height = 15;
|
||||
pzone_cfg->user_zones[4].width = 15;
|
||||
pzone_cfg->user_zones[4].x_centre = 8;
|
||||
pzone_cfg->user_zones[4].y_centre = 8;
|
||||
|
||||
status = VL53L1_init_zone_config_histogram_bins(pzone_cfg);
|
||||
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_init_zone_config_histogram_bins(
|
||||
VL53L1_zone_config_t *pdata)
|
||||
{
|
||||
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
uint8_t i;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
for (i = 0; i < pdata->max_zones; i++)
|
||||
pdata->bin_config[i] = VL53L1_ZONECONFIG_BINCONFIG__LOWAMB;
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
89
drivers/input/misc/vl53L1_14_1_2/stmvl53l1-i2c.h
Normal file
89
drivers/input/misc/vl53L1_14_1_2/stmvl53l1-i2c.h
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @file stmvl53l1-i2c.h
|
||||
* Linux kernel i2c/cci wrapper for ST VL53L1 sensor i2c interface
|
||||
**/
|
||||
|
||||
#ifndef STMVL53L1_I2C_H
|
||||
#define STMVL53L1_I2C_H
|
||||
#include <linux/types.h>
|
||||
#include "stmvl53l1.h"
|
||||
|
||||
struct i2c_data {
|
||||
struct i2c_client *client;
|
||||
/** back link to driver for interrupt and clean-up */
|
||||
struct stmvl53l1_data *vl53l1_data;
|
||||
|
||||
/* reference counter */
|
||||
struct kref ref;
|
||||
|
||||
/*!< if null no regulator use for power ctrl */
|
||||
struct regulator *vdd;
|
||||
|
||||
/*!< power enable gpio number
|
||||
*
|
||||
* if -1 no gpio if vdd not avl pwr is not controllable
|
||||
*/
|
||||
int pwren_gpio;
|
||||
|
||||
/*!< xsdn reset (low active) gpio number to device
|
||||
*
|
||||
* -1 mean none assume no "resetable"
|
||||
*/
|
||||
int xsdn_gpio;
|
||||
|
||||
/*!< intr gpio number to device
|
||||
*
|
||||
* intr is active/low negative edge by default
|
||||
*
|
||||
* -1 mean none assume use polling
|
||||
* @warning if the dev tree and intr gpio is require please adapt code
|
||||
*/
|
||||
int intr_gpio;
|
||||
|
||||
/*!< device boot i2c register address
|
||||
*
|
||||
* boot_reg is the value of device i2c address after it is bring out
|
||||
* of reset.
|
||||
*/
|
||||
int boot_reg;
|
||||
|
||||
/*!< is set if above irq gpio got acquired */
|
||||
struct i2d_data_flags_t {
|
||||
unsigned pwr_owned:1; /*!< set if pwren gpio is owned*/
|
||||
unsigned xsdn_owned:1; /*!< set if sxdn gpio is owned*/
|
||||
unsigned intr_owned:1; /*!< set if intr gpio is owned*/
|
||||
unsigned intr_started:1; /*!< set if irq is hanlde */
|
||||
} io_flag;
|
||||
|
||||
/** the irq vectore assigned to gpio
|
||||
* -1 if no irq hanled
|
||||
*/
|
||||
int irq;
|
||||
|
||||
struct msgtctrl_t {
|
||||
unsigned unhandled_irq_vec:1;
|
||||
} msg_flag;
|
||||
};
|
||||
|
||||
int stmvl53l1_init_i2c(void);
|
||||
void __exit stmvl53l1_exit_i2c(void *arg);
|
||||
int stmvl53l1_power_up_i2c(void *arg);
|
||||
int stmvl53l1_power_down_i2c(void *arg);
|
||||
int stmvl53l1_reset_release_i2c(void *arg);
|
||||
int stmvl53l1_reset_hold_i2c(void *arg);
|
||||
void stmvl53l1_clean_up_i2c(void);
|
||||
int stmvl53l1_start_intr(void *object, int *poll_mode);
|
||||
void *stmvl53l1_get(void *arg);
|
||||
void stmvl53l1_put(void *arg);
|
||||
|
||||
#endif /* STMVL53L1_I2C_H */
|
||||
287
drivers/input/misc/vl53L1_14_1_2/stmvl53l1.h
Normal file
287
drivers/input/misc/vl53L1_14_1_2/stmvl53l1.h
Normal file
|
|
@ -0,0 +1,287 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file stmvl53l1.h header for vl53l1 sensor driver
|
||||
*/
|
||||
#ifndef STMVL53L1_H
|
||||
#define STMVL53L1_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/miscdevice.h>
|
||||
#include <linux/wait.h>
|
||||
|
||||
#include "vl53l1_api.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
# define IPP_PRINT(...) printk(__VA_ARGS__)
|
||||
#else
|
||||
# define IPP_PRINT(...) (void)0
|
||||
#endif
|
||||
|
||||
struct st_timeval {
|
||||
time64_t tv_sec; /* seconds */
|
||||
long tv_usec; /* microseconds */
|
||||
};
|
||||
|
||||
void st_gettimeofday(struct st_timeval *tv);
|
||||
|
||||
#include "stmvl53l1_if.h"
|
||||
|
||||
#define STMVL53L1_MAX_CCI_XFER_SZ 256
|
||||
#define STMVL53L1_DRV_NAME "stmvl53l1"
|
||||
|
||||
/**
|
||||
* configure usage of regulator device from device tree info
|
||||
* to enable/disable sensor power
|
||||
* see module-i2c or module-cci file
|
||||
*/
|
||||
/* define CFG_STMVL53L1_HAVE_REGULATOR */
|
||||
|
||||
#define DRIVER_VERSION "14.1.2"
|
||||
|
||||
/** @ingroup vl53l1_config
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Configure max number of device the driver can support
|
||||
*/
|
||||
#define STMVL53L1_CFG_MAX_DEV 2
|
||||
/** @} */ /* ingroup vl53l1_config */
|
||||
|
||||
/** @ingroup vl53l1_mod_dbg
|
||||
* @{
|
||||
*/
|
||||
#if 0
|
||||
#define DEBUG 1
|
||||
#endif
|
||||
#if 0
|
||||
#define FORCE_CONSOLE_DEBUG 1
|
||||
#endif
|
||||
|
||||
extern int stmvl53l1_enable_debug;
|
||||
|
||||
#ifdef DEBUG
|
||||
# ifdef FORCE_CONSOLE_DEBUG
|
||||
#define vl53l1_dbgmsg(str, ...) do { \
|
||||
if (stmvl53l1_enable_debug) \
|
||||
pr_err("%s: " str, __func__, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
# else
|
||||
#define vl53l1_dbgmsg(str, ...) do { \
|
||||
if (stmvl53l1_enable_debug) \
|
||||
pr_err("%s: " str, __func__, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
# endif
|
||||
#else
|
||||
# define vl53l1_dbgmsg(...) (void)0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* set to 0 1 activate or not debug from work (data interrupt/polling)
|
||||
*/
|
||||
#define WORK_DEBUG 0
|
||||
#if WORK_DEBUG
|
||||
# define work_dbg(msg, ...)\
|
||||
printk("[D WK53L1] :" msg "\n", ##__VA_ARGS__)
|
||||
#else
|
||||
# define work_dbg(...) (void)0
|
||||
#endif
|
||||
|
||||
#define vl53l1_info(str, args...) \
|
||||
pr_info("%s: " str, __func__, ##args)
|
||||
|
||||
#define vl53l1_errmsg(str, args...) \
|
||||
pr_err("%s: " str, __func__, ##args)
|
||||
|
||||
#define vl53l1_wanrmsg(str, args...) \
|
||||
pr_warn("%s: " str, __func__, ##args)
|
||||
|
||||
/* turn off poll log if not defined */
|
||||
#ifndef STMVL53L1_LOG_POLL_TIMING
|
||||
# define STMVL53L1_LOG_POLL_TIMING 0
|
||||
#endif
|
||||
/* turn off cci log timing if not defined */
|
||||
#ifndef STMVL53L1_LOG_CCI_TIMING
|
||||
# define STMVL53L1_LOG_CCI_TIMING 0
|
||||
#endif
|
||||
|
||||
/**@} */ /* ingroup mod_dbg*/
|
||||
|
||||
#include <net/sock.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/wait.h>
|
||||
|
||||
struct stmvl53l1_waiters {
|
||||
struct list_head list;
|
||||
pid_t pid;
|
||||
};
|
||||
|
||||
/*
|
||||
* driver data structs
|
||||
*/
|
||||
struct stmvl53l1_data {
|
||||
int id; /*!< multiple device id 0 based*/
|
||||
char name[64]; /*!< misc device name */
|
||||
uint8_t product_type; /*!< L1:0xCC L3:0xAA i.e. module_type in datasheet */
|
||||
|
||||
VL53L1_DevData_t stdev; /*!<embed ST VL53L1 Dev data as "stdev" */
|
||||
|
||||
void *client_object; /*!< cci or i2c model i/f specific ptr */
|
||||
bool is_device_remove; /*!< true when device has been remove */
|
||||
|
||||
struct mutex work_mutex; /*!< main dev mutex/lock */;
|
||||
struct delayed_work dwork;
|
||||
/*!< work for pseudo irq polling check */
|
||||
|
||||
struct input_dev *input_dev_ps;
|
||||
/*!< input device used for sending event */
|
||||
|
||||
/* misc device */
|
||||
struct miscdevice miscdev;
|
||||
/* first irq has no valid data, so avoid to update data on first one */
|
||||
int is_first_irq;
|
||||
/* set when first start has be done */
|
||||
int is_first_start_done;
|
||||
|
||||
/* control data */
|
||||
int poll_mode; /*!< use poll even if interrupt line present*/
|
||||
int poll_delay_ms; /*!< rescheduled time use in poll mode */
|
||||
int enable_sensor; /*!< actual device enabled state */
|
||||
struct st_timeval start_tv;/*!< stream start time */
|
||||
int enable_debug;
|
||||
bool allow_hidden_start_stop; /*!< allow stop/start sequence in bare */
|
||||
|
||||
/* Custom values set by app */
|
||||
|
||||
int preset_mode; /*!< preset working mode of the device */
|
||||
uint32_t timing_budget; /*!< Timing Budget */
|
||||
int distance_mode; /*!< distance mode of the device */
|
||||
int crosstalk_enable; /*!< is crosstalk compensation is enable */
|
||||
int output_mode; /*!< output mode of the device */
|
||||
bool force_device_on_en;/*!< keep device active when stopped */
|
||||
bool force_device_on_en_default;
|
||||
int sar_mode; /*!< is sar mode enable/disabled */
|
||||
int cam_mode; /*!< is camera mode enable/disabled */
|
||||
VL53L1_Error last_error;/*!< last device internal error */
|
||||
int offset_correction_mode;/*!< offset correction mode to apply */
|
||||
FixPoint1616_t dmax_reflectance;/*!< reflectance use for dmax calc */
|
||||
int dmax_mode; /*!< Dmax mode of the device */
|
||||
int smudge_correction_mode; /*!< smudge mode */
|
||||
|
||||
/* Read only values */
|
||||
FixPoint1616_t optical_offset_x;
|
||||
FixPoint1616_t optical_offset_y;
|
||||
bool is_xtalk_value_changed; /*!< xtalk values has been updated */
|
||||
|
||||
/* PS parameters */
|
||||
|
||||
/* Calibration parameters */
|
||||
bool is_calibrating; /*!< active during calibration phases */
|
||||
uint16_t xtalk_offset; /*!< crosstalk compensation plane offset kcps */
|
||||
int16_t xtalk_x; /*!< crosstalk compensation x plane gradient kcps */
|
||||
int16_t xtalk_y; /*!< crosstalk compensation y plane gradient kcps */
|
||||
int16_t inner_offset; /*!< inner offset mm */
|
||||
int16_t outer_offset; /*!< outer offset mm */
|
||||
VL53L1_CalibrationData_t *cali_data; /*!< full calibration data */
|
||||
|
||||
/* Range Data and stat */
|
||||
struct range_t {
|
||||
uint32_t cnt;
|
||||
uint32_t intr;
|
||||
int poll_cnt;
|
||||
uint32_t err_cnt; /* on actual measurement */
|
||||
uint32_t err_tot; /* from start */
|
||||
struct st_timeval start_tv;
|
||||
struct st_timeval comp_tv;
|
||||
VL53L1_RangingMeasurementData_t single_range_data;
|
||||
VL53L1_MultiRangingData_t multi_range_data;
|
||||
VL53L1_MultiRangingData_t tmp_range_data;
|
||||
VL53L1_AdditionalData_t additional_data;
|
||||
/* non mode 1 for data agregation */
|
||||
} meas;
|
||||
|
||||
/* workqueue use to fire flush event */
|
||||
uint32_t flushCount;
|
||||
int flush_todo_counter;
|
||||
|
||||
/* Device parameters */
|
||||
/* Polling thread */
|
||||
/* Wait Queue on which the poll thread blocks */
|
||||
|
||||
/* Manage blocking ioctls */
|
||||
struct list_head simple_data_reader_list;
|
||||
struct list_head mz_data_reader_list;
|
||||
wait_queue_head_t waiter_for_data;
|
||||
bool is_data_valid;
|
||||
|
||||
/* control when using delay is acceptable */
|
||||
bool is_delay_allowed;
|
||||
|
||||
/* maintain reset state */
|
||||
int reset_state;
|
||||
|
||||
/* Recent interrupt status */
|
||||
/* roi */
|
||||
VL53L1_RoiConfig_t roi_cfg;
|
||||
|
||||
/* use for zone calibration / roi mismatch detection */
|
||||
uint32_t current_roi_id;
|
||||
|
||||
/* Embed here since it's too huge for kernek stack */
|
||||
struct stmvl53l1_ioctl_zone_calibration_data_t calib;
|
||||
|
||||
/* autonomous config */
|
||||
uint32_t auto_pollingTimeInMs;
|
||||
VL53L1_DetectionConfig_t auto_config;
|
||||
|
||||
/* autonomous config for camera */
|
||||
uint32_t auto_pollingTimeInMs_cam;
|
||||
VL53L1_DetectionConfig_t auto_config_cam;
|
||||
|
||||
int sysfs_base;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* st_timeval diff in us
|
||||
*
|
||||
* @param pstart_tv
|
||||
* @param pstop_tv
|
||||
*/
|
||||
long stmvl53l1_tv_dif(struct st_timeval *pstart_tv, struct st_timeval *pstop_tv);
|
||||
|
||||
|
||||
/**
|
||||
* The device table list table is update as device get added
|
||||
* we do not support adding removing device mutiple time !
|
||||
* use for clean "unload" purpose
|
||||
*/
|
||||
extern struct stmvl53l1_data *stmvl53l1_dev_table[];
|
||||
|
||||
int stmvl53l1_setup(struct stmvl53l1_data *data);
|
||||
void stmvl53l1_cleanup(struct stmvl53l1_data *data);
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
void stmvl53l1_pm_suspend_stop(struct stmvl53l1_data *data);
|
||||
#endif
|
||||
int stmvl53l1_intr_handler(struct stmvl53l1_data *data);
|
||||
|
||||
int stmvl53l1_sysfs_laser(struct stmvl53l1_data *data, bool create);
|
||||
|
||||
/*
|
||||
* function pointer structs
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#endif /* STMVL53L1_H */
|
||||
352
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_i2c.c
Normal file
352
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_i2c.c
Normal file
|
|
@ -0,0 +1,352 @@
|
|||
|
||||
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file stmvl53l1_i2c.c vl53l1 linux native i2c interface
|
||||
*
|
||||
*/
|
||||
#include "stmvl53l1.h"
|
||||
#include "stmvl53l1-i2c.h"
|
||||
#include <linux/i2c.h>
|
||||
|
||||
#define WRITE_MULTIPLE_CHUNK_MAX 32
|
||||
|
||||
#if STMVL53L1_LOG_POLL_TIMING
|
||||
/**
|
||||
* helper to elapse time in polling
|
||||
* @param ptv pointer to start time_val
|
||||
|
||||
*/
|
||||
# define poll_timing_log(ptv) \
|
||||
vl53l1_dbgmsg("poll in %d us\n", tv_elapsed_us(ptv))
|
||||
#else
|
||||
# define poll_timing_log(...) (void)0
|
||||
#endif
|
||||
|
||||
#if STMVL53L1_LOG_CCI_TIMING
|
||||
/**
|
||||
* compute elapsed time in in micro sec based on do_gettimeofday
|
||||
* @param tv pointer to start time_val
|
||||
* @return time elapsed in micro seconde
|
||||
*/
|
||||
|
||||
/**
|
||||
* compute elapsed time in in micro sec based on do_gettimeofday
|
||||
* @param tv pointer to start time_val
|
||||
* @return time elapsed in micro seconde
|
||||
*/
|
||||
static uint32_t tv_elapsed_us(struct st_timeval *tv)
|
||||
{
|
||||
struct st_timeval now;
|
||||
|
||||
st_gettimeofday(&now);
|
||||
return (now.tv_sec - tv->tv_sec) * 1000000 + (now.tv_usec -
|
||||
tv->tv_usec);
|
||||
}
|
||||
|
||||
# define cci_access_var struct st_timeval cci_log_start_tv
|
||||
# define cci_access_start()\
|
||||
st_gettimeofday(&cci_log_start_tv)
|
||||
# define cci_access_over(fmt, ...) \
|
||||
vl53l1_dbgmsg("cci_timing %d us" fmt "\n", \
|
||||
tv_elapsed_us(&cci_log_start_tv), ##__VA_ARGS__)
|
||||
#else
|
||||
# define cci_access_var
|
||||
# define cci_access_start(...) (void)0
|
||||
# define cci_access_over(...) (void)0
|
||||
#endif
|
||||
|
||||
#ifdef STMVL53L1_DEBUG_I2C
|
||||
# define i2c_debug(fmt, ...) vl53l1_dbgmsg(fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
# define i2c_debug(fmt, ...) (void)0
|
||||
#endif
|
||||
|
||||
VL53L1_Error VL53L1_GetTickCount(VL53L1_Dev_t *pdev, uint32_t *ptime_ms)
|
||||
{
|
||||
(void)pdev;
|
||||
(void)ptime_ms;
|
||||
BUG_ON(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* compute elapsed time in in milli sec based on do_gettimeofday
|
||||
* @param tv pointer to start time_val
|
||||
* @return time elapsed in milli seconde
|
||||
*/
|
||||
static uint32_t tv_elapsed_ms(struct st_timeval *tv)
|
||||
{
|
||||
struct st_timeval now;
|
||||
|
||||
st_gettimeofday(&now);
|
||||
return (now.tv_sec - tv->tv_sec) * 1000 +
|
||||
(now.tv_usec - tv->tv_usec) / 1000;
|
||||
}
|
||||
|
||||
static int cci_write(struct stmvl53l1_data *dev, int index,
|
||||
uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint8_t buffer[STMVL53L1_MAX_CCI_XFER_SZ + 2];
|
||||
struct i2c_msg msg;
|
||||
struct i2c_data *i2c_client_obj = (struct i2c_data *)dev->client_object;
|
||||
struct i2c_client *client = (struct i2c_client *)i2c_client_obj->client;
|
||||
int rc;
|
||||
|
||||
cci_access_var;
|
||||
if (len > STMVL53L1_MAX_CCI_XFER_SZ || len == 0) {
|
||||
vl53l1_errmsg("invalid len %d\n", len);
|
||||
return -1;
|
||||
}
|
||||
cci_access_start();
|
||||
/* build up little endian index in buffer */
|
||||
buffer[0] = (index >> 8) & 0xFF;
|
||||
buffer[1] = (index >> 0) & 0xFF;
|
||||
/* copy write data to buffer after index */
|
||||
memcpy(buffer + 2, data, len);
|
||||
/* set i2c msg */
|
||||
msg.addr = client->addr;
|
||||
msg.flags = client->flags;
|
||||
msg.buf = buffer;
|
||||
msg.len = len + 2;
|
||||
|
||||
rc = i2c_transfer(client->adapter, &msg, 1);
|
||||
if (rc != 1) {
|
||||
vl53l1_errmsg("wr i2c_transfer err:%d, index 0x%x len %d\n",
|
||||
rc, index, len);
|
||||
}
|
||||
cci_access_over("rd status %d long %d ", rc != 1, len);
|
||||
return rc != 1;
|
||||
}
|
||||
|
||||
static int cci_read(struct stmvl53l1_data *dev, int index,
|
||||
uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint8_t buffer[2];
|
||||
struct i2c_msg msg[2];
|
||||
struct i2c_data *i2c_client_obj = (struct i2c_data *)dev->client_object;
|
||||
struct i2c_client *client = (struct i2c_client *)i2c_client_obj->client;
|
||||
int rc;
|
||||
|
||||
cci_access_var;
|
||||
if (len > STMVL53L1_MAX_CCI_XFER_SZ || len == 0) {
|
||||
vl53l1_errmsg("invalid len %d\n", len);
|
||||
return -1;
|
||||
}
|
||||
cci_access_start();
|
||||
|
||||
/* build up little endian index in buffer */
|
||||
buffer[0] = (index >> 8) & 0xFF;
|
||||
buffer[1] = (index >> 0) & 0xFF;
|
||||
|
||||
msg[0].addr = client->addr;
|
||||
msg[0].flags = client->flags; /* Write */
|
||||
msg[0].buf = buffer;
|
||||
msg[0].len = 2;
|
||||
/* read part of the i2c transaction */
|
||||
msg[1].addr = client->addr;
|
||||
msg[1].flags = I2C_M_RD | client->flags;
|
||||
msg[1].buf = data;
|
||||
msg[1].len = len;
|
||||
|
||||
rc = i2c_transfer(client->adapter, msg, 2);
|
||||
if (rc != 2) {
|
||||
pr_err("%s: i2c_transfer :%d, @%x index 0x%x len %d\n",
|
||||
__func__, rc, client->addr, index, len);
|
||||
|
||||
}
|
||||
cci_access_over(" wr len %d status %d", rc != 2, len);
|
||||
return rc != 2;
|
||||
}
|
||||
|
||||
VL53L1_Error VL53L1_WrByte(VL53L1_DEV pdev, uint16_t index, uint8_t data)
|
||||
{
|
||||
struct stmvl53l1_data *dev;
|
||||
|
||||
dev = (struct stmvl53l1_data *)container_of(pdev,
|
||||
struct stmvl53l1_data,
|
||||
stdev);
|
||||
|
||||
return cci_write(dev, index, &data, 1);
|
||||
|
||||
}
|
||||
|
||||
VL53L1_Error VL53L1_RdByte(VL53L1_DEV pdev, uint16_t index, uint8_t *pdata)
|
||||
{
|
||||
struct stmvl53l1_data *dev;
|
||||
|
||||
dev = (struct stmvl53l1_data *)container_of(pdev,
|
||||
struct stmvl53l1_data,
|
||||
stdev);
|
||||
|
||||
return cci_read(dev, index, pdata, 1) ?
|
||||
VL53L1_ERROR_CONTROL_INTERFACE : VL53L1_ERROR_NONE;
|
||||
}
|
||||
|
||||
VL53L1_Error VL53L1_WrWord(VL53L1_DEV pdev, uint16_t index, uint16_t data)
|
||||
{
|
||||
VL53L1_Error status;
|
||||
uint8_t buffer[2];
|
||||
|
||||
/* Split 16-bit word into MS and L* stmvl53l1 FlightSense sensor */
|
||||
|
||||
buffer[0] = (uint8_t) (data >> 8);
|
||||
buffer[1] = (uint8_t) (data & 0x00FF);
|
||||
i2c_debug(" @%x d= %x => [ %x , %x ] ", index, data, buffer[0],
|
||||
buffer[1]);
|
||||
status = VL53L1_WriteMulti(pdev, index, buffer, 2);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
VL53L1_Error VL53L1_RdWord(VL53L1_DEV pdev, uint16_t index, uint16_t *pdata)
|
||||
{
|
||||
VL53L1_Error status;
|
||||
uint8_t buffer[2];
|
||||
|
||||
status = VL53L1_ReadMulti(pdev, index, buffer, 2);
|
||||
|
||||
*pdata = ((uint16_t) buffer[0] << 8) + (uint16_t) buffer[1];
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
VL53L1_Error VL53L1_WrDWord(VL53L1_DEV pdev, uint16_t index, uint32_t data)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
uint8_t buffer[4];
|
||||
|
||||
/* Split 32-bit word into MS ... LS bytes */
|
||||
buffer[0] = (uint8_t) (data >> 24);
|
||||
buffer[1] = (uint8_t) ((data & 0x00FF0000) >> 16);
|
||||
buffer[2] = (uint8_t) ((data & 0x0000FF00) >> 8);
|
||||
buffer[3] = (uint8_t) (data & 0x000000FF);
|
||||
|
||||
status = VL53L1_WriteMulti(pdev, index, buffer, 4);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
VL53L1_Error VL53L1_RdDWord(VL53L1_DEV pdev, uint16_t index, uint32_t *pdata)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
uint8_t buffer[4];
|
||||
|
||||
status = VL53L1_ReadMulti(pdev, index, buffer, 4);
|
||||
|
||||
*pdata = ((uint32_t) buffer[0] << 24) + ((uint32_t) buffer[1] << 16)
|
||||
+ ((uint32_t) buffer[2] << 8) + (uint32_t) buffer[3];
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
VL53L1_Error VL53L1_WriteMulti(VL53L1_DEV pdev, uint16_t index,
|
||||
uint8_t *pdata, uint32_t count)
|
||||
{
|
||||
struct stmvl53l1_data *dev;
|
||||
uint32_t chunk_size = WRITE_MULTIPLE_CHUNK_MAX;
|
||||
VL53L1_Error status;
|
||||
uint32_t i;
|
||||
uint16_t hostaddr = index;
|
||||
|
||||
dev = (struct stmvl53l1_data *)container_of(pdev,
|
||||
struct stmvl53l1_data,
|
||||
stdev);
|
||||
|
||||
for (i = 0; i < count; i += chunk_size) {
|
||||
status = (cci_write(dev, hostaddr, &pdata[i],
|
||||
min(chunk_size, (count - i))) ?
|
||||
VL53L1_ERROR_CONTROL_INTERFACE : VL53L1_ERROR_NONE);
|
||||
if (status != VL53L1_ERROR_NONE)
|
||||
break;
|
||||
hostaddr += chunk_size;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
VL53L1_Error VL53L1_ReadMulti(VL53L1_DEV pdev, uint16_t index,
|
||||
uint8_t *pdata, uint32_t count)
|
||||
{
|
||||
struct stmvl53l1_data *dev;
|
||||
|
||||
dev = (struct stmvl53l1_data *)container_of(pdev,
|
||||
struct stmvl53l1_data,
|
||||
stdev);
|
||||
|
||||
return cci_read(dev, index, pdata, count) ?
|
||||
VL53L1_ERROR_CONTROL_INTERFACE : VL53L1_ERROR_NONE;
|
||||
}
|
||||
|
||||
static int is_time_over(struct st_timeval *tv, uint32_t msec)
|
||||
{
|
||||
return tv_elapsed_ms(tv) >= msec;
|
||||
}
|
||||
|
||||
VL53L1_Error VL53L1_WaitValueMaskEx(VL53L1_DEV pdev,
|
||||
uint32_t timeout_ms,
|
||||
uint16_t index,
|
||||
uint8_t value,
|
||||
uint8_t mask, uint32_t poll_delay_ms)
|
||||
{
|
||||
struct st_timeval start_tv;
|
||||
struct stmvl53l1_data *dev;
|
||||
int rc, time_over;
|
||||
uint8_t rd_val;
|
||||
|
||||
dev = (struct stmvl53l1_data *)container_of(pdev,
|
||||
struct stmvl53l1_data,
|
||||
stdev);
|
||||
|
||||
st_gettimeofday(&start_tv);
|
||||
do {
|
||||
rc = cci_read(dev, index, &rd_val, 1);
|
||||
if (rc)
|
||||
return VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
if ((rd_val & mask) == value) {
|
||||
poll_timing_log(&start_tv);
|
||||
return VL53L1_ERROR_NONE;
|
||||
}
|
||||
vl53l1_dbgmsg("poll @%x %x & %d != %x", index,
|
||||
rd_val, mask, value);
|
||||
time_over = is_time_over(&start_tv, timeout_ms);
|
||||
if (!time_over)
|
||||
msleep(poll_delay_ms);
|
||||
} while (!time_over);
|
||||
vl53l1_errmsg("time over %d ms", timeout_ms);
|
||||
return VL53L1_ERROR_TIME_OUT;
|
||||
}
|
||||
|
||||
VL53L1_Error VL53L1_WaitUs(VL53L1_DEV pdev, int32_t wait_us)
|
||||
{
|
||||
struct stmvl53l1_data *data;
|
||||
|
||||
data = (struct stmvl53l1_data *)container_of(pdev,
|
||||
struct stmvl53l1_data,
|
||||
stdev);
|
||||
|
||||
if (!data->is_delay_allowed)
|
||||
return VL53L1_ERROR_PLATFORM_SPECIFIC_START;
|
||||
|
||||
/* follow Documentation/timers/timers-howto.txt recommendations */
|
||||
if (wait_us < 10)
|
||||
udelay(wait_us);
|
||||
else if (wait_us < 20000)
|
||||
usleep_range(wait_us, wait_us + 1);
|
||||
else
|
||||
msleep(wait_us / 1000);
|
||||
|
||||
return VL53L1_ERROR_NONE;
|
||||
}
|
||||
|
||||
VL53L1_Error VL53L1_WaitMs(VL53L1_DEV pdev, int32_t wait_ms)
|
||||
{
|
||||
return VL53L1_WaitUs(pdev, wait_ms * 1000);
|
||||
}
|
||||
694
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_if.h
Normal file
694
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_if.h
Normal file
|
|
@ -0,0 +1,694 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file stmvl53l1_if.h vl53l1 kernel driver user interface
|
||||
*
|
||||
* @note to use this header in a user space application it requires
|
||||
* all st bare/ll driver platform wrapper files (for data struct def)
|
||||
* this files (types etc ..) shall be same or compliant with bar driver version
|
||||
* used in the kernel module
|
||||
*/
|
||||
|
||||
#ifndef STMVL53L1_IF_H
|
||||
#define STMVL53L1_IF_H
|
||||
|
||||
|
||||
#include "vl53l1_def.h"
|
||||
/**
|
||||
* @addtogroup vl53l1_ioctl
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* misc device name for ioctl device
|
||||
*
|
||||
* for mutli instance all device 2nd and next instance are basic name +"1"+"2"
|
||||
* @li stmvl53l1_ranging
|
||||
* @li stmvl53l1_ranging1
|
||||
* @li stmvl53l1_ranging2
|
||||
*/
|
||||
#define VL53L1_MISC_DEV_NAME "laser"
|
||||
/**
|
||||
* register data use for simple/single ranging data @ref VL53L1_IOCTL_GETDATAS
|
||||
*
|
||||
* @warning this definition is subject to change !
|
||||
*/
|
||||
#define stmvl531_range_data_t VL53L1_RangingMeasurementData_t
|
||||
|
||||
/**
|
||||
* parameter name in @ref stmvl53l1_parameter when using
|
||||
* @ref VL53L1_IOCTL_PARAMETER
|
||||
*/
|
||||
enum __stmv53l1_parameter_name_e {
|
||||
VL53L1_XTALKENABLE_PAR = 2,
|
||||
/*!< VL53L1_XTALKENABLE_PAR enable/disable crosstalk compensation\n
|
||||
* valid value :
|
||||
* @li 0 disable crosstalk compensation
|
||||
* @li 1 enable crosstalk compensation
|
||||
*
|
||||
* @warning mode can only be set while not ranging
|
||||
*/
|
||||
|
||||
VL53L1_DEVICEMODE_PAR = 6,
|
||||
/*!< DEVICEMODE_PAR set ranging mode \n
|
||||
* valid mode value :
|
||||
* @li 1 @a VL53L1_PRESETMODE_RANGING default ranging
|
||||
* @li 2 @a VL53L1_PRESETMODE_MULTIZONES_SCANNING multiple zone
|
||||
* @li 3 @a VL53L1_PRESETMODE_AUTONOMOUS autonomous mode
|
||||
* @li 4 @a VL53L1_PRESETMODE_LITE_RANGING low mips ranging mode
|
||||
* @li 8 @a VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS low power autonomous
|
||||
* mode
|
||||
*
|
||||
* @note VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS and
|
||||
* VL53L1_PRESETMODE_AUTONOMOUS ranging modes use the polling time and
|
||||
* the threholds set by @ref VL53L1_IOCTL_AUTONOMOUS_CONFIG
|
||||
*
|
||||
* @warning mode can only be set while not ranging
|
||||
*/
|
||||
|
||||
VL53L1_POLLDELAY_PAR = 10,
|
||||
/*!< set the polling delay (msec)\n
|
||||
*
|
||||
* @note apply only when operates in polling mode as no effect
|
||||
* otherwise
|
||||
*/
|
||||
VL53L1_TIMINGBUDGET_PAR = 11,
|
||||
/*!< VL53L1_TIMINGBUDGET_PAR
|
||||
* @ref stmvl53l1_parameter.value field is timing budget
|
||||
* in micro second
|
||||
*
|
||||
* @note Please refer to VL53L1 user manual for minimum timing budget
|
||||
* according to the selected mode
|
||||
*
|
||||
* Mode / timing budget | Min | Typical
|
||||
* ------------------------------------- | ----- | -------
|
||||
* VL53L1_PRESETMODE_RANGING | 8 ms | 16 ms
|
||||
* VL53L1_PRESETMODE_MULTIZONES_SCANNING | 8 ms | 16 ms
|
||||
* VL53L1_PRESETMODE_AUTONOMOUS | 41 ms | 76 ms
|
||||
* VL53L1_PRESETMODE_LITE_RANGING | 17 ms | 66 ms
|
||||
* VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS | 20 ms | 20 ms
|
||||
*
|
||||
*/
|
||||
|
||||
VL53L1_DISTANCEMODE_PAR = 12,
|
||||
/*!< VL53L1_DISTANCEMODE_PAR
|
||||
* valid distance mode value :
|
||||
* @li 1 @a VL53L1_DISTANCEMODE_SHORT
|
||||
* @li 2 @a VL53L1_DISTANCEMODE_MEDIUM
|
||||
* @li 3 @a VL53L1_DISTANCEMODE_LONG
|
||||
*
|
||||
* @warning distance mode can only be set while not ranging
|
||||
*/
|
||||
|
||||
VL53L1_OUTPUTMODE_PAR = 13,
|
||||
/*!< VL53L1_OUTPUTMODE_PAR
|
||||
* valid output mode value :
|
||||
* @li 1 @a VL53L1_OUTPUTMODE_NEAREST
|
||||
* @li 2 @a VL53L1_OUTPUTMODE_STRONGEST
|
||||
*
|
||||
* @warning distance mode can only be set while not ranging
|
||||
*/
|
||||
|
||||
VL53L1_FORCEDEVICEONEN_PAR = 14,
|
||||
/*!< VL53L1_FORCEDEVICEONEN_PAR
|
||||
* This parameter will control if device is put under reset when
|
||||
* stopped.
|
||||
* valid force device on value :
|
||||
* @li 0 feature is disable. Device is put under reset when stopped.
|
||||
* @li 1 feature is enable. Device is not put under reset when stopped.
|
||||
*/
|
||||
|
||||
VL53L1_LASTERROR_PAR = 15,
|
||||
/*!< VL53L1_LASTERROR_PAR
|
||||
* This is a read only parameter. It will return last device internal
|
||||
* error. It's valid only after an ioctl/sysfs return an -EIO error.
|
||||
*/
|
||||
|
||||
VL53L1_OFFSETCORRECTIONMODE_PAR = 16,
|
||||
/*!< VL53L1_OFFSETCORRECTIONMODE_PAR
|
||||
* This parameter will define which mode to use for the offset
|
||||
* correction.
|
||||
* valid force device on value :
|
||||
* @li 1 @a VL53L1_OFFSETCORRECTIONMODE_STANDARD
|
||||
* @li 2 @a VL53L1_OFFSETCORRECTIONMODE_PERZONE
|
||||
*
|
||||
* @warning offset correction mode can only be set while not ranging
|
||||
*/
|
||||
|
||||
VL53L1_OPTICALCENTER_PAR = 17,
|
||||
/*!< VL53L1_OPTICALCENTER_PAR
|
||||
* This is a read only parameter. It will return optical center issued
|
||||
* from the nvm set at FTM stage. value will contain X position of
|
||||
* center. value2 will contain Y position of center.
|
||||
* Return values have FixPoint1616_t type.
|
||||
*/
|
||||
|
||||
VL53L1_DMAXREFLECTANCE_PAR = 18,
|
||||
/*!< VL53L1_DMAXREFLECTANCE_PAR
|
||||
* This parameter will define target reflectance @ 940nm used to
|
||||
* calculate the ambient DMAX. Parameter is of type FixPoint1616_t.
|
||||
*
|
||||
* @warning dmax reflectance can only be be set while not ranging
|
||||
*/
|
||||
|
||||
VL53L1_DMAXMODE_PAR = 19,
|
||||
/*!< VL53L1_DMAXMODE_PAR
|
||||
* This parameter will select Dmax mode.
|
||||
* valid Dmax mode value :
|
||||
* @li 1 @a VL53L1_DMAXMODE_FMT_CAL_DATA
|
||||
* @li 2 @a VL53L1_DMAXMODE_CUSTCAL_DATA
|
||||
* @li 3 @a VL53L1_DMAXMODE_PER_ZONE_CAL_DATA
|
||||
*
|
||||
* @warning Dmax mode can only be set while not ranging
|
||||
*/
|
||||
|
||||
VL53L1_TUNING_PAR = 20,
|
||||
/*!< VL53L1_DMAXMODE_PAR
|
||||
* This parameter is a write only parameter. It will allow to provide
|
||||
* low level layer with a configuration parameter.
|
||||
* value will be use as a key parameter.
|
||||
* value2 will be use as value parameter.
|
||||
*
|
||||
* @warning those configuration parameter settings are only allowed
|
||||
* before device is start once.
|
||||
*/
|
||||
|
||||
VL53L1_SMUDGECORRECTIONMODE_PAR = 21,
|
||||
/*!< VL53L1_SMUDGECORRECTIONMODE_PAR
|
||||
* This parameter will control if smudge correction is enable and how
|
||||
* crosstalk values are updated.
|
||||
* @li 0 @a VL53L1_SMUDGE_CORRECTION_NONE
|
||||
* @li 1 @a VL53L1_SMUDGE_CORRECTION_CONTINUOUS
|
||||
* @li 2 @a VL53L1_SMUDGE_CORRECTION_SINGLE
|
||||
* @li 3 @a VL53L1_SMUDGE_CORRECTION_DEBUG
|
||||
*/
|
||||
|
||||
VL53L1_ISXTALKVALUECHANGED_PAR = 22,
|
||||
/*!< VL53L1_ISXTALKCHANGED_PAR
|
||||
* This is a read only parameter. It will return if Xtalk value has
|
||||
* been updated while ranging. This parameter is reset each time device
|
||||
* start to range.
|
||||
* @li 0 Xtalk values has not been changed.
|
||||
* @li 1 Xtalk values has been changed.
|
||||
*/
|
||||
};
|
||||
#define stmv53l1_parameter_name_e enum __stmv53l1_parameter_name_e
|
||||
|
||||
/**
|
||||
* parameter structure use in @ref VL53L1_IOCTL_PARAMETER
|
||||
*/
|
||||
struct stmvl53l1_parameter {
|
||||
uint32_t is_read; /*!< [in] 1: Get 0: Set*/
|
||||
/*!< [in] parameter to set/get
|
||||
* see @ref stmv53l1_parameter_name_e
|
||||
*/
|
||||
stmv53l1_parameter_name_e name;
|
||||
int32_t value; /*!< [in/out] value to set /get */
|
||||
int32_t value2; /*!< [in/out] optional 2nd value */
|
||||
int32_t status; /*!< [out] status of the operation */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* roi structure use as @ref VL53L1_IOCTL_ROI arg
|
||||
*
|
||||
* see @ref stmvl53l1_roi_full_t for easy to use type variable declaration
|
||||
* required
|
||||
*/
|
||||
struct stmvl53l1_roi_t {
|
||||
int32_t is_read;
|
||||
/*!< specify roi transfer direction \n
|
||||
* @li 0 to get roi
|
||||
* @li !0 to set roi
|
||||
*/
|
||||
/*! roi data and count type use in @ VL53L1_IOCTL_ROI */
|
||||
struct roi_cfg_t {
|
||||
uint8_t NumberOfRoi;
|
||||
/*!< [in/out] Number of Rois to set/get
|
||||
*
|
||||
* on set :\n
|
||||
* [in] number of roi to set
|
||||
* @note 0 set can be used to return to device default roi usage
|
||||
*
|
||||
* on get :\n
|
||||
* [in] max number provided\n
|
||||
* [out] number of ROI copied back to user\n
|
||||
* @warning 0 will not return any roi datas!
|
||||
*/
|
||||
VL53L1_UserRoi_t UserRois[1];
|
||||
/*!< roi data array length definition is 1 but
|
||||
* NumberOfRoi+ FirstRoiToScan in array are required
|
||||
* and will be effectively copy to/from user space
|
||||
*
|
||||
* @sa stmvl53l1_roi_full_t
|
||||
*/
|
||||
} roi_cfg /*! [in/out] roi data and count */;
|
||||
};
|
||||
|
||||
/**
|
||||
* full roi struct use in @ref VL53L1_IOCTL_ROI arg
|
||||
*
|
||||
* this definition make easier variable declaration with the max roi storage
|
||||
* capabilities.
|
||||
*
|
||||
* @sa stmvl53l1_roi_t for field details
|
||||
*/
|
||||
struct stmvl53l1_roi_full_t {
|
||||
int32_t is_read;
|
||||
/*!< specify roi transfer direction \n
|
||||
* @li 0 to get roi
|
||||
* @li !0 to set roi
|
||||
*/
|
||||
VL53L1_RoiConfig_t roi_cfg;
|
||||
/*!< roi data array of max length but only requested copy to/from user
|
||||
* space effectively used
|
||||
* see @a stmvl53l1_roi_t::roi_cfg for details
|
||||
*/
|
||||
};
|
||||
|
||||
/**
|
||||
* parameter structure use in @ref VL53L1_IOCTL_CALIBRATION_DATA
|
||||
*/
|
||||
struct stmvl53l1_ioctl_calibration_data_t {
|
||||
int32_t is_read; /*!< [in] 1: Get 0: Set*/
|
||||
VL53L1_CalibrationData_t data;
|
||||
/*!< [in/out] data to set /get. Caller
|
||||
* should consider this structure as an opaque one
|
||||
*/
|
||||
};
|
||||
|
||||
/**
|
||||
* Opaque structure use to hold content of zone offset calibration result.
|
||||
*/
|
||||
#define stmvl531_zone_calibration_data_t \
|
||||
struct _stmvl531_zone_calibration_data_t
|
||||
|
||||
struct _stmvl531_zone_calibration_data_t {
|
||||
uint32_t id;
|
||||
VL53L1_ZoneCalibrationData_t data;
|
||||
};
|
||||
|
||||
/**
|
||||
* parameter structure use in @ref VL53L1_IOCTL_ZONE_CALIBRATION_DATA
|
||||
*/
|
||||
struct stmvl53l1_ioctl_zone_calibration_data_t {
|
||||
int32_t is_read; /*!< [in] 1: Get 0: Set*/
|
||||
stmvl531_zone_calibration_data_t data;
|
||||
/*!< [in/out] data to set /get. Caller
|
||||
* should consider this structure as an opaque one
|
||||
*/
|
||||
};
|
||||
|
||||
/** Select reference spad calibration in @ref VL53L1_IOCTL_PERFORM_CALIBRATION.
|
||||
*
|
||||
* param1, param2 and param3 not use
|
||||
*/
|
||||
#define VL53L1_CALIBRATION_REF_SPAD 0
|
||||
|
||||
/** Select crosstalk calibration in @ref VL53L1_IOCTL_PERFORM_CALIBRATION.
|
||||
*
|
||||
* param1 is calibration method. param2 and param3 not use.
|
||||
* @li VL53L1_XTALKCALIBRATIONMODE_NO_TARGET
|
||||
* @li VL53L1_XTALKCALIBRATIONMODE_SINGLE_TARGET
|
||||
* @li VL53L1_XTALKCALIBRATIONMODE_FULL_ROI
|
||||
*/
|
||||
#define VL53L1_CALIBRATION_CROSSTALK 1
|
||||
|
||||
/** Select offset calibration @ref VL53L1_IOCTL_PERFORM_CALIBRATION.
|
||||
* param1 is offset calibration mode. Parameter is either:
|
||||
* - VL53L1_OFFSETCALIBRATIONMODE_STANDARD
|
||||
* - VL53L1_OFFSETCALIBRATIONMODE_PRERANGE_ONLY
|
||||
* - VL53L1_OFFSETCALIBRATIONMODE_MULTI_ZONE (deprecated)
|
||||
* param2 is target distance in mm.
|
||||
* param3 is target reflectance in percent. Parameter is of type FixPoint1616_t.
|
||||
*
|
||||
* Note that VL53L1_OFFSETCALIBRATIONMODE_MULTI_ZONE usage is deprecated. Per
|
||||
* zone offset calibration should use VL53L1_CALIBRATION_OFFSET_PER_ZONE
|
||||
* instead.
|
||||
*/
|
||||
#define VL53L1_CALIBRATION_OFFSET 2
|
||||
|
||||
/** Select offset calibration per zone @ref VL53L1_IOCTL_PERFORM_CALIBRATION.
|
||||
* param1 is offset calibration mode. Parameter is:
|
||||
* - VL53L1_OFFSETCALIBRATIONMODE_MULTI_ZONE
|
||||
* param2 is target distance in mm.
|
||||
* param3 is target reflectance in percent. Parameter is of type FixPoint1616_t.
|
||||
*
|
||||
* Note that region of interest should be defined by a prior call to
|
||||
* VL53L1_IOCTL_ROI before calling VL53L1_IOCTL_PERFORM_CALIBRATION /
|
||||
* VL53L1_CALIBRATION_OFFSET combinaison.
|
||||
*/
|
||||
#define VL53L1_CALIBRATION_OFFSET_PER_ZONE 3
|
||||
|
||||
/** Select simple offset calibration @ref VL53L1_IOCTL_PERFORM_CALIBRATION.
|
||||
* param1 is target distance in mm.
|
||||
* param2 and param3 are not used
|
||||
*/
|
||||
#define VL53L1_CALIBRATION_OFFSET_SIMPLE 4
|
||||
|
||||
/** Select per Vcsel offset calibration @ref VL53L1_IOCTL_PERFORM_CALIBRATION.
|
||||
* param1 is target distance in mm.
|
||||
* param2 and param3 are not used
|
||||
* this calibration is used by the VL53L1_OFFSETCORRECTIONMODE_PERVCSEL mode
|
||||
*/
|
||||
#define VL53L1_CALIBRATION_OFFSET_PER_VCSEL 5
|
||||
|
||||
/** Select no Distance offset calibration @ref VL53L1_IOCTL_PERFORM_CALIBRATION.
|
||||
* param1, param2 and param3 are not used
|
||||
*/
|
||||
#define VL53L1_CALIBRATION_OFFSET_ZERO_DISTANCE 6
|
||||
|
||||
/**
|
||||
* parameter structure use in @ref VL53L1_IOCTL_PERFORM_CALIBRATION
|
||||
*/
|
||||
struct stmvl53l1_ioctl_perform_calibration_t {
|
||||
uint32_t calibration_type;
|
||||
/*!< [in] select which calibration to do :
|
||||
* @li @ref VL53L1_CALIBRATION_REF_SPAD
|
||||
* @li @ref VL53L1_CALIBRATION_CROSSTALK
|
||||
* @li @ref VL53L1_CALIBRATION_OFFSET
|
||||
* @li @ref VL53L1_CALIBRATION_OFFSET_PER_ZONE
|
||||
* @li @ref VL53L1_CALIBRATION_OFFSET_SIMPLE
|
||||
* @li @ref VL53L1_CALIBRATION_OFFSET_PER_VCSEL
|
||||
* @li @ref VL53L1_CALIBRATION_OFFSET_ZERO_DISTANCE
|
||||
*/
|
||||
uint32_t param1;
|
||||
/*!< [in] first param. Usage depends on calibration_type */
|
||||
uint32_t param2;
|
||||
/*!< [in] second param. Usage depends on calibration_type */
|
||||
uint32_t param3;
|
||||
/*!< [in] third param. Usage depends on calibration_type */
|
||||
};
|
||||
|
||||
/**
|
||||
* parameter structure use in @ref VL53L1_IOCTL_AUTONOMOUS_CONFIG
|
||||
*/
|
||||
struct stmvl53l1_autonomous_config_t {
|
||||
int32_t is_read;
|
||||
/*!< [in] 1: Get 0: Set*/
|
||||
uint32_t pollingTimeInMs;
|
||||
/*!< [in/out] interval between two measure in ms */
|
||||
VL53L1_DetectionConfig_t config;
|
||||
/*!< [int/out] autonomous mode configuration structure */
|
||||
};
|
||||
|
||||
/*
|
||||
* IOCTL definitions
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Start ranging (no argument)
|
||||
*
|
||||
* @note sysfs and ioctl control are assumed mutual exclusive use
|
||||
* control from ioctl execute with no consideration of sysfs path.
|
||||
*
|
||||
* @return :
|
||||
* @li 0 on success
|
||||
* @li -EBUSY if already started
|
||||
* @li -ENXIO failed to change i2c address change after reset release
|
||||
* @li -EIO. Read last_error to get device error code
|
||||
* @li -ENODEV. Device has been removed.
|
||||
*
|
||||
* example user land :
|
||||
@code
|
||||
int smtvl53l1_start(int fd){error
|
||||
int rc;
|
||||
rc= ioctl(fd, VL53L1_IOCTL_START,NULL);
|
||||
if( rc ){
|
||||
if( errno == EBUSY){
|
||||
//the device is already started
|
||||
ioctl_warn("already started");
|
||||
return EBUSY;
|
||||
}
|
||||
}
|
||||
if( rc ){
|
||||
ioctl_error("%d %s", rc,strerror(errno));
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
|
||||
#define VL53L1_IOCTL_START _IO('p', 0x01)
|
||||
|
||||
/**
|
||||
* stop ranging (no argument)
|
||||
|
||||
* @note sysfs and ioctl control are assumed mutual exclusive use
|
||||
* control from ioctl execute action with no consideration of sysfs path.
|
||||
*
|
||||
* @return
|
||||
* @li 0 on success
|
||||
* @li -EBUSY if it was already
|
||||
* @li -EIO. Read last_error to get device error code
|
||||
* @li -ENODEV. Device has been removed.
|
||||
*
|
||||
* example user land :
|
||||
@code
|
||||
int smtvl53l1_stop(int fd){
|
||||
int rc;
|
||||
rc= ioctl(fd, VL53L1_IOCTL_STOP,NULL);
|
||||
if( rc ){
|
||||
if( errno == EBUSY ){
|
||||
ioctl_warn("already stopped");
|
||||
return errno;
|
||||
}
|
||||
ioctl_error("%d %s", rc,strerror(errno));
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
#define VL53L1_IOCTL_STOP _IO('p', 0x05)
|
||||
|
||||
/**
|
||||
* get single ranging data @sa for multi zone/objet
|
||||
*
|
||||
* retrieve the last range data available form the device
|
||||
*
|
||||
* @param in/out data struct ptr of type @ref stmvl531_range_data_t
|
||||
* it may come in but is out as of now
|
||||
*
|
||||
* @return 0 on success else o, error check errno
|
||||
* @li -EFAULT fault in cpy to f/m user out range data not copied
|
||||
* @li -ENODEV. Device has been removed.
|
||||
*
|
||||
* @warning this ioctl will not wait for a new range sample acquisition
|
||||
* it will return what available at time it get called . Hence same data maybe
|
||||
* returned many time when doing fast polling.\n
|
||||
* End user must inspect the data structure (time stamp etc )to find about it\n
|
||||
* Despite it's non "waiting" nature this ioctl may still block/sleep shortly
|
||||
* to ensure race free usage acquiring mutex and/or locks.
|
||||
*/
|
||||
#define VL53L1_IOCTL_GETDATAS \
|
||||
_IOWR('p', 0x0b, stmvl531_range_data_t)
|
||||
|
||||
/**
|
||||
* set or get parameter
|
||||
*
|
||||
* @param parameter in/out @ref stmvl53l1_parameter
|
||||
* @sa stmv53l1_parameter_name_e
|
||||
*
|
||||
* for get if ioctl fail do not check for out params it is not valid
|
||||
* for set theirs not copy back only see ioctl status, errno to get error case
|
||||
*
|
||||
* @return 0 on success else o, error check errno
|
||||
* @li -ENODEV. Device has been removed.
|
||||
*
|
||||
* @note a set parameter may not be absorbed straight aways !
|
||||
*/
|
||||
#define VL53L1_IOCTL_PARAMETER \
|
||||
_IOWR('p', 0x0d, struct stmvl53l1_parameter)
|
||||
|
||||
|
||||
/**
|
||||
* set/get roi
|
||||
*
|
||||
* shall only be use while device is stopped (EBUSY error otherwise)
|
||||
* setting 0 rois stand for "disable user define roi usage, use device default"
|
||||
*
|
||||
* @param roi_cfg [in/out] type @ref stmvl53l1_roi_t and
|
||||
* @ref stmvl53l1_roi_full_t
|
||||
* @note when getting roi the returned roi cnt is set to available number
|
||||
* of roi in driver but at most requested number or available one
|
||||
* will be set in returned structure
|
||||
* @warning the coordinate system is not usual image x,y (y down)but traditional
|
||||
* ecludian x,y (y up)
|
||||
*
|
||||
* @warning once defined the user roi is kept alive until unset by user .
|
||||
* User shall update roi when required (mode change etc ..)\n
|
||||
* To return to default unset roi by setting none, device will return to default
|
||||
* at next start
|
||||
*
|
||||
* @note roi validity is only checked at start ranging , as such invalid roi set
|
||||
* can make start to fail
|
||||
*
|
||||
* @return 0 on success , see errno for error detail
|
||||
* @li EBUSY when trying to set roi while ranging
|
||||
* @li ENODEV never device get started and trying to get more rois than set
|
||||
* @li other errno code could be ll driver specific
|
||||
*/
|
||||
#define VL53L1_IOCTL_ROI\
|
||||
_IOWR('p', 0x0e, struct stmvl53l1_roi_t)
|
||||
|
||||
/**
|
||||
* Get multi object/zone ranging data
|
||||
*
|
||||
* this call is non blocking and will return what available internally
|
||||
* in all case (veen error)
|
||||
*
|
||||
* @param [out] multi zone range @ref VL53L1_MultiRangingData_t always update
|
||||
* but -EFAULT error case
|
||||
*
|
||||
* @return 0 on success else o, error check errno
|
||||
* @li -EFAULT fault in cpy to f/m user out range data not copyed
|
||||
* @li -ENOEXEC active mode is not mutli-zone
|
||||
* @li -ENODEV device is not ranging or device has been removed.
|
||||
* as in that case MZ data may not be fully valid
|
||||
*/
|
||||
#define VL53L1_IOCTL_MZ_DATA\
|
||||
_IOR('p', 0x0f, VL53L1_MultiRangingData_t)
|
||||
|
||||
/**
|
||||
* get single ranging data @sa for multi zone/objet
|
||||
*
|
||||
* this call is equivalent to VL53L1_IOCTL_GETDATAS but will block until
|
||||
* new data are available since previous call.
|
||||
*
|
||||
* @param in/out data struct ptr of type @ref stmvl531_range_data_t
|
||||
* it may come in but is out as of now
|
||||
*
|
||||
* @return 0 on success else o, error check errno
|
||||
* @li -EFAULT fault in cpy to f/m user out range data not copied
|
||||
* @li -ENODEV device is not ranging or device has been removed.
|
||||
* @li -ERESTARTSYS interrupt while sleeping.
|
||||
*/
|
||||
#define VL53L1_IOCTL_GETDATAS_BLOCKING\
|
||||
_IOWR('p', 0x10, stmvl531_range_data_t)
|
||||
|
||||
/**
|
||||
* Get multi object/zone ranging data
|
||||
*
|
||||
* this call is equivalent to VL53L1_IOCTL_MZ_DATA but will block until
|
||||
* new data are available since previous call.
|
||||
*
|
||||
* @param [out] multi zone range @ref VL53L1_MultiRangingData_t always update
|
||||
* but -EFAULT error case
|
||||
*
|
||||
* @return 0 on success else o, error check errno
|
||||
* @li -EFAULT fault in cpy to f/m user out range data not copyed
|
||||
* @li -ENOEXEC active mode is not mutli-zone
|
||||
* @li -ENODEV device is not ranging or device has been removed.
|
||||
* @li -ERESTARTSYS interrupt while sleeping.
|
||||
* as in that case MZ data may not be fully valid
|
||||
*/
|
||||
#define VL53L1_IOCTL_MZ_DATA_BLOCKING\
|
||||
_IOR('p', 0x11, VL53L1_MultiRangingData_t)
|
||||
|
||||
/**
|
||||
* Get / set calibration data
|
||||
*
|
||||
* this call allow client to either read calibration data after calibration
|
||||
* has been performed to store them in the host filesystem or push calibration
|
||||
* data before ranging at each start-up.
|
||||
*
|
||||
* @param [in/out] data struct ptr of type
|
||||
* @ref stmvl53l1_ioctl_calibration_data_t. Caller should consider it as an
|
||||
* opaque structure.
|
||||
*
|
||||
* use this after either VL53L1_CALIBRATION_REF_SPAD,
|
||||
* VL53L1_CALIBRATION_CROSSTALK or VL53L1_CALIBRATION_OFFSET.
|
||||
*
|
||||
* @return 0 on success else o, error check errno
|
||||
* @li -EFAULT fault in cpy to f/m user out range data not copied
|
||||
* @li -EBUSY when trying to set calibration data while ranging
|
||||
* @li -EIO. Read last_error to get device error code
|
||||
* @li -ENODEV. Device has been removed.
|
||||
*/
|
||||
#define VL53L1_IOCTL_CALIBRATION_DATA\
|
||||
_IOWR('p', 0x12, struct stmvl53l1_ioctl_calibration_data_t)
|
||||
|
||||
/**
|
||||
* Get / set zone calibration data
|
||||
*
|
||||
* this call allow client to either read zone calibration data after calibration
|
||||
* has been performed to store them in the host filesystem or push zone
|
||||
* calibration data before ranging at each start-up.
|
||||
*
|
||||
* use this after VL53L1_CALIBRATION_OFFSET_PER_ZONE calibration.
|
||||
*
|
||||
* @param [in/out] data struct ptr of type
|
||||
* @ref stmvl53l1_ioctl_zone_calibration_data_t. Caller should consider it as an
|
||||
* opaque structure.
|
||||
*
|
||||
* @return 0 on success else o, error check errno
|
||||
* @li -EFAULT fault in cpy to f/m user out range data not copied
|
||||
* @li -EBUSY when trying to set calibration data while ranging
|
||||
* @li -EIO. Read last_error to get device error code
|
||||
* @li -ENODEV. Device has been removed.
|
||||
*/
|
||||
#define VL53L1_IOCTL_ZONE_CALIBRATION_DATA\
|
||||
_IOWR('p', 0x12, struct stmvl53l1_ioctl_zone_calibration_data_t)
|
||||
|
||||
/**
|
||||
* perform calibration squence according to calibration_type
|
||||
*
|
||||
* this call is attended to be used during factory calibration. You select
|
||||
* calibration to issue using calibration_type.
|
||||
*
|
||||
* @param [in] data struct ptr of type
|
||||
* @ref stmvl53l1_ioctl_perform_calibration_t.
|
||||
*
|
||||
* @return 0 on success else o, error check errno
|
||||
* @li -EFAULT fault in cpy to f/m user out range data not copied
|
||||
* @li -EBUSY when trying to perform calibration data while ranging
|
||||
* @li -EIO. Read last_error to get device error code
|
||||
* @li -ENODEV. Device has been removed.
|
||||
*/
|
||||
#define VL53L1_IOCTL_PERFORM_CALIBRATION\
|
||||
_IOW('p', 0x13, struct stmvl53l1_ioctl_perform_calibration_t)
|
||||
|
||||
/**
|
||||
* set/get configure autonomous mode parameters
|
||||
*
|
||||
* Allow to get or set autonomous configuration when device operates
|
||||
* in VL53L1_PRESETMODE_AUTONOMOUS or VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS\n
|
||||
* Change it only when device is stopped otherwise you will receive
|
||||
* an EBUSY error.
|
||||
*
|
||||
* @param stmvl53l1_autonomous_config_t [in/out]
|
||||
*
|
||||
* @note autonomous config validity is only checked at start ranging , as such
|
||||
* invalid autonomous config set can make start to fail.
|
||||
*
|
||||
* @return 0 on success , see errno for error detail
|
||||
* @li -EFAULT failed to copy from/to configuration.
|
||||
* @li -EBUSY when trying to change configuration while ranging.
|
||||
* @li -ENODEV. Device has been removed.
|
||||
* example user land \n
|
||||
* trig interrupt when a target is withing [0..300mm[ distance
|
||||
@code
|
||||
struct stmvl53l1_autonomous_config_t SD;
|
||||
SD.is_read = 0;
|
||||
SD.pollingTimeInMs = 100;
|
||||
SD.config.DetectionMode = 1;
|
||||
SD.config.Distance.CrossMode = 0;
|
||||
SD.config.Distance.Low = 300;
|
||||
rc = ioctl(fd, VL53L1_IOCTL_AUTONOMOUS_CONFIG, &SD);
|
||||
@endcode
|
||||
*/
|
||||
#define VL53L1_IOCTL_AUTONOMOUS_CONFIG\
|
||||
_IOWR('p', 0x14, struct stmvl53l1_autonomous_config_t)
|
||||
|
||||
/** @} */ /* ioctl group */
|
||||
#endif /* STMVL53L1_IF_H */
|
||||
100
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_internal_if.h
Normal file
100
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_internal_if.h
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef STMVL53L1_INTERNAL_IF_H
|
||||
#define STMVL53L1_INTERNAL_IF_H
|
||||
|
||||
#include "vl53l1_def.h"
|
||||
|
||||
/* interface definition move in this file is not supposed to be use by a normal
|
||||
* client. It's only here for internal testing purpose.
|
||||
*/
|
||||
|
||||
/* structure and ioctl that allow raw access to vl53l1 register */
|
||||
struct stmvl53l1_register {
|
||||
uint32_t is_read; /*!< type of the access 1: read 0: write*/
|
||||
uint32_t index; /*!< register index */
|
||||
uint32_t cnt; /*!< register size shall be 1 to n */
|
||||
int32_t status; /*!< operation status 0 ok else error */
|
||||
|
||||
union reg_data_t {
|
||||
uint8_t b; /*!< single data byte*/
|
||||
uint16_t w; /*!< single data word (16 bits)*/
|
||||
uint32_t dw; /*!< single data dword (32 bits)*/
|
||||
/*!< any size byte array
|
||||
* @note only effectively used array size is needed and will be
|
||||
* set/used another possible register definition is
|
||||
* @ref stmvl53l1_register_flexi
|
||||
*/
|
||||
uint8_t bytes[256];
|
||||
/*!< data only *@warning device is big endian and
|
||||
* no endianess adaptation is performed by
|
||||
* @ref VL53L1_IOCTL_REGISTER
|
||||
*/
|
||||
} data;
|
||||
};
|
||||
|
||||
struct stmvl53l1_register_flexi {
|
||||
uint32_t is_read; /*!< [in] type of the access 1: read 0: write*/
|
||||
uint32_t index; /*!< [in] register index */
|
||||
uint32_t cnt; /*!< [in] register size shall be 1 to n */
|
||||
int32_t status; /*!< [out] operation status 0 ok else error */
|
||||
uint8_t data[]; /*!< [in/out] flexible array size data */
|
||||
/*!< data only *@warning device is big endian and
|
||||
* no endianess adaptation is performed by @ref VL53L1_IOCTL_REGISTER
|
||||
*/
|
||||
};
|
||||
|
||||
#define VL53L1_IOCTL_REGISTER _IOWR('p', 0x0c, struct stmvl53l1_register)
|
||||
|
||||
struct stmvl53l1_data_with_additional {
|
||||
VL53L1_MultiRangingData_t data;
|
||||
VL53L1_AdditionalData_t additional_data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get multi object/zone ranging data with additional data for debug
|
||||
*
|
||||
* this call is non blocking and will return what available internally
|
||||
* in all case (veen error)
|
||||
*
|
||||
* @param [out] multi zone range @ref VL53L1_MultiRangingData_t always update
|
||||
* but -EFAULT error case
|
||||
*
|
||||
* @return 0 on success else o, error check errno
|
||||
* @li -EFAULT fault in cpy to f/m user out range data not copyed
|
||||
* @li -ENOEXEC active mode is not mutli-zone
|
||||
* @li -ENODEV device is not ranging or device has been removed.
|
||||
* as in that case MZ data may not be fully valid
|
||||
*/
|
||||
#define VL53L1_IOCTL_MZ_DATA_ADDITIONAL\
|
||||
_IOR('p', 0x15, struct stmvl53l1_data_with_additional)
|
||||
|
||||
/**
|
||||
* Get multi object/zone ranging data
|
||||
*
|
||||
* this call is equivalent to VL53L1_IOCTL_MZ_DATA_ADDITIONAL but will block
|
||||
* until new data are available since previous call.
|
||||
*
|
||||
* @param [out] multi zone range @ref VL53L1_MultiRangingData_t always update
|
||||
* but -EFAULT error case
|
||||
*
|
||||
* @return 0 on success else o, error check errno
|
||||
* @li -EFAULT fault in cpy to f/m user out range data not copyed
|
||||
* @li -ENOEXEC active mode is not mutli-zone
|
||||
* @li -ENODEV device is not ranging or device has been removed.
|
||||
* @li -ERESTARTSYS interrupt while sleeping.
|
||||
* as in that case MZ data may not be fully valid
|
||||
*/
|
||||
#define VL53L1_IOCTL_MZ_DATA_ADDITIONAL_BLOCKING\
|
||||
_IOR('p', 0x16, struct stmvl53l1_data_with_additional)
|
||||
|
||||
#endif
|
||||
366
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_ipp.h
Normal file
366
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_ipp.h
Normal file
|
|
@ -0,0 +1,366 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file stmvl53l1_ipp.h
|
||||
*
|
||||
* helper to serialize de-serialize data in ipp exchange between user/kernel
|
||||
*
|
||||
* @date Sep 2, 2016
|
||||
* @author imaging
|
||||
*/
|
||||
|
||||
#ifndef _STMVL53L1_IPP_H_
|
||||
#define _STMVL53L1_IPP_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
|
||||
|
||||
/** @ingroup ipp_dev
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup ipp_serialize ST IPP serialization helper
|
||||
*
|
||||
* to use the dump help you lust define first a few extra "specific"
|
||||
*
|
||||
* @li IPP_PRINT(fmt,..) with typical printf/printk interface
|
||||
*/
|
||||
/** @{ */
|
||||
/**
|
||||
* generic data type to serialized scalar and offset for pointer
|
||||
*
|
||||
* serialized data can be seen as a first array of n ipp_art_t
|
||||
* where each input are arg value for scaler type
|
||||
* and an offset with respect to the ipp_arg base array where the data
|
||||
*
|
||||
* @note if all ipp argument can fit on 32 bit then ipp_arg_t is best set as
|
||||
* a 32 bit base type '(i e uint32_t) to save space
|
||||
* on 64 bit cpu it can remain 64 bit type to get better alignment
|
||||
*/
|
||||
typedef uint64_t ipp_arg_t;
|
||||
|
||||
/**
|
||||
* set to the cpu structure alignment and packing constrain
|
||||
*
|
||||
* all serialized argument passed by pointer will be stored with
|
||||
* this memory align constrain
|
||||
*
|
||||
*
|
||||
* @note if target cpu is ok to access unaligned data or less constrain ie 64
|
||||
* bit data align 32 are ok then it can be set to 4 to save space in data
|
||||
* packing and copy\n
|
||||
* We may be over constraining in many cases as a struct is only required to
|
||||
* be aligned on i'st biggest item size
|
||||
*
|
||||
* @warning it must be a 2 power of 2 (& operation instead of mudulo used in
|
||||
* align calculation)
|
||||
* @warning using 8 byte constrain require that the @a ipp_arg_t is already
|
||||
* aligned on that constrain
|
||||
*/
|
||||
#define IPP_ALIGN_REQ 8
|
||||
|
||||
/**
|
||||
* set x to it's nearest aligned offset (not that 0 is fine as a valid offset
|
||||
* than will not be up aligned to next align chunk )
|
||||
*/
|
||||
#define IPP_ALIGN_OFFSET(x) (((x)+(IPP_ALIGN_REQ-1)) & (~(IPP_ALIGN_REQ-1)))
|
||||
|
||||
/**
|
||||
* declare variable needed for ipp serialization
|
||||
*/
|
||||
#define IPP_SERIALIZE_VAR int ipp_offset
|
||||
/**
|
||||
* Put in function start to init the serialization coding
|
||||
*
|
||||
* @param ipp_args buffer for data serialization
|
||||
* @param n_args is the total number of argument scalar and ptr to serialized
|
||||
* dot not count out only arg that will be returned
|
||||
*
|
||||
* it define local var "ipp_offset" used to accumulate all input args that must
|
||||
* be serialize. It reserve header room in the buffer to place for scalar args
|
||||
* and offset for args ptr copy
|
||||
*
|
||||
* args pass by pointer must be serialized by @ref IPP_SET_ARG_PTR in order they
|
||||
* are declare\n
|
||||
* scalar args can be serialized in any order with @ref IPP_SET_ARG
|
||||
*
|
||||
* scalar args that can't be cast to basic @ref ipp_arg_t shall be serialized
|
||||
* Manually or using a macro similar to ptr that can be pass by copy
|
||||
*
|
||||
*@note @ref IPP_SERIALIZE_VAR must be use first
|
||||
* @code
|
||||
* int ipp_to _ser(int arg0, struct st_t *pdata1){
|
||||
* char *local var;
|
||||
* ipp_arg_t args[256];
|
||||
* IPP_SERIALIZE_START(2);
|
||||
* IPP_SET_ARG(args, 0, arg0);
|
||||
* IPP_SET_ARG_PTR(args, 1, pdata);
|
||||
* do_one_ipp(args);
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
#define IPP_SERIALIZE_START(ipp_args, n_args)\
|
||||
(ipp_offset = IPP_ALIGN_OFFSET((char *)(&ipp_args[n_args]) - \
|
||||
(char *)ipp_args))
|
||||
|
||||
/**
|
||||
* @brief Serialize scalar argument
|
||||
*
|
||||
* serialized arg number n into ipp_args\n
|
||||
* can be used in any order
|
||||
*
|
||||
* @param ipp_args the args buffer
|
||||
* @param n 0 base arg number
|
||||
* @param v the scalar argument variable
|
||||
* @warning usable only for scalar type that can be copy on a ipp_arg_t
|
||||
*/
|
||||
#define IPP_SET_ARG(ipp_args, n, v) memcpy(&ipp_args[n], &v, sizeof(v))
|
||||
|
||||
/**
|
||||
* @brief Serialize an arg passed by pointer
|
||||
*
|
||||
* @param ipp_args the arg ptr array
|
||||
* @param n the arg number to serialize
|
||||
* @param pdata argument it must be a type like struct x_t * int [n] etc ...
|
||||
* that size is given by size of and and be copied by a single memcpy
|
||||
*/
|
||||
#define IPP_SET_ARG_PTR(ipp_args, n, pdata)\
|
||||
do {\
|
||||
ipp_args[n] = ipp_offset;\
|
||||
memcpy(((char *)ipp_args) + ipp_offset, pdata, sizeof(*pdata));\
|
||||
ipp_offset = IPP_ALIGN_OFFSET(ipp_offset + sizeof(*pdata));\
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* serialize out get ptr for pdata
|
||||
*
|
||||
* @note it does not cpy data just set ptr and update the offset
|
||||
* @warning to be use in order
|
||||
*
|
||||
* @param ipp_args the arg ptr array
|
||||
* @param n the arg number to serialize (unused)
|
||||
* @param pdata init to ptr in ipp_args type is used for offset computation
|
||||
* @warning to use sequential in order agr are serialized
|
||||
*/
|
||||
#define IPP_OUT_ARG_PTR(ipp_args, n, pdata)\
|
||||
do {\
|
||||
pdata = (void *)(((char *)ipp_args) + ipp_offset);\
|
||||
ipp_offset = IPP_ALIGN_OFFSET(ipp_offset + \
|
||||
(int)sizeof(*pdata));\
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
* @brief ipp get payload
|
||||
*
|
||||
* @return paylaod at time used \n
|
||||
* when all done it's overall out payload
|
||||
*
|
||||
* require @ref IPP_SERIALIZE_VAR and @ref IPP_SERIALIZE_START used first\n
|
||||
* best use after all @ref IPP_OUT_ARG_PTR or @ref IPP_SET_ARG_PTR done to get
|
||||
* full payload
|
||||
**/
|
||||
#define IPP_SERIALIZE_PAYLAOD() (ipp_offset + IPP_WORK_HDR_SIZE)
|
||||
|
||||
/**
|
||||
* de-serialize and argument that was passed by value
|
||||
* @param ipp_args the args array
|
||||
* @param n the 0 base argument number
|
||||
* @param v argument it must be exact type
|
||||
*
|
||||
*
|
||||
* @code
|
||||
* f_deserialize(ipp_arg_t args[])
|
||||
* {
|
||||
* // f_ser is like (uint16_t arg0, struct s_arg_t * arg1, int arg2)
|
||||
* uint16_t arg0;
|
||||
* void * parg1;
|
||||
* int arg2;
|
||||
*
|
||||
* IPP_GET_ARG( args, 0, arg0)
|
||||
* IPP_GET_ARG( args, 2, arg2)
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
#define IPP_GET_ARG(ipp_args, n, v) memcpy(&v, &ipp_args[n], sizeof(v))
|
||||
|
||||
|
||||
/**
|
||||
* de-serialize an argument passed by pointer
|
||||
*
|
||||
* @param ipp_args the serialized argument array
|
||||
* @param n 0 base argument number
|
||||
* @param p ptr to arg to be set
|
||||
*
|
||||
* @note unlike serializing de-serializing pointer args data can be done in any
|
||||
* order
|
||||
*
|
||||
* @code
|
||||
* struct some_struct_t *parg2;
|
||||
* IPP_GET_ARG_PTR(args,2,parg2);
|
||||
* @endcode
|
||||
*/
|
||||
#define IPP_GET_ARG_PTR(ipp_args, n, p) (p = (void *)((char *)ipp_args + \
|
||||
ipp_args[n]))
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* debug macro to pint out all serialized args
|
||||
*
|
||||
* Implementation shall define IPP_PRINT_FUNC function to use
|
||||
*/
|
||||
#define IPP_PRINT_ARGS(ipp_args, n) \
|
||||
do {\
|
||||
int i;\
|
||||
for (i = 0; i < n; i++)\
|
||||
IPP_PRINT("arg#%d/%d is %8d 0x%08x\n", i, n,\
|
||||
ipp_args[i], ipp_args[i]);\
|
||||
IPP_PRINT("used data size %d\n", ipp_offset);\
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
* processing code type of proccesing
|
||||
*
|
||||
* used in @a ipp_work_t::process_no
|
||||
*/
|
||||
enum stmvl53l1_ipp_proccesing_e {
|
||||
stmvl53l1_ipp_ping = 0,
|
||||
/*!< stmvl53l1_ipp_ping
|
||||
* @li can be sent by driver to check client is alive
|
||||
* @li daemon sent it to identify and register himself to the driver
|
||||
*/
|
||||
stmvl53l1_ipp_cal_hist = 1,
|
||||
/*!< stmvl53l1_ipp_cal_hist process cal hist*/
|
||||
|
||||
stmvl53l1_ipp_xtalk_calibration = 2,
|
||||
/*!< stmvl53l1_ipp_xtalk_calibration process crosstalk calibration data
|
||||
*/
|
||||
|
||||
stmvl53l1_ipp_hist_ambient_dmax = 3,
|
||||
/*!< stmvl53l1_ipp_hist_ambient_dmax process ambient dmac calculation
|
||||
* from histogram
|
||||
*/
|
||||
|
||||
stmvl53l1_ipp_generate_dual_reflectance_xtalk_samples = 4,
|
||||
/*!< stmvl53l1_ipp_generate_dual_reflectance_xtalk_samples process
|
||||
* Xtalk data from dual reflectance histogram data
|
||||
*/
|
||||
|
||||
/** keep last*/
|
||||
stmvl53l1_ipp_max /*!< stmvl53l1_ipp_max */
|
||||
};
|
||||
|
||||
/**
|
||||
* status use on @a ipp_work_t::status
|
||||
*/
|
||||
enum stmvl53l1_ipp_status_e {
|
||||
stmvl53l1_ipp_status_ok = 0, /*!< ok work done */
|
||||
stmvl53l1_ipp_status_inv_id, /*!< dev id not supported or invalid */
|
||||
stmvl53l1_ipp_status_inv_proc,
|
||||
/*!< process_no asked not supported or not implemented */
|
||||
stmvl53l1_ipp_status_inv_payload,
|
||||
/*!< data payload for asked processing incorrect*/
|
||||
|
||||
stmvl53l1_ipp_status_proc_code = 0x100,
|
||||
/*!< the lowest 8 bit is the error code form the processing */
|
||||
};
|
||||
|
||||
/**
|
||||
* Ipp work (job) struct
|
||||
*
|
||||
* containing header with sequenc control information plus serialized data
|
||||
*/
|
||||
struct ipp_work_t {
|
||||
int8_t dev_id; /*!< [in]/[out] device id */
|
||||
/*!< Identify the work do be run see @a stmvl53l1_ipp_proccesing_e */
|
||||
uint8_t process_no;
|
||||
/*!< [out] status from daemon */
|
||||
int16_t status;
|
||||
/*!< [in/out] unique xfer id */
|
||||
uint32_t xfer_id;
|
||||
/*!< [in/out] effective data length including header*/
|
||||
uint32_t payload;
|
||||
|
||||
/** max IPP data payload (not including header)
|
||||
*
|
||||
* we substract size of of item above
|
||||
* must be lesss than one netlink packet
|
||||
*/
|
||||
#define MAX_IPP_DATA ((4096-4*3)/8)
|
||||
ipp_arg_t data[MAX_IPP_DATA]; /*!< [in][out] */
|
||||
};
|
||||
|
||||
/**
|
||||
* size of header only message ( no payload)
|
||||
* require \#include <stddef.h> in user land
|
||||
*/
|
||||
#define IPP_WORK_HDR_SIZE (offsetof(struct ipp_work_t, data[0]))
|
||||
/**
|
||||
* max payload per ipp transfer
|
||||
*/
|
||||
#define IPP_WORK_MAX_PAYLOAD sizeof(struct ipp_work_t)
|
||||
|
||||
/** copy ipp header from src to dest
|
||||
*
|
||||
* used to prepare return work using incoming work header
|
||||
* @param dest dest work ptr
|
||||
* @param src src work ptr
|
||||
*/
|
||||
#define IPP_CPY_HEADER(dest, src) memcpy(dest, src, IPP_WORK_HDR_SIZE)
|
||||
|
||||
/**
|
||||
* dump in human readble way ipp struct
|
||||
*
|
||||
* @note require IPP_PRINT macro
|
||||
*
|
||||
* @param pw ipp_work struct to dump
|
||||
* @param max_data max amount of data to be dump
|
||||
* @param max_dev max number of dev (for check)
|
||||
*/
|
||||
static inline void ipp_dump_work(struct ipp_work_t *pw, uint32_t max_data,
|
||||
int max_dev)
|
||||
{
|
||||
uint32_t data_cnt;
|
||||
uint32_t i;
|
||||
uint8_t *pbdata;
|
||||
|
||||
(void)max_dev; /* avoid warning when not used */
|
||||
(void)pbdata; /*avoid warning in case no print no use*/
|
||||
|
||||
IPP_PRINT("dev #%d (%s)\n", pw->dev_id, pw->dev_id < max_dev ?
|
||||
"ok" : "bad");
|
||||
IPP_PRINT("process #%d (%s)\n", pw->process_no,
|
||||
pw->process_no < stmvl53l1_ipp_max ? "ok" : "bad");
|
||||
IPP_PRINT("status %d\n", pw->status);
|
||||
IPP_PRINT("Xfer id 0x%08X payload %d bytes (%s)\n", pw->xfer_id,
|
||||
pw->payload,
|
||||
pw->payload > IPP_WORK_MAX_PAYLOAD ? "invalid" : "ok");
|
||||
data_cnt = pw->payload > IPP_WORK_MAX_PAYLOAD ?
|
||||
IPP_WORK_MAX_PAYLOAD : pw->payload;
|
||||
data_cnt = data_cnt > max_data ? max_data : data_cnt;
|
||||
for (i = 0, pbdata = (uint8_t *)pw->data; i < data_cnt; i++) {
|
||||
if (i%16 == 0)
|
||||
IPP_PRINT("\n%4X\t", i);
|
||||
IPP_PRINT("%02X ", pbdata[i]);
|
||||
}
|
||||
IPP_PRINT("\n");
|
||||
}
|
||||
|
||||
/** @} */ /* ingroup helper */
|
||||
|
||||
/** @} */ /* ingroup ipp_dev */
|
||||
#endif /* _STMVL53L1_IPP_H_ */
|
||||
363
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_ipp_nl.c
Normal file
363
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_ipp_nl.c
Normal file
|
|
@ -0,0 +1,363 @@
|
|||
|
||||
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file stmvl53l1_ipp_nl.c vl53l1 ipp proxy over netlink kernel side
|
||||
*/
|
||||
#include <linux/module.h>
|
||||
#include <net/sock.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#include "stmvl53l1.h"
|
||||
|
||||
#include "vl53l1_platform_ipp.h"
|
||||
#include "stmvl53l1_ipp.h"
|
||||
|
||||
#define IPP_DEBUG 1
|
||||
#ifndef IPP_DEBUG
|
||||
# define _ipp_dump_work(...) (void)0
|
||||
#else
|
||||
# define _ipp_dump_work(...) ipp_dump_work(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define IPP_STATE_PENDING 1
|
||||
#define IPP_STATE_COMPLETED 2
|
||||
#define IPP_STATE_CANCELED 4
|
||||
|
||||
#define IPP_TIMEOUT_MS 100
|
||||
|
||||
/** the single netlink strut use by all instance
|
||||
* @note is NULL until set
|
||||
*/
|
||||
static struct sock *nl_sk;
|
||||
|
||||
static DEFINE_MUTEX(ipp_mutex);
|
||||
|
||||
/**
|
||||
* current registered daemon pid
|
||||
* @note default value 0 or later 1 is kind of invalid and will require
|
||||
* user space to connect before we can send any packet
|
||||
*/
|
||||
static int daemon_pid;
|
||||
|
||||
/**
|
||||
* next xfer_id (shared other all dev)
|
||||
* no direct us used @@ref get_next_xfer_id (will get lock)
|
||||
* @note default to 0 what is "reserved"
|
||||
*/
|
||||
static int next_xfer_id;
|
||||
|
||||
|
||||
#define ipp_err(fmt, ...) pr_err("STMVL53L1 IPP Err in %s %d :" fmt "\n", \
|
||||
__func__, __LINE__, ##__VA_ARGS__)
|
||||
|
||||
#define ipp_warn(fmt, ...) pr_warn("STMVL53L1 IPP wng in %s %d : "fmt"\n",\
|
||||
__func__, __LINE__, ##__VA_ARGS__)
|
||||
|
||||
#if 0
|
||||
# define ipp_dbg(fmt, ...) pr_info("IPP %s %d " fmt "\n",\
|
||||
__func__, __LINE__, ##__VA_ARGS__)
|
||||
#else
|
||||
# define ipp_dbg(...) (void)0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* get and managed increment of next xfer_id
|
||||
* @note will get ipp_mutex
|
||||
* @return the xfer_id to be used
|
||||
*/
|
||||
static int get_next_xfer_id(void)
|
||||
{
|
||||
mutex_lock(&ipp_mutex);
|
||||
next_xfer_id++;
|
||||
/*0 is reserved skip it*/
|
||||
if (next_xfer_id == 0)
|
||||
next_xfer_id = 1;
|
||||
mutex_unlock(&ipp_mutex);
|
||||
|
||||
return next_xfer_id;
|
||||
}
|
||||
|
||||
static int send_client_msg(void *msg_data, int msg_size)
|
||||
{
|
||||
int rc;
|
||||
struct sk_buff *skb_out;
|
||||
struct nlmsghdr *nlh;
|
||||
void *nl_data;
|
||||
|
||||
ipp_dbg("to send %d byte", msg_size);
|
||||
skb_out = nlmsg_new(msg_size, 0);
|
||||
if (!skb_out) {
|
||||
ipp_err("nlmsg_new fail\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
nlh = nlmsg_put(skb_out, 0, 0, NLMSG_DONE, msg_size, 0);
|
||||
NETLINK_CB(skb_out).dst_group = 0; /* not in mcast group */
|
||||
|
||||
nl_data = nlmsg_data(nlh); /*get data ptr from header*/
|
||||
memcpy(nl_data, msg_data, msg_size);
|
||||
|
||||
/* FIXME do we real need to lock to send a data other nl_sk ? */
|
||||
mutex_lock(&ipp_mutex);
|
||||
rc = nlmsg_unicast(nl_sk, skb_out, daemon_pid);
|
||||
if (rc < 0)
|
||||
ipp_err("fail to send data size %d to pid %d\n",
|
||||
msg_size, daemon_pid);
|
||||
/* stat can be done here in else case */
|
||||
mutex_unlock(&ipp_mutex);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* ipp lock is held ping already handled
|
||||
*/
|
||||
int ipp_in_process(struct ipp_work_t *pwork)
|
||||
{
|
||||
struct stmvl53l1_data *data;
|
||||
|
||||
ipp_dbg("enter");
|
||||
_ipp_dump_work(pwork, IPP_WORK_MAX_PAYLOAD, STMVL53L1_CFG_MAX_DEV);
|
||||
|
||||
/* work id check already done */
|
||||
data = stmvl53l1_dev_table[pwork->dev_id];
|
||||
ipp_dbg("to lock ");
|
||||
/* Release now useless ipp_mutex for below work since we may deadlock
|
||||
* with irq path.
|
||||
*/
|
||||
mutex_unlock(&ipp_mutex);
|
||||
mutex_lock(&data->work_mutex);
|
||||
if (data->ipp.buzy == IPP_STATE_PENDING) {
|
||||
/* if it was already handled ignore it */
|
||||
if (data->ipp.waited_xfer_id == pwork->xfer_id) {
|
||||
/* ok that is what we are expecting back */
|
||||
memcpy(&data->ipp.work_out, pwork, pwork->payload);
|
||||
data->ipp.buzy |= IPP_STATE_COMPLETED;
|
||||
ipp_dbg("to wake ipp waiter as buzy state %d",
|
||||
data->ipp.buzy);
|
||||
wake_up(&data->ipp.waitq);
|
||||
goto done_lock;
|
||||
}
|
||||
}
|
||||
/* either not waiting any more or not the expected id drop it */
|
||||
ipp_err("dev #%d ippp buzy %d xfer id %d rcv id %d droping it",
|
||||
data->id, data->ipp.buzy, data->ipp.waited_xfer_id,
|
||||
pwork->xfer_id);
|
||||
done_lock:
|
||||
mutex_unlock(&data->work_mutex);
|
||||
mutex_lock(&ipp_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int stmvl53l1_ipp_stop(struct stmvl53l1_data *data)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = data->ipp.buzy;
|
||||
ipp_dbg("#%d to stop buzy %d", data->id, data->ipp.buzy);
|
||||
if (data->ipp.buzy) {
|
||||
/* set invalid wait id to discard canceled job when back */
|
||||
data->ipp.waited_xfer_id = 0;
|
||||
data->ipp.buzy |= IPP_STATE_CANCELED|IPP_STATE_COMPLETED;
|
||||
ipp_dbg("#%dto wake up worker", data->id);
|
||||
/* wake up worker or abort the thread */
|
||||
wake_up(&data->ipp.waitq);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* ipp and dev lock are held
|
||||
* release and re-grabbed here
|
||||
*/
|
||||
int stmvl53l1_ipp_do(struct stmvl53l1_data *data,
|
||||
struct ipp_work_t *pin, struct ipp_work_t *pout)
|
||||
{
|
||||
int xfer_id;
|
||||
int rc;
|
||||
bool has_timeout;
|
||||
|
||||
ipp_dbg("enter");
|
||||
|
||||
xfer_id = get_next_xfer_id();
|
||||
/* set xfer and device dependent part of the work */
|
||||
pin->dev_id = data->id;
|
||||
pin->xfer_id = xfer_id;
|
||||
data->ipp.waited_xfer_id = xfer_id;
|
||||
/* try to do it */
|
||||
rc = send_client_msg(pin, pin->payload);
|
||||
/* shall we retry if fail to send for some time or number of try ? */
|
||||
if (rc < 0) {
|
||||
rc = -1;
|
||||
ipp_err("fail to send msg %d", rc);
|
||||
} else if (data->ipp.buzy == 0) {
|
||||
/* send ok put the ipp on buzy state while locked */
|
||||
data->ipp.buzy = IPP_STATE_PENDING;
|
||||
/* unlock now that state is marked buzy */
|
||||
mutex_unlock(&data->work_mutex);
|
||||
|
||||
/* put task to wait for completion */
|
||||
ipp_dbg("to wait");
|
||||
has_timeout = !wait_event_timeout(data->ipp.waitq,
|
||||
(data->ipp.buzy != IPP_STATE_PENDING),
|
||||
msecs_to_jiffies(IPP_TIMEOUT_MS));
|
||||
|
||||
/* relock the main lock */
|
||||
mutex_lock(&data->work_mutex);
|
||||
|
||||
rc = (data->ipp.buzy & IPP_STATE_CANCELED) || has_timeout ?
|
||||
-1 : 0;
|
||||
if (rc) {
|
||||
ipp_dbg("waking up with from canceled/timeout ipp");
|
||||
} else {
|
||||
/* return status from the ipp itself */
|
||||
ipp_dbg("ip back with status %d", data->ipp.status);
|
||||
rc = data->ipp.status;
|
||||
}
|
||||
data->ipp.buzy = 0;/* buzy clear but locked so safe */
|
||||
} else {
|
||||
ipp_dbg("buzy still not zero %d", data->ipp.buzy);
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
|
||||
/* done_lock: */
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
static void stmvl53l1_nl_recv_msg(struct sk_buff *skb_in)
|
||||
{
|
||||
int pid_chg = 0;
|
||||
int pid;
|
||||
struct nlmsghdr *nlh;
|
||||
struct ipp_work_t *pwork;
|
||||
|
||||
ipp_dbg("Entering");
|
||||
|
||||
nlh = (struct nlmsghdr *)skb_in->data;
|
||||
pid = nlh->nlmsg_pid; /*pid of sending process */
|
||||
|
||||
pwork = nlmsg_data(nlh);
|
||||
if (pwork->payload < IPP_WORK_HDR_SIZE ||
|
||||
pwork->payload > IPP_WORK_MAX_PAYLOAD){
|
||||
/* invalid header size */
|
||||
ipp_err("invalid msg header size %d", pwork->payload);
|
||||
_ipp_dump_work(pwork, IPP_WORK_MAX_PAYLOAD,
|
||||
STMVL53L1_CFG_MAX_DEV);
|
||||
return;
|
||||
}
|
||||
|
||||
mutex_lock(&ipp_mutex);
|
||||
|
||||
if ((pwork->dev_id >= STMVL53L1_CFG_MAX_DEV) || (pwork->dev_id < 0)) {
|
||||
ipp_err("invalid dev id on msg %d", pwork->dev_id);
|
||||
_ipp_dump_work(pwork, IPP_WORK_MAX_PAYLOAD,
|
||||
STMVL53L1_CFG_MAX_DEV);
|
||||
goto done_locked;
|
||||
}
|
||||
|
||||
if (pwork->process_no == stmvl53l1_ipp_ping) {
|
||||
/* in that case the payload must be exact status size only
|
||||
* if not it is a badly format message or bad message
|
||||
*/
|
||||
if (pwork->payload != IPP_WORK_HDR_SIZE) {
|
||||
ipp_err("invalid ping msg size %d!=%zu ",
|
||||
pwork->payload, IPP_WORK_HDR_SIZE);
|
||||
_ipp_dump_work(pwork, IPP_WORK_MAX_PAYLOAD,
|
||||
STMVL53L1_CFG_MAX_DEV);
|
||||
goto done_locked;
|
||||
}
|
||||
/* if pid was not set or change resent all ongoing ipp */
|
||||
if (pid != daemon_pid)
|
||||
ipp_warn("pid chg %d => %d\n", daemon_pid, pid);
|
||||
else
|
||||
ipp_dbg("got ping fm pid %d\n", daemon_pid);
|
||||
daemon_pid = pid;
|
||||
pid_chg = 1;
|
||||
} else {
|
||||
ipp_in_process(pwork);
|
||||
}
|
||||
done_locked:
|
||||
mutex_unlock(&ipp_mutex);
|
||||
}
|
||||
|
||||
int stmvl53l1_ipp_setup(struct stmvl53l1_data *data)
|
||||
{
|
||||
int rc;
|
||||
|
||||
mutex_lock(&ipp_mutex);
|
||||
|
||||
data->ipp.buzy = 0;
|
||||
init_waitqueue_head(&data->ipp.waitq);
|
||||
ipp_dbg("now %d dev daemon pid is %d", STMVL53L1_CFG_MAX_DEV,
|
||||
daemon_pid);
|
||||
rc = 0;
|
||||
|
||||
mutex_unlock(&ipp_mutex);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void stmvl53l1_ipp_cleanup(struct stmvl53l1_data *data)
|
||||
{
|
||||
/* nothink to do */
|
||||
}
|
||||
|
||||
#if !defined(OLD_NETLINK_API)
|
||||
struct netlink_kernel_cfg cfg = {
|
||||
.input = stmvl53l1_nl_recv_msg
|
||||
};
|
||||
#endif
|
||||
|
||||
static int netlink_protocol_type = STMVL531_CFG_NETLINK_USER;
|
||||
|
||||
module_param(netlink_protocol_type, int, 0444);
|
||||
MODULE_PARM_DESC(netlink_protocol_type,
|
||||
"select netlink protocol type for ipp communications");
|
||||
|
||||
int stmvl53l1_ipp_init(void)
|
||||
{
|
||||
mutex_init(&ipp_mutex);
|
||||
daemon_pid = 1; /* pid 1 is safe should not be use for user space */
|
||||
|
||||
#if defined(OLD_NETLINK_API)
|
||||
nl_sk = netlink_kernel_create(&init_net,
|
||||
netlink_protocol_type,
|
||||
0,
|
||||
stmvl53l1_nl_recv_msg,
|
||||
NULL,
|
||||
THIS_MODULE);
|
||||
#else
|
||||
nl_sk = netlink_kernel_create(&init_net,
|
||||
netlink_protocol_type,
|
||||
&cfg);
|
||||
#endif
|
||||
|
||||
return nl_sk ? 0 : -1;
|
||||
}
|
||||
|
||||
|
||||
void stmvl53l1_ipp_exit(void)
|
||||
{
|
||||
if (nl_sk != NULL) {
|
||||
vl53l1_dbgmsg("releasing netlink socket");
|
||||
netlink_kernel_release(nl_sk);
|
||||
nl_sk = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
59
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_log.c
Normal file
59
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_log.c
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
|
||||
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file /stmvl53l1_module.c vl53l1_module ST VL53L1 linux kernel module
|
||||
*
|
||||
* This is implementation of low level driver trace support
|
||||
*/
|
||||
#include <linux/module.h>
|
||||
#include <linux/printk.h>
|
||||
|
||||
#include "stmvl53l1.h"
|
||||
|
||||
#ifdef VL53L1_LOG_ENABLE
|
||||
|
||||
static bool trace_function;
|
||||
static int trace_module;
|
||||
static int trace_level;
|
||||
|
||||
module_param(trace_function, bool, 0644);
|
||||
MODULE_PARM_DESC(trace_function,
|
||||
"allow tracing of low level function entry and exit");
|
||||
|
||||
module_param(trace_module, int, 0644);
|
||||
MODULE_PARM_DESC(trace_module,
|
||||
"control tracing of low level per module");
|
||||
|
||||
module_param(trace_level, int, 0644);
|
||||
MODULE_PARM_DESC(trace_level,
|
||||
"control tracing of low level per level");
|
||||
|
||||
void log_trace_print(uint32_t module, uint32_t level, uint32_t function,
|
||||
const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
if (function && !trace_function)
|
||||
return;
|
||||
|
||||
if (!(module & trace_module))
|
||||
return;
|
||||
|
||||
if (level > trace_level)
|
||||
return;
|
||||
|
||||
va_start(args, format);
|
||||
vprintk(format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
#endif
|
||||
900
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_module-i2c.c
Normal file
900
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_module-i2c.c
Normal file
|
|
@ -0,0 +1,900 @@
|
|||
|
||||
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file stmvl53l1_module-i2c.c
|
||||
*
|
||||
* implement STM VL53L1 module interface i2c wrapper + control
|
||||
* using linux native i2c + gpio + reg api
|
||||
*/
|
||||
#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>
|
||||
#include <linux/version.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>
|
||||
#include <linux/gpio.h>
|
||||
|
||||
#include "stmvl53l1-i2c.h"
|
||||
#include "stmvl53l1.h"
|
||||
|
||||
#define STMVL53L1_SLAVE_ADDR (0x52>>1)
|
||||
|
||||
/** @ingroup drv_port
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* control specific debug message echo
|
||||
*
|
||||
* Set to 0/1 do not remove
|
||||
*
|
||||
* most dbg warn err messages goes true main driver macro
|
||||
* this one permit some specific debug without activating all main dbg
|
||||
*/
|
||||
#define MODI2C_DEBUG 0
|
||||
|
||||
/*
|
||||
* mutex to handle device i2c address changes. It allow to avoid multiple
|
||||
* device active with same i2c addresses at the same time. Note that we don't
|
||||
* support case where boot_reg has the same value as a final i2c address of
|
||||
* another device.
|
||||
*/
|
||||
static DEFINE_MUTEX(dev_addr_change_mutex);
|
||||
|
||||
/**
|
||||
* i2c client assigned to our driver
|
||||
*
|
||||
* this is use for stm test purpose as we fake client create and regstration
|
||||
* we stores the i2c client for release in clean-up overwise we wan't reload
|
||||
* the module multiple time
|
||||
*
|
||||
* in a normal dev tree prod system this is not required
|
||||
*/
|
||||
static struct i2c_client *stm_test_i2c_client;
|
||||
|
||||
/*
|
||||
* pi3:
|
||||
* insmod stmvl53l1.ko force_device=1 adapter_nb=1 xsdn_gpio_nb=19
|
||||
* intr_gpio_nb=16 pwren_gpio_nb=12
|
||||
*
|
||||
* panda
|
||||
* insmod stmvl53l1.ko force_device=1 adapter_nb=4 xsdn_gpio_nb=56
|
||||
* intr_gpio_nb=59 pwren_gpio_nb=55
|
||||
*/
|
||||
|
||||
static int force_device;
|
||||
static int adapter_nb = -1;
|
||||
static int xsdn_gpio_nb = -1;
|
||||
static int pwren_gpio_nb = -1;
|
||||
static int intr_gpio_nb = -1;
|
||||
static int i2c_addr_nb = STMVL53L1_SLAVE_ADDR;
|
||||
|
||||
module_param(force_device, int, 0000);
|
||||
MODULE_PARM_DESC(force_device, "force device insertion at module init");
|
||||
|
||||
module_param(adapter_nb, int, 0000);
|
||||
MODULE_PARM_DESC(adapter_nb, "i2c adapter to use");
|
||||
|
||||
module_param(xsdn_gpio_nb, int, 0000);
|
||||
MODULE_PARM_DESC(xsdn_gpio_nb, "select gpio numer to use for vl53l1 reset");
|
||||
|
||||
module_param(pwren_gpio_nb, int, 0000);
|
||||
MODULE_PARM_DESC(pwren_gpio_nb, "select gpio numer to use for vl53l1 power");
|
||||
|
||||
module_param(intr_gpio_nb, int, 0000);
|
||||
MODULE_PARM_DESC(intr_gpio_nb, "select gpio numer to use for vl53l1 interrupt");
|
||||
|
||||
/**
|
||||
* warn message
|
||||
*
|
||||
* @warning use only in scope where i2c_data ptr is present
|
||||
**/
|
||||
#define modi2c_warn(fmt, ...)\
|
||||
dev_WARN(&i2c_data->client->dev, fmt, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* err message
|
||||
*
|
||||
* @warning use only in scope where i2c_data ptr is present
|
||||
*/
|
||||
#define modi2c_err(fmt, ...)\
|
||||
dev_err(&i2c_data->client->dev, fmt, ##__VA_ARGS__)
|
||||
|
||||
|
||||
|
||||
#if MODI2C_DEBUG
|
||||
# define modi2c_dbg(fmt, ...)\
|
||||
pr_devel("%s "fmt"\n", __func__, ##__VA_ARGS__)
|
||||
#else
|
||||
# define modi2c_dbg(...) (void)0
|
||||
#endif
|
||||
|
||||
struct vl53l1_pinctrl_info {
|
||||
struct pinctrl *pinctrl;
|
||||
struct pinctrl_state *gpio_state_active;
|
||||
struct pinctrl_state *gpio_state_suspend;
|
||||
} g_pinctrl_info;
|
||||
|
||||
static int insert_device(void)
|
||||
{
|
||||
int ret = 0;
|
||||
struct i2c_adapter *adapter;
|
||||
struct i2c_board_info info = {
|
||||
.type = "stmvl53l1",
|
||||
.addr = STMVL53L1_SLAVE_ADDR,
|
||||
};
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
strcpy(info.type, "stmvl53l1");
|
||||
info.addr = STMVL53L1_SLAVE_ADDR;
|
||||
adapter = i2c_get_adapter(adapter_nb);
|
||||
if (!adapter) {
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0)
|
||||
stm_test_i2c_client = i2c_new_device(adapter, &info);
|
||||
#else
|
||||
stm_test_i2c_client = i2c_new_client_device(adapter, &info);
|
||||
#endif
|
||||
if (!stm_test_i2c_client)
|
||||
ret = -EINVAL;
|
||||
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int get_xsdn(struct device *dev, struct i2c_data *i2c_data)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
i2c_data->io_flag.xsdn_owned = 0;
|
||||
if (i2c_data->xsdn_gpio == -1) {
|
||||
vl53l1_errmsg("reset gpio is required");
|
||||
rc = -ENODEV;
|
||||
goto no_gpio;
|
||||
}
|
||||
|
||||
vl53l1_dbgmsg("request xsdn_gpio %d", i2c_data->xsdn_gpio);
|
||||
//gpio_free(i2c_data->xsdn_gpio);
|
||||
rc = gpio_request(i2c_data->xsdn_gpio, "vl53l1_xsdn");
|
||||
if (rc) {
|
||||
vl53l1_errmsg("fail to acquire xsdn %d", rc);
|
||||
goto request_failed;
|
||||
}
|
||||
|
||||
rc = gpio_direction_output(i2c_data->xsdn_gpio, 0);
|
||||
if (rc) {
|
||||
vl53l1_errmsg("fail to configure xsdn as output %d", rc);
|
||||
goto direction_failed;
|
||||
}
|
||||
i2c_data->io_flag.xsdn_owned = 1;
|
||||
|
||||
return rc;
|
||||
|
||||
direction_failed:
|
||||
gpio_free(i2c_data->xsdn_gpio);
|
||||
|
||||
request_failed:
|
||||
no_gpio:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void put_xsdn(struct i2c_data *i2c_data)
|
||||
{
|
||||
if (i2c_data->io_flag.xsdn_owned) {
|
||||
vl53l1_dbgmsg("release xsdn_gpio %d", i2c_data->xsdn_gpio);
|
||||
gpio_free(i2c_data->xsdn_gpio);
|
||||
i2c_data->io_flag.xsdn_owned = 0;
|
||||
i2c_data->xsdn_gpio = -1;
|
||||
}
|
||||
i2c_data->xsdn_gpio = -1;
|
||||
}
|
||||
|
||||
static int get_pwren(struct device *dev, struct i2c_data *i2c_data)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
i2c_data->io_flag.pwr_owned = 0;
|
||||
if (i2c_data->pwren_gpio == -1) {
|
||||
vl53l1_wanrmsg("pwren gpio disable");
|
||||
goto no_gpio;
|
||||
}
|
||||
|
||||
vl53l1_dbgmsg("request pwren_gpio %d", i2c_data->pwren_gpio);
|
||||
rc = gpio_request(i2c_data->pwren_gpio, "vl53l1_pwren");
|
||||
if (rc) {
|
||||
vl53l1_errmsg("fail to acquire pwren %d", rc);
|
||||
goto request_failed;
|
||||
}
|
||||
|
||||
rc = gpio_direction_output(i2c_data->pwren_gpio, 0);
|
||||
if (rc) {
|
||||
vl53l1_errmsg("fail to configure pwren as output %d", rc);
|
||||
goto direction_failed;
|
||||
}
|
||||
i2c_data->io_flag.pwr_owned = 1;
|
||||
|
||||
return rc;
|
||||
|
||||
direction_failed:
|
||||
gpio_free(i2c_data->xsdn_gpio);
|
||||
|
||||
request_failed:
|
||||
no_gpio:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void put_pwren(struct i2c_data *i2c_data)
|
||||
{
|
||||
if (i2c_data->io_flag.pwr_owned) {
|
||||
vl53l1_dbgmsg("release pwren_gpio %d", i2c_data->pwren_gpio);
|
||||
gpio_free(i2c_data->pwren_gpio);
|
||||
i2c_data->io_flag.pwr_owned = 0;
|
||||
i2c_data->pwren_gpio = -1;
|
||||
}
|
||||
i2c_data->pwren_gpio = -1;
|
||||
}
|
||||
|
||||
static int get_intr(struct device *dev, struct i2c_data *i2c_data)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
i2c_data->io_flag.intr_owned = 0;
|
||||
if (i2c_data->intr_gpio == -1) {
|
||||
vl53l1_wanrmsg("no interrupt gpio");
|
||||
goto no_gpio;
|
||||
}
|
||||
|
||||
vl53l1_dbgmsg("request intr_gpio %d", i2c_data->intr_gpio);
|
||||
rc = gpio_request(i2c_data->intr_gpio, "vl53l1_intr");
|
||||
if (rc) {
|
||||
vl53l1_errmsg("fail to acquire intr %d", rc);
|
||||
goto request_failed;
|
||||
}
|
||||
|
||||
rc = gpio_direction_input(i2c_data->intr_gpio);
|
||||
if (rc) {
|
||||
vl53l1_errmsg("fail to configure intr as input %d", rc);
|
||||
goto direction_failed;
|
||||
}
|
||||
|
||||
i2c_data->irq = gpio_to_irq(i2c_data->intr_gpio);
|
||||
if (i2c_data->irq < 0) {
|
||||
vl53l1_errmsg("fail to map GPIO: %d to interrupt:%d\n",
|
||||
i2c_data->intr_gpio, i2c_data->irq);
|
||||
goto irq_failed;
|
||||
}
|
||||
i2c_data->io_flag.intr_owned = 1;
|
||||
|
||||
return rc;
|
||||
|
||||
irq_failed:
|
||||
direction_failed:
|
||||
gpio_free(i2c_data->intr_gpio);
|
||||
|
||||
request_failed:
|
||||
no_gpio:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void put_intr(struct i2c_data *i2c_data)
|
||||
{
|
||||
if (i2c_data->io_flag.intr_owned) {
|
||||
if (i2c_data->io_flag.intr_started) {
|
||||
free_irq(i2c_data->irq, i2c_data);
|
||||
i2c_data->io_flag.intr_started = 0;
|
||||
}
|
||||
vl53l1_dbgmsg("release intr_gpio %d", i2c_data->intr_gpio);
|
||||
gpio_free(i2c_data->intr_gpio);
|
||||
i2c_data->io_flag.intr_owned = 0;
|
||||
}
|
||||
i2c_data->intr_gpio = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* parse dev tree for all platform specific input
|
||||
*/
|
||||
static int stmvl53l1_parse_tree(struct device *dev, struct i2c_data *i2c_data)
|
||||
{
|
||||
struct i2c_client *client = (struct i2c_client *) i2c_data->client;
|
||||
int rc = 0;
|
||||
//u32 reg;
|
||||
|
||||
/* if force device is in use then gpio nb comes from module param else
|
||||
* we use devicetree.
|
||||
*/
|
||||
i2c_data->vdd = NULL;
|
||||
i2c_data->pwren_gpio = -1;
|
||||
i2c_data->xsdn_gpio = -1;
|
||||
i2c_data->intr_gpio = -1;
|
||||
i2c_data->boot_reg = STMVL53L1_SLAVE_ADDR;
|
||||
if (force_device) {
|
||||
i2c_data->xsdn_gpio = xsdn_gpio_nb;
|
||||
i2c_data->pwren_gpio = pwren_gpio_nb;
|
||||
i2c_data->intr_gpio = intr_gpio_nb;
|
||||
client->addr = i2c_addr_nb;
|
||||
} else if (dev->of_node) {
|
||||
/* power : either vdd or pwren_gpio. try reulator first */
|
||||
i2c_data->vdd = regulator_get_optional(dev, "vdd-vl53l1");
|
||||
if (IS_ERR(i2c_data->vdd) || i2c_data->vdd == NULL) {
|
||||
i2c_data->vdd = NULL;
|
||||
/* try gpio */
|
||||
i2c_data->pwren_gpio = of_get_named_gpio(dev->of_node, "pwren-gpio", 0);
|
||||
if (i2c_data->pwren_gpio < 0) {
|
||||
i2c_data->pwren_gpio = -1;
|
||||
vl53l1_errmsg(" get i2c_data->pwren_gpio failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
g_pinctrl_info.pinctrl = devm_pinctrl_get(dev);
|
||||
if (!IS_ERR_OR_NULL(g_pinctrl_info.pinctrl)) {
|
||||
g_pinctrl_info.gpio_state_active =
|
||||
pinctrl_lookup_state(g_pinctrl_info.pinctrl,
|
||||
"laser_default");
|
||||
|
||||
g_pinctrl_info.gpio_state_suspend =
|
||||
pinctrl_lookup_state(g_pinctrl_info.pinctrl,
|
||||
"laser_suspend");
|
||||
} else
|
||||
vl53l1_errmsg("Getting pinctrl handle failed\n");
|
||||
|
||||
rc = of_property_read_u32_array(dev->of_node, "xsdn-gpio",
|
||||
&i2c_data->xsdn_gpio, 1);
|
||||
if (rc) {
|
||||
vl53l1_wanrmsg("Unable to find xsdn-gpio %d %d",
|
||||
rc, i2c_data->xsdn_gpio);
|
||||
if (of_gpio_count(dev->of_node) >= 2)
|
||||
i2c_data->xsdn_gpio = of_get_gpio(dev->of_node,
|
||||
0);
|
||||
else
|
||||
i2c_data->xsdn_gpio = -1;
|
||||
}
|
||||
rc = of_property_read_u32_array(dev->of_node, "intr-gpio",
|
||||
&i2c_data->intr_gpio, 1);
|
||||
if (rc) {
|
||||
vl53l1_wanrmsg("Unable to find intr-gpio %d %d",
|
||||
rc, i2c_data->intr_gpio);
|
||||
if (of_gpio_count(dev->of_node) >= 2)
|
||||
i2c_data->intr_gpio = of_get_gpio(dev->of_node,
|
||||
1);
|
||||
else
|
||||
i2c_data->intr_gpio = -1;
|
||||
}
|
||||
rc = of_property_read_u32_array(dev->of_node, "boot-reg",
|
||||
&i2c_data->boot_reg, 1);
|
||||
if (rc) {
|
||||
vl53l1_wanrmsg("Unable to find boot-reg %d %d",
|
||||
rc, i2c_data->boot_reg);
|
||||
i2c_data->boot_reg = STMVL53L1_SLAVE_ADDR;
|
||||
}
|
||||
}
|
||||
|
||||
/* configure gpios */
|
||||
rc = get_xsdn(dev, i2c_data);
|
||||
if (rc)
|
||||
goto no_xsdn;
|
||||
rc = get_pwren(dev, i2c_data);
|
||||
if (rc)
|
||||
goto no_pwren;
|
||||
rc = get_intr(dev, i2c_data);
|
||||
if (rc)
|
||||
goto no_intr;
|
||||
|
||||
return rc;
|
||||
|
||||
no_intr:
|
||||
if (i2c_data->vdd) {
|
||||
regulator_put(i2c_data->vdd);
|
||||
i2c_data->vdd = NULL;
|
||||
}
|
||||
put_pwren(i2c_data);
|
||||
no_pwren:
|
||||
put_xsdn(i2c_data);
|
||||
no_xsdn:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void stmvl53l1_release_gpios(struct i2c_data *i2c_data)
|
||||
{
|
||||
put_xsdn(i2c_data);
|
||||
if (i2c_data->vdd) {
|
||||
regulator_put(i2c_data->vdd);
|
||||
i2c_data->vdd = NULL;
|
||||
}
|
||||
put_pwren(i2c_data);
|
||||
put_intr(i2c_data);
|
||||
}
|
||||
|
||||
static int stmvl53l1_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
int rc = 0;
|
||||
struct stmvl53l1_data *vl53l1_data = NULL;
|
||||
struct i2c_data *i2c_data = NULL;
|
||||
|
||||
vl53l1_errmsg("Enter %s : 0x%02x\n", client->name, client->addr);
|
||||
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) {
|
||||
rc = -EIO;
|
||||
return rc;
|
||||
}
|
||||
|
||||
vl53l1_data = kzalloc(sizeof(struct stmvl53l1_data), GFP_KERNEL);
|
||||
if (!vl53l1_data) {
|
||||
rc = -ENOMEM;
|
||||
return rc;
|
||||
}
|
||||
if (vl53l1_data) {
|
||||
vl53l1_data->client_object =
|
||||
kzalloc(sizeof(struct i2c_data), GFP_KERNEL);
|
||||
if (!vl53l1_data)
|
||||
goto done_freemem;
|
||||
i2c_data = (struct i2c_data *)vl53l1_data->client_object;
|
||||
}
|
||||
i2c_data->client = client;
|
||||
i2c_data->vl53l1_data = vl53l1_data;
|
||||
i2c_data->irq = -1 ; /* init to no irq */
|
||||
|
||||
/* parse and configure hardware */
|
||||
rc = stmvl53l1_parse_tree(&i2c_data->client->dev, i2c_data);
|
||||
if (rc)
|
||||
goto done_freemem;
|
||||
|
||||
/* setup device name */
|
||||
/* vl53l1_data->dev_name = dev_name(&client->dev); */
|
||||
|
||||
/* setup client data */
|
||||
i2c_set_clientdata(client, vl53l1_data);
|
||||
|
||||
/* end up by core driver setup */
|
||||
rc = stmvl53l1_setup(vl53l1_data);
|
||||
if (rc)
|
||||
goto release_gpios;
|
||||
|
||||
vl53l1_data->sysfs_base = i2c_data->client->addr;
|
||||
rc = stmvl53l1_sysfs_laser(vl53l1_data, true);
|
||||
if (rc)
|
||||
goto release_gpios;
|
||||
vl53l1_dbgmsg("End\n");
|
||||
kref_init(&i2c_data->ref);
|
||||
|
||||
return rc;
|
||||
|
||||
release_gpios:
|
||||
stmvl53l1_release_gpios(i2c_data);
|
||||
|
||||
done_freemem:
|
||||
/* kfree safe against NULL */
|
||||
kfree(vl53l1_data);
|
||||
kfree(i2c_data);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int stmvl53l1_remove(struct i2c_client *client)
|
||||
{
|
||||
struct stmvl53l1_data *data = i2c_get_clientdata(client);
|
||||
struct i2c_data *i2c_data = (struct i2c_data *)data->client_object;
|
||||
|
||||
vl53l1_dbgmsg("Enter\n");
|
||||
mutex_lock(&data->work_mutex);
|
||||
|
||||
stmvl53l1_sysfs_laser(data, false);
|
||||
|
||||
/* main driver cleanup */
|
||||
stmvl53l1_cleanup(data);
|
||||
|
||||
/* release gpios */
|
||||
stmvl53l1_release_gpios(i2c_data);
|
||||
|
||||
mutex_unlock(&data->work_mutex);
|
||||
|
||||
stmvl53l1_put(data->client_object);
|
||||
|
||||
vl53l1_dbgmsg("End\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int stmvl53l1_suspend(struct device *dev)
|
||||
{
|
||||
struct stmvl53l1_data *data = i2c_get_clientdata(to_i2c_client(dev));
|
||||
|
||||
vl53l1_dbgmsg("Enter\n");
|
||||
mutex_lock(&data->work_mutex);
|
||||
/* Stop ranging */
|
||||
stmvl53l1_pm_suspend_stop(data);
|
||||
|
||||
mutex_unlock(&data->work_mutex);
|
||||
|
||||
vl53l1_dbgmsg("End\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stmvl53l1_resume(struct device *dev)
|
||||
{
|
||||
#if 0
|
||||
struct stmvl53l1_data *data = i2c_get_clientdata(to_i2c_client(dev));
|
||||
|
||||
vl53l1_dbgmsg("Enter\n");
|
||||
|
||||
mutex_lock(&data->work_mutex);
|
||||
|
||||
/* do nothing user will restart measurements */
|
||||
|
||||
mutex_unlock(&data->work_mutex);
|
||||
|
||||
vl53l1_dbgmsg("End\n");
|
||||
#else
|
||||
vl53l1_dbgmsg("Enter\n");
|
||||
vl53l1_dbgmsg("End\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(stmvl53l1_pm_ops, stmvl53l1_suspend, stmvl53l1_resume);
|
||||
|
||||
static const struct i2c_device_id stmvl53l1_id[] = {
|
||||
{ STMVL53L1_DRV_NAME, 0 },
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, stmvl53l1_id);
|
||||
|
||||
static const struct of_device_id st_stmvl53l1_dt_match[] = {
|
||||
{ .compatible = "st,"STMVL53L1_DRV_NAME, },
|
||||
{ },
|
||||
};
|
||||
|
||||
static struct i2c_driver stmvl53l1_driver = {
|
||||
.driver = {
|
||||
.name = STMVL53L1_DRV_NAME,
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = st_stmvl53l1_dt_match,
|
||||
.pm = &stmvl53l1_pm_ops,
|
||||
},
|
||||
.probe = stmvl53l1_probe,
|
||||
.remove = stmvl53l1_remove,
|
||||
.id_table = stmvl53l1_id,
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* give power to device
|
||||
*
|
||||
* @param object the i2c layer object
|
||||
* @return
|
||||
*/
|
||||
int stmvl53l1_power_up_i2c(void *object)
|
||||
{
|
||||
int rc = 0;
|
||||
struct i2c_data *data = (struct i2c_data *) object;
|
||||
|
||||
vl53l1_dbgmsg("Enter\n");
|
||||
|
||||
/* turn on power */
|
||||
if (data->vdd) {
|
||||
rc = regulator_enable(data->vdd);
|
||||
if (rc) {
|
||||
vl53l1_errmsg("fail to turn on regulator");
|
||||
return rc;
|
||||
}
|
||||
} else if (data->pwren_gpio != -1) {
|
||||
gpio_set_value(data->pwren_gpio, 1);
|
||||
vl53l1_info("slow power on");
|
||||
} else
|
||||
vl53l1_wanrmsg("no power control");
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* remove power to device (reset it)
|
||||
*
|
||||
* @param i2c_object the i2c layer object
|
||||
* @return 0 on success
|
||||
*/
|
||||
int stmvl53l1_power_down_i2c(void *i2c_object)
|
||||
{
|
||||
struct i2c_data *data = (struct i2c_data *) i2c_object;
|
||||
int rc = 0;
|
||||
|
||||
vl53l1_dbgmsg("Enter\n");
|
||||
|
||||
/* turn off power */
|
||||
if (data->vdd) {
|
||||
rc = regulator_disable(data->vdd);
|
||||
if (rc)
|
||||
vl53l1_errmsg("reg disable failed. rc=%d\n",
|
||||
rc);
|
||||
} else if (data->pwren_gpio != -1) {
|
||||
gpio_set_value(data->pwren_gpio, 0);
|
||||
}
|
||||
vl53l1_dbgmsg("power off");
|
||||
|
||||
vl53l1_dbgmsg("End\n");
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int handle_i2c_address_device_change_lock(struct i2c_data *data)
|
||||
{
|
||||
struct i2c_client *client = (struct i2c_client *) data->client;
|
||||
uint8_t buffer[3];
|
||||
struct i2c_msg msg;
|
||||
int rc = 0;
|
||||
|
||||
vl53l1_dbgmsg("change device i2c address from 0x%02x to 0x%02x",
|
||||
data->boot_reg, client->addr);
|
||||
/* no i2c-access must occur before fw boot time */
|
||||
usleep_range(VL53L1_FIRMWARE_BOOT_TIME_US,
|
||||
VL53L1_FIRMWARE_BOOT_TIME_US + 1);
|
||||
|
||||
/* manually send message to update i2c address */
|
||||
buffer[0] = (VL53L1_I2C_SLAVE__DEVICE_ADDRESS >> 8) & 0xFF;
|
||||
buffer[1] = (VL53L1_I2C_SLAVE__DEVICE_ADDRESS >> 0) & 0xFF;
|
||||
buffer[2] = client->addr;
|
||||
msg.addr = data->boot_reg;
|
||||
msg.flags = client->flags;
|
||||
msg.buf = buffer;
|
||||
msg.len = 3;
|
||||
if (i2c_transfer(client->adapter, &msg, 1) != 1) {
|
||||
rc = -ENXIO;
|
||||
vl53l1_errmsg("Fail to change i2c address to 0x%02x",
|
||||
client->addr);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* reset release will also handle device address change. It will avoid state
|
||||
* where multiple stm53l1 are bring out of reset at the same time with the
|
||||
* same boot address.
|
||||
* Note that we don't manage case where boot_reg has the same value as a final
|
||||
* i2c address of another device. This case is not supported and will lead
|
||||
* to unpredictable behavior.
|
||||
*/
|
||||
static int release_reset(struct i2c_data *data)
|
||||
{
|
||||
struct i2c_client *client = (struct i2c_client *) data->client;
|
||||
int rc = 0;
|
||||
bool is_address_change = client->addr != data->boot_reg;
|
||||
|
||||
if (is_address_change)
|
||||
mutex_lock(&dev_addr_change_mutex);
|
||||
|
||||
gpio_set_value(data->xsdn_gpio, 1);
|
||||
if (is_address_change) {
|
||||
rc = handle_i2c_address_device_change_lock(data);
|
||||
if (rc)
|
||||
gpio_set_value(data->xsdn_gpio, 0);
|
||||
}
|
||||
|
||||
if (is_address_change)
|
||||
mutex_unlock(&dev_addr_change_mutex);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* release device reset
|
||||
*
|
||||
* @param i2c_object the i2c layer object
|
||||
* @return 0 on success
|
||||
*/
|
||||
int stmvl53l1_reset_release_i2c(void *i2c_object)
|
||||
{
|
||||
int rc;
|
||||
struct i2c_data *data = (struct i2c_data *) i2c_object;
|
||||
|
||||
vl53l1_dbgmsg("Enter\n");
|
||||
|
||||
rc = release_reset(data);
|
||||
pinctrl_select_state(g_pinctrl_info.pinctrl,
|
||||
g_pinctrl_info.gpio_state_active);
|
||||
if (rc)
|
||||
goto error;
|
||||
|
||||
/* and now wait for device end of boot */
|
||||
data->vl53l1_data->is_delay_allowed = true;
|
||||
rc = VL53L1_WaitDeviceBooted(&data->vl53l1_data->stdev);
|
||||
data->vl53l1_data->is_delay_allowed = false;
|
||||
if (rc) {
|
||||
gpio_set_value(data->xsdn_gpio, 0);
|
||||
vl53l1_errmsg("boot fail with error %d", rc);
|
||||
data->vl53l1_data->last_error = rc;
|
||||
rc = -EIO;
|
||||
}
|
||||
|
||||
error:
|
||||
vl53l1_dbgmsg("End\n");
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* put device under reset
|
||||
*
|
||||
* @param i2c_object the i2c layer object
|
||||
* @return 0 on success
|
||||
*/
|
||||
int stmvl53l1_reset_hold_i2c(void *i2c_object)
|
||||
{
|
||||
struct i2c_data *data = (struct i2c_data *) i2c_object;
|
||||
|
||||
vl53l1_dbgmsg("Enter\n");
|
||||
|
||||
gpio_set_value(data->xsdn_gpio, 0);
|
||||
|
||||
pinctrl_select_state(g_pinctrl_info.pinctrl,
|
||||
g_pinctrl_info.gpio_state_suspend);
|
||||
|
||||
vl53l1_dbgmsg("End\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int stmvl53l1_init_i2c(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
vl53l1_dbgmsg("Enter\n");
|
||||
|
||||
/* register as a i2c client device */
|
||||
ret = i2c_add_driver(&stmvl53l1_driver);
|
||||
if (ret)
|
||||
vl53l1_errmsg("%d erro ret:%d\n", __LINE__, ret);
|
||||
|
||||
if (!ret && force_device)
|
||||
ret = insert_device();
|
||||
|
||||
if (ret)
|
||||
i2c_del_driver(&stmvl53l1_driver);
|
||||
|
||||
vl53l1_dbgmsg("End with rc:%d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void stmvl53l1_clean_up_i2c(void)
|
||||
{
|
||||
if (stm_test_i2c_client) {
|
||||
vl53l1_dbgmsg("to unregister i2c client\n");
|
||||
i2c_unregister_device(stm_test_i2c_client);
|
||||
}
|
||||
}
|
||||
|
||||
static irqreturn_t stmvl53l1_irq_handler_i2c(int vec, void *info)
|
||||
{
|
||||
struct i2c_data *i2c_data = (struct i2c_data *)info;
|
||||
|
||||
if (i2c_data->irq == vec) {
|
||||
modi2c_dbg("irq");
|
||||
stmvl53l1_intr_handler(i2c_data->vl53l1_data);
|
||||
modi2c_dbg("over");
|
||||
} else {
|
||||
if (!i2c_data->msg_flag.unhandled_irq_vec) {
|
||||
modi2c_warn("unmatching vec %d != %d\n",
|
||||
vec, i2c_data->irq);
|
||||
i2c_data->msg_flag.unhandled_irq_vec = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
/**
|
||||
* enable and start intr handling
|
||||
*
|
||||
* @param object our i2c_data specific object
|
||||
* @param poll_mode [in/out] set to force mode clear to use irq
|
||||
* @return 0 on success and set ->poll_mode if it faill ranging wan't start
|
||||
*/
|
||||
int stmvl53l1_start_intr(void *object, int *poll_mode)
|
||||
{
|
||||
struct i2c_data *i2c_data;
|
||||
int rc;
|
||||
|
||||
i2c_data = (struct i2c_data *)object;
|
||||
/* irq and gpio acquire config done in parse_tree */
|
||||
if (i2c_data->irq < 0) {
|
||||
/* the i2c tree as no intr force polling mode */
|
||||
*poll_mode = -1;
|
||||
return 0;
|
||||
}
|
||||
/* clear irq warning report enabe it again for this session */
|
||||
i2c_data->msg_flag.unhandled_irq_vec = 0;
|
||||
/* if started do no nothing */
|
||||
if (i2c_data->io_flag.intr_started) {
|
||||
/* nothing to do */
|
||||
*poll_mode = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
vl53l1_dbgmsg("to register_irq:%d\n", i2c_data->irq);
|
||||
rc = request_threaded_irq(i2c_data->irq, NULL,
|
||||
stmvl53l1_irq_handler_i2c,
|
||||
IRQF_TRIGGER_FALLING|IRQF_ONESHOT,
|
||||
"vl53l1_interrupt",
|
||||
(void *)i2c_data);
|
||||
if (rc) {
|
||||
vl53l1_errmsg("fail to req threaded irq rc=%d\n", rc);
|
||||
*poll_mode = 0;
|
||||
} else {
|
||||
vl53l1_dbgmsg("irq %d now handled\n", i2c_data->irq);
|
||||
i2c_data->io_flag.intr_started = 1;
|
||||
*poll_mode = 0;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
void *stmvl53l1_get(void *object)
|
||||
{
|
||||
struct i2c_data *data = (struct i2c_data *) object;
|
||||
|
||||
vl53l1_dbgmsg("Enter\n");
|
||||
kref_get(&data->ref);
|
||||
vl53l1_dbgmsg("End\n");
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void memory_release(struct kref *kref)
|
||||
{
|
||||
struct i2c_data *data = container_of(kref, struct i2c_data, ref);
|
||||
|
||||
vl53l1_dbgmsg("Enter\n");
|
||||
kfree(data->vl53l1_data);
|
||||
kfree(data);
|
||||
vl53l1_dbgmsg("End\n");
|
||||
}
|
||||
|
||||
void stmvl53l1_put(void *object)
|
||||
{
|
||||
struct i2c_data *data = (struct i2c_data *) object;
|
||||
|
||||
vl53l1_dbgmsg("Enter\n");
|
||||
kref_put(&data->ref, memory_release);
|
||||
vl53l1_dbgmsg("End\n");
|
||||
}
|
||||
|
||||
void __exit stmvl53l1_exit_i2c(void *i2c_object)
|
||||
{
|
||||
vl53l1_dbgmsg("Enter\n");
|
||||
i2c_del_driver(&stmvl53l1_driver);
|
||||
vl53l1_dbgmsg("End\n");
|
||||
}
|
||||
4436
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_module.c
Normal file
4436
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_module.c
Normal file
File diff suppressed because it is too large
Load diff
22
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_tunings.h
Normal file
22
drivers/input/misc/vl53L1_14_1_2/stmvl53l1_tunings.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* THIS IS A GENERATED FILE
|
||||
*/
|
||||
|
||||
#ifndef STMVL53L1_TUNINGS_H
|
||||
#define STMVL53L1_TUNINGS_H
|
||||
|
||||
static const int tunings[][2] = {
|
||||
};
|
||||
|
||||
#endif /* STMVL53L1_TUNINGS_H */
|
||||
423
drivers/input/misc/vl53L1_14_1_2/vl53l1_platform.h
Normal file
423
drivers/input/misc/vl53L1_14_1_2/vl53l1_platform.h
Normal file
|
|
@ -0,0 +1,423 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_H_
|
||||
#define _VL53L1_PLATFORM_H_
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_platform_log.h"
|
||||
|
||||
#include "vl53l1_platform_user_data.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file vl53l1_platform.h
|
||||
*
|
||||
* @brief All end user OS/platform/application porting
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialise platform comms.
|
||||
*
|
||||
* @param[in] pdev : pointer to device structure (device handle)
|
||||
* @param[in] comms_type : selects between I2C and SPI
|
||||
* @param[in] comms_speed_khz : unsigned short containing the I2C speed in kHz
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_CommsInitialise(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint8_t comms_type,
|
||||
uint16_t comms_speed_khz);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Close platform comms.
|
||||
*
|
||||
* @param[in] pdev : pointer to device structure (device handle)
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_CommsClose(
|
||||
VL53L1_Dev_t *pdev);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Writes the supplied byte buffer to the device
|
||||
*
|
||||
* @param[in] pdev : pointer to device structure (device handle)
|
||||
* @param[in] index : uint16_t register index value
|
||||
* @param[in] pdata : pointer to uint8_t (byte) buffer containing the data
|
||||
* to be written
|
||||
* @param[in] count : number of bytes in the supplied byte buffer
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_WriteMulti(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint16_t index,
|
||||
uint8_t *pdata,
|
||||
uint32_t count);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reads the requested number of bytes from the device
|
||||
*
|
||||
* @param[in] pdev : pointer to device structure (device handle)
|
||||
* @param[in] index : uint16_t register index value
|
||||
* @param[out] pdata : pointer to the uint8_t (byte) buffer to store read
|
||||
* data
|
||||
* @param[in] count : number of bytes to read
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_ReadMulti(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint16_t index,
|
||||
uint8_t *pdata,
|
||||
uint32_t count);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Writes a single byte to the device
|
||||
*
|
||||
* @param[in] pdev : pointer to device structure (device handle)
|
||||
* @param[in] index : uint16_t register index value
|
||||
* @param[in] data : uint8_t data value to write
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_WrByte(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint16_t index,
|
||||
uint8_t data);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Writes a single word (16-bit unsigned) to the device
|
||||
*
|
||||
* Manages the big-endian nature of the device register map
|
||||
* (first byte written is the MS byte).
|
||||
*
|
||||
* @param[in] pdev : pointer to device structure (device handle)
|
||||
* @param[in] index : uint16_t register index value
|
||||
* @param[in] data : uin16_t data value write
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_WrWord(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint16_t index,
|
||||
uint16_t data);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Writes a single dword (32-bit unsigned) to the device
|
||||
*
|
||||
* Manages the big-endian nature of the device register map
|
||||
* (first byte written is the MS byte).
|
||||
*
|
||||
* @param[in] pdev : pointer to device structure (device handle)
|
||||
* @param[in] index : uint16_t register index value
|
||||
* @param[in] data : uint32_t data value to write
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_WrDWord(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint16_t index,
|
||||
uint32_t data);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reads a single byte from the device
|
||||
*
|
||||
* @param[in] pdev : pointer to device structure (device handle)
|
||||
* @param[in] index : uint16_t register index
|
||||
* @param[out] pdata : pointer to uint8_t data value
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_RdByte(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint16_t index,
|
||||
uint8_t *pdata);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reads a single word (16-bit unsigned) from the device
|
||||
*
|
||||
* Manages the big-endian nature of the device (first byte read is the MS byte).
|
||||
*
|
||||
* @param[in] pdev : pointer to device structure (device handle)
|
||||
* @param[in] index : uint16_t register index value
|
||||
* @param[out] pdata : pointer to uint16_t data value
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_RdWord(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint16_t index,
|
||||
uint16_t *pdata);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reads a single dword (32-bit unsigned) from the device
|
||||
*
|
||||
* Manages the big-endian nature of the device (first byte read is the MS byte).
|
||||
*
|
||||
* @param[in] pdev : pointer to device structure (device handle)
|
||||
* @param[in] index : uint16_t register index value
|
||||
* @param[out] pdata : pointer to uint32_t data value
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_RdDWord(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint16_t index,
|
||||
uint32_t *pdata);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Implements a programmable wait in us
|
||||
*
|
||||
* @param[in] pdev : pointer to device structure (device handle)
|
||||
* @param[in] wait_us : integer wait in micro seconds
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_WaitUs(
|
||||
VL53L1_Dev_t *pdev,
|
||||
int32_t wait_us);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Implements a programmable wait in ms
|
||||
*
|
||||
* @param[in] pdev : pointer to device structure (device handle)
|
||||
* @param[in] wait_ms : integer wait in milliseconds
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_WaitMs(
|
||||
VL53L1_Dev_t *pdev,
|
||||
int32_t wait_ms);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the frequency of the timer used for ranging results time stamps
|
||||
*
|
||||
* @param[out] ptimer_freq_hz : pointer for timer frequency
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_GetTimerFrequency(int32_t *ptimer_freq_hz);
|
||||
|
||||
/**
|
||||
* @brief Get the timer value in units of timer_freq_hz (see
|
||||
* VL53L1_get_timestamp_frequency())
|
||||
*
|
||||
* @param[out] ptimer_count : pointer for timer count value
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_GetTimerValue(int32_t *ptimer_count);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set the mode of a specified GPIO pin
|
||||
*
|
||||
* @param pin - an identifier specifying the pin being modified - defined per
|
||||
* platform
|
||||
*
|
||||
* @param mode - an identifier specifying the requested mode - defined per
|
||||
* platform
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_GpioSetMode(uint8_t pin, uint8_t mode);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set the value of a specified GPIO pin
|
||||
*
|
||||
* @param pin - an identifier specifying the pin being modified - defined per
|
||||
* platform
|
||||
*
|
||||
* @param value - a value to set on the GPIO pin - typically 0 or 1
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_GpioSetValue(uint8_t pin, uint8_t value);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the value of a specified GPIO pin
|
||||
*
|
||||
* @param pin - an identifier specifying the pin being modified - defined per
|
||||
* platform
|
||||
*
|
||||
* @param pvalue - a value retrieved from the GPIO pin - typically 0 or 1
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_GpioGetValue(uint8_t pin, uint8_t *pvalue);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Sets and clears the XShutdown pin on the Ewok
|
||||
*
|
||||
* @param value - the value for xshutdown - 0 = in reset, 1 = operational
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_GpioXshutdown(uint8_t value);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Sets and clears the Comms Mode pin (NCS) on the Ewok
|
||||
*
|
||||
* @param value - the value for comms select - 0 = I2C, 1 = SPI
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_GpioCommsSelect(uint8_t value);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Enables and disables the power to the Ewok module
|
||||
*
|
||||
* @param value - the state of the power supply - 0 = power off, 1 = power on
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_GpioPowerEnable(uint8_t value);
|
||||
|
||||
/**
|
||||
* @brief Enables callbacks to the supplied funtion pointer when Ewok interrupts
|
||||
* ocurr
|
||||
*
|
||||
* @param function - a function callback supplies by the caller, for interrupt
|
||||
* notification
|
||||
* @param edge_type - falling edge or rising edge interrupt detection
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_GpioInterruptEnable(void (*function)(void),
|
||||
uint8_t edge_type);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Disables the callback on Ewok interrupts
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_GpioInterruptDisable(void);
|
||||
|
||||
|
||||
/*
|
||||
* @brief Gets current system tick count in [ms]
|
||||
*
|
||||
* @param[in] pdev : pointer to device structure (device handle)
|
||||
* @return time_ms : current time in [ms]
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_GetTickCount(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint32_t *ptime_ms);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Register "wait for value" polling routine
|
||||
*
|
||||
* Port of the V2WReg Script function WaitValueMaskEx()
|
||||
*
|
||||
* @param[in] pdev : pointer to device structure (device handle)
|
||||
* @param[in] timeout_ms : timeout in [ms]
|
||||
* @param[in] index : uint16_t register index value
|
||||
* @param[in] value : value to wait for
|
||||
* @param[in] mask : mask to be applied before comparison with value
|
||||
* @param[in] poll_delay_ms : polling delay been each read transaction in [ms]
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_WaitValueMaskEx(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint32_t timeout_ms,
|
||||
uint16_t index,
|
||||
uint8_t value,
|
||||
uint8_t mask,
|
||||
uint32_t poll_delay_ms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
127
drivers/input/misc/vl53L1_14_1_2/vl53l1_platform_ipp.c
Normal file
127
drivers/input/misc/vl53L1_14_1_2/vl53l1_platform_ipp.c
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
|
||||
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file vl53l1_platform_ipp.c
|
||||
*
|
||||
* @brief EwokPlus25 IPP Wrapper Layer
|
||||
*/
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
#include "vl53l1_platform_ipp.h"
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_hist_structs.h"
|
||||
#include "vl53l1_hist_funcs.h"
|
||||
#include "vl53l1_xtalk.h"
|
||||
|
||||
|
||||
#define LOG_FUNCTION_START(fmt, ...) \
|
||||
_LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END(status, ...) \
|
||||
_LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_ipp_hist_process_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_dmax_calibration_data_t *pdmax_cal,
|
||||
VL53L1_hist_gen3_dmax_config_t *pdmax_cfg,
|
||||
VL53L1_hist_post_process_config_t *ppost_cfg,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_xtalk_histogram_data_t *pxtalk,
|
||||
uint8_t *pArea1,
|
||||
uint8_t *pArea2,
|
||||
uint8_t *phisto_merge_nb,
|
||||
VL53L1_range_results_t *presults)
|
||||
{
|
||||
|
||||
/*
|
||||
* IPP wrapper for histogram post processing function
|
||||
*/
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
SUPPRESS_UNUSED_WARNING(Dev);
|
||||
|
||||
status =
|
||||
VL53L1_hist_process_data(
|
||||
pdmax_cal,
|
||||
pdmax_cfg,
|
||||
ppost_cfg,
|
||||
pbins,
|
||||
pxtalk,
|
||||
pArea1,
|
||||
pArea2,
|
||||
presults,
|
||||
phisto_merge_nb);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_ipp_hist_ambient_dmax(
|
||||
VL53L1_DEV Dev,
|
||||
uint16_t target_reflectance,
|
||||
VL53L1_dmax_calibration_data_t *pdmax_cal,
|
||||
VL53L1_hist_gen3_dmax_config_t *pdmax_cfg,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
int16_t *pambient_dmax_mm)
|
||||
{
|
||||
|
||||
/*
|
||||
* IPP wrapper for histogram ambient DMAX function
|
||||
*
|
||||
* The target reflectance in percent for the DMAX calculation
|
||||
* is set by target_reflectance input
|
||||
*
|
||||
* The fixed point format is 7.2
|
||||
*/
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
SUPPRESS_UNUSED_WARNING(Dev);
|
||||
|
||||
status =
|
||||
VL53L1_hist_ambient_dmax(
|
||||
target_reflectance,
|
||||
pdmax_cal,
|
||||
pdmax_cfg,
|
||||
pbins,
|
||||
pambient_dmax_mm);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_ipp_xtalk_calibration_process_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_xtalk_range_results_t *pxtalk_ranges,
|
||||
VL53L1_xtalk_histogram_data_t *pxtalk_shape,
|
||||
VL53L1_xtalk_calibration_results_t *pxtalk_cal)
|
||||
{
|
||||
|
||||
/*
|
||||
* IPP wrapper for histogram post processing function
|
||||
*/
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
SUPPRESS_UNUSED_WARNING(Dev);
|
||||
|
||||
status =
|
||||
VL53L1_xtalk_calibration_process_data(
|
||||
pxtalk_ranges,
|
||||
pxtalk_shape,
|
||||
pxtalk_cal);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
170
drivers/input/misc/vl53L1_14_1_2/vl53l1_platform_ipp.h
Normal file
170
drivers/input/misc/vl53L1_14_1_2/vl53l1_platform_ipp.h
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_IPP_H_
|
||||
#define _VL53L1_PLATFORM_IPP_H_
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file vl53l1_platform_ipp.h
|
||||
*
|
||||
* @brief EwokPlus25 IPP Wrapper Functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief IPP Wrapper call for histogram post processing
|
||||
*
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[in] pdmax_cal : DMAX calibration data
|
||||
* @param[in] pdmax_cfg : DMAX configuration data
|
||||
* @param[in] ppost_cfg : VL53L1_hist_post_process_config_t
|
||||
* @param[in] pbins : Input histogram raw bin data
|
||||
* @param[in] pxtalk : Cross talk histogram data
|
||||
* @param[out] presults : Output VL53L1_range_results_t
|
||||
* structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_ipp_hist_process_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_dmax_calibration_data_t *pdmax_cal,
|
||||
VL53L1_hist_gen3_dmax_config_t *pdmax_cfg,
|
||||
VL53L1_hist_post_process_config_t *ppost_cfg,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
VL53L1_xtalk_histogram_data_t *pxtalk,
|
||||
uint8_t *pArea1,
|
||||
uint8_t *pArea2,
|
||||
uint8_t *phisto_merge_nb,
|
||||
VL53L1_range_results_t *presults);
|
||||
|
||||
|
||||
/**
|
||||
* @brief IPP Wrapper call for histogram ambient dmax calc
|
||||
*
|
||||
* The target reflectance in percent for the DMAX calculation
|
||||
* is set by target_reflectance input
|
||||
*
|
||||
* The fixed point format is 7.2
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[in] target_reflectance : target reflectance to report ambient DMAX
|
||||
* Percentage in 7.2 fixed point format
|
||||
* @param[in] pdmax_cal : DMAX calibration data
|
||||
* @param[in] pdmax_cfg : DMAX configuration data
|
||||
* @param[in] pbins : Input histogram raw bin data
|
||||
* @param[out] pambient_dmax_mm : Output ambient DMAX distance in [mm]
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_ipp_hist_ambient_dmax(
|
||||
VL53L1_DEV Dev,
|
||||
uint16_t target_reflectance,
|
||||
VL53L1_dmax_calibration_data_t *pdmax_cal,
|
||||
VL53L1_hist_gen3_dmax_config_t *pdmax_cfg,
|
||||
VL53L1_histogram_bin_data_t *pbins,
|
||||
int16_t *pambient_dmax_mm);
|
||||
|
||||
|
||||
/**
|
||||
* @brief IPP Wrapper call for xtalk calibration post processing
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[in] pxtalk_ranges : Input VL53L1_xtalk_range_results_t
|
||||
* Must contain 5 ranges, 4 quadrants + 1
|
||||
* full FoV
|
||||
* @param[out] pxtalk_shape : Output normalised Cross talk histogram
|
||||
* shape
|
||||
* @param[out] pxtalk_cal : Output VL53L1_xtalk_calibration_results_t
|
||||
* structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_ipp_xtalk_calibration_process_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_xtalk_range_results_t *pxtalk_ranges,
|
||||
VL53L1_xtalk_histogram_data_t *pxtalk_shape,
|
||||
VL53L1_xtalk_calibration_results_t *pxtalk_cal);
|
||||
|
||||
|
||||
/**
|
||||
* @brief IPP Wrapper call for applying histogram xtalk correction
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[in] pcustomer : Pointer to input customer data structure
|
||||
* @param[in] pdyn_cfg : Pointer to input dynamic parameters
|
||||
* structure
|
||||
* @param[in] pxtalk_shape : Pointer to input normalised xtalk
|
||||
* histogram shape
|
||||
* @param[in] pip_hist_data : Pointer to input histogram data struct
|
||||
* @param[out] pop_hist_data : Pointer to output xtalk corrected
|
||||
* histogram data struct
|
||||
* @param[out] pxtalk_count_data : Pointer to output xtalk histogram
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_ipp_hist_xtalk_correction(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_customer_nvm_managed_t *pcustomer,
|
||||
VL53L1_dynamic_config_t *pdyn_cfg,
|
||||
VL53L1_xtalk_histogram_data_t *pxtalk_shape,
|
||||
VL53L1_histogram_bin_data_t *pip_hist_data,
|
||||
VL53L1_histogram_bin_data_t *pop_hist_data,
|
||||
VL53L1_histogram_bin_data_t *pxtalk_count_data);
|
||||
|
||||
/**
|
||||
* @brief IPP Wrapper call for Generating Xtalk data from dual reflectance
|
||||
* histogram data
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[in] pxtalk_results : Pointer to xtalk_results structure
|
||||
* containing dual reflectance
|
||||
* histogram data
|
||||
* @param[in] expected_target_distance_mm : User input of true target distance
|
||||
* @param[in] higher_reflectance : User input detailing which
|
||||
* histogram data 1 or 2 has the
|
||||
* highest reflectance.
|
||||
* @param[out] pxtalk_avg_samples : Pointer to output xtalk histogram
|
||||
* data
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_ipp_generate_dual_reflectance_xtalk_samples(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_xtalk_range_results_t *pxtalk_results,
|
||||
uint16_t expected_target_distance_mm,
|
||||
uint8_t higher_reflectance,
|
||||
VL53L1_histogram_bin_data_t *pxtalk_avg_samples);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_IPP_IMPORTS_H_
|
||||
#define _VL53L1_PLATFORM_IPP_IMPORTS_H_
|
||||
|
||||
#endif
|
||||
157
drivers/input/misc/vl53L1_14_1_2/vl53l1_platform_log.h
Normal file
157
drivers/input/misc/vl53L1_14_1_2/vl53l1_platform_log.h
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file vl53l1_platform_log.h
|
||||
*
|
||||
* @brief EwokPlus25 platform logging function definition
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_LOG_H_
|
||||
#define _VL53L1_PLATFORM_LOG_H_
|
||||
|
||||
#include <linux/string.h>
|
||||
|
||||
#ifdef VL53L1_LOG_ENABLE
|
||||
#include "vl53l1_platform_user_config.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define EWOKPLUS_EXPORTS __declspec(dllexport)
|
||||
#else
|
||||
# define EWOKPLUS_EXPORTS
|
||||
#endif
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <linux/time.h>
|
||||
|
||||
/**
|
||||
* @brief Set the level, output and specific functions for module
|
||||
* logging.
|
||||
*
|
||||
*
|
||||
* @param filename - full path of output log file, NULL for print to
|
||||
* stdout
|
||||
*
|
||||
* @param modules - Module or None or All to trace
|
||||
* VL53L1_TRACE_MODULE_NONE
|
||||
* VL53L1_TRACE_MODULE_API
|
||||
* VL53L1_TRACE_MODULE_CORE
|
||||
* VL53L1_TRACE_MODULE_TUNING
|
||||
* VL53L1_TRACE_MODULE_CHARACTERISATION
|
||||
* VL53L1_TRACE_MODULE_PLATFORM
|
||||
* VL53L1_TRACE_MODULE_ALL
|
||||
*
|
||||
* @param level - trace level
|
||||
* VL53L1_TRACE_LEVEL_NONE
|
||||
* VL53L1_TRACE_LEVEL_ERRORS
|
||||
* VL53L1_TRACE_LEVEL_WARNING
|
||||
* VL53L1_TRACE_LEVEL_INFO
|
||||
* VL53L1_TRACE_LEVEL_DEBUG
|
||||
* VL53L1_TRACE_LEVEL_ALL
|
||||
* VL53L1_TRACE_LEVEL_IGNORE
|
||||
*
|
||||
* @param functions - function level to trace;
|
||||
* VL53L1_TRACE_FUNCTION_NONE
|
||||
* VL53L1_TRACE_FUNCTION_I2C
|
||||
* VL53L1_TRACE_FUNCTION_ALL
|
||||
*
|
||||
* @return status - always VL53L1_ERROR_NONE
|
||||
*
|
||||
*/
|
||||
|
||||
#define VL53L1_TRACE_LEVEL_NONE 0x00000000
|
||||
#define VL53L1_TRACE_LEVEL_ERRORS 0x00000001
|
||||
#define VL53L1_TRACE_LEVEL_WARNING 0x00000002
|
||||
#define VL53L1_TRACE_LEVEL_INFO 0x00000004
|
||||
#define VL53L1_TRACE_LEVEL_DEBUG 0x00000008
|
||||
#define VL53L1_TRACE_LEVEL_ALL 0x00000010
|
||||
#define VL53L1_TRACE_LEVEL_IGNORE 0x00000020
|
||||
|
||||
#define VL53L1_TRACE_FUNCTION_NONE 0x00000000
|
||||
#define VL53L1_TRACE_FUNCTION_I2C 0x00000001
|
||||
#define VL53L1_TRACE_FUNCTION_ALL 0x7fffffff
|
||||
|
||||
#define VL53L1_TRACE_MODULE_NONE 0x00000000
|
||||
#define VL53L1_TRACE_MODULE_API 0x00000001
|
||||
#define VL53L1_TRACE_MODULE_CORE 0x00000002
|
||||
#define VL53L1_TRACE_MODULE_PROTECTED 0x00000004
|
||||
#define VL53L1_TRACE_MODULE_HISTOGRAM 0x00000008
|
||||
#define VL53L1_TRACE_MODULE_REGISTERS 0x00000010
|
||||
#define VL53L1_TRACE_MODULE_PLATFORM 0x00000020
|
||||
#define VL53L1_TRACE_MODULE_NVM 0x00000040
|
||||
#define VL53L1_TRACE_MODULE_CALIBRATION_DATA 0x00000080
|
||||
#define VL53L1_TRACE_MODULE_NVM_DATA 0x00000100
|
||||
#define VL53L1_TRACE_MODULE_HISTOGRAM_DATA 0x00000200
|
||||
#define VL53L1_TRACE_MODULE_RANGE_RESULTS_DATA 0x00000400
|
||||
#define VL53L1_TRACE_MODULE_XTALK_DATA 0x00000800
|
||||
#define VL53L1_TRACE_MODULE_OFFSET_DATA 0x00001000
|
||||
#define VL53L1_TRACE_MODULE_DATA_INIT 0x00002000
|
||||
#define VL53L1_TRACE_MODULE_REF_SPAD_CHAR 0x00004000
|
||||
#define VL53L1_TRACE_MODULE_SPAD_RATE_MAP 0x00008000
|
||||
#ifdef PAL_EXTENDED
|
||||
#define VL53L1_TRACE_MODULE_SPAD 0x01000000
|
||||
#define VL53L1_TRACE_MODULE_FMT 0x02000000
|
||||
#define VL53L1_TRACE_MODULE_UTILS 0x04000000
|
||||
#define VL53L1_TRACE_MODULE_BENCH_FUNCS 0x08000000
|
||||
#endif
|
||||
#define VL53L1_TRACE_MODULE_CUSTOMER_API 0x40000000
|
||||
#define VL53L1_TRACE_MODULE_ALL 0x7fffffff
|
||||
|
||||
extern void log_trace_print(uint32_t module, uint32_t level,
|
||||
uint32_t function, const char *format, ...);
|
||||
|
||||
#define _LOG_TRACE_PRINT_FMT(module, level, function, format, ...) \
|
||||
log_trace_print(module, level, function, \
|
||||
KERN_INFO "<TRACE> " format, ##__VA_ARGS__)
|
||||
#define _LOG_TRACE_PRINT(module, level, function, ...) \
|
||||
_LOG_TRACE_PRINT_FMT(module, level, function, ##__VA_ARGS__)
|
||||
#define _LOG_FUNCTION_START(module, fmt, ...) \
|
||||
log_trace_print(module, VL53L1_TRACE_LEVEL_NONE, \
|
||||
VL53L1_TRACE_FUNCTION_ALL, \
|
||||
KERN_INFO "<START> %s "fmt"\n", __func__, ##__VA_ARGS__)
|
||||
#define _LOG_FUNCTION_END(module, status, ...) \
|
||||
log_trace_print(module, VL53L1_TRACE_LEVEL_NONE, \
|
||||
VL53L1_TRACE_FUNCTION_ALL, \
|
||||
KERN_INFO "<END> %s %d\n", __func__, status)
|
||||
#define _LOG_FUNCTION_END_FMT(module, status, fmt, ...) \
|
||||
log_trace_print(module, VL53L1_TRACE_LEVEL_NONE, \
|
||||
VL53L1_TRACE_FUNCTION_ALL, \
|
||||
KERN_INFO "<END > %s %d"fmt"\n", __func__, status, \
|
||||
##__VA_ARGS__)
|
||||
#define _LOG_GET_TRACE_FUNCTIONS() 0
|
||||
#define _LOG_SET_TRACE_FUNCTIONS(functions)
|
||||
|
||||
#define _LOG_STRING_BUFFER(x) char x[VL53L1_MAX_STRING_LENGTH]
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* VL53L1_LOG_ENABLE - no logging */
|
||||
#include "vl53l1_platform_user_config.h"
|
||||
|
||||
#define _LOG_TRACE_PRINT(module, level, function, ...)
|
||||
#define _LOG_FUNCTION_START(module, fmt, ...)
|
||||
#define _LOG_FUNCTION_END(module, status, ...)
|
||||
#define _LOG_FUNCTION_END_FMT(module, status, fmt, ...)
|
||||
#define _LOG_GET_TRACE_FUNCTIONS() 0
|
||||
#define _LOG_SET_TRACE_FUNCTIONS(functions)
|
||||
#define _LOG_STRING_BUFFER(x)
|
||||
|
||||
#endif /* VL53L1_LOG_ENABLE */
|
||||
|
||||
#endif /* _VL53L1_PLATFORM_LOG_H_ */
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file vl53l1_platform_user_config.h
|
||||
*
|
||||
* @brief EwokPlus compile time user modifiable configuration
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_USER_CONFIG_H_
|
||||
#define _VL53L1_PLATFORM_USER_CONFIG_H_
|
||||
|
||||
#define VL53L1_BYTES_PER_WORD 2
|
||||
#define VL53L1_BYTES_PER_DWORD 4
|
||||
|
||||
/* Define polling delays */
|
||||
#define VL53L1_BOOT_COMPLETION_POLLING_TIMEOUT_MS 500
|
||||
#define VL53L1_RANGE_COMPLETION_POLLING_TIMEOUT_MS 2000
|
||||
#define VL53L1_TEST_COMPLETION_POLLING_TIMEOUT_MS 60000
|
||||
|
||||
#define VL53L1_POLLING_DELAY_MS 1
|
||||
|
||||
/* Define LLD TuningParms Page Base Address
|
||||
* - Part of Patch_AddedTuningParms_11761
|
||||
*/
|
||||
#define VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS 0x8000
|
||||
#define VL53L1_TUNINGPARM_PRIVATE_PAGE_BASE_ADDRESS 0xC000
|
||||
|
||||
#define VL53L1_GAIN_FACTOR__STANDARD_DEFAULT 0x0800
|
||||
/*!< Default standard ranging gain correction factor
|
||||
* 1.11 format. 1.0 = 0x0800, 0.980 = 0x07D7
|
||||
*/
|
||||
#define VL53L1_GAIN_FACTOR__HISTOGRAM_DEFAULT 0x0800
|
||||
/*!< Default histogram ranging gain correction factor
|
||||
* 1.11 format. 1.0 = 0x0800, 0.975 = 0x07CC
|
||||
*/
|
||||
|
||||
|
||||
#define VL53L1_OFFSET_CAL_MIN_EFFECTIVE_SPADS 0x0500
|
||||
/*!< Lower Limit for the MM1 effective SPAD count during offset
|
||||
* calibration Format 8.8 0x0500 -> 5.0 effective SPADs
|
||||
*/
|
||||
|
||||
#define VL53L1_OFFSET_CAL_MAX_PRE_PEAK_RATE_MCPS 0x1900
|
||||
/*!< Max Limit for the pre range preak rate during offset
|
||||
* calibration Format 9.7 0x1900 -> 50.0 Mcps.
|
||||
* If larger then in pile up
|
||||
*/
|
||||
|
||||
#define VL53L1_OFFSET_CAL_MAX_SIGMA_MM 0x0040
|
||||
/*!< Max sigma estimate limit during offset calibration
|
||||
* Check applies to pre-range, mm1 and mm2 ranges
|
||||
* Format 14.2 0x0040 -> 16.0mm.
|
||||
*/
|
||||
|
||||
|
||||
#define VL53L1_ZONE_CAL_MAX_PRE_PEAK_RATE_MCPS 0x1900
|
||||
/*!< Max Peak Rate Limit for the during zone calibration
|
||||
* Format 9.7 0x1900 -> 50.0 Mcps.
|
||||
* If larger then in pile up
|
||||
*/
|
||||
|
||||
#define VL53L1_ZONE_CAL_MAX_SIGMA_MM 0x0040
|
||||
/*!< Max sigma estimate limit during zone calibration
|
||||
* Format 14.2 0x0040 -> 16.0mm.
|
||||
*/
|
||||
|
||||
|
||||
#define VL53L1_XTALK_EXTRACT_MAX_SIGMA_MM 0x008C
|
||||
/*!< Max Sigma value allowed for a successful xtalk extraction
|
||||
* Format 14.2 0x008C -> 35.0 mm.
|
||||
*/
|
||||
|
||||
|
||||
#define VL53L1_MAX_USER_ZONES 169
|
||||
/*!< Max number of user Zones - maximal limitation from
|
||||
* FW stream divide - value of 254
|
||||
*/
|
||||
|
||||
#define VL53L1_MAX_RANGE_RESULTS 4
|
||||
/*!< Sets the maximum number of targets distances the histogram
|
||||
* post processing can generate
|
||||
*/
|
||||
|
||||
#define VL53L1_MAX_STRING_LENGTH 512
|
||||
|
||||
#endif /* _VL53L1_PLATFORM_USER_CONFIG_H_ */
|
||||
|
||||
43
drivers/input/misc/vl53L1_14_1_2/vl53l1_platform_user_data.h
Normal file
43
drivers/input/misc/vl53L1_14_1_2/vl53l1_platform_user_data.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_USER_DATA_H_
|
||||
#define _VL53L1_PLATFORM_USER_DATA_H_
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
|
||||
#include <linux/string.h>
|
||||
#include "vl53l1_def.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <linux/string.h>
|
||||
|
||||
#define VL53L1_Dev_t VL53L1_DevData_t
|
||||
#define VL53L1_DEV VL53L1_DevData_t *
|
||||
|
||||
#define VL53L1DevDataGet(Dev, field) (Dev->field)
|
||||
#define VL53L1DevDataSet(Dev, field, data) ((Dev->field) = (data))
|
||||
|
||||
#define VL53L1DevStructGetLLDriverHandle(Dev) (&VL53L1DevDataGet(Dev, LLData))
|
||||
#define VL53L1DevStructGetLLResultsHandle(Dev) (&VL53L1DevDataGet(Dev,\
|
||||
llresults))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_USER_DEFINES_H_
|
||||
#define _VL53L1_PLATFORM_USER_DEFINES_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/math64.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file vl53l1_platform_user_defines.h
|
||||
*
|
||||
* @brief All end user OS/platform/application definitions
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @def do_division_u
|
||||
* @brief customer supplied division operation - 64-bit unsigned
|
||||
*
|
||||
* @param dividend unsigned 64-bit numerator
|
||||
* @param divisor unsigned 64-bit denominator
|
||||
*/
|
||||
#ifdef __KERNEL__
|
||||
#define do_division_u(dividend, divisor) div64_u64(dividend, divisor)
|
||||
#else
|
||||
#define do_division_u(dividend, divisor) (dividend / divisor)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def do_division_s
|
||||
* @brief customer supplied division operation - 64-bit signed
|
||||
*
|
||||
* @param dividend signed 64-bit numerator
|
||||
* @param divisor signed 64-bit denominator
|
||||
*/
|
||||
#ifdef __KERNEL__
|
||||
#define do_division_s(dividend, divisor) div64_s64(dividend, divisor)
|
||||
#else
|
||||
#define do_division_s(dividend, divisor) (dividend / divisor)
|
||||
#endif
|
||||
|
||||
#define WARN_OVERRIDE_STATUS(__X__)\
|
||||
trace_print(VL53L1_TRACE_LEVEL_WARNING, #__X__)
|
||||
|
||||
|
||||
#define DISABLE_WARNINGS()
|
||||
#define ENABLE_WARNINGS()
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
27
drivers/input/misc/vl53L1_14_1_2/vl53l1_types.h
Normal file
27
drivers/input/misc/vl53L1_14_1_2/vl53l1_types.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file vl53l1_types.h
|
||||
* @brief VL53L1 types definition
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_TYPES_H_
|
||||
#define _VL53L1_TYPES_H_
|
||||
|
||||
#include <linux/types.h>
|
||||
/** use where fractional values are expected
|
||||
*
|
||||
* Given a floating point value f it's .16 bit point is (int)(f*(1<<16))
|
||||
*/
|
||||
typedef uint32_t FixPoint1616_t;
|
||||
|
||||
#endif /* VL53L1_TYPES_H_ */
|
||||
Loading…
Reference in a new issue