drivers/vl53l5cx: Update driver and platform.

This commit is contained in:
iabdalkader 2024-10-01 16:16:38 +02:00
parent be35ac86d2
commit 4fb0acdf9b
11 changed files with 5578 additions and 6074 deletions

View File

@ -1,217 +1,69 @@
/*******************************************************************************
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
*
* This file is part of the VL53L5CX Ultra Lite Driver 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, the VL53L5CX Ultra Lite Driver 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:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*******************************************************************************/
#ifndef _PLATFORM_H_
#define _PLATFORM_H_
#pragma once
/*
* This file is part of the OpenMV project.
*
* Copyright (c) 2013-2021 Ibrahim Abdelkader <iabdalkader@openmv.io>
* Copyright (c) 2013-2021 Kwabena W. Agyeman <kwagyeman@openmv.io>
*
* This work is licensed under the MIT license, see the file LICENSE for details.
*
* VL53L5CX platform implementation.
*/
#ifndef __VL53L5CX_PLATFORM_H__
#define __VL53L5CX_PLATFORM_H__
#include <stdint.h>
#include <string.h>
#include "omv_i2c.h"
/**
* @brief Structure VL53L5CX_Platform needs to be filled by the customer,
* depending on his platform. At least, it contains the VL53L5CX I2C address.
* Some additional fields can be added, as descriptors, or platform
* dependencies. Anything added into this structure is visible into the platform
* layer.
*/
typedef struct
{
/* To be filled with customer's platform. At least an I2C address/descriptor
* needs to be added */
/* Example for most standard platform : I2C address of sensor */
omv_i2c_t *bus;
uint16_t address;
} VL53L5CX_Platform;
/*
* @brief The macro below is used to define the number of target per zone sent
* through I2C. This value can be changed by user, in order to tune I2C
* transaction, and also the total memory size (a lower number of target per
* zone means a lower RAM). The value must be between 1 and 4.
*/
#define VL53L5CX_NB_TARGET_PER_ZONE 1U
/*
* @brief The macro below can be used to avoid data conversion into the driver.
* By default there is a conversion between firmware and user data. Using this macro
* allows to use the firmware format instead of user format. The firmware format allows
* an increased precision.
*/
// #define VL53L5CX_USE_RAW_FORMAT
/*
* @brief All macro below are used to configure the sensor output. User can
* define some macros if he wants to disable selected output, in order to reduce
* I2C access.
*/
#include <omv_i2c.h>
#include "py/mphal.h"
// Driver configuration
#define VL53L5CX_NB_TARGET_PER_ZONE (1U)
#define VL53L5CX_DISABLE_AMBIENT_PER_SPAD
#define VL53L5CX_DISABLE_NB_SPADS_ENABLED
#define VL53L5CX_DISABLE_NB_TARGET_DETECTED
#define VL53L5CX_DISABLE_SIGNAL_PER_SPAD
#define VL53L5CX_DISABLE_RANGE_SIGMA_MM
//#define VL53L5CX_DISABLE_DISTANCE_MM
#define VL53L5CX_DISABLE_REFLECTANCE_PERCENT
#define VL53L5CX_DISABLE_TARGET_STATUS
#define VL53L5CX_DISABLE_MOTION_INDICATOR
/**
* @param (VL53L5CX_Platform*) p_platform : Pointer of VL53L5CX platform
* structure.
* @param (uint16_t) Address : I2C location of value to read.
* @param (uint8_t) *p_values : Pointer of value to read.
* @return (uint8_t) status : 0 if OK
*/
// Platform struct.
typedef struct {
omv_i2c_t *bus;
uint16_t address;
} VL53L5CX_Platform;
uint8_t RdByte(
VL53L5CX_Platform *p_platform,
uint16_t RegisterAdress,
uint8_t *p_value);
void vl53l5cx_reset(VL53L5CX_Platform *platform);
void vl53l5cx_swap(uint8_t *buf, uint16_t size);
uint8_t vl53l5cx_read(VL53L5CX_Platform *platform, uint16_t addr, uint8_t *buf, uint32_t size);
uint8_t vl53l5cx_write(VL53L5CX_Platform *platform, uint16_t addr, uint8_t *buf, uint32_t size);
/**
* @brief Mandatory function used to write one single byte.
* @param (VL53L5CX_Platform*) p_platform : Pointer of VL53L5CX platform
* structure.
* @param (uint16_t) Address : I2C location of value to read.
* @param (uint8_t) value : Pointer of value to write.
* @return (uint8_t) status : 0 if OK
*/
// Platform API.
#define VL53L5CX_CHECK_STATUS(status) ({ \
if (status != VL53L5CX_STATUS_OK) { \
return -1; \
} \
status; \
})
#define VL53L5CX_RdByte(platform, addr, buf) ({ \
uint8_t status = vl53l5cx_read(platform, addr, buf, 1); \
VL53L5CX_CHECK_STATUS(status); \
})
uint8_t WrByte(
VL53L5CX_Platform *p_platform,
uint16_t RegisterAdress,
uint8_t value);
#define VL53L5CX_WrByte(platform, addr, buf) ({ \
uint8_t status = vl53l5cx_write(platform, addr, (uint8_t [1]){ buf }, 1); \
VL53L5CX_CHECK_STATUS(status); \
})
/**
* @brief Mandatory function used to read multiples bytes.
* @param (VL53L5CX_Platform*) p_platform : Pointer of VL53L5CX platform
* structure.
* @param (uint16_t) Address : I2C location of values to read.
* @param (uint8_t) *p_values : Buffer of bytes to read.
* @param (uint32_t) size : Size of *p_values buffer.
* @return (uint8_t) status : 0 if OK
*/
#define VL53L5CX_RdMulti(platform, addr, buf, size) ({ \
uint8_t status = vl53l5cx_read(platform, addr, buf, size); \
VL53L5CX_CHECK_STATUS(status); \
})
uint8_t RdMulti(
VL53L5CX_Platform *p_platform,
uint16_t RegisterAdress,
uint8_t *p_values,
uint32_t size);
/**
* @brief Mandatory function used to write multiples bytes.
* @param (VL53L5CX_Platform*) p_platform : Pointer of VL53L5CX platform
* structure.
* @param (uint16_t) Address : I2C location of values to write.
* @param (uint8_t) *p_values : Buffer of bytes to write.
* @param (uint32_t) size : Size of *p_values buffer.
* @return (uint8_t) status : 0 if OK
*/
uint8_t WrMulti(
VL53L5CX_Platform *p_platform,
uint16_t RegisterAdress,
uint8_t *p_values,
uint32_t size);
/**
* @brief Optional function, only used to perform an hardware reset of the
* sensor. This function is not used in the API, but it can be used by the host.
* This function is not mandatory to fill if user don't want to reset the
* sensor.
* @param (VL53L5CX_Platform*) p_platform : Pointer of VL53L5CX platform
* structure.
* @return (uint8_t) status : 0 if OK
*/
uint8_t Reset_Sensor(
VL53L5CX_Platform *p_platform);
/**
* @brief Mandatory function, used to swap a buffer. The buffer size is always a
* multiple of 4 (4, 8, 12, 16, ...).
* @param (uint8_t*) buffer : Buffer to swap, generally uint32_t
* @param (uint16_t) size : Buffer size to swap
*/
void SwapBuffer(
uint8_t *buffer,
uint16_t size);
/**
* @brief Mandatory function, used to wait during an amount of time. It must be
* filled as it's used into the API.
* @param (VL53L5CX_Platform*) p_platform : Pointer of VL53L5CX platform
* structure.
* @param (uint32_t) TimeMs : Time to wait in ms.
* @return (uint8_t) status : 0 if wait is finished.
*/
uint8_t WaitMs(
VL53L5CX_Platform *p_platform,
uint32_t TimeMs);
#endif // _PLATFORM_H_
#define VL53L5CX_WrMulti(platform, addr, buf, size) ({ \
uint8_t status = vl53l5cx_write(platform, addr, buf, size); \
VL53L5CX_CHECK_STATUS(status); \
})
#define VL53L5CX_WaitMs(platform, ms) ({ mp_hal_delay_ms(ms); 0; })
#define VL53L5CX_SwapBuffer(buf, size) vl53l5cx_swap(buf, size)
#endif // __VL53L5CX_PLATFORM_H__

View File

@ -1,64 +1,14 @@
/*******************************************************************************
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
*
* This file is part of the VL53L5CX Ultra Lite Driver 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, the VL53L5CX Ultra Lite Driver 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:
*
* 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.
*
*
*******************************************************************************/
/**
*
* Copyright (c) 2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
#ifndef VL53L5CX_API_H_
#define VL53L5CX_API_H_
@ -75,7 +25,7 @@
* @brief Current driver version.
*/
#define VL53L5CX_API_REVISION "VL53L5CX_1.3.0"
#define VL53L5CX_API_REVISION "VL53L5CX_2.0.0"
/**
* @brief Default I2C address of VL53L5CX sensor. Can be changed using function
@ -130,6 +80,9 @@
#define VL53L5CX_STATUS_OK ((uint8_t) 0U)
#define VL53L5CX_STATUS_TIMEOUT_ERROR ((uint8_t) 1U)
#define VL53L5CX_STATUS_CORRUPTED_FRAME ((uint8_t) 2U)
#define VL53L5CX_STATUS_CRC_CSUM_FAILED ((uint8_t) 3U)
#define VL53L5CX_STATUS_XTALK_FAILED ((uint8_t) 4U)
#define VL53L5CX_MCU_ERROR ((uint8_t) 66U)
#define VL53L5CX_STATUS_INVALID_PARAM ((uint8_t) 127U)
#define VL53L5CX_STATUS_ERROR ((uint8_t) 255U)
@ -140,36 +93,36 @@
#if VL53L5CX_NB_TARGET_PER_ZONE == 1
#define VL53L5CX_START_BH ((uint32_t)0x0000000DU)
#define VL53L5CX_START_BH ((uint32_t)0x0000000DU)
#define VL53L5CX_METADATA_BH ((uint32_t)0x54B400C0U)
#define VL53L5CX_COMMONDATA_BH ((uint32_t)0x54C00040U)
#define VL53L5CX_AMBIENT_RATE_BH ((uint32_t)0x54D00104U)
#define VL53L5CX_SPAD_COUNT_BH ((uint32_t)0x55D00404U)
#define VL53L5CX_NB_TARGET_DETECTED_BH ((uint32_t)0xCF7C0401U)
#define VL53L5CX_SIGNAL_RATE_BH ((uint32_t)0xCFBC0404U)
#define VL53L5CX_RANGE_SIGMA_MM_BH ((uint32_t)0xD2BC0402U)
#define VL53L5CX_DISTANCE_BH ((uint32_t)0xD33C0402U)
#define VL53L5CX_REFLECTANCE_BH ((uint32_t)0xD43C0401U)
#define VL53L5CX_TARGET_STATUS_BH ((uint32_t)0xD47C0401U)
#define VL53L5CX_MOTION_DETECT_BH ((uint32_t)0xCC5008C0U)
#define VL53L5CX_NB_TARGET_DETECTED_BH ((uint32_t)0xDB840401U)
#define VL53L5CX_SIGNAL_RATE_BH ((uint32_t)0xDBC40404U)
#define VL53L5CX_RANGE_SIGMA_MM_BH ((uint32_t)0xDEC40402U)
#define VL53L5CX_DISTANCE_BH ((uint32_t)0xDF440402U)
#define VL53L5CX_REFLECTANCE_BH ((uint32_t)0xE0440401U)
#define VL53L5CX_TARGET_STATUS_BH ((uint32_t)0xE0840401U)
#define VL53L5CX_MOTION_DETECT_BH ((uint32_t)0xD85808C0U)
#define VL53L5CX_METADATA_IDX ((uint16_t)0x54B4U)
#define VL53L5CX_SPAD_COUNT_IDX ((uint16_t)0x55D0U)
#define VL53L5CX_AMBIENT_RATE_IDX ((uint16_t)0x54D0U)
#define VL53L5CX_NB_TARGET_DETECTED_IDX ((uint16_t)0xCF7CU)
#define VL53L5CX_SIGNAL_RATE_IDX ((uint16_t)0xCFBCU)
#define VL53L5CX_RANGE_SIGMA_MM_IDX ((uint16_t)0xD2BCU)
#define VL53L5CX_DISTANCE_IDX ((uint16_t)0xD33CU)
#define VL53L5CX_REFLECTANCE_EST_PC_IDX ((uint16_t)0xD43CU)
#define VL53L5CX_TARGET_STATUS_IDX ((uint16_t)0xD47CU)
#define VL53L5CX_MOTION_DETEC_IDX ((uint16_t)0xCC50U)
#define VL53L5CX_NB_TARGET_DETECTED_IDX ((uint16_t)0xDB84U)
#define VL53L5CX_SIGNAL_RATE_IDX ((uint16_t)0xDBC4U)
#define VL53L5CX_RANGE_SIGMA_MM_IDX ((uint16_t)0xDEC4U)
#define VL53L5CX_DISTANCE_IDX ((uint16_t)0xDF44U)
#define VL53L5CX_REFLECTANCE_EST_PC_IDX ((uint16_t)0xE044U)
#define VL53L5CX_TARGET_STATUS_IDX ((uint16_t)0xE084U)
#define VL53L5CX_MOTION_DETEC_IDX ((uint16_t)0xD858U)
#else
#define VL53L5CX_START_BH ((uint32_t)0x0000000DU)
#define VL53L5CX_START_BH ((uint32_t)0x0000000DU)
#define VL53L5CX_METADATA_BH ((uint32_t)0x54B400C0U)
#define VL53L5CX_COMMONDATA_BH ((uint32_t)0x54C00040U)
#define VL53L5CX_AMBIENT_RATE_BH ((uint32_t)0x54D00104U)
#define VL53L5CX_NB_TARGET_DETECTED_BH ((uint32_t)0x57D00401U)
#define VL53L5CX_NB_TARGET_DETECTED_BH ((uint32_t)0x57D00401U)
#define VL53L5CX_SPAD_COUNT_BH ((uint32_t)0x55D00404U)
#define VL53L5CX_SIGNAL_RATE_BH ((uint32_t)0x58900404U)
#define VL53L5CX_RANGE_SIGMA_MM_BH ((uint32_t)0x64900402U)
@ -181,11 +134,11 @@
#define VL53L5CX_METADATA_IDX ((uint16_t)0x54B4U)
#define VL53L5CX_SPAD_COUNT_IDX ((uint16_t)0x55D0U)
#define VL53L5CX_AMBIENT_RATE_IDX ((uint16_t)0x54D0U)
#define VL53L5CX_NB_TARGET_DETECTED_IDX ((uint16_t)0x57D0U)
#define VL53L5CX_NB_TARGET_DETECTED_IDX ((uint16_t)0x57D0U)
#define VL53L5CX_SIGNAL_RATE_IDX ((uint16_t)0x5890U)
#define VL53L5CX_RANGE_SIGMA_MM_IDX ((uint16_t)0x6490U)
#define VL53L5CX_DISTANCE_IDX ((uint16_t)0x6690U)
#define VL53L5CX_REFLECTANCE_EST_PC_IDX ((uint16_t)0x6A90U)
#define VL53L5CX_REFLECTANCE_EST_PC_IDX ((uint16_t)0x6A90U)
#define VL53L5CX_TARGET_STATUS_IDX ((uint16_t)0x6B90U)
#define VL53L5CX_MOTION_DETEC_IDX ((uint16_t)0xCC50U)
#endif
@ -206,18 +159,23 @@
#define VL53L5CX_DCI_FW_NB_TARGET ((uint16_t)0x5478)
#define VL53L5CX_DCI_RANGING_MODE ((uint16_t)0xAD30U)
#define VL53L5CX_DCI_DSS_CONFIG ((uint16_t)0xAD38U)
#define VL53L5CX_DCI_VHV_CONFIG ((uint16_t)0xAD60U)
#define VL53L5CX_DCI_TARGET_ORDER ((uint16_t)0xAE64U)
#define VL53L5CX_DCI_SHARPENER ((uint16_t)0xAED8U)
#define VL53L5CX_DCI_MOTION_DETECTOR_CFG ((uint16_t)0xBFACU)
#define VL53L5CX_DCI_SINGLE_RANGE ((uint16_t)0xCD5CU)
#define VL53L5CX_DCI_OUTPUT_CONFIG ((uint16_t)0xCD60U)
#define VL53L5CX_DCI_OUTPUT_ENABLES ((uint16_t)0xCD68U)
#define VL53L5CX_DCI_OUTPUT_LIST ((uint16_t)0xCD78U)
#define VL53L5CX_DCI_PIPE_CONTROL ((uint16_t)0xCF78U)
#define VL53L5CX_DCI_INTERNAL_CP ((uint16_t)0xB39CU)
#define VL53L5CX_DCI_SYNC_PIN ((uint16_t)0xB5F0U)
#define VL53L5CX_DCI_MOTION_DETECTOR_CFG ((uint16_t)0xBFACU)
#define VL53L5CX_DCI_SINGLE_RANGE ((uint16_t)0xD964U)
#define VL53L5CX_DCI_OUTPUT_CONFIG ((uint16_t)0xD968U)
#define VL53L5CX_DCI_OUTPUT_ENABLES ((uint16_t)0xD970U)
#define VL53L5CX_DCI_OUTPUT_LIST ((uint16_t)0xD980U)
#define VL53L5CX_DCI_PIPE_CONTROL ((uint16_t)0xDB80U)
#define VL53L5CX_GLARE_FILTER ((uint16_t)0xE108U)
#define VL53L5CX_UI_CMD_STATUS ((uint16_t)0x2C00U)
#define VL53L5CX_UI_CMD_START ((uint16_t)0x2C04U)
#define VL53L5CX_UI_CMD_END ((uint16_t)0x2FFFU)
#define VL53L5CX_UI_CMD_END ((uint16_t)0x2FFFU)
/**
* @brief Inner values for API. Max buffer size depends of the selected output.
@ -280,13 +238,13 @@
/**
* @brief Macro VL53L5CX_MAX_RESULTS_SIZE indicates the maximum size used by
* output through I2C. Value 40 corresponds to headers + meta-data + common-data
* and 8 corresponds to the footer.
* and 20 corresponds to the footer.
*/
#define VL53L5CX_MAX_RESULTS_SIZE ( 40U \
+ L5CX_AMB_SIZE + L5CX_SPAD_SIZE + L5CX_NTAR_SIZE + L5CX_SPS_SIZE \
+ L5CX_SIGR_SIZE + L5CX_DIST_SIZE + L5CX_RFLEST_SIZE + L5CX_STA_SIZE \
+ L5CX_MOT_SIZE + 8U)
+ L5CX_MOT_SIZE + 20U)
/**
* @brief Macro VL53L5CX_TEMPORARY_BUFFER_SIZE can be used to know the size of
@ -324,6 +282,8 @@ typedef struct
uint8_t xtalk_data[VL53L5CX_XTALK_BUFFER_SIZE];
/* Temporary buffer used for internal driver processing */
uint8_t temp_buffer[VL53L5CX_TEMPORARY_BUFFER_SIZE];
/* Auto-stop flag for stopping the sensor */
uint8_t is_auto_stop_enabled;
} VL53L5CX_Configuration;
@ -674,6 +634,49 @@ uint8_t vl53l5cx_set_ranging_mode(
VL53L5CX_Configuration *p_dev,
uint8_t ranging_mode);
/**
* @brief This function is used to disable the VCSEL charge pump
* This optimizes the power consumption of the device
* To be used only if AVDD = 3.3V
* @param (VL53L5CX_Configuration) *p_dev : VL53L5CX configuration structure.
*/
uint8_t vl53l5cx_enable_internal_cp(
VL53L5CX_Configuration *p_dev);
/**
* @brief This function is used to disable the VCSEL charge pump
* This optimizes the power consumption of the device
* To be used only if AVDD = 3.3V
* @param (VL53L5CX_Configuration) *p_dev : VL53L5CX configuration structure.
*/
uint8_t vl53l5cx_disable_internal_cp(
VL53L5CX_Configuration *p_dev);
/**
* @brief This function is used to get the number of frames between 2 temperature
* compensation.
* @param (VL53L5CX_Configuration) *p_dev : VL53L5CX configuration structure.
* @param (uint32_t) *p_repeat_count : Number of frames before next temperature
* compensation. Set to 0 to disable the feature (default configuration).
*/
uint8_t vl53l5cx_get_VHV_repeat_count(
VL53L5CX_Configuration *p_dev,
uint32_t *p_repeat_count);
/**
* @brief This function is used to set a periodic temperature compensation. By
* setting a repeat count different to 0 the firmware automatically runs a
* temperature calibration every N frames.
* default the repeat count is set to 0
* @param (VL53L5CX_Configuration) *p_dev : VL53L5CX configuration structure.
* @param (uint32_t) repeat_count : Number of frames between temperature
* compensation. Set to 0 to disable the feature (default configuration).
*/
uint8_t vl53l5cx_set_VHV_repeat_count(
VL53L5CX_Configuration *p_dev,
uint32_t repeat_count);
/**
* @brief This function can be used to read 'extra data' from DCI. Using a known
* index, the function fills the casted structure passed in argument.

File diff suppressed because it is too large Load Diff

View File

@ -1,64 +1,14 @@
/*******************************************************************************
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
*
* This file is part of the VL53L5CX Ultra Lite Driver 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, the VL53L5CX Ultra Lite Driver 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:
*
* 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.
*
*
*******************************************************************************/
/**
*
* Copyright (c) 2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
#ifndef VL53L5CX_PLUGIN_DETECTION_THRESHOLDS_H_
#define VL53L5CX_PLUGIN_DETECTION_THRESHOLDS_H_
@ -77,9 +27,9 @@
*/
#define VL53L5CX_DCI_DET_THRESH_CONFIG ((uint16_t)0x5488U)
#define VL53L5CX_DCI_DET_THRESH_GLOBAL_CONFIG ((uint16_t)0xB6E0U)
#define VL53L5CX_DCI_DET_THRESH_GLOBAL_CONFIG ((uint16_t)0xB6E0U)
#define VL53L5CX_DCI_DET_THRESH_START ((uint16_t)0xB6E8U)
#define VL53L5CX_DCI_DET_THRESH_VALID_STATUS ((uint16_t)0xB9F0U)
#define VL53L5CX_DCI_DET_THRESH_VALID_STATUS ((uint16_t)0xB9F0U)
/**
* @brief Macro VL53L5CX_LAST_THRESHOLD is used to indicate the end of checkers

View File

@ -1,64 +1,14 @@
/*******************************************************************************
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
*
* This file is part of the VL53L5CX Ultra Lite Driver 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, the VL53L5CX Ultra Lite Driver 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:
*
* 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.
*
*
*******************************************************************************/
/**
*
* Copyright (c) 2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
#ifndef VL53L5CX_PLUGIN_MOTION_INDICATOR_H_
#define VL53L5CX_PLUGIN_MOTION_INDICATOR_H_

View File

@ -1,64 +1,14 @@
/*******************************************************************************
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
*
* This file is part of the VL53L5CX Ultra Lite Driver 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, the VL53L5CX Ultra Lite Driver 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:
*
* 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.
*
*
*******************************************************************************/
/**
*
* Copyright (c) 2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
#ifndef VL53L5CX_PLUGIN_XTALK_H_
#define VL53L5CX_PLUGIN_XTALK_H_

View File

@ -14,102 +14,47 @@
#include "py/mphal.h"
#include "omv_i2c.h"
#include "platform.h"
#include "omv_gpio.h"
#include "vl53l5cx_api.h"
uint8_t RdByte(VL53L5CX_Platform *platform, uint16_t regaddr, uint8_t *data)
{
regaddr = __REVSH(regaddr);
void vl53l5cx_reset(VL53L5CX_Platform *platform) {
omv_gpio_config(OMV_TOF_RESET_PIN, OMV_GPIO_MODE_OUTPUT, OMV_GPIO_PULL_NONE, OMV_GPIO_SPEED_LOW, -1);
omv_gpio_write(OMV_TOF_RESET_PIN, 1);
mp_hal_delay_ms(10);
omv_gpio_write(OMV_TOF_RESET_PIN, 0);
mp_hal_delay_ms(10);
}
if (omv_i2c_write_bytes(platform->bus, platform->address, (uint8_t *) &regaddr, 2, OMV_I2C_XFER_NO_STOP) != 0) {
return -1;
void vl53l5cx_swap(uint8_t *buf, uint16_t size) {
for (size_t i=0; i<size; i++) {
((uint32_t *) buf)[i] = __REV(((uint32_t *) buf)[i]);
}
}
uint8_t vl53l5cx_read(VL53L5CX_Platform *platform, uint16_t addr, uint8_t *buf, uint32_t size) {
addr = __REVSH(addr);
if (omv_i2c_write_bytes(platform->bus, platform->address, (uint8_t *) &addr, 2, OMV_I2C_XFER_NO_STOP) != 0) {
return VL53L5CX_STATUS_ERROR;
}
if (omv_i2c_read_bytes(platform->bus, platform->address, data, 1, OMV_I2C_XFER_NO_FLAGS) != 0) {
return -1;
if (omv_i2c_read_bytes(platform->bus, platform->address, buf, size, OMV_I2C_XFER_NO_FLAGS) != 0) {
return VL53L5CX_STATUS_ERROR;
}
return 0;
}
uint8_t WrByte(VL53L5CX_Platform *platform, uint16_t regaddr, uint8_t data)
{
regaddr = __REVSH(regaddr);
uint8_t vl53l5cx_write(VL53L5CX_Platform *platform, uint16_t addr, uint8_t *buf, uint32_t size) {
addr = __REVSH(addr);
if (omv_i2c_write_bytes(platform->bus, platform->address, (uint8_t*) &regaddr, 2, OMV_I2C_XFER_SUSPEND) != 0) {
return -1;
if (omv_i2c_write_bytes(platform->bus, platform->address, (uint8_t*) &addr, 2, OMV_I2C_XFER_SUSPEND) != 0) {
return VL53L5CX_STATUS_ERROR;
}
if (omv_i2c_write_bytes(platform->bus, platform->address, &data, 1, OMV_I2C_XFER_NO_FLAGS) != 0) {
return -1;
if (omv_i2c_write_bytes(platform->bus, platform->address, buf, size, OMV_I2C_XFER_NO_FLAGS) != 0) {
return VL53L5CX_STATUS_ERROR;
}
return 0;
}
uint8_t RdMulti(VL53L5CX_Platform *platform, uint16_t regaddr, uint8_t *data, uint32_t size)
{
regaddr = __REVSH(regaddr);
if (omv_i2c_write_bytes(platform->bus, platform->address, (uint8_t *) &regaddr, 2, OMV_I2C_XFER_NO_STOP) != 0) {
return -1;
}
if (omv_i2c_read_bytes(platform->bus, platform->address, data, size, OMV_I2C_XFER_NO_FLAGS) != 0) {
return -1;
}
return 0;
}
uint8_t WrMulti(VL53L5CX_Platform *platform, uint16_t regaddr, uint8_t *data, uint32_t size)
{
regaddr = __REVSH(regaddr);
if (omv_i2c_write_bytes(platform->bus, platform->address, (uint8_t*) &regaddr, 2, OMV_I2C_XFER_SUSPEND) != 0) {
return -1;
}
if (omv_i2c_write_bytes(platform->bus, platform->address, data, size, OMV_I2C_XFER_NO_FLAGS) != 0) {
return -1;
}
return 0;
}
uint8_t Reset_Sensor( VL53L5CX_Platform *platform)
{
uint8_t status = 0;
/* (Optional) Need to be implemented by customer. This function returns 0 if OK */
/* Set pin LPN to LOW */
/* Set pin AVDD to LOW */
/* Set pin VDDIO to LOW */
WaitMs(platform, 100);
/* Set pin LPN of to HIGH */
/* Set pin AVDD of to HIGH */
/* Set pin VDDIO of to HIGH */
WaitMs(platform, 100);
return status;
}
void SwapBuffer(uint8_t *buffer, uint16_t size)
{
uint32_t i, tmp;
/* Example of possible implementation using <string.h> */
for(i = 0; i < size; i = i + 4) {
tmp = (
buffer[i]<<24)
|(buffer[i+1]<<16)
|(buffer[i+2]<<8)
|(buffer[i+3]);
memcpy(&(buffer[i]), &tmp, 4);
}
}
uint8_t WaitMs(VL53L5CX_Platform *platform, uint32_t ms)
{
mp_hal_delay_ms(ms);
return 0;
}
#endif // #if (OMV_TOF_VL53L5CX_ENABLE == 1)

View File

@ -1,64 +1,14 @@
/*******************************************************************************
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
*
* This file is part of the VL53L5CX Ultra Lite Driver 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, the VL53L5CX Ultra Lite Driver 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:
*
* 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.
*
*
*******************************************************************************/
/**
*
* Copyright (c) 2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
#include <stdlib.h>
#include <string.h>
@ -82,17 +32,19 @@ static uint8_t _vl53l5cx_poll_for_answer(
uint8_t timeout = 0;
do {
status |= RdMulti(&(p_dev->platform), address,
status |= VL53L5CX_RdMulti(&(p_dev->platform), address,
p_dev->temp_buffer, size);
status |= WaitMs(&(p_dev->platform), 10);
status |= VL53L5CX_WaitMs(&(p_dev->platform), 10);
if(timeout >= (uint8_t)200) /* 2s timeout */
{
status |= (uint8_t)VL53L5CX_STATUS_TIMEOUT_ERROR;
break;
}else if((size >= (uint8_t)4)
&& (p_dev->temp_buffer[2] >= (uint8_t)0x7f))
{
status |= VL53L5CX_MCU_ERROR;
break;
}
else
{
@ -114,13 +66,13 @@ static uint8_t _vl53l5cx_poll_for_mcu_boot(
uint16_t timeout = 0;
do {
status |= RdByte(&(p_dev->platform), 0x06, &go2_status0);
status |= VL53L5CX_RdByte(&(p_dev->platform), 0x06, &go2_status0);
if((go2_status0 & (uint8_t)0x80) != (uint8_t)0){
status |= RdByte(&(p_dev->platform), 0x07, &go2_status1);
status |= VL53L5CX_RdByte(&(p_dev->platform), 0x07, &go2_status1);
status |= go2_status1;
break;
}
(void)WaitMs(&(p_dev->platform), 1);
(void)VL53L5CX_WaitMs(&(p_dev->platform), 1);
timeout++;
if((go2_status0 & (uint8_t)0x1) != (uint8_t)0){
@ -155,7 +107,7 @@ static uint8_t _vl53l5cx_send_offset_data(
/* Data extrapolation is required for 4X4 offset */
if(resolution == (uint8_t)VL53L5CX_RESOLUTION_4X4){
(void)memcpy(&(p_dev->temp_buffer[0x10]), dss_4x4, sizeof(dss_4x4));
SwapBuffer(p_dev->temp_buffer, VL53L5CX_OFFSET_BUFFER_SIZE);
VL53L5CX_SwapBuffer(p_dev->temp_buffer, VL53L5CX_OFFSET_BUFFER_SIZE);
(void)memcpy(signal_grid,&(p_dev->temp_buffer[0x3C]),
sizeof(signal_grid));
(void)memcpy(range_grid,&(p_dev->temp_buffer[0x140]),
@ -185,7 +137,7 @@ static uint8_t _vl53l5cx_send_offset_data(
signal_grid, sizeof(signal_grid));
(void)memcpy(&(p_dev->temp_buffer[0x140]),
range_grid, sizeof(range_grid));
SwapBuffer(p_dev->temp_buffer, VL53L5CX_OFFSET_BUFFER_SIZE);
VL53L5CX_SwapBuffer(p_dev->temp_buffer, VL53L5CX_OFFSET_BUFFER_SIZE);
}
for(k = 0; k < (VL53L5CX_OFFSET_BUFFER_SIZE - (uint16_t)4); k++)
@ -194,7 +146,7 @@ static uint8_t _vl53l5cx_send_offset_data(
}
(void)memcpy(&(p_dev->temp_buffer[0x1E0]), footer, 8);
status |= WrMulti(&(p_dev->platform), 0x2e18, p_dev->temp_buffer,
status |= VL53L5CX_WrMulti(&(p_dev->platform), 0x2e18, p_dev->temp_buffer,
VL53L5CX_OFFSET_BUFFER_SIZE);
status |=_vl53l5cx_poll_for_answer(p_dev, 4, 1,
VL53L5CX_UI_CMD_STATUS, 0xff, 0x03);
@ -229,7 +181,7 @@ static uint8_t _vl53l5cx_send_xtalk_data(
(void)memcpy(&(p_dev->temp_buffer[0x020]),
dss_4x4, sizeof(dss_4x4));
SwapBuffer(p_dev->temp_buffer, VL53L5CX_XTALK_BUFFER_SIZE);
VL53L5CX_SwapBuffer(p_dev->temp_buffer, VL53L5CX_XTALK_BUFFER_SIZE);
(void)memcpy(signal_grid, &(p_dev->temp_buffer[0x34]),
sizeof(signal_grid));
@ -247,14 +199,14 @@ static uint8_t _vl53l5cx_send_xtalk_data(
(void)memset(&signal_grid[0x10], 0, (uint32_t)192);
(void)memcpy(&(p_dev->temp_buffer[0x34]),
signal_grid, sizeof(signal_grid));
SwapBuffer(p_dev->temp_buffer, VL53L5CX_XTALK_BUFFER_SIZE);
VL53L5CX_SwapBuffer(p_dev->temp_buffer, VL53L5CX_XTALK_BUFFER_SIZE);
(void)memcpy(&(p_dev->temp_buffer[0x134]),
profile_4x4, sizeof(profile_4x4));
(void)memset(&(p_dev->temp_buffer[0x078]),0 ,
(uint32_t)4*sizeof(uint8_t));
}
status |= WrMulti(&(p_dev->platform), 0x2cf8,
status |= VL53L5CX_WrMulti(&(p_dev->platform), 0x2cf8,
p_dev->temp_buffer, VL53L5CX_XTALK_BUFFER_SIZE);
status |=_vl53l5cx_poll_for_answer(p_dev, 4, 1,
VL53L5CX_UI_CMD_STATUS, 0xff, 0x03);
@ -269,10 +221,10 @@ uint8_t vl53l5cx_is_alive(
uint8_t status = VL53L5CX_STATUS_OK;
uint8_t device_id, revision_id;
status |= WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= RdByte(&(p_dev->platform), 0, &device_id);
status |= RdByte(&(p_dev->platform), 1, &revision_id);
status |= WrByte(&(p_dev->platform), 0x7fff, 0x02);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= VL53L5CX_RdByte(&(p_dev->platform), 0, &device_id);
status |= VL53L5CX_RdByte(&(p_dev->platform), 1, &revision_id);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x02);
if((device_id == (uint8_t)0xF0) && (revision_id == (uint8_t)0x02))
{
@ -295,112 +247,124 @@ uint8_t vl53l5cx_init(
p_dev->default_xtalk = (uint8_t*)VL53L5CX_DEFAULT_XTALK;
p_dev->default_configuration = (uint8_t*)VL53L5CX_DEFAULT_CONFIGURATION;
p_dev->is_auto_stop_enabled = (uint8_t)0x0;
/* SW reboot sequence */
status |= WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= WrByte(&(p_dev->platform), 0x0009, 0x04);
status |= WrByte(&(p_dev->platform), 0x000F, 0x40);
status |= WrByte(&(p_dev->platform), 0x000A, 0x03);
status |= RdByte(&(p_dev->platform), 0x7FFF, &tmp);
status |= WrByte(&(p_dev->platform), 0x000C, 0x01);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x0009, 0x04);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x000F, 0x40);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x000A, 0x03);
status |= VL53L5CX_RdByte(&(p_dev->platform), 0x7FFF, &tmp);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x000C, 0x01);
status |= WrByte(&(p_dev->platform), 0x0101, 0x00);
status |= WrByte(&(p_dev->platform), 0x0102, 0x00);
status |= WrByte(&(p_dev->platform), 0x010A, 0x01);
status |= WrByte(&(p_dev->platform), 0x4002, 0x01);
status |= WrByte(&(p_dev->platform), 0x4002, 0x00);
status |= WrByte(&(p_dev->platform), 0x010A, 0x03);
status |= WrByte(&(p_dev->platform), 0x0103, 0x01);
status |= WrByte(&(p_dev->platform), 0x000C, 0x00);
status |= WrByte(&(p_dev->platform), 0x000F, 0x43);
status |= WaitMs(&(p_dev->platform), 1);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x0101, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x0102, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x010A, 0x01);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x4002, 0x01);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x4002, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x010A, 0x03);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x0103, 0x01);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x000C, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x000F, 0x43);
status |= VL53L5CX_WaitMs(&(p_dev->platform), 1);
status |= WrByte(&(p_dev->platform), 0x000F, 0x40);
status |= WrByte(&(p_dev->platform), 0x000A, 0x01);
status |= WaitMs(&(p_dev->platform), 100);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x000F, 0x40);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x000A, 0x01);
status |= VL53L5CX_WaitMs(&(p_dev->platform), 100);
/* Wait for sensor booted (several ms required to get sensor ready ) */
status |= WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= _vl53l5cx_poll_for_answer(p_dev, 1, 0, 0x06, 0xff, 1);
if(status != (uint8_t)0){
goto exit;
}
status |= WrByte(&(p_dev->platform), 0x000E, 0x01);
status |= WrByte(&(p_dev->platform), 0x7fff, 0x02);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x000E, 0x01);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x02);
/* Enable FW access */
status |= WrByte(&(p_dev->platform), 0x03, 0x0D);
status |= WrByte(&(p_dev->platform), 0x7fff, 0x01);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x03, 0x0D);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x01);
status |= _vl53l5cx_poll_for_answer(p_dev, 1, 0, 0x21, 0x10, 0x10);
status |= WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x00);
/* Enable host access to GO1 */
status += RdByte(&(p_dev->platform), 0x7fff, &tmp);
status |= WrByte(&(p_dev->platform), 0x0C, 0x01);
status |= VL53L5CX_RdByte(&(p_dev->platform), 0x7fff, &tmp);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x0C, 0x01);
/* Power ON status */
status |= WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= WrByte(&(p_dev->platform), 0x101, 0x00);
status |= WrByte(&(p_dev->platform), 0x102, 0x00);
status |= WrByte(&(p_dev->platform), 0x010A, 0x01);
status |= WrByte(&(p_dev->platform), 0x4002, 0x01);
status |= WrByte(&(p_dev->platform), 0x4002, 0x00);
status |= WrByte(&(p_dev->platform), 0x010A, 0x03);
status |= WrByte(&(p_dev->platform), 0x103, 0x01);
status |= WrByte(&(p_dev->platform), 0x400F, 0x00);
status |= WrByte(&(p_dev->platform), 0x21A, 0x43);
status |= WrByte(&(p_dev->platform), 0x21A, 0x03);
status |= WrByte(&(p_dev->platform), 0x21A, 0x01);
status |= WrByte(&(p_dev->platform), 0x21A, 0x00);
status |= WrByte(&(p_dev->platform), 0x219, 0x00);
status |= WrByte(&(p_dev->platform), 0x21B, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x101, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x102, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x010A, 0x01);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x4002, 0x01);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x4002, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x010A, 0x03);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x103, 0x01);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x400F, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x21A, 0x43);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x21A, 0x03);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x21A, 0x01);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x21A, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x219, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x21B, 0x00);
/* Wake up MCU */
status |= WrByte(&(p_dev->platform), 0x7fff, 0x00);
status += RdByte(&(p_dev->platform), 0x7fff, &tmp);
status |= WrByte(&(p_dev->platform), 0x0C, 0x00);
status |= WrByte(&(p_dev->platform), 0x7fff, 0x01);
status |= WrByte(&(p_dev->platform), 0x20, 0x07);
status |= WrByte(&(p_dev->platform), 0x20, 0x06);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= VL53L5CX_RdByte(&(p_dev->platform), 0x7fff, &tmp);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x0C, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x01);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x20, 0x07);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x20, 0x06);
/* Download FW into VL53L5 */
status |= WrByte(&(p_dev->platform), 0x7fff, 0x09);
status |= WrMulti(&(p_dev->platform),0,
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x09);
status |= VL53L5CX_WrMulti(&(p_dev->platform),0,
(uint8_t*)&VL53L5CX_FIRMWARE[0],0x8000);
status |= WrByte(&(p_dev->platform), 0x7fff, 0x0a);
status |= WrMulti(&(p_dev->platform),0,
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x0a);
status |= VL53L5CX_WrMulti(&(p_dev->platform),0,
(uint8_t*)&VL53L5CX_FIRMWARE[0x8000],0x8000);
status |= WrByte(&(p_dev->platform), 0x7fff, 0x0b);
status |= WrMulti(&(p_dev->platform),0,
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x0b);
status |= VL53L5CX_WrMulti(&(p_dev->platform),0,
(uint8_t*)&VL53L5CX_FIRMWARE[0x10000],0x5000);
status |= WrByte(&(p_dev->platform), 0x7fff, 0x01);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x01);
/* Check if FW correctly downloaded */
status |= WrByte(&(p_dev->platform), 0x7fff, 0x02);
status |= WrByte(&(p_dev->platform), 0x03, 0x0D);
status |= WrByte(&(p_dev->platform), 0x7fff, 0x01);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x02);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x03, 0x0D);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x01);
status |= _vl53l5cx_poll_for_answer(p_dev, 1, 0, 0x21, 0x10, 0x10);
status |= WrByte(&(p_dev->platform), 0x7fff, 0x00);
status += RdByte(&(p_dev->platform), 0x7fff, &tmp);
status |= WrByte(&(p_dev->platform), 0x0C, 0x01);
if(status != (uint8_t)0){
goto exit;
}
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= VL53L5CX_RdByte(&(p_dev->platform), 0x7fff, &tmp);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x0C, 0x01);
/* Reset MCU and wait boot */
status |= WrByte(&(p_dev->platform), 0x7FFF, 0x00);
status |= WrByte(&(p_dev->platform), 0x114, 0x00);
status |= WrByte(&(p_dev->platform), 0x115, 0x00);
status |= WrByte(&(p_dev->platform), 0x116, 0x42);
status |= WrByte(&(p_dev->platform), 0x117, 0x00);
status |= WrByte(&(p_dev->platform), 0x0B, 0x00);
status += RdByte(&(p_dev->platform), 0x7fff, &tmp);
status |= WrByte(&(p_dev->platform), 0x0C, 0x00);
status |= WrByte(&(p_dev->platform), 0x0B, 0x01);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7FFF, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x114, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x115, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x116, 0x42);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x117, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x0B, 0x00);
status |= VL53L5CX_RdByte(&(p_dev->platform), 0x7fff, &tmp);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x0C, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x0B, 0x01);
status |= _vl53l5cx_poll_for_mcu_boot(p_dev);
status |= WrByte(&(p_dev->platform), 0x7fff, 0x02);
if(status != (uint8_t)0){
goto exit;
}
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x02);
/* Get offset NVM data and store them into the offset buffer */
status |= WrMulti(&(p_dev->platform), 0x2fd8,
status |= VL53L5CX_WrMulti(&(p_dev->platform), 0x2fd8,
(uint8_t*)VL53L5CX_GET_NVM_CMD, sizeof(VL53L5CX_GET_NVM_CMD));
status |= _vl53l5cx_poll_for_answer(p_dev, 4, 0,
VL53L5CX_UI_CMD_STATUS, 0xff, 2);
status |= RdMulti(&(p_dev->platform), VL53L5CX_UI_CMD_START,
status |= VL53L5CX_RdMulti(&(p_dev->platform), VL53L5CX_UI_CMD_START,
p_dev->temp_buffer, VL53L5CX_NVM_DATA_SIZE);
(void)memcpy(p_dev->offset_data, p_dev->temp_buffer,
VL53L5CX_OFFSET_BUFFER_SIZE);
@ -412,7 +376,7 @@ uint8_t vl53l5cx_init(
status |= _vl53l5cx_send_xtalk_data(p_dev, VL53L5CX_RESOLUTION_4X4);
/* Send default configuration to VL53L5CX firmware */
status |= WrMulti(&(p_dev->platform), 0x2c34,
status |= VL53L5CX_WrMulti(&(p_dev->platform), 0x2c34,
p_dev->default_configuration,
sizeof(VL53L5CX_DEFAULT_CONFIGURATION));
status |= _vl53l5cx_poll_for_answer(p_dev, 4, 1,
@ -431,6 +395,13 @@ uint8_t vl53l5cx_init(
VL53L5CX_DCI_SINGLE_RANGE,
(uint16_t)sizeof(single_range));
tmp = (uint8_t)1;
status |= vl53l5cx_dci_replace_data(p_dev, p_dev->temp_buffer,
VL53L5CX_GLARE_FILTER, 40, (uint8_t*)&tmp, 1, 0x26);
status |= vl53l5cx_dci_replace_data(p_dev, p_dev->temp_buffer,
VL53L5CX_GLARE_FILTER, 40, (uint8_t*)&tmp, 1, 0x25);
exit:
return status;
}
@ -440,10 +411,10 @@ uint8_t vl53l5cx_set_i2c_address(
{
uint8_t status = VL53L5CX_STATUS_OK;
status |= WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= WrByte(&(p_dev->platform), 0x4, (uint8_t)(i2c_address >> 1));
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x4, (uint8_t)(i2c_address >> 1));
p_dev->platform.address = i2c_address;
status |= WrByte(&(p_dev->platform), 0x7fff, 0x02);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x02);
return status;
}
@ -454,8 +425,8 @@ uint8_t vl53l5cx_get_power_mode(
{
uint8_t tmp, status = VL53L5CX_STATUS_OK;
status |= WrByte(&(p_dev->platform), 0x7FFF, 0x00);
status |= RdByte(&(p_dev->platform), 0x009, &tmp);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7FFF, 0x00);
status |= VL53L5CX_RdByte(&(p_dev->platform), 0x009, &tmp);
switch(tmp)
{
@ -472,7 +443,7 @@ uint8_t vl53l5cx_get_power_mode(
break;
}
status |= WrByte(&(p_dev->platform), 0x7FFF, 0x02);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7FFF, 0x02);
return status;
}
@ -489,15 +460,15 @@ uint8_t vl53l5cx_set_power_mode(
switch(power_mode)
{
case VL53L5CX_POWER_MODE_WAKEUP:
status |= WrByte(&(p_dev->platform), 0x7FFF, 0x00);
status |= WrByte(&(p_dev->platform), 0x09, 0x04);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7FFF, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x09, 0x04);
status |= _vl53l5cx_poll_for_answer(
p_dev, 1, 0, 0x06, 0x01, 1);
break;
case VL53L5CX_POWER_MODE_SLEEP:
status |= WrByte(&(p_dev->platform), 0x7FFF, 0x00);
status |= WrByte(&(p_dev->platform), 0x09, 0x02);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7FFF, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x09, 0x02);
status |= _vl53l5cx_poll_for_answer(
p_dev, 1, 0, 0x06, 0x01, 0);
break;
@ -506,7 +477,7 @@ uint8_t vl53l5cx_set_power_mode(
status = VL53L5CX_STATUS_ERROR;
break;
}
status |= WrByte(&(p_dev->platform), 0x7FFF, 0x02);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7FFF, 0x02);
}
return status;
@ -598,8 +569,8 @@ uint8_t vl53l5cx_start_ranging(
}
else
{
bh_ptr->size = (uint8_t)(resolution
* (uint8_t)VL53L5CX_NB_TARGET_PER_ZONE);
bh_ptr->size = (uint16_t)((uint16_t)resolution
* (uint16_t)VL53L5CX_NB_TARGET_PER_ZONE);
}
p_dev->data_read_size += bh_ptr->type * bh_ptr->size;
}
@ -609,7 +580,7 @@ uint8_t vl53l5cx_start_ranging(
}
p_dev->data_read_size += (uint32_t)4;
}
p_dev->data_read_size += (uint32_t)20;
p_dev->data_read_size += (uint32_t)24;
status |= vl53l5cx_dci_write_data(p_dev,
(uint8_t*)&(output), VL53L5CX_DCI_OUTPUT_LIST,
@ -627,18 +598,18 @@ uint8_t vl53l5cx_start_ranging(
(uint16_t)sizeof(output_bh_enable));
/* Start xshut bypass (interrupt mode) */
status |= WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= WrByte(&(p_dev->platform), 0x09, 0x05);
status |= WrByte(&(p_dev->platform), 0x7fff, 0x02);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x09, 0x05);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x02);
/* Start ranging session */
status |= WrMulti(&(p_dev->platform), VL53L5CX_UI_CMD_END -
status |= VL53L5CX_WrMulti(&(p_dev->platform), VL53L5CX_UI_CMD_END -
(uint16_t)(4 - 1), (uint8_t*)cmd, sizeof(cmd));
status |= _vl53l5cx_poll_for_answer(p_dev, 4, 1,
VL53L5CX_UI_CMD_STATUS, 0xff, 0x03);
/* Read ui range data content and compare if data size is the correct one */
status += vl53l5cx_dci_read_data(p_dev,
status |= vl53l5cx_dci_read_data(p_dev,
(uint8_t*)p_dev->temp_buffer, 0x5440, 12);
(void)memcpy(&tmp, &(p_dev->temp_buffer[0x8]), sizeof(tmp));
if(tmp != p_dev->data_read_size)
@ -656,21 +627,22 @@ uint8_t vl53l5cx_stop_ranging(
uint16_t timeout = 0;
uint32_t auto_stop_flag = 0;
status |= RdMulti(&(p_dev->platform),
status |= VL53L5CX_RdMulti(&(p_dev->platform),
0x2FFC, (uint8_t*)&auto_stop_flag, 4);
if(auto_stop_flag != (uint32_t)0x4FF)
if((auto_stop_flag != (uint32_t)0x4FF)
&& (p_dev->is_auto_stop_enabled == (uint8_t)0))
{
status |= WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x00);
/* Provoke MCU stop */
status |= WrByte(&(p_dev->platform), 0x15, 0x16);
status |= WrByte(&(p_dev->platform), 0x14, 0x01);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x15, 0x16);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x14, 0x01);
/* Poll for G02 status 0 MCU stop */
while(((tmp & (uint8_t)0x80) >> 7) == (uint8_t)0x00)
{
status |= RdByte(&(p_dev->platform), 0x6, &tmp);
status |= WaitMs(&(p_dev->platform), 10);
status |= VL53L5CX_RdByte(&(p_dev->platform), 0x6, &tmp);
status |= VL53L5CX_WaitMs(&(p_dev->platform), 10);
timeout++; /* Timeout reached after 5 seconds */
if(timeout > (uint16_t)500)
@ -682,22 +654,22 @@ uint8_t vl53l5cx_stop_ranging(
}
/* Check GO2 status 1 if status is still OK */
status += RdByte(&(p_dev->platform), 0x6, &tmp);
status |= VL53L5CX_RdByte(&(p_dev->platform), 0x6, &tmp);
if((tmp & (uint8_t)0x80) != (uint8_t)0){
status += RdByte(&(p_dev->platform), 0x7, &tmp);
status |= VL53L5CX_RdByte(&(p_dev->platform), 0x7, &tmp);
if((tmp != (uint8_t)0x84) && (tmp != (uint8_t)0x85)){
status |= tmp;
}
}
/* Undo MCU stop */
status |= WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= WrByte(&(p_dev->platform), 0x14, 0x00);
status |= WrByte(&(p_dev->platform), 0x15, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x14, 0x00);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x15, 0x00);
/* Stop xshut bypass */
status |= WrByte(&(p_dev->platform), 0x09, 0x04);
status |= WrByte(&(p_dev->platform), 0x7fff, 0x02);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x09, 0x04);
status |= VL53L5CX_WrByte(&(p_dev->platform), 0x7fff, 0x02);
return status;
}
@ -708,7 +680,7 @@ uint8_t vl53l5cx_check_data_ready(
{
uint8_t status = VL53L5CX_STATUS_OK;
status |= RdMulti(&(p_dev->platform), 0x0, p_dev->temp_buffer, 4);
status |= VL53L5CX_RdMulti(&(p_dev->platform), 0x0, p_dev->temp_buffer, 4);
if((p_dev->temp_buffer[0] != p_dev->streamcount)
&& (p_dev->temp_buffer[0] != (uint8_t)255)
@ -739,12 +711,13 @@ uint8_t vl53l5cx_get_ranging_data(
{
uint8_t status = VL53L5CX_STATUS_OK;
union Block_header *bh_ptr;
uint32_t i, j, msize;
(void) j;
status |= RdMulti(&(p_dev->platform), 0x0,
uint16_t header_id, footer_id;
uint32_t i, msize;
status |= VL53L5CX_RdMulti(&(p_dev->platform), 0x0,
p_dev->temp_buffer, p_dev->data_read_size);
p_dev->streamcount = p_dev->temp_buffer[0];
SwapBuffer(p_dev->temp_buffer, (uint16_t)p_dev->data_read_size);
VL53L5CX_SwapBuffer(p_dev->temp_buffer, (uint16_t)p_dev->data_read_size);
/* Start conversion at position 16 to avoid headers */
for (i = (uint32_t)16; i
@ -884,6 +857,22 @@ uint8_t vl53l5cx_get_ranging_data(
#endif
#endif
/* Check if footer id and header id are matching. This allows to detect
* corrupted frames */
header_id = ((uint16_t)(p_dev->temp_buffer[0x8])<<8) & 0xFF00U;
header_id |= ((uint16_t)(p_dev->temp_buffer[0x9])) & 0x00FFU;
footer_id = ((uint16_t)(p_dev->temp_buffer[p_dev->data_read_size
- (uint32_t)4]) << 8) & 0xFF00U;
footer_id |= ((uint16_t)(p_dev->temp_buffer[p_dev->data_read_size
- (uint32_t)3])) & 0xFFU;
if(header_id != footer_id)
{
status |= VL53L5CX_STATUS_CORRUPTED_FRAME;
}
return status;
}
@ -1162,6 +1151,68 @@ uint8_t vl53l5cx_set_ranging_mode(
return status;
}
uint8_t vl53l5cx_enable_internal_cp(
VL53L5CX_Configuration *p_dev)
{
uint8_t status = VL53L5CX_STATUS_OK;
uint8_t vcsel_bootup_fsm = 1;
uint8_t analog_dynamic_pad_0 = 0;
status |= vl53l5cx_dci_replace_data(p_dev, p_dev->temp_buffer,
VL53L5CX_DCI_INTERNAL_CP, 16,
(uint8_t*)&vcsel_bootup_fsm, 1, 0x0A);
status |= vl53l5cx_dci_replace_data(p_dev, p_dev->temp_buffer,
VL53L5CX_DCI_INTERNAL_CP, 16,
(uint8_t*)&analog_dynamic_pad_0, 1, 0x0E);
return status;
}
uint8_t vl53l5cx_disable_internal_cp(
VL53L5CX_Configuration *p_dev)
{
uint8_t status = VL53L5CX_STATUS_OK;
uint8_t vcsel_bootup_fsm = 0;
uint8_t analog_dynamic_pad_0 = 1;
status |= vl53l5cx_dci_replace_data(p_dev, p_dev->temp_buffer,
VL53L5CX_DCI_INTERNAL_CP, 16,
(uint8_t*)&vcsel_bootup_fsm, 1, 0x0A);
status |= vl53l5cx_dci_replace_data(p_dev, p_dev->temp_buffer,
VL53L5CX_DCI_INTERNAL_CP, 16,
(uint8_t*)&analog_dynamic_pad_0, 1, 0x0E);
return status;
}
uint8_t vl53l5cx_get_VHV_repeat_count(
VL53L5CX_Configuration *p_dev,
uint32_t *p_repeat_count)
{
uint8_t status = VL53L5CX_STATUS_OK;
status |= vl53l5cx_dci_read_data(p_dev, (uint8_t*)p_dev->temp_buffer,
VL53L5CX_DCI_VHV_CONFIG, 16);
*p_repeat_count = ((uint32_t)p_dev->temp_buffer[7] << 24)
| ((uint32_t)p_dev->temp_buffer[6] << 16)
| ((uint32_t)p_dev->temp_buffer[5] << 8)
| (uint32_t)p_dev->temp_buffer[4];
return status;
}
uint8_t vl53l5cx_set_VHV_repeat_count(
VL53L5CX_Configuration *p_dev,
uint32_t repeat_count)
{
uint8_t status = VL53L5CX_STATUS_OK;
status |= vl53l5cx_dci_replace_data(p_dev, p_dev->temp_buffer,
VL53L5CX_DCI_VHV_CONFIG, 16, (uint8_t*)&repeat_count, 4, 0x4);
return status;
}
uint8_t vl53l5cx_dci_read_data(
VL53L5CX_Configuration *p_dev,
uint8_t *data,
@ -1188,16 +1239,16 @@ uint8_t vl53l5cx_dci_read_data(
cmd[3] = (uint8_t)((data_size & (uint16_t)0xf) << 4);
/* Request data reading from FW */
status |= WrMulti(&(p_dev->platform),
status |= VL53L5CX_WrMulti(&(p_dev->platform),
(VL53L5CX_UI_CMD_END-(uint16_t)11),cmd, sizeof(cmd));
status |= _vl53l5cx_poll_for_answer(p_dev, 4, 1,
VL53L5CX_UI_CMD_STATUS,
0xff, 0x03);
/* Read new data sent (4 bytes header + data_size + 8 bytes footer) */
status |= RdMulti(&(p_dev->platform), VL53L5CX_UI_CMD_START,
status |= VL53L5CX_RdMulti(&(p_dev->platform), VL53L5CX_UI_CMD_START,
p_dev->temp_buffer, rd_size);
SwapBuffer(p_dev->temp_buffer, data_size + (uint16_t)12);
VL53L5CX_SwapBuffer(p_dev->temp_buffer, data_size + (uint16_t)12);
/* Copy data from FW into input structure (-4 bytes to remove header) */
for(i = 0 ; i < (int16_t)data_size;i++){
@ -1239,7 +1290,7 @@ uint8_t vl53l5cx_dci_write_data(
headers[3] = (uint8_t)((data_size & (uint16_t)0xf) << 4);
/* Copy data from structure to FW format (+4 bytes to add header) */
SwapBuffer(data, data_size);
VL53L5CX_SwapBuffer(data, data_size);
for(i = (int16_t)data_size - (int16_t)1 ; i >= 0; i--)
{
p_dev->temp_buffer[i + 4] = data[i];
@ -1251,13 +1302,13 @@ uint8_t vl53l5cx_dci_write_data(
footer, sizeof(footer));
/* Send data to FW */
status |= WrMulti(&(p_dev->platform),address,
status |= VL53L5CX_WrMulti(&(p_dev->platform),address,
p_dev->temp_buffer,
(uint32_t)((uint32_t)data_size + (uint32_t)12));
status |= _vl53l5cx_poll_for_answer(p_dev, 4, 1,
VL53L5CX_UI_CMD_STATUS, 0xff, 0x03);
SwapBuffer(data, data_size);
VL53L5CX_SwapBuffer(data, data_size);
}
return status;

View File

@ -1,64 +1,14 @@
/*******************************************************************************
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
*
* This file is part of the VL53L5CX Ultra Lite Driver 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, the VL53L5CX Ultra Lite Driver 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:
*
* 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.
*
*
*******************************************************************************/
/**
*
* Copyright (c) 2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
#include "vl53l5cx_plugin_detection_thresholds.h"

View File

@ -1,64 +1,14 @@
/*******************************************************************************
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
*
* This file is part of the VL53L5CX Ultra Lite Driver 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, the VL53L5CX Ultra Lite Driver 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:
*
* 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.
*
*
*******************************************************************************/
/**
*
* Copyright (c) 2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
#include <math.h>
#include "vl53l5cx_plugin_motion_indicator.h"
@ -160,7 +110,7 @@ uint8_t vl53l5cx_motion_indicator_set_resolution(
break;
}
if(status != (uint8_t)0)
if (status == VL53L5CX_STATUS_OK)
{
status |= vl53l5cx_dci_write_data(p_dev,
(uint8_t*)(p_motion_config),

View File

@ -1,64 +1,14 @@
/*******************************************************************************
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
*
* This file is part of the VL53L5CX Ultra Lite Driver 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, the VL53L5CX Ultra Lite Driver 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:
*
* 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.
*
*
*******************************************************************************/
/**
*
* Copyright (c) 2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
#include "vl53l5cx_plugin_xtalk.h"
@ -76,9 +26,9 @@ static uint8_t _vl53l5cx_poll_for_answer(
uint8_t timeout = 0;
do {
status |= RdMulti(&(p_dev->platform),
status |= VL53L5CX_RdMulti(&(p_dev->platform),
address, p_dev->temp_buffer, 4);
status |= WaitMs(&(p_dev->platform), 10);
status |= VL53L5CX_WaitMs(&(p_dev->platform), 10);
/* 2s timeout or FW error*/
if((timeout >= (uint8_t)200)
@ -87,10 +37,10 @@ static uint8_t _vl53l5cx_poll_for_answer(
status |= VL53L5CX_MCU_ERROR;
break;
}
else
{
timeout++;
}
else
{
timeout++;
}
}while ((p_dev->temp_buffer[0x1]) != expected_value);
return status;
@ -106,8 +56,8 @@ static uint8_t _vl53l5cx_program_output_config(
{
uint8_t resolution, status = VL53L5CX_STATUS_OK;
uint32_t i;
uint64_t header_config;
union Block_header *bh_ptr;
uint32_t header_config[2] = {0, 0};
status |= vl53l5cx_get_resolution(p_dev, &resolution);
p_dev->data_read_size = 0;
@ -171,22 +121,21 @@ static uint8_t _vl53l5cx_program_output_config(
{
p_dev->data_read_size += bh_ptr->size;
}
p_dev->data_read_size += (uint32_t)4;
}
p_dev->data_read_size += (uint32_t)20;
p_dev->data_read_size += (uint32_t)24;
status |= vl53l5cx_dci_write_data(p_dev,
(uint8_t*)&(output),
VL53L5CX_DCI_OUTPUT_LIST, (uint16_t)sizeof(output));
header_config = (uint64_t)i + (uint64_t)1;
header_config = header_config << 32;
header_config += (uint64_t)p_dev->data_read_size;
header_config[0] = p_dev->data_read_size;
header_config[1] = i + (uint32_t)1;
status |= vl53l5cx_dci_write_data(p_dev,
(uint8_t*)&(header_config), VL53L5CX_DCI_OUTPUT_CONFIG,
(uint16_t)sizeof(header_config));
status |= vl53l5cx_dci_write_data(p_dev, (uint8_t*)&(header_config),
VL53L5CX_DCI_OUTPUT_CONFIG,
(uint16_t)sizeof(header_config));
status |= vl53l5cx_dci_write_data(p_dev, (uint8_t*)&(output_bh_enable),
VL53L5CX_DCI_OUTPUT_ENABLES,
(uint16_t)sizeof(output_bh_enable));
@ -211,6 +160,7 @@ uint8_t vl53l5cx_calibrate_xtalk(
uint16_t reflectance = reflectance_percent;
uint8_t samples = nb_samples;
uint16_t distance = distance_mm;
uint8_t *default_xtalk_ptr;
/* Get initial configuration */
status |= vl53l5cx_get_resolution(p_dev, &resolution);
@ -236,7 +186,7 @@ uint8_t vl53l5cx_calibrate_xtalk(
/* Send Xtalk calibration buffer */
(void)memcpy(p_dev->temp_buffer, VL53L5CX_CALIBRATE_XTALK,
sizeof(VL53L5CX_CALIBRATE_XTALK));
status |= WrMulti(&(p_dev->platform), 0x2c28,
status |= VL53L5CX_WrMulti(&(p_dev->platform), 0x2c28,
p_dev->temp_buffer,
(uint16_t)sizeof(VL53L5CX_CALIBRATE_XTALK));
status |= _vl53l5cx_poll_for_answer(p_dev,
@ -263,7 +213,7 @@ uint8_t vl53l5cx_calibrate_xtalk(
status |= _vl53l5cx_program_output_config(p_dev);
/* Start ranging session */
status |= WrMulti(&(p_dev->platform),
status |= VL53L5CX_WrMulti(&(p_dev->platform),
VL53L5CX_UI_CMD_END - (uint16_t)(4 - 1),
(uint8_t*)cmd, sizeof(cmd));
status |= _vl53l5cx_poll_for_answer(p_dev,
@ -271,8 +221,9 @@ uint8_t vl53l5cx_calibrate_xtalk(
/* Wait for end of calibration */
do {
status |= RdMulti(&(p_dev->platform),
status |= VL53L5CX_RdMulti(&(p_dev->platform),
0x0, p_dev->temp_buffer, 4);
if(p_dev->temp_buffer[0] != VL53L5CX_STATUS_ERROR)
{
/* Coverglass too good for Xtalk calibration */
@ -280,9 +231,11 @@ uint8_t vl53l5cx_calibrate_xtalk(
(((uint16_t)(p_dev->temp_buffer[3] &
(uint16_t)0x80) >> 7) == (uint16_t)1))
{
default_xtalk_ptr = p_dev->default_xtalk;
(void)memcpy(p_dev->xtalk_data,
p_dev->default_xtalk,
VL53L5CX_XTALK_BUFFER_SIZE);
default_xtalk_ptr,
sizeof(p_dev->xtalk_data));
status |= VL53L5CX_STATUS_XTALK_FAILED;
}
continue_loop = (uint8_t)0;
}
@ -294,7 +247,7 @@ uint8_t vl53l5cx_calibrate_xtalk(
else
{
timeout++;
status |= WaitMs(&(p_dev->platform), 50);
status |= VL53L5CX_WaitMs(&(p_dev->platform), 50);
}
}while (continue_loop == (uint8_t)1);
@ -303,11 +256,11 @@ uint8_t vl53l5cx_calibrate_xtalk(
/* Save Xtalk data into the Xtalk buffer */
(void)memcpy(p_dev->temp_buffer, VL53L5CX_GET_XTALK_CMD,
sizeof(VL53L5CX_GET_XTALK_CMD));
status |= WrMulti(&(p_dev->platform), 0x2fb8,
status |= VL53L5CX_WrMulti(&(p_dev->platform), 0x2fb8,
p_dev->temp_buffer,
(uint16_t)sizeof(VL53L5CX_GET_XTALK_CMD));
status |= _vl53l5cx_poll_for_answer(p_dev,VL53L5CX_UI_CMD_STATUS, 0x03);
status |= RdMulti(&(p_dev->platform), VL53L5CX_UI_CMD_START,
status |= VL53L5CX_RdMulti(&(p_dev->platform), VL53L5CX_UI_CMD_START,
p_dev->temp_buffer,
VL53L5CX_XTALK_BUFFER_SIZE + (uint16_t)4);
@ -317,7 +270,7 @@ uint8_t vl53l5cx_calibrate_xtalk(
- (uint16_t)8]), footer, sizeof(footer));
/* Reset default buffer */
status |= WrMulti(&(p_dev->platform), 0x2c34,
status |= VL53L5CX_WrMulti(&(p_dev->platform), 0x2c34,
p_dev->default_configuration,
VL53L5CX_CONFIGURATION_SIZE);
status |= _vl53l5cx_poll_for_answer(p_dev,VL53L5CX_UI_CMD_STATUS, 0x03);
@ -346,10 +299,10 @@ uint8_t vl53l5cx_get_caldata_xtalk(
(void)memcpy(p_dev->temp_buffer, VL53L5CX_GET_XTALK_CMD,
sizeof(VL53L5CX_GET_XTALK_CMD));
status |= WrMulti(&(p_dev->platform), 0x2fb8,
status |= VL53L5CX_WrMulti(&(p_dev->platform), 0x2fb8,
p_dev->temp_buffer, sizeof(VL53L5CX_GET_XTALK_CMD));
status |= _vl53l5cx_poll_for_answer(p_dev,VL53L5CX_UI_CMD_STATUS, 0x03);
status |= RdMulti(&(p_dev->platform), VL53L5CX_UI_CMD_START,
status |= VL53L5CX_RdMulti(&(p_dev->platform), VL53L5CX_UI_CMD_START,
p_dev->temp_buffer,
VL53L5CX_XTALK_BUFFER_SIZE + (uint16_t)4);