mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 21:59:12 -04:00
Remove vl53l1 ToF test driver
VL53L1 test driver was added to fix TCMD compilation errors. ST shared official Maintenance release #2 driver, so test driver not needed anymore. Olson is the first program to use ToF as DLKM, so it will not impact any NPI/legacy programs in 'bo' branch. Change-Id: Idf4add39ca9fcf77b27296e0ca6a82ec40c08a59 Reviewed-on: https://gerrit.mot.com/1233050 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Sumit Jamadar <xkbr38@motorola.com> Reviewed-by: Rav(CR) Vembu <raviv@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
e5ac8247cd
commit
140506b2cd
69 changed files with 0 additions and 77904 deletions
|
|
@ -1,8 +0,0 @@
|
|||
DLKM_DIR := motorola/kernel/modules
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := stmvl53l1.ko
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
|
||||
include $(DLKM_DIR)/AndroidKernelModule.mk
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#
|
||||
# Makefile for the vl53L1 drivers.
|
||||
#
|
||||
|
||||
ccflags-y += -Idrivers/input/misc/vl53L1/inc \
|
||||
-Idrivers/input/misc/vl53L1/ipp -Idrivers/input/misc/vl53L1
|
||||
|
||||
# define this environment variable if you want to compile driver for an old
|
||||
# kernel
|
||||
ifdef OLD_NETLINK_API
|
||||
ccflags-y += -DOLD_NETLINK_API
|
||||
endif
|
||||
|
||||
obj-m += stmvl53l1.o
|
||||
stmvl53l1-objs := stmvl53l1_module.o stmvl53l1_module-i2c.o
|
||||
stmvl53l1-objs += stmvl53l1_i2c.o stmvl53l1_ipp_nl.o
|
||||
stmvl53l1-objs += src/vl53l1_api.o src/vl53l1_api_core.o
|
||||
stmvl53l1-objs += src/vl53l1_api_strings.o src/vl53l1_error_strings.o
|
||||
stmvl53l1-objs += src/vl53l1_core.o src/vl53l1_register_funcs.o
|
||||
stmvl53l1-objs += src/vl53l1_api_preset_modes.o
|
||||
stmvl53l1-objs += src/vl53l1_api_calibration.o
|
||||
stmvl53l1-objs += src/vl53l1_fpga_core.o src/vl53l1_silicon_core.o
|
||||
stmvl53l1-objs += src/vl53l1_zone_presets.o src/vl53l1_nvm.o
|
||||
stmvl53l1-objs += src/vl53l1_wait.o ipp/ipp_linux.o
|
||||
stmvl53l1-objs += src/vl53l1_api_debug.o src/vl53l1_core_support.o
|
||||
stmvl53l1-objs += src/vl53l1_nvm_debug.o stmvl53l1_log.o
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build
|
||||
|
||||
all:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(shell pwd) modules $(KBUILD_OPTIONS)
|
||||
|
||||
modules_install:
|
||||
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(shell pwd) modules_install
|
||||
|
||||
clean:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,569 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _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,
|
||||
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,
|
||||
uint8_t num_of_samples,
|
||||
VL53L1_Error *pcal_status);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_run_xtalk_extraction_dual_reflectance(
|
||||
VL53L1_DEV Dev,
|
||||
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,
|
||||
uint8_t num_of_samples,
|
||||
uint8_t calc_parms,
|
||||
uint8_t higher_reflectance,
|
||||
uint16_t expected_target_distance_mm,
|
||||
uint16_t xtalk_filter_thresh_mm,
|
||||
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_get_and_avg_all_xtalk_samples(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t num_of_samples,
|
||||
uint8_t measurement_mode,
|
||||
int16_t xtalk_filter_thresh_mm,
|
||||
VL53L1_xtalk_range_results_t *pxtalk_results,
|
||||
VL53L1_histogram_bin_data_t *pavg_histo_z0,
|
||||
VL53L1_histogram_bin_data_t *pavg_histo_z1,
|
||||
VL53L1_histogram_bin_data_t *pavg_histo_z2,
|
||||
VL53L1_histogram_bin_data_t *pavg_histo_z3,
|
||||
VL53L1_histogram_bin_data_t *pavg_histo_z4);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_run_offset_calibration(
|
||||
VL53L1_DEV Dev,
|
||||
uint16_t dss_config__target_total_rate_mcps,
|
||||
uint32_t phasecal_config_timeout_us,
|
||||
uint32_t range_config_timeout_us,
|
||||
uint8_t pre_num_of_samples,
|
||||
uint8_t mm1_num_of_samples,
|
||||
uint8_t mm2_num_of_samples,
|
||||
int16_t cal_distance_mm,
|
||||
uint16_t cal_reflectance_pc,
|
||||
VL53L1_Error *pcal_status);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_run_zone_calibration(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DevicePresetModes device_preset_mode,
|
||||
VL53L1_DeviceZonePreset zone_preset,
|
||||
VL53L1_zone_config_t *pzone_cfg,
|
||||
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,
|
||||
uint16_t num_of_samples,
|
||||
int16_t cal_distance_mm,
|
||||
uint16_t cal_reflectance_pc,
|
||||
VL53L1_Error *pcal_status);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,649 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _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_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_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_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_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
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,210 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file 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
|
||||
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,410 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _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_PRM_00009,
|
||||
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_PRM_00006,
|
||||
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_PRM_00013,
|
||||
uint16_t zero_distance_phase,
|
||||
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_PRM_00017,
|
||||
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
|
||||
|
||||
|
||||
|
|
@ -1,704 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file 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
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** PAL SPECIFICATION major version */
|
||||
#define VL53L1_SPECIFICATION_VER_MAJOR 1
|
||||
/** PAL SPECIFICATION minor version */
|
||||
#define VL53L1_SPECIFICATION_VER_MINOR 2
|
||||
/** PAL SPECIFICATION sub version */
|
||||
#define VL53L1_SPECIFICATION_VER_SUB 7
|
||||
/** PAL SPECIFICATION sub version */
|
||||
#define VL53L1_SPECIFICATION_VER_REVISION 1440
|
||||
|
||||
/** VL53L1 IMPLEMENTATION major version */
|
||||
#define VL53L1_IMPLEMENTATION_VER_MAJOR 4
|
||||
/** VL53L1 IMPLEMENTATION minor version */
|
||||
#define VL53L1_IMPLEMENTATION_VER_MINOR 1
|
||||
/** VL53L1 IMPLEMENTATION sub version */
|
||||
#define VL53L1_IMPLEMENTATION_VER_SUB 0
|
||||
/** VL53L1 IMPLEMENTATION sub version */
|
||||
#define VL53L1_IMPLEMENTATION_VER_REVISION 1249
|
||||
|
||||
|
||||
/****************************************
|
||||
* 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];
|
||||
/*!< Name of the Device e.g. Left_Distance */
|
||||
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 = 1, VL53L1 = 2*/
|
||||
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)
|
||||
|
||||
/* ... 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)
|
||||
#define VL53L1_DISTANCEMODE_AUTO_LITE ((VL53L1_DistanceModes) 4)
|
||||
#define VL53L1_DISTANCEMODE_AUTO ((VL53L1_DistanceModes) 5)
|
||||
|
||||
/* ... Modes to be added depending on device */
|
||||
/** @} 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_OffsetCalibrationModes_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_OffsetCalibrationModes_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 DMAXMODE_FMT_CAL_DATA ((VL53L1_DeviceDmaxModes) 1)
|
||||
#define DMAXMODE_CUSTCAL_DATA ((VL53L1_DeviceDmaxModes) 2)
|
||||
#define DMAXMODE_PER_ZONE_CAL_DATA ((VL53L1_DeviceDmaxModes) 3)
|
||||
|
||||
/** @} VL53L1_define_DeviceDmaxModes_group */
|
||||
|
||||
/** @defgroup VL53L1_define_OffsetCalibrationModesBD_group
|
||||
* Device Offset Correction 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)
|
||||
|
||||
/** @} VL53L1_define_OffsetCalibrationModesBD_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_define_InterruptPolarity_group Defines the Polarity
|
||||
* of the Interrupt
|
||||
* Defines the Polarity of the Interrupt
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_InterruptPolarity;
|
||||
|
||||
#define VL53L1_INTERRUPTPOLARITY_LOW ((VL53L1_InterruptPolarity) 0)
|
||||
/*!< Set active low polarity best setup for falling edge. */
|
||||
#define VL53L1_INTERRUPTPOLARITY_HIGH ((VL53L1_InterruptPolarity) 1)
|
||||
/*!< Set active high polarity best setup for rising edge. */
|
||||
|
||||
/** @} VL53L1_define_InterruptPolarity_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; /*!< See #VL53L1_GpioThreshold */
|
||||
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; /*!< See #VL53L1_GpioThreshold */
|
||||
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_GPIODetectionMode*/
|
||||
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 */
|
||||
VL53L1_DistanceModes InternalDistanceMode;
|
||||
/*!< Defines the internal operating mode to be used for the next
|
||||
* measure
|
||||
*/
|
||||
VL53L1_DistanceModes NewDistanceMode;
|
||||
/*!< Defines the new operating mode to be programmed 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
|
||||
*/
|
||||
uint8_t AmbientDmaxIndex;
|
||||
/*!< This value stores the index of the ambient Dmax to take from
|
||||
* ambient_dmax_mm[] table to populate ranging results
|
||||
*/
|
||||
} 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 */
|
||||
|
||||
|
||||
/**
|
||||
* @struct VL53L1_SingleRangingData_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
|
||||
*/
|
||||
|
||||
int16_t DmaxMilliMeter;
|
||||
/*!< range Dmax distance in millimeter.
|
||||
*/
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
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_ROIRangeResults_t
|
||||
* @brief Structure for storing the set of range results for a single ROI
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
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_RangingMeasurementData_t RangeData[VL53L1_MAX_RANGE_RESULTS];
|
||||
/*!< Range data each target distance */
|
||||
|
||||
} 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 x 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_CalibrationData_t
|
||||
* @brief Structure for storing the Calibration Data
|
||||
*
|
||||
*/
|
||||
typedef VL53L1_calibration_data_t VL53L1_CalibrationData_t;
|
||||
|
||||
|
||||
/** @defgroup VL53L1_define_SequenceStepId_group Defines the SequenceStep
|
||||
* Defines the 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_MIN_RANGE_FAIL 3
|
||||
/*!<Min Range fail. */
|
||||
#define VL53L1_RANGESTATUS_PHASE_FAIL 4
|
||||
/*!<Phase fail. */
|
||||
#define VL53L1_RANGESTATUS_HARDWARE_FAIL 5
|
||||
/*!<Hardware fail. */
|
||||
#define VL53L1_RANGESTATUS_RANGE_VALID_NO_WRAP_CHECK 6
|
||||
/*!<The Range is valid but the wraparound check has not been done. */
|
||||
#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) \
|
||||
(PALDevDataSet(Dev, CurrentParameters.field, value))
|
||||
|
||||
#define VL53L1_GETPARAMETERFIELD(Dev, field, variable) \
|
||||
(variable = PALDevDataGet(Dev, CurrentParameters).field)
|
||||
|
||||
|
||||
#define VL53L1_SETARRAYPARAMETERFIELD(Dev, field, index, value) \
|
||||
(PALDevDataSet(Dev, CurrentParameters.field[index], value))
|
||||
|
||||
#define VL53L1_GETARRAYPARAMETERFIELD(Dev, field, index, variable) \
|
||||
(variable = PALDevDataGet(Dev, CurrentParameters).field[index])
|
||||
|
||||
|
||||
#define VL53L1_SETDEVICESPECIFICPARAMETER(Dev, field, value) \
|
||||
(PALDevDataSet(Dev, DeviceSpecificParameters.field, value))
|
||||
|
||||
#define VL53L1_GETDEVICESPECIFICPARAMETER(Dev, field) \
|
||||
(PALDevDataGet(Dev, DeviceSpecificParameters).field)
|
||||
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT72(Value) \
|
||||
(uint16_t)((Value>>2)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT72TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)(Value<<2)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT97(Value) \
|
||||
(uint16_t)((Value>>9)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT97TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)(Value<<9)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT88(Value) \
|
||||
(uint16_t)((Value>>8)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT88TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)(Value<<8)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT412(Value) \
|
||||
(uint16_t)((Value>>4)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT412TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)(Value<<4)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT313(Value) \
|
||||
(uint16_t)((Value>>3)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT313TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)(Value<<3)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT08(Value) \
|
||||
(uint8_t)((Value>>8)&0x00FF)
|
||||
#define VL53L1_FIXPOINT08TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)(Value<<8)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT53(Value) \
|
||||
(uint8_t)((Value>>13)&0x00FF)
|
||||
#define VL53L1_FIXPOINT53TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)(Value<<13)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT102(Value) \
|
||||
(uint16_t)((Value>>14)&0x0FFF)
|
||||
#define VL53L1_FIXPOINT102TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)(Value<<14)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT142(Value) \
|
||||
(uint16_t)((Value>>14)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT142TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)(Value<<14)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT160(Value) \
|
||||
(uint16_t)((Value>>16)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT160TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_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_ */
|
||||
|
|
@ -1,205 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _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;
|
||||
|
||||
|
||||
|
||||
uint16_t target_reflectance_for_dmax_calc[VL53L1_MAX_AMBIENT_DMAX_VALUES];
|
||||
|
||||
|
||||
uint8_t estimated_spad_yield;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint16_t dss_config__target_total_rate_mcps;
|
||||
|
||||
|
||||
uint8_t dss_config__aperture_attenuation;
|
||||
|
||||
|
||||
|
||||
} VL53L1_hist_gen3_dmax_config_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,323 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_ERROR_CODES_H_
|
||||
#define _VL53L1_ERROR_CODES_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef int8_t VL53L1_Error;
|
||||
|
||||
#define VL53L1_ERROR_NONE ((VL53L1_Error) 0)
|
||||
#define VL53L1_ERROR_CALIBRATION_WARNING ((VL53L1_Error) - 1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_ERROR_MIN_CLIPPED ((VL53L1_Error) - 2)
|
||||
|
||||
|
||||
|
||||
#define VL53L1_ERROR_UNDEFINED ((VL53L1_Error) - 3)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_INVALID_PARAMS ((VL53L1_Error) - 4)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_NOT_SUPPORTED ((VL53L1_Error) - 5)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_RANGE_ERROR ((VL53L1_Error) - 6)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_TIME_OUT ((VL53L1_Error) - 7)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_MODE_NOT_SUPPORTED ((VL53L1_Error) - 8)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_BUFFER_TOO_SMALL ((VL53L1_Error) - 9)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL ((VL53L1_Error) - 10)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_GPIO_NOT_EXISTING ((VL53L1_Error) - 11)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED ((VL53L1_Error) - 12)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_CONTROL_INTERFACE ((VL53L1_Error) - 13)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_INVALID_COMMAND ((VL53L1_Error) - 14)
|
||||
|
||||
|
||||
|
||||
#define VL53L1_ERROR_DIVISION_BY_ZERO ((VL53L1_Error) - 15)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_REF_SPAD_INIT ((VL53L1_Error) - 16)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_GPH_SYNC_CHECK_FAIL ((VL53L1_Error) - 17)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_STREAM_COUNT_CHECK_FAIL ((VL53L1_Error) - 18)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_GPH_ID_CHECK_FAIL ((VL53L1_Error) - 19)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL ((VL53L1_Error) - 20)
|
||||
|
||||
|
||||
#define VL53L1_ERROR_ZONE_GPH_ID_CHECK_FAIL ((VL53L1_Error) - 21)
|
||||
|
||||
|
||||
|
||||
#define VL53L1_ERROR_XTALK_EXTRACTION_NO_SAMPLE_FAIL ((VL53L1_Error) - 22)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL ((VL53L1_Error) - 23)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL ((VL53L1_Error) - 24)
|
||||
|
||||
|
||||
|
||||
#define VL53L1_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL ((VL53L1_Error) - 25)
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_ERROR_ZONE_CAL_NO_SAMPLE_FAIL ((VL53L1_Error) - 26)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS ((VL53L1_Error) - 27)
|
||||
|
||||
|
||||
#define VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH ((VL53L1_Error) - 28)
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW ((VL53L1_Error) - 29)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES ((VL53L1_Error) - 30)
|
||||
|
||||
|
||||
|
||||
#define VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH ((VL53L1_Error) - 31)
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH ((VL53L1_Error) - 32)
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW ((VL53L1_Error) - 33)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_WARNING_ZONE_CAL_MISSING_SAMPLES ((VL53L1_Error) - 34)
|
||||
|
||||
|
||||
|
||||
#define VL53L1_WARNING_ZONE_CAL_SIGMA_TOO_HIGH ((VL53L1_Error) - 35)
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_WARNING_ZONE_CAL_RATE_TOO_HIGH ((VL53L1_Error) - 36)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_WARNING_XTALK_MISSING_SAMPLES ((VL53L1_Error) - 37)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT ((VL53L1_Error) - 38)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT ((VL53L1_Error) - 39)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_ERROR_NOT_IMPLEMENTED ((VL53L1_Error) - 40)
|
||||
|
||||
|
||||
|
||||
#define VL53L1_ERROR_PLATFORM_SPECIFIC_START ((VL53L1_Error) - 60)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _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
|
||||
|
||||
|
||||
|
|
@ -1,243 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef 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_PRM_00012 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_PRM_00012 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
|
||||
|
||||
|
||||
|
|
@ -1,134 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_FPGA_CORE_H_
|
||||
#define _VL53L1_FPGA_CORE_H_
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_is_firmware_ready_fpga(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pready);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -1,175 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _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
|
||||
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _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
|
||||
|
||||
|
|
@ -1,477 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _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;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
||||
|
||||
uint8_t algo__crosstalk_compensation_enable;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
||||
|
||||
} 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_PRM_00015;
|
||||
|
||||
|
||||
uint8_t VL53L1_PRM_00016;
|
||||
|
||||
|
||||
uint8_t VL53L1_PRM_00017;
|
||||
|
||||
|
||||
|
||||
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_PRM_00007;
|
||||
|
||||
|
||||
uint16_t VL53L1_PRM_00018;
|
||||
|
||||
|
||||
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_PRM_00026;
|
||||
|
||||
|
||||
|
||||
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_PRM_00015;
|
||||
|
||||
|
||||
uint8_t VL53L1_PRM_00016;
|
||||
|
||||
|
||||
uint8_t VL53L1_PRM_00017;
|
||||
|
||||
|
||||
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_PRM_00018;
|
||||
|
||||
|
||||
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
|
||||
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,843 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _VL53L1_LL_DEVICE_H_
|
||||
#define _VL53L1_LL_DEVICE_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
|
||||
#define VL53L1_I2C 0x01
|
||||
#define VL53L1_SPI 0x00
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_WaitMethod;
|
||||
|
||||
#define VL53L1_WAIT_METHOD_BLOCKING ((VL53L1_WaitMethod) 0)
|
||||
#define VL53L1_WAIT_METHOD_NON_BLOCKING ((VL53L1_WaitMethod) 1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_DeviceState;
|
||||
|
||||
#define VL53L1_DEVICESTATE_POWERDOWN ((VL53L1_DeviceState) 0)
|
||||
#define VL53L1_DEVICESTATE_HW_STANDBY ((VL53L1_DeviceState) 1)
|
||||
#define VL53L1_DEVICESTATE_FW_COLDBOOT ((VL53L1_DeviceState) 2)
|
||||
#define VL53L1_DEVICESTATE_SW_STANDBY ((VL53L1_DeviceState) 3)
|
||||
#define VL53L1_DEVICESTATE_RANGING_DSS_AUTO ((VL53L1_DeviceState) 4)
|
||||
#define VL53L1_DEVICESTATE_RANGING_DSS_MANUAL ((VL53L1_DeviceState) 5)
|
||||
#define VL53L1_DEVICESTATE_RANGING_WAIT_GPH_SYNC ((VL53L1_DeviceState) 6)
|
||||
#define VL53L1_DEVICESTATE_RANGING_GATHER_DATA ((VL53L1_DeviceState) 7)
|
||||
#define VL53L1_DEVICESTATE_RANGING_OUTPUT_DATA ((VL53L1_DeviceState) 8)
|
||||
|
||||
#define VL53L1_DEVICESTATE_UNKNOWN ((VL53L1_DeviceState) 98)
|
||||
#define VL53L1_DEVICESTATE_ERROR ((VL53L1_DeviceState) 99)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_DeviceZonePreset;
|
||||
|
||||
#define VL53L1_DEVICEZONEPRESET_NONE ((VL53L1_DeviceZonePreset) 0)
|
||||
|
||||
#define VL53L1_DEVICEZONEPRESET_XTALK_PLANAR ((VL53L1_DeviceZonePreset) 1)
|
||||
#define VL53L1_DEVICEZONEPRESET_1X1_SIZE_16X16 ((VL53L1_DeviceZonePreset) 2)
|
||||
#define VL53L1_DEVICEZONEPRESET_1X2_SIZE_16X8 ((VL53L1_DeviceZonePreset) 3)
|
||||
#define VL53L1_DEVICEZONEPRESET_2X1_SIZE_8X16 ((VL53L1_DeviceZonePreset) 4)
|
||||
#define VL53L1_DEVICEZONEPRESET_2X2_SIZE_8X8 ((VL53L1_DeviceZonePreset) 5)
|
||||
#define VL53L1_DEVICEZONEPRESET_3X3_SIZE_5X5 ((VL53L1_DeviceZonePreset) 6)
|
||||
#define VL53L1_DEVICEZONEPRESET_4X4_SIZE_4X4 ((VL53L1_DeviceZonePreset) 7)
|
||||
#define VL53L1_DEVICEZONEPRESET_5X5_SIZE_4X4 ((VL53L1_DeviceZonePreset) 8)
|
||||
#define VL53L1_DEVICEZONEPRESET_11X11_SIZE_5X5 ((VL53L1_DeviceZonePreset) 9)
|
||||
#define VL53L1_DEVICEZONEPRESET_13X13_SIZE_4X4 ((VL53L1_DeviceZonePreset) 10)
|
||||
|
||||
#define VL53L1_DEVICEZONEPRESET_1X1_SIZE_4X4_POS_8X8 ((VL53L1_DeviceZonePreset) 11)
|
||||
|
||||
#define VL53L1_DEVICEZONEPRESET_CUSTOM ((VL53L1_DeviceZonePreset) 255)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_DevicePresetModes;
|
||||
|
||||
#define VL53L1_DEVICEPRESETMODE_NONE ((VL53L1_DevicePresetModes) 0)
|
||||
#define VL53L1_DEVICEPRESETMODE_STANDARD_RANGING ((VL53L1_DevicePresetModes) 1)
|
||||
#define VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_SHORT_RANGE ((VL53L1_DevicePresetModes) 2)
|
||||
#define VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_LONG_RANGE ((VL53L1_DevicePresetModes) 3)
|
||||
#define VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM1_CAL ((VL53L1_DevicePresetModes) 4)
|
||||
#define VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM2_CAL ((VL53L1_DevicePresetModes) 5)
|
||||
#define VL53L1_DEVICEPRESETMODE_TIMED_RANGING ((VL53L1_DevicePresetModes) 6)
|
||||
#define VL53L1_DEVICEPRESETMODE_TIMED_RANGING_SHORT_RANGE ((VL53L1_DevicePresetModes) 7)
|
||||
#define VL53L1_DEVICEPRESETMODE_TIMED_RANGING_LONG_RANGE ((VL53L1_DevicePresetModes) 8)
|
||||
#define VL53L1_DEVICEPRESETMODE_NEAR_FARRANGING ((VL53L1_DevicePresetModes) 9)
|
||||
#define VL53L1_DEVICEPRESETMODE_QUADRANT_RANGING ((VL53L1_DevicePresetModes) 10)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_RANGING ((VL53L1_DevicePresetModes) 11)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_RANGING_SHORT_TIMING ((VL53L1_DevicePresetModes) 12)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_CHARACTERISATION ((VL53L1_DevicePresetModes) 13)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_XTALK_PLANAR ((VL53L1_DevicePresetModes) 14)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_XTALK_MM1 ((VL53L1_DevicePresetModes) 15)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_XTALK_MM2 ((VL53L1_DevicePresetModes) 16)
|
||||
#define VL53L1_DEVICEPRESETMODE_OLT ((VL53L1_DevicePresetModes) 17)
|
||||
#define VL53L1_DEVICEPRESETMODE_SINGLESHOT_RANGING ((VL53L1_DevicePresetModes) 18)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_REF_ARRAY ((VL53L1_DevicePresetModes) 19)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_RANGING_WITH_MM1 ((VL53L1_DevicePresetModes) 20)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_RANGING_WITH_MM2 ((VL53L1_DevicePresetModes) 21)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_RANGING_MM1_CAL ((VL53L1_DevicePresetModes) 22)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_RANGING_MM2_CAL ((VL53L1_DevicePresetModes) 23)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_MULTIZONE ((VL53L1_DevicePresetModes) 24)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_MULTIZONE_SHORT_RANGE ((VL53L1_DevicePresetModes) 25)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_MULTIZONE_LONG_RANGE ((VL53L1_DevicePresetModes) 26)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_LONG_RANGE ((VL53L1_DevicePresetModes) 27)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_LONG_RANGE_MM1 ((VL53L1_DevicePresetModes) 28)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_LONG_RANGE_MM2 ((VL53L1_DevicePresetModes) 29)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_MEDIUM_RANGE ((VL53L1_DevicePresetModes) 30)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_MEDIUM_RANGE_MM1 ((VL53L1_DevicePresetModes) 31)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_MEDIUM_RANGE_MM2 ((VL53L1_DevicePresetModes) 32)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_SHORT_RANGE ((VL53L1_DevicePresetModes) 33)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_SHORT_RANGE_MM1 ((VL53L1_DevicePresetModes) 34)
|
||||
#define VL53L1_DEVICEPRESETMODE_HISTOGRAM_SHORT_RANGE_MM2 ((VL53L1_DevicePresetModes) 35)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_DeviceMeasurementModes;
|
||||
|
||||
#define VL53L1_DEVICEMEASUREMENTMODE_STOP ((VL53L1_DeviceMeasurementModes) 0x00)
|
||||
#define VL53L1_DEVICEMEASUREMENTMODE_SINGLESHOT ((VL53L1_DeviceMeasurementModes) 0x10)
|
||||
#define VL53L1_DEVICEMEASUREMENTMODE_BACKTOBACK ((VL53L1_DeviceMeasurementModes) 0x20)
|
||||
#define VL53L1_DEVICEMEASUREMENTMODE_TIMED ((VL53L1_DeviceMeasurementModes) 0x40)
|
||||
#define VL53L1_DEVICEMEASUREMENTMODE_ABORT ((VL53L1_DeviceMeasurementModes) 0x80)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_OffsetCalibrationMode;
|
||||
|
||||
#define VL53L1_OFFSETCALIBRATIONMODE__NONE ((VL53L1_OffsetCalibrationMode) 0)
|
||||
#define VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD ((VL53L1_OffsetCalibrationMode) 1)
|
||||
#define VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__HISTOGRAM ((VL53L1_OffsetCalibrationMode) 2)
|
||||
#define VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD_PRE_RANGE_ONLY ((VL53L1_OffsetCalibrationMode) 3)
|
||||
#define VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__HISTOGRAM_PRE_RANGE_ONLY ((VL53L1_OffsetCalibrationMode) 4)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_OffsetCorrectionMode;
|
||||
|
||||
#define VL53L1_OFFSETCORRECTIONMODE__NONE ((VL53L1_OffsetCorrectionMode) 0)
|
||||
#define VL53L1_OFFSETCORRECTIONMODE__MM1_MM2_OFFSETS ((VL53L1_OffsetCorrectionMode) 1)
|
||||
#define VL53L1_OFFSETCORRECTIONMODE__PER_ZONE_OFFSETS ((VL53L1_OffsetCorrectionMode) 2)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_DeviceDmaxMode;
|
||||
|
||||
#define VL53L1_DEVICEDMAXMODE__NONE ((VL53L1_DeviceDmaxMode) 0)
|
||||
#define VL53L1_DEVICEDMAXMODE__FMT_CAL_DATA ((VL53L1_DeviceDmaxMode) 1)
|
||||
#define VL53L1_DEVICEDMAXMODE__CUST_CAL_DATA ((VL53L1_DeviceDmaxMode) 2)
|
||||
#define VL53L1_DEVICEDMAXMODE__PER_ZONE_CAL_DATA ((VL53L1_DeviceDmaxMode) 3)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_DeviceSequenceConfig;
|
||||
|
||||
#define VL53L1_DEVICESEQUENCECONFIG_VHV ((VL53L1_DeviceSequenceConfig) 0)
|
||||
#define VL53L1_DEVICESEQUENCECONFIG_PHASECAL ((VL53L1_DeviceSequenceConfig) 1)
|
||||
#define VL53L1_DEVICESEQUENCECONFIG_REFERENCE_PHASE ((VL53L1_DeviceSequenceConfig) 2)
|
||||
#define VL53L1_DEVICESEQUENCECONFIG_DSS1 ((VL53L1_DeviceSequenceConfig) 3)
|
||||
#define VL53L1_DEVICESEQUENCECONFIG_DSS2 ((VL53L1_DeviceSequenceConfig) 4)
|
||||
#define VL53L1_DEVICESEQUENCECONFIG_MM1 ((VL53L1_DeviceSequenceConfig) 5)
|
||||
#define VL53L1_DEVICESEQUENCECONFIG_MM2 ((VL53L1_DeviceSequenceConfig) 6)
|
||||
#define VL53L1_DEVICESEQUENCECONFIG_RANGE ((VL53L1_DeviceSequenceConfig) 7)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_DeviceInterruptPolarity;
|
||||
|
||||
#define VL53L1_DEVICEINTERRUPTPOLARITY_ACTIVE_HIGH ((VL53L1_DeviceInterruptPolarity) 0x00)
|
||||
#define VL53L1_DEVICEINTERRUPTPOLARITY_ACTIVE_LOW ((VL53L1_DeviceInterruptPolarity) 0x10)
|
||||
#define VL53L1_DEVICEINTERRUPTPOLARITY_BIT_MASK ((VL53L1_DeviceInterruptPolarity) 0x10)
|
||||
#define VL53L1_DEVICEINTERRUPTPOLARITY_CLEAR_MASK ((VL53L1_DeviceInterruptPolarity) 0xEF)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_DeviceGpioMode;
|
||||
|
||||
#define VL53L1_DEVICEGPIOMODE_OUTPUT_CONSTANT_ZERO ((VL53L1_DeviceGpioMode) 0x00)
|
||||
#define VL53L1_DEVICEGPIOMODE_OUTPUT_RANGE_AND_ERROR_INTERRUPTS ((VL53L1_DeviceGpioMode) 0x01)
|
||||
#define VL53L1_DEVICEGPIOMODE_OUTPUT_TIMIER_INTERRUPTS ((VL53L1_DeviceGpioMode) 0x02)
|
||||
#define VL53L1_DEVICEGPIOMODE_OUTPUT_RANGE_MODE_INTERRUPT_STATUS ((VL53L1_DeviceGpioMode) 0x03)
|
||||
#define VL53L1_DEVICEGPIOMODE_OUTPUT_SLOW_OSCILLATOR_CLOCK ((VL53L1_DeviceGpioMode) 0x04)
|
||||
#define VL53L1_DEVICEGPIOMODE_BIT_MASK ((VL53L1_DeviceGpioMode) 0x0F)
|
||||
#define VL53L1_DEVICEGPIOMODE_CLEAR_MASK ((VL53L1_DeviceGpioMode) 0xF0)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_DeviceError;
|
||||
|
||||
#define VL53L1_DEVICEERROR_NOUPDATE ((VL53L1_DeviceError) 0)
|
||||
|
||||
|
||||
#define VL53L1_DEVICEERROR_VCSELCONTINUITYTESTFAILURE ((VL53L1_DeviceError) 1)
|
||||
#define VL53L1_DEVICEERROR_VCSELWATCHDOGTESTFAILURE ((VL53L1_DeviceError) 2)
|
||||
#define VL53L1_DEVICEERROR_NOVHVVALUEFOUND ((VL53L1_DeviceError) 3)
|
||||
#define VL53L1_DEVICEERROR_MSRCNOTARGET ((VL53L1_DeviceError) 4)
|
||||
#define VL53L1_DEVICEERROR_RANGEPHASECHECK ((VL53L1_DeviceError) 5)
|
||||
#define VL53L1_DEVICEERROR_SIGMATHRESHOLDCHECK ((VL53L1_DeviceError) 6)
|
||||
#define VL53L1_DEVICEERROR_PHASECONSISTENCY ((VL53L1_DeviceError) 7)
|
||||
#define VL53L1_DEVICEERROR_MINCLIP ((VL53L1_DeviceError) 8)
|
||||
#define VL53L1_DEVICEERROR_RANGECOMPLETE ((VL53L1_DeviceError) 9)
|
||||
#define VL53L1_DEVICEERROR_ALGOUNDERFLOW ((VL53L1_DeviceError) 10)
|
||||
#define VL53L1_DEVICEERROR_ALGOOVERFLOW ((VL53L1_DeviceError) 11)
|
||||
#define VL53L1_DEVICEERROR_RANGEIGNORETHRESHOLD ((VL53L1_DeviceError) 12)
|
||||
#define VL53L1_DEVICEERROR_USERROICLIP ((VL53L1_DeviceError) 13)
|
||||
#define VL53L1_DEVICEERROR_REFSPADCHARNOTENOUGHDPADS ((VL53L1_DeviceError) 14)
|
||||
#define VL53L1_DEVICEERROR_REFSPADCHARMORETHANTARGET ((VL53L1_DeviceError) 15)
|
||||
#define VL53L1_DEVICEERROR_REFSPADCHARLESSTHANTARGET ((VL53L1_DeviceError) 16)
|
||||
#define VL53L1_DEVICEERROR_MULTCLIPFAIL ((VL53L1_DeviceError) 17)
|
||||
#define VL53L1_DEVICEERROR_GPHSTREAMCOUNT0READY ((VL53L1_DeviceError) 18)
|
||||
#define VL53L1_DEVICEERROR_RANGECOMPLETE_NO_WRAP_CHECK ((VL53L1_DeviceError) 19)
|
||||
#define VL53L1_DEVICEERROR_EVENTCONSISTENCY ((VL53L1_DeviceError) 20)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_DeviceReportStatus;
|
||||
|
||||
#define VL53L1_DEVICEREPORTSTATUS_NOUPDATE ((VL53L1_DeviceReportStatus) 0)
|
||||
|
||||
|
||||
#define VL53L1_DEVICEREPORTSTATUS_ROI_SETUP ((VL53L1_DeviceReportStatus) 1)
|
||||
#define VL53L1_DEVICEREPORTSTATUS_VHV ((VL53L1_DeviceReportStatus) 2)
|
||||
#define VL53L1_DEVICEREPORTSTATUS_PHASECAL ((VL53L1_DeviceReportStatus) 3)
|
||||
#define VL53L1_DEVICEREPORTSTATUS_REFERENCE_PHASE ((VL53L1_DeviceReportStatus) 4)
|
||||
#define VL53L1_DEVICEREPORTSTATUS_DSS1 ((VL53L1_DeviceReportStatus) 5)
|
||||
#define VL53L1_DEVICEREPORTSTATUS_DSS2 ((VL53L1_DeviceReportStatus) 6)
|
||||
#define VL53L1_DEVICEREPORTSTATUS_MM1 ((VL53L1_DeviceReportStatus) 7)
|
||||
#define VL53L1_DEVICEREPORTSTATUS_MM2 ((VL53L1_DeviceReportStatus) 8)
|
||||
#define VL53L1_DEVICEREPORTSTATUS_RANGE ((VL53L1_DeviceReportStatus) 9)
|
||||
#define VL53L1_DEVICEREPORTSTATUS_HISTOGRAM ((VL53L1_DeviceReportStatus) 10)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_DeviceDssMode;
|
||||
|
||||
#define VL53L1_DEVICEDSSMODE__DISABLED \
|
||||
((VL53L1_DeviceDssMode) 0)
|
||||
#define VL53L1_DEVICEDSSMODE__TARGET_RATE \
|
||||
((VL53L1_DeviceDssMode) 1)
|
||||
#define VL53L1_DEVICEDSSMODE__REQUESTED_EFFFECTIVE_SPADS \
|
||||
((VL53L1_DeviceDssMode) 2)
|
||||
#define VL53L1_DEVICEDSSMODE__BLOCK_SELECT \
|
||||
((VL53L1_DeviceDssMode) 3)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_HistAlgoSelect;
|
||||
|
||||
#define VL53L1_HIST_ALGO_SELECT__PW_HIST_GEN1 \
|
||||
((VL53L1_HistAlgoSelect) 1)
|
||||
#define VL53L1_HIST_ALGO_SELECT__PW_HIST_GEN2 \
|
||||
((VL53L1_HistAlgoSelect) 2)
|
||||
#define VL53L1_HIST_ALGO_SELECT__PW_HIST_GEN3 \
|
||||
((VL53L1_HistAlgoSelect) 3)
|
||||
#define VL53L1_HIST_ALGO_SELECT__PW_HIST_GEN4 \
|
||||
((VL53L1_HistAlgoSelect) 4)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_HistTargetOrder;
|
||||
|
||||
#define VL53L1_HIST_TARGET_ORDER__INCREASING_DISTANCE \
|
||||
((VL53L1_HistTargetOrder) 1)
|
||||
#define VL53L1_HIST_TARGET_ORDER__STRONGEST_FIRST \
|
||||
((VL53L1_HistTargetOrder) 2)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_HistAmbEstMethod;
|
||||
|
||||
#define VL53L1_HIST_AMB_EST_METHOD__AMBIENT_BINS \
|
||||
((VL53L1_HistAmbEstMethod) 1)
|
||||
#define VL53L1_HIST_AMB_EST_METHOD__THRESHOLDED_BINS \
|
||||
((VL53L1_HistAmbEstMethod) 2)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_HistXtalkCompEnable;
|
||||
|
||||
#define VL53L1_HIST_XTALK_COMP__DIS \
|
||||
((VL53L1_HistXtalkCompEnable) 0)
|
||||
#define VL53L1_HIST_XTALK_COMP__EN \
|
||||
((VL53L1_HistXtalkCompEnable) 1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_DeviceConfigLevel;
|
||||
|
||||
#define VL53L1_DEVICECONFIGLEVEL_SYSTEM_CONTROL \
|
||||
((VL53L1_DeviceConfigLevel) 0)
|
||||
|
||||
|
||||
#define VL53L1_DEVICECONFIGLEVEL_DYNAMIC_ONWARDS \
|
||||
((VL53L1_DeviceConfigLevel) 1)
|
||||
|
||||
|
||||
#define VL53L1_DEVICECONFIGLEVEL_TIMING_ONWARDS \
|
||||
((VL53L1_DeviceConfigLevel) 2)
|
||||
|
||||
|
||||
|
||||
#define VL53L1_DEVICECONFIGLEVEL_GENERAL_ONWARDS \
|
||||
((VL53L1_DeviceConfigLevel) 3)
|
||||
|
||||
|
||||
|
||||
#define VL53L1_DEVICECONFIGLEVEL_STATIC_ONWARDS \
|
||||
((VL53L1_DeviceConfigLevel) 4)
|
||||
|
||||
|
||||
|
||||
#define VL53L1_DEVICECONFIGLEVEL_CUSTOMER_ONWARDS \
|
||||
((VL53L1_DeviceConfigLevel) 5)
|
||||
|
||||
|
||||
|
||||
#define VL53L1_DEVICECONFIGLEVEL_FULL \
|
||||
((VL53L1_DeviceConfigLevel) 6)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_DeviceResultsLevel;
|
||||
|
||||
#define VL53L1_DEVICERESULTSLEVEL_SYSTEM_RESULTS \
|
||||
((VL53L1_DeviceResultsLevel) 0)
|
||||
|
||||
|
||||
#define VL53L1_DEVICERESULTSLEVEL_UPTO_CORE \
|
||||
((VL53L1_DeviceResultsLevel) 1)
|
||||
|
||||
|
||||
#define VL53L1_DEVICERESULTSLEVEL_FULL \
|
||||
((VL53L1_DeviceResultsLevel) 2)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_DeviceTestMode;
|
||||
|
||||
#define VL53L1_DEVICETESTMODE_NONE \
|
||||
((VL53L1_DeviceTestMode) 0x00)
|
||||
|
||||
|
||||
#define VL53L1_DEVICETESTMODE_NVM_ZERO \
|
||||
((VL53L1_DeviceTestMode) 0x01)
|
||||
|
||||
|
||||
#define VL53L1_DEVICETESTMODE_NVM_COPY \
|
||||
((VL53L1_DeviceTestMode) 0x02)
|
||||
|
||||
|
||||
#define VL53L1_DEVICETESTMODE_PATCH \
|
||||
((VL53L1_DeviceTestMode) 0x03)
|
||||
|
||||
|
||||
#define VL53L1_DEVICETESTMODE_DCR \
|
||||
((VL53L1_DeviceTestMode) 0x04)
|
||||
|
||||
|
||||
#define VL53L1_DEVICETESTMODE_LCR_VCSEL_OFF \
|
||||
((VL53L1_DeviceTestMode) 0x05)
|
||||
|
||||
|
||||
|
||||
#define VL53L1_DEVICETESTMODE_LCR_VCSEL_ON \
|
||||
((VL53L1_DeviceTestMode) 0x06)
|
||||
|
||||
|
||||
|
||||
#define VL53L1_DEVICETESTMODE_SPOT_CENTRE_LOCATE \
|
||||
((VL53L1_DeviceTestMode) 0x07)
|
||||
|
||||
|
||||
#define VL53L1_DEVICETESTMODE_REF_SPAD_CHAR_WITH_PRE_VHV \
|
||||
((VL53L1_DeviceTestMode) 0x08)
|
||||
|
||||
|
||||
#define VL53L1_DEVICETESTMODE_REF_SPAD_CHAR_ONLY \
|
||||
((VL53L1_DeviceTestMode) 0x09)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_DeviceSscArray;
|
||||
|
||||
#define VL53L1_DEVICESSCARRAY_RTN ((VL53L1_DeviceSscArray) 0x00)
|
||||
|
||||
|
||||
#define VL53L1_DEVICETESTMODE_REF ((VL53L1_DeviceSscArray) 0x01)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_RETURN_ARRAY_ONLY 0x01
|
||||
|
||||
|
||||
#define VL53L1_REFERENCE_ARRAY_ONLY 0x10
|
||||
|
||||
|
||||
#define VL53L1_BOTH_RETURN_AND_REFERENCE_ARRAYS 0x11
|
||||
|
||||
|
||||
#define VL53L1_NEITHER_RETURN_AND_REFERENCE_ARRAYS 0x00
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_HIGH 0x00
|
||||
|
||||
|
||||
#define VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_LOW 0x10
|
||||
|
||||
|
||||
#define VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_MASK 0x10
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_POLLING_DELAY_US 1000
|
||||
|
||||
|
||||
#define VL53L1_SOFTWARE_RESET_DURATION_US 100
|
||||
|
||||
|
||||
#define VL53L1_FIRMWARE_BOOT_TIME_US 1200
|
||||
|
||||
|
||||
|
||||
#define VL53L1_ENABLE_POWERFORCE_SETTLING_TIME_US 250
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_SPAD_ARRAY_WIDTH 16
|
||||
|
||||
|
||||
#define VL53L1_SPAD_ARRAY_HEIGHT 16
|
||||
|
||||
|
||||
#define VL53L1_NVM_SIZE_IN_BYTES 512
|
||||
|
||||
|
||||
#define VL53L1_NO_OF_SPAD_ENABLES 256
|
||||
|
||||
|
||||
#define VL53L1_RTN_SPAD_BUFFER_SIZE 32
|
||||
|
||||
|
||||
#define VL53L1_REF_SPAD_BUFFER_SIZE 6
|
||||
|
||||
|
||||
#define VL53L1_AMBIENT_WINDOW_VCSEL_PERIODS 256
|
||||
|
||||
|
||||
#define VL53L1_RANGING_WINDOW_VCSEL_PERIODS 2048
|
||||
|
||||
|
||||
#define VL53L1_MACRO_PERIOD_VCSEL_PERIODS \
|
||||
(VL53L1_AMBIENT_WINDOW_VCSEL_PERIODS + VL53L1_RANGING_WINDOW_VCSEL_PERIODS)
|
||||
|
||||
|
||||
#define VL53L1_MAX_ALLOWED_PHASE 0xFFFF
|
||||
|
||||
|
||||
|
||||
#define VL53L1_RTN_SPAD_UNITY_TRANSMISSION 0x0100
|
||||
|
||||
|
||||
#define VL53L1_RTN_SPAD_APERTURE_TRANSMISSION 0x0038
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define VL53L1_SPAD_TOTAL_COUNT_MAX ((0x01 << 29) - 1)
|
||||
|
||||
|
||||
#define VL53L1_SPAD_TOTAL_COUNT_RES_THRES (0x01 << 24)
|
||||
|
||||
|
||||
#define VL53L1_COUNT_RATE_INTERNAL_MAX ((0x01 << 24) - 1)
|
||||
|
||||
|
||||
#define VL53L1_SPEED_OF_LIGHT_IN_AIR 299704
|
||||
|
||||
|
||||
#define VL53L1_SPEED_OF_LIGHT_IN_AIR_DIV_8 (299704 >> 3)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_ZoneConfig_BinConfig_select;
|
||||
|
||||
#define VL53L1_ZONECONFIG_BINCONFIG__LOWAMB \
|
||||
((VL53L1_ZoneConfig_BinConfig_select) 1)
|
||||
#define VL53L1_ZONECONFIG_BINCONFIG__MIDAMB \
|
||||
((VL53L1_ZoneConfig_BinConfig_select) 2)
|
||||
#define VL53L1_ZONECONFIG_BINCONFIG__HIGHAMB \
|
||||
((VL53L1_ZoneConfig_BinConfig_select) 3)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef uint8_t VL53L1_GPIO_Interrupt_Mode;
|
||||
|
||||
#define VL53L1_GPIOINTMODE_LEVEL_LOW \
|
||||
((VL53L1_GPIO_Interrupt_Mode) 0)
|
||||
|
||||
|
||||
#define VL53L1_GPIOINTMODE_LEVEL_HIGH \
|
||||
((VL53L1_GPIO_Interrupt_Mode) 1)
|
||||
|
||||
|
||||
#define VL53L1_GPIOINTMODE_OUT_OF_WINDOW \
|
||||
((VL53L1_GPIO_Interrupt_Mode) 2)
|
||||
|
||||
|
||||
#define VL53L1_GPIOINTMODE_IN_WINDOW \
|
||||
((VL53L1_GPIO_Interrupt_Mode) 3)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,422 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _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_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_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
|
||||
|
||||
|
|
@ -1,201 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _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
|
||||
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,804 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _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_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
|
||||
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,273 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,133 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _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
|
||||
|
||||
|
||||
|
|
@ -1,318 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _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
|
||||
|
||||
|
||||
|
|
@ -1,182 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _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
|
||||
|
||||
|
||||
|
|
@ -1,343 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file 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;
|
||||
}
|
||||
BUG_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;
|
||||
}
|
||||
BUG_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[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,
|
||||
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;
|
||||
|
||||
/* setup pin */
|
||||
IPP_SERIALIZE_START(pin->data, 5);
|
||||
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);
|
||||
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;
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,333 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "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
|
||||
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
|
||||
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
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,931 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "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("");
|
||||
|
||||
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_PRM_00009,
|
||||
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_PRM_00009
|
||||
* 1000 * 256);
|
||||
|
||||
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_PRM_00013 = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
period = 2048 *
|
||||
(uint32_t)VL53L1_decode_vcsel_period(pdata->VL53L1_PRM_00007);
|
||||
|
||||
VL53L1_PRM_00013 = period;
|
||||
VL53L1_PRM_00013 += (uint32_t)pdata->phasecal_result__reference_phase;
|
||||
VL53L1_PRM_00013 += (2048 * (uint32_t)pdata->phasecal_result__vcsel_start);
|
||||
VL53L1_PRM_00013 -= (2048 * (uint32_t)pdata->cal_config__vcsel_start);
|
||||
|
||||
VL53L1_PRM_00013 = VL53L1_PRM_00013 % period;
|
||||
|
||||
pdata->zero_distance_phase = (uint16_t)VL53L1_PRM_00013;
|
||||
|
||||
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_PRM_00029 = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_hist_find_min_max_bin_values(pdata);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VL53L1_PRM_00029 = (int32_t)VL53L1_isqrt((uint32_t)pdata->min_bin_value);
|
||||
VL53L1_PRM_00029 *= ambient_threshold_sigma;
|
||||
VL53L1_PRM_00029 += 0x07;
|
||||
VL53L1_PRM_00029 = VL53L1_PRM_00029 >> 4;
|
||||
VL53L1_PRM_00029 += pdata->min_bin_value;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pdata->number_of_ambient_samples = 0;
|
||||
pdata->ambient_events_sum = 0;
|
||||
|
||||
for (bin = 0 ; bin < pdata->VL53L1_PRM_00017 ; bin++) {
|
||||
if (pdata->bin_data[bin] < VL53L1_PRM_00029) {
|
||||
pdata->ambient_events_sum += pdata->bin_data[bin];
|
||||
pdata->number_of_ambient_samples++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (pdata->number_of_ambient_samples > 0) {
|
||||
pdata->VL53L1_PRM_00026 = pdata->ambient_events_sum;
|
||||
pdata->VL53L1_PRM_00026 += ((int32_t)pdata->number_of_ambient_samples/2);
|
||||
pdata->VL53L1_PRM_00026 /= (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 VL53L1_PRM_00001 = 0;
|
||||
uint8_t i = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
if ((pdata->bin_seq[0] & 0x07) == 0x07) {
|
||||
|
||||
i = 0;
|
||||
for (VL53L1_PRM_00001 = 0 ; VL53L1_PRM_00001 < VL53L1_MAX_BIN_SEQUENCE_LENGTH ; VL53L1_PRM_00001++) {
|
||||
if ((pdata->bin_seq[VL53L1_PRM_00001] & 0x07) != 0x07) {
|
||||
pdata->bin_seq[i] = pdata->bin_seq[VL53L1_PRM_00001];
|
||||
pdata->bin_rep[i] = pdata->bin_rep[VL53L1_PRM_00001];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (VL53L1_PRM_00001 = i ; VL53L1_PRM_00001 < VL53L1_MAX_BIN_SEQUENCE_LENGTH ; VL53L1_PRM_00001++) {
|
||||
pdata->bin_seq[VL53L1_PRM_00001] = VL53L1_MAX_BIN_SEQUENCE_CODE + 1;
|
||||
pdata->bin_rep[VL53L1_PRM_00001] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (pdata->number_of_ambient_bins > 0) {
|
||||
|
||||
|
||||
|
||||
for (bin = pdata->number_of_ambient_bins ;
|
||||
bin < pdata->VL53L1_PRM_00016 ; bin++) {
|
||||
pdata->bin_data[bin-pdata->number_of_ambient_bins] =
|
||||
pdata->bin_data[bin];
|
||||
}
|
||||
|
||||
|
||||
|
||||
pdata->VL53L1_PRM_00017 =
|
||||
pdata->VL53L1_PRM_00017 -
|
||||
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_PRM_00006,
|
||||
uint32_t time_us)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t tmp_int = 0;
|
||||
uint32_t frac_bits = 7;
|
||||
uint16_t rate_mcps = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (VL53L1_PRM_00006 > VL53L1_SPAD_TOTAL_COUNT_MAX) {
|
||||
tmp_int = VL53L1_SPAD_TOTAL_COUNT_MAX;
|
||||
} else if (VL53L1_PRM_00006 > 0) {
|
||||
tmp_int = (uint32_t)VL53L1_PRM_00006;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (VL53L1_PRM_00006 > 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_PRM_00006 > 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_PRM_00013,
|
||||
uint16_t zero_distance_phase,
|
||||
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;
|
||||
|
||||
|
||||
|
||||
|
||||
pll_period_us = VL53L1_calc_pll_period_us(fast_osc_frequency);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
tmp_long_int = (int64_t)VL53L1_PRM_00013 - (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;
|
||||
|
||||
|
||||
|
||||
range_mm = range_mm / (0x01 << 2);
|
||||
|
||||
return range_mm;
|
||||
}
|
||||
|
||||
|
||||
uint8_t VL53L1_decode_vcsel_period(uint8_t vcsel_period_reg)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint8_t VL53L1_PRM_00028 = 0;
|
||||
|
||||
VL53L1_PRM_00028 = (vcsel_period_reg + 1) << 1;
|
||||
|
||||
return VL53L1_PRM_00028;
|
||||
}
|
||||
|
||||
|
||||
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_PRM_00018 =
|
||||
pxtalk->VL53L1_PRM_00018;
|
||||
phist->VL53L1_PRM_00015 =
|
||||
pxtalk->VL53L1_PRM_00015;
|
||||
|
||||
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_PRM_00016 = pxtalk->VL53L1_PRM_00016;
|
||||
phist->time_stamp = pxtalk->time_stamp;
|
||||
}
|
||||
|
||||
|
||||
void VL53L1_init_histogram_bin_data_struct(
|
||||
int32_t bin_value,
|
||||
uint16_t VL53L1_PRM_00017,
|
||||
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_PRM_00015 = 0;
|
||||
pdata->VL53L1_PRM_00016 = VL53L1_HISTOGRAM_BUFFER_SIZE;
|
||||
pdata->VL53L1_PRM_00017 = (uint8_t)VL53L1_PRM_00017;
|
||||
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_PRM_00007 = 0;
|
||||
pdata->VL53L1_PRM_00018 = 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_PRM_00026 = 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_PRM_00017) {
|
||||
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_PRM_00017 ; 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_PRM_00026 = pdata->ambient_events_sum;
|
||||
pdata->VL53L1_PRM_00026 +=
|
||||
((int32_t)pdata->number_of_ambient_bins / 2);
|
||||
pdata->VL53L1_PRM_00026 /=
|
||||
(int32_t)pdata->number_of_ambient_bins;
|
||||
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(0);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,327 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -1,167 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_platform.h"
|
||||
#include "vl53l1_register_map.h"
|
||||
#include "vl53l1_core.h"
|
||||
#include "vl53l1_fpga_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_fpga(
|
||||
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) {
|
||||
|
||||
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->dbg_results.interrupt_manager__enables & 0x1F) == 0x1F) &&
|
||||
((pdev->dbg_results.interrupt_manager__clear & 0x1F) == 0x1F))
|
||||
*pready = 0x01;
|
||||
else
|
||||
*pready = 0x00;
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
@ -1,282 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <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("");
|
||||
|
||||
|
||||
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,180 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "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) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
@ -1,627 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_ll_device.h"
|
||||
#include "vl53l1_platform.h"
|
||||
#include "vl53l1_core.h"
|
||||
#include "vl53l1_fpga_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("");
|
||||
|
||||
if (pdev->fpga_system > 0)
|
||||
status = VL53L1_is_firmware_ready_fpga(
|
||||
Dev,
|
||||
pready);
|
||||
else
|
||||
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(&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(¤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;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,253 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* This file is part of VL53L1 Core 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/sla0044
|
||||
*
|
||||
* STMicroelectronics confidential
|
||||
* Reproduction and Communication of this document is strictly prohibited unless
|
||||
* specifically authorized in writing by STMicroelectronics.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* Alternatively, VL53L1 Core may be distributed under the terms of
|
||||
* 'BSD 3-clause "New" or "Revised" License', in which case the following
|
||||
* provisions apply instead of the ones
|
||||
* mentioned above :
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
********************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "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++;
|
||||
}
|
||||
}
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
|
||||
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;
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/** @file 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 *);
|
||||
int stmvl53l1_power_up_i2c(void *);
|
||||
int stmvl53l1_power_down_i2c(void *);
|
||||
int stmvl53l1_reset_release_i2c(void *);
|
||||
int stmvl53l1_reset_hold_i2c(void *);
|
||||
void stmvl53l1_clean_up_i2c(void);
|
||||
int stmvl53l1_start_intr(void *object, int *poll_mode);
|
||||
void *stmvl53l1_get(void *);
|
||||
void stmvl53l1_put(void *);
|
||||
|
||||
#endif /* STMVL53L1_I2C_H */
|
||||
|
|
@ -1,379 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
*License terms : BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**
|
||||
* @file 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"
|
||||
|
||||
/**
|
||||
* IPP adapt
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
# define IPP_PRINT(...) printk(__VA_ARGS__)
|
||||
#else
|
||||
# define IPP_PRINT(...) (void)0
|
||||
#endif
|
||||
|
||||
#include "stmvl53l1_ipp.h"
|
||||
#include "stmvl53l1_if.h"
|
||||
|
||||
/**
|
||||
* Configure the Netlink-id use
|
||||
*/
|
||||
#define STMVL531_CFG_NETLINK_USER 23
|
||||
|
||||
#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 "8.0.0_b4.1._1268"
|
||||
|
||||
/** @ingroup vl53l1_config
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Configure max number of device the driver can support
|
||||
*/
|
||||
#define STMVL53L1_CFG_MAX_DEV 2
|
||||
/** @ingroup vl53l1_mod_dbg
|
||||
* @{
|
||||
*/
|
||||
#if 1
|
||||
#define DEBUG 1
|
||||
#endif
|
||||
#if 0
|
||||
#define FORCE_CONSOLE_DEBUG
|
||||
#endif
|
||||
|
||||
extern int stmvl53l1_enable_debug;
|
||||
|
||||
#ifdef DEBUG
|
||||
# ifdef FORCE_CONSOLE_DEBUG
|
||||
#define vl53l1_dbgmsg(str, ...) do { \
|
||||
if (stmvl53l1_enable_debug) \
|
||||
pr_info("%s: " str, __func__, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
# else
|
||||
#define vl53l1_dbgmsg(str, ...) do { \
|
||||
if (stmvl53l1_enable_debug) \
|
||||
pr_debug("%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>
|
||||
|
||||
/** if set to 1 enable ipp execution timing (if debug enabled)
|
||||
* @ingroup vl53l1_mod_dbg
|
||||
*/
|
||||
#define IPP_LOG_TIMING 1
|
||||
|
||||
struct ipp_data_t {
|
||||
struct ipp_work_t work;
|
||||
struct ipp_work_t work_out;
|
||||
int test_n;
|
||||
int buzy; /*!< buzy state 0 is idle
|
||||
* any other value do not try to use (state value defined in source)
|
||||
*/
|
||||
int waited_xfer_id;
|
||||
/*!< when buzy is set that is the id we are expecting
|
||||
* note that value 0 is reserved and stand for "not waiting"
|
||||
* as such never id 0 will be in any round trip exchange
|
||||
* it's ok for daemon to use 0 in "ping" when it identify himself
|
||||
*/
|
||||
int status; /** if that is not 0 do not look at out work data */
|
||||
wait_queue_head_t waitq;
|
||||
/*!< ipp caller are put in that queue wait while job is posted to user
|
||||
* @warning ipp and dev mutex will be released before waiting
|
||||
* see @ref ipp_abort
|
||||
*/
|
||||
#if IPP_LOG_TIMING
|
||||
struct timeval start_tv, stop_tv;
|
||||
#endif
|
||||
};
|
||||
|
||||
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 */
|
||||
int32_t hw_rev; /*!< hardware revision number*/
|
||||
|
||||
VL53L1_DevData_t stdev; /*!<embed ST VL53L0 Dev data as "stdev" */
|
||||
|
||||
void *client_object; /*!< cci or i2c moduel i/f speficic 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;
|
||||
|
||||
/* 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 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 */
|
||||
int sar_mode; /*!< is sar mode enable/disabled */
|
||||
int cam_mode; /*!< is camera mode enable/disabled */
|
||||
VL53L1_Error last_error;/*!< last device internal error */
|
||||
/* 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 */
|
||||
|
||||
/* 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 timeval start_tv;
|
||||
struct timeval comp_tv;
|
||||
VL53L1_MultiRangingData_t multi_range_data;
|
||||
VL53L1_MultiRangingData_t tmp_range_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;
|
||||
|
||||
/* 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;
|
||||
/* Debug */
|
||||
struct ipp_data_t ipp;
|
||||
#if IPP_LOG_TIMING
|
||||
# define stmvl531_ipp_tim_stop(data)\
|
||||
do_gettimeofday(&data->ipp.stop_tv)
|
||||
# define stmvl531_ipp_tim_start(data)\
|
||||
do_gettimeofday(&data->ipp.start_tv)
|
||||
# define stmvl531_ipp_time(data)\
|
||||
stmvl53l1_tv_dif(&data->ipp.start_tv, &data->ipp.stop_tv)
|
||||
# define stmvl531_ipp_stat(data, fmt, ...)\
|
||||
vl53l1_dbgmsg("IPPSTAT " fmt "\n", ##__VA_ARGS__)
|
||||
#else
|
||||
# define stmvl531_ipp_tim_stop(data) (void)0
|
||||
# define stmvl531_ipp_tim_start(data) (void)0
|
||||
# define stmvl531_ipp_stat(...) (void)0
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* timeval diff in us
|
||||
*
|
||||
* @param pstart_tv
|
||||
* @param pstop_tv
|
||||
*/
|
||||
long stmvl53l1_tv_dif(struct timeval *pstart_tv, struct 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);
|
||||
int stmvl53l1_intr_handler(struct stmvl53l1_data *data);
|
||||
|
||||
int stmvl53l1_sysfs_laser(struct stmvl53l1_data *data, bool create);
|
||||
|
||||
/**
|
||||
* request ipp to abort or stop
|
||||
*
|
||||
* require dev work_mutex held
|
||||
*
|
||||
* @warning because the "waiting" work can't be aborted we must wake it up
|
||||
* it will happen and at some later time not earlier than release of lock
|
||||
* if after lock release we have a new request to start the race may not be
|
||||
* handled correctly
|
||||
*
|
||||
* @param data the device
|
||||
* @return 0 if no ipp got canceled, @warning this is maybe not grant we
|
||||
* can't re-sched "dev work" and re-run the worker back
|
||||
*/
|
||||
int stmvl53l1_ipp_stop(struct stmvl53l1_data *data);
|
||||
|
||||
int stmvl53l1_ipp_do(struct stmvl53l1_data *data, struct ipp_work_t *work_in,
|
||||
struct ipp_work_t *work_out);
|
||||
|
||||
/**
|
||||
* per device netlink init
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
int stmvl53l1_ipp_setup(struct stmvl53l1_data *data);
|
||||
/**
|
||||
* per device ipp netlink cleaning
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
void stmvl53l1_ipp_cleanup(struct stmvl53l1_data *data);
|
||||
|
||||
/**
|
||||
* Module init for netlink
|
||||
* @return 0 on success
|
||||
*/
|
||||
int stmvl53l1_ipp_init(void);
|
||||
|
||||
/**
|
||||
* Module exit for netlink
|
||||
* @return 0 on success
|
||||
*/
|
||||
void __exit stmvl53l1_ipp_exit(void);
|
||||
|
||||
/**
|
||||
* enable and start ipp exhange
|
||||
* @param n_dev number of device to run on
|
||||
* @param data dev struct
|
||||
* @return 0 on success
|
||||
*/
|
||||
int stmvl53l1_ipp_enable(int n_dev, struct stmvl53l1_data *data);
|
||||
|
||||
|
||||
/*
|
||||
* function pointer structs
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#endif /* STMVL53L1_H */
|
||||
|
|
@ -1,366 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file stmvl53l1_i2c.c vl53l1 linux native i2c interface
|
||||
*
|
||||
*/
|
||||
#include "stmvl53l1.h"
|
||||
#include "stmvl53l1-i2c.h"
|
||||
#include <linux/i2c.h>
|
||||
|
||||
|
||||
|
||||
#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 timeval *tv)
|
||||
{
|
||||
struct timeval now;
|
||||
|
||||
do_gettimeofday(&now);
|
||||
return (now.tv_sec - tv->tv_sec)*1000000 + (now.tv_usec - tv->tv_usec);
|
||||
}
|
||||
|
||||
# define cci_access_var struct timeval cci_log_start_tv
|
||||
# define cci_access_start()\
|
||||
do_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(uint32_t *ptime_ms)
|
||||
{
|
||||
(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 timeval *tv)
|
||||
{
|
||||
struct timeval now;
|
||||
|
||||
do_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;
|
||||
|
||||
dev = (struct stmvl53l1_data *) container_of(pdev,
|
||||
struct stmvl53l1_data, stdev);
|
||||
|
||||
return cci_write(dev, index, pdata, count) ?
|
||||
VL53L1_ERROR_CONTROL_INTERFACE : VL53L1_ERROR_NONE;
|
||||
}
|
||||
|
||||
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 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 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);
|
||||
|
||||
do_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);
|
||||
}
|
||||
|
|
@ -1,564 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
*License terms : BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @file 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
|
||||
*
|
||||
* @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 the value cannot be set while ranging will set ebusy errno,
|
||||
* value set is absorbed at next range start @ref VL53L1_IOCTL_START
|
||||
*/
|
||||
|
||||
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
|
||||
* @li 4 @a VL53L1_DISTANCEMODE_AUTO_LITE
|
||||
* @li 5 @a VL53L1_DISTANCEMODE_AUTO
|
||||
*
|
||||
* @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_CAMERAMODE_PAR = 16,
|
||||
/*!< VL53L1_CAMERAMODE_PAR
|
||||
* valid camera mode value :
|
||||
* @li 0 device is out of camera mode.
|
||||
* @li 1 device is in camera mode.
|
||||
*/
|
||||
|
||||
VL53L1_HWREV_PAR = 17,
|
||||
/*!< VL53L1_HWREV_PAR
|
||||
* This is a read only parameter. It will return HW revision number
|
||||
*/
|
||||
};
|
||||
#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*/
|
||||
stmv53l1_parameter_name_e name; /*!< [in] parameter to set/get
|
||||
* see @ref stmv53l1_parameter_name_e
|
||||
*/
|
||||
|
||||
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
|
||||
*/
|
||||
};
|
||||
|
||||
/** 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.
|
||||
*/
|
||||
#define VL53L1_CALIBRATION_CROSSTALK 1
|
||||
|
||||
/** Select offset calibration @ref VL53L1_IOCTL_PERFORM_CALIBRATION.
|
||||
* param1 is target distance in mm. param2 and
|
||||
* param3 not use.
|
||||
*/
|
||||
#define VL53L1_CALIBRATION_OFFSET 2
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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 other any possible over "st bare driver error code"
|
||||
* (shall be positive)
|
||||
*
|
||||
* 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)
|
||||
|
||||
/* Alias for VL53L1_IOCTL_START. Still present for legacy support but usage is
|
||||
* deprecated. Consider using VL53L1_IOCTL_START instead. May be removed without
|
||||
* further notice.
|
||||
*/
|
||||
#define VL53L1_IOCTL_INIT VL53L1_IOCTL_START
|
||||
|
||||
/**
|
||||
* 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 other specific error code shall be >0
|
||||
*
|
||||
* c example userland :
|
||||
@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
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @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
|
||||
* 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.
|
||||
* @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.
|
||||
* @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.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
#define VL53L1_IOCTL_CALIBRATION_DATA\
|
||||
_IOWR('p', 0x12, struct stmvl53l1_ioctl_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
|
||||
*/
|
||||
#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. 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.
|
||||
*/
|
||||
#define VL53L1_IOCTL_AUTONOMOUS_CONFIG\
|
||||
_IOWR('p', 0x14, struct stmvl53l1_autonomous_config_t)
|
||||
|
||||
/**
|
||||
* suspend 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 other specific error code shall be >0
|
||||
*
|
||||
* c example userland :
|
||||
@code
|
||||
int smtvl53l1_stop(int fd){
|
||||
int rc;
|
||||
rc= ioctl(fd, VL53L1_IOCTL_SUSPEND,NULL);
|
||||
if( rc ){
|
||||
if( errno == EBUSY ){
|
||||
ioctl_warn("already suspended");
|
||||
return errno;
|
||||
}
|
||||
ioctl_error("%d %s", rc,strerror(errno));
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
#define VL53L1_IOCTL_SUSPEND _IO('p', 0x15)
|
||||
|
||||
/** @} */ /* ioctl group */
|
||||
#endif /* STMVL53L1_IF_H */
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef 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)*/
|
||||
uint8_t bytes[256]; /*!< 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
|
||||
*/
|
||||
} data; /*!< data only *@warning device is big endian and
|
||||
* no endianess adaptation is performed by @ref VL53L1_IOCTL_REGISTER
|
||||
*/
|
||||
};
|
||||
|
||||
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; /*!< [în] 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)
|
||||
|
||||
#endif
|
||||
|
|
@ -1,386 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file 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_ */
|
||||
|
|
@ -1,378 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
*License terms : BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file 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 ");
|
||||
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);
|
||||
|
||||
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) {
|
||||
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 __exit stmvl53l1_ipp_exit(void)
|
||||
{
|
||||
if (nl_sk != NULL) {
|
||||
vl53l1_dbgmsg("releasing netlink socket");
|
||||
netlink_kernel_release(nl_sk);
|
||||
nl_sk = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**
|
||||
* @file /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
|
||||
|
|
@ -1,890 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
*License terms : BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file 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);
|
||||
|
||||
struct vl53l1_pinctrl_info {
|
||||
struct pinctrl *pinctrl;
|
||||
struct pinctrl_state *gpio_state_active;
|
||||
struct pinctrl_state *gpio_state_suspend;
|
||||
} g_pinctrl_info;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
module_param(force_device, int, 0);
|
||||
MODULE_PARM_DESC(force_device, "force device insertion at module init");
|
||||
|
||||
module_param(adapter_nb, int, 0);
|
||||
MODULE_PARM_DESC(adapter_nb, "i2c adapter to use");
|
||||
|
||||
module_param(xsdn_gpio_nb, int, 0);
|
||||
MODULE_PARM_DESC(xsdn_gpio_nb, "select gpio numer to use for vl53l1 reset");
|
||||
|
||||
module_param(pwren_gpio_nb, int, 0);
|
||||
MODULE_PARM_DESC(pwren_gpio_nb, "select gpio numer to use for vl53l1 power");
|
||||
|
||||
module_param(intr_gpio_nb, int, 0);
|
||||
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
|
||||
|
||||
static int insert_device(void)
|
||||
{
|
||||
int ret = 0;
|
||||
struct i2c_adapter *adapter;
|
||||
struct i2c_board_info info = {
|
||||
.type = "stmvl53l1",
|
||||
.addr = STMVL53L1_SLAVE_ADDR,
|
||||
};
|
||||
|
||||
adapter = i2c_get_adapter(adapter_nb);
|
||||
if (!adapter)
|
||||
ret = -EINVAL;
|
||||
stm_test_i2c_client = i2c_new_device(adapter, &info);
|
||||
if (!stm_test_i2c_client)
|
||||
ret = -EINVAL;
|
||||
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
static int get_dt_xtalk_data(struct device_node *of_node,
|
||||
struct stmvl53l1_data *vl53l1_data)
|
||||
{
|
||||
int rc = 0;
|
||||
uint32_t x_array[3] = {0};
|
||||
|
||||
if(of_node == NULL || vl53l1_data == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
rc = of_property_read_u32_array(of_node, "st,xtalkval",
|
||||
x_array, 3);
|
||||
if (rc) {
|
||||
vl53l1_errmsg("failed to read xtalk-offset\n");
|
||||
vl53l1_data->xtalk_offset = 0;
|
||||
vl53l1_data->xtalk_x = 0;
|
||||
vl53l1_data->xtalk_y = 0;
|
||||
} else {
|
||||
vl53l1_data->xtalk_offset = (uint16_t)x_array[0] & 0xFFFF;
|
||||
vl53l1_data->xtalk_x = (int16_t)(x_array[1] & 0xFFFF);
|
||||
vl53l1_data->xtalk_y = (int16_t)(x_array[2] & 0xFFFF);
|
||||
}
|
||||
|
||||
vl53l1_info("xtalk info: %u %d %d\n",
|
||||
vl53l1_data->xtalk_offset,
|
||||
vl53l1_data->xtalk_x,
|
||||
vl53l1_data->xtalk_y);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* parse dev tree for all platform specific input
|
||||
*/
|
||||
static int stmvl53l1_parse_tree(struct device *dev, struct i2c_data *i2c_data)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
/* 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;
|
||||
} 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 */
|
||||
rc = of_property_read_u32_array(dev->of_node,
|
||||
"pwren-gpio", &i2c_data->pwren_gpio, 1);
|
||||
if (rc) {
|
||||
i2c_data->pwren_gpio = -1;
|
||||
vl53l1_wanrmsg(
|
||||
"no regulator, nor power gpio => power ctrl disabled");
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
get_dt_xtalk_data(dev->of_node, i2c_data->vl53l1_data);
|
||||
}
|
||||
|
||||
/* 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_dbgmsg("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;
|
||||
}
|
||||
|
||||
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,
|
||||
},
|
||||
.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();
|
||||
|
||||
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");
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,447 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_H_
|
||||
#define _VL53L1_PLATFORM_H_
|
||||
|
||||
/*#define VL53L1_LOG_ENABLE 1 */
|
||||
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_platform_log.h"
|
||||
|
||||
#define VL53L1_IPP_API
|
||||
#include "vl53l1_platform_ipp_imports.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]
|
||||
*
|
||||
* @return time_ms : current time in [ms]
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_GetTickCount(
|
||||
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
|
||||
|
||||
|
|
@ -1,188 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _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,
|
||||
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
|
||||
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_IPP_IMPORTS_H_
|
||||
#define _VL53L1_PLATFORM_IPP_IMPORTS_H_
|
||||
|
||||
#endif
|
||||
|
|
@ -1,176 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file 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
|
||||
#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_ */
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
/*******************************************************************************
|
||||
Copyright (C) 2015, STMicroelectronics International N.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of STMicroelectronics nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
||||
NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* @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 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 peak 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_ */
|
||||
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _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 PALDevDataGet(Dev, field) (Dev->field)
|
||||
#define PALDevDataSet(Dev, field, data) ((Dev->field) = (data))
|
||||
|
||||
#define VL53L1DevStructGetLLDriverHandle(Dev) (&PALDevDataGet(Dev, LLData))
|
||||
#define VL53L1DevStructGetLLResultsHandle(Dev) (&PALDevDataGet(Dev, llresults))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _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
|
||||
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/*******************************************************************************
|
||||
*Copyright (c) 2016, STMicroelectronics - All Rights Reserved
|
||||
*
|
||||
* License terms: BSD 3-clause "New" or "Revised" License.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************/
|
||||
/**
|
||||
* @file 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