Initial commit v2.4.5
Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
commit
88ed984b02
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,236 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_core.h
|
||||
*
|
||||
* @brief EwokPlus25 low level API function definitions
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_API_CALIBRATION_H_
|
||||
#define _VL53L1_API_CALIBRATION_H_
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Run Reference Array SPAD Characterisation.
|
||||
*
|
||||
* This function finds the required number of reference SPAD
|
||||
* to meet the input required peak reference rate.
|
||||
*
|
||||
* The algorithm first tries the non apertured reference SPAD's,
|
||||
* if the rate is too high for the minimum allowed SPAD count (5)
|
||||
* then the algo switches to 5x apertured SPAD's and if the rate
|
||||
* is still to high then the 10x apertured SPAD are selected.
|
||||
*
|
||||
* The function reads the following results from the device and
|
||||
* both caches the values in the pdev->customer structure and
|
||||
* writes the data into the G02 customer register group.
|
||||
*
|
||||
* - num_ref_spads
|
||||
* - ref_location
|
||||
* - DCR SPAD enables for selected reference location
|
||||
*
|
||||
* Note power force is enabled as the function needs to read
|
||||
* data from the Patch RAM.
|
||||
*
|
||||
* Should only be called once per part with coverglass attached to
|
||||
* generate the required num of SPAD, Ref location and DCR SPAD enable
|
||||
* data
|
||||
*
|
||||
* @param[in] Dev : Device Handle
|
||||
* @param[out] pcal_status : Pointer to unfiltered calibration status
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS
|
||||
* Less than 5 Good SPAD available, output not valid
|
||||
* @return VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH
|
||||
* At end of search reference rate > 40.0 Mcps
|
||||
* Offset stability may be degraded.
|
||||
* @return VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW
|
||||
* At end of search reference rate < 10.0 Mcps
|
||||
* Offset stability may be degraded.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef VL53L1_NOCALIB
|
||||
VL53L1_Error VL53L1_run_ref_spad_char(VL53L1_DEV Dev, VL53L1_Error *pcal_status);
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Runs the input Device Test
|
||||
*
|
||||
* Calls
|
||||
*
|
||||
* - VL53L1_enable_powerforce()
|
||||
* - VL53L1_start_test()
|
||||
* - VL53L1_poll_for_range_completion()
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[in] device_test_mode : Device test mode register value
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
#ifndef VL53L1_NOCALIB
|
||||
VL53L1_Error VL53L1_run_device_test(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DeviceTestMode device_test_mode);
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Runs SPAD rate map
|
||||
*
|
||||
* Output structure contains SPAD rate data in SPAD number order
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[in] device_test_mode : Device test mode register value.
|
||||
* Valid options: \n
|
||||
* - VL53L1_DEVICETESTMODE_LCR_VCSEL_OFF \n
|
||||
* - VL53L1_DEVICETESTMODE_LCR_VCSEL_ON
|
||||
* @param[in] array_select : Device SPAD array select
|
||||
* Valid options: \n
|
||||
* - VL53L1_DEVICESSCARRAY_RTN \n
|
||||
* - VL53L1_DEVICESSCARRAY_REF
|
||||
* @param[in] ssc_config_timeout_us : SSC timeout in [us] e.g 36000us
|
||||
* @param[out] pspad_rate_data : pointer to output rates structure
|
||||
* 1.15 format for LCR_VCSEL_OFF
|
||||
* 9.7 format for LCR_VCSEL_ON
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
#ifndef VL53L1_NOCALIB
|
||||
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);
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Run offset calibration
|
||||
*
|
||||
* Runs the standard ranging MM1 and MM2 calibration presets
|
||||
* to generate the MM1 and MM2 range offset data
|
||||
*
|
||||
* The range config timeout is used for both MM1 and MM2 so that
|
||||
* the sigma delta settling is the same as for the 'real' range
|
||||
*
|
||||
* Places results into VL53L1_customer_nvm_managed_t within pdev
|
||||
*
|
||||
* Use VL53L1_get_part_to_part_data() to get the offset calibration
|
||||
* results
|
||||
*
|
||||
* Current FMT settings:
|
||||
*
|
||||
* - offset_calibration_mode = VL53L1_OFFSETCALIBRATIONMODE__STANDARD_RANGING
|
||||
* - dss_config__target_total_rate_mcps = 0x0A00 (20.0Mcps) to 0x1400 (40.0Mcps)
|
||||
* - phasecal_config_timeout_us = 1000
|
||||
* - range_config_timeout_us = 13000
|
||||
* - pre_num_of_samples = 32
|
||||
* - mm1_num_of_samples = 100
|
||||
* - mm2_range_num_of_samples = 64
|
||||
* - target_distance_mm = 140 mm
|
||||
* - target reflectance = 5%
|
||||
*
|
||||
* Note: function parms simplified as part of Patch_CalFunctionSimplification_11791
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[in] cal_distance_mm : Distance to target in [mm] - the ground truth
|
||||
* @param[out] pcal_status : Pointer to unfiltered calibration status
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return VL53L1_WARNING_OFFSET_CAL_INSUFFICIENT_MM1_SPADS
|
||||
* Effective MM1 SPAD count too low (<5.0).
|
||||
* Out with recommended calibration condition.
|
||||
* Accuracy of offset calibration may be degraded.
|
||||
* @return VL53L1_WARNING_OFFSET_CAL_PRE_RANGE_RATE_TOO_HIGH
|
||||
* Pre range too high (>40.0) in pile up region.
|
||||
* Out with recommended calibration condition.
|
||||
* Accuracy of offset calibration may be degraded.
|
||||
*/
|
||||
|
||||
#ifndef VL53L1_NOCALIB
|
||||
VL53L1_Error VL53L1_run_offset_calibration(
|
||||
VL53L1_DEV Dev,
|
||||
int16_t cal_distance_mm,
|
||||
VL53L1_Error *pcal_status);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _VL53L1_API_CALIBRATION_H_ */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,354 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_debug.h
|
||||
*
|
||||
* @brief EwokPlus25 low level API function definitions
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_API_DEBUG_H_
|
||||
#define _VL53L1_API_DEBUG_H_
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Start Patch_AdditionalDebugData_11823 */
|
||||
|
||||
/**
|
||||
* @brief Gets the current LL Driver configuration parameters and the last
|
||||
* set of histogram data for debug
|
||||
*
|
||||
* @param[in] Dev : Device Handle
|
||||
* @param[out] pdata : pointer to VL53L1_additional_data_t data structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_get_additional_data(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_additional_data_t *pdata);
|
||||
|
||||
/* End Patch_AdditionalDebugData_11823 */
|
||||
|
||||
|
||||
#ifdef VL53L1_LOG_ENABLE
|
||||
|
||||
/**
|
||||
* @brief Implements an sprintf function for signed fixed point numbers
|
||||
*
|
||||
* @param[in] fp_value : input signed fixed point number
|
||||
* @param[in] frac_bits : number of fixed point fractional bits
|
||||
* @param[in] buf_size : size of supplied text buffer
|
||||
* @param[out] pbuffer : pointer to text buffer
|
||||
*
|
||||
*/
|
||||
|
||||
void VL53L1_signed_fixed_point_sprintf(
|
||||
int32_t fp_value,
|
||||
uint8_t frac_bits,
|
||||
uint16_t buf_size,
|
||||
char *pbuffer);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience function to print out VL53L1_static_nvm_managed_t for debug
|
||||
*
|
||||
* @param[in] pdata : pointer to VL53L1_static_nvm_managed_t
|
||||
* @param[in] pprefix : pointer to name prefix string
|
||||
* @param[in] trace_flags : logging module enable bit flags
|
||||
*/
|
||||
|
||||
void VL53L1_print_static_nvm_managed(
|
||||
VL53L1_static_nvm_managed_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience function to print out VL53L1_customer_nvm_managed_t for debug
|
||||
*
|
||||
* @param[in] pdata : pointer to VL53L1_customer_nvm_managed_t
|
||||
* @param[in] pprefix : pointer to name prefix string
|
||||
* @param[in] trace_flags : logging module enable bit flags
|
||||
*/
|
||||
|
||||
void VL53L1_print_customer_nvm_managed(
|
||||
VL53L1_customer_nvm_managed_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience function to print out VL53L1_nvm_copy_data_t for debug
|
||||
*
|
||||
* @param[in] pdata : pointer to VL53L1_nvm_copy_data_t
|
||||
* @param[in] pprefix : pointer to name prefix string
|
||||
* @param[in] trace_flags : logging module enable bit flags
|
||||
*/
|
||||
|
||||
void VL53L1_print_nvm_copy_data(
|
||||
VL53L1_nvm_copy_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience function to print out the contents of
|
||||
* the Range Results structure for debug
|
||||
*
|
||||
* @param[in] pdata : pointer to a VL53L1_range_results_t structure
|
||||
* @param[in] pprefix : pointer to name prefix string
|
||||
* @param[in] trace_flags : logging module enable bit flags
|
||||
*/
|
||||
|
||||
void VL53L1_print_range_results(
|
||||
VL53L1_range_results_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
/**
|
||||
* @brief Convenience function to print out the contents of
|
||||
* the Range Data structure for debug
|
||||
*
|
||||
* @param[in] pdata : pointer to a VL53L1_range_data_t structure
|
||||
* @param[in] pprefix : pointer to name prefix string
|
||||
* @param[in] trace_flags : logging module enable bit flags
|
||||
*/
|
||||
|
||||
void VL53L1_print_range_data(
|
||||
VL53L1_range_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
/**
|
||||
* @brief Convenience function to print out the contents of
|
||||
* the offset range results structure for debug
|
||||
*
|
||||
* @param[in] pdata : pointer to a VL53L1_offset_range_results_t structure
|
||||
* @param[in] pprefix : pointer to name prefix string
|
||||
* @param[in] trace_flags : logging module enable bit flags
|
||||
*/
|
||||
|
||||
void VL53L1_print_offset_range_results(
|
||||
VL53L1_offset_range_results_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
/**
|
||||
* @brief Convenience function to print out the contents of
|
||||
* the offset range data structure for debug
|
||||
*
|
||||
* @param[in] pdata : pointer to a VL53L1_offset_range_data_t structure
|
||||
* @param[in] pprefix : pointer to name prefix string
|
||||
* @param[in] trace_flags : logging module enable bit flags
|
||||
*/
|
||||
|
||||
void VL53L1_print_offset_range_data(
|
||||
VL53L1_offset_range_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience function to print out the contents of
|
||||
* the peak rate map calibration data structure
|
||||
*
|
||||
* @param[in] pdata : pointer to a VL53L1_cal_peak_rate_map_t structure
|
||||
* @param[in] pprefix : pointer to name prefix string
|
||||
* @param[in] trace_flags : logging module enable bit flags
|
||||
*/
|
||||
|
||||
void VL53L1_print_cal_peak_rate_map(
|
||||
VL53L1_cal_peak_rate_map_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience function to print out the contents of
|
||||
* the additional offset calibration data structure
|
||||
*
|
||||
* @param[in] pdata : pointer to a VL53L1_additional_offset_cal_data_t structure
|
||||
* @param[in] pprefix : pointer to name prefix string
|
||||
* @param[in] trace_flags : logging module enable bit flags
|
||||
*/
|
||||
|
||||
void VL53L1_print_additional_offset_cal_data(
|
||||
VL53L1_additional_offset_cal_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
/**
|
||||
* @brief Convenience function to print out the contents of
|
||||
* the additional data structure
|
||||
*
|
||||
* @param[in] pdata : pointer to a VL53L1_additional_data_t structure
|
||||
* @param[in] pprefix : pointer to name prefix string
|
||||
* @param[in] trace_flags : logging module enable bit flags
|
||||
*/
|
||||
|
||||
void VL53L1_print_additional_data(
|
||||
VL53L1_additional_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience function to print out the contents of
|
||||
* the LL driver gain calibration data structure
|
||||
*
|
||||
* @param[in] pdata : pointer to a VL53L1_gain_calibration_data_t structure
|
||||
* @param[in] pprefix : pointer to name prefix string
|
||||
* @param[in] trace_flags : logging module enable bit flags
|
||||
*/
|
||||
|
||||
void VL53L1_print_gain_calibration_data(
|
||||
VL53L1_gain_calibration_data_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience function to print out the contents of
|
||||
* the xtalk configuration data for debug
|
||||
*
|
||||
* @param[in] pdata : pointer to a VL53L1_xtalk_config_t Structure
|
||||
* @param[in] pprefix : pointer to name prefix string
|
||||
* @param[in] trace_flags : logging module enable bit flags
|
||||
*/
|
||||
|
||||
void VL53L1_print_xtalk_config(
|
||||
VL53L1_xtalk_config_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
/**
|
||||
* @brief Convenience function to print out the contents of
|
||||
* the Optical Centre structure for debug
|
||||
*
|
||||
* @param[in] pdata : pointer to a VL53L1_optical_centre_t structure
|
||||
* @param[in] pprefix : pointer to name prefix string
|
||||
* @param[in] trace_flags : logging module enable bit flags
|
||||
*/
|
||||
|
||||
void VL53L1_print_optical_centre(
|
||||
VL53L1_optical_centre_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience function to print out the contents of
|
||||
* the User Zone (ROI) structure for debug
|
||||
*
|
||||
* @param[in] pdata : pointer to a VL53L1_user_zone_t structure
|
||||
* @param[in] pprefix : pointer to name prefix string
|
||||
* @param[in] trace_flags : logging module enable bit flags
|
||||
*/
|
||||
|
||||
void VL53L1_print_user_zone(
|
||||
VL53L1_user_zone_t *pdata,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
/**
|
||||
* @brief Convenience function for printing out VL53L1_spad_rate_data_t
|
||||
*
|
||||
* @param[in] pspad_rates : pointer to VL53L1_spad_rate_data_t
|
||||
* @param[in] pprefix : pointer to name prefix string
|
||||
* @param[in] trace_flags : logging module enable bit flags
|
||||
*/
|
||||
|
||||
void VL53L1_print_spad_rate_data(
|
||||
VL53L1_spad_rate_data_t *pspad_rates,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convenience function for printing out VL53L1_spad_rate_map_t
|
||||
*
|
||||
* @param[in] pspad_rates : pointer to VL53L1_spad_rate_map_t
|
||||
* @param[in] pprefix : pointer to name prefix string
|
||||
* @param[in] trace_flags : logging module enable bit flags
|
||||
*/
|
||||
|
||||
void VL53L1_print_spad_rate_map(
|
||||
VL53L1_spad_rate_data_t *pspad_rates,
|
||||
char *pprefix,
|
||||
uint32_t trace_flags);
|
||||
|
||||
|
||||
#endif /* VL53L1_LOG_ENABLE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _VL53L1_API_DEBUG_H_ */
|
|
@ -0,0 +1,471 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_preset_modes.h
|
||||
*
|
||||
* @brief EwokPlus25 API core function definition
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_API_PRESET_MODES_H_
|
||||
#define _VL53L1_API_PRESET_MODES_H_
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes Ref SPAD Char Configuration Parameters
|
||||
*
|
||||
* @param[out] pdata : pointer to VL53L1_refspadchar_config_t data structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
#ifndef VL53L1_NOCALIB
|
||||
VL53L1_Error VL53L1_init_refspadchar_config_struct(
|
||||
VL53L1_refspadchar_config_t *pdata);
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes SPAD Self Check (SSC) Configuration Parameters
|
||||
*
|
||||
* @param[out] pdata : pointer to VL53L1_ssc_config_t data structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_init_ssc_config_struct(
|
||||
VL53L1_ssc_config_t *pdata);
|
||||
|
||||
/**
|
||||
* @brief Initializes Xtalk Configuration Parameters
|
||||
*
|
||||
* @param[in] pnvm : pointer to VL53L1_customer_nvm_managed_t data structure
|
||||
* @param[out] pdata : pointer to VL53L1_xtalk_config_t data structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_init_xtalk_config_struct(
|
||||
VL53L1_customer_nvm_managed_t *pnvm,
|
||||
VL53L1_xtalk_config_t *pdata);
|
||||
|
||||
/**
|
||||
* @brief Initializes Offset Calibration Configuration Parameters
|
||||
*
|
||||
* @param[out] pdata : pointer to VL53L1_offsetcal_config_t data structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
#ifndef VL53L1_NOCALIB
|
||||
VL53L1_Error VL53L1_init_offset_cal_config_struct(
|
||||
VL53L1_offsetcal_config_t *pdata);
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes Tuning Parameter Storage Values
|
||||
*
|
||||
* @param[out] pdata : pointer to VL53L1_tuning_parm_storage_t data structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_init_tuning_parm_storage_struct(
|
||||
VL53L1_tuning_parm_storage_t *pdata);
|
||||
|
||||
/**
|
||||
* @brief Initializes static and dynamic configuration settings for
|
||||
* preset mode VL53L1_DEVICEPRESETMODE_STANDARD_RANGING
|
||||
*
|
||||
* @param[out] pstatic : pointer to VL53L1_static_config_t data structure
|
||||
* @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
|
||||
* @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
|
||||
* @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
|
||||
* @param[out] psystem : pointer to VL53L1_system_control_t data structure
|
||||
* @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_standard_ranging(
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms);
|
||||
|
||||
/**
|
||||
* @brief Initializes static and dynamic configuration settings for
|
||||
* preset mode VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_SHORT_RANGE
|
||||
*
|
||||
* @param[out] pstatic : pointer to VL53L1_static_config_t data structure
|
||||
* @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
|
||||
* @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
|
||||
* @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
|
||||
* @param[out] psystem : pointer to VL53L1_system_control_t data structure
|
||||
* @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_standard_ranging_short_range(
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes static and dynamic configuration settings for
|
||||
* preset mode VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_LONG_RANGE
|
||||
*
|
||||
* @param[out] pstatic : pointer to VL53L1_static_config_t data structure
|
||||
* @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
|
||||
* @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
|
||||
* @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
|
||||
* @param[out] psystem : pointer to VL53L1_system_control_t data structure
|
||||
* @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_standard_ranging_long_range(
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms);
|
||||
|
||||
/**
|
||||
* @brief Initializes static and dynamic configuration settings for
|
||||
* preset mode VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM1_CAL
|
||||
*
|
||||
* @param[out] pstatic : pointer to VL53L1_static_config_t data structure
|
||||
* @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
|
||||
* @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
|
||||
* @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
|
||||
* @param[out] psystem : pointer to VL53L1_system_control_t data structure
|
||||
* @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
#ifndef VL53L1_NOCALIB
|
||||
VL53L1_Error VL53L1_preset_mode_standard_ranging_mm1_cal(
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms);
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes static and dynamic configuration settings for
|
||||
* preset mode VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM2_CAL
|
||||
*
|
||||
* @param[out] pstatic : pointer to VL53L1_static_config_t data structure
|
||||
* @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
|
||||
* @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
|
||||
* @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
|
||||
* @param[out] psystem : pointer to VL53L1_system_control_t data structure
|
||||
* @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
#ifndef VL53L1_NOCALIB
|
||||
VL53L1_Error VL53L1_preset_mode_standard_ranging_mm2_cal(
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms);
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes static and dynamic configuration settings for
|
||||
* preset mode VL53L1_DEVICEPRESETMODE_TIMED_RANGING
|
||||
*
|
||||
* @param[out] pstatic : pointer to VL53L1_static_config_t data structure
|
||||
* @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
|
||||
* @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
|
||||
* @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
|
||||
* @param[out] psystem : pointer to VL53L1_system_control_t data structure
|
||||
* @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_timed_ranging(
|
||||
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms);
|
||||
|
||||
/**
|
||||
* @brief Initializes static and dynamic configuration settings for
|
||||
* preset mode VL53L1_DEVICEPRESETMODE_TIMED_RANGING_SHORT_RANGE
|
||||
*
|
||||
* @param[out] pstatic : pointer to VL53L1_static_config_t data structure
|
||||
* @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
|
||||
* @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
|
||||
* @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
|
||||
* @param[out] psystem : pointer to VL53L1_system_control_t data structure
|
||||
* @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_timed_ranging_short_range(
|
||||
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms);
|
||||
|
||||
/**
|
||||
* @brief Initializes static and dynamic configuration settings for
|
||||
* preset mode VL53L1_DEVICEPRESETMODE_TIMED_RANGING_LONG_RANGE
|
||||
*
|
||||
* @param[out] pstatic : pointer to VL53L1_static_config_t data structure
|
||||
* @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
|
||||
* @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
|
||||
* @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
|
||||
* @param[out] psystem : pointer to VL53L1_system_control_t data structure
|
||||
* @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_timed_ranging_long_range(
|
||||
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms);
|
||||
|
||||
/**
|
||||
* @brief Initializes static and dynamic configuration settings for
|
||||
* preset mode VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_MEDIUM_RANGE
|
||||
*
|
||||
* @param[out] pstatic : pointer to VL53L1_static_config_t data structure
|
||||
* @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
|
||||
* @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
|
||||
* @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
|
||||
* @param[out] psystem : pointer to VL53L1_system_control_t data structure
|
||||
* @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
|
||||
* @param[out] plpadata : pointer to VL53L1_low_power_auto_data_t data structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_low_power_auto_ranging(
|
||||
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_low_power_auto_data_t *plpadata);
|
||||
|
||||
/**
|
||||
* @brief Initializes static and dynamic configuration settings for
|
||||
* preset mode VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_SHORT_RANGE
|
||||
*
|
||||
* @param[out] pstatic : pointer to VL53L1_static_config_t data structure
|
||||
* @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
|
||||
* @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
|
||||
* @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
|
||||
* @param[out] psystem : pointer to VL53L1_system_control_t data structure
|
||||
* @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
|
||||
* @param[out] plpadata : pointer to VL53L1_low_power_auto_data_t data structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_low_power_auto_short_ranging(
|
||||
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_low_power_auto_data_t *plpadata);
|
||||
|
||||
/**
|
||||
* @brief Initializes static and dynamic configuration settings for
|
||||
* preset mode VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_LONG_RANGE
|
||||
*
|
||||
* @param[out] pstatic : pointer to VL53L1_static_config_t data structure
|
||||
* @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
|
||||
* @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
|
||||
* @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
|
||||
* @param[out] psystem : pointer to VL53L1_system_control_t data structure
|
||||
* @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
|
||||
* @param[out] plpadata : pointer to VL53L1_low_power_auto_data_t data structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_low_power_auto_long_ranging(
|
||||
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms,
|
||||
VL53L1_low_power_auto_data_t *plpadata);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes static and dynamic configuration settings for
|
||||
* preset mode VL53L1_DEVICEPRESETMODE_OLT
|
||||
*
|
||||
* @param[out] pstatic : pointer to VL53L1_static_config_t data structure
|
||||
* @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
|
||||
* @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
|
||||
* @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
|
||||
* @param[out] psystem : pointer to VL53L1_system_control_t data structure
|
||||
* @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_olt(
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms);
|
||||
|
||||
/**
|
||||
* @brief Initializes static and dynamic configuration settings for
|
||||
* preset mode VL53L1_DEVICEPRESETMODE_SINGLESHOT_RANGING
|
||||
*
|
||||
* @param[out] pstatic : pointer to VL53L1_static_config_t data structure
|
||||
* @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
|
||||
* @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
|
||||
* @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
|
||||
* @param[out] psystem : pointer to VL53L1_system_control_t data structure
|
||||
* @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_preset_mode_singleshot_ranging(
|
||||
|
||||
VL53L1_static_config_t *pstatic,
|
||||
VL53L1_general_config_t *pgeneral,
|
||||
VL53L1_timing_config_t *ptiming,
|
||||
VL53L1_dynamic_config_t *pdynamic,
|
||||
VL53L1_system_control_t *psystem,
|
||||
VL53L1_tuning_parm_storage_t *ptuning_parms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _VL53L1_API_CORE_H_ */
|
|
@ -0,0 +1,159 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file vl53l1_api_strings.h
|
||||
* @brief VL53L1 API function declarations for decoding error codes to a
|
||||
* text strings
|
||||
*/
|
||||
|
||||
|
||||
#ifndef VL53L1_API_STRINGS_H_
|
||||
#define VL53L1_API_STRINGS_H_
|
||||
|
||||
#include "vl53l1_def.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Generates a string for the input device range status code
|
||||
*
|
||||
* @param[in] RangeStatus : Device Range AStatus Code
|
||||
* @param[out] pRangeStatusString : pointer to character buffer
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_get_range_status_string(
|
||||
uint8_t RangeStatus,
|
||||
char *pRangeStatusString);
|
||||
|
||||
/**
|
||||
* @brief Generates an error string for the input PAL error code
|
||||
*
|
||||
* @param[in] PalErrorCode : PAL Error Code
|
||||
* @param[out] pPalErrorString : pointer to character buffer
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_get_pal_error_string(
|
||||
VL53L1_Error PalErrorCode,
|
||||
char *pPalErrorString);
|
||||
|
||||
/**
|
||||
* @brief Generates a string for the input PAL State code
|
||||
*
|
||||
* @param[in] PalStateCode : PAL State Code
|
||||
* @param[out] pPalStateString : pointer to character buffer
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_get_pal_state_string(
|
||||
VL53L1_State PalStateCode,
|
||||
char *pPalStateString);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Generates a string for the sequence step Id
|
||||
*
|
||||
* @param[in] SequenceStepId : Sequence Step Id
|
||||
* @param[out] pSequenceStepsString : pointer to character buffer
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
VL53L1_Error VL53L1_get_sequence_steps_info(
|
||||
VL53L1_SequenceStepId SequenceStepId,
|
||||
char *pSequenceStepsString);
|
||||
|
||||
/**
|
||||
* @brief Generates a string for the limit check Id
|
||||
*
|
||||
* @param[in] LimitCheckId : Limit check Id
|
||||
* @param[out] pLimitCheckString : pointer to character buffer
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
VL53L1_Error VL53L1_get_limit_check_info(uint16_t LimitCheckId,
|
||||
char *pLimitCheckString);
|
||||
|
||||
#ifndef VL53L1_USE_EMPTY_STRING
|
||||
#define VL53L1_STRING_DEVICE_INFO_NAME0 "VL53L1 cut1.0"
|
||||
#define VL53L1_STRING_DEVICE_INFO_NAME1 "VL53L1 cut1.1"
|
||||
#define VL53L1_STRING_DEVICE_INFO_TYPE "VL53L1"
|
||||
|
||||
/* Range Status */
|
||||
#define VL53L1_STRING_RANGESTATUS_NONE "No Update"
|
||||
#define VL53L1_STRING_RANGESTATUS_RANGEVALID "Range Valid"
|
||||
#define VL53L1_STRING_RANGESTATUS_SIGMA "Sigma Fail"
|
||||
#define VL53L1_STRING_RANGESTATUS_SIGNAL "Signal Fail"
|
||||
#define VL53L1_STRING_RANGESTATUS_MINRANGE "Min Range Fail"
|
||||
#define VL53L1_STRING_RANGESTATUS_PHASE "Phase Fail"
|
||||
#define VL53L1_STRING_RANGESTATUS_HW "Hardware Fail"
|
||||
|
||||
|
||||
/* Range Status */
|
||||
#define VL53L1_STRING_STATE_POWERDOWN "POWERDOWN State"
|
||||
#define VL53L1_STRING_STATE_WAIT_STATICINIT \
|
||||
"Wait for staticinit State"
|
||||
#define VL53L1_STRING_STATE_STANDBY "STANDBY State"
|
||||
#define VL53L1_STRING_STATE_IDLE "IDLE State"
|
||||
#define VL53L1_STRING_STATE_RUNNING "RUNNING State"
|
||||
#define VL53L1_STRING_STATE_RESET "RESET State"
|
||||
#define VL53L1_STRING_STATE_UNKNOWN "UNKNOWN State"
|
||||
#define VL53L1_STRING_STATE_ERROR "ERROR State"
|
||||
|
||||
|
||||
|
||||
/* Check Enable */
|
||||
#define VL53L1_STRING_CHECKENABLE_SIGMA_FINAL_RANGE \
|
||||
"SIGMA FINAL RANGE"
|
||||
#define VL53L1_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE \
|
||||
"SIGNAL RATE FINAL RANGE"
|
||||
#define VL53L1_STRING_CHECKENABLE_SIGNAL_MIN_CLIP \
|
||||
"SIGNAL MIN CLIP"
|
||||
#define VL53L1_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD \
|
||||
"RANGE IGNORE THRESHOLD"
|
||||
#define VL53L1_STRING_CHECKENABLE_RANGE_PHASE_HIGH \
|
||||
"RANGE PHASE HIGH"
|
||||
#define VL53L1_STRING_CHECKENABLE_RANGE_PHASE_LOW \
|
||||
"RANGE PHASE LOW"
|
||||
#define VL53L1_STRING_CHECKENABLE_RANGE_PHASE_CONSISTENCY \
|
||||
"RANGE PHASE CONSISTENCY"
|
||||
|
||||
/* Sequence Step */
|
||||
#define VL53L1_STRING_SEQUENCESTEP_VHV "VHV"
|
||||
#define VL53L1_STRING_SEQUENCESTEP_PHASECAL "PHASE CAL"
|
||||
#define VL53L1_STRING_SEQUENCESTEP_REFPHASE "REF PHASE"
|
||||
#define VL53L1_STRING_SEQUENCESTEP_DSS1 "DSS1"
|
||||
#define VL53L1_STRING_SEQUENCESTEP_DSS2 "DSS2"
|
||||
#define VL53L1_STRING_SEQUENCESTEP_MM1 "MM1"
|
||||
#define VL53L1_STRING_SEQUENCESTEP_MM2 "MM2"
|
||||
#define VL53L1_STRING_SEQUENCESTEP_RANGE "RANGE"
|
||||
#endif /* VL53L1_USE_EMPTY_STRING */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,222 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_core_support.h
|
||||
*
|
||||
* @brief EwokPlus25 core function definitions
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_CORE_SUPPORT_H_
|
||||
#define _VL53L1_CORE_SUPPORT_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Calculates the PLL period in [us] from the input
|
||||
* fast_osc_frequency
|
||||
*
|
||||
* @param[in] fast_osc_frequency : fast oscillator frequency in 4.12 MHz format
|
||||
*
|
||||
* @return pll_period_us : PLL period in [us] 8.24 format
|
||||
*/
|
||||
|
||||
uint32_t VL53L1_calc_pll_period_us(
|
||||
uint16_t fast_osc_frequency);
|
||||
|
||||
|
||||
|
||||
#ifdef PAL_EXTENDED
|
||||
/**
|
||||
* @brief Calculates the ranging duration in ns using fixed point maths
|
||||
* *
|
||||
* Uses a temporary uint64_t variable internally
|
||||
*
|
||||
* @param[in] pll_period_us : PLL Period in [us] 0.25 format
|
||||
* @param[in] vcsel_parm_pclks : period, width or WOI window in PLL clocks
|
||||
* in 6.4 format.
|
||||
* @param[in] window_vclks : ranging or ambient window duration in VCSEL clocks
|
||||
* @param[in] periods_elapsed_mclks : elapsed time in macro clocks
|
||||
*
|
||||
* @return duration_us : uint32_t containing the duration time in us
|
||||
*/
|
||||
|
||||
uint32_t VL53L1_duration_maths(
|
||||
uint32_t pll_period_us,
|
||||
uint32_t vcsel_parm_pclks,
|
||||
uint32_t window_vclks,
|
||||
uint32_t periods_elapsed_mclks);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Calculates the square root of the input integer
|
||||
*
|
||||
* Reference : http://en.wikipedia.org/wiki/Methods_of_computing_square_roots
|
||||
*
|
||||
* @param[in] num : input integer
|
||||
*
|
||||
* @return res : square root result
|
||||
*/
|
||||
|
||||
uint32_t VL53L1_isqrt(
|
||||
uint32_t num);
|
||||
|
||||
/**
|
||||
* @brief Calculates the count rate using fixed point maths
|
||||
*
|
||||
* Uses a temporary uint64_t variable internally
|
||||
* Any negative negative rates are clipped to 0.
|
||||
*
|
||||
* @param[in] events : accumulated SPAD events
|
||||
* @param[in] time_us : elapsed time in us
|
||||
*
|
||||
* @return rate_mcps : uint16_t count rate in 9.7 format
|
||||
*/
|
||||
|
||||
uint16_t VL53L1_rate_maths(
|
||||
int32_t events,
|
||||
uint32_t time_us);
|
||||
|
||||
/**
|
||||
* @brief Calculates the Rate per spad
|
||||
*
|
||||
* Uses a temporary uint32_t variable internally
|
||||
* Any output rates larger than 16 bit are clipped to 0xFFFF.
|
||||
*
|
||||
* @param[in] frac_bits : required output fractional precision - 7 \
|
||||
* due to inherent resolution of pk_rate
|
||||
* @param[in] peak_count_rate : peak signal count rate in mcps
|
||||
* @param[in] num_spads : actual effective spads in 8.8
|
||||
* @param[in] max_output_value : User set value to clip output
|
||||
*
|
||||
* @return rate_per_spad : uint16_t count rate in variable fractional format
|
||||
*/
|
||||
|
||||
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);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Calculates the range from the phase data
|
||||
*
|
||||
* Uses a temporary int64_t variable internally
|
||||
*
|
||||
* @param[in] fast_osc_frequency : Fast oscillator freq [MHz] 4.12 format
|
||||
* @param[in] phase : phase in 5.11 format
|
||||
* @param[in] zero_distance_phase : zero distance phase in 5.11 format
|
||||
* @param[in] fractional_bits : valid options : 0, 1, 2
|
||||
* @param[in] gain_factor : gain correction factor 1.11 format
|
||||
* @param[in] range_offset_mm : range offset [mm] 14.2 format
|
||||
|
||||
* @return range_mm : signed range in [mm]
|
||||
* format depends on fractional_bits input
|
||||
*/
|
||||
|
||||
int32_t VL53L1_range_maths(
|
||||
uint16_t fast_osc_frequency,
|
||||
uint16_t phase,
|
||||
uint16_t zero_distance_phase,
|
||||
uint8_t fractional_bits,
|
||||
int32_t gain_factor,
|
||||
int32_t range_offset_mm);
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Decodes VCSEL period register value into the real period in PLL clocks
|
||||
*
|
||||
* @param[in] vcsel_period_reg : 8 -bit register value
|
||||
*
|
||||
* @return vcsel_period_pclks : 8-bit decoded value
|
||||
*
|
||||
*/
|
||||
|
||||
uint8_t VL53L1_decode_vcsel_period(
|
||||
uint8_t vcsel_period_reg);
|
||||
|
||||
/**
|
||||
* @brief Decodes the Byte.Bit coord encoding into an (x,y) coord value
|
||||
*
|
||||
* @param[in] spad_number : Coord location in Byte.Bit format
|
||||
* @param[out] prow : Decoded row
|
||||
* @param[out] pcol : Decoded column
|
||||
*
|
||||
*/
|
||||
|
||||
void VL53L1_decode_row_col(
|
||||
uint8_t spad_number,
|
||||
uint8_t *prow,
|
||||
uint8_t *pcol);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _VL53L1_CORE_SUPPORT_H_ */
|
|
@ -0,0 +1,603 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file vl53l1_def.h
|
||||
*
|
||||
* @brief Type definitions for VL53L1 API.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VL53L1_DEF_H_
|
||||
#define _VL53L1_DEF_H_
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @defgroup VL53L1_globaldefine_group VL53L1 Defines
|
||||
* @brief VL53L1 Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** VL53L1 IMPLEMENTATION major version */
|
||||
#define VL53L1_IMPLEMENTATION_VER_MAJOR 2
|
||||
/** VL53L1 IMPLEMENTATION minor version */
|
||||
#define VL53L1_IMPLEMENTATION_VER_MINOR 4
|
||||
/** VL53L1 IMPLEMENTATION sub version */
|
||||
#define VL53L1_IMPLEMENTATION_VER_SUB 5
|
||||
/** VL53L1 IMPLEMENTATION sub version */
|
||||
#define VL53L1_IMPLEMENTATION_VER_REVISION 2548
|
||||
|
||||
/****************************************
|
||||
* PRIVATE define do not edit
|
||||
****************************************/
|
||||
|
||||
/** @brief Defines the parameters of the Get Version Functions
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t revision; /*!< revision number */
|
||||
uint8_t major; /*!< major number */
|
||||
uint8_t minor; /*!< minor number */
|
||||
uint8_t build; /*!< build number */
|
||||
} VL53L1_Version_t;
|
||||
|
||||
|
||||
#define VL53L1_DEVINFO_STRLEN 32
|
||||
|
||||
/** @brief Defines the parameters of the Get Device Info Functions
|
||||
*/
|
||||
typedef struct {
|
||||
char Name[VL53L1_DEVINFO_STRLEN];
|
||||
/*!< Full Name of the Device e.g. VL53L1 cut1.1 */
|
||||
char Type[VL53L1_DEVINFO_STRLEN];
|
||||
/*!< Type of the Device e.g VL53L1 */
|
||||
char ProductId[VL53L1_DEVINFO_STRLEN];
|
||||
/*!< Product Identifier String
|
||||
* @warning Not yet implemented
|
||||
*/
|
||||
uint8_t ProductType;
|
||||
/*!< Product Type, VL53L1 = 0xCC, VL53L3 = 0xAA
|
||||
* Stands as module_type in the datasheet
|
||||
*/
|
||||
uint8_t ProductRevisionMajor;
|
||||
/*!< Product revision major */
|
||||
uint8_t ProductRevisionMinor;
|
||||
/*!< Product revision minor */
|
||||
} VL53L1_DeviceInfo_t;
|
||||
|
||||
|
||||
|
||||
/** @defgroup VL53L1_define_PresetModes_group Defines Preset modes
|
||||
* Defines all possible preset modes for the device
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_PresetModes;
|
||||
|
||||
#define VL53L1_PRESETMODE_AUTONOMOUS ((VL53L1_PresetModes) 3)
|
||||
#define VL53L1_PRESETMODE_LITE_RANGING ((VL53L1_PresetModes) 4)
|
||||
#define VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS ((VL53L1_PresetModes) 8)
|
||||
|
||||
/* ... Modes to be added depending on device */
|
||||
/** @} VL53L1_define_PresetModes_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_define_DistanceModes_group Defines Distance modes
|
||||
* Defines all possible Distance modes for the device
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_DistanceModes;
|
||||
|
||||
#define VL53L1_DISTANCEMODE_SHORT ((VL53L1_DistanceModes) 1)
|
||||
#define VL53L1_DISTANCEMODE_MEDIUM ((VL53L1_DistanceModes) 2)
|
||||
#define VL53L1_DISTANCEMODE_LONG ((VL53L1_DistanceModes) 3)
|
||||
/** @} VL53L1_define_DistanceModes_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_define_XtalkCal_group Defines Xtalk Calibration modes
|
||||
* Defines all possible Offset Calibration modes for the device
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_XtalkCalibrationModes;
|
||||
|
||||
#define VL53L1_XTALKCALIBRATIONMODE_NO_TARGET \
|
||||
((VL53L1_OffsetCalibrationModes) 0)
|
||||
/*!< To perform Xtalk calibration with no target below 80 cm */
|
||||
#define VL53L1_XTALKCALIBRATIONMODE_SINGLE_TARGET \
|
||||
((VL53L1_OffsetCalibrationModes) 1)
|
||||
/*!< To perform Xtalk calibration with one target */
|
||||
#define VL53L1_XTALKCALIBRATIONMODE_FULL_ROI \
|
||||
((VL53L1_OffsetCalibrationModes) 2)
|
||||
/*!< To perform Xtalk calibration based on histogram with full ROI */
|
||||
|
||||
/** @} VL53L1_define_XtalkCal_group */
|
||||
|
||||
/** @defgroup VL53L1_define_OffsetCal_group Defines Offset Calibration modes
|
||||
* Defines all possible Offset Calibration modes for the device
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_OffsetCalibrationModes;
|
||||
|
||||
#define VL53L1_OFFSETCALIBRATIONMODE_STANDARD \
|
||||
((VL53L1_OffsetCalibrationModes) 1)
|
||||
#define VL53L1_OFFSETCALIBRATIONMODE_PRERANGE_ONLY \
|
||||
((VL53L1_OffsetCalibrationModes) 2)
|
||||
|
||||
/** @} VL53L1_define_OffsetCal_group */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** @defgroup VL53L1_CheckEnable_group Check Enable list
|
||||
* @brief Check Enable code
|
||||
*
|
||||
* Define used to specify the LimitCheckId.
|
||||
* Use @a VL53L1_GetLimitCheckInfo() to get the string.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE 0
|
||||
#define VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE 1
|
||||
|
||||
#define VL53L1_CHECKENABLE_NUMBER_OF_CHECKS 2
|
||||
|
||||
/** @} end of VL53L1_CheckEnable_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_ThresholdMode_gropup Detection Functionality
|
||||
* @brief Defines the different functionalities for the detection feature
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_ThresholdMode;
|
||||
|
||||
#define VL53L1_THRESHOLD_CROSSED_LOW \
|
||||
((VL53L1_ThresholdMode) 0)
|
||||
/*!< Trigger interrupt if value < thresh_low */
|
||||
#define VL53L1_THRESHOLD_CROSSED_HIGH \
|
||||
((VL53L1_ThresholdMode) 1)
|
||||
/*!< Trigger interrupt if value > thresh_high */
|
||||
#define VL53L1_THRESHOLD_OUT_OF_WINDOW \
|
||||
((VL53L1_ThresholdMode) 2)
|
||||
/*!< Trigger interrupt if value < thresh_low OR value > thresh_high */
|
||||
#define VL53L1_THRESHOLD_IN_WINDOW \
|
||||
((VL53L1_ThresholdMode) 3)
|
||||
/*!< Trigger interrupt if value > thresh_low AND value < thresh_high */
|
||||
|
||||
/** @} end of VL53L1_ThresholdMode_gropup */
|
||||
|
||||
/** @brief Defines parameters for Distance detection Thresholds configuration
|
||||
*/
|
||||
typedef struct {
|
||||
VL53L1_ThresholdMode CrossMode;
|
||||
uint16_t High; /*!< Distance threshold high limit in mm */
|
||||
uint16_t Low; /*!< Distance threshold low limit in mm */
|
||||
} VL53L1_DistanceThreshold_t;
|
||||
|
||||
/** @brief Defines parameters for Signal rate detection Thresholds configuration
|
||||
*/
|
||||
typedef struct {
|
||||
VL53L1_ThresholdMode CrossMode;
|
||||
FixPoint1616_t High; /*!< Signal rate threshold high limit */
|
||||
FixPoint1616_t Low; /*!< Signal rate threshold low limit */
|
||||
} VL53L1_RateThreshold_t;
|
||||
|
||||
/** @defgroup VL53L1_DetectionMode_group Gpio Functionality
|
||||
* @brief Defines conditions leading to device's IT on GPIO
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_DetectionMode;
|
||||
|
||||
#define VL53L1_DETECTION_NORMAL_RUN \
|
||||
((VL53L1_DetectionMode) 0)
|
||||
/*!< Trigger interrupt on new measurement regardless of threshold
|
||||
* just like after a VL53L1_SetPresetMode() call
|
||||
*/
|
||||
#define VL53L1_DETECTION_DISTANCE_ONLY \
|
||||
((VL53L1_DetectionMode) 1)
|
||||
/*!< Trigger interrupt if "threshold event" occurs on distance */
|
||||
#define VL53L1_DETECTION_RATE_ONLY \
|
||||
((VL53L1_DetectionMode) 2)
|
||||
/*!< Trigger interrupt if "threshold event" occurs on signal rate */
|
||||
#define VL53L1_DETECTION_DISTANCE_AND_RATE \
|
||||
((VL53L1_DetectionMode) 3)
|
||||
/*!< Trigger interrupt if "threshold event" occurs on distance AND rate
|
||||
*/
|
||||
#define VL53L1_DETECTION_DISTANCE_OR_RATE \
|
||||
((VL53L1_DetectionMode) 4)
|
||||
/*!< Trigger interrupt if "threshold event" occurs on distance OR rate
|
||||
*/
|
||||
|
||||
/** @} end of VL53L1_DetectionMode_group */
|
||||
|
||||
/** @brief Defines parameters for User/object Detection configuration
|
||||
*/
|
||||
typedef struct {
|
||||
VL53L1_DetectionMode DetectionMode; /*!< See #VL53L1_DetectionMode*/
|
||||
uint8_t IntrNoTarget; /*!< 1 to trigger IT in case of no target found */
|
||||
VL53L1_DistanceThreshold_t Distance; /*!< limits in mm */
|
||||
VL53L1_RateThreshold_t Rate;/*!< limits in FixPoint1616_t */
|
||||
} VL53L1_DetectionConfig_t;
|
||||
|
||||
|
||||
/** @brief Defines all parameters for the device
|
||||
*/
|
||||
typedef struct {
|
||||
VL53L1_PresetModes PresetMode;
|
||||
/*!< Defines the operating mode to be used for the next measure */
|
||||
VL53L1_DistanceModes DistanceMode;
|
||||
/*!< Defines the operating mode to be used for the next measure */
|
||||
uint32_t MeasurementTimingBudgetMicroSeconds;
|
||||
/*!< Defines the allowed total time for a single measurement */
|
||||
uint8_t LimitChecksEnable[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
|
||||
/*!< This Array store all the Limit Check enable for this device. */
|
||||
uint8_t LimitChecksStatus[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
|
||||
/*!< This Array stores all the Status of the check linked to last
|
||||
* measurement.
|
||||
*/
|
||||
FixPoint1616_t LimitChecksValue[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
|
||||
/*!< This Array stores all the Limit Check value for this device */
|
||||
FixPoint1616_t LimitChecksCurrent[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
|
||||
/*!< This Array stores all the Limit Check current value from latest
|
||||
* ranging
|
||||
*/
|
||||
} VL53L1_DeviceParameters_t;
|
||||
|
||||
|
||||
/** @defgroup VL53L1_define_State_group Defines the current status of the device
|
||||
* Defines the current status of the device
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef uint8_t VL53L1_State;
|
||||
|
||||
#define VL53L1_STATE_POWERDOWN ((VL53L1_State) 0)
|
||||
/*!< Device is in HW reset */
|
||||
#define VL53L1_STATE_WAIT_STATICINIT ((VL53L1_State) 1)
|
||||
/*!< Device is initialized and wait for static initialization */
|
||||
#define VL53L1_STATE_STANDBY ((VL53L1_State) 2)
|
||||
/*!< Device is in Low power Standby mode */
|
||||
#define VL53L1_STATE_IDLE ((VL53L1_State) 3)
|
||||
/*!< Device has been initialized and ready to do measurements */
|
||||
#define VL53L1_STATE_RUNNING ((VL53L1_State) 4)
|
||||
/*!< Device is performing measurement */
|
||||
#define VL53L1_STATE_RESET ((VL53L1_State) 5)
|
||||
/*!< Soft reset has been run on Device */
|
||||
#define VL53L1_STATE_UNKNOWN ((VL53L1_State) 98)
|
||||
/*!< Device is in unknown state and need to be rebooted */
|
||||
#define VL53L1_STATE_ERROR ((VL53L1_State) 99)
|
||||
/*!< Device is in error state and need to be rebooted */
|
||||
|
||||
/** @} VL53L1_define_State_group */
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @struct VL53L1_RangingMeasurementData_t
|
||||
* @brief Single Range measurement data.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t TimeStamp;
|
||||
/*!< 32-bit time stamp.
|
||||
* @warning Not yet implemented
|
||||
*/
|
||||
|
||||
uint8_t StreamCount;
|
||||
/*!< 8-bit Stream Count. */
|
||||
|
||||
uint8_t RangeQualityLevel;
|
||||
/*!< indicate a quality level in percentage from 0 to 100
|
||||
* @warning Not yet implemented
|
||||
*/
|
||||
|
||||
FixPoint1616_t SignalRateRtnMegaCps;
|
||||
/*!< Return signal rate (MCPS)\n these is a 16.16 fix point
|
||||
* value, which is effectively a measure of target
|
||||
* reflectance.
|
||||
*/
|
||||
|
||||
FixPoint1616_t AmbientRateRtnMegaCps;
|
||||
/*!< Return ambient rate (MCPS)\n these is a 16.16 fix point
|
||||
* value, which is effectively a measure of the ambient
|
||||
* light.
|
||||
*/
|
||||
|
||||
uint16_t EffectiveSpadRtnCount;
|
||||
/*!< Return the effective SPAD count for the return signal.
|
||||
* To obtain Real value it should be divided by 256
|
||||
*/
|
||||
|
||||
FixPoint1616_t SigmaMilliMeter;
|
||||
/*!< Return the Sigma value in millimeter */
|
||||
|
||||
int16_t RangeMilliMeter;
|
||||
/*!< range distance in millimeter. This should be between
|
||||
* RangeMinMilliMeter and RangeMaxMilliMeter
|
||||
*/
|
||||
|
||||
uint8_t RangeFractionalPart;
|
||||
/*!< Fractional part of range distance. Final value is a
|
||||
* RangeMilliMeter + RangeFractionalPart/256.
|
||||
* @warning Not yet implemented
|
||||
*/
|
||||
|
||||
uint8_t RangeStatus;
|
||||
/*!< Range Status for the current measurement. This is device
|
||||
* dependent. Value = 0 means value is valid.
|
||||
*/
|
||||
} VL53L1_RangingMeasurementData_t;
|
||||
|
||||
|
||||
|
||||
/** @brief Defines User Zone(ROI) parameters
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
|
||||
uint8_t TopLeftX; /*!< Top Left x coordinate: 0-15 range */
|
||||
uint8_t TopLeftY; /*!< Top Left y coordinate: 0-15 range */
|
||||
uint8_t BotRightX; /*!< Bot Right x coordinate: 0-15 range */
|
||||
uint8_t BotRightY; /*!< Bot Right y coordinate: 0-15 range */
|
||||
|
||||
} VL53L1_UserRoi_t;
|
||||
|
||||
|
||||
/** @brief Defines ROI configuration parameters
|
||||
*
|
||||
* Support up a max of 16 zones, Each Zone has the same size
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @struct VL53L1_CustomerNvmManaged_t
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
uint8_t global_config__spad_enables_ref_0;
|
||||
uint8_t global_config__spad_enables_ref_1;
|
||||
uint8_t global_config__spad_enables_ref_2;
|
||||
uint8_t global_config__spad_enables_ref_3;
|
||||
uint8_t global_config__spad_enables_ref_4;
|
||||
uint8_t global_config__spad_enables_ref_5;
|
||||
uint8_t global_config__ref_en_start_select;
|
||||
uint8_t ref_spad_man__num_requested_ref_spads;
|
||||
uint8_t ref_spad_man__ref_location;
|
||||
uint32_t algo__crosstalk_compensation_plane_offset_kcps;
|
||||
int16_t algo__crosstalk_compensation_x_plane_gradient_kcps;
|
||||
int16_t algo__crosstalk_compensation_y_plane_gradient_kcps;
|
||||
uint16_t ref_spad_char__total_rate_target_mcps;
|
||||
int16_t algo__part_to_part_range_offset_mm;
|
||||
int16_t mm_config__inner_offset_mm;
|
||||
int16_t mm_config__outer_offset_mm;
|
||||
} VL53L1_CustomerNvmManaged_t;
|
||||
|
||||
/**
|
||||
* @struct VL53L1_CalibrationData_t
|
||||
* @brief Structure for storing the Calibration Data
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
|
||||
uint32_t struct_version;
|
||||
VL53L1_CustomerNvmManaged_t customer;
|
||||
VL53L1_additional_offset_cal_data_t add_off_cal_data;
|
||||
VL53L1_optical_centre_t optical_centre;
|
||||
VL53L1_gain_calibration_data_t gain_cal;
|
||||
VL53L1_cal_peak_rate_map_t cal_peak_rate_map;
|
||||
} VL53L1_CalibrationData_t;
|
||||
|
||||
#define VL53L1_ADDITIONAL_CALIBRATION_DATA_STRUCT_VERSION 0x20
|
||||
/** VL53L1 additional Calibration Data struct version final struct version
|
||||
* is given by adding it to VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION
|
||||
*/
|
||||
|
||||
#define VL53L1_CALIBRATION_DATA_STRUCT_VERSION \
|
||||
(VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION + \
|
||||
VL53L1_ADDITIONAL_CALIBRATION_DATA_STRUCT_VERSION)
|
||||
/* VL53L1 Calibration Data struct version */
|
||||
|
||||
/**
|
||||
* @struct VL53L1_AdditionalData_t
|
||||
* @brief Structure for storing the Additional Data
|
||||
*
|
||||
*/
|
||||
typedef VL53L1_additional_data_t VL53L1_AdditionalData_t;
|
||||
|
||||
|
||||
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. */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_define_RangeStatus_group Defines the Range Status
|
||||
* @{
|
||||
*/
|
||||
#define VL53L1_RANGESTATUS_RANGE_VALID 0
|
||||
/*!<The Range is valid. */
|
||||
#define VL53L1_RANGESTATUS_SIGMA_FAIL 1
|
||||
/*!<Sigma Fail. */
|
||||
#define VL53L1_RANGESTATUS_SIGNAL_FAIL 2
|
||||
/*!<Signal fail. */
|
||||
#define VL53L1_RANGESTATUS_RANGE_VALID_MIN_RANGE_CLIPPED 3
|
||||
/*!<Target is below minimum detection threshold. */
|
||||
#define VL53L1_RANGESTATUS_OUTOFBOUNDS_FAIL 4
|
||||
/*!<Phase out of valid limits - different to a wrap exit. */
|
||||
#define VL53L1_RANGESTATUS_HARDWARE_FAIL 5
|
||||
/*!<Hardware fail. */
|
||||
#define VL53L1_RANGESTATUS_RANGE_VALID_NO_WRAP_CHECK_FAIL 6
|
||||
/*!<The Range is valid but the wraparound check has not been done. */
|
||||
#define VL53L1_RANGESTATUS_WRAP_TARGET_FAIL 7
|
||||
/*!<Wrapped target - no matching phase in other VCSEL period timing. */
|
||||
#define VL53L1_RANGESTATUS_PROCESSING_FAIL 8
|
||||
/*!<Internal algo underflow or overflow in lite ranging. */
|
||||
#define VL53L1_RANGESTATUS_XTALK_SIGNAL_FAIL 9
|
||||
/*!<Specific to lite ranging. */
|
||||
#define VL53L1_RANGESTATUS_SYNCRONISATION_INT 10
|
||||
/*!<1st interrupt when starting ranging in back to back mode. Ignore data. */
|
||||
#define VL53L1_RANGESTATUS_RANGE_VALID_MERGED_PULSE 11
|
||||
/*!<All Range ok but object is result of multiple pulses merging together.
|
||||
* Used by RQL for merged pulse detection
|
||||
*/
|
||||
#define VL53L1_RANGESTATUS_TARGET_PRESENT_LACK_OF_SIGNAL 12
|
||||
/*!<Used by RQL as different to phase fail. */
|
||||
#define VL53L1_RANGESTATUS_MIN_RANGE_FAIL 13
|
||||
/*!<User ROI input is not valid e.g. beyond SPAD Array.*/
|
||||
#define VL53L1_RANGESTATUS_RANGE_INVALID 14
|
||||
/*!<lld returned valid range but negative value ! */
|
||||
#define VL53L1_RANGESTATUS_NONE 255
|
||||
/*!<No Update. */
|
||||
|
||||
/** @} VL53L1_define_RangeStatus_group */
|
||||
|
||||
|
||||
/** @brief Contains the Internal data of the Bare Driver
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
VL53L1_LLDriverData_t LLData;
|
||||
/*!< Low Level Driver data structure */
|
||||
|
||||
VL53L1_LLDriverResults_t llresults;
|
||||
/*!< Low Level Driver data structure */
|
||||
|
||||
VL53L1_State PalState; /* Store the pal state */
|
||||
VL53L1_DeviceParameters_t CurrentParameters;
|
||||
/*!< Current Device Parameter */
|
||||
|
||||
} VL53L1_DevData_t;
|
||||
|
||||
|
||||
/* MACRO Definitions */
|
||||
/** @defgroup VL53L1_define_GeneralMacro_group General Macro Defines
|
||||
* General Macro Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Defines */
|
||||
#define VL53L1_SETPARAMETERFIELD(Dev, field, value) \
|
||||
(VL53L1DevDataSet(Dev, CurrentParameters.field, value))
|
||||
|
||||
#define VL53L1_GETPARAMETERFIELD(Dev, field, variable) \
|
||||
(variable = VL53L1DevDataGet(Dev, CurrentParameters).field)
|
||||
|
||||
|
||||
#define VL53L1_SETARRAYPARAMETERFIELD(Dev, field, index, value) \
|
||||
(VL53L1DevDataSet(Dev, CurrentParameters.field[index], value))
|
||||
|
||||
#define VL53L1_GETARRAYPARAMETERFIELD(Dev, field, index, variable) \
|
||||
(variable = VL53L1DevDataGet(Dev, CurrentParameters).field[index])
|
||||
|
||||
|
||||
#define VL53L1_SETDEVICESPECIFICPARAMETER(Dev, field, value) \
|
||||
(VL53L1DevDataSet(Dev, DeviceSpecificParameters.field, value))
|
||||
|
||||
#define VL53L1_GETDEVICESPECIFICPARAMETER(Dev, field) \
|
||||
(VL53L1DevDataGet(Dev, DeviceSpecificParameters).field)
|
||||
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT44(Value) \
|
||||
(uint16_t)((Value>>12)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT44TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<12)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT72(Value) \
|
||||
(uint16_t)((Value>>14)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT72TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<14)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT97(Value) \
|
||||
(uint16_t)((Value>>9)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT97TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<9)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT88(Value) \
|
||||
(uint16_t)((Value>>8)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT88TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<8)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT412(Value) \
|
||||
(uint16_t)((Value>>4)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT412TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<4)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT313(Value) \
|
||||
(uint16_t)((Value>>3)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT313TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<3)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT08(Value) \
|
||||
(uint8_t)((Value>>8)&0x00FF)
|
||||
#define VL53L1_FIXPOINT08TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<8)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT53(Value) \
|
||||
(uint8_t)((Value>>13)&0x00FF)
|
||||
#define VL53L1_FIXPOINT53TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<13)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT102(Value) \
|
||||
(uint16_t)((Value>>14)&0x0FFF)
|
||||
#define VL53L1_FIXPOINT102TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<14)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT142(Value) \
|
||||
(uint16_t)((Value>>14)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT142TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<14)
|
||||
|
||||
#define VL53L1_FIXPOINT1616TOFIXPOINT160(Value) \
|
||||
(uint16_t)((Value>>16)&0xFFFF)
|
||||
#define VL53L1_FIXPOINT160TOFIXPOINT1616(Value) \
|
||||
(FixPoint1616_t)((uint32_t)Value<<16)
|
||||
|
||||
#define VL53L1_MAKEUINT16(lsb, msb) (uint16_t)((((uint16_t)msb)<<8) + \
|
||||
(uint16_t)lsb)
|
||||
|
||||
#ifndef SUPPRESS_UNUSED_WARNING
|
||||
#define SUPPRESS_UNUSED_WARNING(x) ((void) (x))
|
||||
#endif
|
||||
|
||||
/** @} VL53L1_define_GeneralMacro_group */
|
||||
|
||||
/** @} VL53L1_globaldefine_group */
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _VL53L1_DEF_H_ */
|
|
@ -0,0 +1,253 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_error_codes.h
|
||||
*
|
||||
* @brief Error Code definitions for VL53L1 API.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_ERROR_CODES_H_
|
||||
#define _VL53L1_ERROR_CODES_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************
|
||||
* PRIVATE define do not edit
|
||||
****************************************/
|
||||
|
||||
/** @defgroup VL53L1_define_Error_group Error and Warning code returned by API
|
||||
* The following DEFINE are used to identify the PAL ERROR
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef int8_t VL53L1_Error;
|
||||
|
||||
#define VL53L1_ERROR_NONE ((VL53L1_Error) 0)
|
||||
#define VL53L1_ERROR_CALIBRATION_WARNING ((VL53L1_Error) - 1)
|
||||
/*!< Warning invalid calibration data may be in used
|
||||
\a VL53L1_InitData()
|
||||
\a VL53L1_GetOffsetCalibrationData
|
||||
\a VL53L1_SetOffsetCalibrationData */
|
||||
#define VL53L1_ERROR_MIN_CLIPPED ((VL53L1_Error) - 2)
|
||||
/*!< Warning parameter passed was clipped to min before to be applied */
|
||||
|
||||
#define VL53L1_ERROR_UNDEFINED ((VL53L1_Error) - 3)
|
||||
/*!< Unqualified error */
|
||||
#define VL53L1_ERROR_INVALID_PARAMS ((VL53L1_Error) - 4)
|
||||
/*!< Parameter passed is invalid or out of range */
|
||||
#define VL53L1_ERROR_NOT_SUPPORTED ((VL53L1_Error) - 5)
|
||||
/*!< Function is not supported in current mode or configuration */
|
||||
#define VL53L1_ERROR_RANGE_ERROR ((VL53L1_Error) - 6)
|
||||
/*!< Device report a ranging error interrupt status */
|
||||
#define VL53L1_ERROR_TIME_OUT ((VL53L1_Error) - 7)
|
||||
/*!< Aborted due to time out */
|
||||
#define VL53L1_ERROR_MODE_NOT_SUPPORTED ((VL53L1_Error) - 8)
|
||||
/*!< Asked mode is not supported by the device */
|
||||
#define VL53L1_ERROR_BUFFER_TOO_SMALL ((VL53L1_Error) - 9)
|
||||
/*!< ... */
|
||||
#define VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL ((VL53L1_Error) - 10)
|
||||
/*!< Supplied buffer is larger than I2C supports */
|
||||
#define VL53L1_ERROR_GPIO_NOT_EXISTING ((VL53L1_Error) - 11)
|
||||
/*!< User tried to setup a non-existing GPIO pin */
|
||||
#define VL53L1_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED ((VL53L1_Error) - 12)
|
||||
/*!< unsupported GPIO functionality */
|
||||
#define VL53L1_ERROR_CONTROL_INTERFACE ((VL53L1_Error) - 13)
|
||||
/*!< error reported from IO functions */
|
||||
#define VL53L1_ERROR_INVALID_COMMAND ((VL53L1_Error) - 14)
|
||||
/*!< The command is not allowed in the current device state
|
||||
* (power down) */
|
||||
#define VL53L1_ERROR_DIVISION_BY_ZERO ((VL53L1_Error) - 15)
|
||||
/*!< In the function a division by zero occurs */
|
||||
#define VL53L1_ERROR_REF_SPAD_INIT ((VL53L1_Error) - 16)
|
||||
/*!< Error during reference SPAD initialization */
|
||||
#define VL53L1_ERROR_GPH_SYNC_CHECK_FAIL ((VL53L1_Error) - 17)
|
||||
/*!< GPH sync interrupt check fail - API out of sync with device*/
|
||||
#define VL53L1_ERROR_STREAM_COUNT_CHECK_FAIL ((VL53L1_Error) - 18)
|
||||
/*!< Stream count check fail - API out of sync with device */
|
||||
#define VL53L1_ERROR_GPH_ID_CHECK_FAIL ((VL53L1_Error) - 19)
|
||||
/*!< GPH ID check fail - API out of sync with device */
|
||||
#define VL53L1_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL ((VL53L1_Error) - 20)
|
||||
/*!< Zone dynamic config stream count check failed - API out of sync */
|
||||
#define VL53L1_ERROR_ZONE_GPH_ID_CHECK_FAIL ((VL53L1_Error) - 21)
|
||||
/*!< Zone dynamic config GPH ID check failed - API out of sync */
|
||||
|
||||
#define VL53L1_ERROR_XTALK_EXTRACTION_NO_SAMPLE_FAIL ((VL53L1_Error) - 22)
|
||||
/*!< Thrown when run_xtalk_extraction fn has 0 succesful samples
|
||||
* when using the full array to sample the xtalk. In this case there is
|
||||
* not enough information to generate new Xtalk parm info. The function
|
||||
* will exit and leave the current xtalk parameters unaltered */
|
||||
#define VL53L1_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL ((VL53L1_Error) - 23)
|
||||
/*!< Thrown when run_xtalk_extraction fn has found that the
|
||||
* avg sigma estimate of the full array xtalk sample is > than the
|
||||
* maximal limit allowed. In this case the xtalk sample is too noisy for
|
||||
* measurement. The function will exit and leave the current xtalk parameters
|
||||
* unaltered. */
|
||||
|
||||
|
||||
#define VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL ((VL53L1_Error) - 24)
|
||||
/*!< Thrown if there one of stages has no valid offset calibration
|
||||
* samples. A fatal error calibration not valid */
|
||||
#define VL53L1_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL ((VL53L1_Error) - 25)
|
||||
/*!< Thrown if there one of stages has zero effective SPADS
|
||||
* Traps the case when MM1 SPADs is zero.
|
||||
* A fatal error calibration not valid */
|
||||
#define VL53L1_ERROR_ZONE_CAL_NO_SAMPLE_FAIL ((VL53L1_Error) - 26)
|
||||
/*!< Thrown if then some of the zones have no valid samples
|
||||
* A fatal error calibration not valid */
|
||||
|
||||
#define VL53L1_ERROR_TUNING_PARM_KEY_MISMATCH ((VL53L1_Error) - 27)
|
||||
/*!< Thrown if the tuning file key table version does not match with
|
||||
* expected value. The driver expects the key table version to match
|
||||
* the compiled default version number in the define
|
||||
* #VL53L1_TUNINGPARM_KEY_TABLE_VERSION_DEFAULT
|
||||
* */
|
||||
|
||||
#define VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS ((VL53L1_Error) - 28)
|
||||
/*!< Thrown if there are less than 5 good SPADs are available. */
|
||||
#define VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH ((VL53L1_Error) - 29)
|
||||
/*!< Thrown if the final reference rate is greater than
|
||||
the upper reference rate limit - default is 40 Mcps.
|
||||
Implies a minimum Q3 (x10) SPAD (5) selected */
|
||||
#define VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW ((VL53L1_Error) - 30)
|
||||
/*!< Thrown if the final reference rate is less than
|
||||
the lower reference rate limit - default is 10 Mcps.
|
||||
Implies maximum Q1 (x1) SPADs selected */
|
||||
|
||||
|
||||
#define VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES ((VL53L1_Error) - 31)
|
||||
/*!< Thrown if there is less than the requested number of
|
||||
* valid samples. */
|
||||
#define VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH ((VL53L1_Error) - 32)
|
||||
/*!< Thrown if the offset calibration range sigma estimate is greater
|
||||
* than 8.0 mm. This is the recommended min value to yield a stable
|
||||
* offset measurement */
|
||||
#define VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH ((VL53L1_Error) - 33)
|
||||
/*!< Thrown when VL53L1_run_offset_calibration() peak rate is greater
|
||||
than that 50.0Mcps. This is the recommended max rate to avoid
|
||||
pile-up influencing the offset measurement */
|
||||
#define VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW ((VL53L1_Error) - 34)
|
||||
/*!< Thrown when VL53L1_run_offset_calibration() when one of stages
|
||||
range has less that 5.0 effective SPADS. This is the recommended
|
||||
min value to yield a stable offset */
|
||||
|
||||
|
||||
#define VL53L1_WARNING_ZONE_CAL_MISSING_SAMPLES ((VL53L1_Error) - 35)
|
||||
/*!< Thrown if one of more of the zones have less than
|
||||
the requested number of valid samples */
|
||||
#define VL53L1_WARNING_ZONE_CAL_SIGMA_TOO_HIGH ((VL53L1_Error) - 36)
|
||||
/*!< Thrown if one or more zones have sigma estimate value greater
|
||||
* than 8.0 mm. This is the recommended min value to yield a stable
|
||||
* offset measurement */
|
||||
#define VL53L1_WARNING_ZONE_CAL_RATE_TOO_HIGH ((VL53L1_Error) - 37)
|
||||
/*!< Thrown if one of more zones have peak rate higher than
|
||||
that 50.0Mcps. This is the recommended max rate to avoid
|
||||
pile-up influencing the offset measurement */
|
||||
|
||||
|
||||
#define VL53L1_WARNING_XTALK_MISSING_SAMPLES ((VL53L1_Error) - 38)
|
||||
/*!< Thrown to notify that some of the xtalk samples did not yield
|
||||
* valid ranging pulse data while attempting to measure
|
||||
* the xtalk signal in vl53l1_run_xtalk_extract(). This can signify any of
|
||||
* the zones are missing samples, for further debug information the
|
||||
* xtalk_results struct should be referred to. This warning is for
|
||||
* notification only, the xtalk pulse and shape have still been generated
|
||||
*/
|
||||
#define VL53L1_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT ((VL53L1_Error) - 39)
|
||||
/*!< Thrown to notify that some of teh xtalk samples used for gradient
|
||||
* generation did not yield valid ranging pulse data while attempting to
|
||||
* measure the xtalk signal in vl53l1_run_xtalk_extract(). This can signify
|
||||
* that any one of the zones 0-3 yielded no successful samples. The
|
||||
* xtalk_results struct should be referred to for further debug info.
|
||||
* This warning is for notification only, the xtalk pulse and shape
|
||||
* have still been generated.
|
||||
*/
|
||||
#define VL53L1_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT ((VL53L1_Error) - 40)
|
||||
/*!< Thrown to notify that some of the xtalk samples used for gradient
|
||||
* generation did not pass the sigma limit check while attempting to
|
||||
* measure the xtalk signal in vl53l1_run_xtalk_extract(). This can signify
|
||||
* that any one of the zones 0-3 yielded an avg sigma_mm value > the limit.
|
||||
* The xtalk_results struct should be referred to for further debug info.
|
||||
* This warning is for notification only, the xtalk pulse and shape
|
||||
* have still been generated.
|
||||
*/
|
||||
|
||||
#define VL53L1_ERROR_NOT_IMPLEMENTED ((VL53L1_Error) - 41)
|
||||
/*!< Tells requested functionality has not been implemented yet or
|
||||
* not compatible with the device */
|
||||
#define VL53L1_ERROR_PLATFORM_SPECIFIC_START ((VL53L1_Error) - 60)
|
||||
/*!< Tells the starting code for platform */
|
||||
/** @} VL53L1_define_Error_group */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _VL53L1_ERROR_CODES_H_ */
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_error_exceptions.h
|
||||
*
|
||||
* @brief EwokPlus25 LL Driver definitions for control of error handling in LL driver
|
||||
*/
|
||||
|
||||
#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 /* _VL53L1_ERROR_EXCEPTIONS_H_ */
|
|
@ -0,0 +1,209 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_error_strings.h
|
||||
* @brief VL53L1 function declarations for decoding error codes to a
|
||||
* text strings
|
||||
*/
|
||||
|
||||
|
||||
#ifndef VL53L1_ERROR_STRINGS_H_
|
||||
#define VL53L1_ERROR_STRINGS_H_
|
||||
|
||||
#include "vl53l1_error_codes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
|
||||
#ifndef VL53L1_USE_EMPTY_STRING
|
||||
|
||||
/* PAL ERROR strings */
|
||||
#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 sigma 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 sigma 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 /* VL53L1_USE_EMPTY_STRING */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,698 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_ll_device.h
|
||||
*
|
||||
* @brief LL Driver Device specific defines. To be adapted by implementer for the
|
||||
* targeted device.
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_LL_DEVICE_H_
|
||||
#define _VL53L1_LL_DEVICE_H_
|
||||
|
||||
#include "vl53l1_types.h"
|
||||
#include "vl53l1_platform_user_config.h"
|
||||
|
||||
#define VL53L1_I2C 0x01
|
||||
#define VL53L1_SPI 0x00
|
||||
|
||||
|
||||
/** @defgroup VL53L1_DevSpecDefines_group VL53L1 Device Specific Defines
|
||||
* @brief VL53L1 cut1.0 Device Specific Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup VL53L1_define_WaitMethod_group Defines Wait method used
|
||||
* For example blocking versus non blocking
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_WaitMethod;
|
||||
|
||||
#define VL53L1_WAIT_METHOD_BLOCKING ((VL53L1_WaitMethod) 0)
|
||||
#define VL53L1_WAIT_METHOD_NON_BLOCKING ((VL53L1_WaitMethod) 1)
|
||||
|
||||
/** @} end of VL53L1_define_WaitMethod_group */
|
||||
|
||||
/** @defgroup VL53L1_define_DeviceState_group Device State
|
||||
*
|
||||
* @brief Defines all possible device states for the device
|
||||
* @{
|
||||
*/
|
||||
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)
|
||||
|
||||
/** @} end of VL53L1_define_DeviceState_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_define_DevicePresetModes_group Device Preset Modes
|
||||
*
|
||||
* @brief Defines all possible device preset modes. The integer values are
|
||||
* kept the same as main EwokPlus driver branch
|
||||
* @{
|
||||
*/
|
||||
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_OLT ((VL53L1_DevicePresetModes) 17)
|
||||
#define VL53L1_DEVICEPRESETMODE_SINGLESHOT_RANGING ((VL53L1_DevicePresetModes) 18)
|
||||
#define VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_SHORT_RANGE ((VL53L1_DevicePresetModes) 36)
|
||||
#define VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_MEDIUM_RANGE ((VL53L1_DevicePresetModes) 37)
|
||||
#define VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_LONG_RANGE ((VL53L1_DevicePresetModes) 38)
|
||||
|
||||
/** @} end of VL53L1_define_DevicePresetModes_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_define_DeviceMeasurementModes_group Device Measurement Modes
|
||||
*
|
||||
* @brief Defines all possible measurement modes for the device
|
||||
* @{
|
||||
*/
|
||||
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)
|
||||
|
||||
/** @} VL53L1_define_DeviceMeasurementModes_group */
|
||||
|
||||
/** @defgroup VL53L1_define_OffsetCalibrationModes_group Device Offset Calibration Mode
|
||||
*
|
||||
* @brief Defines possible offset calibration modes for the device
|
||||
* @{
|
||||
*/
|
||||
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)
|
||||
#define VL53L1_OFFSETCALIBRATIONMODE__PER_ZONE ((VL53L1_OffsetCalibrationMode) 5)
|
||||
|
||||
/** @} VL53L1_define_OffsetCalibrationModes_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_define_OffsetCalibrationModes_group Device Offset Correction Mode
|
||||
*
|
||||
* @brief Defines all possible offset correction modes for the device
|
||||
* @{
|
||||
*/
|
||||
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)
|
||||
|
||||
/** @} VL53L1_define_OffsetCalibrationModes_group */
|
||||
|
||||
|
||||
|
||||
/** @defgroup VL53L1_DeviceSequenceConfig_group Device Sequence Config
|
||||
*
|
||||
* @brief Individual bit enables for each stage in the ranging scheduler
|
||||
* The values below encode the bit shift for each bit
|
||||
* @{
|
||||
*/
|
||||
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)
|
||||
|
||||
/** @} VL53L1_DeviceSequenceConfig_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_DeviceInterruptPolarity_group Device Interrupt Polarity
|
||||
*
|
||||
* @brief Device Interrupt Polarity
|
||||
* @{
|
||||
*/
|
||||
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)
|
||||
|
||||
/** @} VL53L1_DeviceInterruptPolarity_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_DeviceGpioMode_group Device GPIO Mode
|
||||
*
|
||||
* @brief Device Gpio Mode
|
||||
* @{
|
||||
*/
|
||||
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)
|
||||
|
||||
/** @} VL53L1_DeviceGpioMode_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_DeviceError_group Device Error
|
||||
*
|
||||
* @brief Device Error code in the range status
|
||||
*
|
||||
* This enum is Device specific it should be updated in the implementation
|
||||
* Use @a VL53L1_GetStatusErrorString() to get the string.
|
||||
* It is related to Status Register of the Device.
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_DeviceError;
|
||||
|
||||
#define VL53L1_DEVICEERROR_NOUPDATE ((VL53L1_DeviceError) 0)
|
||||
/*!< 0 No Update */
|
||||
#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)
|
||||
#define VL53L1_DEVICEERROR_MINSIGNALEVENTCHECK ((VL53L1_DeviceError) 21)
|
||||
#define VL53L1_DEVICEERROR_RANGECOMPLETE_MERGED_PULSE ((VL53L1_DeviceError) 22)
|
||||
|
||||
/* Patch_NewDeviceErrorCodePrevRangeNoTargets_11786 */
|
||||
#define VL53L1_DEVICEERROR_PREV_RANGE_NO_TARGETS ((VL53L1_DeviceError) 23)
|
||||
|
||||
/** @} end of VL53L1_DeviceError_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_DeviceReportStatus_group Device Report Status
|
||||
* @brief Device Report Status code
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_DeviceReportStatus;
|
||||
|
||||
#define VL53L1_DEVICEREPORTSTATUS_NOUPDATE ((VL53L1_DeviceReportStatus) 0)
|
||||
/*!< 0 No Update */
|
||||
#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)
|
||||
|
||||
/** @} end of VL53L1_DeviceReportStatus_group */
|
||||
|
||||
/** @defgroup VL53L1_DeviceDssMode_group Dynamic SPAD Selection Mode
|
||||
* @brief Selects the device Dynamic SPAD Selection Mode
|
||||
* @{
|
||||
*/
|
||||
|
||||
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)
|
||||
|
||||
/** @} end of VL53L1_DeviceDssMode_group */
|
||||
|
||||
/** @defgroup VL53L1_DeviceConfigLevel_group Device Config Level
|
||||
*
|
||||
* @brief Defines the contents of the config & start range I2C multi byte transaction
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_DeviceConfigLevel;
|
||||
|
||||
#define VL53L1_DEVICECONFIGLEVEL_SYSTEM_CONTROL \
|
||||
((VL53L1_DeviceConfigLevel) 0)
|
||||
/*!< Configs system control & start range */
|
||||
#define VL53L1_DEVICECONFIGLEVEL_DYNAMIC_ONWARDS \
|
||||
((VL53L1_DeviceConfigLevel) 1)
|
||||
/*!< Dynamic config onwards (dynamic_config, system_control) & start range */
|
||||
#define VL53L1_DEVICECONFIGLEVEL_TIMING_ONWARDS \
|
||||
((VL53L1_DeviceConfigLevel) 2)
|
||||
/*!< Dynamic config onwards (timing config, dynamic_config, system_control) &
|
||||
start range */
|
||||
#define VL53L1_DEVICECONFIGLEVEL_GENERAL_ONWARDS \
|
||||
((VL53L1_DeviceConfigLevel) 3)
|
||||
/*!< General config onwards (general_config, timing config, dynamic_config,
|
||||
system_control) & start range */
|
||||
#define VL53L1_DEVICECONFIGLEVEL_STATIC_ONWARDS \
|
||||
((VL53L1_DeviceConfigLevel) 4)
|
||||
/*!< Static config onwards (static_config, general_config, timing_config,
|
||||
dynamic_config, system_control) & start range */
|
||||
#define VL53L1_DEVICECONFIGLEVEL_CUSTOMER_ONWARDS \
|
||||
((VL53L1_DeviceConfigLevel) 5)
|
||||
/*!< Full device config (customer_nvm_managed, static_config, general_config,
|
||||
timing config, dynamic_config, system_control) & start range */
|
||||
#define VL53L1_DEVICECONFIGLEVEL_FULL \
|
||||
((VL53L1_DeviceConfigLevel) 6)
|
||||
/*!< Full device config (static_nvm_managed, customer_nvm_managed, static_config,
|
||||
general_config, timing config, dynamic_config, system_control) & start range */
|
||||
|
||||
/** @} end of VL53L1_DeviceConfigLevel_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_DeviceResultsLevel_group Device Results Level
|
||||
*
|
||||
* @brief Defines the contents of the read results I2C multi byte transaction
|
||||
* @{
|
||||
*/
|
||||
typedef uint8_t VL53L1_DeviceResultsLevel;
|
||||
|
||||
#define VL53L1_DEVICERESULTSLEVEL_SYSTEM_RESULTS \
|
||||
((VL53L1_DeviceResultsLevel) 0)
|
||||
/*!< Read just system_results */
|
||||
#define VL53L1_DEVICERESULTSLEVEL_UPTO_CORE \
|
||||
((VL53L1_DeviceResultsLevel) 1)
|
||||
/*!< Read both system and core results */
|
||||
#define VL53L1_DEVICERESULTSLEVEL_FULL \
|
||||
((VL53L1_DeviceResultsLevel) 2)
|
||||
/*!< Read system, core and debug results */
|
||||
|
||||
/** @} end of VL53L1_DeviceResultsLevel_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_DeviceTestMode_group Device Test Mode
|
||||
*
|
||||
* @brief Values below match the the TEST_MODE__CTRL register
|
||||
* do not change
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef uint8_t VL53L1_DeviceTestMode;
|
||||
|
||||
#define VL53L1_DEVICETESTMODE_NONE \
|
||||
((VL53L1_DeviceTestMode) 0x00)
|
||||
/*!< Idle */
|
||||
#define VL53L1_DEVICETESTMODE_NVM_ZERO \
|
||||
((VL53L1_DeviceTestMode) 0x01)
|
||||
/*!< NVM zero */
|
||||
#define VL53L1_DEVICETESTMODE_NVM_COPY \
|
||||
((VL53L1_DeviceTestMode) 0x02)
|
||||
/*!< NVM copy */
|
||||
#define VL53L1_DEVICETESTMODE_PATCH \
|
||||
((VL53L1_DeviceTestMode) 0x03)
|
||||
/*!< Patch */
|
||||
#define VL53L1_DEVICETESTMODE_DCR \
|
||||
((VL53L1_DeviceTestMode) 0x04)
|
||||
/*!< DCR - SPAD Self-Check (Pass if Count Rate is less than Threshold) */
|
||||
#define VL53L1_DEVICETESTMODE_LCR_VCSEL_OFF \
|
||||
((VL53L1_DeviceTestMode) 0x05)
|
||||
/*!< LCR - SPAD Self-Check (Pass if Count Rate is greater than Threshold
|
||||
and VCSEL off) */
|
||||
#define VL53L1_DEVICETESTMODE_LCR_VCSEL_ON \
|
||||
((VL53L1_DeviceTestMode) 0x06)
|
||||
/*!< LCR - SPAD Self-Check (Pass if Count Rate is greater than Threshold
|
||||
and VCSEL on) */
|
||||
#define VL53L1_DEVICETESTMODE_SPOT_CENTRE_LOCATE \
|
||||
((VL53L1_DeviceTestMode) 0x07)
|
||||
/*!< Spot centre locate */
|
||||
#define VL53L1_DEVICETESTMODE_REF_SPAD_CHAR_WITH_PRE_VHV \
|
||||
((VL53L1_DeviceTestMode) 0x08)
|
||||
/*!<Reference SPAD Characterisation with pre-VHV */
|
||||
#define VL53L1_DEVICETESTMODE_REF_SPAD_CHAR_ONLY \
|
||||
((VL53L1_DeviceTestMode) 0x09)
|
||||
/*!< Reference SPAD Characterisation Only */
|
||||
|
||||
/** @} end of VL53L1_DeviceTestMode_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_DeviceSscArray_group Device Test Mode
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef uint8_t VL53L1_DeviceSscArray;
|
||||
|
||||
#define VL53L1_DEVICESSCARRAY_RTN ((VL53L1_DeviceSscArray) 0x00)
|
||||
/*!<Return Array Rates */
|
||||
#define VL53L1_DEVICETESTMODE_REF ((VL53L1_DeviceSscArray) 0x01)
|
||||
/*!< Reference Array Rates Only */
|
||||
|
||||
/** @} end of VL53L1_DeviceSscArray_group */
|
||||
|
||||
|
||||
/** @defgroup VL53L1_SpadArraySelection_group SPAD Array Selection Functionality
|
||||
* @brief SPAD array selection definitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define VL53L1_RETURN_ARRAY_ONLY 0x01
|
||||
/*!< Return SPAD Array only */
|
||||
#define VL53L1_REFERENCE_ARRAY_ONLY 0x10
|
||||
/*!< Reference SPAD Array only */
|
||||
#define VL53L1_BOTH_RETURN_AND_REFERENCE_ARRAYS 0x11
|
||||
/*!< Both Return and Reference SPAD Arrays */
|
||||
#define VL53L1_NEITHER_RETURN_AND_REFERENCE_ARRAYS 0x00
|
||||
/*!< Neither Return or Reference SPAD Array */
|
||||
|
||||
/** @} end of VL53L1_SpadArraySelection_group */
|
||||
|
||||
/** @defgroup VL53L1_DeviceInterruptLevel_group Interrupt Level Functionality
|
||||
* @brief Interrupt Output Level types
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_HIGH 0x00
|
||||
/*!< Active High Interrupt */
|
||||
#define VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_LOW 0x10
|
||||
/*!< Active Low Interrupt */
|
||||
#define VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_MASK 0x10
|
||||
/*!< Active Bit Mask */
|
||||
|
||||
/** @} end of VL53L1_DeviceInterruptLevel_group */
|
||||
|
||||
/** @defgroup VL53L1_ApiCore_group Misc Functionality
|
||||
* @brief API core specific definitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define VL53L1_POLLING_DELAY_US 1000
|
||||
/*!< 1000us delay for register polling */
|
||||
#define VL53L1_SOFTWARE_RESET_DURATION_US 100
|
||||
/*!< 100us software reset duration */
|
||||
#define VL53L1_FIRMWARE_BOOT_TIME_US 1200
|
||||
/*!< Duration of firmware boot time for which I2C
|
||||
access is blocked. Real Device 1ms, FPGA 15ms */
|
||||
#define VL53L1_ENABLE_POWERFORCE_SETTLING_TIME_US 250
|
||||
/*!< After enabling power force a delay is required
|
||||
to bring regulator, bandgap, oscillator time
|
||||
to power up and settle */
|
||||
#define VL53L1_SPAD_ARRAY_WIDTH 16
|
||||
/*!< SPAD array width */
|
||||
#define VL53L1_SPAD_ARRAY_HEIGHT 16
|
||||
/*!< SPAD array height */
|
||||
#define VL53L1_NVM_SIZE_IN_BYTES 512
|
||||
/*!< NVM (OTP) size in bytes */
|
||||
#define VL53L1_NO_OF_SPAD_ENABLES 256
|
||||
/*!< Number of SPADs each SPAD array */
|
||||
#define VL53L1_RTN_SPAD_BUFFER_SIZE 32
|
||||
/*!< Number of Return SPAD enable registers (bytes) */
|
||||
#define VL53L1_REF_SPAD_BUFFER_SIZE 6
|
||||
/*!< Number of Reference SPAD enable registers (bytes) */
|
||||
#define VL53L1_AMBIENT_WINDOW_VCSEL_PERIODS 256
|
||||
/*!< Sigma Delta Ambient window in VCSEL Periods */
|
||||
#define VL53L1_RANGING_WINDOW_VCSEL_PERIODS 2048
|
||||
/*!< Sigma Delta Ranging window in VCSEL periods */
|
||||
#define VL53L1_MACRO_PERIOD_VCSEL_PERIODS \
|
||||
(VL53L1_AMBIENT_WINDOW_VCSEL_PERIODS + VL53L1_RANGING_WINDOW_VCSEL_PERIODS)
|
||||
/*!< Macro Period in VCSEL periods */
|
||||
#define VL53L1_MAX_ALLOWED_PHASE 0xFFFF
|
||||
/*!< Maximum Allowed phase 0xFFFF means 31.999 PLL Clocks */
|
||||
|
||||
#define VL53L1_RTN_SPAD_UNITY_TRANSMISSION 0x0100
|
||||
/*!< SPAD unity transmission value - 1.0 in 8.8 format */
|
||||
#define VL53L1_RTN_SPAD_APERTURE_TRANSMISSION 0x0038
|
||||
/*!< Apertured SPAD transmission value - 8.8 format
|
||||
Nominal: 5x -> 0.200000 * 256 = 51 = 0x33
|
||||
Measured: 4.6x -> 0.217391 * 256 = 56 = 0x38 */
|
||||
|
||||
#define VL53L1_SPAD_TOTAL_COUNT_MAX ((0x01 << 29) - 1)
|
||||
/*!< Maximum SPAD count - 512Mcps * 1sec = 29bits) */
|
||||
#define VL53L1_SPAD_TOTAL_COUNT_RES_THRES (0x01 << 24)
|
||||
/*!< SPAD count threshold for reduced 3-bit fractional resolution */
|
||||
#define VL53L1_COUNT_RATE_INTERNAL_MAX ((0x01 << 24) - 1)
|
||||
/*!< Maximum internal count rate is a 17.7 (24-b) value */
|
||||
#define VL53L1_SPEED_OF_LIGHT_IN_AIR 299704
|
||||
/*!< Speed of light in air in mm/sec */
|
||||
#define VL53L1_SPEED_OF_LIGHT_IN_AIR_DIV_8 (299704 >> 3)
|
||||
/*!< Speed of light in air in divided by 8, 2 for round trip
|
||||
and 4 as an additional scaling factor */
|
||||
|
||||
/** @} end of VL53L1_ApiCore_group */
|
||||
|
||||
/** @} end of VL53L1_DevSpecDefines_group */
|
||||
|
||||
/** @defgroup VL53L1_GPIO_Interrupt_Mode_group Interrupt modes
|
||||
* @brief Selects between four interrupt modes
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef uint8_t VL53L1_GPIO_Interrupt_Mode;
|
||||
|
||||
#define VL53L1_GPIOINTMODE_LEVEL_LOW \
|
||||
((VL53L1_GPIO_Interrupt_Mode) 0)
|
||||
/*!< Trigger interupt if value < thresh_low */
|
||||
#define VL53L1_GPIOINTMODE_LEVEL_HIGH \
|
||||
((VL53L1_GPIO_Interrupt_Mode) 1)
|
||||
/*!< Trigger interupt if value > thresh_high */
|
||||
#define VL53L1_GPIOINTMODE_OUT_OF_WINDOW \
|
||||
((VL53L1_GPIO_Interrupt_Mode) 2)
|
||||
/*!< Trigger interupt if value < thresh_low OR value > thresh_high */
|
||||
#define VL53L1_GPIOINTMODE_IN_WINDOW \
|
||||
((VL53L1_GPIO_Interrupt_Mode) 3)
|
||||
/*!< Trigger interupt if value > thresh_low AND value < thresh_high */
|
||||
|
||||
/** @} end of VL53L1_GPIO_Interrupt_Mode_group */
|
||||
|
||||
/** @defgroup VL53L1_TuningParms_group Tuning Parameters
|
||||
* @brief Selects specific tuning parameter inputs to get/set \
|
||||
* Added as part of Patch_AddedTuningParms_11761
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef uint16_t VL53L1_TuningParms;
|
||||
|
||||
#define VL53L1_TUNINGPARMS_LLD_PUBLIC_MIN_ADDRESS \
|
||||
((VL53L1_TuningParms) VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS)
|
||||
#define VL53L1_TUNINGPARMS_LLD_PUBLIC_MAX_ADDRESS \
|
||||
((VL53L1_TuningParms) VL53L1_TUNINGPARM_LOWPOWERAUTO_RANGE_CONFIG_TIMEOUT_US)
|
||||
|
||||
#define VL53L1_TUNINGPARMS_LLD_PRIVATE_MIN_ADDRESS \
|
||||
((VL53L1_TuningParms) VL53L1_TUNINGPARM_PRIVATE_PAGE_BASE_ADDRESS)
|
||||
#define VL53L1_TUNINGPARMS_LLD_PRIVATE_MAX_ADDRESS \
|
||||
((VL53L1_TuningParms) VL53L1_TUNINGPARMS_LLD_PRIVATE_MIN_ADDRESS)
|
||||
|
||||
#define VL53L1_TUNINGPARM_VERSION \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 0))
|
||||
#define VL53L1_TUNINGPARM_KEY_TABLE_VERSION \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 1))
|
||||
#define VL53L1_TUNINGPARM_LLD_VERSION \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 2))
|
||||
#define VL53L1_TUNINGPARM_CONSISTENCY_LITE_PHASE_TOLERANCE \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 3))
|
||||
#define VL53L1_TUNINGPARM_PHASECAL_TARGET \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 4))
|
||||
#define VL53L1_TUNINGPARM_LITE_CAL_REPEAT_RATE \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 5))
|
||||
#define VL53L1_TUNINGPARM_LITE_RANGING_GAIN_FACTOR \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 6))
|
||||
#define VL53L1_TUNINGPARM_LITE_MIN_CLIP_MM \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 7))
|
||||
#define VL53L1_TUNINGPARM_LITE_LONG_SIGMA_THRESH_MM \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 8))
|
||||
#define VL53L1_TUNINGPARM_LITE_MED_SIGMA_THRESH_MM \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 9))
|
||||
#define VL53L1_TUNINGPARM_LITE_SHORT_SIGMA_THRESH_MM \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 10))
|
||||
#define VL53L1_TUNINGPARM_LITE_LONG_MIN_COUNT_RATE_RTN_MCPS \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 11))
|
||||
#define VL53L1_TUNINGPARM_LITE_MED_MIN_COUNT_RATE_RTN_MCPS \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 12))
|
||||
#define VL53L1_TUNINGPARM_LITE_SHORT_MIN_COUNT_RATE_RTN_MCPS \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 13))
|
||||
#define VL53L1_TUNINGPARM_LITE_SIGMA_EST_PULSE_WIDTH \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 14))
|
||||
#define VL53L1_TUNINGPARM_LITE_SIGMA_EST_AMB_WIDTH_NS \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 15))
|
||||
#define VL53L1_TUNINGPARM_LITE_SIGMA_REF_MM \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 16))
|
||||
#define VL53L1_TUNINGPARM_LITE_RIT_MULT \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 17))
|
||||
#define VL53L1_TUNINGPARM_LITE_SEED_CONFIG \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 18))
|
||||
#define VL53L1_TUNINGPARM_LITE_QUANTIFIER \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 19))
|
||||
#define VL53L1_TUNINGPARM_LITE_FIRST_ORDER_SELECT \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 20))
|
||||
#define VL53L1_TUNINGPARM_LITE_XTALK_MARGIN_KCPS \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 21))
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_LONG_RANGE \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 22))
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_MED_RANGE \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 23))
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_SHORT_RANGE \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 24))
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_LONG_RANGE \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 25))
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_MED_RANGE \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 26))
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_SHORT_RANGE \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 27))
|
||||
#define VL53L1_TUNINGPARM_TIMED_SEED_CONFIG \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 28))
|
||||
#define VL53L1_TUNINGPARM_VHV_LOOPBOUND \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 29))
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_DEVICE_TEST_MODE \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 30))
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_VCSEL_PERIOD \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 31))
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_PHASECAL_TIMEOUT_US \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 32))
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_TARGET_COUNT_RATE_MCPS \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 33))
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_MIN_COUNTRATE_LIMIT_MCPS \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 34))
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_MAX_COUNTRATE_LIMIT_MCPS \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 35))
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_DSS_RATE_MCPS \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 36))
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_PHASECAL_TIMEOUT_US \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 37))
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_MM_TIMEOUT_US \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 38))
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_RANGE_TIMEOUT_US \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 39))
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_PRE_SAMPLES \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 40))
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_MM1_SAMPLES \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 41))
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_MM2_SAMPLES \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 42))
|
||||
#define VL53L1_TUNINGPARM_SPADMAP_VCSEL_PERIOD \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 43))
|
||||
#define VL53L1_TUNINGPARM_SPADMAP_VCSEL_START \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 44))
|
||||
#define VL53L1_TUNINGPARM_SPADMAP_RATE_LIMIT_MCPS \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 45))
|
||||
#define VL53L1_TUNINGPARM_LITE_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 46))
|
||||
#define VL53L1_TUNINGPARM_TIMED_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 47))
|
||||
#define VL53L1_TUNINGPARM_LITE_PHASECAL_CONFIG_TIMEOUT_US \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 48))
|
||||
#define VL53L1_TUNINGPARM_TIMED_PHASECAL_CONFIG_TIMEOUT_US \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 49))
|
||||
#define VL53L1_TUNINGPARM_LITE_MM_CONFIG_TIMEOUT_US \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 50))
|
||||
#define VL53L1_TUNINGPARM_TIMED_MM_CONFIG_TIMEOUT_US \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 51))
|
||||
#define VL53L1_TUNINGPARM_LITE_RANGE_CONFIG_TIMEOUT_US \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 52))
|
||||
#define VL53L1_TUNINGPARM_TIMED_RANGE_CONFIG_TIMEOUT_US \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 53))
|
||||
#define VL53L1_TUNINGPARM_LOWPOWERAUTO_VHV_LOOP_BOUND \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 54))
|
||||
#define VL53L1_TUNINGPARM_LOWPOWERAUTO_MM_CONFIG_TIMEOUT_US \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 55))
|
||||
#define VL53L1_TUNINGPARM_LOWPOWERAUTO_RANGE_CONFIG_TIMEOUT_US \
|
||||
((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 56))
|
||||
|
||||
|
||||
/** @} end of VL53L1_TuningParms_group */
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* _VL53L1_DEVICE_H_ */
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,72 @@
|
|||
|
||||
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_PRESET_SETUP_H_
|
||||
#define _VL53L1_PRESET_SETUP_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* indexes for the bare driver tuning setting API function */
|
||||
enum VL53L1_Tuning_t {
|
||||
VL53L1_TUNING_VERSION = 0,
|
||||
VL53L1_TUNING_PROXY_MIN,
|
||||
VL53L1_TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM,
|
||||
VL53L1_TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER,
|
||||
VL53L1_TUNING_MIN_AMBIENT_DMAX_VALID,
|
||||
VL53L1_TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER,
|
||||
VL53L1_TUNING_XTALK_FULL_ROI_TARGET_DISTANCE_MM,
|
||||
VL53L1_TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT,
|
||||
VL53L1_TUNING_XTALK_FULL_ROI_BIN_SUM_MARGIN,
|
||||
VL53L1_TUNING_XTALK_FULL_ROI_DEFAULT_OFFSET,
|
||||
VL53L1_TUNING_ZERO_DISTANCE_OFFSET_NON_LINEAR_FACTOR,
|
||||
VL53L1_TUNING_PHASECAL_PATCH_POWER,
|
||||
VL53L1_TUNING_MAX_TUNABLE_KEY
|
||||
};
|
||||
|
||||
/* default values for the tuning settings parameters */
|
||||
#define TUNING_VERSION 0x0007
|
||||
|
||||
#define TUNING_PROXY_MIN -30 /* min distance in mm */
|
||||
#define TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM 600
|
||||
/* Target distance in mm for single target Xtalk */
|
||||
#define TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER 50
|
||||
/* Number of sample used for single target Xtalk */
|
||||
#define TUNING_MIN_AMBIENT_DMAX_VALID 8
|
||||
/* Minimum ambient level to state the Dmax returned by the device is valid */
|
||||
#define TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER 50
|
||||
/* Maximum loops to perform simple offset calibration */
|
||||
#define TUNING_XTALK_FULL_ROI_TARGET_DISTANCE_MM 600
|
||||
/* Target distance in mm for target Xtalk from Bins method*/
|
||||
#define TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT 1
|
||||
/* Number of loops done during the simple offset calibration*/
|
||||
#define TUNING_ZERO_DISTANCE_OFFSET_NON_LINEAR_FACTOR_DEFAULT 9
|
||||
/* zero distance offset calibration non linear compensation default value */
|
||||
|
||||
/* The following settings are related to the fix for ticket EwokP #558410 */
|
||||
#define TUNING_XTALK_FULL_ROI_BIN_SUM_MARGIN 24
|
||||
/* Acceptance margin for the xtalk_shape bin_data sum computation */
|
||||
#define TUNING_XTALK_FULL_ROI_DEFAULT_OFFSET 50
|
||||
/* Recovery value for Xtalk compensation plane offset in kcps */
|
||||
/* 50 stands for ~0.10 kcps cover glass in 7.9 format */
|
||||
/* End of settings related to the fix for ticket EwokP #558410 */
|
||||
#define TUNING_PHASECAL_PATCH_POWER 0
|
||||
/* PhaseCal duration patch tuning param
|
||||
* 0 default duration 15ms, 1 leads to 60ms, 2 for 240ms and 3 for 3580ms
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _VL53L1_PRESET_SETUP_H_ */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,222 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_register_settings.h
|
||||
*
|
||||
* @brief Device register setting defines.
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_REGISTER_SETTINGS_H_
|
||||
#define _VL53L1_REGISTER_SETTINGS_H_
|
||||
|
||||
|
||||
/** @defgroup VL53L1_RegisterSettings_group Functionality
|
||||
* @brief Defines the register settings for key device
|
||||
* configuration registers
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup VL53L1_DeviceSchedulerMode_group - Pseudo, Streaming & Hist
|
||||
* @brief Values below match the bit positions in the SYSTEM__MODE_START
|
||||
* register do not change
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define VL53L1_DEVICESCHEDULERMODE_PSEUDO_SOLO 0x00
|
||||
#define VL53L1_DEVICESCHEDULERMODE_STREAMING 0x01
|
||||
#define VL53L1_DEVICESCHEDULERMODE_HISTOGRAM 0x02
|
||||
|
||||
/** @} end of VL53L1_DeviceReadoutMode_group */
|
||||
|
||||
/** @defgroup VL53L1_DeviceReadoutMode_group - Single, Dual, Split & Manual
|
||||
* @brief Values below match the bit positions in the SYSTEM__MODE_START
|
||||
* register do not change
|
||||
* @{
|
||||
*/
|
||||
|
||||
#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)
|
||||
|
||||
/** @} end of VL53L1_DeviceReadoutMode_group */
|
||||
|
||||
/** @defgroup VL53L1_DeviceMeasurementMode_group - SingleShot, BackToBack & timed
|
||||
* @brief Values below match the bit positions in the SYSTEM__MODE_START
|
||||
* register do not change
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
#define VL53L1_DEVICEMEASUREMENTMODE_STOP 0x00
|
||||
#define VL53L1_DEVICEMEASUREMENTMODE_SINGLESHOT 0x10
|
||||
#define VL53L1_DEVICEMEASUREMENTMODE_BACKTOBACK 0x20
|
||||
#define VL53L1_DEVICEMEASUREMENTMODE_TIMED 0x40
|
||||
#define VL53L1_DEVICEMEASUREMENTMODE_ABORT 0x80
|
||||
*/
|
||||
#define VL53L1_DEVICEMEASUREMENTMODE_MODE_MASK 0xF0
|
||||
#define VL53L1_DEVICEMEASUREMENTMODE_STOP_MASK 0x0F
|
||||
|
||||
#define VL53L1_GROUPEDPARAMETERHOLD_ID_MASK 0x02
|
||||
|
||||
/** @} end of VL53L1_DeviceMeasurementMode_group */
|
||||
|
||||
#define VL53L1_EWOK_I2C_DEV_ADDR_DEFAULT 0x29
|
||||
/*!< Device default 7-bit I2C address */
|
||||
#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
|
||||
|
||||
/* Result Status */
|
||||
#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
|
||||
|
||||
/* Interrupt Config */
|
||||
#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
|
||||
|
||||
/* Interrupt Clear */
|
||||
#define VL53L1_CLEAR_RANGE_INT 0x01
|
||||
#define VL53L1_CLEAR_ERROR_INT 0x02
|
||||
|
||||
/* Sequence Config */
|
||||
#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
|
||||
|
||||
/* defines for DSS__ROI_CONTROL */
|
||||
#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
|
||||
|
||||
/* SPAD Readout defines
|
||||
*
|
||||
* 7:6 - SPAD_IN_SEL_REF
|
||||
* 5:4 - SPAD_IN_SEL_RTN
|
||||
* 2 - SPAD_PS_BYPASS
|
||||
* 0 - SPAD_EN_PULSE_EXTENDER
|
||||
*/
|
||||
|
||||
#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
|
||||
|
||||
/* Range Status defines
|
||||
*
|
||||
* 7 - GPH ID
|
||||
* 6 - Min threshold hit
|
||||
* 5 - Max threshold hit
|
||||
* 4:0 - Range Status
|
||||
*/
|
||||
|
||||
#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
|
||||
|
||||
/* Interrupt Status defines
|
||||
*
|
||||
* 5 - GPH ID
|
||||
* 4:3 - Interrupt Error Status
|
||||
* 2:0 - Interrupt Status
|
||||
*/
|
||||
|
||||
#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
|
||||
|
||||
/** @} end of VL53L1_RegisterSettings_group */
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* _VL53L1_REGISTER_SETTINGS_H_ */
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_silicon_core.h
|
||||
*
|
||||
* @brief EwokPlus25 low level silicon specific API function definitions
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_SILICON_CORE_H_
|
||||
#define _VL53L1_SILICON_CORE_H_
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Checks if the firmware is ready for ranging (Silicon variant)
|
||||
*
|
||||
* @param[in] Dev : Device Handle
|
||||
* @param[out] pready : pointer to data ready flag \n
|
||||
* 0 = firmware not ready \n
|
||||
* 1 = firmware ready
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_is_firmware_ready_silicon(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pready);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _VL53L1_SILICON_CORE_H_ */
|
|
@ -0,0 +1,210 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_tuning_parm_defaults.h
|
||||
*
|
||||
* @brief Define defaults for tuning parm list
|
||||
*
|
||||
* - Ensures coherence of internal defaults to tuning table
|
||||
* - Allows reduction of tuning parm list to only changes from the
|
||||
* standard settings defined below
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VL53L1_TUNING_PARM_DEFAULTS_H_
|
||||
#define _VL53L1_TUNING_PARM_DEFAULTS_H_
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @defgroup VL53L1_tuningparmdefault_group VL53L1 Defines
|
||||
* @brief VL53L1 Tuning Parm Default Values
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define VL53L1_TUNINGPARM_VERSION_DEFAULT \
|
||||
((uint16_t) 32771)
|
||||
#define VL53L1_TUNINGPARM_KEY_TABLE_VERSION_DEFAULT \
|
||||
((uint16_t) 32769)
|
||||
#define VL53L1_TUNINGPARM_LLD_VERSION_DEFAULT \
|
||||
((uint16_t) 32833)
|
||||
#define VL53L1_TUNINGPARM_CONSISTENCY_LITE_PHASE_TOLERANCE_DEFAULT \
|
||||
((uint8_t) 2)
|
||||
#define VL53L1_TUNINGPARM_PHASECAL_TARGET_DEFAULT \
|
||||
((uint8_t) 33)
|
||||
#define VL53L1_TUNINGPARM_LITE_CAL_REPEAT_RATE_DEFAULT \
|
||||
((uint16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_LITE_RANGING_GAIN_FACTOR_DEFAULT \
|
||||
((uint16_t) 2011)
|
||||
#define VL53L1_TUNINGPARM_LITE_MIN_CLIP_MM_DEFAULT \
|
||||
((uint8_t) 0)
|
||||
#define VL53L1_TUNINGPARM_LITE_LONG_SIGMA_THRESH_MM_DEFAULT \
|
||||
((uint16_t) 360)
|
||||
#define VL53L1_TUNINGPARM_LITE_MED_SIGMA_THRESH_MM_DEFAULT \
|
||||
((uint16_t) 360)
|
||||
#define VL53L1_TUNINGPARM_LITE_SHORT_SIGMA_THRESH_MM_DEFAULT \
|
||||
((uint16_t) 360)
|
||||
#define VL53L1_TUNINGPARM_LITE_LONG_MIN_COUNT_RATE_RTN_MCPS_DEFAULT \
|
||||
((uint16_t) 192)
|
||||
#define VL53L1_TUNINGPARM_LITE_MED_MIN_COUNT_RATE_RTN_MCPS_DEFAULT \
|
||||
((uint16_t) 192)
|
||||
#define VL53L1_TUNINGPARM_LITE_SHORT_MIN_COUNT_RATE_RTN_MCPS_DEFAULT \
|
||||
((uint16_t) 192)
|
||||
#define VL53L1_TUNINGPARM_LITE_SIGMA_EST_PULSE_WIDTH_DEFAULT \
|
||||
((uint8_t) 8)
|
||||
#define VL53L1_TUNINGPARM_LITE_SIGMA_EST_AMB_WIDTH_NS_DEFAULT \
|
||||
((uint8_t) 16)
|
||||
#define VL53L1_TUNINGPARM_LITE_SIGMA_REF_MM_DEFAULT \
|
||||
((uint8_t) 1)
|
||||
#define VL53L1_TUNINGPARM_LITE_RIT_MULT_DEFAULT \
|
||||
((uint8_t) 64)
|
||||
#define VL53L1_TUNINGPARM_LITE_SEED_CONFIG_DEFAULT \
|
||||
((uint8_t) 2)
|
||||
#define VL53L1_TUNINGPARM_LITE_QUANTIFIER_DEFAULT \
|
||||
((uint8_t) 2)
|
||||
#define VL53L1_TUNINGPARM_LITE_FIRST_ORDER_SELECT_DEFAULT \
|
||||
((uint8_t) 0)
|
||||
#define VL53L1_TUNINGPARM_LITE_XTALK_MARGIN_KCPS_DEFAULT \
|
||||
((int16_t) 0)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_LONG_RANGE_DEFAULT \
|
||||
((uint8_t) 14)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_MED_RANGE_DEFAULT \
|
||||
((uint8_t) 10)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_SHORT_RANGE_DEFAULT \
|
||||
((uint8_t) 6)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_LONG_RANGE_DEFAULT \
|
||||
((uint8_t) 14)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_MED_RANGE_DEFAULT \
|
||||
((uint8_t) 10)
|
||||
#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_SHORT_RANGE_DEFAULT \
|
||||
((uint8_t) 6)
|
||||
#define VL53L1_TUNINGPARM_TIMED_SEED_CONFIG_DEFAULT \
|
||||
((uint8_t) 1)
|
||||
#define VL53L1_TUNINGPARM_VHV_LOOPBOUND_DEFAULT \
|
||||
((uint8_t) 32)
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_DEVICE_TEST_MODE_DEFAULT \
|
||||
((uint8_t) 8)
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_VCSEL_PERIOD_DEFAULT \
|
||||
((uint8_t) 11)
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_PHASECAL_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 1000)
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_TARGET_COUNT_RATE_MCPS_DEFAULT \
|
||||
((uint16_t) 2560)
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_MIN_COUNTRATE_LIMIT_MCPS_DEFAULT \
|
||||
((uint16_t) 1280)
|
||||
#define VL53L1_TUNINGPARM_REFSPADCHAR_MAX_COUNTRATE_LIMIT_MCPS_DEFAULT \
|
||||
((uint16_t) 5120)
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_DSS_RATE_MCPS_DEFAULT \
|
||||
((uint16_t) 2560)
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_PHASECAL_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 1000)
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_MM_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 13000)
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_RANGE_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 13000)
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_PRE_SAMPLES_DEFAULT \
|
||||
((uint8_t) 8)
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_MM1_SAMPLES_DEFAULT \
|
||||
((uint8_t) 40)
|
||||
#define VL53L1_TUNINGPARM_OFFSET_CAL_MM2_SAMPLES_DEFAULT \
|
||||
((uint8_t) 9)
|
||||
#define VL53L1_TUNINGPARM_SPADMAP_VCSEL_PERIOD_DEFAULT \
|
||||
((uint8_t) 18)
|
||||
#define VL53L1_TUNINGPARM_SPADMAP_VCSEL_START_DEFAULT \
|
||||
((uint8_t) 15)
|
||||
#define VL53L1_TUNINGPARM_SPADMAP_RATE_LIMIT_MCPS_DEFAULT \
|
||||
((uint16_t) 12)
|
||||
#define VL53L1_TUNINGPARM_LITE_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS_DEFAULT \
|
||||
((uint16_t) 2560)
|
||||
#define VL53L1_TUNINGPARM_TIMED_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS_DEFAULT \
|
||||
((uint16_t) 2560)
|
||||
#define VL53L1_TUNINGPARM_LITE_PHASECAL_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 1000)
|
||||
#define VL53L1_TUNINGPARM_TIMED_PHASECAL_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 1000)
|
||||
#define VL53L1_TUNINGPARM_LITE_MM_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 2000)
|
||||
#define VL53L1_TUNINGPARM_TIMED_MM_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 2000)
|
||||
#define VL53L1_TUNINGPARM_LITE_RANGE_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 63000)
|
||||
#define VL53L1_TUNINGPARM_TIMED_RANGE_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 13000)
|
||||
#define VL53L1_TUNINGPARM_LOWPOWERAUTO_VHV_LOOP_BOUND_DEFAULT \
|
||||
((uint8_t) 3)
|
||||
#define VL53L1_TUNINGPARM_LOWPOWERAUTO_MM_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 700)
|
||||
#define VL53L1_TUNINGPARM_LOWPOWERAUTO_RANGE_CONFIG_TIMEOUT_US_DEFAULT \
|
||||
((uint32_t) 8000)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _VL53L1_LL_DEF_H_ */
|
||||
|
||||
|
|
@ -0,0 +1,276 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_wait.h
|
||||
*
|
||||
* @brief EwokPlus25 low level Driver wait function definitions
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_WAIT_H_
|
||||
#define _VL53L1_WAIT_H_
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Wait for initial firmware boot to finish
|
||||
*
|
||||
* Calls VL53L1_poll_for_boot_completion()
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_wait_for_boot_completion(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Waits for initial firmware ready
|
||||
*
|
||||
* Only waits to see if the firmware is ready in timed and
|
||||
* single shot modes.
|
||||
*
|
||||
* Calls VL53L1_poll_for_firmware_ready()
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_wait_for_firmware_ready(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Waits for the next ranging interrupt
|
||||
*
|
||||
* Calls VL53L1_poll_for_range_completion()
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_wait_for_range_completion(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Waits for a device test mode to complete.
|
||||
|
||||
* Calls VL53L1_poll_for_test_completion()
|
||||
*
|
||||
* @param[in] Dev : Device Handle
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_wait_for_test_completion(
|
||||
VL53L1_DEV Dev);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reads FIRMWARE__SYSTEM_STATUS register to detect if the
|
||||
* firmware was finished booting
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[out] pready : pointer to data ready flag \n
|
||||
* 0 = boot not complete \n
|
||||
* 1 = boot complete
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_is_boot_complete(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pready);
|
||||
|
||||
/**
|
||||
* @brief Reads FIRMWARE__SYSTEM_STATUS register to detect if the
|
||||
* firmware is ready for ranging.
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[out] pready : pointer to data ready flag \n
|
||||
* 0 = firmware not ready \n
|
||||
* 1 = firmware ready
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_is_firmware_ready(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pready);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reads bit 0 of VL53L1_GPIO__TIO_HV_STATUS register to determine
|
||||
* if new range data is ready (available).
|
||||
*
|
||||
* Interrupt may be either active high or active low. The behaviour of bit 0
|
||||
* of the VL53L1_GPIO__TIO_HV_STATUS register is the same as the interrupt
|
||||
* signal generated on the GPIO pin.
|
||||
*
|
||||
* pdev->stat_cfg.gpio_hv_mux_ctrl bit 4 is used to select required check level
|
||||
*
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[out] pready : pointer to data ready flag \n
|
||||
* 0 = data not ready \n
|
||||
* 1 = new range data available
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_is_new_data_ready(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pready);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Waits (polls) for initial firmware boot to finish
|
||||
*
|
||||
* After power on or a device reset via XSHUTDOWN EwokPlus25 firmware takes
|
||||
* about 2ms to boot. During this boot sequence elected NVM data is copied
|
||||
* to the device's Host & MCU G02 registers
|
||||
*
|
||||
* This function polls the FIRMWARE__SYSTEM_STATUS register to detect when
|
||||
* firmware is ready.
|
||||
*
|
||||
* Polling is implemented using VL53L1_WaitValueMaskEx()
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[in] timeout_ms : Wait timeout in [ms]
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_poll_for_boot_completion(
|
||||
VL53L1_DEV Dev,
|
||||
uint32_t timeout_ms);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Waits (polls) for initial firmware ready
|
||||
*
|
||||
* Polling is implemented using VL53L1_WaitValueMaskEx()
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[in] timeout_ms : Wait timeout in [ms]
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_poll_for_firmware_ready(
|
||||
VL53L1_DEV Dev,
|
||||
uint32_t timeout_ms);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Polls bit 0 of VL53L1_GPIO__TIO_HV_STATUS register to determine
|
||||
* the state of the GPIO (Interrupt) pin.
|
||||
*
|
||||
* Interrupt may be either active high or active low. The behaviour of bit 0
|
||||
* of the VL53L1_GPIO__TIO_HV_STATUS register is the same as the interrupt
|
||||
* signal generated on the GPIO pin.
|
||||
*
|
||||
* pdev->stat_cfg.gpio_hv_mux_ctrl bit 4 is used to select required check level
|
||||
*
|
||||
* Polling is implemented using VL53L1_WaitValueMaskEx()
|
||||
*
|
||||
* @param[in] Dev : Device handle
|
||||
* @param[in] timeout_ms : Wait timeout in [ms]
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_poll_for_range_completion(
|
||||
VL53L1_DEV Dev,
|
||||
uint32_t timeout_ms);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _VL53L1_WAIT_H_ */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,876 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_core.c
|
||||
*
|
||||
* @brief EwokPlus25 low level API function definition
|
||||
*/
|
||||
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_ll_device.h"
|
||||
#include "vl53l1_platform.h"
|
||||
#include "vl53l1_register_map.h"
|
||||
#include "vl53l1_register_funcs.h"
|
||||
#include "vl53l1_register_settings.h"
|
||||
#include "vl53l1_core.h"
|
||||
#include "vl53l1_wait.h"
|
||||
#include "vl53l1_api_preset_modes.h"
|
||||
#include "vl53l1_silicon_core.h"
|
||||
#include "vl53l1_api_core.h"
|
||||
#include "vl53l1_api_calibration.h"
|
||||
|
||||
#ifdef VL53L1_LOG_ENABLE
|
||||
#include "vl53l1_api_debug.h"
|
||||
#endif
|
||||
#ifdef VL53L1_LOGGING
|
||||
#include "vl53l1_debug.h"
|
||||
#endif
|
||||
|
||||
#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__)
|
||||
|
||||
|
||||
#ifndef VL53L1_NOCALIB
|
||||
VL53L1_Error VL53L1_run_ref_spad_char(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_Error *pcal_status)
|
||||
{
|
||||
/*
|
||||
* Runs Reference SPAD Characterisation
|
||||
*/
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
|
||||
|
||||
uint8_t comms_buffer[6];
|
||||
|
||||
VL53L1_refspadchar_config_t *prefspadchar = &(pdev->refspadchar);
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
/*
|
||||
* Ensure power force is enabled
|
||||
*/
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
|
||||
status = VL53L1_enable_powerforce(Dev);
|
||||
|
||||
/*
|
||||
* Configure device
|
||||
*/
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_set_ref_spad_char_config(
|
||||
Dev,
|
||||
prefspadchar->vcsel_period,
|
||||
prefspadchar->timeout_us,
|
||||
prefspadchar->target_count_rate_mcps,
|
||||
prefspadchar->max_count_rate_limit_mcps,
|
||||
prefspadchar->min_count_rate_limit_mcps,
|
||||
pdev->stat_nvm.osc_measured__fast_osc__frequency);
|
||||
|
||||
/*
|
||||
* Run device test
|
||||
*/
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_run_device_test(
|
||||
Dev,
|
||||
prefspadchar->device_test_mode);
|
||||
|
||||
/*
|
||||
* Read results
|
||||
*/
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_ReadMulti(
|
||||
Dev,
|
||||
VL53L1_REF_SPAD_CHAR_RESULT__NUM_ACTUAL_REF_SPADS,
|
||||
comms_buffer,
|
||||
2);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
pdev->dbg_results.ref_spad_char_result__num_actual_ref_spads =
|
||||
comms_buffer[0];
|
||||
pdev->dbg_results.ref_spad_char_result__ref_location =
|
||||
comms_buffer[1];
|
||||
}
|
||||
|
||||
/*
|
||||
* copy results to customer nvm managed G02 registers
|
||||
*/
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_WriteMulti(
|
||||
Dev,
|
||||
VL53L1_REF_SPAD_MAN__NUM_REQUESTED_REF_SPADS,
|
||||
comms_buffer,
|
||||
2);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
pdev->customer.ref_spad_man__num_requested_ref_spads =
|
||||
comms_buffer[0];
|
||||
pdev->customer.ref_spad_man__ref_location =
|
||||
comms_buffer[1];
|
||||
}
|
||||
|
||||
/* After Ref Spad Char the final set of good SPAD enables
|
||||
* are stored in the NCY results registers below
|
||||
*
|
||||
* - RESULT__SPARE_0_SD_1
|
||||
* - RESULT__SPARE_1_SD_1
|
||||
* - RESULT__SPARE_2_SD_1
|
||||
*/
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_ReadMulti(
|
||||
Dev,
|
||||
VL53L1_RESULT__SPARE_0_SD1,
|
||||
comms_buffer,
|
||||
6);
|
||||
|
||||
/*
|
||||
* copy reference SPAD enables to customer nvm managed
|
||||
* G02 registers
|
||||
*/
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_WriteMulti(
|
||||
Dev,
|
||||
VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_REF_0,
|
||||
comms_buffer,
|
||||
6);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
pdev->customer.global_config__spad_enables_ref_0 =
|
||||
comms_buffer[0];
|
||||
pdev->customer.global_config__spad_enables_ref_1 =
|
||||
comms_buffer[1];
|
||||
pdev->customer.global_config__spad_enables_ref_2 =
|
||||
comms_buffer[2];
|
||||
pdev->customer.global_config__spad_enables_ref_3 =
|
||||
comms_buffer[3];
|
||||
pdev->customer.global_config__spad_enables_ref_4 =
|
||||
comms_buffer[4];
|
||||
pdev->customer.global_config__spad_enables_ref_5 =
|
||||
comms_buffer[5];
|
||||
}
|
||||
|
||||
#ifdef VL53L1_LOG_ENABLE
|
||||
/* Print customer nvm managed data */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
VL53L1_print_customer_nvm_managed(
|
||||
&(pdev->customer),
|
||||
"run_ref_spad_char():pdev->lldata.customer.",
|
||||
VL53L1_TRACE_MODULE_REF_SPAD_CHAR);
|
||||
#endif
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
|
||||
switch (pdev->sys_results.result__range_status) {
|
||||
|
||||
case VL53L1_DEVICEERROR_REFSPADCHARNOTENOUGHDPADS:
|
||||
status = VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS;
|
||||
break;
|
||||
|
||||
case VL53L1_DEVICEERROR_REFSPADCHARMORETHANTARGET:
|
||||
status = VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH;
|
||||
break;
|
||||
|
||||
case VL53L1_DEVICEERROR_REFSPADCHARLESSTHANTARGET:
|
||||
status = VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Save unfiltered status
|
||||
*/
|
||||
|
||||
*pcal_status = status;
|
||||
|
||||
/* Status exception code */
|
||||
|
||||
IGNORE_STATUS(
|
||||
IGNORE_REF_SPAD_CHAR_NOT_ENOUGH_SPADS,
|
||||
VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS,
|
||||
status);
|
||||
|
||||
IGNORE_STATUS(
|
||||
IGNORE_REF_SPAD_CHAR_RATE_TOO_HIGH,
|
||||
VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH,
|
||||
status);
|
||||
|
||||
IGNORE_STATUS(
|
||||
IGNORE_REF_SPAD_CHAR_RATE_TOO_LOW,
|
||||
VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW,
|
||||
status);
|
||||
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
VL53L1_Error VL53L1_run_offset_calibration(
|
||||
VL53L1_DEV Dev,
|
||||
int16_t cal_distance_mm,
|
||||
VL53L1_Error *pcal_status)
|
||||
{
|
||||
/*
|
||||
* Runs offset calibration
|
||||
*
|
||||
* Recommended tuning parm settings:
|
||||
*
|
||||
* - pre_num_of_samples = 32
|
||||
* - mm1_num_of_samples = 100
|
||||
* - mm2_num_of_samples = 64
|
||||
* - target_distance_mm = 140mm
|
||||
* - target reflectance = 5%
|
||||
*
|
||||
* Standard Ranging (sigma delta mode):
|
||||
* - dss_config__target_total_rate_mcps = 20.0 -40.0 Mcps
|
||||
* - phasecal_config_timeout_us = 1000
|
||||
* - range_config_timeout_us = 13000
|
||||
* - mm_config_timeout_us = 13000
|
||||
*
|
||||
*
|
||||
* Note: function parms simplified as part of
|
||||
* Patch_CalFunctionSimplification_11791
|
||||
*
|
||||
*/
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
VL53L1_LLDriverData_t *pdev =
|
||||
VL53L1DevStructGetLLDriverHandle(Dev);
|
||||
|
||||
VL53L1_DevicePresetModes device_preset_modes[VL53L1_MAX_OFFSET_RANGE_RESULTS];
|
||||
|
||||
VL53L1_range_results_t range_results;
|
||||
VL53L1_range_results_t *prange_results = &range_results;
|
||||
VL53L1_range_data_t *prange_data = NULL;
|
||||
VL53L1_offset_range_data_t *poffset = NULL;
|
||||
|
||||
uint8_t i = 0;
|
||||
uint8_t m = 0;
|
||||
uint8_t measurement_mode =
|
||||
VL53L1_DEVICEMEASUREMENTMODE_BACKTOBACK;
|
||||
uint16_t manual_effective_spads =
|
||||
pdev->gen_cfg.dss_config__manual_effective_spads_select;
|
||||
|
||||
uint8_t num_of_samples[VL53L1_MAX_OFFSET_RANGE_RESULTS];
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
/* select requested offset calibration mode */
|
||||
|
||||
switch (pdev->offset_calibration_mode) {
|
||||
|
||||
default:
|
||||
device_preset_modes[0] =
|
||||
VL53L1_DEVICEPRESETMODE_STANDARD_RANGING;
|
||||
device_preset_modes[1] =
|
||||
VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM1_CAL;
|
||||
device_preset_modes[2] =
|
||||
VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM2_CAL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* initialise num_of_samples */
|
||||
/* Start Patch_CalFunctionSimplification_11791 */
|
||||
num_of_samples[0] = pdev->offsetcal_cfg.pre_num_of_samples;
|
||||
num_of_samples[1] = pdev->offsetcal_cfg.mm1_num_of_samples;
|
||||
num_of_samples[2] = pdev->offsetcal_cfg.mm2_num_of_samples;
|
||||
/* End Patch_CalFunctionSimplification_11791 */
|
||||
|
||||
/* force all offsets to zero */
|
||||
|
||||
switch (pdev->offset_calibration_mode) {
|
||||
|
||||
case VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD_PRE_RANGE_ONLY:
|
||||
/* only run pre range */
|
||||
pdev->offset_results.active_results = 1;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
pdev->customer.mm_config__inner_offset_mm = 0;
|
||||
pdev->customer.mm_config__outer_offset_mm = 0;
|
||||
pdev->offset_results.active_results =
|
||||
VL53L1_MAX_OFFSET_RANGE_RESULTS;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
pdev->customer.algo__part_to_part_range_offset_mm = 0;
|
||||
|
||||
/* initialise offset range results */
|
||||
|
||||
pdev->offset_results.max_results = VL53L1_MAX_OFFSET_RANGE_RESULTS;
|
||||
pdev->offset_results.cal_distance_mm = cal_distance_mm;
|
||||
|
||||
for (m = 0 ; m < VL53L1_MAX_OFFSET_RANGE_RESULTS; m++) {
|
||||
|
||||
poffset = &(pdev->offset_results.data[m]);
|
||||
poffset->preset_mode = 0;
|
||||
poffset->no_of_samples = 0;
|
||||
poffset->effective_spads = 0;
|
||||
poffset->peak_rate_mcps = 0;
|
||||
poffset->sigma_mm = 0;
|
||||
poffset->median_range_mm = 0;
|
||||
}
|
||||
|
||||
for (m = 0 ; m < pdev->offset_results.active_results ; m++) {
|
||||
|
||||
poffset = &(pdev->offset_results.data[m]);
|
||||
|
||||
poffset->preset_mode = device_preset_modes[m];
|
||||
|
||||
/* Apply preset mode */
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_set_preset_mode(
|
||||
Dev,
|
||||
device_preset_modes[m],
|
||||
/* Start Patch_CalFunctionSimplification_11791 */
|
||||
pdev->offsetcal_cfg.dss_config__target_total_rate_mcps,
|
||||
pdev->offsetcal_cfg.phasecal_config_timeout_us,
|
||||
pdev->offsetcal_cfg.mm_config_timeout_us,
|
||||
pdev->offsetcal_cfg.range_config_timeout_us,
|
||||
/* End Patch_CalFunctionSimplification_11791 */
|
||||
100);
|
||||
|
||||
pdev->gen_cfg.dss_config__manual_effective_spads_select =
|
||||
manual_effective_spads;
|
||||
|
||||
/* Initialise device and start range */
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_init_and_start_range(
|
||||
Dev,
|
||||
measurement_mode,
|
||||
VL53L1_DEVICECONFIGLEVEL_CUSTOMER_ONWARDS);
|
||||
|
||||
for (i = 0 ; i <= (num_of_samples[m]+2) ; i++) {
|
||||
|
||||
/* Wait for range completion */
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_wait_for_range_completion(Dev);
|
||||
|
||||
/*
|
||||
* Get Device Results
|
||||
* - Checks the stream count is the expected one
|
||||
* - Read device system results
|
||||
*/
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_get_device_results(
|
||||
Dev,
|
||||
VL53L1_DEVICERESULTSLEVEL_FULL,
|
||||
prange_results);
|
||||
|
||||
/*
|
||||
* Ignore 1st two ranges to give the sigma delta initial
|
||||
* phase time to settle
|
||||
*
|
||||
* accummulate range results if range is successful
|
||||
*/
|
||||
|
||||
prange_data = &(prange_results->data[0]);
|
||||
|
||||
if (prange_results->stream_count > 1) {
|
||||
|
||||
if (prange_data->range_status ==
|
||||
VL53L1_DEVICEERROR_RANGECOMPLETE) {
|
||||
|
||||
poffset->no_of_samples++;
|
||||
poffset->effective_spads +=
|
||||
(uint32_t)prange_data->actual_effective_spads;
|
||||
poffset->peak_rate_mcps +=
|
||||
(uint32_t)prange_data->peak_signal_count_rate_mcps;
|
||||
poffset->sigma_mm +=
|
||||
(uint32_t)prange_data->sigma_mm;
|
||||
poffset->median_range_mm +=
|
||||
(int32_t)prange_data->median_range_mm;
|
||||
|
||||
poffset->dss_config__roi_mode_control =
|
||||
pdev->gen_cfg.dss_config__roi_mode_control;
|
||||
poffset->dss_config__manual_effective_spads_select =
|
||||
pdev->gen_cfg.dss_config__manual_effective_spads_select;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Conditional wait for firmware ready. Only waits for timed
|
||||
* and single shot modes. Mode check is performed inside the
|
||||
* wait function
|
||||
*/
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_wait_for_firmware_ready(Dev);
|
||||
|
||||
/*
|
||||
* Send ranging handshake
|
||||
*
|
||||
* - Update Zone management
|
||||
* - Update GPH registers
|
||||
* - Clear current interrupt
|
||||
* - Initialise SYSTEM__MODE_START for next range (if there is one!)
|
||||
*/
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_clear_interrupt_and_enable_next_range(
|
||||
Dev,
|
||||
measurement_mode);
|
||||
}
|
||||
|
||||
/* Stop range */
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_stop_range(Dev);
|
||||
|
||||
/* Wait for Stop (abort) range to complete */
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_WaitUs(Dev, 1000);
|
||||
|
||||
/* generate average values */
|
||||
if (poffset->no_of_samples > 0) {
|
||||
|
||||
poffset->effective_spads += (poffset->no_of_samples/2);
|
||||
poffset->effective_spads /= poffset->no_of_samples;
|
||||
|
||||
poffset->peak_rate_mcps += (poffset->no_of_samples/2);
|
||||
poffset->peak_rate_mcps /= poffset->no_of_samples;
|
||||
|
||||
poffset->sigma_mm += (poffset->no_of_samples/2);
|
||||
poffset->sigma_mm /= poffset->no_of_samples;
|
||||
|
||||
poffset->median_range_mm += (poffset->no_of_samples/2);
|
||||
poffset->median_range_mm /= poffset->no_of_samples;
|
||||
|
||||
poffset->range_mm_offset = (int32_t)cal_distance_mm;
|
||||
poffset->range_mm_offset -= poffset->median_range_mm;
|
||||
|
||||
/* remember the number of SPADs for standard ranging */
|
||||
if (poffset->preset_mode ==
|
||||
VL53L1_DEVICEPRESETMODE_STANDARD_RANGING)
|
||||
manual_effective_spads =
|
||||
(uint16_t)poffset->effective_spads;
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate offsets */
|
||||
|
||||
switch (pdev->offset_calibration_mode) {
|
||||
|
||||
case VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD_PRE_RANGE_ONLY:
|
||||
|
||||
/* copy offsets to customer data structure */
|
||||
pdev->customer.mm_config__inner_offset_mm +=
|
||||
(int16_t)pdev->offset_results.data[0].range_mm_offset;
|
||||
pdev->customer.mm_config__outer_offset_mm +=
|
||||
(int16_t)pdev->offset_results.data[0].range_mm_offset;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* copy offsets to customer data structure */
|
||||
pdev->customer.mm_config__inner_offset_mm =
|
||||
(int16_t)pdev->offset_results.data[1].range_mm_offset;
|
||||
pdev->customer.mm_config__outer_offset_mm =
|
||||
(int16_t)pdev->offset_results.data[2].range_mm_offset;
|
||||
pdev->customer.algo__part_to_part_range_offset_mm = 0;
|
||||
|
||||
/* copy average rate and effective SPAD count to
|
||||
additional offset calibration data structure */
|
||||
|
||||
pdev->add_off_cal_data.result__mm_inner_actual_effective_spads =
|
||||
(uint16_t)pdev->offset_results.data[1].effective_spads;
|
||||
pdev->add_off_cal_data.result__mm_outer_actual_effective_spads =
|
||||
(uint16_t)pdev->offset_results.data[2].effective_spads;
|
||||
|
||||
pdev->add_off_cal_data.result__mm_inner_peak_signal_count_rtn_mcps =
|
||||
(uint16_t)pdev->offset_results.data[1].peak_rate_mcps;
|
||||
pdev->add_off_cal_data.result__mm_outer_peak_signal_count_rtn_mcps =
|
||||
(uint16_t)pdev->offset_results.data[2].peak_rate_mcps;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* apply to device */
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_set_customer_nvm_managed(
|
||||
Dev,
|
||||
&(pdev->customer));
|
||||
|
||||
/*
|
||||
* Check the peak rates, sigma, min spads for each stage
|
||||
*/
|
||||
|
||||
for (m = 0 ; m < pdev->offset_results.active_results ; m++) {
|
||||
|
||||
poffset = &(pdev->offset_results.data[m]);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
|
||||
pdev->offset_results.cal_report = m;
|
||||
|
||||
if (poffset->no_of_samples < num_of_samples[m])
|
||||
status = VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES;
|
||||
|
||||
/* only check sigma for the pre-range as
|
||||
* the it is not calculated by the device
|
||||
* for the MM1 and MM2 stages
|
||||
*/
|
||||
if (m == 0 && poffset->sigma_mm >
|
||||
((uint32_t)VL53L1_OFFSET_CAL_MAX_SIGMA_MM<<5))
|
||||
status = VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH;
|
||||
|
||||
if (poffset->peak_rate_mcps >
|
||||
VL53L1_OFFSET_CAL_MAX_PRE_PEAK_RATE_MCPS)
|
||||
status = VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH;
|
||||
|
||||
if (poffset->dss_config__manual_effective_spads_select <
|
||||
VL53L1_OFFSET_CAL_MIN_EFFECTIVE_SPADS)
|
||||
status = VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW;
|
||||
|
||||
if (poffset->dss_config__manual_effective_spads_select == 0)
|
||||
status = VL53L1_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL;
|
||||
|
||||
if (poffset->no_of_samples == 0)
|
||||
status = VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Save unfiltered status
|
||||
*/
|
||||
|
||||
pdev->offset_results.cal_status = status;
|
||||
*pcal_status = pdev->offset_results.cal_status;
|
||||
|
||||
/* Status exception codes */
|
||||
|
||||
IGNORE_STATUS(
|
||||
IGNORE_OFFSET_CAL_MISSING_SAMPLES,
|
||||
VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES,
|
||||
status);
|
||||
|
||||
IGNORE_STATUS(
|
||||
IGNORE_OFFSET_CAL_SIGMA_TOO_HIGH,
|
||||
VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH,
|
||||
status);
|
||||
|
||||
IGNORE_STATUS(
|
||||
IGNORE_OFFSET_CAL_RATE_TOO_HIGH,
|
||||
VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH,
|
||||
status);
|
||||
|
||||
IGNORE_STATUS(
|
||||
IGNORE_OFFSET_CAL_SPAD_COUNT_TOO_LOW,
|
||||
VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW,
|
||||
status);
|
||||
|
||||
#ifdef VL53L1_LOG_ENABLE
|
||||
|
||||
/* Prints out the offset calibration data for debug */
|
||||
|
||||
VL53L1_print_customer_nvm_managed(
|
||||
&(pdev->customer),
|
||||
"run_offset_calibration():pdev->lldata.customer.",
|
||||
VL53L1_TRACE_MODULE_OFFSET_DATA);
|
||||
|
||||
VL53L1_print_additional_offset_cal_data(
|
||||
&(pdev->add_off_cal_data),
|
||||
"run_offset_calibration():pdev->lldata.add_off_cal_data.",
|
||||
VL53L1_TRACE_MODULE_OFFSET_DATA);
|
||||
|
||||
VL53L1_print_offset_range_results(
|
||||
&(pdev->offset_results),
|
||||
"run_offset_calibration():pdev->lldata.offset_results.",
|
||||
VL53L1_TRACE_MODULE_OFFSET_DATA);
|
||||
#endif
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef VL53L1_NOCALIB
|
||||
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)
|
||||
{
|
||||
|
||||
/**
|
||||
* Runs SPAD Rate Map
|
||||
*/
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
VL53L1_LLDriverData_t *pdev =
|
||||
VL53L1DevStructGetLLDriverHandle(Dev);
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
/*
|
||||
* Ensure power force is enabled
|
||||
*/
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_enable_powerforce(Dev);
|
||||
|
||||
/*
|
||||
* Configure the test
|
||||
*/
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
pdev->ssc_cfg.array_select = array_select;
|
||||
pdev->ssc_cfg.timeout_us = ssc_config_timeout_us;
|
||||
status =
|
||||
VL53L1_set_ssc_config(
|
||||
Dev,
|
||||
&(pdev->ssc_cfg),
|
||||
pdev->stat_nvm.osc_measured__fast_osc__frequency);
|
||||
}
|
||||
|
||||
/*
|
||||
* Run device test
|
||||
*/
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_run_device_test(
|
||||
Dev,
|
||||
device_test_mode);
|
||||
|
||||
/*
|
||||
* Read Rate Data from Patch Ram
|
||||
*/
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_get_spad_rate_data(
|
||||
Dev,
|
||||
pspad_rate_data);
|
||||
|
||||
if (device_test_mode == VL53L1_DEVICETESTMODE_LCR_VCSEL_ON)
|
||||
pspad_rate_data->fractional_bits = 7;
|
||||
else
|
||||
pspad_rate_data->fractional_bits = 15;
|
||||
|
||||
/* Ensure power force is disabled */
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_disable_powerforce(Dev);
|
||||
|
||||
#ifdef VL53L1_LOG_ENABLE
|
||||
/* Print return rate data and map */
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
VL53L1_print_spad_rate_data(
|
||||
pspad_rate_data,
|
||||
"run_spad_rate_map():",
|
||||
VL53L1_TRACE_MODULE_SPAD_RATE_MAP);
|
||||
VL53L1_print_spad_rate_map(
|
||||
pspad_rate_data,
|
||||
"run_spad_rate_map():",
|
||||
VL53L1_TRACE_MODULE_SPAD_RATE_MAP);
|
||||
}
|
||||
#endif
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef VL53L1_NOCALIB
|
||||
VL53L1_Error VL53L1_run_device_test(
|
||||
VL53L1_DEV Dev,
|
||||
VL53L1_DeviceTestMode device_test_mode)
|
||||
{
|
||||
/*
|
||||
* Runs the selected Device Test Mode
|
||||
*/
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
|
||||
|
||||
uint8_t comms_buffer[2];
|
||||
uint8_t gpio_hv_mux__ctrl = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
/*
|
||||
* Get current interrupt config
|
||||
*/
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
|
||||
status =
|
||||
VL53L1_RdByte(
|
||||
Dev,
|
||||
VL53L1_GPIO_HV_MUX__CTRL,
|
||||
&gpio_hv_mux__ctrl);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
pdev->stat_cfg.gpio_hv_mux__ctrl = gpio_hv_mux__ctrl;
|
||||
|
||||
/*
|
||||
* Trigger the test
|
||||
*/
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_start_test(
|
||||
Dev,
|
||||
device_test_mode);
|
||||
|
||||
/*
|
||||
* Wait for test completion
|
||||
*/
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_wait_for_test_completion(Dev);
|
||||
|
||||
/*
|
||||
* Read range and report status
|
||||
*/
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_ReadMulti(
|
||||
Dev,
|
||||
VL53L1_RESULT__RANGE_STATUS,
|
||||
comms_buffer,
|
||||
2);
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
pdev->sys_results.result__range_status = comms_buffer[0];
|
||||
pdev->sys_results.result__report_status = comms_buffer[1];
|
||||
}
|
||||
|
||||
/* mask range status bits */
|
||||
|
||||
pdev->sys_results.result__range_status &=
|
||||
VL53L1_RANGE_STATUS__RANGE_STATUS_MASK;
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
trace_print(
|
||||
VL53L1_TRACE_LEVEL_INFO,
|
||||
" Device Test Complete:\n\t%-32s = %3u\n\t%-32s = %3u\n",
|
||||
"result__range_status",
|
||||
pdev->sys_results.result__range_status,
|
||||
"result__report_status",
|
||||
pdev->sys_results.result__report_status);
|
||||
|
||||
/*
|
||||
* Clear interrupt
|
||||
*/
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_clear_interrupt(Dev);
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear test mode register
|
||||
* - required so that next test command will trigger
|
||||
* internal MCU interrupt
|
||||
*/
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status =
|
||||
VL53L1_start_test(
|
||||
Dev,
|
||||
0x00);
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif
|
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
|
@ -0,0 +1,220 @@
|
|||
|
||||
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
||||
/******************************************************************************
|
||||
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
|
||||
|
||||
This file is part of VL53L1 and is dual licensed,
|
||||
either GPL-2.0+
|
||||
or 'BSD 3-clause "New" or "Revised" License' , at your option.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file vl53l1_api_strings.c
|
||||
* @brief VL53L1 API functions for decoding error codes to a text string
|
||||
*/
|
||||
|
||||
#include "vl53l1_api_core.h"
|
||||
#include "vl53l1_api_strings.h"
|
||||
#include "vl53l1_error_codes.h"
|
||||
#include "vl53l1_error_strings.h"
|
||||
|
||||
#define LOG_FUNCTION_START(fmt, ...) \
|
||||
_LOG_FUNCTION_START(VL53L1_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END(status, ...) \
|
||||
_LOG_FUNCTION_END(VL53L1_TRACE_MODULE_API, status, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
|
||||
_LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_API, status, fmt, \
|
||||
##__VA_ARGS__)
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_range_status_string(
|
||||
uint8_t RangeStatus,
|
||||
char *pRangeStatusString)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
#ifdef VL53L1_USE_EMPTY_STRING
|
||||
SUPPRESS_UNUSED_WARNING(RangeStatus);
|
||||
VL53L1_COPYSTRING(pRangeStatusString, "");
|
||||
#else
|
||||
switch (RangeStatus) {
|
||||
case 0:
|
||||
VL53L1_COPYSTRING(pRangeStatusString,
|
||||
VL53L1_STRING_RANGESTATUS_RANGEVALID);
|
||||
break;
|
||||
case 1:
|
||||
VL53L1_COPYSTRING(pRangeStatusString,
|
||||
VL53L1_STRING_RANGESTATUS_SIGMA);
|
||||
break;
|
||||
case 2:
|
||||
VL53L1_COPYSTRING(pRangeStatusString,
|
||||
VL53L1_STRING_RANGESTATUS_SIGNAL);
|
||||
break;
|
||||
case 3:
|
||||
VL53L1_COPYSTRING(pRangeStatusString,
|
||||
VL53L1_STRING_RANGESTATUS_MINRANGE);
|
||||
break;
|
||||
case 4:
|
||||
VL53L1_COPYSTRING(pRangeStatusString,
|
||||
VL53L1_STRING_RANGESTATUS_PHASE);
|
||||
break;
|
||||
case 5:
|
||||
VL53L1_COPYSTRING(pRangeStatusString,
|
||||
VL53L1_STRING_RANGESTATUS_HW);
|
||||
break;
|
||||
|
||||
default: /**/
|
||||
VL53L1_COPYSTRING(pRangeStatusString,
|
||||
VL53L1_STRING_RANGESTATUS_NONE);
|
||||
}
|
||||
#endif
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_get_pal_state_string(
|
||||
VL53L1_State PalStateCode,
|
||||
char *pPalStateString)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
#ifdef VL53L1_USE_EMPTY_STRING
|
||||
SUPPRESS_UNUSED_WARNING(PalStateCode);
|
||||
VL53L1_COPYSTRING(pPalStateString, "");
|
||||
#else
|
||||
switch (PalStateCode) {
|
||||
case VL53L1_STATE_POWERDOWN:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_POWERDOWN);
|
||||
break;
|
||||
case VL53L1_STATE_WAIT_STATICINIT:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_WAIT_STATICINIT);
|
||||
break;
|
||||
case VL53L1_STATE_STANDBY:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_STANDBY);
|
||||
break;
|
||||
case VL53L1_STATE_IDLE:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_IDLE);
|
||||
break;
|
||||
case VL53L1_STATE_RUNNING:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_RUNNING);
|
||||
break;
|
||||
case VL53L1_STATE_RESET:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_RESET);
|
||||
break;
|
||||
case VL53L1_STATE_UNKNOWN:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_UNKNOWN);
|
||||
break;
|
||||
case VL53L1_STATE_ERROR:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_ERROR);
|
||||
break;
|
||||
|
||||
default:
|
||||
VL53L1_COPYSTRING(pPalStateString,
|
||||
VL53L1_STRING_STATE_UNKNOWN);
|
||||
}
|
||||
#endif
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
VL53L1_Error VL53L1_get_sequence_steps_info(
|
||||
VL53L1_SequenceStepId SequenceStepId,
|
||||
char *pSequenceStepsString)
|
||||
{
|
||||
VL53L1_Error Status = VL53L1_ERROR_NONE;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
#ifdef VL53L1_USE_EMPTY_STRING
|
||||
SUPPRESS_UNUSED_WARNING(SequenceStepId);
|
||||
VL53L1_COPYSTRING(pSequenceStepsString, "");
|
||||
#else
|
||||
switch (SequenceStepId) {
|
||||
case VL53L1_SEQUENCESTEP_VHV:
|
||||
VL53L1_COPYSTRING(pSequenceStepsString,
|
||||
VL53L1_STRING_SEQUENCESTEP_VHV);
|
||||
break;
|
||||
case VL53L1_SEQUENCESTEP_PHASECAL:
|
||||
VL53L1_COPYSTRING(pSequenceStepsString,
|
||||
VL53L1_STRING_SEQUENCESTEP_PHASECAL);
|
||||
break;
|
||||
case VL53L1_SEQUENCESTEP_REFPHASE:
|
||||
VL53L1_COPYSTRING(pSequenceStepsString,
|
||||
VL53L1_STRING_SEQUENCESTEP_DSS1);
|
||||
break;
|
||||
case VL53L1_SEQUENCESTEP_DSS1:
|
||||
VL53L1_COPYSTRING(pSequenceStepsString,
|
||||
VL53L1_STRING_SEQUENCESTEP_DSS1);
|
||||
break;
|
||||
case VL53L1_SEQUENCESTEP_DSS2:
|
||||
VL53L1_COPYSTRING(pSequenceStepsString,
|
||||
VL53L1_STRING_SEQUENCESTEP_DSS2);
|
||||
break;
|
||||
case VL53L1_SEQUENCESTEP_MM1:
|
||||
VL53L1_COPYSTRING(pSequenceStepsString,
|
||||
VL53L1_STRING_SEQUENCESTEP_MM1);
|
||||
break;
|
||||
case VL53L1_SEQUENCESTEP_MM2:
|
||||
VL53L1_COPYSTRING(pSequenceStepsString,
|
||||
VL53L1_STRING_SEQUENCESTEP_MM2);
|
||||
break;
|
||||
case VL53L1_SEQUENCESTEP_RANGE:
|
||||
VL53L1_COPYSTRING(pSequenceStepsString,
|
||||
VL53L1_STRING_SEQUENCESTEP_RANGE);
|
||||
break;
|
||||
default:
|
||||
Status = VL53L1_ERROR_INVALID_PARAMS;
|
||||
}
|
||||
#endif
|
||||
|
||||
LOG_FUNCTION_END(Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
VL53L1_Error VL53L1_get_limit_check_info(uint16_t LimitCheckId,
|
||||
char *pLimitCheckString)
|
||||
{
|
||||
VL53L1_Error Status = VL53L1_ERROR_NONE;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
#ifdef VL53L1_USE_EMPTY_STRING
|
||||
SUPPRESS_UNUSED_WARNING(LimitCheckId);
|
||||
VL53L1_COPYSTRING(pLimitCheckString, "");
|
||||
#else
|
||||
switch (LimitCheckId) {
|
||||
case VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE:
|
||||
VL53L1_COPYSTRING(pLimitCheckString,
|
||||
VL53L1_STRING_CHECKENABLE_SIGMA_FINAL_RANGE);
|
||||
break;
|
||||
case VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE:
|
||||
VL53L1_COPYSTRING(pLimitCheckString,
|
||||
VL53L1_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE);
|
||||
break;
|
||||
default:
|
||||
VL53L1_COPYSTRING(pLimitCheckString,
|
||||
VL53L1_STRING_UNKNOW_ERROR_CODE);
|
||||
}
|
||||
#endif
|
||||
|
||||
LOG_FUNCTION_END(Status);
|
||||
return Status;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,445 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_core_support.c
|
||||
*
|
||||
* @brief EwokPlus25 core function definition
|
||||
*/
|
||||
|
||||
#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"
|
||||
|
||||
#ifdef VL53L1_LOGGING
|
||||
#include "vl53l1_debug.h"
|
||||
#include "vl53l1_register_debug.h"
|
||||
#endif
|
||||
|
||||
#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)
|
||||
{
|
||||
/* Calculates PLL frequency using NVM fast_osc_frequency
|
||||
* Fast osc frequency fixed point format = unsigned 4.12
|
||||
*
|
||||
* PLL period fixed point format = unsigned 0.24
|
||||
* Min input fast osc frequency = 1 MHz
|
||||
* PLL Multiplier = 64 (fixed)
|
||||
* Min PLL freq = 64.0MHz
|
||||
* -> max PLL period = 1/ 64
|
||||
* -> only the 18 LS bits are used
|
||||
*
|
||||
* 2^30 = (2^24) (1.0us) * 4096 (2^12) / 64 (PLL Multiplier)
|
||||
*/
|
||||
|
||||
uint32_t pll_period_us = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
pll_period_us = (0x01 << 30) / fast_osc_frequency;
|
||||
|
||||
#ifdef VL53L1_LOGGING
|
||||
trace_print(VL53L1_TRACE_LEVEL_DEBUG,
|
||||
" %-48s : %10u\n", "pll_period_us",
|
||||
pll_period_us);
|
||||
#endif
|
||||
|
||||
LOG_FUNCTION_END(0);
|
||||
|
||||
return pll_period_us;
|
||||
}
|
||||
|
||||
|
||||
#ifdef PAL_EXTENDED
|
||||
uint32_t VL53L1_duration_maths(
|
||||
uint32_t pll_period_us,
|
||||
uint32_t vcsel_parm_pclks,
|
||||
uint32_t window_vclks,
|
||||
uint32_t elapsed_mclks)
|
||||
{
|
||||
/*
|
||||
* Generates the ranging duration in us
|
||||
*
|
||||
* duration_us = elapsed_mclks * vcsel_perm_pclks *
|
||||
* window_vclks * pll_period_us
|
||||
*
|
||||
* returned value in [us] with no fraction bits
|
||||
*/
|
||||
|
||||
uint64_t tmp_long_int = 0;
|
||||
uint32_t duration_us = 0;
|
||||
|
||||
/* PLL period us = 0.24 18 LS bits used
|
||||
* window_vclks = 12.0 (2304 max)
|
||||
* output 30b (6.24)
|
||||
*/
|
||||
duration_us = window_vclks * pll_period_us;
|
||||
|
||||
/* down shift by 12
|
||||
* output 18b (6.12)
|
||||
*/
|
||||
duration_us = duration_us >> 12;
|
||||
|
||||
/* Save first part of the calc (#1) */
|
||||
tmp_long_int = (uint64_t)duration_us;
|
||||
|
||||
/* Multiply elapsed macro periods (22-bit)
|
||||
* by VCSEL parameter 6.4 (max 63.9999)
|
||||
* output 32b (28.4)
|
||||
*/
|
||||
duration_us = elapsed_mclks * vcsel_parm_pclks;
|
||||
|
||||
/* down shift by 4 to remove fractional bits (#2)
|
||||
* output 28b (28.0)
|
||||
*/
|
||||
duration_us = duration_us >> 4;
|
||||
|
||||
/* Multiply #1 18b (6.12) by #2 28b (28.0)
|
||||
* output 46b (34.12)
|
||||
*/
|
||||
tmp_long_int = tmp_long_int * (uint64_t)duration_us;
|
||||
|
||||
/* Remove fractional part
|
||||
* output 34b (34.0)
|
||||
*/
|
||||
tmp_long_int = tmp_long_int >> 12;
|
||||
|
||||
/* Clip to 32-bits */
|
||||
if (tmp_long_int > 0xFFFFFFFF) {
|
||||
tmp_long_int = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
duration_us = (uint32_t)tmp_long_int;
|
||||
|
||||
return duration_us;
|
||||
}
|
||||
|
||||
|
||||
uint32_t VL53L1_isqrt(uint32_t num)
|
||||
{
|
||||
|
||||
/*
|
||||
* Implements an integer square root
|
||||
*
|
||||
* From: http://en.wikipedia.org/wiki/Methods_of_computing_square_roots
|
||||
*/
|
||||
|
||||
uint32_t res = 0;
|
||||
uint32_t bit = 1 << 30; /* The second-to-top bit is set: 1 << 14 for 16-bits, 1 << 30 for 32 bits */
|
||||
|
||||
/* "bit" starts at the highest power of four <= the argument. */
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
uint16_t VL53L1_rate_maths(
|
||||
int32_t events,
|
||||
uint32_t time_us)
|
||||
{
|
||||
/*
|
||||
* Converts events into count rate
|
||||
*
|
||||
* Max events = 512 Mcps * 1sec
|
||||
* = 512,000,000 events
|
||||
* = 29b
|
||||
*
|
||||
* If events > 2^24 use 3-bit fractional bits is used internally
|
||||
* otherwise 7-bit fractional bits are used
|
||||
*/
|
||||
|
||||
uint32_t tmp_int = 0;
|
||||
uint32_t frac_bits = 7;
|
||||
uint16_t rate_mcps = 0; /* 9.7 format */
|
||||
|
||||
/*
|
||||
* Clip input event range
|
||||
*/
|
||||
|
||||
if (events > VL53L1_SPAD_TOTAL_COUNT_MAX) {
|
||||
tmp_int = VL53L1_SPAD_TOTAL_COUNT_MAX;
|
||||
} else if (events > 0) {
|
||||
tmp_int = (uint32_t)events;
|
||||
}
|
||||
|
||||
/*
|
||||
* if events > VL53L1_SPAD_TOTAL_COUNT_RES_THRES use 3 rather
|
||||
* than 7 fractional bits internal to function
|
||||
*/
|
||||
|
||||
if (events > VL53L1_SPAD_TOTAL_COUNT_RES_THRES) {
|
||||
frac_bits = 3;
|
||||
} else {
|
||||
frac_bits = 7;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create 3 or 7 fractional bits
|
||||
* output 32b (29.3 or 25.7)
|
||||
* Divide by range duration in [us] - no fractional bits
|
||||
*/
|
||||
if (time_us > 0) {
|
||||
tmp_int = ((tmp_int << frac_bits) + (time_us / 2)) / time_us;
|
||||
}
|
||||
|
||||
/*
|
||||
* Re align if reduced resolution
|
||||
*/
|
||||
if (events > VL53L1_SPAD_TOTAL_COUNT_RES_THRES) {
|
||||
tmp_int = tmp_int << 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* Firmware internal count is 17.7 (24b) but it this
|
||||
* case clip to 16-bit value for reporting
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
/* rate_per_spad Format varies with prog frac_bits */
|
||||
uint16_t rate_per_spad = 0;
|
||||
|
||||
/* Calculate rate per spad with variable fractional bits */
|
||||
|
||||
/* Frac_bits should be programmed as final frac_bits - 7 as
|
||||
* the pk_rate contains an inherent 7 bit resolution
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* Clip in case of overwrap - special code */
|
||||
|
||||
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 phase,
|
||||
uint16_t zero_distance_phase,
|
||||
uint8_t fractional_bits,
|
||||
int32_t gain_factor,
|
||||
int32_t range_offset_mm)
|
||||
{
|
||||
/*
|
||||
* Converts phase information into distance in [mm]
|
||||
*/
|
||||
|
||||
uint32_t pll_period_us = 0; /* 0.24 format */
|
||||
int64_t tmp_long_int = 0;
|
||||
int32_t range_mm = 0;
|
||||
|
||||
/* Calculate PLL period in [ps] */
|
||||
|
||||
pll_period_us = VL53L1_calc_pll_period_us(fast_osc_frequency);
|
||||
|
||||
/* Raw range in [mm]
|
||||
*
|
||||
* calculate the phase difference between return and reference phases
|
||||
*
|
||||
* phases 16b (5.11)
|
||||
* output 17b including sign bit
|
||||
*/
|
||||
|
||||
tmp_long_int = (int64_t)phase - (int64_t)zero_distance_phase;
|
||||
|
||||
/*
|
||||
* multiply by the PLL period
|
||||
*
|
||||
* PLL period 24bit (0.24) but only 18 LS bits used
|
||||
*
|
||||
* Output 35b (0.35) (17b + 18b)
|
||||
*/
|
||||
|
||||
tmp_long_int = tmp_long_int * (int64_t)pll_period_us;
|
||||
|
||||
/*
|
||||
* Down shift by 9 - Output 26b (0.26)
|
||||
*/
|
||||
|
||||
tmp_long_int = tmp_long_int / (0x01 << 9);
|
||||
|
||||
/*
|
||||
* multiply by speed of light in air divided by 8
|
||||
* Factor of 8 includes 2 for the round trip and 4 scaling
|
||||
*
|
||||
* VL53L1_SPEED_OF_LIGHT_IN_AIR_DIV_8 = 16b (16.2)
|
||||
*
|
||||
* Output 42b (18.24) (16b + 26b)
|
||||
*/
|
||||
|
||||
tmp_long_int = tmp_long_int * VL53L1_SPEED_OF_LIGHT_IN_AIR_DIV_8;
|
||||
|
||||
/*
|
||||
* Down shift by 22 - Output 20b (18.2)
|
||||
*/
|
||||
|
||||
tmp_long_int = tmp_long_int / (0x01 << 22);
|
||||
|
||||
/* Add range offset */
|
||||
range_mm = (int32_t)tmp_long_int + range_offset_mm;
|
||||
|
||||
/* apply correction gain */
|
||||
range_mm *= gain_factor;
|
||||
range_mm += 0x0400;
|
||||
range_mm /= 0x0800;
|
||||
|
||||
/* Remove fractional bits */
|
||||
if (fractional_bits == 0)
|
||||
range_mm = range_mm / (0x01 << 2);
|
||||
else if (fractional_bits == 1)
|
||||
range_mm = range_mm / (0x01 << 1);
|
||||
|
||||
return range_mm;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t VL53L1_decode_vcsel_period(uint8_t vcsel_period_reg)
|
||||
{
|
||||
/*
|
||||
* Converts the encoded VCSEL period register value into
|
||||
* the real period in PLL clocks
|
||||
*/
|
||||
|
||||
uint8_t vcsel_period_pclks = 0;
|
||||
|
||||
vcsel_period_pclks = (vcsel_period_reg + 1) << 1;
|
||||
|
||||
return vcsel_period_pclks;
|
||||
}
|
||||
|
||||
|
||||
void VL53L1_decode_row_col(
|
||||
uint8_t spad_number,
|
||||
uint8_t *prow,
|
||||
uint8_t *pcol)
|
||||
{
|
||||
|
||||
/**
|
||||
* Decodes the array (row,col) location from
|
||||
* the input SPAD number
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,304 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_error_strings.c
|
||||
* @brief VL53L1 API functions for decoding error codes to a text string
|
||||
*/
|
||||
|
||||
#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__)
|
||||
|
||||
|
||||
#ifndef VL53L1_DEBUG
|
||||
#define VL53L1_USE_EMPTY_STRING
|
||||
#endif
|
||||
|
||||
VL53L1_Error VL53L1_get_pal_error_string(
|
||||
VL53L1_Error PalErrorCode,
|
||||
char *pPalErrorString)
|
||||
{
|
||||
VL53L1_Error Status = VL53L1_ERROR_NONE;
|
||||
|
||||
#ifdef VL53L1_USE_EMPTY_STRING
|
||||
SUPPRESS_UNUSED_WARNING(PalErrorCode);
|
||||
#endif
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
#ifdef VL53L1_USE_EMPTY_STRING
|
||||
VL53L1_COPYSTRING(pPalErrorString, "");
|
||||
#else
|
||||
|
||||
switch (PalErrorCode) {
|
||||
case VL53L1_ERROR_NONE:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_NONE);
|
||||
break;
|
||||
case VL53L1_ERROR_CALIBRATION_WARNING:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_CALIBRATION_WARNING);
|
||||
break;
|
||||
case VL53L1_ERROR_MIN_CLIPPED:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_MIN_CLIPPED);
|
||||
break;
|
||||
case VL53L1_ERROR_UNDEFINED:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_UNDEFINED);
|
||||
break;
|
||||
case VL53L1_ERROR_INVALID_PARAMS:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_INVALID_PARAMS);
|
||||
break;
|
||||
case VL53L1_ERROR_NOT_SUPPORTED:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_NOT_SUPPORTED);
|
||||
break;
|
||||
case VL53L1_ERROR_RANGE_ERROR:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_RANGE_ERROR);
|
||||
break;
|
||||
case VL53L1_ERROR_TIME_OUT:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_TIME_OUT);
|
||||
break;
|
||||
case VL53L1_ERROR_MODE_NOT_SUPPORTED:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_MODE_NOT_SUPPORTED);
|
||||
break;
|
||||
case VL53L1_ERROR_BUFFER_TOO_SMALL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_BUFFER_TOO_SMALL);
|
||||
break;
|
||||
case VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_COMMS_BUFFER_TOO_SMALL);
|
||||
break;
|
||||
case VL53L1_ERROR_GPIO_NOT_EXISTING:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_GPIO_NOT_EXISTING);
|
||||
break;
|
||||
case VL53L1_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED);
|
||||
break;
|
||||
case VL53L1_ERROR_CONTROL_INTERFACE:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_CONTROL_INTERFACE);
|
||||
break;
|
||||
case VL53L1_ERROR_INVALID_COMMAND:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_INVALID_COMMAND);
|
||||
break;
|
||||
case VL53L1_ERROR_DIVISION_BY_ZERO:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_DIVISION_BY_ZERO);
|
||||
break;
|
||||
case VL53L1_ERROR_REF_SPAD_INIT:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_REF_SPAD_INIT);
|
||||
break;
|
||||
case VL53L1_ERROR_GPH_SYNC_CHECK_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_GPH_SYNC_CHECK_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_STREAM_COUNT_CHECK_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_STREAM_COUNT_CHECK_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_GPH_ID_CHECK_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_GPH_ID_CHECK_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_ZONE_GPH_ID_CHECK_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_ZONE_GPH_ID_CHECK_FAIL);
|
||||
break;
|
||||
|
||||
case VL53L1_ERROR_XTALK_EXTRACTION_NO_SAMPLE_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_XTALK_EXTRACTION_NO_SAMPLES_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL);
|
||||
break;
|
||||
|
||||
case VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_ZONE_CAL_NO_SAMPLE_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_ZONE_CAL_NO_SAMPLE_FAIL);
|
||||
break;
|
||||
|
||||
case VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_OFFSET_CAL_MISSING_SAMPLES);
|
||||
break;
|
||||
case VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH);
|
||||
break;
|
||||
case VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_OFFSET_CAL_RATE_TOO_HIGH);
|
||||
break;
|
||||
case VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW);
|
||||
break;
|
||||
|
||||
case VL53L1_WARNING_ZONE_CAL_MISSING_SAMPLES:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_ZONE_CAL_MISSING_SAMPLES);
|
||||
break;
|
||||
case VL53L1_WARNING_ZONE_CAL_SIGMA_TOO_HIGH:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_ZONE_CAL_SIGMA_TOO_HIGH);
|
||||
break;
|
||||
case VL53L1_WARNING_ZONE_CAL_RATE_TOO_HIGH:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_ZONE_CAL_RATE_TOO_HIGH);
|
||||
break;
|
||||
|
||||
case VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS);
|
||||
break;
|
||||
case VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH);
|
||||
break;
|
||||
case VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW);
|
||||
break;
|
||||
|
||||
case VL53L1_WARNING_XTALK_MISSING_SAMPLES:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_XTALK_MISSING_SAMPLES);
|
||||
break;
|
||||
case VL53L1_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT);
|
||||
break;
|
||||
case VL53L1_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT);
|
||||
break;
|
||||
|
||||
case VL53L1_ERROR_DEVICE_FIRMWARE_TOO_OLD:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_DEVICE_FIRMWARE_TOO_OLD);
|
||||
break;
|
||||
case VL53L1_ERROR_DEVICE_FIRMWARE_TOO_NEW:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_DEVICE_FIRMWARE_TOO_NEW);
|
||||
break;
|
||||
case VL53L1_ERROR_UNIT_TEST_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_UNIT_TEST_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_FILE_READ_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_FILE_READ_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_FILE_WRITE_FAIL:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_FILE_WRITE_FAIL);
|
||||
break;
|
||||
case VL53L1_ERROR_NOT_IMPLEMENTED:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_ERROR_NOT_IMPLEMENTED);
|
||||
break;
|
||||
default:
|
||||
VL53L1_COPYSTRING(pPalErrorString,
|
||||
VL53L1_STRING_UNKNOW_ERROR_CODE);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
LOG_FUNCTION_END(Status);
|
||||
|
||||
return Status;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_silicon_core.c
|
||||
*
|
||||
* @brief EwokPlus25 low level silicon LL Driver function definition
|
||||
*/
|
||||
|
||||
|
||||
#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)
|
||||
{
|
||||
/**
|
||||
* Determines if the firmware is ready to range
|
||||
*
|
||||
* There are 2 different behaviors depending on whether
|
||||
* power force is enabled or not
|
||||
*/
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
|
||||
|
||||
uint8_t comms_buffer[5];
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
/* read interrupt and power force reset status */
|
||||
|
||||
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 {
|
||||
|
||||
/* set ready flag if bit 0 is zero i.g G01 is in reset */
|
||||
if ((pdev->dbg_results.power_management__go1_reset_status & 0x01) == 0x00)
|
||||
*pready = 0x01;
|
||||
else
|
||||
*pready = 0x00;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
|
@ -0,0 +1,558 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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/sla0081
|
||||
*
|
||||
* 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_wait.c
|
||||
*
|
||||
* @brief EwokPlus25 low level Driver wait function definition
|
||||
*/
|
||||
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_ll_device.h"
|
||||
#include "vl53l1_platform.h"
|
||||
#include "vl53l1_core.h"
|
||||
#include "vl53l1_silicon_core.h"
|
||||
#include "vl53l1_wait.h"
|
||||
#include "vl53l1_register_settings.h"
|
||||
|
||||
|
||||
#define LOG_FUNCTION_START(fmt, ...) \
|
||||
_LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END(status, ...) \
|
||||
_LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
|
||||
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
|
||||
_LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE, status, \
|
||||
fmt, ##__VA_ARGS__)
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_wait_for_boot_completion(
|
||||
VL53L1_DEV Dev)
|
||||
{
|
||||
|
||||
/* Waits for firmware boot to finish
|
||||
*/
|
||||
|
||||
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) {
|
||||
|
||||
/* blocking version */
|
||||
|
||||
status =
|
||||
VL53L1_poll_for_boot_completion(
|
||||
Dev,
|
||||
VL53L1_BOOT_COMPLETION_POLLING_TIMEOUT_MS);
|
||||
|
||||
} else {
|
||||
|
||||
/* implement non blocking version below */
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
/* If in timed mode or single shot then check firmware is ready
|
||||
* before sending handshake
|
||||
*/
|
||||
|
||||
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("");
|
||||
|
||||
/* Filter out tje measure mode part of the mode
|
||||
* start register
|
||||
*/
|
||||
mode_start =
|
||||
pdev->sys_ctrl.system__mode_start &
|
||||
VL53L1_DEVICEMEASUREMENTMODE_MODE_MASK;
|
||||
|
||||
/*
|
||||
* conditional wait for firmware ready
|
||||
* only waits for timed and single shot modes
|
||||
*/
|
||||
|
||||
if ((mode_start == VL53L1_DEVICEMEASUREMENTMODE_TIMED) ||
|
||||
(mode_start == VL53L1_DEVICEMEASUREMENTMODE_SINGLESHOT)) {
|
||||
|
||||
if (pdev->wait_method == VL53L1_WAIT_METHOD_BLOCKING) {
|
||||
|
||||
/* blocking version */
|
||||
|
||||
status =
|
||||
VL53L1_poll_for_firmware_ready(
|
||||
Dev,
|
||||
VL53L1_RANGE_COMPLETION_POLLING_TIMEOUT_MS);
|
||||
|
||||
} else {
|
||||
|
||||
/* implement non blocking version below */
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
/* Wrapper function for waiting for range completion
|
||||
*/
|
||||
|
||||
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) {
|
||||
|
||||
/* blocking version */
|
||||
|
||||
status =
|
||||
VL53L1_poll_for_range_completion(
|
||||
Dev,
|
||||
VL53L1_RANGE_COMPLETION_POLLING_TIMEOUT_MS);
|
||||
|
||||
} else {
|
||||
|
||||
/* implement non blocking version below */
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
/* Wrapper function for waiting for test mode completion
|
||||
*/
|
||||
|
||||
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) {
|
||||
|
||||
/* blocking version */
|
||||
|
||||
status =
|
||||
VL53L1_poll_for_range_completion(
|
||||
Dev,
|
||||
VL53L1_TEST_COMPLETION_POLLING_TIMEOUT_MS);
|
||||
|
||||
} else {
|
||||
|
||||
/* implement non blocking version below */
|
||||
|
||||
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)
|
||||
{
|
||||
/**
|
||||
* Determines if the firmware finished booting by reading
|
||||
* bit 0 of firmware__system_status register
|
||||
*/
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
uint8_t firmware__system_status = 0;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
/* read current range interrupt state */
|
||||
|
||||
status =
|
||||
VL53L1_RdByte(
|
||||
Dev,
|
||||
VL53L1_FIRMWARE__SYSTEM_STATUS,
|
||||
&firmware__system_status);
|
||||
|
||||
/* set *pready = 1 if new range data ready complete
|
||||
* zero otherwise
|
||||
*/
|
||||
|
||||
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)
|
||||
{
|
||||
/**
|
||||
* Determines if the firmware is ready to range
|
||||
*/
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
status = VL53L1_is_firmware_ready_silicon(
|
||||
Dev,
|
||||
pready);
|
||||
|
||||
pdev->fw_ready = *pready;
|
||||
|
||||
LOG_FUNCTION_END(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_is_new_data_ready(
|
||||
VL53L1_DEV Dev,
|
||||
uint8_t *pready)
|
||||
{
|
||||
/**
|
||||
* Determines if new range data is ready by reading bit 0 of
|
||||
* VL53L1_GPIO__TIO_HV_STATUS to determine the current state
|
||||
* of output interrupt pin
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
/* read current range interrupt state */
|
||||
|
||||
status = VL53L1_RdByte(
|
||||
Dev,
|
||||
VL53L1_GPIO__TIO_HV_STATUS,
|
||||
&gpio__tio_hv_status);
|
||||
|
||||
/* set *pready = 1 if new range data ready complete zero otherwise */
|
||||
|
||||
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)
|
||||
{
|
||||
/**
|
||||
* Polls the bit 0 of the FIRMWARE__SYSTEM_STATUS register to see if
|
||||
* the firmware is ready.
|
||||
*/
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
LOG_FUNCTION_START("");
|
||||
|
||||
/* after reset for the firmware blocks I2C access while
|
||||
* it copies the NVM data into the G02 host register banks
|
||||
* The host must wait the required time to allow the copy
|
||||
* to complete before attempting to read the firmware status
|
||||
*/
|
||||
|
||||
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)
|
||||
{
|
||||
/**
|
||||
* Polls the bit 0 of the FIRMWARE__SYSTEM_STATUS register to see if
|
||||
* the firmware is ready.
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
/* calculate time limit in absolute time */
|
||||
|
||||
VL53L1_GetTickCount(Dev, &start_time_ms); /*lint !e534 ignoring return*/
|
||||
pdev->fw_ready_poll_duration_ms = 0;
|
||||
|
||||
/* wait until firmware is ready, timeout reached on error occurred */
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update polling time (Compare difference rather than
|
||||
* absolute to negate 32bit wrap around issue)
|
||||
*/
|
||||
VL53L1_GetTickCount(Dev, ¤t_time_ms); /*lint !e534 ignoring return*/
|
||||
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)
|
||||
{
|
||||
/**
|
||||
* Polls bit 0 of VL53L1_GPIO__TIO_HV_STATUS to determine
|
||||
* the state of output interrupt pin
|
||||
*
|
||||
* Interrupt may be either active high or active low. Use active_high to
|
||||
* select the required level check
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,431 @@
|
|||
/*******************************************************************************
|
||||
Copyright (C) 2016, STMicroelectronics International N.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of STMicroelectronics nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
||||
NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_H_
|
||||
#define _VL53L1_PLATFORM_H_
|
||||
|
||||
#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
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
/*******************************************************************************
|
||||
Copyright (C) 2016, STMicroelectronics International N.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of STMicroelectronics nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
||||
NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_INIT_H_
|
||||
#define _VL53L1_PLATFORM_INIT_H_
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file vl53l1_platform_init.h
|
||||
*
|
||||
* @brief EwokPlus25 comms and GPIO init
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialise platform comms, GPIO and reset device
|
||||
*
|
||||
* Initialises comms, sets the states of GPIO (xshutdown, ncs,
|
||||
* EVK device power regulator enable) and resets the device
|
||||
*
|
||||
* @param[in] pdev : pointer to device structure (device handle)
|
||||
* @param[in] i2c_slave_address : I2C slave address
|
||||
* @param[in] comms_type : Comms type: VL53L1_I2C or VL53L1_SPI
|
||||
* @param[in] comms_speed_khz : 400kHz recommended for I2C
|
||||
*
|
||||
* @return VL53L1_ERROR_NONE Success
|
||||
* @return "Other error code" See ::VL53L1_Error
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_platform_init(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint8_t i2c_slave_address,
|
||||
uint8_t comms_type,
|
||||
uint16_t comms_speed_khz);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Close platform comms and GPIO
|
||||
*
|
||||
* Puts the device into reset, disables the EVK device power regulator
|
||||
* and closes 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_platform_terminate(
|
||||
VL53L1_Dev_t *pdev);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
#ifdef VL53L1_NEEDS_IPP
|
||||
# undef VL53L1_IPP_API
|
||||
# define VL53L1_IPP_API __declspec(dllimport)
|
||||
# pragma comment (lib, "EwokPlus25API_IPP")
|
||||
#endif
|
|
@ -0,0 +1,223 @@
|
|||
/*******************************************************************************
|
||||
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_log.h
|
||||
*
|
||||
* @brief EwokPlus25 platform logging function definition
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_LOG_H_
|
||||
#define _VL53L1_PLATFORM_LOG_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 <time.h>
|
||||
|
||||
/**
|
||||
* @brief Set the level, output and specific functions for module logging.
|
||||
*
|
||||
*
|
||||
* @param filename - full path of output log file, NULL for print to stdout
|
||||
*
|
||||
* @param modules - Module or None or All to trace
|
||||
* VL53L1_TRACE_MODULE_NONE
|
||||
* VL53L1_TRACE_MODULE_API
|
||||
* VL53L1_TRACE_MODULE_CORE
|
||||
* VL53L1_TRACE_MODULE_TUNING
|
||||
* VL53L1_TRACE_MODULE_CHARACTERISATION
|
||||
* VL53L1_TRACE_MODULE_PLATFORM
|
||||
* VL53L1_TRACE_MODULE_ALL
|
||||
*
|
||||
* @param level - trace level
|
||||
* VL53L1_TRACE_LEVEL_NONE
|
||||
* VL53L1_TRACE_LEVEL_ERRORS
|
||||
* VL53L1_TRACE_LEVEL_WARNING
|
||||
* VL53L1_TRACE_LEVEL_INFO
|
||||
* VL53L1_TRACE_LEVEL_DEBUG
|
||||
* VL53L1_TRACE_LEVEL_ALL
|
||||
* VL53L1_TRACE_LEVEL_IGNORE
|
||||
*
|
||||
* @param functions - function level to trace;
|
||||
* VL53L1_TRACE_FUNCTION_NONE
|
||||
* VL53L1_TRACE_FUNCTION_I2C
|
||||
* VL53L1_TRACE_FUNCTION_ALL
|
||||
*
|
||||
* @return status - always VL53L1_ERROR_NONE
|
||||
*
|
||||
*/
|
||||
|
||||
#define VL53L1_TRACE_LEVEL_NONE 0x00000000
|
||||
#define VL53L1_TRACE_LEVEL_ERRORS 0x00000001
|
||||
#define VL53L1_TRACE_LEVEL_WARNING 0x00000002
|
||||
#define VL53L1_TRACE_LEVEL_INFO 0x00000004
|
||||
#define VL53L1_TRACE_LEVEL_DEBUG 0x00000008
|
||||
#define VL53L1_TRACE_LEVEL_ALL 0x00000010
|
||||
#define VL53L1_TRACE_LEVEL_IGNORE 0x00000020
|
||||
|
||||
#define VL53L1_TRACE_FUNCTION_NONE 0x00000000
|
||||
#define VL53L1_TRACE_FUNCTION_I2C 0x00000001
|
||||
#define VL53L1_TRACE_FUNCTION_ALL 0x7fffffff
|
||||
|
||||
#define VL53L1_TRACE_MODULE_NONE 0x00000000
|
||||
#define VL53L1_TRACE_MODULE_API 0x00000001
|
||||
#define VL53L1_TRACE_MODULE_CORE 0x00000002
|
||||
#define VL53L1_TRACE_MODULE_PROTECTED 0x00000004
|
||||
#define VL53L1_TRACE_MODULE_HISTOGRAM 0x00000008
|
||||
#define VL53L1_TRACE_MODULE_REGISTERS 0x00000010
|
||||
#define VL53L1_TRACE_MODULE_PLATFORM 0x00000020
|
||||
#define VL53L1_TRACE_MODULE_NVM 0x00000040
|
||||
#define VL53L1_TRACE_MODULE_CALIBRATION_DATA 0x00000080
|
||||
#define VL53L1_TRACE_MODULE_NVM_DATA 0x00000100
|
||||
#define VL53L1_TRACE_MODULE_HISTOGRAM_DATA 0x00000200
|
||||
#define VL53L1_TRACE_MODULE_RANGE_RESULTS_DATA 0x00000400
|
||||
#define VL53L1_TRACE_MODULE_XTALK_DATA 0x00000800
|
||||
#define VL53L1_TRACE_MODULE_OFFSET_DATA 0x00001000
|
||||
#define VL53L1_TRACE_MODULE_DATA_INIT 0x00002000
|
||||
#define VL53L1_TRACE_MODULE_REF_SPAD_CHAR 0x00004000
|
||||
#define VL53L1_TRACE_MODULE_SPAD_RATE_MAP 0x00008000
|
||||
#ifdef PAL_EXTENDED
|
||||
#define VL53L1_TRACE_MODULE_SPAD 0x01000000
|
||||
#define VL53L1_TRACE_MODULE_FMT 0x02000000
|
||||
#define VL53L1_TRACE_MODULE_UTILS 0x04000000
|
||||
#define VL53L1_TRACE_MODULE_BENCH_FUNCS 0x08000000
|
||||
#endif
|
||||
#define VL53L1_TRACE_MODULE_CUSTOMER_API 0x40000000
|
||||
#define VL53L1_TRACE_MODULE_ALL 0x7fffffff
|
||||
|
||||
|
||||
extern uint32_t _trace_level;
|
||||
|
||||
/*
|
||||
* NOTE: dynamically exported if we enable logging.
|
||||
* this way, Python interfaces can access this function, but we don't
|
||||
* need to include it in the .def files.
|
||||
*/
|
||||
EWOKPLUS_EXPORTS int8_t VL53L1_trace_config(
|
||||
char *filename,
|
||||
uint32_t modules,
|
||||
uint32_t level,
|
||||
uint32_t functions);
|
||||
|
||||
/**
|
||||
* @brief Print trace module function.
|
||||
*
|
||||
* @param module - ??
|
||||
* @param level - ??
|
||||
* @param function - ??
|
||||
* @param format - ??
|
||||
*
|
||||
*/
|
||||
|
||||
EWOKPLUS_EXPORTS void VL53L1_trace_print_module_function(
|
||||
uint32_t module,
|
||||
uint32_t level,
|
||||
uint32_t function,
|
||||
const char *format, ...);
|
||||
|
||||
/**
|
||||
* @brief Get global _trace_functions parameter
|
||||
*
|
||||
* @return _trace_functions
|
||||
*/
|
||||
|
||||
uint32_t VL53L1_get_trace_functions(void);
|
||||
|
||||
/**
|
||||
* @brief Set global _trace_functions parameter
|
||||
*
|
||||
* @param[in] function : new function code
|
||||
*/
|
||||
|
||||
void VL53L1_set_trace_functions(uint32_t function);
|
||||
|
||||
|
||||
/*
|
||||
* @brief Returns the current system tick count in [ms]
|
||||
*
|
||||
* @return time_ms : current time in [ms]
|
||||
*
|
||||
*/
|
||||
|
||||
uint32_t VL53L1_clock(void);
|
||||
|
||||
#define LOG_GET_TIME() \
|
||||
((int)VL53L1_clock())
|
||||
|
||||
#define _LOG_TRACE_PRINT(module, level, function, ...) \
|
||||
VL53L1_trace_print_module_function(module, level, function, ##__VA_ARGS__);
|
||||
|
||||
#define _LOG_FUNCTION_START(module, fmt, ...) \
|
||||
VL53L1_trace_print_module_function(module, _trace_level, VL53L1_TRACE_FUNCTION_ALL, "%6ld <START> %s "fmt"\n", LOG_GET_TIME(), __FUNCTION__, ##__VA_ARGS__);
|
||||
|
||||
#define _LOG_FUNCTION_END(module, status, ...)\
|
||||
VL53L1_trace_print_module_function(module, _trace_level, VL53L1_TRACE_FUNCTION_ALL, "%6ld <END> %s %d\n", LOG_GET_TIME(), __FUNCTION__, (int)status, ##__VA_ARGS__)
|
||||
|
||||
#define _LOG_FUNCTION_END_FMT(module, status, fmt, ...)\
|
||||
VL53L1_trace_print_module_function(module, _trace_level, VL53L1_TRACE_FUNCTION_ALL, "%6ld <END> %s %d "fmt"\n", LOG_GET_TIME(), __FUNCTION__, (int)status, ##__VA_ARGS__)
|
||||
|
||||
#define _LOG_GET_TRACE_FUNCTIONS()\
|
||||
VL53L1_get_trace_functions()
|
||||
|
||||
#define _LOG_SET_TRACE_FUNCTIONS(functions)\
|
||||
VL53L1_set_trace_functions(functions)
|
||||
|
||||
#define _LOG_STRING_BUFFER(x) char x[VL53L1_MAX_STRING_LENGTH]
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* VL53L1_LOG_ENABLE - no logging */
|
||||
|
||||
#define _LOG_TRACE_PRINT(module, level, function, ...)
|
||||
#define _LOG_FUNCTION_START(module, fmt, ...)
|
||||
#define _LOG_FUNCTION_END(module, status, ...)
|
||||
#define _LOG_FUNCTION_END_FMT(module, status, fmt, ...)
|
||||
#define _LOG_GET_TRACE_FUNCTIONS() 0
|
||||
#define _LOG_SET_TRACE_FUNCTIONS(functions)
|
||||
#define _LOG_STRING_BUFFER(x)
|
||||
|
||||
#endif /* VL53L1_LOG_ENABLE */
|
||||
|
||||
#endif /* _VL53L1_PLATFORM_LOG_H_ */
|
|
@ -0,0 +1,84 @@
|
|||
/*******************************************************************************
|
||||
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 LLD TuningParms Page Base Address
|
||||
* - Part of Patch_AddedTuningParms_11761
|
||||
*/
|
||||
#define VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS 0x8000
|
||||
#define VL53L1_TUNINGPARM_PRIVATE_PAGE_BASE_ADDRESS 0xC000
|
||||
|
||||
#define VL53L1_GAIN_FACTOR__STANDARD_DEFAULT 0x0800
|
||||
/*!< Default standard ranging gain correction factor
|
||||
1.11 format. 1.0 = 0x0800, 0.980 = 0x07D7 */
|
||||
|
||||
#define VL53L1_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_MAX_USER_ZONES 1
|
||||
/*!< Max number of user Zones - maximal limitation from
|
||||
FW stream divide - value of 254 */
|
||||
|
||||
#define VL53L1_MAX_RANGE_RESULTS 2
|
||||
/*!< Allocates storage for return and reference restults */
|
||||
|
||||
|
||||
#define VL53L1_MAX_STRING_LENGTH 512
|
||||
|
||||
#endif /* _VL53L1_PLATFORM_USER_CONFIG_H_ */
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
/*******************************************************************************
|
||||
Copyright (C) 2016, STMicroelectronics International N.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of STMicroelectronics nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
||||
NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_USER_DATA_H_
|
||||
#define _VL53L1_PLATFORM_USER_DATA_H_
|
||||
|
||||
#ifndef __KERNEL__
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "vl53l1_def.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file vl53l1_platform_user_data.h
|
||||
*
|
||||
* @brief All end user OS/platform/application porting
|
||||
*/
|
||||
|
||||
/** @brief Contains the current state and internal values of the API
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
|
||||
VL53L1_DevData_t Data;
|
||||
/*!< Low Level Driver data structure */
|
||||
|
||||
uint8_t i2c_slave_address;
|
||||
/*!< i2c device address user specific field */
|
||||
uint8_t comms_type;
|
||||
/*!< Type of comms : VL53L1_I2C or VL53L1_SPI */
|
||||
uint16_t comms_speed_khz;
|
||||
/*!< Comms speed [kHz] : typically 400kHz for I2C */
|
||||
|
||||
uint32_t new_data_ready_poll_duration_ms;
|
||||
/*!< New data ready poll duration in ms - for debug */
|
||||
} VL53L1_Dev_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Declare the device Handle as a pointer of the structure @a VL53L1_Dev_t.
|
||||
*
|
||||
*/
|
||||
typedef VL53L1_Dev_t *VL53L1_DEV;
|
||||
|
||||
/**
|
||||
* @def PALDevDataGet
|
||||
* @brief Get ST private structure @a VL53L1_DevData_t data access
|
||||
*
|
||||
* @param Dev Device Handle
|
||||
* @param field ST structure field name
|
||||
* It maybe used and as real data "ref" not just as "get" for sub-structure item
|
||||
* like PALDevDataGet(FilterData.field)[i] or
|
||||
* PALDevDataGet(FilterData.MeasurementIndex)++
|
||||
*/
|
||||
#define PALDevDataGet(Dev, field) (Dev->Data.field)
|
||||
|
||||
|
||||
/**
|
||||
* @def PALDevDataSet(Dev, field, data)
|
||||
* @brief Set ST private structure @a VL53L1_DevData_t data field
|
||||
* @param Dev Device Handle
|
||||
* @param field ST structure field name
|
||||
* @param data Data to be set
|
||||
*/
|
||||
#define PALDevDataSet(Dev, field, data) ((Dev->Data.field) = (data))
|
||||
|
||||
|
||||
/**
|
||||
* @def VL53L1DevStructGetLLDriverHandle
|
||||
* @brief Get LL Driver handle @a VL53L0_Dev_t data access
|
||||
*
|
||||
* @param Dev Device Handle
|
||||
*/
|
||||
#define VL53L1DevStructGetLLDriverHandle(Dev) (&Dev->Data.LLData)
|
||||
|
||||
/**
|
||||
* @def VL53L1DevStructGetLLResultsHandle
|
||||
* @brief Get LL Results handle @a VL53L0_Dev_t data access
|
||||
*
|
||||
* @param Dev Device Handle
|
||||
*/
|
||||
#define VL53L1DevStructGetLLResultsHandle(Dev) (&Dev->Data.llresults)
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
/*******************************************************************************
|
||||
Copyright (C) 2016, STMicroelectronics International N.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of STMicroelectronics nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
||||
NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _VL53L1_PLATFORM_USER_DEFINES_H_
|
||||
#define _VL53L1_PLATFORM_USER_DEFINES_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#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
|
||||
*/
|
||||
#define do_division_u(dividend, divisor) (dividend / divisor)
|
||||
|
||||
|
||||
/**
|
||||
* @def do_division_s
|
||||
* @brief customer supplied division operation - 64-bit signed
|
||||
*
|
||||
* @param dividend signed 64-bit numerator
|
||||
* @param divisor signed 64-bit denominator
|
||||
*/
|
||||
#define do_division_s(dividend, divisor) (dividend / divisor)
|
||||
|
||||
|
||||
/**
|
||||
* @def WARN_OVERRIDE_STATUS
|
||||
* @brief customer supplied macro to optionally output info when a specific
|
||||
error has been overridden with success within the EwokPlus driver
|
||||
*
|
||||
* @param __X__ the macro which enabled the suppression
|
||||
*/
|
||||
#define WARN_OVERRIDE_STATUS(__X__)\
|
||||
trace_print (VL53L1_TRACE_LEVEL_WARNING, #__X__);
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define DISABLE_WARNINGS() { \
|
||||
__pragma (warning (push)); \
|
||||
__pragma (warning (disable:4127)); \
|
||||
}
|
||||
#define ENABLE_WARNINGS() { \
|
||||
__pragma (warning (pop)); \
|
||||
}
|
||||
#else
|
||||
#define DISABLE_WARNINGS()
|
||||
#define ENABLE_WARNINGS()
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _VL53L1_PLATFORM_USER_DEFINES_H_
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
/*******************************************************************************
|
||||
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_types.h
|
||||
* @brief VL53L1 types definition
|
||||
*/
|
||||
|
||||
#ifndef _VL53L1_TYPES_H_
|
||||
#define _VL53L1_TYPES_H_
|
||||
|
||||
/** @defgroup porting_type Basic type definition
|
||||
* @ingroup api_platform
|
||||
*
|
||||
* @brief file vl53l1_types.h files hold basic type definition that may requires porting
|
||||
*
|
||||
* contains type that must be defined for the platform\n
|
||||
* when target platform and compiler provide stdint.h and stddef.h it is enough to include it.\n
|
||||
* If stdint.h is not available review and adapt all signed and unsigned 8/16/32 bits basic types. \n
|
||||
* If stddef.h is not available review and adapt NULL definition .
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef NULL
|
||||
#error "Error NULL definition should be done. Please add required include "
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(STDINT_H) && !defined(_STDINT_H) && !defined(_GCC_STDINT_H) && !defined(__STDINT_DECLS) && !defined(_GCC_WRAP_STDINT_H) && !defined(_STDINT)
|
||||
|
||||
#pragma message("Please review type definition of STDINT define for your platform and add to list above ")
|
||||
|
||||
/*
|
||||
* target platform do not provide stdint or use a different #define than above
|
||||
* to avoid seeing the message below addapt the #define list above or implement
|
||||
* all type and delete these pragma
|
||||
*/
|
||||
|
||||
/** \ingroup VL53L1_portingType_group
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
typedef unsigned long long uint64_t;
|
||||
|
||||
|
||||
/** @brief Typedef defining 32 bit unsigned int type.\n
|
||||
* The developer should modify this to suit the platform being deployed.
|
||||
*/
|
||||
typedef unsigned int uint32_t;
|
||||
|
||||
/** @brief Typedef defining 32 bit int type.\n
|
||||
* The developer should modify this to suit the platform being deployed.
|
||||
*/
|
||||
typedef int int32_t;
|
||||
|
||||
/** @brief Typedef defining 16 bit unsigned short type.\n
|
||||
* The developer should modify this to suit the platform being deployed.
|
||||
*/
|
||||
typedef unsigned short uint16_t;
|
||||
|
||||
/** @brief Typedef defining 16 bit short type.\n
|
||||
* The developer should modify this to suit the platform being deployed.
|
||||
*/
|
||||
typedef short int16_t;
|
||||
|
||||
/** @brief Typedef defining 8 bit unsigned char type.\n
|
||||
* The developer should modify this to suit the platform being deployed.
|
||||
*/
|
||||
typedef unsigned char uint8_t;
|
||||
|
||||
/** @brief Typedef defining 8 bit char type.\n
|
||||
* The developer should modify this to suit the platform being deployed.
|
||||
*/
|
||||
typedef signed char int8_t;
|
||||
|
||||
/** @} */
|
||||
#endif /* _STDINT_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_ */
|
|
@ -0,0 +1,860 @@
|
|||
/*******************************************************************************
|
||||
Copyright (C) 2016, STMicroelectronics International N.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of STMicroelectronics nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
||||
NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @file vl53l1_platform.c
|
||||
* @brief Code function definitions for EwokPlus25 Platform Layer
|
||||
* RANGING SENSOR VERSION
|
||||
*
|
||||
*/
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdio.h> // sprintf(), vsnprintf(), printf()
|
||||
#include <stdint.h>
|
||||
#include <string.h> // strncpy(), strnlen()
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#include "vl53l1_platform.h"
|
||||
#include "vl53l1_platform_log.h"
|
||||
|
||||
#ifdef PAL_EXTENDED
|
||||
#include "vl53l1_register_strings.h"
|
||||
#else
|
||||
#define VL53L1_get_register_name(a,b)
|
||||
#endif
|
||||
|
||||
#include "ranging_sensor_comms.h"
|
||||
#include "power_board_defs.h"
|
||||
|
||||
// flag to indicate if power board has been accessed
|
||||
const uint32_t _power_board_in_use = 0;
|
||||
|
||||
// flag to indicate if we can use the extended voltage ranges (not laser safe!)
|
||||
uint32_t _power_board_extended = 0;
|
||||
|
||||
// cache of the comms type flag
|
||||
uint8_t global_comms_type = 0;
|
||||
|
||||
#define VL53L1_COMMS_CHUNK_SIZE 56
|
||||
#define VL53L1_COMMS_BUFFER_SIZE 64
|
||||
|
||||
#define GPIO_INTERRUPT RS_GPIO62
|
||||
#define GPIO_POWER_ENABLE RS_GPIO60
|
||||
#define GPIO_XSHUTDOWN RS_GPIO61
|
||||
#define GPIO_SPI_CHIP_SELECT RS_GPIO51
|
||||
|
||||
/*!
|
||||
* The intent of this Abstraction layer is to provide the same API
|
||||
* to the underlying SystemVerilog tasks as the C driver will have
|
||||
* to ST Comms DLL's for the talking to Ewok via the USB + STM32
|
||||
* or if the C-driver is implemented directly on the STM32
|
||||
*/
|
||||
|
||||
#define trace_print(level, ...) \
|
||||
_LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_PLATFORM, \
|
||||
level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
|
||||
|
||||
#define trace_i2c(...) \
|
||||
_LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_NONE, \
|
||||
VL53L1_TRACE_LEVEL_NONE, VL53L1_TRACE_FUNCTION_I2C, ##__VA_ARGS__)
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_CommsInitialise(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint8_t comms_type,
|
||||
uint16_t comms_speed_khz)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
char comms_error_string[ERROR_TEXT_LENGTH];
|
||||
|
||||
SUPPRESS_UNUSED_WARNING(pdev);
|
||||
SUPPRESS_UNUSED_WARNING(comms_speed_khz);
|
||||
|
||||
global_comms_type = comms_type;
|
||||
|
||||
if(global_comms_type == VL53L1_I2C)
|
||||
{
|
||||
if ((CP_STATUS)RANGING_SENSOR_COMMS_Init_CCI(0, 0, 0) != CP_STATUS_OK)
|
||||
{
|
||||
RANGING_SENSOR_COMMS_Get_Error_Text(comms_error_string); /*lint !e534 ignoring return value */
|
||||
trace_i2c("VL53L1_CommsInitialise: RANGING_SENSOR_COMMS_Init_CCI() failed\n");
|
||||
trace_i2c(comms_error_string);
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
}
|
||||
else if(global_comms_type == VL53L1_SPI)
|
||||
{
|
||||
if ((CP_STATUS)RANGING_SENSOR_COMMS_Init_SPI_V2W8(0, 0, 0) != CP_STATUS_OK)
|
||||
{
|
||||
RANGING_SENSOR_COMMS_Get_Error_Text(comms_error_string); /*lint !e534 ignoring return value */
|
||||
trace_i2c("VL53L1_CommsInitialise: RANGING_SENSOR_COMMS_Init_SPI_V2W8() failed\n");
|
||||
trace_i2c(comms_error_string);
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
trace_i2c("VL53L1_CommsInitialise: Comms must be one of VL53L1_I2C or VL53L1_SPI\n");
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_CommsClose(
|
||||
VL53L1_Dev_t *pdev)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
char comms_error_string[ERROR_TEXT_LENGTH];
|
||||
|
||||
SUPPRESS_UNUSED_WARNING(pdev);
|
||||
|
||||
if(global_comms_type == VL53L1_I2C)
|
||||
{
|
||||
if((CP_STATUS)RANGING_SENSOR_COMMS_Fini_CCI() != CP_STATUS_OK)
|
||||
{
|
||||
RANGING_SENSOR_COMMS_Get_Error_Text(comms_error_string); /*lint !e534 ignoring return value */
|
||||
trace_i2c("VL53L1_CommsClose: RANGING_SENSOR_COMMS_Fini_CCI() failed\n");
|
||||
trace_i2c(comms_error_string);
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
}
|
||||
else if(global_comms_type == VL53L1_SPI)
|
||||
{
|
||||
if((CP_STATUS)RANGING_SENSOR_COMMS_Fini_SPI_V2W8() != CP_STATUS_OK)
|
||||
{
|
||||
RANGING_SENSOR_COMMS_Get_Error_Text(comms_error_string); /*lint !e534 ignoring return value */
|
||||
trace_i2c("VL53L1_CommsClose: RANGING_SENSOR_COMMS_Fini_SPI_V2W8() failed\n");
|
||||
trace_i2c(comms_error_string);
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
trace_i2c("VL53L1_CommsClose: Comms must be one of VL53L1_I2C or VL53L1_SPI\n");
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ----------------- COMMS FUNCTIONS -----------------
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_WriteMulti(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint16_t index,
|
||||
uint8_t *pdata,
|
||||
uint32_t count)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
uint32_t position = 0;
|
||||
uint32_t data_size = 0;
|
||||
|
||||
char comms_error_string[ERROR_TEXT_LENGTH];
|
||||
|
||||
_LOG_STRING_BUFFER(register_name);
|
||||
_LOG_STRING_BUFFER(value_as_str);
|
||||
|
||||
if(global_comms_type == VL53L1_I2C)
|
||||
{
|
||||
for(position=0; position<count; position+=VL53L1_COMMS_CHUNK_SIZE)
|
||||
{
|
||||
if (count > VL53L1_COMMS_CHUNK_SIZE)
|
||||
{
|
||||
if((position + VL53L1_COMMS_CHUNK_SIZE) > count)
|
||||
{
|
||||
data_size = count - position;
|
||||
}
|
||||
else
|
||||
{
|
||||
data_size = VL53L1_COMMS_CHUNK_SIZE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
data_size = count;
|
||||
}
|
||||
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
{
|
||||
if( RANGING_SENSOR_COMMS_Write_CCI(
|
||||
pdev->i2c_slave_address,
|
||||
0,
|
||||
index+position,
|
||||
pdata+position,
|
||||
data_size) != 0 )
|
||||
{
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VL53L1_LOG_ENABLE
|
||||
if (status == VL53L1_ERROR_NONE) {
|
||||
char* pvalue_as_str;
|
||||
uint32_t i;
|
||||
|
||||
/*lint --e{661} Suppress out of bounds walkthrough warning */
|
||||
/*lint --e{662} Suppress out of bounds walkthrough warning */
|
||||
|
||||
// Build value as string;
|
||||
pvalue_as_str = value_as_str;
|
||||
for(i = 0 ; i < data_size ; i++)
|
||||
{
|
||||
sprintf(pvalue_as_str, ", 0x%02X", *(pdata+position+i));
|
||||
pvalue_as_str = pvalue_as_str + 6;
|
||||
}
|
||||
|
||||
register_name[0] = 0;
|
||||
VL53L1_get_register_name(
|
||||
index+(uint16_t)position,
|
||||
register_name);
|
||||
|
||||
trace_i2c(
|
||||
/* "WriteAutoIncrement(0x%04X%s); // %3u bytes\n",
|
||||
index+(uint16_t)position, */
|
||||
"WriteAutoIncrement(%s%s); // %3u bytes\n",
|
||||
register_name,
|
||||
value_as_str,
|
||||
data_size);
|
||||
}
|
||||
#endif // VL53L1_LOG_ENABLE
|
||||
}
|
||||
|
||||
if(status != VL53L1_ERROR_NONE)
|
||||
{
|
||||
RANGING_SENSOR_COMMS_Get_Error_Text(comms_error_string); /*lint !e534 ignoring return value */
|
||||
trace_i2c("VL53L1_WriteMulti RANGING_SENSOR_COMMS_Write_CCI() failed\n");
|
||||
trace_i2c(comms_error_string);
|
||||
}
|
||||
}
|
||||
else if(global_comms_type == VL53L1_SPI)
|
||||
{
|
||||
if((CP_STATUS)RANGING_SENSOR_COMMS_Write_SPI_16I(0, 0, index, pdata, count) != CP_STATUS_OK)
|
||||
{
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
|
||||
if(status != VL53L1_ERROR_NONE)
|
||||
{
|
||||
RANGING_SENSOR_COMMS_Get_Error_Text(comms_error_string); /*lint !e534 ignoring return value */
|
||||
trace_i2c("VL53L1_WriteMulti RANGING_SENSOR_COMMS_Write_SPI_16I() failed\n");
|
||||
trace_i2c(comms_error_string);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
trace_i2c("VL53L1_WriteMulti: Comms must be one of VL53L1_I2C or VL53L1_SPI\n");
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_ReadMulti(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint16_t index,
|
||||
uint8_t *pdata,
|
||||
uint32_t count)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
uint32_t position = 0;
|
||||
uint32_t data_size = 0;
|
||||
|
||||
char comms_error_string[ERROR_TEXT_LENGTH];
|
||||
|
||||
_LOG_STRING_BUFFER(register_name);
|
||||
_LOG_STRING_BUFFER(value_as_str);
|
||||
|
||||
if(global_comms_type == VL53L1_I2C)
|
||||
{
|
||||
for(position=0; position<count; position+=VL53L1_COMMS_CHUNK_SIZE)
|
||||
{
|
||||
if(count > VL53L1_COMMS_CHUNK_SIZE)
|
||||
{
|
||||
if((position + VL53L1_COMMS_CHUNK_SIZE) > count)
|
||||
{
|
||||
data_size = count - position;
|
||||
}
|
||||
else
|
||||
{
|
||||
data_size = VL53L1_COMMS_CHUNK_SIZE;
|
||||
}
|
||||
}
|
||||
else
|
||||
data_size = count;
|
||||
|
||||
if(status == VL53L1_ERROR_NONE)
|
||||
{
|
||||
if( RANGING_SENSOR_COMMS_Read_CCI(
|
||||
pdev->i2c_slave_address,
|
||||
0,
|
||||
index+position,
|
||||
pdata+position,
|
||||
data_size) != 0 )
|
||||
{
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
}
|
||||
#ifdef VL53L1_LOG_ENABLE
|
||||
if(status == VL53L1_ERROR_NONE)
|
||||
{
|
||||
char* pvalue_as_str;
|
||||
uint32_t i;
|
||||
|
||||
/*lint --e{661} Suppress out of bounds walkthrough warning */
|
||||
/*lint --e{662} Suppress out of bounds walkthrough warning */
|
||||
pvalue_as_str = value_as_str;
|
||||
for(i = 0 ; i < data_size ; i++) {
|
||||
sprintf(pvalue_as_str, "0x%02X", *(pdata+position+i));
|
||||
if (i == 0) {
|
||||
pvalue_as_str = pvalue_as_str + 4;
|
||||
}
|
||||
else {
|
||||
pvalue_as_str = pvalue_as_str + 6;
|
||||
}
|
||||
}
|
||||
|
||||
register_name[0] = 0;
|
||||
VL53L1_get_register_name(
|
||||
index+(uint16_t)position,
|
||||
register_name);
|
||||
|
||||
trace_i2c(
|
||||
/* "ReadAutoIncrement(0x%04X,%3u); // = (%s)\n",
|
||||
index+(uint16_t)position, */
|
||||
"ReadAutoIncrement(%s,%3u); // = (%s)\n",
|
||||
register_name,
|
||||
data_size,
|
||||
value_as_str);
|
||||
}
|
||||
#endif // VL53L1_LOG_ENABLE
|
||||
}
|
||||
|
||||
if(status != VL53L1_ERROR_NONE)
|
||||
{
|
||||
RANGING_SENSOR_COMMS_Get_Error_Text(comms_error_string); /*lint !e534 ignoring return value */
|
||||
trace_i2c("VL53L1_ReadMulti: RANGING_SENSOR_COMMS_Read_CCI() failed\n");
|
||||
trace_i2c(comms_error_string);
|
||||
}
|
||||
}
|
||||
else if(global_comms_type == VL53L1_SPI)
|
||||
{
|
||||
if((CP_STATUS)RANGING_SENSOR_COMMS_Read_SPI_16I(0, 0, index, pdata, count) != CP_STATUS_OK)
|
||||
{
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
|
||||
if(status != VL53L1_ERROR_NONE)
|
||||
{
|
||||
RANGING_SENSOR_COMMS_Get_Error_Text(comms_error_string); /*lint !e534 ignoring return value */
|
||||
trace_i2c("VL53L1_ReadMulti: RANGING_SENSOR_COMMS_Read_SPI_16I() failed\n");
|
||||
trace_i2c(comms_error_string);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
trace_i2c("VL53L1_ReadMulti: Comms must be one of VL53L1_I2C or VL53L1_SPI\n");
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_WrByte(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint16_t index,
|
||||
uint8_t data)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
uint8_t buffer[1];
|
||||
|
||||
// Split 16-bit word into MS and LS uint8_t
|
||||
buffer[0] = (uint8_t)(data);
|
||||
|
||||
status = VL53L1_WriteMulti(pdev, index, buffer, 1);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_WrWord(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint16_t index,
|
||||
uint16_t data)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
uint8_t buffer[2];
|
||||
|
||||
// Split 16-bit word into MS and LS uint8_t
|
||||
buffer[0] = (uint8_t)(data >> 8);
|
||||
buffer[1] = (uint8_t)(data & 0x00FF);
|
||||
|
||||
status = VL53L1_WriteMulti(pdev, index, buffer, VL53L1_BYTES_PER_WORD);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_WrDWord(
|
||||
VL53L1_Dev_t *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, VL53L1_BYTES_PER_DWORD);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_RdByte(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint16_t index,
|
||||
uint8_t *pdata)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
uint8_t buffer[1];
|
||||
|
||||
status = VL53L1_ReadMulti(pdev, index, buffer, 1);
|
||||
|
||||
*pdata = buffer[0];
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_RdWord(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint16_t index,
|
||||
uint16_t *pdata)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
uint8_t buffer[2];
|
||||
|
||||
status = VL53L1_ReadMulti(
|
||||
pdev,
|
||||
index,
|
||||
buffer,
|
||||
VL53L1_BYTES_PER_WORD);
|
||||
|
||||
*pdata = (uint16_t)(((uint16_t)(buffer[0])<<8) + (uint16_t)buffer[1]);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_RdDWord(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint16_t index,
|
||||
uint32_t *pdata)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
uint8_t buffer[4];
|
||||
|
||||
status = VL53L1_ReadMulti(
|
||||
pdev,
|
||||
index,
|
||||
buffer,
|
||||
VL53L1_BYTES_PER_DWORD);
|
||||
|
||||
*pdata = ((uint32_t)buffer[0]<<24) + ((uint32_t)buffer[1]<<16) + ((uint32_t)buffer[2]<<8) + (uint32_t)buffer[3];
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ----------------- HOST TIMING FUNCTIONS -----------------
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_WaitUs(
|
||||
VL53L1_Dev_t *pdev,
|
||||
int32_t wait_us)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
float wait_ms = (float)wait_us/1000.0f; /*lint !e586 float in windows platform*/
|
||||
HANDLE hEvent = CreateEvent(0, TRUE, FALSE, 0);
|
||||
|
||||
SUPPRESS_UNUSED_WARNING(pdev);
|
||||
|
||||
/*
|
||||
* Use windows event handling to perform non-blocking wait.
|
||||
*/
|
||||
WaitForSingleObject(hEvent, (DWORD)(wait_ms + 0.5f)); /*lint !e534 ignoring return value */
|
||||
|
||||
trace_i2c("WaitUs(%6d);\n", wait_us);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_WaitMs(
|
||||
VL53L1_Dev_t *pdev,
|
||||
int32_t wait_ms)
|
||||
{
|
||||
return VL53L1_WaitUs(pdev, wait_ms * 1000);
|
||||
}
|
||||
|
||||
/*
|
||||
* ----------------- DEVICE TIMING FUNCTIONS -----------------
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_GetTimerFrequency(int32_t *ptimer_freq_hz)
|
||||
{
|
||||
*ptimer_freq_hz = 0;
|
||||
|
||||
trace_print(VL53L1_TRACE_LEVEL_INFO, "VL53L1_GetTimerFrequency: Freq : %dHz\n", *ptimer_freq_hz);
|
||||
return VL53L1_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_GetTimerValue(int32_t *ptimer_count)
|
||||
{
|
||||
*ptimer_count = 0;
|
||||
|
||||
trace_print(VL53L1_TRACE_LEVEL_INFO, "VL53L1_GetTimerValue: Freq : %dHz\n", *ptimer_count);
|
||||
return VL53L1_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ----------------- GPIO FUNCTIONS -----------------
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_GpioSetMode(uint8_t pin, uint8_t mode)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
if((CP_STATUS)RANGING_SENSOR_COMMS_GPIO_Set_Mode((RS_GPIO_Pin)pin, (RS_GPIO_Mode)mode) != CP_STATUS_OK)
|
||||
{
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
|
||||
trace_print(VL53L1_TRACE_LEVEL_INFO, "VL53L1_GpioSetMode: Status %d. Pin %d, Mode %d\n", status, pin, mode);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_GpioSetValue(uint8_t pin, uint8_t value)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
if((CP_STATUS)RANGING_SENSOR_COMMS_GPIO_Set_Value((RS_GPIO_Pin)pin, value) != CP_STATUS_OK)
|
||||
{
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
|
||||
trace_print(VL53L1_TRACE_LEVEL_INFO, "VL53L1_GpioSetValue: Status %d. Pin %d, Mode %d\n", status, pin, value);
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_GpioGetValue(uint8_t pin, uint8_t *pvalue)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
DWORD value = 0;
|
||||
|
||||
if((CP_STATUS)RANGING_SENSOR_COMMS_GPIO_Get_Value((RS_GPIO_Pin)pin, &value) != CP_STATUS_OK)
|
||||
{
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pvalue = (uint8_t)value;
|
||||
}
|
||||
|
||||
trace_print(VL53L1_TRACE_LEVEL_INFO, "VL53L1_GpioGetValue: Status %d. Pin %d, Mode %d\n", status, pin, *pvalue);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ----------------- HARDWARE STATE FUNCTIONS -----------------
|
||||
*/
|
||||
|
||||
VL53L1_Error VL53L1_GpioXshutdown(uint8_t value)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
if(status == VL53L1_ERROR_NONE) /*lint !e774 always true */
|
||||
{
|
||||
status = VL53L1_GpioSetMode((uint8_t)GPIO_XSHUTDOWN, (uint8_t)GPIO_OutputPP);
|
||||
}
|
||||
|
||||
if(status == VL53L1_ERROR_NONE)
|
||||
{
|
||||
if(value)
|
||||
{
|
||||
if ((CP_STATUS)RANGING_SENSOR_COMMS_GPIO_Set_Value(GPIO_XSHUTDOWN, (DWORD)Pin_State_High) != CP_STATUS_OK)
|
||||
{
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((CP_STATUS)RANGING_SENSOR_COMMS_GPIO_Set_Value(GPIO_XSHUTDOWN, (DWORD)Pin_State_Low) != CP_STATUS_OK)
|
||||
{
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trace_print(VL53L1_TRACE_LEVEL_INFO, "VL53L1_GpioXShutdown: Status %d. Value %d\n", status, value);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_GpioCommsSelect(uint8_t value)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
if(status == VL53L1_ERROR_NONE) /*lint !e774 always true */
|
||||
{
|
||||
status = VL53L1_GpioSetMode((uint8_t)GPIO_SPI_CHIP_SELECT, (uint8_t)GPIO_OutputPP);
|
||||
}
|
||||
|
||||
if(status == VL53L1_ERROR_NONE)
|
||||
{
|
||||
if(value)
|
||||
{
|
||||
if((CP_STATUS)RANGING_SENSOR_COMMS_GPIO_Set_Value(GPIO_SPI_CHIP_SELECT, (DWORD)Pin_State_High) != CP_STATUS_OK)
|
||||
{
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((CP_STATUS)RANGING_SENSOR_COMMS_GPIO_Set_Value(GPIO_SPI_CHIP_SELECT, (DWORD)Pin_State_Low) != CP_STATUS_OK)
|
||||
{
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trace_print(VL53L1_TRACE_LEVEL_INFO, "VL53L1_GpioCommsSelect: Status %d. Value %d\n", status, value);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_GpioPowerEnable(uint8_t value)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
POWER_BOARD_CMD power_cmd;
|
||||
|
||||
if(status == VL53L1_ERROR_NONE) /*lint !e774 always true */
|
||||
{
|
||||
status = VL53L1_GpioSetMode((uint8_t)GPIO_POWER_ENABLE, (uint8_t)GPIO_OutputPP);
|
||||
}
|
||||
|
||||
if(status == VL53L1_ERROR_NONE)
|
||||
{
|
||||
if(value)
|
||||
{
|
||||
if((CP_STATUS)RANGING_SENSOR_COMMS_GPIO_Set_Value(GPIO_POWER_ENABLE, (DWORD)Pin_State_High) != CP_STATUS_OK)
|
||||
{
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((CP_STATUS)RANGING_SENSOR_COMMS_GPIO_Set_Value(GPIO_POWER_ENABLE, (DWORD)Pin_State_Low) != CP_STATUS_OK)
|
||||
{
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(status == VL53L1_ERROR_NONE && _power_board_in_use == 1 && value) /*lint !e506 !e845 !e774*/
|
||||
{
|
||||
memset(&power_cmd, 0, sizeof(POWER_BOARD_CMD));
|
||||
power_cmd.command = ENABLE_DUT_POWER;
|
||||
|
||||
if((CP_STATUS)RANGING_SENSOR_COMMS_Write_System_I2C(
|
||||
POWER_BOARD_I2C_ADDRESS, sizeof(POWER_BOARD_CMD), (uint8_t*)&power_cmd) != CP_STATUS_OK)
|
||||
{
|
||||
status = VL53L1_ERROR_CONTROL_INTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
trace_print(VL53L1_TRACE_LEVEL_INFO, "VL53L1_GpioPowerEnable: Status %d. Value %d\n", status, value);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_GpioInterruptEnable(void (*function)(void), uint8_t edge_type)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
SUPPRESS_UNUSED_WARNING(function);
|
||||
SUPPRESS_UNUSED_WARNING(edge_type);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_GpioInterruptDisable(void)
|
||||
{
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_GetTickCount(
|
||||
uint32_t *ptick_count_ms)
|
||||
{
|
||||
|
||||
/* Returns current tick count in [ms] */
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
*ptick_count_ms = timeGetTime();
|
||||
|
||||
trace_print(
|
||||
VL53L1_TRACE_LEVEL_DEBUG,
|
||||
"VL53L1_GetTickCount() = %5u ms;\n",
|
||||
*ptick_count_ms);
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
/*
|
||||
* Platform implementation of WaitValueMaskEx V2WReg script command
|
||||
*
|
||||
* WaitValueMaskEx(
|
||||
* duration_ms,
|
||||
* index,
|
||||
* value,
|
||||
* mask,
|
||||
* poll_delay_ms);
|
||||
*/
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
uint32_t start_time_ms = 0;
|
||||
uint32_t current_time_ms = 0;
|
||||
uint8_t byte_value = 0;
|
||||
uint8_t found = 0;
|
||||
#ifdef VL53L1_LOG_ENABLE
|
||||
uint32_t trace_functions = 0;
|
||||
#endif
|
||||
|
||||
_LOG_STRING_BUFFER(register_name);
|
||||
|
||||
SUPPRESS_UNUSED_WARNING(poll_delay_ms);
|
||||
|
||||
#ifdef VL53L1_LOG_ENABLE
|
||||
/* look up register name */
|
||||
VL53L1_get_register_name(
|
||||
index,
|
||||
register_name);
|
||||
|
||||
/* Output to I2C logger for FMT/DFT */
|
||||
trace_i2c("WaitValueMaskEx(%5d, %s, 0x%02X, 0x%02X, %5d);\n",
|
||||
timeout_ms, register_name, value, mask, poll_delay_ms);
|
||||
#endif // VL53L1_LOG_ENABLE
|
||||
|
||||
/* calculate time limit in absolute time */
|
||||
|
||||
VL53L1_GetTickCount(&start_time_ms);
|
||||
pdev->new_data_ready_poll_duration_ms = 0;
|
||||
|
||||
/* remember current trace functions and temporarily disable
|
||||
* function logging
|
||||
*/
|
||||
|
||||
#ifdef VL53L1_LOG_ENABLE
|
||||
trace_functions = _LOG_GET_TRACE_FUNCTIONS();
|
||||
#endif
|
||||
_LOG_SET_TRACE_FUNCTIONS(VL53L1_TRACE_FUNCTION_NONE);
|
||||
|
||||
/* wait until value is found, timeout reached on error occurred */
|
||||
|
||||
while ((status == VL53L1_ERROR_NONE) &&
|
||||
(pdev->new_data_ready_poll_duration_ms < timeout_ms) &&
|
||||
(found == 0))
|
||||
{
|
||||
status = VL53L1_RdByte(
|
||||
pdev,
|
||||
index,
|
||||
&byte_value);
|
||||
|
||||
if ((byte_value & mask) == value)
|
||||
{
|
||||
found = 1;
|
||||
}
|
||||
|
||||
/*if (status == VL53L1_ERROR_NONE &&
|
||||
found == 0 &&
|
||||
poll_delay_ms > 0)
|
||||
status = VL53L1_WaitMs(
|
||||
pdev,
|
||||
poll_delay_ms);
|
||||
*/
|
||||
|
||||
/* Update polling time (Compare difference rather than absolute to
|
||||
negate 32bit wrap around issue) */
|
||||
VL53L1_GetTickCount(¤t_time_ms);
|
||||
pdev->new_data_ready_poll_duration_ms = current_time_ms - start_time_ms;
|
||||
}
|
||||
|
||||
/* Restore function logging */
|
||||
_LOG_SET_TRACE_FUNCTIONS(trace_functions);
|
||||
|
||||
if (found == 0 && status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_ERROR_TIME_OUT;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
/*******************************************************************************
|
||||
Copyright (C) 2016, STMicroelectronics International N.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of STMicroelectronics nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
||||
NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @file vl53l1_platform_init.c
|
||||
* @brief EwokPlus25 comms and GPIO init
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "vl53l1_ll_def.h"
|
||||
#include "vl53l1_platform.h"
|
||||
#include "vl53l1_platform_init.h"
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_platform_init(
|
||||
VL53L1_Dev_t *pdev,
|
||||
uint8_t i2c_slave_address,
|
||||
uint8_t comms_type,
|
||||
uint16_t comms_speed_khz)
|
||||
{
|
||||
/*
|
||||
* Initialise comms, GPIOs (xshutdown, ncs, EVK power regulator enable)
|
||||
* and reset Device
|
||||
*/
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
/* remember comms settings */
|
||||
|
||||
pdev->i2c_slave_address = i2c_slave_address;
|
||||
pdev->comms_type = comms_type;
|
||||
pdev->comms_speed_khz = comms_speed_khz;
|
||||
|
||||
if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
|
||||
status =
|
||||
VL53L1_CommsInitialise(
|
||||
pdev,
|
||||
pdev->comms_type,
|
||||
pdev->comms_speed_khz);
|
||||
|
||||
/* Ensure device is in reset */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_GpioXshutdown(0);
|
||||
|
||||
/* disable the platform regulators */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_GpioPowerEnable(0);
|
||||
|
||||
/* set the NCS pin for I2C mode */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_GpioCommsSelect(0);
|
||||
|
||||
/* 1ms Wait to ensure XSHUTD / NCS are in the right state */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_WaitUs(pdev, 1000);
|
||||
|
||||
/* enable the platform regulators */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_GpioPowerEnable(1);
|
||||
|
||||
/* 1ms Wait for power regs to settle */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_WaitUs(pdev, 1000);
|
||||
|
||||
/* finally, bring the device out of reset */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_GpioXshutdown(1);
|
||||
|
||||
/* Wait 100us for device to exit reset */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_WaitUs(pdev, 100);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
VL53L1_Error VL53L1_platform_terminate(
|
||||
VL53L1_Dev_t *pdev)
|
||||
{
|
||||
/*
|
||||
* Puts the device into reset, disables EVK power regulator
|
||||
* and closes comms
|
||||
*/
|
||||
|
||||
VL53L1_Error status = VL53L1_ERROR_NONE;
|
||||
|
||||
/* put device in reset */
|
||||
if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
|
||||
status = VL53L1_GpioXshutdown(0);
|
||||
|
||||
/* disable the platform regulators */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_GpioPowerEnable(0);
|
||||
|
||||
/* close the comms interfaces */
|
||||
if (status == VL53L1_ERROR_NONE)
|
||||
status = VL53L1_CommsClose(pdev);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* COPYRIGHT (C) STMicroelectronics 2015. All rights reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of
|
||||
* STMicroelectronics ("Confidential Information"). You shall not
|
||||
* disclose such Confidential Information and shall use it only in
|
||||
* accordance with the terms of the license agreement you entered into
|
||||
* with STMicroelectronics
|
||||
*
|
||||
* Programming Golden Rule: Keep it Simple!
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file vl53l1_platform_log.c
|
||||
*
|
||||
* @brief Code function definitions for EwokPlus25 Platform Logging Layer
|
||||
*/
|
||||
|
||||
#include <stdio.h> // sprintf(), vsnprintf(), printf()
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "vl53l1_platform_log.h"
|
||||
#include "vl53l1_platform_user_config.h"
|
||||
|
||||
#ifdef VL53L1_LOG_ENABLE
|
||||
|
||||
char * _trace_filename = NULL;
|
||||
FILE *_tracefile = NULL;
|
||||
|
||||
uint32_t _trace_level = VL53L1_TRACE_LEVEL_WARNING;
|
||||
uint32_t _trace_modules = VL53L1_TRACE_MODULE_NONE;
|
||||
uint32_t _trace_functions = VL53L1_TRACE_FUNCTION_ALL;
|
||||
|
||||
int8_t VL53L1_trace_config(
|
||||
char *filename,
|
||||
uint32_t modules,
|
||||
uint32_t level,
|
||||
uint32_t functions)
|
||||
{
|
||||
int8_t status = 0;
|
||||
|
||||
// // Something in the commented out code below causes ncsim to crash!
|
||||
//
|
||||
// if (((_trace_filename != NULL) && (_trace_filename != filename)) ||strcmp(filename,"")==0)
|
||||
// {
|
||||
// if ( _tracefile != NULL )
|
||||
// {
|
||||
// fclose(_tracefile);
|
||||
// _tracefile = NULL;
|
||||
// }
|
||||
// free(_trace_filename);
|
||||
// _trace_filename = NULL;
|
||||
// }
|
||||
//
|
||||
|
||||
if (((filename != NULL) && (_tracefile == NULL)) && strcmp(filename,""))
|
||||
{
|
||||
_tracefile = fopen(filename, "w+");
|
||||
|
||||
//TODO: Add time and header banner to the log file to indicate we've just opened a new log session
|
||||
|
||||
if ( _tracefile != NULL )
|
||||
{
|
||||
_trace_filename = (char*)malloc((strlen(filename) + 1) * sizeof(char));
|
||||
strcpy(_trace_filename, filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("VL53L1_trace_config(): failed to open log file (%s)\n", filename);
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
_trace_modules = modules;
|
||||
_trace_level = level;
|
||||
_trace_functions = functions;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void VL53L1_trace_print_module_function(uint32_t module, uint32_t level, uint32_t function, const char *format, ...)
|
||||
{
|
||||
if ( ((level <=_trace_level) && ((module & _trace_modules) > 0))
|
||||
|| ((function & _trace_functions) > 0) )
|
||||
{
|
||||
va_list arg_list;
|
||||
char message[VL53L1_MAX_STRING_LENGTH];
|
||||
|
||||
va_start(arg_list, format);
|
||||
vsnprintf(message, VL53L1_MAX_STRING_LENGTH-1, format, arg_list); /*lint !e534 ignore return*/
|
||||
va_end(arg_list);
|
||||
|
||||
if (_tracefile != NULL)
|
||||
{
|
||||
fprintf(_tracefile, message); /*lint !e592 ignore format specifier*/
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(message); /*lint !e592 ignore format specifier*/
|
||||
}
|
||||
|
||||
// if (_tracefile != NULL)
|
||||
// fprintf(_tracefile, message);
|
||||
// else
|
||||
// printf(message);
|
||||
} /*lint !e438 ignore issues with arg_list*/
|
||||
}
|
||||
|
||||
|
||||
uint32_t VL53L1_get_trace_functions(void)
|
||||
{
|
||||
return _trace_functions;
|
||||
}
|
||||
|
||||
|
||||
void VL53L1_set_trace_functions(uint32_t function)
|
||||
{
|
||||
_trace_functions = function;
|
||||
}
|
||||
|
||||
|
||||
uint32_t VL53L1_clock(void)
|
||||
{
|
||||
/* Returns current tick count in [ms] */
|
||||
uint32_t tick_count_ms = (uint32_t)clock();
|
||||
return tick_count_ms;
|
||||
}
|
||||
#endif // VL53L1_LOG_ENABLE
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,8 @@
|
|||
VL53L1X_API_xxx zip file content:
|
||||
- "core" directory contains the driver files
|
||||
- "platform" directory contains the platform files.
|
||||
Note: The user has to implement the I2C functions prototyped in the vl53l1_platform.c file accordingly.
|
||||
For the STM32 target the user may download the X-CUBE-53L1A1 code on ST.COM and inspire on the implementation of the I2C functions developed
|
||||
for stm32 ODE in the vl53l1_platform.c file.
|
||||
- VL53L1X API user manual (UM2356)
|
||||
- Release Notes
|
Loading…
Reference in New Issue