Add samsung specific changes

This commit is contained in:
2025-08-11 14:29:00 +02:00
parent c66122e619
commit 4d134a1294
2688 changed files with 1127995 additions and 11475 deletions

7
drivers/sensors/Kconfig Executable file
View File

@@ -0,0 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only
config SENSORS
tristate "Sensors Class Support"
help
This option enables the sensor sysfs class in /sys/class/sensors.
You'll need this to do anything useful with sensors. If unsure, say N.

1
drivers/sensors/Makefile Executable file
View File

@@ -0,0 +1 @@
obj-$(CONFIG_SENSORS) += sensors_core.o

260
drivers/sensors/sensors_core.c Executable file
View File

@@ -0,0 +1,260 @@
/*
* Copyright (C) 2013 Samsung Electronics. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/sysfs.h>
#include <linux/err.h>
#include <linux/input.h>
#include <linux/sensor/sensors_core.h>
struct class *sensors_class;
struct class *sensors_event_class;
static struct device *symlink_dev;
static struct device *sensor_dev;
static struct input_dev *meta_input_dev;
static atomic_t sensor_count;
int sensors_create_symlink(struct kobject *target, const char *name)
{
int err = 0;
if (symlink_dev == NULL) {
pr_err("%s, symlink_dev is NULL!!!\n", __func__);
return err;
}
err = sysfs_create_link(&symlink_dev->kobj, target, name);
if (err < 0) {
pr_err("%s, %s failed!(%d)\n", __func__, name, err);
return err;
}
return err;
}
EXPORT_SYMBOL_GPL(sensors_create_symlink);
void sensors_remove_symlink(struct kobject *target, const char *name)
{
if (symlink_dev == NULL)
pr_err("%s, symlink_dev is NULL!!!\n", __func__);
else
sysfs_remove_link(&symlink_dev->kobj, name);
}
EXPORT_SYMBOL_GPL(sensors_remove_symlink);
static ssize_t set_flush(struct device *dev, struct device_attribute *attr,
const char *buf, size_t size)
{
int64_t dTemp;
u8 sensor_type = 0;
if (kstrtoll(buf, 10, &dTemp) < 0)
return -EINVAL;
sensor_type = (u8)dTemp;
input_report_rel(meta_input_dev, REL_DIAL,
1); /*META_DATA_FLUSH_COMPLETE*/
input_report_rel(meta_input_dev, REL_HWHEEL, sensor_type + 1);
input_sync(meta_input_dev);
pr_info("[SENSOR] flush %d\n", sensor_type);
return size;
}
static DEVICE_ATTR(flush, S_IWUSR | S_IWGRP, NULL, set_flush);
static struct device_attribute *sensor_attr[] = {
&dev_attr_flush,
NULL,
};
int sensors_register(struct device **dev, void *drvdata,
struct device_attribute *attributes[], char *name)
{
int ret = 0;
int i;
if (sensors_class == NULL) {
sensors_class = class_create("sensors");
if (IS_ERR(sensors_class))
return PTR_ERR(sensors_class);
}
*dev = device_create(sensors_class, NULL, 0, drvdata, "%s", name);
if (IS_ERR(*dev)) {
ret = PTR_ERR(*dev);
pr_err("[SENSORS CORE] device_create failed![%d]\n", ret);
return ret;
}
for (i = 0; attributes[i] != NULL; i++)
if ((device_create_file(*dev, attributes[i])) < 0)
pr_err("[SENSOR CORE] fail device_create_file"\
"(dev, attributes[%d])\n", i);
atomic_inc(&sensor_count);
return ret;
}
EXPORT_SYMBOL_GPL(sensors_register);
void sensors_unregister(struct device *dev,
struct device_attribute *attributes[])
{
int i;
for (i = 0; attributes[i] != NULL; i++)
device_remove_file(dev, attributes[i]);
}
EXPORT_SYMBOL_GPL(sensors_unregister);
void destroy_sensor_class(void)
{
if (sensors_class) {
device_destroy(sensors_class, sensor_dev->devt);
class_destroy(sensors_class);
sensor_dev = NULL;
sensors_class = NULL;
}
if (sensors_event_class) {
device_destroy(sensors_event_class, symlink_dev->devt);
class_destroy(sensors_event_class);
symlink_dev = NULL;
sensors_event_class = NULL;
}
}
int sensors_input_init(void)
{
int ret;
/* Meta Input Event Initialization */
meta_input_dev = input_allocate_device();
if (!meta_input_dev) {
pr_err("[SENSOR CORE] failed alloc meta dev\n");
return -ENOMEM;
}
meta_input_dev->name = "meta_event";
input_set_capability(meta_input_dev, EV_REL, REL_HWHEEL);
input_set_capability(meta_input_dev, EV_REL, REL_DIAL);
ret = input_register_device(meta_input_dev);
if (ret < 0) {
pr_err("[SENSOR CORE] failed register meta dev\n");
input_free_device(meta_input_dev);
return ret;
}
ret = sensors_create_symlink(&meta_input_dev->dev.kobj,
meta_input_dev->name);
if (ret < 0) {
pr_err("[SENSOR CORE] failed create meta symlink\n");
input_unregister_device(meta_input_dev);
input_free_device(meta_input_dev);
return ret;
}
return ret;
}
void sensors_input_clean(void)
{
sensors_remove_symlink(&meta_input_dev->dev.kobj,
meta_input_dev->name);
input_unregister_device(meta_input_dev);
input_free_device(meta_input_dev);
}
static int __init sensors_class_init(void)
{
pr_info("[SENSORS CORE] sensors_class_init\n");
sensors_class = class_create("sensors");
if (IS_ERR(sensors_class)) {
pr_err("%s, create sensors_class is failed.(err=%d)\n",
__func__, IS_ERR(sensors_class));
return PTR_ERR(sensors_class);
}
/* For flush sysfs */
sensor_dev = device_create(sensors_class, NULL, 0, NULL,
"%s", "sensor_dev");
if (IS_ERR(sensor_dev)) {
pr_err("[SENSORS CORE] sensor_dev create failed![%d]\n",
IS_ERR(sensor_dev));
class_destroy(sensors_class);
return PTR_ERR(sensor_dev);
} else {
if ((device_create_file(sensor_dev, *sensor_attr)) < 0)
pr_err("[SENSOR CORE] failed flush device_file\n");
}
/* For symbolic link */
sensors_event_class = class_create("sensor_event");
if (IS_ERR(sensors_event_class)) {
pr_err("%s, create sensors_class is failed.(err=%d)\n",
__func__, IS_ERR(sensors_event_class));
class_destroy(sensors_class);
return PTR_ERR(sensors_event_class);
}
symlink_dev = device_create(sensors_event_class, NULL, 0, NULL,
"%s", "symlink");
if (IS_ERR(symlink_dev)) {
pr_err("[SENSORS CORE] symlink_dev create failed![%d]\n",
IS_ERR(symlink_dev));
class_destroy(sensors_class);
class_destroy(sensors_event_class);
return PTR_ERR(symlink_dev);
}
atomic_set(&sensor_count, 0);
sensors_class->dev_uevent = NULL;
sensors_input_init();
return 0;
}
static void __exit sensors_class_exit(void)
{
if (meta_input_dev)
sensors_input_clean();
if (sensors_class || sensors_event_class) {
class_destroy(sensors_class);
sensors_class = NULL;
class_destroy(sensors_event_class);
sensors_event_class = NULL;
}
}
subsys_initcall(sensors_class_init);
module_exit(sensors_class_exit);
MODULE_DESCRIPTION("Universal sensors core class");
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Samsung Electronics");

View File

@@ -0,0 +1,52 @@
# SPDX-License-Identifier: GPL-2.0-only
config SENSORS_VL53L8
depends on SPI
tristate "VL53L8 driver"
default n
help
Say Y here if you use VL53L5.
This option enables range sensor using VL53L8.
config SENSORS_VL53L8_SUPPORT_UAPI
tristate "STM VL53L8 ranging sensor UPAI interface"
default n
help
STM VL53L8 ranging sensor UPAI interface.
config SENSORS_VL53L8_SUPPORT_KERNEL_INTERFACE
tristate "STM VL53L8 ranging sensor Kernel Interface"
default n
help
STM VL53L8 ranging sensor Kernel Interface.
config SENSORS_VL53L8_QCOM
tristate "VL53L8 ranging sensor feature for Snapdragon"
default n
help
VL53L8 ranging sensor feature for Snapdragon AP.
config SENSORS_VL53L8_SLSI
tristate "VL53L8 ranging sensor feature for Exynos"
default n
help
VL53L8 ranging sensor feature for Exynos AP.
config SEPARATE_IO_CORE_POWER
tristate "VL53L8 ranging sensor feature for IO/CORE Power source"
default n
help
This option enables IO and CORE power separation.
config SENSORS_LAF_FAILURE_DEBUG
tristate "VL53L8 error code collection"
default n
help
This option enables error code collection.
config SENSORS_VL53L8_SUPPORT_RESUME_WORK
tristate "VL53L8 work func to reduce resume time"
default n
help
VL53L8 ranging sensor feature to reduce resume time.

View File

@@ -0,0 +1,247 @@
################################################################################
# Copyright (c) 2022, STMicroelectronics - All Rights Reserved
#
# This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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.
#
#
###############################################################################/
# Parameters
MODULE := stmvl53l8
CONFIG_STMVL53L8 := $(CONFIG_SENSORS_VL53L8)
# Configure the build type : RELEASE, DEBUG
BUILD_TYPE = RELEASE
#BUILD_TYPE = DEBUG
# Sets the servicing mode to use i.e. INTERRUPT or DEFAULT
RANGE_SERVICING = INTERRUPT
# Set to TRUE to enable TCDM dump
TCDM_DUMP_ENABLE = FALSE
# Set to TRUE to enable rad2perp calibration
RAD2PERP_CAL_ENABLE = FALSE
# Set to TRUE to enable code for internal testing
LEGACY_CODE = FALSE
# Set to TRUE to enable logging functions.
LOG_ENABLE = FALSE
# Set to TRUE to enable force error.
FORCE_ERROR = FALSE
# Set to TRUE to enable legacy results data. Only use if legacy config's available
LEGACY_RESULTS_DATA = FALSE
# Set to TRUE to enable legacy results data. Only use if legacy config's available
EXTENDED_RESULTS_DATA = TRUE
KDIR = /lib/modules/$(shell uname -r)/build
ccflags-y += -I$(srctree)/drivers/sensors/vl53l8/inc
ccflags-y += -I$(srctree)/drivers/sensors/vl53l8/bare_driver/common/inc
ccflags-y += -I$(srctree)/drivers/sensors/vl53l8/bare_driver/api/inc
ccflags-y += -I$(srctree)/drivers/sensors/vl53l8/bare_driver/dci/inc
ccflags-y += -I$(srctree)/drivers/sensors/vl53l8/platform/inc
ccflags-y += -Wall -Werror -Wno-missing-braces
KERNEL_DRIVER_OBJS = \
src/vl53l8_k_module.o \
src/vl53l8_k_ioctl_controls.o \
src/vl53l8_k_gpio_utils.o \
src/vl53l8_k_error_converter.o \
src/vl53l8_k_range_wait_handler.o \
src/vl53l8_k_glare_filter.o
PLATFORM_OBJS = \
platform/src/vl53l5_platform.o \
platform/src/vl53l5_platform_init.o \
platform/src/vl53l5_platform_maths.o \
platform/src/vl53l5_platform_log.o
BARE_DRIVER_OBJS = \
bare_driver/api/src/vl53l5_api_core.o \
bare_driver/api/src/vl53l5_api_power.o \
bare_driver/api/src/vl53l5_api_ranging.o \
bare_driver/api/src/vl53l5_api_range_decode.o \
bare_driver/api/src/vl53l5_api_calibration_decode.o\
bare_driver/dci/src/vl53l5_core_decode.o\
bare_driver/dci/src/vl53l5_dci_core.o \
bare_driver/dci/src/vl53l5_dci_decode.o \
bare_driver/dci/src/vl53l5_dci_helpers.o \
bare_driver/dci/src/vl53l5_dci_ranging.o \
bare_driver/dci/src/vl53l5_dci_utils.o \
bare_driver/dci/src/vl53l5_decode_switch.o\
bare_driver/dci/src/vl53l5_calibration_decode.o \
bare_driver/dci/src/page_map_switch.o \
bare_driver/common/src/vl53l5_checks.o \
bare_driver/common/src/vl53l5_commands.o \
bare_driver/common/src/vl53l5_error_handler.o \
bare_driver/common/src/vl53l5_load_firmware.o \
bare_driver/common/src/vl53l5_register_utils.o \
bare_driver/common/src/vl53l5_rom_boot.o
ifeq "$(BUILD_TYPE)" "DEBUG"
$(warning BUILD_TYPE=$(BUILD_TYPE))
ccflags-y += -DDEBUG -DVL53L5_LOG_ENABLE
endif
ifeq "$(BUILD_TYPE)" "RELEASE"
$(warning BUILD_TYPE=$(BUILD_TYPE))
endif
ifeq "$(RANGE_SERVICING)" "INTERRUPT"
$(warning RANGE_SERVICING=$(RANGE_SERVICING))
ccflags-y += -DVL53L8_INTERRUPT
KERNEL_DRIVER_OBJS += src/vl53l8_k_interrupt.o
endif
ifeq "$(LOG_ENABLE)" "TRUE"
$(warning LOG_ENABLE=$(LOG_ENABLE))
ccflags-y += -DVL53L8_KERNEL_LOG
endif
ifeq "$(TCDM_DUMP_ENABLE)" "TRUE"
$(warning TCDM_DUMP_ENABLE=$(TCDM_DUMP_ENABLE))
ccflags-y += -DVL53L5_TCDM_DUMP
BARE_DRIVER_OBJS += bare_driver/common/src/vl53l5_tcdm_dump.o
endif
ifeq "$(LEGACY_CODE)" "TRUE"
$(warning LEGACY_CODE=$(LEGACY_CODE))
ccflags-y += -DSTM_VL53L8_SUPPORT_LEGACY_CODE
else
ccflags-y += -DSS_SUPPORT_SEC_CODE
endif
ifeq "$(FORCE_ERROR)" "TRUE"
$(warning FORCE_ERROR=$(FORCE_ERROR))
ccflags-y += -DVL53L8_FORCE_ERROR_COMMAND
endif
ifeq "$(RAD2PERP_CAL_ENABLE)" "TRUE"
$(warning RAD2PERP_CAL_ENABLE=$(RAD2PERP_CAL_ENABLE))
ccflags-y += -DVL53L8_RAD2PERP_CAL
endif
ifeq "$(LEGACY_RESULTS_DATA)" "TRUE"
$(warning LEGACY_RESULTS_DATA=$(LEGACY_RESULTS_DATA))
BARE_DRIVER_OBJS += \
bare_driver/dci/src/vl53l5_results_decode.o
ccflags-y += -I$(srctree)/drivers/sensors/vl53l8/bare_driver/results/inc
ccflags-y += -DVL53L5_RESULTS_DATA_ENABLED
endif
ifeq "$(EXTENDED_RESULTS_DATA)" "TRUE"
$(warning EXTENDED_RESULTS_DATA=$(EXTENDED_RESULTS_DATA))
BARE_DRIVER_OBJS += \
bare_driver/patch/src/vl53l5_patch_api_core.o \
bare_driver/patch/src/vl53l5_patch_core_decode.o \
bare_driver/patch/src/vl53l5_patch_decode_switch.o \
bare_driver/patch/src/vl53l5_tcpm_patch_0_core_decode.o \
bare_driver/patch/src/vl53l5_tcpm_patch_0_decode_switch.o \
bare_driver/patch/src/vl53l5_tcpm_patch_0_results_decode.o \
bare_driver/patch/src/vl53l5_tcpm_patch_1_core_decode.o \
bare_driver/patch/src/vl53l5_tcpm_patch_1_decode_switch.o
ccflags-y += -I$(srctree)/drivers/sensors/vl53l8/bare_driver/patch/inc
ccflags-y += -DVL53L5_PATCH_DATA_ENABLED
endif
obj-$(CONFIG_STMVL53L8) += $(MODULE).o
# # Kernel level objects
$(MODULE)-objs += $(KERNEL_DRIVER_OBJS)
$(MODULE)-objs += $(BARE_DRIVER_OBJS)
$(MODULE)-objs += $(PLATFORM_OBJS)
all:
make -C $(KDIR) M=$(PWD) modules
clean:
make -C $(KDIR) M=$(PWD) clean
# Insert the module using insmod with the configured module parameters
insert:
sudo insmod $(MODULE).ko
dtb:
-sudo dtoverlay -r $(MODULE)
-sudo rm -f /boot/overlays/$(MODULE).dtbo
dtc -@ -I dts -O dtb -o $(MODULE)_spi.dtbo $(MODULE)_spi.dts
sudo cp $(MODULE)_spi.dtbo /boot/overlays/$(MODULE).dtbo
sudo dtoverlay $(MODULE)
dtb_gpio:
-sudo dtoverlay -r $(MODULE)
-sudo rm -f /boot/overlays/$(MODULE).dtbo
dtc -@ -I dts -O dtb -o $(MODULE)_spi_gpio.dtbo $(MODULE)_spi_gpio.dts
sudo cp $(MODULE)_spi_gpio.dtbo /boot/overlays/$(MODULE).dtbo
sudo dtoverlay $(MODULE)
clean_dtb:
sudo rm -f $(MODULE).dtbo
sudo rm -f /boot/overlays/$(MODULE).dtbo
sudo dtoverlay -r $(MODULE)
# Remove the module using rmmod
remove:
-sudo rmmod $(MODULE)

View File

@@ -0,0 +1,84 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 VL53L5_API_CALIBRATION_DECODE_H_
#define VL53L5_API_CALIBRATION_DECODE_H_
#include "vl53l5_platform_user_data.h"
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef VL53L5_CALIBRATION_DECODE_ON
int32_t vl53l5_decode_calibration_data(
struct vl53l5_dev_handle_t *p_dev,
struct vl53l5_calibration_data_t *p_data,
uint8_t *buffer,
uint32_t data_size);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,170 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 VL53L5_API_CORE_H_
#define VL53L5_API_CORE_H_
#include "vl53l5_platform_user_data.h"
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C"
{
#endif
#define VL53L5_ASSIGN_FW_BUFF(p_dev, fw_buff_ptr, count) \
do {\
(p_dev)->host_dev.p_fw_buff = (fw_buff_ptr);\
(p_dev)->host_dev.fw_buff_count = (count);\
} while (0)
#define VL53L5_ASSIGN_COMMS_BUFF(p_dev, comms_buff_ptr, max_count) \
do {\
(p_dev)->host_dev.p_comms_buff = (comms_buff_ptr);\
(p_dev)->host_dev.comms_buff_max_count = (max_count);\
} while (0)
#define VL53L5_FGC_STRING_LENGTH 19
struct vl53l5_version_t {
struct {
uint16_t ver_major;
uint16_t ver_minor;
uint16_t ver_build;
uint16_t ver_revision;
} driver;
struct {
uint16_t ver_major;
uint16_t ver_minor;
uint16_t ver_build;
uint16_t ver_revision;
} firmware;
};
struct vl53l5_module_info_t {
uint8_t fgc[VL53L5_FGC_STRING_LENGTH];
uint32_t module_id_lo;
uint32_t module_id_hi;
};
struct vl53l5_ranging_mode_flags_t {
uint8_t timed_interrupt : 1;
uint8_t timed_retention : 1;
};
int32_t vl53l5_init(struct vl53l5_dev_handle_t *p_dev);
int32_t vl53l5_term(struct vl53l5_dev_handle_t *p_dev);
int32_t vl53l5_get_version(
struct vl53l5_dev_handle_t *p_dev,
struct vl53l5_version_t *p_version);
int32_t vl53l5_get_module_info(
struct vl53l5_dev_handle_t *p_dev,
struct vl53l5_module_info_t *p_module_info);
int32_t vl53l5_read_device_error(
struct vl53l5_dev_handle_t *p_dev,
int32_t latest_status);
int32_t vl53l5_start(
struct vl53l5_dev_handle_t *p_dev,
struct vl53l5_ranging_mode_flags_t *p_flags);
int32_t vl53l5_stop(
struct vl53l5_dev_handle_t *p_dev,
struct vl53l5_ranging_mode_flags_t *p_flags);
int32_t vl53l5_get_device_parameters(
struct vl53l5_dev_handle_t *p_dev,
uint32_t *p_block_headers,
uint32_t num_block_headers);
int32_t vl53l5_set_device_parameters(
struct vl53l5_dev_handle_t *p_dev,
uint8_t *p_buff,
uint32_t buff_count);
int32_t vl53l5_set_ranging_rate_hz(
struct vl53l5_dev_handle_t *p_dev,
uint32_t ranging_rate_hz);
int32_t vl53l5_set_integration_time_us(
struct vl53l5_dev_handle_t *p_dev,
uint32_t integration_time_us);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,79 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 VL53L5_API_POWER_H_
#define VL53L5_API_POWER_H_
#include "vl53l5_platform_user_data.h"
#include "vl53l5_power_states.h"
#ifdef __cplusplus
extern "C"
{
#endif
int32_t vl53l5_set_power_mode(
struct vl53l5_dev_handle_t *p_dev,
enum vl53l5_power_states power_mode);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,98 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 VL53L5_API_RANGE_DECODE_H_
#define VL53L5_API_RANGE_DECODE_H_
#include "vl53l5_platform_user_data.h"
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef SS_SUPPORT_SEC_CODE
struct vl53l8_update_data_t {
int pass_fail;
int cmd;
};
struct vl53l8_cal_data_t {
char pcal_data[1800];
int size;
int cmd;
};
struct vl53l8_file_list_t {
int file_list;
};
#endif // SS_SUPPORT_SEC_CODE2
#if defined(VL53L5_RESULTS_DATA_ENABLED) || defined(VL53L5_PATCH_DATA_ENABLED)
int32_t vl53l5_decode_range_data(
struct vl53l5_dev_handle_t *p_dev,
struct vl53l5_range_data_t *p_data);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,79 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 VL53L5_API_RANGING_H_
#define VL53L5_API_RANGING_H_
#include "vl53l5_platform_user_data.h"
#ifdef __cplusplus
extern "C"
{
#endif
int32_t vl53l5_get_range_data(
struct vl53l5_dev_handle_t *p_dev);
int32_t vl53l5_check_data_ready(struct vl53l5_dev_handle_t *p_dev);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,117 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*******************************************************************************/
#include "vl53l5_api_calibration_decode.h"
#ifdef VL53L5_CALIBRATION_DECODE_ON
#include "vl53l5_globals.h"
#include "vl53l5_dci_decode.h"
#include "vl53l5_dci_utils.h"
#include "vl53l5_error_codes.h"
#include "vl53l5_platform_log.h"
#define trace_print(level, ...) \
_LOG_TRACE_PRINT(VL53L5_TRACE_MODULE_API, \
level, VL53L5_TRACE_FUNCTION_ALL, ##__VA_ARGS__)
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START(VL53L5_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_API, status, ##__VA_ARGS__)
#define LOG_FUNCTION_END_FLUSH(status, ...) \
do { \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_API, status, ##__VA_ARGS__);\
_FLUSH_TRACE_TO_OUTPUT();\
} while (0)
int32_t vl53l5_decode_calibration_data(
struct vl53l5_dev_handle_t *p_dev,
struct vl53l5_calibration_data_t *p_data,
uint8_t *buffer,
uint32_t data_size)
{
int32_t status = VL53L5_ERROR_NONE;
LOG_FUNCTION_START("");
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (VL53L5_ISNULL(p_data)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
status = VL53L5_GET_VERSION_CHECK_STATUS(p_dev);
if (status < STATUS_OK)
goto exit;
p_dev->host_dev.pcalibration_dev = &p_data->core;
status = vl53l5_dci_decode_data(p_dev, buffer, data_size);
exit:
if (!VL53L5_ISNULL(p_dev))
p_dev->host_dev.pcalibration_dev = NULL;
LOG_FUNCTION_END_FLUSH(status);
return status;
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,371 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*******************************************************************************/
#include "vl53l5_api_power.h"
#include "vl53l5_checks.h"
#include "vl53l5_register_utils.h"
#include "vl53l5_load_firmware.h"
#include "vl53l5_globals.h"
#include "vl53l5_trans.h"
#include "vl53l5_dci_core.h"
#include "vl53l5_dci_utils.h"
#include "vl53l5_platform.h"
#include "vl53l5_platform_log.h"
#include "vl53l5_platform_user_config.h"
#include "vl53l5_error_codes.h"
#define trace_print(level, ...) \
_LOG_TRACE_PRINT(VL53L5_TRACE_MODULE_API, \
level, VL53L5_TRACE_FUNCTION_ALL, ##__VA_ARGS__)
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START(VL53L5_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_API, status, ##__VA_ARGS__)
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
_LOG_FUNCTION_END_FMT(VL53L5_TRACE_MODULE_API, status, fmt,\
##__VA_ARGS__)
#define LOG_FUNCTION_END_FLUSH(status, ...) \
do { \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_API, status, ##__VA_ARGS__);\
_FLUSH_TRACE_TO_OUTPUT();\
} while (0)
#define GPIO_LOW 0
#define GPIO_HIGH 1
#define REGULATOR_DISABLE 0
#define REGULATOR_ENABLE 1
#define DEFAULT_PAGE 2
#define GO2_PAGE 0
static int32_t _set_power_to_hp_idle(struct vl53l5_dev_handle_t *p_dev);
static int32_t _set_power_to_lp_idle_comms(struct vl53l5_dev_handle_t *p_dev);
static int32_t _set_power_to_ulp_idle(struct vl53l5_dev_handle_t *p_dev);
static int32_t _go_to_hp_idle(struct vl53l5_dev_handle_t *p_dev);
static int32_t _go_to_lp_idle_comms(struct vl53l5_dev_handle_t *p_dev);
static int32_t _go_to_ulp_idle(struct vl53l5_dev_handle_t *p_dev);
int32_t vl53l5_set_power_mode(
struct vl53l5_dev_handle_t *p_dev,
enum vl53l5_power_states power_mode)
{
int32_t status = STATUS_OK;
LOG_FUNCTION_START("");
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if ((VL53L5_CHECK_POWER_STATE_OFF(p_dev) &&
p_dev->host_dev.device_booted == false) ||
VL53L5_CHECK_POWER_STATE_RANGING(p_dev)) {
status = VL53L5_ERROR_POWER_STATE;
goto exit;
}
switch (power_mode) {
case VL53L5_POWER_STATE_HP_IDLE:
if (p_dev->host_dev.power_state
!= VL53L5_POWER_STATE_HP_IDLE)
status = _set_power_to_hp_idle(p_dev);
break;
case VL53L5_POWER_STATE_LP_IDLE_COMMS:
if (p_dev->host_dev.power_state
!= VL53L5_POWER_STATE_LP_IDLE_COMMS)
status = _set_power_to_lp_idle_comms(p_dev);
break;
case VL53L5_POWER_STATE_ULP_IDLE:
if (p_dev->host_dev.power_state
!= VL53L5_POWER_STATE_ULP_IDLE)
status = _set_power_to_ulp_idle(p_dev);
break;
case VL53L5_POWER_STATE_OFF:
case VL53L5_POWER_STATE_RANGING:
default:
status = VL53L5_ERROR_POWER_STATE;
break;
}
exit:
LOG_FUNCTION_END_FLUSH(status);
return status;
}
static int32_t _go_to_hp_idle(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
if (VL53L5_CHECK_POWER_STATE_ULP_IDLE(p_dev)) {
status = vl53l5_set_manual_xshut_state(p_dev, GPIO_HIGH);
if (status < STATUS_OK)
goto exit;
status = vl53l5_set_regulators(p_dev, REGULATOR_ENABLE,
REGULATOR_ENABLE);
if (status < STATUS_OK)
goto exit;
} else if (VL53L5_CHECK_POWER_STATE_LP_IDLE_COMMS(p_dev)) {
status = vl53l5_set_manual_xshut_state(p_dev, GPIO_HIGH);
if (status < STATUS_OK)
goto exit;
} else if (VL53L5_CHECK_POWER_STATE_OFF(p_dev) &&
p_dev->host_dev.device_booted == true) {
status = vl53l5_set_manual_xshut_state(p_dev, GPIO_HIGH);
if (status < STATUS_OK)
goto exit;
} else {
status = VL53L5_ERROR_POWER_STATE;
goto exit;
}
status = vl53l5_wait_mcu_boot(p_dev, VL53L5_BOOT_STATE_HIGH,
0, VL53L5_HP_IDLE_WAIT_DELAY);
if (status < STATUS_OK)
goto exit;
p_dev->host_dev.power_state = VL53L5_POWER_STATE_HP_IDLE;
exit:
return status;
}
static int32_t _go_to_lp_idle_comms(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
status = vl53l5_set_manual_xshut_state(p_dev, GPIO_LOW);
if (status < STATUS_OK)
goto exit;
status = vl53l5_wait_mcu_boot(p_dev, VL53L5_BOOT_STATE_LOW,
0, VL53L5_LP_IDLE_WAIT_DELAY);
if (status < STATUS_OK)
goto exit;
p_dev->host_dev.power_state = VL53L5_POWER_STATE_LP_IDLE_COMMS;
exit:
return status;
}
static int32_t _go_to_ulp_idle(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
status = _go_to_lp_idle_comms(p_dev);
if (status < STATUS_OK)
goto exit;
status = vl53l5_set_regulators(p_dev, REGULATOR_DISABLE,
REGULATOR_DISABLE);
if (status < STATUS_OK)
goto exit;
p_dev->host_dev.version_match.map_version_match = false;
p_dev->host_dev.power_state = VL53L5_POWER_STATE_ULP_IDLE;
exit:
return status;
}
static int32_t _set_power_to_hp_idle(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
enum vl53l5_power_states current_state = p_dev->host_dev.power_state;
bool comms_on = true;
if (VL53L5_CHECK_POWER_STATE_HP_IDLE(p_dev))
goto exit;
if (comms_on) {
status = vl53l5_set_page(p_dev, GO2_PAGE);
if (status < STATUS_OK)
goto exit_page_changed;
}
status = _go_to_hp_idle(p_dev);
exit_page_changed:
if (status != STATUS_OK) {
(void)vl53l5_set_page(p_dev, DEFAULT_PAGE);
goto exit;
} else {
status = vl53l5_set_page(p_dev, DEFAULT_PAGE);
if (status != STATUS_OK)
goto exit;
}
if (current_state == VL53L5_POWER_STATE_ULP_IDLE) {
if (!VL53L5_FW_BUFF_ISNULL(p_dev)) {
status = vl53l5_load_firmware(p_dev);
if (status != STATUS_OK)
goto exit;
}
}
if (current_state == VL53L5_POWER_STATE_ULP_IDLE ||
p_dev->host_dev.device_booted == true) {
status = vl53l5_check_map_version(p_dev);
if (status != STATUS_OK)
goto exit;
}
exit:
return status;
}
static int32_t _set_power_to_lp_idle_comms(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
enum vl53l5_power_states current_state = p_dev->host_dev.power_state;
bool comms_on = true;
if (VL53L5_CHECK_POWER_STATE_LP_IDLE_COMMS(p_dev))
goto exit;
if (current_state == VL53L5_POWER_STATE_ULP_IDLE) {
status = _set_power_to_hp_idle(p_dev);
if (status < STATUS_OK)
goto exit;
}
if (comms_on) {
status = vl53l5_set_page(p_dev, GO2_PAGE);
if (status < STATUS_OK)
goto exit;
}
if (!VL53L5_CHECK_POWER_STATE_HP_IDLE(p_dev)) {
status = _go_to_hp_idle(p_dev);
if (status < STATUS_OK)
goto exit_page_changed;
}
status = _go_to_lp_idle_comms(p_dev);
exit_page_changed:
if (status < STATUS_OK)
(void)vl53l5_set_page(p_dev, DEFAULT_PAGE);
else
status = vl53l5_set_page(p_dev, DEFAULT_PAGE);
exit:
return status;
}
static int32_t _set_power_to_ulp_idle(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = VL53L5_ERROR_NONE;
bool comms_on = true;
if (VL53L5_CHECK_POWER_STATE_ULP_IDLE(p_dev))
goto exit;
if (comms_on) {
status = vl53l5_set_page(p_dev, GO2_PAGE);
if (status < STATUS_OK)
goto exit;
}
if (!VL53L5_CHECK_POWER_STATE_HP_IDLE(p_dev)) {
status = _go_to_hp_idle(p_dev);
if (status < STATUS_OK)
goto exit_page_changed;
}
status = _go_to_ulp_idle(p_dev);
if (status < STATUS_OK)
goto exit_page_changed;
exit_page_changed:
if (status < STATUS_OK)
(void)vl53l5_set_page(p_dev, DEFAULT_PAGE);
else
status = vl53l5_set_page(p_dev, DEFAULT_PAGE);
exit:
return status;
}

View File

@@ -0,0 +1,132 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*******************************************************************************/
#include "vl53l5_api_range_decode.h"
#include "vl53l5_globals.h"
#include "vl53l5_dci_decode.h"
#include "vl53l5_dci_utils.h"
#include "vl53l5_error_codes.h"
#include "vl53l5_platform_log.h"
#define trace_print(level, ...) \
_LOG_TRACE_PRINT(VL53L5_TRACE_MODULE_API, \
level, VL53L5_TRACE_FUNCTION_ALL, ##__VA_ARGS__)
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START(VL53L5_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_API, status, ##__VA_ARGS__)
#define LOG_FUNCTION_END_FLUSH(status, ...) \
do { \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_API, status, ##__VA_ARGS__);\
_FLUSH_TRACE_TO_OUTPUT();\
} while (0)
#if defined(VL53L5_RESULTS_DATA_ENABLED) || defined(VL53L5_PATCH_DATA_ENABLED)
int32_t vl53l5_decode_range_data(
struct vl53l5_dev_handle_t *p_dev,
struct vl53l5_range_data_t *p_data)
{
int32_t status = VL53L5_ERROR_NONE;
LOG_FUNCTION_START("");
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (VL53L5_ISNULL(p_data)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (VL53L5_COMMS_BUFF_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
status = VL53L5_GET_VERSION_CHECK_STATUS(p_dev);
if (status < STATUS_OK)
goto exit;
#ifdef VL53L5_RESULTS_DATA_ENABLED
p_dev->host_dev.presults_dev = &p_data->core;
#endif
#ifdef VL53L5_PATCH_DATA_ENABLED
p_dev->host_dev.ptcpm_patch_0_results_dev = &p_data->tcpm_0_patch;
#endif
status = vl53l5_dci_decode_range_data(p_dev);
exit:
#ifdef VL53L5_RESULTS_DATA_ENABLED
if (!VL53L5_ISNULL(p_dev))
p_dev->host_dev.presults_dev = NULL;
#endif
#ifdef VL53L5_PATCH_DATA_ENABLED
if (!VL53L5_ISNULL(p_dev))
p_dev->host_dev.ptcpm_patch_0_results_dev = NULL;
#endif
LOG_FUNCTION_END_FLUSH(status);
return status;
}
#endif

View File

@@ -0,0 +1,162 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*******************************************************************************/
#include "vl53l5_api_ranging.h"
#include "vl53l5_globals.h"
#include "vl53l5_dci_core.h"
#include "vl53l5_dci_ranging.h"
#include "vl53l5_driver_dev_path.h"
#include "vl53l5_dci_utils.h"
#include "vl53l5_error_codes.h"
#include "vl53l5_platform_log.h"
#define trace_print(level, ...) \
_LOG_TRACE_PRINT(VL53L5_TRACE_MODULE_API, \
level, VL53L5_TRACE_FUNCTION_ALL, ##__VA_ARGS__)
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START(VL53L5_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_API, status, ##__VA_ARGS__)
#define LOG_FUNCTION_END_FLUSH(status, ...) \
do { \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_API, status, ##__VA_ARGS__);\
_FLUSH_TRACE_TO_OUTPUT();\
} while (0)
int32_t vl53l5_check_data_ready(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
uint8_t stored_stream_id = 0;
LOG_FUNCTION_START("");
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (VL53L5_COMMS_BUFF_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
status = VL53L5_GET_VERSION_CHECK_STATUS(p_dev);
if (status < STATUS_OK)
goto exit;
stored_stream_id = VL53L5_UI_DEV_STREAM(p_dev);
status = vl53l5_dci_get_device_info(p_dev);
if (status < STATUS_OK)
goto exit_reset_stream_id;
status = vl53l5_dci_check_device_info(p_dev,
stored_stream_id,
true,
true);
if (status == VL53L5_TOO_HIGH_AMBIENT_WARNING)
goto exit;
exit_reset_stream_id:
VL53L5_UI_DEV_STREAM(p_dev) = stored_stream_id;
exit:
switch (status) {
case VL53L5_NO_NEW_RANGE_DATA_ERROR:
case VL53L5_TOO_HIGH_AMBIENT_WARNING:
case STATUS_OK:
LOG_FUNCTION_END(status);
break;
default:
LOG_FUNCTION_END_FLUSH(status);
break;
}
return status;
}
int32_t vl53l5_get_range_data(
struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = VL53L5_ERROR_NONE;
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (VL53L5_COMMS_BUFF_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
status = VL53L5_GET_VERSION_CHECK_STATUS(p_dev);
if (status < STATUS_OK)
goto exit;
status = vl53l5_dci_read_range(p_dev);
exit:
LOG_FUNCTION_END_FLUSH(status);
return status;
}

View File

@@ -0,0 +1,79 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 _VL53L5_CHECKS_H_
#define _VL53L5_CHECKS_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "vl53l5_platform_user_data.h"
int32_t vl53l5_check_map_version(struct vl53l5_dev_handle_t *p_dev);
int32_t vl53l5_test_map_version(struct vl53l5_dev_handle_t *p_dev,
uint8_t *p_buffer);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,83 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 _VL53L5_COMMANDS_H_
#define _VL53L5_COMMANDS_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "vl53l5_platform_user_data.h"
int32_t vl53l5_encode_block_headers(
struct vl53l5_dev_handle_t *p_dev,
uint32_t *p_block_headers,
uint32_t num_block_headers,
bool encode_version);
int32_t vl53l5_execute_command(
struct vl53l5_dev_handle_t *p_dev,
uint8_t command_id);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,162 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 _VL53L5_DEVICE_H_
#define _VL53L5_DEVICE_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "vl53l5_globals.h"
#include "vl53l5_types.h"
#include "dci_ui_structs.h"
#include "vl53l5_power_states.h"
#include "vl53l5_core_map.h"
#include "vl53l5_patch_structs.h"
#ifdef VL53L5_CALIBRATION_DECODE_ON
#include "vl53l5_calibration_map.h"
#endif
#ifdef VL53L5_PATCH_DATA_ENABLED
#include "vl53l5_patch_core_map.h"
#include "vl53l5_tcpm_patch_0_core_map.h"
#include "vl53l5_tcpm_patch_1_core_map.h"
#include "vl53l5_tcpm_patch_0_results_map.h"
#endif
#ifdef VL53L5_RESULTS_DATA_ENABLED
#include "vl53l5_results_map.h"
#endif
struct vl53l5_dev_handle_internal_t {
uint8_t *p_fw_buff;
uint32_t fw_buff_count;
uint8_t *p_comms_buff;
uint32_t comms_buff_max_count;
uint32_t comms_buff_count;
uint32_t latest_trans_id;
struct dci_ui__cmd_info_t cmd_status;
struct vl53l5_core_dev_t core_dev;
#ifdef VL53L5_RESULTS_DATA_ENABLED
struct vl53l5_range_results_t *presults_dev;
#endif
#ifdef VL53L5_CALIBRATION_DECODE_ON
struct vl53l5_calibration_dev_t *pcalibration_dev;
#endif
#ifdef VL53L5_PATCH_DATA_ENABLED
struct vl53l5_patch_core_dev_t *ppatch_core_dev;
#endif
#ifdef VL53L5_PATCH_DATA_ENABLED
struct vl53l5_tcpm_patch_0_core_dev_t *ptcpm_patch_0_core_dev;
struct vl53l5_tcpm_patch_1_core_dev_t *ptcpm_patch_1_core_dev;
struct vl53l5_tcpm_patch_0_results_dev_t *ptcpm_patch_0_results_dev;
#endif
struct dci_ui__dev_info_t ui_dev_info;
bool mcu_warnings_on;
enum vl53l5_power_states power_state;
struct {
bool map_version_match;
} version_match;
struct {
uint16_t dev_info_start_addr;
uint16_t data_start_offset_bytes;
uint16_t data_size_bytes;
} range_data_addr;
bool device_booted;
struct vl53l5_patch_data_t patch_data;
uint8_t device_id;
uint8_t revision_id;
bool firmware_load;
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,87 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 _VL53L5_DRIVER_DEV_PATH_H_
#define _VL53L5_DRIVER_DEV_PATH_H_
#ifdef __cplusplus
extern "C"
{
#endif
#define VL53L5_GO2_STATUS_0(p_dev)\
((p_dev)->host_dev.ui_dev_info.dev_info__go2_status_0)
#define VL53L5_GO2_STATUS_1(p_dev)\
((p_dev)->host_dev.ui_dev_info.dev_info__go2_status_1)
#define VL53L5_UI_DEV_STREAM(p_dev)\
((p_dev)->host_dev.ui_dev_info.dev_info__ui_stream_count)
#define VL53L5_UI_DEV_STATUS(p_dev)\
((p_dev)->host_dev.ui_dev_info.dev_info__device_status)
#define VL53L5_CMD_INFO(p_dev)\
((p_dev)->host_dev.cmd_status.cmd_info)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,239 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 _VL53L5_ERROR_CODES_H_
#define _VL53L5_ERROR_CODES_H_
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_Error int32_t
#define VL53L5_ERROR_NONE ((VL53L5_Error) 0)
#define VL53L5_FAILED_TO_CREATE_CALIB_FILE ((VL53L5_Error) - 2)
#define VL53L5_ERROR_INVALID_PARAMS ((VL53L5_Error) - 4)
#define VL53L5_BUFFER_LARGER_THAN_EXPECTED_DATA ((VL53L5_Error) - 5)
#define VL53L5_INVALID_IDX_ENCODE_CMD_ERROR ((VL53L5_Error) - 6)
#define VL53L5_ERROR_TIME_OUT ((VL53L5_Error) - 7)
#define VL53L5_CAL_TYPE_UNRECOGNISED ((VL53L5_Error) - 8)
#define VL53L5_INVALID_IDX_DECODE_CMD_ERROR ((VL53L5_Error) - 9)
#define VL53L5_INVALID_PAGE_ERROR ((VL53L5_Error) - 10)
#define VL53L5_DATA_BUFFER_MISMATCH ((VL53L5_Error) - 11)
#define VL53L5_ERROR_NULL_DEV_PTR ((VL53L5_Error) - 12)
#define VL53L5_ERROR_CONTROL_INTERFACE ((VL53L5_Error) - 13)
#define VL53L5_DATA_EXCEEDS_CMD_BUFFER_SIZE ((VL53L5_Error) - 14)
#define VL53L5_ERROR_DIVISION_BY_ZERO ((VL53L5_Error) - 15)
#define VL53L5_ERROR_INVALID_SET_COMMAND ((VL53L5_Error) - 16)
#define VL53L5_ERROR_CALIBRATION_REQUEST_INVALID ((VL53L5_Error) - 17)
#define VL53L5_ERROR_IDX_NOT_PRESENT ((VL53L5_Error) - 18)
#define VL53L5_ERROR_INVALID_BH_ENCODE ((VL53L5_Error) - 21)
#define VL53L5_ERROR_INVALID_BH_SIZE ((VL53L5_Error) - 22)
#define VL53L5_ERROR_NULL_CALIBRATION_DEV_PTR ((VL53L5_Error) - 23)
#define VL53L5_GPIO_UNDEFINED ((VL53L5_Error) - 24)
#define VL53L5_DEVICE_STATE_INVALID ((VL53L5_Error) - 25)
#define VL53L5_ERROR_NULL_RESULTS_DEV_PTR ((VL53L5_Error) - 26)
#define VL53L5_ERROR_COMPARE_FIRMWARE_FAILURE ((VL53L5_Error) - 40)
#define VL53L5_ERROR_NOT_IMPLEMENTED ((VL53L5_Error) - 41)
#define VL53L5_ERROR_POWER_STATE ((VL53L5_Error) - 42)
#define VL53L5_PLL_LOCK_FAIL ((VL53L5_Error) - 45)
#define VL53L5_LS_WATCHDOG_FAIL ((VL53L5_Error) - 46)
#define VL53L5_FILE_NOT_EXIST ((VL53L5_Error) - 49)
#define VL53L5_ERROR_BOOT_COMPLETE_TIMEOUT ((VL53L5_Error) - 51)
#define VL53L5_ERROR_MCU_IDLE_TIMEOUT ((VL53L5_Error) - 52)
#define VL53L5_ERROR_RANGE_DATA_READY_TIMEOUT ((VL53L5_Error) - 53)
#define VL53L5_ERROR_CMD_STATUS_TIMEOUT ((VL53L5_Error) - 54)
#define VL53L5_ERROR_UI_FW_STATUS_TIMEOUT ((VL53L5_Error) - 55)
#define VL53L5_ERROR_UI_RAM_WATCHDOG_TIMEOUT ((VL53L5_Error) - 56)
#define VL53L5_ERROR_FW_BUFF_NOT_FOUND ((VL53L5_Error) - 57)
#define VL53L5_ERROR_MCU_ERROR_AT_ROM_BOOT ((VL53L5_Error) - 60)
#define VL53L5_ERROR_FALSE_MCU_ERROR_AT_ROM_BOOT ((VL53L5_Error) - 61)
#define VL53L5_ERROR_MCU_ERROR_AT_RAM_BOOT ((VL53L5_Error) - 62)
#define VL53L5_ERROR_FALSE_MCU_ERROR_AT_RAM_BOOT ((VL53L5_Error) - 63)
#define VL53L5_ERROR_MCU_ERROR_POWER_STATE ((VL53L5_Error) - 64)
#define VL53L5_ERROR_FALSE_MCU_ERROR_POWER_STATE ((VL53L5_Error) - 65)
#define VL53L5_DEV_INFO_MCU_ERROR ((VL53L5_Error) - 66)
#define VL53L5_FALSE_DEV_INFO_MCU_ERROR ((VL53L5_Error) - 67)
#define VL53L5_ERROR_FALSE_MCU_ERROR_IN_BANK_CHECK ((VL53L5_Error) - 68)
#define VL53L5_ERROR_PADDING_NOT_REQUIRED ((VL53L5_Error) - 70)
#define VL53L5_BYTE_SWAP_FAIL ((VL53L5_Error) - 71)
#define VL53L5_IDX_MISSING_FROM_RETURN_PACKET ((VL53L5_Error) - 72)
#define VL53L5_VERSION_IDX_NOT_PRESENT ((VL53L5_Error) - 73)
#define VL53L5_RANGE_DATA_ADDR_NOT_PRESENT ((VL53L5_Error) - 74)
#define VL53L5_ENCODE_CMD_ERROR ((VL53L5_Error) - 75)
#define VL53L5_DECODE_CMD_ERROR ((VL53L5_Error) - 76)
#define VL53L5_CONFIG_ERROR_INVALID_VERSION ((VL53L5_Error) - 77)
#define VL53L5_DCI_VERSION_ERROR ((VL53L5_Error) - 78)
#define VL53L5_DCI_CMD_STATUS_ERROR ((VL53L5_Error) - 79)
#define VL53L5_INVALID_CMD_ID ((VL53L5_Error) - 80)
#define VL53L5_DCI_END_BLOCK_ERROR ((VL53L5_Error) - 81)
#define VL53L5_INVALID_GROUP_INDEX ((VL53L5_Error) - 82)
#define VL53L5_BOOT_TIMEOUT_BEFORE_FW_DOWNLOAD ((VL53L5_Error) - 83)
#define VL53L5_BOOT_TIMEOUT_AFTER_FW_DOWNLOAD ((VL53L5_Error) - 84)
#define VL53L5_BOOT_TIMEOUT_MCU_IDLE ((VL53L5_Error) - 85)
#define VL53L5_DCI_RANGE_INTEGRITY_ERROR ((VL53L5_Error) - 86)
#define VL53L5_ERROR_NVM_COPY ((VL53L5_Error) - 87)
#define VL53L5_NO_NEW_RANGE_DATA_ERROR ((VL53L5_Error) - 89)
#define VL53L5_DATA_BUFFER_TOO_LARGE ((VL53L5_Error) - 90)
#define VL53L5_GET_PARMS_ERROR_INVALID_IDX ((VL53L5_Error) - 91)
#define VL53L5_MAX_BUFFER_SIZE_REACHED ((VL53L5_Error) - 92)
#define VL53L5_COMMS_ERROR ((VL53L5_Error) - 93)
#define VL53L5_SPI_COMMS_ERROR ((VL53L5_Error) - 94)
#define VL53L5_I2C_COMMS_ERROR ((VL53L5_Error) - 95)
#define VL53L5_DATA_SIZE_MISMATCH ((VL53L5_Error) - 96)
#define VL53L5_ERROR_GPIO_SET_FAIL ((VL53L5_Error) - 97)
#define VL53L5_READ_RANGE_ERROR_CALIB_FILE_UNSPECIFIED ((VL53L5_Error) - 98)
#define VL53L5_VER_CHECK_NOT_PERFORMED ((VL53L5_Error) - 99)
#define VL53L5_UNKNOWN_SILICON_REVISION ((VL53L5_Error) - 100)
#define VL53L5_TOO_HIGH_AMBIENT_WARNING ((VL53L5_Error) - 58)
#define VL53L5_ERROR_MCU_ERROR_WAIT_STATE ((VL53L5_Error) - 69)
#define VL53L5_ERROR_MCU_ERROR_HW_STATE ((VL53L5_Error) - 59)
#define VL53L5_ERROR_MCU_NVM_NOT_PROGRAMMED ((VL53L5_Error) - 50)
#define VL53L5_ERROR_INIT_FW_CHECKSUM ((VL53L5_Error) - 48)
#define VL53L5_ERROR_PATCH_SIZE_MISMATCH ((VL53L5_Error) - 30)
#define VL53L5_INVALID_SILICON_REVISION ((VL53L5_Error) - 31)
#define VL53L5_ERROR_INVALID_PATCH_BOOT_FLAG ((VL53L5_Error) - 32)
#define VL53L5_ERROR_INVALID_RETURN_DATA_SIZE ((VL53L5_Error) - 19)
#define VL53L5_ERROR_INVALID_VALUE ((VL53L5_Error) - 20)
#define VL53L5_NEW_RANGE_DATA_PRESENT ((VL53L5_Error) 1)
#define VL53L5_ERROR_UNDEFINED ((VL53L5_Error) - 999)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,94 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 VL53L5_ERROR_HANDLER_H_
#define VL53L5_ERROR_HANDLER_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "common_datatype_structs.h"
#include "vl53l5_platform_user_data.h"
int32_t vl53l5_check_status_registers(
struct vl53l5_dev_handle_t *p_dev,
union dci_union__go2_status_0_go1_u *p_go2_status_0,
union dci_union__go2_status_1_go1_u *p_go2_status_1,
bool ignore_warnings,
uint8_t current_page);
int32_t vl53l5_compose_fw_status_code(
struct vl53l5_dev_handle_t *p_dev,
struct common_grp__status_t *p_status);
int32_t vl53l5_get_secondary_error_info(
struct vl53l5_dev_handle_t *p_dev,
struct common_grp__status_t *p_status);
int32_t vl53l5_get_secondary_warning_info(
struct vl53l5_dev_handle_t *p_dev,
struct common_grp__status_t *p_status);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,219 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 _VL53L5_GLOBALS_H_
#define _VL53L5_GLOBALS_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "vl53l5_types.h"
#include "vl53l5_results_config.h"
#include "dci_ui_memory_defs.h"
#include "dci_size.h"
#include "dci_ui_size.h"
#ifdef VL53L5_PATCH_DATA_ENABLED
#ifdef VL53L5_SILICON_TEMP_DATA_ON
#define VL53L5_SILICON_TEMP_DATA_BLOCK_SZ \
(VL53L5_SILICON_TEMPERATURE_DATA_SZ \
+ VL53L5_DCI_UI_PACKED_DATA_BH_SZ)
#else
#define VL53L5_SILICON_TEMP_DATA_BLOCK_SZ \
0
#endif
#ifdef VL53L5_ZONE_CFG_ON
#define VL53L5_ZONE_CFG_BLOCK_SZ \
(VL53L5_ZONE_CFG_SZ \
+ VL53L5_DCI_UI_PACKED_DATA_BH_SZ)
#else
#define VL53L5_ZONE_CFG_BLOCK_SZ \
0
#endif
#endif
#if defined(VL53L5_RESULTS_DATA_ENABLED) && !defined(VL53L5_PATCH_DATA_ENABLED)
#define VL53L5_RESULTS_SIZE_BYTES VL53L5_RESULTS_TOTAL_SIZE_BYTES
#endif
#if defined(VL53L5_PATCH_DATA_ENABLED) && !defined(VL53L5_RESULTS_DATA_ENABLED)
#define VL53L5_RESULTS_SIZE_BYTES \
(VL53L5_TCPM_PATCH_0_MAP_RESULTS_TOTAL_SIZE_BYTES + \
VL53L5_SILICON_TEMP_DATA_BLOCK_SZ + \
VL53L5_ZONE_CFG_BLOCK_SZ)
#endif
#if defined(VL53L5_PATCH_DATA_ENABLED) && defined(VL53L5_RESULTS_DATA_ENABLED)
#define VL53L5_TCPM_RESULTS_SIZE_BYTES \
(VL53L5_TCPM_PATCH_0_MAP_RESULTS_TOTAL_SIZE_BYTES + \
VL53L5_SILICON_TEMP_DATA_BLOCK_SZ + \
VL53L5_ZONE_CFG_BLOCK_SZ)
#define VL53L5_RESULTS_SIZE_BYTES \
(VL53L5_TCPM_RESULTS_SIZE_BYTES > VL53L5_RESULTS_TOTAL_SIZE_BYTES ? \
VL53L5_TCPM_RESULTS_SIZE_BYTES : VL53L5_RESULTS_TOTAL_SIZE_BYTES)
#endif
#define VL53L5_ISNULL(ptr) ((ptr) == NULL)
#define VL53L5_COMMS_BUFF_ISNULL(p_dev)\
((p_dev)->host_dev.p_comms_buff == NULL)
#define VL53L5_COMMS_BUFF_ISEMPTY(p_dev)\
((p_dev)->host_dev.comms_buff_count == 0)
#define VL53L5_COMMS_BUFF(p_dev)\
((p_dev)->host_dev.p_comms_buff)
#define VL53L5_COMMS_BUFF_COUNT(p_dev)\
((p_dev)->host_dev.comms_buff_count)
#define VL53L5_COMMS_BUFF_MAX_COUNT(p_dev)\
((p_dev)->host_dev.comms_buff_max_count)
#define VL53L5_CHECK_COMMS_BUFF_AVAILABLE_BYTES(p_dev, required_bytes)\
((VL53L5_COMMS_BUFF_COUNT(p_dev) + required_bytes) <\
VL53L5_COMMS_BUFF_MAX_COUNT(p_dev))
#define VL53L5_COMMS_BUFF_NEXT_BYTE(p_dev)\
(&VL53L5_COMMS_BUFF(p_dev)[VL53L5_COMMS_BUFF_COUNT(p_dev)])
#define VL53L5_FW_BUFF_ISNULL(p_dev)\
((p_dev)->host_dev.p_fw_buff == NULL)
#define VL53L5_FW_BUFF_ISEMPTY(p_dev)\
((p_dev)->host_dev.fw_buff_count == 0)
#define VL53L5_RESET_COMMS_BUFF(p_dev)\
((p_dev)->host_dev.comms_buff_count = 0)
#define VL53L5_GET_VERSION_CHECK_STATUS(p_dev)\
(((p_dev)->host_dev.version_match.map_version_match == true) ? \
STATUS_OK : VL53L5_VER_CHECK_NOT_PERFORMED)
#define VL53L5_DEV_RANGE_UI_SIZE_BYTES \
(((DCI_UI__COMMAND_INFO__START_IDX & 0xFFFF) - \
(DCI_UI__DEVICE_INFO__START_IDX & 0xFFFF)) - 4)
#define VL53L5_MIN_FW_ERROR ((int32_t) 0xfe000000)
#define VL53L5_MAX_FW_ERROR ((int32_t) 0xfeffffff)
#define VL53L5_MAX_FW_STATUS_1_WARNING ((uint8_t) 0x7f)
#define STATUS_OK 0
#define VL53L5_MAX_RANGE_UI_SIZE_BYTES \
((VL53L5_DEV_RANGE_UI_SIZE_BYTES > VL53L5_RESULTS_SIZE_BYTES) ? \
VL53L5_RESULTS_SIZE_BYTES : VL53L5_DEV_RANGE_UI_SIZE_BYTES)
#define VL53L5_MAX_CMD_UI_SIZE_BYTES \
(((DCI_UI__COMMAND_INFO__START_IDX - DCI_UI__RANGE_DATA__START_IDX) \
& 0xffff) - 4)
#define VL53L5_DEV_INFO_BLOCK_SZ DCI_UI__DEVICE_INFO__SIZE_BYTES
#define VL53L5_HEADER_FOOTER_BLOCK_SZ DCI_UI__DEVICE_INFO__SIZE_BYTES
#define VL53L5_UI_DUMMY_BYTES 4
#define VL53L5_CONFIG_HEADER_SIZE \
(2 * VL53L5_DCI_UI_PACKED_DATA_BH_SZ + \
VL53L5_MAP_VERSION_SZ + \
VL53L5_CFG_INFO_SZ)
#define VL53L5_CALIBRATION_HEADER_SIZE \
(VL53L5_DCI_UI_PACKED_DATA_BH_SZ + VL53L5_MAP_VERSION_SZ)
#define VL53L5_MAX_CONF_CAL_SIZE_BYTES VL53L5_CONFIG_SIZE_BYTES
#define VL53L5_MAX_APPEND_SIZE_BYTES 100
#define VL53L5_COMMS_BUFFER_SIZE_BYTES \
((VL53L5_MAX_CONF_CAL_SIZE_BYTES + VL53L5_MAX_APPEND_SIZE_BYTES >\
VL53L5_MAX_RANGE_UI_SIZE_BYTES) ?\
(VL53L5_MAX_CONF_CAL_SIZE_BYTES + VL53L5_MAX_APPEND_SIZE_BYTES) :\
VL53L5_MAX_RANGE_UI_SIZE_BYTES)
#define VL53L5_DEBUG_BUFFER_SIZE_BYTES VL53L5_DEV_RANGE_UI_SIZE_BYTES
#define VL53L5_MAX_INPUT_DATA_LENGTH \
((VL53L5_COMMS_BUFFER_SIZE_BYTES > VL53L5_MAX_CMD_UI_SIZE_BYTES) ?\
VL53L5_MAX_CMD_UI_SIZE_BYTES - 8 : VL53L5_COMMS_BUFFER_SIZE_BYTES - 8)
#define BYTE_1 1
#define BYTE_2 2
#define BYTE_3 3
#define BYTE_4 4
#define BYTE_8 8
#define MAX_NUM_RANGE_RETURNS 0
#ifdef STM_VL53L8_SUPPORT_LEGACY_CODE
#define VL53L5_BOOT_COMPLETION_POLLING_TIMEOUT_MS 100
#else // SS_SUPPORT_SEC_CODE
#define VL53L5_BOOT_COMPLETION_POLLING_TIMEOUT_MS 500
#endif // SS_SUPPORT_SEC_CODE
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,76 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 _VL53L5_LOAD_FIRMWARE_H_
#define _VL53L5_LOAD_FIRMWARE_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "vl53l5_platform_user_data.h"
int32_t vl53l5_load_firmware(struct vl53l5_dev_handle_t *p_dev);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,157 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_PATCH_STRUCTS_H__
#define __VL53L5_PATCH_STRUCTS_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include "vl53l5_types.h"
#define VL53L5_PATCH_LOAD 1
#define VL53L5_PATCH_BOOT 2
#define VL53L5_RAM_LOAD 3
struct vl53l5_patch_data_t {
uint32_t patch_ver_major;
uint32_t patch_ver_minor;
uint32_t patch_ver_build;
uint32_t patch_ver_revision;
uint32_t boot_flag;
uint32_t patch_offset;
uint32_t patch_size;
uint32_t patch_checksum;
uint32_t tcpm_offset;
uint32_t tcpm_size;
uint32_t tcpm_page;
uint32_t tcpm_page_offset;
uint32_t hooks_offset;
uint32_t hooks_size;
uint32_t hooks_page;
uint32_t hooks_page_offset;
uint32_t breakpoint_en_offset;
uint32_t breakpoint_en_size;
uint32_t breakpoint_en_page;
uint32_t breakpoint_en_page_offset;
uint32_t breakpoint_offset;
uint32_t breakpoint_size;
uint32_t breakpoint_page;
uint32_t breakpoint_page_offset;
uint32_t checksum_en_offset;
uint32_t checksum_en_size;
uint32_t checksum_en_page;
uint32_t checksum_en_page_offset;
uint32_t patch_code_offset;
uint32_t patch_code_size;
uint32_t patch_code_page;
uint32_t patch_code_page_offset;
uint32_t dci_tcpm_patch_0_offset;
uint32_t dci_tcpm_patch_0_size;
uint32_t dci_tcpm_patch_0_page;
uint32_t dci_tcpm_patch_0_page_offset;
uint32_t dci_tcpm_patch_1_offset;
uint32_t dci_tcpm_patch_1_size;
uint32_t dci_tcpm_patch_1_page;
uint32_t dci_tcpm_patch_1_page_offset;
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,107 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 _VL53L5_POWER_STATES_H_
#define _VL53L5_POWER_STATES_H_
#ifdef __cplusplus
extern "C"
{
#endif
#define VL53L5_CHECK_POWER_STATE(p_dev, state)\
((p_dev)->host_dev.power_state == (state))
#define VL53L5_CHECK_POWER_STATE_OFF(p_dev)\
(VL53L5_CHECK_POWER_STATE((p_dev), VL53L5_POWER_STATE_OFF))
#define VL53L5_CHECK_POWER_STATE_ULP_IDLE(p_dev)\
(VL53L5_CHECK_POWER_STATE((p_dev),\
VL53L5_POWER_STATE_ULP_IDLE))
#define VL53L5_CHECK_POWER_STATE_LP_IDLE_COMMS(p_dev)\
(VL53L5_CHECK_POWER_STATE((p_dev),\
VL53L5_POWER_STATE_LP_IDLE_COMMS))
#define VL53L5_CHECK_POWER_STATE_HP_IDLE(p_dev)\
(VL53L5_CHECK_POWER_STATE((p_dev),\
VL53L5_POWER_STATE_HP_IDLE))
#define VL53L5_CHECK_POWER_STATE_RANGING(p_dev)\
(VL53L5_CHECK_POWER_STATE((p_dev),\
VL53L5_POWER_STATE_RANGING))
enum vl53l5_power_states {
VL53L5_POWER_STATE_OFF = 0,
VL53L5_POWER_STATE_ULP_IDLE = 1,
VL53L5_POWER_STATE_LP_IDLE_COMMS = 3,
VL53L5_POWER_STATE_HP_IDLE = 4,
VL53L5_POWER_STATE_RANGING = 5
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,128 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 VL53L5_REGISTER_UTILS_H_
#define VL53L5_REGISTER_UTILS_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "vl53l5_platform_user_data.h"
enum vl53l5_boot_state {
VL53L5_BOOT_STATE_LOW = 0,
VL53L5_BOOT_STATE_HIGH = 1,
VL53L5_BOOT_STATE_ERROR = 2
};
#define VL53L5_GO2_STATUS_0(p_dev) \
((p_dev)->host_dev.ui_dev_info.dev_info__go2_status_0)
#define VL53L5_GO2_STATUS_1(p_dev) \
((p_dev)->host_dev.ui_dev_info.dev_info__go2_status_1)
#define HW_TRAP(p_dev)\
(VL53L5_GO2_STATUS_0(p_dev).mcu__hw_trap_flag_go1 == 1)
#define MCU_ERROR(p_dev)\
(VL53L5_GO2_STATUS_0(p_dev).mcu__error_flag_go1 == 1)
#define MCU_BOOT_COMPLETE(p_dev)\
(VL53L5_GO2_STATUS_0(p_dev).mcu__boot_complete_go1 == 1)
#define MCU_BOOT_NOT_COMPLETE(p_dev)\
(VL53L5_GO2_STATUS_0(p_dev).mcu__boot_complete_go1 == 0)
#define MCU_FIRST_BOOT(p_dev)\
(VL53L5_GO2_STATUS_1(p_dev).bytes == 0x1f)
#define MCU_NVM_PROGRAMMED(p_dev)\
(VL53L5_GO2_STATUS_1(p_dev).mcu__spare1 == 1)
int32_t vl53l5_register_read_modify_write(
struct vl53l5_dev_handle_t *p_dev, uint16_t addr,
uint8_t first_and_mask, uint8_t second_or_mask);
int32_t vl53l5_set_page(struct vl53l5_dev_handle_t *p_dev, uint8_t page);
int32_t vl53l5_set_regulators(
struct vl53l5_dev_handle_t *p_dev,
uint8_t lp_reg_enable,
uint8_t hp_reg_enable);
int32_t vl53l5_set_xshut_bypass(
struct vl53l5_dev_handle_t *p_dev, uint8_t state);
int32_t vl53l5_set_manual_xshut_state(
struct vl53l5_dev_handle_t *p_dev, uint8_t state);
int32_t vl53l5_wait_mcu_boot(
struct vl53l5_dev_handle_t *p_dev, enum vl53l5_boot_state state,
uint32_t timeout_ms, uint32_t wait_time_ms);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_RESULTS_CONFIG_H__
#define __VL53L5_RESULTS_CONFIG_H__
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef VL53L5_RESULTS_DATA_ENABLED
#include "vl53l5_main_results_config.h"
#endif
#ifdef VL53L5_PATCH_DATA_ENABLED
#include "vl53l5_tcpm_patch_0_results_config.h"
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,76 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 VL53L5_ROM_BOOT_H_
#define VL53L5_ROM_BOOT_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "vl53l5_platform_user_data.h"
int32_t vl53l5_check_rom_firmware_boot(struct vl53l5_dev_handle_t *p_dev);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,82 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 _VL53L5_TCDM_DUMP_H_
#define _VL53L5_TCDM_DUMP_H_
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef VL53L5_TCDM_ENABLE
#include "vl53l5_platform_user_data.h"
#define VL53L5_TCDM_BUFFER_SIZE 0x10004
#define VL53L5_TCDM_DUMP_STATUS_TIMEOUT 500
int32_t vl53l5_tcdm_dump(struct vl53l5_dev_handle_t *p_dev,
uint8_t *buffer, uint32_t *count);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 VL53L5_TRANS_H_
#define VL53L5_TRANS_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "vl53l5_platform_user_data.h"
#define VL53L5_GET_CURRENT_TRANS_ID(p_dev) \
((p_dev)->host_dev.latest_trans_id)
#define VL53L5_GET_NEXT_TRANS_ID(p_dev) \
(++(p_dev)->host_dev.latest_trans_id)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,77 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 VL53L5_VERSION_H_
#define VL53L5_VERSION_H_
#ifdef __cplusplus
extern "C"
{
#endif
#define VL53L5_VERSION_MAJOR 4
#define VL53L5_VERSION_MINOR 3
#define VL53L5_VERSION_BUILD 0
#define VL53L5_VERSION_REVISION 1
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,186 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*******************************************************************************/
#include "vl53l5_checks.h"
#include "vl53l5_commands.h"
#include "vl53l5_register_utils.h"
#include "vl53l5_globals.h"
#include "vl53l5_platform_log.h"
#include "vl53l5_error_codes.h"
#include "vl53l5_dci_core.h"
#include "vl53l5_dci_utils.h"
#include "vl53l5_core_map_bh.h"
#define trace_print(level, ...) \
_LOG_TRACE_PRINT(VL53L5_TRACE_MODULE_DCI, \
level, VL53L5_TRACE_FUNCTION_ALL, ##__VA_ARGS__)
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START(VL53L5_TRACE_MODULE_DCI, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_DCI, status, ##__VA_ARGS__)
#define TEST_NVM_REG_INDEX 0x21
#define PAGE_SELECT_INDEX 0x7fff
static int32_t _test_end_block(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = VL53L5_ERROR_NONE;
uint32_t end_of_data_footer_index =
VL53L5_MAP_VERSION_SZ + VL53L5_DCI_UI_PACKED_DATA_BH_SZ;
uint8_t *p_buff = NULL;
if (p_dev->host_dev.revision_id == 0x0C)
p_buff = &VL53L5_COMMS_BUFF(p_dev)[VL53L5_UI_DUMMY_BYTES];
else
p_buff = VL53L5_COMMS_BUFF(p_dev);
if ((p_buff[end_of_data_footer_index] & 0x0f) !=
DCI_BH__P_TYPE__END_OF_DATA)
status = VL53L5_DCI_END_BLOCK_ERROR;
return status;
}
int32_t vl53l5_test_map_version(struct vl53l5_dev_handle_t *p_dev,
uint8_t *p_buffer)
{
int32_t status = VL53L5_ERROR_NONE;
uint8_t *p_buff = p_buffer;
uint16_t map_major = 0;
uint16_t map_minor = 0;
uint32_t block_header = 0;
LOG_FUNCTION_START("");
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (VL53L5_COMMS_BUFF_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
block_header = vl53l5_decode_uint32_t(BYTE_4, p_buff);
if (block_header != VL53L5_MAP_VERSION_BH) {
status = VL53L5_VERSION_IDX_NOT_PRESENT;
goto exit;
}
p_buff += 4;
map_major = vl53l5_decode_uint16_t(BYTE_2, p_buff);
p_buff += 2;
map_minor = vl53l5_decode_uint16_t(BYTE_2, p_buff);
trace_print(
VL53L5_TRACE_LEVEL_INFO, "Map version: %u.%u\n",
map_major, map_minor);
if ((map_major != MAP_VERSION_MAJOR) ||
(map_minor != MAP_VERSION_MINOR)) {
status = VL53L5_DCI_VERSION_ERROR;
goto exit;
}
exit:
LOG_FUNCTION_END(status);
return status;
}
int32_t vl53l5_check_map_version(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = VL53L5_ERROR_NONE;
uint32_t block_headers[] = {VL53L5_MAP_VERSION_BH};
uint8_t *p_buff = NULL;
LOG_FUNCTION_START("");
p_dev->host_dev.version_match.map_version_match = false;
status = vl53l5_encode_block_headers(p_dev, block_headers, 1, false);
if (status != VL53L5_ERROR_NONE)
goto exit;
status = vl53l5_execute_command(p_dev, DCI_CMD_ID__GET_PARMS);
if (status != VL53L5_ERROR_NONE)
goto exit;
status = _test_end_block(p_dev);
if (status != VL53L5_ERROR_NONE)
goto exit;
if (p_dev->host_dev.revision_id == 0x0C)
p_buff = &VL53L5_COMMS_BUFF(p_dev)[VL53L5_UI_DUMMY_BYTES];
else
p_buff = VL53L5_COMMS_BUFF(p_dev);
status = vl53l5_test_map_version(p_dev, p_buff);
if (status != VL53L5_ERROR_NONE)
goto exit;
p_dev->host_dev.version_match.map_version_match = true;
exit:
LOG_FUNCTION_END(status);
return status;
}

View File

@@ -0,0 +1,183 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*******************************************************************************/
#include "vl53l5_commands.h"
#include "vl53l5_globals.h"
#include "vl53l5_trans.h"
#include "vl53l5_platform_log.h"
#include "vl53l5_error_codes.h"
#include "vl53l5_dci_core.h"
#include "vl53l5_dci_utils.h"
#include "vl53l5_core_map_bh.h"
#define trace_print(level, ...) \
_LOG_TRACE_PRINT(VL53L5_TRACE_MODULE_DCI, \
level, VL53L5_TRACE_FUNCTION_ALL, ##__VA_ARGS__)
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START(VL53L5_TRACE_MODULE_DCI, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_DCI, status, ##__VA_ARGS__)
#define BLOCK_HEADER_SIZE 4
#define COMMAND_HAS_RETURN(command_id) \
((command_id == DCI_CMD_ID__GET_PARMS) ||\
(command_id == DCI_CMD_ID__START_RANGE))
int32_t vl53l5_encode_block_headers(
struct vl53l5_dev_handle_t *p_dev,
uint32_t *p_block_headers,
uint32_t num_block_headers,
bool encode_version)
{
int32_t status = VL53L5_ERROR_NONE;
uint32_t num_bh = num_block_headers;
uint32_t i = 0;
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (VL53L5_ISNULL(p_block_headers)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (num_block_headers == 0) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (VL53L5_COMMS_BUFF_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (encode_version)
num_bh++;
if ((num_bh * BLOCK_HEADER_SIZE) >
VL53L5_COMMS_BUFF_MAX_COUNT(p_dev)) {
status = VL53L5_MAX_BUFFER_SIZE_REACHED;
goto exit;
}
VL53L5_RESET_COMMS_BUFF(p_dev);
if (encode_version) {
vl53l5_encode_uint32_t(
VL53L5_MAP_VERSION_BH, BLOCK_HEADER_SIZE,
VL53L5_COMMS_BUFF_NEXT_BYTE(p_dev));
VL53L5_COMMS_BUFF_COUNT(p_dev) += BLOCK_HEADER_SIZE;
}
for (i = 0; i < num_block_headers; i++) {
if ((p_block_headers[i] == VL53L5_MAP_VERSION_BH) &&
(encode_version))
continue;
vl53l5_encode_uint32_t(
p_block_headers[i], BLOCK_HEADER_SIZE,
VL53L5_COMMS_BUFF_NEXT_BYTE(p_dev));
VL53L5_COMMS_BUFF_COUNT(p_dev) += BLOCK_HEADER_SIZE;
}
exit:
return status;
}
int32_t vl53l5_execute_command(
struct vl53l5_dev_handle_t *p_dev,
uint8_t command_id)
{
int32_t status = VL53L5_ERROR_NONE;
uint8_t trans_id = 0;
LOG_FUNCTION_START("");
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (VL53L5_COMMS_BUFF_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (command_id == DCI_CMD_ID__NULL) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
trans_id = VL53L5_GET_NEXT_TRANS_ID(p_dev);
status = vl53l5_dci_write_command(p_dev, command_id, trans_id);
if (status != STATUS_OK)
goto exit;
status = vl53l5_dci_poll_command_status(p_dev, trans_id, 0);
if (status != STATUS_OK)
goto exit;
if (COMMAND_HAS_RETURN(command_id))
status = vl53l5_dci_read_command(p_dev);
exit:
LOG_FUNCTION_END(status);
return status;
}

View File

@@ -0,0 +1,361 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*******************************************************************************/
#include "vl53l5_error_handler.h"
#include "vl53l5_commands.h"
#include "vl53l5_error_codes.h"
#include "vl53l5_platform.h"
#include "vl53l5_trans.h"
#include "vl53l5_dci_utils.h"
#include "vl53l5_dci_core.h"
#include "vl53l5_core_map_bh.h"
#define trace_print(level, ...) \
_LOG_TRACE_PRINT(VL53L5_TRACE_MODULE_POWER_API, \
level, VL53L5_TRACE_FUNCTION_ALL, ##__VA_ARGS__)
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START(VL53L5_TRACE_MODULE_POWER_API, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_POWER_API, status, ##__VA_ARGS__)
#define PAGE_SELECT 0x7FFF
#define GO2_STATUS_0 0x6
#define GO2_STATUS_1 0x7
#define BASE_FW_ERROR 0xE0000000
#define FW_ERROR_MIN_ID 128
static int32_t _get_status_struct(
struct vl53l5_dev_handle_t *p_dev,
struct common_grp__status_t *p_status,
uint32_t block_header)
{
int32_t status = STATUS_OK;
uint32_t check_block_header = 0;
uint8_t *p_buff = NULL;
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto out;
}
if (VL53L5_ISNULL(p_status)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto out;
}
if (VL53L5_COMMS_BUFF_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto out;
}
status = vl53l5_encode_block_headers(p_dev, &block_header, 1, false);
if (status != STATUS_OK)
goto out;
status = vl53l5_execute_command(p_dev, DCI_CMD_ID__GET_PARMS);
if (status != STATUS_OK)
goto out;
if (p_dev->host_dev.revision_id == 0x0C)
p_buff = &VL53L5_COMMS_BUFF(p_dev)[VL53L5_UI_DUMMY_BYTES];
else
p_buff = VL53L5_COMMS_BUFF(p_dev);
check_block_header = vl53l5_decode_uint32_t(BYTE_4, p_buff);
if (check_block_header != block_header) {
status = VL53L5_IDX_MISSING_FROM_RETURN_PACKET;
goto out;
}
p_buff += 4;
p_status->status__group = vl53l5_decode_int16_t(BYTE_2, p_buff);
p_buff += 2;
p_status->status__type = vl53l5_decode_int16_t(BYTE_2, p_buff);
p_buff += 2;
p_status->status__stage_id = vl53l5_decode_int16_t(BYTE_2, p_buff);
p_buff += 2;
p_status->status__debug_0 = vl53l5_decode_uint16_t(BYTE_2, p_buff);
p_buff += 2;
p_status->status__debug_1 = vl53l5_decode_uint16_t(BYTE_2, p_buff);
p_buff += 2;
p_status->status__debug_2 = vl53l5_decode_uint16_t(BYTE_2, p_buff);
trace_print(
VL53L5_TRACE_LEVEL_DEBUG,
"group:%i type:%i stage:%i debug0:%i debug1:%i debug2:%i\n",
p_status->status__group,
p_status->status__type,
p_status->status__stage_id,
p_status->status__debug_0,
p_status->status__debug_1,
p_status->status__debug_2);
out:
LOG_FUNCTION_END(status);
return status;
}
int32_t vl53l5_check_status_registers(
struct vl53l5_dev_handle_t *p_dev,
union dci_union__go2_status_0_go1_u *p_go2_status_0,
union dci_union__go2_status_1_go1_u *p_go2_status_1,
bool ignore_warnings,
uint8_t current_page)
{
int32_t status = STATUS_OK;
uint8_t wr_byte = 0;
LOG_FUNCTION_START("");
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto out_no_page_change;
}
if (VL53L5_ISNULL(p_go2_status_0)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto out_no_page_change;
}
if (VL53L5_ISNULL(p_go2_status_1)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto out_no_page_change;
}
if (current_page != 0) {
wr_byte = 0x00;
status = vl53l5_write_multi(p_dev, PAGE_SELECT, &wr_byte, 1);
if (status < STATUS_OK)
goto out_no_page_change;
}
status = vl53l5_read_multi(
p_dev, GO2_STATUS_0, &p_go2_status_0->bytes, 1);
if (status < STATUS_OK)
goto out;
trace_print(
VL53L5_TRACE_LEVEL_DEBUG,
"go2 status 0\n"
"bytes: 0x%x\n"
"mcu__boot_complete_go1: %x\n"
"mcu__analog_checks_ok_go1: %x\n"
"mcu__threshold_triggered_g01: %x\n"
"mcu__error_flag_go1: %x\n"
"mcu__ui_range_data_present_go1: %x\n"
"mcu__ui_new_range_data_avail_go1: %x\n"
"mcu__ui_update_blocked_go1: %x\n"
"mcu__hw_trap_flag_go1: %x\n",
p_go2_status_0->bytes,
p_go2_status_0->mcu__boot_complete_go1,
p_go2_status_0->mcu__analog_checks_ok_go1,
p_go2_status_0->mcu__threshold_triggered_g01,
p_go2_status_0->mcu__error_flag_go1,
p_go2_status_0->mcu__ui_range_data_present_go1,
p_go2_status_0->mcu__ui_new_range_data_avail_go1,
p_go2_status_0->mcu__ui_update_blocked_go1,
p_go2_status_0->mcu__hw_trap_flag_go1);
if ((p_go2_status_0->mcu__error_flag_go1) &&
(!p_go2_status_0->mcu__hw_trap_flag_go1)) {
p_go2_status_1->bytes = 0;
goto out;
}
status = vl53l5_read_multi(
p_dev, GO2_STATUS_1, &p_go2_status_1->bytes, 1);
if (status < STATUS_OK)
goto out;
trace_print(
VL53L5_TRACE_LEVEL_DEBUG,
"go2 status 1\n"
"bytes: 0x%x\n"
"mcu__avdd_reg_ok_go1: %x\n"
"mcu__pll_lock_ok_go1: %x\n"
"mcu__ls_watchdog_pass_go1: %x\n"
"mcu__warning_flag_go1: %x\n"
"mcu__cp_collapse_flag_go1: %x\n"
"mcu__spare0: %x\n"
"mcu__initial_ram_boot_complete: %x\n"
"mcu__spare1: %x\n",
p_go2_status_1->bytes,
p_go2_status_1->mcu__avdd_reg_ok_go1,
p_go2_status_1->mcu__pll_lock_ok_go1,
p_go2_status_1->mcu__ls_watchdog_pass_go1,
p_go2_status_1->mcu__warning_flag_go1,
p_go2_status_1->mcu__cp_collapse_flag_go1,
p_go2_status_1->mcu__spare0,
p_go2_status_1->mcu__initial_ram_boot_complete,
p_go2_status_1->mcu__spare1);
if (p_go2_status_0->mcu__hw_trap_flag_go1 &&
(p_go2_status_1->bytes == 0)) {
status = VL53L5_ERROR_FALSE_MCU_ERROR_IN_BANK_CHECK;
goto out;
}
if (!p_go2_status_0->mcu__hw_trap_flag_go1 &&
ignore_warnings &&
p_go2_status_1->mcu__warning_flag_go1)
p_go2_status_1->bytes = 0;
out:
if (current_page != 0) {
wr_byte = current_page;
if (status < STATUS_OK)
(void)vl53l5_write_multi(
p_dev, PAGE_SELECT, &wr_byte, 1);
else
status = vl53l5_write_multi(
p_dev, PAGE_SELECT, &wr_byte, 1);
}
out_no_page_change:
if (status < STATUS_OK) {
if (!VL53L5_ISNULL(p_go2_status_0))
p_go2_status_0->bytes = 0;
if (!VL53L5_ISNULL(p_go2_status_1))
p_go2_status_1->bytes = 0;
}
LOG_FUNCTION_END(status);
return status;
}
int32_t vl53l5_get_secondary_error_info(
struct vl53l5_dev_handle_t *p_dev,
struct common_grp__status_t *p_status)
{
int32_t status = STATUS_OK;
LOG_FUNCTION_START("");
status = _get_status_struct(
p_dev, p_status, VL53L5_DEVICE_ERROR_STATUS_BH);
if (status != STATUS_OK)
goto exit;
exit:
LOG_FUNCTION_END(status);
return status;
}
int32_t vl53l5_get_secondary_warning_info(
struct vl53l5_dev_handle_t *p_dev,
struct common_grp__status_t *p_status)
{
int32_t status = STATUS_OK;
LOG_FUNCTION_START("");
status = _get_status_struct(
p_dev, p_status, VL53L5_DEVICE_WARNING_STATUS_BH);
if (status != STATUS_OK)
goto exit;
exit:
LOG_FUNCTION_END(status);
return status;
}
int32_t vl53l5_compose_fw_status_code(
struct vl53l5_dev_handle_t *p_dev,
struct common_grp__status_t *p_status)
{
int32_t status = STATUS_OK;
uint32_t tmp = 0;
uint16_t *p_reinterpret = NULL;
LOG_FUNCTION_START("");
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto out;
}
if (VL53L5_ISNULL(p_status)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto out;
}
if (!p_status->status__type)
goto out;
status = BASE_FW_ERROR;
p_reinterpret = (uint16_t *)&p_status->status__group;
tmp |= ((uint32_t)(0xff & *p_reinterpret) << 24);
p_reinterpret = (uint16_t *)&p_status->status__type;
tmp |= ((uint32_t)(0xff & *p_reinterpret) << 16);
p_reinterpret = (uint16_t *)&p_status->status__stage_id;
tmp |= ((uint32_t)(0xff & *p_reinterpret) << 8);
p_reinterpret = (uint16_t *)&p_status->status__debug_2;
tmp |= (uint32_t)(0xff & *p_reinterpret);
status += (int32_t)tmp;
out:
LOG_FUNCTION_END(status);
return status;
}

View File

@@ -0,0 +1,736 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*******************************************************************************/
#include "vl53l5_load_firmware.h"
#include "vl53l5_platform.h"
#include "vl53l5_register_utils.h"
#include "vl53l5_platform_log.h"
#include "vl53l5_dci_utils.h"
#include "vl53l5_dci_helpers.h"
#include "dci_ui_memory_defs.h"
#include "vl53l5_platform_user_config.h"
#define trace_print(level, ...) \
_LOG_TRACE_PRINT(VL53L5_TRACE_MODULE_LOAD_FIRMWARE, \
level, VL53L5_TRACE_FUNCTION_ALL, ##__VA_ARGS__)
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START(VL53L5_TRACE_MODULE_LOAD_FIRMWARE, fmt, \
##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_LOAD_FIRMWARE, status, \
##__VA_ARGS__)
#define CHECK_FOR_TIMEOUT(status, p_dev, start_ms, end_ms, timeout_ms) \
(status = vl53l5_check_for_timeout(\
(p_dev), start_ms, end_ms, timeout_ms))
#define MAX_FW_FILE_SIZE 100000
#define WRITE_CHUNK_SIZE(p_dev) VL53L5_COMMS_BUFF_MAX_COUNT(p_dev)
static int32_t _write_byte(
struct vl53l5_dev_handle_t *p_dev, uint16_t address, uint8_t value)
{
return vl53l5_write_multi(p_dev, address, &value, 1);
}
static int32_t _read_byte(
struct vl53l5_dev_handle_t *p_dev, uint16_t address, uint8_t *p_value)
{
return vl53l5_read_multi(p_dev, address, p_value, 1);
}
static int32_t _write_page(struct vl53l5_dev_handle_t *p_dev, uint8_t *p_buffer,
uint16_t page_offset, uint32_t page_size,
uint32_t max_chunk_size, uint32_t *p_write_count)
{
int32_t status = STATUS_OK;
uint32_t write_size = 0;
uint32_t remainder_size = 0;
uint8_t *p_write_buff = NULL;
if ((page_offset + max_chunk_size) < page_size)
write_size = max_chunk_size;
else
write_size = page_size - page_offset;
if (*p_write_count > p_dev->host_dev.fw_buff_count) {
p_write_buff = p_dev->host_dev.p_comms_buff;
memset(p_write_buff, 0, write_size);
} else {
if ((p_dev->host_dev.fw_buff_count - *p_write_count)
< write_size) {
p_write_buff = p_dev->host_dev.p_comms_buff;
remainder_size =
p_dev->host_dev.fw_buff_count - *p_write_count;
memcpy(p_write_buff,
p_buffer + *p_write_count,
remainder_size);
memset(p_write_buff + remainder_size,
0,
write_size - remainder_size);
} else {
p_write_buff = p_buffer + *p_write_count;
}
}
status = vl53l5_write_multi(p_dev, page_offset, p_write_buff,
write_size);
if (status < STATUS_OK)
goto exit;
(*p_write_count) += write_size;
exit:
return status;
}
static int32_t _write_data_to_ram(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
uint16_t tcpm_page_offset = p_dev->host_dev.patch_data.tcpm_page_offset;
uint8_t tcpm_page = p_dev->host_dev.patch_data.tcpm_page;
uint8_t current_page = 0;
uint32_t tcpm_page_size = 0;
uint32_t write_count = 0;
uint32_t tcpm_offset = p_dev->host_dev.patch_data.tcpm_offset;
uint32_t tcpm_size = p_dev->host_dev.patch_data.tcpm_size;
uint32_t current_size = tcpm_size;
uint8_t *write_buff = NULL;
p_dev->host_dev.fw_buff_count = tcpm_size;
write_buff = &p_dev->host_dev.p_fw_buff[tcpm_offset];
LOG_FUNCTION_START("");
p_dev->host_dev.firmware_load = true;
for (current_page = tcpm_page; current_page < 12; current_page++) {
status = _write_byte(p_dev, 0x7FFF, current_page);
if (status < STATUS_OK)
goto exit;
if (current_page == 9)
tcpm_page_size = 0x8000;
if (current_page == 10)
tcpm_page_size = 0x8000;
if (current_page == 11)
tcpm_page_size = 0x5000;
if (current_size < tcpm_page_size)
tcpm_page_size = current_size;
for (tcpm_page_offset = 0; tcpm_page_offset < tcpm_page_size;
tcpm_page_offset += WRITE_CHUNK_SIZE(p_dev)) {
status = _write_page(p_dev, write_buff,
tcpm_page_offset, tcpm_page_size,
WRITE_CHUNK_SIZE(p_dev), &write_count);
if (status != STATUS_OK)
goto exit;
}
if (write_count == tcpm_size)
break;
current_size -= write_count;
}
exit:
p_dev->host_dev.firmware_load = false;
LOG_FUNCTION_END(status);
return status;
}
static void _decode_patch_struct(struct vl53l5_dev_handle_t *p_dev)
{
uint8_t *p_buff = p_dev->host_dev.p_fw_buff;
LOG_FUNCTION_START("");
p_dev->host_dev.patch_data.patch_ver_major =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.patch_ver_major: 0x%x\n",
p_dev->host_dev.patch_data.patch_ver_major);
p_dev->host_dev.patch_data.patch_ver_minor =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.patch_ver_minor: 0x%x\n",
p_dev->host_dev.patch_data.patch_ver_minor);
p_dev->host_dev.patch_data.patch_ver_build =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.patch_ver_build: 0x%x\n",
p_dev->host_dev.patch_data.patch_ver_build);
p_dev->host_dev.patch_data.patch_ver_revision =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.patch_ver_revision: 0x%x\n",
p_dev->host_dev.patch_data.patch_ver_revision);
p_buff += BYTE_4;
p_dev->host_dev.patch_data.patch_offset =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.patch_offset: 0x%x\n",
p_dev->host_dev.patch_data.patch_offset);
p_dev->host_dev.patch_data.patch_size =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.patch_size: 0x%x\n",
p_dev->host_dev.patch_data.patch_size);
p_dev->host_dev.patch_data.patch_checksum =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.patch_checksum: 0x%x\n",
p_dev->host_dev.patch_data.patch_checksum);
p_dev->host_dev.patch_data.tcpm_offset =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.tcpm_offset: 0x%x\n",
p_dev->host_dev.patch_data.tcpm_offset);
p_dev->host_dev.patch_data.tcpm_size =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.tcpm_size: 0x%x\n",
p_dev->host_dev.patch_data.tcpm_size);
p_dev->host_dev.patch_data.tcpm_page =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.tcpm_page: 0x%x\n",
p_dev->host_dev.patch_data.tcpm_page);
p_dev->host_dev.patch_data.tcpm_page_offset =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.tcpm_page_offset: 0x%x\n",
p_dev->host_dev.patch_data.tcpm_page_offset);
p_buff += 48;
p_dev->host_dev.patch_data.checksum_en_offset =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.checksum_en_offset: 0x%x\n",
p_dev->host_dev.patch_data.checksum_en_offset);
p_dev->host_dev.patch_data.checksum_en_size =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.checksum_en_size: 0x%x\n",
p_dev->host_dev.patch_data.checksum_en_size);
p_dev->host_dev.patch_data.checksum_en_page =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.checksum_en_page: 0x%x\n",
p_dev->host_dev.patch_data.checksum_en_page);
p_dev->host_dev.patch_data.checksum_en_page_offset =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.checksum_en_page_offset: 0x%x\n",
p_dev->host_dev.patch_data.checksum_en_page_offset);
p_dev->host_dev.patch_data.patch_code_offset =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.patch_code_offset: 0x%x\n",
p_dev->host_dev.patch_data.patch_code_offset);
p_dev->host_dev.patch_data.patch_code_size =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.patch_code_size: 0x%x\n",
p_dev->host_dev.patch_data.patch_code_size);
p_dev->host_dev.patch_data.patch_code_page =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.patch_code_page: 0x%x\n",
p_dev->host_dev.patch_data.patch_code_page);
p_dev->host_dev.patch_data.patch_code_page_offset =
vl53l5_decode_uint32_t(BYTE_4, p_buff);
p_buff += BYTE_4;
trace_print(VL53L5_TRACE_LEVEL_INFO,
"p_dev->host_dev.patch_data.patch_code_page_offset: 0x%x\n",
p_dev->host_dev.patch_data.patch_code_page_offset);
LOG_FUNCTION_END(0);
}
static int32_t _write_patch_code(
struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
uint16_t page =
(uint16_t)p_dev->host_dev.patch_data.patch_code_page;
uint16_t addr =
(uint16_t)p_dev->host_dev.patch_data.patch_code_page_offset;
uint32_t size = p_dev->host_dev.patch_data.patch_code_size;
uint32_t offset = p_dev->host_dev.patch_data.patch_code_offset;
uint8_t *reg_data = &p_dev->host_dev.p_fw_buff[offset];
LOG_FUNCTION_START("");
trace_print(VL53L5_TRACE_LEVEL_DEBUG, "page: 0x%x addr: 0x%x\n",
page, addr);
status = _write_byte(p_dev, 0x7FFF, page);
if (status < STATUS_OK)
goto exit;
status = vl53l5_write_multi(p_dev, addr, reg_data, size);
if (status < STATUS_OK)
goto exit;
exit:
LOG_FUNCTION_END(status);
return status;
}
static int32_t _write_checksum_en(
struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
uint16_t page =
(uint16_t)p_dev->host_dev.patch_data.checksum_en_page;
uint16_t addr =
(uint16_t)p_dev->host_dev.patch_data.checksum_en_page_offset;
uint32_t size = p_dev->host_dev.patch_data.checksum_en_size;
uint32_t offset = p_dev->host_dev.patch_data.checksum_en_offset;
uint8_t *reg_data = &p_dev->host_dev.p_fw_buff[offset];
LOG_FUNCTION_START("");
trace_print(VL53L5_TRACE_LEVEL_DEBUG, "page: 0x%x addr: 0x%x\n",
page, addr);
status = _write_byte(p_dev, 0x7FFF, page);
if (status < STATUS_OK)
goto exit;
status = vl53l5_write_multi(p_dev, addr, reg_data, size);
if (status < STATUS_OK)
goto exit;
exit:
LOG_FUNCTION_END(status);
return status;
}
static int32_t _check_fw_checksum(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
uint32_t checksum = 0;
uint32_t expected_checksum = p_dev->host_dev.patch_data.patch_checksum;
uint8_t data[4] = {0};
uint16_t ui_addr = (uint16_t)(DCI_UI__FIRMWARE_CHECKSUM_IDX & 0xFFFF);
LOG_FUNCTION_START("");
data[0] = 0;
status = vl53l5_read_multi(p_dev, ui_addr, data, 4);
if (status < STATUS_OK)
goto exit;
status = vl53l5_dci_swap_buffer_byte_ordering(data, BYTE_4);
if (status < STATUS_OK)
goto exit;
checksum = vl53l5_decode_uint32_t(BYTE_4, data);
trace_print(VL53L5_TRACE_LEVEL_INFO,
"Expected Checksum: 0x%x Actual Checksum: 0x%x\n",
expected_checksum, checksum);
if (checksum != expected_checksum) {
status = VL53L5_ERROR_INIT_FW_CHECKSUM;
goto exit;
}
exit:
LOG_FUNCTION_END(status);
return status;
}
static int32_t _enable_host_access_to_go1_async(
struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
uint32_t start_time_ms = 0;
uint32_t current_time_ms = 0;
uint8_t m_status = 0;
LOG_FUNCTION_START("");
if (p_dev->host_dev.revision_id == 2) {
status = _write_byte(p_dev, 0x7FFF, 0x02);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x03, 0x12);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x7FFF, 0x01);
if (status < STATUS_OK)
goto exit;
} else {
status = _write_byte(p_dev, 0x7FFF, 0x01);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x06, 0x01);
if (status < STATUS_OK)
goto exit;
}
m_status = 0;
status = vl53l5_get_tick_count(p_dev, &start_time_ms);
if (status < STATUS_OK)
goto exit;
while ((m_status & 0x04) == 0) {
status = _read_byte(p_dev, 0x21, &m_status);
if (status < STATUS_OK)
goto exit;
status = vl53l5_get_tick_count(p_dev, &current_time_ms);
if (status < STATUS_OK)
goto exit;
CHECK_FOR_TIMEOUT(
status, p_dev, start_time_ms, current_time_ms,
VL53L5_BOOT_COMPLETION_POLLING_TIMEOUT_MS);
if (status < STATUS_OK) {
trace_print(
VL53L5_TRACE_LEVEL_ERRORS,
"ERROR: timeout waiting for mcu idle m_status %02x\n",
m_status);
status = VL53L5_ERROR_MCU_IDLE_TIMEOUT;
goto exit;
}
}
status = _write_byte(p_dev, 0x7FFF, 0x00);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x0C, 0x01);
if (status < STATUS_OK)
goto exit;
exit:
LOG_FUNCTION_END(status);
return status;
}
static int32_t _reset_mcu_and_wait_boot(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
uint8_t u_start[] = {0, 0, 0x42, 0};
LOG_FUNCTION_START("");
status = _write_byte(p_dev, 0x7FFF, 0x00);
if (status < STATUS_OK)
goto exit;
status = vl53l5_write_multi(p_dev, 0x114, u_start, 4);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x0B, 0x00);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x0C, 0x00);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x0B, 0x01);
if (status < STATUS_OK)
goto exit;
status = vl53l5_wait_mcu_boot(p_dev, VL53L5_BOOT_STATE_HIGH,
0, VL53L5_MCU_BOOT_WAIT_DELAY);
exit:
LOG_FUNCTION_END(status);
return status;
}
static int32_t _disable_pll(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
LOG_FUNCTION_START("");
status = _write_byte(p_dev, 0x7FFF, 0x00);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x400F, 0x00);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x21A, 0x43);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x21A, 0x03);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x21A, 0x01);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x21A, 0x00);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x219, 0x00);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x21B, 0x00);
if (status < STATUS_OK)
goto exit;
exit:
LOG_FUNCTION_END(status);
return status;
}
static int32_t _set_to_power_on_status(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
LOG_FUNCTION_START("");
status = _write_byte(p_dev, 0x7FFF, 0x00);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x101, 0x00);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x102, 0x00);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x010a, 0x00);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x4002, 0x01);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x4002, 0x00);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x103, 0x01);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, 0x010a, 0x03);
if (status < STATUS_OK)
goto exit;
exit:
LOG_FUNCTION_END(status);
return status;
}
static int32_t _wait_for_boot_complete_before_fw_load(
struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
LOG_FUNCTION_START("");
status = _enable_host_access_to_go1_async(p_dev);
if (status < STATUS_OK)
goto exit;
status = _set_to_power_on_status(p_dev);
if (status < STATUS_OK)
goto exit;
exit:
LOG_FUNCTION_END(status);
return status;
}
static int32_t _wait_for_boot_complete_after_fw_load(
struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
LOG_FUNCTION_START("");
status = _disable_pll(p_dev);
if (status < STATUS_OK)
goto exit;
status = _reset_mcu_and_wait_boot(p_dev);
if (status < STATUS_OK)
goto exit;
exit:
LOG_FUNCTION_END(status);
return status;
}
int32_t vl53l5_load_firmware(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
LOG_FUNCTION_START("");
trace_print(VL53L5_TRACE_LEVEL_INFO, "\n\n#### load_firmware ####\n\n");
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (VL53L5_FW_BUFF_ISNULL(p_dev)) {
status = VL53L5_ERROR_FW_BUFF_NOT_FOUND;
goto exit;
}
if (VL53L5_FW_BUFF_ISEMPTY(p_dev)) {
status = VL53L5_ERROR_FW_BUFF_NOT_FOUND;
goto exit;
}
if (VL53L5_COMMS_BUFF_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
_decode_patch_struct(p_dev);
status = _wait_for_boot_complete_before_fw_load(p_dev);
if (status < STATUS_OK)
goto exit_change_page;
status = _write_data_to_ram(p_dev);
if (status < STATUS_OK)
goto exit_change_page;
status = _write_patch_code(p_dev);
if (status < STATUS_OK)
goto exit_change_page;
status = _write_checksum_en(p_dev);
if (status < STATUS_OK)
goto exit_change_page;
status = _wait_for_boot_complete_after_fw_load(p_dev);
if (status < STATUS_OK)
goto exit_change_page;
status = _write_byte(p_dev, 0x7FFF, 0x02);
if (status < STATUS_OK)
goto exit_change_page;
status = _check_fw_checksum(p_dev);
if (status < STATUS_OK)
goto exit_change_page;
exit_change_page:
if (status < STATUS_OK)
(void)_write_byte(p_dev, 0x7FFF, 0x02);
exit:
LOG_FUNCTION_END(status);
return status;
}

View File

@@ -0,0 +1,295 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*******************************************************************************/
#include "vl53l5_register_utils.h"
#include "vl53l5_rom_boot.h"
#include "vl53l5_error_codes.h"
#include "vl53l5_platform.h"
#define trace_print(level, ...) \
_LOG_TRACE_PRINT(VL53L5_TRACE_MODULE_POWER_API, \
level, VL53L5_TRACE_FUNCTION_ALL, ##__VA_ARGS__)
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START(VL53L5_TRACE_MODULE_POWER_API, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_POWER_API, status, ##__VA_ARGS__)
#define CHECK_FOR_TIMEOUT(status, p_dev, start_ms, end_ms, timeout_ms) \
(status = vl53l5_check_for_timeout(\
(p_dev), start_ms, end_ms, timeout_ms))
#define PAGE_SELECT 0x7FFF
#define GO2_STATUS_0 0x6
#define GO2_STATUS_1 0x7
#define GPIO_LOW 0
#define GPIO_HIGH 1
#define REGULATOR_DISABLE 0
#define REGULATOR_ENABLE 1
#define REGDVDD1V1__INDEX 0x000F
#define XSHUT_CTRL 0x0009
#define DEFAULT_PAGE 2
#define GO2_PAGE 0
#define REGULATOR_REGISTER_OR_MASK(return_mask, lp_reg_enable, hp_reg_enable)\
do {\
return_mask = 0;\
return_mask |= (lp_reg_enable ? 0x00 : 0x02);\
return_mask |= (hp_reg_enable ? 0x00 : 0x01);\
} while (0)
#define REGULATOR_REGISTER_AND_MASK(return_mask)\
(return_mask = 0xfc)
#define MASK_XSHUT_REGISTER(reg_val, value)\
do {\
reg_val &= 0xf8;\
reg_val |= (value ? 0x04 : 0x02);\
} while (0)
#define BOOT_STATE_MATCHED(p_dev, state) \
(((state == VL53L5_BOOT_STATE_HIGH) && MCU_BOOT_COMPLETE(p_dev)) || \
((state == VL53L5_BOOT_STATE_LOW) && MCU_BOOT_NOT_COMPLETE(p_dev)))
int32_t vl53l5_register_read_modify_write(
struct vl53l5_dev_handle_t *p_dev, uint16_t addr,
uint8_t first_and_mask, uint8_t second_or_mask)
{
int32_t status = STATUS_OK;
uint8_t reg_val = 0;
status = vl53l5_read_multi(p_dev, addr, &reg_val, 1);
if (status != STATUS_OK)
goto out;
reg_val &= first_and_mask;
reg_val |= second_or_mask;
status = vl53l5_write_multi(p_dev, addr, &reg_val, 1);
out:
return status;
}
int32_t vl53l5_set_page(struct vl53l5_dev_handle_t *p_dev, uint8_t page)
{
int32_t status = STATUS_OK;
status = vl53l5_write_multi(p_dev, PAGE_SELECT, &page, 1);
return status;
}
int32_t vl53l5_set_regulators(
struct vl53l5_dev_handle_t *p_dev,
uint8_t lp_reg_enable,
uint8_t hp_reg_enable)
{
int32_t status = STATUS_OK;
uint16_t reg_index = 0;
uint8_t and_mask = 0;
uint8_t or_mask = 0;
REGULATOR_REGISTER_AND_MASK(and_mask);
REGULATOR_REGISTER_OR_MASK(or_mask, lp_reg_enable, hp_reg_enable);
reg_index = REGDVDD1V1__INDEX;
status = vl53l5_register_read_modify_write(p_dev, reg_index,
and_mask, or_mask);
return status;
}
int32_t vl53l5_set_xshut_bypass(
struct vl53l5_dev_handle_t *p_dev, uint8_t state)
{
int32_t status = STATUS_OK;
uint16_t reg_index = 0;
uint8_t and_mask = 0;
uint8_t or_mask = 0;
reg_index = 0x09;
if (state == 1) {
and_mask = 0xff;
or_mask = 0x01;
} else {
and_mask = 0xfe;
or_mask = 0x00;
}
status = vl53l5_register_read_modify_write(
p_dev, reg_index, and_mask, or_mask);
return status;
}
int32_t vl53l5_set_manual_xshut_state(
struct vl53l5_dev_handle_t *p_dev, uint8_t state)
{
int32_t status = STATUS_OK;
uint16_t reg_index = 0;
uint8_t reg_val = 0;
reg_index = XSHUT_CTRL;
reg_val = 0;
status = vl53l5_read_multi(p_dev, reg_index, &reg_val, 1);
if (status != STATUS_OK)
goto exit;
MASK_XSHUT_REGISTER(reg_val, state);
status = vl53l5_write_multi(p_dev, reg_index, &reg_val, 1);
exit:
return status;
}
int32_t vl53l5_wait_mcu_boot(
struct vl53l5_dev_handle_t *p_dev, enum vl53l5_boot_state state,
uint32_t timeout_ms, uint32_t wait_time_ms)
{
int32_t status = STATUS_OK;
uint32_t start_time_ms = 0;
uint32_t current_time_ms = 0;
status = vl53l5_get_tick_count(p_dev, &start_time_ms);
if (status != STATUS_OK)
goto exit;
if (timeout_ms == 0)
timeout_ms = VL53L5_BOOT_COMPLETION_POLLING_TIMEOUT_MS;
if (wait_time_ms > timeout_ms)
wait_time_ms = timeout_ms;
VL53L5_GO2_STATUS_0(p_dev).bytes = 0;
VL53L5_GO2_STATUS_1(p_dev).bytes = 0;
do {
status = vl53l5_read_multi(p_dev, GO2_STATUS_0,
&VL53L5_GO2_STATUS_0(p_dev).bytes, 1);
if (status != STATUS_OK)
goto exit;
if (HW_TRAP(p_dev)) {
status = vl53l5_read_multi(p_dev, GO2_STATUS_1,
&VL53L5_GO2_STATUS_1(p_dev).bytes, 1);
if (status != STATUS_OK)
goto exit;
if (VL53L5_GO2_STATUS_1(p_dev).bytes)
status = VL53L5_ERROR_MCU_ERROR_HW_STATE;
else
status =
VL53L5_ERROR_FALSE_MCU_ERROR_POWER_STATE;
goto exit;
}
if (state == VL53L5_BOOT_STATE_ERROR) {
if (MCU_ERROR(p_dev)) {
status = VL53L5_ERROR_MCU_ERROR_WAIT_STATE;
goto exit;
}
} else {
if (BOOT_STATE_MATCHED(p_dev, state))
goto exit_error;
}
status = vl53l5_get_tick_count(p_dev, &current_time_ms);
if (status != STATUS_OK)
goto exit;
CHECK_FOR_TIMEOUT(
status, p_dev, start_time_ms, current_time_ms,
timeout_ms);
if (status != STATUS_OK) {
status = VL53L5_ERROR_BOOT_COMPLETE_TIMEOUT;
goto exit;
}
if (wait_time_ms) {
status = vl53l5_wait_ms(p_dev, wait_time_ms);
if (status != STATUS_OK)
goto exit;
}
} while (1);
exit_error:
if (MCU_ERROR(p_dev)) {
(void)vl53l5_read_multi(p_dev, GO2_STATUS_1,
&VL53L5_GO2_STATUS_1(p_dev).bytes, 1);
if (MCU_NVM_PROGRAMMED(p_dev))
status = VL53L5_ERROR_MCU_NVM_NOT_PROGRAMMED;
else
status = VL53L5_ERROR_MCU_ERROR_WAIT_STATE;
}
exit:
return status;
}

View File

@@ -0,0 +1,204 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*******************************************************************************/
#include "vl53l5_rom_boot.h"
#include "vl53l5_error_codes.h"
#include "vl53l5_platform.h"
#include "vl53l5_register_utils.h"
#define trace_print(level, ...) \
_LOG_TRACE_PRINT(VL53L5_TRACE_MODULE_POWER_API, \
level, VL53L5_TRACE_FUNCTION_ALL, ##__VA_ARGS__)
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START(VL53L5_TRACE_MODULE_POWER_API, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_POWER_API, status, ##__VA_ARGS__)
#define CHECK_FOR_TIMEOUT(status, p_dev, start_ms, end_ms, timeout_ms) \
(status = vl53l5_check_for_timeout(\
(p_dev), start_ms, end_ms, timeout_ms))
#define MCU_FIRST_BOOT_COMPLETE(p_dev) \
(VL53L5_GO2_STATUS_1(p_dev).mcu__initial_ram_boot_complete == 1)
#define MCU_FIRST_BOOT_NOT_COMPLETE(p_dev) \
(VL53L5_GO2_STATUS_1(p_dev).mcu__initial_ram_boot_complete == 0)
#define MCU_FIRST_BOOT_COMPLETE_REVISION_C(p_dev) \
(VL53L5_GO2_STATUS_1(p_dev).mcu__spare0 == 1)
#define MCU_FIRST_BOOT_NOT_COMPLETE_CUT_1_4(p_dev) \
(VL53L5_GO2_STATUS_1(p_dev).mcu__spare0 == 0)
#define DEFAULT_PAGE 2
#define GO2_PAGE 0
#define DEVICE_ID 0x0
#define REVISION_ID 0x1
#define GO2_STATUS_1 0x07
#define BYTE_SIZE_1 1
static int32_t _write_byte(
struct vl53l5_dev_handle_t *p_dev, uint16_t address, uint8_t value)
{
return vl53l5_write_multi(p_dev, address, &value, BYTE_SIZE_1);
}
static int32_t _check_device_booted(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
VL53L5_GO2_STATUS_1(p_dev).bytes = 0;
status = vl53l5_read_multi(p_dev, GO2_STATUS_1,
&VL53L5_GO2_STATUS_1(p_dev).bytes, BYTE_SIZE_1);
if (status != STATUS_OK)
goto exit;
if (p_dev->host_dev.revision_id == 0x0c) {
if (MCU_FIRST_BOOT_COMPLETE_REVISION_C(p_dev))
p_dev->host_dev.device_booted = true;
else
p_dev->host_dev.device_booted = false;
} else {
if (MCU_FIRST_BOOT_COMPLETE(p_dev))
p_dev->host_dev.device_booted = true;
else
p_dev->host_dev.device_booted = false;
}
exit:
return status;
}
static int32_t _check_rom_firmware_boot(
struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
status = vl53l5_wait_mcu_boot(p_dev, VL53L5_BOOT_STATE_HIGH, 0, 0);
(void)_write_byte(p_dev, 0x000E, 0x01);
return status;
}
int32_t vl53l5_check_rom_firmware_boot(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
LOG_FUNCTION_START("");
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
status = vl53l5_set_page(p_dev, GO2_PAGE);
if (status < STATUS_OK)
goto exit;
status = vl53l5_read_multi(
p_dev, DEVICE_ID, &p_dev->host_dev.device_id, BYTE_SIZE_1);
if (status < STATUS_OK)
goto exit_change_page;
status = vl53l5_read_multi(
p_dev, REVISION_ID, &p_dev->host_dev.revision_id, BYTE_SIZE_1);
if (status < STATUS_OK)
goto exit_change_page;
status = _check_device_booted(p_dev);
if (status < STATUS_OK)
goto exit_change_page;
if (p_dev->host_dev.device_booted == true)
goto exit_change_page;
if ((p_dev->host_dev.device_id == 0xF0) &&
(p_dev->host_dev.revision_id == 0x02 ||
p_dev->host_dev.revision_id == 0x0C)) {
trace_print(VL53L5_TRACE_LEVEL_INFO,
"device id 0x%x revision id 0x%x\n",
p_dev->host_dev.device_id,
p_dev->host_dev.revision_id);
status = _check_rom_firmware_boot(p_dev);
if (status < STATUS_OK)
goto exit_change_page;
} else {
trace_print(VL53L5_TRACE_LEVEL_ERRORS,
"Unsupported device id 0x%x revision id 0x%x\n",
p_dev->host_dev.device_id,
p_dev->host_dev.revision_id);
status = VL53L5_UNKNOWN_SILICON_REVISION;
goto exit_change_page;
}
exit_change_page:
if (status != STATUS_OK)
(void)vl53l5_set_page(p_dev, DEFAULT_PAGE);
else
status = vl53l5_set_page(p_dev, DEFAULT_PAGE);
exit:
LOG_FUNCTION_END(status);
return status;
}

View File

@@ -0,0 +1,286 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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.
*
*
*******************************************************************************/
#ifdef VL53L5_TCDM_ENABLE
#include "vl53l5_platform.h"
#include "vl53l5_tcdm_dump.h"
#define trace_print(level, ...) \
_LOG_TRACE_PRINT(VL53L5_TRACE_MODULE_POWER_API, \
level, VL53L5_TRACE_FUNCTION_ALL, ##__VA_ARGS__)
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START(VL53L5_TRACE_MODULE_POWER_API, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_POWER_API, status, ##__VA_ARGS__)
#define STXP70_TEST_A0_8 0x06
#define PAGE_SELECT 0x7FFF
#define STXP70_CTRL 0x20
#define STXP70_STATUS 0x21
#define MCU_BYPASS 0x0C
#define UI_RAM_SIZE_BYTES (12 * 1024)
#define PAGE_3_SIZE_BYTES (32 * 1024)
#define PAGE_4_SIZE_BYTES (32 * 1024)
static int32_t _write_byte(
struct vl53l5_dev_handle_t *p_dev,
uint16_t address, uint8_t value)
{
return vl53l5_write_multi(p_dev, address, &value, 1);
}
static int32_t _read_byte(
struct vl53l5_dev_handle_t *p_dev,
uint16_t address, uint8_t *p_value)
{
return vl53l5_read_multi(p_dev, address, p_value, 1);
}
static int32_t _set_page(
struct vl53l5_dev_handle_t *p_dev, uint8_t page)
{
int32_t status = STATUS_OK;
status = _write_byte(p_dev, PAGE_SELECT, page);
if (status < STATUS_OK)
goto exit;
exit:
return status;
}
static int32_t _read_page(
struct vl53l5_dev_handle_t *p_dev,
uint16_t page, uint32_t count, uint8_t *p_value)
{
int32_t status = STATUS_OK;
status = _set_page(p_dev, page);
if (status < STATUS_OK)
goto exit;
status = vl53l5_read_multi(p_dev, 0, p_value, count);
if (status < STATUS_OK)
goto exit;
exit:
return status;
}
static int32_t mcu_go1_async_access(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
LOG_FUNCTION_START("");
status = _set_page(p_dev, 0);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, MCU_BYPASS, 0x00);
if (status < STATUS_OK)
goto exit;
status = _set_page(p_dev, 1);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, STXP70_CTRL, 0x07);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, STXP70_CTRL, 0x06);
if (status < STATUS_OK)
goto exit;
exit:
LOG_FUNCTION_END(status);
return status;
}
static int32_t host_go1_async_access(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
uint8_t m_status = 0;
uint32_t start_time_ms = 0;
uint32_t current_time_ms = 0;
LOG_FUNCTION_START("");
status = _set_page(p_dev, 1);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, STXP70_TEST_A0_8, 0x01);
if (status < STATUS_OK)
goto exit;
status = vl53l5_get_tick_count(p_dev, &start_time_ms);
if (status < STATUS_OK)
goto exit;
do {
status = _read_byte(p_dev, STXP70_STATUS, &m_status);
if (status < STATUS_OK)
goto exit;
status = vl53l5_get_tick_count(p_dev, &current_time_ms);
if (status < STATUS_OK)
goto exit;
status = vl53l5_check_for_timeout(
p_dev,
start_time_ms,
current_time_ms,
VL53L5_TCDM_DUMP_STATUS_TIMEOUT);
if (status < STATUS_OK)
goto exit;
} while (m_status != 0x04);
status = _set_page(p_dev, 0);
if (status < STATUS_OK)
goto exit;
status = _write_byte(p_dev, MCU_BYPASS, 0x01);
if (status < STATUS_OK)
goto exit;
exit:
LOG_FUNCTION_END(status);
return status;
}
static int32_t dump_tcdm_state(struct vl53l5_dev_handle_t *p_dev,
uint8_t *buffer,
uint32_t *pbytes_written)
{
int32_t status = STATUS_OK;
LOG_FUNCTION_START("");
*pbytes_written = 0;
status = _read_page(p_dev, 3, PAGE_3_SIZE_BYTES, buffer);
if (status < STATUS_OK)
goto exit;
*pbytes_written += PAGE_3_SIZE_BYTES;
status = _read_page(
p_dev, 4, PAGE_4_SIZE_BYTES, buffer + PAGE_3_SIZE_BYTES);
if (status < STATUS_OK)
goto exit;
*pbytes_written += PAGE_4_SIZE_BYTES;
exit:
LOG_FUNCTION_END(status);
return status;
}
int32_t vl53l5_tcdm_dump(
struct vl53l5_dev_handle_t *p_dev, uint8_t *buffer, uint32_t *count)
{
int32_t status = STATUS_OK;
uint32_t bytes_written = 0;
uint8_t *p_buff = buffer;
LOG_FUNCTION_START("");
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (buffer == NULL) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (count == NULL) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
status = host_go1_async_access(p_dev);
if (status < STATUS_OK)
goto exit_page;
status = dump_tcdm_state(p_dev, p_buff, &bytes_written);
if (status < STATUS_OK)
goto exit_page;
*count += bytes_written;
status = mcu_go1_async_access(p_dev);
if (status < STATUS_OK)
goto exit_page;
exit_page:
if (status < STATUS_OK)
(void)_set_page(p_dev, 2);
else
status = _set_page(p_dev, 2);
exit:
LOG_FUNCTION_END(status);
return status;
}
#endif

View File

@@ -0,0 +1,86 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __CAL_DEFS_H__
#define __CAL_DEFS_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define CAL_DEF__MAX_HIST_BINS \
((uint32_t) 144U)
#define CAL_DEF__MAX_XTALK_SHAPE_BINS \
((uint32_t) 144U)
#define CAL_DEF__MAX_COLS \
((uint32_t) 10U)
#define CAL_DEF__MAX_ROWS \
((uint32_t) 8U)
#define CAL_DEF__MAX_COLS_X_MAX_ROWS \
((uint32_t) 64U)
#define CAL_DEF__XTALK_MON_MAX_ZONES \
((uint32_t) 8U)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,160 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __CAL_LUTS_H__
#define __CAL_LUTS_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define CAL_ERROR__NONE \
((int32_t) 0)
#define CAL_ERROR__NO_SAMPLE_FAIL \
((int32_t) 1)
#define CAL_ERROR__RATE_SIGMA_LIMIT_FAIL \
((int32_t) 2)
#define CAL_ERROR__RANGE_SIGMA_LIMIT_FAIL \
((int32_t) 3)
#define CAL_ERROR__MISSING_SAMPLES \
((int32_t) 4)
#define CAL_ERROR__INVALID_REPLACEMENT_MODE \
((int32_t) 5)
#define CAL_ERROR__MAX_FAILING_ZONES_LIMIT_FAIL \
((int32_t) 6)
#define CAL_ERROR__NO_VALID_ZONES \
((int32_t) 7)
#define CAL_ERROR__8x8_TO_4x4__CONVERSION_FAIL \
((int32_t) 8)
#define CAL_ERROR__TARGET_TOO_CLOSE \
((int32_t) 9)
#define CAL_WARNING__NONE \
((int32_t) 128)
#define CAL_WARNING__NO_SAMPLE_FAIL \
((int32_t) 129)
#define CAL_WARNING__RATE_SIGMA_LIMIT_FAIL \
((int32_t) 130)
#define CAL_WARNING__RANGE_SIGMA_LIMIT_FAIL \
((int32_t) 131)
#define CAL_WARNING__MISSING_SAMPLES \
((int32_t) 132)
#define CAL_WARNING__ZONE_REPLACED_BY_MIN_XTALK \
((int32_t) 133)
#define CAL_WARNING__ZONE_REPLACED_BY_FIXED_VAL_XTALK \
((int32_t) 134)
#define CAL_WARNING__8x8_TO_4x4_CONVERSION__INPUT_RATE_CLIPPED \
((int32_t) 135)
#define CAL_WARNING__8x8_TO_4x4_CONVERSION__ZERO_RATES_DETECTED \
((int32_t) 136)
#define CAL_WARNING__8x8_TO_4x4_CONVERSION__SPAD_COUNTS_SUM_CLIPPED \
((int32_t) 137)
#define CAL_WARNING__TARGET_TOO_CLOSE \
((int32_t) 138)
#define CAL_STAGE__INVALID \
((int32_t) 0)
#define CAL_STAGE__RANGE_OFFSET \
((int32_t) 1)
#define CAL_STAGE__PEAK_RATE \
((int32_t) 2)
#define CAL_STAGE__XTALK_RATE \
((int32_t) 3)
#define CAL_STAGE__XTALK_SHAPE \
((int32_t) 4)
#define CAL_STAGE__RANGE_OFFSET_8x8_TO_4x4_CONVERSION \
((int32_t) 5)
#define CAL_STAGE__PEAK_RATE_8x8_TO_4x4_CONVERSION \
((int32_t) 6)
#define CAL_STAGE__XTALK_RATE_8x8_TO_4x4_CONVERSION \
((int32_t) 7)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,202 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __CAL_SIZE_H__
#define __CAL_SIZE_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_CAL_GRP_STATUS_SZ \
((uint16_t) 16)
#define VL53L5_CAL_GRP_REF_SPAD_INFO_SZ \
((uint16_t) 8)
#define VL53L5_CAL_GRP_TEMP_SENSOR_DATA_SZ \
((uint16_t) 4)
#define VL53L5_CAL_GRP_OPTICAL_CENTRE_DATA_SZ \
((uint16_t) 4)
#define VL53L5_CAL_GRP_OSCILLATOR_DATA_SZ \
((uint16_t) 8)
#define VL53L5_CAL_GRP_VHV_DATA_SZ \
((uint16_t) 4)
#define VL53L5_CAL_GRP_GRID_META_SZ \
((uint16_t) 12)
#define VL53L5_CAL_GRP_GRID_DATA_RATE_KCPS_PER_SPAD_SZ \
((uint16_t) 256)
#define VL53L5_CGGDRKPS_CAL_GRID_DATA_RATE_KCPS_PER_SPAD_SZ \
((uint16_t) 256)
#define VL53L5_CAL_GRP_GRID_DATA_EFFECTIVE_SPAD_COUNT_SZ \
((uint16_t) 128)
#define VL53L5_CGGDESC_CAL_GRID_DATA_EFFECTIVE_SPAD_COUNT_SZ \
((uint16_t) 128)
#define VL53L5_CAL_GRP_GRID_DATA_RANGE_MM_SZ \
((uint16_t) 128)
#define VL53L5_CGGDRM_CAL_GRID_DATA_RANGE_MM_SZ \
((uint16_t) 128)
#define VL53L5_CAL_GRP_GRID_DATA_SCALE_FACTOR_SZ \
((uint16_t) 128)
#define VL53L5_CGGDSF_CAL_GRID_DATA_SCALE_FACTOR_SZ \
((uint16_t) 128)
#define VL53L5_CAL_GRP_XTALK_SHAPE_META_SZ \
((uint16_t) 12)
#define VL53L5_CAL_GRP_XTALK_SHAPE_DATA_SZ \
((uint16_t) 288)
#define VL53L5_CGXSD_CAL_XTALK_SHAPE_BIN_DATA_SZ \
((uint16_t) 288)
#define VL53L5_CAL_GRP_XTALK_MON_META_DATA_SZ \
((uint16_t) 4)
#define VL53L5_CAL_GRP_XTALK_MON_ZONES_SZ \
((uint16_t) 32)
#define VL53L5_CGXMZ_CAL_XMON_ZONE_X_OFF_SZ \
((uint16_t) 8)
#define VL53L5_CGXMZ_CAL_XMON_ZONE_Y_OFF_SZ \
((uint16_t) 8)
#define VL53L5_CGXMZ_CAL_XMON_ZONE_WIDTH_SZ \
((uint16_t) 8)
#define VL53L5_CGXMZ_CAL_XMON_ZONE_HEIGHT_SZ \
((uint16_t) 8)
#define VL53L5_CAL_GRP_XTALK_MON_DATA_SZ \
((uint16_t) 48)
#define VL53L5_CGXMD_CAL_XMON_ZONE_RATE_KCPS_SPAD_SZ \
((uint16_t) 32)
#define VL53L5_CGXMD_CAL_XMON_ZONE_AVG_COUNT_SZ \
((uint16_t) 16)
#define VL53L5_CAL_GRP_PHASE_STATS_SZ \
((uint16_t) 20)
#define VL53L5_CAL_GRP_TEMPERATURE_STATS_SZ \
((uint16_t) 4)
#define VL53L5_CAL_GRP_COMMON_SUM_DATA_SZ \
((uint16_t) 48)
#define VL53L5_CAL_GRP_XMON_SUM_DATA_SZ \
((uint16_t) 96)
#define VL53L5_CGXSD_CAL_XMON_SUM_RATE_KCPS_PER_SPAD_SZ \
((uint16_t) 64)
#define VL53L5_CGXSD_CAL_XMON_SUM_AVG_COUNT_SZ \
((uint16_t) 16)
#define VL53L5_CGXSD_CAL_XMON_SUM_SAMPLE_COUNT_SZ \
((uint16_t) 16)
#define VL53L5_CAL_GRP_ZONE_SUM_DATA_SZ \
((uint16_t) 1088)
#define VL53L5_CGZSD_CAL_ZONE_SUM_RATE_KCPS_PER_SPAD_SZ \
((uint16_t) 512)
#define VL53L5_CGZSD_CAL_ZONE_SUM_EFFECTIVE_SPAD_COUNT_SZ \
((uint16_t) 256)
#define VL53L5_CGZSD_CAL_ZONE_SUM_MEDIAN_RANGE_MM_SZ \
((uint16_t) 256)
#define VL53L5_CGZSD_CAL_ZONE_SUM_SAMPLE_COUNT_SZ \
((uint16_t) 64)
#define VL53L5_CAL_GRP_HIST_SUM_META_SZ \
((uint16_t) 8)
#define VL53L5_CAL_GRP_HIST_SUM_DATA_SZ \
((uint16_t) 1440)
#define VL53L5_CGHSD_CAL_HIST_SUM_BIN_EVENTS_SZ \
((uint16_t) 1152)
#define VL53L5_CGHSD_CAL_HIST_SUM_SAMPLE_COUNT_SZ \
((uint16_t) 288)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,235 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __CAL_STRUCTS_H__
#define __CAL_STRUCTS_H__
#include "cal_defs.h"
#include "cal_luts.h"
#include "packing_structs.h"
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
struct cal_grp__status_t {
int32_t cal__status__type;
int32_t cal__status__stage_id;
int32_t cal__target__idx;
int32_t cal__zone_id;
};
struct cal_grp__ref_spad_info_t {
uint8_t cal__ref_spad__offset;
uint8_t cal__ref_spad__count;
uint8_t cal__ref_spad__count_10x;
uint8_t cal__ref_spad__count_100x;
uint8_t cal__ref_spad__left_right_sel;
uint8_t cal__ref_spad__status;
uint8_t cal__ref_spad_info__pad_0;
uint8_t cal__ref_spad_info__pad_1;
};
struct cal_grp__optical_centre_data_t {
uint8_t cal__optical_centre__x;
uint8_t cal__optical_centre__y;
uint8_t cal__optical_centre__pad_0;
uint8_t cal__optical_centre__pad_1;
};
struct cal_grp__grid_meta_t {
int16_t cal__grid_meta__distance_mm;
uint16_t cal__grid_meta__reflectance_pc;
int8_t cal__grid_meta__silicon_temp_degc;
uint8_t cal__grid_meta__cols;
uint8_t cal__grid_meta__rows;
uint8_t cal__grid_meta__x_offset_spads;
uint8_t cal__grid_meta__y_offset_spads;
uint8_t cal__grid_meta__x_pitch_spads;
uint8_t cal__grid_meta__y_pitch_spads;
uint8_t cal__grid_meta__avg_count;
};
struct cal_grp__grid_data__rate_kcps_per_spad_t {
uint32_t cal__grid_data__rate_kcps_per_spad[
CAL_DEF__MAX_COLS_X_MAX_ROWS];
};
struct cal_grp__grid_data__effective_spad_count_t {
uint16_t cal__grid_data_effective_spad_count[
CAL_DEF__MAX_COLS_X_MAX_ROWS];
};
struct cal_grp__grid_data__range_mm_t {
int16_t cal__grid_data__range_mm[CAL_DEF__MAX_COLS_X_MAX_ROWS];
};
struct cal_grp__grid_data__scale_factor_t {
uint16_t cal__grid_data__scale_factor[CAL_DEF__MAX_COLS_X_MAX_ROWS];
};
struct cal_grp__xtalk_shape_meta_t {
uint32_t cal__xtalk_shape__median_phase;
uint16_t cal__xtalk_shape__avg_count;
uint8_t cal__xtalk_shape__no_of_bins;
uint8_t cal__xtalk_shape__normalisation_power;
int8_t cal__xtalk_shape__silicon_temp_degc;
uint8_t cal__xtalk_shape__spare_0;
uint8_t cal__xtalk_shape__spare_1;
uint8_t cal__xtalk_shape__spare_2;
};
struct cal_grp__xtalk_shape_data_t {
uint16_t cal__xtalk_shape__bin_data[CAL_DEF__MAX_XTALK_SHAPE_BINS];
};
struct cal_grp__xtalk_mon__meta_data_t {
uint8_t cal__xmon__max_zones;
uint8_t cal__xmon__no_of_zones;
uint8_t cal__xmon__zone_idx;
int8_t cal__xmon__silicon_temp_degc;
};
struct cal_grp__xtalk_mon__zones_t {
uint8_t cal__xmon__zone__x_off[CAL_DEF__XTALK_MON_MAX_ZONES];
uint8_t cal__xmon__zone__y_off[CAL_DEF__XTALK_MON_MAX_ZONES];
uint8_t cal__xmon__zone__width[CAL_DEF__XTALK_MON_MAX_ZONES];
uint8_t cal__xmon__zone__height[CAL_DEF__XTALK_MON_MAX_ZONES];
};
struct cal_grp__xtalk_mon__data_t {
uint32_t cal__xmon__zone__rate_kcps_spad[CAL_DEF__XTALK_MON_MAX_ZONES];
uint16_t cal__xmon__zone__avg_count[CAL_DEF__XTALK_MON_MAX_ZONES];
};
struct cal_grp__phase_stats_t {
uint32_t cal__stats__avg_phase__ref;
uint32_t cal__stats__avg_phase__rtn;
uint32_t cal__stats__avg_phase__flex;
uint16_t cal__stats__avg_count__ref;
uint16_t cal__stats__avg_count__rtn;
uint16_t cal__stats__avg_count__flex;
uint16_t cal__stats__spare_0;
};
struct cal_grp__temperature_stats_t {
int8_t cal__stats__avg_temp_degc__start__ref;
int8_t cal__stats__avg_temp_degc__end__ref;
int8_t cal__stats__avg_temp_degc__start__rtn;
int8_t cal__stats__avg_temp_degc__end__rtn;
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __COMMON_DATATYPE_DEFS_H__
#define __COMMON_DATATYPE_DEFS_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define COMMON_MAX_CHANNELS \
((uint32_t) 16U)
#define COMMON_MAX_HIST_BINS \
((uint32_t) 144U)
#define COMMON_MAX_XTALK_SHAPE_BINS \
((uint32_t) 144U)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,392 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __COMMON_DATATYPE_LUTS_H__
#define __COMMON_DATATYPE_LUTS_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define FUNC_ERROR__NONE \
((int16_t) 0)
#define FUNC_ERROR__PHOOK_OVERWRITE \
((int16_t) 128)
#define FUNC_ERROR__WDOG_TMOUT \
((int16_t) 129)
#define FUNC_ERROR__WDOG_FAIL \
((int16_t) 130)
#define FUNC_ERROR__PLL_LOCK_TMOUT \
((int16_t) 131)
#define FUNC_ERROR__CONT_TMOUT \
((int16_t) 132)
#define FUNC_ERROR__CONT_FAIL \
((int16_t) 133)
#define FUNC_ERROR__VCSELCP_TMOUT \
((int16_t) 134)
#define FUNC_ERROR__VCSELCP_FAIL \
((int16_t) 135)
#define FUNC_ERROR__POR_AVDD1V1_TMOUT \
((int16_t) 136)
#define FUNC_ERROR__CONT_SKIP_VECTOR \
((int16_t) 137)
#define FUNC_ERROR__INT_MGR \
((int16_t) 138)
#define FUNC_ERROR__NVM_EN_FAILED \
((int16_t) 139)
#define FUNC_ERROR__NVM_DONE_TMOUT \
((int16_t) 140)
#define FUNC_ERROR__NVM_DISABLED_FAIL \
((int16_t) 13)
#define FUNC_ERROR__TIMESTAMP_TMOUT \
((int16_t) 141)
#define FUNC_ERROR__NVM_CRC_CHECKSUM_FAILED \
((int16_t) 142)
#define FUNC_ERROR__ZONE_INVALID_NUM \
((int16_t) 143)
#define FUNC_ERROR__ZONE_OUT_OF_ACTIVE_BOUND \
((int16_t) 144)
#define FUNC_ERROR__DSS_OPTICAL_CENTRE_MISALIGNED \
((int16_t) 17)
#define FUNC_ERROR__DSS_MIN_SIG_RATE_FAIL \
((int16_t) 146)
#define FUNC_ERROR__DSS_MP_POSITION_INVALID \
((int16_t) 147)
#define FUNC_ERROR__VHV_SEARCH_FAIL \
((int16_t) 148)
#define FUNC_ERROR__RANGING_TIMEOUT \
((int16_t) 149)
#define FUNC_ERROR__VCSEL_PERIOD_CLIPPED \
((int16_t) 150)
#define FUNC_ERROR__VCSEL_STOP_CLIPPED \
((int16_t) 151)
#define FUNC_ERROR__RANGING_WINDOW_CLIPPED \
((int16_t) 152)
#define FUNC_ERROR__AMBIENT_WINDOW_DURATION_CLIPPED \
((int16_t) 153)
#define FUNC_ERROR__SPAD_EN_XFER_FAIL \
((int16_t) 154)
#define FUNC_ERROR__REF_SPAD_EN_TMOUT \
((int16_t) 155)
#define FUNC_ERROR__RTN_SPAD_EN_TMOUT \
((int16_t) 156)
#define FUNC_ERROR__SPAD_REF_STATUS_CHECK \
((int16_t) 157)
#define FUNC_ERROR__SPAD_RTN_STATUS_CHECK \
((int16_t) 158)
#define FUNC_ERROR__GRID_COLS_ROWS_OUT_BOUNDS \
((int16_t) 159)
#define FUNC_ERROR__GRID_COLS_ROWS_NOT_MULT_2 \
((int16_t) 160)
#define FUNC_ERROR__GRID_PARAM_NOT_MULT_4 \
((int16_t) 161)
#define FUNC_ERROR__GRID_ZONES_NOT_SQUARE \
((int16_t) 162)
#define FUNC_ERROR__GRID_ZONE_SIZE_OUT_BOUNDS \
((int16_t) 163)
#define FUNC_ERROR__GRID_START_OUT_BOUNDS \
((int16_t) 164)
#define FUNC_ERROR__INVALID_GRID_CONFIG \
((int16_t) 165)
#define FUNC_ERROR__OPTICAL_CENTRE_OUT_BOUNDS \
((int16_t) 166)
#define FUNC_ERROR__GRID_SIZE_TOO_LARGE \
((int16_t) 167)
#define FUNC_ERROR__REPOSITION_ARRAY_FAIL \
((int16_t) 40)
#define FUNC_WARNING__CALIBRATION \
((int16_t) 42)
#define FUNC_WARNING__PARAM_CLIPPED \
((int16_t) 43)
#define FUNC_WARNING__PARAM_INVALID \
((int16_t) 44)
#define FUNC_ERROR__MODE_NOT_SUPPORTED \
((int16_t) 45)
#define FUNC_ERROR__INVALID_CMD \
((int16_t) 46)
#define FUNC_ERROR__NO_GPIO_PIN \
((int16_t) 47)
#define FUNC_ERROR__GPIO_FN_NOT_SUPPORTED \
((int16_t) 48)
#define FUNC_ERROR__CTRL_INTERFACE \
((int16_t) 49)
#define FUNC_ERROR__VCSELCP_FAIL_RETRY \
((int16_t) 50)
#define FUNC_ERROR__REF_SPAD_INIT \
((int16_t) 178)
#define FUNC_ERROR__REF_SPAD_CHAR_NOT_ENOUGH \
((int16_t) 51)
#define FUNC_ERROR__REF_SPAD_CHAR_RATE_HIGH \
((int16_t) 52)
#define FUNC_ERROR__REF_SPAD_CHAR_RATE_LOW \
((int16_t) 53)
#define FUNC_ERROR__REF_SPAD_APPLY_NUM_MAXED \
((int16_t) 182)
#define FUNC_ERROR__REF_SPAD_APPLY_MIN_CLIP \
((int16_t) 55)
#define FUNC_ERROR__XTALK_EXTRN_NO_SAMPLE_FAIL \
((int16_t) 56)
#define FUNC_ERROR__XTALK_EXTRN_SIGMA_LIMIT_FAIL \
((int16_t) 57)
#define FUNC_ERROR__XTALK_EXTRN_MISSING_SAMPLES \
((int16_t) 58)
#define FUNC_ERROR__OFFSET_CAL_NO_SAMPLE_FAIL \
((int16_t) 59)
#define FUNC_ERROR__OFFSET_CAL_NO_SPADS_EN_FAIL \
((int16_t) 60)
#define FUNC_ERROR__OFFSET_CAL_MISSING_SAMPLES \
((int16_t) 61)
#define FUNC_ERROR__OFFSET_CAL_SIGMA_HIGH \
((int16_t) 62)
#define FUNC_ERROR__OFFSET_CAL_RATE_HIGH \
((int16_t) 63)
#define FUNC_ERROR__OFFSET_CAL_SPAD_COUNT_LOW \
((int16_t) 64)
#define FUNC_ERROR__LEGACY_MODE_CHECK_FAILED \
((int16_t) 193)
#define FUNC_ERROR__UNIT_TEST_FAIL \
((int16_t) 194)
#define FUNC_ERROR__DEBUG_DATA_REQ_UI_OVERFLOW \
((int16_t) 195)
#define FUNC_ERROR__TEMPERATURE_LIMIT_REACHED \
((int16_t) 196)
#define FUNC_ERROR__PIPE_ERROR \
((int16_t) 197)
#define FUNC_WARNING__OUTPUT_RATE_CLIPPED \
((int16_t) 70)
#define FUNC_ERROR__DYNXTALKMON_ZONES_SELECT_FAIL \
((int16_t) 199)
#define FUNC_ERROR__CAL_ERROR \
((int16_t) 200)
#define FUNC_ERROR__PIPE_WARNING \
((int16_t) 73)
#define FUNC_ERROR__CAL_WARNING \
((int16_t) 74)
#define FUNC_WARNING__INCOMPATABLE_BLANKING_INTEGRATION_MODES \
((int16_t) 75)
#define FUNC_WARNING__INTEGRATION_TIME_MIN_CLIPPED \
((int16_t) 76)
#define FUNC_WARNING__INTEGRATION_TIME_MAX_CLIPPED \
((int16_t) 77)
#define FUNC_WARNING__CP_COLLAPSE \
((int16_t) 78)
#define FUNC_ERROR__HW_NVM_COPY_LASER_SAFETY_CLIP \
((int16_t) 230)
#define FUNC_ERROR__OVER_VOLT_PROT_AVDD \
((int16_t) 233)
#define FUNC_ERROR__OVER_VOLT_PROT_ANODE \
((int16_t) 234)
#define FUNC_ERROR__OVER_VOLT_PROT_DVDDHP \
((int16_t) 235)
#define FUNC_ERROR__VCSEL_MONITOR_FAIL \
((int16_t) 236)
#define FUNC_ERROR__VCSEL_CP_OVER_CURRENT \
((int16_t) 237)
#define FUNC_ERROR__PLL_LOCK_LOST \
((int16_t) 238)
#define FUNC_ERROR__BAND_GAP_FAIL \
((int16_t) 239)
#define FUNC_ERROR__CP_COLLAPSE \
((int16_t) 240)
#define FUNC_ERROR__DVIM_DIV_BY_ZERO_TRAP \
((int16_t) 241)
#define FUNC_ERROR__OVERFLOW_TRAP \
((int16_t) 242)
#define FUNC_ERROR__TRAP_PROTECT \
((int16_t) 243)
#define FUNC_ERROR__TRAP_OPCODE \
((int16_t) 244)
#define FUNC_ERROR__TRAP_GPRSIZE \
((int16_t) 245)
#define FUNC_ERROR__TRAP_PMISALIGN \
((int16_t) 246)
#define FUNC_ERROR__TRAP_POUTOFMEM \
((int16_t) 247)
#define FUNC_ERROR__TRAP_PEXECUTE \
((int16_t) 248)
#define FUNC_ERROR__TRAP_DMISALIGN \
((int16_t) 249)
#define FUNC_ERROR__TRAP_DOUTOFMEM \
((int16_t) 250)
#define FUNC_ERROR__TRAP_DREAD \
((int16_t) 251)
#define FUNC_ERROR__TRAP_DWRITE \
((int16_t) 252)
#define FUNC_ERROR__TRAP_DVOLATILE \
((int16_t) 253)
#define FUNC_ERROR__TRAP_PSYSERR \
((int16_t) 254)
#define FUNC_EROR__PARAM_INVALID \
((int16_t) 65533)
#define FUNC_ERROR__UNDEFINED \
((int16_t) 65534)
#define FUNC_ERROR__DIVIDE_BY_ZERO \
((int16_t) 65535)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,106 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __COMMON_DATATYPE_SIZE_H__
#define __COMMON_DATATYPE_SIZE_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_COMMON_GRP_VERSION_SZ \
((uint16_t) 8)
#define VL53L5_COMMON_GRP_STATUS_SZ \
((uint16_t) 12)
#define VL53L5_COMMON_GRP_CAL_XTALK_SHAPE_DATA_SZ \
((uint16_t) 288)
#define VL53L5_CGCXSD_CAL_XTALK_SHAPE_BIN_DATA_SZ \
((uint16_t) 288)
#define VL53L5_COMMON_GRP_HIST_BIN_DATA_SZ \
((uint16_t) 576)
#define VL53L5_COMMON_GRP_HIST_BIN_DATA_PACKED_SZ \
((uint16_t) 432)
#define VL53L5_CGHBD_HIST_BIN_EVENTS_SZ \
((uint16_t) 576)
#define VL53L5_CGHBD_HIST_BIN_EVENTS_PACKED_SZ \
((uint16_t) 432)
#define VL53L5_COMMON_GRP_HIST_BIN_DATA_64B_SZ \
((uint16_t) 1152)
#define VL53L5_CGHBD6_HIST_BIN_EVENTS_64B_SZ \
((uint16_t) 1152)
#define VL53L5_COMMON_GRP_PADDING_32_SZ \
((uint16_t) 4)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,113 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __COMMON_DATATYPE_STRUCTS_H__
#define __COMMON_DATATYPE_STRUCTS_H__
#include "packing_structs.h"
#include "common_datatype_defs.h"
#include "common_datatype_luts.h"
#include "packing_structs.h"
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
struct common_grp__version_t {
uint16_t version__revision;
uint16_t version__build;
uint16_t version__minor;
uint16_t version__major;
};
struct common_grp__status_t {
int16_t status__group;
int16_t status__type;
int16_t status__stage_id;
uint16_t status__debug_0;
uint16_t status__debug_1;
uint16_t status__debug_2;
};
struct common_grp__cal__xtalk_shape_data_t {
uint16_t cal__xtalk_shape_bin_data[COMMON_MAX_XTALK_SHAPE_BINS];
};
struct common_grp__hist__bin_data_64b_t {
int64_t hist__bin_events_64b[COMMON_MAX_HIST_BINS];
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,225 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __DCI_DEFS_H__
#define __DCI_DEFS_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define DCI_DEF__FW_WORKSPACE_SIZE \
((uint32_t) 2560U)
#define DCI_DEF__UI_OUTPUT_BUFFER_SIZE \
((uint32_t) 2816U)
#define DCI_DEF__UI_COMMAND_BUFFER_SIZE \
((uint32_t) 256U)
#define DCI_MAX_CHANNELS \
((uint32_t) 16U)
#define DCI_MAX_ZONES \
((uint32_t) 68U)
#define DCI_MAX_GLOBAL_TARGETS \
((uint32_t) 8U)
#define DCI_MAX_TARGET_PER_ZONE \
((uint32_t) 4U)
#define DCI_MAX_TARGETS \
((uint32_t) 272U)
#define DCI_MAX_HIST_BINS \
((uint32_t) 144U)
#define DCI_MAX_XTALK_SHAPE_BINS \
((uint32_t) 144U)
#define DCI_REF_MPX_MAX_COLS \
((uint32_t) 4U)
#define DCI_REF_MPX_MAX_ROWS \
((uint32_t) 2U)
#define DCI_RTN_MPX_MAX_COLS \
((uint32_t) 14U)
#define DCI_RTN_MPX_MAX_ROWS \
((uint32_t) 10U)
#define DCI_OFFSET_CAL_MAX_COLS \
((uint32_t) 8U)
#define DCI_OFFSET_CAL_MAX_ROWS \
((uint32_t) 8U)
#define DCI_XTALK_CAL_MAX_COLS \
((uint32_t) 8U)
#define DCI_XTALK_CAL_MAX_ROWS \
((uint32_t) 8U)
#define DCI_XTALK_MON_MAX_ZONES \
((uint32_t) 8U)
#define DCI_INITIAL_IDX \
((uint32_t) 0U)
#define DCI_REF_MPX_MAX_COLS_X_MAX_ROWS \
((uint32_t) DCI_REF_MPX_MAX_COLS * DCI_REF_MPX_MAX_ROWS)
#define DCI_RTN_MPX_MAX_COLS_X_MAX_ROWS \
((uint32_t) DCI_RTN_MPX_MAX_COLS * DCI_RTN_MPX_MAX_ROWS)
#define DCI_OFFSET_CAL_MAX_COLS_X_MAX_ROWS \
((uint32_t) 64U)
#define DCI_XTALK_CAL_MAX_COLS_X_MAX_ROWS \
((uint32_t) 64U)
#define DCI_TRIG_CORR_MAX_COLS_X_MAX_ROWS \
((uint32_t) 64U)
#define DCI_REF_ARRAY_WIDTH_SPADS \
((uint32_t) 16U)
#define DCI_REF_ARRAY_HEIGHT_SPADS \
((uint32_t) 8U)
#define DCI_REF_ARRAY_WIDTH_X_HEIGHT_SPADS \
((uint32_t) DCI_REF_ARRAY_WIDTH_SPADS * DCI_REF_ARRAY_HEIGHT_SPADS)
#define DCI_REF_ARRAY_ENABLE_SIZE_BYTES \
((uint32_t) 16U)
#define DCI_RTN_ARRAY_WIDTH_SPADS \
((uint32_t) 56U)
#define DCI_RTN_ARRAY_HEIGHT_SPADS \
((uint32_t) 40U)
#define DCI_RTN_ARRAY_WIDTH_X_HEIGHT_SPADS \
((uint32_t) DCI_RTN_ARRAY_WIDTH_SPADS * DCI_RTN_ARRAY_HEIGHT_SPADS)
#define DCI_RTN_ARRAY_ENABLE_SIZE_BYTES \
((uint32_t) 280U)
#define DCI_RTN_MPX_BLOCK_INDEX_COUNT \
((uint32_t) 140U)
#define DCI_RTN_MPX_BLOCK_DEFINITIONS_COUNT \
((uint32_t) 16U)
#define DCI_RTN_MPX_ENABLES_SIZE_BYTES \
((uint32_t) 18U)
#define DCI_RTN_MPX_ENABLES_BUFFER_BYTES \
((uint32_t) 20U)
#define DCI_VHV_MAX_SEARCH_STEPS \
((uint32_t) 64U)
#define DCI_CAL_REF_SPAD_MAX_SEARCH_STEPS \
((uint32_t) 64U)
#define DCI_DEF__MIN_BIN_IDX \
((uint32_t) 0U)
#define DCI_DEF__MAX_BIN_IDX \
((uint32_t) 255U)
#define DCI_DEF__MIN_RATE_KCPS_PER_SPAD \
((uint32_t) 0U)
#define DCI_DEF__MAX_RATE_KCPS_PER_SPAD \
((uint32_t) 1073741823U)
#define DCI_DEF__MIN_RATE_MCPS \
((uint32_t) 0U)
#define DCI_DEF__MAX_RATE_MCPS \
((uint32_t) 524287U)
#define DCI_DEF__MIN_PHASE \
((uint32_t) 0U)
#define DCI_DEF__MAX_PHASE \
((uint32_t) 524287U)
#define DCI_DEF__MIN_RANGE_MM \
((int32_t) -32768)
#define DCI_DEF__MAX_RANGE_MM \
((int32_t) 32767)
#define DCI_DEF__MIN_RNG_SIGMA_EST_MM \
((uint32_t) 0U)
#define DCI_DEF__MAX_RNG_SIGMA_EST_MM \
((uint32_t) 65535U)
#define DCI_DEF__MIN_REFLECT_EST_PC \
((uint32_t) 0U)
#define DCI_DEF__MAX_REFLECT_EST_PC \
((uint32_t) 255U)
#define DCI__ZONE_THRESH_STATUS_ARRAY_SIZE \
((uint32_t) 8U)
#define DCI_INTERRUPT_CFG_MAX_IC_CHECKERS \
((uint32_t) 64U)
#define DCI_DEF__MAX_OP_BH_ENABLE_SIZE \
((uint32_t) 4U)
#define DCI_DEF__MAX_OP_BH_LIST_SIZE \
((uint32_t) 128U)
#define DCI_DEF__PATCH_HOOK_ENABLE_WORD32 \
((uint32_t) 4U)
#define DCI_DEF__MIN_ZSCORE \
((uint32_t) 0U)
#define DCI_DEF__MAX_ZSCORE \
((uint32_t) 65535U)
#define DCI_ZONE_CFG_SELECT__INVALID \
((uint32_t) 0U)
#define DCI_ZONE_CFG_SELECT__1X1 \
((uint32_t) 1U)
#define DCI_ZONE_CFG_SELECT__4X4 \
((uint32_t) 2U)
#define DCI_ZONE_CFG_SELECT__8X8 \
((uint32_t) 3U)
#define DCI_SHARPENER_NO_RANGE_GROUP \
((uint8_t) 255U)
#define DCI_SHARPENER_CONFIDENCE_ZERO \
((uint8_t) 0U)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,775 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __DCI_LUTS_H__
#define __DCI_LUTS_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define DCI_BH__P_TYPE__CONSEC_PARAMS_LIST \
((uint8_t) 0U)
#define DCI_BH__P_TYPE__GRP_PARAMS_START \
((uint8_t) 13U)
#define DCI_BH__P_TYPE__GRP_PARAMS_END \
((uint8_t) 14U)
#define DCI_BH__P_TYPE__END_OF_DATA \
((uint8_t) 15U)
#define DCI_FW_STATE_VAL__NOUPDATE \
((uint8_t) 0U)
#define DCI_FW_STATE_VAL__RESET_RETENTION_STATE \
((uint8_t) 1U)
#define DCI_FW_STATE_VAL__BOOT_STATE \
((uint8_t) 2U)
#define DCI_FW_STATE_VAL__DFT_STATE \
((uint8_t) 3U)
#define DCI_FW_STATE_VAL__MAIN_STATE \
((uint8_t) 4U)
#define DCI_FW_STATE_VAL__ACTIVE_STATE \
((uint8_t) 5U)
#define DCI_FW_STATE_VAL__IDLE_STATE \
((uint8_t) 6U)
#define DCI_FW_MODE_STATUS__NO_MODE \
((uint8_t) 0U)
#define DCI_FW_MODE_STATUS__STREAMING \
((uint8_t) 1U)
#define DCI_FW_MODE_STATUS__SINGLE_SHOT \
((uint8_t) 2U)
#define DCI_FW_MODE_STATUS__AUTONOMOUS \
((uint8_t) 3U)
#define DCI_CMD_STATUS__NOUPDATE \
((uint8_t) 0U)
#define DCI_CMD_STATUS__RECEIVED \
((uint8_t) 1U)
#define DCI_CMD_STATUS__PROCESSING \
((uint8_t) 2U)
#define DCI_CMD_STATUS__COMPLETED \
((uint8_t) 3U)
#define DCI_CMD_STATUS__ERROR \
((uint8_t) 4U)
#define DCI_DEVICE_STATUS__NOUPDATE \
((uint8_t) 0U)
#define DCI_DEVICE_STATUS__OK \
((uint8_t) 1U)
#define DCI_DEVICE_STATUS__VCSELCONTINUITYTESTFAILURE \
((uint8_t) 2U)
#define DCI_DEVICE_STATUS__VCSELWATCHDOGTESTFAILURE \
((uint8_t) 3U)
#define DCI_DEVICE_STATUS__VCSELREFERENCERATEFAILURE \
((uint8_t) 4U)
#define DCI_DEVICE_STATUS__NOVHVVALUEFOUND \
((uint8_t) 5U)
#define DCI_DEVICE_STATUS__USERROICLIP \
((uint8_t) 6U)
#define DCI_DEVICE_STATUS__MULTCLIPFAIL \
((uint8_t) 7U)
#define DCI_TARGET_STATUS__NOUPDATE \
((uint8_t) 0U)
#define DCI_TARGET_STATUS__MSRCNOTARGET \
((uint8_t) 1U)
#define DCI_TARGET_STATUS__RANGEPHASECHECK \
((uint8_t) 2U)
#define DCI_TARGET_STATUS__SIGMATHRESHOLDCHECK \
((uint8_t) 3U)
#define DCI_TARGET_STATUS__PHASECONSISTENCY \
((uint8_t) 4U)
#define DCI_TARGET_STATUS__RANGECOMPLETE \
((uint8_t) 5U)
#define DCI_TARGET_STATUS__RANGECOMPLETE_NO_WRAP_CHECK \
((uint8_t) 6U)
#define DCI_TARGET_STATUS__EVENTCONSISTENCY \
((uint8_t) 7U)
#define DCI_TARGET_STATUS__MINSIGNALEVENTCHECK \
((uint8_t) 8U)
#define DCI_TARGET_STATUS__RANGECOMPLETE_MERGED_PULSE \
((uint8_t) 9U)
#define DCI_TARGET_STATUS__PREV_RANGE_NO_TARGETS \
((uint8_t) 10U)
#define DCI_TARGET_STATUS__RANGEIGNORETHRESHOLD \
((uint8_t) 11U)
#define DCI_TARGET_STATUS__TARGETDUETOBLUR \
((uint8_t) 12U)
#define DCI_TARGET_STATUS__TARGETDUETOLONGTAIL \
((uint8_t) 13U)
#define DCI_TARGET_STATUS__TARGETSEPARATIONTOOSMALL \
((uint8_t) 14U)
#define DCI_TARGET_STATUS__TARGETDUETOBLUR_NO_WRAP_CHECK \
((uint8_t) 15U)
#define DCI_TARGET_STATUS__TARGETDUETOBLUR_MERGED_PULSE \
((uint8_t) 16U)
#define DCI_TARGET_STATUS__RANGECOMPLETE_PILE_UP \
((uint8_t) 17U)
#define DCI_CMD_ID__NULL \
((uint8_t) 0U)
#define DCI_CMD_ID__SET_PARMS \
((uint8_t) 1U)
#define DCI_CMD_ID__GET_PARMS \
((uint8_t) 2U)
#define DCI_CMD_ID__START_RANGE \
((uint8_t) 3U)
#define DCI_CMD_ID__STOP_RANGE \
((uint8_t) 4U)
#define DCI_DISTANCE_MODE__NONE \
((uint8_t) 0U)
#define DCI_DISTANCE_MODE__AUTO \
((uint8_t) 1U)
#define DCI_DISTANCE_MODE__SHORT \
((uint8_t) 2U)
#define DCI_DISTANCE_MODE__LONG \
((uint8_t) 3U)
#define DCI_RNG_MODE__NONE \
((uint8_t) 0U)
#define DCI_RNG_MODE__BACK_TO_BACK \
((uint8_t) 1U)
#define DCI_RNG_MODE__SINGLE_SHOT \
((uint8_t) 2U)
#define DCI_RNG_MODE__TIMED \
((uint8_t) 3U)
#define DCI_RNG_MODE__CAL__REF_SPAD \
((uint8_t) 4U)
#define DCI_RNG_MODE__CAL__REF_SPAD_WITH_VHV_SEARCH \
((uint8_t) 5U)
#define DCI_RNG_MODE__CAL__XTALK__SINGLE_TARGET \
((uint8_t) 6U)
#define DCI_RNG_MODE__CAL__XTALK__DUAL_TARGET_0 \
((uint8_t) 7U)
#define DCI_RNG_MODE__CAL__XTALK__DUAL_TARGET_1 \
((uint8_t) 8U)
#define DCI_RNG_MODE__CAL__OFFSET_AND_DMAX \
((uint8_t) 9U)
#define DCI_RNG_MODE__TEST__VHV_SEARCH \
((uint8_t) 10U)
#define DCI_RNG_MODE__TEST__SSC__DCR \
((uint8_t) 11U)
#define DCI_RNG_MODE__TEST__SSC__LCR \
((uint8_t) 12U)
#define DCI_RNG_MODE__TEST__SSC__VCR \
((uint8_t) 13U)
#define DCI_RNG_MODE__BACK_TO_BACK_BLANK \
((uint8_t) 14U)
#define DCI_B2BB_DISABLE__RNG_CORE \
((uint8_t) 1U)
#define DCI_B2BB_DISABLE__PLL \
((uint8_t) 2U)
#define DCI_LIVE_XTALK_MODE__NONE \
((uint8_t) 0U)
#define DCI_LIVE_XTALK_MODE__DISABLED \
((uint8_t) 1U)
#define DCI_LIVE_XTALK_MODE__ENABLED \
((uint8_t) 2U)
#define DCI_INTEGRATION_MODE__NONE \
((uint8_t) 0U)
#define DCI_INTEGRATION_MODE__MIN \
((uint8_t) 1U)
#define DCI_INTEGRATION_MODE__MAX \
((uint8_t) 2U)
#define DCI_INTEGRATION_MODE__RANGING_RATE \
((uint8_t) 3U)
#define DCI_INTEGRATION_MODE__AUTO__INVERSE_DMAX \
((uint8_t) 4U)
#define DCI_INTEGRATION_MODE__AUTO__RNG_SIGMA \
((uint8_t) 5U)
#define DCI_BLANKING_MODE__OFF \
((uint8_t) 0U)
#define DCI_BLANKING_MODE__BA \
((uint8_t) 1U)
#define DCI_BLANKING_MODE__AB_BA \
((uint8_t) 2U)
#define DCI_BLANKING_TYPE__INVALID \
((uint8_t) 0U)
#define DCI_BLANKING_TYPE__NORMAL \
((uint8_t) 1U)
#define DCI_BLANKING_TYPE__RETENTION \
((uint8_t) 2U)
#define DCI_BLANKING_TYPE__INTERRUPT \
((uint8_t) 3U)
#define DCI_DSS_MODE__NONE \
((uint8_t) 0U)
#define DCI_DSS_MODE__AUTO \
((uint8_t) 1U)
#define DCI_DSS_MODE__PAUSE \
((uint8_t) 2U)
#define DCI_DSS_MODE__MANUAL \
((uint8_t) 3U)
#define DCI_DSS_SPATIAL_MODE__INVALID \
((uint8_t) 0U)
#define DCI_DSS_SPATIAL_MODE__OFF \
((uint8_t) 1U)
#define DCI_DSS_SPATIAL_MODE__ON \
((uint8_t) 2U)
#define DCI_HIST_TYPE__INVALID \
((uint8_t) 0U)
#define DCI_HIST_TYPE__RTN_ARRAY \
((uint8_t) 1U)
#define DCI_HIST_TYPE__REF_ARRAY \
((uint8_t) 2U)
#define DCI_HIST_TYPE__XTALK \
((uint8_t) 3U)
#define DCI_HIST_TYPE__OFFSET \
((uint8_t) 4U)
#define DCI_HIST_TYPE__FLEX \
((uint8_t) 5U)
#define DCI_HIST_TYPE__XTALK__FLEX \
((uint8_t) 6U)
#define DCI_HIST_TYPE__OFFSET__FLEX \
((uint8_t) 7U)
#define DCI_HIST_TYPE__ACC \
((uint8_t) 8U)
#define DCI_HIST_TYPE__ACC__XTALK \
((uint8_t) 9U)
#define DCI_HIST_TYPE__ACC__OFFSET \
((uint8_t) 10U)
#define DCI_HIST_TYPE__ACC__PARTIAL \
((uint8_t) 11U)
#define DCI_MPX_TYPE__INVALID \
((uint8_t) 0U)
#define DCI_MPX_TYPE__RTN_ARRAY \
((uint8_t) 1U)
#define DCI_MPX_TYPE__REF_ARRAY \
((uint8_t) 2U)
#define DCI_MPX_TYPE__RTN_XTALK \
((uint8_t) 3U)
#define DCI_MPX_TYPE__RTN_OFFSET \
((uint8_t) 4U)
#define DCI__AMB_RATE_KCPS_PER_SPAD__EN \
((uint32_t) 1U)
#define DCI__AMB_RATE_MCPS__EN \
((uint32_t) 2U)
#define DCI__RNG__EFFECTIVE_SPAD_COUNT__EN \
((uint32_t) 4U)
#define DCI__AMB_DMAX_MM__EN \
((uint32_t) 8U)
#define DCI__RNG__NO_OF_TARGETS__EN \
((uint32_t) 16U)
#define DCI__RNG__ZONE_ID__EN \
((uint32_t) 32U)
#define DCI__PEAK_RATE_KCPS_PER_SPAD__EN \
((uint32_t) 1U)
#define DCI__PEAK_RATE_MCPS__EN \
((uint32_t) 2U)
#define DCI__MEDIAN_RANGE_MM__EN \
((uint32_t) 4U)
#define DCI__MEDIAN_PHASE__EN \
((uint32_t) 8U)
#define DCI__TARGET_RANGING_EVENTS__EN \
((uint32_t) 16U)
#define DCI__TARGET_AMB_EVENTS__EN \
((uint32_t) 32U)
#define DCI__SIGNAL_SIGMA_EVENTS__EN \
((uint32_t) 64U)
#define DCI__RANGE_SIIGMA_MM__EN \
((uint32_t) 128U)
#define DCI__MIN_RANGE_DELTA_MM__EN \
((uint32_t) 256U)
#define DCI__MAX_RANGE_DELTA_MM__EN \
((uint32_t) 512U)
#define DCI__TARGET_STATUS__EN \
((uint32_t) 1024U)
#define DCI__GBL_TGT__PEAK_RATE_KCPS_PER_SPAD__EN \
((uint32_t) 1U)
#define DCI__GBL_TGT__AMB_RATE_KCPS_PER_SPAD__EN \
((uint32_t) 2U)
#define DCI__GBL_TGT__PEAK_RATE_MCPS__EN \
((uint32_t) 4U)
#define DCI__GBL_TGT__AMB_RATE_MCPS__EN \
((uint32_t) 8U)
#define DCI__GBL_TGT__MEDIAN_RANGE_MM__EN \
((uint32_t) 16U)
#define DCI__GBL_TGT__MIN_RANGE_DELTA_MM__EN \
((uint32_t) 32U)
#define DCI__GBL_TGT__MAX_RANGE_DELTA_MM__EN \
((uint32_t) 64U)
#define DCI__GBL_TGT__STATUS__EN \
((uint32_t) 128U)
#define DCI__GBL_TGT__X_CENTRE__EN \
((uint32_t) 256U)
#define DCI__GBL_TGT__Y_CENTRE__EN \
((uint32_t) 512U)
#define DCI__GBL_TGT__WIDTH__EN \
((uint32_t) 1024U)
#define DCI__GBL_TGT__HEIGHT__EN \
((uint32_t) 2048U)
#define DCI__GBL_TGT__NO_OF_ROIS__EN \
((uint32_t) 4096U)
#define DCI__RTN_MPX__PEAK_RATE_KCPS_PER_SPAD__EN \
((uint32_t) 1U)
#define DCI__RTN_MPX__AMB_RATE_KCPS_PER_SPAD__EN \
((uint32_t) 2U)
#define DCI__RTN_MPX__PEAK_RATE_MCPS__EN \
((uint32_t) 4U)
#define DCI__RTN_MPX__AMB_RATE_MCPS__EN \
((uint32_t) 8U)
#define DCI__RTN_MPX__RANGING_TOTAL_EVENTS__EN \
((uint32_t) 16U)
#define DCI__RTN_MPX__AMBIENT_WINDOW_EVENTS__EN \
((uint32_t) 32U)
#define DCI__RTN_MPX__EFFECTIVE_SPAD_COUNT__EN \
((uint32_t) 64U)
#define DCI__RTN_MPX__CONFIDENCE__EN \
((uint32_t) 128U)
#define DCI__DYN_XTALK_LEAKAGE_FULL_IDX \
((uint8_t) 0U)
#define DCI__DYN_XTALK_LEAKAGE_LEFT_IDX \
((uint8_t) 1U)
#define DCI__DYN_XTALK_LEAKAGE_RIGHT_IDX \
((uint8_t) 2U)
#define DCI__DYN_XTALK_LEAKAGE_SPARE_IDX \
((uint8_t) 3U)
#define DCI__DYN_XTALK_MONITOR_LEFT_1_IDX \
((uint8_t) 4U)
#define DCI__DYN_XTALK_MONITOR_LEFT_2_IDX \
((uint8_t) 5U)
#define DCI__DYN_XTALK_MONITOR_RIGHT_1_IDX \
((uint8_t) 6U)
#define DCI__DYN_XTALK_MONITOR_RIGHT_2_IDX \
((uint8_t) 7U)
#define DCI__INTERRUPT_CFG_MODE__NONE \
((uint8_t) 0U)
#define DCI__INTERRUPT_CFG_MODE__NEW_DATA_READY \
((uint8_t) 1U)
#define DCI__INTERRUPT_CFG_MODE__THRESHOLDS \
((uint8_t) 2U)
#define DCI__PHOOK_EN_00_HOOK_000 \
((uint32_t) 1U)
#define DCI__PHOOK_EN_00_HOOK_001 \
((uint32_t) 2U)
#define DCI__PHOOK_EN_00_HOOK_002 \
((uint32_t) 4U)
#define DCI__PHOOK_EN_00_HOOK_003 \
((uint32_t) 8U)
#define DCI__PHOOK_EN_00_HOOK_004 \
((uint32_t) 16U)
#define DCI__PHOOK_EN_00_HOOK_005 \
((uint32_t) 32U)
#define DCI__PHOOK_EN_00_HOOK_006 \
((uint32_t) 64U)
#define DCI__PHOOK_EN_00_HOOK_007 \
((uint32_t) 128U)
#define DCI__PHOOK_EN_00_HOOK_008 \
((uint32_t) 256U)
#define DCI__PHOOK_EN_00_HOOK_009 \
((uint32_t) 512U)
#define DCI__PHOOK_EN_00_HOOK_010 \
((uint32_t) 1024U)
#define DCI__PHOOK_EN_00_HOOK_011 \
((uint32_t) 2048U)
#define DCI__PHOOK_EN_00_HOOK_012 \
((uint32_t) 4096U)
#define DCI__PHOOK_EN_00_HOOK_013 \
((uint32_t) 8192U)
#define DCI__PHOOK_EN_00_HOOK_014 \
((uint32_t) 16384U)
#define DCI__PHOOK_EN_00_HOOK_015 \
((uint32_t) 32768U)
#define DCI__PHOOK_EN_00_HOOK_016 \
((uint32_t) 65536U)
#define DCI__PHOOK_EN_00_HOOK_017 \
((uint32_t) 131072U)
#define DCI__PHOOK_EN_00_HOOK_018 \
((uint32_t) 262144U)
#define DCI__PHOOK_EN_00_HOOK_019 \
((uint32_t) 524288U)
#define DCI__PHOOK_EN_00_HOOK_020 \
((uint32_t) 1048576U)
#define DCI__PHOOK_EN_00_HOOK_021 \
((uint32_t) 2097152U)
#define DCI__PHOOK_EN_00_HOOK_022 \
((uint32_t) 4194304U)
#define DCI__PHOOK_EN_00_HOOK_023 \
((uint32_t) 8388608U)
#define DCI__PHOOK_EN_00_HOOK_024 \
((uint32_t) 16777216U)
#define DCI__PHOOK_EN_00_HOOK_025 \
((uint32_t) 33554432U)
#define DCI__PHOOK_EN_00_HOOK_026 \
((uint32_t) 67108864U)
#define DCI__PHOOK_EN_00_HOOK_027 \
((uint32_t) 134217728U)
#define DCI__PHOOK_EN_00_HOOK_028 \
((uint32_t) 268435456U)
#define DCI__PHOOK_EN_00_HOOK_029 \
((uint32_t) 536870912U)
#define DCI__PHOOK_EN_00_HOOK_030 \
((uint32_t) 1073741824U)
#define DCI__PHOOK_EN_00_HOOK_031 \
((uint32_t) 2147483648U)
#define DCI__PHOOK_EN_01_HOOK_032 \
((uint32_t) 1U)
#define DCI__PHOOK_EN_01_HOOK_033 \
((uint32_t) 2U)
#define DCI__PHOOK_EN_01_HOOK_034 \
((uint32_t) 4U)
#define DCI__PHOOK_EN_01_HOOK_035 \
((uint32_t) 8U)
#define DCI__PHOOK_EN_01_HOOK_036 \
((uint32_t) 16U)
#define DCI__PHOOK_EN_01_HOOK_037 \
((uint32_t) 32U)
#define DCI__PHOOK_EN_01_HOOK_038 \
((uint32_t) 64U)
#define DCI__PHOOK_EN_01_HOOK_039 \
((uint32_t) 128U)
#define DCI__PHOOK_EN_01_HOOK_040 \
((uint32_t) 256U)
#define DCI__PHOOK_EN_01_HOOK_041 \
((uint32_t) 512U)
#define DCI__PHOOK_EN_01_HOOK_042 \
((uint32_t) 1024U)
#define DCI__PHOOK_EN_01_HOOK_043 \
((uint32_t) 2048U)
#define DCI__PHOOK_EN_01_HOOK_044 \
((uint32_t) 4096U)
#define DCI__PHOOK_EN_01_HOOK_045 \
((uint32_t) 8192U)
#define DCI__PHOOK_EN_01_HOOK_046 \
((uint32_t) 16384U)
#define DCI__PHOOK_EN_01_HOOK_047 \
((uint32_t) 32768U)
#define DCI__PHOOK_EN_01_HOOK_048 \
((uint32_t) 65536U)
#define DCI__PHOOK_EN_01_HOOK_049 \
((uint32_t) 131072U)
#define DCI__PHOOK_EN_01_HOOK_050 \
((uint32_t) 262144U)
#define DCI__PHOOK_EN_01_HOOK_051 \
((uint32_t) 524288U)
#define DCI__PHOOK_EN_01_HOOK_052 \
((uint32_t) 1048576U)
#define DCI__PHOOK_EN_01_HOOK_053 \
((uint32_t) 2097152U)
#define DCI__PHOOK_EN_01_HOOK_054 \
((uint32_t) 4194304U)
#define DCI__PHOOK_EN_01_HOOK_055 \
((uint32_t) 8388608U)
#define DCI__PHOOK_EN_01_HOOK_056 \
((uint32_t) 16777216U)
#define DCI__PHOOK_EN_01_HOOK_057 \
((uint32_t) 33554432U)
#define DCI__PHOOK_EN_01_HOOK_058 \
((uint32_t) 67108864U)
#define DCI__PHOOK_EN_01_HOOK_059 \
((uint32_t) 134217728U)
#define DCI__PHOOK_EN_01_HOOK_060 \
((uint32_t) 268435456U)
#define DCI__PHOOK_EN_01_HOOK_061 \
((uint32_t) 536870912U)
#define DCI__PHOOK_EN_01_HOOK_062 \
((uint32_t) 1073741824U)
#define DCI__PHOOK_EN_01_HOOK_063 \
((uint32_t) 2147483648U)
#define DCI__PHOOK_EN_02_HOOK_064 \
((uint32_t) 1U)
#define DCI__PHOOK_EN_02_HOOK_065 \
((uint32_t) 2U)
#define DCI__PHOOK_EN_02_HOOK_066 \
((uint32_t) 4U)
#define DCI__PHOOK_EN_02_HOOK_067 \
((uint32_t) 8U)
#define DCI__PHOOK_EN_02_HOOK_068 \
((uint32_t) 16U)
#define DCI__PHOOK_EN_02_HOOK_069 \
((uint32_t) 32U)
#define DCI__PHOOK_EN_02_HOOK_070 \
((uint32_t) 64U)
#define DCI__PHOOK_EN_02_HOOK_071 \
((uint32_t) 128U)
#define DCI__PHOOK_EN_02_HOOK_072 \
((uint32_t) 256U)
#define DCI__PHOOK_EN_02_HOOK_073 \
((uint32_t) 512U)
#define DCI__PHOOK_EN_02_HOOK_074 \
((uint32_t) 1024U)
#define DCI__PHOOK_EN_02_HOOK_075 \
((uint32_t) 2048U)
#define DCI__PHOOK_EN_02_HOOK_076 \
((uint32_t) 4096U)
#define DCI__PHOOK_EN_02_HOOK_077 \
((uint32_t) 8192U)
#define DCI__PHOOK_EN_02_HOOK_078 \
((uint32_t) 16384U)
#define DCI__PHOOK_EN_02_HOOK_079 \
((uint32_t) 32768U)
#define DCI__PHOOK_EN_02_HOOK_080 \
((uint32_t) 65536U)
#define DCI__PHOOK_EN_02_HOOK_081 \
((uint32_t) 131072U)
#define DCI__PHOOK_EN_02_HOOK_082 \
((uint32_t) 262144U)
#define DCI__PHOOK_EN_02_HOOK_083 \
((uint32_t) 524288U)
#define DCI__PHOOK_EN_02_HOOK_084 \
((uint32_t) 1048576U)
#define DCI__PHOOK_EN_02_HOOK_085 \
((uint32_t) 2097152U)
#define DCI__PHOOK_EN_02_HOOK_086 \
((uint32_t) 4194304U)
#define DCI__PHOOK_EN_02_HOOK_087 \
((uint32_t) 8388608U)
#define DCI__PHOOK_EN_02_HOOK_088 \
((uint32_t) 16777216U)
#define DCI__PHOOK_EN_02_HOOK_089 \
((uint32_t) 33554432U)
#define DCI__PHOOK_EN_02_HOOK_090 \
((uint32_t) 67108864U)
#define DCI__PHOOK_EN_02_HOOK_091 \
((uint32_t) 134217728U)
#define DCI__PHOOK_EN_02_HOOK_092 \
((uint32_t) 268435456U)
#define DCI__PHOOK_EN_02_HOOK_093 \
((uint32_t) 536870912U)
#define DCI__PHOOK_EN_02_HOOK_094 \
((uint32_t) 1073741824U)
#define DCI__PHOOK_EN_02_HOOK_095 \
((uint32_t) 2147483648U)
#define DCI__PHOOK_EN_03_HOOK_096 \
((uint32_t) 1U)
#define DCI__PHOOK_EN_03_HOOK_097 \
((uint32_t) 2U)
#define DCI__PHOOK_EN_03_HOOK_098 \
((uint32_t) 4U)
#define DCI__PHOOK_EN_03_HOOK_099 \
((uint32_t) 8U)
#define DCI__PHOOK_EN_03_HOOK_100 \
((uint32_t) 16U)
#define DCI__PHOOK_EN_03_HOOK_101 \
((uint32_t) 32U)
#define DCI__PHOOK_EN_03_HOOK_102 \
((uint32_t) 64U)
#define DCI__PHOOK_EN_03_HOOK_103 \
((uint32_t) 128U)
#define DCI__PHOOK_EN_03_HOOK_104 \
((uint32_t) 256U)
#define DCI__PHOOK_EN_03_HOOK_105 \
((uint32_t) 512U)
#define DCI__PHOOK_EN_03_HOOK_106 \
((uint32_t) 1024U)
#define DCI__PHOOK_EN_03_HOOK_107 \
((uint32_t) 2048U)
#define DCI__PHOOK_EN_03_HOOK_108 \
((uint32_t) 4096U)
#define DCI__PHOOK_EN_03_HOOK_109 \
((uint32_t) 8192U)
#define DCI__PHOOK_EN_03_HOOK_110 \
((uint32_t) 16384U)
#define DCI__PHOOK_EN_03_HOOK_111 \
((uint32_t) 32768U)
#define DCI__PHOOK_EN_03_HOOK_112 \
((uint32_t) 65536U)
#define DCI__PHOOK_EN_03_HOOK_113 \
((uint32_t) 131072U)
#define DCI__PHOOK_EN_03_HOOK_114 \
((uint32_t) 262144U)
#define DCI__PHOOK_EN_03_HOOK_115 \
((uint32_t) 524288U)
#define DCI__PHOOK_EN_03_HOOK_116 \
((uint32_t) 1048576U)
#define DCI__PHOOK_EN_03_HOOK_117 \
((uint32_t) 2097152U)
#define DCI__PHOOK_EN_03_HOOK_118 \
((uint32_t) 4194304U)
#define DCI__PHOOK_EN_03_HOOK_119 \
((uint32_t) 8388608U)
#define DCI__PHOOK_EN_03_HOOK_120 \
((uint32_t) 16777216U)
#define DCI__PHOOK_EN_03_HOOK_121 \
((uint32_t) 33554432U)
#define DCI__PHOOK_EN_03_HOOK_122 \
((uint32_t) 67108864U)
#define DCI__PHOOK_EN_03_HOOK_123 \
((uint32_t) 134217728U)
#define DCI__PHOOK_EN_03_HOOK_124 \
((uint32_t) 268435456U)
#define DCI__PHOOK_EN_03_HOOK_125 \
((uint32_t) 536870912U)
#define DCI__PHOOK_EN_03_HOOK_126 \
((uint32_t) 1073741824U)
#define DCI__PHOOK_EN_03_HOOK_127 \
((uint32_t) 2147483648U)
#define DCI__ZONE_ID__ACC__0 \
((uint8_t) 251U)
#define DCI_ZONE_ID__REF \
((uint8_t) 255U)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,541 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __DCI_SIZE_H__
#define __DCI_SIZE_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_FW_WORKSPACE_SZ \
((uint16_t) 10240)
#define VL53L5_FW_FW_WORKSPACE_ARRAY_SZ \
((uint16_t) 10240)
#define VL53L5_UI_BUFFER_SZ \
((uint16_t) 11264)
#define VL53L5_UB_DCI_OUTPUT_BUFFER_SZ \
((uint16_t) 11264)
#define VL53L5_MAP_VERSION_SZ \
((uint16_t) 4)
#define VL53L5_FW_VERSION_SZ \
((uint16_t) 8)
#define VL53L5_CFG_INFO_SZ \
((uint16_t) 20)
#define VL53L5_CP_COLLAPSE_CTRL_SZ \
((uint16_t) 4)
#define VL53L5_SILICON_TEMPERATURE_DATA_SZ \
((uint16_t) 4)
#define VL53L5_FMT_TRACEABILITY_SZ \
((uint16_t) 24)
#define VL53L5_EWS_TRACEABILITY_SZ \
((uint16_t) 12)
#define VL53L5_ZONE_CFG_SZ \
((uint16_t) 8)
#define VL53L5_DEVICE_MODE_CFG_SZ \
((uint16_t) 8)
#define VL53L5_DSS_CFG_SZ \
((uint16_t) 16)
#define VL53L5_RANGING_RATE_CFG_SZ \
((uint16_t) 4)
#define VL53L5_INTEGRATION_TIME_CFG_SZ \
((uint16_t) 4)
#define VL53L5_FACTORY_CAL_CFG_SZ \
((uint16_t) 8)
#define VL53L5_OUTPUT_DATA_CFG_SZ \
((uint16_t) 4)
#define VL53L5_INTERRUPT_CFG_SZ \
((uint16_t) 8)
#define VL53L5_TIMING_CFG_SZ \
((uint16_t) 16)
#define VL53L5_STATIC_TIMING_CFG_SZ \
((uint16_t) 8)
#define VL53L5_VHV_CFG_SZ \
((uint16_t) 12)
#define VL53L5_REF_MSR_CFG_SZ \
((uint16_t) 8)
#define VL53L5_VHV_REF_SCHEDULING_CTRL_SZ \
((uint16_t) 8)
#define VL53L5_CAL_REF_SPAD_CFG_SZ \
((uint16_t) 8)
#define VL53L5_SSC_CFG_SZ \
((uint16_t) 4)
#define VL53L5_CAL_REF_SPAD_INFO_SZ \
((uint16_t) 8)
#define VL53L5_CAL_TEMP_SENSOR_DATA_SZ \
((uint16_t) 4)
#define VL53L5_CAL_OPTICAL_CENTRE_DATA_SZ \
((uint16_t) 4)
#define VL53L5_REF_ARRAY_META_DATA_SZ \
((uint16_t) 8)
#define VL53L5_RTN_ARRAY_META_DATA_SZ \
((uint16_t) 8)
#define VL53L5_REF_ARRAY_SPAD_ENABLES_SZ \
((uint16_t) 16)
#define VL53L5_RASE_REF_ARRAY_SPADS_ENABLES_SZ \
((uint16_t) 16)
#define VL53L5_RTN_ARRAY_SPAD_ENABLES_SZ \
((uint16_t) 280)
#define VL53L5_RASE_RTN_ARRAY_SPAD_ENABLES_SZ \
((uint16_t) 280)
#define VL53L5_UI_RNG_DATA_ADDR_SZ \
((uint16_t) 12)
#define VL53L5_BUF_META_DATA_SZ \
((uint16_t) 12)
#define VL53L5_HIST_ZONE_GRID_POINT_META_DATA_SZ \
((uint16_t) 8)
#define VL53L5_HIST_ZONE_GRID_POINT_DATA_SZ \
((uint16_t) 136)
#define VL53L5_HZGPD_HIST_ZONE_CENTRE_X_COORD_SZ \
((uint16_t) 68)
#define VL53L5_HZGPD_HIST_ZONE_CENTRE_Y_COORD_SZ \
((uint16_t) 68)
#define VL53L5_HIST_COMMON_DATA_SZ \
((uint16_t) 20)
#define VL53L5_HIST_TIMING_DATA_SZ \
((uint16_t) 4)
#define VL53L5_HIST_CHANNEL_DATA_SZ \
((uint16_t) 224)
#define VL53L5_HIST_CHANNEL_DATA_PACKED_SZ \
((uint16_t) 176)
#define VL53L5_HCD_HIST_EFFECTIVE_SPAD_COUNT_SZ \
((uint16_t) 64)
#define VL53L5_HCD_HIST_EFFECTIVE_SPAD_COUNT_PACKED_SZ \
((uint16_t) 48)
#define VL53L5_HCD_HIST_AMB_WINDOW_EVENTS_SZ \
((uint16_t) 64)
#define VL53L5_HCD_HIST_AMB_WINDOW_EVENTS_PACKED_SZ \
((uint16_t) 48)
#define VL53L5_HCD_HIST_AMB_EVENTS_PER_BIN_SZ \
((uint16_t) 64)
#define VL53L5_HCD_HIST_AMB_EVENTS_PER_BIN_PACKED_SZ \
((uint16_t) 48)
#define VL53L5_HCD_HIST_ZONE_ID_SZ \
((uint16_t) 16)
#define VL53L5_HCD_HIST_TYPE_SZ \
((uint16_t) 16)
#define VL53L5_HIST_REF_CHANNEL_DATA_SZ \
((uint16_t) 16)
#define VL53L5_HIST_REF_CHANNEL_DATA_PACKED_SZ \
((uint16_t) 13)
#define VL53L5_HIST_ACC_DATA_SZ \
((uint16_t) 8)
#define VL53L5_MPX_META_DATA_SZ \
((uint16_t) 4)
#define VL53L5_MPX_COMMON_DATA_SZ \
((uint16_t) 12)
#define VL53L5_MPX_TIMING_DATA_SZ \
((uint16_t) 4)
#define VL53L5_REF_MPX_DATA_SZ \
((uint16_t) 192)
#define VL53L5_RMD_REF_MPX_PEAK_RATE_KCPS_PER_SPAD_SZ \
((uint16_t) 32)
#define VL53L5_RMD_REF_MPX_AMB_RATE_KCPS_PER_SPAD_SZ \
((uint16_t) 32)
#define VL53L5_RMD_REF_MPX_RANGING_TOTAL_EVENTS_SZ \
((uint16_t) 32)
#define VL53L5_RMD_REF_MPX_AMBIENT_WINDOW_EVENTS_SZ \
((uint16_t) 32)
#define VL53L5_RMD_REF_MPX_EFFECTIVE_SPAD_COUNT_SZ \
((uint16_t) 32)
#define VL53L5_RMD_REF_MPX_SPATIAL_METRIC_SZ \
((uint16_t) 32)
#define VL53L5_RTN_MPX_DATA_SZ \
((uint16_t) 3360)
#define VL53L5_RMD_RTN_MPX_PEAK_RATE_KCPS_PER_SPAD_SZ \
((uint16_t) 560)
#define VL53L5_RMD_RTN_MPX_AMB_RATE_KCPS_PER_SPAD_SZ \
((uint16_t) 560)
#define VL53L5_RMD_RTN_MPX_RANGING_TOTAL_EVENTS_SZ \
((uint16_t) 560)
#define VL53L5_RMD_RTN_MPX_AMBIENT_WINDOW_EVENTS_SZ \
((uint16_t) 560)
#define VL53L5_RMD_RTN_MPX_EFFECTIVE_SPAD_COUNT_SZ \
((uint16_t) 560)
#define VL53L5_RMD_RTN_MPX_SPATIAL_METRIC_SZ \
((uint16_t) 560)
#define VL53L5_RNG_TIMING_DATA_SZ \
((uint16_t) 12)
#define VL53L5_RNG_COMMON_DATA_SZ \
((uint16_t) 8)
#define VL53L5_RNG_PER_ZONE_DATA_SZ \
((uint16_t) 1020)
#define VL53L5_RPZD_AMB_RATE_KCPS_PER_SPAD_SZ \
((uint16_t) 4 * VL53L5_MAX_ZONES)
#define VL53L5_RPZD_RNG_EFFECTIVE_SPAD_COUNT_SZ \
((uint16_t) 4 * VL53L5_MAX_ZONES)
#define VL53L5_RPZD_AMB_DMAX_MM_SZ \
((uint16_t) 2 * VL53L5_MAX_ZONES)
#define VL53L5_RPZD_SILICON_TEMP_DEGC_START_SZ \
((uint16_t) 1 * VL53L5_MAX_ZONES)
#define VL53L5_RPZD_SILICON_TEMP_DEGC_END_SZ \
((uint16_t) 1 * VL53L5_MAX_ZONES)
#define VL53L5_RPZD_RNG_NO_OF_TARGETS_SZ \
((uint16_t) 1 * VL53L5_MAX_ZONES)
#define VL53L5_RPZD_RNG_ZONE_ID_SZ \
((uint16_t) 1 * VL53L5_MAX_ZONES)
#define VL53L5_RPZD_RNG_SEQUENCE_IDX_SZ \
((uint16_t) 1 * VL53L5_MAX_ZONES)
#define VL53L5_RNG_PER_TARGET_DATA_SZ \
((uint16_t) 7072)
#define VL53L5_RPTD_PEAK_RATE_KCPS_PER_SPAD_SZ \
((uint16_t) 4 * VL53L5_MAX_TARGETS)
#define VL53L5_RPTD_MEDIAN_PHASE_SZ \
((uint16_t) 4 * VL53L5_MAX_TARGETS)
#define VL53L5_RPTD_RATE_SIGMA_KCPS_PER_SPAD_SZ \
((uint16_t) 4 * VL53L5_MAX_TARGETS)
#define VL53L5_RPTD_TARGET_ZSCORE_SZ \
((uint16_t) 2 * VL53L5_MAX_TARGETS)
#define VL53L5_RPTD_RANGE_SIGMA_MM_SZ \
((uint16_t) 2 * VL53L5_MAX_TARGETS)
#define VL53L5_RPTD_MEDIAN_RANGE_MM_SZ \
((uint16_t) 2 * VL53L5_MAX_TARGETS)
#define VL53L5_RPTD_START_RANGE_MM_SZ \
((uint16_t) 2 * VL53L5_MAX_TARGETS)
#define VL53L5_RPTD_END_RANGE_MM_SZ \
((uint16_t) 2 * VL53L5_MAX_TARGETS)
#define VL53L5_RPTD_MIN_RANGE_DELTA_MM_SZ \
((uint16_t) 1 * VL53L5_MAX_TARGETS)
#define VL53L5_RPTD_MAX_RANGE_DELTA_MM_SZ \
((uint16_t) 1 * VL53L5_MAX_TARGETS)
#define VL53L5_RPTD_TARGET_REFLECTANCE_EST_PC_SZ \
((uint16_t) 1 * VL53L5_MAX_TARGETS)
#define VL53L5_RPTD_TARGET_STATUS_SZ \
((uint16_t) 1 * VL53L5_MAX_TARGETS)
#define VL53L5_REF_CHANNEL_DATA_SZ \
((uint16_t) 16)
#define VL53L5_REF_TARGET_DATA_SZ \
((uint16_t) 28)
#define VL53L5_GBL_TGT_META_DATA_SZ \
((uint16_t) 8)
#define VL53L5_GBL_TGT_DATA_SZ \
((uint16_t) 216)
#define VL53L5_GBL_TGT_DATA_PACKED_SZ \
((uint16_t) 200)
#define VL53L5_GTD_GBL_TGT_PEAK_RATE_KCPS_PER_SPAD_SZ \
((uint16_t) 32)
#define VL53L5_GTD_GBL_TGT_AMB_RATE_KCPS_PER_SPAD_SZ \
((uint16_t) 32)
#define VL53L5_GTD_GBL_TGT_PEAK_RATE_MCPS_SZ \
((uint16_t) 32)
#define VL53L5_GTD_GBL_TGT_PEAK_RATE_MCPS_PACKED_SZ \
((uint16_t) 24)
#define VL53L5_GTD_GBL_TGT_AMB_RATE_MCPS_SZ \
((uint16_t) 32)
#define VL53L5_GTD_GBL_TGT_AMB_RATE_MCPS_PACKED_SZ \
((uint16_t) 24)
#define VL53L5_GTD_GBL_TGT_MEDIAN_RANGE_MM_SZ \
((uint16_t) 16)
#define VL53L5_GTD_GBL_TGT_MIN_RANGE_DELTA_MM_SZ \
((uint16_t) 8)
#define VL53L5_GTD_GBL_TGT_MAX_RANGE_DELTA_MM_SZ \
((uint16_t) 8)
#define VL53L5_GTD_GBL_TGT_REFLECT_EST_PC_SZ \
((uint16_t) 8)
#define VL53L5_GTD_GBL_TGT_STATUS_SZ \
((uint16_t) 8)
#define VL53L5_GTD_GBL_TGT_X_CENTRE_SZ \
((uint16_t) 8)
#define VL53L5_GTD_GBL_TGT_Y_CENTRE_SZ \
((uint16_t) 8)
#define VL53L5_GTD_GBL_TGT_WIDTH_SZ \
((uint16_t) 8)
#define VL53L5_GTD_GBL_TGT_HEIGHT_SZ \
((uint16_t) 8)
#define VL53L5_GTD_GBL_TGT_NO_OF_ROIS_SZ \
((uint16_t) 8)
#define VL53L5_VHV_RESULT_DATA_SZ \
((uint16_t) 8)
#define VL53L5_VHV_SEARCH_DATA_SZ \
((uint16_t) 384)
#define VL53L5_VSD_VHV_SEARCH_EVENTS_SZ \
((uint16_t) 256)
#define VL53L5_VSD_VHV_SEARCH_VHV_VALUE_SZ \
((uint16_t) 64)
#define VL53L5_VSD_VHV_SEARCH_SILICON_TEMP_DEGC_SZ \
((uint16_t) 64)
#define VL53L5_CAL_REF_SPAD_SEARCH_META_DATA_SZ \
((uint16_t) 4)
#define VL53L5_CAL_REF_SPAD_SEARCH_DATA_SZ \
((uint16_t) 384)
#define VL53L5_CRSSD_CAL_REF_SPAD_SEARCH_TOTAL_RATE_MCPS_SZ \
((uint16_t) 256)
#define VL53L5_CRSSD_CAL_REF_SPAD_SEARCH_COUNT_SZ \
((uint16_t) 64)
#define VL53L5_CRSSD_CAL_REF_SPAD_SEARCH_APERTURE_SZ \
((uint16_t) 64)
#define VL53L5_SHARPENER_TARGET_DATA_SZ \
((uint16_t) 544)
#define VL53L5_STD_SHARPENER_GROUP_INDEX_SZ \
((uint16_t) 1 * VL53L5_MAX_TARGETS)
#define VL53L5_STD_SHARPENER_CONFIDENCE_SZ \
((uint16_t) 1 * VL53L5_MAX_TARGETS)
#define VL53L5_XTALK_MON_META_DATA_SZ \
((uint16_t) 4)
#define VL53L5_XTALK_MON_ZONES_SZ \
((uint16_t) 32)
#define VL53L5_XMZ_XTALK_MON_ZONE_X_OFF_SZ \
((uint16_t) 8)
#define VL53L5_XMZ_XTALK_MON_ZONE_Y_OFF_SZ \
((uint16_t) 8)
#define VL53L5_XMZ_XTALK_MON_ZONE_WIDTH_SZ \
((uint16_t) 8)
#define VL53L5_XMZ_XTALK_MON_ZONE_HEIGHT_SZ \
((uint16_t) 8)
#define VL53L5_XTALK_MON_DATA_SZ \
((uint16_t) 112)
#define VL53L5_XMD_XTALK_MON_PEAK_RATE_KCPS_SPAD_SZ \
((uint16_t) 32)
#define VL53L5_XMD_XTALK_MON_AMB_RATE_KCPS_SPAD_SZ \
((uint16_t) 32)
#define VL53L5_XMD_XTALK_MON_PEAK_RATE_SIGMA_KCPS_PER_SPAD_SZ \
((uint16_t) 32)
#define VL53L5_XMD_XTALK_MON_MPX_COUNT_SZ \
((uint16_t) 16)
#define VL53L5_DYN_XTALK_PERSISTENT_DATA_SZ \
((uint16_t) 28)
#define VL53L5_ZONE_THRESH_STATUS_ARRAY_SZ \
((uint16_t) 8)
#define VL53L5_ZTSA_ZONE_THRESH_STATUS_BYTES_SZ \
((uint16_t) 8)
#define VL53L5_NVM_LASER_SAFETY_NVM2_SZ \
((uint16_t) 4)
#define VL53L5_OUTPUT_BH_CFG_SZ \
((uint16_t) 8)
#define VL53L5_OUTPUT_BH_ENABLES_SZ \
((uint16_t) 16)
#define VL53L5_OBE_OP_BH_ENABLES_SZ \
((uint16_t) 16)
#define VL53L5_OUTPUT_BH_LIST_SZ \
((uint16_t) 512)
#define VL53L5_OBL_OP_BH_LIST_SZ \
((uint16_t) 512)
#define VL53L5_PATCH_HOOK_ENABLES_SZ \
((uint16_t) 16)
#define VL53L5_PHE_PATCH_HOOK_ENABLES_SZ \
((uint16_t) 16)
#define VL53L5_ACC_ZONE_GENERAL_CFG_SZ \
((uint16_t) 4)
#define VL53L5_ACC_ZONE_ARRAYED_CFG_SZ \
((uint16_t) 68)
#define VL53L5_AZAC_ACC_ZONE_0_IDS_SZ \
((uint16_t) 68)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,650 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __DCI_STRUCTS_H__
#define __DCI_STRUCTS_H__
#include "vl53l5_results_config.h"
#include "packing_structs.h"
#include "dci_defs.h"
#include "dci_luts.h"
#include "dci_union_structs.h"
#include "packing_structs.h"
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
struct dci_grp__map_version_t {
uint16_t map__major;
uint16_t map__minor;
};
struct dci_grp__fw_version_t {
uint16_t fw__revision;
uint16_t fw__build;
uint16_t fw__minor;
uint16_t fw__major;
};
struct dci_grp__cfg_info_t {
union dci_union__config_presets_u cfg__presets;
union dci_union__config_parms_u cfg__parms;
uint32_t cfg__timing_ranging_rate_hz;
uint32_t cfg__results__size_bytes;
uint16_t cfg__version_major;
uint16_t cfg__version_minor;
};
struct dci_grp__silicon_temperature_data_t {
int8_t silicon_temp_degc__start;
int8_t silicon_temp_degc__end;
int8_t silicon_temp__pad_0;
int8_t silicon_temp__pad_1;
};
struct dci_grp__fmt_traceability_t {
union dci_union__st_fgc_0_u st_fgc_0_u;
union dci_union__st_fgc_1_u st_fgc_1_u;
union dci_union__st_fgc_2_u st_fgc_2_u;
union dci_union__st_fgc_3_u st_fgc_3_u;
union dci_union__identification_0_u identification_0_u;
union dci_union__identification_1_u identification_1_u;
};
struct dci_grp__ews_traceability_t {
union dci_union__test_traceability_u test_traceability_u;
union dci_union__die_traceability_0_u die_traceability_0_u;
union dci_union__die_traceability_1_u die_traceability_1_u;
};
struct dci_grp__zone_cfg_t {
uint8_t zone__grid_cols;
uint8_t zone__grid_rows;
uint8_t zone__grid_x_ll;
uint8_t zone__grid_y_ll;
uint8_t zone__grid_x_pitch;
uint8_t zone__grid_y_pitch;
uint8_t zone__pad_0;
uint8_t zone__pad_1;
};
struct dci_grp__device_mode_cfg_t {
uint8_t distance_mode;
uint8_t ranging_mode;
uint8_t live_xtalk_mode;
uint8_t integration__mode;
uint8_t blanking__mode;
uint8_t blanking__type;
uint8_t zone_cfg_select;
uint8_t device_mode__spare_0;
};
struct dci_grp__ranging_rate_cfg_t {
uint32_t ranging_rate_hz;
};
struct dci_grp__integration_time_cfg_t {
uint32_t integration_time_us;
};
struct dci_grp__factory_cal_cfg_t {
int16_t factory_cal__target_distance_mm;
uint16_t factory_cal__target_reflectance_pc;
uint8_t factory_cal__no_of_samples;
uint8_t factory_cal__pad_0;
uint8_t factory_cal__pad_1;
uint8_t factory_cal__pad_2;
};
struct dci_grp__output_data_cfg_t {
uint8_t output__max_targets_per_zone;
uint8_t output__dummy_bytes;
uint8_t output__spare_0;
uint8_t output__spare_1;
};
struct dci_grp__interrupt_cfg_t {
union dci_union__interrupt__config_u interrupt__config;
uint8_t interrupt__cfg_mode;
uint8_t interrupt__cfg_num_active_checkers;
uint8_t interrupt__cfg_spare_0;
uint8_t interrupt__cfg_spare_1;
uint8_t interrupt__cfg_spare_2;
uint8_t interrupt__cfg_spare_3;
uint8_t interrupt__cfg_spare_4;
};
struct dci_grp__cal__ref_spad_info_t {
uint8_t cal__ref_spad__offset;
uint8_t cal__ref_spad__count;
uint8_t cal__ref_spad__count_10x;
uint8_t cal__ref_spad__count_100x;
uint8_t cal__ref_spad__left_right_sel;
uint8_t cal__ref_spad__status;
uint8_t cal__ref_spad_info__pad_0;
uint8_t cal__ref_spad_info__pad_1;
};
struct dci_grp__cal__temp_sensor_data_t {
uint8_t cal__temp_sensor__degc;
uint8_t cal__temp_sensor__value;
uint8_t cal__temp_sensor__pad_0;
uint8_t cal__temp_sensor__pad_1;
};
struct dci_grp__cal__optical_centre_data_t {
uint8_t cal__optical_centre__x;
uint8_t cal__optical_centre__y;
uint8_t cal__optical_centre__pad_0;
uint8_t cal__optical_centre__pad_1;
};
struct dci_grp__ui_rng_data_addr_t {
uint16_t ui_rng_data_int_start_addr;
uint16_t ui_rng_data_int_end_addr;
uint16_t ui_rng_data_dummy_bytes;
uint16_t ui_rng_data_offset_bytes;
uint16_t ui_rng_data_size_bytes;
uint16_t ui_device_info_start_addr;
};
struct vl53l5_range_meta_data_t {
uint32_t time_stamp;
uint8_t device_status;
uint8_t transaction_id;
uint8_t buffer_id;
uint8_t stream_count;
int8_t silicon_temp_degc;
uint8_t buf_meta_data__pad_0;
uint8_t buf_meta_data__pad_1;
uint8_t buf_meta_data__pad_2;
};
struct vl53l5_range_timing_data_t {
uint32_t rng__integration_time_us;
uint32_t rng__total_periods_elapsed;
uint32_t rng__blanking_time_us;
};
struct vl53l5_range_common_data_t {
uint16_t wrap_dmax_mm;
uint8_t rng__no_of_zones;
uint8_t rng__max_targets_per_zone;
uint8_t rng__acc__no_of_zones;
uint8_t rng__acc__zone_id;
uint8_t rng__common__spare_0;
uint8_t rng__common__spare_1;
};
struct vl53l5_range_per_zone_results_t {
#ifdef VL53L5_AMB_RATE_KCPS_PER_SPAD_ON
uint32_t amb_rate_kcps_per_spad[VL53L5_MAX_ZONES];
#endif
#ifdef VL53L5_EFFECTIVE_SPAD_COUNT_ON
uint32_t rng__effective_spad_count[VL53L5_MAX_ZONES];
#endif
#ifdef VL53L5_AMB_DMAX_MM_ON
uint16_t amb_dmax_mm[VL53L5_MAX_ZONES];
#endif
#ifdef VL53L5_SILICON_TEMP_DEGC_START_ON
int8_t silicon_temp_degc__start[VL53L5_MAX_ZONES];
#endif
#ifdef VL53L5_SILICON_TEMP_DEGC_END_ON
int8_t silicon_temp_degc__end[VL53L5_MAX_ZONES];
#endif
#ifdef VL53L5_NO_OF_TARGETS_ON
uint8_t rng__no_of_targets[VL53L5_MAX_ZONES];
#endif
#ifdef VL53L5_ZONE_ID_ON
uint8_t rng__zone_id[VL53L5_MAX_ZONES];
#endif
#ifdef VL53L5_SEQUENCE_IDX_ON
uint8_t rng__sequence_idx[VL53L5_MAX_ZONES];
#endif
#if !defined(VL53L5_AMB_RATE_KCPS_PER_SPAD_ON) && \
!defined(VL53L5_EFFECTIVE_SPAD_COUNT_ON) && \
!defined(VL53L5_AMB_DMAX_MM_ON) && \
!defined(VL53L5_SILICON_TEMP_DEGC_START_ON) && \
!defined(VL53L5_SILICON_TEMP_DEGC_END_ON) && \
!defined(VL53L5_NO_OF_TARGETS_ON) && \
!defined(VL53L5_ZONE_ID_ON) && \
!defined(VL53L5_SEQUENCE_IDX_ON)
uint32_t dummy;
#endif
};
struct vl53l5_range_per_tgt_results_t {
#ifdef VL53L5_PEAK_RATE_KCPS_PER_SPAD_ON
uint32_t peak_rate_kcps_per_spad[VL53L5_MAX_TARGETS];
#endif
#ifdef VL53L5_MEDIAN_PHASE_ON
uint32_t median_phase[VL53L5_MAX_TARGETS];
#endif
#ifdef VL53L5_RATE_SIGMA_KCPS_PER_SPAD_ON
uint32_t rate_sigma_kcps_per_spad[VL53L5_MAX_TARGETS];
#endif
#ifdef VL53L5_TARGET_ZSCORE_ON
uint16_t target_zscore[VL53L5_MAX_TARGETS];
#endif
#ifdef VL53L5_RANGE_SIGMA_MM_ON
uint16_t range_sigma_mm[VL53L5_MAX_TARGETS];
#endif
#ifdef VL53L5_MEDIAN_RANGE_MM_ON
int16_t median_range_mm[VL53L5_MAX_TARGETS];
#endif
#ifdef VL53L5_START_RANGE_MM_ON
int16_t start_range_mm[VL53L5_MAX_TARGETS];
#endif
#ifdef VL53L5_END_RANGE_MM_ON
int16_t end_range_mm[VL53L5_MAX_TARGETS];
#endif
#ifdef VL53L5_MIN_RANGE_DELTA_MM_ON
uint8_t min_range_delta_mm[VL53L5_MAX_TARGETS];
#endif
#ifdef VL53L5_MAX_RANGE_DELTA_MM_ON
uint8_t max_range_delta_mm[VL53L5_MAX_TARGETS];
#endif
#ifdef VL53L5_TARGET_REFLECTANCE_EST_PC_ON
uint8_t target_reflectance_est_pc[VL53L5_MAX_TARGETS];
#endif
#ifdef VL53L5_TARGET_STATUS_ON
uint8_t target_status[VL53L5_MAX_TARGETS];
#endif
#if !defined(VL53L5_PEAK_RATE_KCPS_PER_SPAD_ON) && \
!defined(VL53L5_MEDIAN_PHASE_ON) && \
!defined(VL53L5_RATE_SIGMA_KCPS_PER_SPAD_ON) && \
!defined(VL53L5_TARGET_ZSCORE_ON) && \
!defined(VL53L5_RANGE_SIGMA_MM_ON) && \
!defined(VL53L5_MEDIAN_RANGE_MM_ON) && \
!defined(VL53L5_START_RANGE_MM_ON) && \
!defined(VL53L5_END_RANGE_MM_ON) && \
!defined(VL53L5_MIN_RANGE_DELTA_MM_ON) && \
!defined(VL53L5_MAX_RANGE_DELTA_MM_ON) && \
!defined(VL53L5_TARGET_REFLECTANCE_EST_PC_ON) && \
!defined(VL53L5_TARGET_STATUS_ON)
uint32_t dummy;
#endif
};
struct vl53l5_ref_channel_data_t {
uint32_t amb_rate_kcps_per_spad;
uint32_t rng__effective_spad_count;
uint16_t amb_dmax_mm;
int8_t silicon_temp_degc__start;
int8_t silicon_temp_degc__end;
uint8_t rng__no_of_targets;
uint8_t rng__zone_id;
uint8_t rng__sequence_idx;
uint8_t ref_channel_data__pad_0;
};
struct vl53l5_ref_target_data_t {
uint32_t peak_rate_kcps_per_spad;
uint32_t median_phase;
uint32_t rate_sigma_kcps_per_spad;
uint16_t target_zscore;
uint16_t range_sigma_mm;
int16_t median_range_mm;
int16_t start_range_mm;
int16_t end_range_mm;
uint8_t min_range_delta_mm;
uint8_t max_range_delta_mm;
uint8_t target_reflectance_est_pc;
uint8_t target_status;
uint8_t ref_target_data__pad_0;
uint8_t ref_target_data__pad_1;
};
struct dci_grp__gbl_tgt_meta_data_t {
uint16_t gbl_tgt__wrap_dmax_mm;
uint16_t gbl_tgt__amb_dmax_mm;
uint8_t gbl_tgt__no_of_targets;
uint8_t gbl_tgt__max_targets;
uint8_t gbl_tgt__pad_0;
uint8_t gbl_tgt__pad_1;
};
struct dci_grp__gbl_tgt_data_t {
uint32_t gbl_tgt__peak_rate_kcps_per_spad[DCI_MAX_GLOBAL_TARGETS];
uint32_t gbl_tgt__amb_rate_kcps_per_spad[DCI_MAX_GLOBAL_TARGETS];
uint32_t gbl_tgt__peak_rate_mcps[DCI_MAX_GLOBAL_TARGETS];
uint32_t gbl_tgt__amb_rate_mcps[DCI_MAX_GLOBAL_TARGETS];
uint16_t gbl_tgt__median_range_mm[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__min_range_delta_mm[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__max_range_delta_mm[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__reflect_est_pc[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__status[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__x_centre[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__y_centre[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__width[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__height[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__no_of_rois[DCI_MAX_GLOBAL_TARGETS];
};
struct vl53l5_sharpener_target_data_t {
#ifdef VL53L5_SHARPENER_GROUP_INDEX_ON
uint8_t sharpener__group_index[VL53L5_MAX_TARGETS];
#endif
#ifdef VL53L5_SHARPENER_CONFIDENCE_ON
uint8_t sharpener__confidence[VL53L5_MAX_TARGETS];
#endif
#if !defined(VL53L5_SHARPENER_GROUP_INDEX_ON) && \
!defined(VL53L5_SHARPENER_CONFIDENCE_ON)
uint32_t dummy;
#endif
};
struct vl53l5_dyn_xtalk_persistent_data_t {
uint32_t dyn_xt__dyn_xtalk_grid_maximum_kcps_per_spad;
uint32_t dyn_xt__dyn_xtalk_grid_max_sigma_kcps_per_spad;
uint32_t dyn_xt__new_max_xtalk_sigma_kcps_per_spad;
int32_t dyn_xt__calibration_gain;
int32_t temp_comp__temp_gain;
uint16_t dyn_xt__nb_samples;
uint16_t dyn_xt__desired_samples;
uint8_t dyn_xt__accumulating;
uint8_t dyn_xt__grid_ready;
uint8_t dyn_xt__grid_ready_internal;
uint8_t dyn_xt__persist_spare_2;
};
struct vl53l5_zone_thresh_status_array_t {
#ifdef VL53L5_ZONE_THRESH_STATUS_BYTES_ON
uint8_t zone_thresh_status_bytes[DCI__ZONE_THRESH_STATUS_ARRAY_SIZE];
#endif
#if !defined(VL53L5_ZONE_THRESH_STATUS_BYTES_ON)
uint32_t dummy;
#endif
};
struct dci_grp__nvm_laser_safety_nvm2_t {
uint32_t nvm_laser_safety__regdvdd1v1_sel_lp;
};
struct dci_grp__output_bh_cfg_t {
uint32_t op_bh__op_packet_size_bytes;
uint32_t op_bh__debug_data_start;
};
struct dci_grp__output_bh_enables_t {
uint32_t op_bh__enables[DCI_DEF__MAX_OP_BH_ENABLE_SIZE];
};
struct dci_grp__output_bh_list_t {
uint32_t op_bh__list[DCI_DEF__MAX_OP_BH_LIST_SIZE];
};
struct dci_grp__patch_hook_enables_t {
uint32_t patch_hook_enables[DCI_DEF__PATCH_HOOK_ENABLE_WORD32];
};
struct dci_grp__gbl_tgt_data_packed_t {
uint32_t gbl_tgt__peak_rate_kcps_per_spad[DCI_MAX_GLOBAL_TARGETS];
uint32_t gbl_tgt__amb_rate_kcps_per_spad[DCI_MAX_GLOBAL_TARGETS];
struct bit_packed_24 gbl_tgt__peak_rate_mcps[
DCI_MAX_GLOBAL_TARGETS / 4];
struct bit_packed_24 gbl_tgt__amb_rate_mcps[DCI_MAX_GLOBAL_TARGETS / 4];
uint16_t gbl_tgt__median_range_mm[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__min_range_delta_mm[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__max_range_delta_mm[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__reflect_est_pc[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__status[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__x_centre[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__y_centre[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__width[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__height[DCI_MAX_GLOBAL_TARGETS];
uint8_t gbl_tgt__no_of_rois[DCI_MAX_GLOBAL_TARGETS];
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,103 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __DCI_UI_MEMORY_DEFS_H__
#define __DCI_UI_MEMORY_DEFS_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define DCI_UI__DEVICE_INFO__START_IDX \
((uint32_t) 0x810000)
#define DCI_UI__DEVICE_INFO__SIZE_BYTES \
((uint32_t) 4U)
#define DCI_UI__RANGE_DATA__START_IDX \
((uint32_t) 0x810008)
#define DCI_UI__COMMAND_WRITE__END_IDX \
((uint32_t) 0x812FFB - 0x04)
#define DCI_UI__COMMAND_INFO__START_IDX \
((uint32_t) DCI_UI__COMMAND_WRITE__END_IDX + 1)
#define DCI_UI__COMMAND_INFO__SIZE_BYTES \
((uint32_t) 4U)
#define DCI_UI__COMMAND_FOOTER__START_IDX \
((uint32_t) 0x812FF8 - 0x04)
#define DCI_UI__COMMAND_FOOTER__SIZE_BYTES \
((uint32_t) 4U)
#define DCI_UI__COMMAND_RETURN__START_IDX \
((uint32_t) 0x812C00)
#define DCI_UI__FIRMWARE_CHECKSUM_IDX \
((uint32_t) 0x812FFC)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,100 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __DCI_UI_SIZE_H__
#define __DCI_UI_SIZE_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_DCI_UI_CMD_FOOTER_SZ \
((uint16_t) 4)
#define VL53L5_DCI_UI_CMD_INFO_SZ \
((uint16_t) 4)
#define VL53L5_DCI_UI_DEV_INFO_SZ \
((uint16_t) 4)
#define VL53L5_DCI_UI_RNG_DATA_HEADER_SZ \
((uint16_t) 4)
#define VL53L5_DCI_UI_RNG_DATA_FOOTER_SZ \
((uint16_t) 4)
#define VL53L5_DCI_UI_PACKED_DATA_BH_SZ \
((uint16_t) 4)
#define VL53L5_DCI_UI_HOST_PACKED_DATA_BH_SZ \
((uint16_t) 8)
#define VL53L5_DCI_UI_FW_BREAKPOINTS_SZ \
((uint16_t) 4)
#define VL53L5_DCI_UI_FW_CHECKSUM_SZ \
((uint16_t) 4)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,126 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __DCI_UI_STRUCTS_H__
#define __DCI_UI_STRUCTS_H__
#include "dci_defs.h"
#include "dci_luts.h"
#include "dci_ui_union_structs.h"
#include "packing_structs.h"
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
struct dci_ui__cmd_footer_t {
union dci_union__cmd_footer_u cmd_footer;
};
struct dci_ui__cmd_info_t {
union dci_union__cmd_info_u cmd_info;
};
struct dci_ui__dev_info_t {
union dci_union__go2_status_0_go1_u dev_info__go2_status_0;
union dci_union__go2_status_1_go1_u dev_info__go2_status_1;
uint8_t dev_info__device_status;
uint8_t dev_info__ui_stream_count;
};
struct dci_ui__rng_data__header_t {
union dci_union__rng_data__header_u rng_data_header;
};
struct dci_ui__rng_data__footer_t {
union dci_union__rng_data__footer_u rng_data_footer;
};
struct dci_ui__packed_data__bh_t {
union dci_union__block_header_u packed_data__bh;
};
struct dci_ui__host_packed_data__bh_t {
union dci_union__block_header_u packed_data__bh;
uint32_t block_sz_bytes;
};
struct dci_ui__fw_breakpoints_t {
uint32_t fw_breakpoints_status;
};
struct dci_ui__fw_checksum_t {
uint32_t fw_checksum;
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,164 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __DCI_UI_UNION_STRUCTS_H__
#define __DCI_UI_UNION_STRUCTS_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
union dci_union__go2_status_0_go1_u {
uint8_t bytes;
struct {
uint8_t mcu__boot_complete_go1 : 1;
uint8_t mcu__analog_checks_ok_go1 : 1;
uint8_t mcu__threshold_triggered_g01 : 1;
uint8_t mcu__error_flag_go1 : 1;
uint8_t mcu__ui_range_data_present_go1 : 1;
uint8_t mcu__ui_new_range_data_avail_go1 : 1;
uint8_t mcu__ui_update_blocked_go1 : 1;
uint8_t mcu__hw_trap_flag_go1 : 1;
};
};
union dci_union__go2_status_1_go1_u {
uint8_t bytes;
struct {
uint8_t mcu__avdd_reg_ok_go1 : 1;
uint8_t mcu__pll_lock_ok_go1 : 1;
uint8_t mcu__ls_watchdog_pass_go1 : 1;
uint8_t mcu__warning_flag_go1 : 1;
uint8_t mcu__cp_collapse_flag_go1 : 1;
uint8_t mcu__spare0 : 1;
uint8_t mcu__initial_ram_boot_complete : 1;
uint8_t mcu__spare1 : 1;
};
};
union dci_union__block_header_u {
uint32_t bytes;
struct {
uint32_t p_type : 4;
uint32_t b_size__p_rep : 12;
uint32_t b_idx__p_idx : 16;
};
};
union dci_union__cmd_footer_u {
uint32_t bytes;
struct {
uint32_t cmd__ip_data_size : 16;
uint32_t cmd__ip_command_id : 8;
uint32_t cmd__ip_transaction_id : 8;
};
};
union dci_union__cmd_info_u {
uint32_t bytes;
struct {
uint32_t cmd__rtn_data_size : 16;
uint32_t cmd__rtn_command_status : 8;
uint32_t cmd__rtn_transaction_id : 8;
};
};
union dci_union__rng_data__header_u {
uint32_t bytes;
struct {
uint32_t rng_data__header__id : 16;
uint32_t rng_data__header__reserved_0 : 8;
uint32_t rng_data__header__reserved_1 : 8;
};
};
union dci_union__rng_data__footer_u {
uint32_t bytes;
struct {
uint32_t rng_data__footer__id : 16;
uint32_t rng_data__footer__reserved_0 : 8;
uint32_t rng_data__footer__reserved_1 : 8;
};
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,326 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __DCI_UNION_STRUCTS_H__
#define __DCI_UNION_STRUCTS_H__
#include "dci_defs.h"
#include "dci_version_defs.h"
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
union dci_union__config_presets_u {
uint32_t bytes;
struct {
uint32_t config__preset__0 : 4;
uint32_t config__preset__1 : 4;
uint32_t config__preset__2 : 4;
uint32_t config__preset__3 : 4;
uint32_t config__preset__4 : 4;
uint32_t config__preset__5 : 4;
uint32_t config__preset__6 : 4;
uint32_t config__preset__7 : 4;
};
};
union dci_union__config_parms_u {
uint32_t bytes;
struct {
uint32_t config__parms__0 : 8;
uint32_t config__parms__1 : 4;
uint32_t config__parms__2 : 4;
uint32_t config__parms__3 : 4;
uint32_t config__parms__4 : 4;
uint32_t config__parms__5 : 2;
uint32_t config__parms__6 : 2;
uint32_t config__parms__7 : 2;
uint32_t config__parms__8 : 1;
uint32_t config__parms__9 : 1;
};
};
union dci_union__interrupt__config_u {
uint8_t bytes;
struct {
uint8_t interrupt__config__pos_edge : 1;
uint8_t interrupt__config__pad_0 : 1;
uint8_t interrupt__config__pad_1 : 1;
uint8_t interrupt__config__pad_2 : 1;
uint8_t interrupt__config__pad_3 : 1;
uint8_t interrupt__config__pad_4 : 1;
uint8_t interrupt__config__pad_5 : 1;
uint8_t interrupt__config__pad_6 : 1;
};
};
union dci_union__vhv__config_u {
uint8_t bytes;
struct {
uint8_t stage_en : 1;
uint8_t manual_override : 1;
uint8_t init_mode : 1;
uint8_t vcsel_enable : 1;
uint8_t debug_en : 1;
uint8_t search_source : 1;
uint8_t search_reset : 1;
uint8_t search_control : 1;
};
};
union dci_union__ref_msr__config_u {
uint8_t bytes;
struct {
uint8_t stage_en : 1;
uint8_t laser_safety_check_en : 1;
uint8_t ref_msr__config__pad_0 : 1;
uint8_t ref_msr__config__pad_1 : 1;
uint8_t ref_msr__config__pad_2 : 1;
uint8_t ref_msr__config__pad_3 : 1;
uint8_t ref_msr__config__pad_4 : 1;
uint8_t ref_msr__config__pad_5 : 1;
};
};
union dci_union__vhv_ref_scheduling_ctrl_u {
uint8_t bytes;
struct {
uint8_t vhv_repeat_en : 1;
uint8_t ref_msr_repeat_en : 1;
uint8_t vhv_ref_scheduling_pad_0 : 1;
uint8_t vhv_ref_scheduling_pad_1 : 1;
uint8_t vhv_ref_scheduling_pad_2 : 1;
uint8_t vhv_ref_scheduling_pad_3 : 1;
uint8_t vhv_ref_scheduling_pad_4 : 1;
uint8_t vhv_ref_scheduling_pad_5 : 1;
};
};
union dci_union__cal__ref_spad__debug_cfg_u {
uint8_t bytes;
struct {
uint8_t debug_en : 1;
uint8_t cal__ref_spad__debug_cfg__pad_0 : 1;
uint8_t cal__ref_spad__debug_cfg__pad_1 : 1;
uint8_t cal__ref_spad__debug_cfg__pad_2 : 1;
uint8_t cal__ref_spad__debug_cfg__pad_3 : 1;
uint8_t cal__ref_spad__debug_cfg__pad_4 : 1;
uint8_t cal__ref_spad__debug_cfg__pad_5 : 1;
uint8_t cal__ref_spad__debug_cfg__pad_6 : 1;
};
};
union dci_union_cp_collapse_ctrl_u {
uint8_t bytes;
struct {
uint8_t cp_collapse_ctrl : 1;
uint8_t cp_collapse_ctrl_pad_0 : 1;
uint8_t cp_collapse_ctrl_pad_1 : 1;
uint8_t cp_collapse_ctrl_pad_2 : 1;
uint8_t cp_collapse_ctrl_pad_3 : 1;
uint8_t cp_collapse_ctrl_pad_4 : 1;
uint8_t cp_collapse_ctrl_pad_5 : 1;
uint8_t cp_collapse_ctrl_pad_6 : 1;
};
};
union dci_union__st_fgc_0_u {
uint32_t bytes;
struct {
uint32_t fgc_4__6_3 : 4;
uint32_t fgc_3 : 7;
uint32_t fgc_2 : 7;
uint32_t fgc_1 : 7;
uint32_t fgc_0 : 7;
};
};
union dci_union__st_fgc_1_u {
uint32_t bytes;
struct {
uint32_t fgc_9__6 : 1;
uint32_t fgc_8 : 7;
uint32_t fgc_7 : 7;
uint32_t fgc_6 : 7;
uint32_t fgc_5 : 7;
uint32_t fgc_4__2_0 : 3;
};
};
union dci_union__st_fgc_2_u {
uint32_t bytes;
struct {
uint32_t fgc_13__6_2 : 5;
uint32_t fgc_12 : 7;
uint32_t fgc_11 : 7;
uint32_t fgc_10 : 7;
uint32_t fgc_9__5_0 : 6;
};
};
union dci_union__st_fgc_3_u {
uint32_t bytes;
struct {
uint32_t word32_250__pad_0 : 2;
uint32_t fgc_17 : 7;
uint32_t fgc_16 : 7;
uint32_t fgc_15 : 7;
uint32_t fgc_14 : 7;
uint32_t fgc_13__1_0 : 2;
};
};
union dci_union__identification_0_u {
uint32_t bytes;
struct {
uint32_t module_date_phase : 3;
uint32_t day : 5;
uint32_t month : 4;
uint32_t year : 4;
uint32_t map_minor : 5;
uint32_t map_major : 3;
uint32_t test_prog_fmt_minor : 5;
uint32_t test_mrog_fmt_major : 3;
};
};
union dci_union__identification_1_u {
uint32_t bytes;
struct {
uint32_t code_site_id_fmt : 8;
uint32_t code_tester_id_fmt : 8;
uint32_t time : 16;
};
};
union dci_union__test_traceability_u {
uint32_t bytes;
struct {
uint32_t word32_253__pad_0 : 8;
uint32_t tester_id_ews : 8;
uint32_t probe_card_minor : 4;
uint32_t probe_card_major : 4;
uint32_t test_prog_ews_minor : 5;
uint32_t test_prog_ews_major : 3;
};
};
union dci_union__die_traceability_0_u {
uint32_t bytes;
struct {
uint32_t lot1_5_4 : 2;
uint32_t lot2 : 6;
uint32_t lot3 : 6;
uint32_t lot4 : 6;
uint32_t lot5 : 6;
uint32_t lot6 : 6;
};
};
union dci_union__die_traceability_1_u {
uint32_t bytes;
struct {
uint32_t ycoord : 8;
uint32_t xcoord : 8;
uint32_t wafer : 5;
uint32_t word32_255__pad_0 : 1;
uint32_t lot0 : 6;
uint32_t lot1_3_0 : 4;
};
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,78 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __DCI_VERSION_DEFS_H__
#define __DCI_VERSION_DEFS_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define MAP_VERSION_MINOR \
((uint16_t) 5U)
#define MAP_VERSION_MAJOR \
((uint16_t) 11U)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,97 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __DYN_XTALK_DEFS_H__
#define __DYN_XTALK_DEFS_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define TEMP_COMP__MAX_NB_LUT_ENTRIES \
((uint8_t) 16U)
#define DYN_XTALK__MAX_NB_LEAKAGE_MONITORS \
((uint8_t) 4U)
#define DYN_XTALK__DEGRADATION_RATE \
((uint32_t) 205U)
#define DYN_XTALK__INTERP_PRECISION_REDUCTION \
((int8_t) 7)
#define DYN_XTALK__TEMP_GAIN_FRACTIONAL_BITS \
((uint8_t) 7U)
#define DYN_XTALK__RATE_FRACTIONAL_BITS \
((uint8_t) 11U)
#define DYN_XTALK__VARIANCE_FRACTIONAL_BITS \
((uint8_t) 22U)
#define DYN_XTALK__PRE_SQRT_FRACTIONAL_BITS \
((uint8_t) 12U)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,169 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __DYN_XTALK_LUTS_H__
#define __DYN_XTALK_LUTS_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define DYN_XTALK_NO_GRID_UPDATE \
((uint8_t) 0U)
#define DYN_XTALK_GRID_UPDATE \
((uint8_t) 1U)
#define DYN_XTALK_KEEP_GRID \
((uint8_t) 0U)
#define DYN_XTALK_DISCARD_GRID \
((uint8_t) 1U)
#define DYN_XTALK_FORCE_MAX_SAMPLES_KEEP_GRID \
((uint8_t) 2U)
#define DYN_XTALK_DISABLE_XTALK_GRID_UPDATE \
((uint8_t) 0U)
#define DYN_XTALK_ENABLE_XTALK_GRID_UPDATE \
((uint8_t) 1U)
#define DYN_XTALK_CONTINUE \
((uint8_t) 0U)
#define DYN_XTALK_RESET \
((uint8_t) 1U)
#define DYN_XTALK_FALSE \
((uint8_t) 0U)
#define DYN_XTALK_TRUE \
((uint8_t) 1U)
#define TEMP_COMP_MODE_NONE \
((uint8_t) 0U)
#define TEMP_COMP_MODE_DISABLED \
((uint8_t) 1U)
#define TEMP_COMP_MODE_ENABLED \
((uint8_t) 2U)
#define DYN_XTALK_ERROR_WARN_OVERFLOW \
((uint8_t) 1U)
#define DYN_XTALK_ERROR_WARN_UNSUPPORTED_MODE \
((uint8_t) 2U)
#define DYN_XTALK_ERROR_WARN_DEGRADED_PERFORMANCE \
((uint8_t) 3U)
#define DYN_XTALK_STAGE_RESET \
((uint8_t) 0U)
#define DYN_XTALK_STAGE_ACCUMULATOR_RESET \
((uint8_t) 1U)
#define DYN_XTALK_STAGE_TEMPERATURE_COMPENSATION_GAIN \
((uint8_t) 2U)
#define DYN_XTALK_STAGE_LINEAR_INTERPOLATION \
((uint8_t) 3U)
#define DYN_XTALK_STAGE_LEAKAGE_GATING \
((uint8_t) 4U)
#define DYN_XTALK_STAGE_LEAKAGE_COMPENSATION \
((uint8_t) 5U)
#define DYN_XTALK_STAGE_GRID_INDEX \
((uint8_t) 6U)
#define DYN_XTALK_STAGE_ACCUMULATE_MONITORS \
((uint8_t) 7U)
#define DYN_XTALK_STAGE_INVERSE_TEMPERATURE_COMPENSATION \
((uint8_t) 8U)
#define DYN_XTALK_STAGE_FORWARD_TEMPERATURE_COMPENSATION \
((uint8_t) 9U)
#define DYN_XTALK_STAGE_NEW_VARIANCE_GRID \
((uint8_t) 10U)
#define DYN_XTALK_STAGE_VARIANCE_GRID_POINT \
((uint8_t) 11U)
#define DYN_XTALK_STAGE_VARIANCE_TO_SIGMA \
((uint8_t) 12U)
#define DYN_XTALK_STAGE_DESIRED_SAMPLES_CHECK \
((uint8_t) 13U)
#define DYN_XTALK_STAGE_REACHED_MAX_SAMPLES_OR_FRAMES \
((uint8_t) 14U)
#define DYN_XTALK_STAGE_FINISHED_ACCUMULATING \
((uint8_t) 15U)
#define DYN_XTALK_STAGE_TX_SUB_FRAME_GRID_TO_OTF \
((uint8_t) 16U)
#define DYN_XTALK_STAGE_TX_OTF_GRID_TO_OUTPUT_GRID \
((uint8_t) 17U)
#define DYN_XTALK_RESET_MODE__START_WITH_PREVIOUS_GRID \
((uint8_t) 0U)
#define DYN_XTALK_RESET_MODE__START_WITH_CAL_GRID \
((uint8_t) 1U)
#define DYN_XTALK_RESET_MODE__START_WITH_XTALK_MON \
((uint8_t) 2U)
#define DYN_XTALK_MODE__NONE \
((uint8_t) 0U)
#define DYN_XTALK_MODE__DISABLED \
((uint8_t) 1U)
#define DYN_XTALK_MODE__ENABLED \
((uint8_t) 2U)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,133 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __DYN_XTALK_SIZE_H__
#define __DYN_XTALK_SIZE_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_DYN_XTALK_GRP_ARRAYED_INTERNAL_SZ \
((uint16_t) 1152)
#define VL53L5_DXGAI_DYN_XT_GRID_NEW_XTALK_ACCUMULATED_VARIANCE_SZ \
((uint16_t) 512)
#define VL53L5_DXGAI_DYN_XT_NEW_XTALK_MON_VARIANCES_AT_CURR_TEMP_KCPS_PER_SPAD_SZ \
((uint16_t) 64)
#define VL53L5_DXGAI_DYN_XT_NEW_XTALK_MON_VARIANCES_AT_CAL_TEMP_KCPS_PER_SPAD_SZ \
((uint16_t) 64)
#define VL53L5_DXGAI_DYN_XT_GRID_NEW_XTALK_RATE_KCPS_PER_SPAD_SZ \
((uint16_t) 256)
#define VL53L5_DXGAI_DYN_XT_GRID_NEW_XTALK_SIGMA_KCPS_PER_SPAD_SZ \
((uint16_t) 256)
#define VL53L5_DYN_XTALK_GRP_GENERAL_CFG_SZ \
((uint16_t) 16)
#define VL53L5_DYN_XTALK_GRP_ARRAYED_CFG_SZ \
((uint16_t) 32)
#define VL53L5_DXGAC_DYN_XT_LEAKAGE_THRESHOLD_KCPS_PER_SPAD_SZ \
((uint16_t) 32)
#define VL53L5_DYN_XTALK_GRP_PERSISTENT_DATA_SZ \
((uint16_t) 24)
#define VL53L5_DYN_XTALK_GRP_ARRAYED_PERSISTENT_DATA_SZ \
((uint16_t) 168)
#define VL53L5_DXGAPD_DYN_XT_ACCUMULATED_XMON_AT_CAL_TEMP_SZ \
((uint16_t) 64)
#define VL53L5_DXGAPD_DYN_XT_ACCUMULATED_XMON_VARIANCES_AT_CAL_TEMP_SZ \
((uint16_t) 64)
#define VL53L5_DXGAPD_DYN_XT_COMPENSATED_LEAKAGE_MONITORS_SZ \
((uint16_t) 32)
#define VL53L5_DXGAPD_DYN_XT_UPDATE_XTALK_SZ \
((uint16_t) 8)
#define VL53L5_DYN_XTALK_GRP_DYNAMIC_CFG_SZ \
((uint16_t) 4)
#define VL53L5_TEMP_COMP_GRP_GENERAL_CFG_SZ \
((uint16_t) 8)
#define VL53L5_TEMP_COMP_GRP_ARRAYED_CFG_SZ \
((uint16_t) 128)
#define VL53L5_TCGAC_TEMP_COMP_TEMPERATURE_SZ \
((uint16_t) 64)
#define VL53L5_TCGAC_TEMP_COMP_GAIN_SZ \
((uint16_t) 64)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,94 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __DYN_XTALK_STRUCTS_H__
#define __DYN_XTALK_STRUCTS_H__
#include "dyn_xtalk_defs.h"
#include "dci_defs.h"
#include "cal_defs.h"
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
struct dyn_xtalk_grp__arrayed_internal_t {
uint64_t dyn_xt__grid_new_xtalk__accumulated_variance[
CAL_DEF__MAX_COLS_X_MAX_ROWS];
uint64_t dyn_xt__new_xtalk_mon_variances_at_curr_temp_kcps_per_spad[
DCI_XTALK_MON_MAX_ZONES];
uint64_t dyn_xt__new_xtalk_mon_variances_at_cal_temp_kcps_per_spad[
DCI_XTALK_MON_MAX_ZONES];
uint32_t dyn_xt__grid_new_xtalk__rate_kcps_per_spad[
CAL_DEF__MAX_COLS_X_MAX_ROWS];
uint32_t dyn_xt__grid_new_xtalk__sigma_kcps_per_spad[
CAL_DEF__MAX_COLS_X_MAX_ROWS];
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,76 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __IC_CHECKERS_DEFS_H__
#define __IC_CHECKERS_DEFS_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define IC_DEF__MAX_TGT_STATUS_LIST \
((uint32_t) 8U)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,134 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __IC_CHECKERS_LUTS_H__
#define __IC_CHECKERS_LUTS_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define CHECKER_TYPE__IN_WINDOW \
((uint8_t) 0U)
#define CHECKER_TYPE__OUT_OF_WINDOW \
((uint8_t) 1U)
#define CHECKER_TYPE__LESS_THAN_EQUAL_MIN_CHECKER \
((uint8_t) 2U)
#define CHECKER_TYPE__GREATER_THAN_MAX_CHECKER \
((uint8_t) 3U)
#define CHECKER_TYPE__EQUAL_MIN_CHECKER \
((uint8_t) 4U)
#define CHECKER_TYPE__NOT_EQUAL_MIN_CHECKER \
((uint8_t) 5U)
#define CHECKER_PARAM_TYPE__INVALID_CHECKER \
((uint8_t) 0U)
#define CHECKER_PARAM_TYPE__MEDIAN_RANGE_MM \
((uint8_t) 1U)
#define CHECKER_PARAM_TYPE__PEAK_RATE_KCPS_PER_SPAD \
((uint8_t) 2U)
#define CHECKER_PARAM_TYPE__RATE_SIGMA_KCPS_PER_SPAD \
((uint8_t) 3U)
#define CHECKER_PARAM_TYPE__RANGE_SIGMA_MM \
((uint8_t) 4U)
#define CHECKER_PARAM_TYPE__TARGET_REFLECTANCE_EST \
((uint8_t) 5U)
#define CHECKER_PARAM_TYPE__MIN_RANGE \
((uint8_t) 6U)
#define CHECKER_PARAM_TYPE__MAX_RANGE \
((uint8_t) 7U)
#define CHECKER_PARAM_TYPE__AMB_RATE_KCPS_PER_SPAD \
((uint8_t) 8U)
#define CHECKER_PARAM_TYPE__NUM_OF_TARGETS \
((uint8_t) 9U)
#define CHECKER_PARAM_TYPE__DMAX_MM \
((uint8_t) 10U)
#define CHECKER_PARAM_TYPE__EWOKMZ_TEMP \
((uint8_t) 11U)
#define CHECKER_PARAM_TYPE__EWOKMZ_TARGET_STATUS \
((uint8_t) 12U)
#define CHECKER_PARAM_TYPE__EFFECTIVE_SPAD_COUNT \
((uint8_t) 13U)
#define CHECKER_PARAM_TYPE__DELTA_START_END_TEMP \
((uint8_t) 14U)
#define CHECKER_PARAM_TYPE__DELTA_START_END_PHASE \
((uint8_t) 15U)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,94 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __IC_CHECKERS_SIZE_H__
#define __IC_CHECKERS_SIZE_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_IC_GRP_CHECKER_CFG_SZ \
((uint16_t) 12)
#define VL53L5_IC_GRP_VALID_TGT_STATUS_SZ \
((uint16_t) 8)
#define VL53L5_IGVTS_VAILD_TARGET_STATUS_SZ \
((uint16_t) 8)
#define VL53L5_IC_GRP_INT_STATUS_SZ \
((uint16_t) 4)
#define VL53L5_IC_GRP_WORKSPACE_SZ \
((uint16_t) 16)
#define VL53L5_IC_GRP_WORKSPACE_ARRAY_SZ \
((uint16_t) 64)
#define VL53L5_IGWA_ZONE_INT_STATUS_SZ \
((uint16_t) 64)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,116 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __IC_CHECKERS_STRUCTS_H__
#define __IC_CHECKERS_STRUCTS_H__
#include "ic_checkers_defs.h"
#include "ic_checkers_luts.h"
#include "ic_checkers_union_structs.h"
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
struct ic_grp__checker_cfg_t {
int32_t checker_param_low_thresh;
int32_t checker_param_high_thresh;
uint8_t checker_param_type;
uint8_t checker_type;
uint8_t zone_num;
union ic_checkers_union__optional_checker_type_u optional_checker_type;
};
struct ic_grp__valid_tgt_status_t {
uint8_t vaild_target_status[IC_DEF__MAX_TGT_STATUS_LIST];
};
struct ic_grp__workspace_t {
int32_t device_value;
uint8_t i;
uint8_t current_checker_num;
uint8_t last_zone;
uint8_t array_index;
uint8_t zone_number;
uint8_t target_status_counter;
uint8_t zone_target_detected;
uint8_t target_counter;
uint8_t AndOr;
uint8_t pad_0;
uint8_t pad_1;
uint8_t pad_2;
};
struct ic_grp__workspace_array_t {
uint8_t zone_int_status[64];
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,90 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __IC_CHECKERS_UNION_STRUCTS_H__
#define __IC_CHECKERS_UNION_STRUCTS_H__
#include "ic_checkers_defs.h"
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
union ic_checkers_union__optional_checker_type_u {
uint8_t bytes;
struct {
uint8_t check_no_targets : 1;
uint8_t and_or : 1;
uint8_t pad_0 : 1;
uint8_t pad_1 : 1;
uint8_t pad_2 : 1;
uint8_t pad_3 : 1;
uint8_t pad_4 : 1;
uint8_t pad_5 : 1;
};
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,82 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __PACKING_STRUCTS_H__
#define __PACKING_STRUCTS_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
struct bit_packed_24 {
uint32_t bit_pack_dword_0;
uint32_t bit_pack_dword_1;
uint32_t bit_pack_dword_2;
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,76 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __PADDING_SIZE_H__
#define __PADDING_SIZE_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_FW_GRP_PADDING_32_SZ \
((uint16_t) 4)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,73 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __PADDING_STRUCTS_H__
#define __PADDING_STRUCTS_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,86 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __PAGE_MAP_DEFS_H__
#define __PAGE_MAP_DEFS_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define PAGE_DEF__PAGE_VL53L5_DEV \
((uint16_t) 0U)
#define PAGE_DEF__PAGE_PATCH_0_DEV \
((uint16_t) 1U)
#define PAGE_DEF__PAGE_PATCH_1_DEV \
((uint16_t) 2U)
#define PAGE_DEF__PAGE_AFTERBOOT_DEV \
((uint16_t) 3U)
#define PAGE_DEF__PAGE_SSC_DEV \
((uint16_t) 4U)
#define PAGE_DEF__PAGE_FW_PIPE_WORKSPACE_DEV \
((uint16_t) 5U)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __PAGE_MAP_SWITCH_H__
#define __PAGE_MAP_SWITCH_H__
#include "vl53l5_platform_user_data.h"
#ifdef __cplusplus
extern "C" {
#endif
int32_t dci_page_map_switch(
uint16_t idx,
uint32_t buffer_size,
uint8_t *buffer,
struct vl53l5_dev_handle_t *p_dev,
uint16_t page_index);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,79 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_CALIBRATION_DECODE_H__
#define __VL53L5_CALIBRATION_DECODE_H__
#include "vl53l5_platform_user_data.h"
#ifdef __cplusplus
extern "C" {
#endif
int32_t vl53l5_calibration_decode_cmd(
uint16_t idx,
uint32_t buffer_size,
uint8_t *buffer,
struct vl53l5_dev_handle_t *p_dev);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,202 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_CALIBRATION_DEV_PATH_H__
#define __VL53L5_CALIBRATION_DEV_PATH_H__
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_MAP_CALIBRATION_DEV(p_dev) \
((p_dev)->host_dev.pcalibration_dev)
#define VL53L5_CAL_REF_SPAD_INFO(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->cal_ref_spad_info
#define VL53L5_CAL_TEMP_SENSOR(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->cal_temp_sensor
#define VL53L5_CAL_OPTICAL_CENTRE(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->cal_optical_centre
#define VL53L5_CAL_OSCILLATORS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->cal_oscillators
#define VL53L5_CAL_VHV(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->cal_vhv
#define VL53L5_POFFSET_GRID_META(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->poffset_grid_meta
#define VL53L5_POFFSET_PHASE_STATS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->poffset_phase_stats
#define VL53L5_POFFSET_TEMPERATURE_STATS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->poffset_temperature_stats
#define VL53L5_POFFSET_GRID_RATE(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->poffset_grid_rate
#define VL53L5_POFFSET_GRID_SPADS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->poffset_grid_spads
#define VL53L5_POFFSET_GRID_OFFSET(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->poffset_grid_offset
#define VL53L5_POFFSET_ERROR_STATUS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->poffset_error_status
#define VL53L5_POFFSET_WARNING_STATUS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->poffset_warning_status
#define VL53L5_POFFSET_4X4_GRID_META(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->poffset_4x4_grid_meta
#define VL53L5_POFFSET_4X4_PHASE_STATS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->poffset_4x4_phase_stats
#define VL53L5_POFFSET_4X4_TEMPERATURE_STATS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->poffset_4x4_temperature_stats
#define VL53L5_POFFSET_4X4_GRID_RATE(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->poffset_4x4_grid_rate
#define VL53L5_POFFSET_4X4_GRID_SPADS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->poffset_4x4_grid_spads
#define VL53L5_POFFSET_4X4_GRID_OFFSET(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->poffset_4x4_grid_offset
#define VL53L5_POFFSET_4X4_ERROR_STATUS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->poffset_4x4_error_status
#define VL53L5_POFFSET_4X4_WARNING_STATUS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->poffset_4x4_warning_status
#define VL53L5_PXTALK_GRID_META(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pxtalk_grid_meta
#define VL53L5_PXTALK_PHASE_STATS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pxtalk_phase_stats
#define VL53L5_PXTALK_TEMPERATURE_STATS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pxtalk_temperature_stats
#define VL53L5_PXTALK_GRID_RATE(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pxtalk_grid_rate
#define VL53L5_PXTALK_GRID_SPADS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pxtalk_grid_spads
#define VL53L5_PXTALK_ERROR_STATUS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pxtalk_error_status
#define VL53L5_PXTALK_WARNING_STATUS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pxtalk_warning_status
#define VL53L5_PCURRENT_XTALK_4X4_GRID_META(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcurrent_xtalk_4x4_grid_meta
#define VL53L5_PCURRENT_XTALK_4X4_PHASE_STATS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcurrent_xtalk_4x4_phase_stats
#define VL53L5_PCURRENT_XTALK_4X4_TEMPERATURE_STATS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcurrent_xtalk_4x4_temperature_stats
#define VL53L5_PCURRENT_XTALK_4X4_GRID_RATE(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcurrent_xtalk_4x4_grid_rate
#define VL53L5_PCURRENT_XTALK_4X4_GRID_SPADS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcurrent_xtalk_4x4_grid_spads
#define VL53L5_PCURRENT_XTALK_4X4_ERROR_STATUS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcurrent_xtalk_4x4_error_status
#define VL53L5_PCURRENT_XTALK_4X4_WARNING_STATUS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcurrent_xtalk_4x4_warning_status
#define VL53L5_PCURRENT_XTALK_8X8_GRID_META(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcurrent_xtalk_8x8_grid_meta
#define VL53L5_PCURRENT_XTALK_8X8_PHASE_STATS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcurrent_xtalk_8x8_phase_stats
#define VL53L5_PCURRENT_XTALK_8X8_TEMPERATURE_STATS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcurrent_xtalk_8x8_temperature_stats
#define VL53L5_PCURRENT_XTALK_8X8_GRID_RATE(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcurrent_xtalk_8x8_grid_rate
#define VL53L5_PCURRENT_XTALK_8X8_GRID_SPADS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcurrent_xtalk_8x8_grid_spads
#define VL53L5_PCURRENT_XTALK_8X8_ERROR_STATUS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcurrent_xtalk_8x8_error_status
#define VL53L5_PCURRENT_XTALK_8X8_WARNING_STATUS(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcurrent_xtalk_8x8_warning_status
#define VL53L5_PXTALK_SHAPE_META(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pxtalk_shape_meta
#define VL53L5_PXTALK_SHAPE_DATA(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pxtalk_shape_data
#define VL53L5_PXTALK_MON_META(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pxtalk_mon_meta
#define VL53L5_PXTALK_MON_ZONES(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pxtalk_mon_zones
#define VL53L5_PXTALK_MON_DATA(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pxtalk_mon_data
#define VL53L5_PRAD2PERP_GRID_META(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->prad2perp_grid_meta
#define VL53L5_PRAD2PERP_GRID_DATA(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->prad2perp_grid_data
#define VL53L5_PRAD2PERP_GRID_4X4_META(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->prad2perp_grid_4x4_meta
#define VL53L5_PRAD2PERP_GRID_4X4_DATA(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->prad2perp_grid_4x4_data
#define VL53L5_PRAD2PERP_GRID_8X8_META(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->prad2perp_grid_8x8_meta
#define VL53L5_PRAD2PERP_GRID_8X8_DATA(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->prad2perp_grid_8x8_data
#define VL53L5_PNORM_GRID_META(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pnorm_grid_meta
#define VL53L5_PNORM_GRID_DATA(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pnorm_grid_data
#define VL53L5_PDYN_XTALK__SUB_FRAME_XTALK_GRID_RATE(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pdyn_xtalk__sub_frame_xtalk_grid_rate
#define VL53L5_PDYN_XTALK__OTF_XTALK_GRID_RATE(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pdyn_xtalk__otf_xtalk_grid_rate
#define VL53L5_DYN_XTALK__LAST_VALID_XMON_DATA(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->dyn_xtalk__last_valid_xmon_data
#define VL53L5_PADDING_32(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->padding_32
#define VL53L5_PCAL_COMMON_SUM(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcal_common_sum
#define VL53L5_PCAL_XMON_SUM(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcal_xmon_sum
#define VL53L5_PCAL_ZONE_SUM(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcal_zone_sum
#define VL53L5_PCAL_HIST_META(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcal_hist_meta
#define VL53L5_PCAL_HIST_SUM(p_dev) \
VL53L5_MAP_CALIBRATION_DEV(p_dev)->pcal_hist_sum
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,118 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_CALIBRATION_ENUM_TYPE_H__
#define __VL53L5_CALIBRATION_ENUM_TYPE_H__
#include "vl53l5_dci_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef VL53L5_CALIBRATION_DECODE_ON
#define VL53L5_CAL_GRP_REF_SPAD_INFO_TYPE \
((enum block_format_type) 0x0)
#endif
#ifdef VL53L5_CALIBRATION_DECODE_ON
#define VL53L5_CAL_GRP_OPTICAL_CENTRE_DATA_TYPE \
((enum block_format_type) 0x0)
#endif
#ifdef VL53L5_CALIBRATION_DECODE_ON
#define VL53L5_CAL_GRP_GRID_META_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_CAL_GRP_PHASE_STATS_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_CAL_GRP_TEMPERATURE_STATS_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_CGGDRKPS_CAL_GRID_DATA_RATE_KCPS_PER_SPAD_TYPE \
((enum block_format_type) 0x4)
#define VL53L5_CGGDESC_CAL_GRID_DATA_EFFECTIVE_SPAD_COUNT_TYPE \
((enum block_format_type) 0x2)
#define VL53L5_CGGDRM_CAL_GRID_DATA_RANGE_MM_TYPE \
((enum block_format_type) 0x2)
#define VL53L5_CAL_GRP_STATUS_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_CAL_GRP_XTALK_SHAPE_META_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_CGXSD_CAL_XTALK_SHAPE_BIN_DATA_TYPE \
((enum block_format_type) 0x2)
#define VL53L5_CAL_GRP_XTALK_MON_META_DATA_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_CGXMZ_CAL_XMON_ZONE_X_OFF_TYPE \
((enum block_format_type) 0x1)
#define VL53L5_CGXMZ_CAL_XMON_ZONE_Y_OFF_TYPE \
((enum block_format_type) 0x1)
#define VL53L5_CGXMZ_CAL_XMON_ZONE_WIDTH_TYPE \
((enum block_format_type) 0x1)
#define VL53L5_CGXMZ_CAL_XMON_ZONE_HEIGHT_TYPE \
((enum block_format_type) 0x1)
#define VL53L5_CGXMD_CAL_XMON_ZONE_RATE_KCPS_SPAD_TYPE \
((enum block_format_type) 0x4)
#define VL53L5_CGXMD_CAL_XMON_ZONE_AVG_COUNT_TYPE \
((enum block_format_type) 0x2)
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,156 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_CALIBRATION_MAP_H__
#define __VL53L5_CALIBRATION_MAP_H__
#include "dci_defs.h"
#include "dci_structs.h"
#include "dci_union_structs.h"
#include "dci_ui_structs.h"
#include "cal_defs.h"
#include "cal_structs.h"
#include "padding_structs.h"
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
struct vl53l5_calibration_dev_t {
#ifdef VL53L5_CALIBRATION_DECODE_ON
struct cal_grp__ref_spad_info_t cal_ref_spad_info;
#endif
#ifdef VL53L5_CALIBRATION_DECODE_ON
struct cal_grp__optical_centre_data_t cal_optical_centre;
#endif
#ifdef VL53L5_CALIBRATION_DECODE_ON
struct cal_grp__grid_meta_t poffset_grid_meta;
struct cal_grp__phase_stats_t poffset_phase_stats;
struct cal_grp__temperature_stats_t poffset_temperature_stats;
struct cal_grp__grid_data__rate_kcps_per_spad_t poffset_grid_rate;
struct cal_grp__grid_data__effective_spad_count_t poffset_grid_spads;
struct cal_grp__grid_data__range_mm_t poffset_grid_offset;
struct cal_grp__status_t poffset_error_status;
struct cal_grp__status_t poffset_warning_status;
#endif
#ifdef VL53L5_CALIBRATION_DECODE_ON
struct cal_grp__grid_meta_t pxtalk_grid_meta;
struct cal_grp__phase_stats_t pxtalk_phase_stats;
struct cal_grp__temperature_stats_t pxtalk_temperature_stats;
struct cal_grp__grid_data__rate_kcps_per_spad_t pxtalk_grid_rate;
struct cal_grp__grid_data__effective_spad_count_t pxtalk_grid_spads;
struct cal_grp__status_t pxtalk_error_status;
struct cal_grp__status_t pxtalk_warning_status;
#endif
#ifdef VL53L5_CALIBRATION_DECODE_ON
struct cal_grp__xtalk_shape_meta_t pxtalk_shape_meta;
struct cal_grp__xtalk_shape_data_t pxtalk_shape_data;
struct cal_grp__xtalk_mon__meta_data_t pxtalk_mon_meta;
struct cal_grp__xtalk_mon__zones_t pxtalk_mon_zones;
struct cal_grp__xtalk_mon__data_t pxtalk_mon_data;
#endif
#ifdef VL53L5_CALIBRATION_DECODE_ON
struct cal_grp__grid_meta_t prad2perp_grid_4x4_meta;
struct cal_grp__grid_data__scale_factor_t prad2perp_grid_4x4_data;
struct cal_grp__grid_meta_t prad2perp_grid_8x8_meta;
struct cal_grp__grid_data__scale_factor_t prad2perp_grid_8x8_data;
#endif
#ifdef VL53L5_CALIBRATION_DECODE_ON
struct cal_grp__xtalk_mon__data_t dyn_xtalk__last_valid_xmon_data;
#endif
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,142 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_CALIBRATION_MAP_BH_H__
#define __VL53L5_CALIBRATION_MAP_BH_H__
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_CAL_REF_SPAD_INFO_BH \
((uint32_t) 0xafdc0080U)
#define VL53L5_CAL_OPTICAL_CENTRE_BH \
((uint32_t) 0xafe80040U)
#define VL53L5_POFFSET_GRID_META_BH \
((uint32_t) 0xaff800c0U)
#define VL53L5_POFFSET_PHASE_STATS_BH \
((uint32_t) 0xb0040140U)
#define VL53L5_POFFSET_TEMPERATURE_STATS_BH \
((uint32_t) 0xb0180040U)
#define VL53L5_POFFSET_GRID_RATE_CAL__GRID_DATA__RATE_KCPS_PER_SPAD_BH \
((uint32_t) 0xb01c0404U)
#define VL53L5_POFFSET_GRID_SPADS_CAL__GRID_DATA_EFFECTIVE_SPAD_COUNT_BH \
((uint32_t) 0xb11c0402U)
#define VL53L5_POFFSET_GRID_OFFSET_CAL__GRID_DATA__RANGE_MM_BH \
((uint32_t) 0xb19c0402U)
#define VL53L5_POFFSET_ERROR_STATUS_BH \
((uint32_t) 0xb21c0100U)
#define VL53L5_POFFSET_WARNING_STATUS_BH \
((uint32_t) 0xb22c0100U)
#define VL53L5_PXTALK_GRID_META_BH \
((uint32_t) 0xb48000c0U)
#define VL53L5_PXTALK_PHASE_STATS_BH \
((uint32_t) 0xb48c0140U)
#define VL53L5_PXTALK_TEMPERATURE_STATS_BH \
((uint32_t) 0xb4a00040U)
#define VL53L5_PXTALK_GRID_RATE_CAL__GRID_DATA__RATE_KCPS_PER_SPAD_BH \
((uint32_t) 0xb4a40404U)
#define VL53L5_PXTALK_GRID_SPADS_CAL__GRID_DATA_EFFECTIVE_SPAD_COUNT_BH \
((uint32_t) 0xb5a40402U)
#define VL53L5_PXTALK_ERROR_STATUS_BH \
((uint32_t) 0xb6240100U)
#define VL53L5_PXTALK_WARNING_STATUS_BH \
((uint32_t) 0xb6340100U)
#define VL53L5_PXTALK_SHAPE_META_BH \
((uint32_t) 0xb9cc00c0U)
#define VL53L5_PXTALK_SHAPE_DATA_CAL__XTALK_SHAPE__BIN_DATA_BH \
((uint32_t) 0xb9d80902U)
#define VL53L5_PXTALK_MON_META_BH \
((uint32_t) 0xbaf80040U)
#define VL53L5_PXTALK_MON_ZONES_CAL__XMON__ZONE__X_OFF_BH \
((uint32_t) 0xbafc0081U)
#define VL53L5_PXTALK_MON_ZONES_CAL__XMON__ZONE__Y_OFF_BH \
((uint32_t) 0xbb040081U)
#define VL53L5_PXTALK_MON_ZONES_CAL__XMON__ZONE__WIDTH_BH \
((uint32_t) 0xbb0c0081U)
#define VL53L5_PXTALK_MON_ZONES_CAL__XMON__ZONE__HEIGHT_BH \
((uint32_t) 0xbb140081U)
#define VL53L5_PXTALK_MON_DATA_CAL__XMON__ZONE__RATE_KCPS_SPAD_BH \
((uint32_t) 0xbb1c0084U)
#define VL53L5_PXTALK_MON_DATA_CAL__XMON__ZONE__AVG_COUNT_BH \
((uint32_t) 0xbb3c0082U)
#define VL53L5_PRAD2PERP_GRID_4X4_META_BH \
((uint32_t) 0xbbd800c0U)
#define VL53L5_PRAD2PERP_GRID_4X4_DATA_CAL__GRID_DATA__SCALE_FACTOR_BH \
((uint32_t) 0xbbe40402U)
#define VL53L5_PRAD2PERP_GRID_8X8_META_BH \
((uint32_t) 0xbc6400c0U)
#define VL53L5_PRAD2PERP_GRID_8X8_DATA_CAL__GRID_DATA__SCALE_FACTOR_BH \
((uint32_t) 0xbc700402U)
#define VL53L5_DYN_XTALK__LAST_VALID_XMON_DATA_CAL__XMON__ZONE__RATE_KCPS_SPAD_BH \
((uint32_t) 0xbf7c0084U)
#define VL53L5_DYN_XTALK__LAST_VALID_XMON_DATA_CAL__XMON__ZONE__AVG_COUNT_BH \
((uint32_t) 0xbf9c0082U)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,191 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_CALIBRATION_MAP_IDX_H__
#define __VL53L5_CALIBRATION_MAP_IDX_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define DEV_CAL_REF_SPAD_INFO_IDX \
((uint16_t) 0xafdc)
#define DEV_CAL_OPTICAL_CENTRE_IDX \
((uint16_t) 0xafe8)
#define DEV_POFFSET_GRID_META_IDX \
((uint16_t) 0xaff8)
#define DEV_POFFSET_PHASE_STATS_IDX \
((uint16_t) 0xb004)
#define DEV_POFFSET_TEMPERATURE_STATS_IDX \
((uint16_t) 0xb018)
#define DEV_POFFSET_GRID_RATE_CAL__GRID_DATA__RATE_KCPS_PER_SPAD_IDX \
((uint16_t) 0xb01c)
#define DEV_POFFSET_GRID_RATE_IDX \
((uint16_t) 0xb01c)
#define DEV_POFFSET_GRID_SPADS_CAL__GRID_DATA_EFFECTIVE_SPAD_COUNT_IDX \
((uint16_t) 0xb11c)
#define DEV_POFFSET_GRID_SPADS_IDX \
((uint16_t) 0xb11c)
#define DEV_POFFSET_GRID_OFFSET_CAL__GRID_DATA__RANGE_MM_IDX \
((uint16_t) 0xb19c)
#define DEV_POFFSET_GRID_OFFSET_IDX \
((uint16_t) 0xb19c)
#define DEV_POFFSET_ERROR_STATUS_IDX \
((uint16_t) 0xb21c)
#define DEV_POFFSET_WARNING_STATUS_IDX \
((uint16_t) 0xb22c)
#define DEV_PXTALK_GRID_META_IDX \
((uint16_t) 0xb480)
#define DEV_PXTALK_PHASE_STATS_IDX \
((uint16_t) 0xb48c)
#define DEV_PXTALK_TEMPERATURE_STATS_IDX \
((uint16_t) 0xb4a0)
#define DEV_PXTALK_GRID_RATE_CAL__GRID_DATA__RATE_KCPS_PER_SPAD_IDX \
((uint16_t) 0xb4a4)
#define DEV_PXTALK_GRID_RATE_IDX \
((uint16_t) 0xb4a4)
#define DEV_PXTALK_GRID_SPADS_CAL__GRID_DATA_EFFECTIVE_SPAD_COUNT_IDX \
((uint16_t) 0xb5a4)
#define DEV_PXTALK_GRID_SPADS_IDX \
((uint16_t) 0xb5a4)
#define DEV_PXTALK_ERROR_STATUS_IDX \
((uint16_t) 0xb624)
#define DEV_PXTALK_WARNING_STATUS_IDX \
((uint16_t) 0xb634)
#define DEV_PXTALK_SHAPE_META_IDX \
((uint16_t) 0xb9cc)
#define DEV_PXTALK_SHAPE_DATA_CAL__XTALK_SHAPE__BIN_DATA_IDX \
((uint16_t) 0xb9d8)
#define DEV_PXTALK_SHAPE_DATA_IDX \
((uint16_t) 0xb9d8)
#define DEV_PXTALK_MON_META_IDX \
((uint16_t) 0xbaf8)
#define DEV_PXTALK_MON_ZONES_CAL__XMON__ZONE__X_OFF_IDX \
((uint16_t) 0xbafc)
#define DEV_PXTALK_MON_ZONES_IDX \
((uint16_t) 0xbafc)
#define DEV_PXTALK_MON_ZONES_CAL__XMON__ZONE__Y_OFF_IDX \
((uint16_t) 0xbb04)
#define DEV_PXTALK_MON_ZONES_CAL__XMON__ZONE__WIDTH_IDX \
((uint16_t) 0xbb0c)
#define DEV_PXTALK_MON_ZONES_CAL__XMON__ZONE__HEIGHT_IDX \
((uint16_t) 0xbb14)
#define DEV_PXTALK_MON_DATA_CAL__XMON__ZONE__RATE_KCPS_SPAD_IDX \
((uint16_t) 0xbb1c)
#define DEV_PXTALK_MON_DATA_IDX \
((uint16_t) 0xbb1c)
#define DEV_PXTALK_MON_DATA_CAL__XMON__ZONE__AVG_COUNT_IDX \
((uint16_t) 0xbb3c)
#define DEV_PRAD2PERP_GRID_4X4_META_IDX \
((uint16_t) 0xbbd8)
#define DEV_PRAD2PERP_GRID_4X4_DATA_CAL__GRID_DATA__SCALE_FACTOR_IDX \
((uint16_t) 0xbbe4)
#define DEV_PRAD2PERP_GRID_4X4_DATA_IDX \
((uint16_t) 0xbbe4)
#define DEV_PRAD2PERP_GRID_8X8_META_IDX \
((uint16_t) 0xbc64)
#define DEV_PRAD2PERP_GRID_8X8_DATA_CAL__GRID_DATA__SCALE_FACTOR_IDX \
((uint16_t) 0xbc70)
#define DEV_PRAD2PERP_GRID_8X8_DATA_IDX \
((uint16_t) 0xbc70)
#define DEV_DYN_XTALK__LAST_VALID_XMON_DATA_CAL__XMON__ZONE__RATE_KCPS_SPAD_IDX \
((uint16_t) 0xbf7c)
#define DEV_DYN_XTALK__LAST_VALID_XMON_DATA_IDX \
((uint16_t) 0xbf7c)
#define DEV_DYN_XTALK__LAST_VALID_XMON_DATA_CAL__XMON__ZONE__AVG_COUNT_IDX \
((uint16_t) 0xbf9c)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_CORE_DECODE_H__
#define __VL53L5_CORE_DECODE_H__
#include "common_datatype_size.h"
#include "vl53l5_platform_user_data.h"
#ifdef __cplusplus
extern "C" {
#endif
int32_t vl53l5_core_decode_cmd(
uint16_t idx,
uint32_t buffer_size,
uint8_t *buffer,
struct vl53l5_dev_handle_t *p_dev);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,252 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_CORE_DEV_PATH_H__
#define __VL53L5_CORE_DEV_PATH_H__
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_MAP_CORE_DEV(p_dev) \
((p_dev)->host_dev.core_dev)
#define VL53L5_MAP_VERSION(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).map_version
#define VL53L5_FW_VERSION(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).fw_version
#define VL53L5_CFG_INFO(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).cfg_info
#define VL53L5_FMT_TRACEABILITY(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).fmt_traceability
#define VL53L5_EWS_TRACEABILITY(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ews_traceability
#define VL53L5_UI_RNG_DATA_ADDR(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ui_rng_data_addr
#define VL53L5_SILICON_TEMP_DATA(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).silicon_temp_data
#define VL53L5_ZONE_CFG(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).zone_cfg
#define VL53L5_DEVICE_MODE_CFG(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).device_mode_cfg
#define VL53L5_RNG_RATE_CFG(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).rng_rate_cfg
#define VL53L5_INT_MAX_CFG(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).int_max_cfg
#define VL53L5_INT_MIN_CFG(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).int_min_cfg
#define VL53L5_INT_MPX_DELTA_CFG(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).int_mpx_delta_cfg
#define VL53L5_INT_DSS_CFG(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).int_dss_cfg
#define VL53L5_FACTORY_CAL_CFG(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).factory_cal_cfg
#define VL53L5_OUTPUT_DATA_CFG(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).output_data_cfg
#define VL53L5_OUTPUT_BH_CFG(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).output_bh_cfg
#define VL53L5_OUTPUT_BH_ENABLES(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).output_bh_enables
#define VL53L5_OUTPUT_BH_LIST(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).output_bh_list
#define VL53L5_INTERRUPT_CFG(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).interrupt_cfg
#define VL53L5_NVM_LASER_SAFETY_INFO(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).nvm_laser_safety_info
#define VL53L5_PATCH_HOOK_ENABLES_ARRAY(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).patch_hook_enables_array
#define VL53L5_DEVICE_ERROR_STATUS(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).device_error_status
#define VL53L5_DEVICE_WARNING_STATUS(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).device_warning_status
#define VL53L5_IC_CHECKER_0(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_0
#define VL53L5_IC_CHECKER_1(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_1
#define VL53L5_IC_CHECKER_2(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_2
#define VL53L5_IC_CHECKER_3(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_3
#define VL53L5_IC_CHECKER_4(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_4
#define VL53L5_IC_CHECKER_5(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_5
#define VL53L5_IC_CHECKER_6(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_6
#define VL53L5_IC_CHECKER_7(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_7
#define VL53L5_IC_CHECKER_8(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_8
#define VL53L5_IC_CHECKER_9(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_9
#define VL53L5_IC_CHECKER_10(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_10
#define VL53L5_IC_CHECKER_11(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_11
#define VL53L5_IC_CHECKER_12(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_12
#define VL53L5_IC_CHECKER_13(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_13
#define VL53L5_IC_CHECKER_14(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_14
#define VL53L5_IC_CHECKER_15(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_15
#define VL53L5_IC_CHECKER_16(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_16
#define VL53L5_IC_CHECKER_17(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_17
#define VL53L5_IC_CHECKER_18(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_18
#define VL53L5_IC_CHECKER_19(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_19
#define VL53L5_IC_CHECKER_20(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_20
#define VL53L5_IC_CHECKER_21(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_21
#define VL53L5_IC_CHECKER_22(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_22
#define VL53L5_IC_CHECKER_23(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_23
#define VL53L5_IC_CHECKER_24(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_24
#define VL53L5_IC_CHECKER_25(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_25
#define VL53L5_IC_CHECKER_26(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_26
#define VL53L5_IC_CHECKER_27(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_27
#define VL53L5_IC_CHECKER_28(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_28
#define VL53L5_IC_CHECKER_29(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_29
#define VL53L5_IC_CHECKER_30(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_30
#define VL53L5_IC_CHECKER_31(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_31
#define VL53L5_IC_CHECKER_32(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_32
#define VL53L5_IC_CHECKER_33(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_33
#define VL53L5_IC_CHECKER_34(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_34
#define VL53L5_IC_CHECKER_35(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_35
#define VL53L5_IC_CHECKER_36(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_36
#define VL53L5_IC_CHECKER_37(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_37
#define VL53L5_IC_CHECKER_38(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_38
#define VL53L5_IC_CHECKER_39(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_39
#define VL53L5_IC_CHECKER_40(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_40
#define VL53L5_IC_CHECKER_41(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_41
#define VL53L5_IC_CHECKER_42(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_42
#define VL53L5_IC_CHECKER_43(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_43
#define VL53L5_IC_CHECKER_44(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_44
#define VL53L5_IC_CHECKER_45(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_45
#define VL53L5_IC_CHECKER_46(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_46
#define VL53L5_IC_CHECKER_47(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_47
#define VL53L5_IC_CHECKER_48(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_48
#define VL53L5_IC_CHECKER_49(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_49
#define VL53L5_IC_CHECKER_50(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_50
#define VL53L5_IC_CHECKER_51(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_51
#define VL53L5_IC_CHECKER_52(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_52
#define VL53L5_IC_CHECKER_53(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_53
#define VL53L5_IC_CHECKER_54(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_54
#define VL53L5_IC_CHECKER_55(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_55
#define VL53L5_IC_CHECKER_56(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_56
#define VL53L5_IC_CHECKER_57(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_57
#define VL53L5_IC_CHECKER_58(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_58
#define VL53L5_IC_CHECKER_59(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_59
#define VL53L5_IC_CHECKER_60(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_60
#define VL53L5_IC_CHECKER_61(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_61
#define VL53L5_IC_CHECKER_62(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_62
#define VL53L5_IC_CHECKER_63(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_checker_63
#define VL53L5_IC_VALID_TGT_STATUS(p_dev) \
VL53L5_MAP_CORE_DEV(p_dev).ic_valid_tgt_status
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,118 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_CORE_ENUM_TYPE_H__
#define __VL53L5_CORE_ENUM_TYPE_H__
#include "vl53l5_dci_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_MAP_VERSION_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_FW_VERSION_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_CFG_INFO_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_FMT_TRACEABILITY_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_EWS_TRACEABILITY_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_UI_RNG_DATA_ADDR_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_SILICON_TEMPERATURE_DATA_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_ZONE_CFG_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_DEVICE_MODE_CFG_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_RANGING_RATE_CFG_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_INTEGRATION_TIME_CFG_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_FACTORY_CAL_CFG_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_OUTPUT_DATA_CFG_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_OUTPUT_BH_CFG_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_OBE_OP_BH_ENABLES_TYPE \
((enum block_format_type) 0x4)
#define VL53L5_OBL_OP_BH_LIST_TYPE \
((enum block_format_type) 0x4)
#define VL53L5_INTERRUPT_CFG_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_NVM_LASER_SAFETY_NVM2_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_PHE_PATCH_HOOK_ENABLES_TYPE \
((enum block_format_type) 0x4)
#define VL53L5_COMMON_GRP_STATUS_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_IC_GRP_CHECKER_CFG_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_IGVTS_VAILD_TARGET_STATUS_TYPE \
((enum block_format_type) 0x1)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,93 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_CORE_MAP_H__
#define __VL53L5_CORE_MAP_H__
#include "dci_defs.h"
#include "dci_structs.h"
#include "dci_union_structs.h"
#include "dci_ui_structs.h"
#include "vl53l5_types.h"
#include "common_datatype_structs.h"
#ifdef __cplusplus
extern "C" {
#endif
struct vl53l5_core_dev_t {
#ifdef VL53L5_CALIBRATION_DECODE_ON
struct dci_grp__map_version_t map_version;
#endif
#ifdef VL53L5_SILICON_TEMP_DATA_ON
struct dci_grp__silicon_temperature_data_t silicon_temp_data;
#endif
#ifdef VL53L5_ZONE_CFG_ON
struct dci_grp__zone_cfg_t zone_cfg;
#endif
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,250 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_CORE_MAP_BH_H__
#define __VL53L5_CORE_MAP_BH_H__
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_MAP_VERSION_BH \
((uint32_t) 0x54000040U)
#define VL53L5_FW_VERSION_BH \
((uint32_t) 0x54040080U)
#define VL53L5_CFG_INFO_BH \
((uint32_t) 0x540c0140U)
#define VL53L5_FMT_TRACEABILITY_BH \
((uint32_t) 0x54200180U)
#define VL53L5_EWS_TRACEABILITY_BH \
((uint32_t) 0x543800c0U)
#define VL53L5_UI_RNG_DATA_ADDR_BH \
((uint32_t) 0x544400c0U)
#define VL53L5_SILICON_TEMP_DATA_BH \
((uint32_t) 0x54500040U)
#define VL53L5_ZONE_CFG_BH \
((uint32_t) 0x54540080U)
#define VL53L5_DEVICE_MODE_CFG_BH \
((uint32_t) 0x545c0080U)
#define VL53L5_RNG_RATE_CFG_BH \
((uint32_t) 0x54640040U)
#define VL53L5_INT_MAX_CFG_BH \
((uint32_t) 0x54680040U)
#define VL53L5_INT_MIN_CFG_BH \
((uint32_t) 0x546c0040U)
#define VL53L5_INT_MPX_DELTA_CFG_BH \
((uint32_t) 0x54700040U)
#define VL53L5_INT_DSS_CFG_BH \
((uint32_t) 0x54740040U)
#define VL53L5_FACTORY_CAL_CFG_BH \
((uint32_t) 0x54780080U)
#define VL53L5_OUTPUT_DATA_CFG_BH \
((uint32_t) 0x54800040U)
#define VL53L5_OUTPUT_BH_CFG_BH \
((uint32_t) 0x54840080U)
#define VL53L5_OUTPUT_BH_ENABLES_OP_BH__ENABLES_BH \
((uint32_t) 0x548c0044U)
#define VL53L5_OUTPUT_BH_LIST_OP_BH__LIST_BH \
((uint32_t) 0x549c0804U)
#define VL53L5_INTERRUPT_CFG_BH \
((uint32_t) 0x569c0080U)
#define VL53L5_NVM_LASER_SAFETY_INFO_BH \
((uint32_t) 0x56a40040U)
#define VL53L5_PATCH_HOOK_ENABLES_ARRAY_PATCH_HOOK_ENABLES_BH \
((uint32_t) 0x56a80044U)
#define VL53L5_DEVICE_ERROR_STATUS_BH \
((uint32_t) 0x56b800c0U)
#define VL53L5_DEVICE_WARNING_STATUS_BH \
((uint32_t) 0x56c400c0U)
#define VL53L5_IC_CHECKER_0_BH \
((uint32_t) 0x56d000c0U)
#define VL53L5_IC_CHECKER_1_BH \
((uint32_t) 0x56dc00c0U)
#define VL53L5_IC_CHECKER_2_BH \
((uint32_t) 0x56e800c0U)
#define VL53L5_IC_CHECKER_3_BH \
((uint32_t) 0x56f400c0U)
#define VL53L5_IC_CHECKER_4_BH \
((uint32_t) 0x570000c0U)
#define VL53L5_IC_CHECKER_5_BH \
((uint32_t) 0x570c00c0U)
#define VL53L5_IC_CHECKER_6_BH \
((uint32_t) 0x571800c0U)
#define VL53L5_IC_CHECKER_7_BH \
((uint32_t) 0x572400c0U)
#define VL53L5_IC_CHECKER_8_BH \
((uint32_t) 0x573000c0U)
#define VL53L5_IC_CHECKER_9_BH \
((uint32_t) 0x573c00c0U)
#define VL53L5_IC_CHECKER_10_BH \
((uint32_t) 0x574800c0U)
#define VL53L5_IC_CHECKER_11_BH \
((uint32_t) 0x575400c0U)
#define VL53L5_IC_CHECKER_12_BH \
((uint32_t) 0x576000c0U)
#define VL53L5_IC_CHECKER_13_BH \
((uint32_t) 0x576c00c0U)
#define VL53L5_IC_CHECKER_14_BH \
((uint32_t) 0x577800c0U)
#define VL53L5_IC_CHECKER_15_BH \
((uint32_t) 0x578400c0U)
#define VL53L5_IC_CHECKER_16_BH \
((uint32_t) 0x579000c0U)
#define VL53L5_IC_CHECKER_17_BH \
((uint32_t) 0x579c00c0U)
#define VL53L5_IC_CHECKER_18_BH \
((uint32_t) 0x57a800c0U)
#define VL53L5_IC_CHECKER_19_BH \
((uint32_t) 0x57b400c0U)
#define VL53L5_IC_CHECKER_20_BH \
((uint32_t) 0x57c000c0U)
#define VL53L5_IC_CHECKER_21_BH \
((uint32_t) 0x57cc00c0U)
#define VL53L5_IC_CHECKER_22_BH \
((uint32_t) 0x57d800c0U)
#define VL53L5_IC_CHECKER_23_BH \
((uint32_t) 0x57e400c0U)
#define VL53L5_IC_CHECKER_24_BH \
((uint32_t) 0x57f000c0U)
#define VL53L5_IC_CHECKER_25_BH \
((uint32_t) 0x57fc00c0U)
#define VL53L5_IC_CHECKER_26_BH \
((uint32_t) 0x580800c0U)
#define VL53L5_IC_CHECKER_27_BH \
((uint32_t) 0x581400c0U)
#define VL53L5_IC_CHECKER_28_BH \
((uint32_t) 0x582000c0U)
#define VL53L5_IC_CHECKER_29_BH \
((uint32_t) 0x582c00c0U)
#define VL53L5_IC_CHECKER_30_BH \
((uint32_t) 0x583800c0U)
#define VL53L5_IC_CHECKER_31_BH \
((uint32_t) 0x584400c0U)
#define VL53L5_IC_CHECKER_32_BH \
((uint32_t) 0x585000c0U)
#define VL53L5_IC_CHECKER_33_BH \
((uint32_t) 0x585c00c0U)
#define VL53L5_IC_CHECKER_34_BH \
((uint32_t) 0x586800c0U)
#define VL53L5_IC_CHECKER_35_BH \
((uint32_t) 0x587400c0U)
#define VL53L5_IC_CHECKER_36_BH \
((uint32_t) 0x588000c0U)
#define VL53L5_IC_CHECKER_37_BH \
((uint32_t) 0x588c00c0U)
#define VL53L5_IC_CHECKER_38_BH \
((uint32_t) 0x589800c0U)
#define VL53L5_IC_CHECKER_39_BH \
((uint32_t) 0x58a400c0U)
#define VL53L5_IC_CHECKER_40_BH \
((uint32_t) 0x58b000c0U)
#define VL53L5_IC_CHECKER_41_BH \
((uint32_t) 0x58bc00c0U)
#define VL53L5_IC_CHECKER_42_BH \
((uint32_t) 0x58c800c0U)
#define VL53L5_IC_CHECKER_43_BH \
((uint32_t) 0x58d400c0U)
#define VL53L5_IC_CHECKER_44_BH \
((uint32_t) 0x58e000c0U)
#define VL53L5_IC_CHECKER_45_BH \
((uint32_t) 0x58ec00c0U)
#define VL53L5_IC_CHECKER_46_BH \
((uint32_t) 0x58f800c0U)
#define VL53L5_IC_CHECKER_47_BH \
((uint32_t) 0x590400c0U)
#define VL53L5_IC_CHECKER_48_BH \
((uint32_t) 0x591000c0U)
#define VL53L5_IC_CHECKER_49_BH \
((uint32_t) 0x591c00c0U)
#define VL53L5_IC_CHECKER_50_BH \
((uint32_t) 0x592800c0U)
#define VL53L5_IC_CHECKER_51_BH \
((uint32_t) 0x593400c0U)
#define VL53L5_IC_CHECKER_52_BH \
((uint32_t) 0x594000c0U)
#define VL53L5_IC_CHECKER_53_BH \
((uint32_t) 0x594c00c0U)
#define VL53L5_IC_CHECKER_54_BH \
((uint32_t) 0x595800c0U)
#define VL53L5_IC_CHECKER_55_BH \
((uint32_t) 0x596400c0U)
#define VL53L5_IC_CHECKER_56_BH \
((uint32_t) 0x597000c0U)
#define VL53L5_IC_CHECKER_57_BH \
((uint32_t) 0x597c00c0U)
#define VL53L5_IC_CHECKER_58_BH \
((uint32_t) 0x598800c0U)
#define VL53L5_IC_CHECKER_59_BH \
((uint32_t) 0x599400c0U)
#define VL53L5_IC_CHECKER_60_BH \
((uint32_t) 0x59a000c0U)
#define VL53L5_IC_CHECKER_61_BH \
((uint32_t) 0x59ac00c0U)
#define VL53L5_IC_CHECKER_62_BH \
((uint32_t) 0x59b800c0U)
#define VL53L5_IC_CHECKER_63_BH \
((uint32_t) 0x59c400c0U)
#define VL53L5_IC_VALID_TGT_STATUS_VAILD_TARGET_STATUS_BH \
((uint32_t) 0x59d00081U)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,348 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_CORE_MAP_IDX_H__
#define __VL53L5_CORE_MAP_IDX_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define DEV_MAP_VERSION_IDX \
((uint16_t) 0x5400)
#define DEV_FW_VERSION_IDX \
((uint16_t) 0x5404)
#define DEV_CFG_INFO_IDX \
((uint16_t) 0x540c)
#define DEV_FMT_TRACEABILITY_IDX \
((uint16_t) 0x5420)
#define DEV_EWS_TRACEABILITY_IDX \
((uint16_t) 0x5438)
#define DEV_UI_RNG_DATA_ADDR_IDX \
((uint16_t) 0x5444)
#define DEV_SILICON_TEMP_DATA_IDX \
((uint16_t) 0x5450)
#define DEV_ZONE_CFG_IDX \
((uint16_t) 0x5454)
#define DEV_DEVICE_MODE_CFG_IDX \
((uint16_t) 0x545c)
#define DEV_RNG_RATE_CFG_IDX \
((uint16_t) 0x5464)
#define DEV_INT_MAX_CFG_IDX \
((uint16_t) 0x5468)
#define DEV_INT_MIN_CFG_IDX \
((uint16_t) 0x546c)
#define DEV_INT_MPX_DELTA_CFG_IDX \
((uint16_t) 0x5470)
#define DEV_INT_DSS_CFG_IDX \
((uint16_t) 0x5474)
#define DEV_FACTORY_CAL_CFG_IDX \
((uint16_t) 0x5478)
#define DEV_OUTPUT_DATA_CFG_IDX \
((uint16_t) 0x5480)
#define DEV_OUTPUT_BH_CFG_IDX \
((uint16_t) 0x5484)
#define DEV_OUTPUT_BH_ENABLES_OP_BH__ENABLES_IDX \
((uint16_t) 0x548c)
#define DEV_OUTPUT_BH_ENABLES_IDX \
((uint16_t) 0x548c)
#define DEV_OUTPUT_BH_LIST_OP_BH__LIST_IDX \
((uint16_t) 0x549c)
#define DEV_OUTPUT_BH_LIST_IDX \
((uint16_t) 0x549c)
#define DEV_INTERRUPT_CFG_IDX \
((uint16_t) 0x569c)
#define DEV_NVM_LASER_SAFETY_INFO_IDX \
((uint16_t) 0x56a4)
#define DEV_PATCH_HOOK_ENABLES_ARRAY_PATCH_HOOK_ENABLES_IDX \
((uint16_t) 0x56a8)
#define DEV_PATCH_HOOK_ENABLES_ARRAY_IDX \
((uint16_t) 0x56a8)
#define DEV_DEVICE_ERROR_STATUS_IDX \
((uint16_t) 0x56b8)
#define DEV_DEVICE_WARNING_STATUS_IDX \
((uint16_t) 0x56c4)
#define DEV_IC_CHECKER_0_IDX \
((uint16_t) 0x56d0)
#define DEV_IC_CHECKER_1_IDX \
((uint16_t) 0x56dc)
#define DEV_IC_CHECKER_2_IDX \
((uint16_t) 0x56e8)
#define DEV_IC_CHECKER_3_IDX \
((uint16_t) 0x56f4)
#define DEV_IC_CHECKER_4_IDX \
((uint16_t) 0x5700)
#define DEV_IC_CHECKER_5_IDX \
((uint16_t) 0x570c)
#define DEV_IC_CHECKER_6_IDX \
((uint16_t) 0x5718)
#define DEV_IC_CHECKER_7_IDX \
((uint16_t) 0x5724)
#define DEV_IC_CHECKER_8_IDX \
((uint16_t) 0x5730)
#define DEV_IC_CHECKER_9_IDX \
((uint16_t) 0x573c)
#define DEV_IC_CHECKER_10_IDX \
((uint16_t) 0x5748)
#define DEV_IC_CHECKER_11_IDX \
((uint16_t) 0x5754)
#define DEV_IC_CHECKER_12_IDX \
((uint16_t) 0x5760)
#define DEV_IC_CHECKER_13_IDX \
((uint16_t) 0x576c)
#define DEV_IC_CHECKER_14_IDX \
((uint16_t) 0x5778)
#define DEV_IC_CHECKER_15_IDX \
((uint16_t) 0x5784)
#define DEV_IC_CHECKER_16_IDX \
((uint16_t) 0x5790)
#define DEV_IC_CHECKER_17_IDX \
((uint16_t) 0x579c)
#define DEV_IC_CHECKER_18_IDX \
((uint16_t) 0x57a8)
#define DEV_IC_CHECKER_19_IDX \
((uint16_t) 0x57b4)
#define DEV_IC_CHECKER_20_IDX \
((uint16_t) 0x57c0)
#define DEV_IC_CHECKER_21_IDX \
((uint16_t) 0x57cc)
#define DEV_IC_CHECKER_22_IDX \
((uint16_t) 0x57d8)
#define DEV_IC_CHECKER_23_IDX \
((uint16_t) 0x57e4)
#define DEV_IC_CHECKER_24_IDX \
((uint16_t) 0x57f0)
#define DEV_IC_CHECKER_25_IDX \
((uint16_t) 0x57fc)
#define DEV_IC_CHECKER_26_IDX \
((uint16_t) 0x5808)
#define DEV_IC_CHECKER_27_IDX \
((uint16_t) 0x5814)
#define DEV_IC_CHECKER_28_IDX \
((uint16_t) 0x5820)
#define DEV_IC_CHECKER_29_IDX \
((uint16_t) 0x582c)
#define DEV_IC_CHECKER_30_IDX \
((uint16_t) 0x5838)
#define DEV_IC_CHECKER_31_IDX \
((uint16_t) 0x5844)
#define DEV_IC_CHECKER_32_IDX \
((uint16_t) 0x5850)
#define DEV_IC_CHECKER_33_IDX \
((uint16_t) 0x585c)
#define DEV_IC_CHECKER_34_IDX \
((uint16_t) 0x5868)
#define DEV_IC_CHECKER_35_IDX \
((uint16_t) 0x5874)
#define DEV_IC_CHECKER_36_IDX \
((uint16_t) 0x5880)
#define DEV_IC_CHECKER_37_IDX \
((uint16_t) 0x588c)
#define DEV_IC_CHECKER_38_IDX \
((uint16_t) 0x5898)
#define DEV_IC_CHECKER_39_IDX \
((uint16_t) 0x58a4)
#define DEV_IC_CHECKER_40_IDX \
((uint16_t) 0x58b0)
#define DEV_IC_CHECKER_41_IDX \
((uint16_t) 0x58bc)
#define DEV_IC_CHECKER_42_IDX \
((uint16_t) 0x58c8)
#define DEV_IC_CHECKER_43_IDX \
((uint16_t) 0x58d4)
#define DEV_IC_CHECKER_44_IDX \
((uint16_t) 0x58e0)
#define DEV_IC_CHECKER_45_IDX \
((uint16_t) 0x58ec)
#define DEV_IC_CHECKER_46_IDX \
((uint16_t) 0x58f8)
#define DEV_IC_CHECKER_47_IDX \
((uint16_t) 0x5904)
#define DEV_IC_CHECKER_48_IDX \
((uint16_t) 0x5910)
#define DEV_IC_CHECKER_49_IDX \
((uint16_t) 0x591c)
#define DEV_IC_CHECKER_50_IDX \
((uint16_t) 0x5928)
#define DEV_IC_CHECKER_51_IDX \
((uint16_t) 0x5934)
#define DEV_IC_CHECKER_52_IDX \
((uint16_t) 0x5940)
#define DEV_IC_CHECKER_53_IDX \
((uint16_t) 0x594c)
#define DEV_IC_CHECKER_54_IDX \
((uint16_t) 0x5958)
#define DEV_IC_CHECKER_55_IDX \
((uint16_t) 0x5964)
#define DEV_IC_CHECKER_56_IDX \
((uint16_t) 0x5970)
#define DEV_IC_CHECKER_57_IDX \
((uint16_t) 0x597c)
#define DEV_IC_CHECKER_58_IDX \
((uint16_t) 0x5988)
#define DEV_IC_CHECKER_59_IDX \
((uint16_t) 0x5994)
#define DEV_IC_CHECKER_60_IDX \
((uint16_t) 0x59a0)
#define DEV_IC_CHECKER_61_IDX \
((uint16_t) 0x59ac)
#define DEV_IC_CHECKER_62_IDX \
((uint16_t) 0x59b8)
#define DEV_IC_CHECKER_63_IDX \
((uint16_t) 0x59c4)
#define DEV_IC_VALID_TGT_STATUS_VAILD_TARGET_STATUS_IDX \
((uint16_t) 0x59d0)
#define DEV_IC_VALID_TGT_STATUS_IDX \
((uint16_t) 0x59d0)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,87 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 _VL53L5_DCI_CORE_H_
#define _VL53L5_DCI_CORE_H_
#include "vl53l5_platform_user_data.h"
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
int32_t vl53l5_dci_write_command(
struct vl53l5_dev_handle_t *p_dev,
uint8_t cmd_id,
uint8_t trans_id);
int32_t vl53l5_dci_read_command(
struct vl53l5_dev_handle_t *p_dev);
int32_t vl53l5_dci_poll_command_status(
struct vl53l5_dev_handle_t *p_dev,
uint32_t trans_id,
uint32_t timeout_ms);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,96 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 _VL53L5_DCI_DECODE_H_
#define _VL53L5_DCI_DECODE_H_
#include "vl53l5_platform_user_data.h"
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define DEV_INFO_SZ VL53L5_DEV_INFO_BLOCK_SZ
#define RANGE_DATA_READ_SIZE(p_dev) \
(p_dev->host_dev.range_data_addr.data_start_offset_bytes\
+ p_dev->host_dev.range_data_addr.data_size_bytes\
+ VL53L5_HEADER_FOOTER_BLOCK_SZ)
#define RANGE_DATA_START(p_dev) \
(VL53L5_COMMS_BUFF(p_dev) \
+ p_dev->host_dev.range_data_addr.data_start_offset_bytes)
#define RANGE_DATA_SIZE(p_dev)\
p_dev->host_dev.range_data_addr.data_size_bytes
int32_t vl53l5_dci_decode_range_data(
struct vl53l5_dev_handle_t *p_dev);
int32_t vl53l5_dci_decode_data(
struct vl53l5_dev_handle_t *p_dev,
uint8_t *buffer,
uint32_t data_size);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,91 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 _VL53L5_DCI_HELPERS_H_
#define _VL53L5_DCI_HELPERS_H_
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
int32_t vl53l5_dci_swap_buffer_byte_ordering(
uint8_t *p_buffer,
uint32_t buffer_count);
int32_t vl53l5_dci_encode_block_header(
uint8_t *p_buffer,
uint32_t max_buffer_size,
uint8_t type,
uint32_t block_byte_size,
uint16_t idx);
int32_t vl53l5_dci_decode_block_header(
uint8_t *p_buffer,
uint32_t max_buffer_size,
uint8_t *p_type,
uint32_t *p_block_byte_size,
uint16_t *p_idx);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,86 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 _VL53L5_DCI_RANGING_H_
#define _VL53L5_DCI_RANGING_H_
#include "vl53l5_platform_user_data.h"
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
int32_t vl53l5_dci_read_range(
struct vl53l5_dev_handle_t *p_dev);
int32_t vl53l5_dci_get_device_info(
struct vl53l5_dev_handle_t *p_dev);
int32_t vl53l5_dci_check_device_info(
struct vl53l5_dev_handle_t *p_dev,
uint8_t last_stream_id,
bool check_stream_count,
bool check_data_present);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,92 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 _VL53L5_DCI_TYPES_H_
#define _VL53L5_DCI_TYPES_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "dci_luts.h"
enum block_format_type {
LIST = DCI_BH__P_TYPE__CONSEC_PARAMS_LIST,
ARRAY_ELEMENT_SZ_1 = 0x1,
ARRAY_ELEMENT_SZ_2 = 0x2,
ARRAY_ELEMENT_SZ_3 = 0x3,
ARRAY_ELEMENT_SZ_4 = 0x4,
ARRAY_ELEMENT_SZ_5 = 0x5,
ARRAY_ELEMENT_SZ_6 = 0x6,
ARRAY_ELEMENT_SZ_7 = 0x7,
ARRAY_ELEMENT_SZ_8 = 0x8,
ARRAY_ELEMENT_SZ_9 = 0x9,
ARRAY_ELEMENT_SZ_10 = 0xA,
ARRAY_ELEMENT_SZ_11 = 0xB,
DCI_PAGE_SELECT = 0xC,
START_OF_GROUP = DCI_BH__P_TYPE__GRP_PARAMS_START,
END_OF_GROUP = DCI_BH__P_TYPE__GRP_PARAMS_END,
END_OF_DATA = DCI_BH__P_TYPE__END_OF_DATA
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,128 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 _VL53L5_DCI_UTILS_H
#define _VL53L5_DCI_UTILS_H
#include "vl53l5_platform.h"
#ifdef __cplusplus
extern "C"
{
#endif
void vl53l5_encode_int32_t(
int32_t value,
uint16_t count,
uint8_t *pbuffer);
int32_t vl53l5_decode_int32_t(
uint16_t count,
uint8_t *pbuffer);
void vl53l5_encode_uint32_t(
uint32_t value,
uint16_t count,
uint8_t *pbuffer);
uint32_t vl53l5_decode_uint32_t(
uint16_t count,
uint8_t *pbuffer);
void vl53l5_encode_int16_t(
int16_t value,
uint16_t count,
uint8_t *pbuffer);
int16_t vl53l5_decode_int16_t(
uint16_t count,
uint8_t *pbuffer);
void vl53l5_encode_uint16_t(
uint16_t value,
uint16_t count,
uint8_t *pbuffer);
uint16_t vl53l5_decode_uint16_t(
uint16_t count,
uint8_t *pbuffer);
void vl53l5_encode_int8_t(
int8_t value,
uint16_t count,
uint8_t *pbuffer);
int8_t vl53l5_decode_int8_t(
uint16_t count,
uint8_t *pbuffer);
void vl53l5_encode_uint8_t(
uint8_t value,
uint16_t count,
uint8_t *pbuffer);
uint8_t vl53l5_decode_uint8_t(
uint16_t count,
uint8_t *pbuffer);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,79 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_DECODE_SWITCH_H__
#define __VL53L5_DECODE_SWITCH_H__
#include "vl53l5_platform_user_data.h"
#ifdef __cplusplus
extern "C" {
#endif
int32_t vl53l5_decode_switch(
uint16_t idx,
uint32_t buffer_size,
uint8_t *buffer,
struct vl53l5_dev_handle_t *p_dev);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,79 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_RESULTS_DECODE_H__
#define __VL53L5_RESULTS_DECODE_H__
#include "vl53l5_platform_user_data.h"
#ifdef __cplusplus
extern "C" {
#endif
int32_t vl53l5_results_decode_cmd(
uint16_t idx,
uint32_t buffer_size,
uint8_t *buffer,
struct vl53l5_dev_handle_t *p_dev);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,164 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_RESULTS_DEV_PATH_H__
#define __VL53L5_RESULTS_DEV_PATH_H__
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_MAP_RESULTS_DEV(p_dev) \
((p_dev)->host_dev.presults_dev)
#define VL53L5_META_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->meta_data
#define VL53L5_COMMON_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->common_data
#define VL53L5_RNG_TIMING_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->rng_timing_data
#define VL53L5_PER_ZONE_RESULTS(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->per_zone_results
#define VL53L5_PER_TGT_RESULTS(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->per_tgt_results
#define VL53L5_REF_TIMING_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->ref_timing_data
#define VL53L5_REF_CHANNEL_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->ref_channel_data
#define VL53L5_REF_TARGET_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->ref_target_data
#define VL53L5_SHARPENER_TARGET_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->sharpener_target_data
#define VL53L5_HIST_ZONE_GRID_POINT_META_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->hist_zone_grid_point_meta_data
#define VL53L5_HIST_ZONE_GRID_POINT_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->hist_zone_grid_point_data
#define VL53L5_HIST_COMMON_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->hist_common_data
#define VL53L5_HIST_TIMING_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->hist_timing_data
#define VL53L5_HIST_CHANNEL_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->hist_channel_data
#define VL53L5_HIST_BIN_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->hist_bin_data
#define VL53L5_HIST_REF_COMMON_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->hist_ref_common_data
#define VL53L5_HIST_REF_TIMING_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->hist_ref_timing_data
#define VL53L5_HIST_REF_CHANNEL_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->hist_ref_channel_data
#define VL53L5_HIST_REF_BIN_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->hist_ref_bin_data
#define VL53L5_HIST_ACC_COMMON_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->hist_acc_common_data
#define VL53L5_HIST_ACC_CHANNEL_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->hist_acc_channel_data
#define VL53L5_HIST_ACC_BIN_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->hist_acc_bin_data
#define VL53L5_ACC_ZONE_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->acc_zone_data
#define VL53L5_REF_MPX_META_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->ref_mpx_meta_data
#define VL53L5_REF_MPX_COMMON_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->ref_mpx_common_data
#define VL53L5_REF_MPX_TIMING_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->ref_mpx_timing_data
#define VL53L5_REF_MPX_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->ref_mpx_data
#define VL53L5_RTN_MPX_META_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->rtn_mpx_meta_data
#define VL53L5_RTN_MPX_COMMON_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->rtn_mpx_common_data
#define VL53L5_RTN_MPX_TIMING_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->rtn_mpx_timing_data
#define VL53L5_RTN_MPX_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->rtn_mpx_data
#define VL53L5_XTALK_MON_META(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->xtalk_mon_meta
#define VL53L5_XTALK_MON_ZONES_MAX(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->xtalk_mon_zones_max
#define VL53L5_XTALK_MON_ZONES_ACTUAL(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->xtalk_mon_zones_actual
#define VL53L5_XTALK_MON_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->xtalk_mon_data
#define VL53L5_VHV_RESULT_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->vhv_result_data
#define VL53L5_VHV_SEARCH_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->vhv_search_data
#define VL53L5_CAL_REF_SPAD_SEARCH_META_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->cal_ref_spad_search_meta_data
#define VL53L5_CAL_REF_SPAD_SEARCH_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->cal_ref_spad_search_data
#define VL53L5_REF_ARRAY_META_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->ref_array_meta_data
#define VL53L5_RTN_ARRAY_META_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->rtn_array_meta_data
#define VL53L5_REF_ARRAY_SPAD_EN(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->ref_array_spad_en
#define VL53L5_RTN_ARRAY_SPAD_EN(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->rtn_array_spad_en
#define VL53L5_ZONE_THRESH_STATUS(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->zone_thresh_status
#define VL53L5_DYN_XTALK_OP_PERSISTENT_DATA(p_dev) \
VL53L5_MAP_RESULTS_DEV(p_dev)->dyn_xtalk_op_persistent_data
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,133 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_RESULTS_ENUM_TYPE_H__
#define __VL53L5_RESULTS_ENUM_TYPE_H__
#include "vl53l5_dci_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_BUF_META_DATA_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_RNG_COMMON_DATA_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_RNG_TIMING_DATA_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_RPZD_AMB_RATE_KCPS_PER_SPAD_TYPE \
((enum block_format_type) 0x4)
#define VL53L5_RPZD_RNG_EFFECTIVE_SPAD_COUNT_TYPE \
((enum block_format_type) 0x4)
#define VL53L5_RPZD_AMB_DMAX_MM_TYPE \
((enum block_format_type) 0x2)
#define VL53L5_RPZD_SILICON_TEMP_DEGC_START_TYPE \
((enum block_format_type) 0x1)
#define VL53L5_RPZD_SILICON_TEMP_DEGC_END_TYPE \
((enum block_format_type) 0x1)
#define VL53L5_RPZD_RNG_NO_OF_TARGETS_TYPE \
((enum block_format_type) 0x1)
#define VL53L5_RPZD_RNG_ZONE_ID_TYPE \
((enum block_format_type) 0x1)
#define VL53L5_RPZD_RNG_SEQUENCE_IDX_TYPE \
((enum block_format_type) 0x1)
#define VL53L5_RPTD_PEAK_RATE_KCPS_PER_SPAD_TYPE \
((enum block_format_type) 0x4)
#define VL53L5_RPTD_MEDIAN_PHASE_TYPE \
((enum block_format_type) 0x4)
#define VL53L5_RPTD_RATE_SIGMA_KCPS_PER_SPAD_TYPE \
((enum block_format_type) 0x4)
#define VL53L5_RPTD_TARGET_ZSCORE_TYPE \
((enum block_format_type) 0x2)
#define VL53L5_RPTD_RANGE_SIGMA_MM_TYPE \
((enum block_format_type) 0x2)
#define VL53L5_RPTD_MEDIAN_RANGE_MM_TYPE \
((enum block_format_type) 0x2)
#define VL53L5_RPTD_START_RANGE_MM_TYPE \
((enum block_format_type) 0x2)
#define VL53L5_RPTD_END_RANGE_MM_TYPE \
((enum block_format_type) 0x2)
#define VL53L5_RPTD_MIN_RANGE_DELTA_MM_TYPE \
((enum block_format_type) 0x1)
#define VL53L5_RPTD_MAX_RANGE_DELTA_MM_TYPE \
((enum block_format_type) 0x1)
#define VL53L5_RPTD_TARGET_REFLECTANCE_EST_PC_TYPE \
((enum block_format_type) 0x1)
#define VL53L5_RPTD_TARGET_STATUS_TYPE \
((enum block_format_type) 0x1)
#define VL53L5_REF_CHANNEL_DATA_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_REF_TARGET_DATA_TYPE \
((enum block_format_type) 0x0)
#define VL53L5_STD_SHARPENER_GROUP_INDEX_TYPE \
((enum block_format_type) 0x1)
#define VL53L5_STD_SHARPENER_CONFIDENCE_TYPE \
((enum block_format_type) 0x1)
#define VL53L5_ZTSA_ZONE_THRESH_STATUS_BYTES_TYPE \
((enum block_format_type) 0x1)
#define VL53L5_DYN_XTALK_PERSISTENT_DATA_TYPE \
((enum block_format_type) 0x0)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,143 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_RESULTS_MAP_H__
#define __VL53L5_RESULTS_MAP_H__
#include "dci_defs.h"
#include "dci_structs.h"
#include "dci_union_structs.h"
#include "dci_ui_structs.h"
#include "common_datatype_structs.h"
#include "common_datatype_defs.h"
#include "packing_structs.h"
#include "vl53l5_types.h"
#include "dyn_xtalk_structs.h"
#include "dyn_xtalk_defs.h"
#include "ic_checkers_structs.h"
#include "ic_checkers_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_CGHBD_HIST_BIN_EVENTS_PACKED_ARRAY_SZ \
((uint16_t) 6912)
struct vl53l5_range_results_t {
#ifdef VL53L5_META_DATA_ON
struct vl53l5_range_meta_data_t meta_data;
#endif
#ifdef VL53L5_COMMON_DATA_ON
struct vl53l5_range_common_data_t common_data;
#endif
#ifdef VL53L5_RNG_TIMING_DATA_ON
struct vl53l5_range_timing_data_t rng_timing_data;
#endif
#ifdef VL53L5_PER_ZONE_RESULTS_ON
struct vl53l5_range_per_zone_results_t per_zone_results;
#endif
#ifdef VL53L5_PER_TGT_RESULTS_ON
struct vl53l5_range_per_tgt_results_t per_tgt_results;
#endif
#ifdef VL53L5_REF_TIMING_DATA_ON
struct vl53l5_range_timing_data_t ref_timing_data;
#endif
#ifdef VL53L5_REF_CHANNEL_DATA_ON
struct vl53l5_ref_channel_data_t ref_channel_data;
#endif
#ifdef VL53L5_REF_TARGET_DATA_ON
struct vl53l5_ref_target_data_t ref_target_data;
#endif
#ifdef VL53L5_SHARPENER_TARGET_DATA_ON
struct vl53l5_sharpener_target_data_t sharpener_target_data;
#endif
#ifdef VL53L5_ZONE_THRESH_STATUS_ON
struct vl53l5_zone_thresh_status_array_t zone_thresh_status;
#endif
#ifdef VL53L5_DYN_XTALK_OP_PERSISTENT_DATA_ON
struct vl53l5_dyn_xtalk_persistent_data_t dyn_xtalk_op_persistent_data;
#endif
};
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,133 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_RESULTS_MAP_BH_H__
#define __VL53L5_RESULTS_MAP_BH_H__
#ifdef __cplusplus
extern "C" {
#endif
#define VL53L5_RNG_META_DATA_BH \
((uint32_t) 0x59d800c0U)
#define VL53L5_RNG_COMMON_DATA_BH \
((uint32_t) 0x59e40080U)
#define VL53L5_RNG_TIMING_DATA_BH \
((uint32_t) 0x59ec00c0U)
#define VL53L5_RNG_PER_ZONE_DATA_AMB_RATE_KCPS_PER_SPAD_BH \
((uint32_t) 0x59f80444U)
#define VL53L5_RNG_PER_ZONE_DATA_RNG__EFFECTIVE_SPAD_COUNT_BH \
((uint32_t) 0x5b080444U)
#define VL53L5_RNG_PER_ZONE_DATA_AMB_DMAX_MM_BH \
((uint32_t) 0x5c180442U)
#define VL53L5_RNG_PER_ZONE_DATA_SILICON_TEMP_DEGC__START_BH \
((uint32_t) 0x5ca00441U)
#define VL53L5_RNG_PER_ZONE_DATA_SILICON_TEMP_DEGC__END_BH \
((uint32_t) 0x5ce40441U)
#define VL53L5_RNG_PER_ZONE_DATA_RNG__NO_OF_TARGETS_BH \
((uint32_t) 0x5d280441U)
#define VL53L5_RNG_PER_ZONE_DATA_RNG__ZONE_ID_BH \
((uint32_t) 0x5d6c0441U)
#define VL53L5_RNG_PER_ZONE_DATA_RNG__SEQUENCE_IDX_BH \
((uint32_t) 0x5db00441U)
#define VL53L5_RNG_PER_TARGET_DATA_PEAK_RATE_KCPS_PER_SPAD_BH \
((uint32_t) 0x5df41104U)
#define VL53L5_RNG_PER_TARGET_DATA_MEDIAN_PHASE_BH \
((uint32_t) 0x62341104U)
#define VL53L5_RNG_PER_TARGET_DATA_RATE_SIGMA_KCPS_PER_SPAD_BH \
((uint32_t) 0x66741104U)
#define VL53L5_RNG_PER_TARGET_DATA_TARGET_ZSCORE_BH \
((uint32_t) 0x6ab41102U)
#define VL53L5_RNG_PER_TARGET_DATA_RANGE_SIGMA_MM_BH \
((uint32_t) 0x6cd41102U)
#define VL53L5_RNG_PER_TARGET_DATA_MEDIAN_RANGE_MM_BH \
((uint32_t) 0x6ef41102U)
#define VL53L5_RNG_PER_TARGET_DATA_START_RANGE_MM_BH \
((uint32_t) 0x71141102U)
#define VL53L5_RNG_PER_TARGET_DATA_END_RANGE_MM_BH \
((uint32_t) 0x73341102U)
#define VL53L5_RNG_PER_TARGET_DATA_MIN_RANGE_DELTA_MM_BH \
((uint32_t) 0x75541101U)
#define VL53L5_RNG_PER_TARGET_DATA_MAX_RANGE_DELTA_MM_BH \
((uint32_t) 0x76641101U)
#define VL53L5_RNG_PER_TARGET_DATA_TARGET_REFLECTANCE_EST_PC_BH \
((uint32_t) 0x77741101U)
#define VL53L5_RNG_PER_TARGET_DATA_TARGET_STATUS_BH \
((uint32_t) 0x78841101U)
#define VL53L5_REF_TIMING_DATA_BH \
((uint32_t) 0x799400c0U)
#define VL53L5_REF_CHANNEL_DATA_BH \
((uint32_t) 0x79a00100U)
#define VL53L5_REF_TARGET_DATA_BH \
((uint32_t) 0x79b001c0U)
#define VL53L5_SHARPENER_TARGET_DATA_SHARPENER__GROUP_INDEX_BH \
((uint32_t) 0x79cc1101U)
#define VL53L5_SHARPENER_TARGET_DATA_SHARPENER__CONFIDENCE_BH \
((uint32_t) 0x7adc1101U)
#define VL53L5_ZONE_THRESH_STATUS_ZONE_THRESH_STATUS_BYTES_BH \
((uint32_t) 0xafb80081U)
#define VL53L5_DYN_XTALK_OP_PERSISTENT_DATA_BH \
((uint32_t) 0xafc001c0U)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,171 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 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 __VL53L5_RESULTS_MAP_IDX_H__
#define __VL53L5_RESULTS_MAP_IDX_H__
#include "vl53l5_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define DEV_RNG_META_DATA_IDX \
((uint16_t) 0x59d8)
#define DEV_RNG_COMMON_DATA_IDX \
((uint16_t) 0x59e4)
#define DEV_RNG_TIMING_DATA_IDX \
((uint16_t) 0x59ec)
#define DEV_RNG_PER_ZONE_DATA_AMB_RATE_KCPS_PER_SPAD_IDX \
((uint16_t) 0x59f8)
#define DEV_RNG_PER_ZONE_DATA_IDX \
((uint16_t) 0x59f8)
#define DEV_RNG_PER_ZONE_DATA_RNG__EFFECTIVE_SPAD_COUNT_IDX \
((uint16_t) 0x5b08)
#define DEV_RNG_PER_ZONE_DATA_AMB_DMAX_MM_IDX \
((uint16_t) 0x5c18)
#define DEV_RNG_PER_ZONE_DATA_SILICON_TEMP_DEGC__START_IDX \
((uint16_t) 0x5ca0)
#define DEV_RNG_PER_ZONE_DATA_SILICON_TEMP_DEGC__END_IDX \
((uint16_t) 0x5ce4)
#define DEV_RNG_PER_ZONE_DATA_RNG__NO_OF_TARGETS_IDX \
((uint16_t) 0x5d28)
#define DEV_RNG_PER_ZONE_DATA_RNG__ZONE_ID_IDX \
((uint16_t) 0x5d6c)
#define DEV_RNG_PER_ZONE_DATA_RNG__SEQUENCE_IDX_IDX \
((uint16_t) 0x5db0)
#define DEV_RNG_PER_TARGET_DATA_PEAK_RATE_KCPS_PER_SPAD_IDX \
((uint16_t) 0x5df4)
#define DEV_RNG_PER_TARGET_DATA_IDX \
((uint16_t) 0x5df4)
#define DEV_RNG_PER_TARGET_DATA_MEDIAN_PHASE_IDX \
((uint16_t) 0x6234)
#define DEV_RNG_PER_TARGET_DATA_RATE_SIGMA_KCPS_PER_SPAD_IDX \
((uint16_t) 0x6674)
#define DEV_RNG_PER_TARGET_DATA_TARGET_ZSCORE_IDX \
((uint16_t) 0x6ab4)
#define DEV_RNG_PER_TARGET_DATA_RANGE_SIGMA_MM_IDX \
((uint16_t) 0x6cd4)
#define DEV_RNG_PER_TARGET_DATA_MEDIAN_RANGE_MM_IDX \
((uint16_t) 0x6ef4)
#define DEV_RNG_PER_TARGET_DATA_START_RANGE_MM_IDX \
((uint16_t) 0x7114)
#define DEV_RNG_PER_TARGET_DATA_END_RANGE_MM_IDX \
((uint16_t) 0x7334)
#define DEV_RNG_PER_TARGET_DATA_MIN_RANGE_DELTA_MM_IDX \
((uint16_t) 0x7554)
#define DEV_RNG_PER_TARGET_DATA_MAX_RANGE_DELTA_MM_IDX \
((uint16_t) 0x7664)
#define DEV_RNG_PER_TARGET_DATA_TARGET_REFLECTANCE_EST_PC_IDX \
((uint16_t) 0x7774)
#define DEV_RNG_PER_TARGET_DATA_TARGET_STATUS_IDX \
((uint16_t) 0x7884)
#define DEV_REF_TIMING_DATA_IDX \
((uint16_t) 0x7994)
#define DEV_REF_CHANNEL_DATA_IDX \
((uint16_t) 0x79a0)
#define DEV_REF_TARGET_DATA_IDX \
((uint16_t) 0x79b0)
#define DEV_SHARPENER_TARGET_DATA_SHARPENER__GROUP_INDEX_IDX \
((uint16_t) 0x79cc)
#define DEV_SHARPENER_TARGET_DATA_IDX \
((uint16_t) 0x79cc)
#define DEV_SHARPENER_TARGET_DATA_SHARPENER__CONFIDENCE_IDX \
((uint16_t) 0x7adc)
#define DEV_ZONE_THRESH_STATUS_ZONE_THRESH_STATUS_BYTES_IDX \
((uint16_t) 0xafb8)
#define DEV_ZONE_THRESH_STATUS_IDX \
((uint16_t) 0xafb8)
#define DEV_DYN_XTALK_OP_PERSISTENT_DATA_IDX \
((uint16_t) 0xafc0)
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,113 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*******************************************************************************/
#include "page_map_switch.h"
#include "page_map_defs.h"
#include "vl53l5_error_codes.h"
#include "vl53l5_platform_log.h"
#include "vl53l5_decode_switch.h"
#ifdef VL53L5_PATCH_DATA_ENABLED
#include "vl53l5_tcpm_patch_0_decode_switch.h"
#include "vl53l5_tcpm_patch_1_decode_switch.h"
#endif
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START( \
VL53L5_TRACE_MODULE_DCI_DECODE, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END( \
VL53L5_TRACE_MODULE_DCI_DECODE, status, ##__VA_ARGS__)
#define LOG_FUNCTION_END_FMT(status, ...) \
_LOG_FUNCTION_END_FMT( \
VL53L5_TRACE_MODULE_DCI_DECODE, status, ##__VA_ARGS__)
int32_t dci_page_map_switch(
uint16_t idx,
uint32_t buffer_size,
uint8_t *buffer,
struct vl53l5_dev_handle_t *p_dev,
uint16_t page_index)
{
int32_t status = VL53L5_ERROR_NONE;
LOG_FUNCTION_START("");
switch (page_index) {
case PAGE_DEF__PAGE_VL53L5_DEV:
status = vl53l5_decode_switch(idx, buffer_size, buffer, p_dev);
break;
#ifdef VL53L5_PATCH_DATA_ENABLED
case PAGE_DEF__PAGE_PATCH_0_DEV:
status = vl53l5_tcpm_patch_0_decode_switch(idx, buffer_size, buffer, p_dev);
break;
case PAGE_DEF__PAGE_PATCH_1_DEV:
status = vl53l5_tcpm_patch_1_decode_switch(idx, buffer_size, buffer, p_dev);
break;
#endif
default:
status = VL53L5_INVALID_PAGE_ERROR;
break;
}
LOG_FUNCTION_END(status);
return status;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,290 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*******************************************************************************/
#include "dci_size.h"
#include "dci_ui_size.h"
#include "vl53l5_core_decode.h"
#include "vl53l5_core_enum_type.h"
#include "vl53l5_core_map_idx.h"
#include "vl53l5_core_dev_path.h"
#include "vl53l5_dci_utils.h"
#include "vl53l5_error_codes.h"
#include "vl53l5_platform_log.h"
#include "common_datatype_size.h"
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START( \
VL53L5_TRACE_MODULE_DCI_DECODE, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END( \
VL53L5_TRACE_MODULE_DCI_DECODE, status, ##__VA_ARGS__)
#define LOG_FUNCTION_END_FMT(status, ...) \
_LOG_FUNCTION_END_FMT( \
VL53L5_TRACE_MODULE_DCI_DECODE, status, ##__VA_ARGS__)
#ifdef VL53L5_CALIBRATION_DECODE_ON
static int32_t _decode_dci_grp_map_version(
uint32_t buffer_size,
uint8_t *buffer,
struct dci_grp__map_version_t *pstruct)
{
int32_t status = STATUS_OK;
uint32_t buff_count = 0;
uint8_t *p_buff = buffer;
LOG_FUNCTION_START("");
if (buffer_size >
(uint32_t)VL53L5_MAP_VERSION_SZ) {
status = VL53L5_BUFFER_LARGER_THAN_EXPECTED_DATA;
goto exit;
}
pstruct->map__major =
vl53l5_decode_uint16_t(BYTE_2, p_buff);
p_buff += BYTE_2;
buff_count += BYTE_2;
pstruct->map__minor =
vl53l5_decode_uint16_t(BYTE_2, p_buff);
p_buff += BYTE_2;
buff_count += BYTE_2;
if (buffer_size != buff_count)
status = VL53L5_DATA_SIZE_MISMATCH;
exit:
LOG_FUNCTION_END(status);
return status;
}
#endif
#ifdef VL53L5_SILICON_TEMP_DATA_ON
static int32_t _decode_dci_grp_silicon_temperature_data(
uint32_t buffer_size,
uint8_t *buffer,
struct dci_grp__silicon_temperature_data_t *pstruct)
{
int32_t status = STATUS_OK;
uint32_t buff_count = 0;
uint8_t *p_buff = buffer;
LOG_FUNCTION_START("");
if (buffer_size >
(uint32_t)VL53L5_SILICON_TEMPERATURE_DATA_SZ) {
status = VL53L5_BUFFER_LARGER_THAN_EXPECTED_DATA;
goto exit;
}
pstruct->silicon_temp_degc__start =
vl53l5_decode_int8_t(BYTE_1, p_buff);
p_buff += BYTE_1;
buff_count += BYTE_1;
pstruct->silicon_temp_degc__end =
vl53l5_decode_int8_t(BYTE_1, p_buff);
p_buff += BYTE_1;
buff_count += BYTE_1;
pstruct->silicon_temp__pad_0 =
vl53l5_decode_int8_t(BYTE_1, p_buff);
p_buff += BYTE_1;
buff_count += BYTE_1;
pstruct->silicon_temp__pad_1 =
vl53l5_decode_int8_t(BYTE_1, p_buff);
p_buff += BYTE_1;
buff_count += BYTE_1;
if (buffer_size != buff_count)
status = VL53L5_DATA_SIZE_MISMATCH;
exit:
LOG_FUNCTION_END(status);
return status;
}
#endif
#ifdef VL53L5_ZONE_CFG_ON
static int32_t _decode_dci_grp_zone_cfg(
uint32_t buffer_size,
uint8_t *buffer,
struct dci_grp__zone_cfg_t *pstruct)
{
int32_t status = STATUS_OK;
uint32_t buff_count = 0;
uint8_t *p_buff = buffer;
LOG_FUNCTION_START("");
if (buffer_size >
(uint32_t)VL53L5_ZONE_CFG_SZ) {
status = VL53L5_BUFFER_LARGER_THAN_EXPECTED_DATA;
goto exit;
}
pstruct->zone__grid_cols =
vl53l5_decode_uint8_t(BYTE_1, p_buff);
p_buff += BYTE_1;
buff_count += BYTE_1;
pstruct->zone__grid_rows =
vl53l5_decode_uint8_t(BYTE_1, p_buff);
p_buff += BYTE_1;
buff_count += BYTE_1;
pstruct->zone__grid_x_ll =
vl53l5_decode_uint8_t(BYTE_1, p_buff);
p_buff += BYTE_1;
buff_count += BYTE_1;
pstruct->zone__grid_y_ll =
vl53l5_decode_uint8_t(BYTE_1, p_buff);
p_buff += BYTE_1;
buff_count += BYTE_1;
pstruct->zone__grid_x_pitch =
vl53l5_decode_uint8_t(BYTE_1, p_buff);
p_buff += BYTE_1;
buff_count += BYTE_1;
pstruct->zone__grid_y_pitch =
vl53l5_decode_uint8_t(BYTE_1, p_buff);
p_buff += BYTE_1;
buff_count += BYTE_1;
pstruct->zone__pad_0 =
vl53l5_decode_uint8_t(BYTE_1, p_buff);
p_buff += BYTE_1;
buff_count += BYTE_1;
pstruct->zone__pad_1 =
vl53l5_decode_uint8_t(BYTE_1, p_buff);
p_buff += BYTE_1;
buff_count += BYTE_1;
if (buffer_size != buff_count)
status = VL53L5_DATA_SIZE_MISMATCH;
exit:
LOG_FUNCTION_END(status);
return status;
}
#endif
int32_t vl53l5_core_decode_cmd(
uint16_t idx,
uint32_t buffer_size,
uint8_t *buffer,
struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = STATUS_OK;
LOG_FUNCTION_START("");
#if !defined(VL53L5_CALIBRATION_DECODE_ON) && \
!defined(VL53L5_SILICON_TEMP_DATA_ON) && \
!defined(VL53L5_ZONE_CFG_ON)
(void)buffer_size;
(void)buffer;
(void)p_dev;
#endif
switch (idx) {
#ifdef VL53L5_CALIBRATION_DECODE_ON
case DEV_MAP_VERSION_IDX:
status =
_decode_dci_grp_map_version(
buffer_size,
buffer,
&VL53L5_MAP_VERSION(p_dev));
break;
#endif
#ifdef VL53L5_SILICON_TEMP_DATA_ON
case DEV_SILICON_TEMP_DATA_IDX:
status =
_decode_dci_grp_silicon_temperature_data(
buffer_size,
buffer,
&VL53L5_SILICON_TEMP_DATA(p_dev));
break;
#endif
#ifdef VL53L5_ZONE_CFG_ON
case DEV_ZONE_CFG_IDX:
status =
_decode_dci_grp_zone_cfg(
buffer_size,
buffer,
&VL53L5_ZONE_CFG(p_dev));
break;
#endif
default:
status = VL53L5_INVALID_IDX_DECODE_CMD_ERROR;
break;
}
LOG_FUNCTION_END(status);
return status;
}

View File

@@ -0,0 +1,446 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*******************************************************************************/
#include "vl53l5_dci_core.h"
#include "vl53l5_dci_helpers.h"
#include "vl53l5_dci_utils.h"
#include "vl53l5_driver_dev_path.h"
#include "vl53l5_globals.h"
#include "vl53l5_platform.h"
#include "vl53l5_platform_log.h"
#include "vl53l5_platform_user_config.h"
#include "vl53l5_error_codes.h"
#include "dci_luts.h"
#define trace_print(level, ...) \
_LOG_TRACE_PRINT(VL53L5_TRACE_MODULE_DCI, \
level, VL53L5_TRACE_FUNCTION_ALL, ##__VA_ARGS__)
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START(VL53L5_TRACE_MODULE_DCI, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_DCI, status, ##__VA_ARGS__)
#define CHECK_FOR_TIMEOUT(status, p_dev, start_ms, end_ms, timeout_ms) \
(status = vl53l5_check_for_timeout(\
(p_dev), start_ms, end_ms, timeout_ms))
#define CMD_STATUS_COMPLETE(p_dev) \
(VL53L5_CMD_INFO(p_dev).cmd__rtn_command_status \
== DCI_CMD_STATUS__COMPLETED)
#define CMD_STATUS_ERROR(p_dev) \
(VL53L5_CMD_INFO(p_dev).cmd__rtn_command_status \
== DCI_CMD_STATUS__ERROR)
#define TRANS_ID_MATCH(p_dev, trans_id) \
(VL53L5_CMD_INFO(p_dev).cmd__rtn_transaction_id == trans_id)
#define DCI_COMMAND_FOOTER_SIZE 4
#define DCI_END_OF_DATA_FOOTER_SIZE 4
#define DCI_END_OF_DATA_TYPE 0xf
#define DCI_COMMAND_STATUS_SIZE 4
#define UI_COMMAND_WRITE_END (DCI_UI__COMMAND_WRITE__END_IDX & 0xFFFF)
#define UI_COMMAND_READ_END \
(UI_COMMAND_WRITE_END - DCI_UI__COMMAND_FOOTER__SIZE_BYTES)
#define UI_STATUS_START \
(DCI_UI__COMMAND_INFO__START_IDX & 0xFFFF)
#define CMD_STATUS_TIMEOUT_MS 1100
static int32_t _encode_end_data_footer(
uint8_t *p_buff, uint32_t *p_count);
static void _encode_command_footer(
uint8_t *p_buff, uint32_t *p_count,
uint8_t command_id, uint8_t transaction_id);
static int32_t _write_comms_buffer_to_command_ui(
struct vl53l5_dev_handle_t *p_dev);
static int32_t _read_command_ui_to_comms_buffer(
struct vl53l5_dev_handle_t *p_dev);
static int32_t _poll_command_status_block(struct vl53l5_dev_handle_t *p_dev,
uint32_t trans_id, uint32_t timeout_ms, uint32_t start_time_ms,
bool check_trans_id, bool check_cmd_status);
static int32_t _get_command_status(struct vl53l5_dev_handle_t *p_dev);
int32_t vl53l5_dci_write_command(
struct vl53l5_dev_handle_t *p_dev,
uint8_t command_id,
uint8_t transaction_id)
{
int32_t status = VL53L5_ERROR_NONE;
uint32_t available_count = 0;
uint32_t required_count = 0;
uint8_t *p_buff = 0;
LOG_FUNCTION_START("");
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (VL53L5_COMMS_BUFF_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (command_id > DCI_CMD_ID__STOP_RANGE) {
status = VL53L5_INVALID_CMD_ID;
goto exit;
}
if (VL53L5_COMMS_BUFF_MAX_COUNT(p_dev) > VL53L5_COMMS_BUFF_COUNT(p_dev)) {
available_count = VL53L5_COMMS_BUFF_MAX_COUNT(p_dev)
- VL53L5_COMMS_BUFF_COUNT(p_dev);
}
required_count = DCI_COMMAND_FOOTER_SIZE;
if (VL53L5_COMMS_BUFF_MAX_COUNT(p_dev))
required_count += DCI_END_OF_DATA_FOOTER_SIZE;
if (required_count > available_count) {
status = VL53L5_MAX_BUFFER_SIZE_REACHED;
goto exit;
} else if ((VL53L5_COMMS_BUFF_COUNT(p_dev) + required_count) >
VL53L5_MAX_CMD_UI_SIZE_BYTES) {
status = VL53L5_DATA_EXCEEDS_CMD_BUFFER_SIZE;
goto exit;
}
p_buff = VL53L5_COMMS_BUFF(p_dev) + VL53L5_COMMS_BUFF_COUNT(p_dev);
if (VL53L5_COMMS_BUFF_COUNT(p_dev)) {
status = _encode_end_data_footer(
p_buff, &VL53L5_COMMS_BUFF_COUNT(p_dev));
p_buff += DCI_END_OF_DATA_FOOTER_SIZE;
if (status != STATUS_OK)
goto exit;
}
_encode_command_footer(
p_buff, &VL53L5_COMMS_BUFF_COUNT(p_dev), command_id,
transaction_id);
status = vl53l5_dci_swap_buffer_byte_ordering(
VL53L5_COMMS_BUFF(p_dev), VL53L5_COMMS_BUFF_COUNT(p_dev));
if (status < STATUS_OK)
goto exit;
status = _write_comms_buffer_to_command_ui(p_dev);
exit:
LOG_FUNCTION_END(status);
return status;
}
int32_t vl53l5_dci_read_command(
struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = VL53L5_ERROR_NONE;
LOG_FUNCTION_START("");
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (VL53L5_COMMS_BUFF_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
status = _read_command_ui_to_comms_buffer(p_dev);
if (status < STATUS_OK)
goto exit;
status = vl53l5_dci_swap_buffer_byte_ordering(
VL53L5_COMMS_BUFF(p_dev), VL53L5_COMMS_BUFF_COUNT(p_dev));
if (status < STATUS_OK)
goto exit;
exit:
LOG_FUNCTION_END(status);
return status;
}
int32_t vl53l5_dci_poll_command_status(
struct vl53l5_dev_handle_t *p_dev,
uint32_t trans_id,
uint32_t timeout_ms)
{
int32_t status = VL53L5_ERROR_NONE;
uint32_t start_time_ms = 0;
LOG_FUNCTION_START("");
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (timeout_ms == 0)
timeout_ms = CMD_STATUS_TIMEOUT_MS;
status = vl53l5_get_tick_count(p_dev, &start_time_ms);
if (status < STATUS_OK)
goto exit;
status = _poll_command_status_block(p_dev, trans_id, timeout_ms,
start_time_ms, true, false);
if (status != STATUS_OK)
goto exit;
status = _poll_command_status_block(p_dev, trans_id, timeout_ms,
start_time_ms, true, true);
exit:
LOG_FUNCTION_END(status);
return status;
}
static int32_t _encode_end_data_footer(
uint8_t *p_buff, uint32_t *p_count)
{
int32_t status = VL53L5_ERROR_NONE;
status = vl53l5_dci_encode_block_header(
p_buff, *p_count + DCI_END_OF_DATA_FOOTER_SIZE,
DCI_END_OF_DATA_TYPE, 0, 0);
if (status == VL53L5_ERROR_NONE)
(*p_count) += DCI_END_OF_DATA_FOOTER_SIZE;
return status;
}
static void _encode_command_footer(
uint8_t *p_buff, uint32_t *p_count,
uint8_t command_id, uint8_t transaction_id)
{
struct dci_ui__cmd_footer_t ui_cmd_footer = {0};
ui_cmd_footer.cmd_footer.cmd__ip_data_size = *p_count;
ui_cmd_footer.cmd_footer.cmd__ip_command_id = command_id;
ui_cmd_footer.cmd_footer.cmd__ip_transaction_id = transaction_id;
vl53l5_encode_uint32_t(
ui_cmd_footer.cmd_footer.bytes, BYTE_4, p_buff);
(*p_count) += DCI_COMMAND_FOOTER_SIZE;
}
static int32_t _write_comms_buffer_to_command_ui(
struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = VL53L5_ERROR_NONE;
uint16_t start_index = (uint16_t)((UI_COMMAND_WRITE_END
- VL53L5_COMMS_BUFF_COUNT(p_dev)) + 1);
status = vl53l5_write_multi(
p_dev, start_index, VL53L5_COMMS_BUFF(p_dev),
VL53L5_COMMS_BUFF_COUNT(p_dev));
return status;
}
static int32_t _read_command_ui_to_comms_buffer(
struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = VL53L5_ERROR_NONE;
uint16_t start_index = 0;
VL53L5_RESET_COMMS_BUFF(p_dev);
if (p_dev->host_dev.revision_id == 0x0C)
VL53L5_CMD_INFO(p_dev).cmd__rtn_data_size +=
VL53L5_UI_DUMMY_BYTES;
start_index = (uint16_t)((UI_COMMAND_READ_END
- VL53L5_CMD_INFO(p_dev).cmd__rtn_data_size) + 1);
if (VL53L5_CMD_INFO(p_dev).cmd__rtn_data_size >
VL53L5_COMMS_BUFF_MAX_COUNT(p_dev)) {
status = VL53L5_MAX_BUFFER_SIZE_REACHED;
goto exit;
}
if (VL53L5_CMD_INFO(p_dev).cmd__rtn_data_size >
VL53L5_MAX_CMD_UI_SIZE_BYTES) {
status = VL53L5_DATA_EXCEEDS_CMD_BUFFER_SIZE;
goto exit;
}
if (VL53L5_CMD_INFO(p_dev).cmd__rtn_data_size == 0) {
status = VL53L5_ERROR_INVALID_RETURN_DATA_SIZE;
goto exit;
}
if ((VL53L5_CMD_INFO(p_dev).cmd__rtn_data_size % 4) != 0) {
status = VL53L5_BYTE_SWAP_FAIL;
goto exit;
}
status = vl53l5_read_multi(
p_dev, start_index, VL53L5_COMMS_BUFF(p_dev),
VL53L5_CMD_INFO(p_dev).cmd__rtn_data_size);
if (status != STATUS_OK)
goto exit;
VL53L5_COMMS_BUFF_COUNT(p_dev) =
VL53L5_CMD_INFO(p_dev).cmd__rtn_data_size;
exit:
return status;
}
static int32_t _get_command_status(struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = VL53L5_ERROR_NONE;
uint32_t count = DCI_COMMAND_STATUS_SIZE;
uint16_t index = UI_STATUS_START;
uint8_t *p_buff = NULL;
VL53L5_RESET_COMMS_BUFF(p_dev);
if (p_dev->host_dev.revision_id == 0x0C) {
count += DCI_COMMAND_STATUS_SIZE;
index -= VL53L5_UI_DUMMY_BYTES;
p_buff = &VL53L5_COMMS_BUFF(p_dev)[VL53L5_UI_DUMMY_BYTES];
} else {
p_buff = VL53L5_COMMS_BUFF(p_dev);
}
status = vl53l5_read_multi(
p_dev, index, VL53L5_COMMS_BUFF(p_dev), count);
if (status < STATUS_OK)
goto exit;
VL53L5_COMMS_BUFF_COUNT(p_dev) = count;
status = vl53l5_dci_swap_buffer_byte_ordering(
VL53L5_COMMS_BUFF(p_dev), VL53L5_COMMS_BUFF_COUNT(p_dev));
if (status < STATUS_OK)
goto exit;
VL53L5_CMD_INFO(p_dev).bytes = vl53l5_decode_uint32_t(BYTE_4, p_buff);
exit:
return status;
}
static int32_t _poll_command_status_block(struct vl53l5_dev_handle_t *p_dev,
uint32_t trans_id, uint32_t timeout_ms, uint32_t start_time_ms,
bool check_trans_id, bool check_cmd_status)
{
int32_t status = STATUS_OK;
uint32_t current_time_ms = 0;
bool success = false;
LOG_FUNCTION_START("");
do {
status = _get_command_status(p_dev);
if (status < STATUS_OK)
goto exit;
success = ((!check_trans_id || TRANS_ID_MATCH(p_dev, trans_id))
&& (!check_cmd_status || CMD_STATUS_COMPLETE(p_dev)));
if (success)
break;
if (check_cmd_status && CMD_STATUS_ERROR(p_dev)) {
status = VL53L5_DCI_CMD_STATUS_ERROR;
goto exit;
}
status = vl53l5_get_tick_count(p_dev, &current_time_ms);
if (status < STATUS_OK)
goto exit;
CHECK_FOR_TIMEOUT(
status,
p_dev,
start_time_ms,
current_time_ms,
timeout_ms);
if (status < STATUS_OK) {
status = VL53L5_ERROR_CMD_STATUS_TIMEOUT;
goto exit;
}
status = vl53l5_wait_ms(
p_dev, VL53L5_DEFAULT_COMMS_POLLING_DELAY_MS);
if (status < STATUS_OK)
goto exit;
} while (1);
exit:
LOG_FUNCTION_END(status);
return status;
}

View File

@@ -0,0 +1,256 @@
/*******************************************************************************
* Copyright (c) 2022, STMicroelectronics - All Rights Reserved
*
* This file is part of VL53L8 Kernel 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, VL53L8 Kernel 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:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*******************************************************************************/
#include "vl53l5_dci_decode.h"
#include "vl53l5_dci_helpers.h"
#include "vl53l5_globals.h"
#include "vl53l5_driver_dev_path.h"
#include "vl53l5_platform_log.h"
#include "vl53l5_error_codes.h"
#include "dci_luts.h"
#include "vl53l5_decode_switch.h"
#include "vl53l5_core_dev_path.h"
#ifdef VL53L5_PATCH_DATA_ENABLED
#include "page_map_switch.h"
#endif
#define trace_print(level, ...) \
_LOG_TRACE_PRINT(VL53L5_TRACE_MODULE_DCI, \
level, VL53L5_TRACE_FUNCTION_ALL, ##__VA_ARGS__)
#define LOG_FUNCTION_START(fmt, ...) \
_LOG_FUNCTION_START(VL53L5_TRACE_MODULE_DCI, fmt, ##__VA_ARGS__)
#define LOG_FUNCTION_END(status, ...) \
_LOG_FUNCTION_END(VL53L5_TRACE_MODULE_DCI, status, ##__VA_ARGS__)
static int32_t _decode_raw_data(
struct vl53l5_dev_handle_t *p_dev, uint8_t *p_buff,
uint32_t buff_count, uint16_t *p_idx_checks, uint32_t num_idx_checks,
bool is_range_data);
int32_t vl53l5_dci_decode_range_data(
struct vl53l5_dev_handle_t *p_dev)
{
int32_t status = VL53L5_ERROR_NONE;
uint32_t read_size = 0;
uint8_t *p_buff = NULL;
LOG_FUNCTION_START("");
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (VL53L5_COMMS_BUFF_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
read_size = RANGE_DATA_READ_SIZE(p_dev);
if (p_dev->host_dev.revision_id == 0x0C) {
read_size = RANGE_DATA_READ_SIZE(p_dev) + BYTE_4;
p_buff = &RANGE_DATA_START(p_dev)[VL53L5_UI_DUMMY_BYTES];
} else {
p_buff = RANGE_DATA_START(p_dev);
}
if (read_size != VL53L5_COMMS_BUFF_COUNT(p_dev)) {
trace_print(VL53L5_TRACE_LEVEL_ERRORS,
"Rng data size %d does not match comms buff count %d\n",
read_size,
VL53L5_COMMS_BUFF_COUNT(p_dev));
status = VL53L5_DATA_BUFFER_MISMATCH;
goto exit;
}
status = _decode_raw_data(
p_dev, p_buff, RANGE_DATA_SIZE(p_dev), NULL, 0, true);
exit:
LOG_FUNCTION_END(status);
return status;
}
int32_t vl53l5_dci_decode_data(
struct vl53l5_dev_handle_t *p_dev,
uint8_t *buffer,
uint32_t data_size)
{
int32_t status = VL53L5_ERROR_NONE;
LOG_FUNCTION_START("");
if (VL53L5_ISNULL(p_dev)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
if (VL53L5_ISNULL(buffer)) {
status = VL53L5_ERROR_INVALID_PARAMS;
goto exit;
}
status = _decode_raw_data(p_dev, buffer, data_size, NULL, 0, false);
exit:
LOG_FUNCTION_END(status);
return status;
}
static int32_t _decode_raw_data(
struct vl53l5_dev_handle_t *p_dev, uint8_t *p_buff,
uint32_t buff_count, uint16_t *p_idx_checks, uint32_t num_idx_checks,
bool is_range_data)
{
int32_t status = VL53L5_ERROR_NONE;
uint8_t type = 0;
uint32_t block_byte_size = 0;
uint16_t idx = 0;
uint32_t bytes_decoded = 0;
#ifdef VL53L5_PATCH_DATA_ENABLED
uint16_t page_index = 0;
#endif
(void)p_idx_checks;
(void)num_idx_checks;
do {
trace_print(
VL53L5_TRACE_LEVEL_DEBUG,
"Decoding block header: [%02x][%02x][%02x][%02x]\n",
p_buff[bytes_decoded],
p_buff[bytes_decoded + 1],
p_buff[bytes_decoded + 2],
p_buff[bytes_decoded + 3]);
status = vl53l5_dci_decode_block_header(
&p_buff[bytes_decoded], buff_count - bytes_decoded,
&type, &block_byte_size, &idx);
if (status < STATUS_OK)
goto exit;
if (type == DCI_BH__P_TYPE__END_OF_DATA)
break;
if ((type == DCI_BH__P_TYPE__GRP_PARAMS_START) ||
(type == DCI_BH__P_TYPE__GRP_PARAMS_END)) {
if ((!is_range_data) && (idx > MAX_NUM_RANGE_RETURNS)) {
status = VL53L5_INVALID_GROUP_INDEX;
goto exit;
}
bytes_decoded += BYTE_4;
continue;
}
if (type == 0xC) {
#ifdef VL53L5_PATCH_DATA_ENABLED
page_index = idx;
#else
if (!is_range_data) {
status = VL53L5_INVALID_PAGE_ERROR;
goto exit;
}
if (idx != 0) {
status = VL53L5_INVALID_PAGE_ERROR;
goto exit;
}
#endif
bytes_decoded += BYTE_4;
continue;
}
bytes_decoded += BYTE_4;
#ifdef VL53L5_PATCH_DATA_ENABLED
status = dci_page_map_switch(idx,
block_byte_size,
&p_buff[bytes_decoded],
p_dev,
page_index);
#else
status = vl53l5_decode_switch(
idx, block_byte_size, &p_buff[bytes_decoded], p_dev);
#endif
if (status < STATUS_OK)
goto exit;
bytes_decoded += block_byte_size;
} while (bytes_decoded < buff_count);
if (type != DCI_BH__P_TYPE__END_OF_DATA) {
status = VL53L5_DCI_END_BLOCK_ERROR;
goto exit;
}
exit:
return status;
}

Some files were not shown because too many files have changed in this diff Show More