Skip to content
C

Add files via upload

Jobit Joseph72c67bcc25de
diff --git a/Firmware/esp-drone/components/drivers/deck/CMakeLists.txt b/Firmware/esp-drone/components/drivers/deck/CMakeLists.txt
new file mode 100644
index 0000000..0c4fdb7
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/deck/CMakeLists.txt
@@ -0,0 +1,3 @@
+idf_component_register(SRCS "deck_digital.c" "deck_spi.c"
+ INCLUDE_DIRS "." "include"
+ PRIV_REQUIRES crazyflie config)
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/deck/deck_digital.c b/Firmware/esp-drone/components/drivers/deck/deck_digital.c
new file mode 100644
index 0000000..3624063
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/deck/deck_digital.c
@@ -0,0 +1,81 @@
+/*
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2015 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * digital.c - Deck-API digital IO implementation
+ */
+
+//#include "deck.h"
+#include "driver/gpio.h"
+#include "deck_digital.h"
+#include "config.h"
+
+void pinMode(uint32_t pin, uint32_t mode)
+{
+ if (!GPIO_IS_VALID_GPIO((int)pin)) {
+ return;
+ }
+
+ gpio_config_t io_conf = {
+ //bit mask of the pins that you want to set,e.g.GPIO18/19
+ .pin_bit_mask = (1ULL << pin),
+ //disable pull-down mode
+ .pull_down_en = 0,
+ //disable pull-up mode
+ .pull_up_en = 0,
+ //configure GPIO with the given settings
+ };
+ //set as output mode
+ if (mode == OUTPUT) {
+ io_conf.mode = GPIO_MODE_OUTPUT;
+ }
+
+ if (mode == INPUT_PULLUP) {
+ io_conf.mode = GPIO_MODE_INPUT;
+ io_conf.pull_up_en = 1;
+ }
+
+ if (mode == INPUT_PULLDOWN) {
+ io_conf.mode = GPIO_MODE_INPUT;
+ io_conf.pull_down_en = 1;
+ }
+
+ gpio_config(&io_conf);
+}
+
+void digitalWrite(uint32_t pin, uint32_t val)
+{
+ if (!GPIO_IS_VALID_GPIO((int)pin)) {
+ return;
+ }
+
+ if (val) {
+ val = 1;
+ }
+
+ gpio_set_level(pin, val);
+}
+
+int digitalRead(uint32_t pin)
+{
+ if (!GPIO_IS_VALID_GPIO((int)pin)) {
+ return -1;
+ }
+
+ int val = gpio_get_level(pin);
+ return val;
+}
diff --git a/Firmware/esp-drone/components/drivers/deck/deck_spi.c b/Firmware/esp-drone/components/drivers/deck/deck_spi.c
new file mode 100644
index 0000000..f1e3a61
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/deck/deck_spi.c
@@ -0,0 +1,150 @@
+/*
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2015 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * deck_spi.c - Deck-API SPI communication implementation
+ */
+
+#include "freertos/FreeRTOS.h"
+#include "freertos/semphr.h"
+#include "driver/spi_master.h"
+
+#include "deck_spi.h"
+#include "config.h"
+#include "cfassert.h"
+#include "nvicconf.h"
+#define DEBUG_MODULE "DECK_SPI"
+#include "debug_cf.h"
+
+#ifdef CONFIG_EXT_FLOW_TESTBOARD //This board use wrong pin definition,only for test.
+ #define SPI_SCK_PIN CONFIG_SPI_PIN_MOSI
+ #define SPI_MOSI_PIN CONFIG_SPI_PIN_CLK
+#else
+ #define SPI_SCK_PIN CONFIG_SPI_PIN_CLK
+ #define SPI_MOSI_PIN CONFIG_SPI_PIN_MOSI
+#endif
+#define SPI_MISO_PIN CONFIG_SPI_PIN_MISO
+
+#define DUMMY_BYTE 0xA5
+
+static bool isInit = false;
+static SemaphoreHandle_t spiMutex;
+
+static void spiConfigureWithSpeed(uint32_t baudRatePrescaler);
+
+static spi_device_handle_t spi;
+
+void spiBegin(void)
+{
+
+ if (isInit) {
+ return;
+ }
+
+ spiMutex = xSemaphoreCreateMutex();
+
+ esp_err_t ret;
+ spi_bus_config_t buscfg = {
+ .miso_io_num = SPI_MISO_PIN,
+ .mosi_io_num = SPI_MOSI_PIN,
+ .sclk_io_num = SPI_SCK_PIN,
+ .quadwp_io_num = -1,
+ .quadhd_io_num = -1,
+ .max_transfer_sz = 0
+ }; //Defaults to 4094 if 0
+ spi_device_interface_config_t devcfg = {
+ .clock_speed_hz = SPI_BAUDRATE_2MHZ, //Clock out at 10 MHz
+ .mode = 3, //SPI mode 0
+ .spics_io_num = -1, //CS pin
+ .queue_size = 8, //We want to be able to queue 7 transactions at a time
+ /*.pre_cb = lcd_spi_pre_transfer_callback, //Specify pre-transfer callback to handle D/C line*/
+ };
+ //Initialize the SPI bus
+ spi_host_device_t host_id = SPI2_HOST;
+#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0))
+ ret = spi_bus_initialize(host_id, &buscfg, SPI_DMA_CH_AUTO);
+#else
+ int dma_chan = host_id; //set dma channel equals to host_id by default
+ ret = spi_bus_initialize(host_id, &buscfg, dma_chan);
+#endif
+ ESP_ERROR_CHECK(ret);
+ //Attach the pmw3901 to the SPI bus
+ ret = spi_bus_add_device(host_id, &devcfg, &spi);
+ ESP_ERROR_CHECK(ret);
+
+ isInit = true;
+}
+
+static void spiConfigureWithSpeed(uint32_t baudRatePrescaler)
+{
+ //TODO:
+}
+
+bool spiTest(void)
+{
+ return isInit;
+}
+
+bool spiExchange(size_t length, bool is_tx, const uint8_t *data_tx, uint8_t *data_rx)
+{
+ if (isInit != true) {
+ return false;
+ }
+
+ if (length == 0) {
+ return true; //no need to send anything
+ }
+
+ esp_err_t ret;
+
+ if (is_tx == true) {
+
+ static spi_transaction_t t;
+ memset(&t, 0, sizeof(t)); //Zero out the transaction
+ t.length = length * 8; //Len is in bytes, transaction length is in bits.
+ t.tx_buffer = data_tx; //Data
+ ret = spi_device_polling_transmit(spi, &t); //Transmit!
+ assert(ret == ESP_OK); //Should have had no issues.
+ //DEBUG_PRINTD("spi send = %d",t.length);
+ return true;
+ }
+
+ static spi_transaction_t r;
+ memset(&r, 0, sizeof(r));
+ r.length = length * 8;
+ r.flags = SPI_TRANS_USE_RXDATA;
+ ret = spi_device_polling_transmit(spi, &r);
+ assert(ret == ESP_OK);
+
+ if (r.rxlength > 0) {
+ //DEBUG_PRINTD("rxlength = %d",r.rxlength);
+ memcpy(data_rx, r.rx_data, length);
+ }
+
+ return true;
+}
+
+void spiBeginTransaction(uint32_t baudRatePrescaler)
+{
+ xSemaphoreTake(spiMutex, portMAX_DELAY);
+ spiConfigureWithSpeed(baudRatePrescaler);
+}
+
+void spiEndTransaction()
+{
+ xSemaphoreGive(spiMutex);
+}
diff --git a/Firmware/esp-drone/components/drivers/deck/include/deck_digital.h b/Firmware/esp-drone/components/drivers/deck/include/deck_digital.h
new file mode 100644
index 0000000..648817d
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/deck/include/deck_digital.h
@@ -0,0 +1,42 @@
+/*
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2015 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * deck_digital.h - Arduino-compatible digital I/O API
+ */
+
+#ifndef __DECK_DIGITAL_H__
+#define __DECK_DIGITAL_H__
+
+#include <stdint.h>
+
+#define LOW 0x0
+#define HIGH 0x1
+
+#define INPUT 0x0
+#define OUTPUT 0x1
+#define INPUT_PULLUP 0x2
+#define INPUT_PULLDOWN 0x3
+
+void pinMode(uint32_t pin, uint32_t mode);
+
+void digitalWrite(uint32_t pin, uint32_t val);
+
+int digitalRead(uint32_t pin);
+
+#endif
diff --git a/Firmware/esp-drone/components/drivers/deck/include/deck_spi.h b/Firmware/esp-drone/components/drivers/deck/include/deck_spi.h
new file mode 100644
index 0000000..e2890d2
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/deck/include/deck_spi.h
@@ -0,0 +1,46 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2015 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * deck_spi.h - Deck-API SPI communication header
+ */
+#ifndef SPI_H_
+#define SPI_H_
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <string.h>
+
+// Based on 84MHz peripheral clock
+#define SPI_BAUDRATE_21MHZ 21*1000*1000
+#define SPI_BAUDRATE_12MHZ 12*1000*1000
+#define SPI_BAUDRATE_6MHZ 6*1000*1000
+#define SPI_BAUDRATE_3MHZ 3*1000*1000
+#define SPI_BAUDRATE_2MHZ 2*1000*1000
+
+/**
+ * Initialize the SPI.
+ */
+void spiBegin(void);
+void spiBeginTransaction(uint32_t baudRatePrescaler);
+void spiEndTransaction();
+
+/* Send the data_tx buffer and receive into the data_rx buffer */
+bool spiExchange(size_t length, bool is_tx, const uint8_t *data_tx, uint8_t *data_rx);
+
+#endif /* SPI_H_ */
diff --git a/Firmware/esp-drone/components/drivers/general/adc/CMakeLists.txt b/Firmware/esp-drone/components/drivers/general/adc/CMakeLists.txt
new file mode 100644
index 0000000..e2662f1
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/adc/CMakeLists.txt
@@ -0,0 +1,9 @@
+if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0")
+idf_component_register(SRCS "adc_esp32.c"
+ INCLUDE_DIRS "." "include"
+ REQUIRES crazyflie config esp_adc)
+else()
+idf_component_register(SRCS "adc_esp32.c"
+ INCLUDE_DIRS "." "include"
+ REQUIRES crazyflie config esp_adc_cal)
+endif()
diff --git a/Firmware/esp-drone/components/drivers/general/adc/adc_esp32.c b/Firmware/esp-drone/components/drivers/general/adc/adc_esp32.c
new file mode 100644
index 0000000..57d14f9
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/adc/adc_esp32.c
@@ -0,0 +1,102 @@
+/**
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * adc.c - Analog Digital Conversion
+ *
+ *
+ */
+
+#include "esp_idf_version.h"
+#include "driver/adc.h"
+#include "esp_adc_cal.h"
+#include "adc_esp32.h"
+#include "config.h"
+#include "pm_esplane.h"
+#include "stm32_legacy.h"
+#define DEBUG_MODULE "ADC"
+#include "debug_cf.h"
+
+static bool isInit;
+
+static esp_adc_cal_characteristics_t *adc_chars;
+#ifdef CONFIG_IDF_TARGET_ESP32
+static const adc_channel_t channel = ADC_CHANNEL_7; //GPIO35 if ADC1
+#elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
+static const adc_channel_t channel = ADC_CHANNEL_1; // GPIO2 if ADC1
+#endif
+
+static const adc_bits_width_t width = ADC_WIDTH_MAX-1;
+static const adc_atten_t atten = ADC_ATTEN_DB_11; //11dB attenuation (ADC_ATTEN_DB_11) gives full-scale voltage 3.9V
+static const adc_unit_t unit = ADC_UNIT_1;
+#define DEFAULT_VREF 1100 //Use adc2_vref_to_gpio() to obtain a better estimate
+#define NO_OF_SAMPLES 30 //Multisampling
+
+static void print_char_val_type(esp_adc_cal_value_t val_type)
+{
+ if (val_type == ESP_ADC_CAL_VAL_EFUSE_TP) {
+ printf("Characterized using Two Point Value\n");
+ } else if (val_type == ESP_ADC_CAL_VAL_EFUSE_VREF) {
+ printf("Characterized using eFuse Vref\n");
+ } else {
+ printf("Characterized using Default Vref\n");
+ }
+}
+
+float analogReadVoltage(uint32_t pin)
+{
+ uint32_t adc_reading = 0;
+ for (int i = 0; i < NO_OF_SAMPLES; i++) {
+ if (unit == ADC_UNIT_1) {
+ adc_reading += adc1_get_raw((adc1_channel_t)channel);
+ } else {
+ int raw;
+ adc2_get_raw((adc2_channel_t)channel, width, &raw);
+ adc_reading += raw;
+ }
+ }
+ adc_reading /= NO_OF_SAMPLES;
+ //Convert adc_reading to voltage in mV
+ uint32_t voltage = esp_adc_cal_raw_to_voltage(adc_reading, adc_chars);
+ return voltage / 1000.0;
+}
+
+void adcInit(void)
+{
+ if (isInit) {
+ return;
+ }
+
+ if (unit == ADC_UNIT_1) {
+ adc1_config_width(width);
+ adc1_config_channel_atten(channel, atten);
+ } else {
+ adc2_config_channel_atten((adc2_channel_t)channel, atten);
+ }
+
+ //Characterize ADC
+ adc_chars = calloc(1, sizeof(esp_adc_cal_characteristics_t));
+ esp_adc_cal_value_t val_type = esp_adc_cal_characterize(unit, atten, width, DEFAULT_VREF, adc_chars);
+ print_char_val_type(val_type);
+
+ isInit = true;
+}
+
+bool adcTest(void)
+{
+ return isInit;
+}
diff --git a/Firmware/esp-drone/components/drivers/general/adc/include/adc_esp32.h b/Firmware/esp-drone/components/drivers/general/adc/include/adc_esp32.h
new file mode 100644
index 0000000..523645a
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/adc/include/adc_esp32.h
@@ -0,0 +1,87 @@
+/**
+ * ESP-Drone Firmware
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * adc.h - Analog Digital Conversion header file
+ */
+#ifndef ADC_H_
+#define ADC_H_
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "freertos/FreeRTOS.h"
+#include "freertos/semphr.h"
+
+#include "config.h"
+
+/******** Types ********/
+
+typedef struct __attribute__((packed)){
+ uint16_t vref;
+ uint16_t val;
+}AdcPair;
+
+typedef struct __attribute__((packed)){
+ AdcPair vbat;
+}AdcGroup;
+
+typedef struct {
+ uint16_t vbat;
+ uint16_t vbatVref;
+} AdcDeciGroup;
+
+/*** Public interface ***/
+
+/**
+ * Initialize analog to digital converter. Configures gyro and vref channels.
+ */
+void adcInit(void);
+
+bool adcTest(void);
+
+/**
+ * @brief Converts a 12 bit ADC value to battery voltage
+ * @param vbat 12 bit adc value
+ * @param vref 12 bit adc value of the internal voltage
+ * reference, 1.2V
+ * @return The voltage in a float value
+ */
+float adcConvertToVoltageFloat(uint16_t v, uint16_t vref);
+
+/**
+ * Starts converting ADC samples by activating the DMA.
+ */
+void adcDmaStart(void);
+
+/**
+ * Stop converting ADC samples.
+ */
+void adcDmaStop(void);
+
+/**
+ * ADC interrupt handler
+ */
+void adcInterruptHandler(void);
+
+/**
+ * ADC task
+ */
+void adcTask(void *param);
+
+float analogReadVoltage(uint32_t pin); //should in deck_analog.c
+
+#endif /* ADC_H_ */
diff --git a/Firmware/esp-drone/components/drivers/general/buzzer/CMakeLists.txt b/Firmware/esp-drone/components/drivers/general/buzzer/CMakeLists.txt
new file mode 100644
index 0000000..9fdabf7
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/buzzer/CMakeLists.txt
@@ -0,0 +1,3 @@
+idf_component_register(SRCS "buzzdeck.c" "piezo.c"
+ INCLUDE_DIRS "." "include"
+ REQUIRES crazyflie platform config)
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/general/buzzer/buzzdeck.c b/Firmware/esp-drone/components/drivers/general/buzzer/buzzdeck.c
new file mode 100644
index 0000000..2f9e560
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/buzzer/buzzdeck.c
@@ -0,0 +1,64 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2015 BitCraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * buzzdeck.c - Deck driver for the buzzer deck
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "stm32_legacy.h"
+#include "param.h"
+#include "buzzer.h"
+#include "piezo.h"
+
+static bool isInit;
+
+static void buzzDeckOn(uint32_t freq)
+{
+ piezoSetRatio(128);
+ piezoSetFreq(freq);
+}
+
+static void buzzDeckOff()
+{
+ piezoSetRatio(0);
+}
+
+static struct buzzerControl buzzDeckCtrl = {
+ .on = buzzDeckOn,
+ .off = buzzDeckOff
+};
+
+void buzzDeckInit()
+{
+ if (isInit) {
+ return;
+ }
+
+ piezoInit();
+ buzzerSetControl(&buzzDeckCtrl);
+
+ isInit = true;
+}
+
+
+PARAM_GROUP_START(deck)
+PARAM_ADD(PARAM_UINT8 | PARAM_RONLY, bcBuzzer, &isInit)
+PARAM_GROUP_STOP(deck)
diff --git a/Firmware/esp-drone/components/drivers/general/buzzer/include/buzzdeck.h b/Firmware/esp-drone/components/drivers/general/buzzer/include/buzzdeck.h
new file mode 100644
index 0000000..7aa542e
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/buzzer/include/buzzdeck.h
@@ -0,0 +1,26 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <stdint.h>
+#include <stdbool.h>
+
+void buzzDeckInit();
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/general/buzzer/include/piezo.h b/Firmware/esp-drone/components/drivers/general/buzzer/include/piezo.h
new file mode 100644
index 0000000..f74e4aa
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/buzzer/include/piezo.h
@@ -0,0 +1,54 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __PIEZO_H__
+#define __PIEZO_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "config.h"
+
+/******** Defines ********/
+
+/*** Public interface ***/
+
+/**
+ * Piezo Initialization. Configures two output compare channels in PWM mode
+ * with one of them inverted to increase power output.
+ */
+void piezoInit();
+
+/**
+ * Test of the motor modules. The test will spin each motor very short in
+ * the sequence M1 to M4.
+ */
+bool piezoTest(void);
+
+/**
+ * Set piezo ratio/power.
+ */
+void piezoSetRatio(uint8_t ratio);
+
+/**
+ * Set piezo frequency in hertz.
+ */
+void piezoSetFreq(uint16_t freq);
+
+#endif /* __MOTORS_H__ */
diff --git a/Firmware/esp-drone/components/drivers/general/buzzer/piezo.c b/Firmware/esp-drone/components/drivers/general/buzzer/piezo.c
new file mode 100644
index 0000000..e322e31
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/buzzer/piezo.c
@@ -0,0 +1,119 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * piezo.c - Piezo/Buzzer driver
+ *
+ * This code mainly interfacing the PWM peripheral lib of ESP32.
+ */
+
+#include <stdbool.h>
+
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "driver/ledc.h"
+
+#include "stm32_legacy.h"
+#include "piezo.h"
+
+// HW defines
+#define PIEZO_TIM_PERIF RCC_APB1Periph_TIM5
+#define PIEZO_TIM TIM5
+#define PIEZO_TIM_DBG DBGMCU_TIM2_STOP
+#define PIEZO_TIM_SETCOMPARE TIM_SetCompare2
+#define PIEZO_TIM_GETCAPTURE TIM_GetCapture2
+
+#define BUZ_PWM_CH1 0
+#define BUZ_PWM_CH2 1
+
+#define PIEZO_GPIO_POS_PIN CONFIG_BUZ1_PIN_POS // buzzer+ -> GPIO39 ; buzzer- -> GND:
+#define PIEZO_GPIO_NEG_PIN CONFIG_BUZ2_PIN_NEG // GND
+
+#define PIEZO_PWM_BITS (13)
+#define PIEZO_PWM_PERIOD ((1<<PIEZO_PWM_BITS) - 1)
+#define PIEZO_PWM_PRESCALE (0)
+
+/* This should be calculated.. */
+#define PIEZO_BASE_FREQ (329500)
+
+static bool isInit = false;
+
+ledc_channel_config_t buzz_channel[1] = {
+ {
+ .channel = BUZ_PWM_CH1,
+ .duty = 0,
+ .gpio_num = PIEZO_GPIO_POS_PIN,
+ .speed_mode = LEDC_LOW_SPEED_MODE,
+ .timer_sel = LEDC_TIMER_1
+
+ },
+};
+
+/* Public functions */
+
+void piezoInit()
+{
+ if (isInit) {
+ return;
+ }
+
+ //Clock the gpio and the timers
+ ledc_timer_config_t ledc_timer = {
+ .duty_resolution = PIEZO_PWM_BITS, // resolution of PWM duty
+ .freq_hz = 4000, // frequency of PWM signal
+ .speed_mode = LEDC_LOW_SPEED_MODE, // timer mode
+ .timer_num = LEDC_TIMER_1, // timer index
+ //.clk_cfg = LEDC_AUTO_CLK, // Auto select the source clock
+ };
+
+ // Set configuration of timer0 for high speed channels
+ if (ledc_timer_config(&ledc_timer) == ESP_OK) {
+
+ }
+
+ for (uint8_t i = 0; i < 1; i++) {
+ ledc_channel_config(&buzz_channel[i]);
+ }
+
+ isInit = true;
+}
+
+bool piezoTest(void)
+{
+ return isInit;
+}
+
+void piezoSetRatio(uint8_t ratio)
+{
+ uint16_t ratio16 = 0;
+ if (ratio > 0) {
+ ratio16 = ratio << 5;
+ }
+ ledc_set_duty(buzz_channel[0].speed_mode, buzz_channel[0].channel, ratio16);
+ ledc_update_duty(buzz_channel[0].speed_mode, buzz_channel[0].channel);
+
+}
+
+void piezoSetFreq(uint16_t freq)
+{
+ if ( freq <= 0 ) {
+ piezoSetRatio(0);
+ } else {
+ ledc_set_freq(buzz_channel[0].speed_mode, buzz_channel[0].timer_sel, freq);
+ }
+}
diff --git a/Firmware/esp-drone/components/drivers/general/led/CMakeLists.txt b/Firmware/esp-drone/components/drivers/general/led/CMakeLists.txt
new file mode 100644
index 0000000..d525c53
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/led/CMakeLists.txt
@@ -0,0 +1,3 @@
+idf_component_register(SRCS "led_esp32.c"
+ INCLUDE_DIRS "." "include"
+ REQUIRES crazyflie platform)
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/general/led/include/led.h b/Firmware/esp-drone/components/drivers/general/led/include/led.h
new file mode 100644
index 0000000..36e3a32
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/led/include/led.h
@@ -0,0 +1,68 @@
+/**
+*
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * led.h - LED functions header file
+ */
+#ifndef __LED_H__
+#define __LED_H__
+
+#include <stdbool.h>
+
+//Led polarity configuration constant
+#define LED_POL_POS 0
+#define LED_POL_NEG 1
+
+#define LED_GPIO_BLUE CONFIG_LED_PIN_BLUE
+#define LED_POL_BLUE LED_POL_POS
+#define LED_GPIO_GREEN CONFIG_LED_PIN_GREEN //different from pcb design
+#define LED_POL_GREEN LED_POL_POS
+#define LED_GPIO_RED CONFIG_LED_PIN_RED
+#define LED_POL_RED LED_POL_POS
+
+#define LINK_LED LED_GREEN
+#define CHG_LED LED_RED
+#define LOWBAT_LED LED_RED
+#define LINK_DOWN_LED LED_BLUE
+#define SYS_LED LED_BLUE
+#define ERR_LED1 LED_RED
+#define ERR_LED2 LED_RED
+
+#define LED_NUM 3
+
+typedef enum {LED_BLUE = 0, LED_RED, LED_GREEN} led_t;
+
+void ledInit();
+bool ledTest();
+
+// Clear all configured LEDs
+void ledClearAll(void);
+
+// Set all configured LEDs
+void ledSetAll(void);
+
+// Procedures to set the status of the LEDs
+void ledSet(led_t led, bool value);
+
+void ledTask(void *param);
+
+//Legacy functions
+#define ledSetRed(VALUE) ledSet(LED_RED, VALUE)
+#define ledSetGreen(VALUE) ledSet(LED_GREEN, VALUE)
+
+#endif
diff --git a/Firmware/esp-drone/components/drivers/general/led/led_esp32.c b/Firmware/esp-drone/components/drivers/general/led/led_esp32.c
new file mode 100644
index 0000000..3eea3f4
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/led/led_esp32.c
@@ -0,0 +1,123 @@
+/**
+*
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * led.c - LED handing functions
+ */
+#include <stdbool.h>
+
+/*FreeRtos includes*/
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "driver/gpio.h"
+#include "led.h"
+#include "stm32_legacy.h"
+
+static unsigned int led_pin[] = {
+ [LED_BLUE] = LED_GPIO_BLUE,
+ [LED_RED] = LED_GPIO_RED,
+ [LED_GREEN] = LED_GPIO_GREEN,
+};
+static int led_polarity[] = {
+ [LED_BLUE] = LED_POL_BLUE,
+ [LED_RED] = LED_POL_RED,
+ [LED_GREEN] = LED_POL_GREEN,
+};
+
+static bool isInit = false;
+
+//Initialize the green led pin as output
+void ledInit()
+{
+ int i;
+
+ if (isInit) {
+ return;
+ }
+
+ for (i = 0; i < LED_NUM; i++) {
+ gpio_config_t io_conf = {
+ //bit mask of the pins that you want to set,e.g.GPIO18/19
+ .pin_bit_mask = (1ULL << led_pin[i]),
+ //disable pull-down mode
+ .pull_down_en = 0,
+ //disable pull-up mode
+ .pull_up_en = 0,
+ //set as output mode
+ .mode = GPIO_MODE_OUTPUT,
+ };
+ //configure GPIO with the given settings
+ gpio_config(&io_conf);
+ ledSet(i, 0);
+ }
+
+ isInit = true;
+}
+
+bool ledTest(void)
+{
+ ledSet(LED_GREEN, 1);
+ ledSet(LED_RED, 0);
+ vTaskDelay(M2T(250));
+ ledSet(LED_GREEN, 0);
+ ledSet(LED_RED, 1);
+ vTaskDelay(M2T(250));
+ // LED test end
+ ledClearAll();
+ ledSet(LED_BLUE, 1);
+
+ return isInit;
+}
+
+void ledClearAll(void)
+{
+ int i;
+
+ for (i = 0; i < LED_NUM; i++) {
+ //Turn off the LED:s
+ ledSet(i, 0);
+ }
+}
+
+void ledSetAll(void)
+{
+ int i;
+
+ for (i = 0; i < LED_NUM; i++) {
+ //Turn on the LED:s
+ ledSet(i, 1);
+ }
+}
+void ledSet(led_t led, bool value)
+{
+ if (led > LED_NUM || led == LED_NUM) {
+ return;
+ }
+
+ if (led_polarity[led] == LED_POL_NEG) {
+ value = !value;
+ }
+
+ if (value) {
+ gpio_set_level(led_pin[led], 1);
+ } else {
+ gpio_set_level(led_pin[led], 0);
+ }
+}
+
+
diff --git a/Firmware/esp-drone/components/drivers/general/motors/CMakeLists.txt b/Firmware/esp-drone/components/drivers/general/motors/CMakeLists.txt
new file mode 100644
index 0000000..105be93
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/motors/CMakeLists.txt
@@ -0,0 +1,3 @@
+idf_component_register(SRCS "motors_def_cf2.c" "motors.c"
+ INCLUDE_DIRS "." "include"
+ REQUIRES crazyflie platform config)
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/general/motors/include/motors.h b/Firmware/esp-drone/components/drivers/general/motors/include/motors.h
new file mode 100644
index 0000000..c7a56fe
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/motors/include/motors.h
@@ -0,0 +1,204 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Motors.h - Motor driver header file
+ *
+ */
+#ifndef __MOTORS_H__
+#define __MOTORS_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "driver/ledc.h"
+
+#include "config.h"
+#include "stm32_legacy.h"
+
+
+/******** Defines ********/
+
+// CF2 PWM ripple is filtered better at 328kHz. At 168kHz the NCP702 regulator is affected.
+
+#define MOTORS_PWM_BITS LEDC_TIMER_8_BIT
+#define MOTORS_PWM_PERIOD ((1<<MOTORS_PWM_BITS) - 1)
+#define MOTORS_TIM_BEEP_CLK_FREQ 4000000
+
+// Compensate thrust depending on battery voltage so it will produce about the same
+// amount of thrust independent of the battery voltage. Based on thrust measurement.
+
+//#define ENABLE_THRUST_BAT_COMPENSATED
+
+
+#define NBR_OF_MOTORS 4
+// Motors IDs define
+#define MOTOR_M1 0
+#define MOTOR_M2 1
+#define MOTOR_M3 2
+#define MOTOR_M4 3
+
+#ifdef CONFIG_TARGET_ESPLANE_V2_S2
+ #define MOTOR3_GPIO CONFIG_MOTOR01_PIN // M1 for ESP32FC
+ #define MOTOR4_GPIO CONFIG_MOTOR02_PIN // M2 for ESP32FC
+ #define MOTOR1_GPIO CONFIG_MOTOR03_PIN // M3 for ESP32FC
+ #define MOTOR2_GPIO CONFIG_MOTOR04_PIN // M4 for ESP32FC
+#else
+ #define MOTOR1_GPIO CONFIG_MOTOR01_PIN // M1 for ESP32FC
+ #define MOTOR2_GPIO CONFIG_MOTOR02_PIN // M2 for ESP32FC
+ #define MOTOR3_GPIO CONFIG_MOTOR03_PIN // M3 for ESP32FC
+ #define MOTOR4_GPIO CONFIG_MOTOR04_PIN // M4 for ESP32FC
+#endif
+
+#define MOT_PWM_CH1 4 // Motor M1 pwmchannel
+#define MOT_PWM_CH2 5 // Motor M2 pwmchannel
+#define MOT_PWM_CH3 6 // Motor M3 pwmchannel
+#define MOT_PWM_CH4 7 // Motor M4 pwmchannel
+
+// Test defines
+#define MOTORS_TEST_RATIO (uint16_t)(0.2*(1<<16))
+#define MOTORS_TEST_ON_TIME_MS 50
+#define MOTORS_TEST_DELAY_TIME_MS 150
+
+// Sound defines
+#define C4 262
+#define DES4 277
+#define D4 294
+#define ES4 311
+#define E4 330
+#define F4 349
+#define GES4 370
+#define G4 392
+#define AS4 415
+#define A4 440
+#define B4 466
+#define H4 493
+#define C5 523
+#define DES5 554
+#define D5 587
+#define ES5 622
+#define E5 659
+#define F5 698
+#define GES5 740
+#define G5 783
+#define AS5 830
+#define A5 880
+#define B5 932
+#define H5 987
+#define C6 1046
+#define DES6 1108
+#define D6 1174
+#define ES6 1244
+#define E6 1318
+#define F6 1396
+#define GES6 1479
+#define G6 1567
+#define AS6 1661
+#define A6 1760
+#define B6 1864
+#define H6 1975
+#define C7 2093
+#define DES7 2217
+#define D7 2349
+#define ES7 2489
+#define E7 2637
+#define F7 2793
+#define GES7 2959
+#define G7 3135
+#define AS7 3322
+#define A7 3520
+#define H7 3729
+#define B7 3951
+
+// Sound duration defines
+#define EIGHTS 125
+#define QUAD 250
+#define HALF 500
+#define FULL 1000
+#define STOP 0
+
+typedef enum {
+ BRUSHED,
+ BRUSHLESS
+} motorsDrvType;
+
+typedef struct {
+ motorsDrvType drvType;
+
+} MotorPerifDef;
+
+/**
+ * Motor mapping configurations
+ */
+//extern const MotorPerifDef* motorMapNoMotors[NBR_OF_MOTORS];
+extern const MotorPerifDef *motorMapDefaultBrushed[NBR_OF_MOTORS];
+// extern const MotorPerifDef* motorMapDefaltConBrushless[NBR_OF_MOTORS];
+// extern const MotorPerifDef* motorMapBigQuadDeck[NBR_OF_MOTORS];
+// extern const MotorPerifDef* motorMapBoltBrushless[NBR_OF_MOTORS];
+
+/**
+ * Test sound tones
+ */
+extern const uint16_t testsound[NBR_OF_MOTORS];
+/*** Public interface ***/
+
+bool pwm_timmer_init();
+/**
+ * Initialisation. Will set all motors ratio to 0%
+ */
+void motorsInit(const MotorPerifDef **motorMapSelect);
+
+/**
+ * DeInitialisation. Reset to default
+ */
+void motorsDeInit(const MotorPerifDef **motorMapSelect);
+
+/**
+ * Test of the motor modules. The test will spin each motor very short in
+ * the sequence M1 to M4.
+ */
+bool motorsTest(void);
+
+/**
+ * Set the PWM ratio of the motor 'id'
+ */
+void motorsSetRatio(uint32_t id, uint16_t ratio);
+
+/**
+ * Get the PWM ratio of the motor 'id'. Return -1 if wrong ID.
+ */
+int motorsGetRatio(uint32_t id);
+
+/**
+ * FreeRTOS Task to test the Motors driver
+ */
+void motorsTestTask(void *params);
+
+/* Set PWM frequency for motor controller
+ * This function will set all motors into a "beep"-mode,
+ * each of the motor will turned on with a given ratio and frequency.
+ * The higher the ratio the higher the given power to the motors.
+ * ATTENTION: To much ratio can push your crazyflie into the air and hurt you!
+ * Example:
+ * motorsBeep(true, 1000, (uint16_t)(72000000L / frequency)/ 20);
+ * motorsBeep(false, 0, 0); *
+ * */
+void motorsBeep(int id, bool enable, uint16_t frequency, uint16_t ratio);
+
+#endif /* __MOTORS_H__ */
+
diff --git a/Firmware/esp-drone/components/drivers/general/motors/motors.c b/Firmware/esp-drone/components/drivers/general/motors/motors.c
new file mode 100644
index 0000000..dbf09c8
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/motors/motors.c
@@ -0,0 +1,270 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * motors.c - Motor driver
+ *
+ */
+
+#include <stdbool.h>
+
+//FreeRTOS includes
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+
+#include "stm32_legacy.h"
+#include "motors.h"
+#include "pm_esplane.h"
+#include "log.h"
+#define DEBUG_MODULE "MOTORS"
+#include "debug_cf.h"
+
+static uint16_t motorsConvBitsTo16(uint16_t bits);
+static uint16_t motorsConv16ToBits(uint16_t bits);
+
+uint32_t motor_ratios[] = {0, 0, 0, 0};
+
+void motorsPlayTone(uint16_t frequency, uint16_t duration_msec);
+void motorsPlayMelody(uint16_t *notes);
+void motorsBeep(int id, bool enable, uint16_t frequency, uint16_t ratio);
+
+const MotorPerifDef **motorMap; /* Current map configuration */
+
+const uint32_t MOTORS[] = {MOTOR_M1, MOTOR_M2, MOTOR_M3, MOTOR_M4};
+
+const uint16_t testsound[NBR_OF_MOTORS] = {A4, A5, F5, D5};
+
+static bool isInit = false;
+static bool isTimerInit = false;
+
+ledc_channel_config_t motors_channel[NBR_OF_MOTORS] = {
+ {
+ .channel = MOT_PWM_CH1,
+ .duty = 0,
+ .gpio_num = MOTOR1_GPIO,
+ .speed_mode = LEDC_LOW_SPEED_MODE,
+ .timer_sel = LEDC_TIMER_0
+ },
+ {
+ .channel = MOT_PWM_CH2,
+ .duty = 0,
+ .gpio_num = MOTOR2_GPIO,
+ .speed_mode = LEDC_LOW_SPEED_MODE,
+ .timer_sel = LEDC_TIMER_0
+ },
+ {
+ .channel = MOT_PWM_CH3,
+ .duty = 0,
+ .gpio_num = MOTOR3_GPIO,
+ .speed_mode = LEDC_LOW_SPEED_MODE,
+ .timer_sel = LEDC_TIMER_0
+ },
+ {
+ .channel = MOT_PWM_CH4,
+ .duty = 0,
+ .gpio_num = MOTOR4_GPIO,
+ .speed_mode = LEDC_LOW_SPEED_MODE,
+ .timer_sel = LEDC_TIMER_0
+ },
+};
+/* Private functions */
+
+static uint16_t motorsConvBitsTo16(uint16_t bits)
+{
+ return ((bits) << (16 - MOTORS_PWM_BITS));
+}
+
+static uint16_t motorsConv16ToBits(uint16_t bits)
+{
+ return ((bits) >> (16 - MOTORS_PWM_BITS) & ((1 << MOTORS_PWM_BITS) - 1));
+}
+
+bool pwm_timmer_init()
+{
+ if (isTimerInit) {
+ // First to init will configure it
+ return TRUE;
+ }
+
+ /*
+ * Prepare and set configuration of timers
+ * that will be used by MOTORS Controller
+ */
+ ledc_timer_config_t ledc_timer = {
+ .duty_resolution = MOTORS_PWM_BITS, // resolution of PWM duty
+ .freq_hz = 15000, // frequency of PWM signal
+ .speed_mode = LEDC_LOW_SPEED_MODE, // timer mode
+ .timer_num = LEDC_TIMER_0, // timer index
+ // .clk_cfg = LEDC_AUTO_CLK, // Auto select the source clock
+ };
+
+ // Set configuration of timer0 for high speed channels
+ if (ledc_timer_config(&ledc_timer) == ESP_OK) {
+ isTimerInit = TRUE;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/* Public functions */
+
+//Initialization. Will set all motors ratio to 0%
+void motorsInit(const MotorPerifDef **motorMapSelect)
+{
+ int i;
+
+ if (isInit) {
+ // First to init will configure it
+ return;
+ }
+
+ motorMap = motorMapSelect;
+
+ if (pwm_timmer_init() != TRUE) {
+ return;
+ }
+
+ for (i = 0; i < NBR_OF_MOTORS; i++) {
+ ledc_channel_config(&motors_channel[i]);
+ }
+
+ isInit = true;
+}
+
+void motorsDeInit(const MotorPerifDef **motorMapSelect)
+{
+ for (int i = 0; i < NBR_OF_MOTORS; i++) {
+ ledc_stop(motors_channel[i].speed_mode, motors_channel[i].channel, 0);
+ }
+}
+
+bool motorsTest(void)
+{
+ int i;
+
+ for (i = 0; i < sizeof(MOTORS) / sizeof(*MOTORS); i++) {
+ if (motorMap[i]->drvType == BRUSHED) {
+#ifdef ACTIVATE_STARTUP_SOUND
+ motorsBeep(MOTORS[i], true, testsound[i], (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / A4) / 20);
+ vTaskDelay(M2T(MOTORS_TEST_ON_TIME_MS));
+ motorsBeep(MOTORS[i], false, 0, 0);
+ vTaskDelay(M2T(MOTORS_TEST_DELAY_TIME_MS));
+#else
+ motorsSetRatio(MOTORS[i], MOTORS_TEST_RATIO);
+ vTaskDelay(M2T(MOTORS_TEST_ON_TIME_MS));
+ motorsSetRatio(MOTORS[i], 0);
+ vTaskDelay(M2T(MOTORS_TEST_DELAY_TIME_MS));
+#endif
+ }
+ }
+
+ return isInit;
+}
+
+// Ithrust is thrust mapped for 65536 <==> 60 grams
+void motorsSetRatio(uint32_t id, uint16_t ithrust)
+{
+ if (isInit) {
+ uint16_t ratio;
+
+ ASSERT(id < NBR_OF_MOTORS);
+
+ ratio = ithrust;
+
+#ifdef ENABLE_THRUST_BAT_COMPENSATED
+
+ if (motorMap[id]->drvType == BRUSHED) {
+ float thrust = ((float)ithrust / 65536.0f) * 40; //根据实际重量修改
+ float volts = -0.0006239f * thrust * thrust + 0.088f * thrust;
+ float supply_voltage = pmGetBatteryVoltage();
+ float percentage = volts / supply_voltage;
+ percentage = percentage > 1.0f ? 1.0f : percentage;
+ ratio = percentage * UINT16_MAX;
+ motor_ratios[id] = ratio;
+ }
+
+#endif
+ ledc_set_duty(motors_channel[id].speed_mode, motors_channel[id].channel, (uint32_t)motorsConv16ToBits(ratio));
+ ledc_update_duty(motors_channel[id].speed_mode, motors_channel[id].channel);
+ motor_ratios[id] = ratio;
+#ifdef DEBUG_EP2
+ DEBUG_PRINT_LOCAL("motors ID = %d ,ithrust_10bit = %d", id, (uint32_t)motorsConv16ToBits(ratio));
+#endif
+ }
+}
+
+int motorsGetRatio(uint32_t id)
+{
+ int ratio;
+ ASSERT(id < NBR_OF_MOTORS);
+ ratio = motorsConvBitsTo16((uint16_t)ledc_get_duty(motors_channel[id].speed_mode, motors_channel[id].channel));
+ return ratio;
+}
+
+void motorsBeep(int id, bool enable, uint16_t frequency, uint16_t ratio)
+{
+ uint32_t freq_hz = 15000;
+ ASSERT(id < NBR_OF_MOTORS);
+ if (ratio != 0) {
+ ratio = (uint16_t)(0.05*(1<<16));
+ }
+
+ if (enable) {
+ freq_hz = frequency;
+ }
+
+ ledc_set_freq(LEDC_LOW_SPEED_MODE,LEDC_TIMER_0,freq_hz);
+ ledc_set_duty(motors_channel[id].speed_mode, motors_channel[id].channel, (uint32_t)motorsConv16ToBits(ratio));
+ ledc_update_duty(motors_channel[id].speed_mode, motors_channel[id].channel);
+}
+
+// Play a tone with a given frequency and a specific duration in milliseconds (ms)
+void motorsPlayTone(uint16_t frequency, uint16_t duration_msec)
+{
+ motorsBeep(MOTOR_M1, true, frequency, (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / frequency) / 20);
+ motorsBeep(MOTOR_M2, true, frequency, (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / frequency) / 20);
+ motorsBeep(MOTOR_M3, true, frequency, (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / frequency) / 20);
+ motorsBeep(MOTOR_M4, true, frequency, (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / frequency) / 20);
+ vTaskDelay(M2T(duration_msec));
+ motorsBeep(MOTOR_M1, false, frequency, 0);
+ motorsBeep(MOTOR_M2, false, frequency, 0);
+ motorsBeep(MOTOR_M3, false, frequency, 0);
+ motorsBeep(MOTOR_M4, false, frequency, 0);
+}
+
+// Plays a melody from a note array
+void motorsPlayMelody(uint16_t *notes)
+{
+ int i = 0;
+ uint16_t note; // Note in hz
+ uint16_t duration; // Duration in ms
+
+ do
+ {
+ note = notes[i++];
+ duration = notes[i++];
+ motorsPlayTone(note, duration);
+ } while (duration != 0);
+}
+LOG_GROUP_START(pwm)
+LOG_ADD(LOG_UINT32, m1_pwm, &motor_ratios[0])
+LOG_ADD(LOG_UINT32, m2_pwm, &motor_ratios[1])
+LOG_ADD(LOG_UINT32, m3_pwm, &motor_ratios[2])
+LOG_ADD(LOG_UINT32, m4_pwm, &motor_ratios[3])
+LOG_GROUP_STOP(pwm)
diff --git a/Firmware/esp-drone/components/drivers/general/motors/motors_def_cf2.c b/Firmware/esp-drone/components/drivers/general/motors/motors_def_cf2.c
new file mode 100644
index 0000000..c1bba30
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/motors/motors_def_cf2.c
@@ -0,0 +1,53 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * motors.c - Motor driver
+ *
+ */
+// Connector M1,
+#include "motors.h"
+
+static const MotorPerifDef CONN_M1 = {
+ .drvType = BRUSHED,
+};
+
+// Connector M2, PB11, TIM2_CH4
+static const MotorPerifDef CONN_M2 = {
+ .drvType = BRUSHED,
+};
+
+// Connector M3, PA15, TIM2_CH1
+static const MotorPerifDef CONN_M3 = {
+ .drvType = BRUSHED,
+};
+
+// Connector M4, PB9, TIM4_CH4
+static const MotorPerifDef CONN_M4 = {
+ .drvType = BRUSHED,
+};
+
+/**
+ * Default brushed mapping to M1-M4 connectors.
+ */
+const MotorPerifDef *motorMapDefaultBrushed[NBR_OF_MOTORS] = {
+ &CONN_M1,
+ &CONN_M2,
+ &CONN_M3,
+ &CONN_M4
+};
diff --git a/Firmware/esp-drone/components/drivers/general/wifi/CMakeLists.txt b/Firmware/esp-drone/components/drivers/general/wifi/CMakeLists.txt
new file mode 100644
index 0000000..1971523
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/wifi/CMakeLists.txt
@@ -0,0 +1,3 @@
+idf_component_register(SRCS "wifi_esp32.c"
+ INCLUDE_DIRS "." "include"
+ REQUIRES crazyflie platform config esp_wifi)
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/general/wifi/include/wifi_esp32.h b/Firmware/esp-drone/components/drivers/general/wifi/include/wifi_esp32.h
new file mode 100644
index 0000000..a125dea
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/wifi/include/wifi_esp32.h
@@ -0,0 +1,55 @@
+#ifndef WIFI_ESP32_H_
+#define WIFI_ESP32_H_
+#include <stdbool.h>
+#include <stdint.h>
+
+#define WIFI_RX_TX_PACKET_SIZE (64)
+
+/* Structure used for in/out data via USB */
+typedef struct
+{
+ uint8_t size;
+ uint8_t data[WIFI_RX_TX_PACKET_SIZE];
+} UDPPacket;
+
+/**
+ * Initialize the wifi.
+ *
+ * @note Initialize CRTP link only if USE_CRTP_WIFI is defined
+ */
+void wifiInit(void);
+
+/**
+ * Test the WIFI status.
+ *
+ * @return true if the WIFI is initialized
+ */
+bool wifiTest(void);
+
+/**
+ * Get CRTP link data structure
+ *
+ * @return Address of the crtp link operations structure.
+ */
+//struct crtpLinkOperations * wifiGetLink();
+
+/**
+ * Get data from rx queue with timeout.
+ * @param[out] c Byte of data
+ *
+ * @return true if byte received, false if timout reached.
+ */
+bool wifiGetDataBlocking(UDPPacket *in);
+
+/**
+ * Sends raw data using a lock. Should be used from
+ * exception functions and for debugging when a lot of data
+ * should be transfered.
+ * @param[in] size Number of bytes to send
+ * @param[in] data Pointer to data
+ *
+ * @note If WIFI Crtp link is activated this function does nothing
+ */
+bool wifiSendData(uint32_t size, uint8_t* data);
+
+#endif
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/general/wifi/wifi_esp32.c b/Firmware/esp-drone/components/drivers/general/wifi/wifi_esp32.c
new file mode 100644
index 0000000..c4cd7d6
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/general/wifi/wifi_esp32.c
@@ -0,0 +1,273 @@
+#include <string.h>
+
+#include "config.h"
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+
+#include "esp_system.h"
+#include "esp_wifi.h"
+#include "esp_event.h"
+#include "esp_netif.h"
+#include "lwip/err.h"
+#include "lwip/sockets.h"
+#include "lwip/sys.h"
+#include <lwip/netdb.h>
+
+#include "queuemonitor.h"
+#include "wifi_esp32.h"
+#include "stm32_legacy.h"
+#define DEBUG_MODULE "WIFI_UDP"
+#include "debug_cf.h"
+
+#define UDP_SERVER_PORT 2390
+#define UDP_SERVER_BUFSIZE 128
+
+static struct sockaddr_in6 source_addr; // Large enough for both IPv4 or IPv6
+
+//#define WIFI_SSID "Udp Server"
+static char WIFI_SSID[32] = "ESP-DRONE";
+static char WIFI_PWD[64] = "12345678" ;
+static uint8_t WIFI_CH = 1;
+#define MAX_STA_CONN (3)
+
+#ifndef MAC2STR
+#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
+#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
+#endif
+
+static char rx_buffer[UDP_SERVER_BUFSIZE];
+static char tx_buffer[UDP_SERVER_BUFSIZE];
+const int addr_family = (int)AF_INET;
+const int ip_protocol = IPPROTO_IP;
+static struct sockaddr_in dest_addr;
+static int sock;
+
+static xQueueHandle udpDataRx;
+static xQueueHandle udpDataTx;
+static UDPPacket inPacket;
+static UDPPacket outPacket;
+
+static bool isInit = false;
+static bool isUDPInit = false;
+static bool isUDPConnected = false;
+
+static esp_err_t udp_server_create(void *arg);
+
+static uint8_t calculate_cksum(void *data, size_t len)
+{
+ unsigned char *c = data;
+ int i;
+ unsigned char cksum = 0;
+
+ for (i = 0; i < len; i++) {
+ cksum += *(c++);
+ }
+
+ return cksum;
+}
+
+static void wifi_event_handler(void *arg, esp_event_base_t event_base,
+ int32_t event_id, void *event_data)
+{
+ if (event_id == WIFI_EVENT_AP_STACONNECTED) {
+ wifi_event_ap_staconnected_t *event = (wifi_event_ap_staconnected_t *) event_data;
+ DEBUG_PRINT_LOCAL("station" MACSTR "join, AID=%d", MAC2STR(event->mac), event->aid);
+
+ } else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) {
+ wifi_event_ap_stadisconnected_t *event = (wifi_event_ap_stadisconnected_t *) event_data;
+ DEBUG_PRINT_LOCAL("station" MACSTR "leave, AID=%d", MAC2STR(event->mac), event->aid);
+ }
+}
+
+bool wifiTest(void)
+{
+ return isInit;
+};
+
+bool wifiGetDataBlocking(UDPPacket *in)
+{
+ /* command step - receive 02 from udp rx queue */
+ while (xQueueReceive(udpDataRx, in, portMAX_DELAY) != pdTRUE) {
+ vTaskDelay(1);
+ }; // Don't return until we get some data on the UDP
+
+ return true;
+};
+
+bool wifiSendData(uint32_t size, uint8_t *data)
+{
+ static UDPPacket outStage;
+ outStage.size = size;
+ memcpy(outStage.data, data, size);
+ // Dont' block when sending
+ return (xQueueSend(udpDataTx, &outStage, M2T(100)) == pdTRUE);
+};
+
+static esp_err_t udp_server_create(void *arg)
+{
+ if (isUDPInit){
+ return ESP_OK;
+ }
+
+ struct sockaddr_in *pdest_addr = &dest_addr;
+ pdest_addr->sin_addr.s_addr = htonl(INADDR_ANY);
+ pdest_addr->sin_family = AF_INET;
+ pdest_addr->sin_port = htons(UDP_SERVER_PORT);
+
+ sock = socket(addr_family, SOCK_DGRAM, ip_protocol);
+ if (sock < 0) {
+ DEBUG_PRINT_LOCAL("Unable to create socket: errno %d", errno);
+ return ESP_FAIL;
+ }
+ DEBUG_PRINT_LOCAL("Socket created");
+
+ int err = bind(sock, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
+ if (err < 0) {
+ DEBUG_PRINT_LOCAL("Socket unable to bind: errno %d", errno);
+ }
+ DEBUG_PRINT_LOCAL("Socket bound, port %d", UDP_SERVER_PORT);
+
+ isUDPInit = true;
+ return ESP_OK;
+}
+
+static void udp_server_rx_task(void *pvParameters)
+{
+ uint8_t cksum = 0;
+ socklen_t socklen = sizeof(source_addr);
+
+ while (true) {
+ if(isUDPInit == false) {
+ vTaskDelay(20);
+ continue;
+ }
+ int len = recvfrom(sock, rx_buffer, sizeof(rx_buffer) - 1, 0, (struct sockaddr *)&source_addr, &socklen);
+ /* command step - receive 01 from Wi-Fi UDP */
+ if (len < 0) {
+ DEBUG_PRINT_LOCAL("recvfrom failed: errno %d", errno);
+ break;
+ } else if(len > WIFI_RX_TX_PACKET_SIZE - 4) {
+ DEBUG_PRINT_LOCAL("Received data length = %d > 64", len);
+ } else {
+ //copy part of the UDP packet
+ rx_buffer[len] = 0;// Null-terminate whatever we received and treat like a string...
+ memcpy(inPacket.data, rx_buffer, len);
+ cksum = inPacket.data[len - 1];
+ //remove cksum, do not belong to CRTP
+ inPacket.size = len - 1;
+ //check packet
+ if (cksum == calculate_cksum(inPacket.data, len - 1) && inPacket.size < 64){
+ xQueueSend(udpDataRx, &inPacket, M2T(2));
+ if(!isUDPConnected) isUDPConnected = true;
+ }else{
+ DEBUG_PRINT_LOCAL("udp packet cksum unmatched");
+ }
+
+#ifdef DEBUG_UDP
+ DEBUG_PRINT_LOCAL("1.Received data size = %d %02X \n cksum = %02X", len, inPacket.data[0], cksum);
+ for (size_t i = 0; i < len; i++) {
+ DEBUG_PRINT_LOCAL(" data[%d] = %02X ", i, inPacket.data[i]);
+ }
+#endif
+ }
+ }
+}
+
+static void udp_server_tx_task(void *pvParameters)
+{
+
+ while (TRUE) {
+ if(isUDPInit == false) {
+ vTaskDelay(20);
+ continue;
+ }
+ if ((xQueueReceive(udpDataTx, &outPacket, 5) == pdTRUE) && isUDPConnected) {
+ memcpy(tx_buffer, outPacket.data, outPacket.size);
+ tx_buffer[outPacket.size] = calculate_cksum(tx_buffer, outPacket.size);
+ tx_buffer[outPacket.size + 1] = 0;
+
+ int err = sendto(sock, tx_buffer, outPacket.size + 1, 0, (struct sockaddr *)&source_addr, sizeof(source_addr));
+ if (err < 0) {
+ DEBUG_PRINT_LOCAL("Error occurred during sending: errno %d", errno);
+ continue;
+ }
+#ifdef DEBUG_UDP
+ DEBUG_PRINT_LOCAL("Send data to");
+ for (size_t i = 0; i < outPacket.size + 1; i++) {
+ DEBUG_PRINT_LOCAL(" data_send[%d] = %02X ", i, tx_buffer[i]);
+ }
+#endif
+ }
+ }
+}
+
+
+void wifiInit(void)
+{
+ if (isInit) {
+ return;
+ }
+
+ esp_netif_t *ap_netif = NULL;
+ ESP_ERROR_CHECK(esp_netif_init());
+ ESP_ERROR_CHECK(esp_event_loop_create_default());
+ ap_netif = esp_netif_create_default_wifi_ap();
+ uint8_t mac[6];
+
+ wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
+ ESP_ERROR_CHECK(esp_wifi_init(&cfg));
+
+ ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
+ ESP_EVENT_ANY_ID,
+ &wifi_event_handler,
+ NULL,
+ NULL));
+
+ ESP_ERROR_CHECK(esp_wifi_get_mac(ESP_IF_WIFI_AP, mac));
+ sprintf(WIFI_SSID, "ESP-DRONE_%02X%02X%02X%02X%02X%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
+ wifi_config_t wifi_config = {
+ .ap = {
+ .channel = WIFI_CH,
+ .max_connection = MAX_STA_CONN,
+ .authmode = WIFI_AUTH_WPA_WPA2_PSK,
+ },
+ };
+
+ memcpy(wifi_config.ap.ssid, WIFI_SSID, strlen(WIFI_SSID) + 1) ;
+ wifi_config.ap.ssid_len = strlen(WIFI_SSID);
+ memcpy(wifi_config.ap.password, WIFI_PWD, strlen(WIFI_PWD) + 1) ;
+
+ if (strlen(WIFI_PWD) == 0) {
+ wifi_config.ap.authmode = WIFI_AUTH_OPEN;
+ }
+
+ ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
+ ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &wifi_config));
+ ESP_ERROR_CHECK(esp_wifi_start());
+
+ esp_netif_ip_info_t ip_info = {
+ .ip.addr = ipaddr_addr("192.168.43.42"),
+ .netmask.addr = ipaddr_addr("255.255.255.0"),
+ .gw.addr = ipaddr_addr("192.168.43.42"),
+ };
+ ESP_ERROR_CHECK(esp_netif_dhcps_stop(ap_netif));
+ ESP_ERROR_CHECK(esp_netif_set_ip_info(ap_netif, &ip_info));
+ ESP_ERROR_CHECK(esp_netif_dhcps_start(ap_netif));
+
+ DEBUG_PRINT_LOCAL("wifi_init_softap complete.SSID:%s password:%s", WIFI_SSID, WIFI_PWD);
+
+ // This should probably be reduced to a CRTP packet size
+ udpDataRx = xQueueCreate(5, sizeof(UDPPacket)); /* Buffer packets (max 64 bytes) */
+ DEBUG_QUEUE_MONITOR_REGISTER(udpDataRx);
+ udpDataTx = xQueueCreate(5, sizeof(UDPPacket)); /* Buffer packets (max 64 bytes) */
+ DEBUG_QUEUE_MONITOR_REGISTER(udpDataTx);
+ if (udp_server_create(NULL) == ESP_FAIL) {
+ DEBUG_PRINT_LOCAL("UDP server create socket failed!!!");
+ } else {
+ DEBUG_PRINT_LOCAL("UDP server create socket succeed!!!");
+ }
+ xTaskCreate(udp_server_tx_task, UDP_TX_TASK_NAME, UDP_TX_TASK_STACKSIZE, NULL, UDP_TX_TASK_PRI, NULL);
+ xTaskCreate(udp_server_rx_task, UDP_RX_TASK_NAME, UDP_RX_TASK_STACKSIZE, NULL, UDP_RX_TASK_PRI, NULL);
+ isInit = true;
+}
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/i2c_bus/CMakeLists.txt b/Firmware/esp-drone/components/drivers/i2c_bus/CMakeLists.txt
new file mode 100644
index 0000000..c69254b
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_bus/CMakeLists.txt
@@ -0,0 +1,4 @@
+idf_component_register(SRCS "i2c_drv.c" "i2cdev_esp32.c"
+ INCLUDE_DIRS "include"
+ REQUIRES crazyflie platform driver
+ PRIV_REQUIRES config)
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/i2c_bus/i2c_drv.c b/Firmware/esp-drone/components/drivers/i2c_bus/i2c_drv.c
new file mode 100644
index 0000000..ad49b00
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_bus/i2c_drv.c
@@ -0,0 +1,116 @@
+/**
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (c) 2014, Bitcraze AB, All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3.0 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.
+ *
+ * i2c_drv.c - i2c driver implementation
+ *
+ * @note
+ * For some reason setting CR1 reg in sequence with
+ * I2C_AcknowledgeConfig(I2C_SENSORS, ENABLE) and after
+ * I2C_GenerateSTART(I2C_SENSORS, ENABLE) sometimes creates an
+ * instant start->stop condition (3.9us long) which I found out with an I2C
+ * analyzer. This fast start->stop is only possible to generate if both
+ * start and stop flag is set in CR1 at the same time. So i tried setting the CR1
+ * at once with I2C_SENSORS->CR1 = (I2C_CR1_START | I2C_CR1_ACK | I2C_CR1_PE) and the
+ * problem is gone. Go figure...
+ */
+
+
+#include <string.h>
+
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "freertos/queue.h"
+#include "freertos/semphr.h"
+
+#include "stm32_legacy.h"
+#include "i2c_drv.h"
+#include "config.h"
+#define DEBUG_MODULE "I2CDRV"
+#include "debug_cf.h"
+
+// Definitions of sensors I2C bus
+#define I2C_DEFAULT_SENSORS_CLOCK_SPEED 400000
+
+// Definition of eeprom and deck I2C buss,use two i2c with 400Khz clock simultaneously could trigger the watchdog
+#define I2C_DEFAULT_DECK_CLOCK_SPEED 100000
+
+static bool isinit_i2cPort[2] = {0, 0};
+
+// Cost definitions of busses
+static const I2cDef sensorBusDef = {
+ .i2cPort = I2C_NUM_0,
+ .i2cClockSpeed = I2C_DEFAULT_SENSORS_CLOCK_SPEED,
+ .gpioSCLPin = CONFIG_I2C0_PIN_SCL,
+ .gpioSDAPin = CONFIG_I2C0_PIN_SDA,
+ .gpioPullup = GPIO_PULLUP_DISABLE,
+};
+
+I2cDrv sensorsBus = {
+ .def = &sensorBusDef,
+};
+
+static const I2cDef deckBusDef = {
+ .i2cPort = I2C_NUM_1,
+ .i2cClockSpeed = I2C_DEFAULT_DECK_CLOCK_SPEED,
+ .gpioSCLPin = CONFIG_I2C1_PIN_SCL,
+ .gpioSDAPin = CONFIG_I2C1_PIN_SDA,
+ .gpioPullup = GPIO_PULLUP_ENABLE,
+};
+
+I2cDrv deckBus = {
+ .def = &deckBusDef,
+};
+
+static void i2cdrvInitBus(I2cDrv *i2c)
+{
+ if (isinit_i2cPort[i2c->def->i2cPort]) {
+ return;
+ }
+
+ i2c_config_t conf = {0};
+ conf.mode = I2C_MODE_MASTER;
+ conf.sda_io_num = i2c->def->gpioSDAPin;
+ conf.sda_pullup_en = i2c->def->gpioPullup;
+ conf.scl_io_num = i2c->def->gpioSCLPin;
+ conf.scl_pullup_en = i2c->def->gpioPullup;
+ conf.master.clk_speed = i2c->def->i2cClockSpeed;
+ esp_err_t err = i2c_param_config(i2c->def->i2cPort, &conf);
+
+ if (!err) {
+ err = i2c_driver_install(i2c->def->i2cPort, conf.mode, 0, 0, 0);
+ }
+
+ DEBUG_PRINTI(" i2c %d driver install return = %d", i2c->def->i2cPort, err);
+ i2c->isBusFreeMutex = xSemaphoreCreateMutex();
+ isinit_i2cPort[i2c->def->i2cPort] = true;
+}
+
+
+//-----------------------------------------------------------
+
+void i2cdrvInit(I2cDrv *i2c)
+{
+ i2cdrvInitBus(i2c);
+}
+
+void i2cdrvTryToRestartBus(I2cDrv *i2c)
+{
+ i2cdrvInitBus(i2c);
+}
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_bus/i2cdev_esp32.c b/Firmware/esp-drone/components/drivers/i2c_bus/i2cdev_esp32.c
new file mode 100644
index 0000000..a4b5fb0
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_bus/i2cdev_esp32.c
@@ -0,0 +1,342 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * i2cdev.c - Functions to write to I2C devices
+ */
+#define DEBUG_MODULE "I2CDEV"
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "freertos/FreeRTOS.h"
+#include "freertos/semphr.h"
+#include "freertos/task.h"
+#include "freertos/queue.h"
+
+#include "stm32_legacy.h"
+#include "i2cdev.h"
+#include "i2c_drv.h"
+#include "nvicconf.h"
+#include "debug_cf.h"
+
+int i2cdevInit(I2C_Dev *dev)
+{
+ i2cdrvInit(dev);
+ return true;
+}
+
+bool i2cdevRead(I2C_Dev *dev, uint8_t devAddress, uint16_t len, uint8_t *data)
+{
+ return i2cdevReadReg8(dev, devAddress, I2CDEV_NO_MEM_ADDR, len, data);
+}
+
+bool i2cdevReadByte(I2C_Dev *dev, uint8_t devAddress, uint8_t memAddress,
+ uint8_t *data)
+{
+ return i2cdevReadReg8(dev, devAddress, memAddress, 1, data);
+}
+
+bool i2cdevReadBit(I2C_Dev *dev, uint8_t devAddress, uint8_t memAddress,
+ uint8_t bitNum, uint8_t *data)
+{
+ uint8_t byte;
+ bool status;
+
+ status = i2cdevReadReg8(dev, devAddress, memAddress, 1, &byte);
+ *data = byte & (1 << bitNum);
+
+ return status;
+}
+
+bool i2cdevReadBits(I2C_Dev *dev, uint8_t devAddress, uint8_t memAddress,
+ uint8_t bitStart, uint8_t length, uint8_t *data)
+{
+ bool status;
+ uint8_t byte;
+
+ if ((status = i2cdevReadByte(dev, devAddress, memAddress, &byte)) == true) {
+ uint8_t mask = ((1 << length) - 1) << (bitStart - length + 1);
+ byte &= mask;
+ byte >>= (bitStart - length + 1);
+ *data = byte;
+ }
+
+ return status;
+}
+
+bool i2cdevReadReg8(I2C_Dev *dev, uint8_t devAddress, uint8_t memAddress,
+ uint16_t len, uint8_t *data)
+{
+ if (xSemaphoreTake(dev->isBusFreeMutex, (TickType_t)5) == pdFALSE) {
+ return false;
+ }
+
+ i2c_cmd_handle_t cmd = i2c_cmd_link_create();
+ if (memAddress != I2CDEV_NO_MEM_ADDR) {
+ i2c_master_start(cmd);
+ i2c_master_write_byte(cmd, (devAddress << 1) | I2C_MASTER_WRITE, I2C_MASTER_ACK_EN);
+ i2c_master_write_byte(cmd, memAddress, I2C_MASTER_ACK_EN);
+ }
+ i2c_master_start(cmd);
+ i2c_master_write_byte(cmd, (devAddress << 1) | I2C_MASTER_READ, I2C_MASTER_ACK_EN);
+ i2c_master_read(cmd, data, len, I2C_MASTER_LAST_NACK);
+ i2c_master_stop(cmd);
+ esp_err_t err = i2c_master_cmd_begin(dev->def->i2cPort, cmd, (TickType_t)5);
+ i2c_cmd_link_delete(cmd);
+
+ xSemaphoreGive(dev->isBusFreeMutex);
+
+#if defined CONFIG_I2CBUS_LOG_READWRITES
+
+ if (!err) {
+ char str[length * 5 + 1];
+
+ for (size_t i = 0; i < length; i++) {
+ sprintf(str + i * 5, "0x%s%X ", (data[i] < 0x10 ? "0" : ""), data[i]);
+ }
+
+ I2CBUS_LOG_RW("[port:%d, slave:0x%X] Read_ %d bytes from register 0x%X, data: %s", port, devAddr, length, regAddr, str);
+ }
+
+#endif
+#if defined CONFIG_I2CBUS_LOG_ERRORS
+#if defined CONFIG_I2CBUS_LOG_READWRITES
+ else {
+#else
+
+ if (err) {
+#endif
+ I2CBUS_LOGE("[port:%d, slave:0x%X] Failed to read %d bytes from register 0x%X, error: 0x%X",
+ port, devAddr, length, regAddr, err);
+ }
+
+#endif
+
+ if (err == ESP_OK) {
+ return TRUE;
+ } else {
+ return false;
+ }
+
+}
+
+bool i2cdevReadReg16(I2C_Dev *dev, uint8_t devAddress, uint16_t memAddress,
+ uint16_t len, uint8_t *data)
+{
+ if (xSemaphoreTake(dev->isBusFreeMutex, (TickType_t)5) == pdFALSE) {
+ return false;
+ }
+
+ uint8_t memAddress8[2];
+ memAddress8[0] = (uint8_t)((memAddress >> 8) & 0x00FF);
+ memAddress8[1] = (uint8_t)(memAddress & 0x00FF);
+ i2c_cmd_handle_t cmd = i2c_cmd_link_create();
+ if (memAddress != I2C_NO_INTERNAL_ADDRESS) {
+ i2c_master_start(cmd);
+ i2c_master_write_byte(cmd, (devAddress << 1) | I2C_MASTER_WRITE, I2C_MASTER_ACK_EN);
+ i2c_master_write(cmd, memAddress8, 2, I2C_MASTER_ACK_EN);
+ }
+ i2c_master_start(cmd);
+ i2c_master_write_byte(cmd, (devAddress << 1) | I2C_MASTER_READ, I2C_MASTER_ACK_EN);
+ i2c_master_read(cmd, data, len, I2C_MASTER_LAST_NACK);
+ i2c_master_stop(cmd);
+ esp_err_t err = i2c_master_cmd_begin(dev->def->i2cPort, cmd, (TickType_t)5);
+ i2c_cmd_link_delete(cmd);
+
+ xSemaphoreGive(dev->isBusFreeMutex);
+
+#if defined CONFIG_I2CBUS_LOG_READWRITES
+
+ if (!err) {
+ char str[length * 5 + 1];
+
+ for (size_t i = 0; i < length; i++) {
+ sprintf(str + i * 5, "0x%s%X ", (data[i] < 0x10 ? "0" : ""), data[i]);
+ }
+
+ I2CBUS_LOG_RW("[port:%d, slave:0x%X] Read_ %d bytes from register 0x%X, data: %s", port, devAddr, length, regAddr, str);
+ }
+
+#endif
+#if defined CONFIG_I2CBUS_LOG_ERRORS
+#if defined CONFIG_I2CBUS_LOG_READWRITES
+ else {
+#else
+
+ if (err) {
+#endif
+ I2CBUS_LOGE("[port:%d, slave:0x%X] Failed to read %d bytes from register 0x%X, error: 0x%X",
+ port, devAddr, length, regAddr, err);
+ }
+
+#endif
+
+ if (err == ESP_OK) {
+ return TRUE;
+ } else {
+ return false;
+ }
+
+}
+
+bool i2cdevWriteByte(I2C_Dev *dev, uint8_t devAddress, uint8_t memAddress,
+ uint8_t data)
+{
+ return i2cdevWriteReg8(dev, devAddress, memAddress, 1, &data);
+}
+
+bool i2cdevWriteBit(I2C_Dev *dev, uint8_t devAddress, uint8_t memAddress,
+ uint8_t bitNum, uint8_t data)
+{
+ uint8_t byte;
+ i2cdevReadByte(dev, devAddress, memAddress, &byte);
+ byte = (data != 0) ? (byte | (1 << bitNum)) : (byte & ~(1 << bitNum));
+ return i2cdevWriteByte(dev, devAddress, memAddress, byte);
+}
+
+bool i2cdevWriteBits(I2C_Dev *dev, uint8_t devAddress, uint8_t memAddress,
+ uint8_t bitStart, uint8_t length, uint8_t data)
+{
+ bool status;
+ uint8_t byte;
+
+ if ((status = i2cdevReadByte(dev, devAddress, memAddress, &byte)) == true) {
+ uint8_t mask = ((1 << length) - 1) << (bitStart - length + 1);
+ data <<= (bitStart - length + 1); // shift data into correct position
+ data &= mask; // zero all non-important bits in data
+ byte &= ~(mask); // zero all important bits in existing byte
+ byte |= data; // combine data with existing byte
+ status = i2cdevWriteByte(dev, devAddress, memAddress, byte);
+ }
+
+ return status;
+}
+
+
+bool i2cdevWriteReg8(I2C_Dev *dev, uint8_t devAddress, uint8_t memAddress,
+ uint16_t len, uint8_t *data)
+{
+ if (xSemaphoreTake(dev->isBusFreeMutex, (TickType_t)5) == pdFALSE) {
+ return false;
+ }
+
+ i2c_cmd_handle_t cmd = i2c_cmd_link_create();
+ i2c_master_start(cmd);
+ i2c_master_write_byte(cmd, (devAddress << 1) | I2C_MASTER_WRITE, I2C_MASTER_ACK_EN);
+ if (memAddress != I2CDEV_NO_MEM_ADDR) {
+ i2c_master_write_byte(cmd, memAddress, I2C_MASTER_ACK_EN);
+ }
+ i2c_master_write(cmd, (uint8_t *)data, len, I2C_MASTER_ACK_EN);
+ i2c_master_stop(cmd);
+ esp_err_t err = i2c_master_cmd_begin(dev->def->i2cPort, cmd, (TickType_t)5);
+ i2c_cmd_link_delete(cmd);
+
+ xSemaphoreGive(dev->isBusFreeMutex);
+
+#if defined CONFIG_I2CBUS_LOG_READWRITES
+
+ if (!err) {
+ char str[length * 5 + 1];
+
+ for (size_t i = 0; i < length; i++) {
+ sprintf(str + i * 5, "0x%s%X ", (data[i] < 0x10 ? "0" : ""), data[i]);
+ }
+
+ I2CBUS_LOG_RW("[port:%d, slave:0x%X] Write %d bytes to register 0x%X, data: %s",
+ port, devAddr, length, regAddr, str);
+ }
+
+#endif
+#if defined CONFIG_I2CBUS_LOG_ERRORS
+#if defined CONFIG_I2CBUS_LOG_READWRITES
+ else {
+#else
+
+ if (err) {
+#endif
+ I2CBUS_LOGE("[port:%d, slave:0x%X] Failed to write %d bytes to__ register 0x%X, error: 0x%X",
+ port, devAddr, length, regAddr, err);
+ }
+
+#endif
+
+ if (err == ESP_OK) {
+ return TRUE;
+ } else {
+ return false;
+ }
+}
+
+bool i2cdevWriteReg16(I2C_Dev *dev, uint8_t devAddress, uint16_t memAddress,
+ uint16_t len, uint8_t *data)
+{
+ if (xSemaphoreTake(dev->isBusFreeMutex, (TickType_t)5) == pdFALSE) {
+ return false;
+ }
+
+ uint8_t memAddress8[2];
+ memAddress8[0] = (uint8_t)((memAddress >> 8) & 0x00FF);
+ memAddress8[1] = (uint8_t)(memAddress & 0x00FF);
+ i2c_cmd_handle_t cmd = i2c_cmd_link_create();
+ i2c_master_start(cmd);
+ i2c_master_write_byte(cmd, (devAddress << 1) | I2C_MASTER_WRITE, I2C_MASTER_ACK_EN);
+ if (memAddress != I2C_NO_INTERNAL_ADDRESS) {
+ i2c_master_write(cmd, memAddress8, 2, I2C_MASTER_ACK_EN);
+ }
+ i2c_master_write(cmd, (uint8_t *)data, len, I2C_MASTER_ACK_EN);
+ i2c_master_stop(cmd);
+ esp_err_t err = i2c_master_cmd_begin(dev->def->i2cPort, cmd, (TickType_t)5);
+ i2c_cmd_link_delete(cmd);
+
+ xSemaphoreGive(dev->isBusFreeMutex);
+#if defined CONFIG_I2CBUS_LOG_READWRITES
+
+ if (!err) {
+ char str[length * 5 + 1];
+
+ for (size_t i = 0; i < length; i++) {
+ sprintf(str + i * 5, "0x%s%X ", (data[i] < 0x10 ? "0" : ""), data[i]);
+ }
+
+ I2CBUS_LOG_RW("[port:%d, slave:0x%X] Write %d bytes to register 0x%X, data: %s",
+ port, devAddr, length, regAddr, str);
+ }
+
+#endif
+
+#if defined CONFIG_I2CBUS_LOG_ERRORS
+#if defined CONFIG_I2CBUS_LOG_READWRITES
+ else {
+#else
+
+ if (err) {
+#endif
+ I2CBUS_LOGE("[port:%d, slave:0x%X] Failed to write %d bytes to__ register 0x%X, error: 0x%X",
+ port, devAddr, length, regAddr, err);
+ }
+
+#endif
+
+ if (err == ESP_OK) {
+ return TRUE;
+ } else {
+ return false;
+ }
+}
diff --git a/Firmware/esp-drone/components/drivers/i2c_bus/include/i2c_drv.h b/Firmware/esp-drone/components/drivers/i2c_bus/include/i2c_drv.h
new file mode 100644
index 0000000..11889b7
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_bus/include/i2c_drv.h
@@ -0,0 +1,109 @@
+#ifndef I2C_H
+#define I2C_H
+
+#include "freertos/FreeRTOS.h"
+#include "freertos/semphr.h"
+#include "freertos/queue.h"
+#include "driver/i2c.h"
+
+#include "stm32_legacy.h"
+
+#define I2C_NO_INTERNAL_ADDRESS 0xFFFF
+
+typedef enum {
+ i2cAck,
+ i2cNack
+} I2cStatus;
+
+typedef enum {
+ i2cWrite,
+ i2cRead
+} I2cDirection;
+
+/**
+ * Structure used to capture the I2C message details. The structure is then
+ * queued for processing by the I2C ISR.
+ */
+typedef struct _I2cMessage {
+ uint32_t messageLength; //< How many bytes of data to send or received.
+ uint8_t slaveAddress; //< The slave address of the device on the I2C bus.
+ uint8_t nbrOfRetries; //< The slave address of the device on the I2C bus.
+ I2cDirection direction; //< Direction of message
+ I2cStatus status; //< i2c status
+ xQueueHandle clientQueue; //< Queue to send received messages to.
+ bool isInternal16bit; //< Is internal address 16 bit. If false 8 bit.
+ uint16_t internalAddress; //< Internal address of device.
+ uint8_t *buffer; //< Pointer to the buffer from where data will be read for transmission, or into which received data will be placed.
+} I2cMessage;
+
+typedef struct {
+ i2c_port_t i2cPort;
+ uint32_t i2cClockSpeed;
+ uint32_t gpioSCLPin;
+ uint32_t gpioSDAPin;
+ gpio_pullup_t gpioPullup;
+} I2cDef;
+
+typedef struct {
+ const I2cDef *def; //< Definition of the i2c
+ SemaphoreHandle_t isBusFreeMutex; //< Mutex to protect buss
+} I2cDrv;
+
+// Definitions of i2c busses found in c file.
+extern I2cDrv deckBus;
+extern I2cDrv sensorsBus;
+
+/**
+ * Initialize i2c peripheral as defined by static I2cDef structs.
+ */
+void i2cdrvInit(I2cDrv *i2c);
+
+/**
+ * Send or receive a message over the I2C bus.
+ *
+ * The message is synchrony by semapthore and uses interrupts to transfer the message.
+ *
+ * @param i2c i2c bus to use.
+ * @param message An I2cMessage struct containing all the i2c message
+ * Information. Message status will be altered if nack.
+ * @return true if successful, false otherwise.
+ */
+bool i2cdrvMessageTransfer(I2cDrv *i2c, I2cMessage *message);
+
+
+/**
+ * Create a message to transfer
+ *
+ * @param message pointer to message struct that will be filled in.
+ * @param slaveAddress i2c slave address
+ * @param direction i2cWrite or i2cRead
+ * @param length Length of message
+ * @param buffer pointer to buffer of send/receive data
+ */
+void i2cdrvCreateMessage(I2cMessage *message,
+ uint8_t slaveAddress,
+ I2cDirection direction,
+ uint32_t length,
+ uint8_t *buffer);
+
+/**
+ * Create a message to transfer with internal "reg" address. Will first do a write
+ * of one or two bytes depending of IsInternal16 and then write/read the data.
+ *
+ * @param message pointer to message struct that will be filled in.
+ * @param slaveAddress i2c slave address
+ * @param IsInternal16 It true 16bit reg address else 8bit.
+ * @param direction i2cWrite or i2cRead
+ * @param length Length of message
+ * @param buffer pointer to buffer of send/receive data
+ */
+void i2cdrvCreateMessageIntAddr(I2cMessage *message,
+ uint8_t slaveAddress,
+ bool IsInternal16,
+ uint16_t intAddress,
+ I2cDirection direction,
+ uint32_t length,
+ uint8_t *buffer);
+
+#endif
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_bus/include/i2cdev.h b/Firmware/esp-drone/components/drivers/i2c_bus/include/i2cdev.h
new file mode 100644
index 0000000..bd02259
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_bus/include/i2cdev.h
@@ -0,0 +1,206 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * i2cdev.h - Functions to write to I2C devices
+ */
+
+#ifndef __I2CDEV_H__
+#define __I2CDEV_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "i2c_drv.h"
+
+#define I2CDEV_NO_MEM_ADDR 0xFF
+
+typedef I2cDrv I2C_Dev;
+#define I2C1_DEV &deckBus
+#define I2C0_DEV &sensorsBus
+
+// For compatibility
+#define i2cdevWrite16 i2cdevWriteReg16
+#define i2cdevRead16 i2cdevReadReg16
+
+#define I2C_TIMEOUT 5
+#define I2CDEV_CLK_TS (1000000 / 100000)
+
+#define I2C_MASTER_ACK_EN true /*!< Enable ack check for master */
+#define I2C_MASTER_ACK_DIS false /*!< Disable ack check for master */
+/**
+ * Read bytes from an I2C peripheral
+ * @param dev Pointer to I2C peripheral to read from
+ * @param devAddress The device address to read from
+ * @param len Number of bytes to read.
+ * @param data Pointer to a buffer to read the data to.
+ *
+ * @return TRUE if read was successful, otherwise FALSE.
+ */
+bool i2cdevRead(I2C_Dev *dev, uint8_t devAddress, uint16_t len, uint8_t *data);
+
+/**
+ * Read bytes from an I2C peripheral
+ * @param dev Pointer to I2C peripheral to read from
+ * @param devAddress The device address to read from
+ * @param memAddress The internal address to read from, I2CDEV_NO_MEM_ADDR if none.
+ * @param len Number of bytes to read.
+ * @param data Pointer to a buffer to read the data to.
+ *
+ * @return TRUE if read was successful, otherwise FALSE.
+ */
+bool i2cdevReadReg8(I2C_Dev *dev, uint8_t devAddress, uint8_t memAddress,
+ uint16_t len, uint8_t *data);
+
+/**
+ * Read bytes from an I2C peripheral with a 16bit internal reg/mem address
+ * @param dev Pointer to I2C peripheral to read from
+ * @param devAddress The device address to read from
+ * @param memAddress The internal address to read from, I2CDEV_NO_MEM_ADDR if none.
+ * @param len Number of bytes to read.
+ * @param data Pointer to a buffer to read the data to.
+ *
+ * @return TRUE if read was successful, otherwise FALSE.
+ */
+bool i2cdevReadReg16(I2C_Dev *dev, uint8_t devAddress, uint16_t memAddress,
+ uint16_t len, uint8_t *data);
+
+/**
+ * I2C device init function.
+ * @param dev Pointer to I2C peripheral to initialize.
+ *
+ * @return TRUE if initialization went OK otherwise FALSE.
+ */
+int i2cdevInit(I2C_Dev *dev);
+
+/**
+ * Read a byte from an I2C peripheral
+ * @param dev Pointer to I2C peripheral to read from
+ * @param devAddress The device address to read from
+ * @param memAddress The internal address to read from, I2CDEV_NO_MEM_ADDR if none.
+ * @param data Pointer to a buffer to read the data to.
+ *
+ * @return TRUE if read was successful, otherwise FALSE.
+ */
+bool i2cdevReadByte(I2C_Dev *dev, uint8_t devAddress, uint8_t memAddress,
+ uint8_t *data);
+
+/**
+ * Read a bit from an I2C peripheral
+ * @param dev Pointer to I2C peripheral to read from
+ * @param devAddress The device address to read from
+ * @param memAddress The internal address to read from, I2CDEV_NO_MEM_ADDR if none.
+ * @param bitNum The bit number 0 - 7 to read.
+ * @param data Pointer to a buffer to read the data to.
+ *
+ * @return TRUE if read was successful, otherwise FALSE.
+ */
+bool i2cdevReadBit(I2C_Dev *dev, uint8_t devAddress, uint8_t memAddress,
+ uint8_t bitNum, uint8_t *data);
+/**
+ * Read up to 8 bits from an I2C peripheral
+ * @param dev Pointer to I2C peripheral to read from
+ * @param devAddress The device address to read from
+ * @param memAddress The internal address to read from, I2CDEV_NO_MEM_ADDR if none.
+ * @param bitStart The bit to start from, 0 - 7, MSB at 0
+ * @param length The number of bits to read, 1 - 8.
+ * @param data Pointer to a buffer to read the data to.
+ *
+ * @return TRUE if read was successful, otherwise FALSE.
+ */
+bool i2cdevReadBits(I2C_Dev *dev, uint8_t devAddress, uint8_t memAddress,
+ uint8_t bitStart, uint8_t length, uint8_t *data);
+
+/**
+ * Write bytes to an I2C peripheral
+ * @param dev Pointer to I2C peripheral to write to
+ * @param devAddress The device address to write to
+ * @param len Number of bytes to read.
+ * @param data Pointer to a buffer to read the data from that will be written.
+ *
+ * @return TRUE if write was successful, otherwise FALSE.
+ */
+bool i2cdevWrite(I2C_Dev *dev, uint8_t devAddress, uint16_t len, uint8_t *data);
+
+/**
+ * Write bytes to an I2C peripheral
+ * @param dev Pointer to I2C peripheral to write to
+ * @param devAddress The device address to write to
+ * @param memAddress The internal address to write to, I2CDEV_NO_MEM_ADDR if none.
+ * @param len Number of bytes to read.
+ * @param data Pointer to a buffer to read the data from that will be written.
+ *
+ * @return TRUE if write was successful, otherwise FALSE.
+ */
+bool i2cdevWriteReg8(I2C_Dev *dev, uint8_t devAddress, uint8_t memAddress,
+ uint16_t len, uint8_t *data);
+
+/**
+ * Write bytes to an I2C peripheral with 16bit internal reg/mem address.
+ * @param dev Pointer to I2C peripheral to write to
+ * @param devAddress The device address to write to
+ * @param memAddress The internal address to write to, I2CDEV_NO_MEM_ADDR if none.
+ * @param len Number of bytes to read.
+ * @param data Pointer to a buffer to read the data from that will be written.
+ *
+ * @return TRUE if write was successful, otherwise FALSE.
+ */
+bool i2cdevWriteReg16(I2C_Dev *dev, uint8_t devAddress, uint16_t memAddress,
+ uint16_t len, uint8_t *data);
+
+/**
+ * Write a byte to an I2C peripheral
+ * @param dev Pointer to I2C peripheral to write to
+ * @param devAddress The device address to write to
+ * @param memAddress The internal address to write from, I2CDEV_NO_MEM_ADDR if none.
+ * @param data The byte to write.
+ *
+ * @return TRUE if write was successful, otherwise FALSE.
+ */
+bool i2cdevWriteByte(I2C_Dev *dev, uint8_t devAddress, uint8_t memAddress,
+ uint8_t data);
+
+/**
+ * Write a bit to an I2C peripheral
+ * @param dev Pointer to I2C peripheral to write to
+ * @param devAddress The device address to write to
+ * @param memAddress The internal address to write to, I2CDEV_NO_MEM_ADDR if none.
+ * @param bitNum The bit number, 0 - 7, to write.
+ * @param data The bit to write.
+ *
+ * @return TRUE if read was successful, otherwise FALSE.
+ */
+bool i2cdevWriteBit(I2C_Dev *dev, uint8_t devAddress, uint8_t memAddress,
+ uint8_t bitNum, uint8_t data);
+
+/**
+ * Write up to 8 bits to an I2C peripheral
+ * @param dev Pointer to I2C peripheral to write to
+ * @param devAddress The device address to write to
+ * @param memAddress The internal address to write to, I2CDEV_NO_MEM_ADDR if none.
+ * @param bitStart The bit to start from, 0 - 7.
+ * @param length The number of bits to write, 1 - 8.
+ * @param data The byte containing the bits to write.
+ *
+ * @return TRUE if read was successful, otherwise FALSE.
+ */
+bool i2cdevWriteBits(I2C_Dev *dev, uint8_t devAddress, uint8_t memAddress,
+ uint8_t bitStart, uint8_t length, uint8_t data);
+
+#endif //__I2CDEV_H__
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/eeprom/CMakeLists.txt b/Firmware/esp-drone/components/drivers/i2c_devices/eeprom/CMakeLists.txt
new file mode 100644
index 0000000..2d415fd
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/eeprom/CMakeLists.txt
@@ -0,0 +1,3 @@
+idf_component_register(SRCS "eeprom.c"
+ INCLUDE_DIRS "." "include"
+ REQUIRES crazyflie spi_flash)
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/eeprom/eeprom.c b/Firmware/esp-drone/components/drivers/i2c_devices/eeprom/eeprom.c
new file mode 100644
index 0000000..b383f1d
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/eeprom/eeprom.c
@@ -0,0 +1,137 @@
+/**
+ * ESP-Drone Firmware
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011 Fabio Varesano <[email protected]>
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * @file eeprom.c
+ * 使用 flash 分区代替 eeprom 保存数据,该部分需要检验,或替换成 NVS
+ *
+ */
+#define DEBUG_MODULE "EEPROM"
+
+#include <string.h>
+
+#include "esp_err.h"
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "eeprom.h"
+#include "debug_cf.h"
+#include "eprintf.h"
+
+#ifdef EEPROM_RUN_WRITE_READ_TEST
+#include "esp_spi_flash.h"
+static bool eepromTestWriteRead(void);
+#endif
+
+static bool isInit;
+
+bool eepromInit(I2C_Dev *i2cPort)
+{
+ if (isInit) {
+ return true;
+ }
+
+ //TODOspi_flash_init();
+ DEBUG_PRINTI("spi_flash_init ... !");
+
+ isInit = true;
+
+ return true;
+}
+
+bool eepromTest(void)
+{
+ bool status;
+
+ status = true;
+ return status;
+}
+
+#ifdef EEPROM_RUN_WRITE_READ_TEST
+static bool eepromTestWriteRead(void)
+{
+ bool status = true;
+ int i;
+ const uint8_t testData[20] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+ uint8_t readData[20];
+
+ for (i = 0; i < sizeof(testData) && status; i++) {
+ // Write one byte with increasing addresses.
+ eepromWriteBuffer(&testData[i], i, 1);
+ // Read it all back and check
+ eepromReadBuffer(readData, 0, i + 1);
+ status = (memcmp(testData, readData, i + 1) == 0);
+ }
+
+ // Write it all.
+ eepromWriteBuffer(testData, 0, sizeof(testData));
+
+ for (i = 0; i < sizeof(testData) && status; i++) {
+ // Read one byte with increasing addresses and check
+ eepromReadBuffer(&readData[i], i, 1);
+ status = (memcmp(testData, readData, i + 1) == 0);
+ }
+
+ return status;
+}
+#endif
+
+bool eepromTestConnection(void)
+{
+ //uint8_t tmp;
+ bool status;
+
+ status = true;
+ return status;
+}
+
+bool eepromReadBuffer(uint8_t *buffer, size_t readAddr, size_t len)
+{
+ bool status = false;
+ esp_err_t err = ESP_OK; //TODO spi_flash_read(readAddr, buffer, len);
+
+ if (err == ESP_OK) {
+
+ status = true;
+ DEBUG_PRINTI("spi_flash_read ok !");
+
+ } else {
+ DEBUG_PRINTW("spi_flash_read err = %d", err);
+ }
+
+ return status;
+}
+
+bool eepromWriteBuffer(uint8_t *buffer, size_t writeAddr, size_t len)
+{
+ bool status = false;
+ writeAddr += EEPROM_IN_FLASH_ADDR;
+
+ //TODO if (spi_flash_write(writeAddr, buffer, len) == ESP_OK) {
+ if (1) {
+
+ status = true;
+
+ }
+
+ return status;
+}
+
+bool eepromWritePage(uint8_t *buffer, uint16_t writeAddr)
+{
+//TODO: implement
+ return false;
+}
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/eeprom/include/eeprom.h b/Firmware/esp-drone/components/drivers/i2c_devices/eeprom/include/eeprom.h
new file mode 100644
index 0000000..868e165
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/eeprom/include/eeprom.h
@@ -0,0 +1,80 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * @file eeprom.h
+ * Driver for the 24AA64F eeprom. esp-drone use nvs
+ *
+ */
+#ifndef EERROM_H
+#define EERROM_H
+
+#include <stdbool.h>
+#include "i2cdev.h"
+
+#define EEPROM_IN_FLASH_ADDR 0x3d2000 //TODO: CHANGE 20200106 NEED TO TEST
+#define EEPROM_I2C_ADDR 0x50 //dont have a eeprom just for latency
+#define EEPROM_SIZE 0x1FFF //EEPROM_IN_FLASH_ADDR
+
+/**
+ * Initialize the i2c eeprom module
+ * @param i2cPort I2C port ( a CPAL_InitTypeDef) the eeprom is connected to.
+ *
+ * @return True on success, else false.
+ */
+bool eepromInit(I2C_Dev *i2cPort);
+
+/**
+ * Test that the eeprom is there
+ *
+ * @return True on success, else false.
+ */
+bool eepromTest(void);
+
+/**
+ * Test that the eeprom is there
+ *
+ * @return True on success, else false.
+ */
+bool eepromTestConnection(void);
+
+/**
+ * Read data from the eeprom into a supplied buffer
+ * @param buffer The buffer to write the data in
+ * @param readAddr The start address to read from
+ * @param len Number of bytes to read
+ *
+ * @return True on success, else false.
+ */
+bool eepromReadBuffer(uint8_t *buffer, size_t readAddr, size_t len);
+
+/**
+ * Write data to the eeprom from a supplied buffer.
+ * Currently very slow as id does single byte write.
+ * @param buffer The buffer to read the data from
+ * @param writeAddr The start address to write to
+ * @param len Number of bytes to write
+ *
+ * @return True on success, else false.
+ */
+bool eepromWriteBuffer(uint8_t *buffer, size_t writeAddr, size_t len);
+
+// TODO
+bool eepromWritePage(uint8_t *buffer, uint16_t writeAddr);
+
+#endif // EERROM_H
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/hmc5883l/CMakeLists.txt b/Firmware/esp-drone/components/drivers/i2c_devices/hmc5883l/CMakeLists.txt
new file mode 100644
index 0000000..87a45f8
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/hmc5883l/CMakeLists.txt
@@ -0,0 +1,4 @@
+idf_component_register(SRCS "hmc5883l.c"
+ INCLUDE_DIRS "." "include"
+ REQUIRES i2c_bus
+ PRIV_REQUIRES crazyflie platform)
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/hmc5883l/hmc5883l.c b/Firmware/esp-drone/components/drivers/i2c_devices/hmc5883l/hmc5883l.c
new file mode 100644
index 0000000..d2876f5
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/hmc5883l/hmc5883l.c
@@ -0,0 +1,486 @@
+// I2Cdev library collection - HMC5883L I2C device class
+// Based on Honeywell HMC5883L datasheet, 10/2010 (Form #900405 Rev B)
+// 6/12/2012 by Jeff Rowberg <[email protected]>
+// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
+
+/* ============================================
+ I2Cdev device library code is placed under the MIT license
+ Copyright (c) 2012 Jeff Rowberg
+ Adapted to Crazyflie FW by Bitcraze
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ ===============================================
+ */
+
+
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+
+#include "eprintf.h"
+#include "hmc5883l.h"
+#include "i2cdev.h"
+#define DEBUG_MODULE "HMC5883L"
+#include "debug_cf.h"
+
+static uint8_t devAddr;
+static uint8_t buffer[6];
+static uint8_t mode;
+static I2C_Dev *I2Cx;
+static bool isInit;
+
+/** Power on and prepare for general usage.
+ * This will prepare the magnetometer with default settings, ready for single-
+ * use mode (very low power requirements). Default settings include 8-sample
+ * averaging, 15 Hz data output rate, normal measurement bias, a,d 1090 gain (in
+ * terms of LSB/Gauss). Be sure to adjust any settings you need specifically
+ * after initialization, especially the gain settings if you happen to be seeing
+ * a lot of -4096 values (see the datasheet for mor information).
+ */
+void hmc5883lInit(I2C_Dev *i2cPort)
+{
+ if (isInit) {
+ return;
+ }
+
+ I2Cx = i2cPort;
+ devAddr = HMC5883L_ADDRESS;
+
+ // write CONFIG_A register
+ i2cdevWriteByte(I2Cx, devAddr, HMC5883L_RA_CONFIG_A,
+ (HMC5883L_AVERAGING_8 << (HMC5883L_CRA_AVERAGE_BIT - HMC5883L_CRA_AVERAGE_LENGTH + 1)) |
+ (HMC5883L_RATE_15 << (HMC5883L_CRA_RATE_BIT - HMC5883L_CRA_RATE_LENGTH + 1)) |
+ (HMC5883L_BIAS_NORMAL << (HMC5883L_CRA_BIAS_BIT - HMC5883L_CRA_BIAS_LENGTH + 1))); //配置信息:采样率15hz,每次结果来自8次采样,不进行校准
+
+ // write CONFIG_B register
+ hmc5883lSetGain(HMC5883L_GAIN_660); //测量范围 +-2.5Ga
+
+ isInit = true;
+}
+
+/** Verify the I2C connection.
+ * Make sure the device is connected and responds as expected.
+ * @return True if connection is valid, false otherwise
+ */
+bool hmc5883lTestConnection()
+{
+ if (i2cdevReadReg8(I2Cx, devAddr, HMC5883L_RA_ID_A, 3, buffer)) {
+ return (buffer[0] == 'H' && buffer[1] == '4' && buffer[2] == '3');
+ }
+
+ return false;
+}
+
+/** Do a self test.
+ * @return True if self test passed, false otherwise
+ */
+bool hmc5883lSelfTest()
+{
+ bool testStatus = true;
+ int16_t mxp, myp, mzp; // positive magnetometer measurements
+ int16_t mxn, myn, mzn; // negative magnetometer measurements
+ struct {
+ uint8_t configA;
+ uint8_t configB;
+ uint8_t mode;
+ } regSave;
+
+ // Save register values
+ if (i2cdevReadReg8(I2Cx, devAddr, HMC5883L_RA_CONFIG_A, sizeof(regSave), (uint8_t *)&regSave) == false) {
+ // TODO: error handling
+ return false;
+ }
+
+ // Set gain (sensitivity)
+ hmc5883lSetGain(HMC5883L_ST_GAIN);
+
+ // Write CONFIG_A register and do positive test
+ i2cdevWriteByte(I2Cx, devAddr, HMC5883L_RA_CONFIG_A,
+ (HMC5883L_AVERAGING_1 << (HMC5883L_CRA_AVERAGE_BIT - HMC5883L_CRA_AVERAGE_LENGTH + 1)) |
+ (HMC5883L_RATE_15 << (HMC5883L_CRA_RATE_BIT - HMC5883L_CRA_RATE_LENGTH + 1)) |
+ (HMC5883L_BIAS_POSITIVE << (HMC5883L_CRA_BIAS_BIT - HMC5883L_CRA_BIAS_LENGTH + 1)));
+
+ /* Perform test measurement & check results */
+ hmc5883lSetMode(HMC5883L_MODE_SINGLE);
+ vTaskDelay(M2T(HMC5883L_ST_DELAY_MS));
+ hmc5883lGetHeading(&mxp, &myp, &mzp);
+
+ // Write CONFIG_A register and do negative test
+ i2cdevWriteByte(I2Cx, devAddr, HMC5883L_RA_CONFIG_A,
+ (HMC5883L_AVERAGING_1 << (HMC5883L_CRA_AVERAGE_BIT - HMC5883L_CRA_AVERAGE_LENGTH + 1)) |
+ (HMC5883L_RATE_15 << (HMC5883L_CRA_RATE_BIT - HMC5883L_CRA_RATE_LENGTH + 1)) |
+ (HMC5883L_BIAS_NEGATIVE << (HMC5883L_CRA_BIAS_BIT - HMC5883L_CRA_BIAS_LENGTH + 1)));
+
+ /* Perform test measurement & check results */
+ hmc5883lSetMode(HMC5883L_MODE_SINGLE);
+ vTaskDelay(M2T(HMC5883L_ST_DELAY_MS));
+ hmc5883lGetHeading(&mxn, &myn, &mzn);
+
+ if (hmc5883lEvaluateSelfTest(HMC5883L_ST_X_MIN, HMC5883L_ST_X_MAX, mxp, "pos X") &&
+ hmc5883lEvaluateSelfTest(HMC5883L_ST_Y_MIN, HMC5883L_ST_Y_MAX, myp, "pos Y") &&
+ hmc5883lEvaluateSelfTest(HMC5883L_ST_Z_MIN, HMC5883L_ST_Z_MAX, mzp, "pos Z") &&
+ hmc5883lEvaluateSelfTest(-HMC5883L_ST_X_MAX, -HMC5883L_ST_X_MIN, mxn, "neg X") &&
+ hmc5883lEvaluateSelfTest(-HMC5883L_ST_Y_MAX, -HMC5883L_ST_Y_MIN, myn, "neg Y") &&
+ hmc5883lEvaluateSelfTest(-HMC5883L_ST_Z_MAX, -HMC5883L_ST_Z_MIN, mzn, "neg Z")) {
+ DEBUG_PRINTD("hmc5883l Self test [OK].\n");
+ } else {
+ testStatus = false;
+ }
+
+ // Restore registers
+ if (i2cdevWriteReg8(I2Cx, devAddr, HMC5883L_RA_CONFIG_A, sizeof(regSave), (uint8_t *)&regSave) == false) {
+ // TODO: error handling
+ return false;
+ }
+
+ return testStatus;
+}
+
+/** Evaluate the values from a HMC8335L self test.
+ * @param min The min limit of the self test
+ * @param max The max limit of the self test
+ * @param value The value to compare with.
+ * @param string A pointer to a string describing the value.
+ * @return True if self test within min - max limit, false otherwise
+ */
+bool hmc5883lEvaluateSelfTest(int16_t min, int16_t max, int16_t value, char *string)
+{
+ if (value < min || value > max) {
+ DEBUG_PRINTD("Self test %s [FAIL]. low: %d, high: %d, measured: %d\n",
+ string, min, max, value);
+ return false;
+ }
+
+ return true;
+}
+
+// CONFIG_A register
+
+/** Get number of samples averaged per measurement.
+ * @return Current samples averaged per measurement (0-3 for 1/2/4/8 respectively)
+ * @see HMC5883L_AVERAGING_8
+ * @see HMC5883L_RA_CONFIG_A
+ * @see HMC5883L_CRA_AVERAGE_BIT
+ * @see HMC5883L_CRA_AVERAGE_LENGTH
+ */
+uint8_t hmc5883lGetSampleAveraging()
+{
+ i2cdevReadBits(I2Cx, devAddr, HMC5883L_RA_CONFIG_A, HMC5883L_CRA_AVERAGE_BIT, HMC5883L_CRA_AVERAGE_LENGTH, buffer);
+ return buffer[0];
+}
+/** Set number of samples averaged per measurement.
+ * @param averaging New samples averaged per measurement setting(0-3 for 1/2/4/8 respectively)
+ * @see HMC5883L_RA_CONFIG_A
+ * @see HMC5883L_CRA_AVERAGE_BIT
+ * @see HMC5883L_CRA_AVERAGE_LENGTH
+ */
+void hmc5883lSetSampleAveraging(uint8_t averaging)
+{
+ i2cdevWriteBits(I2Cx, devAddr, HMC5883L_RA_CONFIG_A, HMC5883L_CRA_AVERAGE_BIT, HMC5883L_CRA_AVERAGE_LENGTH, averaging);
+}
+/** Get data output rate value.
+ * The Table below shows all selectable output rates in continuous measurement
+ * mode. All three channels shall be measured within a given output rate. Other
+ * output rates with maximum rate of 160 Hz can be achieved by monitoring DRDY
+ * interrupt pin in single measurement mode.
+ *
+ * Value | Typical Data Output Rate (Hz)
+ * ------+------------------------------
+ * 0 | 0.75
+ * 1 | 1.5
+ * 2 | 3
+ * 3 | 7.5
+ * 4 | 15 (Default)
+ * 5 | 30
+ * 6 | 75
+ * 7 | Not used
+ *
+ * @return Current rate of data output to registers
+ * @see HMC5883L_RATE_15
+ * @see HMC5883L_RA_CONFIG_A
+ * @see HMC5883L_CRA_RATE_BIT
+ * @see HMC5883L_CRA_RATE_LENGTH
+ */
+uint8_t hmc5883lGetDataRate()
+{
+ i2cdevReadBits(I2Cx, devAddr, HMC5883L_RA_CONFIG_A, HMC5883L_CRA_RATE_BIT, HMC5883L_CRA_RATE_LENGTH, buffer);
+ return buffer[0];
+}
+/** Set data output rate value.
+ * @param rate Rate of data output to registers
+ * @see getDataRate()
+ * @see HMC5883L_RATE_15
+ * @see HMC5883L_RA_CONFIG_A
+ * @see HMC5883L_CRA_RATE_BIT
+ * @see HMC5883L_CRA_RATE_LENGTH
+ */
+void hmc5883lSetDataRate(uint8_t rate)
+{
+ i2cdevWriteBits(I2Cx, devAddr, HMC5883L_RA_CONFIG_A, HMC5883L_CRA_RATE_BIT, HMC5883L_CRA_RATE_LENGTH, rate);
+}
+/** Get measurement bias value.
+ * @return Current bias value (0-2 for normal/positive/negative respectively)
+ * @see HMC5883L_BIAS_NORMAL
+ * @see HMC5883L_RA_CONFIG_A
+ * @see HMC5883L_CRA_BIAS_BIT
+ * @see HMC5883L_CRA_BIAS_LENGTH
+ */
+uint8_t hmc5883lGetMeasurementBias()
+{
+ i2cdevReadBits(I2Cx, devAddr, HMC5883L_RA_CONFIG_A, HMC5883L_CRA_BIAS_BIT, HMC5883L_CRA_BIAS_LENGTH, buffer);
+ return buffer[0];
+}
+/** Set measurement bias value.
+ * @param bias New bias value (0-2 for normal/positive/negative respectively)
+ * @see HMC5883L_BIAS_NORMAL
+ * @see HMC5883L_RA_CONFIG_A
+ * @see HMC5883L_CRA_BIAS_BIT
+ * @see HMC5883L_CRA_BIAS_LENGTH
+ */
+void hmc5883lSetMeasurementBias(uint8_t bias)
+{
+ i2cdevWriteBits(I2Cx, devAddr, HMC5883L_RA_CONFIG_A, HMC5883L_CRA_BIAS_BIT, HMC5883L_CRA_BIAS_LENGTH, bias);
+}
+
+// CONFIG_B register
+
+/** Get magnetic field gain value.
+ * The table below shows nominal gain settings. Use the "Gain" column to convert
+ * counts to Gauss. Choose a lower gain value (higher GN#) when total field
+ * strength causes overflow in one of the data output registers (saturation).
+ * The data output range for all settings is 0xF800-0x07FF (-2048 - 2047).
+ *
+ * Value | Field Range | Gain (LSB/Gauss)
+ * ------+-------------+-----------------
+ * 0 | +/- 0.88 Ga | 1370
+ * 1 | +/- 1.3 Ga | 1090 (Default)
+ * 2 | +/- 1.9 Ga | 820
+ * 3 | +/- 2.5 Ga | 660
+ * 4 | +/- 4.0 Ga | 440
+ * 5 | +/- 4.7 Ga | 390
+ * 6 | +/- 5.6 Ga | 330
+ * 7 | +/- 8.1 Ga | 230
+ *
+ * @return Current magnetic field gain value
+ * @see HMC5883L_GAIN_1090
+ * @see HMC5883L_RA_CONFIG_B
+ * @see HMC5883L_CRB_GAIN_BIT
+ * @see HMC5883L_CRB_GAIN_LENGTH
+ */
+uint8_t hmc5883lGetGain()
+{
+ i2cdevReadBits(I2Cx, devAddr, HMC5883L_RA_CONFIG_B, HMC5883L_CRB_GAIN_BIT, HMC5883L_CRB_GAIN_LENGTH, buffer);
+ return buffer[0];
+}
+/** Set magnetic field gain value.
+ * @param gain New magnetic field gain value
+ * @see getGain()
+ * @see HMC5883L_RA_CONFIG_B
+ * @see HMC5883L_CRB_GAIN_BIT
+ * @see HMC5883L_CRB_GAIN_LENGTH
+ */
+void hmc5883lSetGain(uint8_t gain)
+{
+ // use this method to guarantee that bits 4-0 are set to zero, which is a
+ // requirement specified in the datasheet; it's actually more efficient than
+ // using the I2Cdev.writeBits method
+ i2cdevWriteByte(I2Cx, devAddr, HMC5883L_RA_CONFIG_B, gain << (HMC5883L_CRB_GAIN_BIT - HMC5883L_CRB_GAIN_LENGTH + 1));
+}
+
+// MODE register
+
+/** Get measurement mode.
+ * In continuous-measurement mode, the device continuously performs measurements
+ * and places the result in the data register. RDY goes high when new data is
+ * placed in all three registers. After a power-on or a write to the mode or
+ * configuration register, the first measurement set is available from all three
+ * data output registers after a period of 2/fDO and subsequent measurements are
+ * available at a frequency of fDO, where fDO is the frequency of data output.
+ *
+ * When single-measurement mode (default) is selected, device performs a single
+ * measurement, sets RDY high and returned to idle mode. Mode register returns
+ * to idle mode bit values. The measurement remains in the data output register
+ * and RDY remains high until the data output register is read or another
+ * measurement is performed.
+ *
+ * @return Current measurement mode
+ * @see HMC5883L_MODE_CONTINUOUS
+ * @see HMC5883L_MODE_SINGLE
+ * @see HMC5883L_MODE_IDLE
+ * @see HMC5883L_RA_MODE
+ * @see HMC5883L_MODEREG_BIT
+ * @see HMC5883L_MODEREG_LENGTH
+ */
+uint8_t hmc5883lGetMode()
+{
+ i2cdevReadBits(I2Cx, devAddr, HMC5883L_RA_MODE, HMC5883L_MODEREG_BIT, HMC5883L_MODEREG_LENGTH, buffer);
+ return buffer[0];
+}
+/** Set measurement mode.
+ * @param newMode New measurement mode
+ * @see getMode()
+ * @see HMC5883L_MODE_CONTINUOUS
+ * @see HMC5883L_MODE_SINGLE
+ * @see HMC5883L_MODE_IDLE
+ * @see HMC5883L_RA_MODE
+ * @see HMC5883L_MODEREG_BIT
+ * @see HMC5883L_MODEREG_LENGTH
+ */
+void hmc5883lSetMode(uint8_t newMode)
+{
+ // use this method to guarantee that bits 7-2 are set to zero, which is a
+ // requirement specified in the datasheet; it's actually more efficient than
+ // using the I2Cdev.writeBits method
+ i2cdevWriteByte(I2Cx, devAddr, HMC5883L_RA_MODE, mode << (HMC5883L_MODEREG_BIT - HMC5883L_MODEREG_LENGTH + 1));
+ mode = newMode;// track to tell if we have to clear bit 7 after a read
+}
+
+// DATA* registers
+
+/** Get 3-axis heading measurements.
+ * In the event the ADC reading overflows or underflows for the given channel,
+ * or if there is a math overflow during the bias measurement, this data
+ * register will contain the value -4096. This register value will clear when
+ * after the next valid measurement is made. Note that this method automatically
+ * clears the appropriate bit in the MODE register if Single mode is active.
+ * @param x 16-bit signed integer container for X-axis heading
+ * @param y 16-bit signed integer container for Y-axis heading
+ * @param z 16-bit signed integer container for Z-axis heading
+ * @see HMC5883L_RA_DATAX_H
+ */
+void hmc5883lGetHeading(int16_t *x, int16_t *y, int16_t *z)
+{
+ i2cdevReadReg8(I2Cx, devAddr, HMC5883L_RA_DATAX_H, 6, buffer);
+
+ if (mode == HMC5883L_MODE_SINGLE) {
+ i2cdevWriteByte(I2Cx, devAddr, HMC5883L_RA_MODE, HMC5883L_MODE_SINGLE << (HMC5883L_MODEREG_BIT - HMC5883L_MODEREG_LENGTH + 1));
+ }
+
+ *x = (((int16_t)buffer[0]) << 8) | buffer[1];
+ *y = (((int16_t)buffer[4]) << 8) | buffer[5];
+ *z = (((int16_t)buffer[2]) << 8) | buffer[3];
+}
+/** Get X-axis heading measurement.
+ * @return 16-bit signed integer with X-axis heading
+ * @see HMC5883L_RA_DATAX_H
+ */
+int16_t hmc5883lGetHeadingX()
+{
+ // each axis read requires that ALL axis registers be read, even if only
+ // one is used; this was not done ineffiently in the code by accident
+ i2cdevReadReg8(I2Cx, devAddr, HMC5883L_RA_DATAX_H, 6, buffer);
+
+ if (mode == HMC5883L_MODE_SINGLE) {
+ i2cdevWriteByte(I2Cx, devAddr, HMC5883L_RA_MODE, HMC5883L_MODE_SINGLE << (HMC5883L_MODEREG_BIT - HMC5883L_MODEREG_LENGTH + 1));
+ }
+
+ return (((int16_t)buffer[0]) << 8) | buffer[1];
+}
+/** Get Y-axis heading measurement.
+ * @return 16-bit signed integer with Y-axis heading
+ * @see HMC5883L_RA_DATAY_H
+ */
+int16_t hmc5883lGetHeadingY()
+{
+ // each axis read requires that ALL axis registers be read, even if only
+ // one is used; this was not done ineffiently in the code by accident
+ i2cdevReadReg8(I2Cx, devAddr, HMC5883L_RA_DATAX_H, 6, buffer);
+
+ if (mode == HMC5883L_MODE_SINGLE) {
+ i2cdevWriteByte(I2Cx, devAddr, HMC5883L_RA_MODE, HMC5883L_MODE_SINGLE << (HMC5883L_MODEREG_BIT - HMC5883L_MODEREG_LENGTH + 1));
+ }
+
+ return (((int16_t)buffer[4]) << 8) | buffer[5];
+}
+/** Get Z-axis heading measurement.
+ * @return 16-bit signed integer with Z-axis heading
+ * @see HMC5883L_RA_DATAZ_H
+ */
+int16_t hmc5883lGetHeadingZ()
+{
+ // each axis read requires that ALL axis registers be read, even if only
+ // one is used; this was not done ineffiently in the code by accident
+ i2cdevReadReg8(I2Cx, devAddr, HMC5883L_RA_DATAX_H, 6, buffer);
+
+ if (mode == HMC5883L_MODE_SINGLE) {
+ i2cdevWriteByte(I2Cx, devAddr, HMC5883L_RA_MODE, HMC5883L_MODE_SINGLE << (HMC5883L_MODEREG_BIT - HMC5883L_MODEREG_LENGTH + 1));
+ }
+
+ return (((int16_t)buffer[2]) << 8) | buffer[3];
+}
+
+// STATUS register
+
+/** Get data output register lock status.
+ * This bit is set when this some but not all for of the six data output
+ * registers have been read. When this bit is set, the six data output registers
+ * are locked and any new data will not be placed in these register until one of
+ * three conditions are met: one, all six bytes have been read or the mode
+ * changed, two, the mode is changed, or three, the measurement configuration is
+ * changed.
+ * @return Data output register lock status
+ * @see HMC5883L_RA_STATUS
+ * @see HMC5883L_STATUS_LOCK_BIT
+ */
+bool hmc5883lGetLockStatus()
+{
+ i2cdevReadBit(I2Cx, devAddr, HMC5883L_RA_STATUS, HMC5883L_STATUS_LOCK_BIT, buffer);
+ return buffer[0];
+}
+/** Get data ready status.
+ * This bit is set when data is written to all six data registers, and cleared
+ * when the device initiates a write to the data output registers and after one
+ * or more of the data output registers are written to. When RDY bit is clear it
+ * shall remain cleared for 250 us. DRDY pin can be used as an alternative to
+ * the status register for monitoring the device for measurement data.
+ * @return Data ready status
+ * @see HMC5883L_RA_STATUS
+ * @see HMC5883L_STATUS_READY_BIT
+ */
+bool hmc5883lGetReadyStatus()
+{
+ i2cdevReadBit(I2Cx, devAddr, HMC5883L_RA_STATUS, HMC5883L_STATUS_READY_BIT, buffer);
+ return buffer[0];
+}
+
+// ID_* registers
+
+/** Get identification byte A
+ * @return ID_A byte (should be 01001000, ASCII value 'H')
+ */
+uint8_t hmc5883lGetIDA()
+{
+ i2cdevReadByte(I2Cx, devAddr, HMC5883L_RA_ID_A, buffer);
+ return buffer[0];
+}
+/** Get identification byte B
+ * @return ID_A byte (should be 00110100, ASCII value '4')
+ */
+uint8_t hmc5883lGetIDB()
+{
+ i2cdevReadByte(I2Cx, devAddr, HMC5883L_RA_ID_B, buffer);
+ return buffer[0];
+}
+/** Get identification byte C
+ * @return ID_A byte (should be 00110011, ASCII value '3')
+ */
+uint8_t hmc5883lGetIDC()
+{
+ i2cdevReadByte(I2Cx, devAddr, HMC5883L_RA_ID_C, buffer);
+ return buffer[0];
+}
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/hmc5883l/include/hmc5883l.h b/Firmware/esp-drone/components/drivers/i2c_devices/hmc5883l/include/hmc5883l.h
new file mode 100644
index 0000000..ccb4ab5
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/hmc5883l/include/hmc5883l.h
@@ -0,0 +1,149 @@
+// I2Cdev library collection - HMC5883L I2C device class header file
+// Based on Honeywell HMC5883L datasheet, 10/2010 (Form #900405 Rev B)
+// 6/12/2012 by Jeff Rowberg <[email protected]>
+// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
+
+/* ============================================
+I2Cdev device library code is placed under the MIT license
+Copyright (c) 2011 Jeff Rowberg
+Adapted to Crazyflie FW by Bitcraze
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+===============================================
+*/
+
+#ifndef HMC5883L_H_
+#define HMC5883L_H_
+#include <stdbool.h>
+#include "i2cdev.h"
+
+#define HMC5883L_ADDRESS 0x1E // this device only has one address
+#define HMC5883L_DEFAULT_ADDRESS 0x1E
+
+#define HMC5883L_RA_CONFIG_A 0x00
+#define HMC5883L_RA_CONFIG_B 0x01
+#define HMC5883L_RA_MODE 0x02
+#define HMC5883L_RA_DATAX_H 0x03
+#define HMC5883L_RA_DATAX_L 0x04
+#define HMC5883L_RA_DATAZ_H 0x05
+#define HMC5883L_RA_DATAZ_L 0x06
+#define HMC5883L_RA_DATAY_H 0x07
+#define HMC5883L_RA_DATAY_L 0x08
+#define HMC5883L_RA_STATUS 0x09
+#define HMC5883L_RA_ID_A 0x0A
+#define HMC5883L_RA_ID_B 0x0B
+#define HMC5883L_RA_ID_C 0x0C
+
+#define HMC5883L_CRA_AVERAGE_BIT 6
+#define HMC5883L_CRA_AVERAGE_LENGTH 2
+#define HMC5883L_CRA_RATE_BIT 4
+#define HMC5883L_CRA_RATE_LENGTH 3
+#define HMC5883L_CRA_BIAS_BIT 1
+#define HMC5883L_CRA_BIAS_LENGTH 2
+
+#define HMC5883L_AVERAGING_1 0x00
+#define HMC5883L_AVERAGING_2 0x01
+#define HMC5883L_AVERAGING_4 0x02
+#define HMC5883L_AVERAGING_8 0x03
+
+#define HMC5883L_RATE_0P75 0x00
+#define HMC5883L_RATE_1P5 0x01
+#define HMC5883L_RATE_3 0x02
+#define HMC5883L_RATE_7P5 0x03
+#define HMC5883L_RATE_15 0x04
+#define HMC5883L_RATE_30 0x05
+#define HMC5883L_RATE_75 0x06
+
+#define HMC5883L_BIAS_NORMAL 0x00
+#define HMC5883L_BIAS_POSITIVE 0x01
+#define HMC5883L_BIAS_NEGATIVE 0x02
+
+#define HMC5883L_CRB_GAIN_BIT 7
+#define HMC5883L_CRB_GAIN_LENGTH 3
+
+#define HMC5883L_GAIN_1370 0x00
+#define HMC5883L_GAIN_1090 0x01
+#define HMC5883L_GAIN_820 0x02
+#define HMC5883L_GAIN_660 0x03
+#define HMC5883L_GAIN_440 0x04
+#define HMC5883L_GAIN_390 0x05
+#define HMC5883L_GAIN_330 0x06
+#define HMC5883L_GAIN_220 0x07
+
+#define HMC5883L_MODEREG_BIT 1
+#define HMC5883L_MODEREG_LENGTH 2
+
+#define HMC5883L_MODE_CONTINUOUS 0x00
+#define HMC5883L_MODE_SINGLE 0x01
+#define HMC5883L_MODE_IDLE 0x02
+
+#define HMC5883L_STATUS_LOCK_BIT 1
+#define HMC5883L_STATUS_READY_BIT 0
+
+#define HMC5883L_ST_GAIN HMC5883L_GAIN_440 // Gain value during self-test
+#define HMC5883L_ST_GAIN_NBR 440
+#define HMC5883L_ST_ERROR 0.2 // Max error
+#define HMC5883L_ST_DELAY_MS 250 // delay in millisec during self test */
+#define HMC5883L_ST_X_NORM (int32_t)(1.16 * HMC5883L_ST_GAIN_NBR)
+#define HMC5883L_ST_X_MIN (int32_t)(HMC5883L_ST_X_NORM - (HMC5883L_ST_X_NORM * HMC5883L_ST_ERROR))
+#define HMC5883L_ST_X_MAX (int32_t)(HMC5883L_ST_X_NORM + (HMC5883L_ST_X_NORM * HMC5883L_ST_ERROR))
+#define HMC5883L_ST_Y_NORM (int32_t)(1.16 * HMC5883L_ST_GAIN_NBR)
+#define HMC5883L_ST_Y_MIN (int32_t)(HMC5883L_ST_Y_NORM - (HMC5883L_ST_Y_NORM * HMC5883L_ST_ERROR))
+#define HMC5883L_ST_Y_MAX (int32_t)(HMC5883L_ST_Y_NORM + (HMC5883L_ST_Y_NORM * HMC5883L_ST_ERROR))
+#define HMC5883L_ST_Z_NORM (int32_t)(1.08 * HMC5883L_ST_GAIN_NBR)
+#define HMC5883L_ST_Z_MIN (int32_t)(HMC5883L_ST_Z_NORM - (HMC5883L_ST_Z_NORM * HMC5883L_ST_ERROR))
+#define HMC5883L_ST_Z_MAX (int32_t)(HMC5883L_ST_Z_NORM + (HMC5883L_ST_Z_NORM * HMC5883L_ST_ERROR))
+
+void hmc5883lInit(I2C_Dev *i2cPort);
+bool hmc5883lTestConnection();
+bool hmc5883lSelfTest();
+bool hmc5883lEvaluateSelfTest(int16_t min, int16_t max, int16_t value, char *string);
+
+// CONFIG_A register
+uint8_t hmc5883lGetSampleAveraging();
+void hmc5883lSetSampleAveraging(uint8_t averaging);
+uint8_t hmc5883lGetDataRate();
+void hmc5883lSetDataRate(uint8_t rate);
+uint8_t hmc5883lGetMeasurementBias();
+void hmc5883lSetMeasurementBias(uint8_t bias);
+
+// CONFIG_B register
+uint8_t hmc5883lGetGain();
+void hmc5883lSetGain(uint8_t gain);
+
+// MODE register
+uint8_t hmc5883lGetMode();
+void hmc5883lSetMode(uint8_t mode);
+
+// DATA* registers
+void hmc5883lGetHeading(int16_t *x, int16_t *y, int16_t *z);
+int16_t hmc5883lGetHeadingX();
+int16_t hmc5883lGetHeadingY();
+int16_t hmc5883lGetHeadingZ();
+
+// STATUS register
+bool hmc5883lGetLockStatus();
+bool hmc5883lGetReadyStatus();
+
+// ID_* registers
+uint8_t hmc5883lGetIDA();
+uint8_t hmc5883lGetIDB();
+uint8_t hmc5883lGetIDC();
+
+#endif /* HMC5883L_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/mpu6050/CMakeLists.txt b/Firmware/esp-drone/components/drivers/i2c_devices/mpu6050/CMakeLists.txt
new file mode 100644
index 0000000..b0484a5
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/mpu6050/CMakeLists.txt
@@ -0,0 +1,4 @@
+idf_component_register(SRCS "mpu6050.c"
+ INCLUDE_DIRS "include"
+ REQUIRES i2c_bus
+ PRIV_REQUIRES crazyflie platform config)
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/mpu6050/include/mpu6050.h b/Firmware/esp-drone/components/drivers/i2c_devices/mpu6050/include/mpu6050.h
new file mode 100644
index 0000000..0f14292
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/mpu6050/include/mpu6050.h
@@ -0,0 +1,1009 @@
+// I2Cdev library collection - MPU6050 I2C device class
+// Based on InvenSense MPU-6050 register map document rev. 2.0, 5/19/2011 (RM-MPU-6000A-00)
+// 10/3/2011 by Jeff Rowberg <[email protected]>
+// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
+
+/* ============================================
+I2Cdev device library code is placed under the MIT license
+Copyright (c) 2011 Jeff Rowberg
+Adapted to Crazyflie FW by Bitcraze
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+===============================================
+*/
+
+#ifndef _MPU6050_H_
+#define _MPU6050_H_
+
+#include "i2cdev.h"
+
+#define MPU6050_ADDRESS_AD0_LOW 0x68 // address pin low (GND), default for InvenSense evaluation board
+#define MPU6050_ADDRESS_AD0_HIGH 0x69 // address pin high (VCC)
+#define MPU6050_DEFAULT_ADDRESS MPU6050_ADDRESS_AD0_LOW
+#define MPU6050_SELF_TEST_DELAY_MS 10
+
+//Product ID Description for MPU6050: | High 4 bits | Low 4 bits |
+// | Product Name | Product Revision |
+#define MPU6050_REV_C4_ES 0x14 // 0001 0100
+#define MPU6050_REV_C5_ES 0x15 // 0001 0101
+#define MPU6050_REV_D6_ES 0x16 // 0001 0110
+#define MPU6050_REV_D7_ES 0x17 // 0001 0111
+#define MPU6050_REV_D8_ES 0x18 // 0001 1000
+#define MPU6050_REV_C4 0x54 // 0101 0100
+#define MPU6050_REV_C5 0x55 // 0101 0101
+#define MPU6050_REV_D6 0x56 // 0101 0110
+#define MPU6050_REV_D7 0x57 // 0101 0111
+#define MPU6050_REV_D8 0x58 // 0101 1000
+#define MPU6050_REV_D9 0x59 // 0101 1001
+
+#define MPU6050_RA_XG_OFFS_TC 0x00 //[7] PWR_MODE, [6:1] XG_OFFS_TC, [0] OTP_BNK_VLD
+#define MPU6050_RA_YG_OFFS_TC 0x01 //[7] PWR_MODE, [6:1] YG_OFFS_TC, [0] OTP_BNK_VLD
+#define MPU6050_RA_ZG_OFFS_TC 0x02 //[7] PWR_MODE, [6:1] ZG_OFFS_TC, [0] OTP_BNK_VLD
+#define MPU6050_RA_X_FINE_GAIN 0x03 //[7:0] X_FINE_GAIN
+#define MPU6050_RA_Y_FINE_GAIN 0x04 //[7:0] Y_FINE_GAIN
+#define MPU6050_RA_Z_FINE_GAIN 0x05 //[7:0] Z_FINE_GAIN
+#define MPU6050_RA_XA_OFFS_H 0x06 //[15:0] XA_OFFS
+#define MPU6050_RA_XA_OFFS_L_TC 0x07
+#define MPU6050_RA_YA_OFFS_H 0x08 //[15:0] YA_OFFS
+#define MPU6050_RA_YA_OFFS_L_TC 0x09
+#define MPU6050_RA_ZA_OFFS_H 0x0A //[15:0] ZA_OFFS
+#define MPU6050_RA_ZA_OFFS_L_TC 0x0B
+#define MPU6050_RA_PRODUCT_ID 0x0C
+#define MPU6050_RA_XG_OFFS_USRH 0x13 //[15:0] XG_OFFS_USR
+#define MPU6050_RA_XG_OFFS_USRL 0x14
+#define MPU6050_RA_YG_OFFS_USRH 0x15 //[15:0] YG_OFFS_USR
+#define MPU6050_RA_YG_OFFS_USRL 0x16
+#define MPU6050_RA_ZG_OFFS_USRH 0x17 //[15:0] ZG_OFFS_USR
+#define MPU6050_RA_ZG_OFFS_USRL 0x18
+#define MPU6050_RA_SMPLRT_DIV 0x19
+#define MPU6050_RA_CONFIG 0x1A
+#define MPU6050_RA_GYRO_CONFIG 0x1B
+#define MPU6050_RA_ACCEL_CONFIG 0x1C
+#define MPU6050_RA_FF_THR 0x1D
+#define MPU6050_RA_FF_DUR 0x1E
+#define MPU6050_RA_MOT_THR 0x1F
+#define MPU6050_RA_MOT_DUR 0x20
+#define MPU6050_RA_ZRMOT_THR 0x21
+#define MPU6050_RA_ZRMOT_DUR 0x22
+#define MPU6050_RA_FIFO_EN 0x23
+#define MPU6050_RA_I2C_MST_CTRL 0x24
+#define MPU6050_RA_I2C_SLV0_ADDR 0x25
+#define MPU6050_RA_I2C_SLV0_REG 0x26
+#define MPU6050_RA_I2C_SLV0_CTRL 0x27
+#define MPU6050_RA_I2C_SLV1_ADDR 0x28
+#define MPU6050_RA_I2C_SLV1_REG 0x29
+#define MPU6050_RA_I2C_SLV1_CTRL 0x2A
+#define MPU6050_RA_I2C_SLV2_ADDR 0x2B
+#define MPU6050_RA_I2C_SLV2_REG 0x2C
+#define MPU6050_RA_I2C_SLV2_CTRL 0x2D
+#define MPU6050_RA_I2C_SLV3_ADDR 0x2E
+#define MPU6050_RA_I2C_SLV3_REG 0x2F
+#define MPU6050_RA_I2C_SLV3_CTRL 0x30
+#define MPU6050_RA_I2C_SLV4_ADDR 0x31
+#define MPU6050_RA_I2C_SLV4_REG 0x32
+#define MPU6050_RA_I2C_SLV4_DO 0x33
+#define MPU6050_RA_I2C_SLV4_CTRL 0x34
+#define MPU6050_RA_I2C_SLV4_DI 0x35
+#define MPU6050_RA_I2C_MST_STATUS 0x36
+#define MPU6050_RA_INT_PIN_CFG 0x37
+#define MPU6050_RA_INT_ENABLE 0x38
+#define MPU6050_RA_DMP_INT_STATUS 0x39
+#define MPU6050_RA_INT_STATUS 0x3A
+#define MPU6050_RA_ACCEL_XOUT_H 0x3B
+#define MPU6050_RA_ACCEL_XOUT_L 0x3C
+#define MPU6050_RA_ACCEL_YOUT_H 0x3D
+#define MPU6050_RA_ACCEL_YOUT_L 0x3E
+#define MPU6050_RA_ACCEL_ZOUT_H 0x3F
+#define MPU6050_RA_ACCEL_ZOUT_L 0x40
+#define MPU6050_RA_TEMP_OUT_H 0x41
+#define MPU6050_RA_TEMP_OUT_L 0x42
+#define MPU6050_RA_GYRO_XOUT_H 0x43
+#define MPU6050_RA_GYRO_XOUT_L 0x44
+#define MPU6050_RA_GYRO_YOUT_H 0x45
+#define MPU6050_RA_GYRO_YOUT_L 0x46
+#define MPU6050_RA_GYRO_ZOUT_H 0x47
+#define MPU6050_RA_GYRO_ZOUT_L 0x48
+#define MPU6050_RA_EXT_SENS_DATA_00 0x49
+#define MPU6050_RA_EXT_SENS_DATA_01 0x4A
+#define MPU6050_RA_EXT_SENS_DATA_02 0x4B
+#define MPU6050_RA_EXT_SENS_DATA_03 0x4C
+#define MPU6050_RA_EXT_SENS_DATA_04 0x4D
+#define MPU6050_RA_EXT_SENS_DATA_05 0x4E
+#define MPU6050_RA_EXT_SENS_DATA_06 0x4F
+#define MPU6050_RA_EXT_SENS_DATA_07 0x50
+#define MPU6050_RA_EXT_SENS_DATA_08 0x51
+#define MPU6050_RA_EXT_SENS_DATA_09 0x52
+#define MPU6050_RA_EXT_SENS_DATA_10 0x53
+#define MPU6050_RA_EXT_SENS_DATA_11 0x54
+#define MPU6050_RA_EXT_SENS_DATA_12 0x55
+#define MPU6050_RA_EXT_SENS_DATA_13 0x56
+#define MPU6050_RA_EXT_SENS_DATA_14 0x57
+#define MPU6050_RA_EXT_SENS_DATA_15 0x58
+#define MPU6050_RA_EXT_SENS_DATA_16 0x59
+#define MPU6050_RA_EXT_SENS_DATA_17 0x5A
+#define MPU6050_RA_EXT_SENS_DATA_18 0x5B
+#define MPU6050_RA_EXT_SENS_DATA_19 0x5C
+#define MPU6050_RA_EXT_SENS_DATA_20 0x5D
+#define MPU6050_RA_EXT_SENS_DATA_21 0x5E
+#define MPU6050_RA_EXT_SENS_DATA_22 0x5F
+#define MPU6050_RA_EXT_SENS_DATA_23 0x60
+#define MPU6050_RA_MOT_DETECT_STATUS 0x61
+#define MPU6050_RA_I2C_SLV0_DO 0x63
+#define MPU6050_RA_I2C_SLV1_DO 0x64
+#define MPU6050_RA_I2C_SLV2_DO 0x65
+#define MPU6050_RA_I2C_SLV3_DO 0x66
+#define MPU6050_RA_I2C_MST_DELAY_CTRL 0x67
+#define MPU6050_RA_SIGNAL_PATH_RESET 0x68
+#define MPU6050_RA_MOT_DETECT_CTRL 0x69
+#define MPU6050_RA_USER_CTRL 0x6A
+#define MPU6050_RA_PWR_MGMT_1 0x6B
+#define MPU6050_RA_PWR_MGMT_2 0x6C
+#define MPU6050_RA_BANK_SEL 0x6D
+#define MPU6050_RA_MEM_START_ADDR 0x6E
+#define MPU6050_RA_MEM_R_W 0x6F
+#define MPU6050_RA_DMP_CFG_1 0x70
+#define MPU6050_RA_DMP_CFG_2 0x71
+#define MPU6050_RA_FIFO_COUNTH 0x72
+#define MPU6050_RA_FIFO_COUNTL 0x73
+#define MPU6050_RA_FIFO_R_W 0x74
+#define MPU6050_RA_WHO_AM_I 0x75
+
+#define MPU6050_TC_PWR_MODE_BIT 7
+#define MPU6050_TC_OFFSET_BIT 6
+#define MPU6050_TC_OFFSET_LENGTH 6
+#define MPU6050_TC_OTP_BNK_VLD_BIT 0
+
+#define MPU6050_VDDIO_LEVEL_VLOGIC 0
+#define MPU6050_VDDIO_LEVEL_VDD 1
+
+#define MPU6050_CFG_EXT_SYNC_SET_BIT 5
+#define MPU6050_CFG_EXT_SYNC_SET_LENGTH 3
+#define MPU6050_CFG_DLPF_CFG_BIT 2
+#define MPU6050_CFG_DLPF_CFG_LENGTH 3
+
+#define MPU6050_EXT_SYNC_DISABLED 0x0
+#define MPU6050_EXT_SYNC_TEMP_OUT_L 0x1
+#define MPU6050_EXT_SYNC_GYRO_XOUT_L 0x2
+#define MPU6050_EXT_SYNC_GYRO_YOUT_L 0x3
+#define MPU6050_EXT_SYNC_GYRO_ZOUT_L 0x4
+#define MPU6050_EXT_SYNC_ACCEL_XOUT_L 0x5
+#define MPU6050_EXT_SYNC_ACCEL_YOUT_L 0x6
+#define MPU6050_EXT_SYNC_ACCEL_ZOUT_L 0x7
+
+#define MPU6050_DLPF_BW_256 0x00
+#define MPU6050_DLPF_BW_188 0x01
+#define MPU6050_DLPF_BW_98 0x02
+#define MPU6050_DLPF_BW_42 0x03
+#define MPU6050_DLPF_BW_20 0x04
+#define MPU6050_DLPF_BW_10 0x05
+#define MPU6050_DLPF_BW_5 0x06
+
+#define MPU6050_GCONFIG_XG_ST_BIT 7
+#define MPU6050_GCONFIG_YG_ST_BIT 6
+#define MPU6050_GCONFIG_ZG_ST_BIT 5
+#define MPU6050_GCONFIG_FS_SEL_BIT 4
+#define MPU6050_GCONFIG_FS_SEL_LENGTH 2
+
+
+#define MPU6050_GYRO_FS_250 0x00
+#define MPU6050_GYRO_FS_500 0x01
+#define MPU6050_GYRO_FS_1000 0x02
+#define MPU6050_GYRO_FS_2000 0x03
+
+#define MPU6050_ACONFIG_XA_ST_BIT 7
+#define MPU6050_ACONFIG_YA_ST_BIT 6
+#define MPU6050_ACONFIG_ZA_ST_BIT 5
+#define MPU6050_ACONFIG_AFS_SEL_BIT 4
+#define MPU6050_ACONFIG_AFS_SEL_LENGTH 2
+#define MPU6050_ACONFIG_ACCEL_HPF_BIT 2
+#define MPU6050_ACONFIG_ACCEL_HPF_LENGTH 3
+
+#define MPU6050_ACCEL_FS_2 0x00
+#define MPU6050_ACCEL_FS_4 0x01
+#define MPU6050_ACCEL_FS_8 0x02
+#define MPU6050_ACCEL_FS_16 0x03
+
+#define MPU6050_DHPF_RESET 0x00
+#define MPU6050_DHPF_5 0x01
+#define MPU6050_DHPF_2P5 0x02
+#define MPU6050_DHPF_1P25 0x03
+#define MPU6050_DHPF_0P63 0x04
+#define MPU6050_DHPF_HOLD 0x07
+
+#define MPU6050_TEMP_FIFO_EN_BIT 7
+#define MPU6050_XG_FIFO_EN_BIT 6
+#define MPU6050_YG_FIFO_EN_BIT 5
+#define MPU6050_ZG_FIFO_EN_BIT 4
+#define MPU6050_ACCEL_FIFO_EN_BIT 3
+#define MPU6050_SLV2_FIFO_EN_BIT 2
+#define MPU6050_SLV1_FIFO_EN_BIT 1
+#define MPU6050_SLV0_FIFO_EN_BIT 0
+
+#define MPU6050_MULT_MST_EN_BIT 7
+#define MPU6050_WAIT_FOR_ES_BIT 6
+#define MPU6050_SLV_3_FIFO_EN_BIT 5
+#define MPU6050_I2C_MST_P_NSR_BIT 4
+#define MPU6050_I2C_MST_CLK_BIT 3
+#define MPU6050_I2C_MST_CLK_LENGTH 4
+
+#define MPU6050_CLOCK_DIV_348 0x0
+#define MPU6050_CLOCK_DIV_333 0x1
+#define MPU6050_CLOCK_DIV_320 0x2
+#define MPU6050_CLOCK_DIV_308 0x3
+#define MPU6050_CLOCK_DIV_296 0x4
+#define MPU6050_CLOCK_DIV_286 0x5
+#define MPU6050_CLOCK_DIV_276 0x6
+#define MPU6050_CLOCK_DIV_267 0x7
+#define MPU6050_CLOCK_DIV_258 0x8
+#define MPU6050_CLOCK_DIV_500 0x9
+#define MPU6050_CLOCK_DIV_471 0xA
+#define MPU6050_CLOCK_DIV_444 0xB
+#define MPU6050_CLOCK_DIV_421 0xC
+#define MPU6050_CLOCK_DIV_400 0xD
+#define MPU6050_CLOCK_DIV_381 0xE
+#define MPU6050_CLOCK_DIV_364 0xF
+
+#define MPU6050_I2C_SLV_RW_BIT 7
+#define MPU6050_I2C_SLV_ADDR_BIT 6
+#define MPU6050_I2C_SLV_ADDR_LENGTH 7
+#define MPU6050_I2C_SLV_EN_BIT 7
+#define MPU6050_I2C_SLV_BYTE_SW_BIT 6
+#define MPU6050_I2C_SLV_REG_DIS_BIT 5
+#define MPU6050_I2C_SLV_GRP_BIT 4
+#define MPU6050_I2C_SLV_LEN_BIT 3
+#define MPU6050_I2C_SLV_LEN_LENGTH 4
+
+#define MPU6050_I2C_SLV4_RW_BIT 7
+#define MPU6050_I2C_SLV4_ADDR_BIT 6
+#define MPU6050_I2C_SLV4_ADDR_LENGTH 7
+#define MPU6050_I2C_SLV4_EN_BIT 7
+#define MPU6050_I2C_SLV4_INT_EN_BIT 6
+#define MPU6050_I2C_SLV4_REG_DIS_BIT 5
+#define MPU6050_I2C_SLV4_MST_DLY_BIT 4
+#define MPU6050_I2C_SLV4_MST_DLY_LENGTH 5
+
+#define MPU6050_MST_PASS_THROUGH_BIT 7
+#define MPU6050_MST_I2C_SLV4_DONE_BIT 6
+#define MPU6050_MST_I2C_LOST_ARB_BIT 5
+#define MPU6050_MST_I2C_SLV4_NACK_BIT 4
+#define MPU6050_MST_I2C_SLV3_NACK_BIT 3
+#define MPU6050_MST_I2C_SLV2_NACK_BIT 2
+#define MPU6050_MST_I2C_SLV1_NACK_BIT 1
+#define MPU6050_MST_I2C_SLV0_NACK_BIT 0
+
+#define MPU6050_INTCFG_INT_LEVEL_BIT 7
+#define MPU6050_INTCFG_INT_OPEN_BIT 6
+#define MPU6050_INTCFG_LATCH_INT_EN_BIT 5
+#define MPU6050_INTCFG_INT_RD_CLEAR_BIT 4
+#define MPU6050_INTCFG_FSYNC_INT_LEVEL_BIT 3
+#define MPU6050_INTCFG_FSYNC_INT_EN_BIT 2
+#define MPU6050_INTCFG_I2C_BYPASS_EN_BIT 1
+#define MPU6050_INTCFG_CLKOUT_EN_BIT 0
+
+#define MPU6050_INTMODE_ACTIVEHIGH 0x00
+#define MPU6050_INTMODE_ACTIVELOW 0x01
+
+#define MPU6050_INTDRV_PUSHPULL 0x00
+#define MPU6050_INTDRV_OPENDRAIN 0x01
+
+#define MPU6050_INTLATCH_50USPULSE 0x00
+#define MPU6050_INTLATCH_WAITCLEAR 0x01
+
+#define MPU6050_INTCLEAR_STATUSREAD 0x00
+#define MPU6050_INTCLEAR_ANYREAD 0x01
+
+#define MPU6050_INTERRUPT_FF_BIT 7
+#define MPU6050_INTERRUPT_MOT_BIT 6
+#define MPU6050_INTERRUPT_ZMOT_BIT 5
+#define MPU6050_INTERRUPT_FIFO_OFLOW_BIT 4
+#define MPU6050_INTERRUPT_I2C_MST_INT_BIT 3
+#define MPU6050_INTERRUPT_PLL_RDY_INT_BIT 2
+#define MPU6050_INTERRUPT_DMP_INT_BIT 1
+#define MPU6050_INTERRUPT_DATA_RDY_BIT 0
+
+// TODO: figure out what these actually do
+// UMPL source code is not very obivous
+#define MPU6050_DMPINT_5_BIT 5
+#define MPU6050_DMPINT_4_BIT 4
+#define MPU6050_DMPINT_3_BIT 3
+#define MPU6050_DMPINT_2_BIT 2
+#define MPU6050_DMPINT_1_BIT 1
+#define MPU6050_DMPINT_0_BIT 0
+
+#define MPU6050_MOTION_MOT_XNEG_BIT 7
+#define MPU6050_MOTION_MOT_XPOS_BIT 6
+#define MPU6050_MOTION_MOT_YNEG_BIT 5
+#define MPU6050_MOTION_MOT_YPOS_BIT 4
+#define MPU6050_MOTION_MOT_ZNEG_BIT 3
+#define MPU6050_MOTION_MOT_ZPOS_BIT 2
+#define MPU6050_MOTION_MOT_ZRMOT_BIT 0
+
+#define MPU6050_DELAYCTRL_DELAY_ES_SHADOW_BIT 7
+#define MPU6050_DELAYCTRL_I2C_SLV4_DLY_EN_BIT 4
+#define MPU6050_DELAYCTRL_I2C_SLV3_DLY_EN_BIT 3
+#define MPU6050_DELAYCTRL_I2C_SLV2_DLY_EN_BIT 2
+#define MPU6050_DELAYCTRL_I2C_SLV1_DLY_EN_BIT 1
+#define MPU6050_DELAYCTRL_I2C_SLV0_DLY_EN_BIT 0
+
+#define MPU6050_PATHRESET_GYRO_RESET_BIT 2
+#define MPU6050_PATHRESET_ACCEL_RESET_BIT 1
+#define MPU6050_PATHRESET_TEMP_RESET_BIT 0
+
+#define MPU6050_DETECT_ACCEL_ON_DELAY_BIT 5
+#define MPU6050_DETECT_ACCEL_ON_DELAY_LENGTH 2
+#define MPU6050_DETECT_FF_COUNT_BIT 3
+#define MPU6050_DETECT_FF_COUNT_LENGTH 2
+#define MPU6050_DETECT_MOT_COUNT_BIT 1
+#define MPU6050_DETECT_MOT_COUNT_LENGTH 2
+
+#define MPU6050_DETECT_DECREMENT_RESET 0x0
+#define MPU6050_DETECT_DECREMENT_1 0x1
+#define MPU6050_DETECT_DECREMENT_2 0x2
+#define MPU6050_DETECT_DECREMENT_4 0x3
+
+#define MPU6050_USERCTRL_DMP_EN_BIT 7
+#define MPU6050_USERCTRL_FIFO_EN_BIT 6
+#define MPU6050_USERCTRL_I2C_MST_EN_BIT 5
+#define MPU6050_USERCTRL_I2C_IF_DIS_BIT 4
+#define MPU6050_USERCTRL_DMP_RESET_BIT 3
+#define MPU6050_USERCTRL_FIFO_RESET_BIT 2
+#define MPU6050_USERCTRL_I2C_MST_RESET_BIT 1
+#define MPU6050_USERCTRL_SIG_COND_RESET_BIT 0
+
+#define MPU6050_PWR1_DEVICE_RESET_BIT 7
+#define MPU6050_PWR1_SLEEP_BIT 6
+#define MPU6050_PWR1_CYCLE_BIT 5
+#define MPU6050_PWR1_TEMP_DIS_BIT 3
+#define MPU6050_PWR1_CLKSEL_BIT 2
+#define MPU6050_PWR1_CLKSEL_LENGTH 3
+
+#define MPU6050_CLOCK_INTERNAL 0x00
+#define MPU6050_CLOCK_PLL_XGYRO 0x01
+#define MPU6050_CLOCK_PLL_YGYRO 0x02
+#define MPU6050_CLOCK_PLL_ZGYRO 0x03
+#define MPU6050_CLOCK_PLL_EXT32K 0x04
+#define MPU6050_CLOCK_PLL_EXT19M 0x05
+#define MPU6050_CLOCK_KEEP_RESET 0x07
+
+#define MPU6050_PWR2_LP_WAKE_CTRL_BIT 7
+#define MPU6050_PWR2_LP_WAKE_CTRL_LENGTH 2
+#define MPU6050_PWR2_STBY_XA_BIT 5
+#define MPU6050_PWR2_STBY_YA_BIT 4
+#define MPU6050_PWR2_STBY_ZA_BIT 3
+#define MPU6050_PWR2_STBY_XG_BIT 2
+#define MPU6050_PWR2_STBY_YG_BIT 1
+#define MPU6050_PWR2_STBY_ZG_BIT 0
+
+#define MPU6050_WAKE_FREQ_1P25 0x0
+#define MPU6050_WAKE_FREQ_2P5 0x1
+#define MPU6050_WAKE_FREQ_5 0x2
+#define MPU6050_WAKE_FREQ_10 0x3
+
+#define MPU6050_BANKSEL_PRFTCH_EN_BIT 6
+#define MPU6050_BANKSEL_CFG_USER_BANK_BIT 5
+#define MPU6050_BANKSEL_MEM_SEL_BIT 4
+#define MPU6050_BANKSEL_MEM_SEL_LENGTH 5
+
+#define MPU6050_WHO_AM_I_BIT 6
+#define MPU6050_WHO_AM_I_LENGTH 6
+
+#define MPU6050_DMP_MEMORY_BANKS 8
+#define MPU6050_DMP_MEMORY_BANK_SIZE 256
+#define MPU6050_DMP_MEMORY_CHUNK_SIZE 16
+
+#define MPU6050_DEG_PER_LSB_250 (float)((2 * 250.0) / 65536.0)
+#define MPU6050_DEG_PER_LSB_500 (float)((2 * 500.0) / 65536.0)
+#define MPU6050_DEG_PER_LSB_1000 (float)((2 * 1000.0) / 65536.0)
+#define MPU6050_DEG_PER_LSB_2000 (float)((2 * 2000.0) / 65536.0)
+
+#define MPU6050_G_PER_LSB_2 (float)((2 * 2) / 65536.0)
+#define MPU6050_G_PER_LSB_4 (float)((2 * 4) / 65536.0)
+#define MPU6050_G_PER_LSB_8 (float)((2 * 8) / 65536.0)
+#define MPU6050_G_PER_LSB_16 (float)((2 * 16) / 65536.0)
+
+#define MPU6050_ST_GYRO_LOW 10.0 // deg/s
+#define MPU6050_ST_GYRO_HIGH 105.0 // deg/s
+#define MPU6050_ST_ACCEL_LOW 0.300 // G
+#define MPU6050_ST_ACCEL_HIGH 0.950 // G
+
+// note: DMP code memory blocks defined at end of header file
+
+void mpu6050Init(I2C_Dev *i2cPort);
+bool mpu6050Test(void);
+
+bool mpu6050TestConnection();
+bool mpu6050EvaluateSelfTest(float low, float high, float value, char *string);
+bool mpu6050SelfTest();
+
+
+// AUX_VDDIO register
+uint8_t mpu6050GetAuxVDDIOLevel();
+void mpu6050SetAuxVDDIOLevel(uint8_t level);
+
+// SMPLRT_DIV register
+uint8_t mpu6050GetRate();
+void mpu6050SetRate(uint8_t rate);
+
+// CONFIG register
+uint8_t mpu6050GetExternalFrameSync();
+void mpu6050SetExternalFrameSync(uint8_t sync);
+uint8_t mpu6050GetDLPFMode();
+void mpu6050SetDLPFMode(uint8_t bandwidth);
+
+// GYRO_CONFIG register
+void mpu6050SetGyroXSelfTest(bool enabled);
+void mpu6050SetGyroYSelfTest(bool enabled);
+void mpu6050SetGyroZSelfTest(bool enabled);
+uint8_t mpu6050GetFullScaleGyroRangeId();
+float mpu6050GetFullScaleGyroDPL();
+void mpu6050SetFullScaleGyroRange(uint8_t range);
+
+// ACCEL_CONFIG register
+bool mpu6050GetAccelXSelfTest();
+void mpu6050SetAccelXSelfTest(bool enabled);
+bool mpu6050GetAccelYSelfTest();
+void mpu6050SetAccelYSelfTest(bool enabled);
+bool mpu6050GetAccelZSelfTest();
+void mpu6050SetAccelZSelfTest(bool enabled);
+uint8_t mpu6050GetFullScaleAccelRangeId();
+void mpu6050SetFullScaleAccelRange(uint8_t range);
+float mpu6050GetFullScaleAccelGPL();
+uint8_t mpu6050GetDHPFMode();
+void mpu6050SetDHPFMode(uint8_t mode);
+
+// FF_THR register
+uint8_t mpu6050GetFreefallDetectionThreshold();
+void mpu6050SetFreefallDetectionThreshold(uint8_t threshold);
+
+// FF_DUR register
+uint8_t mpu6050GetFreefallDetectionDuration();
+void mpu6050SetFreefallDetectionDuration(uint8_t duration);
+
+// MOT_THR register
+uint8_t mpu6050GetMotionDetectionThreshold();
+void mpu6050SetMotionDetectionThreshold(uint8_t threshold);
+
+// MOT_DUR register
+uint8_t mpu6050GetMotionDetectionDuration();
+void mpu6050SetMotionDetectionDuration(uint8_t duration);
+
+// ZRMOT_THR register
+uint8_t mpu6050GetZeroMotionDetectionThreshold();
+void mpu6050SetZeroMotionDetectionThreshold(uint8_t threshold);
+
+// ZRMOT_DUR register
+uint8_t mpu6050GetZeroMotionDetectionDuration();
+void mpu6050SetZeroMotionDetectionDuration(uint8_t duration);
+
+// FIFO_EN register
+bool mpu6050GetTempFIFOEnabled();
+void mpu6050SetTempFIFOEnabled(bool enabled);
+bool mpu6050GetXGyroFIFOEnabled();
+void mpu6050SetXGyroFIFOEnabled(bool enabled);
+bool mpu6050GetYGyroFIFOEnabled();
+void mpu6050SetYGyroFIFOEnabled(bool enabled);
+bool mpu6050GetZGyroFIFOEnabled();
+void mpu6050SetZGyroFIFOEnabled(bool enabled);
+bool mpu6050GetAccelFIFOEnabled();
+void mpu6050SetAccelFIFOEnabled(bool enabled);
+bool mpu6050GetSlave2FIFOEnabled();
+void mpu6050SetSlave2FIFOEnabled(bool enabled);
+bool mpu6050GetSlave1FIFOEnabled();
+void mpu6050SetSlave1FIFOEnabled(bool enabled);
+bool mpu6050GetSlave0FIFOEnabled();
+void mpu6050SetSlave0FIFOEnabled(bool enabled);
+
+// I2C_MST_CTRL register
+bool mpu6050GetMultiMasterEnabled();
+void mpu6050SetMultiMasterEnabled(bool enabled);
+bool mpu6050GetWaitForExternalSensorEnabled();
+void mpu6050SetWaitForExternalSensorEnabled(bool enabled);
+bool mpu6050GetSlave3FIFOEnabled();
+void mpu6050SetSlave3FIFOEnabled(bool enabled);
+bool mpu6050GetSlaveReadWriteTransitionEnabled();
+void mpu6050SetSlaveReadWriteTransitionEnabled(bool enabled);
+uint8_t mpu6050GetMasterClockSpeed();
+void mpu6050SetMasterClockSpeed(uint8_t speed);
+
+// I2C_SLV* registers (Slave 0-3)
+uint8_t mpu6050GetSlaveAddress(uint8_t num);
+void mpu6050SetSlaveAddress(uint8_t num, uint8_t address);
+uint8_t mpu6050GetSlaveRegister(uint8_t num);
+void mpu6050SetSlaveRegister(uint8_t num, uint8_t reg);
+bool mpu6050GetSlaveEnabled(uint8_t num);
+void mpu6050SetSlaveEnabled(uint8_t num, bool enabled);
+bool mpu6050GetSlaveWordByteSwap(uint8_t num);
+void mpu6050SetSlaveWordByteSwap(uint8_t num, bool enabled);
+bool mpu6050GetSlaveWriteMode(uint8_t num);
+void mpu6050SetSlaveWriteMode(uint8_t num, bool mode);
+bool mpu6050GetSlaveWordGroupOffmpu6050Set(uint8_t num);
+void setSlaveWordGroupOffset(uint8_t num, bool enabled);
+uint8_t mpu6050GetSlaveDataLength(uint8_t num);
+void mpu6050SetSlaveDataLength(uint8_t num, uint8_t length);
+
+// I2C_SLV* registers (Slave 4)
+uint8_t mpu6050GetSlave4Address();
+void mpu6050SetSlave4Address(uint8_t address);
+uint8_t mpu6050GetSlave4Register();
+void mpu6050SetSlave4Register(uint8_t reg);
+void mpu6050SetSlave4OutputByte(uint8_t data);
+bool mpu6050GetSlave4Enabled();
+void mpu6050SetSlave4Enabled(bool enabled);
+bool mpu6050GetSlave4InterruptEnabled();
+void mpu6050SetSlave4InterruptEnabled(bool enabled);
+bool mpu6050GetSlave4WriteMode();
+void mpu6050SetSlave4WriteMode(bool mode);
+uint8_t mpu6050GetSlave4MasterDelay();
+void mpu6050SetSlave4MasterDelay(uint8_t delay);
+uint8_t mpu6050GetSlate4InputByte();
+
+// I2C_MST_STATUS register
+bool mpu6050GetPassthroughStatus();
+bool mpu6050GetSlave4IsDone();
+bool mpu6050GetLostArbitration();
+bool mpu6050GetSlave4Nack();
+bool mpu6050GetSlave3Nack();
+bool mpu6050GetSlave2Nack();
+bool mpu6050GetSlave1Nack();
+bool mpu6050GetSlave0Nack();
+
+// INT_PIN_CFG register
+bool mpu6050GetInterruptMode();
+void mpu6050SetInterruptMode(bool mode);
+bool mpu6050GetInterruptDrive();
+void mpu6050SetInterruptDrive(bool drive);
+bool mpu6050GetInterruptLatch();
+void mpu6050SetInterruptLatch(bool latch);
+bool mpu6050GetInterruptLatchClear();
+void mpu6050SetInterruptLatchClear(bool clear);
+bool mpu6050GetFSyncInterruptLevel();
+void mpu6050SetFSyncInterruptLevel(bool level);
+bool mpu6050GetFSyncInterruptEnabled();
+void mpu6050SetFSyncInterruptEnabled(bool enabled);
+bool mpu6050GetI2CBypassEnabled();
+void mpu6050SetI2CBypassEnabled(bool enabled);
+bool mpu6050GetClockOutputEnabled();
+void mpu6050SetClockOutputEnabled(bool enabled);
+
+// INT_ENABLE register
+uint8_t mpu6050GetIntEnabled();
+void mpu6050SetIntEnabled(uint8_t enabled);
+bool mpu6050GetIntFreefallEnabled();
+void mpu6050SetIntFreefallEnabled(bool enabled);
+bool mpu6050GetIntMotionEnabled();
+void mpu6050SetIntMotionEnabled(bool enabled);
+bool mpu6050GetIntZeroMotionEnabled();
+void mpu6050SetIntZeroMotionEnabled(bool enabled);
+bool mpu6050GetIntFIFOBufferOverflowEnabled();
+void mpu6050SetIntFIFOBufferOverflowEnabled(bool enabled);
+bool mpu6050GetIntI2CMasterEnabled();
+void mpu6050SetIntI2CMasterEnabled(bool enabled);
+bool mpu6050GetIntDataReadyEnabled();
+void mpu6050SetIntDataReadyEnabled(bool enabled);
+
+// INT_STATUS register
+uint8_t mpu6050GetIntStatus();
+bool mpu6050GetIntFreefallStatus();
+bool mpu6050GetIntMotionStatus();
+bool mpu6050GetIntZeroMotionStatus();
+bool mpu6050GetIntFIFOBufferOverflowStatus();
+bool mpu6050GetIntI2CMasterStatus();
+bool mpu6050GetIntDataReadyStatus();
+
+// ACCEL_*OUT_* registers
+void mpu6050GetMotion9(int16_t *ax, int16_t *ay, int16_t *az, int16_t *gx, int16_t *gy, int16_t *gz, int16_t *mx, int16_t *my, int16_t *mz);
+void mpu6050GetMotion6(int16_t *ax, int16_t *ay, int16_t *az, int16_t *gx, int16_t *gy, int16_t *gz);
+void mpu6050GetAcceleration(int16_t *x, int16_t *y, int16_t *z);
+int16_t mpu6050GetAccelerationX();
+int16_t mpu6050GetAccelerationY();
+int16_t mpu6050GetAccelerationZ();
+
+// TEMP_OUT_* registers
+int16_t mpu6050GetTemperature();
+
+// GYRO_*OUT_* registers
+void mpu6050GetRotation(int16_t *x, int16_t *y, int16_t *z);
+int16_t mpu6050GetRotationX();
+int16_t mpu6050GetRotationY();
+int16_t mpu6050GetRotationZ();
+
+// EXT_SENS_DATA_* registers
+uint8_t mpu6050GetExternalSensorByte(int position);
+uint16_t mpu6050GetExternalSensorWord(int position);
+uint32_t mpu6050GetExternalSensorDWord(int position);
+
+// MOT_DETECT_STATUS register
+bool mpu6050GetXNegMotionDetected();
+bool mpu6050GetXPosMotionDetected();
+bool mpu6050GetYNegMotionDetected();
+bool mpu6050GetYPosMotionDetected();
+bool mpu6050GetZNegMotionDetected();
+bool mpu6050GetZPosMotionDetected();
+bool mpu6050GetZeroMotionDetected();
+
+// I2C_SLV*_DO register
+void mpu6050SetSlaveOutputByte(uint8_t num, uint8_t data);
+
+// I2C_MST_DELAY_CTRL register
+bool mpu6050GetExternalShadowDelayEnabled();
+void mpu6050SetExternalShadowDelayEnabled(bool enabled);
+bool mpu6050GetSlaveDelayEnabled(uint8_t num);
+void mpu6050SetSlaveDelayEnabled(uint8_t num, bool enabled);
+
+// SIGNAL_PATH_RESET register
+void rempu6050SetGyroscopePath();
+void rempu6050SetAccelerometerPath();
+void rempu6050SetTemperaturePath();
+
+// MOT_DETECT_CTRL register
+uint8_t mpu6050GetAccelerometerPowerOnDelay();
+void mpu6050SetAccelerometerPowerOnDelay(uint8_t delay);
+uint8_t mpu6050GetFreefallDetectionCounterDecrement();
+void mpu6050SetFreefallDetectionCounterDecrement(uint8_t decrement);
+uint8_t mpu6050GetMotionDetectionCounterDecrement();
+void mpu6050SetMotionDetectionCounterDecrement(uint8_t decrement);
+
+// USER_CTRL register
+bool mpu6050GetFIFOEnabled();
+void mpu6050SetFIFOEnabled(bool enabled);
+bool mpu6050GetI2CMasterModeEnabled();
+void mpu6050SetI2CMasterModeEnabled(bool enabled);
+void mpu6050SwitchSPIEnabled(bool enabled);
+void mpu6050ResetFIFO();
+void mpu6050ResetI2CMaster();
+void mpu6050ResetSensors();
+
+// PWR_MGMT_1 register
+void mpu6050Reset();
+bool mpu6050GetSleepEnabled();
+void mpu6050SetSleepEnabled(bool enabled);
+bool mpu6050GetWakeCycleEnabled();
+void mpu6050SetWakeCycleEnabled(bool enabled);
+bool mpu6050GetTempSensorEnabled();
+void mpu6050SetTempSensorEnabled(bool enabled);
+uint8_t mpu6050GetClockSource();
+void mpu6050SetClockSource(uint8_t source);
+
+// PWR_MGMT_2 register
+uint8_t mpu6050GetWakeFrequency();
+void mpu6050SetWakeFrequency(uint8_t frequency);
+bool mpu6050GetStandbyXAccelEnabled();
+void mpu6050SetStandbyXAccelEnabled(bool enabled);
+bool mpu6050GetStandbyYAccelEnabled();
+void mpu6050SetStandbyYAccelEnabled(bool enabled);
+bool mpu6050GetStandbyZAccelEnabled();
+void mpu6050SetStandbyZAccelEnabled(bool enabled);
+bool mpu6050GetStandbyXGyroEnabled();
+void mpu6050SetStandbyXGyroEnabled(bool enabled);
+bool mpu6050GetStandbyYGyroEnabled();
+void mpu6050SetStandbyYGyroEnabled(bool enabled);
+bool mpu6050GetStandbyZGyroEnabled();
+void mpu6050SetStandbyZGyroEnabled(bool enabled);
+
+// FIFO_COUNT_* registers
+uint16_t mpu6050GetFIFOCount();
+
+// FIFO_R_W register
+uint8_t mpu6050GetFIFOByte();
+void mpu6050SetFIFOByte(uint8_t data);
+void mpu6050GetFIFOBytes(uint8_t *data, uint8_t length);
+
+// WHO_AM_I register
+uint8_t mpu6050GetDeviceID();
+void mpu6050SetDeviceID(uint8_t id);
+
+// ======== UNDOCUMENTED/DMP REGISTERS/METHODS ========
+
+// XG_OFFS_TC register
+uint8_t mpu6050GetOTPBankValid();
+void mpu6050SetOTPBankValid(bool enabled);
+int8_t mpu6050GetXGyroOffset();
+void mpu6050SetXGyroOffset(int8_t offset);
+
+// YG_OFFS_TC register
+int8_t mpu6050GetYGyroOffset();
+void mpu6050SetYGyroOffset(int8_t offset);
+
+// ZG_OFFS_TC register
+int8_t mpu6050GetZGyroOffset();
+void mpu6050SetGyroOffset(int8_t offset);
+
+// X_FINE_GAIN register
+int8_t mpu6050GetXFineGain();
+void mpu6050SetXFineGain(int8_t gain);
+
+// Y_FINE_GAIN register
+int8_t mpu6050GetYFineGain();
+void mpu6050SetYFineGain(int8_t gain);
+
+// Z_FINE_GAIN register
+int8_t mpu6050GetZFineGain();
+void mpu6050SetZFineGain(int8_t gain);
+
+// XA_OFFS_* registers
+int16_t mpu6050GetXAccelOffset();
+void mpu6050SetXAccelOffset(int16_t offset);
+
+// YA_OFFS_* register
+int16_t mpu6050GetYAccelOffset();
+void mpu6050SetYAccelOffset(int16_t offset);
+
+// ZA_OFFS_* register
+int16_t mpu6050GetZAccelOffset();
+void mpu6050SetZAccelOffset(int16_t offset);
+
+// XG_OFFS_USR* registers
+int16_t mpu6050GetXGyroOffsetUser();
+void mpu6050SetXGyroOffsetUser(int16_t offset);
+
+// YG_OFFS_USR* register
+int16_t mpu6050GetYGyroOffsetUser();
+void mpu6050SetYGyroOffsetUser(int16_t offset);
+
+// ZG_OFFS_USR* register
+int16_t mpu6050GetZGyroOffsetUser();
+void mpu6050SetZGyroOffsetUser(int16_t offset);
+
+// INT_ENABLE register (DMP functions)
+bool mpu6050GetIntPLLReadyEnabled();
+void mpu6050SetIntPLLReadyEnabled(bool enabled);
+bool mpu6050GetIntDMPEnabled();
+void mpu6050SetIntDMPEnabled(bool enabled);
+
+// DMP_INT_STATUS
+bool mpu6050GetDMPInt5Status();
+bool mpu6050GetDMPInt4Status();
+bool mpu6050GetDMPInt3Status();
+bool mpu6050GetDMPInt2Status();
+bool mpu6050GetDMPInt1Status();
+bool mpu6050GetDMPInt0Status();
+
+// INT_STATUS register (DMP functions)
+bool mpu6050GetIntPLLReadyStatus();
+bool mpu6050GetIntDMPStatus();
+
+// USER_CTRL register (DMP functions)
+bool mpu6050GetDMPEnabled();
+void mpu6050SetDMPEnabled(bool enabled);
+void mpu6050ResetDMP();
+
+// BANK_SEL register
+void mpu6050SetMemoryBank(uint8_t bank, bool prefetchEnabled, bool userBank);
+
+// MEM_START_ADDR register
+void mpu6050SetMemoryStartAddress(uint8_t address);
+
+// MEM_R_W register
+uint8_t mpu6050ReadMemoryByte();
+void mpu6050WriteMemoryByte(uint8_t data);
+void mpu6050ReadMemoryBlock(uint8_t *data, uint16_t dataSize, uint8_t bank, uint8_t address);
+bool mpu6050WriteMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank, uint8_t address, bool verify);
+bool mpu6050WriteProgMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank, uint8_t address, bool verify);
+
+bool mpu6050WriteDMPConfigurationSet(const uint8_t *data, uint16_t dataSize);
+bool mpu6050WiteProgDMPConfigurationSet(const uint8_t *data, uint16_t dataSize);
+
+// DMP_CFG_1 register
+uint8_t mpu6050GetDMPConfig1();
+void mpu6050SetDMPConfig1(uint8_t config);
+
+// DMP_CFG_2 register
+uint8_t mpu6050GetDMPConfig2();
+void mpu6050SetDMPConfig2(uint8_t config);
+
+
+#ifdef MPU6050_INCLUDE_DMP_MOTIONAPPS20
+/* This is only included if you want it, since it eats about 2K of program
+ * memory, which is a waste if you aren't using the DMP (or if you aren't
+ * using this particular flavor of DMP).
+ *
+ * Source is from the InvenSense MotionApps v2 demo code. Original source is
+ * unavailable, unless you happen to be amazing as decompiling binary by
+ * hand (in which case, please contact me, and I'm totally serious).
+ *
+ * Also, I'd like to offer many, many thanks to Noah Zerkin for all of the
+ * DMP reverse-engineering he did to help make this bit of wizardry
+ * possible.
+ */
+
+#define MPU6050_DMP_CODE_SIZE 1929
+
+// this block of memory gets written to the MPU on start-up, and it seems
+// to be volatile memory, so it has to be done each time (it only takes ~1
+// second though)
+const prog_uchar dmpMemory[MPU6050_DMP_CODE_SIZE] PROGMEM = {
+ // bank 0, 256 bytes
+ 0xFB, 0x00, 0x00, 0x3E, 0x00, 0x0B, 0x00, 0x36, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00,
+ 0x00, 0x65, 0x00, 0x54, 0xFF, 0xEF, 0x00, 0x00, 0xFA, 0x80, 0x00, 0x0B, 0x12, 0x82, 0x00, 0x01,
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x28, 0x00, 0x00, 0xFF, 0xFF, 0x45, 0x81, 0xFF, 0xFF, 0xFA, 0x72, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x03, 0xE8, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x7F, 0xFF, 0xFF, 0xFE, 0x80, 0x01,
+ 0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x3E, 0x03, 0x30, 0x40, 0x00, 0x00, 0x00, 0x02, 0xCA, 0xE3, 0x09, 0x3E, 0x80, 0x00, 0x00,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
+ 0x41, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x2A, 0x00, 0x00, 0x16, 0x55, 0x00, 0x00, 0x21, 0x82,
+ 0xFD, 0x87, 0x26, 0x50, 0xFD, 0x80, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x05, 0x80, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
+ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x6F, 0x00, 0x02, 0x65, 0x32, 0x00, 0x00, 0x5E, 0xC0,
+ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xFB, 0x8C, 0x6F, 0x5D, 0xFD, 0x5D, 0x08, 0xD9, 0x00, 0x7C, 0x73, 0x3B, 0x00, 0x6C, 0x12, 0xCC,
+ 0x32, 0x00, 0x13, 0x9D, 0x32, 0x00, 0xD0, 0xD6, 0x32, 0x00, 0x08, 0x00, 0x40, 0x00, 0x01, 0xF4,
+ 0xFF, 0xE6, 0x80, 0x79, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0xD6, 0x00, 0x00, 0x27, 0x10,
+
+ // bank 1, 256 bytes
+ 0xFB, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xFA, 0x36, 0xFF, 0xBC, 0x30, 0x8E, 0x00, 0x05, 0xFB, 0xF0, 0xFF, 0xD9, 0x5B, 0xC8,
+ 0xFF, 0xD0, 0x9A, 0xBE, 0x00, 0x00, 0x10, 0xA9, 0xFF, 0xF4, 0x1E, 0xB2, 0x00, 0xCE, 0xBB, 0xF7,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x0C,
+ 0xFF, 0xC2, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0xCF, 0x80, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x14,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x3F, 0x68, 0xB6, 0x79, 0x35, 0x28, 0xBC, 0xC6, 0x7E, 0xD1, 0x6C,
+ 0x80, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB2, 0x6A, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x30,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x25, 0x4D, 0x00, 0x2F, 0x70, 0x6D, 0x00, 0x00, 0x05, 0xAE, 0x00, 0x0C, 0x02, 0xD0,
+
+ // bank 2, 256 bytes
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x00, 0x54, 0xFF, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0xFF, 0xEF, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+ // bank 3, 256 bytes
+ 0xD8, 0xDC, 0xBA, 0xA2, 0xF1, 0xDE, 0xB2, 0xB8, 0xB4, 0xA8, 0x81, 0x91, 0xF7, 0x4A, 0x90, 0x7F,
+ 0x91, 0x6A, 0xF3, 0xF9, 0xDB, 0xA8, 0xF9, 0xB0, 0xBA, 0xA0, 0x80, 0xF2, 0xCE, 0x81, 0xF3, 0xC2,
+ 0xF1, 0xC1, 0xF2, 0xC3, 0xF3, 0xCC, 0xA2, 0xB2, 0x80, 0xF1, 0xC6, 0xD8, 0x80, 0xBA, 0xA7, 0xDF,
+ 0xDF, 0xDF, 0xF2, 0xA7, 0xC3, 0xCB, 0xC5, 0xB6, 0xF0, 0x87, 0xA2, 0x94, 0x24, 0x48, 0x70, 0x3C,
+ 0x95, 0x40, 0x68, 0x34, 0x58, 0x9B, 0x78, 0xA2, 0xF1, 0x83, 0x92, 0x2D, 0x55, 0x7D, 0xD8, 0xB1,
+ 0xB4, 0xB8, 0xA1, 0xD0, 0x91, 0x80, 0xF2, 0x70, 0xF3, 0x70, 0xF2, 0x7C, 0x80, 0xA8, 0xF1, 0x01,
+ 0xB0, 0x98, 0x87, 0xD9, 0x43, 0xD8, 0x86, 0xC9, 0x88, 0xBA, 0xA1, 0xF2, 0x0E, 0xB8, 0x97, 0x80,
+ 0xF1, 0xA9, 0xDF, 0xDF, 0xDF, 0xAA, 0xDF, 0xDF, 0xDF, 0xF2, 0xAA, 0xC5, 0xCD, 0xC7, 0xA9, 0x0C,
+ 0xC9, 0x2C, 0x97, 0x97, 0x97, 0x97, 0xF1, 0xA9, 0x89, 0x26, 0x46, 0x66, 0xB0, 0xB4, 0xBA, 0x80,
+ 0xAC, 0xDE, 0xF2, 0xCA, 0xF1, 0xB2, 0x8C, 0x02, 0xA9, 0xB6, 0x98, 0x00, 0x89, 0x0E, 0x16, 0x1E,
+ 0xB8, 0xA9, 0xB4, 0x99, 0x2C, 0x54, 0x7C, 0xB0, 0x8A, 0xA8, 0x96, 0x36, 0x56, 0x76, 0xF1, 0xB9,
+ 0xAF, 0xB4, 0xB0, 0x83, 0xC0, 0xB8, 0xA8, 0x97, 0x11, 0xB1, 0x8F, 0x98, 0xB9, 0xAF, 0xF0, 0x24,
+ 0x08, 0x44, 0x10, 0x64, 0x18, 0xF1, 0xA3, 0x29, 0x55, 0x7D, 0xAF, 0x83, 0xB5, 0x93, 0xAF, 0xF0,
+ 0x00, 0x28, 0x50, 0xF1, 0xA3, 0x86, 0x9F, 0x61, 0xA6, 0xDA, 0xDE, 0xDF, 0xD9, 0xFA, 0xA3, 0x86,
+ 0x96, 0xDB, 0x31, 0xA6, 0xD9, 0xF8, 0xDF, 0xBA, 0xA6, 0x8F, 0xC2, 0xC5, 0xC7, 0xB2, 0x8C, 0xC1,
+ 0xB8, 0xA2, 0xDF, 0xDF, 0xDF, 0xA3, 0xDF, 0xDF, 0xDF, 0xD8, 0xD8, 0xF1, 0xB8, 0xA8, 0xB2, 0x86,
+
+ // bank 4, 256 bytes
+ 0xB4, 0x98, 0x0D, 0x35, 0x5D, 0xB8, 0xAA, 0x98, 0xB0, 0x87, 0x2D, 0x35, 0x3D, 0xB2, 0xB6, 0xBA,
+ 0xAF, 0x8C, 0x96, 0x19, 0x8F, 0x9F, 0xA7, 0x0E, 0x16, 0x1E, 0xB4, 0x9A, 0xB8, 0xAA, 0x87, 0x2C,
+ 0x54, 0x7C, 0xB9, 0xA3, 0xDE, 0xDF, 0xDF, 0xA3, 0xB1, 0x80, 0xF2, 0xC4, 0xCD, 0xC9, 0xF1, 0xB8,
+ 0xA9, 0xB4, 0x99, 0x83, 0x0D, 0x35, 0x5D, 0x89, 0xB9, 0xA3, 0x2D, 0x55, 0x7D, 0xB5, 0x93, 0xA3,
+ 0x0E, 0x16, 0x1E, 0xA9, 0x2C, 0x54, 0x7C, 0xB8, 0xB4, 0xB0, 0xF1, 0x97, 0x83, 0xA8, 0x11, 0x84,
+ 0xA5, 0x09, 0x98, 0xA3, 0x83, 0xF0, 0xDA, 0x24, 0x08, 0x44, 0x10, 0x64, 0x18, 0xD8, 0xF1, 0xA5,
+ 0x29, 0x55, 0x7D, 0xA5, 0x85, 0x95, 0x02, 0x1A, 0x2E, 0x3A, 0x56, 0x5A, 0x40, 0x48, 0xF9, 0xF3,
+ 0xA3, 0xD9, 0xF8, 0xF0, 0x98, 0x83, 0x24, 0x08, 0x44, 0x10, 0x64, 0x18, 0x97, 0x82, 0xA8, 0xF1,
+ 0x11, 0xF0, 0x98, 0xA2, 0x24, 0x08, 0x44, 0x10, 0x64, 0x18, 0xDA, 0xF3, 0xDE, 0xD8, 0x83, 0xA5,
+ 0x94, 0x01, 0xD9, 0xA3, 0x02, 0xF1, 0xA2, 0xC3, 0xC5, 0xC7, 0xD8, 0xF1, 0x84, 0x92, 0xA2, 0x4D,
+ 0xDA, 0x2A, 0xD8, 0x48, 0x69, 0xD9, 0x2A, 0xD8, 0x68, 0x55, 0xDA, 0x32, 0xD8, 0x50, 0x71, 0xD9,
+ 0x32, 0xD8, 0x70, 0x5D, 0xDA, 0x3A, 0xD8, 0x58, 0x79, 0xD9, 0x3A, 0xD8, 0x78, 0x93, 0xA3, 0x4D,
+ 0xDA, 0x2A, 0xD8, 0x48, 0x69, 0xD9, 0x2A, 0xD8, 0x68, 0x55, 0xDA, 0x32, 0xD8, 0x50, 0x71, 0xD9,
+ 0x32, 0xD8, 0x70, 0x5D, 0xDA, 0x3A, 0xD8, 0x58, 0x79, 0xD9, 0x3A, 0xD8, 0x78, 0xA8, 0x8A, 0x9A,
+ 0xF0, 0x28, 0x50, 0x78, 0x9E, 0xF3, 0x88, 0x18, 0xF1, 0x9F, 0x1D, 0x98, 0xA8, 0xD9, 0x08, 0xD8,
+ 0xC8, 0x9F, 0x12, 0x9E, 0xF3, 0x15, 0xA8, 0xDA, 0x12, 0x10, 0xD8, 0xF1, 0xAF, 0xC8, 0x97, 0x87,
+
+ // bank 5, 256 bytes
+ 0x34, 0xB5, 0xB9, 0x94, 0xA4, 0x21, 0xF3, 0xD9, 0x22, 0xD8, 0xF2, 0x2D, 0xF3, 0xD9, 0x2A, 0xD8,
+ 0xF2, 0x35, 0xF3, 0xD9, 0x32, 0xD8, 0x81, 0xA4, 0x60, 0x60, 0x61, 0xD9, 0x61, 0xD8, 0x6C, 0x68,
+ 0x69, 0xD9, 0x69, 0xD8, 0x74, 0x70, 0x71, 0xD9, 0x71, 0xD8, 0xB1, 0xA3, 0x84, 0x19, 0x3D, 0x5D,
+ 0xA3, 0x83, 0x1A, 0x3E, 0x5E, 0x93, 0x10, 0x30, 0x81, 0x10, 0x11, 0xB8, 0xB0, 0xAF, 0x8F, 0x94,
+ 0xF2, 0xDA, 0x3E, 0xD8, 0xB4, 0x9A, 0xA8, 0x87, 0x29, 0xDA, 0xF8, 0xD8, 0x87, 0x9A, 0x35, 0xDA,
+ 0xF8, 0xD8, 0x87, 0x9A, 0x3D, 0xDA, 0xF8, 0xD8, 0xB1, 0xB9, 0xA4, 0x98, 0x85, 0x02, 0x2E, 0x56,
+ 0xA5, 0x81, 0x00, 0x0C, 0x14, 0xA3, 0x97, 0xB0, 0x8A, 0xF1, 0x2D, 0xD9, 0x28, 0xD8, 0x4D, 0xD9,
+ 0x48, 0xD8, 0x6D, 0xD9, 0x68, 0xD8, 0xB1, 0x84, 0x0D, 0xDA, 0x0E, 0xD8, 0xA3, 0x29, 0x83, 0xDA,
+ 0x2C, 0x0E, 0xD8, 0xA3, 0x84, 0x49, 0x83, 0xDA, 0x2C, 0x4C, 0x0E, 0xD8, 0xB8, 0xB0, 0xA8, 0x8A,
+ 0x9A, 0xF5, 0x20, 0xAA, 0xDA, 0xDF, 0xD8, 0xA8, 0x40, 0xAA, 0xD0, 0xDA, 0xDE, 0xD8, 0xA8, 0x60,
+ 0xAA, 0xDA, 0xD0, 0xDF, 0xD8, 0xF1, 0x97, 0x86, 0xA8, 0x31, 0x9B, 0x06, 0x99, 0x07, 0xAB, 0x97,
+ 0x28, 0x88, 0x9B, 0xF0, 0x0C, 0x20, 0x14, 0x40, 0xB8, 0xB0, 0xB4, 0xA8, 0x8C, 0x9C, 0xF0, 0x04,
+ 0x28, 0x51, 0x79, 0x1D, 0x30, 0x14, 0x38, 0xB2, 0x82, 0xAB, 0xD0, 0x98, 0x2C, 0x50, 0x50, 0x78,
+ 0x78, 0x9B, 0xF1, 0x1A, 0xB0, 0xF0, 0x8A, 0x9C, 0xA8, 0x29, 0x51, 0x79, 0x8B, 0x29, 0x51, 0x79,
+ 0x8A, 0x24, 0x70, 0x59, 0x8B, 0x20, 0x58, 0x71, 0x8A, 0x44, 0x69, 0x38, 0x8B, 0x39, 0x40, 0x68,
+ 0x8A, 0x64, 0x48, 0x31, 0x8B, 0x30, 0x49, 0x60, 0xA5, 0x88, 0x20, 0x09, 0x71, 0x58, 0x44, 0x68,
+
+ // bank 6, 256 bytes
+ 0x11, 0x39, 0x64, 0x49, 0x30, 0x19, 0xF1, 0xAC, 0x00, 0x2C, 0x54, 0x7C, 0xF0, 0x8C, 0xA8, 0x04,
+ 0x28, 0x50, 0x78, 0xF1, 0x88, 0x97, 0x26, 0xA8, 0x59, 0x98, 0xAC, 0x8C, 0x02, 0x26, 0x46, 0x66,
+ 0xF0, 0x89, 0x9C, 0xA8, 0x29, 0x51, 0x79, 0x24, 0x70, 0x59, 0x44, 0x69, 0x38, 0x64, 0x48, 0x31,
+ 0xA9, 0x88, 0x09, 0x20, 0x59, 0x70, 0xAB, 0x11, 0x38, 0x40, 0x69, 0xA8, 0x19, 0x31, 0x48, 0x60,
+ 0x8C, 0xA8, 0x3C, 0x41, 0x5C, 0x20, 0x7C, 0x00, 0xF1, 0x87, 0x98, 0x19, 0x86, 0xA8, 0x6E, 0x76,
+ 0x7E, 0xA9, 0x99, 0x88, 0x2D, 0x55, 0x7D, 0x9E, 0xB9, 0xA3, 0x8A, 0x22, 0x8A, 0x6E, 0x8A, 0x56,
+ 0x8A, 0x5E, 0x9F, 0xB1, 0x83, 0x06, 0x26, 0x46, 0x66, 0x0E, 0x2E, 0x4E, 0x6E, 0x9D, 0xB8, 0xAD,
+ 0x00, 0x2C, 0x54, 0x7C, 0xF2, 0xB1, 0x8C, 0xB4, 0x99, 0xB9, 0xA3, 0x2D, 0x55, 0x7D, 0x81, 0x91,
+ 0xAC, 0x38, 0xAD, 0x3A, 0xB5, 0x83, 0x91, 0xAC, 0x2D, 0xD9, 0x28, 0xD8, 0x4D, 0xD9, 0x48, 0xD8,
+ 0x6D, 0xD9, 0x68, 0xD8, 0x8C, 0x9D, 0xAE, 0x29, 0xD9, 0x04, 0xAE, 0xD8, 0x51, 0xD9, 0x04, 0xAE,
+ 0xD8, 0x79, 0xD9, 0x04, 0xD8, 0x81, 0xF3, 0x9D, 0xAD, 0x00, 0x8D, 0xAE, 0x19, 0x81, 0xAD, 0xD9,
+ 0x01, 0xD8, 0xF2, 0xAE, 0xDA, 0x26, 0xD8, 0x8E, 0x91, 0x29, 0x83, 0xA7, 0xD9, 0xAD, 0xAD, 0xAD,
+ 0xAD, 0xF3, 0x2A, 0xD8, 0xD8, 0xF1, 0xB0, 0xAC, 0x89, 0x91, 0x3E, 0x5E, 0x76, 0xF3, 0xAC, 0x2E,
+ 0x2E, 0xF1, 0xB1, 0x8C, 0x5A, 0x9C, 0xAC, 0x2C, 0x28, 0x28, 0x28, 0x9C, 0xAC, 0x30, 0x18, 0xA8,
+ 0x98, 0x81, 0x28, 0x34, 0x3C, 0x97, 0x24, 0xA7, 0x28, 0x34, 0x3C, 0x9C, 0x24, 0xF2, 0xB0, 0x89,
+ 0xAC, 0x91, 0x2C, 0x4C, 0x6C, 0x8A, 0x9B, 0x2D, 0xD9, 0xD8, 0xD8, 0x51, 0xD9, 0xD8, 0xD8, 0x79,
+
+ // bank 7, 138 bytes (remainder)
+ 0xD9, 0xD8, 0xD8, 0xF1, 0x9E, 0x88, 0xA3, 0x31, 0xDA, 0xD8, 0xD8, 0x91, 0x2D, 0xD9, 0x28, 0xD8,
+ 0x4D, 0xD9, 0x48, 0xD8, 0x6D, 0xD9, 0x68, 0xD8, 0xB1, 0x83, 0x93, 0x35, 0x3D, 0x80, 0x25, 0xDA,
+ 0xD8, 0xD8, 0x85, 0x69, 0xDA, 0xD8, 0xD8, 0xB4, 0x93, 0x81, 0xA3, 0x28, 0x34, 0x3C, 0xF3, 0xAB,
+ 0x8B, 0xF8, 0xA3, 0x91, 0xB6, 0x09, 0xB4, 0xD9, 0xAB, 0xDE, 0xFA, 0xB0, 0x87, 0x9C, 0xB9, 0xA3,
+ 0xDD, 0xF1, 0xA3, 0xA3, 0xA3, 0xA3, 0x95, 0xF1, 0xA3, 0xA3, 0xA3, 0x9D, 0xF1, 0xA3, 0xA3, 0xA3,
+ 0xA3, 0xF2, 0xA3, 0xB4, 0x90, 0x80, 0xF2, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3,
+ 0xA3, 0xB2, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xB0, 0x87, 0xB5, 0x99, 0xF1, 0xA3, 0xA3, 0xA3,
+ 0x98, 0xF1, 0xA3, 0xA3, 0xA3, 0xA3, 0x97, 0xA3, 0xA3, 0xA3, 0xA3, 0xF3, 0x9B, 0xA3, 0xA3, 0xDC,
+ 0xB9, 0xA7, 0xF1, 0x26, 0x26, 0x26, 0xD8, 0xD8, 0xFF
+};
+
+#define MPU6050_DMP_CONFIG_SIZE 192
+
+// thanks to Noah Zerkin for piecing this stuff together!
+const prog_uchar dmpConfig[MPU6050_DMP_CONFIG_SIZE] PROGMEM = {
+ // BANK OFFSET LENGTH [DATA]
+ 0x03, 0x7B, 0x03, 0x4C, 0xCD, 0x6C, // FCFG_1 inv_set_gyro_calibration
+ 0x03, 0xAB, 0x03, 0x36, 0x56, 0x76, // FCFG_3 inv_set_gyro_calibration
+ 0x00, 0x68, 0x04, 0x02, 0xCB, 0x47, 0xA2, // D_0_104 inv_set_gyro_calibration
+ 0x02, 0x18, 0x04, 0x00, 0x05, 0x8B, 0xC1, // D_0_24 inv_set_gyro_calibration
+ 0x01, 0x0C, 0x04, 0x00, 0x00, 0x00, 0x00, // D_1_152 inv_set_accel_calibration
+ 0x03, 0x7F, 0x06, 0x0C, 0xC9, 0x2C, 0x97, 0x97, 0x97, // FCFG_2 inv_set_accel_calibration
+ 0x03, 0x89, 0x03, 0x26, 0x46, 0x66, // FCFG_7 inv_set_accel_calibration
+ 0x00, 0x6C, 0x02, 0x20, 0x00, // D_0_108 inv_set_accel_calibration
+ 0x02, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_00 inv_set_compass_calibration
+ 0x02, 0x44, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_01
+ 0x02, 0x48, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_02
+ 0x02, 0x4C, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_10
+ 0x02, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_11
+ 0x02, 0x54, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_12
+ 0x02, 0x58, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_20
+ 0x02, 0x5C, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_21
+ 0x02, 0xBC, 0x04, 0x00, 0x00, 0x00, 0x00, // CPASS_MTX_22
+ 0x01, 0xEC, 0x04, 0x00, 0x00, 0x40, 0x00, // D_1_236 inv_apply_endian_accel
+ 0x03, 0x7F, 0x06, 0x0C, 0xC9, 0x2C, 0x97, 0x97, 0x97, // FCFG_2 inv_set_mpu_sensors
+ 0x04, 0x02, 0x03, 0x0D, 0x35, 0x5D, // CFG_MOTION_BIAS inv_turn_on_bias_from_no_motion
+ 0x04, 0x09, 0x04, 0x87, 0x2D, 0x35, 0x3D, // FCFG_5 inv_set_bias_update
+ 0x00, 0xA3, 0x01, 0x00, // D_0_163 inv_set_dead_zone
+ // SPECIAL 0x01 = enable interrupts
+ 0x00, 0x00, 0x00, 0x01, // SET INT_ENABLE at i=22, SPECIAL INSTRUCTION
+ 0x07, 0x86, 0x01, 0xFE, // CFG_6 inv_set_fifo_interupt
+ 0x07, 0x41, 0x05, 0xF1, 0x20, 0x28, 0x30, 0x38, // CFG_8 inv_send_quaternion
+ 0x07, 0x7E, 0x01, 0x30, // CFG_16 inv_set_footer
+ 0x07, 0x46, 0x01, 0x9A, // CFG_GYRO_SOURCE inv_send_gyro
+ 0x07, 0x47, 0x04, 0xF1, 0x28, 0x30, 0x38, // CFG_9 inv_send_gyro -> inv_construct3_fifo
+ 0x07, 0x6C, 0x04, 0xF1, 0x28, 0x30, 0x38, // CFG_12 inv_send_accel -> inv_construct3_fifo
+ 0x02, 0x16, 0x02, 0x00, 0x0A // D_0_22 inv_set_fifo_rate
+};
+
+#endif
+
+#endif /* _MPU6050_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/mpu6050/mpu6050.c b/Firmware/esp-drone/components/drivers/i2c_devices/mpu6050/mpu6050.c
new file mode 100644
index 0000000..5516ab1
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/mpu6050/mpu6050.c
@@ -0,0 +1,3713 @@
+// I2Cdev library collection - MPU6050 I2C device class
+// Based on InvenSense MPU-6050 register map document rev. 2.0, 5/19/2011 (RM-MPU-6000A-00)
+// 8/24/2011 by Jeff Rowberg <[email protected]>
+// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
+
+/* ============================================
+ I2Cdev device library code is placed under the MIT license
+ Copyright (c) 2011 Jeff Rowberg
+ Adapted to Crazyflie FW by Bitcraze
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ ===============================================
+ */
+
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+
+#include "i2cdev.h"
+#include "mpu6050.h"
+#include "eprintf.h"
+#include "stm32_legacy.h"
+#define DEBUG_MODULE "MPU6050"
+#include "debug_cf.h"
+
+static uint8_t devAddr;
+static I2C_Dev *I2Cx;
+static uint8_t buffer[14];
+static bool isInit;
+
+/** Default constructor, uses default I2C address.
+ * @see MPU6050_DEFAULT_ADDRESS
+ */
+void mpu6050Init(I2C_Dev *i2cPort)
+{
+ if (isInit) {
+ return;
+ }
+
+ I2Cx = i2cPort;
+ devAddr = MPU6050_ADDRESS_AD0_LOW;
+ isInit = true;
+
+}
+
+bool mpu6050Test(void)
+{
+ bool testStatus;
+
+ if (!isInit) {
+ return false;
+ }
+
+ testStatus = mpu6050TestConnection();
+
+ return testStatus;
+}
+
+/** Verify the I2C connection.
+ * Make sure the device is connected and responds as expected.
+ * @return True if connection is valid, false otherwise
+ */
+bool mpu6050TestConnection()
+{
+ return mpu6050GetDeviceID() == 0b110100;
+}
+
+/** Do a MPU6050 self test.
+ * @return True if self test passed, false otherwise
+ */
+bool mpu6050SelfTest()
+{
+ bool testStatus = true;
+ int16_t axi16, ayi16, azi16;
+ int16_t gxi16, gyi16, gzi16;
+ float axf, ayf, azf;
+ float gxf, gyf, gzf;
+ float axfTst, ayfTst, azfTst;
+ float gxfTst, gyfTst, gzfTst;
+ float axfDiff, ayfDiff, azfDiff;
+ float gxfDiff, gyfDiff, gzfDiff;
+ float gRange, aRange;
+ uint32_t scrap;
+
+ aRange = mpu6050GetFullScaleAccelGPL();
+ gRange = mpu6050GetFullScaleGyroDPL();
+
+ // First values after startup can be read as zero. Scrap a couple to be sure.
+ for (scrap = 0; scrap < 5; scrap++) {
+ mpu6050GetMotion6(&axi16, &ayi16, &azi16, &gxi16, &gyi16, &gzi16);
+ vTaskDelay(M2T(2));
+ }
+
+ // First measurement
+ gxf = gxi16 * gRange;
+ gyf = gyi16 * gRange;
+ gzf = gzi16 * gRange;
+ axf = axi16 * aRange;
+ ayf = ayi16 * aRange;
+ azf = azi16 * aRange;
+
+ // Enable self test
+ mpu6050SetGyroXSelfTest(true);
+ mpu6050SetGyroYSelfTest(true);
+ mpu6050SetGyroZSelfTest(true);
+ mpu6050SetAccelXSelfTest(true);
+ mpu6050SetAccelYSelfTest(true);
+ mpu6050SetAccelZSelfTest(true);
+
+ // Wait for self test to take effect
+ vTaskDelay(1000 / portTICK_PERIOD_MS);//vTaskDelay(M2T(MPU6050_SELF_TEST_DELAY_MS));
+ // Take second measurement
+ mpu6050GetMotion6(&axi16, &ayi16, &azi16, &gxi16, &gyi16, &gzi16);
+ gxfTst = gxi16 * gRange;
+ gyfTst = gyi16 * gRange;
+ gzfTst = gzi16 * gRange;
+ axfTst = axi16 * aRange;
+ ayfTst = ayi16 * aRange;
+ azfTst = azi16 * aRange;
+
+ // Disable self test
+ mpu6050SetGyroXSelfTest(false);
+ mpu6050SetGyroYSelfTest(false);
+ mpu6050SetGyroZSelfTest(false);
+ mpu6050SetAccelXSelfTest(false);
+ mpu6050SetAccelYSelfTest(false);
+ mpu6050SetAccelZSelfTest(false);
+
+// Read factory values
+// i2cdevReadByte(I2Cx, devAddr, 0x00, (uint8_t *)&gxfi8);
+// i2cdevReadByte(I2Cx, devAddr, 0x01, (uint8_t *)&gyfi8);
+// i2cdevReadByte(I2Cx, devAddr, 0x02, (uint8_t *)&gzfi8);
+// i2cdevReadByte(I2Cx, devAddr, 0x0D, (uint8_t *)&axfi8);
+// i2cdevReadByte(I2Cx, devAddr, 0x0E, (uint8_t *)&ayfi8);
+// i2cdevReadByte(I2Cx, devAddr, 0x0F, (uint8_t *)&azfi8);
+
+// fprintf("gxf:%i, gyf:%i, gzf:%i, axf:%i, ayf:%i, azf:%i\n",
+// (int)gxfi8, (int)gyfi8, (int)gzfi8, (int)axfi8, (int)ayfi8, (int)azfi8);
+
+ // Calculate difference
+ gxfDiff = gxfTst - gxf;
+ gyfDiff = gyfTst - gyf;
+ gzfDiff = gzfTst - gzf;
+ axfDiff = axfTst - axf;
+ ayfDiff = ayfTst - ayf;
+ azfDiff = azfTst - azf;
+
+ // Check result
+ if (mpu6050EvaluateSelfTest(MPU6050_ST_GYRO_LOW, MPU6050_ST_GYRO_HIGH, gxfDiff, "gyro X") &&
+ mpu6050EvaluateSelfTest(-MPU6050_ST_GYRO_HIGH, -MPU6050_ST_GYRO_LOW, gyfDiff, "gyro Y") &&
+ mpu6050EvaluateSelfTest(MPU6050_ST_GYRO_LOW, MPU6050_ST_GYRO_HIGH, gzfDiff, "gyro Z") &&
+ mpu6050EvaluateSelfTest(MPU6050_ST_ACCEL_LOW, MPU6050_ST_ACCEL_HIGH, axfDiff, "acc X") &&
+ mpu6050EvaluateSelfTest(MPU6050_ST_ACCEL_LOW, MPU6050_ST_ACCEL_HIGH, ayfDiff, "acc Y") &&
+ mpu6050EvaluateSelfTest(MPU6050_ST_ACCEL_LOW, MPU6050_ST_ACCEL_HIGH, azfDiff, "acc Z")) {
+ DEBUG_PRINTD("mpu6050 Self test [OK].\n");
+ } else {
+ testStatus = false;
+ }
+
+ return testStatus;
+}
+
+/** Evaluate the values from a MPU6050 self test.
+ * @param low The low limit of the self test
+ * @param high The high limit of the self test
+ * @param value The value to compare with.
+ * @param string A pointer to a string describing the value.
+ * @return True if self test within low - high limit, false otherwise
+ */
+bool mpu6050EvaluateSelfTest(float low, float high, float value, char *string)
+{
+ if (value < low || value > high) {
+ DEBUG_PRINTD("Self test %s [FAIL]. low: %0.2f, high: %0.2f, measured: %0.2f\n",
+ string, (double)low, (double)high, (double)value);
+ return false;
+ }
+
+ return true;
+}
+
+// AUX_VDDIO register (InvenSense demo code calls this RA_*G_OFFS_TC)
+
+/** Get the auxiliary I2C supply voltage level.
+ * When set to 1, the auxiliary I2C bus high logic level is VDD. When cleared to
+ * 0, the auxiliary I2C bus high logic level is VLOGIC. This does not apply to
+ * the MPU-6000, which does not have a VLOGIC pin.
+ * @return I2C supply voltage level (0=VLOGIC, 1=VDD)
+ */
+uint8_t mpu6050GetAuxVDDIOLevel()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_YG_OFFS_TC, MPU6050_TC_PWR_MODE_BIT, buffer);
+ return buffer[0];
+}
+/** Set the auxiliary I2C supply voltage level.
+ * When set to 1, the auxiliary I2C bus high logic level is VDD. When cleared to
+ * 0, the auxiliary I2C bus high logic level is VLOGIC. This does not apply to
+ * the MPU-6000, which does not have a VLOGIC pin.
+ * @param level I2C supply voltage level (0=VLOGIC, 1=VDD)
+ */
+void mpu6050SetAuxVDDIOLevel(uint8_t level)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_YG_OFFS_TC, MPU6050_TC_PWR_MODE_BIT, level);
+}
+
+// SMPLRT_DIV register
+
+/** Get gyroscope output rate divider.
+ * The sensor register output, FIFO output, DMP sampling, Motion detection, Zero
+ * Motion detection, and Free Fall detection are all based on the Sample Rate.
+ * The Sample Rate is generated by dividing the gyroscope output rate by
+ * SMPLRT_DIV:
+ *
+ * Sample Rate = Gyroscope Output Rate / (1 + SMPLRT_DIV)
+ *
+ * where Gyroscope Output Rate = 8kHz when the DLPF is disabled (DLPF_CFG = 0 or
+ * 7), and 1kHz when the DLPF is enabled (see Register 26).
+ *
+ * Note: The accelerometer output rate is 1kHz. This means that for a Sample
+ * Rate greater than 1kHz, the same accelerometer sample may be output to the
+ * FIFO, DMP, and sensor registers more than once.
+ *
+ * For a diagram of the gyroscope and accelerometer signal paths, see Section 8
+ * of the MPU-6000/MPU-6050 Product Specification document.
+ *
+ * @return Current sample rate
+ * @see MPU6050_RA_SMPLRT_DIV
+ */
+uint8_t mpu6050GetRate()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_SMPLRT_DIV, buffer);
+ return buffer[0];
+}
+/** Set gyroscope sample rate divider.
+ * @param rate New sample rate divider
+ * @see getRate()
+ * @see MPU6050_RA_SMPLRT_DIV
+ */
+void mpu6050SetRate(uint8_t rate)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_SMPLRT_DIV, rate);
+}
+
+// CONFIG register
+
+/** Get external FSYNC configuration.
+ * Configures the external Frame Synchronization (FSYNC) pin sampling. An
+ * external signal connected to the FSYNC pin can be sampled by configuring
+ * EXT_SYNC_SET. Signal changes to the FSYNC pin are latched so that short
+ * strobes may be captured. The latched FSYNC signal will be sampled at the
+ * Sampling Rate, as defined in register 25. After sampling, the latch will
+ * reset to the current FSYNC signal state.
+ *
+ * The sampled value will be reported in place of the least significant bit in
+ * a sensor data register determined by the value of EXT_SYNC_SET according to
+ * the following table.
+ *
+ * <pre>
+ * EXT_SYNC_SET | FSYNC Bit Location
+ * -------------+-------------------
+ * 0 | Input disabled
+ * 1 | TEMP_OUT_L[0]
+ * 2 | GYRO_XOUT_L[0]
+ * 3 | GYRO_YOUT_L[0]
+ * 4 | GYRO_ZOUT_L[0]
+ * 5 | ACCEL_XOUT_L[0]
+ * 6 | ACCEL_YOUT_L[0]
+ * 7 | ACCEL_ZOUT_L[0]
+ * </pre>
+ *
+ * @return FSYNC configuration value
+ */
+uint8_t mpu6050GetExternalFrameSync()
+{
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_CONFIG, MPU6050_CFG_EXT_SYNC_SET_BIT,
+ MPU6050_CFG_EXT_SYNC_SET_LENGTH, buffer);
+ return buffer[0];
+}
+/** Set external FSYNC configuration.
+ * @see getExternalFrameSync()
+ * @see MPU6050_RA_CONFIG
+ * @param sync New FSYNC configuration value
+ */
+void mpu6050SetExternalFrameSync(uint8_t sync)
+{
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_CONFIG, MPU6050_CFG_EXT_SYNC_SET_BIT,
+ MPU6050_CFG_EXT_SYNC_SET_LENGTH, sync);
+}
+/** Get digital low-pass filter configuration.
+ * The DLPF_CFG parameter sets the digital low pass filter configuration. It
+ * also determines the internal sampling rate used by the device as shown in
+ * the table below.
+ *
+ * Note: The accelerometer output rate is 1kHz. This means that for a Sample
+ * Rate greater than 1kHz, the same accelerometer sample may be output to the
+ * FIFO, DMP, and sensor registers more than once.
+ *
+ * <pre>
+ * | ACCELEROMETER | GYROSCOPE
+ * DLPF_CFG | Bandwidth | Delay | Bandwidth | Delay | Sample Rate
+ * ---------+-----------+--------+-----------+--------+-------------
+ * 0 | 260Hz | 0ms | 256Hz | 0.98ms | 8kHz
+ * 1 | 184Hz | 2.0ms | 188Hz | 1.9ms | 1kHz
+ * 2 | 94Hz | 3.0ms | 98Hz | 2.8ms | 1kHz
+ * 3 | 44Hz | 4.9ms | 42Hz | 4.8ms | 1kHz
+ * 4 | 21Hz | 8.5ms | 20Hz | 8.3ms | 1kHz
+ * 5 | 10Hz | 13.8ms | 10Hz | 13.4ms | 1kHz
+ * 6 | 5Hz | 19.0ms | 5Hz | 18.6ms | 1kHz
+ * 7 | -- Reserved -- | -- Reserved -- | Reserved
+ * </pre>
+ *
+ * @return DLFP configuration
+ * @see MPU6050_RA_CONFIG
+ * @see MPU6050_CFG_DLPF_CFG_BIT
+ * @see MPU6050_CFG_DLPF_CFG_LENGTH
+ */
+uint8_t mpu6050GetDLPFMode()
+{
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_CONFIG, MPU6050_CFG_DLPF_CFG_BIT,
+ MPU6050_CFG_DLPF_CFG_LENGTH, buffer);
+ return buffer[0];
+}
+/** Set digital low-pass filter configuration.
+ * @param mode New DLFP configuration setting
+ * @see getDLPFBandwidth()
+ * @see MPU6050_DLPF_BW_256
+ * @see MPU6050_RA_CONFIG
+ * @see MPU6050_CFG_DLPF_CFG_BIT
+ * @see MPU6050_CFG_DLPF_CFG_LENGTH
+ */
+void mpu6050SetDLPFMode(uint8_t mode)
+{
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_CONFIG, MPU6050_CFG_DLPF_CFG_BIT,
+ MPU6050_CFG_DLPF_CFG_LENGTH, mode);
+}
+
+// GYRO_CONFIG register
+
+/** Get full-scale gyroscope range id.
+ * The FS_SEL parameter allows setting the full-scale range of the gyro sensors,
+ * as described in the table below.
+ *
+ * <pre>
+ * 0 = +/- 250 degrees/sec
+ * 1 = +/- 500 degrees/sec
+ * 2 = +/- 1000 degrees/sec
+ * 3 = +/- 2000 degrees/sec
+ * </pre>
+ *
+ * @return Current full-scale gyroscope range setting
+ * @see MPU6050_GYRO_FS_250
+ * @see MPU6050_RA_GYRO_CONFIG
+ * @see MPU6050_GCONFIG_FS_SEL_BIT
+ * @see MPU6050_GCONFIG_FS_SEL_LENGTH
+ */
+uint8_t mpu6050GetFullScaleGyroRangeId()
+{
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_GYRO_CONFIG, MPU6050_GCONFIG_FS_SEL_BIT,
+ MPU6050_GCONFIG_FS_SEL_LENGTH, buffer);
+ return buffer[0];
+}
+
+/** Get full-scale gyroscope degrees per LSB.
+ *
+ * @return float of current full-scale gyroscope setting as degrees per LSB
+ * @see MPU6050_GYRO_FS_250
+ * @see MPU6050_RA_GYRO_CONFIG
+ * @see MPU6050_GCONFIG_FS_SEL_BIT
+ * @see MPU6050_GCONFIG_FS_SEL_LENGTH
+ */
+float mpu6050GetFullScaleGyroDPL()
+{
+ int32_t rangeId;
+ float range;
+
+ rangeId = mpu6050GetFullScaleGyroRangeId();
+
+ switch (rangeId) {
+ case MPU6050_GYRO_FS_250:
+ range = MPU6050_DEG_PER_LSB_250;
+ break;
+
+ case MPU6050_GYRO_FS_500:
+ range = MPU6050_DEG_PER_LSB_500;
+ break;
+
+ case MPU6050_GYRO_FS_1000:
+ range = MPU6050_DEG_PER_LSB_1000;
+ break;
+
+ case MPU6050_GYRO_FS_2000:
+ range = MPU6050_DEG_PER_LSB_2000;
+ break;
+
+ default:
+ range = MPU6050_DEG_PER_LSB_1000;
+ break;
+ }
+
+ return range;
+}
+
+/** Set full-scale gyroscope range.
+ * @param range New full-scale gyroscope range value
+ * @see getFullScaleRange()
+ * @see MPU6050_GYRO_FS_250
+ * @see MPU6050_RA_GYRO_CONFIG
+ * @see MPU6050_GCONFIG_FS_SEL_BIT
+ * @see MPU6050_GCONFIG_FS_SEL_LENGTH
+ */
+void mpu6050SetFullScaleGyroRange(uint8_t range)
+{
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_GYRO_CONFIG, MPU6050_GCONFIG_FS_SEL_BIT,
+ MPU6050_GCONFIG_FS_SEL_LENGTH, range);
+}
+
+void mpu6050SetGyroXSelfTest(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_GYRO_CONFIG, MPU6050_GCONFIG_XG_ST_BIT, enabled);
+}
+
+void mpu6050SetGyroYSelfTest(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_GYRO_CONFIG, MPU6050_GCONFIG_YG_ST_BIT, enabled);
+}
+
+void mpu6050SetGyroZSelfTest(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_GYRO_CONFIG, MPU6050_GCONFIG_ZG_ST_BIT, enabled);
+}
+
+// ACCEL_CONFIG register
+
+/** Get self-test enabled setting for accelerometer X axis.
+ * @return Self-test enabled value
+ * @see MPU6050_RA_ACCEL_CONFIG
+ */
+bool mpu6050GetAccelXSelfTest()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_XA_ST_BIT, buffer);
+ return buffer[0];
+}
+/** Get self-test enabled setting for accelerometer X axis.
+ * @param enabled Self-test enabled value
+ * @see MPU6050_RA_ACCEL_CONFIG
+ */
+void mpu6050SetAccelXSelfTest(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_XA_ST_BIT, enabled);
+}
+/** Get self-test enabled value for accelerometer Y axis.
+ * @return Self-test enabled value
+ * @see MPU6050_RA_ACCEL_CONFIG
+ */
+bool mpu6050GetAccelYSelfTest()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_YA_ST_BIT, buffer);
+ return buffer[0];
+}
+/** Get self-test enabled value for accelerometer Y axis.
+ * @param enabled Self-test enabled value
+ * @see MPU6050_RA_ACCEL_CONFIG
+ */
+void mpu6050SetAccelYSelfTest(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_YA_ST_BIT, enabled);
+}
+/** Get self-test enabled value for accelerometer Z axis.
+ * @return Self-test enabled value
+ * @see MPU6050_RA_ACCEL_CONFIG
+ */
+bool mpu6050GetAccelZSelfTest()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_ZA_ST_BIT, buffer);
+ return buffer[0];
+}
+/** Set self-test enabled value for accelerometer Z axis.
+ * @param enabled Self-test enabled value
+ * @see MPU6050_RA_ACCEL_CONFIG
+ */
+void mpu6050SetAccelZSelfTest(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_ZA_ST_BIT, enabled);
+}
+/** Get full-scale accelerometer range.
+ * The FS_SEL parameter allows setting the full-scale range of the accelerometer
+ * sensors, as described in the table below.
+ *
+ * <pre>
+ * 0 = +/- 2g
+ * 1 = +/- 4g
+ * 2 = +/- 8g
+ * 3 = +/- 16g
+ * </pre>
+ *
+ * @return Current full-scale accelerometer range setting
+ * @see MPU6050_ACCEL_FS_2
+ * @see MPU6050_RA_ACCEL_CONFIG
+ * @see MPU6050_ACONFIG_AFS_SEL_BIT
+ * @see MPU6050_ACONFIG_AFS_SEL_LENGTH
+ */
+uint8_t mpu6050GetFullScaleAccelRangeId()
+{
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_AFS_SEL_BIT,
+ MPU6050_ACONFIG_AFS_SEL_LENGTH, buffer);
+ return buffer[0];
+}
+
+/** Get full-scale accelerometer G per LSB.
+ *
+ * @return float of current full-scale accelerometer setting as G per LSB
+ * @see MPU6050_ACCEL_FS_2
+ * @see MPU6050_RA_ACCEL_CONFIG
+ * @see MPU6050_ACONFIG_AFS_SEL_BIT
+ * @see MPU6050_ACONFIG_AFS_SEL_LENGTH
+ */
+float mpu6050GetFullScaleAccelGPL()
+{
+ int32_t rangeId;
+ float range;
+
+ rangeId = mpu6050GetFullScaleAccelRangeId();
+
+ switch (rangeId) {
+ case MPU6050_ACCEL_FS_2:
+ range = MPU6050_G_PER_LSB_2;
+ break;
+
+ case MPU6050_ACCEL_FS_4:
+ range = MPU6050_G_PER_LSB_4;
+ break;
+
+ case MPU6050_ACCEL_FS_8:
+ range = MPU6050_G_PER_LSB_8;
+ break;
+
+ case MPU6050_ACCEL_FS_16:
+ range = MPU6050_G_PER_LSB_16;
+ break;
+
+ default:
+ range = MPU6050_DEG_PER_LSB_1000;
+ break;
+ }
+
+ return range;
+}
+
+/** Set full-scale accelerometer range.
+ * @param range New full-scale accelerometer range setting
+ * @see getFullScaleAccelRange()
+ */
+void mpu6050SetFullScaleAccelRange(uint8_t range)
+{
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_AFS_SEL_BIT,
+ MPU6050_ACONFIG_AFS_SEL_LENGTH, range);
+}
+/** Get the high-pass filter configuration.
+ * The DHPF is a filter module in the path leading to motion detectors (Free
+ * Fall, Motion threshold, and Zero Motion). The high pass filter output is not
+ * available to the data registers (see Figure in Section 8 of the MPU-6000/
+ * MPU-6050 Product Specification document).
+ *
+ * The high pass filter has three modes:
+ *
+ * <pre>
+ * Reset: The filter output settles to zero within one sample. This
+ * effectively disables the high pass filter. This mode may be toggled
+ * to quickly settle the filter.
+ *
+ * On: The high pass filter will pass signals above the cut off frequency.
+ *
+ * Hold: When triggered, the filter holds the present sample. The filter
+ * output will be the difference between the input sample and the held
+ * sample.
+ * </pre>
+ *
+ * <pre>
+ * ACCEL_HPF | Filter Mode | Cut-off Frequency
+ * ----------+-------------+------------------
+ * 0 | Reset | None
+ * 1 | On | 5Hz
+ * 2 | On | 2.5Hz
+ * 3 | On | 1.25Hz
+ * 4 | On | 0.63Hz
+ * 7 | Hold | None
+ * </pre>
+ *
+ * @return Current high-pass filter configuration
+ * @see MPU6050_DHPF_RESET
+ * @see MPU6050_RA_ACCEL_CONFIG
+ */
+uint8_t mpu6050GetDHPFMode()
+{
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_ACCEL_HPF_BIT,
+ MPU6050_ACONFIG_ACCEL_HPF_LENGTH, buffer);
+ return buffer[0];
+}
+/** Set the high-pass filter configuration.
+ * @param bandwidth New high-pass filter configuration
+ * @see setDHPFMode()
+ * @see MPU6050_DHPF_RESET
+ * @see MPU6050_RA_ACCEL_CONFIG
+ */
+void mpu6050SetDHPFMode(uint8_t bandwidth)
+{
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_ACCEL_HPF_BIT,
+ MPU6050_ACONFIG_ACCEL_HPF_LENGTH, bandwidth);
+}
+
+// FF_THR register
+
+/** Get free-fall event acceleration threshold.
+ * This register configures the detection threshold for Free Fall event
+ * detection. The unit of FF_THR is 1LSB = 2mg. Free Fall is detected when the
+ * absolute value of the accelerometer measurements for the three axes are each
+ * less than the detection threshold. This condition increments the Free Fall
+ * duration counter (Register 30). The Free Fall interrupt is triggered when the
+ * Free Fall duration counter reaches the time specified in FF_DUR.
+ *
+ * For more details on the Free Fall detection interrupt, see Section 8.2 of the
+ * MPU-6000/MPU-6050 Product Specification document as well as Registers 56 and
+ * 58 of this document.
+ *
+ * @return Current free-fall acceleration threshold value (LSB = 2mg)
+ * @see MPU6050_RA_FF_THR
+ */
+uint8_t mpu6050GetFreefallDetectionThreshold()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_FF_THR, buffer);
+ return buffer[0];
+}
+/** Get free-fall event acceleration threshold.
+ * @param threshold New free-fall acceleration threshold value (LSB = 2mg)
+ * @see getFreefallDetectionThreshold()
+ * @see MPU6050_RA_FF_THR
+ */
+void mpu6050SetFreefallDetectionThreshold(uint8_t threshold)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_FF_THR, threshold);
+}
+
+// FF_DUR register
+
+/** Get free-fall event duration threshold.
+ * This register configures the duration counter threshold for Free Fall event
+ * detection. The duration counter ticks at 1kHz, therefore FF_DUR has a unit
+ * of 1 LSB = 1 ms.
+ *
+ * The Free Fall duration counter increments while the absolute value of the
+ * accelerometer measurements are each less than the detection threshold
+ * (Register 29). The Free Fall interrupt is triggered when the Free Fall
+ * duration counter reaches the time specified in this register.
+ *
+ * For more details on the Free Fall detection interrupt, see Section 8.2 of
+ * the MPU-6000/MPU-6050 Product Specification document as well as Registers 56
+ * and 58 of this document.
+ *
+ * @return Current free-fall duration threshold value (LSB = 1ms)
+ * @see MPU6050_RA_FF_DUR
+ */
+uint8_t mpu6050GetFreefallDetectionDuration()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_FF_DUR, buffer);
+ return buffer[0];
+}
+/** Get free-fall event duration threshold.
+ * @param duration New free-fall duration threshold value (LSB = 1ms)
+ * @see getFreefallDetectionDuration()
+ * @see MPU6050_RA_FF_DUR
+ */
+void mpu6050SetFreefallDetectionDuration(uint8_t duration)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_FF_DUR, duration);
+}
+
+// MOT_THR register
+
+/** Get motion detection event acceleration threshold.
+ * This register configures the detection threshold for Motion interrupt
+ * generation. The unit of MOT_THR is 1LSB = 2mg. Motion is detected when the
+ * absolute value of any of the accelerometer measurements exceeds this Motion
+ * detection threshold. This condition increments the Motion detection duration
+ * counter (Register 32). The Motion detection interrupt is triggered when the
+ * Motion Detection counter reaches the time count specified in MOT_DUR
+ * (Register 32).
+ *
+ * The Motion interrupt will indicate the axis and polarity of detected motion
+ * in MOT_DETECT_STATUS (Register 97).
+ *
+ * For more details on the Motion detection interrupt, see Section 8.3 of the
+ * MPU-6000/MPU-6050 Product Specification document as well as Registers 56 and
+ * 58 of this document.
+ *
+ * @return Current motion detection acceleration threshold value (LSB = 2mg)
+ * @see MPU6050_RA_MOT_THR
+ */
+uint8_t mpu6050GetMotionDetectionThreshold()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_MOT_THR, buffer);
+ return buffer[0];
+}
+/** Set free-fall event acceleration threshold.
+ * @param threshold New motion detection acceleration threshold value (LSB = 2mg)
+ * @see getMotionDetectionThreshold()
+ * @see MPU6050_RA_MOT_THR
+ */
+void mpu6050SetMotionDetectionThreshold(uint8_t threshold)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_MOT_THR, threshold);
+}
+
+// MOT_DUR register
+
+/** Get motion detection event duration threshold.
+ * This register configures the duration counter threshold for Motion interrupt
+ * generation. The duration counter ticks at 1 kHz, therefore MOT_DUR has a unit
+ * of 1LSB = 1ms. The Motion detection duration counter increments when the
+ * absolute value of any of the accelerometer measurements exceeds the Motion
+ * detection threshold (Register 31). The Motion detection interrupt is
+ * triggered when the Motion detection counter reaches the time count specified
+ * in this register.
+ *
+ * For more details on the Motion detection interrupt, see Section 8.3 of the
+ * MPU-6000/MPU-6050 Product Specification document.
+ *
+ * @return Current motion detection duration threshold value (LSB = 1ms)
+ * @see MPU6050_RA_MOT_DUR
+ */
+uint8_t mpu6050GetMotionDetectionDuration()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_MOT_DUR, buffer);
+ return buffer[0];
+}
+/** Set motion detection event duration threshold.
+ * @param duration New motion detection duration threshold value (LSB = 1ms)
+ * @see getMotionDetectionDuration()
+ * @see MPU6050_RA_MOT_DUR
+ */
+void mpu6050SetMotionDetectionDuration(uint8_t duration)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_MOT_DUR, duration);
+}
+
+// ZRMOT_THR register
+
+/** Get zero motion detection event acceleration threshold.
+ * This register configures the detection threshold for Zero Motion interrupt
+ * generation. The unit of ZRMOT_THR is 1LSB = 2mg. Zero Motion is detected when
+ * the absolute value of the accelerometer measurements for the 3 axes are each
+ * less than the detection threshold. This condition increments the Zero Motion
+ * duration counter (Register 34). The Zero Motion interrupt is triggered when
+ * the Zero Motion duration counter reaches the time count specified in
+ * ZRMOT_DUR (Register 34).
+ *
+ * Unlike Free Fall or Motion detection, Zero Motion detection triggers an
+ * interrupt both when Zero Motion is first detected and when Zero Motion is no
+ * longer detected.
+ *
+ * When a zero motion event is detected, a Zero Motion Status will be indicated
+ * in the MOT_DETECT_STATUS register (Register 97). When a motion-to-zero-motion
+ * condition is detected, the status bit is set to 1. When a zero-motion-to-
+ * motion condition is detected, the status bit is set to 0.
+ *
+ * For more details on the Zero Motion detection interrupt, see Section 8.4 of
+ * the MPU-6000/MPU-6050 Product Specification document as well as Registers 56
+ * and 58 of this document.
+ *
+ * @return Current zero motion detection acceleration threshold value (LSB = 2mg)
+ * @see MPU6050_RA_ZRMOT_THR
+ */
+uint8_t mpu6050GetZeroMotionDetectionThreshold()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_ZRMOT_THR, buffer);
+ return buffer[0];
+}
+/** Set zero motion detection event acceleration threshold.
+ * @param threshold New zero motion detection acceleration threshold value (LSB = 2mg)
+ * @see getZeroMotionDetectionThreshold()
+ * @see MPU6050_RA_ZRMOT_THR
+ */
+void mpu6050SetZeroMotionDetectionThreshold(uint8_t threshold)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_ZRMOT_THR, threshold);
+}
+
+// ZRMOT_DUR register
+
+/** Get zero motion detection event duration threshold.
+ * This register configures the duration counter threshold for Zero Motion
+ * interrupt generation. The duration counter ticks at 16 Hz, therefore
+ * ZRMOT_DUR has a unit of 1 LSB = 64 ms. The Zero Motion duration counter
+ * increments while the absolute value of the accelerometer measurements are
+ * each less than the detection threshold (Register 33). The Zero Motion
+ * interrupt is triggered when the Zero Motion duration counter reaches the time
+ * count specified in this register.
+ *
+ * For more details on the Zero Motion detection interrupt, see Section 8.4 of
+ * the MPU-6000/MPU-6050 Product Specification document, as well as Registers 56
+ * and 58 of this document.
+ *
+ * @return Current zero motion detection duration threshold value (LSB = 64ms)
+ * @see MPU6050_RA_ZRMOT_DUR
+ */
+uint8_t mpu6050GetZeroMotionDetectionDuration()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_ZRMOT_DUR, buffer);
+ return buffer[0];
+}
+/** Set zero motion detection event duration threshold.
+ * @param duration New zero motion detection duration threshold value (LSB = 1ms)
+ * @see getZeroMotionDetectionDuration()
+ * @see MPU6050_RA_ZRMOT_DUR
+ */
+void mpu6050SetZeroMotionDetectionDuration(uint8_t duration)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_ZRMOT_DUR, duration);
+}
+
+// FIFO_EN register
+
+/** Get temperature FIFO enabled value.
+ * When set to 1, this bit enables TEMP_OUT_H and TEMP_OUT_L (Registers 65 and
+ * 66) to be written into the FIFO buffer.
+ * @return Current temperature FIFO enabled value
+ * @see MPU6050_RA_FIFO_EN
+ */
+bool mpu6050GetTempFIFOEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_TEMP_FIFO_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set temperature FIFO enabled value.
+ * @param enabled New temperature FIFO enabled value
+ * @see getTempFIFOEnabled()
+ * @see MPU6050_RA_FIFO_EN
+ */
+void mpu6050SetTempFIFOEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_TEMP_FIFO_EN_BIT, enabled);
+}
+/** Get gyroscope X-axis FIFO enabled value.
+ * When set to 1, this bit enables GYRO_XOUT_H and GYRO_XOUT_L (Registers 67 and
+ * 68) to be written into the FIFO buffer.
+ * @return Current gyroscope X-axis FIFO enabled value
+ * @see MPU6050_RA_FIFO_EN
+ */
+bool mpu6050GetXGyroFIFOEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_XG_FIFO_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set gyroscope X-axis FIFO enabled value.
+ * @param enabled New gyroscope X-axis FIFO enabled value
+ * @see getXGyroFIFOEnabled()
+ * @see MPU6050_RA_FIFO_EN
+ */
+void mpu6050SetXGyroFIFOEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_XG_FIFO_EN_BIT, enabled);
+}
+/** Get gyroscope Y-axis FIFO enabled value.
+ * When set to 1, this bit enables GYRO_YOUT_H and GYRO_YOUT_L (Registers 69 and
+ * 70) to be written into the FIFO buffer.
+ * @return Current gyroscope Y-axis FIFO enabled value
+ * @see MPU6050_RA_FIFO_EN
+ */
+bool mpu6050GetYGyroFIFOEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_YG_FIFO_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set gyroscope Y-axis FIFO enabled value.
+ * @param enabled New gyroscope Y-axis FIFO enabled value
+ * @see getYGyroFIFOEnabled()
+ * @see MPU6050_RA_FIFO_EN
+ */
+void mpu6050SetYGyroFIFOEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_YG_FIFO_EN_BIT, enabled);
+}
+/** Get gyroscope Z-axis FIFO enabled value.
+ * When set to 1, this bit enables GYRO_ZOUT_H and GYRO_ZOUT_L (Registers 71 and
+ * 72) to be written into the FIFO buffer.
+ * @return Current gyroscope Z-axis FIFO enabled value
+ * @see MPU6050_RA_FIFO_EN
+ */
+bool mpu6050GetZGyroFIFOEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_ZG_FIFO_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set gyroscope Z-axis FIFO enabled value.
+ * @param enabled New gyroscope Z-axis FIFO enabled value
+ * @see getZGyroFIFOEnabled()
+ * @see MPU6050_RA_FIFO_EN
+ */
+void mpu6050SetZGyroFIFOEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_ZG_FIFO_EN_BIT, enabled);
+}
+/** Get accelerometer FIFO enabled value.
+ * When set to 1, this bit enables ACCEL_XOUT_H, ACCEL_XOUT_L, ACCEL_YOUT_H,
+ * ACCEL_YOUT_L, ACCEL_ZOUT_H, and ACCEL_ZOUT_L (Registers 59 to 64) to be
+ * written into the FIFO buffer.
+ * @return Current accelerometer FIFO enabled value
+ * @see MPU6050_RA_FIFO_EN
+ */
+bool mpu6050GetAccelFIFOEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_ACCEL_FIFO_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set accelerometer FIFO enabled value.
+ * @param enabled New accelerometer FIFO enabled value
+ * @see getAccelFIFOEnabled()
+ * @see MPU6050_RA_FIFO_EN
+ */
+void mpu6050SetAccelFIFOEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_ACCEL_FIFO_EN_BIT, enabled);
+}
+/** Get Slave 2 FIFO enabled value.
+ * When set to 1, this bit enables EXT_SENS_DATA registers (Registers 73 to 96)
+ * associated with Slave 2 to be written into the FIFO buffer.
+ * @return Current Slave 2 FIFO enabled value
+ * @see MPU6050_RA_FIFO_EN
+ */
+bool mpu6050GetSlave2FIFOEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_SLV2_FIFO_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set Slave 2 FIFO enabled value.
+ * @param enabled New Slave 2 FIFO enabled value
+ * @see getSlave2FIFOEnabled()
+ * @see MPU6050_RA_FIFO_EN
+ */
+void mpu6050SetSlave2FIFOEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_SLV2_FIFO_EN_BIT, enabled);
+}
+/** Get Slave 1 FIFO enabled value.
+ * When set to 1, this bit enables EXT_SENS_DATA registers (Registers 73 to 96)
+ * associated with Slave 1 to be written into the FIFO buffer.
+ * @return Current Slave 1 FIFO enabled value
+ * @see MPU6050_RA_FIFO_EN
+ */
+bool mpu6050GetSlave1FIFOEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_SLV1_FIFO_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set Slave 1 FIFO enabled value.
+ * @param enabled New Slave 1 FIFO enabled value
+ * @see getSlave1FIFOEnabled()
+ * @see MPU6050_RA_FIFO_EN
+ */
+void mpu6050SetSlave1FIFOEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_SLV1_FIFO_EN_BIT, enabled);
+}
+/** Get Slave 0 FIFO enabled value.
+ * When set to 1, this bit enables EXT_SENS_DATA registers (Registers 73 to 96)
+ * associated with Slave 0 to be written into the FIFO buffer.
+ * @return Current Slave 0 FIFO enabled value
+ * @see MPU6050_RA_FIFO_EN
+ */
+bool mpu6050GetSlave0FIFOEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_SLV0_FIFO_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set Slave 0 FIFO enabled value.
+ * @param enabled New Slave 0 FIFO enabled value
+ * @see getSlave0FIFOEnabled()
+ * @see MPU6050_RA_FIFO_EN
+ */
+void mpu6050SetSlave0FIFOEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_SLV0_FIFO_EN_BIT, enabled);
+}
+
+// I2C_MST_CTRL register
+
+/** Get multi-master enabled value.
+ * Multi-master capability allows multiple I2C masters to operate on the same
+ * bus. In circuits where multi-master capability is required, set MULT_MST_EN
+ * to 1. This will increase current drawn by approximately 30uA.
+ *
+ * In circuits where multi-master capability is required, the state of the I2C
+ * bus must always be monitored by each separate I2C Master. Before an I2C
+ * Master can assume arbitration of the bus, it must first confirm that no other
+ * I2C Master has arbitration of the bus. When MULT_MST_EN is set to 1, the
+ * MPU-60X0's bus arbitration detection logic is turned on, enabling it to
+ * detect when the bus is available.
+ *
+ * @return Current multi-master enabled value
+ * @see MPU6050_RA_I2C_MST_CTRL
+ */
+bool mpu6050GetMultiMasterEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_MULT_MST_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set multi-master enabled value.
+ * @param enabled New multi-master enabled value
+ * @see getMultiMasterEnabled()
+ * @see MPU6050_RA_I2C_MST_CTRL
+ */
+void mpu6050SetMultiMasterEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_MULT_MST_EN_BIT, enabled);
+}
+/** Get wait-for-external-sensor-data enabled value.
+ * When the WAIT_FOR_ES bit is set to 1, the Data Ready interrupt will be
+ * delayed until External Sensor data from the Slave Devices are loaded into the
+ * EXT_SENS_DATA registers. This is used to ensure that both the internal sensor
+ * data (i.e. from gyro and accel) and external sensor data have been loaded to
+ * their respective data registers (i.e. the data is synced) when the Data Ready
+ * interrupt is triggered.
+ *
+ * @return Current wait-for-external-sensor-data enabled value
+ * @see MPU6050_RA_I2C_MST_CTRL
+ */
+bool mpu6050GetWaitForExternalSensorEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_WAIT_FOR_ES_BIT, buffer);
+ return buffer[0];
+}
+/** Set wait-for-external-sensor-data enabled value.
+ * @param enabled New wait-for-external-sensor-data enabled value
+ * @see getWaitForExternalSensorEnabled()
+ * @see MPU6050_RA_I2C_MST_CTRL
+ */
+void mpu6050SetWaitForExternalSensorEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_WAIT_FOR_ES_BIT, enabled);
+}
+/** Get Slave 3 FIFO enabled value.
+ * When set to 1, this bit enables EXT_SENS_DATA registers (Registers 73 to 96)
+ * associated with Slave 3 to be written into the FIFO buffer.
+ * @return Current Slave 3 FIFO enabled value
+ * @see MPU6050_RA_MST_CTRL
+ */
+bool mpu6050GetSlave3FIFOEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_SLV_3_FIFO_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set Slave 3 FIFO enabled value.
+ * @param enabled New Slave 3 FIFO enabled value
+ * @see getSlave3FIFOEnabled()
+ * @see MPU6050_RA_MST_CTRL
+ */
+void mpu6050SetSlave3FIFOEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_SLV_3_FIFO_EN_BIT, enabled);
+}
+/** Get slave read/write transition enabled value.
+ * The I2C_MST_P_NSR bit configures the I2C Master's transition from one slave
+ * read to the next slave read. If the bit equals 0, there will be a restart
+ * between reads. If the bit equals 1, there will be a stop followed by a start
+ * of the following read. When a write transaction follows a read transaction,
+ * the stop followed by a start of the successive write will be always used.
+ *
+ * @return Current slave read/write transition enabled value
+ * @see MPU6050_RA_I2C_MST_CTRL
+ */
+bool mpu6050GetSlaveReadWriteTransitionEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_I2C_MST_P_NSR_BIT, buffer);
+ return buffer[0];
+}
+/** Set slave read/write transition enabled value.
+ * @param enabled New slave read/write transition enabled value
+ * @see getSlaveReadWriteTransitionEnabled()
+ * @see MPU6050_RA_I2C_MST_CTRL
+ */
+void mpu6050SetSlaveReadWriteTransitionEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_I2C_MST_P_NSR_BIT, enabled);
+}
+/** Get I2C master clock speed.
+ * I2C_MST_CLK is a 4 bit unsigned value which configures a divider on the
+ * MPU-60X0 internal 8MHz clock. It sets the I2C master clock speed according to
+ * the following table:
+ *
+ * <pre>
+ * I2C_MST_CLK | I2C Master Clock Speed | 8MHz Clock Divider
+ * ------------+------------------------+-------------------
+ * 0 | 348kHz | 23
+ * 1 | 333kHz | 24
+ * 2 | 320kHz | 25
+ * 3 | 308kHz | 26
+ * 4 | 296kHz | 27
+ * 5 | 286kHz | 28
+ * 6 | 276kHz | 29
+ * 7 | 267kHz | 30
+ * 8 | 258kHz | 31
+ * 9 | 500kHz | 16
+ * 10 | 471kHz | 17
+ * 11 | 444kHz | 18
+ * 12 | 421kHz | 19
+ * 13 | 400kHz | 20
+ * 14 | 381kHz | 21
+ * 15 | 364kHz | 22
+ * </pre>
+ *
+ * @return Current I2C master clock speed
+ * @see MPU6050_RA_I2C_MST_CTRL
+ */
+uint8_t mpu6050GetMasterClockSpeed()
+{
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_I2C_MST_CLK_BIT,
+ MPU6050_I2C_MST_CLK_LENGTH, buffer);
+ return buffer[0];
+}
+/** Set I2C master clock speed.
+ * @reparam speed Current I2C master clock speed
+ * @see MPU6050_RA_I2C_MST_CTRL
+ */
+void mpu6050SetMasterClockSpeed(uint8_t speed)
+{
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_I2C_MST_CLK_BIT,
+ MPU6050_I2C_MST_CLK_LENGTH, speed);
+}
+
+// I2C_SLV* registers (Slave 0-3)
+
+/** Get the I2C address of the specified slave (0-3).
+ * Note that Bit 7 (MSB) controls read/write mode. If Bit 7 is set, it's a read
+ * operation, and if it is cleared, then it's a write operation. The remaining
+ * bits (6-0) are the 7-bit device address of the slave device.
+ *
+ * In read mode, the result of the read is placed in the lowest available
+ * EXT_SENS_DATA register. For further information regarding the allocation of
+ * read results, please refer to the EXT_SENS_DATA register description
+ * (Registers 73 - 96).
+ *
+ * The MPU-6050 supports a total of five slaves, but Slave 4 has unique
+ * characteristics, and so it has its own functions (getSlave4* and setSlave4*).
+ *
+ * I2C data transactions are performed at the Sample Rate, as defined in
+ * Register 25. The user is responsible for ensuring that I2C data transactions
+ * to and from each enabled Slave can be completed within a single period of the
+ * Sample Rate.
+ *
+ * The I2C slave access rate can be reduced relative to the Sample Rate. This
+ * reduced access rate is determined by I2C_MST_DLY (Register 52). Whether a
+ * slave's access rate is reduced relative to the Sample Rate is determined by
+ * I2C_MST_DELAY_CTRL (Register 103).
+ *
+ * The processing order for the slaves is fixed. The sequence followed for
+ * processing the slaves is Slave 0, Slave 1, Slave 2, Slave 3 and Slave 4. If a
+ * particular Slave is disabled it will be skipped.
+ *
+ * Each slave can either be accessed at the sample rate or at a reduced sample
+ * rate. In a case where some slaves are accessed at the Sample Rate and some
+ * slaves are accessed at the reduced rate, the sequence of accessing the slaves
+ * (Slave 0 to Slave 4) is still followed. However, the reduced rate slaves will
+ * be skipped if their access rate dictates that they should not be accessed
+ * during that particular cycle. For further information regarding the reduced
+ * access rate, please refer to Register 52. Whether a slave is accessed at the
+ * Sample Rate or at the reduced rate is determined by the Delay Enable bits in
+ * Register 103.
+ *
+ * @param num Slave number (0-3)
+ * @return Current address for specified slave
+ * @see MPU6050_RA_I2C_SLV0_ADDR
+ */
+uint8_t mpu6050GetSlaveAddress(uint8_t num)
+{
+ if (num > 3) {
+ return 0;
+ }
+
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_ADDR + num * 3, buffer);
+ return buffer[0];
+}
+/** Set the I2C address of the specified slave (0-3).
+ * @param num Slave number (0-3)
+ * @param address New address for specified slave
+ * @see getSlaveAddress()
+ * @see MPU6050_RA_I2C_SLV0_ADDR
+ */
+void mpu6050SetSlaveAddress(uint8_t num, uint8_t address)
+{
+ if (num > 3) {
+ return;
+ }
+
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_ADDR + num * 3, address);
+}
+/** Get the active internal register for the specified slave (0-3).
+ * Read/write operations for this slave will be done to whatever internal
+ * register address is stored in this MPU register.
+ *
+ * The MPU-6050 supports a total of five slaves, but Slave 4 has unique
+ * characteristics, and so it has its own functions.
+ *
+ * @param num Slave number (0-3)
+ * @return Current active register for specified slave
+ * @see MPU6050_RA_I2C_SLV0_REG
+ */
+uint8_t mpu6050GetSlaveRegister(uint8_t num)
+{
+ if (num > 3) {
+ return 0;
+ }
+
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_REG + num * 3, buffer);
+ return buffer[0];
+}
+/** Set the active internal register for the specified slave (0-3).
+ * @param num Slave number (0-3)
+ * @param reg New active register for specified slave
+ * @see getSlaveRegister()
+ * @see MPU6050_RA_I2C_SLV0_REG
+ */
+void mpu6050SetSlaveRegister(uint8_t num, uint8_t reg)
+{
+ if (num > 3) {
+ return;
+ }
+
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_REG + num * 3, reg);
+}
+/** Get the enabled value for the specified slave (0-3).
+ * When set to 1, this bit enables Slave 0 for data transfer operations. When
+ * cleared to 0, this bit disables Slave 0 from data transfer operations.
+ * @param num Slave number (0-3)
+ * @return Current enabled value for specified slave
+ * @see MPU6050_RA_I2C_SLV0_CTRL
+ */
+bool mpu6050GetSlaveEnabled(uint8_t num)
+{
+ if (num > 3) {
+ return 0;
+ }
+
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set the enabled value for the specified slave (0-3).
+ * @param num Slave number (0-3)
+ * @param enabled New enabled value for specified slave
+ * @see getSlaveEnabled()
+ * @see MPU6050_RA_I2C_SLV0_CTRL
+ */
+void mpu6050SetSlaveEnabled(uint8_t num, bool enabled)
+{
+ if (num > 3) {
+ return;
+ }
+
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_EN_BIT,
+ enabled);
+}
+/** Get word pair byte-swapping enabled for the specified slave (0-3).
+ * When set to 1, this bit enables byte swapping. When byte swapping is enabled,
+ * the high and low bytes of a word pair are swapped. Please refer to
+ * I2C_SLV0_GRP for the pairing convention of the word pairs. When cleared to 0,
+ * bytes transferred to and from Slave 0 will be written to EXT_SENS_DATA
+ * registers in the order they were transferred.
+ *
+ * @param num Slave number (0-3)
+ * @return Current word pair byte-swapping enabled value for specified slave
+ * @see MPU6050_RA_I2C_SLV0_CTRL
+ */
+bool mpu6050GetSlaveWordByteSwap(uint8_t num)
+{
+ if (num > 3) {
+ return 0;
+ }
+
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_BYTE_SW_BIT,
+ buffer);
+ return buffer[0];
+}
+/** Set word pair byte-swapping enabled for the specified slave (0-3).
+ * @param num Slave number (0-3)
+ * @param enabled New word pair byte-swapping enabled value for specified slave
+ * @see getSlaveWordByteSwap()
+ * @see MPU6050_RA_I2C_SLV0_CTRL
+ */
+void mpu6050SetSlaveWordByteSwap(uint8_t num, bool enabled)
+{
+ if (num > 3) {
+ return;
+ }
+
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_BYTE_SW_BIT,
+ enabled);
+}
+/** Get write mode for the specified slave (0-3).
+ * When set to 1, the transaction will read or write data only. When cleared to
+ * 0, the transaction will write a register address prior to reading or writing
+ * data. This should equal 0 when specifying the register address within the
+ * Slave device to/from which the ensuing data transaction will take place.
+ *
+ * @param num Slave number (0-3)
+ * @return Current write mode for specified slave (0 = register address + data, 1 = data only)
+ * @see MPU6050_RA_I2C_SLV0_CTRL
+ */
+bool mpu6050GetSlaveWriteMode(uint8_t num)
+{
+ if (num > 3) {
+ return 0;
+ }
+
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_REG_DIS_BIT,
+ buffer);
+ return buffer[0];
+}
+/** Set write mode for the specified slave (0-3).
+ * @param num Slave number (0-3)
+ * @param mode New write mode for specified slave (0 = register address + data, 1 = data only)
+ * @see getSlaveWriteMode()
+ * @see MPU6050_RA_I2C_SLV0_CTRL
+ */
+void mpu6050SetSlaveWriteMode(uint8_t num, bool mode)
+{
+ if (num > 3) {
+ return;
+ }
+
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_REG_DIS_BIT,
+ mode);
+}
+/** Get word pair grouping order offset for the specified slave (0-3).
+ * This sets specifies the grouping order of word pairs received from registers.
+ * When cleared to 0, bytes from register addresses 0 and 1, 2 and 3, etc (even,
+ * then odd register addresses) are paired to form a word. When set to 1, bytes
+ * from register addresses are paired 1 and 2, 3 and 4, etc. (odd, then even
+ * register addresses) are paired to form a word.
+ *
+ * @param num Slave number (0-3)
+ * @return Current word pair grouping order offset for specified slave
+ * @see MPU6050_RA_I2C_SLV0_CTRL
+ */
+bool mpu6050GetSlaveWordGroupOffset(uint8_t num)
+{
+ if (num > 3) {
+ return 0;
+ }
+
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_GRP_BIT, buffer);
+ return buffer[0];
+}
+/** Set word pair grouping order offset for the specified slave (0-3).
+ * @param num Slave number (0-3)
+ * @param enabled New word pair grouping order offset for specified slave
+ * @see getSlaveWordGroupOffset()
+ * @see MPU6050_RA_I2C_SLV0_CTRL
+ */
+void mpu6050SetSlaveWordGroupOffset(uint8_t num, bool enabled)
+{
+ if (num > 3) {
+ return;
+ }
+
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_GRP_BIT,
+ enabled);
+}
+/** Get number of bytes to read for the specified slave (0-3).
+ * Specifies the number of bytes transferred to and from Slave 0. Clearing this
+ * bit to 0 is equivalent to disabling the register by writing 0 to I2C_SLV0_EN.
+ * @param num Slave number (0-3)
+ * @return Number of bytes to read for specified slave
+ * @see MPU6050_RA_I2C_SLV0_CTRL
+ */
+uint8_t mpu6050GetSlaveDataLength(uint8_t num)
+{
+ if (num > 3) {
+ return 0;
+ }
+
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_LEN_BIT,
+ MPU6050_I2C_SLV_LEN_LENGTH, buffer);
+ return buffer[0];
+}
+/** Set number of bytes to read for the specified slave (0-3).
+ * @param num Slave number (0-3)
+ * @param length Number of bytes to read for specified slave
+ * @see getSlaveDataLength()
+ * @see MPU6050_RA_I2C_SLV0_CTRL
+ */
+void mpu6050SetSlaveDataLength(uint8_t num, uint8_t length)
+{
+ if (num > 3) {
+ return;
+ }
+
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_LEN_BIT,
+ MPU6050_I2C_SLV_LEN_LENGTH, length);
+}
+
+// I2C_SLV* registers (Slave 4)
+
+/** Get the I2C address of Slave 4.
+ * Note that Bit 7 (MSB) controls read/write mode. If Bit 7 is set, it's a read
+ * operation, and if it is cleared, then it's a write operation. The remaining
+ * bits (6-0) are the 7-bit device address of the slave device.
+ *
+ * @return Current address for Slave 4
+ * @see getSlaveAddress()
+ * @see MPU6050_RA_I2C_SLV4_ADDR
+ */
+uint8_t mpu6050GetSlave4Address()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_ADDR, buffer);
+ return buffer[0];
+}
+/** Set the I2C address of Slave 4.
+ * @param address New address for Slave 4
+ * @see getSlave4Address()
+ * @see MPU6050_RA_I2C_SLV4_ADDR
+ */
+void mpu6050SetSlave4Address(uint8_t address)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_ADDR, address);
+}
+/** Get the active internal register for the Slave 4.
+ * Read/write operations for this slave will be done to whatever internal
+ * register address is stored in this MPU register.
+ *
+ * @return Current active register for Slave 4
+ * @see MPU6050_RA_I2C_SLV4_REG
+ */
+uint8_t mpu6050GetSlave4Register()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_REG, buffer);
+ return buffer[0];
+}
+/** Set the active internal register for Slave 4.
+ * @param reg New active register for Slave 4
+ * @see getSlave4Register()
+ * @see MPU6050_RA_I2C_SLV4_REG
+ */
+void mpu6050SetSlave4Register(uint8_t reg)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_REG, reg);
+}
+/** Set new byte to write to Slave 4.
+ * This register stores the data to be written into the Slave 4. If I2C_SLV4_RW
+ * is set 1 (set to read), this register has no effect.
+ * @param data New byte to write to Slave 4
+ * @see MPU6050_RA_I2C_SLV4_DO
+ */
+void mpu6050SetSlave4OutputByte(uint8_t data)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_DO, data);
+}
+/** Get the enabled value for the Slave 4.
+ * When set to 1, this bit enables Slave 4 for data transfer operations. When
+ * cleared to 0, this bit disables Slave 4 from data transfer operations.
+ * @return Current enabled value for Slave 4
+ * @see MPU6050_RA_I2C_SLV4_CTRL
+ */
+bool mpu6050GetSlave4Enabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set the enabled value for Slave 4.
+ * @param enabled New enabled value for Slave 4
+ * @see getSlave4Enabled()
+ * @see MPU6050_RA_I2C_SLV4_CTRL
+ */
+void mpu6050SetSlave4Enabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_EN_BIT, enabled);
+}
+/** Get the enabled value for Slave 4 transaction interrupts.
+ * When set to 1, this bit enables the generation of an interrupt signal upon
+ * completion of a Slave 4 transaction. When cleared to 0, this bit disables the
+ * generation of an interrupt signal upon completion of a Slave 4 transaction.
+ * The interrupt status can be observed in Register 54.
+ *
+ * @return Current enabled value for Slave 4 transaction interrupts.
+ * @see MPU6050_RA_I2C_SLV4_CTRL
+ */
+bool mpu6050GetSlave4InterruptEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_INT_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set the enabled value for Slave 4 transaction interrupts.
+ * @param enabled New enabled value for Slave 4 transaction interrupts.
+ * @see getSlave4InterruptEnabled()
+ * @see MPU6050_RA_I2C_SLV4_CTRL
+ */
+void mpu6050SetSlave4InterruptEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_INT_EN_BIT, enabled);
+}
+/** Get write mode for Slave 4.
+ * When set to 1, the transaction will read or write data only. When cleared to
+ * 0, the transaction will write a register address prior to reading or writing
+ * data. This should equal 0 when specifying the register address within the
+ * Slave device to/from which the ensuing data transaction will take place.
+ *
+ * @return Current write mode for Slave 4 (0 = register address + data, 1 = data only)
+ * @see MPU6050_RA_I2C_SLV4_CTRL
+ */
+bool mpu6050GetSlave4WriteMode()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_REG_DIS_BIT, buffer);
+ return buffer[0];
+}
+/** Set write mode for the Slave 4.
+ * @param mode New write mode for Slave 4 (0 = register address + data, 1 = data only)
+ * @see getSlave4WriteMode()
+ * @see MPU6050_RA_I2C_SLV4_CTRL
+ */
+void mpu6050SetSlave4WriteMode(bool mode)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_REG_DIS_BIT, mode);
+}
+/** Get Slave 4 master delay value.
+ * This configures the reduced access rate of I2C slaves relative to the Sample
+ * Rate. When a slave's access rate is decreased relative to the Sample Rate,
+ * the slave is accessed every:
+ *
+ * 1 / (1 + I2C_MST_DLY) samples
+ *
+ * This base Sample Rate in turn is determined by SMPLRT_DIV (register 25) and
+ * DLPF_CFG (register 26). Whether a slave's access rate is reduced relative to
+ * the Sample Rate is determined by I2C_MST_DELAY_CTRL (register 103). For
+ * further information regarding the Sample Rate, please refer to register 25.
+ *
+ * @return Current Slave 4 master delay value
+ * @see MPU6050_RA_I2C_SLV4_CTRL
+ */
+uint8_t mpu6050GetSlave4MasterDelay()
+{
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_MST_DLY_BIT,
+ MPU6050_I2C_SLV4_MST_DLY_LENGTH, buffer);
+ return buffer[0];
+}
+/** Set Slave 4 master delay value.
+ * @param delay New Slave 4 master delay value
+ * @see getSlave4MasterDelay()
+ * @see MPU6050_RA_I2C_SLV4_CTRL
+ */
+void mpu6050SetSlave4MasterDelay(uint8_t delay)
+{
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_MST_DLY_BIT,
+ MPU6050_I2C_SLV4_MST_DLY_LENGTH, delay);
+}
+/** Get last available byte read from Slave 4.
+ * This register stores the data read from Slave 4. This field is populated
+ * after a read transaction.
+ * @return Last available byte read from to Slave 4
+ * @see MPU6050_RA_I2C_SLV4_DI
+ */
+uint8_t mpu6050GetSlate4InputByte()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_DI, buffer);
+ return buffer[0];
+}
+
+// I2C_MST_STATUS register
+
+/** Get FSYNC interrupt status.
+ * This bit reflects the status of the FSYNC interrupt from an external device
+ * into the MPU-60X0. This is used as a way to pass an external interrupt
+ * through the MPU-60X0 to the host application processor. When set to 1, this
+ * bit will cause an interrupt if FSYNC_INT_EN is asserted in INT_PIN_CFG
+ * (Register 55).
+ * @return FSYNC interrupt status
+ * @see MPU6050_RA_I2C_MST_STATUS
+ */
+bool mpu6050GetPassthroughStatus()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_PASS_THROUGH_BIT, buffer);
+ return buffer[0];
+}
+/** Get Slave 4 transaction done status.
+ * Automatically sets to 1 when a Slave 4 transaction has completed. This
+ * triggers an interrupt if the I2C_MST_INT_EN bit in the INT_ENABLE register
+ * (Register 56) is asserted and if the SLV_4_DONE_INT bit is asserted in the
+ * I2C_SLV4_CTRL register (Register 52).
+ * @return Slave 4 transaction done status
+ * @see MPU6050_RA_I2C_MST_STATUS
+ */
+bool mpu6050GetSlave4IsDone()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV4_DONE_BIT, buffer);
+ return buffer[0];
+}
+/** Get master arbitration lost status.
+ * This bit automatically sets to 1 when the I2C Master has lost arbitration of
+ * the auxiliary I2C bus (an error condition). This triggers an interrupt if the
+ * I2C_MST_INT_EN bit in the INT_ENABLE register (Register 56) is asserted.
+ * @return Master arbitration lost status
+ * @see MPU6050_RA_I2C_MST_STATUS
+ */
+bool mpu6050GetLostArbitration()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_LOST_ARB_BIT, buffer);
+ return buffer[0];
+}
+/** Get Slave 4 NACK status.
+ * This bit automatically sets to 1 when the I2C Master receives a NACK in a
+ * transaction with Slave 4. This triggers an interrupt if the I2C_MST_INT_EN
+ * bit in the INT_ENABLE register (Register 56) is asserted.
+ * @return Slave 4 NACK interrupt status
+ * @see MPU6050_RA_I2C_MST_STATUS
+ */
+bool mpu6050GetSlave4Nack()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV4_NACK_BIT, buffer);
+ return buffer[0];
+}
+/** Get Slave 3 NACK status.
+ * This bit automatically sets to 1 when the I2C Master receives a NACK in a
+ * transaction with Slave 3. This triggers an interrupt if the I2C_MST_INT_EN
+ * bit in the INT_ENABLE register (Register 56) is asserted.
+ * @return Slave 3 NACK interrupt status
+ * @see MPU6050_RA_I2C_MST_STATUS
+ */
+bool mpu6050GetSlave3Nack()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV3_NACK_BIT, buffer);
+ return buffer[0];
+}
+/** Get Slave 2 NACK status.
+ * This bit automatically sets to 1 when the I2C Master receives a NACK in a
+ * transaction with Slave 2. This triggers an interrupt if the I2C_MST_INT_EN
+ * bit in the INT_ENABLE register (Register 56) is asserted.
+ * @return Slave 2 NACK interrupt status
+ * @see MPU6050_RA_I2C_MST_STATUS
+ */
+bool mpu6050GetSlave2Nack()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV2_NACK_BIT, buffer);
+ return buffer[0];
+}
+/** Get Slave 1 NACK status.
+ * This bit automatically sets to 1 when the I2C Master receives a NACK in a
+ * transaction with Slave 1. This triggers an interrupt if the I2C_MST_INT_EN
+ * bit in the INT_ENABLE register (Register 56) is asserted.
+ * @return Slave 1 NACK interrupt status
+ * @see MPU6050_RA_I2C_MST_STATUS
+ */
+bool mpu6050GetSlave1Nack()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV1_NACK_BIT, buffer);
+ return buffer[0];
+}
+/** Get Slave 0 NACK status.
+ * This bit automatically sets to 1 when the I2C Master receives a NACK in a
+ * transaction with Slave 0. This triggers an interrupt if the I2C_MST_INT_EN
+ * bit in the INT_ENABLE register (Register 56) is asserted.
+ * @return Slave 0 NACK interrupt status
+ * @see MPU6050_RA_I2C_MST_STATUS
+ */
+bool mpu6050GetSlave0Nack()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV0_NACK_BIT, buffer);
+ return buffer[0];
+}
+
+// INT_PIN_CFG register
+
+/** Get interrupt logic level mode.
+ * Will be set 0 for active-high, 1 for active-low.
+ * @return Current interrupt mode (0=active-high, 1=active-low)
+ * @see MPU6050_RA_INT_PIN_CFG
+ * @see MPU6050_INTCFG_INT_LEVEL_BIT
+ */
+bool mpu6050GetInterruptMode()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_LEVEL_BIT, buffer);
+ return buffer[0];
+}
+/** Set interrupt logic level mode.
+ * @param mode New interrupt mode (0=active-high, 1=active-low)
+ * @see getInterruptMode()
+ * @see MPU6050_RA_INT_PIN_CFG
+ * @see MPU6050_INTCFG_INT_LEVEL_BIT
+ */
+void mpu6050SetInterruptMode(bool mode)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_LEVEL_BIT, mode);
+}
+/** Get interrupt drive mode.
+ * Will be set 0 for push-pull, 1 for open-drain.
+ * @return Current interrupt drive mode (0=push-pull, 1=open-drain)
+ * @see MPU6050_RA_INT_PIN_CFG
+ * @see MPU6050_INTCFG_INT_OPEN_BIT
+ */
+bool mpu6050GetInterruptDrive()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_OPEN_BIT, buffer);
+ return buffer[0];
+}
+/** Set interrupt drive mode.
+ * @param drive New interrupt drive mode (0=push-pull, 1=open-drain)
+ * @see getInterruptDrive()
+ * @see MPU6050_RA_INT_PIN_CFG
+ * @see MPU6050_INTCFG_INT_OPEN_BIT
+ */
+void mpu6050SetInterruptDrive(bool drive)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_OPEN_BIT, drive);
+}
+/** Get interrupt latch mode.
+ * Will be set 0 for 50us-pulse, 1 for latch-until-int-cleared.
+ * @return Current latch mode (0=50us-pulse, 1=latch-until-int-cleared)
+ * @see MPU6050_RA_INT_PIN_CFG
+ * @see MPU6050_INTCFG_LATCH_INT_EN_BIT
+ */
+bool mpu6050GetInterruptLatch()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_LATCH_INT_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set interrupt latch mode.
+ * @param latch New latch mode (0=50us-pulse, 1=latch-until-int-cleared)
+ * @see getInterruptLatch()
+ * @see MPU6050_RA_INT_PIN_CFG
+ * @see MPU6050_INTCFG_LATCH_INT_EN_BIT
+ */
+void mpu6050SetInterruptLatch(bool latch)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_LATCH_INT_EN_BIT, latch);
+}
+/** Get interrupt latch clear mode.
+ * Will be set 0 for status-read-only, 1 for any-register-read.
+ * @return Current latch clear mode (0=status-read-only, 1=any-register-read)
+ * @see MPU6050_RA_INT_PIN_CFG
+ * @see MPU6050_INTCFG_INT_RD_CLEAR_BIT
+ */
+bool mpu6050GetInterruptLatchClear()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_RD_CLEAR_BIT, buffer);
+ return buffer[0];
+}
+/** Set interrupt latch clear mode.
+ * @param clear New latch clear mode (0=status-read-only, 1=any-register-read)
+ * @see getInterruptLatchClear()
+ * @see MPU6050_RA_INT_PIN_CFG
+ * @see MPU6050_INTCFG_INT_RD_CLEAR_BIT
+ */
+void mpu6050SetInterruptLatchClear(bool clear)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_RD_CLEAR_BIT, clear);
+}
+/** Get FSYNC interrupt logic level mode.
+ * @return Current FSYNC interrupt mode (0=active-high, 1=active-low)
+ * @see getFSyncInterruptMode()
+ * @see MPU6050_RA_INT_PIN_CFG
+ * @see MPU6050_INTCFG_FSYNC_INT_LEVEL_BIT
+ */
+bool mpu6050GetFSyncInterruptLevel()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_FSYNC_INT_LEVEL_BIT, buffer);
+ return buffer[0];
+}
+/** Set FSYNC interrupt logic level mode.
+ * @param mode New FSYNC interrupt mode (0=active-high, 1=active-low)
+ * @see getFSyncInterruptMode()
+ * @see MPU6050_RA_INT_PIN_CFG
+ * @see MPU6050_INTCFG_FSYNC_INT_LEVEL_BIT
+ */
+void mpu6050SetFSyncInterruptLevel(bool level)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_FSYNC_INT_LEVEL_BIT, level);
+}
+/** Get FSYNC pin interrupt enabled setting.
+ * Will be set 0 for disabled, 1 for enabled.
+ * @return Current interrupt enabled setting
+ * @see MPU6050_RA_INT_PIN_CFG
+ * @see MPU6050_INTCFG_FSYNC_INT_EN_BIT
+ */
+bool mpu6050GetFSyncInterruptEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_FSYNC_INT_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set FSYNC pin interrupt enabled setting.
+ * @param enabled New FSYNC pin interrupt enabled setting
+ * @see getFSyncInterruptEnabled()
+ * @see MPU6050_RA_INT_PIN_CFG
+ * @see MPU6050_INTCFG_FSYNC_INT_EN_BIT
+ */
+void mpu6050SetFSyncInterruptEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_FSYNC_INT_EN_BIT, enabled);
+}
+/** Get I2C bypass enabled status.
+ * When this bit is equal to 1 and I2C_MST_EN (Register 106 bit[5]) is equal to
+ * 0, the host application processor will be able to directly access the
+ * auxiliary I2C bus of the MPU-60X0. When this bit is equal to 0, the host
+ * application processor will not be able to directly access the auxiliary I2C
+ * bus of the MPU-60X0 regardless of the state of I2C_MST_EN (Register 106
+ * bit[5]).
+ * @return Current I2C bypass enabled status
+ * @see MPU6050_RA_INT_PIN_CFG
+ * @see MPU6050_INTCFG_I2C_BYPASS_EN_BIT
+ */
+bool mpu6050GetI2CBypassEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_I2C_BYPASS_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set I2C bypass enabled status.
+ * When this bit is equal to 1 and I2C_MST_EN (Register 106 bit[5]) is equal to
+ * 0, the host application processor will be able to directly access the
+ * auxiliary I2C bus of the MPU-60X0. When this bit is equal to 0, the host
+ * application processor will not be able to directly access the auxiliary I2C
+ * bus of the MPU-60X0 regardless of the state of I2C_MST_EN (Register 106
+ * bit[5]).
+ * @param enabled New I2C bypass enabled status
+ * @see MPU6050_RA_INT_PIN_CFG
+ * @see MPU6050_INTCFG_I2C_BYPASS_EN_BIT
+ */
+void mpu6050SetI2CBypassEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_I2C_BYPASS_EN_BIT, enabled);
+}
+/** Get reference clock output enabled status.
+ * When this bit is equal to 1, a reference clock output is provided at the
+ * CLKOUT pin. When this bit is equal to 0, the clock output is disabled. For
+ * further information regarding CLKOUT, please refer to the MPU-60X0 Product
+ * Specification document.
+ * @return Current reference clock output enabled status
+ * @see MPU6050_RA_INT_PIN_CFG
+ * @see MPU6050_INTCFG_CLKOUT_EN_BIT
+ */
+bool mpu6050GetClockOutputEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_CLKOUT_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set reference clock output enabled status.
+ * When this bit is equal to 1, a reference clock output is provided at the
+ * CLKOUT pin. When this bit is equal to 0, the clock output is disabled. For
+ * further information regarding CLKOUT, please refer to the MPU-60X0 Product
+ * Specification document.
+ * @param enabled New reference clock output enabled status
+ * @see MPU6050_RA_INT_PIN_CFG
+ * @see MPU6050_INTCFG_CLKOUT_EN_BIT
+ */
+void mpu6050SetClockOutputEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_CLKOUT_EN_BIT, enabled);
+}
+
+// INT_ENABLE register
+
+/** Get full interrupt enabled status.
+ * Full register byte for all interrupts, for quick reading. Each bit will be
+ * set 0 for disabled, 1 for enabled.
+ * @return Current interrupt enabled status
+ * @see MPU6050_RA_INT_ENABLE
+ * @see MPU6050_INTERRUPT_FF_BIT
+ **/
+uint8_t mpu6050GetIntEnabled()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, buffer);
+ return buffer[0];
+}
+/** Set full interrupt enabled status.
+ * Full register byte for all interrupts, for quick reading. Each bit should be
+ * set 0 for disabled, 1 for enabled.
+ * @param enabled New interrupt enabled status
+ * @see getIntFreefallEnabled()
+ * @see MPU6050_RA_INT_ENABLE
+ * @see MPU6050_INTERRUPT_FF_BIT
+ **/
+void mpu6050SetIntEnabled(uint8_t enabled)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, enabled);
+}
+/** Get Free Fall interrupt enabled status.
+ * Will be set 0 for disabled, 1 for enabled.
+ * @return Current interrupt enabled status
+ * @see MPU6050_RA_INT_ENABLE
+ * @see MPU6050_INTERRUPT_FF_BIT
+ **/
+bool mpu6050GetIntFreefallEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_FF_BIT, buffer);
+ return buffer[0];
+}
+/** Set Free Fall interrupt enabled status.
+ * @param enabled New interrupt enabled status
+ * @see getIntFreefallEnabled()
+ * @see MPU6050_RA_INT_ENABLE
+ * @see MPU6050_INTERRUPT_FF_BIT
+ **/
+void mpu6050SetIntFreefallEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_FF_BIT, enabled);
+}
+/** Get Motion Detection interrupt enabled status.
+ * Will be set 0 for disabled, 1 for enabled.
+ * @return Current interrupt enabled status
+ * @see MPU6050_RA_INT_ENABLE
+ * @see MPU6050_INTERRUPT_MOT_BIT
+ **/
+bool mpu6050GetIntMotionEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_MOT_BIT, buffer);
+ return buffer[0];
+}
+/** Set Motion Detection interrupt enabled status.
+ * @param enabled New interrupt enabled status
+ * @see getIntMotionEnabled()
+ * @see MPU6050_RA_INT_ENABLE
+ * @see MPU6050_INTERRUPT_MOT_BIT
+ **/
+void mpu6050SetIntMotionEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_MOT_BIT, enabled);
+}
+/** Get Zero Motion Detection interrupt enabled status.
+ * Will be set 0 for disabled, 1 for enabled.
+ * @return Current interrupt enabled status
+ * @see MPU6050_RA_INT_ENABLE
+ * @see MPU6050_INTERRUPT_ZMOT_BIT
+ **/
+bool mpu6050GetIntZeroMotionEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_ZMOT_BIT, buffer);
+ return buffer[0];
+}
+/** Set Zero Motion Detection interrupt enabled status.
+ * @param enabled New interrupt enabled status
+ * @see getIntZeroMotionEnabled()
+ * @see MPU6050_RA_INT_ENABLE
+ * @see MPU6050_INTERRUPT_ZMOT_BIT
+ **/
+void mpu6050SetIntZeroMotionEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_ZMOT_BIT, enabled);
+}
+/** Get FIFO Buffer Overflow interrupt enabled status.
+ * Will be set 0 for disabled, 1 for enabled.
+ * @return Current interrupt enabled status
+ * @see MPU6050_RA_INT_ENABLE
+ * @see MPU6050_INTERRUPT_FIFO_OFLOW_BIT
+ **/
+bool mpu6050GetIntFIFOBufferOverflowEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_FIFO_OFLOW_BIT, buffer);
+ return buffer[0];
+}
+/** Set FIFO Buffer Overflow interrupt enabled status.
+ * @param enabled New interrupt enabled status
+ * @see getIntFIFOBufferOverflowEnabled()
+ * @see MPU6050_RA_INT_ENABLE
+ * @see MPU6050_INTERRUPT_FIFO_OFLOW_BIT
+ **/
+void mpu6050SetIntFIFOBufferOverflowEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_FIFO_OFLOW_BIT, enabled);
+}
+/** Get I2C Master interrupt enabled status.
+ * This enables any of the I2C Master interrupt sources to generate an
+ * interrupt. Will be set 0 for disabled, 1 for enabled.
+ * @return Current interrupt enabled status
+ * @see MPU6050_RA_INT_ENABLE
+ * @see MPU6050_INTERRUPT_I2C_MST_INT_BIT
+ **/
+bool mpu6050GetIntI2CMasterEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_I2C_MST_INT_BIT, buffer);
+ return buffer[0];
+}
+/** Set I2C Master interrupt enabled status.
+ * @param enabled New interrupt enabled status
+ * @see getIntI2CMasterEnabled()
+ * @see MPU6050_RA_INT_ENABLE
+ * @see MPU6050_INTERRUPT_I2C_MST_INT_BIT
+ **/
+void mpu6050SetIntI2CMasterEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_I2C_MST_INT_BIT, enabled);
+}
+/** Get Data Ready interrupt enabled setting.
+ * This event occurs each time a write operation to all of the sensor registers
+ * has been completed. Will be set 0 for disabled, 1 for enabled.
+ * @return Current interrupt enabled status
+ * @see MPU6050_RA_INT_ENABLE
+ * @see MPU6050_INTERRUPT_DATA_RDY_BIT
+ */
+bool mpu6050GetIntDataReadyEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_DATA_RDY_BIT, buffer);
+ return buffer[0];
+}
+/** Set Data Ready interrupt enabled status.
+ * @param enabled New interrupt enabled status
+ * @see getIntDataReadyEnabled()
+ * @see MPU6050_RA_INT_CFG
+ * @see MPU6050_INTERRUPT_DATA_RDY_BIT
+ */
+void mpu6050SetIntDataReadyEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_DATA_RDY_BIT, enabled);
+}
+
+// INT_STATUS register
+
+/** Get full set of interrupt status bits.
+ * These bits clear to 0 after the register has been read. Very useful
+ * for getting multiple INT statuses, since each single bit read clears
+ * all of them because it has to read the whole byte.
+ * @return Current interrupt status
+ * @see MPU6050_RA_INT_STATUS
+ */
+uint8_t mpu6050GetIntStatus()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_INT_STATUS, buffer);
+ return buffer[0];
+}
+/** Get Free Fall interrupt status.
+ * This bit automatically sets to 1 when a Free Fall interrupt has been
+ * generated. The bit clears to 0 after the register has been read.
+ * @return Current interrupt status
+ * @see MPU6050_RA_INT_STATUS
+ * @see MPU6050_INTERRUPT_FF_BIT
+ */
+bool mpu6050GetIntFreefallStatus()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_FF_BIT, buffer);
+ return buffer[0];
+}
+/** Get Motion Detection interrupt status.
+ * This bit automatically sets to 1 when a Motion Detection interrupt has been
+ * generated. The bit clears to 0 after the register has been read.
+ * @return Current interrupt status
+ * @see MPU6050_RA_INT_STATUS
+ * @see MPU6050_INTERRUPT_MOT_BIT
+ */
+bool mpu6050GetIntMotionStatus()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_MOT_BIT, buffer);
+ return buffer[0];
+}
+/** Get Zero Motion Detection interrupt status.
+ * This bit automatically sets to 1 when a Zero Motion Detection interrupt has
+ * been generated. The bit clears to 0 after the register has been read.
+ * @return Current interrupt status
+ * @see MPU6050_RA_INT_STATUS
+ * @see MPU6050_INTERRUPT_ZMOT_BIT
+ */
+bool mpu6050GetIntZeroMotionStatus()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_ZMOT_BIT, buffer);
+ return buffer[0];
+}
+/** Get FIFO Buffer Overflow interrupt status.
+ * This bit automatically sets to 1 when a Free Fall interrupt has been
+ * generated. The bit clears to 0 after the register has been read.
+ * @return Current interrupt status
+ * @see MPU6050_RA_INT_STATUS
+ * @see MPU6050_INTERRUPT_FIFO_OFLOW_BIT
+ */
+bool mpu6050GetIntFIFOBufferOverflowStatus()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_FIFO_OFLOW_BIT, buffer);
+ return buffer[0];
+}
+/** Get I2C Master interrupt status.
+ * This bit automatically sets to 1 when an I2C Master interrupt has been
+ * generated. For a list of I2C Master interrupts, please refer to Register 54.
+ * The bit clears to 0 after the register has been read.
+ * @return Current interrupt status
+ * @see MPU6050_RA_INT_STATUS
+ * @see MPU6050_INTERRUPT_I2C_MST_INT_BIT
+ */
+bool mpu6050GetIntI2CMasterStatus()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_I2C_MST_INT_BIT, buffer);
+ return buffer[0];
+}
+/** Get Data Ready interrupt status.
+ * This bit automatically sets to 1 when a Data Ready interrupt has been
+ * generated. The bit clears to 0 after the register has been read.
+ * @return Current interrupt status
+ * @see MPU6050_RA_INT_STATUS
+ * @see MPU6050_INTERRUPT_DATA_RDY_BIT
+ */
+bool mpu6050GetIntDataReadyStatus()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_DATA_RDY_BIT, buffer);
+ return buffer[0];
+}
+
+// ACCEL_*OUT_* registers
+
+/** Get raw 9-axis motion sensor readings (accel/gyro/compass).
+ * FUNCTION NOT FULLY IMPLEMENTED YET.
+ * @param ax 16-bit signed integer container for accelerometer X-axis value
+ * @param ay 16-bit signed integer container for accelerometer Y-axis value
+ * @param az 16-bit signed integer container for accelerometer Z-axis value
+ * @param gx 16-bit signed integer container for gyroscope X-axis value
+ * @param gy 16-bit signed integer container for gyroscope Y-axis value
+ * @param gz 16-bit signed integer container for gyroscope Z-axis value
+ * @param mx 16-bit signed integer container for magnetometer X-axis value
+ * @param my 16-bit signed integer container for magnetometer Y-axis value
+ * @param mz 16-bit signed integer container for magnetometer Z-axis value
+ * @see getMotion6()
+ * @see getAcceleration()
+ * @see getRotation()
+ * @see MPU6050_RA_ACCEL_XOUT_H
+ */
+void mpu6050GetMotion9(int16_t *ax, int16_t *ay, int16_t *az, int16_t *gx, int16_t *gy, int16_t *gz,
+ int16_t *mx, int16_t *my, int16_t *mz)
+{
+ mpu6050GetMotion6(ax, ay, az, gx, gy, gz);
+ // TODO: magnetometer integration
+}
+/** Get raw 6-axis motion sensor readings (accel/gyro).
+ * Retrieves all currently available motion sensor values.
+ * @param ax 16-bit signed integer container for accelerometer X-axis value
+ * @param ay 16-bit signed integer container for accelerometer Y-axis value
+ * @param az 16-bit signed integer container for accelerometer Z-axis value
+ * @param gx 16-bit signed integer container for gyroscope X-axis value
+ * @param gy 16-bit signed integer container for gyroscope Y-axis value
+ * @param gz 16-bit signed integer container for gyroscope Z-axis value
+ * @see getAcceleration()
+ * @see getRotation()
+ * @see MPU6050_RA_ACCEL_XOUT_H
+ */
+
+
+void mpu6050GetMotion6(int16_t *ax, int16_t *ay, int16_t *az, int16_t *gx, int16_t *gy, int16_t *gz)
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ACCEL_XOUT_H, 14, buffer);
+ *ax = (((int16_t) buffer[0]) << 8) | buffer[1];
+ *ay = (((int16_t) buffer[2]) << 8) | buffer[3];
+ *az = (((int16_t) buffer[4]) << 8) | buffer[5];
+ *gx = (((int16_t) buffer[8]) << 8) | buffer[9];
+ *gy = (((int16_t) buffer[10]) << 8) | buffer[11];
+ *gz = (((int16_t) buffer[12]) << 8) | buffer[13];
+}
+/** Get 3-axis accelerometer readings.
+ * These registers store the most recent accelerometer measurements.
+ * Accelerometer measurements are written to these registers at the Sample Rate
+ * as defined in Register 25.
+ *
+ * The accelerometer measurement registers, along with the temperature
+ * measurement registers, gyroscope measurement registers, and external sensor
+ * data registers, are composed of two sets of registers: an internal register
+ * set and a user-facing read register set.
+ *
+ * The data within the accelerometer sensors' internal register set is always
+ * updated at the Sample Rate. Meanwhile, the user-facing read register set
+ * duplicates the internal register set's data values whenever the serial
+ * interface is idle. This guarantees that a burst read of sensor registers will
+ * read measurements from the same sampling instant. Note that if burst reads
+ * are not used, the user is responsible for ensuring a set of single byte reads
+ * correspond to a single sampling instant by checking the Data Ready interrupt.
+ *
+ * Each 16-bit accelerometer measurement has a full scale defined in ACCEL_FS
+ * (Register 28). For each full scale setting, the accelerometers' sensitivity
+ * per LSB in ACCEL_xOUT is shown in the table below:
+ *
+ * <pre>
+ * AFS_SEL | Full Scale Range | LSB Sensitivity
+ * --------+------------------+----------------
+ * 0 | +/- 2g | 8192 LSB/mg
+ * 1 | +/- 4g | 4096 LSB/mg
+ * 2 | +/- 8g | 2048 LSB/mg
+ * 3 | +/- 16g | 1024 LSB/mg
+ * </pre>
+ *
+ * @param x 16-bit signed integer container for X-axis acceleration
+ * @param y 16-bit signed integer container for Y-axis acceleration
+ * @param z 16-bit signed integer container for Z-axis acceleration
+ * @see MPU6050_RA_GYRO_XOUT_H
+ */
+void mpu6050GetAcceleration(int16_t *x, int16_t *y, int16_t *z)
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ACCEL_XOUT_H, 6, buffer);
+ *x = (((int16_t) buffer[0]) << 8) | buffer[1];
+ *y = (((int16_t) buffer[2]) << 8) | buffer[3];
+ *z = (((int16_t) buffer[4]) << 8) | buffer[5];
+}
+/** Get X-axis accelerometer reading.
+ * @return X-axis acceleration measurement in 16-bit 2's complement format
+ * @see getMotion6()
+ * @see MPU6050_RA_ACCEL_XOUT_H
+ */
+int16_t mpu6050GetAccelerationX()
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ACCEL_XOUT_H, 2, buffer);
+ return (((int16_t) buffer[0]) << 8) | buffer[1];
+}
+/** Get Y-axis accelerometer reading.
+ * @return Y-axis acceleration measurement in 16-bit 2's complement format
+ * @see getMotion6()
+ * @see MPU6050_RA_ACCEL_YOUT_H
+ */
+int16_t mpu6050GetAccelerationY()
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ACCEL_YOUT_H, 2, buffer);
+ return (((int16_t) buffer[0]) << 8) | buffer[1];
+}
+/** Get Z-axis accelerometer reading.
+ * @return Z-axis acceleration measurement in 16-bit 2's complement format
+ * @see getMotion6()
+ * @see MPU6050_RA_ACCEL_ZOUT_H
+ */
+int16_t mpu6050GetAccelerationZ()
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ACCEL_ZOUT_H, 2, buffer);
+ return (((int16_t) buffer[0]) << 8) | buffer[1];
+}
+
+// TEMP_OUT_* registers
+
+/** Get current internal temperature.
+ * @return Temperature reading in 16-bit 2's complement format
+ * @see MPU6050_RA_TEMP_OUT_H
+ */
+int16_t mpu6050GetTemperature()
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_TEMP_OUT_H, 2, buffer);
+ return (((int16_t) buffer[0]) << 8) | buffer[1];
+}
+
+// GYRO_*OUT_* registers
+
+/** Get 3-axis gyroscope readings.
+ * These gyroscope measurement registers, along with the accelerometer
+ * measurement registers, temperature measurement registers, and external sensor
+ * data registers, are composed of two sets of registers: an internal register
+ * set and a user-facing read register set.
+ * The data within the gyroscope sensors' internal register set is always
+ * updated at the Sample Rate. Meanwhile, the user-facing read register set
+ * duplicates the internal register set's data values whenever the serial
+ * interface is idle. This guarantees that a burst read of sensor registers will
+ * read measurements from the same sampling instant. Note that if burst reads
+ * are not used, the user is responsible for ensuring a set of single byte reads
+ * correspond to a single sampling instant by checking the Data Ready interrupt.
+ *
+ * Each 16-bit gyroscope measurement has a full scale defined in FS_SEL
+ * (Register 27). For each full scale setting, the gyroscopes' sensitivity per
+ * LSB in GYRO_xOUT is shown in the table below:
+ *
+ * <pre>
+ * FS_SEL | Full Scale Range | LSB Sensitivity
+ * -------+--------------------+----------------
+ * 0 | +/- 250 degrees/s | 131 LSB/deg/s
+ * 1 | +/- 500 degrees/s | 65.5 LSB/deg/s
+ * 2 | +/- 1000 degrees/s | 32.8 LSB/deg/s
+ * 3 | +/- 2000 degrees/s | 16.4 LSB/deg/s
+ * </pre>
+ *
+ * @param x 16-bit signed integer container for X-axis rotation
+ * @param y 16-bit signed integer container for Y-axis rotation
+ * @param z 16-bit signed integer container for Z-axis rotation
+ * @see getMotion6()
+ * @see MPU6050_RA_GYRO_XOUT_H
+ */
+void mpu6050GetRotation(int16_t *x, int16_t *y, int16_t *z)
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_GYRO_XOUT_H, 6, buffer);
+ *x = (((int16_t) buffer[0]) << 8) | buffer[1];
+ *y = (((int16_t) buffer[2]) << 8) | buffer[3];
+ *z = (((int16_t) buffer[4]) << 8) | buffer[5];
+}
+/** Get X-axis gyroscope reading.
+ * @return X-axis rotation measurement in 16-bit 2's complement format
+ * @see getMotion6()
+ * @see MPU6050_RA_GYRO_XOUT_H
+ */
+int16_t mpu6050GetRotationX()
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_GYRO_XOUT_H, 2, buffer);
+ return (((int16_t) buffer[0]) << 8) | buffer[1];
+}
+/** Get Y-axis gyroscope reading.
+ * @return Y-axis rotation measurement in 16-bit 2's complement format
+ * @see getMotion6()
+ * @see MPU6050_RA_GYRO_YOUT_H
+ */
+int16_t mpu6050GetRotationY()
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_GYRO_YOUT_H, 2, buffer);
+ return (((int16_t) buffer[0]) << 8) | buffer[1];
+}
+/** Get Z-axis gyroscope reading.
+ * @return Z-axis rotation measurement in 16-bit 2's complement format
+ * @see getMotion6()
+ * @see MPU6050_RA_GYRO_ZOUT_H
+ */
+int16_t mpu6050GetRotationZ()
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_GYRO_ZOUT_H, 2, buffer);
+ return (((int16_t) buffer[0]) << 8) | buffer[1];
+}
+
+// EXT_SENS_DATA_* registers
+
+/** Read single byte from external sensor data register.
+ * These registers store data read from external sensors by the Slave 0, 1, 2,
+ * and 3 on the auxiliary I2C interface. Data read by Slave 4 is stored in
+ * I2C_SLV4_DI (Register 53).
+ *
+ * External sensor data is written to these registers at the Sample Rate as
+ * defined in Register 25. This access rate can be reduced by using the Slave
+ * Delay Enable registers (Register 103).
+ *
+ * External sensor data registers, along with the gyroscope measurement
+ * registers, accelerometer measurement registers, and temperature measurement
+ * registers, are composed of two sets of registers: an internal register set
+ * and a user-facing read register set.
+ *
+ * The data within the external sensors' internal register set is always updated
+ * at the Sample Rate (or the reduced access rate) whenever the serial interface
+ * is idle. This guarantees that a burst read of sensor registers will read
+ * measurements from the same sampling instant. Note that if burst reads are not
+ * used, the user is responsible for ensuring a set of single byte reads
+ * correspond to a single sampling instant by checking the Data Ready interrupt.
+ *
+ * Data is placed in these external sensor data registers according to
+ * I2C_SLV0_CTRL, I2C_SLV1_CTRL, I2C_SLV2_CTRL, and I2C_SLV3_CTRL (Registers 39,
+ * 42, 45, and 48). When more than zero bytes are read (I2C_SLVx_LEN > 0) from
+ * an enabled slave (I2C_SLVx_EN = 1), the slave is read at the Sample Rate (as
+ * defined in Register 25) or delayed rate (if specified in Register 52 and
+ * 103). During each Sample cycle, slave reads are performed in order of Slave
+ * number. If all slaves are enabled with more than zero bytes to be read, the
+ * order will be Slave 0, followed by Slave 1, Slave 2, and Slave 3.
+ *
+ * Each enabled slave will have EXT_SENS_DATA registers associated with it by
+ * number of bytes read (I2C_SLVx_LEN) in order of slave number, starting from
+ * EXT_SENS_DATA_00. Note that this means enabling or disabling a slave may
+ * change the higher numbered slaves' associated registers. Furthermore, if
+ * fewer total bytes are being read from the external sensors as a result of
+ * such a change, then the data remaining in the registers which no longer have
+ * an associated slave device (i.e. high numbered registers) will remain in
+ * these previously allocated registers unless reset.
+ *
+ * If the sum of the read lengths of all SLVx transactions exceed the number of
+ * available EXT_SENS_DATA registers, the excess bytes will be dropped. There
+ * are 24 EXT_SENS_DATA registers and hence the total read lengths between all
+ * the slaves cannot be greater than 24 or some bytes will be lost.
+ *
+ * Note: Slave 4's behavior is distinct from that of Slaves 0-3. For further
+ * information regarding the characteristics of Slave 4, please refer to
+ * Registers 49 to 53.
+ *
+ * EXAMPLE:
+ * Suppose that Slave 0 is enabled with 4 bytes to be read (I2C_SLV0_EN = 1 and
+ * I2C_SLV0_LEN = 4) while Slave 1 is enabled with 2 bytes to be read so that
+ * I2C_SLV1_EN = 1 and I2C_SLV1_LEN = 2. In such a situation, EXT_SENS_DATA _00
+ * through _03 will be associated with Slave 0, while EXT_SENS_DATA _04 and 05
+ * will be associated with Slave 1. If Slave 2 is enabled as well, registers
+ * starting from EXT_SENS_DATA_06 will be allocated to Slave 2.
+ *
+ * If Slave 2 is disabled while Slave 3 is enabled in this same situation, then
+ * registers starting from EXT_SENS_DATA_06 will be allocated to Slave 3
+ * instead.
+ *
+ * REGISTER ALLOCATION FOR DYNAMIC DISABLE VS. NORMAL DISABLE:
+ * If a slave is disabled at any time, the space initially allocated to the
+ * slave in the EXT_SENS_DATA register, will remain associated with that slave.
+ * This is to avoid dynamic adjustment of the register allocation.
+ *
+ * The allocation of the EXT_SENS_DATA registers is recomputed only when (1) all
+ * slaves are disabled, or (2) the I2C_MST_RST bit is set (Register 106).
+ *
+ * This above is also true if one of the slaves gets NACKed and stops
+ * functioning.
+ *
+ * @param position Starting position (0-23)
+ * @return Byte read from register
+ */
+uint8_t mpu6050GetExternalSensorByte(int position)
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_EXT_SENS_DATA_00 + position, buffer);
+ return buffer[0];
+}
+/** Read word (2 bytes) from external sensor data registers.
+ * @param position Starting position (0-21)
+ * @return Word read from register
+ * @see getExternalSensorByte()
+ */
+uint16_t mpu6050GetExternalSensorWord(int position)
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_EXT_SENS_DATA_00 + position, 2, buffer);
+ return (((uint16_t) buffer[0]) << 8) | buffer[1];
+}
+/** Read double word (4 bytes) from external sensor data registers.
+ * @param position Starting position (0-20)
+ * @return Double word read from registers
+ * @see getExternalSensorByte()
+ */
+uint32_t mpu6050GetExternalSensorDWord(int position)
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_EXT_SENS_DATA_00 + position, 4, buffer);
+ return (((uint32_t) buffer[0]) << 24) | (((uint32_t) buffer[1]) << 16)
+ | (((uint16_t) buffer[2]) << 8) | buffer[3];
+}
+
+// MOT_DETECT_STATUS register
+
+/** Get X-axis negative motion detection interrupt status.
+ * @return Motion detection status
+ * @see MPU6050_RA_MOT_DETECT_STATUS
+ * @see MPU6050_MOTION_MOT_XNEG_BIT
+ */
+bool mpu6050GetXNegMotionDetected()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_XNEG_BIT, buffer);
+ return buffer[0];
+}
+/** Get X-axis positive motion detection interrupt status.
+ * @return Motion detection status
+ * @see MPU6050_RA_MOT_DETECT_STATUS
+ * @see MPU6050_MOTION_MOT_XPOS_BIT
+ */
+bool mpu6050GetXPosMotionDetected()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_XPOS_BIT, buffer);
+ return buffer[0];
+}
+/** Get Y-axis negative motion detection interrupt status.
+ * @return Motion detection status
+ * @see MPU6050_RA_MOT_DETECT_STATUS
+ * @see MPU6050_MOTION_MOT_YNEG_BIT
+ */
+bool mpu6050GetYNegMotionDetected()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_YNEG_BIT, buffer);
+ return buffer[0];
+}
+/** Get Y-axis positive motion detection interrupt status.
+ * @return Motion detection status
+ * @see MPU6050_RA_MOT_DETECT_STATUS
+ * @see MPU6050_MOTION_MOT_YPOS_BIT
+ */
+bool mpu6050GetYPosMotionDetected()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_YPOS_BIT, buffer);
+ return buffer[0];
+}
+/** Get Z-axis negative motion detection interrupt status.
+ * @return Motion detection status
+ * @see MPU6050_RA_MOT_DETECT_STATUS
+ * @see MPU6050_MOTION_MOT_ZNEG_BIT
+ */
+bool mpu6050GetZNegMotionDetected()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_ZNEG_BIT, buffer);
+ return buffer[0];
+}
+/** Get Z-axis positive motion detection interrupt status.
+ * @return Motion detection status
+ * @see MPU6050_RA_MOT_DETECT_STATUS
+ * @see MPU6050_MOTION_MOT_ZPOS_BIT
+ */
+bool mpu6050GetZPosMotionDetected()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_ZPOS_BIT, buffer);
+ return buffer[0];
+}
+/** Get zero motion detection interrupt status.
+ * @return Motion detection status
+ * @see MPU6050_RA_MOT_DETECT_STATUS
+ * @see MPU6050_MOTION_MOT_ZRMOT_BIT
+ */
+bool mpu6050GetZeroMotionDetected()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_ZRMOT_BIT, buffer);
+ return buffer[0];
+}
+
+// I2C_SLV*_DO register
+
+/** Write byte to Data Output container for specified slave.
+ * This register holds the output data written into Slave when Slave is set to
+ * write mode. For further information regarding Slave control, please
+ * refer to Registers 37 to 39 and immediately following.
+ * @param num Slave number (0-3)
+ * @param data Byte to write
+ * @see MPU6050_RA_I2C_SLV0_DO
+ */
+void mpu6050SetSlaveOutputByte(uint8_t num, uint8_t data)
+{
+ if (num > 3) {
+ return;
+ }
+
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_DO + num, data);
+}
+
+// I2C_MST_DELAY_CTRL register
+
+/** Get external data shadow delay enabled status.
+ * This register is used to specify the timing of external sensor data
+ * shadowing. When DELAY_ES_SHADOW is set to 1, shadowing of external
+ * sensor data is delayed until all data has been received.
+ * @return Current external data shadow delay enabled status.
+ * @see MPU6050_RA_I2C_MST_DELAY_CTRL
+ * @see MPU6050_DELAYCTRL_DELAY_ES_SHADOW_BIT
+ */
+bool mpu6050GetExternalShadowDelayEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_DELAY_CTRL, MPU6050_DELAYCTRL_DELAY_ES_SHADOW_BIT,
+ buffer);
+ return buffer[0];
+}
+/** Set external data shadow delay enabled status.
+ * @param enabled New external data shadow delay enabled status.
+ * @see getExternalShadowDelayEnabled()
+ * @see MPU6050_RA_I2C_MST_DELAY_CTRL
+ * @see MPU6050_DELAYCTRL_DELAY_ES_SHADOW_BIT
+ */
+void mpu6050SetExternalShadowDelayEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_DELAY_CTRL,
+ MPU6050_DELAYCTRL_DELAY_ES_SHADOW_BIT, enabled);
+}
+/** Get slave delay enabled status.
+ * When a particular slave delay is enabled, the rate of access for the that
+ * slave device is reduced. When a slave's access rate is decreased relative to
+ * the Sample Rate, the slave is accessed every:
+ *
+ * 1 / (1 + I2C_MST_DLY) Samples
+ *
+ * This base Sample Rate in turn is determined by SMPLRT_DIV (register * 25)
+ * and DLPF_CFG (register 26).
+ *
+ * For further information regarding I2C_MST_DLY, please refer to register 52.
+ * For further information regarding the Sample Rate, please refer to register 25.
+ *
+ * @param num Slave number (0-4)
+ * @return Current slave delay enabled status.
+ * @see MPU6050_RA_I2C_MST_DELAY_CTRL
+ * @see MPU6050_DELAYCTRL_I2C_SLV0_DLY_EN_BIT
+ */
+bool mpu6050GetSlaveDelayEnabled(uint8_t num)
+{
+ // MPU6050_DELAYCTRL_I2C_SLV4_DLY_EN_BIT is 4, SLV3 is 3, etc.
+ if (num > 4) {
+ return 0;
+ }
+
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_DELAY_CTRL, num, buffer);
+ return buffer[0];
+}
+/** Set slave delay enabled status.
+ * @param num Slave number (0-4)
+ * @param enabled New slave delay enabled status.
+ * @see MPU6050_RA_I2C_MST_DELAY_CTRL
+ * @see MPU6050_DELAYCTRL_I2C_SLV0_DLY_EN_BIT
+ */
+void mpu6050SetSlaveDelayEnabled(uint8_t num, bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_DELAY_CTRL, num, enabled);
+}
+
+// SIGNAL_PATH_RESET register
+
+/** Reset gyroscope signal path.
+ * The reset will revert the signal path analog to digital converters and
+ * filters to their power up configurations.
+ * @see MPU6050_RA_SIGNAL_PATH_RESET
+ * @see MPU6050_PATHRESET_GYRO_RESET_BIT
+ */
+void mpu6050ResetGyroscopePath()
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_SIGNAL_PATH_RESET, MPU6050_PATHRESET_GYRO_RESET_BIT, 1);
+}
+/** Reset accelerometer signal path.
+ * The reset will revert the signal path analog to digital converters and
+ * filters to their power up configurations.
+ * @see MPU6050_RA_SIGNAL_PATH_RESET
+ * @see MPU6050_PATHRESET_ACCEL_RESET_BIT
+ */
+void mpu6050ResetAccelerometerPath()
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_SIGNAL_PATH_RESET, MPU6050_PATHRESET_ACCEL_RESET_BIT, 1);
+}
+/** Reset temperature sensor signal path.
+ * The reset will revert the signal path analog to digital converters and
+ * filters to their power up configurations.
+ * @see MPU6050_RA_SIGNAL_PATH_RESET
+ * @see MPU6050_PATHRESET_TEMP_RESET_BIT
+ */
+void mpu6050ResetTemperaturePath()
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_SIGNAL_PATH_RESET, MPU6050_PATHRESET_TEMP_RESET_BIT, 1);
+}
+
+// MOT_DETECT_CTRL register
+
+/** Get accelerometer power-on delay.
+ * The accelerometer data path provides samples to the sensor registers, Motion
+ * detection, Zero Motion detection, and Free Fall detection modules. The
+ * signal path contains filters which must be flushed on wake-up with new
+ * samples before the detection modules begin operations. The default wake-up
+ * delay, of 4ms can be lengthened by up to 3ms. This additional delay is
+ * specified in ACCEL_ON_DELAY in units of 1 LSB = 1 ms. The user may select
+ * any value above zero unless instructed otherwise by InvenSense. Please refer
+ * to Section 8 of the MPU-6000/MPU-6050 Product Specification document for
+ * further information regarding the detection modules.
+ * @return Current accelerometer power-on delay
+ * @see MPU6050_RA_MOT_DETECT_CTRL
+ * @see MPU6050_DETECT_ACCEL_ON_DELAY_BIT
+ */
+uint8_t mpu6050GetAccelerometerPowerOnDelay()
+{
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_ACCEL_ON_DELAY_BIT,
+ MPU6050_DETECT_ACCEL_ON_DELAY_LENGTH, buffer);
+ return buffer[0];
+}
+/** Set accelerometer power-on delay.
+ * @param delay New accelerometer power-on delay (0-3)
+ * @see getAccelerometerPowerOnDelay()
+ * @see MPU6050_RA_MOT_DETECT_CTRL
+ * @see MPU6050_DETECT_ACCEL_ON_DELAY_BIT
+ */
+void mpu6050SetAccelerometerPowerOnDelay(uint8_t delay)
+{
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_ACCEL_ON_DELAY_BIT,
+ MPU6050_DETECT_ACCEL_ON_DELAY_LENGTH, delay);
+}
+/** Get Free Fall detection counter decrement configuration.
+ * Detection is registered by the Free Fall detection module after accelerometer
+ * measurements meet their respective threshold conditions over a specified
+ * number of samples. When the threshold conditions are met, the corresponding
+ * detection counter increments by 1. The user may control the rate at which the
+ * detection counter decrements when the threshold condition is not met by
+ * configuring FF_COUNT. The decrement rate can be set according to the
+ * following table:
+ *
+ * <pre>
+ * FF_COUNT | Counter Decrement
+ * ---------+------------------
+ * 0 | Reset
+ * 1 | 1
+ * 2 | 2
+ * 3 | 4
+ * </pre>
+ *
+ * When FF_COUNT is configured to 0 (reset), any non-qualifying sample will
+ * reset the counter to 0. For further information on Free Fall detection,
+ * please refer to Registers 29 to 32.
+ *
+ * @return Current decrement configuration
+ * @see MPU6050_RA_MOT_DETECT_CTRL
+ * @see MPU6050_DETECT_FF_COUNT_BIT
+ */
+uint8_t mpu6050GetFreefallDetectionCounterDecrement()
+{
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_FF_COUNT_BIT,
+ MPU6050_DETECT_FF_COUNT_LENGTH, buffer);
+ return buffer[0];
+}
+/** Set Free Fall detection counter decrement configuration.
+ * @param decrement New decrement configuration value
+ * @see getFreefallDetectionCounterDecrement()
+ * @see MPU6050_RA_MOT_DETECT_CTRL
+ * @see MPU6050_DETECT_FF_COUNT_BIT
+ */
+void mpu6050SetFreefallDetectionCounterDecrement(uint8_t decrement)
+{
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_FF_COUNT_BIT,
+ MPU6050_DETECT_FF_COUNT_LENGTH, decrement);
+}
+/** Get Motion detection counter decrement configuration.
+ * Detection is registered by the Motion detection module after accelerometer
+ * measurements meet their respective threshold conditions over a specified
+ * number of samples. When the threshold conditions are met, the corresponding
+ * detection counter increments by 1. The user may control the rate at which the
+ * detection counter decrements when the threshold condition is not met by
+ * configuring MOT_COUNT. The decrement rate can be set according to the
+ * following table:
+ *
+ * <pre>
+ * MOT_COUNT | Counter Decrement
+ * ----------+------------------
+ * 0 | Reset
+ * 1 | 1
+ * 2 | 2
+ * 3 | 4
+ * </pre>
+ *
+ * When MOT_COUNT is configured to 0 (reset), any non-qualifying sample will
+ * reset the counter to 0. For further information on Motion detection,
+ * please refer to Registers 29 to 32.
+ *
+ */
+uint8_t mpu6050GetMotionDetectionCounterDecrement()
+{
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_MOT_COUNT_BIT,
+ MPU6050_DETECT_MOT_COUNT_LENGTH, buffer);
+ return buffer[0];
+}
+/** Set Motion detection counter decrement configuration.
+ * @param decrement New decrement configuration value
+ * @see getMotionDetectionCounterDecrement()
+ * @see MPU6050_RA_MOT_DETECT_CTRL
+ * @see MPU6050_DETECT_MOT_COUNT_BIT
+ */
+void mpu6050SetMotionDetectionCounterDecrement(uint8_t decrement)
+{
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_MOT_COUNT_BIT,
+ MPU6050_DETECT_MOT_COUNT_LENGTH, decrement);
+}
+
+// USER_CTRL register
+
+/** Get FIFO enabled status.
+ * When this bit is set to 0, the FIFO buffer is disabled. The FIFO buffer
+ * cannot be written to or read from while disabled. The FIFO buffer's state
+ * does not change unless the MPU-60X0 is power cycled.
+ * @return Current FIFO enabled status
+ * @see MPU6050_RA_USER_CTRL
+ * @see MPU6050_USERCTRL_FIFO_EN_BIT
+ */
+bool mpu6050GetFIFOEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_FIFO_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set FIFO enabled status.
+ * @param enabled New FIFO enabled status
+ * @see getFIFOEnabled()
+ * @see MPU6050_RA_USER_CTRL
+ * @see MPU6050_USERCTRL_FIFO_EN_BIT
+ */
+void mpu6050SetFIFOEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_FIFO_EN_BIT, enabled);
+}
+/** Get I2C Master Mode enabled status.
+ * When this mode is enabled, the MPU-60X0 acts as the I2C Master to the
+ * external sensor slave devices on the auxiliary I2C bus. When this bit is
+ * cleared to 0, the auxiliary I2C bus lines (AUX_DA and AUX_CL) are logically
+ * driven by the primary I2C bus (SDA and SCL). This is a precondition to
+ * enabling Bypass Mode. For further information regarding Bypass Mode, please
+ * refer to Register 55.
+ * @return Current I2C Master Mode enabled status
+ * @see MPU6050_RA_USER_CTRL
+ * @see MPU6050_USERCTRL_I2C_MST_EN_BIT
+ */
+bool mpu6050GetI2CMasterModeEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_I2C_MST_EN_BIT, buffer);
+ return buffer[0];
+}
+/** Set I2C Master Mode enabled status.
+ * @param enabled New I2C Master Mode enabled status
+ * @see getI2CMasterModeEnabled()
+ * @see MPU6050_RA_USER_CTRL
+ * @see MPU6050_USERCTRL_I2C_MST_EN_BIT
+ */
+void mpu6050SetI2CMasterModeEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_I2C_MST_EN_BIT, enabled);
+}
+/** Switch from I2C to SPI mode (MPU-6000 only)
+ * If this is set, the primary SPI interface will be enabled in place of the
+ * disabled primary I2C interface.
+ */
+void mpu6050SwitchSPIEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_I2C_IF_DIS_BIT, enabled);
+}
+/** Reset the FIFO.
+ * This bit resets the FIFO buffer when set to 1 while FIFO_EN equals 0. This
+ * bit automatically clears to 0 after the reset has been triggered.
+ * @see MPU6050_RA_USER_CTRL
+ * @see MPU6050_USERCTRL_FIFO_RESET_BIT
+ */
+void mpu6050ResetFIFO()
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_FIFO_RESET_BIT, 1);
+}
+/** Reset the I2C Master.
+ * This bit resets the I2C Master when set to 1 while I2C_MST_EN equals 0.
+ * This bit automatically clears to 0 after the reset has been triggered.
+ * @see MPU6050_RA_USER_CTRL
+ * @see MPU6050_USERCTRL_I2C_MST_RESET_BIT
+ */
+void mpu6050ResetI2CMaster()
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_I2C_MST_RESET_BIT, 1);
+}
+/** Reset all sensor registers and signal paths.
+ * When set to 1, this bit resets the signal paths for all sensors (gyroscopes,
+ * accelerometers, and temperature sensor). This operation will also clear the
+ * sensor registers. This bit automatically clears to 0 after the reset has been
+ * triggered.
+ *
+ * When resetting only the signal path (and not the sensor registers), please
+ * use Register 104, SIGNAL_PATH_RESET.
+ *
+ * @see MPU6050_RA_USER_CTRL
+ * @see MPU6050_USERCTRL_SIG_COND_RESET_BIT
+ */
+void mpu6050ResetSensors()
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_SIG_COND_RESET_BIT, 1);
+}
+
+// PWR_MGMT_1 register
+
+/** Trigger a full device reset.
+ * A small delay of ~50ms may be desirable after triggering a reset.
+ * @see MPU6050_RA_PWR_MGMT_1
+ * @see MPU6050_PWR1_DEVICE_RESET_BIT
+ */
+void mpu6050Reset()
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_DEVICE_RESET_BIT, 1);
+}
+/** Get sleep mode status.
+ * Setting the SLEEP bit in the register puts the device into very low power
+ * sleep mode. In this mode, only the serial interface and internal registers
+ * remain active, allowing for a very low standby current. Clearing this bit
+ * puts the device back into normal mode. To save power, the individual standby
+ * selections for each of the gyros should be used if any gyro axis is not used
+ * by the application.
+ * @return Current sleep mode enabled status
+ * @see MPU6050_RA_PWR_MGMT_1
+ * @see MPU6050_PWR1_SLEEP_BIT
+ */
+bool mpu6050GetSleepEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_SLEEP_BIT, buffer);
+ return buffer[0];
+}
+/** Set sleep mode status.
+ * @param enabled New sleep mode enabled status
+ * @see getSleepEnabled()
+ * @see MPU6050_RA_PWR_MGMT_1
+ * @see MPU6050_PWR1_SLEEP_BIT
+ */
+void mpu6050SetSleepEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_SLEEP_BIT, enabled);
+}
+/** Get wake cycle enabled status.
+ * When this bit is set to 1 and SLEEP is disabled, the MPU-60X0 will cycle
+ * between sleep mode and waking up to take a single sample of data from active
+ * sensors at a rate determined by LP_WAKE_CTRL (register 108).
+ * @return Current sleep mode enabled status
+ * @see MPU6050_RA_PWR_MGMT_1
+ * @see MPU6050_PWR1_CYCLE_BIT
+ */
+bool mpu6050GetWakeCycleEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_CYCLE_BIT, buffer);
+ return buffer[0];
+}
+/** Set wake cycle enabled status.
+ * @param enabled New sleep mode enabled status
+ * @see getWakeCycleEnabled()
+ * @see MPU6050_RA_PWR_MGMT_1
+ * @see MPU6050_PWR1_CYCLE_BIT
+ */
+void mpu6050SetWakeCycleEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_CYCLE_BIT, enabled);
+}
+/** Get temperature sensor enabled status.
+ * Control the usage of the internal temperature sensor.
+ *
+ * Note: this register stores the *disabled* value, but for consistency with the
+ * rest of the code, the function is named and used with standard true/false
+ * values to indicate whether the sensor is enabled or disabled, respectively.
+ *
+ * @return Current temperature sensor enabled status
+ * @see MPU6050_RA_PWR_MGMT_1
+ * @see MPU6050_PWR1_TEMP_DIS_BIT
+ */
+bool mpu6050GetTempSensorEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_TEMP_DIS_BIT, buffer);
+ return buffer[0] == 0; // 1 is actually disabled here
+}
+/** Set temperature sensor enabled status.
+ * Note: this register stores the *disabled* value, but for consistency with the
+ * rest of the code, the function is named and used with standard true/false
+ * values to indicate whether the sensor is enabled or disabled, respectively.
+ *
+ * @param enabled New temperature sensor enabled status
+ * @see getTempSensorEnabled()
+ * @see MPU6050_RA_PWR_MGMT_1
+ * @see MPU6050_PWR1_TEMP_DIS_BIT
+ */
+void mpu6050SetTempSensorEnabled(bool enabled)
+{
+ // 1 is actually disabled here
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_TEMP_DIS_BIT, !enabled);
+}
+/** Get clock source setting.
+ * @return Current clock source setting
+ * @see MPU6050_RA_PWR_MGMT_1
+ * @see MPU6050_PWR1_CLKSEL_BIT
+ * @see MPU6050_PWR1_CLKSEL_LENGTH
+ */
+uint8_t mpu6050GetClockSource()
+{
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_CLKSEL_BIT,
+ MPU6050_PWR1_CLKSEL_LENGTH, buffer);
+ return buffer[0];
+}
+/** Set clock source setting.
+ * An internal 8MHz oscillator, gyroscope based clock, or external sources can
+ * be selected as the MPU-60X0 clock source. When the internal 8 MHz oscillator
+ * or an external source is chosen as the clock source, the MPU-60X0 can operate
+ * in low power modes with the gyroscopes disabled.
+ *
+ * Upon power up, the MPU-60X0 clock source defaults to the internal oscillator.
+ * However, it is highly recommended that the device be configured to use one of
+ * the gyroscopes (or an external clock source) as the clock reference for
+ * improved stability. The clock source can be selected according to the following table:
+ *
+ * <pre>
+ * CLK_SEL | Clock Source
+ * --------+--------------------------------------
+ * 0 | Internal oscillator
+ * 1 | PLL with X Gyro reference
+ * 2 | PLL with Y Gyro reference
+ * 3 | PLL with Z Gyro reference
+ * 4 | PLL with external 32.768kHz reference
+ * 5 | PLL with external 19.2MHz reference
+ * 6 | Reserved
+ * 7 | Stops the clock and keeps the timing generator in reset
+ * </pre>
+ *
+ * @param source New clock source setting
+ * @see getClockSource()
+ * @see MPU6050_RA_PWR_MGMT_1
+ * @see MPU6050_PWR1_CLKSEL_BIT
+ * @see MPU6050_PWR1_CLKSEL_LENGTH
+ */
+void mpu6050SetClockSource(uint8_t source)
+{
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_CLKSEL_BIT,
+ MPU6050_PWR1_CLKSEL_LENGTH, source);
+}
+
+// PWR_MGMT_2 register
+
+/** Get wake frequency in Accel-Only Low Power Mode.
+ * The MPU-60X0 can be put into Accerlerometer Only Low Power Mode by setting
+ * PWRSEL to 1 in the Power Management 1 register (Register 107). In this mode,
+ * the device will power off all devices except for the primary I2C interface,
+ * waking only the accelerometer at fixed intervals to take a single
+ * measurement. The frequency of wake-ups can be configured with LP_WAKE_CTRL
+ * as shown below:
+ *
+ * <pre>
+ * LP_WAKE_CTRL | Wake-up Frequency
+ * -------------+------------------
+ * 0 | 1.25 Hz
+ * 1 | 2.5 Hz
+ * 2 | 5 Hz
+ * 3 | 10 Hz
+ * <pre>
+ *
+ * For further information regarding the MPU-60X0's power modes, please refer to
+ * Register 107.
+ *
+ * @return Current wake frequency
+ * @see MPU6050_RA_PWR_MGMT_2
+ */
+uint8_t mpu6050GetWakeFrequency()
+{
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_LP_WAKE_CTRL_BIT,
+ MPU6050_PWR2_LP_WAKE_CTRL_LENGTH, buffer);
+ return buffer[0];
+}
+/** Set wake frequency in Accel-Only Low Power Mode.
+ * @param frequency New wake frequency
+ * @see MPU6050_RA_PWR_MGMT_2
+ */
+void mpu6050SetWakeFrequency(uint8_t frequency)
+{
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_LP_WAKE_CTRL_BIT,
+ MPU6050_PWR2_LP_WAKE_CTRL_LENGTH, frequency);
+}
+
+/** Get X-axis accelerometer standby enabled status.
+ * If enabled, the X-axis will not gather or report data (or use power).
+ * @return Current X-axis standby enabled status
+ * @see MPU6050_RA_PWR_MGMT_2
+ * @see MPU6050_PWR2_STBY_XA_BIT
+ */
+bool mpu6050GetStandbyXAccelEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_XA_BIT, buffer);
+ return buffer[0];
+}
+/** Set X-axis accelerometer standby enabled status.
+ * @param New X-axis standby enabled status
+ * @see getStandbyXAccelEnabled()
+ * @see MPU6050_RA_PWR_MGMT_2
+ * @see MPU6050_PWR2_STBY_XA_BIT
+ */
+void mpu6050SetStandbyXAccelEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_XA_BIT, enabled);
+}
+/** Get Y-axis accelerometer standby enabled status.
+ * If enabled, the Y-axis will not gather or report data (or use power).
+ * @return Current Y-axis standby enabled status
+ * @see MPU6050_RA_PWR_MGMT_2
+ * @see MPU6050_PWR2_STBY_YA_BIT
+ */
+bool mpu6050GetStandbyYAccelEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_YA_BIT, buffer);
+ return buffer[0];
+}
+/** Set Y-axis accelerometer standby enabled status.
+ * @param New Y-axis standby enabled status
+ * @see getStandbyYAccelEnabled()
+ * @see MPU6050_RA_PWR_MGMT_2
+ * @see MPU6050_PWR2_STBY_YA_BIT
+ */
+void mpu6050SetStandbyYAccelEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_YA_BIT, enabled);
+}
+/** Get Z-axis accelerometer standby enabled status.
+ * If enabled, the Z-axis will not gather or report data (or use power).
+ * @return Current Z-axis standby enabled status
+ * @see MPU6050_RA_PWR_MGMT_2
+ * @see MPU6050_PWR2_STBY_ZA_BIT
+ */
+bool mpu6050GetStandbyZAccelEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_ZA_BIT, buffer);
+ return buffer[0];
+}
+/** Set Z-axis accelerometer standby enabled status.
+ * @param New Z-axis standby enabled status
+ * @see getStandbyZAccelEnabled()
+ * @see MPU6050_RA_PWR_MGMT_2
+ * @see MPU6050_PWR2_STBY_ZA_BIT
+ */
+void mpu6050SetStandbyZAccelEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_ZA_BIT, enabled);
+}
+/** Get X-axis gyroscope standby enabled status.
+ * If enabled, the X-axis will not gather or report data (or use power).
+ * @return Current X-axis standby enabled status
+ * @see MPU6050_RA_PWR_MGMT_2
+ * @see MPU6050_PWR2_STBY_XG_BIT
+ */
+bool mpu6050GetStandbyXGyroEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_XG_BIT, buffer);
+ return buffer[0];
+}
+/** Set X-axis gyroscope standby enabled status.
+ * @param New X-axis standby enabled status
+ * @see getStandbyXGyroEnabled()
+ * @see MPU6050_RA_PWR_MGMT_2
+ * @see MPU6050_PWR2_STBY_XG_BIT
+ */
+void mpu6050SetStandbyXGyroEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_XG_BIT, enabled);
+}
+/** Get Y-axis gyroscope standby enabled status.
+ * If enabled, the Y-axis will not gather or report data (or use power).
+ * @return Current Y-axis standby enabled status
+ * @see MPU6050_RA_PWR_MGMT_2
+ * @see MPU6050_PWR2_STBY_YG_BIT
+ */
+bool mpu6050GetStandbyYGyroEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_YG_BIT, buffer);
+ return buffer[0];
+}
+/** Set Y-axis gyroscope standby enabled status.
+ * @param New Y-axis standby enabled status
+ * @see getStandbyYGyroEnabled()
+ * @see MPU6050_RA_PWR_MGMT_2
+ * @see MPU6050_PWR2_STBY_YG_BIT
+ */
+void mpu6050SetStandbyYGyroEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_YG_BIT, enabled);
+}
+/** Get Z-axis gyroscope standby enabled status.
+ * If enabled, the Z-axis will not gather or report data (or use power).
+ * @return Current Z-axis standby enabled status
+ * @see MPU6050_RA_PWR_MGMT_2
+ * @see MPU6050_PWR2_STBY_ZG_BIT
+ */
+bool mpu6050GetStandbyZGyroEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_ZG_BIT, buffer);
+ return buffer[0];
+}
+/** Set Z-axis gyroscope standby enabled status.
+ * @param New Z-axis standby enabled status
+ * @see getStandbyZGyroEnabled()
+ * @see MPU6050_RA_PWR_MGMT_2
+ * @see MPU6050_PWR2_STBY_ZG_BIT
+ */
+void mpu6050SetStandbyZGyroEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_ZG_BIT, enabled);
+}
+
+// FIFO_COUNT* registers
+
+/** Get current FIFO buffer size.
+ * This value indicates the number of bytes stored in the FIFO buffer. This
+ * number is in turn the number of bytes that can be read from the FIFO buffer
+ * and it is directly proportional to the number of samples available given the
+ * set of sensor data bound to be stored in the FIFO (register 35 and 36).
+ * @return Current FIFO buffer size
+ */
+uint16_t mpu6050GetFIFOCount()
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_FIFO_COUNTH, 2, buffer);
+ return (((uint16_t) buffer[0]) << 8) | buffer[1];
+}
+
+// FIFO_R_W register
+
+/** Get byte from FIFO buffer.
+ * This register is used to read and write data from the FIFO buffer. Data is
+ * written to the FIFO in order of register number (from lowest to highest). If
+ * all the FIFO enable flags (see below) are enabled and all External Sensor
+ * Data registers (Registers 73 to 96) are associated with a Slave device, the
+ * contents of registers 59 through 96 will be written in order at the Sample
+ * Rate.
+ *
+ * The contents of the sensor data registers (Registers 59 to 96) are written
+ * into the FIFO buffer when their corresponding FIFO enable flags are set to 1
+ * in FIFO_EN (Register 35). An additional flag for the sensor data registers
+ * associated with I2C Slave 3 can be found in I2C_MST_CTRL (Register 36).
+ *
+ * If the FIFO buffer has overflowed, the status bit FIFO_OFLOW_INT is
+ * automatically set to 1. This bit is located in INT_STATUS (Register 58).
+ * When the FIFO buffer has overflowed, the oldest data will be lost and new
+ * data will be written to the FIFO.
+ *
+ * If the FIFO buffer is empty, reading this register will return the last byte
+ * that was previously read from the FIFO until new data is available. The user
+ * should check FIFO_COUNT to ensure that the FIFO buffer is not read when
+ * empty.
+ *
+ * @return Byte from FIFO buffer
+ */
+uint8_t mpu6050GetFIFOByte()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_FIFO_R_W, buffer);
+ return buffer[0];
+}
+void mpu6050GetFIFOBytes(uint8_t *data, uint8_t length)
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_FIFO_R_W, length, data);
+}
+/** Write byte to FIFO buffer.
+ * @see getFIFOByte()
+ * @see MPU6050_RA_FIFO_R_W
+ */
+void mpu6050SetFIFOByte(uint8_t data)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_FIFO_R_W, data);
+}
+
+// WHO_AM_I register
+
+/** Get Device ID.
+ * This register is used to verify the identity of the device (0b110100).
+ * @return Device ID (should be 0x68, 104 dec, 150 oct)
+ * @see MPU6050_RA_WHO_AM_I
+ * @see MPU6050_WHO_AM_I_BIT
+ * @see MPU6050_WHO_AM_I_LENGTH
+ */
+uint8_t mpu6050GetDeviceID()
+{
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_WHO_AM_I, MPU6050_WHO_AM_I_BIT, MPU6050_WHO_AM_I_LENGTH,
+ buffer);
+ return buffer[0];
+}
+/** Set Device ID.
+ * Write a new ID into the WHO_AM_I register (no idea why this should ever be
+ * necessary though).
+ * @param id New device ID to set.
+ * @see getDeviceID()
+ * @see MPU6050_RA_WHO_AM_I
+ * @see MPU6050_WHO_AM_I_BIT
+ * @see MPU6050_WHO_AM_I_LENGTH
+ */
+void mpu6050SetDeviceID(uint8_t id)
+{
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_WHO_AM_I, MPU6050_WHO_AM_I_BIT, MPU6050_WHO_AM_I_LENGTH,
+ id);
+}
+
+// ======== UNDOCUMENTED/DMP REGISTERS/METHODS ========
+
+// XG_OFFS_TC register
+
+uint8_t mpu6050GetOTPBankValid()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_XG_OFFS_TC, MPU6050_TC_OTP_BNK_VLD_BIT, buffer);
+ return buffer[0];
+}
+void mpu6050SetOTPBankValid(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_XG_OFFS_TC, MPU6050_TC_OTP_BNK_VLD_BIT, enabled);
+}
+int8_t mpu6050GetXGyroOffset()
+{
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_XG_OFFS_TC, MPU6050_TC_OFFSET_BIT,
+ MPU6050_TC_OFFSET_LENGTH, buffer);
+ return buffer[0];
+}
+void mpu6050SetXGyroOffset(int8_t offset)
+{
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_XG_OFFS_TC, MPU6050_TC_OFFSET_BIT,
+ MPU6050_TC_OFFSET_LENGTH, offset);
+}
+
+// YG_OFFS_TC register
+
+int8_t mpu6050GetYGyroOffset()
+{
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_YG_OFFS_TC, MPU6050_TC_OFFSET_BIT,
+ MPU6050_TC_OFFSET_LENGTH, buffer);
+ return buffer[0];
+}
+void mpu6050SetYGyroOffset(int8_t offset)
+{
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_YG_OFFS_TC, MPU6050_TC_OFFSET_BIT,
+ MPU6050_TC_OFFSET_LENGTH, offset);
+}
+
+// ZG_OFFS_TC register
+
+int8_t mpu6050GetZGyroOffset()
+{
+ i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_ZG_OFFS_TC, MPU6050_TC_OFFSET_BIT,
+ MPU6050_TC_OFFSET_LENGTH, buffer);
+ return buffer[0];
+}
+void mpu6050SetZGyroOffset(int8_t offset)
+{
+ i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_ZG_OFFS_TC, MPU6050_TC_OFFSET_BIT,
+ MPU6050_TC_OFFSET_LENGTH, offset);
+}
+
+// X_FINE_GAIN register
+
+int8_t mpu6050GetXFineGain()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_X_FINE_GAIN, buffer);
+ return buffer[0];
+}
+void mpu6050SetXFineGain(int8_t gain)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_X_FINE_GAIN, gain);
+}
+
+// Y_FINE_GAIN register
+
+int8_t mpu6050GetYFineGain()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_Y_FINE_GAIN, buffer);
+ return buffer[0];
+}
+void mpu6050SetYFineGain(int8_t gain)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_Y_FINE_GAIN, gain);
+}
+
+// Z_FINE_GAIN register
+
+int8_t mpu6050GetZFineGain()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_Z_FINE_GAIN, buffer);
+ return buffer[0];
+}
+void mpu6050SetZFineGain(int8_t gain)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_Z_FINE_GAIN, gain);
+}
+
+// XA_OFFS_* registers
+
+int16_t mpu6050GetXAccelOffset()
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_XA_OFFS_H, 2, buffer);
+ return (((int16_t) buffer[0]) << 8) | buffer[1];
+}
+void mpu6050SetXAccelOffset(int16_t offset)
+{
+ i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_XA_OFFS_H, 2, (uint8_t *)&offset);
+}
+
+// YA_OFFS_* register
+
+int16_t mpu6050GetYAccelOffset()
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_YA_OFFS_H, 2, buffer);
+ return (((int16_t) buffer[0]) << 8) | buffer[1];
+}
+void mpu6050SetYAccelOffset(int16_t offset)
+{
+ i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_YA_OFFS_H, 2, (uint8_t *)&offset);
+}
+
+// ZA_OFFS_* register
+
+int16_t mpu6050GetZAccelOffset()
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ZA_OFFS_H, 2, buffer);
+ return (((int16_t) buffer[0]) << 8) | buffer[1];
+}
+void mpu6050SetZAccelOffset(int16_t offset)
+{
+ i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_ZA_OFFS_H, 2, (uint8_t *)&offset);
+}
+
+// XG_OFFS_USR* registers
+
+int16_t mpu6050GetXGyroOffsetUser()
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_XG_OFFS_USRH, 2, buffer);
+ return (((int16_t) buffer[0]) << 8) | buffer[1];
+}
+void mpu6050SetXGyroOffsetUser(int16_t offset)
+{
+ i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_XG_OFFS_USRH, 2, (uint8_t *)&offset);
+}
+
+// YG_OFFS_USR* register
+
+int16_t mpu6050GetYGyroOffsetUser()
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_YG_OFFS_USRH, 2, buffer);
+ return (((int16_t) buffer[0]) << 8) | buffer[1];
+}
+void mpu6050SetYGyroOffsetUser(int16_t offset)
+{
+ i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_YG_OFFS_USRH, 2, (uint8_t *)&offset);
+}
+
+// ZG_OFFS_USR* register
+
+int16_t mpu6050GetZGyroOffsetUser()
+{
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ZG_OFFS_USRH, 2, buffer);
+ return (((int16_t) buffer[0]) << 8) | buffer[1];
+}
+void mpu6050SetZGyroOffsetUser(int16_t offset)
+{
+ i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_ZG_OFFS_USRH, 2, (uint8_t *)&offset);
+}
+
+// INT_ENABLE register (DMP functions)
+
+bool mpu6050GetIntPLLReadyEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_PLL_RDY_INT_BIT, buffer);
+ return buffer[0];
+}
+void mpu6050SetIntPLLReadyEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_PLL_RDY_INT_BIT, enabled);
+}
+bool mpu6050GetIntDMPEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_DMP_INT_BIT, buffer);
+ return buffer[0];
+}
+void mpu6050SetIntDMPEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_DMP_INT_BIT, enabled);
+}
+
+// DMP_INT_STATUS
+
+bool mpu6050GetDMPInt5Status()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_5_BIT, buffer);
+ return buffer[0];
+}
+bool mpu6050GetDMPInt4Status()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_4_BIT, buffer);
+ return buffer[0];
+}
+bool mpu6050GetDMPInt3Status()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_3_BIT, buffer);
+ return buffer[0];
+}
+bool mpu6050GetDMPInt2Status()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_2_BIT, buffer);
+ return buffer[0];
+}
+bool mpu6050GetDMPInt1Status()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_1_BIT, buffer);
+ return buffer[0];
+}
+bool mpu6050GetDMPInt0Status()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_0_BIT, buffer);
+ return buffer[0];
+}
+
+// INT_STATUS register (DMP functions)
+
+bool mpu6050GetIntPLLReadyStatus()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_PLL_RDY_INT_BIT, buffer);
+ return buffer[0];
+}
+bool mpu6050GetIntDMPStatus()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_DMP_INT_BIT, buffer);
+ return buffer[0];
+}
+
+// USER_CTRL register (DMP functions)
+
+bool mpu6050GetDMPEnabled()
+{
+ i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_DMP_EN_BIT, buffer);
+ return buffer[0];
+}
+void mpu6050SetDMPEnabled(bool enabled)
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_DMP_EN_BIT, enabled);
+}
+void mpu6050ResetDMP()
+{
+ i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_DMP_RESET_BIT, 1);
+}
+
+// BANK_SEL register
+
+void mpu6050SetMemoryBank(uint8_t bank, bool prefetchEnabled, bool userBank)
+{
+ bank &= 0x1F;
+
+ if (userBank) {
+ bank |= 0x20;
+ }
+
+ if (prefetchEnabled) {
+ bank |= 0x40;
+ }
+
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_BANK_SEL, bank);
+}
+
+// MEM_START_ADDR register
+
+void mpu6050SetMemoryStartAddress(uint8_t address)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_MEM_START_ADDR, address);
+}
+
+// MEM_R_W register
+
+uint8_t mpu6050ReadMemoryByte()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_MEM_R_W, buffer);
+ return buffer[0];
+}
+void mpu6050WriteMemoryByte(uint8_t data)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_MEM_R_W, data);
+}
+void mpu6050ReadMemoryBlock(uint8_t *data, uint16_t dataSize, uint8_t bank, uint8_t address)
+{
+ mpu6050SetMemoryBank(bank, true, true);
+ mpu6050SetMemoryStartAddress(address);
+ uint8_t chunkSize;
+ uint16_t i;
+
+ for (i = 0; i < dataSize;) {
+ // determine correct chunk size according to bank position and data size
+ chunkSize = MPU6050_DMP_MEMORY_CHUNK_SIZE;
+
+ // make sure we don't go past the data size
+ if (i + chunkSize > dataSize) {
+ chunkSize = dataSize - i;
+ }
+
+ // make sure this chunk doesn't go past the bank boundary (256 bytes)
+ if (chunkSize > 256 - address) {
+ chunkSize = 256 - address;
+ }
+
+ // read the chunk of data as specified
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_MEM_R_W, chunkSize, data + i);
+
+ // increase byte index by [chunkSize]
+ i += chunkSize;
+
+ // uint8_t automatically wraps to 0 at 256
+ address += chunkSize;
+
+ // if we aren't done, update bank (if necessary) and address
+ if (i < dataSize) {
+ if (address == 0) {
+ bank++;
+ }
+
+ mpu6050SetMemoryBank(bank, true, true);
+ mpu6050SetMemoryStartAddress(address);
+ }
+ }
+}
+bool mpu6050WriteMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank, uint8_t address,
+ bool verify)
+{
+ static uint8_t verifyBuffer[MPU6050_DMP_MEMORY_CHUNK_SIZE];
+ uint8_t chunkSize;
+ uint8_t *progBuffer;
+ uint16_t i;
+
+ mpu6050SetMemoryBank(bank, true, true);
+ mpu6050SetMemoryStartAddress(address);
+
+ for (i = 0; i < dataSize;) {
+ // determine correct chunk size according to bank position and data size
+ chunkSize = MPU6050_DMP_MEMORY_CHUNK_SIZE;
+
+ // make sure we don't go past the data size
+ if (i + chunkSize > dataSize) {
+ chunkSize = dataSize - i;
+ }
+
+ // make sure this chunk doesn't go past the bank boundary (256 bytes)
+ if (chunkSize > 256 - address) {
+ chunkSize = 256 - address;
+ }
+
+ // write the chunk of data as specified
+ progBuffer = (uint8_t *) data + i;
+
+ i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_MEM_R_W, chunkSize, progBuffer);
+
+ // verify data if needed
+ if (verify) {
+ uint32_t j;
+ mpu6050SetMemoryBank(bank, true, true);
+ mpu6050SetMemoryStartAddress(address);
+ i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_MEM_R_W, chunkSize, verifyBuffer);
+
+ for (j = 0; j < chunkSize; j++) {
+ if (progBuffer[j] != verifyBuffer[j]) {
+ /*Serial.print("Block write verification error, bank ");
+ Serial.print(bank, DEC);
+ Serial.print(", address ");
+ Serial.print(address, DEC);
+ Serial.print("!\nExpected:");
+ for (j = 0; j < chunkSize; j++) {
+ Serial.print(" 0x");
+ if (progBuffer[j] < 16) Serial.print("0");
+ Serial.print(progBuffer[j], HEX);
+ }
+ Serial.print("\nReceived:");
+ for (uint8_t j = 0; j < chunkSize; j++) {
+ Serial.print(" 0x");
+ if (verifyBuffer[i + j] < 16) Serial.print("0");
+ Serial.print(verifyBuffer[i + j], HEX);
+ }
+ Serial.print("\n");*/
+ return false;
+ }
+ }
+ }
+
+ // increase byte index by [chunkSize]
+ i += chunkSize;
+
+ // uint8_t automatically wraps to 0 at 256
+ address += chunkSize;
+
+ // if we aren't done, update bank (if necessary) and address
+ if (i < dataSize) {
+ if (address == 0) {
+ bank++;
+ }
+
+ mpu6050SetMemoryBank(bank, true, true);
+ mpu6050SetMemoryStartAddress(address);
+ }
+ }
+
+ return true;
+}
+bool mpu6050WriteProgMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank,
+ uint8_t address, bool verify)
+{
+ return mpu6050WriteMemoryBlock(data, dataSize, bank, address, verify);
+}
+#define MPU6050_DMP_CONFIG_BLOCK_SIZE 6
+bool mpu6050WriteDMPConfigurationSet(const uint8_t *data, uint16_t dataSize)
+{
+ uint8_t *progBuffer, success, special;
+ uint16_t i;
+
+ // config set data is a long string of blocks with the following structure:
+ // [bank] [offset] [length] [byte[0], byte[1], ..., byte[length]]
+ uint8_t bank = 0;
+ uint8_t offset = 0;
+ uint8_t length = 0;
+
+ for (i = 0; i < dataSize;) {
+ bank = data[i++];
+ offset = data[i++];
+ length = data[i++];
+ }
+
+ // write data or perform special action
+ if (length > 0) {
+ // regular block of data to write
+ /*Serial.print("Writing config block to bank ");
+ Serial.print(bank);
+ Serial.print(", offset ");
+ Serial.print(offset);
+ Serial.print(", length=");
+ Serial.println(length);*/
+ progBuffer = (uint8_t *) data + i;
+ success = mpu6050WriteMemoryBlock(progBuffer, length, bank, offset, true);
+ i += length;
+ } else {
+ // special instruction
+ // NOTE: this kind of behavior (what and when to do certain things)
+ // is totally undocumented. This code is in here based on observed
+ // behavior only, and exactly why (or even whether) it has to be here
+ // is anybody's guess for now.
+ special = data[i++];
+
+ /*Serial.print("Special command code ");
+ Serial.print(special, HEX);
+ Serial.println(" found...");*/
+ if (special == 0x01) {
+ // enable DMP-related interrupts
+ mpu6050SetIntZeroMotionEnabled(true);
+ mpu6050SetIntFIFOBufferOverflowEnabled(true);
+ mpu6050SetIntDMPEnabled(true);
+ //i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, 0x32);
+ success = true;
+ } else {
+ // unknown special command
+ success = false;
+ }
+ }
+
+ if (!success) {
+ return false; // uh oh
+ }
+
+ return true;
+}
+
+bool mpu6050WriteProgDMPConfigurationSet(const uint8_t *data, uint16_t dataSize)
+{
+ return mpu6050WriteDMPConfigurationSet(data, dataSize);
+}
+
+// DMP_CFG_1 register
+
+uint8_t mpu6050GetDMPConfig1()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_DMP_CFG_1, buffer);
+ return buffer[0];
+}
+void mpu6050SetDMPConfig1(uint8_t config)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_DMP_CFG_1, config);
+}
+
+// DMP_CFG_2 register
+
+uint8_t mpu6050GetDMPConfig2()
+{
+ i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_DMP_CFG_2, buffer);
+ return buffer[0];
+}
+void mpu6050SetDMPConfig2(uint8_t config)
+{
+ i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_DMP_CFG_2, config);
+}
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/ms5611/CMakeLists.txt b/Firmware/esp-drone/components/drivers/i2c_devices/ms5611/CMakeLists.txt
new file mode 100644
index 0000000..108f90d
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/ms5611/CMakeLists.txt
@@ -0,0 +1,4 @@
+idf_component_register(SRCS "ms5611.c"
+ INCLUDE_DIRS "." "include"
+ REQUIRES i2c_bus
+ PRIV_REQUIRES crazyflie platform)
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/ms5611/include/ms5611.h b/Firmware/esp-drone/components/drivers/i2c_devices/ms5611/include/ms5611.h
new file mode 100644
index 0000000..c76413a
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/ms5611/include/ms5611.h
@@ -0,0 +1,87 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011 Fabio Varesano <[email protected]>
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * @file ms5611.h
+ * Driver for the ms5611 pressure sensor from measurement specialties.
+ * Datasheet at http://www.meas-spec.com/downloads/MS5611-01BA03.pdf
+ *
+ */
+#ifndef MS5611_H
+#define MS5611_H
+
+#include <stdbool.h>
+#include "i2cdev.h"
+
+// addresses of the device
+#define MS5611_ADDR_CSB_HIGH 0x76 //CBR=1 0x76 I2C address when CSB is connected to HIGH (VCC)
+#define MS5611_ADDR_CSB_LOW 0x77 //CBR=0 0x77 I2C address when CSB is connected to LOW (GND)
+
+// registers of the device
+#define MS5611_D1 0x40
+#define MS5611_D2 0x50
+#define MS5611_RESET 0x1E
+
+// D1 and D2 result size (bytes)
+#define MS5611_D1D2_SIZE 3
+
+// OSR (Over Sampling Ratio) constants
+#define MS5611_OSR_256 0x00
+#define MS5611_OSR_512 0x02
+#define MS5611_OSR_1024 0x04
+#define MS5611_OSR_2048 0x06
+#define MS5611_OSR_4096 0x08
+#define MS5611_OSR_DEFAULT MS5611_OSR_4096
+
+#define MS5611_PROM_BASE_ADDR 0xA2 // by adding ints from 0 to 6 we can read all the prom configuration values.
+// C1 will be at 0xA2 and all the subsequent are multiples of 2
+#define MS5611_PROM_REG_COUNT 6 // number of registers in the PROM
+#define MS5611_PROM_REG_SIZE 2 // size in bytes of a prom registry.
+
+// Self test parameters. Only checks that values are sane
+#define MS5611_ST_PRESS_MAX (1100.0) //mbar
+#define MS5611_ST_PRESS_MIN (450.0) //mbar
+#define MS5611_ST_TEMP_MAX (60.0) //degree celcius
+#define MS5611_ST_TEMP_MIN (-20.0) //degree celcius
+
+// Constants used to determine altitude from pressure
+#define CONST_SEA_PRESSURE 102610.f //1026.1f //http://www.meteo.physik.uni-muenchen.de/dokuwiki/doku.php?id=wetter:stadt:messung
+#define CONST_PF 0.1902630958 //(1/5.25588f) Pressure factor
+#define CONST_PF2 44330.0f
+
+
+bool ms5611Init(I2C_Dev *i2cPort);
+bool ms5611SelfTest(void);
+bool ms5611EvaluateSelfTest(float min, float max, float value, char *string);
+float ms5611GetPressure(uint8_t osr);
+float ms5611CalcPressure(int32_t rawPress, int32_t dT);
+float ms5611GetTemperature(uint8_t osr);
+float ms5611CalcTemp(int32_t deltaT);
+int32_t ms5611GetDeltaTemp(uint8_t osr);
+int32_t ms5611CalcDeltaTemp(int32_t rawTemp);
+int32_t ms5611RawPressure(uint8_t osr);
+int32_t ms5611RawTemperature(uint8_t osr);
+bool ms5611ReadPROM();
+void ms5611Reset();
+void ms5611StartConversion(uint8_t command);
+int32_t ms5611GetConversion(uint8_t command);
+
+void ms5611GetData(float *pressure, float *temperature, float *asl);
+float ms5611PressureToAltitude(float *pressure);
+#endif // MS5611_H
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/ms5611/ms5611.c b/Firmware/esp-drone/components/drivers/i2c_devices/ms5611/ms5611.c
new file mode 100644
index 0000000..8d16fe0
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/ms5611/ms5611.c
@@ -0,0 +1,374 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011 Fabio Varesano <[email protected]>
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * @file ms5611.c
+ * Driver for the ms5611 pressure sensor from measurement specialties.
+ * Datasheet at http://www.meas-spec.com/downloads/MS5611-01BA03.pdf
+ *
+ */
+#define DEBUG_MODULE "MS5611"
+
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+
+#include "ms5611.h"
+#include "i2cdev.h"
+#include "debug_cf.h"
+#include "eprintf.h"
+
+#include "math.h"
+
+#define EXTRA_PRECISION 5 // trick to add more precision to the pressure and temp readings
+#define CONVERSION_TIME_MS 10 // conversion time in milliseconds. 10 is minimum
+#define PRESSURE_PER_TEMP 5 // Length of reading cycle: 1x temp, rest pressure. Good values: 1-10
+#define FIX_TEMP 25 // Fixed Temperature. ASL is a function of pressure and temperature, but as the temperature changes so much (blow a little towards the flie and watch it drop 5 degrees) it corrupts the ASL estimates.
+// TLDR: Adjusting for temp changes does more harm than good.
+
+typedef struct {
+ uint16_t psens;
+ uint16_t off;
+ uint16_t tcs;
+ uint16_t tco;
+ uint16_t tref;
+ uint16_t tsens;
+} CalReg;
+
+static uint8_t devAddr;
+static I2C_Dev *I2Cx;
+static bool isInit;
+
+static CalReg calReg;
+static uint32_t lastPresConv;
+static uint32_t lastTempConv;
+static int32_t tempCache;
+
+static uint8_t readState = 0;
+static uint32_t lastConv = 0;
+static int32_t tempDeltaT;
+
+bool ms5611Init(I2C_Dev *i2cPort)
+{
+ if (isInit) {
+ return true;
+ }
+
+ I2Cx = i2cPort;
+ devAddr = MS5611_ADDR_CSB_LOW;
+
+ ms5611Reset(); // reset the device to populate its internal PROM registers
+ vTaskDelay(M2T(5));
+
+ if (ms5611ReadPROM() == false) { // reads the PROM into object variables for later use
+ return false;
+ }
+
+ isInit = true;
+
+ return true;
+}
+
+bool ms5611SelfTest(void)
+{
+ bool testStatus = true;
+ int32_t rawPress;
+ int32_t rawTemp;
+ int32_t deltaT;
+ float pressure;
+ float temperature;
+
+ if (!isInit) {
+ return false;
+ }
+
+ ms5611StartConversion(MS5611_D1 + MS5611_OSR_4096);
+ vTaskDelay(M2T(CONVERSION_TIME_MS));
+ rawPress = ms5611GetConversion(MS5611_D1 + MS5611_OSR_4096);
+
+ ms5611StartConversion(MS5611_D2 + MS5611_OSR_4096);
+ vTaskDelay(M2T(CONVERSION_TIME_MS));
+ rawTemp = ms5611GetConversion(MS5611_D2 + MS5611_OSR_4096);
+
+ deltaT = ms5611CalcDeltaTemp(rawTemp);
+ temperature = ms5611CalcTemp(deltaT);
+ pressure = ms5611CalcPressure(rawPress, deltaT);
+
+ if (ms5611EvaluateSelfTest(MS5611_ST_PRESS_MIN, MS5611_ST_PRESS_MAX, pressure, "pressure") &&
+ ms5611EvaluateSelfTest(MS5611_ST_TEMP_MIN, MS5611_ST_TEMP_MAX, temperature, "temperature")) {
+ DEBUG_PRINTD("ms5611 Self test [OK].\n");
+ } else {
+ testStatus = false;
+ }
+
+ return testStatus;
+}
+
+bool ms5611EvaluateSelfTest(float min, float max, float value, char *string)
+{
+ if (value < min || value > max) {
+ DEBUG_PRINTD("Self test %s [FAIL]. low: %0.2f, high: %0.2f, measured: %0.2f\n",
+ string, (double)min, (double)max, (double)value);
+ return false;
+ }
+
+ return true;
+}
+
+float ms5611GetPressure(uint8_t osr)
+{
+ // see datasheet page 7 for formulas
+ int32_t rawPress = ms5611RawPressure(osr);
+ int64_t dT = (int64_t)ms5611GetDeltaTemp(osr);
+
+ if (dT == 0) {
+ return 0;
+ }
+
+ int64_t off = (((int64_t)calReg.off) << 16) + ((calReg.tco * dT) >> 7);
+ int64_t sens = (((int64_t)calReg.psens) << 15) + ((calReg.tcs * dT) >> 8);
+
+ if (rawPress != 0) {
+ return ((((rawPress * sens) >> 21) - off) >> (15 - EXTRA_PRECISION))
+ / ((1 << EXTRA_PRECISION) * 100.0);
+ } else {
+ return 0;
+ }
+}
+
+float ms5611CalcPressure(int32_t rawPress, int32_t dT)
+{
+ int64_t off;
+ int64_t sens;
+
+ if (rawPress == 0 || dT == 0) {
+ return 0;
+ }
+
+ off = (((int64_t)calReg.off) << 16) + ((calReg.tco * (int64_t)dT) >> 7);
+ sens = (((int64_t)calReg.psens) << 15) + ((calReg.tcs * (int64_t)dT) >> 8);
+
+ return ((((rawPress * sens) >> 21) - off) >> (15 - EXTRA_PRECISION))
+ / ((1 << EXTRA_PRECISION) * 100.0);
+}
+
+float ms5611GetTemperature(uint8_t osr)
+{
+ // see datasheet page 7 for formulas
+ int32_t dT;
+
+ dT = ms5611GetDeltaTemp(osr);
+
+ if (dT != 0) {
+ return ms5611CalcTemp(dT);
+ } else {
+ return 0;
+ }
+}
+
+int32_t ms5611GetDeltaTemp(uint8_t osr)
+{
+ int32_t rawTemp = ms5611RawTemperature(osr);
+
+ if (rawTemp != 0) {
+ return ms5611CalcDeltaTemp(rawTemp);
+ } else {
+ return 0;
+ }
+}
+
+float ms5611CalcTemp(int32_t deltaT)
+{
+ if (deltaT == 0) {
+ return 0;
+ } else {
+ return (float)(((1 << EXTRA_PRECISION) * 2000)
+ + (((int64_t)deltaT * calReg.tsens) >> (23 - EXTRA_PRECISION)))
+ / ((1 << EXTRA_PRECISION) * 100.0f);
+ }
+}
+
+int32_t ms5611CalcDeltaTemp(int32_t rawTemp)
+{
+ if (rawTemp == 0) {
+ return 0;
+ } else {
+ return rawTemp - (((int32_t)calReg.tref) << 8);
+ }
+}
+
+int32_t ms5611RawPressure(uint8_t osr)
+{
+ uint32_t now = xTaskGetTickCount();
+
+ if (lastPresConv != 0 && (now - lastPresConv) >= CONVERSION_TIME_MS) {
+ lastPresConv = 0;
+ return ms5611GetConversion(MS5611_D1 + osr);
+ } else {
+ if (lastPresConv == 0 && lastTempConv == 0) {
+ ms5611StartConversion(MS5611_D1 + osr);
+ lastPresConv = now;
+ }
+
+ return 0;
+ }
+}
+
+int32_t ms5611RawTemperature(uint8_t osr)
+{
+ uint32_t now = xTaskGetTickCount();
+
+ if (lastTempConv != 0 && (now - lastTempConv) >= CONVERSION_TIME_MS) {
+ lastTempConv = 0;
+ tempCache = ms5611GetConversion(MS5611_D2 + osr);
+ return tempCache;
+ } else {
+ if (lastTempConv == 0 && lastPresConv == 0) {
+ ms5611StartConversion(MS5611_D2 + osr);
+ lastTempConv = now;
+ }
+
+ return tempCache;
+ }
+}
+
+// see page 11 of the datasheet
+void ms5611StartConversion(uint8_t command)
+{
+ // initialize pressure conversion
+ i2cdevWriteByte(I2Cx, devAddr, I2CDEV_NO_MEM_ADDR, command);
+}
+
+int32_t ms5611GetConversion(uint8_t command)
+{
+ int32_t conversion = 0;
+ uint8_t buffer[MS5611_D1D2_SIZE];
+
+ // start read sequence
+ i2cdevWriteByte(I2Cx, devAddr, I2CDEV_NO_MEM_ADDR, 0);
+ // Read conversion
+ i2cdevRead(I2Cx, devAddr, MS5611_D1D2_SIZE, buffer);
+ conversion = ((int32_t)buffer[0] << 16) |
+ ((int32_t)buffer[1] << 8) | buffer[2];
+
+ return conversion;
+}
+
+/**
+ * Reads factory calibration and store it into object variables.
+ */
+bool ms5611ReadPROM()
+{
+ uint8_t buffer[MS5611_PROM_REG_SIZE];
+ uint16_t *pCalRegU16 = (uint16_t *)&calReg;
+ int32_t i = 0;
+ bool status = false;
+
+ for (i = 0; i < MS5611_PROM_REG_COUNT; i++) {
+ // start read sequence
+ status = i2cdevWriteByte(I2Cx, devAddr, I2CDEV_NO_MEM_ADDR,
+ MS5611_PROM_BASE_ADDR + (i * MS5611_PROM_REG_SIZE));
+
+ // Read conversion
+ if (status) {
+ status = i2cdevRead(I2Cx, devAddr, MS5611_PROM_REG_SIZE, buffer);
+ pCalRegU16[i] = ((uint16_t)buffer[0] << 8) | buffer[1];
+ }
+ }
+
+ return status;
+}
+
+/**
+ * Send a reset command to the device. With the reset command the device
+ * populates its internal registers with the values read from the PROM.
+ */
+void ms5611Reset()
+{
+ i2cdevWriteByte(I2Cx, devAddr, I2CDEV_NO_MEM_ADDR, MS5611_RESET);
+}
+
+
+
+
+/**
+ * Gets pressure, temperature and above sea level altitude estimate (asl).
+ * Best called at 100hz. For every PRESSURE_PER_TEMP-1 pressure readings temp is read once.
+ * Effective 50-90hz baro update and 50-10hz temperature update if called at 100hz.
+ */
+void ms5611GetData(float *pressure, float *temperature, float *asl)
+{
+ int32_t tempPressureRaw, tempTemperatureRaw;
+ static float savedPress, savedTemp;
+
+ // Dont reader faster than we can
+ uint32_t now = xTaskGetTickCount();
+
+ if ((now - lastConv) < CONVERSION_TIME_MS) {
+ *pressure = savedPress;
+ *temperature = savedTemp;
+ return;
+ }
+
+ lastConv = now;
+
+ if (readState == 0) {
+ // read temp
+ ++readState;
+ tempTemperatureRaw = ms5611GetConversion(MS5611_D2 + MS5611_OSR_DEFAULT);
+ tempDeltaT = ms5611CalcDeltaTemp(tempTemperatureRaw);
+ *temperature = ms5611CalcTemp(tempDeltaT);
+ savedTemp = *temperature;
+ *pressure = savedPress;
+ // cmd to read pressure
+ ms5611StartConversion(MS5611_D1 + MS5611_OSR_DEFAULT);
+ } else {
+ // read pressure
+ ++readState;
+ tempPressureRaw = ms5611GetConversion(MS5611_D1 + MS5611_OSR_DEFAULT);
+ *pressure = ms5611CalcPressure(tempPressureRaw, tempDeltaT);
+ savedPress = *pressure;
+ *asl = ms5611PressureToAltitude(pressure);
+ *temperature = savedTemp;
+
+ if (readState == PRESSURE_PER_TEMP) {
+ // cmd to read temp
+ ms5611StartConversion(MS5611_D2 + MS5611_OSR_DEFAULT);
+ readState = 0;
+ } else {
+ // cmd to read pressure
+ ms5611StartConversion(MS5611_D1 + MS5611_OSR_DEFAULT);
+ }
+ }
+}
+
+//TODO: pretty expensive function. Rather smooth the pressure estimates and only call this when needed
+
+/**
+ * Converts pressure to altitude above sea level (ASL) in meters
+ */
+float ms5611PressureToAltitude(float *pressure/*, float* ground_pressure, float* ground_temp*/)
+{
+ if (*pressure > 0) {
+ //return (1.f - powf(*pressure / CONST_SEA_PRESSURE, CONST_PF)) * CONST_PF2;
+ //return ((powf((1015.7f / *pressure), CONST_PF) - 1.0f) * (25.f + 273.15f)) / 0.0065f;
+ return ((powf((1015.7f / *pressure), CONST_PF) - 1.0f) * (FIX_TEMP + 273.15f)) / 0.0065f;
+ } else {
+ return 0;
+ }
+}
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l0/CMakeLists.txt b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l0/CMakeLists.txt
new file mode 100644
index 0000000..454c79c
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l0/CMakeLists.txt
@@ -0,0 +1,3 @@
+idf_component_register(SRCS "vl53l0x.c" "zranger.c"
+ INCLUDE_DIRS "." "include"
+ REQUIRES i2c_bus crazyflie platform config)
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l0/include/vl53l0x.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l0/include/vl53l0x.h
new file mode 100644
index 0000000..a2726ed
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l0/include/vl53l0x.h
@@ -0,0 +1,263 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2012 BitCraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * vl53l0x.h: Time-of-flight distance sensor driver
+ */
+
+#ifndef _VL53L0X_H_
+#define _VL53L0X_H_
+
+#include "i2cdev.h"
+
+#define VL53L0X_DEFAULT_ADDRESS 0x29 //0b0101001
+#define VL53L0X_ID 0xEEAA
+
+#define VL53L0X_RA_SYSRANGE_START 0x00
+
+#define VL53L0X_REG_I2C_SLAVE_DEVICE_ADDRESS 0x8a
+
+#define VL53L0X_RA_SYSTEM_THRESH_HIGH 0x0C
+#define VL53L0X_RA_SYSTEM_THRESH_LOW 0x0E
+
+#define VL53L0X_RA_SYSTEM_SEQUENCE_CONFIG 0x01
+#define VL53L0X_RA_SYSTEM_RANGE_CONFIG 0x09
+#define VL53L0X_RA_SYSTEM_INTERMEASUREMENT_PERIOD 0x04
+
+#define VL53L0X_RA_SYSTEM_INTERRUPT_CONFIG_GPIO 0x0A
+
+#define VL53L0X_RA_GPIO_HV_MUX_ACTIVE_HIGH 0x84
+
+#define VL53L0X_RA_SYSTEM_INTERRUPT_CLEAR 0x0B
+
+#define VL53L0X_RA_RESULT_INTERRUPT_STATUS 0x13
+#define VL53L0X_RA_RESULT_RANGE_STATUS 0x14
+
+#define VL53L0X_RA_RESULT_CORE_AMBIENT_WINDOW_EVENTS_RTN 0xBC
+#define VL53L0X_RA_RESULT_CORE_RANGING_TOTAL_EVENTS_RTN 0xC0
+#define VL53L0X_RA_RESULT_CORE_AMBIENT_WINDOW_EVENTS_REF 0xD0
+#define VL53L0X_RA_RESULT_CORE_RANGING_TOTAL_EVENTS_REF 0xD4
+#define VL53L0X_RA_RESULT_PEAK_SIGNAL_RATE_REF 0xB6
+
+#define VL53L0X_RA_ALGO_PART_TO_PART_RANGE_OFFSET_MM 0x28
+
+#define VL53L0X_RA_I2C_SLAVE_DEVICE_ADDRESS 0x8A
+
+#define VL53L0X_RA_MSRC_CONFIG_CONTROL 0x60
+
+#define VL53L0X_RA_PRE_RANGE_CONFIG_MIN_SNR 0x27
+#define VL53L0X_RA_PRE_RANGE_CONFIG_VALID_PHASE_LOW 0x56
+#define VL53L0X_RA_PRE_RANGE_CONFIG_VALID_PHASE_HIGH 0x57
+#define VL53L0X_RA_PRE_RANGE_MIN_COUNT_RATE_RTN_LIMIT 0x64
+
+#define VL53L0X_RA_FINAL_RANGE_CONFIG_MIN_SNR 0x67
+#define VL53L0X_RA_FINAL_RANGE_CONFIG_VALID_PHASE_LOW 0x47
+#define VL53L0X_RA_FINAL_RANGE_CONFIG_VALID_PHASE_HIGH 0x48
+#define VL53L0X_RA_FINAL_RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT 0x44
+
+#define VL53L0X_RA_PRE_RANGE_CONFIG_SIGMA_THRESH_HI 0x61
+#define VL53L0X_RA_PRE_RANGE_CONFIG_SIGMA_THRESH_LO 0x62
+
+#define VL53L0X_RA_PRE_RANGE_CONFIG_VCSEL_PERIOD 0x50
+#define VL53L0X_RA_PRE_RANGE_CONFIG_TIMEOUT_MACROP_HI 0x51
+#define VL53L0X_RA_PRE_RANGE_CONFIG_TIMEOUT_MACROP_LO 0x52
+
+#define VL53L0X_RA_SYSTEM_HISTOGRAM_BIN 0x81
+#define VL53L0X_RA_HISTOGRAM_CONFIG_INITIAL_PHASE_SELECT 0x33
+#define VL53L0X_RA_HISTOGRAM_CONFIG_READOUT_CTRL 0x55
+
+#define VL53L0X_RA_FINAL_RANGE_CONFIG_VCSEL_PERIOD 0x70
+#define VL53L0X_RA_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_HI 0x71
+#define VL53L0X_RA_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_LO 0x72
+#define VL53L0X_RA_CROSSTALK_COMPENSATION_PEAK_RATE_MCPS 0x20
+
+#define VL53L0X_RA_MSRC_CONFIG_TIMEOUT_MACROP 0x46
+
+#define VL53L0X_RA_SOFT_RESET_GO2_SOFT_RESET_N 0xBF
+#define VL53L0X_RA_IDENTIFICATION_MODEL_ID 0xC0
+#define VL53L0X_RA_IDENTIFICATION_REVISION_ID 0xC2
+
+#define VL53L0X_IDENTIFICATION_MODEL_ID 0xEEAA
+#define VL53L0X_IDENTIFICATION_REVISION_ID 0x10
+
+#define VL53L0X_RA_OSC_CALIBRATE_VAL 0xF8
+
+#define VL53L0X_RA_GLOBAL_CONFIG_VCSEL_WIDTH 0x32
+#define VL53L0X_RA_GLOBAL_CONFIG_SPAD_ENABLES_REF_0 0xB0
+#define VL53L0X_RA_GLOBAL_CONFIG_SPAD_ENABLES_REF_1 0xB1
+#define VL53L0X_RA_GLOBAL_CONFIG_SPAD_ENABLES_REF_2 0xB2
+#define VL53L0X_RA_GLOBAL_CONFIG_SPAD_ENABLES_REF_3 0xB3
+#define VL53L0X_RA_GLOBAL_CONFIG_SPAD_ENABLES_REF_4 0xB4
+#define VL53L0X_RA_GLOBAL_CONFIG_SPAD_ENABLES_REF_5 0xB5
+
+#define VL53L0X_RA_GLOBAL_CONFIG_REF_EN_START_SELECT 0xB6
+#define VL53L0X_RA_DYNAMIC_SPAD_NUM_REQUESTED_REF_SPAD 0x4E
+#define VL53L0X_RA_DYNAMIC_SPAD_REF_EN_START_OFFSET 0x4F
+#define VL53L0X_RA_POWER_MANAGEMENT_GO1_POWER_FORCE 0x80
+
+#define VL53L0X_RA_VHV_CONFIG_PAD_SCL_SDA__EXTSUP_HV 0x89
+
+#define VL53L0X_RA_ALGO_PHASECAL_LIM 0x30
+#define VL53L0X_RA_ALGO_PHASECAL_CONFIG_TIMEOUT 0x30
+
+// TCC: Target CentreCheck
+// MSRC: Minimum Signal Rate Check
+// DSS: Dynamic Spad Selection
+typedef struct {
+ bool tcc;
+ bool msrc;
+ bool dss;
+ bool pre_range;
+ bool final_range;
+} SequenceStepEnables;
+
+typedef struct
+{
+ uint16_t pre_range_vcsel_period_pclks, final_range_vcsel_period_pclks;
+ uint16_t msrc_dss_tcc_mclks, pre_range_mclks, final_range_mclks;
+ uint32_t msrc_dss_tcc_us, pre_range_us, final_range_us;
+} SequenceStepTimeouts;
+
+typedef enum vcselPeriodType_t { VcselPeriodPreRange, VcselPeriodFinalRange } vcselPeriodType;
+
+typedef struct
+{
+ uint8_t devAddr;
+ I2C_Dev *I2Cx;
+
+ uint16_t io_timeout;
+ bool did_timeout;
+ uint16_t timeout_start_ms;
+
+ // read by init and used when starting measurement;
+ // is StopVariable field of VL53L0X_DevData_t structure in API
+ uint8_t stop_variable;
+
+ uint32_t measurement_timing_budget_us;
+ uint16_t measurement_timing_budget_ms;
+} VL53L0xDev;
+
+/** Default constructor, uses external I2C address.
+ * @see VL53L0X_DEFAULT_ADDRESS
+ */
+bool vl53l0xInit(VL53L0xDev* dev, I2C_Dev *I2Cx, bool io_2V8);
+
+/** Verify the I2C connection.
+ * Make sure the device is connected and responds as expected.
+ * @return True if connection is valid, false otherwise
+ */
+bool vl53l0xTestConnection(VL53L0xDev* dev);
+
+/** Get Model ID.
+ * This register is used to verify the model number of the device,
+ * but only before it has been configured to run
+ * @return Model ID
+ * @see VL53L0X_RA_IDENTIFICATION_MODEL_ID
+ * @see VL53L0X_IDENTIFICATION_MODEL_ID
+ */
+uint16_t vl53l0xGetModelID(VL53L0xDev* dev);
+
+/** Get Revision ID.
+ * This register is used to verify the revision number of the device,
+ * but only before it has been configured to run
+ * @return Revision ID
+ * @see VL53L0X_RA_IDENTIFICATION_REVISION_ID
+ * @see VL53L0X_IDENTIFICATION_REVISION_ID
+ */
+uint8_t vl53l0xGetRevisionID(VL53L0xDev* dev);
+
+/** Set I2C address
+ * Any subsequent communication will be on the new address
+ * The address passed is the 7bit I2C address from LSB (ie. without the
+ * read/write bit)
+ */
+bool vl53l0xSetI2CAddress(VL53L0xDev* dev, uint8_t address);
+
+// Initialize sensor using sequence based on VL53L0X_DataInit(),
+// VL53L0X_StaticInit(), and VL53L0X_PerformRefCalibration().
+// This function does not perform reference SPAD calibration
+// (VL53L0X_PerformRefSpadManagement()), since the API user manual says that it
+// is performed by ST on the bare modules; it seems like that should work well
+// enough unless a cover glass is added.
+// If io_2v8 (optional) is true or not given, the sensor is configured for 2V8
+// mode.
+bool vl53l0xInitSensor(VL53L0xDev* dev, bool io_2v8);
+
+// Set the return signal rate limit check value in units of MCPS (mega counts
+// per second). "This represents the amplitude of the signal reflected from the
+// target and detected by the device"; setting this limit presumably determines
+// the minimum measurement necessary for the sensor to report a valid reading.
+// Setting a lower limit increases the potential range of the sensor but also
+// seems to increase the likelihood of getting an inaccurate reading because of
+// unwanted reflections from objects other than the intended target.
+// Defaults to 0.25 MCPS as initialized by the ST API and this library.
+bool vl53l0xSetSignalRateLimit(VL53L0xDev* dev, float limit_Mcps);
+
+// Set the measurement timing budget in microseconds, which is the time allowed
+// for one measurement; the ST API and this library take care of splitting the
+// timing budget among the sub-steps in the ranging sequence. A longer timing
+// budget allows for more accurate measurements. Increasing the budget by a
+// factor of N decreases the range measurement standard deviation by a factor of
+// sqrt(N). Defaults to about 33 milliseconds; the minimum is 20 ms.
+// based on VL53L0X_set_measurement_timing_budget_micro_seconds()
+bool vl53l0xSetMeasurementTimingBudget(VL53L0xDev* dev, uint32_t budget_us);
+
+// Get the measurement timing budget in microseconds
+// based on VL53L0X_get_measurement_timing_budget_micro_seconds()
+// in us
+uint32_t vl53l0xGetMeasurementTimingBudget(VL53L0xDev* dev);
+
+// Set the VCSEL (vertical cavity surface emitting laser) pulse period for the
+// given period type (pre-range or final range) to the given value in PCLKs.
+// Longer periods seem to increase the potential range of the sensor.
+// Valid values are (even numbers only):
+// pre: 12 to 18 (initialized default: 14)
+// final: 8 to 14 (initialized default: 10)
+// based on VL53L0X_set_vcsel_pulse_period()
+bool vl53l0xSetVcselPulsePeriod(VL53L0xDev* dev, vcselPeriodType type, uint8_t period_pclks);
+
+// Get the VCSEL pulse period in PCLKs for the given period type.
+// based on VL53L0X_get_vcsel_pulse_period()
+uint8_t vl53l0xGetVcselPulsePeriod(VL53L0xDev* dev, vcselPeriodType type);
+
+// Start continuous ranging measurements. If period_ms (optional) is 0 or not
+// given, continuous back-to-back mode is used (the sensor takes measurements as
+// often as possible); otherwise, continuous timed mode is used, with the given
+// inter-measurement period in milliseconds determining how often the sensor
+// takes a measurement.
+// based on VL53L0X_StartMeasurement()
+void vl53l0xStartContinuous(VL53L0xDev* dev, uint32_t period_ms);
+
+// Stop continuous measurements
+// based on VL53L0X_StopMeasurement()
+void vl53l0xStopContinuous(VL53L0xDev* dev);
+
+// Returns a range reading in millimeters when continuous mode is active
+// (readRangeSingleMillimeters() also calls this function after starting a
+// single-shot range measurement)
+uint16_t vl53l0xReadRangeContinuousMillimeters(VL53L0xDev* dev);
+
+// Performs a single-shot range measurement and returns the reading in
+// millimeters
+// based on VL53L0X_PerformSingleRangingMeasurement()
+uint16_t vl53l0xReadRangeSingleMillimeters(VL53L0xDev* dev);
+
+uint16_t vl53l0xReadReg16Bit(VL53L0xDev* dev, uint8_t reg);
+
+
+#endif /* _VL53L0X_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l0/include/zranger.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l0/include/zranger.h
new file mode 100644
index 0000000..0c822d3
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l0/include/zranger.h
@@ -0,0 +1,38 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2012 BitCraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * zranger.h: Z-Ranger deck driver
+ */
+
+#ifndef _ZRANGER_H_
+#define _ZRANGER_H_
+
+#include "stabilizer_types.h"
+//#include "deck_core.h"
+
+void zRangerInit(void);//DeckInfo* info);
+
+bool zRangerTest(void);
+void zRangerTask(void* arg);
+
+bool zRangerReadRange(zDistance_t* zrange, const uint32_t tick);
+
+int16_t zRangerMeasurementAndRestart();
+
+#endif /* _ZRANGER_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l0/vl53l0x.c b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l0/vl53l0x.c
new file mode 100644
index 0000000..165fc2f
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l0/vl53l0x.c
@@ -0,0 +1,1083 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2012 BitCraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * vl53l0x.c: Time-of-flight distance sensor driver
+ */
+
+#define DEBUG_MODULE "VLX"
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+
+#include "debug_cf.h"
+
+#include "i2cdev.h"
+#include "vl53l0x.h"
+
+// Record the current time to check an upcoming timeout against
+#define startTimeout() (dev->timeout_start_ms = xTaskGetTickCount())
+
+// Check if timeout is enabled (set to nonzero value) and has expired
+#define checkTimeoutExpired() (dev->io_timeout > 0 && ((uint16_t)xTaskGetTickCount() - dev->timeout_start_ms) > dev->io_timeout)
+
+// Decode VCSEL (vertical cavity surface emitting laser) pulse period in PCLKs
+// from register value
+// based on VL53L0X_decode_vcsel_period()
+#define decodeVcselPeriod(reg_val) (((reg_val) + 1) << 1)
+
+// Encode VCSEL pulse period register value from period in PCLKs
+// based on VL53L0X_encode_vcsel_period()
+#define encodeVcselPeriod(period_pclks) (((period_pclks) >> 1) - 1)
+
+// Calculate macro period in *nanoseconds* from VCSEL period in PCLKs
+// based on VL53L0X_calc_macro_period_ps()
+// PLL_period_ps = 1655; macro_period_vclks = 2304
+#define calcMacroPeriod(vcsel_period_pclks) ((((uint32_t)2304 * (vcsel_period_pclks) * 1655) + 500) / 1000)
+
+// Get reference SPAD (single photon avalanche diode) count and type
+// based on VL53L0X_get_info_from_device(),
+// but only gets reference SPAD count and type
+static bool vl53l0xGetSpadInfo(VL53L0xDev *dev, uint8_t *count, bool *type_is_aperture);
+
+// Get sequence step enables
+// based on VL53L0X_GetSequenceStepEnables()
+static void vl53l0xGetSequenceStepEnables(VL53L0xDev *dev, SequenceStepEnables *enables);
+
+// Get sequence step timeouts
+// based on get_sequence_step_timeout(),
+// but gets all timeouts instead of just the requested one, and also stores
+// intermediate values
+static void vl53l0xGetSequenceStepTimeouts(VL53L0xDev *dev, SequenceStepEnables const *enables, SequenceStepTimeouts *timeouts);
+
+// based on VL53L0X_perform_single_ref_calibration()
+static bool vl53l0xPerformSingleRefCalibration(VL53L0xDev *dev, uint8_t vhv_init_byte);
+
+// Decode sequence step timeout in MCLKs from register value
+// based on VL53L0X_decode_timeout()
+// Note: the original function returned a uint32_t, but the return value is
+// always stored in a uint16_t.
+static uint16_t vl53l0xDecodeTimeout(uint16_t reg_val);
+
+// Encode sequence step timeout register value from timeout in MCLKs
+// based on VL53L0X_encode_timeout()
+// Note: the original function took a uint16_t, but the argument passed to it
+// is always a uint16_t.
+static uint16_t vl53l0xEncodeTimeout(uint16_t timeout_mclks);
+
+// Convert sequence step timeout from MCLKs to microseconds with given VCSEL period in PCLKs
+// based on VL53L0X_calc_timeout_us()
+static uint32_t vl53l0xTimeoutMclksToMicroseconds(uint16_t timeout_period_mclks, uint8_t vcsel_period_pclks);
+
+// Convert sequence step timeout from microseconds to MCLKs with given VCSEL period in PCLKs
+// based on VL53L0X_calc_timeout_mclks()
+static uint32_t vl53l0xTimeoutMicrosecondsToMclks(uint32_t timeout_period_us, uint8_t vcsel_period_pclks);
+
+uint16_t vl53l0xReadReg16Bit(VL53L0xDev *dev, uint8_t reg);
+static bool vl53l0xWriteReg16Bit(VL53L0xDev *dev, uint8_t reg, uint16_t val);
+static bool vl53l0xWriteReg32Bit(VL53L0xDev *dev, uint8_t reg, uint32_t val);
+
+//static int nextI2CAddress = VL53L0X_DEFAULT_ADDRESS + 1;
+
+/** Default constructor, uses default I2C address.
+ * @see VL53L0X_DEFAULT_ADDRESS
+ */
+
+bool vl53l0xInit(VL53L0xDev *dev, I2C_Dev *I2Cx, bool io_2V8)
+{
+ // dev->I2Cx = I2Cx;
+ // dev->devAddr = VL53L0X_DEFAULT_ADDRESS;
+ // i2cdevInit(dev->I2Cx);
+
+ // dev->io_timeout = 0;
+ // dev->did_timeout = 0;
+ // dev->timeout_start_ms = 0;
+ // dev->stop_variable = 0;
+ // dev->measurement_timing_budget_us = 0;
+ // dev->measurement_timing_budget_ms = 0;
+
+ if (!vl53l0xInitSensor(dev, io_2V8)) {
+ return false;
+ }
+
+ /* Move initialized sensor to a new I2C address */
+ //int newAddress;
+
+ // taskENTER_CRITICAL();
+ // newAddress = nextI2CAddress++;
+ // taskEXIT_CRITICAL();
+
+ //return vl53l0xSetI2CAddress(dev, newAddress);
+ return true;
+}
+
+/** Verify the I2C connection.
+ * Make sure the device is connected and responds as expected.
+ * @return True if connection is valid, false otherwise
+ */
+bool vl53l0xTestConnection(VL53L0xDev *dev)
+{
+ bool ret = true;
+ ret &= vl53l0xGetModelID(dev) == VL53L0X_IDENTIFICATION_MODEL_ID;
+ ret &= vl53l0xGetRevisionID(dev) == VL53L0X_IDENTIFICATION_REVISION_ID;
+ return ret;
+}
+
+/** Get Model ID.
+ * This register is used to verify the model number of the device,
+ * but only before it has been configured to run
+ * @return Model ID
+ * @see VL53L0X_RA_IDENTIFICATION_MODEL_ID
+ * @see VL53L0X_IDENTIFICATION_MODEL_ID
+ */
+uint16_t vl53l0xGetModelID(VL53L0xDev *dev)
+{
+ return vl53l0xReadReg16Bit(dev, VL53L0X_RA_IDENTIFICATION_MODEL_ID);
+}
+
+/** Get Revision ID.
+ * This register is used to verify the revision number of the device,
+ * but only before it has been configured to run
+ * @return Revision ID
+ * @see VL53L0X_RA_IDENTIFICATION_REVISION_ID
+ * @see VL53L0X_IDENTIFICATION_REVISION_ID
+ */
+uint8_t vl53l0xGetRevisionID(VL53L0xDev *dev)
+{
+ uint8_t output = 0;
+ i2cdevReadByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_IDENTIFICATION_REVISION_ID, &output);
+ return output;
+}
+
+/** Set I2C address
+ * Any subsequent communication will be on the new address
+ * The address passed is the 7bit I2C address from LSB (ie. without the
+ * read/write bit)
+ */
+bool vl53l0xSetI2CAddress(VL53L0xDev *dev, uint8_t address)
+{
+ bool pass = i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_REG_I2C_SLAVE_DEVICE_ADDRESS, address);
+ dev->devAddr = address;
+ return pass;
+}
+
+// Initialize sensor using sequence based on VL53L0X_DataInit(),
+// VL53L0X_StaticInit(), and VL53L0X_PerformRefCalibration().
+// This function does not perform reference SPAD calibration
+// (VL53L0X_PerformRefSpadManagement()), since the API user manual says that it
+// is performed by ST on the bare modules; it seems like that should work well
+// enough unless a cover glass is added.
+// If io_2v8 (optional) is true or not given, the sensor is configured for 2V8
+// mode.
+bool vl53l0xInitSensor(VL53L0xDev *dev, bool io_2v8)
+{
+ uint8_t temp;
+ // VL53L0X_DataInit() begin
+
+ // sensor uses 1V8 mode for I/O by default; switch to 2V8 mode if necessary
+ if (io_2v8) {
+ i2cdevWriteBit(dev->I2Cx, dev->devAddr, VL53L0X_RA_VHV_CONFIG_PAD_SCL_SDA__EXTSUP_HV, 0, 0x01);
+ }
+
+ // "Set I2C standard mode"
+ if (!i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x88, 0x00)) {
+ return false;
+ }
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x80, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x00, 0x00);
+ i2cdevReadByte(dev->I2Cx, dev->devAddr, 0x91, &dev->stop_variable);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x00, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x80, 0x00);
+
+ // disable SIGNAL_RATE_MSRC (bit 1) and SIGNAL_RATE_PRE_RANGE (bit 4) limit checks
+ i2cdevReadByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_MSRC_CONFIG_CONTROL, &temp);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_MSRC_CONFIG_CONTROL, temp | 0x12);
+
+ // set final range signal rate limit to 0.25 MCPS (million counts per second)
+ vl53l0xSetSignalRateLimit(dev, 0.25);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSTEM_SEQUENCE_CONFIG, 0xFF);
+
+ // VL53L0X_DataInit() end
+
+ // VL53L0X_StaticInit() begin
+
+ uint8_t spad_count;
+ bool spad_type_is_aperture;
+
+ if (!vl53l0xGetSpadInfo(dev, &spad_count, &spad_type_is_aperture)) {
+ return false;
+ }
+
+ // The SPAD map (RefGoodSpadMap) is read by VL53L0X_get_info_from_device() in
+ // the API, but the same data seems to be more easily readable from
+ // GLOBAL_CONFIG_SPAD_ENABLES_REF_0 through _6, so read it from there
+ uint8_t ref_spad_map[6];
+ i2cdevReadReg8(dev->I2Cx, dev->devAddr, VL53L0X_RA_GLOBAL_CONFIG_SPAD_ENABLES_REF_0, 6, ref_spad_map);
+
+ // -- VL53L0X_set_reference_spads() begin (assume NVM values are valid)
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_DYNAMIC_SPAD_REF_EN_START_OFFSET, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_DYNAMIC_SPAD_NUM_REQUESTED_REF_SPAD, 0x2C);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_GLOBAL_CONFIG_REF_EN_START_SELECT, 0xB4);
+
+ uint8_t first_spad_to_enable = spad_type_is_aperture ? 12 : 0; // 12 is the first aperture spad
+ uint8_t spads_enabled = 0;
+
+ for (uint8_t i = 0; i < 48; i++) {
+ if (i < first_spad_to_enable || spads_enabled == spad_count) {
+ // This bit is lower than the first one that should be enabled, or
+ // (reference_spad_count) bits have already been enabled, so zero this bit
+ ref_spad_map[i / 8] &= ~(1 << (i % 8));
+ } else if ((ref_spad_map[i / 8] >> (i % 8)) & 0x1) {
+ spads_enabled++;
+ }
+ }
+
+ i2cdevWriteReg8(dev->I2Cx, dev->devAddr, VL53L0X_RA_GLOBAL_CONFIG_SPAD_ENABLES_REF_0, 6, ref_spad_map);
+
+ // -- VL53L0X_set_reference_spads() end
+
+ // -- VL53L0X_load_tuning_settings() begin
+ // DefaultTuningSettings from vl53l0x_tuning.h
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x00, 0x00);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x09, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x10, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x11, 0x00);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x24, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x25, 0xFF);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x75, 0x00);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x4E, 0x2C);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x48, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x30, 0x20);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x30, 0x09);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x54, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x31, 0x04);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x32, 0x03);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x40, 0x83);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x46, 0x25);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x60, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x27, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x50, 0x06);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x51, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x52, 0x96);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x56, 0x08);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x57, 0x30);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x61, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x62, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x64, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x65, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x66, 0xA0);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x22, 0x32);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x47, 0x14);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x49, 0xFF);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x4A, 0x00);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x7A, 0x0A);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x7B, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x78, 0x21);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x23, 0x34);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x42, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x44, 0xFF);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x45, 0x26);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x46, 0x05);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x40, 0x40);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x0E, 0x06);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x20, 0x1A);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x43, 0x40);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x34, 0x03);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x35, 0x44);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x31, 0x04);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x4B, 0x09);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x4C, 0x05);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x4D, 0x04);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x44, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x45, 0x20);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x47, 0x08);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x48, 0x28);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x67, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x70, 0x04);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x71, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x72, 0xFE);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x76, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x77, 0x00);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x0D, 0x01);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x80, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x01, 0xF8);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x8E, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x00, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x80, 0x00);
+
+ // -- VL53L0X_load_tuning_settings() end
+
+ // "Set interrupt config to new sample ready"
+ // -- VL53L0X_SetGpioConfig() begin
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSTEM_INTERRUPT_CONFIG_GPIO, 0x04);
+ i2cdevWriteBit(dev->I2Cx, dev->devAddr, VL53L0X_RA_GPIO_HV_MUX_ACTIVE_HIGH, 4, 0); // active low
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSTEM_INTERRUPT_CLEAR, 0x01);
+
+ // -- VL53L0X_SetGpioConfig() end
+
+ dev->measurement_timing_budget_us = vl53l0xGetMeasurementTimingBudget(dev);
+ dev->measurement_timing_budget_ms = (uint16_t)(dev->measurement_timing_budget_us / 1000.0f);
+
+ // "Disable MSRC and TCC by default"
+ // MSRC = Minimum Signal Rate Check
+ // TCC = Target CentreCheck
+ // -- VL53L0X_SetSequenceStepEnable() begin
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSTEM_SEQUENCE_CONFIG, 0xE8);
+
+ // -- VL53L0X_SetSequenceStepEnable() end
+
+ // "Recalculate timing budget"
+ vl53l0xSetMeasurementTimingBudget(dev, dev->measurement_timing_budget_us);
+
+ // VL53L0X_StaticInit() end
+
+ // VL53L0X_PerformRefCalibration() begin (VL53L0X_perform_ref_calibration())
+
+ // -- VL53L0X_perform_vhv_calibration() begin
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSTEM_SEQUENCE_CONFIG, 0x01);
+
+ if (!vl53l0xPerformSingleRefCalibration(dev, 0x40)) {
+ DEBUG_PRINTD("Failed VHV calibration");
+ return false;
+ }
+
+ // -- VL53L0X_perform_vhv_calibration() end
+
+ // -- VL53L0X_perform_phase_calibration() begin
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSTEM_SEQUENCE_CONFIG, 0x02);
+
+ if (!vl53l0xPerformSingleRefCalibration(dev, 0x00)) {
+ DEBUG_PRINTD("Failed phase calibration");
+ return false;
+ }
+
+ // -- VL53L0X_perform_phase_calibration() end
+
+ // "restore the previous Sequence Config"
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSTEM_SEQUENCE_CONFIG, 0xE8);
+
+ // VL53L0X_PerformRefCalibration() end
+
+ return true;
+}
+
+// Set the return signal rate limit check value in units of MCPS (mega counts
+// per second). "This represents the amplitude of the signal reflected from the
+// target and detected by the device"; setting this limit presumably determines
+// the minimum measurement necessary for the sensor to report a valid reading.
+// Setting a lower limit increases the potential range of the sensor but also
+// seems to increase the likelihood of getting an inaccurate reading because of
+// unwanted reflections from objects other than the intended target.
+// Defaults to 0.25 MCPS as initialized by the ST API and this library.
+bool vl53l0xSetSignalRateLimit(VL53L0xDev *dev, float limit_Mcps)
+{
+ if (limit_Mcps < 0 || limit_Mcps > 511.99f) {
+ return false;
+ }
+
+ // Q9.7 fixed point format (9 integer bits, 7 fractional bits)
+ uint16_t fixed_pt = limit_Mcps * (1 << 7);
+ return vl53l0xWriteReg16Bit(dev, VL53L0X_RA_FINAL_RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT, fixed_pt);
+}
+
+// Set the measurement timing budget in microseconds, which is the time allowed
+// for one measurement; the ST API and this library take care of splitting the
+// timing budget among the sub-steps in the ranging sequence. A longer timing
+// budget allows for more accurate measurements. Increasing the budget by a
+// factor of N decreases the range measurement standard deviation by a factor of
+// sqrt(N). Defaults to about 33 milliseconds; the minimum is 20 ms.
+// based on VL53L0X_set_measurement_timing_budget_micro_seconds()
+bool vl53l0xSetMeasurementTimingBudget(VL53L0xDev *dev, uint32_t budget_us)
+{
+ SequenceStepEnables enables;
+ SequenceStepTimeouts timeouts;
+
+ uint16_t const StartOverhead = 1320; // note that this is different than the value in get_
+ uint16_t const EndOverhead = 960;
+ uint16_t const MsrcOverhead = 660;
+ uint16_t const TccOverhead = 590;
+ uint16_t const DssOverhead = 690;
+ uint16_t const PreRangeOverhead = 660;
+ uint16_t const FinalRangeOverhead = 550;
+
+ uint32_t const MinTimingBudget = 20000;
+
+ if (budget_us < MinTimingBudget) {
+ return false;
+ }
+
+ uint32_t used_budget_us = StartOverhead + EndOverhead;
+
+ vl53l0xGetSequenceStepEnables(dev, &enables);
+ vl53l0xGetSequenceStepTimeouts(dev, &enables, &timeouts);
+
+ if (enables.tcc) {
+ used_budget_us += (timeouts.msrc_dss_tcc_us + TccOverhead);
+ }
+
+ if (enables.dss) {
+ used_budget_us += 2 * (timeouts.msrc_dss_tcc_us + DssOverhead);
+ } else if (enables.msrc) {
+ used_budget_us += (timeouts.msrc_dss_tcc_us + MsrcOverhead);
+ }
+
+ if (enables.pre_range) {
+ used_budget_us += (timeouts.pre_range_us + PreRangeOverhead);
+ }
+
+ if (enables.final_range) {
+ used_budget_us += FinalRangeOverhead;
+
+ // "Note that the final range timeout is determined by the timing
+ // budget and the sum of all other timeouts within the sequence.
+ // If there is no room for the final range timeout, then an error
+ // will be set. Otherwise the remaining time will be applied to
+ // the final range."
+
+ if (used_budget_us > budget_us) {
+ // "Requested timeout too big."
+ return false;
+ }
+
+ uint32_t final_range_timeout_us = budget_us - used_budget_us;
+
+ // set_sequence_step_timeout() begin
+ // (SequenceStepId == VL53L0X_SEQUENCESTEP_FINAL_RANGE)
+
+ // "For the final range timeout, the pre-range timeout
+ // must be added. To do this both final and pre-range
+ // timeouts must be expressed in macro periods MClks
+ // because they have different vcsel periods."
+
+ uint16_t final_range_timeout_mclks =
+ vl53l0xTimeoutMicrosecondsToMclks(final_range_timeout_us,
+ timeouts.final_range_vcsel_period_pclks);
+
+ if (enables.pre_range) {
+ final_range_timeout_mclks += timeouts.pre_range_mclks;
+ }
+
+ uint16_t temp = vl53l0xEncodeTimeout(final_range_timeout_mclks);
+ vl53l0xWriteReg16Bit(dev, VL53L0X_RA_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_HI, temp);
+
+ // set_sequence_step_timeout() end
+
+ dev->measurement_timing_budget_us = budget_us; // store for internal reuse
+ dev->measurement_timing_budget_ms = (uint16_t)(dev->measurement_timing_budget_us / 1000.0f);
+ }
+
+ return true;
+}
+
+// Get the measurement timing budget in microseconds
+// based on VL53L0X_get_measurement_timing_budget_micro_seconds()
+// in us
+uint32_t vl53l0xGetMeasurementTimingBudget(VL53L0xDev *dev)
+{
+ SequenceStepEnables enables;
+ SequenceStepTimeouts timeouts;
+
+ uint16_t const StartOverhead = 1910; // note that this is different than the value in set_
+ uint16_t const EndOverhead = 960;
+ uint16_t const MsrcOverhead = 660;
+ uint16_t const TccOverhead = 590;
+ uint16_t const DssOverhead = 690;
+ uint16_t const PreRangeOverhead = 660;
+ uint16_t const FinalRangeOverhead = 550;
+
+ // "Start and end overhead times always present"
+ uint32_t budget_us = StartOverhead + EndOverhead;
+
+ vl53l0xGetSequenceStepEnables(dev, &enables);
+ vl53l0xGetSequenceStepTimeouts(dev, &enables, &timeouts);
+
+ if (enables.tcc) {
+ budget_us += (timeouts.msrc_dss_tcc_us + TccOverhead);
+ }
+
+ if (enables.dss) {
+ budget_us += 2 * (timeouts.msrc_dss_tcc_us + DssOverhead);
+ } else if (enables.msrc) {
+ budget_us += (timeouts.msrc_dss_tcc_us + MsrcOverhead);
+ }
+
+ if (enables.pre_range) {
+ budget_us += (timeouts.pre_range_us + PreRangeOverhead);
+ }
+
+ if (enables.final_range) {
+ budget_us += (timeouts.final_range_us + FinalRangeOverhead);
+ }
+
+ dev->measurement_timing_budget_us = budget_us; // store for internal reuse
+ dev->measurement_timing_budget_ms = (uint16_t)(dev->measurement_timing_budget_us / 1000.0f);
+ return budget_us;
+}
+
+
+// Set the VCSEL (vertical cavity surface emitting laser) pulse period for the
+// given period type (pre-range or final range) to the given value in PCLKs.
+// Longer periods seem to increase the potential range of the sensor.
+// Valid values are (even numbers only):
+// pre: 12 to 18 (initialized default: 14)
+// final: 8 to 14 (initialized default: 10)
+// based on VL53L0X_set_vcsel_pulse_period()
+bool vl53l0xSetVcselPulsePeriod(VL53L0xDev *dev, vcselPeriodType type, uint8_t period_pclks)
+{
+ uint8_t vcsel_period_reg = encodeVcselPeriod(period_pclks);
+
+ SequenceStepEnables enables;
+ SequenceStepTimeouts timeouts;
+
+ vl53l0xGetSequenceStepEnables(dev, &enables);
+ vl53l0xGetSequenceStepTimeouts(dev, &enables, &timeouts);
+
+ // "Apply specific settings for the requested clock period"
+ // "Re-calculate and apply timeouts, in macro periods"
+
+ // "When the VCSEL period for the pre or final range is changed,
+ // the corresponding timeout must be read from the device using
+ // the current VCSEL period, then the new VCSEL period can be
+ // applied. The timeout then must be written back to the device
+ // using the new VCSEL period.
+ //
+ // For the MSRC timeout, the same applies - this timeout being
+ // dependant on the pre-range vcsel period."
+
+
+ if (type == VcselPeriodPreRange) {
+ // "Set phase check limits"
+ switch (period_pclks) {
+ case 12:
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_PRE_RANGE_CONFIG_VALID_PHASE_HIGH, 0x18);
+ break;
+
+ case 14:
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_PRE_RANGE_CONFIG_VALID_PHASE_HIGH, 0x30);
+ break;
+
+ case 16:
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_PRE_RANGE_CONFIG_VALID_PHASE_HIGH, 0x40);
+ break;
+
+ case 18:
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_PRE_RANGE_CONFIG_VALID_PHASE_HIGH, 0x50);
+ break;
+
+ default:
+ // invalid period
+ return false;
+ }
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_PRE_RANGE_CONFIG_VALID_PHASE_LOW, 0x08);
+
+ // apply new VCSEL period
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_PRE_RANGE_CONFIG_VCSEL_PERIOD, vcsel_period_reg);
+
+ // update timeouts
+
+ // set_sequence_step_timeout() begin
+ // (SequenceStepId == VL53L0X_SEQUENCESTEP_PRE_RANGE)
+
+ uint16_t new_pre_range_timeout_mclks =
+ vl53l0xTimeoutMicrosecondsToMclks(timeouts.pre_range_us, period_pclks);
+
+ uint16_t new_pre_range_timeout_encoded = vl53l0xEncodeTimeout(new_pre_range_timeout_mclks);
+ vl53l0xWriteReg16Bit(dev, VL53L0X_RA_PRE_RANGE_CONFIG_TIMEOUT_MACROP_HI, new_pre_range_timeout_encoded);
+
+ // set_sequence_step_timeout() end
+
+ // set_sequence_step_timeout() begin
+ // (SequenceStepId == VL53L0X_SEQUENCESTEP_MSRC)
+
+ uint16_t new_msrc_timeout_mclks =
+ vl53l0xTimeoutMicrosecondsToMclks(timeouts.msrc_dss_tcc_us, period_pclks);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_MSRC_CONFIG_TIMEOUT_MACROP,
+ (new_msrc_timeout_mclks > 256) ? 255 : (new_msrc_timeout_mclks - 1));
+
+ // set_sequence_step_timeout() end
+ } else if (type == VcselPeriodFinalRange) {
+ switch (period_pclks) {
+ case 8:
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_FINAL_RANGE_CONFIG_VALID_PHASE_HIGH, 0x10);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_FINAL_RANGE_CONFIG_VALID_PHASE_LOW, 0x08);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_GLOBAL_CONFIG_VCSEL_WIDTH, 0x02);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_ALGO_PHASECAL_CONFIG_TIMEOUT, 0x0C);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_ALGO_PHASECAL_LIM, 0x30);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+ break;
+
+ case 10:
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_FINAL_RANGE_CONFIG_VALID_PHASE_HIGH, 0x28);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_FINAL_RANGE_CONFIG_VALID_PHASE_LOW, 0x08);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_GLOBAL_CONFIG_VCSEL_WIDTH, 0x03);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_ALGO_PHASECAL_CONFIG_TIMEOUT, 0x09);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_ALGO_PHASECAL_LIM, 0x20);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+ break;
+
+ case 12:
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_FINAL_RANGE_CONFIG_VALID_PHASE_HIGH, 0x38);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_FINAL_RANGE_CONFIG_VALID_PHASE_LOW, 0x08);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_GLOBAL_CONFIG_VCSEL_WIDTH, 0x03);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_ALGO_PHASECAL_CONFIG_TIMEOUT, 0x08);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_ALGO_PHASECAL_LIM, 0x20);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+ break;
+
+ case 14:
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_FINAL_RANGE_CONFIG_VALID_PHASE_HIGH, 0x48);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_FINAL_RANGE_CONFIG_VALID_PHASE_LOW, 0x08);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_GLOBAL_CONFIG_VCSEL_WIDTH, 0x03);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_ALGO_PHASECAL_CONFIG_TIMEOUT, 0x07);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_ALGO_PHASECAL_LIM, 0x20);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+ break;
+
+ default:
+ // invalid period
+ return false;
+ }
+
+ // apply new VCSEL period
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_FINAL_RANGE_CONFIG_VCSEL_PERIOD, vcsel_period_reg);
+
+ // update timeouts
+
+ // set_sequence_step_timeout() begin
+ // (SequenceStepId == VL53L0X_SEQUENCESTEP_FINAL_RANGE)
+
+ // "For the final range timeout, the pre-range timeout
+ // must be added. To do this both final and pre-range
+ // timeouts must be expressed in macro periods MClks
+ // because they have different vcsel periods."
+
+ uint16_t new_final_range_timeout_mclks =
+ vl53l0xTimeoutMicrosecondsToMclks(timeouts.final_range_us, period_pclks);
+
+ if (enables.pre_range) {
+ new_final_range_timeout_mclks += timeouts.pre_range_mclks;
+ }
+
+ uint16_t new_final_range_timeout_encoded = vl53l0xEncodeTimeout(new_final_range_timeout_mclks);
+ vl53l0xWriteReg16Bit(dev, VL53L0X_RA_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_HI, new_final_range_timeout_encoded);
+
+ // set_sequence_step_timeout end
+ } else {
+ // invalid type
+ return false;
+ }
+
+ // "Finally, the timing budget must be re-applied"
+
+ vl53l0xSetMeasurementTimingBudget(dev, dev->measurement_timing_budget_us);
+
+ // "Perform the phase calibration. This is needed after changing on vcsel period."
+ // VL53L0X_perform_phase_calibration() begin
+
+ uint8_t sequence_config = 0;
+ i2cdevReadByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSTEM_SEQUENCE_CONFIG, &sequence_config);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSTEM_SEQUENCE_CONFIG, 0x02);
+ bool ret = vl53l0xPerformSingleRefCalibration(dev, 0x0);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSTEM_SEQUENCE_CONFIG, sequence_config);
+
+ // VL53L0X_perform_phase_calibration() end
+
+ return ret;
+}
+
+// Get the VCSEL pulse period in PCLKs for the given period type.
+// based on VL53L0X_get_vcsel_pulse_period()
+uint8_t vl53l0xGetVcselPulsePeriod(VL53L0xDev *dev, vcselPeriodType type)
+{
+ if (type == VcselPeriodPreRange) {
+ uint8_t temp = 0;
+ i2cdevReadByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_PRE_RANGE_CONFIG_VCSEL_PERIOD, &temp);
+ return decodeVcselPeriod(temp);
+ } else if (type == VcselPeriodFinalRange) {
+ uint8_t temp = 0;
+ i2cdevReadByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_FINAL_RANGE_CONFIG_VCSEL_PERIOD, &temp);
+ return decodeVcselPeriod(temp);
+ } else {
+ return 255;
+ }
+}
+
+// Start continuous ranging measurements. If period_ms (optional) is 0 or not
+// given, continuous back-to-back mode is used (the sensor takes measurements as
+// often as possible); otherwise, continuous timed mode is used, with the given
+// inter-measurement period in milliseconds determining how often the sensor
+// takes a measurement.
+// based on VL53L0X_StartMeasurement()
+void vl53l0xStartContinuous(VL53L0xDev *dev, uint32_t period_ms)
+{
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x80, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x00, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x91, dev->stop_variable);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x00, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x80, 0x00);
+
+ if (period_ms != 0) {
+ // continuous timed mode
+
+ // VL53L0X_SetInterMeasurementPeriodMilliSeconds() begin
+
+ uint16_t osc_calibrate_val = vl53l0xReadReg16Bit(dev, VL53L0X_RA_OSC_CALIBRATE_VAL);
+
+ if (osc_calibrate_val != 0) {
+ period_ms *= osc_calibrate_val;
+ }
+
+ vl53l0xWriteReg32Bit(dev, VL53L0X_RA_SYSTEM_INTERMEASUREMENT_PERIOD, period_ms);
+
+ // VL53L0X_SetInterMeasurementPeriodMilliSeconds() end
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSRANGE_START, 0x04); // VL53L0X_REG_SYSRANGE_MODE_TIMED
+ } else {
+ // continuous back-to-back mode
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSRANGE_START, 0x02); // VL53L0X_REG_SYSRANGE_MODE_BACKTOBACK
+ }
+}
+
+// Stop continuous measurements
+// based on VL53L0X_StopMeasurement()
+void vl53l0xStopContinuous(VL53L0xDev *dev)
+{
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSRANGE_START, 0x01); // VL53L0X_REG_SYSRANGE_MODE_SINGLESHOT
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x00, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x91, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x00, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+}
+
+// Returns a range reading in millimeters when continuous mode is active
+// (readRangeSingleMillimeters() also calls this function after starting a
+// single-shot range measurement)
+uint16_t vl53l0xReadRangeContinuousMillimeters(VL53L0xDev *dev)
+{
+ startTimeout();
+ uint8_t val = 0;
+
+ while ((val & 0x07) == 0) {
+ i2cdevReadByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_RESULT_INTERRUPT_STATUS, &val);
+
+ if ((val & 0x07) == 0) {
+ // Relaxation delay when polling interrupt
+ vTaskDelay(M2T(1));
+ }
+
+ if (checkTimeoutExpired()) {
+ dev->did_timeout = true;
+ return 65535;
+ }
+ }
+
+ // assumptions: Linearity Corrective Gain is 1000 (default);
+ // fractional ranging is not enabled
+ uint16_t range = vl53l0xReadReg16Bit(dev, VL53L0X_RA_RESULT_RANGE_STATUS + 10);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSTEM_INTERRUPT_CLEAR, 0x01);
+
+ return range;
+}
+
+// Performs a single-shot range measurement and returns the reading in
+// millimeters
+// based on VL53L0X_PerformSingleRangingMeasurement()
+uint16_t vl53l0xReadRangeSingleMillimeters(VL53L0xDev *dev)
+{
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x80, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x00, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x91, dev->stop_variable);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x00, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x80, 0x00);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSRANGE_START, 0x01);
+
+ // "Wait until start bit has been cleared"
+ startTimeout();
+ uint8_t val = 0x01;
+
+ while (val & 0x01) {
+ i2cdevReadByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSRANGE_START, &val);
+
+ if (checkTimeoutExpired()) {
+ dev->did_timeout = true;
+ return 65535;
+ }
+ }
+
+ return vl53l0xReadRangeContinuousMillimeters(dev);
+}
+
+// Get reference SPAD (single photon avalanche diode) count and type
+// based on VL53L0X_get_info_from_device(),
+// but only gets reference SPAD count and type
+bool vl53l0xGetSpadInfo(VL53L0xDev *dev, uint8_t *count, bool *type_is_aperture)
+{
+ uint8_t tmp;
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x80, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x00, 0x00);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x06);
+ i2cdevWriteBit(dev->I2Cx, dev->devAddr, 0x83, 2, 0x01);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x07);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x81, 0x01);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x80, 0x01);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x94, 0x6b);
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x83, 0x00);
+ startTimeout();
+
+ uint8_t val = 0x00;
+
+ while (val == 0x00) {
+ i2cdevReadByte(dev->I2Cx, dev->devAddr, 0x83, &val);
+
+ if (checkTimeoutExpired()) {
+ return false;
+ }
+ };
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x83, 0x01);
+
+ i2cdevReadByte(dev->I2Cx, dev->devAddr, 0x92, &tmp);
+
+ *count = tmp & 0x7f;
+
+ *type_is_aperture = (tmp >> 7) & 0x01;
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x81, 0x00);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x06);
+
+ i2cdevWriteBit(dev->I2Cx, dev->devAddr, 0x83, 2, 0);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x01);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x00, 0x01);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0xFF, 0x00);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, 0x80, 0x00);
+
+ return true;
+}
+
+// Get sequence step enables
+// based on VL53L0X_GetSequenceStepEnables()
+void vl53l0xGetSequenceStepEnables(VL53L0xDev *dev, SequenceStepEnables *enables)
+{
+ uint8_t sequence_config = 0;
+ i2cdevReadByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSTEM_SEQUENCE_CONFIG, &sequence_config);
+
+ enables->tcc = (sequence_config >> 4) & 0x1;
+ enables->dss = (sequence_config >> 3) & 0x1;
+ enables->msrc = (sequence_config >> 2) & 0x1;
+ enables->pre_range = (sequence_config >> 6) & 0x1;
+ enables->final_range = (sequence_config >> 7) & 0x1;
+}
+
+// Get sequence step timeouts
+// based on get_sequence_step_timeout(),
+// but gets all timeouts instead of just the requested one, and also stores
+// intermediate values
+void vl53l0xGetSequenceStepTimeouts(VL53L0xDev *dev, SequenceStepEnables const *enables, SequenceStepTimeouts *timeouts)
+{
+ timeouts->pre_range_vcsel_period_pclks = vl53l0xGetVcselPulsePeriod(dev, VcselPeriodPreRange);
+
+ uint8_t temp = 0;
+ i2cdevReadByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_MSRC_CONFIG_TIMEOUT_MACROP, &temp);
+ timeouts->msrc_dss_tcc_mclks = temp + 1;
+ timeouts->msrc_dss_tcc_us =
+ vl53l0xTimeoutMclksToMicroseconds(timeouts->msrc_dss_tcc_mclks,
+ timeouts->pre_range_vcsel_period_pclks);
+
+ uint16_t pre_range_encoded = vl53l0xReadReg16Bit(dev, VL53L0X_RA_PRE_RANGE_CONFIG_TIMEOUT_MACROP_HI);
+ timeouts->pre_range_mclks = vl53l0xDecodeTimeout(pre_range_encoded);
+ timeouts->pre_range_us =
+ vl53l0xTimeoutMclksToMicroseconds(timeouts->pre_range_mclks,
+ timeouts->pre_range_vcsel_period_pclks);
+
+ timeouts->final_range_vcsel_period_pclks = vl53l0xGetVcselPulsePeriod(dev, VcselPeriodFinalRange);
+
+ uint16_t final_range_encoded = vl53l0xReadReg16Bit(dev, VL53L0X_RA_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_HI);
+ timeouts->final_range_mclks = vl53l0xDecodeTimeout(final_range_encoded);
+
+ if (enables->pre_range) {
+ timeouts->final_range_mclks -= timeouts->pre_range_mclks;
+ }
+
+ timeouts->final_range_us =
+ vl53l0xTimeoutMclksToMicroseconds(timeouts->final_range_mclks,
+ timeouts->final_range_vcsel_period_pclks);
+}
+
+// Decode sequence step timeout in MCLKs from register value
+// based on VL53L0X_decode_timeout()
+// Note: the original function returned a uint32_t, but the return value is
+// always stored in a uint16_t.
+uint16_t vl53l0xDecodeTimeout(uint16_t reg_val)
+{
+ // format: "(LSByte * 2^MSByte) + 1"
+ return (uint16_t)((reg_val & 0x00FF) <<
+ (uint16_t)((reg_val & 0xFF00) >> 8)) + 1;
+}
+
+// Encode sequence step timeout register value from timeout in MCLKs
+// based on VL53L0X_encode_timeout()
+// Note: the original function took a uint16_t, but the argument passed to it
+// is always a uint16_t.
+uint16_t vl53l0xEncodeTimeout(uint16_t timeout_mclks)
+{
+ // format: "(LSByte * 2^MSByte) + 1"
+
+ uint32_t ls_byte = 0;
+ uint16_t ms_byte = 0;
+
+ if (timeout_mclks > 0) {
+ ls_byte = timeout_mclks - 1;
+
+ while ((ls_byte & 0xFFFFFF00LU) > 0) {
+ ls_byte >>= 1;
+ ms_byte++;
+ }
+
+ return (ms_byte << 8) | (ls_byte & 0xFF);
+ } else {
+ return 0;
+ }
+}
+
+// Convert sequence step timeout from MCLKs to microseconds with given VCSEL period in PCLKs
+// based on VL53L0X_calc_timeout_us()
+uint32_t vl53l0xTimeoutMclksToMicroseconds(uint16_t timeout_period_mclks, uint8_t vcsel_period_pclks)
+{
+ uint32_t macro_period_ns = calcMacroPeriod(vcsel_period_pclks);
+
+ return ((timeout_period_mclks * macro_period_ns) + (macro_period_ns / 2)) / 1000;
+}
+
+// Convert sequence step timeout from microseconds to MCLKs with given VCSEL period in PCLKs
+// based on VL53L0X_calc_timeout_mclks()
+uint32_t vl53l0xTimeoutMicrosecondsToMclks(uint32_t timeout_period_us, uint8_t vcsel_period_pclks)
+{
+ uint32_t macro_period_ns = calcMacroPeriod(vcsel_period_pclks);
+
+ return (((timeout_period_us * 1000) + (macro_period_ns / 2)) / macro_period_ns);
+}
+
+// based on VL53L0X_perform_single_ref_calibration()
+bool vl53l0xPerformSingleRefCalibration(VL53L0xDev *dev, uint8_t vhv_init_byte)
+{
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSRANGE_START, 0x01 | vhv_init_byte); // VL53L0X_REG_SYSRANGE_MODE_START_STOP
+
+ startTimeout();
+ uint8_t temp = 0x00;
+
+ while ((temp & 0x07) == 0) {
+ i2cdevReadByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_RESULT_INTERRUPT_STATUS, &temp);
+
+ if (checkTimeoutExpired()) {
+ return false;
+ }
+ }
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSTEM_INTERRUPT_CLEAR, 0x01);
+
+ i2cdevWriteByte(dev->I2Cx, dev->devAddr, VL53L0X_RA_SYSRANGE_START, 0x00);
+
+ return true;
+}
+
+uint16_t vl53l0xReadReg16Bit(VL53L0xDev *dev, uint8_t reg)
+{
+ uint8_t buffer[2] = {};
+ i2cdevReadReg8(dev->I2Cx, dev->devAddr, reg, 2, (uint8_t *)&buffer);
+ return ((uint16_t)(buffer[0]) << 8) | buffer[1];
+}
+
+bool vl53l0xWriteReg16Bit(VL53L0xDev *dev, uint8_t reg, uint16_t val)
+{
+ uint8_t buffer[2] = {};
+ buffer[0] = ((val >> 8) & 0xFF);
+ buffer[1] = ((val) & 0xFF);
+ return i2cdevWriteReg8(dev->I2Cx, dev->devAddr, reg, 2, (uint8_t *)&buffer);
+}
+
+bool vl53l0xWriteReg32Bit(VL53L0xDev *dev, uint8_t reg, uint32_t val)
+{
+ uint8_t buffer[4] = {};
+ buffer[0] = ((val >> 24) & 0xFF);
+ buffer[1] = ((val >> 16) & 0xFF);
+ buffer[2] = ((val >> 8) & 0xFF);
+ buffer[3] = ((val) & 0xFF);
+ return i2cdevWriteReg8(dev->I2Cx, dev->devAddr, reg, 4, (uint8_t *)&buffer);
+}
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l0/zranger.c b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l0/zranger.c
new file mode 100644
index 0000000..150c5d3
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l0/zranger.c
@@ -0,0 +1,225 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2012 BitCraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * vl53l0x.c: Time-of-flight distance sensor driver
+ */
+
+#define DEBUG_MODULE "VLX"
+
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+
+//#include "deck.h"
+#include "system.h"
+#include "debug_cf.h"
+#include "log.h"
+#include "param.h"
+#include "range.h"
+#include "config.h"
+#include "i2cdev.h"
+#include "zranger.h"
+#include "vl53l0x.h"
+#include "stabilizer_types.h"
+#include "estimator.h"
+#include "cf_math.h"
+
+// Measurement noise model
+static const float expPointA = 1.0f;
+static const float expStdA = 0.0025f; // STD at elevation expPointA [m]
+static const float expPointB = 1.3f;
+static const float expStdB = 0.2f; // STD at elevation expPointB [m]
+static float expCoeff;
+
+#define RANGE_OUTLIER_LIMIT 3000 // the measured range is in [mm]
+
+static uint16_t range_last = 0;
+
+static bool isInit;
+
+static VL53L0xDev dev;
+
+static uint8_t vl53l0dataReady = 0;
+
+static int16_t range1;
+static int16_t dataready = 0;
+
+int16_t zRangerMeasurementAndRestart()
+{
+ if (isInit == false)
+ {
+ return -1;
+ }
+ uint8_t val = 0;
+ i2cdevReadByte(dev.I2Cx, dev.devAddr, VL53L0X_RA_RESULT_INTERRUPT_STATUS, &val);
+
+ if ((val & 0x07) == 0)
+ {
+ vl53l0dataReady = 0;
+
+ }else
+ {
+ vl53l0dataReady = 1;
+ }
+
+
+ if (vl53l0dataReady != 0)
+ {
+
+ // assumptions: Linearity Corrective Gain is 1000 (default);
+ // fractional ranging is not enabled
+ uint16_t rangetemp = vl53l0xReadReg16Bit(&dev, VL53L0X_RA_RESULT_RANGE_STATUS + 10);
+
+ if (rangetemp != 0)
+ {
+ range1 = rangetemp;
+ dataready = 1;
+ }
+ else
+ {
+ return -2;
+ }
+
+ i2cdevWriteByte(dev.I2Cx, dev.devAddr, VL53L0X_RA_SYSTEM_INTERRUPT_CLEAR, 0x01);; //clear Interrupt start next measurement
+ }
+ else
+ {
+ return -3;
+ }
+ return 0;
+}
+
+static int16_t zRangerGetMeasurementAndRestart(VL53L0xDev *dev)
+{
+
+ int16_t range;
+ while (dataready == 0)
+ {
+ vTaskDelay(M2T(20));
+ }
+ dataready = 0;
+ return range = range1;
+}
+
+void zRangerInit(void)
+{
+ if (isInit)
+ return;
+
+ dev.I2Cx = 0;
+ dev.devAddr = VL53L0X_DEFAULT_ADDRESS;
+ i2cdevInit(dev.I2Cx);
+
+ dev.io_timeout = 0;
+ dev.did_timeout = 0;
+ dev.timeout_start_ms = 0;
+ dev.stop_variable = 0;
+ dev.measurement_timing_budget_us = 0;
+ dev.measurement_timing_budget_ms = 0;
+
+ vTaskDelay(M2T(20));
+
+ uint16_t wordData;
+ wordData = vl53l0xGetModelID(&dev);
+ DEBUG_PRINTI( "VL53L0X: %02X\n\r", wordData);
+
+ if(wordData == VL53L0X_ID)
+ {
+ DEBUG_PRINT( "VL53L0X I2C commection [OK].\n");
+ }
+
+ vl53l0xInit(&dev, I2C1_DEV, true);
+
+ xTaskCreate(zRangerTask, ZRANGER_TASK_NAME, ZRANGER_TASK_STACKSIZE, NULL, ZRANGER_TASK_PRI, NULL);
+
+ // pre-compute constant in the measurement noise model for kalman
+ expCoeff = logf(expStdB / expStdA) / (expPointB - expPointA);
+
+ isInit = true;
+}
+
+bool zRangerTest(void)
+{
+ bool testStatus;
+
+ if (!isInit)
+ return false;
+
+ testStatus = vl53l0xTestConnection(&dev);
+
+ return testStatus;
+}
+
+void zRangerTask(void* arg)
+{
+ systemWaitStart();
+ TickType_t xLastWakeTime;
+
+ vl53l0xSetVcselPulsePeriod(&dev, VcselPeriodPreRange, 18);/*长距离模式 33ms 周期*/
+ vl53l0xSetVcselPulsePeriod(&dev, VcselPeriodFinalRange, 14);/*长距离模式 33ms 周期*/
+ vl53l0xStartContinuous(&dev, 0);
+
+ xLastWakeTime = xTaskGetTickCount();
+
+ while (1) {
+ vTaskDelayUntil(&xLastWakeTime, M2T(dev.measurement_timing_budget_ms));
+
+ range_last = zRangerGetMeasurementAndRestart(&dev);
+ rangeSet(rangeDown, range_last / 1000.0f);
+ DEBUG_PRINTD("ZRANGE = %f",range_last/ 1000.0f);
+
+ // check if range is feasible and push into the estimator
+ // the sensor should not be able to measure >3 [m], and outliers typically
+ // occur as >8 [m] measurements
+ if (range_last < RANGE_OUTLIER_LIMIT) {
+ float distance = (float)range_last * 0.001f; // Scale from [mm] to [m]
+ float stdDev = expStdA * (1.0f + expf( expCoeff * (distance - expPointA)));
+ rangeEnqueueDownRangeInEstimator(distance, stdDev, xTaskGetTickCount());
+ }
+ }
+}
+
+bool zRangerReadRange(zDistance_t* zrange, const uint32_t tick)
+{
+ bool updated = false;
+
+ if (isInit) {
+ if (range_last != 0 && range_last < RANGE_OUTLIER_LIMIT) {
+ zrange->distance = (float)range_last * 0.001f; // Scale from [mm] to [m]
+ zrange->timestamp = tick;
+ updated = true;
+ }
+ }
+ return updated;
+}
+
+// static const DeckDriver zranger_deck = {
+// .vid = 0xBC,
+// .pid = 0x09,
+// .name = "bcZRanger",
+// .usedGpio = 0x0C,
+
+// .init = zRangerInit,
+// .test = zRangerTest,
+// };
+
+// DECK_DRIVER(zranger_deck);
+
+PARAM_GROUP_START(deck)
+PARAM_ADD(PARAM_UINT8 | PARAM_RONLY, bcZRanger, &isInit)
+PARAM_GROUP_STOP(deck)
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/CMakeLists.txt b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/CMakeLists.txt
new file mode 100644
index 0000000..dcfc3fd
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/CMakeLists.txt
@@ -0,0 +1,16 @@
+idf_component_register(SRCS "vl53l1x.c"
+ "zranger2.c"
+ "core/src/vl53l1_api_calibration.c"
+ "core/src/vl53l1_api_core.c"
+ "core/src/vl53l1_api_debug.c"
+ "core/src/vl53l1_api_preset_modes.c"
+ "core/src/vl53l1_api_strings.c"
+ "core/src/vl53l1_api.c"
+ "core/src/vl53l1_core_support.c"
+ "core/src/vl53l1_core.c"
+ "core/src/vl53l1_error_strings.c"
+ "core/src/vl53l1_register_funcs.c"
+ "core/src/vl53l1_silicon_core.c"
+ "core/src/vl53l1_wait.c"
+ INCLUDE_DIRS "." "include" "core/inc"
+ REQUIRES i2c_bus crazyflie platform config)
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api.h
new file mode 100644
index 0000000..6065f4c
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api.h
@@ -0,0 +1,1171 @@
+
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+#ifndef _VL53L1_API_H_
+#define _VL53L1_API_H_
+
+#include "vl53l1_api_strings.h"
+#include "vl53l1_api_core.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#if !defined(VL53L1DevDataGet)
+#warning "Usage of PALDevDataGet is deprecated define VL53L1DevDataGet instead\
+ in your vl53l1_platform_user_data.h file"
+#define VL53L1DevDataGet(Dev, field) (Dev->Data.field)
+#endif
+
+#if !defined(VL53L1DevDataSet)
+#warning "Usage of PALDevDataSet is deprecated define VL53L1DevDataSet instead\
+ in your vl53l1_platform_user_data.h file"
+#define VL53L1DevDataSet(Dev, field, data) ((Dev->Data.field) = (data))
+#endif
+
+/** @defgroup VL53L1_cut11_group VL53L1 cut1.1 Function Definition
+ * @brief VL53L1 cut1.1 Function Definition
+ * @{
+ */
+
+/** @defgroup VL53L1_general_group VL53L1 General Functions
+ * @brief General functions and definitions
+ * @{
+ */
+
+/**
+ * @brief Return the VL53L1 driver Version
+ *
+ * @note This function doesn't access to the device
+ *
+ * @param pVersion Rer to current driver Version
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetVersion(VL53L1_Version_t *pVersion);
+
+/**
+ * @brief Reads the Product Revision for a for given Device
+ * This function can be used to distinguish cut1.0 from cut1.1.
+ *
+ * @param Dev Device Handle
+ * @param pProductRevisionMajor Pointer to Product Revision Major
+ * for a given Device
+ * @param pProductRevisionMinor Pointer to Product Revision Minor
+ * for a given Device
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetProductRevision(VL53L1_DEV Dev,
+ uint8_t *pProductRevisionMajor, uint8_t *pProductRevisionMinor);
+
+/**
+ * @brief Reads the Device information for given Device
+ *
+ * @note This function Access to the device
+ *
+ * @param Dev Device Handle
+ * @param pVL53L1_DeviceInfo Pointer to current device info for a given
+ * Device
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetDeviceInfo(VL53L1_DEV Dev,
+ VL53L1_DeviceInfo_t *pVL53L1_DeviceInfo);
+
+/**
+ * @brief Human readable Range Status string for a given RangeStatus
+ *
+ * @note This function doesn't access to the device
+ *
+ * @param RangeStatus The RangeStatus code as stored on
+ * @a VL53L1_RangingMeasurementData_t
+ * @param pRangeStatusString The returned RangeStatus string. Shall be
+ * defined as char buf[VL53L1_MAX_STRING_LENGTH]
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetRangeStatusString(uint8_t RangeStatus,
+ char *pRangeStatusString);
+
+/**
+ * @brief Human readable error string for driver error status
+ *
+ * @note This function doesn't access to the device
+ *
+ * @param PalErrorCode The error code as stored on @a VL53L1_Error
+ * @param pPalErrorString The error string corresponding to the
+ * PalErrorCode. Shall be defined as char buf[VL53L1_MAX_STRING_LENGTH]
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetPalErrorString(VL53L1_Error PalErrorCode,
+ char *pPalErrorString);
+
+/**
+ * @brief Human readable driver State string
+ *
+ * @note This function doesn't access to the device
+ *
+ * @param PalStateCode The State code as stored on @a VL53L1_State
+ * @param pPalStateString The State string corresponding to the
+ * PalStateCode. Shall be defined as char buf[VL53L1_MAX_STRING_LENGTH]
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetPalStateString(VL53L1_State PalStateCode,
+ char *pPalStateString);
+
+/**
+ * @brief Reads the internal state of the driver for a given Device
+ *
+ * @note This function doesn't access to the device
+ *
+ * @param Dev Device Handle
+ * @param pPalState Pointer to current state of the PAL for a
+ * given Device
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetPalState(VL53L1_DEV Dev,
+ VL53L1_State *pPalState);
+
+
+
+/** @} VL53L1_general_group */
+
+/** @defgroup VL53L1_init_group VL53L1 Init Functions
+ * @brief VL53L1 Init Functions
+ * @{
+ */
+
+/**
+ * @brief Set new device address
+ *
+ * After completion the device will answer to the new address programmed.
+ * This function should be called when several devices are used in parallel
+ * before start programming the sensor.
+ * When a single device us used, there is no need to call this function.
+ *
+ * When it is requested for multi devices system this function MUST be called
+ * prior to VL53L1_DataInit()
+ *
+ * @note This function Access to the device
+ *
+ * @param Dev Device Handle
+ * @param DeviceAddress The new Device address
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_SetDeviceAddress(VL53L1_DEV Dev,
+ uint8_t DeviceAddress);
+
+/**
+ *
+ * @brief One time device initialization
+ *
+ * To be called once and only once after device is brought out of reset
+ * (Chip enable) and booted see @a VL53L1_WaitDeviceBooted()
+ *
+ * @par Function Description
+ * When not used after a fresh device "power up" or reset, it may return
+ * @a #VL53L1_ERROR_CALIBRATION_WARNING meaning wrong calibration data
+ * may have been fetched from device that can result in ranging offset error\n
+ * If application cannot execute device reset or need to run VL53L1_DataInit
+ * multiple time then it must ensure proper offset calibration saving and
+ * restore on its own by using @a VL53L1_GetOffsetCalibrationData() on first
+ * power up and then @a VL53L1_SetOffsetCalibrationData() in all subsequent init
+ * This function will change the VL53L1_State from VL53L1_STATE_POWERDOWN to
+ * VL53L1_STATE_WAIT_STATICINIT.
+ *
+ * @note This function Access to the device
+ *
+ * @param Dev Device Handle
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_DataInit(VL53L1_DEV Dev);
+
+
+/**
+ * @brief Do basic device init (and eventually patch loading)
+ * This function will change the VL53L1_State from
+ * VL53L1_STATE_WAIT_STATICINIT to VL53L1_STATE_IDLE.
+ * In this stage all default setting will be applied.
+ *
+ * @note This function Access to the device
+ *
+ * @param Dev Device Handle
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_StaticInit(VL53L1_DEV Dev);
+
+/**
+ * @brief Wait for device booted after chip enable (hardware standby)
+ * This function can be run only when VL53L1_State is VL53L1_STATE_POWERDOWN.
+ *
+ * @param Dev Device Handle
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ *
+ */
+VL53L1_Error VL53L1_WaitDeviceBooted(VL53L1_DEV Dev);
+
+
+/** @} VL53L1_init_group */
+
+/** @defgroup VL53L1_parameters_group VL53L1 Parameters Functions
+ * @brief Functions used to prepare and setup the device
+ * @{
+ */
+
+/**
+ * @brief Set a new Preset Mode
+ * @par Function Description
+ * Set device to a new Operating Mode (High speed ranging, Multi objects ...)
+ *
+ * @note This function doesn't Access to the device
+ *
+ * @warning This function change the timing budget to 16 ms and the inter-
+ * measurement period to 1000 ms. Also the VL53L1_DISTANCEMODE_LONG is used.
+ *
+ * @param Dev Device Handle
+ * @param PresetMode New Preset mode to apply
+ * <br>Valid values are:
+ */
+/**
+ * @li VL53L1_PRESETMODE_LITE_RANGING
+ * @li VL53L1_PRESETMODE_AUTONOMOUS
+ * @li VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS
+ */
+/**
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return VL53L1_ERROR_MODE_NOT_SUPPORTED This error occurs when PresetMode is
+ * not in the supported list
+ */
+VL53L1_Error VL53L1_SetPresetMode(VL53L1_DEV Dev,
+ VL53L1_PresetModes PresetMode);
+
+/**
+ * @brief Get current Preset Mode
+ * @par Function Description
+ * Get actual mode of the device(ranging, histogram ...)
+ *
+ * @note This function doesn't Access to the device
+ *
+ * @param Dev Device Handle
+ * @param pPresetMode Pointer to current apply mode value
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return VL53L1_ERROR_MODE_NOT_SUPPORTED This error occurs when
+ * DeviceMode is not in the supported list
+ */
+VL53L1_Error VL53L1_GetPresetMode(VL53L1_DEV Dev,
+ VL53L1_PresetModes *pPresetMode);
+
+
+/**
+ * @brief Set the distance mode
+ * @par Function Description
+ * Set the distance mode to be used for the next ranging.<br>
+ * The modes Short, Medium and Long are used to optimize the ranging accuracy
+ * in a specific range of distance.<br> The user select one of these modes to
+ * select the distance range.
+ * @note This function doesn't Access to the device
+ *
+ * @warning This function should be called after @a VL53L1_SetPresetMode().
+
+ * @param Dev Device Handle
+ * @param DistanceMode Distance mode to apply, valid values are:
+ * @li VL53L1_DISTANCEMODE_SHORT
+ * @li VL53L1_DISTANCEMODE_MEDIUM
+ * @li VL53L1_DISTANCEMODE_LONG
+ * @return VL53L1_ERROR_NONE Success
+ * @return VL53L1_ERROR_MODE_NOT_SUPPORTED This error occurs when DistanceMode
+ * is not in the supported list
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_SetDistanceMode(VL53L1_DEV Dev,
+ VL53L1_DistanceModes DistanceMode);
+
+/**
+ * @brief Get the distance mode
+ * @par Function Description
+ * Get the distance mode used for the next ranging.
+ *
+ * @param Dev Device Handle
+ * @param *pDistanceMode Pointer to Distance mode
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetDistanceMode(VL53L1_DEV Dev,
+ VL53L1_DistanceModes *pDistanceMode);
+
+
+
+
+/**
+ * @brief Set Ranging Timing Budget in microseconds
+ *
+ * @par Function Description
+ * Defines the maximum time allowed by the user to the device to run a
+ * full ranging sequence for the current mode (ranging, histogram, ASL ...)
+ *
+ * @param Dev Device Handle
+ * @param MeasurementTimingBudgetMicroSeconds Max measurement time in
+ * microseconds.
+ * @return VL53L1_ERROR_NONE Success
+ * @return VL53L1_ERROR_INVALID_PARAMS Error timing parameter not
+ * supported.
+ * The maximum accepted value for the
+ * computed timing budget is 10 seconds
+ * the minimum value depends on the preset
+ * mode selected.
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_SetMeasurementTimingBudgetMicroSeconds(
+ VL53L1_DEV Dev, uint32_t MeasurementTimingBudgetMicroSeconds);
+
+/**
+ * @brief Get Ranging Timing Budget in microseconds
+ *
+ * @par Function Description
+ * Returns the programmed the maximum time allowed by the user to the
+ * device to run a full ranging sequence for the current mode
+ * (ranging, histogram, ASL ...)
+ *
+ * @param Dev Device Handle
+ * @param pMeasurementTimingBudgetMicroSeconds Max measurement time in
+ * microseconds.
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetMeasurementTimingBudgetMicroSeconds(
+ VL53L1_DEV Dev, uint32_t *pMeasurementTimingBudgetMicroSeconds);
+
+
+/**
+ * Program continuous mode Inter-Measurement period in milliseconds
+ *
+ * @par Function Description
+ * When trying to set too short time return INVALID_PARAMS minimal value
+ *
+ * @param Dev Device Handle
+ * @param InterMeasurementPeriodMilliSeconds Inter-Measurement Period in ms.
+ * this value should be greater than the duration set in
+ * @a VL53L1_SetMeasurementTimingBudgetMicroSeconds() to ensure smooth ranging
+ * operation.
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_SetInterMeasurementPeriodMilliSeconds(
+ VL53L1_DEV Dev, uint32_t InterMeasurementPeriodMilliSeconds);
+
+/**
+ * Get continuous mode Inter-Measurement period in milliseconds
+ *
+ * @par Function Description
+ *
+ * @param Dev Device Handle
+ * @param pInterMeasurementPeriodMilliSeconds Pointer to programmed
+ * Inter-Measurement Period in milliseconds.
+ * @return VL53L1_ERROR_NONE
+ */
+VL53L1_Error VL53L1_GetInterMeasurementPeriodMilliSeconds(
+ VL53L1_DEV Dev, uint32_t *pInterMeasurementPeriodMilliSeconds);
+
+
+/** @} VL53L1_parameters_group */
+
+
+/** @defgroup VL53L1_limitcheck_group VL53L1 Limit Check Functions
+ * @brief Functions used for the Limit checks
+ * @{
+ */
+
+
+
+/**
+ * @brief Get the number of the check limit managed by a given Device
+ *
+ * @par Function Description
+ * This function give the number of the check limit managed by the Device
+ *
+ * @param pNumberOfLimitCheck Pointer to the number of check limit.
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetNumberOfLimitCheck(
+ uint16_t *pNumberOfLimitCheck);
+
+/**
+ * @brief Return a description string for a given limit check number
+ *
+ * @par Function Description
+ * This function returns a description string for a given limit check number.
+ * The limit check is identified with the LimitCheckId.
+ *
+ * @param LimitCheckId Limit Check ID
+ (0<= LimitCheckId < VL53L1_GetNumberOfLimitCheck() ).
+ * @param pLimitCheckString Pointer to the description string of
+ * the given check limit. Shall be defined as char buf[VL53L1_MAX_STRING_LENGTH]
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetLimitCheckInfo(uint16_t LimitCheckId,
+ char *pLimitCheckString);
+
+/**
+ * @brief Return a the Status of the specified check limit
+ *
+ * @par Function Description
+ * This function returns the Status of the specified check limit.
+ * The value indicate if the check is fail or not.
+ * The limit check is identified with the LimitCheckId.
+ *
+ * @param Dev Device Handle
+ * @param LimitCheckId Limit Check ID
+ (0<= LimitCheckId < VL53L1_GetNumberOfLimitCheck() ).
+ * @param pLimitCheckStatus Pointer to the
+ Limit Check Status of the given check limit.
+ * LimitCheckStatus :
+ * 0 the check is not fail or not enabled
+ * 1 the check if fail
+ *
+ * <p><ul>
+ * <li>VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE: the sigma indicate the quality
+ * of the measure. The more it is little the better it is.
+ * The status is 1 when current sigma is greater then the limit.</li>
+ * <li>VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE: the signal rate indicate
+ * the strength of the returned signal. The more it is big the better it is.
+ * The status is 1 when current signal is lower then the limit.</li>
+ * </ul></p>
+ *
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetLimitCheckStatus(VL53L1_DEV Dev,
+ uint16_t LimitCheckId, uint8_t *pLimitCheckStatus);
+
+/**
+ * @brief Enable/Disable a specific limit check
+ *
+ * @par Function Description
+ * This function Enable/Disable a specific limit check.
+ * The limit check is identified with the LimitCheckId.
+ *
+ * @note This function doesn't Access to the device
+ *
+ * @param Dev Device Handle
+ * @param LimitCheckId Limit Check ID
+ * (0<= LimitCheckId < VL53L1_GetNumberOfLimitCheck() ).
+ * @param LimitCheckEnable
+ * @li set LimitCheckEnable=1 enables the LimitCheckId limit
+ * @li set LimitCheckEnable=0 disables the LimitCheckId limit
+ * @return VL53L1_ERROR_NONE Success
+ * @return VL53L1_ERROR_INVALID_PARAMS This error is returned
+ * when LimitCheckId value is out of range.
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_SetLimitCheckEnable(VL53L1_DEV Dev,
+ uint16_t LimitCheckId, uint8_t LimitCheckEnable);
+
+/**
+ * @brief Get specific limit check enable state
+ *
+ * @par Function Description
+ * This function get the enable state of a specific limit check.
+ * The limit check is identified with the LimitCheckId.
+ *
+ * @note This function Access to the device
+ *
+ * @param Dev Device Handle
+ * @param LimitCheckId Limit Check ID
+ * (0<= LimitCheckId < VL53L1_GetNumberOfLimitCheck() ).
+ * @param pLimitCheckEnable Pointer to the check limit enable
+ * value.
+ * @li if 1 the check limit corresponding to LimitCheckId is Enabled
+ * @li if 0 the check limit corresponding to LimitCheckId is disabled
+ * @return VL53L1_ERROR_NONE Success
+ * @return VL53L1_ERROR_INVALID_PARAMS This error is returned
+ * when LimitCheckId value is out of range.
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetLimitCheckEnable(VL53L1_DEV Dev,
+ uint16_t LimitCheckId, uint8_t *pLimitCheckEnable);
+
+/**
+ * @brief Set a specific limit check value
+ *
+ * @par Function Description
+ * This function set a specific limit check value.
+ * The limit check is identified with the LimitCheckId.
+ *
+ * @note Note that the value written with that function will not be applied if
+ * the limit is not enabled. In other words this function will not enable the
+ * limit but change only the value. In case the limit is not enabled the value
+ * is saved internally and applied with VL53L1_SetLimitCheckEnable.
+ *
+ * @param Dev Device Handle
+ * @param LimitCheckId Limit Check ID
+ * (0<= LimitCheckId < VL53L1_GetNumberOfLimitCheck() ).
+ * @param LimitCheckValue Limit check Value for a given
+ * LimitCheckId
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_SetLimitCheckValue(VL53L1_DEV Dev,
+ uint16_t LimitCheckId, FixPoint1616_t LimitCheckValue);
+
+/**
+ * @brief Get a specific limit check value
+ *
+ * @par Function Description
+ * This function get a specific limit check value from device then it updates
+ * internal values and check enables.
+ * The limit check is identified with the LimitCheckId.
+ *
+ * @note This function get the current value from device if zero then the value
+ * returned is the one stored by the user, but in that case the check is store
+ * as disabled. If the value from device is not zero, this is returned and set
+ * into the memory at the same way that user call VL53L1_SetLimitCheckValue()
+ *
+ * @param Dev Device Handle
+ * @param LimitCheckId Limit Check ID
+ * (0<= LimitCheckId < VL53L1_GetNumberOfLimitCheck() ).
+ * @param pLimitCheckValue Pointer to Limit
+ * check Value for a given LimitCheckId.
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetLimitCheckValue(VL53L1_DEV Dev,
+ uint16_t LimitCheckId, FixPoint1616_t *pLimitCheckValue);
+
+/**
+ * @brief Get the current value of the signal used for the limit check
+ *
+ * @par Function Description
+ * This function get a the current value of the signal used for the limit check.
+ * To obtain the latest value you should run a valid ranging before.
+ * The value reported is linked to the limit check identified with the
+ * LimitCheckId.
+ *
+ * @param Dev Device Handle
+ * @param LimitCheckId Limit Check ID
+ * (0<= LimitCheckId < VL53L1_GetNumberOfLimitCheck() ).
+ * @param pLimitCheckCurrent Pointer to current Value for a
+ * given LimitCheckId.
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetLimitCheckCurrent(VL53L1_DEV Dev,
+ uint16_t LimitCheckId, FixPoint1616_t *pLimitCheckCurrent);
+
+/** @} VL53L1_limitcheck_group */
+
+
+
+/** @defgroup VL53L1_ROI_group VL53L1 ROI Functions
+ * @brief Functions used to select ROIs
+ * @{
+ */
+
+/**
+ * @brief Set the ROI to be used for ranging
+ *
+ * @par Function Description
+ * The user defined ROI is a rectangle described as per the following system
+ * from the Top Left corner to the Bottom Right corner.
+ * <br>Minimal ROI size is 4x4 spads
+ * @image html roi_coord.png
+ *
+ * @param Dev Device Handle
+ * @param pUserROi Pointer to the Structure definining the ROI
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_SetUserROI(VL53L1_DEV Dev,
+ VL53L1_UserRoi_t *pUserROi);
+
+/**
+ * @brief Get the ROI managed by the Device
+ *
+ * @par Function Description
+ * Get the ROI managed by the Device
+ *
+ * @param Dev Device Handle
+ * @param pUserROi Pointer to the Structure definining the ROI
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetUserROI(VL53L1_DEV Dev,
+ VL53L1_UserRoi_t *pUserROi);
+
+/** @} VL53L1_ROI_group */
+
+/* \internal */
+/** @defgroup VL53L1_sequencestep_group VL53L1 Sequence Step Functions
+ * @brief Functions used to select Steps done on each ranging
+ * @{
+ */
+
+/**
+ * @brief Gets number of sequence steps managed by the API.
+ *
+ * @par Function Description
+ * This function retrieves the number of sequence steps currently managed
+ * by the API
+ *
+ * @note This function Accesses the device
+ *
+ * @param Dev Device Handle
+ * @param pNumberOfSequenceSteps Out parameter reporting the number of
+ * sequence steps.
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetNumberOfSequenceSteps(VL53L1_DEV Dev,
+ uint8_t *pNumberOfSequenceSteps);
+
+/**
+ * @brief Gets the name of a given sequence step.
+ *
+ * @par Function Description
+ * This function retrieves the name of sequence steps corresponding to
+ * SequenceStepId.
+ *
+ * @note This function doesn't Accesses the device
+ *
+ * @param SequenceStepId Sequence step identifier.
+ * @param pSequenceStepsString Pointer to Info string. Shall be
+ * defined as char buf[VL53L1_MAX_STRING_LENGTH]
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetSequenceStepsInfo(
+ VL53L1_SequenceStepId SequenceStepId, char *pSequenceStepsString);
+
+
+
+/**
+ * @brief Sets the (on/off) state of a requested sequence step.
+ *
+ * @par Function Description
+ * This function enables/disables a requested sequence step.
+ *
+ * @note This function Accesses the device
+ *
+ * @param Dev Device Handle
+ * @param SequenceStepId Sequence step identifier.
+ * @param SequenceStepEnabled Demanded state {0=Off,1=On}
+ * is enabled.
+ * @return VL53L1_ERROR_NONE Success
+ * @return VL53L1_ERROR_INVALID_PARAMS Error SequenceStepId parameter not
+ * supported.
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_SetSequenceStepEnable(VL53L1_DEV Dev,
+ VL53L1_SequenceStepId SequenceStepId, uint8_t SequenceStepEnabled);
+
+/**
+ * @brief Gets the (on/off) state of a requested sequence step.
+ *
+ * @par Function Description
+ * This function retrieves the state of a requested sequence step, i.e. on/off.
+ *
+ * @note This function Accesses the device
+ *
+ * @param Dev Device Handle
+ * @param SequenceStepId Sequence step identifier.
+ * @param pSequenceStepEnabled Out parameter reporting if the sequence step
+ * is enabled {0=Off,1=On}.
+ * @return VL53L1_ERROR_NONE Success
+ * @return VL53L1_ERROR_INVALID_PARAMS Error SequenceStepId parameter not
+ * supported.
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetSequenceStepEnable(VL53L1_DEV Dev,
+ VL53L1_SequenceStepId SequenceStepId, uint8_t *pSequenceStepEnabled);
+
+
+/** @} VL53L1_sequencestep_group */
+/* \endinternal */
+
+
+
+/** @defgroup VL53L1_measurement_group VL53L1 Measurement Functions
+ * @brief Functions used for the measurements
+ * @{
+ */
+
+/**
+ * @brief Start device measurement
+ *
+ * @details Started measurement will depend on preset parameters set through
+ * @a VL53L1_SetPreseMode()
+ * This function will change the VL53L1_State from VL53L1_STATE_IDLE to
+ * VL53L1_STATE_RUNNING.
+ *
+ * @note This function Access to the device
+ *
+ * @param Dev Device Handle
+ * @return VL53L1_ERROR_NONE Success
+ * @return VL53L1_ERROR_MODE_NOT_SUPPORTED This error occurs when
+ * PresetMode programmed with @a VL53L1_SetPresetMode
+ * @return VL53L1_ERROR_TIME_OUT Time out on start measurement
+ * @return VL53L1_ERROR_INVALID_PARAMS This error might occur in timed mode
+ * when inter measurement period is smaller or too close to the timing budget.
+ * In such case measurements are not started and user must correct the timings
+ * passed to @a VL53L1_SetMeasurementTimingBudgetMicroSeconds() and
+ * @a VL53L1_SetInterMeasurementPeriodMilliSeconds() functions.
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_StartMeasurement(VL53L1_DEV Dev);
+
+/**
+ * @brief Stop device measurement
+ *
+ * @details Will set the device in standby mode at end of current measurement\n
+ * Not necessary in single mode as device shall return automatically
+ * in standby mode at end of measurement.
+ * This function will change the VL53L1_State from VL53L1_STATE_RUNNING
+ * to VL53L1_STATE_IDLE.
+ *
+ * @note This function Access to the device
+ *
+ * @param Dev Device Handle
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_StopMeasurement(VL53L1_DEV Dev);
+
+/**
+ * @brief Clear the Interrupt flag and start new measurement
+ * *
+ * @note This function Access to the device
+ *
+ * @param Dev Device Handle
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_ClearInterruptAndStartMeasurement(VL53L1_DEV Dev);
+
+/**
+ * @brief Return Measurement Data Ready
+ *
+ * @par Function Description
+ * This function indicate that a measurement data is ready.
+ * This function is used for non-blocking capture.
+ *
+ * @note This function Access to the device
+ *
+ * @param Dev Device Handle
+ * @param pMeasurementDataReady Pointer to Measurement Data Ready.
+ * 0 = data not ready, 1 = data ready
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetMeasurementDataReady(VL53L1_DEV Dev,
+ uint8_t *pMeasurementDataReady);
+
+/**
+ * @brief Wait for measurement data ready.
+ * Blocking function.
+ * Note that the timeout is given by:
+ * VL53L1_RANGE_COMPLETION_POLLING_TIMEOUT_MS defined in def.h
+ *
+ *
+ * @note This function Access to the device
+ *
+ * @param Dev Device Handle
+ * @return VL53L1_ERROR_NONE Success
+ * @return VL53L1_ERROR_TIME_OUT In case of timeout
+ */
+VL53L1_Error VL53L1_WaitMeasurementDataReady(VL53L1_DEV Dev);
+
+
+/**
+ * @brief Retrieve the measurements from device for a given setup
+ *
+ * @par Function Description
+ * Get data from last successful Ranging measurement
+ */
+/**
+ *
+ * @warning USER must call @a VL53L1_ClearInterruptAndStartMeasurement() prior
+ * to call again this function
+ *
+ * @note This function Access to the device
+ *
+ * @note The first valid value returned by this function will have a range
+ * status equal to VL53L1_RANGESTATUS_RANGE_VALID_NO_WRAP_CHECK which means that
+ * the data is valid but no wrap around check have been done. User should take
+ * care about that.
+ *
+ * @param Dev Device Handle
+ * @param pRangingMeasurementData Pointer to the data structure to fill up.
+ * @return VL53L1_ERROR_NONE Success
+ * @return VL53L1_ERROR_MODE_NOT_SUPPORTED in case of MULTIZONES_SCANNING
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetRangingMeasurementData(VL53L1_DEV Dev,
+ VL53L1_RangingMeasurementData_t *pRangingMeasurementData);
+
+
+
+/** @} VL53L1_measurement_group */
+
+/** @defgroup VL53L1_Calibration_group VL53L1 Calibration Functions
+ * @brief Functions used for Calibration
+ * @{
+ */
+
+
+/**
+ * @brief Set Tuning Parameter value for a given parameter ID
+ *
+ * @par Function Description
+ * This function is used to improve the performance of the device. It permit to
+ * change a particular value used for a timeout or a threshold or a constant
+ * in an algorithm. The function will change the value of the parameter
+ * identified by an unique ID.
+ *
+ * @note This function doesn't Access to the device
+ *
+ * @param Dev Device Handle
+ * @param TuningParameterId Tuning Parameter ID
+ * @param TuningParameterValue Tuning Parameter Value
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_SetTuningParameter(VL53L1_DEV Dev,
+ uint16_t TuningParameterId, int32_t TuningParameterValue);
+
+/**
+ * @brief Get Tuning Parameter value for a given parameter ID
+ *
+ * @par Function Description
+ * This function is used to get the value of the parameter
+ * identified by an unique ID.
+ *
+ * @note This function doesn't Access to the device
+ *
+ * @param Dev Device Handle
+ * @param TuningParameterId Tuning Parameter ID
+ * @param pTuningParameterValue Pointer to Tuning Parameter Value
+ * for a given TuningParameterId.
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetTuningParameter(VL53L1_DEV Dev,
+ uint16_t TuningParameterId, int32_t *pTuningParameterValue);
+
+/**
+ * @brief Performs Reference Spad Management
+ *
+ * @par Function Description
+ * The reference SPAD initialization procedure determines the minimum amount
+ * of reference spads to be enables to achieve a target reference signal rate
+ * and should be performed once during initialization.
+ *
+ * @note This function Access to the device
+ *
+ * @param Dev Device Handle
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_PerformRefSpadManagement(VL53L1_DEV Dev);
+
+
+/**
+ * @brief Enable/Disable Cross talk compensation feature
+ *
+ * Enable/Disable Cross Talk correction.
+ *
+ * @param Dev Device Handle
+ * @param XTalkCompensationEnable Cross talk compensation
+ * to be set 0 = disabled or 1 = enabled.
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+*/
+VL53L1_Error VL53L1_SetXTalkCompensationEnable(VL53L1_DEV Dev,
+uint8_t XTalkCompensationEnable);
+
+/**
+ * @brief Get Cross talk compensation rate enable
+ *
+ * Get if the Cross Talk is Enabled or Disabled.
+ *
+ * @note This function doesn't access to the device
+ *
+ * @param Dev Device Handle
+ * @param pXTalkCompensationEnable Pointer to the Cross talk compensation
+ * state 0=disabled or 1 = enabled
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetXTalkCompensationEnable(VL53L1_DEV Dev,
+ uint8_t *pXTalkCompensationEnable);
+
+/**
+ * @brief Perform XTalk Calibration
+ *
+ * @details Perform a XTalk calibration of the Device.
+ * This function will launch a ranging measurement, if interrupts
+ * are enabled an interrupt will be done.
+ * This function will clear the interrupt generated automatically.
+ * This function will program a new value for the XTalk compensation
+ * and it will enable the cross talk before exit.
+ *
+ * @warning This function is a blocking function
+ *
+ * @note This function Access to the device
+ *
+ * @param Dev Device Handle
+ * @param CalDistanceMilliMeter Target distance in mm
+ * The calibration uses current preset and distance mode without altering them.
+ * <br>User must call @a VL53L1_SetPresetMode() with
+ * VL53L1_PRESETMODE_AUTONOMOUS, VL53L1_PRESETMODE_LITE_RANGING or
+ * VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS parameter prior to launch calibration
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_PerformSingleTargetXTalkCalibration(VL53L1_DEV Dev,
+ int32_t CalDistanceMilliMeter);
+
+
+/**
+ * @brief Define the mode to be used for the offset calibration
+ *
+ * Define the mode to be used for the offset calibration. This function should
+ * be called before run the @a VL53L1_PerformOffsetCalibration()
+ *
+ * @param Dev Device Handle
+ * @param OffsetCalibrationMode Offset Calibration Mode valid values are:
+ * @li VL53L1_OFFSETCALIBRATIONMODE_STANDARD
+ * @li VL53L1_OFFSETCALIBRATIONMODE_PRERANGE_ONLY
+ */
+/**
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_SetOffsetCalibrationMode(VL53L1_DEV Dev,
+ VL53L1_OffsetCalibrationModes OffsetCalibrationMode);
+
+
+
+/**
+ * @brief Perform Offset Calibration
+ *
+ * @details Perform a Offset calibration of the Device.
+ * This function will launch a ranging measurement, if interrupts are
+ * enabled interrupts will be done.
+ * This function will program a new value for the Offset calibration value
+ *
+ * @warning This function is a blocking function
+ *
+ * @note This function Access to the device
+ *
+ * @param Dev Device Handle
+ * @param CalDistanceMilliMeter Calibration distance value used for the
+ * offset compensation.
+ *
+ * @return VL53L1_ERROR_NONE
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_PerformOffsetCalibration(VL53L1_DEV Dev,
+ int32_t CalDistanceMilliMeter);
+
+/**
+ * @brief Perform Offset simple Calibration
+ *
+ * @details Perform a very simple offset calibration of the Device.
+ * This function will launch few ranging measurements and computes offset
+ * calibration. The preset mode and the distance mode MUST be set by the
+ * application before to call this function.
+ *
+ * @warning This function is a blocking function
+ *
+ * @note This function Access to the device
+ *
+ * @param Dev Device Handle
+ * @param CalDistanceMilliMeter Calibration distance value used for the
+ * offset compensation.
+ *
+ * @return VL53L1_ERROR_NONE
+ * @return VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL the calibration failed by
+ * lack of valid measurements
+ * @return VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH means that the target
+ * distance combined to the number of loops performed in the calibration lead to
+ * an internal overflow. Try to reduce the distance of the target (140 mm)
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_PerformOffsetSimpleCalibration(VL53L1_DEV Dev,
+ int32_t CalDistanceMilliMeter);
+
+/**
+ * @brief Sets the Calibration Data.
+ *
+ * @par Function Description
+ * This function set all the Calibration Data issued from the functions
+ * @a VL53L1_PerformRefSpadManagement(), @a VL53L1_PerformXTalkCalibration,
+ * @a VL53L1_PerformOffsetCalibration()
+ *
+ * @note This function doesn't Accesses the device
+ *
+ * @param Dev Device Handle
+ * @param *pCalibrationData Pointer to Calibration data to be set.
+ * @return VL53L1_ERROR_NONE Success
+ * @return VL53L1_ERROR_INVALID_PARAMS pCalibrationData points to an older
+ * version of the inner structure. Need for support to convert its content.
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_SetCalibrationData(VL53L1_DEV Dev,
+ VL53L1_CalibrationData_t *pCalibrationData);
+
+/**
+ * @brief Gets the Calibration Data.
+ *
+ * @par Function Description
+ * This function get all the Calibration Data issued from the functions
+ * @a VL53L1_PerformRefSpadManagement(), @a VL53L1_PerformXTalkCalibration,
+ * @a VL53L1_PerformOffsetCalibration()
+ *
+ * @note This function doesn't Accesses the device
+ *
+ * @param Dev Device Handle
+ * @param *pCalibrationData pointer where to store Calibration
+ * data.
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetCalibrationData(VL53L1_DEV Dev,
+ VL53L1_CalibrationData_t *pCalibrationData);
+
+/**
+ * @brief Gets the optical center.
+ *
+ * @par Function Description
+ * This function get the optical center issued from the nvm set at FTM stage
+ * expressed in the same coordinate system as the ROI are
+ *
+ * @note This function doesn't Accesses the device
+ *
+ * @param Dev Device Handle
+ * @param *pOpticalCentreX pointer to the X position of center
+ * in 16.16 fix point
+ * @param *pOpticalCentreY pointer to the Y position of center
+ * in 16.16 fix point
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_GetOpticalCenter(VL53L1_DEV Dev,
+ FixPoint1616_t *pOpticalCenterX,
+ FixPoint1616_t *pOpticalCenterY);
+
+/** @} VL53L1_Calibration_group */
+
+/** @defgroup VL53L1_Thresholds_group VL53L1 IRQ Triggered events Functions
+ * @brief Functions used to configure interrupt to be triggered only when
+ * a measurement satisfies some thresholds parameters
+ * @{
+ */
+
+/**
+* @brief Configure the interrupt config, from the given structure
+*
+* @param[in] Dev : Device Handle
+* @param[in] pConfig : pointer to configuration structure
+*/
+
+VL53L1_Error VL53L1_SetThresholdConfig(VL53L1_DEV Dev,
+ VL53L1_DetectionConfig_t *pConfig);
+
+/**
+* @brief Retrieves the interrupt config structure currently programmed
+* into the API
+*
+* @param[in] Dev : Device Handle
+* @param[out] pConfig : pointer to configuration structure
+*/
+
+VL53L1_Error VL53L1_GetThresholdConfig(VL53L1_DEV Dev,
+ VL53L1_DetectionConfig_t *pConfig);
+
+
+/** @} VL53L1_Thresholds_group */
+
+
+/** @} VL53L1_cut11_group */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VL53L1_API_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api_calibration.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api_calibration.h
new file mode 100644
index 0000000..1fd05a7
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api_calibration.h
@@ -0,0 +1,236 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_api_core.h
+ *
+ * @brief EwokPlus25 low level API function definitions
+ */
+
+#ifndef _VL53L1_API_CALIBRATION_H_
+#define _VL53L1_API_CALIBRATION_H_
+
+#include "vl53l1_platform.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @brief Run Reference Array SPAD Characterisation.
+ *
+ * This function finds the required number of reference SPAD
+ * to meet the input required peak reference rate.
+ *
+ * The algorithm first tries the non apertured reference SPAD's,
+ * if the rate is too high for the minimum allowed SPAD count (5)
+ * then the algo switches to 5x apertured SPAD's and if the rate
+ * is still to high then the 10x apertured SPAD are selected.
+ *
+ * The function reads the following results from the device and
+ * both caches the values in the pdev->customer structure and
+ * writes the data into the G02 customer register group.
+ *
+ * - num_ref_spads
+ * - ref_location
+ * - DCR SPAD enables for selected reference location
+ *
+ * Note power force is enabled as the function needs to read
+ * data from the Patch RAM.
+ *
+ * Should only be called once per part with coverglass attached to
+ * generate the required num of SPAD, Ref location and DCR SPAD enable
+ * data
+ *
+ * @param[in] Dev : Device Handle
+ * @param[out] pcal_status : Pointer to unfiltered calibration status
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS
+ * Less than 5 Good SPAD available, output not valid
+ * @return VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH
+ * At end of search reference rate > 40.0 Mcps
+ * Offset stability may be degraded.
+ * @return VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW
+ * At end of search reference rate < 10.0 Mcps
+ * Offset stability may be degraded.
+ *
+ */
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_run_ref_spad_char(VL53L1_DEV Dev, VL53L1_Error *pcal_status);
+#endif
+
+
+/**
+ * @brief Runs the input Device Test
+ *
+ * Calls
+ *
+ * - VL53L1_enable_powerforce()
+ * - VL53L1_start_test()
+ * - VL53L1_poll_for_range_completion()
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] device_test_mode : Device test mode register value
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_run_device_test(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceTestMode device_test_mode);
+#endif
+
+
+/**
+ * @brief Runs SPAD rate map
+ *
+ * Output structure contains SPAD rate data in SPAD number order
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] device_test_mode : Device test mode register value.
+ * Valid options: \n
+ * - VL53L1_DEVICETESTMODE_LCR_VCSEL_OFF \n
+ * - VL53L1_DEVICETESTMODE_LCR_VCSEL_ON
+ * @param[in] array_select : Device SPAD array select
+ * Valid options: \n
+ * - VL53L1_DEVICESSCARRAY_RTN \n
+ * - VL53L1_DEVICESSCARRAY_REF
+ * @param[in] ssc_config_timeout_us : SSC timeout in [us] e.g 36000us
+ * @param[out] pspad_rate_data : pointer to output rates structure
+ * 1.15 format for LCR_VCSEL_OFF
+ * 9.7 format for LCR_VCSEL_ON
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_run_spad_rate_map(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceTestMode device_test_mode,
+ VL53L1_DeviceSscArray array_select,
+ uint32_t ssc_config_timeout_us,
+ VL53L1_spad_rate_data_t *pspad_rate_data);
+#endif
+
+
+/**
+ * @brief Run offset calibration
+ *
+ * Runs the standard ranging MM1 and MM2 calibration presets
+ * to generate the MM1 and MM2 range offset data
+ *
+ * The range config timeout is used for both MM1 and MM2 so that
+ * the sigma delta settling is the same as for the 'real' range
+ *
+ * Places results into VL53L1_customer_nvm_managed_t within pdev
+ *
+ * Use VL53L1_get_part_to_part_data() to get the offset calibration
+ * results
+ *
+ * Current FMT settings:
+ *
+ * - offset_calibration_mode = VL53L1_OFFSETCALIBRATIONMODE__STANDARD_RANGING
+ * - dss_config__target_total_rate_mcps = 0x0A00 (20.0Mcps) to 0x1400 (40.0Mcps)
+ * - phasecal_config_timeout_us = 1000
+ * - range_config_timeout_us = 13000
+ * - pre_num_of_samples = 32
+ * - mm1_num_of_samples = 100
+ * - mm2_range_num_of_samples = 64
+ * - target_distance_mm = 140 mm
+ * - target reflectance = 5%
+ *
+ * Note: function parms simplified as part of Patch_CalFunctionSimplification_11791
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] cal_distance_mm : Distance to target in [mm] - the ground truth
+ * @param[out] pcal_status : Pointer to unfiltered calibration status
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return VL53L1_WARNING_OFFSET_CAL_INSUFFICIENT_MM1_SPADS
+ * Effective MM1 SPAD count too low (<5.0).
+ * Out with recommended calibration condition.
+ * Accuracy of offset calibration may be degraded.
+ * @return VL53L1_WARNING_OFFSET_CAL_PRE_RANGE_RATE_TOO_HIGH
+ * Pre range too high (>40.0) in pile up region.
+ * Out with recommended calibration condition.
+ * Accuracy of offset calibration may be degraded.
+ */
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_run_offset_calibration(
+ VL53L1_DEV Dev,
+ int16_t cal_distance_mm,
+ VL53L1_Error *pcal_status);
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VL53L1_API_CALIBRATION_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api_core.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api_core.h
new file mode 100644
index 0000000..309485f
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api_core.h
@@ -0,0 +1,1183 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_api_core.h
+ *
+ * @brief EwokPlus25 low level API function definitions
+ */
+
+#ifndef _VL53L1_API_CORE_H_
+#define _VL53L1_API_CORE_H_
+
+#include "vl53l1_platform.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @brief Get LL Driver version information
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] pversion : pointer to VL53L1_ll_version_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ */
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_get_version(
+ VL53L1_DEV Dev,
+ VL53L1_ll_version_t *pversion);
+
+/**
+ * @brief Gets Device Firmware version
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] pfw_version : pointer to uint16_t FW version
+ *
+ * @return VL53L1_ERROR_NONE Success
+ */
+
+VL53L1_Error VL53L1_get_device_firmware_version(
+ VL53L1_DEV Dev,
+ uint16_t *pfw_version);
+#endif
+
+
+/**
+ * @brief Initialises pdev structure and optionally read the
+ * part to part information form he device G02 registers
+ *
+ * Important: VL53L1_platform_initialise() *must* called before calling
+ * this function
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] read_p2p_data : if > 0 then reads and caches P2P data
+ *
+ * @return VL53L1_ERROR_NONE Success
+ */
+
+VL53L1_Error VL53L1_data_init(
+ VL53L1_DEV Dev,
+ uint8_t read_p2p_data);
+
+
+/**
+ * @brief For C-API one time initialization only reads device
+ * G02 registers containing data copied from NVM
+ *
+ * Contains the key NVM data e.g identification info
+ * fast oscillator freq, max trim and laser safety info
+ *
+ * Function all only be called after the device has finished booting
+ *
+ * @param[in] Dev : Device handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ */
+
+VL53L1_Error VL53L1_read_p2p_data(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Performs device software reset and then waits for the firmware
+ * to finish booting
+ *
+ * @param[in] Dev : Device handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_software_reset(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Sets the customer part to part data
+ *
+ * Important: does **not** apply the settings to the device.
+ * Updates the following structures in the device structure
+ *
+ * Just an internal memcpy to
+ *
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] pcal_data : pointer to VL53L1_calibration_data_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_part_to_part_data(
+ VL53L1_DEV Dev,
+ VL53L1_calibration_data_t *pcal_data);
+
+
+/**
+ * @brief Gets the customer part to part data
+ *
+ * Just an internal memory copy
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] pcal_data : pointer to VL53L1_calibration_data_t
+ *
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_part_to_part_data(
+ VL53L1_DEV Dev,
+ VL53L1_calibration_data_t *pcal_data);
+
+
+/**
+ * @brief Gets the tuning parm part to part data
+ *
+ * Just an internal copy
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] ptun_data : pointer to VL53L1_tuning_parameters_t
+ *
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_get_tuning_debug_data(
+ VL53L1_DEV Dev,
+ VL53L1_tuning_parameters_t *ptun_data);
+#endif
+
+
+/**
+ * @brief Sets the inter measurement period in the VL53L1_timing_config_t structure
+ *
+ * Uses the pdev->dbg_results.result__osc_calibrate_val value convert from [ms]
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] inter_measurement_period_ms : requested inter measurement period in [ms]
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_inter_measurement_period_ms(
+ VL53L1_DEV Dev,
+ uint32_t inter_measurement_period_ms);
+
+
+/**
+ * @brief Gets inter measurement period from the VL53L1_timing_config_t structure
+ *
+ * Uses the pdev->dbg_results.result__osc_calibrate_val value convert into [ms]
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] pinter_measurement_period_ms : current inter measurement period in [ms]
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_inter_measurement_period_ms(
+ VL53L1_DEV Dev,
+ uint32_t *pinter_measurement_period_ms);
+
+
+/**
+ * @brief Sets the phasecal, mode mitigation and ranging timeouts
+ * in the VL53L1_timing_config_t structure
+ *
+ * Uses the pdev->stat_nvm.osc_measured__fast_osc__frequency value convert from [us]
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] phasecal_config_timeout_us : requested Phase Cal Timeout e.g. 1000us
+ * @param[in] mm_config_timeout_us : requested MM Timeout e.g. 2000us
+ * @param[in] range_config_timeout_us : requested Ranging Timeout e.g 13000us
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_timeouts_us(
+ VL53L1_DEV Dev,
+ uint32_t phasecal_config_timeout_us,
+ uint32_t mm_config_timeout_us,
+ uint32_t range_config_timeout_us);
+
+
+/**
+ * @brief Gets the phasecal, mode mitigation and ranging timeouts
+ * for the VL53L1_timing_config_t structure
+ *
+ * Uses the pdev->stat_nvm.osc_measured__fast_osc__frequency convert into [us]
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] pphasecal_config_timeout_us : current Phase Cal Timeout in [us]
+ * @param[out] pmm_config_timeout_us : current MM Timeout in [us]
+ * @param[out] prange_config_timeout_us : current Ranging Timeout in [us]
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_timeouts_us(
+ VL53L1_DEV Dev,
+ uint32_t *pphasecal_config_timeout_us,
+ uint32_t *pmm_config_timeout_us,
+ uint32_t *prange_config_timeout_us);
+
+
+/**
+ * @brief Sets the 12-bit calibration repeat period value
+ *
+ * Sets the repeat period for VHV and phasecal in ranges.
+ * Setting to zero to disables the repeat, but the VHV
+ * and PhaseCal is still run on the very first range in
+ * this case.
+ *
+ * Only even values should be set
+ *
+ * The max value is 4094 i.e. every
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] cal_config__repeat_period : current calibration config repeat period
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_calibration_repeat_period(
+ VL53L1_DEV Dev,
+ uint16_t cal_config__repeat_period);
+
+
+/**
+ * @brief Gets the current 12-bit calibration repeat period value
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] pcal_config__repeat_period : current calibration config repeat period
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_calibration_repeat_period(
+ VL53L1_DEV Dev,
+ uint16_t *pcal_config__repeat_period);
+
+
+/**
+ * @brief Set system sequence config bit value
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] bit_id : VL53L1_DeviceSequenceConfig bit id
+ * @param[in] value : Input Bit value = 0 or 1
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_sequence_config_bit(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceSequenceConfig bit_id,
+ uint8_t value);
+
+
+/**
+ * @brief Get system sequence config bit value
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] bit_id : VL53L1_DeviceSequenceConfig bit id
+ * @param[out] pvalue : Output Bit value = 0 or 1
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_sequence_config_bit(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceSequenceConfig bit_id,
+ uint8_t *pvalue);
+
+
+/**
+ * @brief Set the interrupt polarity bit in
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] interrupt_polarity : Interrupt Polarity
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_interrupt_polarity(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceInterruptPolarity interrupt_polarity);
+
+
+/**
+ * @brief Get the interrupt polarity bit state
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] pinterrupt_polarity : Interrupt Polarity Bit value
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_interrupt_polarity(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceInterruptPolarity *pinterrupt_polarity);
+
+/**
+ * @brief Set the Ref spad char cfg struct internal to pdev
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] pdata : Input pointer to VL53L1_refspadchar_config_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_get_refspadchar_config_struct(
+ VL53L1_DEV Dev,
+ VL53L1_refspadchar_config_t *pdata);
+#endif
+
+/**
+ * @brief Extract the Ref spad char cfg struct from pdev
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] pdata : Output pointer to VL53L1_refspadchar_config_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_set_refspadchar_config_struct(
+ VL53L1_DEV Dev,
+ VL53L1_refspadchar_config_t *pdata);
+#endif
+
+/**
+ * @brief Set the Range Ignore Threshold Rate value
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] range_ignore_thresh_mult : Input RIT Mult value, in \
+ * 3.5 fractional value
+ * @param[in] range_ignore_threshold_mcps : Range Ignore Threshold value
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_range_ignore_threshold(
+ VL53L1_DEV Dev,
+ uint8_t range_ignore_thresh_mult,
+ uint16_t range_ignore_threshold_mcps);
+
+/**
+ * @brief Get the Range Ignore Threshold Rate value
+ *
+ *
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] prange_ignore_thresh_mult : \
+ * Range ignore threshold internal multiplier value in \
+ * 3.5 fractional format.
+ * @param[out] prange_ignore_threshold_mcps_internal : \
+ * Range Ignore Threshold Rate value generated from \
+ * current xtalk parms
+ * @param[out] prange_ignore_threshold_mcps_current : \
+ * Range Ignore Threshold Rate value generated from \
+ * device static config struct
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_range_ignore_threshold(
+ VL53L1_DEV Dev,
+ uint8_t *prange_ignore_thresh_mult,
+ uint16_t *prange_ignore_threshold_mcps_internal,
+ uint16_t *prange_ignore_threshold_mcps_current);
+
+
+/**
+ * @brief Sets the current user Zone (ROI) configuration structure data
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] puser_zone : pointer to user Zone (ROI) data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_user_zone(
+ VL53L1_DEV Dev,
+ VL53L1_user_zone_t *puser_zone);
+
+
+/**
+ * @brief Gets the current user zone (ROI) configuration structure data
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] puser_zone : pointer to user zone (ROI) data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_user_zone(
+ VL53L1_DEV Dev,
+ VL53L1_user_zone_t *puser_zone);
+
+
+/**
+ * @brief Gets the current mode mitigation zone (ROI) configuration structure data
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] pmm_roi : pointer to user zone (ROI) data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_mode_mitigation_roi(
+ VL53L1_DEV Dev,
+ VL53L1_user_zone_t *pmm_roi);
+
+
+/**
+ * @brief Initialises the configuration data structures for
+ * the selected preset mode
+ *
+ * Important: does **not** apply the settings to the device.
+ * Updates the following structures in the device structure
+ *
+ * - static config : pdev->stat_cfg
+ * - dynamic config : pdev->dyn_cfg
+ * - system_control :pdev->sys_ctrl
+ *
+ * Uses osc_measured__fast_osc__frequency in pdev->stat_nvm to
+ * convert the input timeouts in [us] to internal macro period
+ * timeout values.
+ *
+ * Please call VL53L1_init_and_start_range() to update device
+ * and start a range
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] device_preset_mode : selected device preset mode
+ * @param[in] dss_config__target_total_rate_mcps : DSS target rate in 9.7 format e.g 0x0A00 -> 20.0 Mcps
+ * @param[in] phasecal_config_timeout_us : requested Phase Cal Timeout e.g. 1000us
+ * @param[in] mm_config_timeout_us : requested MM Timeout e.g. 2000us
+ * @param[in] range_config_timeout_us : requested Ranging Timeout e.g 10000us
+ * @param[in] inter_measurement_period_ms : requested timed mode repeat rate e.g 100ms
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_preset_mode(
+ VL53L1_DEV Dev,
+ VL53L1_DevicePresetModes device_preset_mode,
+ uint16_t dss_config__target_total_rate_mcps,
+ uint32_t phasecal_config_timeout_us,
+ uint32_t mm_config_timeout_us,
+ uint32_t range_config_timeout_us,
+ uint32_t inter_measurement_period_ms);
+
+
+/**
+ * @brief Gets the requested preset mode configuration tuning parameters
+ *
+ * Function Added as part of Patch_TuningParmPresetModeAddition_11839
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] device_preset_mode : selected device preset mode
+ * @param[out] pdss_config__target_total_rate_mcps : dss rate output value
+ * @param[out] pphasecal_config_timeout_us : phasecal timeout output value
+ * @param[out] pmm_config_timeout_us : mm timeout output value
+ * @param[out] prange_config_timeout_us : range timeout output value
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_preset_mode_timing_cfg(
+ VL53L1_DEV Dev,
+ VL53L1_DevicePresetModes device_preset_mode,
+ uint16_t *pdss_config__target_total_rate_mcps,
+ uint32_t *pphasecal_config_timeout_us,
+ uint32_t *pmm_config_timeout_us,
+ uint32_t *prange_config_timeout_us);
+
+/**
+ * @brief Simple function to enable xtalk compensation
+ *
+ * Applies xtalk compensation to hist post processing,
+ * and applies settings to device,
+ *
+ * @param[in] Dev : Device Handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_enable_xtalk_compensation(
+ VL53L1_DEV Dev);
+
+/**
+ * @brief Simple function to disable xtalk compensation
+ *
+ * Disables xtalk compensation from hist post processing,
+ * and clears settings to device
+ *
+ * @param[in] Dev : Device Handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_disable_xtalk_compensation(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Simple function to retrieve xtalk compensation
+ * status
+ *
+ * @param[in] Dev : Device Handle
+ * @param[out] pcrosstalk_compensation_enable : pointer to \
+ * uint8 type, returns crosstalk compensation status \
+ * where 0 means disabled and 1 means enabled.
+ *
+ */
+
+void VL53L1_get_xtalk_compensation_enable(
+ VL53L1_DEV Dev,
+ uint8_t *pcrosstalk_compensation_enable);
+
+/**
+ * @brief Builds and sends the I2C buffer to initialize the device
+ * and start a range measurement
+ *
+ * The device_config_level input controls the level of initialization
+ * applied to the device
+ *
+ * - System control only
+ * - Dynamic Onwards
+ * - dynamic_config and system_control
+ * - Static Onwards
+ * - static_config, dynamic_config & system_control
+ * - software standby mode only
+ * - Customer Onwards
+ * - customer_nvm_managed, static_config, dynamic_config & system_control
+ * - software standby mode only
+ * - Full
+ * - static_nvm_managed, customer_nvm_managed, static_config, dynamic_config & system_control
+ * - software standby mode only
+ *
+ * The system_control register group is always written as the last
+ * register of this group SYSTEM__MODE_START decides what happens next ...
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] measurement_mode : Options: \n
+ * VL53L1_DEVICEMEASUREMENTMODE_STOP \n
+ * VL53L1_DEVICEMEASUREMENTMODE_SINGLESHOT \n
+ * VL53L1_DEVICEMEASUREMENTMODE_BACKTOBACK \n
+ * VL53L1_DEVICEMEASUREMENTMODE_TIMED
+ * @param[in] device_config_level : Options: \n
+ * VL53L1_DEVICECONFIGLEVEL_SYSTEM_CONTROL \n
+ * VL53L1_DEVICECONFIGLEVEL_DYNAMIC_ONWARDS \n
+ * VL53L1_DEVICECONFIGLEVEL_TIMING_ONWARDS \n
+ * VL53L1_DEVICECONFIGLEVEL_STATIC_ONWARDS \n
+ * VL53L1_DEVICECONFIGLEVEL_CUSTOMER_ONWARDS \n
+ * VL53L1_DEVICECONFIGLEVEL_FULL
+ *
+ * The system_control register group is always written as the last
+ * register of this group SYSTEM__MODE_START decides what happens next ..
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_init_and_start_range(
+ VL53L1_DEV Dev,
+ uint8_t measurement_mode,
+ VL53L1_DeviceConfigLevel device_config_level);
+
+
+/**
+ * @brief Sends an abort command to stop the in progress range.
+ * Also clears all of the measurement mode bits.
+ *
+ * @param[in] Dev : Device handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_stop_range(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Get range measurement result data
+ *
+ * Reads the required number of registers as single multi byte read
+ * transaction and decodes the data into the data structures
+ *
+ * range_result_level controls which result data is read back from the
+ * device
+ *
+ * - Full
+ * - both system and core results are read back
+ * - System Results
+ * - only system results are read back
+ * - only the system_results structure is updated in this case
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] device_result_level : Options: \n
+ * VL53L1_DEVICERESULTSLEVEL_FULL \n
+ * VL53L1_DEVICERESULTSLEVEL_UPTO_CORE \n
+ * VL53L1_DEVICERESULTSLEVEL_SYSTEM_RESULTS
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_measurement_results(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceResultsLevel device_result_level);
+
+
+/**
+ * @brief Get device system results, updates GPH registers and
+ * clears interrupt and configures SYSTEM__MODE_START
+ * based on the input measurement mode
+ *
+ * Internally uses the following functions:
+ *
+ * - VL53L1_get_measurement_results()
+ * - VLS3L1_init_and_start_range()
+ *
+ * The system_control register group is always written as the last
+ * register of this group SYSTEM__MODE_START decides what happens next ...
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] device_result_level : Options: \n
+ * VL53L1_DEVICERESULTSLEVEL_FULL \n
+ * VL53L1_DEVICERESULTSLEVEL_UPTO_CORE \n
+ * VL53L1_DEVICERESULTSLEVEL_SYSTEM_RESULTS
+ * @param[out] prange_results : pointer to VL53L1_range_results_t
+
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_device_results(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceResultsLevel device_result_level,
+ VL53L1_range_results_t *prange_results);
+
+
+/**
+ * @brief Sends the ranging handshake to clear the interrupt
+ * allow the device to move onto the next range
+ *
+ * updates GPH registers and clears interrupt and configures
+ * SYSTEM__MODE_START register based on the input measurement mode
+ *
+ * Internally uses the following functions:
+ *
+ * - VLS3L1_init_and_start_range()
+ *
+ * The system_control register group is always written as the last
+ * register of this group SYSTEM__MODE_START decides what happens next ...
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] measurement_mode : Options: \n
+ * VL53L1_DEVICEMEASUREMENTMODE_STOP \n
+ * VL53L1_DEVICEMEASUREMENTMODE_SINGLESHOT \n
+ * VL53L1_DEVICEMEASUREMENTMODE_BACKTOBACK \n
+ * VL53L1_DEVICEMEASUREMENTMODE_TIMED
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_clear_interrupt_and_enable_next_range(
+ VL53L1_DEV Dev,
+ uint8_t measurement_mode);
+
+
+/**
+ * @brief Copies system and core results to range results data structure
+ *
+ * @param[in] gain_factor : gain correction factor 1.11 format
+ * @param[in] psys : pointer to VL53L1_system_results_t
+ * @param[in] pcore : pointer to VL53L1_core_results_t
+ * @param[out] presults : pointer to VL53L1_range_results_t
+ */
+
+void VL53L1_copy_sys_and_core_results_to_range_results(
+ int32_t gain_factor,
+ VL53L1_system_results_t *psys,
+ VL53L1_core_results_t *pcore,
+ VL53L1_range_results_t *presults);
+
+/**
+ * @brief Configure the GPIO interrupt config, from the given input
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] intr_mode_distance : distance interrupt mode
+ * @param[in] intr_mode_rate : rate interrupt mode
+ * @param[in] intr_new_measure_ready : trigger when new interrupt ready
+ * @param[in] intr_no_target : trigger when no target found
+ * @param[in] intr_combined_mode : switch on combined mode
+ * @param[in] thresh_distance_high : High distance threshold in mm
+ * @param[in] thresh_distance_low : Low distance threshold in mm
+ * @param[in] thresh_rate_high : High rate threshold in 9.7 Mcps
+ * @param[in] thresh_rate_low : Low rate threshold in 9.7 Mcps
+ */
+
+VL53L1_Error VL53L1_set_GPIO_interrupt_config(
+ VL53L1_DEV Dev,
+ VL53L1_GPIO_Interrupt_Mode intr_mode_distance,
+ VL53L1_GPIO_Interrupt_Mode intr_mode_rate,
+ uint8_t intr_new_measure_ready,
+ uint8_t intr_no_target,
+ uint8_t intr_combined_mode,
+ uint16_t thresh_distance_high,
+ uint16_t thresh_distance_low,
+ uint16_t thresh_rate_high,
+ uint16_t thresh_rate_low
+ );
+
+/**
+ * @brief Configure the GPIO interrupt config, from the given structure
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] intconf : input structure (note, not a pointer)
+ */
+
+VL53L1_Error VL53L1_set_GPIO_interrupt_config_struct(
+ VL53L1_DEV Dev,
+ VL53L1_GPIO_interrupt_config_t intconf);
+
+/**
+ * @brief Retrieves the GPIO interrupt config structure currently programmed
+ * into the API
+ *
+ * @param[in] Dev : Device Handle
+ * @param[out] pintconf : output pointer to structure (note, pointer)
+ */
+
+VL53L1_Error VL53L1_get_GPIO_interrupt_config(
+ VL53L1_DEV Dev,
+ VL53L1_GPIO_interrupt_config_t *pintconf);
+
+/**
+ * @brief Set function for offset calibration mode
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] offset_cal_mode : input calibration mode
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_offset_calibration_mode(
+ VL53L1_DEV Dev,
+ VL53L1_OffsetCalibrationMode offset_cal_mode);
+
+
+/**
+ * @brief Get function for offset calibration mode
+ *
+ * @param[in] Dev : Device Handle
+ * @param[out] poffset_cal_mode : output pointer for calibration mode
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_offset_calibration_mode(
+ VL53L1_DEV Dev,
+ VL53L1_OffsetCalibrationMode *poffset_cal_mode);
+
+
+/**
+ * @brief Set function for offset correction mode
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] offset_cor_mode : input correction mode
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_offset_correction_mode(
+ VL53L1_DEV Dev,
+ VL53L1_OffsetCalibrationMode offset_cor_mode);
+
+
+/**
+ * @brief Get function for offset correction mode
+ *
+ * @param[in] Dev : Device Handle
+ * @param[out] poffset_cor_mode : output pointer for correction mode
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_offset_correction_mode(
+ VL53L1_DEV Dev,
+ VL53L1_OffsetCorrectionMode *poffset_cor_mode);
+
+/**
+ * @brief Get function for Xtalk Margin setting
+ * Histogram Mode version
+ *
+ * @param[in] Dev : Device Handle
+ * @param[out] pxtalk_margin : output pointer for int16_t xtalk_margin factor \
+ * in fixed point 7.9 Kcps.
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_lite_xtalk_margin_kcps(
+ VL53L1_DEV Dev,
+ int16_t *pxtalk_margin);
+
+/**
+ * @brief Set function for Xtalk Margin setting
+ * Histogram Mode version
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] xtalk_margin : Input int16_t xtalk_margin factor \
+ * in fixed point 7.9 Kcps.
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_lite_xtalk_margin_kcps(
+ VL53L1_DEV Dev,
+ int16_t xtalk_margin);
+
+/**
+ * @brief Get function for Lite Mode Minimum Count Rate
+ * parameter, used to filter and validate ranges based on
+ * signal rate
+ *
+ * Note: the min count rate value is overwritten when setting preset
+ * modes, and should only be altered after preset mode has been
+ * selected when running Lite Mode.
+ *
+ * @param[in] Dev : Device Handle
+ * @param[out] plite_mincountrate : Output pointer for uint16_t min count rate\
+ * in fixed point 9.7 Mcps
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_lite_min_count_rate(
+ VL53L1_DEV Dev,
+ uint16_t *plite_mincountrate);
+
+
+/**
+ * @brief Set function for Lite Mode Minimum Count Rate
+ * parameter, used to filter and validate ranges based on
+ * signal rate
+ *
+ * Note: the min count rate value is overwritten when setting preset
+ * modes, and should only be altered after preset mode has been
+ * selected when running Lite Mode.
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] lite_mincountrate : Input uint16_t min count rate
+ * in fixed point 9.7 Mcps
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_lite_min_count_rate(
+ VL53L1_DEV Dev,
+ uint16_t lite_mincountrate);
+
+
+/**
+ * @brief Get function for Lite Mode Max Sigma Threshold
+ * parameter, used to filter and validate ranges based on
+ * estimated sigma level
+ *
+ * Note: the sigma thresh value is overwritten when setting preset
+ * modes, and should only be altered after preset mode has been
+ * selected when running Lite Mode.
+ *
+ * @param[in] Dev : Device Handle
+ * @param[out] plite_sigma : Output pointer for uint16_t sigma thresh\
+ * in fixed point 14.2 mm
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+
+VL53L1_Error VL53L1_get_lite_sigma_threshold(
+ VL53L1_DEV Dev,
+ uint16_t *plite_sigma);
+
+
+/**
+ * @brief Set function for Lite Mode Max Sigma Threshold
+ * parameter, used to filter and validate ranges based on
+ * estimated sigma level
+ *
+ * Note: the sigma thresh value is overwritten when setting preset
+ * modes, and should only be altered after preset mode has been
+ * selected when running Lite Mode.
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] lite_sigma : Input uint16_t sigma thresh\
+ * in fixed point 14.2 mm
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_lite_sigma_threshold(
+ VL53L1_DEV Dev,
+ uint16_t lite_sigma);
+
+
+/**
+ * @brief Function to restore the plane_offset, x gradient and y gradient
+ * values to original NVM values.
+ *
+ * This function does not recalculate all xtalk parms derived from the
+ * rates in question. In order to ensure correct ranging, a call to
+ * VL53L1_enable_xtalk_compensation should always be called prior
+ * to starting the ranging process.
+ *
+ * @param[in] Dev : Device Handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_restore_xtalk_nvm_default(
+ VL53L1_DEV Dev);
+
+/**
+ * @brief Set function for VHV Config values
+ * sets two parms into individual internal byte
+ *
+ * init_en - enables use of the init value instead of latest setting
+ * init_value - custom vhv setting or populated from nvm
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] vhv_init_en : input init_en setting
+ * @param[in] vhv_init_value : input vhv custom value
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_vhv_config(
+ VL53L1_DEV Dev,
+ uint8_t vhv_init_en,
+ uint8_t vhv_init_value);
+
+/**
+ * @brief Get function for VHV Config values
+ * extracts two parms from individual internal byte
+ *
+ * init_en - enables use of the init value instead of latest setting
+ * init_value - custom vhv setting or populated from nvm
+ *
+ * @param[in] Dev : Device Handle
+ * @param[out] pvhv_init_en : Output pointer to uint8_t value
+ * @param[out] pvhv_init_value : Output pointer to uint8_t value
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_vhv_config(
+ VL53L1_DEV Dev,
+ uint8_t *pvhv_init_en,
+ uint8_t *pvhv_init_value);
+
+/**
+ * @brief Set function for VHV loopbound config
+ *
+ * Loopbound sets the number of +/- vhv settings to try
+ * around the vhv init value during vhv search
+ * i.e. if init_value = 10 and loopbound = 2
+ * vhv search will run from 10-2 to 10+2
+ * 8 to 12.
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] vhv_loopbound : input loopbound value
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_vhv_loopbound(
+ VL53L1_DEV Dev,
+ uint8_t vhv_loopbound);
+
+/**
+ * @brief Get function for VHV loopbound config
+ *
+ * Loopbound sets the number of +/- vhv settings to try
+ * around the vhv init value during vhv search
+ * i.e. if init_value = 10 and loopbound = 2
+ * vhv search will run from 10-2 to 10+2
+ * 8 to 12.
+ *
+ * @param[in] Dev : Device Handle
+ * @param[out] pvhv_loopbound : pointer to byte to extract loopbound
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_vhv_loopbound(
+ VL53L1_DEV Dev,
+ uint8_t *pvhv_loopbound);
+
+/**
+ * @brief Generic Tuning Parameter extraction function
+ *
+ * User passes a key input to retrieve a specific tuning parameter
+ * value, this will be cast to the int32_t type and output via
+ * the ptuning_parm_value pointer
+ *
+ * If the key does not match any tuning parameter, status is returned
+ * with VL53L1_ERROR_INVALID_PARAMS
+ *
+ * Patch_AddedTuningParms_11761
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] tuning_parm_key : Key value to access specific tuning parm
+ * @param[out] ptuning_parm_value : Pointer to output int32_t type, retrieves \
+ * requested tuning parm
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_tuning_parm(
+ VL53L1_DEV Dev,
+ VL53L1_TuningParms tuning_parm_key,
+ int32_t *ptuning_parm_value);
+
+/**
+ * @brief Generic Tuning Parameter set function
+ *
+ * User passes a key input to set a specific tuning parameter
+ * value, this will be cast to the internal data type from the
+ * input int32_t data type.
+ *
+ * If the key does not match any tuning parameter, status is returned
+ * with VL53L1_ERROR_INVALID_PARAMS
+ *
+ * Patch_AddedTuningParms_11761
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] tuning_parm_key : Key value to access specific tuning parm
+ * @param[in] tuning_parm_value : Input tuning parm value of int32_t type, \
+ * sets requested tuning parm.
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_tuning_parm(
+ VL53L1_DEV Dev,
+ VL53L1_TuningParms tuning_parm_key,
+ int32_t tuning_parm_value);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VL53L1_API_CORE_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api_debug.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api_debug.h
new file mode 100644
index 0000000..835e33a
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api_debug.h
@@ -0,0 +1,354 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_api_debug.h
+ *
+ * @brief EwokPlus25 low level API function definitions
+ */
+
+#ifndef _VL53L1_API_DEBUG_H_
+#define _VL53L1_API_DEBUG_H_
+
+#include "vl53l1_platform.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+/* Start Patch_AdditionalDebugData_11823 */
+
+/**
+ * @brief Gets the current LL Driver configuration parameters and the last
+ * set of histogram data for debug
+ *
+ * @param[in] Dev : Device Handle
+ * @param[out] pdata : pointer to VL53L1_additional_data_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_additional_data(
+ VL53L1_DEV Dev,
+ VL53L1_additional_data_t *pdata);
+
+/* End Patch_AdditionalDebugData_11823 */
+
+
+#ifdef VL53L1_LOG_ENABLE
+
+/**
+ * @brief Implements an sprintf function for signed fixed point numbers
+ *
+ * @param[in] fp_value : input signed fixed point number
+ * @param[in] frac_bits : number of fixed point fractional bits
+ * @param[in] buf_size : size of supplied text buffer
+ * @param[out] pbuffer : pointer to text buffer
+ *
+ */
+
+void VL53L1_signed_fixed_point_sprintf(
+ int32_t fp_value,
+ uint8_t frac_bits,
+ uint16_t buf_size,
+ char *pbuffer);
+
+
+/**
+ * @brief Convenience function to print out VL53L1_static_nvm_managed_t for debug
+ *
+ * @param[in] pdata : pointer to VL53L1_static_nvm_managed_t
+ * @param[in] pprefix : pointer to name prefix string
+ * @param[in] trace_flags : logging module enable bit flags
+ */
+
+void VL53L1_print_static_nvm_managed(
+ VL53L1_static_nvm_managed_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags);
+
+
+/**
+ * @brief Convenience function to print out VL53L1_customer_nvm_managed_t for debug
+ *
+ * @param[in] pdata : pointer to VL53L1_customer_nvm_managed_t
+ * @param[in] pprefix : pointer to name prefix string
+ * @param[in] trace_flags : logging module enable bit flags
+ */
+
+void VL53L1_print_customer_nvm_managed(
+ VL53L1_customer_nvm_managed_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags);
+
+
+/**
+ * @brief Convenience function to print out VL53L1_nvm_copy_data_t for debug
+ *
+ * @param[in] pdata : pointer to VL53L1_nvm_copy_data_t
+ * @param[in] pprefix : pointer to name prefix string
+ * @param[in] trace_flags : logging module enable bit flags
+ */
+
+void VL53L1_print_nvm_copy_data(
+ VL53L1_nvm_copy_data_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags);
+
+
+/**
+ * @brief Convenience function to print out the contents of
+ * the Range Results structure for debug
+ *
+ * @param[in] pdata : pointer to a VL53L1_range_results_t structure
+ * @param[in] pprefix : pointer to name prefix string
+ * @param[in] trace_flags : logging module enable bit flags
+ */
+
+void VL53L1_print_range_results(
+ VL53L1_range_results_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags);
+
+/**
+ * @brief Convenience function to print out the contents of
+ * the Range Data structure for debug
+ *
+ * @param[in] pdata : pointer to a VL53L1_range_data_t structure
+ * @param[in] pprefix : pointer to name prefix string
+ * @param[in] trace_flags : logging module enable bit flags
+ */
+
+void VL53L1_print_range_data(
+ VL53L1_range_data_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags);
+
+/**
+ * @brief Convenience function to print out the contents of
+ * the offset range results structure for debug
+ *
+ * @param[in] pdata : pointer to a VL53L1_offset_range_results_t structure
+ * @param[in] pprefix : pointer to name prefix string
+ * @param[in] trace_flags : logging module enable bit flags
+ */
+
+void VL53L1_print_offset_range_results(
+ VL53L1_offset_range_results_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags);
+
+/**
+ * @brief Convenience function to print out the contents of
+ * the offset range data structure for debug
+ *
+ * @param[in] pdata : pointer to a VL53L1_offset_range_data_t structure
+ * @param[in] pprefix : pointer to name prefix string
+ * @param[in] trace_flags : logging module enable bit flags
+ */
+
+void VL53L1_print_offset_range_data(
+ VL53L1_offset_range_data_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags);
+
+
+/**
+ * @brief Convenience function to print out the contents of
+ * the peak rate map calibration data structure
+ *
+ * @param[in] pdata : pointer to a VL53L1_cal_peak_rate_map_t structure
+ * @param[in] pprefix : pointer to name prefix string
+ * @param[in] trace_flags : logging module enable bit flags
+ */
+
+void VL53L1_print_cal_peak_rate_map(
+ VL53L1_cal_peak_rate_map_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags);
+
+
+/**
+ * @brief Convenience function to print out the contents of
+ * the additional offset calibration data structure
+ *
+ * @param[in] pdata : pointer to a VL53L1_additional_offset_cal_data_t structure
+ * @param[in] pprefix : pointer to name prefix string
+ * @param[in] trace_flags : logging module enable bit flags
+ */
+
+void VL53L1_print_additional_offset_cal_data(
+ VL53L1_additional_offset_cal_data_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags);
+
+/**
+ * @brief Convenience function to print out the contents of
+ * the additional data structure
+ *
+ * @param[in] pdata : pointer to a VL53L1_additional_data_t structure
+ * @param[in] pprefix : pointer to name prefix string
+ * @param[in] trace_flags : logging module enable bit flags
+ */
+
+void VL53L1_print_additional_data(
+ VL53L1_additional_data_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags);
+
+
+/**
+ * @brief Convenience function to print out the contents of
+ * the LL driver gain calibration data structure
+ *
+ * @param[in] pdata : pointer to a VL53L1_gain_calibration_data_t structure
+ * @param[in] pprefix : pointer to name prefix string
+ * @param[in] trace_flags : logging module enable bit flags
+ */
+
+void VL53L1_print_gain_calibration_data(
+ VL53L1_gain_calibration_data_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags);
+
+
+/**
+ * @brief Convenience function to print out the contents of
+ * the xtalk configuration data for debug
+ *
+ * @param[in] pdata : pointer to a VL53L1_xtalk_config_t Structure
+ * @param[in] pprefix : pointer to name prefix string
+ * @param[in] trace_flags : logging module enable bit flags
+ */
+
+void VL53L1_print_xtalk_config(
+ VL53L1_xtalk_config_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags);
+
+/**
+ * @brief Convenience function to print out the contents of
+ * the Optical Centre structure for debug
+ *
+ * @param[in] pdata : pointer to a VL53L1_optical_centre_t structure
+ * @param[in] pprefix : pointer to name prefix string
+ * @param[in] trace_flags : logging module enable bit flags
+ */
+
+void VL53L1_print_optical_centre(
+ VL53L1_optical_centre_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags);
+
+
+/**
+ * @brief Convenience function to print out the contents of
+ * the User Zone (ROI) structure for debug
+ *
+ * @param[in] pdata : pointer to a VL53L1_user_zone_t structure
+ * @param[in] pprefix : pointer to name prefix string
+ * @param[in] trace_flags : logging module enable bit flags
+ */
+
+void VL53L1_print_user_zone(
+ VL53L1_user_zone_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags);
+
+/**
+ * @brief Convenience function for printing out VL53L1_spad_rate_data_t
+ *
+ * @param[in] pspad_rates : pointer to VL53L1_spad_rate_data_t
+ * @param[in] pprefix : pointer to name prefix string
+ * @param[in] trace_flags : logging module enable bit flags
+ */
+
+void VL53L1_print_spad_rate_data(
+ VL53L1_spad_rate_data_t *pspad_rates,
+ char *pprefix,
+ uint32_t trace_flags);
+
+
+/**
+ * @brief Convenience function for printing out VL53L1_spad_rate_map_t
+ *
+ * @param[in] pspad_rates : pointer to VL53L1_spad_rate_map_t
+ * @param[in] pprefix : pointer to name prefix string
+ * @param[in] trace_flags : logging module enable bit flags
+ */
+
+void VL53L1_print_spad_rate_map(
+ VL53L1_spad_rate_data_t *pspad_rates,
+ char *pprefix,
+ uint32_t trace_flags);
+
+
+#endif /* VL53L1_LOG_ENABLE */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VL53L1_API_DEBUG_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api_preset_modes.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api_preset_modes.h
new file mode 100644
index 0000000..f140b0c
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api_preset_modes.h
@@ -0,0 +1,471 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_api_preset_modes.h
+ *
+ * @brief EwokPlus25 API core function definition
+ */
+
+#ifndef _VL53L1_API_PRESET_MODES_H_
+#define _VL53L1_API_PRESET_MODES_H_
+
+#include "vl53l1_ll_def.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @brief Initializes Ref SPAD Char Configuration Parameters
+ *
+ * @param[out] pdata : pointer to VL53L1_refspadchar_config_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_init_refspadchar_config_struct(
+ VL53L1_refspadchar_config_t *pdata);
+#endif
+
+
+/**
+ * @brief Initializes SPAD Self Check (SSC) Configuration Parameters
+ *
+ * @param[out] pdata : pointer to VL53L1_ssc_config_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_init_ssc_config_struct(
+ VL53L1_ssc_config_t *pdata);
+
+/**
+ * @brief Initializes Xtalk Configuration Parameters
+ *
+ * @param[in] pnvm : pointer to VL53L1_customer_nvm_managed_t data structure
+ * @param[out] pdata : pointer to VL53L1_xtalk_config_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_init_xtalk_config_struct(
+ VL53L1_customer_nvm_managed_t *pnvm,
+ VL53L1_xtalk_config_t *pdata);
+
+/**
+ * @brief Initializes Offset Calibration Configuration Parameters
+ *
+ * @param[out] pdata : pointer to VL53L1_offsetcal_config_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_init_offset_cal_config_struct(
+ VL53L1_offsetcal_config_t *pdata);
+#endif
+
+
+/**
+ * @brief Initializes Tuning Parameter Storage Values
+ *
+ * @param[out] pdata : pointer to VL53L1_tuning_parm_storage_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_init_tuning_parm_storage_struct(
+ VL53L1_tuning_parm_storage_t *pdata);
+
+/**
+ * @brief Initializes static and dynamic configuration settings for
+ * preset mode VL53L1_DEVICEPRESETMODE_STANDARD_RANGING
+ *
+ * @param[out] pstatic : pointer to VL53L1_static_config_t data structure
+ * @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
+ * @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
+ * @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
+ * @param[out] psystem : pointer to VL53L1_system_control_t data structure
+ * @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_preset_mode_standard_ranging(
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms);
+
+/**
+ * @brief Initializes static and dynamic configuration settings for
+ * preset mode VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_SHORT_RANGE
+ *
+ * @param[out] pstatic : pointer to VL53L1_static_config_t data structure
+ * @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
+ * @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
+ * @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
+ * @param[out] psystem : pointer to VL53L1_system_control_t data structure
+ * @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_preset_mode_standard_ranging_short_range(
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms);
+
+
+/**
+ * @brief Initializes static and dynamic configuration settings for
+ * preset mode VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_LONG_RANGE
+ *
+ * @param[out] pstatic : pointer to VL53L1_static_config_t data structure
+ * @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
+ * @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
+ * @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
+ * @param[out] psystem : pointer to VL53L1_system_control_t data structure
+ * @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_preset_mode_standard_ranging_long_range(
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms);
+
+/**
+ * @brief Initializes static and dynamic configuration settings for
+ * preset mode VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM1_CAL
+ *
+ * @param[out] pstatic : pointer to VL53L1_static_config_t data structure
+ * @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
+ * @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
+ * @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
+ * @param[out] psystem : pointer to VL53L1_system_control_t data structure
+ * @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_preset_mode_standard_ranging_mm1_cal(
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms);
+#endif
+
+
+/**
+ * @brief Initializes static and dynamic configuration settings for
+ * preset mode VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM2_CAL
+ *
+ * @param[out] pstatic : pointer to VL53L1_static_config_t data structure
+ * @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
+ * @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
+ * @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
+ * @param[out] psystem : pointer to VL53L1_system_control_t data structure
+ * @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_preset_mode_standard_ranging_mm2_cal(
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms);
+#endif
+
+
+/**
+ * @brief Initializes static and dynamic configuration settings for
+ * preset mode VL53L1_DEVICEPRESETMODE_TIMED_RANGING
+ *
+ * @param[out] pstatic : pointer to VL53L1_static_config_t data structure
+ * @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
+ * @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
+ * @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
+ * @param[out] psystem : pointer to VL53L1_system_control_t data structure
+ * @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_preset_mode_timed_ranging(
+
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms);
+
+/**
+ * @brief Initializes static and dynamic configuration settings for
+ * preset mode VL53L1_DEVICEPRESETMODE_TIMED_RANGING_SHORT_RANGE
+ *
+ * @param[out] pstatic : pointer to VL53L1_static_config_t data structure
+ * @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
+ * @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
+ * @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
+ * @param[out] psystem : pointer to VL53L1_system_control_t data structure
+ * @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_preset_mode_timed_ranging_short_range(
+
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms);
+
+/**
+ * @brief Initializes static and dynamic configuration settings for
+ * preset mode VL53L1_DEVICEPRESETMODE_TIMED_RANGING_LONG_RANGE
+ *
+ * @param[out] pstatic : pointer to VL53L1_static_config_t data structure
+ * @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
+ * @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
+ * @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
+ * @param[out] psystem : pointer to VL53L1_system_control_t data structure
+ * @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_preset_mode_timed_ranging_long_range(
+
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms);
+
+/**
+ * @brief Initializes static and dynamic configuration settings for
+ * preset mode VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_MEDIUM_RANGE
+ *
+ * @param[out] pstatic : pointer to VL53L1_static_config_t data structure
+ * @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
+ * @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
+ * @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
+ * @param[out] psystem : pointer to VL53L1_system_control_t data structure
+ * @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
+ * @param[out] plpadata : pointer to VL53L1_low_power_auto_data_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_preset_mode_low_power_auto_ranging(
+
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms,
+ VL53L1_low_power_auto_data_t *plpadata);
+
+/**
+ * @brief Initializes static and dynamic configuration settings for
+ * preset mode VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_SHORT_RANGE
+ *
+ * @param[out] pstatic : pointer to VL53L1_static_config_t data structure
+ * @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
+ * @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
+ * @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
+ * @param[out] psystem : pointer to VL53L1_system_control_t data structure
+ * @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
+ * @param[out] plpadata : pointer to VL53L1_low_power_auto_data_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_preset_mode_low_power_auto_short_ranging(
+
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms,
+ VL53L1_low_power_auto_data_t *plpadata);
+
+/**
+ * @brief Initializes static and dynamic configuration settings for
+ * preset mode VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_LONG_RANGE
+ *
+ * @param[out] pstatic : pointer to VL53L1_static_config_t data structure
+ * @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
+ * @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
+ * @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
+ * @param[out] psystem : pointer to VL53L1_system_control_t data structure
+ * @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
+ * @param[out] plpadata : pointer to VL53L1_low_power_auto_data_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_preset_mode_low_power_auto_long_ranging(
+
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms,
+ VL53L1_low_power_auto_data_t *plpadata);
+
+
+/**
+ * @brief Initializes static and dynamic configuration settings for
+ * preset mode VL53L1_DEVICEPRESETMODE_OLT
+ *
+ * @param[out] pstatic : pointer to VL53L1_static_config_t data structure
+ * @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
+ * @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
+ * @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
+ * @param[out] psystem : pointer to VL53L1_system_control_t data structure
+ * @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_preset_mode_olt(
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms);
+
+/**
+ * @brief Initializes static and dynamic configuration settings for
+ * preset mode VL53L1_DEVICEPRESETMODE_SINGLESHOT_RANGING
+ *
+ * @param[out] pstatic : pointer to VL53L1_static_config_t data structure
+ * @param[out] pgeneral : pointer to VL53L1_general_config_t data structure
+ * @param[out] ptiming : pointer to VL53L1_timing_config_t data structure
+ * @param[out] pdynamic : pointer to VL53L1_dynamic_config_t data structure
+ * @param[out] psystem : pointer to VL53L1_system_control_t data structure
+ * @param[out] ptuning_parms : pointer to VL53L1_tuning_parms_storage_t structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_preset_mode_singleshot_ranging(
+
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VL53L1_API_CORE_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api_strings.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api_strings.h
new file mode 100644
index 0000000..d771e05
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_api_strings.h
@@ -0,0 +1,211 @@
+
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_api_strings.h
+ * @brief VL53L1 API function declarations for decoding error codes to a
+ * text strings
+ */
+
+
+#ifndef VL53L1_API_STRINGS_H_
+#define VL53L1_API_STRINGS_H_
+
+#include "vl53l1_def.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+/**
+ * @brief Generates a string for the input device range status code
+ *
+ * @param[in] RangeStatus : Device Range AStatus Code
+ * @param[out] pRangeStatusString : pointer to character buffer
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_range_status_string(
+ uint8_t RangeStatus,
+ char *pRangeStatusString);
+
+/**
+ * @brief Generates an error string for the input PAL error code
+ *
+ * @param[in] PalErrorCode : PAL Error Code
+ * @param[out] pPalErrorString : pointer to character buffer
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_pal_error_string(
+ VL53L1_Error PalErrorCode,
+ char *pPalErrorString);
+
+/**
+ * @brief Generates a string for the input PAL State code
+ *
+ * @param[in] PalStateCode : PAL State Code
+ * @param[out] pPalStateString : pointer to character buffer
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_pal_state_string(
+ VL53L1_State PalStateCode,
+ char *pPalStateString);
+
+
+/**
+ * @brief Generates a string for the sequence step Id
+ *
+ * @param[in] SequenceStepId : Sequence Step Id
+ * @param[out] pSequenceStepsString : pointer to character buffer
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_get_sequence_steps_info(
+ VL53L1_SequenceStepId SequenceStepId,
+ char *pSequenceStepsString);
+
+/**
+ * @brief Generates a string for the limit check Id
+ *
+ * @param[in] LimitCheckId : Limit check Id
+ * @param[out] pLimitCheckString : pointer to character buffer
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_get_limit_check_info(uint16_t LimitCheckId,
+ char *pLimitCheckString);
+
+#ifndef VL53L1_USE_EMPTY_STRING
+ #define VL53L1_STRING_DEVICE_INFO_NAME0 "VL53L1 cut1.0"
+ #define VL53L1_STRING_DEVICE_INFO_NAME1 "VL53L1 cut1.1"
+ #define VL53L1_STRING_DEVICE_INFO_TYPE "VL53L1"
+
+ /* Range Status */
+ #define VL53L1_STRING_RANGESTATUS_NONE "No Update"
+ #define VL53L1_STRING_RANGESTATUS_RANGEVALID "Range Valid"
+ #define VL53L1_STRING_RANGESTATUS_SIGMA "Sigma Fail"
+ #define VL53L1_STRING_RANGESTATUS_SIGNAL "Signal Fail"
+ #define VL53L1_STRING_RANGESTATUS_MINRANGE "Min Range Fail"
+ #define VL53L1_STRING_RANGESTATUS_PHASE "Phase Fail"
+ #define VL53L1_STRING_RANGESTATUS_HW "Hardware Fail"
+
+
+ /* Range Status */
+ #define VL53L1_STRING_STATE_POWERDOWN "POWERDOWN State"
+ #define VL53L1_STRING_STATE_WAIT_STATICINIT \
+ "Wait for staticinit State"
+ #define VL53L1_STRING_STATE_STANDBY "STANDBY State"
+ #define VL53L1_STRING_STATE_IDLE "IDLE State"
+ #define VL53L1_STRING_STATE_RUNNING "RUNNING State"
+ #define VL53L1_STRING_STATE_RESET "RESET State"
+ #define VL53L1_STRING_STATE_UNKNOWN "UNKNOWN State"
+ #define VL53L1_STRING_STATE_ERROR "ERROR State"
+
+
+
+ /* Check Enable */
+ #define VL53L1_STRING_CHECKENABLE_SIGMA_FINAL_RANGE \
+ "SIGMA FINAL RANGE"
+ #define VL53L1_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE \
+ "SIGNAL RATE FINAL RANGE"
+ #define VL53L1_STRING_CHECKENABLE_SIGNAL_MIN_CLIP \
+ "SIGNAL MIN CLIP"
+ #define VL53L1_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD \
+ "RANGE IGNORE THRESHOLD"
+ #define VL53L1_STRING_CHECKENABLE_RANGE_PHASE_HIGH \
+ "RANGE PHASE HIGH"
+ #define VL53L1_STRING_CHECKENABLE_RANGE_PHASE_LOW \
+ "RANGE PHASE LOW"
+ #define VL53L1_STRING_CHECKENABLE_RANGE_PHASE_CONSISTENCY \
+ "RANGE PHASE CONSISTENCY"
+
+ /* Sequence Step */
+ #define VL53L1_STRING_SEQUENCESTEP_VHV "VHV"
+ #define VL53L1_STRING_SEQUENCESTEP_PHASECAL "PHASE CAL"
+ #define VL53L1_STRING_SEQUENCESTEP_REFPHASE "REF PHASE"
+ #define VL53L1_STRING_SEQUENCESTEP_DSS1 "DSS1"
+ #define VL53L1_STRING_SEQUENCESTEP_DSS2 "DSS2"
+ #define VL53L1_STRING_SEQUENCESTEP_MM1 "MM1"
+ #define VL53L1_STRING_SEQUENCESTEP_MM2 "MM2"
+ #define VL53L1_STRING_SEQUENCESTEP_RANGE "RANGE"
+#endif /* VL53L1_USE_EMPTY_STRING */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_core.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_core.h
new file mode 100644
index 0000000..5cde433
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_core.h
@@ -0,0 +1,1090 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_core.h
+ *
+ * @brief EwokPlus25 core function definitions
+ */
+
+#ifndef _VL53L1_CORE_H_
+#define _VL53L1_CORE_H_
+
+#include "vl53l1_platform.h"
+#include "vl53l1_core_support.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @brief Initialise version info in pdev
+ *
+ * @param[out] Dev : Device handle
+ */
+
+void VL53L1_init_version(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Initialise LL Driver State
+ *
+ * @param[out] Dev : Device handle
+ * @param[in] ll_state : Device state
+ */
+
+void VL53L1_init_ll_driver_state(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceState ll_state);
+
+
+/**
+ * @brief Update LL Driver Read State
+ *
+ * @param[out] Dev : Device handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_update_ll_driver_rd_state(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Checks if the LL Driver Read state and expected stream count
+ * matches the state and stream count received from the device
+ *
+ * @param[out] Dev : Device handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_check_ll_driver_rd_state(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Update LL Driver Configuration State
+ *
+ * @param[out] Dev : Device handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_update_ll_driver_cfg_state(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Convenience function to copy return SPAD enables to buffer
+ *
+ * @param[in ] pdata : pointer to VL53L1_nvm_copy_data_t
+ * @param[out] pbuffer : pointer to buffer
+ */
+
+void VL53L1_copy_rtn_good_spads_to_buffer(
+ VL53L1_nvm_copy_data_t *pdata,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Initialise system results structure to all ones
+ *
+ * This mimics what the device firmware does the the results registers
+ * at the start of each range
+ *
+ * @param[out] pdata : pointer to VL53L1_system_results_t
+ */
+
+void VL53L1_init_system_results(
+ VL53L1_system_results_t *pdata);
+
+
+/**
+ * @brief Initialise zone dynamic config DSS control values
+ *
+ * @param[in] Dev : Device handler
+ */
+
+void V53L1_init_zone_dss_configs(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Encodes a uint16_t register value into an I2C write buffer
+ *
+ * The register is encoded MS byte first is the buffer i.e as per the device register map
+ *
+ * @param[in] ip_value : input uint16_t value
+ * @param[in] count : register size of in bytes (1, 2, 3 or 4)
+ * @param[out] pbuffer : uint8_t pointer to the I2C write buffer
+ */
+
+void VL53L1_i2c_encode_uint16_t(
+ uint16_t ip_value,
+ uint16_t count,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes a uint16_t register value from an I2C read buffer
+ *
+ * The I2C read buffer is assumed to be MS byte first i.e. matching the device register map
+ *
+ * @param[in] count : register size of in bytes (1, 2, 3 or 4)
+ * @param[in] pbuffer : uint8_t pointer to the I2C read buffer
+ *
+ * @return value : decoded uint16_t value
+ */
+
+uint16_t VL53L1_i2c_decode_uint16_t(
+ uint16_t count,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Encodes a int16_t register value into an I2C write buffer
+ *
+ * The register is encoded MS byte first is the buffer i.e as per the device register map
+ *
+ * @param[in] ip_value : input int16_t value
+ * @param[in] count : register size of in bytes (1, 2, 3 or 4)
+ * @param[out] pbuffer : uint8_t pointer to the I2C write buffer
+ */
+
+void VL53L1_i2c_encode_int16_t(
+ int16_t ip_value,
+ uint16_t count,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes a int16_t register value from an I2C read buffer
+ *
+ * The I2C read buffer is assumed to be MS byte first i.e. matching the device register map
+ *
+ * @param[in] count : register size of in bytes (1, 2, 3 or 4)
+ * @param[in] pbuffer : uint8_t pointer to the I2C read buffer
+ *
+ * @return value : decoded int16_t value
+ */
+
+int16_t VL53L1_i2c_decode_int16_t(
+ uint16_t count,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Encodes a uint32_t register value into an I2C write buffer
+ *
+ * The register is encoded MS byte first is the buffer i.e as per the device register map
+ *
+ * @param[in] ip_value : input uint32_t value
+ * @param[in] count : register size of in bytes (1, 2, 3 or 4)
+ * @param[out] pbuffer : uint8_t pointer to the I2C write buffer
+ */
+
+void VL53L1_i2c_encode_uint32_t(
+ uint32_t ip_value,
+ uint16_t count,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes a uint32_t register value from an I2C read buffer
+ *
+ * The I2C read buffer is assumed to be MS byte first i.e. matching the device register map
+ *
+ * @param[in] count : register size of in bytes (1, 2, 3 or 4)
+ * @param[in] pbuffer : uint8_t pointer to the I2C read buffer
+ *
+ * @return value : decoded uint32_t value
+ */
+
+uint32_t VL53L1_i2c_decode_uint32_t(
+ uint16_t count,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes an integer register value from an I2C read buffer
+ *
+ * The I2C read buffer is assumed to be MS byte first i.e. matching the device register map
+ *
+ * @param[in] count : integer size of in bytes (1, 2, 3 or 4)
+ * @param[in] pbuffer : uint8_t pointer to the I2C read buffer
+ * @param[in] bit_mask : bit mask to apply
+ * @param[in] down_shift : down shift to apply
+ * @param[in] offset : offset to apply after the down shift
+ *
+ * @return value : decoded integer value
+ */
+
+uint32_t VL53L1_i2c_decode_with_mask(
+ uint16_t count,
+ uint8_t *pbuffer,
+ uint32_t bit_mask,
+ uint32_t down_shift,
+ uint32_t offset);
+
+
+/**
+ * @brief Encodes a int32_t register value into an I2C write buffer
+ *
+ * The register is encoded MS byte first is the buffer i.e as per the device register map
+ *
+ * @param[in] ip_value : input int32_t value
+ * @param[in] count : register size of in bytes (1, 2, 3 or 4)
+ * @param[out] pbuffer : uint8_t pointer to the I2C write buffer
+ */
+
+void VL53L1_i2c_encode_int32_t(
+ int32_t ip_value,
+ uint16_t count,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes a int32_t register value from an I2C read buffer
+ *
+ * The I2C read buffer is assumed to be MS byte first i.e. matching the device register map
+ *
+ * @param[in] count : register size of in bytes (1, 2, 3 or 4)
+ * @param[in] pbuffer : uint8_t pointer to the I2C read buffer
+ *
+ * @return value : decoded int32_t value
+ */
+
+int32_t VL53L1_i2c_decode_int32_t(
+ uint16_t count,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Triggers the start of the provided test_mode.
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] test_mode__ctrl : VL53L1_TEST_MODE__CTRL register value
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_start_test(
+ VL53L1_DEV Dev,
+ uint8_t test_mode__ctrl);
+#endif
+
+
+/**
+ * @brief Set firmware enable register
+ *
+ * Wrapper for setting power force register state
+ * Also updates pdev->sys_ctrl.firmware__enable
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] value : register value
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_firmware_enable_register(
+ VL53L1_DEV Dev,
+ uint8_t value);
+
+
+/**
+ * @brief Enables MCU firmware
+ *
+ * @param[in] Dev : Device handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_enable_firmware(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Disables MCU firmware
+ *
+ * This required to write to MCU G02, G01 registers and access the patch RAM
+ *
+ * @param[in] Dev : Device handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_disable_firmware(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Set power force register
+ *
+ * Wrapper for setting power force register state
+ * Also updates pdev->sys_ctrl.power_management__go1_power_force
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] value : register value
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_powerforce_register(
+ VL53L1_DEV Dev,
+ uint8_t value);
+
+
+/**
+ * @brief Enables power force
+ *
+ * This prevents the G01 and patch RAM from powering down between
+ * ranges to enable reading of G01 and patch RAM data
+ *
+ * Calls VL53L1_set_powerforce_register()
+ *
+ * @param[in] Dev : Device handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+
+VL53L1_Error VL53L1_enable_powerforce(
+ VL53L1_DEV Dev);
+
+/**
+ * @brief Disables power force
+ *
+ * @param[in] Dev : Device handle
+ *
+ * Disable power force
+ *
+ * Calls VL53L1_set_powerforce_register()
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_disable_powerforce(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Clears Ranging Interrupt
+ *
+ * @param[in] Dev : Device handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+
+VL53L1_Error VL53L1_clear_interrupt(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Forces shadow stream count to zero
+ *
+ * @param[in] Dev : Device handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_force_shadow_stream_count_to_zero(
+ VL53L1_DEV Dev);
+#endif
+
+/**
+ * @brief Calculates the macro period in [us] for the input
+ * fast_osc_frequency and VCSEL period register value
+ *
+ * Processing steps:
+ *
+ * 1. PLL period from fast_osc_frequency
+ * 2. VCSEL period
+ * 3. Macro period
+ *
+ * @param[in] fast_osc_frequency : fast oscillator frequency in 4.12 MHz format
+ * @param[in] vcsel_period : VCSEL period register value
+ *
+ * @return macro_period_us : macro period in [us] 12.12 format
+ */
+
+uint32_t VL53L1_calc_macro_period_us(
+ uint16_t fast_osc_frequency,
+ uint8_t vcsel_period);
+
+
+/**
+ * @brief Calculates the Xtalk Range Ignore Threshold
+ * rate per spad in 3.13Mcps
+ *
+ * This is done by calculating the worst case xtalk seen on the array
+ * and applying a user specified fractional multiplier.
+ *
+ * @param[in] central_rate : xtalk central rate in 9.9u Kcps format
+ * @param[in] x_gradient : xtalk xgradient rate in 4.11s Kcps format
+ * @param[in] y_gradient : xtalk ygradient rate in 4.11s Kcps format
+ * @param[in] rate_mult : rate multiplier in 2.5 fractional format
+ *
+ * @return range_ignore_threshold_kcps : rate per spad in mcps 3.13
+ */
+
+uint16_t VL53L1_calc_range_ignore_threshold(
+ uint32_t central_rate,
+ int16_t x_gradient,
+ int16_t y_gradient,
+ uint8_t rate_mult);
+
+
+/**
+ * @brief Calculates the timeout value in macro period based on the input
+ * timeout period in milliseconds and the macro period in us
+ *
+ * @param[in] timeout_us : timeout period in microseconds
+ * @param[in] macro_period_us : macro period in microseconds 12.12
+ *
+ * @return timeout_mclks : timeout in macro periods
+ */
+
+uint32_t VL53L1_calc_timeout_mclks(
+ uint32_t timeout_us,
+ uint32_t macro_period_us);
+
+/**
+ * @brief Calculates the encoded timeout register value based on the input
+ * timeout period in milliseconds and the macro period in us
+ *
+ * @param[in] timeout_us : timeout period in microseconds
+ * @param[in] macro_period_us : macro period in microseconds 12.12
+ *
+ * @return timeout_encoded : encoded timeout register value
+ */
+
+uint16_t VL53L1_calc_encoded_timeout(
+ uint32_t timeout_us,
+ uint32_t macro_period_us);
+
+
+/**
+ * @brief Calculates the timeout in us based on the input
+ * timeout im macro periods value and the macro period in us
+ *
+ * @param[in] timeout_mclks : timeout im macro periods
+ * @param[in] macro_period_us : macro period in microseconds 12.12
+ *
+ * @return timeout_us : encoded timeout register value
+ */
+
+uint32_t VL53L1_calc_timeout_us(
+ uint32_t timeout_mclks,
+ uint32_t macro_period_us);
+
+/**
+ * @brief Calculates the decoded timeout in us based on the input
+ * encoded timeout register value and the macro period in us
+ *
+ * @param[in] timeout_encoded : encoded timeout register value
+ * @param[in] macro_period_us : macro period in microseconds 12.12
+ *
+ * @return timeout_us : encoded timeout register value
+ */
+
+uint32_t VL53L1_calc_decoded_timeout_us(
+ uint16_t timeout_encoded,
+ uint32_t macro_period_us);
+
+
+/**
+ * @brief Encode timeout in (LSByte * 2^MSByte) + 1 register format.
+ *
+ * @param[in] timeout_mclks : uint32_t timeout value (macro periods)
+ *
+ * @return encoded_timeout : 16-bit encoded value
+ */
+
+uint16_t VL53L1_encode_timeout(
+ uint32_t timeout_mclks);
+
+
+/**
+ * @brief Decode 16-bit timeout register value.
+ *
+ * @param[in] encoded_timeout : 16-bit timeout register value
+ *
+ * @return timeout_macro_clks : uint32_t decoded value
+ *
+ */
+
+uint32_t VL53L1_decode_timeout(
+ uint16_t encoded_timeout);
+
+
+/**
+ * @brief Converts the input MM and range timeouts in [us]
+ * into the appropriate register values
+ *
+ * Must also be run after the VCSEL period settings are changed
+ *
+ * @param[in] phasecal_config_timeout_us : requested Phase Cal Timeout e.g. 1000us
+ * @param[in] mm_config_timeout_us : requested MM Timeout e.g. 2000us
+ * @param[in] range_config_timeout_us : requested Ranging Timeout e.g 10000us
+ * @param[in] fast_osc_frequency : fast oscillator frequency in 4.12 MHz format
+ * @param[out] pgeneral : general data struct
+ * @param[out] ptiming : timing data struct with input vcsel period data
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_calc_timeout_register_values(
+ uint32_t phasecal_config_timeout_us,
+ uint32_t mm_config_timeout_us,
+ uint32_t range_config_timeout_us,
+ uint16_t fast_osc_frequency,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming);
+
+
+/**
+ * @brief Encodes the real period in PLL clocks into the register value
+ *
+ * @param[in] vcsel_period_pclks : 8-bit value
+ *
+ * @return vcsel_period_reg : 8-bit encoded value
+ *
+ */
+
+uint8_t VL53L1_encode_vcsel_period(
+ uint8_t vcsel_period_pclks);
+
+
+/**
+ * @brief Decodes an unsigned integer from a uint8_t buffer 16-bit, 24-bit or 32-bit integers.
+ *
+ * Assumes MS Byte first
+ *
+ * @param[in] pbuffer : pointer to start of integer uint8_t data
+ * @param[in] no_of_bytes : size of integer in bytes
+ *
+ * @return decoded_value : decoded integer value
+ *
+ */
+
+uint32_t VL53L1_decode_unsigned_integer(
+ uint8_t *pbuffer,
+ uint8_t no_of_bytes);
+
+
+/**
+ * @brief Encodes an unsigned integer into a uint8_t buffer MS byte first
+ *
+ * @param[in] ip_value : input unsigned integer
+ * @param[in] no_of_bytes : size of integer storage in bytes
+ * @param[out] pbuffer : pointer to output buffer
+ *
+ */
+
+void VL53L1_encode_unsigned_integer(
+ uint32_t ip_value,
+ uint8_t no_of_bytes,
+ uint8_t *pbuffer);
+
+/**
+ * @brief Get the SPAD number, byte index (0-31) and bit index (0-7) for
+ *
+ * Takes the map index (0 - 255) and calculated the SPAD number, byte index
+ * within the SPAD enable byte array and but position within the SPAD enable
+ * byte
+ *
+ *
+ * @param[in] spad_number : spad number
+ * @param[out] pbyte_index : pointer to output 0-31 byte index for SPAD enables
+ * @param[out] pbit_index : pointer to output 0-7 bit index
+ * @param[out] pbit_mask : pointer to output bit mask for the byte
+ *
+ */
+
+void VL53L1_spad_number_to_byte_bit_index(
+ uint8_t spad_number,
+ uint8_t *pbyte_index,
+ uint8_t *pbit_index,
+ uint8_t *pbit_mask);
+
+
+/**
+ * @brief Encodes a (col,row) coord value into ByteIndex.BitIndex format
+ *
+ *
+ * @param[in] row : Row
+ * @param[in] col : Column
+ * @param[out] pspad_number : Encoded Coord in Byte.Bit format
+ *
+ */
+
+void VL53L1_encode_row_col(
+ uint8_t row,
+ uint8_t col,
+ uint8_t *pspad_number);
+
+
+/**
+ * @brief Decodes encoded zone size format into width and height values
+ *
+ * @param[in] encoded_xy_size : Encoded zone size
+ * @param[out] pwidth : Decoded zone width
+ * @param[out] pheight : Decoded zone height
+ *
+ */
+
+void VL53L1_decode_zone_size(
+ uint8_t encoded_xy_size,
+ uint8_t *pwidth,
+ uint8_t *pheight);
+
+
+/**
+ * @brief Encodes a zone width & height into encoded size format
+ *
+ * @param[in] width : Zone Width
+ * @param[in] height : Zone height
+ * @param[out] pencoded_xy_size : Encoded zone size
+ *
+ */
+
+void VL53L1_encode_zone_size(
+ uint8_t width,
+ uint8_t height,
+ uint8_t *pencoded_xy_size);
+
+
+/**
+ * @brief Decodes encoded zone info into min/max limits
+ *
+ * Note both the lower left and upper right coordinated lie within
+ * the zone (inclusive)
+ *
+ * @param[in] encoded_xy_centre : Encoded zone centre (spad number)
+ * @param[in] encoded_xy_size : Encoded zone size
+ * @param[out] px_ll : Decoded zone lower left x coord
+ * @param[out] py_ll : Decoded zone lower left y coord
+ * @param[out] px_ur : Decoded zone upper right x coord
+ * @param[out] py_ur : Decoded zone upper right y coord
+ */
+
+void VL53L1_decode_zone_limits(
+ uint8_t encoded_xy_centre,
+ uint8_t encoded_xy_size,
+ int16_t *px_ll,
+ int16_t *py_ll,
+ int16_t *px_ur,
+ int16_t *py_ur);
+
+
+/**
+ * @brief Returns > 0 if input (row,col) location is an apertured SPAD
+ *
+ * @param[in] row : Row
+ * @param[in] col : Column
+ *
+ * @return is_aperture : if > 0 the location is an apertured SPAD
+ */
+
+uint8_t VL53L1_is_aperture_location(
+ uint8_t row,
+ uint8_t col);
+
+
+/**
+ * @brief Calculates the effective SPAD counts for the MM inner and outer
+ * regions based on the input MM ROI, Zone info and return good
+ * SPAD map
+ *
+ * @param[in] encoded_mm_roi_centre : Encoded MM ROI centre - spad number
+ * @param[in] encoded_mm_roi_size : Encoded MM ROI size
+ * @param[in] encoded_zone_centre : Encoded Zone centre - spad number
+ * @param[in] encoded_zone_size : Encoded Zone size
+ * @param[in] pgood_spads : Return array good SPAD map (32 bytes)
+ * @param[in] aperture_attenuation : Aperture attenuation value, Format 8.8
+ * @param[out] pmm_inner_effective_spads : MM Inner effective SPADs, Format 8.8
+ * @param[out] pmm_outer_effective_spads : MM Outer effective SPADs, Format 8.8
+ *
+ */
+
+void VL53L1_calc_mm_effective_spads(
+ uint8_t encoded_mm_roi_centre,
+ uint8_t encoded_mm_roi_size,
+ uint8_t encoded_zone_centre,
+ uint8_t encoded_zone_size,
+ uint8_t *pgood_spads,
+ uint16_t aperture_attenuation,
+ uint16_t *pmm_inner_effective_spads,
+ uint16_t *pmm_outer_effective_spads);
+
+/**
+ * @brief Function to save dynamic config data per zone at init and start range
+ *
+ * @param[in] Dev : Pointer to data structure
+ *
+ *
+ * @return VL53L1_ERROR_NONE Success
+ *
+ */
+
+VL53L1_Error VL53L1_save_cfg_data(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Encodes VL53L1_GPIO_interrupt_config_t structure to FW register format
+ *
+ * @param[in] pintconf : pointer to gpio interrupt config structure
+ * @return The encoded system__interrupt_config_gpio byte
+ */
+
+uint8_t VL53L1_encode_GPIO_interrupt_config(
+ VL53L1_GPIO_interrupt_config_t *pintconf);
+
+/**
+ * @brief Decodes FW register to VL53L1_GPIO_interrupt_config_t structure
+ *
+ * @param[in] system__interrupt_config : interrupt config register byte
+ * @return The decoded structure
+ */
+
+VL53L1_GPIO_interrupt_config_t VL53L1_decode_GPIO_interrupt_config(
+ uint8_t system__interrupt_config);
+
+/**
+ * @brief SET GPIO distance threshold
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] threshold_high : High distance threshold in mm
+ * @param[in] threshold_low : Low distance threshold in mm
+ */
+
+VL53L1_Error VL53L1_set_GPIO_distance_threshold(
+ VL53L1_DEV Dev,
+ uint16_t threshold_high,
+ uint16_t threshold_low);
+
+/**
+ * @brief SET GPIO rate threshold
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] threshold_high : High rate threshold in 9.7 Mcps
+ * @param[in] threshold_low : Low rate threshold in 9.7 Mcps
+ */
+
+VL53L1_Error VL53L1_set_GPIO_rate_threshold(
+ VL53L1_DEV Dev,
+ uint16_t threshold_high,
+ uint16_t threshold_low);
+
+/**
+ * @brief SET GPIO thresholds from structure. Sets both rate and distance
+ * thresholds
+ *
+ * @param[in] Dev : Device Handle
+ * @param[in] pintconf : Pointer to structure
+ */
+
+VL53L1_Error VL53L1_set_GPIO_thresholds_from_struct(
+ VL53L1_DEV Dev,
+ VL53L1_GPIO_interrupt_config_t *pintconf);
+
+
+/**
+ * @brief Set Ref SPAD Characterisation Config
+ *
+ * Initialises the timeout and VCSEL period for the Reference
+ * SPAD Characterisation test mode.
+ *
+ * Register Mapping:
+ *
+ * - timeout -> VL53L1_PHASECAL_CONFIG__TIMEOUT_MACROP
+ * - vcsel_period -> VL53L1_RANGE_CONFIG__VCSEL_PERIOD_A \n
+ * -> VL53L1_SD_CONFIG__WOI_SD0 \n
+ * -> VL53L1_SD_CONFIG__WOI_SD1
+ * - total_rate_target_mcps -> VL53L1_REF_SPAD_CHAR__TOTAL_RATE_TARGET_MCPS
+ * - max_count_rate_rtn_limit_mcps -> VL53L1_RANGE_CONFIG__SIGMA_THRESH
+ * - min_count_rate_rtn_limit_mcps -> VL53L1_SRANGE_CONFIG__SIGMA_THRESH
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] vcsel_period_a : VCSEL period A register value
+ * @param[in] phasecal_timeout_us : requested PhaseCal Timeout in [us]
+ * e.g 1000us
+ * @param[in] total_rate_target_mcps : Target reference rate [Mcps] 9.7 format
+ * @param[in] max_count_rate_rtn_limit_mcps : Max rate final check limit [Mcps] 9.7 format
+ * @param[in] min_count_rate_rtn_limit_mcps : Min rate final check limit [Mcps] 9.7 format
+ * @param[in] fast_osc_frequency : Fast Osc Frequency (4.12) format
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_set_ref_spad_char_config(
+ VL53L1_DEV Dev,
+ uint8_t vcsel_period_a,
+ uint32_t phasecal_timeout_us,
+ uint16_t total_rate_target_mcps,
+ uint16_t max_count_rate_rtn_limit_mcps,
+ uint16_t min_count_rate_rtn_limit_mcps,
+ uint16_t fast_osc_frequency);
+#endif
+
+
+/**
+ * @brief Applies SSC (SPAD Self Check) configuration to device.
+ *
+ * Prior to calling this function it is assumed both the Fast Osc
+ * and VCSEL have already been trimmed and the register values set.
+ *
+ * Internally the required timeout in macro periods is calculated
+ * from the input VCSEL period, fast_osc_frequency and requested
+ * timeout in microseconds.
+ *
+ * Register Mapping:
+ *
+ * - rate_select -> VL53L1_NVM_BIST__CTRL
+ * - timeout -> VL53L1_RANGE_CONFIG__TIMEOUT_MACROP_ B_HI & _LO
+ * - vcsel_period -> VL53L1_RANGE_CONFIG__VCSEL_PERIOD_B \n
+ * -> VL53L1_SD_CONFIG__WOI_SD0 \n
+ * -> VL53L1_SD_CONFIG__WOI_SD1
+ * - vcsel_start -> VL53L1_CAL_CONFIG__VCSEL_START
+ * - vcsel_width -> VL53L1_GLOBAL_CONFIG__VCSEL_WIDTH
+ * - ssc_limit_mcps -> VL53L1_RANGE_CONFIG__SIGMA_THRESH
+ *
+ * ssc_rate_limit_mcps format:
+ *
+ * - 1.15 for DCR/LCR test modes with VCSEL off
+ * - 9.7 LCR test mode with VCSEL on
+ *
+ * The configuration is set to the device via a 5-byte multi byte write.
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] pssc_cfg : pointer to VL53L1_ssc_config_t
+ * @param[in] fast_osc_frequency : Fast Osc Frequency (4.12) format
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_set_ssc_config(
+ VL53L1_DEV Dev,
+ VL53L1_ssc_config_t *pssc_cfg,
+ uint16_t fast_osc_frequency);
+#endif
+
+
+/**
+ * @brief Gets the 256 return array SSC rates from the Patch RAM
+ *
+ * Each SSC rate is 1.15 or 9.7 dependent on test run.
+ * Total of 512 bytes to read!
+ *
+ * ssc_rate_mcps buffer format:
+ *
+ * - 1.15 for DCR/LCR test modes with VCSEL off (ambient)
+ * - 9.7 LCR test mode with VCSEL on (which rate?)
+ *
+ * Assumes that power force has already been enabled
+ *
+ * Function disables firmware at start to allow patch RAM to be read
+ * and then enables the firmware before returning
+ *
+ * The order of the rates is in SPAD number order (increasing)
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] pspad_rates : pointer to VL53L1_spad_rate_data_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_get_spad_rate_data(
+ VL53L1_DEV Dev,
+ VL53L1_spad_rate_data_t *pspad_rates);
+#endif
+
+/**
+ * @brief Function to add signed margin to the
+ * xtalk plane offset value, dealing with signed and unsigned
+ * value mixing
+ *
+ * Clips output to 0 if negative
+ * Clips to max possible value of 9.9 Kcps if exceeds this limitation
+ *
+ * @param[in] plane_offset_kcps : xtalk plane offset (9.9 format) Kcps
+ * @param[in] margin_offset_kcps : margin offset signed (6.9 format) Kcps
+ *
+ * @return plane_offset_with_margin in Kcps (7.9 format)
+ */
+
+uint32_t VL53L1_calc_crosstalk_plane_offset_with_margin(
+ uint32_t plane_offset_kcps,
+ int16_t margin_offset_kcps);
+
+/**
+ * @brief Initialize the Low Power Auto data structure
+ *
+ * Patch_LowPowerAutoMode
+ *
+ * @param[in] Dev : Device Handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_low_power_auto_data_init(
+ VL53L1_DEV Dev
+ );
+
+/**
+ * @brief Reset internal state but leave low_power_auto mode intact
+ *
+ * Patch_LowPowerAutoMode
+ *
+ * @param[in] Dev : Device Handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_low_power_auto_data_stop_range(
+ VL53L1_DEV Dev
+ );
+
+/**
+ * @brief Initialize the config strcutures when low power auto preset modes are
+ * selected
+ *
+ * Patch_LowPowerAutoMode
+ *
+ * @param[in] pgeneral : pointer to the general config structure
+ * @param[in] pdynamic : pointer to the dynamic config structure
+ * @param[in] plpadata : pointer to the low power auto config structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_config_low_power_auto_mode(
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_low_power_auto_data_t *plpadata
+ );
+
+/**
+ * @brief Setup ranges after the first one in low power auto mode by turning
+ * off FW calibration steps and programming static values
+ *
+ * Patch_LowPowerAutoMode
+ *
+ * @param[out] Dev : Device handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_low_power_auto_setup_manual_calibration(
+ VL53L1_DEV Dev);
+
+/**
+ * @brief Do a DSS calculation and update manual config
+ *
+ * Patch_LowPowerAutoMode
+ *
+ * @param[out] Dev : Device handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_low_power_auto_update_DSS(
+ VL53L1_DEV Dev);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VL53L1_API_CORE_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_core_support.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_core_support.h
new file mode 100644
index 0000000..8c7893a
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_core_support.h
@@ -0,0 +1,222 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_core_support.h
+ *
+ * @brief EwokPlus25 core function definitions
+ */
+
+#ifndef _VL53L1_CORE_SUPPORT_H_
+#define _VL53L1_CORE_SUPPORT_H_
+
+#include "vl53l1_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @brief Calculates the PLL period in [us] from the input
+ * fast_osc_frequency
+ *
+ * @param[in] fast_osc_frequency : fast oscillator frequency in 4.12 MHz format
+ *
+ * @return pll_period_us : PLL period in [us] 8.24 format
+ */
+
+uint32_t VL53L1_calc_pll_period_us(
+ uint16_t fast_osc_frequency);
+
+
+
+#ifdef PAL_EXTENDED
+/**
+ * @brief Calculates the ranging duration in ns using fixed point maths
+ * *
+ * Uses a temporary uint64_t variable internally
+ *
+ * @param[in] pll_period_us : PLL Period in [us] 0.25 format
+ * @param[in] vcsel_parm_pclks : period, width or WOI window in PLL clocks
+ * in 6.4 format.
+ * @param[in] window_vclks : ranging or ambient window duration in VCSEL clocks
+ * @param[in] periods_elapsed_mclks : elapsed time in macro clocks
+ *
+ * @return duration_us : uint32_t containing the duration time in us
+ */
+
+uint32_t VL53L1_duration_maths(
+ uint32_t pll_period_us,
+ uint32_t vcsel_parm_pclks,
+ uint32_t window_vclks,
+ uint32_t periods_elapsed_mclks);
+
+
+/**
+ * @brief Calculates the square root of the input integer
+ *
+ * Reference : http://en.wikipedia.org/wiki/Methods_of_computing_square_roots
+ *
+ * @param[in] num : input integer
+ *
+ * @return res : square root result
+ */
+
+uint32_t VL53L1_isqrt(
+ uint32_t num);
+
+/**
+ * @brief Calculates the count rate using fixed point maths
+ *
+ * Uses a temporary uint64_t variable internally
+ * Any negative negative rates are clipped to 0.
+ *
+ * @param[in] events : accumulated SPAD events
+ * @param[in] time_us : elapsed time in us
+ *
+ * @return rate_mcps : uint16_t count rate in 9.7 format
+ */
+
+uint16_t VL53L1_rate_maths(
+ int32_t events,
+ uint32_t time_us);
+
+/**
+ * @brief Calculates the Rate per spad
+ *
+ * Uses a temporary uint32_t variable internally
+ * Any output rates larger than 16 bit are clipped to 0xFFFF.
+ *
+ * @param[in] frac_bits : required output fractional precision - 7 \
+ * due to inherent resolution of pk_rate
+ * @param[in] peak_count_rate : peak signal count rate in mcps
+ * @param[in] num_spads : actual effective spads in 8.8
+ * @param[in] max_output_value : User set value to clip output
+ *
+ * @return rate_per_spad : uint16_t count rate in variable fractional format
+ */
+
+uint16_t VL53L1_rate_per_spad_maths(
+ uint32_t frac_bits,
+ uint32_t peak_count_rate,
+ uint16_t num_spads,
+ uint32_t max_output_value);
+
+
+/**
+ * @brief Calculates the range from the phase data
+ *
+ * Uses a temporary int64_t variable internally
+ *
+ * @param[in] fast_osc_frequency : Fast oscillator freq [MHz] 4.12 format
+ * @param[in] phase : phase in 5.11 format
+ * @param[in] zero_distance_phase : zero distance phase in 5.11 format
+ * @param[in] fractional_bits : valid options : 0, 1, 2
+ * @param[in] gain_factor : gain correction factor 1.11 format
+ * @param[in] range_offset_mm : range offset [mm] 14.2 format
+
+ * @return range_mm : signed range in [mm]
+ * format depends on fractional_bits input
+ */
+
+int32_t VL53L1_range_maths(
+ uint16_t fast_osc_frequency,
+ uint16_t phase,
+ uint16_t zero_distance_phase,
+ uint8_t fractional_bits,
+ int32_t gain_factor,
+ int32_t range_offset_mm);
+#endif
+
+
+/**
+ * @brief Decodes VCSEL period register value into the real period in PLL clocks
+ *
+ * @param[in] vcsel_period_reg : 8 -bit register value
+ *
+ * @return vcsel_period_pclks : 8-bit decoded value
+ *
+ */
+
+uint8_t VL53L1_decode_vcsel_period(
+ uint8_t vcsel_period_reg);
+
+/**
+ * @brief Decodes the Byte.Bit coord encoding into an (x,y) coord value
+ *
+ * @param[in] spad_number : Coord location in Byte.Bit format
+ * @param[out] prow : Decoded row
+ * @param[out] pcol : Decoded column
+ *
+ */
+
+void VL53L1_decode_row_col(
+ uint8_t spad_number,
+ uint8_t *prow,
+ uint8_t *pcol);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VL53L1_CORE_SUPPORT_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_def.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_def.h
new file mode 100644
index 0000000..5e87049
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_def.h
@@ -0,0 +1,666 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_def.h
+ *
+ * @brief Type definitions for VL53L1 API.
+ *
+ */
+
+
+#ifndef _VL53L1_DEF_H_
+#define _VL53L1_DEF_H_
+
+#include "vl53l1_ll_def.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @defgroup VL53L1_globaldefine_group VL53L1 Defines
+ * @brief VL53L1 Defines
+ * @{
+ */
+
+
+/** VL53L1 IMPLEMENTATION major version */
+#define VL53L1_IMPLEMENTATION_VER_MAJOR 2
+/** VL53L1 IMPLEMENTATION minor version */
+#define VL53L1_IMPLEMENTATION_VER_MINOR 3
+/** VL53L1 IMPLEMENTATION sub version */
+#define VL53L1_IMPLEMENTATION_VER_SUB 3
+/** VL53L1 IMPLEMENTATION sub version */
+#define VL53L1_IMPLEMENTATION_VER_REVISION 1885
+
+/****************************************
+ * PRIVATE define do not edit
+ ****************************************/
+
+/** @brief Defines the parameters of the Get Version Functions
+ */
+typedef struct {
+ uint32_t revision; /*!< revision number */
+ uint8_t major; /*!< major number */
+ uint8_t minor; /*!< minor number */
+ uint8_t build; /*!< build number */
+} VL53L1_Version_t;
+
+
+#define VL53L1_DEVINFO_STRLEN 32
+
+/** @brief Defines the parameters of the Get Device Info Functions
+ */
+typedef struct {
+ char Name[VL53L1_DEVINFO_STRLEN];
+ /*!< Name of the Device e.g. Left_Distance */
+ char Type[VL53L1_DEVINFO_STRLEN];
+ /*!< Type of the Device e.g VL53L1 */
+ char ProductId[VL53L1_DEVINFO_STRLEN];
+ /*!< Product Identifier String
+ * @warning Not yet implemented
+ */
+ uint8_t ProductType;
+ /*!< Product Type, VL53L1 = 1, VL53L1 = 2*/
+ uint8_t ProductRevisionMajor;
+ /*!< Product revision major */
+ uint8_t ProductRevisionMinor;
+ /*!< Product revision minor */
+} VL53L1_DeviceInfo_t;
+
+
+
+/** @defgroup VL53L1_define_PresetModes_group Defines Preset modes
+ * Defines all possible preset modes for the device
+ * @{
+ */
+typedef uint8_t VL53L1_PresetModes;
+
+#define VL53L1_PRESETMODE_AUTONOMOUS ((VL53L1_PresetModes) 3)
+#define VL53L1_PRESETMODE_LITE_RANGING ((VL53L1_PresetModes) 4)
+#define VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS ((VL53L1_PresetModes) 8)
+
+ /* ... Modes to be added depending on device */
+/** @} VL53L1_define_PresetModes_group */
+
+
+/** @defgroup VL53L1_define_DistanceModes_group Defines Distance modes
+ * Defines all possible Distance modes for the device
+ * @{
+ */
+typedef uint8_t VL53L1_DistanceModes;
+
+#define VL53L1_DISTANCEMODE_SHORT ((VL53L1_DistanceModes) 1)
+#define VL53L1_DISTANCEMODE_MEDIUM ((VL53L1_DistanceModes) 2)
+#define VL53L1_DISTANCEMODE_LONG ((VL53L1_DistanceModes) 3)
+/** @} VL53L1_define_DistanceModes_group */
+
+
+/** @defgroup VL53L1_define_XtalkCal_group Defines Xtalk Calibration modes
+* Defines all possible Offset Calibration modes for the device
+* @{
+*/
+typedef uint8_t VL53L1_XtalkCalibrationModes;
+
+#define VL53L1_XTALKCALIBRATIONMODE_NO_TARGET \
+ ((VL53L1_OffsetCalibrationModes) 0)
+/*!< To perform Xtalk calibration with no target below 80 cm */
+#define VL53L1_XTALKCALIBRATIONMODE_SINGLE_TARGET \
+ ((VL53L1_OffsetCalibrationModes) 1)
+/*!< To perform Xtalk calibration with one target */
+#define VL53L1_XTALKCALIBRATIONMODE_FULL_ROI \
+ ((VL53L1_OffsetCalibrationModes) 2)
+/*!< To perform Xtalk calibration based on histogram with full ROI */
+
+/** @} VL53L1_define_XtalkCal_group */
+
+/** @defgroup VL53L1_define_OffsetCal_group Defines Offset Calibration modes
+* Defines all possible Offset Calibration modes for the device
+* @{
+*/
+typedef uint8_t VL53L1_OffsetCalibrationModes;
+
+#define VL53L1_OFFSETCALIBRATIONMODE_STANDARD \
+ ((VL53L1_OffsetCalibrationModes) 1)
+#define VL53L1_OFFSETCALIBRATIONMODE_PRERANGE_ONLY \
+ ((VL53L1_OffsetCalibrationModes) 2)
+
+/** @} VL53L1_define_OffsetCal_group */
+
+
+
+
+
+/** @defgroup VL53L1_CheckEnable_group Check Enable list
+ * @brief Check Enable code
+ *
+ * Define used to specify the LimitCheckId.
+ * Use @a VL53L1_GetLimitCheckInfo() to get the string.
+ * @{
+ */
+
+#define VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE 0
+#define VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE 1
+
+#define VL53L1_CHECKENABLE_NUMBER_OF_CHECKS 2
+
+/** @} end of VL53L1_CheckEnable_group */
+
+
+/** @defgroup VL53L1_ThresholdMode_gropup Detection Functionality
+ * @brief Defines the different functionalities for the detection feature
+ * @{
+ */
+typedef uint8_t VL53L1_ThresholdMode;
+
+#define VL53L1_THRESHOLD_CROSSED_LOW \
+ ((VL53L1_ThresholdMode) 0)
+ /*!< Trigger interrupt if value < thresh_low */
+#define VL53L1_THRESHOLD_CROSSED_HIGH \
+ ((VL53L1_ThresholdMode) 1)
+ /*!< Trigger interrupt if value > thresh_high */
+#define VL53L1_THRESHOLD_OUT_OF_WINDOW \
+ ((VL53L1_ThresholdMode) 2)
+ /*!< Trigger interrupt if value < thresh_low OR value > thresh_high */
+#define VL53L1_THRESHOLD_IN_WINDOW \
+ ((VL53L1_ThresholdMode) 3)
+ /*!< Trigger interrupt if value > thresh_low AND value < thresh_high */
+
+/** @} end of VL53L1_ThresholdMode_gropup */
+
+/** @brief Defines parameters for Distance detection Thresholds configuration
+ */
+typedef struct {
+ VL53L1_ThresholdMode CrossMode;
+ uint16_t High; /*!< Distance threshold high limit in mm */
+ uint16_t Low; /*!< Distance threshold low limit in mm */
+} VL53L1_DistanceThreshold_t;
+
+/** @brief Defines parameters for Signal rate detection Thresholds configuration
+ */
+typedef struct {
+ VL53L1_ThresholdMode CrossMode;
+ FixPoint1616_t High; /*!< Signal rate threshold high limit */
+ FixPoint1616_t Low; /*!< Signal rate threshold low limit */
+} VL53L1_RateThreshold_t;
+
+/** @defgroup VL53L1_DetectionMode_group Gpio Functionality
+ * @brief Defines conditions leading to device's IT on GPIO
+ * @{
+ */
+typedef uint8_t VL53L1_DetectionMode;
+
+#define VL53L1_DETECTION_NORMAL_RUN \
+ ((VL53L1_DetectionMode) 0)
+ /*!< Trigger interrupt on new measurement regardless of threshold
+ * just like after a VL53L1_SetPresetMode() call
+ */
+#define VL53L1_DETECTION_DISTANCE_ONLY \
+ ((VL53L1_DetectionMode) 1)
+ /*!< Trigger interrupt if "threshold event" occurs on distance */
+#define VL53L1_DETECTION_RATE_ONLY \
+ ((VL53L1_DetectionMode) 2)
+ /*!< Trigger interrupt if "threshold event" occurs on signal rate */
+#define VL53L1_DETECTION_DISTANCE_AND_RATE \
+ ((VL53L1_DetectionMode) 3)
+ /*!< Trigger interrupt if "threshold event" occurs on distance AND rate
+ */
+#define VL53L1_DETECTION_DISTANCE_OR_RATE \
+ ((VL53L1_DetectionMode) 4)
+ /*!< Trigger interrupt if "threshold event" occurs on distance OR rate
+ */
+
+/** @} end of VL53L1_DetectionMode_group */
+
+/** @brief Defines parameters for User/object Detection configuration
+ */
+typedef struct {
+ VL53L1_DetectionMode DetectionMode; /*!< See #VL53L1_DetectionMode*/
+ uint8_t IntrNoTarget; /*!< 1 to trigger IT in case of no target found */
+ VL53L1_DistanceThreshold_t Distance; /*!< limits in mm */
+ VL53L1_RateThreshold_t Rate;/*!< limits in FixPoint1616_t */
+} VL53L1_DetectionConfig_t;
+
+
+/** @brief Defines all parameters for the device
+ */
+typedef struct {
+ VL53L1_PresetModes PresetMode;
+ /*!< Defines the operating mode to be used for the next measure */
+ VL53L1_DistanceModes DistanceMode;
+ /*!< Defines the operating mode to be used for the next measure */
+ VL53L1_DistanceModes InternalDistanceMode;
+ /*!< Defines the internal operating mode to be used for the next
+ * measure
+ */
+ VL53L1_DistanceModes NewDistanceMode;
+ /*!< Defines the new operating mode to be programmed for the next
+ * measure
+ */
+ uint32_t MeasurementTimingBudgetMicroSeconds;
+ /*!< Defines the allowed total time for a single measurement */
+ uint8_t LimitChecksEnable[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
+ /*!< This Array store all the Limit Check enable for this device. */
+ uint8_t LimitChecksStatus[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
+ /*!< This Array stores all the Status of the check linked to last
+ * measurement.
+ */
+ FixPoint1616_t LimitChecksValue[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
+ /*!< This Array stores all the Limit Check value for this device */
+ FixPoint1616_t LimitChecksCurrent[VL53L1_CHECKENABLE_NUMBER_OF_CHECKS];
+ /*!< This Array stores all the Limit Check current value from latest
+ * ranging
+ */
+} VL53L1_DeviceParameters_t;
+
+
+/** @defgroup VL53L1_define_State_group Defines the current status of the device
+ * Defines the current status of the device
+ * @{
+ */
+
+typedef uint8_t VL53L1_State;
+
+#define VL53L1_STATE_POWERDOWN ((VL53L1_State) 0)
+ /*!< Device is in HW reset */
+#define VL53L1_STATE_WAIT_STATICINIT ((VL53L1_State) 1)
+ /*!< Device is initialized and wait for static initialization */
+#define VL53L1_STATE_STANDBY ((VL53L1_State) 2)
+ /*!< Device is in Low power Standby mode */
+#define VL53L1_STATE_IDLE ((VL53L1_State) 3)
+ /*!< Device has been initialized and ready to do measurements */
+#define VL53L1_STATE_RUNNING ((VL53L1_State) 4)
+ /*!< Device is performing measurement */
+#define VL53L1_STATE_RESET ((VL53L1_State) 5)
+ /*!< Soft reset has been run on Device */
+#define VL53L1_STATE_UNKNOWN ((VL53L1_State) 98)
+ /*!< Device is in unknown state and need to be rebooted */
+#define VL53L1_STATE_ERROR ((VL53L1_State) 99)
+ /*!< Device is in error state and need to be rebooted */
+
+/** @} VL53L1_define_State_group */
+
+
+
+/**
+ * @struct VL53L1_RangingMeasurementData_t
+ * @brief Single Range measurement data.
+ */
+typedef struct {
+ uint32_t TimeStamp;
+ /*!< 32-bit time stamp.
+ * @warning Not yet implemented
+ */
+
+ uint8_t StreamCount;
+ /*!< 8-bit Stream Count. */
+
+ uint8_t RangeQualityLevel;
+ /*!< indicate a quality level in percentage from 0 to 100
+ * @warning Not yet implemented
+ */
+
+ FixPoint1616_t SignalRateRtnMegaCps;
+ /*!< Return signal rate (MCPS)\n these is a 16.16 fix point
+ * value, which is effectively a measure of target
+ * reflectance.
+ */
+
+ FixPoint1616_t AmbientRateRtnMegaCps;
+ /*!< Return ambient rate (MCPS)\n these is a 16.16 fix point
+ * value, which is effectively a measure of the ambien
+ * t light.
+ */
+
+ uint16_t EffectiveSpadRtnCount;
+ /*!< Return the effective SPAD count for the return signal.
+ * To obtain Real value it should be divided by 256
+ */
+
+ FixPoint1616_t SigmaMilliMeter;
+ /*!< Return the Sigma value in millimeter */
+
+ int16_t RangeMilliMeter;
+ /*!< range distance in millimeter. This should be between
+ * RangeMinMilliMeter and RangeMaxMilliMeter
+ */
+
+ uint8_t RangeFractionalPart;
+ /*!< Fractional part of range distance. Final value is a
+ * RangeMilliMeter + RangeFractionalPart/256.
+ * @warning Not yet implemented
+ */
+
+ uint8_t RangeStatus;
+ /*!< Range Status for the current measurement. This is device
+ * dependent. Value = 0 means value is valid.
+ */
+} VL53L1_RangingMeasurementData_t;
+
+
+
+/** @brief Defines User Zone(ROI) parameters
+ *
+ */
+typedef struct {
+
+ uint8_t TopLeftX; /*!< Top Left x coordinate: 0-15 range */
+ uint8_t TopLeftY; /*!< Top Left y coordinate: 0-15 range */
+ uint8_t BotRightX; /*!< Bot Right x coordinate: 0-15 range */
+ uint8_t BotRightY; /*!< Bot Right y coordinate: 0-15 range */
+
+} VL53L1_UserRoi_t;
+
+
+/** @brief Defines ROI configuration parameters
+ *
+ * Support up a max of 16 zones, Each Zone has the same size
+ *
+ */
+
+/**
+ * @struct VL53L1_CustomerNvmManaged_t
+ *
+ */
+
+typedef struct {
+ uint8_t global_config__spad_enables_ref_0;
+ uint8_t global_config__spad_enables_ref_1;
+ uint8_t global_config__spad_enables_ref_2;
+ uint8_t global_config__spad_enables_ref_3;
+ uint8_t global_config__spad_enables_ref_4;
+ uint8_t global_config__spad_enables_ref_5;
+ uint8_t global_config__ref_en_start_select;
+ uint8_t ref_spad_man__num_requested_ref_spads;
+ uint8_t ref_spad_man__ref_location;
+ uint32_t algo__crosstalk_compensation_plane_offset_kcps;
+ int16_t algo__crosstalk_compensation_x_plane_gradient_kcps;
+ int16_t algo__crosstalk_compensation_y_plane_gradient_kcps;
+ uint16_t ref_spad_char__total_rate_target_mcps;
+ int16_t algo__part_to_part_range_offset_mm;
+ int16_t mm_config__inner_offset_mm;
+ int16_t mm_config__outer_offset_mm;
+} VL53L1_CustomerNvmManaged_t;
+
+/**
+ * @struct VL53L1_CalibrationData_t
+ * @brief Structure for storing the Calibration Data
+ *
+ */
+
+typedef struct {
+
+ uint32_t struct_version;
+ VL53L1_CustomerNvmManaged_t customer;
+ VL53L1_additional_offset_cal_data_t add_off_cal_data;
+ VL53L1_optical_centre_t optical_centre;
+ VL53L1_gain_calibration_data_t gain_cal;
+ VL53L1_cal_peak_rate_map_t cal_peak_rate_map;
+
+} VL53L1_CalibrationData_t;
+
+#define VL53L1_ADDITIONAL_CALIBRATION_DATA_STRUCT_VERSION 0x10
+/** VL53L1 additional Calibration Data struct version final struct version
+ * is given by adding it to VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION
+ */
+
+#define VL53L1_CALIBRATION_DATA_STRUCT_VERSION \
+ (VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION + \
+ VL53L1_ADDITIONAL_CALIBRATION_DATA_STRUCT_VERSION)
+/* VL53L1 Calibration Data struct version */
+
+/**
+ * @struct VL53L1_AdditionalData_t
+ * @brief Structure for storing the Additional Data
+ *
+ */
+typedef VL53L1_additional_data_t VL53L1_AdditionalData_t;
+
+
+typedef uint8_t VL53L1_SequenceStepId;
+
+#define VL53L1_SEQUENCESTEP_VHV ((VL53L1_SequenceStepId) 0)
+/*!<VHV. */
+#define VL53L1_SEQUENCESTEP_PHASECAL ((VL53L1_SequenceStepId) 1)
+/*!<Phase Calibration. */
+#define VL53L1_SEQUENCESTEP_REFPHASE ((VL53L1_SequenceStepId) 2)
+/*!<Reference Phase. */
+#define VL53L1_SEQUENCESTEP_DSS1 ((VL53L1_SequenceStepId) 3)
+/*!<DSS1. */
+#define VL53L1_SEQUENCESTEP_DSS2 ((VL53L1_SequenceStepId) 4)
+/*!<DSS2. */
+#define VL53L1_SEQUENCESTEP_MM1 ((VL53L1_SequenceStepId) 5)
+/*!<Mode Mitigation 1. */
+#define VL53L1_SEQUENCESTEP_MM2 ((VL53L1_SequenceStepId) 6)
+/*!<Mode Mitigation 2. */
+#define VL53L1_SEQUENCESTEP_RANGE ((VL53L1_SequenceStepId) 7)
+/*!<Final Range step. */
+
+#define VL53L1_SEQUENCESTEP_NUMBER_OF_ITEMS 8
+/*!<Number of Sequence Step Managed by the API. */
+
+
+/** @defgroup VL53L1_define_RangeStatus_group Defines the Range Status
+ * @{
+ */
+#define VL53L1_RANGESTATUS_RANGE_VALID 0
+/*!<The Range is valid. */
+#define VL53L1_RANGESTATUS_SIGMA_FAIL 1
+/*!<Sigma Fail. */
+#define VL53L1_RANGESTATUS_SIGNAL_FAIL 2
+/*!<Signal fail. */
+#define VL53L1_RANGESTATUS_RANGE_VALID_MIN_RANGE_CLIPPED 3
+/*!<Target is below minimum detection threshold. */
+#define VL53L1_RANGESTATUS_OUTOFBOUNDS_FAIL 4
+/*!<Phase out of valid limits - different to a wrap exit. */
+#define VL53L1_RANGESTATUS_HARDWARE_FAIL 5
+/*!<Hardware fail. */
+#define VL53L1_RANGESTATUS_RANGE_VALID_NO_WRAP_CHECK_FAIL 6
+/*!<The Range is valid but the wraparound check has not been done. */
+#define VL53L1_RANGESTATUS_WRAP_TARGET_FAIL 7
+/*!<Wrapped target - no matching phase in other VCSEL period timing. */
+#define VL53L1_RANGESTATUS_PROCESSING_FAIL 8
+/*!<Internal algo underflow or overflow in lite ranging. */
+#define VL53L1_RANGESTATUS_XTALK_SIGNAL_FAIL 9
+/*!<Specific to lite ranging. */
+#define VL53L1_RANGESTATUS_SYNCRONISATION_INT 10
+/*!<1st interrupt when starting ranging in back to back mode. Ignore data. */
+#define VL53L1_RANGESTATUS_RANGE_VALID_MERGED_PULSE 11
+/*!<All Range ok but object is result of multiple pulses merging together.
+ * Used by RQL for merged pulse detection
+ */
+#define VL53L1_RANGESTATUS_TARGET_PRESENT_LACK_OF_SIGNAL 12
+/*!<Used by RQL as different to phase fail. */
+#define VL53L1_RANGESTATUS_MIN_RANGE_FAIL 13
+/*!<User ROI input is not valid e.g. beyond SPAD Array.*/
+#define VL53L1_RANGESTATUS_RANGE_INVALID 14
+/*!<lld returned valid range but negative value ! */
+#define VL53L1_RANGESTATUS_NONE 255
+/*!<No Update. */
+
+/** @} VL53L1_define_RangeStatus_group */
+
+
+/** @brief Contains the Internal data of the Bare Driver
+ */
+
+typedef struct {
+ VL53L1_LLDriverData_t LLData;
+ /*!< Low Level Driver data structure */
+
+ VL53L1_LLDriverResults_t llresults;
+ /*!< Low Level Driver data structure */
+
+ VL53L1_State PalState; /* Store the pal state */
+ VL53L1_DeviceParameters_t CurrentParameters;
+ /*!< Current Device Parameter */
+
+} VL53L1_DevData_t;
+
+
+/* MACRO Definitions */
+/** @defgroup VL53L1_define_GeneralMacro_group General Macro Defines
+ * General Macro Defines
+ * @{
+ */
+
+/* Defines */
+#define VL53L1_SETPARAMETERFIELD(Dev, field, value) \
+ (VL53L1DevDataSet(Dev, CurrentParameters.field, value))
+
+#define VL53L1_GETPARAMETERFIELD(Dev, field, variable) \
+ (variable = VL53L1DevDataGet(Dev, CurrentParameters).field)
+
+
+#define VL53L1_SETARRAYPARAMETERFIELD(Dev, field, index, value) \
+ (VL53L1DevDataSet(Dev, CurrentParameters.field[index], value))
+
+#define VL53L1_GETARRAYPARAMETERFIELD(Dev, field, index, variable) \
+ (variable = VL53L1DevDataGet(Dev, CurrentParameters).field[index])
+
+
+#define VL53L1_SETDEVICESPECIFICPARAMETER(Dev, field, value) \
+ (VL53L1DevDataSet(Dev, DeviceSpecificParameters.field, value))
+
+#define VL53L1_GETDEVICESPECIFICPARAMETER(Dev, field) \
+ (VL53L1DevDataGet(Dev, DeviceSpecificParameters).field)
+
+
+#define VL53L1_FIXPOINT1616TOFIXPOINT44(Value) \
+ (uint16_t)((Value>>12)&0xFFFF)
+#define VL53L1_FIXPOINT44TOFIXPOINT1616(Value) \
+ (FixPoint1616_t)((uint32_t)Value<<12)
+
+#define VL53L1_FIXPOINT1616TOFIXPOINT72(Value) \
+ (uint16_t)((Value>>14)&0xFFFF)
+#define VL53L1_FIXPOINT72TOFIXPOINT1616(Value) \
+ (FixPoint1616_t)((uint32_t)Value<<14)
+
+#define VL53L1_FIXPOINT1616TOFIXPOINT97(Value) \
+ (uint16_t)((Value>>9)&0xFFFF)
+#define VL53L1_FIXPOINT97TOFIXPOINT1616(Value) \
+ (FixPoint1616_t)((uint32_t)Value<<9)
+
+#define VL53L1_FIXPOINT1616TOFIXPOINT88(Value) \
+ (uint16_t)((Value>>8)&0xFFFF)
+#define VL53L1_FIXPOINT88TOFIXPOINT1616(Value) \
+ (FixPoint1616_t)((uint32_t)Value<<8)
+
+#define VL53L1_FIXPOINT1616TOFIXPOINT412(Value) \
+ (uint16_t)((Value>>4)&0xFFFF)
+#define VL53L1_FIXPOINT412TOFIXPOINT1616(Value) \
+ (FixPoint1616_t)((uint32_t)Value<<4)
+
+#define VL53L1_FIXPOINT1616TOFIXPOINT313(Value) \
+ (uint16_t)((Value>>3)&0xFFFF)
+#define VL53L1_FIXPOINT313TOFIXPOINT1616(Value) \
+ (FixPoint1616_t)((uint32_t)Value<<3)
+
+#define VL53L1_FIXPOINT1616TOFIXPOINT08(Value) \
+ (uint8_t)((Value>>8)&0x00FF)
+#define VL53L1_FIXPOINT08TOFIXPOINT1616(Value) \
+ (FixPoint1616_t)((uint32_t)Value<<8)
+
+#define VL53L1_FIXPOINT1616TOFIXPOINT53(Value) \
+ (uint8_t)((Value>>13)&0x00FF)
+#define VL53L1_FIXPOINT53TOFIXPOINT1616(Value) \
+ (FixPoint1616_t)((uint32_t)Value<<13)
+
+#define VL53L1_FIXPOINT1616TOFIXPOINT102(Value) \
+ (uint16_t)((Value>>14)&0x0FFF)
+#define VL53L1_FIXPOINT102TOFIXPOINT1616(Value) \
+ (FixPoint1616_t)((uint32_t)Value<<14)
+
+#define VL53L1_FIXPOINT1616TOFIXPOINT142(Value) \
+ (uint16_t)((Value>>14)&0xFFFF)
+#define VL53L1_FIXPOINT142TOFIXPOINT1616(Value) \
+ (FixPoint1616_t)((uint32_t)Value<<14)
+
+#define VL53L1_FIXPOINT1616TOFIXPOINT160(Value) \
+ (uint16_t)((Value>>16)&0xFFFF)
+#define VL53L1_FIXPOINT160TOFIXPOINT1616(Value) \
+ (FixPoint1616_t)((uint32_t)Value<<16)
+
+#define VL53L1_MAKEUINT16(lsb, msb) (uint16_t)((((uint16_t)msb)<<8) + \
+ (uint16_t)lsb)
+
+#ifndef SUPPRESS_UNUSED_WARNING
+#define SUPPRESS_UNUSED_WARNING(x) ((void) (x))
+#endif
+
+#define CHECK_ERROR_GO_ENDFUNC do {\
+ if (Status != VL53L1_ERROR_NONE) \
+ goto ENDFUNC; \
+ } while (0)
+
+/** @} VL53L1_define_GeneralMacro_group */
+
+/** @} VL53L1_globaldefine_group */
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _VL53L1_DEF_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_error_codes.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_error_codes.h
new file mode 100644
index 0000000..1d58a2f
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_error_codes.h
@@ -0,0 +1,253 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_error_codes.h
+ *
+ * @brief Error Code definitions for VL53L1 API.
+ *
+ */
+
+#ifndef _VL53L1_ERROR_CODES_H_
+#define _VL53L1_ERROR_CODES_H_
+
+#include "vl53l1_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/****************************************
+ * PRIVATE define do not edit
+ ****************************************/
+
+/** @defgroup VL53L1_define_Error_group Error and Warning code returned by API
+ * The following DEFINE are used to identify the PAL ERROR
+ * @{
+ */
+
+typedef int8_t VL53L1_Error;
+
+#define VL53L1_ERROR_NONE ((VL53L1_Error) 0)
+#define VL53L1_ERROR_CALIBRATION_WARNING ((VL53L1_Error) - 1)
+ /*!< Warning invalid calibration data may be in used
+ \a VL53L1_InitData()
+ \a VL53L1_GetOffsetCalibrationData
+ \a VL53L1_SetOffsetCalibrationData */
+#define VL53L1_ERROR_MIN_CLIPPED ((VL53L1_Error) - 2)
+ /*!< Warning parameter passed was clipped to min before to be applied */
+
+#define VL53L1_ERROR_UNDEFINED ((VL53L1_Error) - 3)
+ /*!< Unqualified error */
+#define VL53L1_ERROR_INVALID_PARAMS ((VL53L1_Error) - 4)
+ /*!< Parameter passed is invalid or out of range */
+#define VL53L1_ERROR_NOT_SUPPORTED ((VL53L1_Error) - 5)
+ /*!< Function is not supported in current mode or configuration */
+#define VL53L1_ERROR_RANGE_ERROR ((VL53L1_Error) - 6)
+ /*!< Device report a ranging error interrupt status */
+#define VL53L1_ERROR_TIME_OUT ((VL53L1_Error) - 7)
+ /*!< Aborted due to time out */
+#define VL53L1_ERROR_MODE_NOT_SUPPORTED ((VL53L1_Error) - 8)
+ /*!< Asked mode is not supported by the device */
+#define VL53L1_ERROR_BUFFER_TOO_SMALL ((VL53L1_Error) - 9)
+ /*!< ... */
+#define VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL ((VL53L1_Error) - 10)
+ /*!< Supplied buffer is larger than I2C supports */
+#define VL53L1_ERROR_GPIO_NOT_EXISTING ((VL53L1_Error) - 11)
+ /*!< User tried to setup a non-existing GPIO pin */
+#define VL53L1_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED ((VL53L1_Error) - 12)
+ /*!< unsupported GPIO functionality */
+#define VL53L1_ERROR_CONTROL_INTERFACE ((VL53L1_Error) - 13)
+ /*!< error reported from IO functions */
+#define VL53L1_ERROR_INVALID_COMMAND ((VL53L1_Error) - 14)
+ /*!< The command is not allowed in the current device state
+ * (power down) */
+#define VL53L1_ERROR_DIVISION_BY_ZERO ((VL53L1_Error) - 15)
+ /*!< In the function a division by zero occurs */
+#define VL53L1_ERROR_REF_SPAD_INIT ((VL53L1_Error) - 16)
+ /*!< Error during reference SPAD initialization */
+#define VL53L1_ERROR_GPH_SYNC_CHECK_FAIL ((VL53L1_Error) - 17)
+ /*!< GPH sync interrupt check fail - API out of sync with device*/
+#define VL53L1_ERROR_STREAM_COUNT_CHECK_FAIL ((VL53L1_Error) - 18)
+ /*!< Stream count check fail - API out of sync with device */
+#define VL53L1_ERROR_GPH_ID_CHECK_FAIL ((VL53L1_Error) - 19)
+ /*!< GPH ID check fail - API out of sync with device */
+#define VL53L1_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL ((VL53L1_Error) - 20)
+ /*!< Zone dynamic config stream count check failed - API out of sync */
+#define VL53L1_ERROR_ZONE_GPH_ID_CHECK_FAIL ((VL53L1_Error) - 21)
+ /*!< Zone dynamic config GPH ID check failed - API out of sync */
+
+#define VL53L1_ERROR_XTALK_EXTRACTION_NO_SAMPLE_FAIL ((VL53L1_Error) - 22)
+ /*!< Thrown when run_xtalk_extraction fn has 0 succesful samples
+ * when using the full array to sample the xtalk. In this case there is
+ * not enough information to generate new Xtalk parm info. The function
+ * will exit and leave the current xtalk parameters unaltered */
+#define VL53L1_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL ((VL53L1_Error) - 23)
+ /*!< Thrown when run_xtalk_extraction fn has found that the
+ * avg sigma estimate of the full array xtalk sample is > than the
+ * maximal limit allowed. In this case the xtalk sample is too noisy for
+ * measurement. The function will exit and leave the current xtalk parameters
+ * unaltered. */
+
+
+#define VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL ((VL53L1_Error) - 24)
+ /*!< Thrown if there one of stages has no valid offset calibration
+ * samples. A fatal error calibration not valid */
+#define VL53L1_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL ((VL53L1_Error) - 25)
+ /*!< Thrown if there one of stages has zero effective SPADS
+ * Traps the case when MM1 SPADs is zero.
+ * A fatal error calibration not valid */
+#define VL53L1_ERROR_ZONE_CAL_NO_SAMPLE_FAIL ((VL53L1_Error) - 26)
+ /*!< Thrown if then some of the zones have no valid samples
+ * A fatal error calibration not valid */
+
+#define VL53L1_ERROR_TUNING_PARM_KEY_MISMATCH ((VL53L1_Error) - 27)
+ /*!< Thrown if the tuning file key table version does not match with
+ * expected value. The driver expects the key table version to match
+ * the compiled default version number in the define
+ * #VL53L1_TUNINGPARM_KEY_TABLE_VERSION_DEFAULT
+ * */
+
+#define VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS ((VL53L1_Error) - 28)
+ /*!< Thrown if there are less than 5 good SPADs are available. */
+#define VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH ((VL53L1_Error) - 29)
+ /*!< Thrown if the final reference rate is greater than
+ the upper reference rate limit - default is 40 Mcps.
+ Implies a minimum Q3 (x10) SPAD (5) selected */
+#define VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW ((VL53L1_Error) - 30)
+ /*!< Thrown if the final reference rate is less than
+ the lower reference rate limit - default is 10 Mcps.
+ Implies maximum Q1 (x1) SPADs selected */
+
+
+#define VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES ((VL53L1_Error) - 31)
+ /*!< Thrown if there is less than the requested number of
+ * valid samples. */
+#define VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH ((VL53L1_Error) - 32)
+ /*!< Thrown if the offset calibration range sigma estimate is greater
+ * than 8.0 mm. This is the recommended min value to yield a stable
+ * offset measurement */
+#define VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH ((VL53L1_Error) - 33)
+ /*!< Thrown when VL53L1_run_offset_calibration() peak rate is greater
+ than that 50.0Mcps. This is the recommended max rate to avoid
+ pile-up influencing the offset measurement */
+#define VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW ((VL53L1_Error) - 34)
+ /*!< Thrown when VL53L1_run_offset_calibration() when one of stages
+ range has less that 5.0 effective SPADS. This is the recommended
+ min value to yield a stable offset */
+
+
+#define VL53L1_WARNING_ZONE_CAL_MISSING_SAMPLES ((VL53L1_Error) - 35)
+ /*!< Thrown if one of more of the zones have less than
+ the requested number of valid samples */
+#define VL53L1_WARNING_ZONE_CAL_SIGMA_TOO_HIGH ((VL53L1_Error) - 36)
+ /*!< Thrown if one or more zones have sigma estimate value greater
+ * than 8.0 mm. This is the recommended min value to yield a stable
+ * offset measurement */
+#define VL53L1_WARNING_ZONE_CAL_RATE_TOO_HIGH ((VL53L1_Error) - 37)
+ /*!< Thrown if one of more zones have peak rate higher than
+ that 50.0Mcps. This is the recommended max rate to avoid
+ pile-up influencing the offset measurement */
+
+
+#define VL53L1_WARNING_XTALK_MISSING_SAMPLES ((VL53L1_Error) - 38)
+ /*!< Thrown to notify that some of the xtalk samples did not yield
+ * valid ranging pulse data while attempting to measure
+ * the xtalk signal in vl53l1_run_xtalk_extract(). This can signify any of
+ * the zones are missing samples, for further debug information the
+ * xtalk_results struct should be referred to. This warning is for
+ * notification only, the xtalk pulse and shape have still been generated
+ */
+#define VL53L1_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT ((VL53L1_Error) - 39)
+ /*!< Thrown to notify that some of teh xtalk samples used for gradient
+ * generation did not yield valid ranging pulse data while attempting to
+ * measure the xtalk signal in vl53l1_run_xtalk_extract(). This can signify
+ * that any one of the zones 0-3 yielded no successful samples. The
+ * xtalk_results struct should be referred to for further debug info.
+ * This warning is for notification only, the xtalk pulse and shape
+ * have still been generated.
+ */
+#define VL53L1_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT ((VL53L1_Error) - 40)
+/*!< Thrown to notify that some of the xtalk samples used for gradient
+ * generation did not pass the sigma limit check while attempting to
+ * measure the xtalk signal in vl53l1_run_xtalk_extract(). This can signify
+ * that any one of the zones 0-3 yielded an avg sigma_mm value > the limit.
+ * The xtalk_results struct should be referred to for further debug info.
+ * This warning is for notification only, the xtalk pulse and shape
+ * have still been generated.
+ */
+
+#define VL53L1_ERROR_NOT_IMPLEMENTED ((VL53L1_Error) - 41)
+ /*!< Tells requested functionality has not been implemented yet or
+ * not compatible with the device */
+#define VL53L1_ERROR_PLATFORM_SPECIFIC_START ((VL53L1_Error) - 60)
+ /*!< Tells the starting code for platform */
+/** @} VL53L1_define_Error_group */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _VL53L1_ERROR_CODES_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_error_exceptions.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_error_exceptions.h
new file mode 100644
index 0000000..e28da34
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_error_exceptions.h
@@ -0,0 +1,93 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_error_exceptions.h
+ *
+ * @brief EwokPlus25 LL Driver definitions for control of error handling in LL driver
+ */
+
+#ifndef _VL53L1_ERROR_EXCEPTIONS_H_
+#define _VL53L1_ERROR_EXCEPTIONS_H_
+
+#define IGNORE_DIVISION_BY_ZERO 0
+
+#define IGNORE_XTALK_EXTRACTION_NO_SAMPLE_FAIL 0
+#define IGNORE_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL 0
+#define IGNORE_XTALK_EXTRACTION_NO_SAMPLE_FOR_GRADIENT_WARN 0
+#define IGNORE_XTALK_EXTRACTION_SIGMA_LIMIT_FOR_GRADIENT_WARN 0
+#define IGNORE_XTALK_EXTRACTION_MISSING_SAMPLES_WARN 0
+
+#define IGNORE_REF_SPAD_CHAR_NOT_ENOUGH_SPADS 0
+#define IGNORE_REF_SPAD_CHAR_RATE_TOO_HIGH 0
+#define IGNORE_REF_SPAD_CHAR_RATE_TOO_LOW 0
+
+#define IGNORE_OFFSET_CAL_MISSING_SAMPLES 0
+#define IGNORE_OFFSET_CAL_SIGMA_TOO_HIGH 0
+#define IGNORE_OFFSET_CAL_RATE_TOO_HIGH 0
+#define IGNORE_OFFSET_CAL_SPAD_COUNT_TOO_LOW 0
+
+#define IGNORE_ZONE_CAL_MISSING_SAMPLES 0
+#define IGNORE_ZONE_CAL_SIGMA_TOO_HIGH 0
+#define IGNORE_ZONE_CAL_RATE_TOO_HIGH 0
+
+#endif /* _VL53L1_ERROR_EXCEPTIONS_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_error_strings.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_error_strings.h
new file mode 100644
index 0000000..d7b2cd8
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_error_strings.h
@@ -0,0 +1,209 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_error_strings.h
+ * @brief VL53L1 function declarations for decoding error codes to a
+ * text strings
+ */
+
+
+#ifndef VL53L1_ERROR_STRINGS_H_
+#define VL53L1_ERROR_STRINGS_H_
+
+#include "vl53l1_error_codes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @brief Generates an error string for the input PAL error code
+ *
+ * @param[in] PalErrorCode : PAL Error Code
+ * @param[out] pPalErrorString : pointer to character buffer
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_pal_error_string(
+ VL53L1_Error PalErrorCode,
+ char *pPalErrorString);
+
+
+#ifndef VL53L1_USE_EMPTY_STRING
+
+ /* PAL ERROR strings */
+ #define VL53L1_STRING_ERROR_NONE \
+ "No Error"
+ #define VL53L1_STRING_ERROR_CALIBRATION_WARNING \
+ "Calibration Warning Error"
+ #define VL53L1_STRING_ERROR_MIN_CLIPPED \
+ "Min clipped error"
+ #define VL53L1_STRING_ERROR_UNDEFINED \
+ "Undefined error"
+ #define VL53L1_STRING_ERROR_INVALID_PARAMS \
+ "Invalid parameters error"
+ #define VL53L1_STRING_ERROR_NOT_SUPPORTED \
+ "Not supported error"
+ #define VL53L1_STRING_ERROR_RANGE_ERROR \
+ "Range error"
+ #define VL53L1_STRING_ERROR_TIME_OUT \
+ "Time out error"
+ #define VL53L1_STRING_ERROR_MODE_NOT_SUPPORTED \
+ "Mode not supported error"
+ #define VL53L1_STRING_ERROR_BUFFER_TOO_SMALL \
+ "Buffer too small"
+ #define VL53L1_STRING_ERROR_COMMS_BUFFER_TOO_SMALL \
+ "Comms Buffer too small"
+ #define VL53L1_STRING_ERROR_GPIO_NOT_EXISTING \
+ "GPIO not existing"
+ #define VL53L1_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED \
+ "GPIO funct not supported"
+ #define VL53L1_STRING_ERROR_CONTROL_INTERFACE \
+ "Control Interface Error"
+ #define VL53L1_STRING_ERROR_INVALID_COMMAND \
+ "Invalid Command Error"
+ #define VL53L1_STRING_ERROR_DIVISION_BY_ZERO \
+ "Division by zero Error"
+ #define VL53L1_STRING_ERROR_REF_SPAD_INIT \
+ "Reference Spad Init Error"
+ #define VL53L1_STRING_ERROR_GPH_SYNC_CHECK_FAIL \
+ "GPH Sync Check Fail - API out of sync"
+ #define VL53L1_STRING_ERROR_STREAM_COUNT_CHECK_FAIL \
+ "Stream Count Check Fail - API out of sync"
+ #define VL53L1_STRING_ERROR_GPH_ID_CHECK_FAIL \
+ "GPH ID Check Fail - API out of sync"
+ #define VL53L1_STRING_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL \
+ "Zone Stream Count Check Fail - API out of sync"
+ #define VL53L1_STRING_ERROR_ZONE_GPH_ID_CHECK_FAIL \
+ "Zone GPH ID Check Fail - API out of sync"
+
+ #define VL53L1_STRING_ERROR_XTALK_EXTRACTION_NO_SAMPLES_FAIL \
+ "No Xtalk using full array - Xtalk Extract Fail"
+ #define VL53L1_STRING_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL \
+ "Xtalk does not meet required sigma limit - Xtalk Extract Fail"
+
+ #define VL53L1_STRING_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL \
+ "Offset Cal - one of more stages with no valid samples - fatal"
+ #define VL53L1_STRING_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL \
+ "Offset Cal - one of more stages with no SPADS enables - fatal"
+ #define VL53L1_STRING_ERROR_ZONE_CAL_NO_SAMPLE_FAIL \
+ "Zone Cal - one of more zones with no valid samples - fatal"
+
+ #define VL53L1_STRING_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS \
+ "Ref SPAD Char - Not Enough Good SPADs"
+ #define VL53L1_STRING_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH \
+ "Ref SPAD Char - Final Ref Rate too high"
+ #define VL53L1_STRING_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW \
+ "Ref SPAD Char - Final Ref Rate too low"
+
+ #define VL53L1_STRING_WARNING_OFFSET_CAL_MISSING_SAMPLES \
+ "Offset Cal - Less than the requested number of valid samples"
+ #define VL53L1_STRING_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH \
+ "Offset Cal - Sigma estimate value too high - offset not stable"
+ #define VL53L1_STRING_WARNING_OFFSET_CAL_RATE_TOO_HIGH \
+ "Offset Cal - Rate too high - in pile up"
+ #define VL53L1_STRING_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW \
+ "Offset Cal - Insufficient SPADs - offset may not be stable"
+
+ #define VL53L1_STRING_WARNING_ZONE_CAL_MISSING_SAMPLES \
+ "Zone Cal - One or more zone with less than requested valid samples"
+ #define VL53L1_STRING_WARNING_ZONE_CAL_SIGMA_TOO_HIGH \
+ "Zone Cal - One of more zones the sigma estimate too high"
+ #define VL53L1_STRING_WARNING_ZONE_CAL_RATE_TOO_HIGH \
+ "Zone Cal - One of more zones with rate too high - in pile up"
+
+ #define VL53L1_STRING_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT \
+ "Xtalk - Gradient sample num = 0"
+ #define VL53L1_STRING_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT \
+ "Xtalk - Gradient Sigma > Limit"
+ #define VL53L1_STRING_WARNING_XTALK_MISSING_SAMPLES \
+ "Xtalk - Some missing and invalid samples"
+
+ #define VL53L1_STRING_ERROR_DEVICE_FIRMWARE_TOO_OLD \
+ "Device Firmware too old"
+ #define VL53L1_STRING_ERROR_DEVICE_FIRMWARE_TOO_NEW \
+ "Device Firmware too new"
+ #define VL53L1_STRING_ERROR_UNIT_TEST_FAIL \
+ "Unit Test Fail"
+ #define VL53L1_STRING_ERROR_FILE_READ_FAIL \
+ "File Read Fail"
+ #define VL53L1_STRING_ERROR_FILE_WRITE_FAIL \
+ "File Write Fail"
+
+ #define VL53L1_STRING_ERROR_NOT_IMPLEMENTED \
+ "Not implemented error"
+ #define VL53L1_STRING_UNKNOW_ERROR_CODE \
+ "Unknown Error Code"
+
+#endif /* VL53L1_USE_EMPTY_STRING */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_ll_def.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_ll_def.h
new file mode 100644
index 0000000..c0fc320
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_ll_def.h
@@ -0,0 +1,1098 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_ll_def.h
+ *
+ * @brief Type definitions for VL53L1 LL Driver.
+ *
+ */
+
+
+#ifndef _VL53L1_LL_DEF_H_
+#define _VL53L1_LL_DEF_H_
+
+#include "vl53l1_ll_device.h"
+#include "vl53l1_error_codes.h"
+#include "vl53l1_register_structs.h"
+#include "vl53l1_platform_user_config.h"
+#include "vl53l1_platform_user_defines.h"
+#include "vl53l1_error_exceptions.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @defgroup VL53L1_globalLLDriverDefine_group VL53L1 Defines
+ * @brief VL53L1 LL Driver Defines
+ * @{
+ */
+
+/** VL53L1 Low Level Driver IMPLEMENTATION major version */
+#define VL53L1_LL_API_IMPLEMENTATION_VER_MAJOR 1
+/** VL53L1 Low Level DriverI IMPLEMENTATION minor version */
+#define VL53L1_LL_API_IMPLEMENTATION_VER_MINOR 2
+/** VL53L1 Low Level DriverI IMPLEMENTATION sub version */
+#define VL53L1_LL_API_IMPLEMENTATION_VER_SUB 10
+/** VL53L1 Low Level Driver IMPLEMENTATION sub version */
+#define VL53L1_LL_API_IMPLEMENTATION_VER_REVISION 1840
+
+#define VL53L1_LL_API_IMPLEMENTATION_VER_STRING "1.2.11.1840"
+
+/** VL53L1_FIRMWARE min and max compatible revisions */
+#define VL53L1_FIRMWARE_VER_MINIMUM 398
+#define VL53L1_FIRMWARE_VER_MAXIMUM 400
+
+
+/****************************************
+ * PRIVATE define do not edit
+ ****************************************/
+
+#define VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION 0xECAB0102
+ /** VL53L1 Calibration Data struct version */
+
+/* Start Patch_ZoneCalDataStructVersion_11854 */
+
+#define VL53L1_LL_ZONE_CALIBRATION_DATA_STRUCT_VERSION 0xECAE0101
+ /** VL53L1 Zone Calibration Data struct version */
+
+/* End Patch_ZoneCalDataStructVersion_11854 */
+
+#define VL53L1_MAX_OFFSET_RANGE_RESULTS 3
+ /*!< Sets the maximum number of offset range results
+ required for the offset calibration.
+ Order is RANGE, MM1, MM2 */
+
+#define VL53L1_NVM_MAX_FMT_RANGE_DATA 4
+ /*!< The number of FMT range data points stored in NVM */
+
+#define VL53L1_NVM_PEAK_RATE_MAP_SAMPLES 25
+ /*!< The number of samples in the NVM peak rate signal map */
+#define VL53L1_NVM_PEAK_RATE_MAP_WIDTH 5
+ /*!< Array width of NVM peak rate signal map */
+#define VL53L1_NVM_PEAK_RATE_MAP_HEIGHT 5
+ /*!< Array height the NVM peak rate signal map */
+
+/** @defgroup VL53L1_defineExtraError_group Error and Warning code returned by API
+ * The following DEFINE are used to identify the PAL ERROR
+ * @{
+ */
+
+#define VL53L1_ERROR_DEVICE_FIRMWARE_TOO_OLD ((VL53L1_Error) - 80)
+ /*!< Device Firmware too old .. */
+#define VL53L1_ERROR_DEVICE_FIRMWARE_TOO_NEW ((VL53L1_Error) - 85)
+ /*!< Device Firmware too new .. */
+#define VL53L1_ERROR_UNIT_TEST_FAIL ((VL53L1_Error) - 90)
+ /*!< Unit Test Fail */
+#define VL53L1_ERROR_FILE_READ_FAIL ((VL53L1_Error) - 95)
+ /*!< File Read Fail */
+#define VL53L1_ERROR_FILE_WRITE_FAIL ((VL53L1_Error) - 96)
+ /*!< File Write Fail */
+ /*!< Tells requested functionality has not been implemented yet or
+ * not compatible with the device */
+/** @} VL53L1_defineExtraError_group */
+
+
+/** @brief Defines the parameters of the LL driver Get Version Functions
+ */
+typedef struct {
+ uint32_t ll_revision; /*!< revision number */
+ uint8_t ll_major; /*!< major number */
+ uint8_t ll_minor; /*!< minor number */
+ uint8_t ll_build; /*!< build number */
+} VL53L1_ll_version_t;
+
+
+/** @brief Reference SPAD Characterization (RefSpadChar) Config
+ */
+
+typedef struct {
+
+ uint8_t device_test_mode; /*!< Device test mode */
+ uint8_t vcsel_period; /*!< VCSEL period (register) value */
+ uint32_t timeout_us; /*!< timeout in [us] */
+ uint16_t target_count_rate_mcps;
+ /*!< Target reference total count rate in [Mcps] - 9.7 format */
+ uint16_t min_count_rate_limit_mcps;
+ /*!< Min valid reference rate [Mcps] - 9.7 format */
+ uint16_t max_count_rate_limit_mcps;
+ /*!< Max valid reference rate [Mcps] - 9.7 format */
+
+} VL53L1_refspadchar_config_t;
+
+
+/** @brief SPAD Self Check (SSC) Config data structure
+ */
+
+
+typedef struct {
+
+ VL53L1_DeviceSscArray array_select;
+ /*!< SPAD Array select
+ * 0 - store RTN array count rates \n
+ * 1 - store REF array count rates */
+ uint8_t vcsel_period;
+ /*!< VCSEL period (register) value */
+ uint8_t vcsel_start;
+ /*!< VCSEL start register value */
+ uint8_t vcsel_width;
+ /*!< VCSEL ssc_timeout_us width register value e.g. 2 */
+ uint32_t timeout_us;
+ /*!< requested Ranging Timeout in [us] e.g 100000us */
+ uint16_t rate_limit_mcps;
+ /*!< Rate limit for checks either 1.15 or
+ * 9.7 dependent on test_mode
+ */
+
+} VL53L1_ssc_config_t;
+
+
+/** @brief Xtalk Extraction and Paramter Config
+ */
+
+typedef struct {
+
+
+ uint32_t algo__crosstalk_compensation_plane_offset_kcps;
+ /*!< Private crosstalk_compensation_plane_offset_kcps (fixed point 9.9) */
+ int16_t algo__crosstalk_compensation_x_plane_gradient_kcps;
+ /*!< Private crosstalk_compensation_x_plane_gradient_kcps (fixed point 5.11) */
+ int16_t algo__crosstalk_compensation_y_plane_gradient_kcps;
+ /*!< Private crosstalk_compensation_y_plane_gradient_kcps (fixed point 5.11) */
+ uint32_t nvm_default__crosstalk_compensation_plane_offset_kcps;
+ /*!< NVm stored crosstalk_compensation_plane_offset_kcps (fixed point 9.9) */
+ int16_t nvm_default__crosstalk_compensation_x_plane_gradient_kcps;
+ /*!< NVM stored crosstalk_compensation_x_plane_gradient_kcps (fixed point 5.11) */
+ int16_t nvm_default__crosstalk_compensation_y_plane_gradient_kcps;
+ /*!< NVM stored crosstalk_compensation_y_plane_gradient_kcps (fixed point 5.11) */
+ uint8_t global_crosstalk_compensation_enable;
+ /*!< Enable switch for crosstalk compensation in all modes */
+ int16_t lite_mode_crosstalk_margin_kcps;
+ /*!< Additional xtalk factor rate, added to plane_offset value in both
+ * SD mode, applied as a seperate addition at point of
+ * application to the device, plane_offset
+ * value remains unaltered. (fixed point 7.9)
+ */
+ uint8_t crosstalk_range_ignore_threshold_mult;
+ /*!< User set multiplier for range ignore threshold setting (fixed point 3.5) */
+ uint16_t crosstalk_range_ignore_threshold_rate_mcps;
+ /*!< Generated range ignore threshold rate in Mcps per spad (fixed
+ * point 3.13)
+ */
+
+} VL53L1_xtalk_config_t;
+
+
+/** @brief TuningParameter Storage
+ *
+ * - Storage structure for any LLD tuning parms
+ * which are dynamically altered by low level functions
+ * mostly when programming directly to the device
+ *
+ *- Added as part of Patch_AddingTuningParmStorage_11821
+ */
+
+typedef struct {
+
+
+ uint16_t tp_tuning_parm_version;
+ /*!< Programmed Global tuning version num for debug
+ */
+ uint16_t tp_tuning_parm_key_table_version;
+ /*!< Key Table tuning structure \
+ * version
+ */
+ uint16_t tp_tuning_parm_lld_version;
+ /*!< Programmed LLD version to ensure matching tuning structure \
+ * key table
+ */
+ uint8_t tp_init_phase_rtn_lite_long;
+ /*!< initial phase value for rtn array \
+ * in Lite Long Ranging Mode
+ */
+ uint8_t tp_init_phase_rtn_lite_med;
+ /*!< initial phase value for rtn array \
+ * in Lite Medium Ranging Mode
+ */
+ uint8_t tp_init_phase_rtn_lite_short;
+ /*!< initial phase value for rtn array \
+ * in Lite Short Ranging Mode
+ */
+ uint8_t tp_init_phase_ref_lite_long;
+ /*!< initial phase value for ref array \
+ * in Lite Long Ranging Mode
+ */
+ uint8_t tp_init_phase_ref_lite_med;
+ /*!< initial phase value for ref array \
+ * in Lite Medium Ranging Mode
+ */
+ uint8_t tp_init_phase_ref_lite_short;
+ /*!< initial phase value for ref array \
+ * in Lite short Ranging Mode
+ */
+
+ uint8_t tp_consistency_lite_phase_tolerance;
+ /*!< Phase tolerance consistency value to be used \
+ * in Lite modes
+ */
+ uint8_t tp_phasecal_target;
+ /*!< Phasecal target value
+ */
+ uint16_t tp_cal_repeat_rate;
+ /*!< Auto VHV/Calibration repeat rate for \
+ * use in Lite mode
+ */
+ uint8_t tp_lite_min_clip;
+ /*!< Min Clip value in mm applied to device in Lite \
+ * modes
+ */
+
+ uint16_t tp_lite_long_sigma_thresh_mm;
+ /*!< Sigma threshold limit for Lite Long mode \
+ * in 14.2 format mm
+ */
+ uint16_t tp_lite_med_sigma_thresh_mm;
+ /*!< Sigma threshold limit for Lite Medium mode \
+ * in 14.2 format mm
+ */
+ uint16_t tp_lite_short_sigma_thresh_mm;
+ /*!< Sigma threshold limit for Lite Short mode \
+ * in 14.2 format mm
+ */
+
+ uint16_t tp_lite_long_min_count_rate_rtn_mcps;
+ /*!< Min count rate level used in lite long mode \
+ * in 9.7 Mcps format
+ */
+ uint16_t tp_lite_med_min_count_rate_rtn_mcps;
+ /*!< Min count rate level used in lite medium mode \
+ * in 9.7 Mcps format
+ */
+ uint16_t tp_lite_short_min_count_rate_rtn_mcps;
+ /*!< Min count rate level used in lite short mode \
+ * in 9.7 Mcps format
+ */
+
+ uint8_t tp_lite_sigma_est_pulse_width_ns;
+ /*!< Sigma thresholding tunign parm for Lite mode
+ */
+ uint8_t tp_lite_sigma_est_amb_width_ns;
+ /*!< Sigma thresholding tunign parm for Lite mode
+ */
+ uint8_t tp_lite_sigma_ref_mm;
+ /*!< Sigma thresholding tunign parm for Lite mode
+ */
+ uint8_t tp_lite_seed_cfg;
+ /*!< Lite Mode Seed mode switch
+ */
+ uint8_t tp_timed_seed_cfg;
+ /*!< Timed Mode Seed mode switch
+ */
+
+ uint8_t tp_lite_quantifier;
+ /*!< Low level quantifier setting for lite modes
+ */
+ uint8_t tp_lite_first_order_select;
+ /*!< Low level First order select setting for lite modes
+ */
+
+ uint16_t tp_dss_target_lite_mcps;
+ /*!< DSS Target rate in 9.7 format Mcps for lite modes
+ */
+ uint16_t tp_dss_target_timed_mcps;
+ /*!< DSS Target rate in 9.7 format Mcps for Timed modes
+ */
+
+ uint32_t tp_phasecal_timeout_lite_us;
+ /*!< Phasecal timeout in us for lite modes
+ */
+
+ uint32_t tp_phasecal_timeout_timed_us;
+ /*!< Phasecal timeout in us for Timed modes
+ */
+
+ uint32_t tp_mm_timeout_lite_us;
+ /*!< MM stage timeout in us for Lite modes
+ */
+ uint32_t tp_mm_timeout_timed_us;
+ /*!< MM stage timeout in us for Timed modes
+ */
+ uint32_t tp_mm_timeout_lpa_us;
+ /*!< MM stage timeout in us for Low Power Auto modes
+ */
+
+ uint32_t tp_range_timeout_lite_us;
+ /*!< Ranging stage timeout in us for Lite modes
+ */
+ uint32_t tp_range_timeout_timed_us;
+ /*!< Ranging stage timeout in us for Timed modes
+ */
+ uint32_t tp_range_timeout_lpa_us;
+ /*!< Ranging stage timeout in us for Low Power Auto modes
+ */
+
+} VL53L1_tuning_parm_storage_t;
+
+
+
+/** @brief Optical Centre data
+ *
+ */
+
+typedef struct {
+
+ uint8_t x_centre; /*!< Optical x centre : 4.4 format */
+ uint8_t y_centre; /*!< Optical y centre : 4.4 format */
+
+} VL53L1_optical_centre_t;
+
+
+/** @brief Defines User Zone(ROI) parameters
+ *
+ */
+
+typedef struct {
+
+ uint8_t x_centre; /*!< Zone x centre : 0-15 range */
+ uint8_t y_centre; /*!< Zone y centre : 0-15 range */
+ uint8_t width; /*!< Width of Zone 0 = 1, 7 = 8, 15 = 16 */
+ uint8_t height; /*!< Height of Zone 0 = 1, 7 = 8, 15 = 16 */
+
+} VL53L1_user_zone_t;
+
+
+/**
+ * @struct VL53L1_GPIO_interrupt_config_t
+ *
+ * @brief Structure to configure conditions when GPIO interrupt is trigerred
+ *
+ */
+
+typedef struct {
+
+ /*! Distance interrupt mode */
+ VL53L1_GPIO_Interrupt_Mode intr_mode_distance;
+
+ /*! Rate interrupt mode */
+ VL53L1_GPIO_Interrupt_Mode intr_mode_rate;
+
+ /*! trigger interrupt if a new measurement is ready
+ * __WARNING!__ will override other settings
+ */
+ uint8_t intr_new_measure_ready;
+
+ /*! Trigger interrupt if no target found */
+ uint8_t intr_no_target;
+
+ /*! If set to 0, interrupts will only be triggered if BOTH rate AND
+ * distance thresholds are triggered (combined mode). If set to 1,
+ * interrupts will be triggered if EITHER rate OR distance thresholds
+ * are triggered (independent mode). */
+ uint8_t intr_combined_mode;
+
+ /* -- thresholds -- */
+ /* The struct holds a copy of the thresholds but they are written when
+ * this structure is set using VL53L1_set_GPIO_interrupt_config/_struct
+ * */
+
+ /*! Distance threshold high limit (mm) */
+ uint16_t threshold_distance_high;
+
+ /*! Distance threshold low limit (mm) */
+ uint16_t threshold_distance_low;
+
+ /*! Rate threshold high limit (9.7 Mcps) */
+ uint16_t threshold_rate_high;
+
+ /*! Rate threshold low limit (9.7 Mcps) */
+ uint16_t threshold_rate_low;
+
+} VL53L1_GPIO_interrupt_config_t;
+
+/* Start Patch_LowPowerAutoMode */
+/**
+ * @struct VL53L1_low_power_auto_data_t
+ *
+ * @brief Structure to hold state, tuning and output variables for the low
+ * power auto mode (Presence)
+ *
+ */
+
+typedef struct {
+
+ /*! Tuning variable for the VHV loop bound setting in low power auto
+ * mode. This is zero based, so the number of loops in VHV is this + 1.
+ * Please note, the first range will run with default VHV settings.
+ * Only lower 6 bits are allowed */
+ uint8_t vhv_loop_bound;
+
+ /*! Indicates if we are or are not in low power auto mode */
+ uint8_t is_low_power_auto_mode;
+
+ /*! Used to check if we're running the first range or not. Not to be
+ * used as a stream count */
+ uint8_t low_power_auto_range_count;
+
+ /*! saved interrupt config byte to restore */
+ uint8_t saved_interrupt_config;
+
+ /*! saved vhv config init byte to restore */
+ uint8_t saved_vhv_init;
+
+ /*! saved vhv config timeout byte to restore */
+ uint8_t saved_vhv_timeout;
+
+ /*! phase cal resutl from the first range */
+ uint8_t first_run_phasecal_result;
+
+ /*! DSS. Total rate per spad given from the current range */
+ uint32_t dss__total_rate_per_spad_mcps;
+
+ /*! DSS. Calculated required SPADs value */
+ uint16_t dss__required_spads;
+
+} VL53L1_low_power_auto_data_t;
+
+/* End Patch_LowPowerAutoMode */
+
+/**
+ * @struct VL53L1_range_data_t
+ * @brief Internal data structure for storing post processed ranges
+ *
+ */
+
+typedef struct {
+
+ /* Info size */
+
+ uint8_t range_id;
+ /*!< Range Result id e.g 0, 1, 2 */
+ uint32_t time_stamp;
+ /*!< 32-bit time stamp */
+
+ uint16_t width;
+ /*!< VCSEL pulse width in [PLL clocks] 6.4 format */
+ uint8_t woi;
+ /*!< WOI width in [PLL clocks] */
+
+ uint16_t fast_osc_frequency;
+ /*!< Oscillator frequency in 4.12 format */
+ uint16_t zero_distance_phase;
+ /*!< Zero Distance phase in 5.11 format */
+ uint16_t actual_effective_spads;
+ /*!< effective SPAD count in 8.8 format */
+
+ uint32_t total_periods_elapsed;
+ /*!< Elapsed time in macro periods for readout channel */
+
+ uint32_t peak_duration_us;
+ /*!< Peak VCSEL width time in us */
+
+ uint32_t woi_duration_us;
+ /*!< WOI duration time in us */
+
+
+ /* Event counts */
+
+ uint32_t ambient_window_events;
+ /*!< Return event count for the ambient window */
+ uint32_t ranging_total_events;
+ /*!< Return ranging event count for the ranging window.
+ This includes both VCSEL and ambient contributions */
+ int32_t signal_total_events;
+ /*!< Return event count for the ranging window with ambient
+ subtracted, Note it is 32-bit signed register */
+
+ /* Rates */
+
+ uint16_t peak_signal_count_rate_mcps;
+ /*! Peak signal (VCSEL) Rate in 9.7 format */
+ uint16_t avg_signal_count_rate_mcps;
+ /*! Average signal (VCSEL) Rate in 9.7 format */
+ uint16_t ambient_count_rate_mcps;
+ /*! Ambient Rate in 9.7 format */
+ uint16_t total_rate_per_spad_mcps;
+ /*! Total Rate Per SPAD in 3.13 format */
+ uint32_t peak_rate_per_spad_kcps;
+ /*! Peak Rate Per SPAD in 13.11 format */
+
+ /* Sigma */
+
+ uint16_t sigma_mm;
+ /*!< Range sigma Estimate [mm] 9.7 format */
+
+ /* Phase */
+
+ uint16_t median_phase;
+ /*!< Median Phase in 5.11 format */
+
+ /* Range */
+
+ int16_t median_range_mm;
+ /*!< Median Range in [mm] by default there are no fractional bits
+ Optionally 1 or 2 fractional can be enabled via the
+ VL53L1_SYSTEM__FRACTIONAL_ENABLE register */
+
+ /* Range status */
+
+ uint8_t range_status;
+
+} VL53L1_range_data_t;
+
+
+/**
+ * @struct VL53L1_range_results_t
+ * @brief Structure for storing the set of range results
+ *
+ */
+
+typedef struct {
+
+ VL53L1_DeviceState cfg_device_state;
+ /*!< Configuration Device State */
+ VL53L1_DeviceState rd_device_state;
+ /*!< Read Device State */
+ uint8_t stream_count;
+ /*!< 8-bit stream count */
+
+ uint8_t device_status;
+ /*!< Global device status for result set */
+
+ VL53L1_range_data_t data[2];
+ /*!< Range data each target distance */
+
+} VL53L1_range_results_t;
+
+/**
+ * @struct VL53L1_offset_range_data_t
+ * @brief Structure for storing the set of range results
+ * required for the mm1 and mm2 offset calibration
+ * functions
+ *
+ */
+
+typedef struct {
+
+ uint8_t preset_mode;
+ /*!< Preset Mode use for range */
+ uint8_t dss_config__roi_mode_control;
+ /*!< Dynamic SPAD selection mode */
+ uint16_t dss_config__manual_effective_spads_select;
+ /*!< Requested number of manual effective SPAD's */
+ uint8_t no_of_samples;
+ /*!< Number of ranges */
+ uint32_t effective_spads;
+ /*!< Average effective SPAD's 8.8 format */
+ uint32_t peak_rate_mcps;
+ /*!< Average peak rate Mcps 9.7 format */
+ uint32_t sigma_mm;
+ /*!< Average sigma in [mm] 14.2 format */
+ int32_t median_range_mm;
+ /*!< Avg of median range over all ranges \
+ note value is signed */
+ int32_t range_mm_offset;
+ /*!< The calculated range offset value */
+
+} VL53L1_offset_range_data_t;
+
+
+/**
+ * @struct VL53L1_offset_range_results_t
+ * @brief Structure for storing the set of range results
+ * required for the offset calibration functions
+ *
+ */
+
+typedef struct {
+
+ int16_t cal_distance_mm;
+ /*!< the calibration distance in [mm]*/
+ VL53L1_Error cal_status;
+ /*!< Calibration status, check for warning codes */
+ uint8_t cal_report;
+ /*!< Stage for above cal status - 0 Pre, 1 = MM1, 2 = MM2 */
+ uint8_t max_results;
+ /*!< Array size for histogram range data i.e. max number
+ of results */
+ uint8_t active_results;
+ /*!< Number of active measurements */
+ VL53L1_offset_range_data_t data[VL53L1_MAX_OFFSET_RANGE_RESULTS];
+ /*!< Range results for each offset measurement */
+
+} VL53L1_offset_range_results_t;
+
+/**
+ * @struct VL53L1_additional_offset_cal_data_t
+ * @brief Additional Offset Calibration Data
+ *
+ * Additional offset calibration data. Contains the rate
+ * and effective SPAD counts for the MM inner and outer
+ * calibration steps.
+ */
+
+typedef struct {
+
+ uint16_t result__mm_inner_actual_effective_spads;
+ /*!< MM Inner actual effective SPADs, 8.8 format */
+ uint16_t result__mm_outer_actual_effective_spads;
+ /*!< MM Outer actual effective SPADs, 8.8 format */
+ uint16_t result__mm_inner_peak_signal_count_rtn_mcps;
+ /*!< Mean value of MM Inner return peak rate in [Mcps], 9.7 format */
+ uint16_t result__mm_outer_peak_signal_count_rtn_mcps;
+ /*!< Mean value of MM Outer return peak rate in [Mcps], 9.7 format */
+
+} VL53L1_additional_offset_cal_data_t;
+
+
+/**
+ * @struct VL53L1_cal_peak_rate_map_t
+ * @brief Structure for storing the calibration peak rate map
+ * Used by DMAX to understand the spatial roll off
+ * in the signal rate map towards the corner of the
+ * SPAD array.
+ */
+
+typedef struct {
+
+ int16_t cal_distance_mm;
+ /*!< calibration distance in [mm], 14.2 format */
+ uint16_t max_samples;
+ /*!< Array size for rate map i.e. max number samples */
+ uint16_t width;
+ /*!< Array width */
+ uint16_t height;
+ /*!< Array height */
+ uint16_t peak_rate_mcps[VL53L1_NVM_PEAK_RATE_MAP_SAMPLES];
+ /*!< Array of rate map samples */
+
+} VL53L1_cal_peak_rate_map_t;
+
+
+/**
+ * @struct VL53L1_gain_calibration_data_t
+ *
+ * @brief Gain calibration data
+ *
+ */
+
+typedef struct {
+
+ uint16_t standard_ranging_gain_factor;
+ /*!< Standard ranging gain correction factor 1.11 format */
+
+} VL53L1_gain_calibration_data_t;
+
+
+/**
+ * @struct VL53L1_ll_driver_state_t
+ *
+ * @brief Contains the driver state information
+ *
+ */
+
+typedef struct {
+
+ VL53L1_DeviceState cfg_device_state;
+ /*!< Configuration Device State */
+ uint8_t cfg_stream_count;
+ /*!< configuration stream count, becomes expected
+ stream count for zone */
+ uint8_t cfg_gph_id;
+ /*!< Config Grouped Parameter Hold ID */
+ uint8_t cfg_timing_status;
+ /*!< Timing A or B flag 0 = A, 1 = B */
+
+ VL53L1_DeviceState rd_device_state;
+ /*!< Read Device State */
+ uint8_t rd_stream_count;
+ /*!< rd stream count, used to check actual stream count */
+ uint8_t rd_gph_id;
+ /*!< Read Grouped Parameter Hold ID */
+ uint8_t rd_timing_status;
+ /*!< Timing A or B flag 0 = A, 1 = B */
+
+} VL53L1_ll_driver_state_t;
+
+/** @brief Run Offset Cal Function (offsetcal) Config
+ */
+
+typedef struct {
+
+ uint16_t dss_config__target_total_rate_mcps;
+ /*!< DSS Target rate in MCPS (9.7 format) used \
+ * during run_offset_calibration() */
+ uint32_t phasecal_config_timeout_us;
+ /*!< Phasecal timeout in us \
+ * used during run_offset_calibration() */
+ uint32_t range_config_timeout_us;
+ /*!< Range timeout in us used during \
+ * run_offset_calibration() */
+ uint32_t mm_config_timeout_us;
+ /*!< MM timeout in us used during \
+ * run_offset_calibration() \
+ * Added as part of Patch_AddedOffsetCalMMTuningParm_11791 */
+ uint8_t pre_num_of_samples;
+ /*!< Number of Ranging samples used during \
+ * run_offset_calibration() */
+ uint8_t mm1_num_of_samples;
+ /*!< Number of MM1 samples used during \
+ * run_offset_calibration() */
+ uint8_t mm2_num_of_samples;
+ /*!< Number of MM2 samples used during \
+ * run_offset_calibration() */
+
+} VL53L1_offsetcal_config_t;
+
+
+
+/**
+ * @struct VL53L1_LLDriverData_t
+ *
+ * @brief VL53L1 LL Driver ST private data structure \n
+ *
+ */
+
+typedef struct {
+
+ uint8_t wait_method;
+ /*!< Wait type : blocking or non blocking */
+ VL53L1_DevicePresetModes preset_mode;
+ /*!< Current preset mode */
+ VL53L1_DeviceMeasurementModes measurement_mode;
+ /*!< Current measurement mode */
+ VL53L1_OffsetCalibrationMode offset_calibration_mode;
+ /*!< Current offset calibration mode */
+ VL53L1_OffsetCorrectionMode offset_correction_mode;
+ /*!< Current offset_ correction mode */
+ uint32_t phasecal_config_timeout_us;
+ /*!< requested Phase Cal Timeout e.g. 1000us */
+ uint32_t mm_config_timeout_us;
+ /*!< requested MM Timeout e.g. 2000us */
+ uint32_t range_config_timeout_us;
+ /*!< requested Ranging Timeout e.g 13000us */
+ uint32_t inter_measurement_period_ms;
+ /*!< requested Timing mode repeat period e.g 100ms */
+ uint16_t dss_config__target_total_rate_mcps;
+ /*!< requested DSS Target Total Rate in 9.7 format e.g. 40.0Mcps
+ * - Patch_ChangingPresetModeInputParms_11780 */
+ uint32_t fw_ready_poll_duration_ms;
+ /*!< FW ready poll duration in ms*/
+ uint8_t fw_ready;
+ /*!< Result of FW ready check */
+ uint8_t debug_mode;
+ /*!< Internal Only - read extra debug data */
+
+ /*!< version info structure */
+ VL53L1_ll_version_t version;
+
+ /*!< version info structure */
+ VL53L1_ll_driver_state_t ll_state;
+
+ /*!< decoded GPIO interrupt config */
+ VL53L1_GPIO_interrupt_config_t gpio_interrupt_config;
+
+ /*!< public register data structures */
+ VL53L1_customer_nvm_managed_t customer;
+ VL53L1_cal_peak_rate_map_t cal_peak_rate_map;
+ VL53L1_additional_offset_cal_data_t add_off_cal_data;
+ VL53L1_gain_calibration_data_t gain_cal;
+ VL53L1_user_zone_t mm_roi;
+ VL53L1_optical_centre_t optical_centre;
+
+ /*!< tuning parameter storage */
+ VL53L1_tuning_parm_storage_t tuning_parms;
+
+ /*!< private return good SPAD map */
+ uint8_t rtn_good_spads[VL53L1_RTN_SPAD_BUFFER_SIZE];
+
+ /*!< private internal configuration structures */
+ VL53L1_refspadchar_config_t refspadchar;
+ VL53L1_ssc_config_t ssc_cfg;
+ VL53L1_xtalk_config_t xtalk_cfg;
+ VL53L1_offsetcal_config_t offsetcal_cfg;
+
+ /*!< private internal register data structures */
+ VL53L1_static_nvm_managed_t stat_nvm;
+ VL53L1_static_config_t stat_cfg;
+ VL53L1_general_config_t gen_cfg;
+ VL53L1_timing_config_t tim_cfg;
+ VL53L1_dynamic_config_t dyn_cfg;
+ VL53L1_system_control_t sys_ctrl;
+ VL53L1_system_results_t sys_results;
+ VL53L1_nvm_copy_data_t nvm_copy_data;
+
+ /*!< Private Offset structure */
+ VL53L1_offset_range_results_t offset_results;
+
+ /*!< private debug register data structures */
+ VL53L1_core_results_t core_results;
+ VL53L1_debug_results_t dbg_results;
+
+ /* Start Patch_LowPowerAutoMode */
+ /*!< Low Powr Auto Mode Data */
+ VL53L1_low_power_auto_data_t low_power_auto_data;
+ /* End Patch_LowPowerAutoMode */
+
+#ifdef PAL_EXTENDED
+ /* Patch Debug Data */
+ VL53L1_patch_results_t patch_results;
+ VL53L1_shadow_core_results_t shadow_core_results;
+ VL53L1_shadow_system_results_t shadow_sys_results;
+ VL53L1_prev_shadow_core_results_t prev_shadow_core_results;
+ VL53L1_prev_shadow_system_results_t prev_shadow_sys_results;
+#endif
+
+} VL53L1_LLDriverData_t;
+
+
+/**
+ * @struct VL53L1_LLDriverResults_t
+ *
+ * @brief VL53L1 LL Driver ST private results structure
+ *
+ */
+
+typedef struct {
+
+ /* Private last range results */
+ VL53L1_range_results_t range_results;
+
+} VL53L1_LLDriverResults_t;
+
+/**
+ * @struct VL53L1_calibration_data_t
+ *
+ * @brief Per Part calibration data
+ *
+ */
+
+typedef struct {
+
+ uint32_t struct_version;
+ VL53L1_customer_nvm_managed_t customer;
+ VL53L1_additional_offset_cal_data_t add_off_cal_data;
+ VL53L1_optical_centre_t optical_centre;
+ VL53L1_gain_calibration_data_t gain_cal;
+ VL53L1_cal_peak_rate_map_t cal_peak_rate_map;
+
+} VL53L1_calibration_data_t;
+
+
+/**
+ * @struct VL53L1_tuning_parameters_t
+ *
+ * @brief Tuning Parameters Debug data
+ *
+ */
+
+typedef struct {
+ uint16_t vl53l1_tuningparm_version;
+ uint16_t vl53l1_tuningparm_key_table_version;
+ uint16_t vl53l1_tuningparm_lld_version;
+ uint8_t vl53l1_tuningparm_consistency_lite_phase_tolerance;
+ uint8_t vl53l1_tuningparm_phasecal_target;
+ uint16_t vl53l1_tuningparm_lite_cal_repeat_rate;
+ uint16_t vl53l1_tuningparm_lite_ranging_gain_factor;
+ uint8_t vl53l1_tuningparm_lite_min_clip_mm;
+ uint16_t vl53l1_tuningparm_lite_long_sigma_thresh_mm;
+ uint16_t vl53l1_tuningparm_lite_med_sigma_thresh_mm;
+ uint16_t vl53l1_tuningparm_lite_short_sigma_thresh_mm;
+ uint16_t vl53l1_tuningparm_lite_long_min_count_rate_rtn_mcps;
+ uint16_t vl53l1_tuningparm_lite_med_min_count_rate_rtn_mcps;
+ uint16_t vl53l1_tuningparm_lite_short_min_count_rate_rtn_mcps;
+ uint8_t vl53l1_tuningparm_lite_sigma_est_pulse_width;
+ uint8_t vl53l1_tuningparm_lite_sigma_est_amb_width_ns;
+ uint8_t vl53l1_tuningparm_lite_sigma_ref_mm;
+ uint8_t vl53l1_tuningparm_lite_rit_mult;
+ uint8_t vl53l1_tuningparm_lite_seed_config;
+ uint8_t vl53l1_tuningparm_lite_quantifier;
+ uint8_t vl53l1_tuningparm_lite_first_order_select;
+ int16_t vl53l1_tuningparm_lite_xtalk_margin_kcps;
+ uint8_t vl53l1_tuningparm_initial_phase_rtn_lite_long_range;
+ uint8_t vl53l1_tuningparm_initial_phase_rtn_lite_med_range;
+ uint8_t vl53l1_tuningparm_initial_phase_rtn_lite_short_range;
+ uint8_t vl53l1_tuningparm_initial_phase_ref_lite_long_range;
+ uint8_t vl53l1_tuningparm_initial_phase_ref_lite_med_range;
+ uint8_t vl53l1_tuningparm_initial_phase_ref_lite_short_range;
+ uint8_t vl53l1_tuningparm_timed_seed_config;
+ uint8_t vl53l1_tuningparm_vhv_loopbound;
+ uint8_t vl53l1_tuningparm_refspadchar_device_test_mode;
+ uint8_t vl53l1_tuningparm_refspadchar_vcsel_period;
+ uint32_t vl53l1_tuningparm_refspadchar_phasecal_timeout_us;
+ uint16_t vl53l1_tuningparm_refspadchar_target_count_rate_mcps;
+ uint16_t vl53l1_tuningparm_refspadchar_min_countrate_limit_mcps;
+ uint16_t vl53l1_tuningparm_refspadchar_max_countrate_limit_mcps;
+ uint16_t vl53l1_tuningparm_offset_cal_dss_rate_mcps;
+ uint32_t vl53l1_tuningparm_offset_cal_phasecal_timeout_us;
+ uint32_t vl53l1_tuningparm_offset_cal_mm_timeout_us;
+ uint32_t vl53l1_tuningparm_offset_cal_range_timeout_us;
+ uint8_t vl53l1_tuningparm_offset_cal_pre_samples;
+ uint8_t vl53l1_tuningparm_offset_cal_mm1_samples;
+ uint8_t vl53l1_tuningparm_offset_cal_mm2_samples;
+ uint8_t vl53l1_tuningparm_spadmap_vcsel_period;
+ uint8_t vl53l1_tuningparm_spadmap_vcsel_start;
+ uint16_t vl53l1_tuningparm_spadmap_rate_limit_mcps;
+ uint16_t vl53l1_tuningparm_lite_dss_config_target_total_rate_mcps;
+ uint16_t vl53l1_tuningparm_timed_dss_config_target_total_rate_mcps;
+ uint32_t vl53l1_tuningparm_lite_phasecal_config_timeout_us;
+ uint32_t vl53l1_tuningparm_timed_phasecal_config_timeout_us;
+ uint32_t vl53l1_tuningparm_lite_mm_config_timeout_us;
+ uint32_t vl53l1_tuningparm_timed_mm_config_timeout_us;
+ uint32_t vl53l1_tuningparm_lite_range_config_timeout_us;
+ uint32_t vl53l1_tuningparm_timed_range_config_timeout_us;
+ uint8_t vl53l1_tuningparm_lowpowerauto_vhv_loop_bound;
+ uint32_t vl53l1_tuningparm_lowpowerauto_mm_config_timeout_us;
+ uint32_t vl53l1_tuningparm_lowpowerauto_range_config_timeout_us;
+} VL53L1_tuning_parameters_t;
+
+
+/**
+ * @struct VL53L1_spad_rate_data_t
+ * @brief SPAD Rate Data output by SSC
+ *
+ * Container for the SPAD Rate data output by SPAD select check (SSC)
+ * The data is stored in the buffer in SPAD number order and not
+ * raster order
+ *
+ * Rate data is it either 1.15 or 9.7 fixed point format
+ */
+
+typedef struct {
+
+ uint8_t spad_type;
+ /*!< Type of rate data stored */
+ uint16_t buffer_size;
+ /*!< SPAD buffer size : should be at least 256 for EwokPlus25 */
+ uint16_t rate_data[VL53L1_NO_OF_SPAD_ENABLES];
+ /*!< word buffer containing the SPAD rates */
+ uint16_t no_of_values;
+ /*!< Number of bytes used in the buffer */
+ uint8_t fractional_bits;
+ /*!< Number of fractional bits either 7 or 15 */
+ uint8_t error_status;
+ /*!< Set if supplied buffer is too small */
+
+} VL53L1_spad_rate_data_t;
+
+
+/* Start Patch_AdditionalDebugData_11823 */
+
+/**
+ * @struct VL53L1_additional_data_t
+ * @brief Additional debug data
+ *
+ * Contains the LL Driver configuration information
+ */
+
+typedef struct {
+
+ VL53L1_DevicePresetModes preset_mode;
+ /*!< Current preset mode */
+ VL53L1_DeviceMeasurementModes measurement_mode;
+ /*!< Current measurement mode */
+
+ uint32_t phasecal_config_timeout_us;
+ /*!< requested Phase Cal Timeout e.g. 1000us */
+ uint32_t mm_config_timeout_us;
+ /*!< requested MM Timeout e.g. 2000us */
+ uint32_t range_config_timeout_us;
+ /*!< requested Ranging Timeout e.g 13000us */
+ uint32_t inter_measurement_period_ms;
+ /*!< requested Timing mode repeat period e.g 100ms */
+ uint16_t dss_config__target_total_rate_mcps;
+ /*!< requested DSS Target Total Rate in 9.7 format e.g. 40.0Mcps*/
+
+} VL53L1_additional_data_t;
+
+/* End Patch_AdditionalDebugData_11823 */
+
+
+/** @} VL53L1_globalLLDriverDefine_group */
+
+
+#define SUPPRESS_UNUSED_WARNING(x) \
+ ((void) (x))
+
+
+#define IGNORE_STATUS(__FUNCTION_ID__, __ERROR_STATUS_CHECK__, __STATUS__) \
+ do { \
+ DISABLE_WARNINGS(); \
+ if (__FUNCTION_ID__) { \
+ if (__STATUS__ == __ERROR_STATUS_CHECK__) { \
+ __STATUS__ = VL53L1_ERROR_NONE; \
+ WARN_OVERRIDE_STATUS(__FUNCTION_ID__); \
+ } \
+ } \
+ ENABLE_WARNINGS(); \
+ } \
+ while (0)
+
+#define VL53L1_COPYSTRING(str, ...) \
+ (strncpy(str, ##__VA_ARGS__, VL53L1_MAX_STRING_LENGTH-1))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VL53L1_LL_DEF_H_ */
+
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_ll_device.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_ll_device.h
new file mode 100644
index 0000000..17e6b26
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_ll_device.h
@@ -0,0 +1,698 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_ll_device.h
+ *
+ * @brief LL Driver Device specific defines. To be adapted by implementer for the
+ * targeted device.
+ */
+
+#ifndef _VL53L1_LL_DEVICE_H_
+#define _VL53L1_LL_DEVICE_H_
+
+#include "vl53l1_types.h"
+#include "vl53l1_platform_user_config.h"
+
+#define VL53L1_I2C 0x01
+#define VL53L1_SPI 0x00
+
+
+/** @defgroup VL53L1_DevSpecDefines_group VL53L1 Device Specific Defines
+ * @brief VL53L1 cut1.0 Device Specific Defines
+ * @{
+ */
+
+/** @defgroup VL53L1_define_WaitMethod_group Defines Wait method used
+ * For example blocking versus non blocking
+ * @{
+ */
+typedef uint8_t VL53L1_WaitMethod;
+
+#define VL53L1_WAIT_METHOD_BLOCKING ((VL53L1_WaitMethod) 0)
+#define VL53L1_WAIT_METHOD_NON_BLOCKING ((VL53L1_WaitMethod) 1)
+
+/** @} end of VL53L1_define_WaitMethod_group */
+
+/** @defgroup VL53L1_define_DeviceState_group Device State
+ *
+ * @brief Defines all possible device states for the device
+ * @{
+ */
+typedef uint8_t VL53L1_DeviceState;
+
+#define VL53L1_DEVICESTATE_POWERDOWN ((VL53L1_DeviceState) 0)
+#define VL53L1_DEVICESTATE_HW_STANDBY ((VL53L1_DeviceState) 1)
+#define VL53L1_DEVICESTATE_FW_COLDBOOT ((VL53L1_DeviceState) 2)
+#define VL53L1_DEVICESTATE_SW_STANDBY ((VL53L1_DeviceState) 3)
+#define VL53L1_DEVICESTATE_RANGING_DSS_AUTO ((VL53L1_DeviceState) 4)
+#define VL53L1_DEVICESTATE_RANGING_DSS_MANUAL ((VL53L1_DeviceState) 5)
+#define VL53L1_DEVICESTATE_RANGING_WAIT_GPH_SYNC ((VL53L1_DeviceState) 6)
+#define VL53L1_DEVICESTATE_RANGING_GATHER_DATA ((VL53L1_DeviceState) 7)
+#define VL53L1_DEVICESTATE_RANGING_OUTPUT_DATA ((VL53L1_DeviceState) 8)
+
+#define VL53L1_DEVICESTATE_UNKNOWN ((VL53L1_DeviceState) 98)
+#define VL53L1_DEVICESTATE_ERROR ((VL53L1_DeviceState) 99)
+
+/** @} end of VL53L1_define_DeviceState_group */
+
+
+/** @defgroup VL53L1_define_DevicePresetModes_group Device Preset Modes
+ *
+ * @brief Defines all possible device preset modes. The integer values are
+ * kept the same as main EwokPlus driver branch
+ * @{
+ */
+typedef uint8_t VL53L1_DevicePresetModes;
+
+#define VL53L1_DEVICEPRESETMODE_NONE ((VL53L1_DevicePresetModes) 0)
+#define VL53L1_DEVICEPRESETMODE_STANDARD_RANGING ((VL53L1_DevicePresetModes) 1)
+#define VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_SHORT_RANGE ((VL53L1_DevicePresetModes) 2)
+#define VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_LONG_RANGE ((VL53L1_DevicePresetModes) 3)
+#define VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM1_CAL ((VL53L1_DevicePresetModes) 4)
+#define VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM2_CAL ((VL53L1_DevicePresetModes) 5)
+#define VL53L1_DEVICEPRESETMODE_TIMED_RANGING ((VL53L1_DevicePresetModes) 6)
+#define VL53L1_DEVICEPRESETMODE_TIMED_RANGING_SHORT_RANGE ((VL53L1_DevicePresetModes) 7)
+#define VL53L1_DEVICEPRESETMODE_TIMED_RANGING_LONG_RANGE ((VL53L1_DevicePresetModes) 8)
+#define VL53L1_DEVICEPRESETMODE_OLT ((VL53L1_DevicePresetModes) 17)
+#define VL53L1_DEVICEPRESETMODE_SINGLESHOT_RANGING ((VL53L1_DevicePresetModes) 18)
+#define VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_SHORT_RANGE ((VL53L1_DevicePresetModes) 36)
+#define VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_MEDIUM_RANGE ((VL53L1_DevicePresetModes) 37)
+#define VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_LONG_RANGE ((VL53L1_DevicePresetModes) 38)
+
+/** @} end of VL53L1_define_DevicePresetModes_group */
+
+
+/** @defgroup VL53L1_define_DeviceMeasurementModes_group Device Measurement Modes
+ *
+ * @brief Defines all possible measurement modes for the device
+ * @{
+ */
+typedef uint8_t VL53L1_DeviceMeasurementModes;
+
+#define VL53L1_DEVICEMEASUREMENTMODE_STOP ((VL53L1_DeviceMeasurementModes) 0x00)
+#define VL53L1_DEVICEMEASUREMENTMODE_SINGLESHOT ((VL53L1_DeviceMeasurementModes) 0x10)
+#define VL53L1_DEVICEMEASUREMENTMODE_BACKTOBACK ((VL53L1_DeviceMeasurementModes) 0x20)
+#define VL53L1_DEVICEMEASUREMENTMODE_TIMED ((VL53L1_DeviceMeasurementModes) 0x40)
+#define VL53L1_DEVICEMEASUREMENTMODE_ABORT ((VL53L1_DeviceMeasurementModes) 0x80)
+
+/** @} VL53L1_define_DeviceMeasurementModes_group */
+
+/** @defgroup VL53L1_define_OffsetCalibrationModes_group Device Offset Calibration Mode
+ *
+ * @brief Defines possible offset calibration modes for the device
+ * @{
+ */
+typedef uint8_t VL53L1_OffsetCalibrationMode;
+
+#define VL53L1_OFFSETCALIBRATIONMODE__NONE ((VL53L1_OffsetCalibrationMode) 0)
+#define VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD ((VL53L1_OffsetCalibrationMode) 1)
+#define VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__HISTOGRAM ((VL53L1_OffsetCalibrationMode) 2)
+#define VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD_PRE_RANGE_ONLY ((VL53L1_OffsetCalibrationMode) 3)
+#define VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__HISTOGRAM_PRE_RANGE_ONLY ((VL53L1_OffsetCalibrationMode) 4)
+#define VL53L1_OFFSETCALIBRATIONMODE__PER_ZONE ((VL53L1_OffsetCalibrationMode) 5)
+
+/** @} VL53L1_define_OffsetCalibrationModes_group */
+
+
+/** @defgroup VL53L1_define_OffsetCalibrationModes_group Device Offset Correction Mode
+ *
+ * @brief Defines all possible offset correction modes for the device
+ * @{
+ */
+typedef uint8_t VL53L1_OffsetCorrectionMode;
+
+#define VL53L1_OFFSETCORRECTIONMODE__NONE ((VL53L1_OffsetCorrectionMode) 0)
+#define VL53L1_OFFSETCORRECTIONMODE__MM1_MM2_OFFSETS ((VL53L1_OffsetCorrectionMode) 1)
+#define VL53L1_OFFSETCORRECTIONMODE__PER_ZONE_OFFSETS ((VL53L1_OffsetCorrectionMode) 2)
+
+/** @} VL53L1_define_OffsetCalibrationModes_group */
+
+
+
+/** @defgroup VL53L1_DeviceSequenceConfig_group Device Sequence Config
+ *
+ * @brief Individual bit enables for each stage in the ranging scheduler
+ * The values below encode the bit shift for each bit
+ * @{
+ */
+typedef uint8_t VL53L1_DeviceSequenceConfig;
+
+#define VL53L1_DEVICESEQUENCECONFIG_VHV ((VL53L1_DeviceSequenceConfig) 0)
+#define VL53L1_DEVICESEQUENCECONFIG_PHASECAL ((VL53L1_DeviceSequenceConfig) 1)
+#define VL53L1_DEVICESEQUENCECONFIG_REFERENCE_PHASE ((VL53L1_DeviceSequenceConfig) 2)
+#define VL53L1_DEVICESEQUENCECONFIG_DSS1 ((VL53L1_DeviceSequenceConfig) 3)
+#define VL53L1_DEVICESEQUENCECONFIG_DSS2 ((VL53L1_DeviceSequenceConfig) 4)
+#define VL53L1_DEVICESEQUENCECONFIG_MM1 ((VL53L1_DeviceSequenceConfig) 5)
+#define VL53L1_DEVICESEQUENCECONFIG_MM2 ((VL53L1_DeviceSequenceConfig) 6)
+#define VL53L1_DEVICESEQUENCECONFIG_RANGE ((VL53L1_DeviceSequenceConfig) 7)
+
+/** @} VL53L1_DeviceSequenceConfig_group */
+
+
+/** @defgroup VL53L1_DeviceInterruptPolarity_group Device Interrupt Polarity
+ *
+ * @brief Device Interrupt Polarity
+ * @{
+ */
+typedef uint8_t VL53L1_DeviceInterruptPolarity;
+
+#define VL53L1_DEVICEINTERRUPTPOLARITY_ACTIVE_HIGH ((VL53L1_DeviceInterruptPolarity) 0x00)
+#define VL53L1_DEVICEINTERRUPTPOLARITY_ACTIVE_LOW ((VL53L1_DeviceInterruptPolarity) 0x10)
+#define VL53L1_DEVICEINTERRUPTPOLARITY_BIT_MASK ((VL53L1_DeviceInterruptPolarity) 0x10)
+#define VL53L1_DEVICEINTERRUPTPOLARITY_CLEAR_MASK ((VL53L1_DeviceInterruptPolarity) 0xEF)
+
+/** @} VL53L1_DeviceInterruptPolarity_group */
+
+
+/** @defgroup VL53L1_DeviceGpioMode_group Device GPIO Mode
+ *
+ * @brief Device Gpio Mode
+ * @{
+ */
+typedef uint8_t VL53L1_DeviceGpioMode;
+
+#define VL53L1_DEVICEGPIOMODE_OUTPUT_CONSTANT_ZERO ((VL53L1_DeviceGpioMode) 0x00)
+#define VL53L1_DEVICEGPIOMODE_OUTPUT_RANGE_AND_ERROR_INTERRUPTS ((VL53L1_DeviceGpioMode) 0x01)
+#define VL53L1_DEVICEGPIOMODE_OUTPUT_TIMIER_INTERRUPTS ((VL53L1_DeviceGpioMode) 0x02)
+#define VL53L1_DEVICEGPIOMODE_OUTPUT_RANGE_MODE_INTERRUPT_STATUS ((VL53L1_DeviceGpioMode) 0x03)
+#define VL53L1_DEVICEGPIOMODE_OUTPUT_SLOW_OSCILLATOR_CLOCK ((VL53L1_DeviceGpioMode) 0x04)
+#define VL53L1_DEVICEGPIOMODE_BIT_MASK ((VL53L1_DeviceGpioMode) 0x0F)
+#define VL53L1_DEVICEGPIOMODE_CLEAR_MASK ((VL53L1_DeviceGpioMode) 0xF0)
+
+/** @} VL53L1_DeviceGpioMode_group */
+
+
+/** @defgroup VL53L1_DeviceError_group Device Error
+ *
+ * @brief Device Error code in the range status
+ *
+ * This enum is Device specific it should be updated in the implementation
+ * Use @a VL53L1_GetStatusErrorString() to get the string.
+ * It is related to Status Register of the Device.
+ * @{
+ */
+typedef uint8_t VL53L1_DeviceError;
+
+#define VL53L1_DEVICEERROR_NOUPDATE ((VL53L1_DeviceError) 0)
+ /*!< 0 No Update */
+#define VL53L1_DEVICEERROR_VCSELCONTINUITYTESTFAILURE ((VL53L1_DeviceError) 1)
+#define VL53L1_DEVICEERROR_VCSELWATCHDOGTESTFAILURE ((VL53L1_DeviceError) 2)
+#define VL53L1_DEVICEERROR_NOVHVVALUEFOUND ((VL53L1_DeviceError) 3)
+#define VL53L1_DEVICEERROR_MSRCNOTARGET ((VL53L1_DeviceError) 4)
+#define VL53L1_DEVICEERROR_RANGEPHASECHECK ((VL53L1_DeviceError) 5)
+#define VL53L1_DEVICEERROR_SIGMATHRESHOLDCHECK ((VL53L1_DeviceError) 6)
+#define VL53L1_DEVICEERROR_PHASECONSISTENCY ((VL53L1_DeviceError) 7)
+#define VL53L1_DEVICEERROR_MINCLIP ((VL53L1_DeviceError) 8)
+#define VL53L1_DEVICEERROR_RANGECOMPLETE ((VL53L1_DeviceError) 9)
+#define VL53L1_DEVICEERROR_ALGOUNDERFLOW ((VL53L1_DeviceError) 10)
+#define VL53L1_DEVICEERROR_ALGOOVERFLOW ((VL53L1_DeviceError) 11)
+#define VL53L1_DEVICEERROR_RANGEIGNORETHRESHOLD ((VL53L1_DeviceError) 12)
+#define VL53L1_DEVICEERROR_USERROICLIP ((VL53L1_DeviceError) 13)
+#define VL53L1_DEVICEERROR_REFSPADCHARNOTENOUGHDPADS ((VL53L1_DeviceError) 14)
+#define VL53L1_DEVICEERROR_REFSPADCHARMORETHANTARGET ((VL53L1_DeviceError) 15)
+#define VL53L1_DEVICEERROR_REFSPADCHARLESSTHANTARGET ((VL53L1_DeviceError) 16)
+#define VL53L1_DEVICEERROR_MULTCLIPFAIL ((VL53L1_DeviceError) 17)
+#define VL53L1_DEVICEERROR_GPHSTREAMCOUNT0READY ((VL53L1_DeviceError) 18)
+#define VL53L1_DEVICEERROR_RANGECOMPLETE_NO_WRAP_CHECK ((VL53L1_DeviceError) 19)
+#define VL53L1_DEVICEERROR_EVENTCONSISTENCY ((VL53L1_DeviceError) 20)
+#define VL53L1_DEVICEERROR_MINSIGNALEVENTCHECK ((VL53L1_DeviceError) 21)
+#define VL53L1_DEVICEERROR_RANGECOMPLETE_MERGED_PULSE ((VL53L1_DeviceError) 22)
+
+/* Patch_NewDeviceErrorCodePrevRangeNoTargets_11786 */
+#define VL53L1_DEVICEERROR_PREV_RANGE_NO_TARGETS ((VL53L1_DeviceError) 23)
+
+/** @} end of VL53L1_DeviceError_group */
+
+
+/** @defgroup VL53L1_DeviceReportStatus_group Device Report Status
+ * @brief Device Report Status code
+ *
+ * @{
+ */
+typedef uint8_t VL53L1_DeviceReportStatus;
+
+#define VL53L1_DEVICEREPORTSTATUS_NOUPDATE ((VL53L1_DeviceReportStatus) 0)
+ /*!< 0 No Update */
+#define VL53L1_DEVICEREPORTSTATUS_ROI_SETUP ((VL53L1_DeviceReportStatus) 1)
+#define VL53L1_DEVICEREPORTSTATUS_VHV ((VL53L1_DeviceReportStatus) 2)
+#define VL53L1_DEVICEREPORTSTATUS_PHASECAL ((VL53L1_DeviceReportStatus) 3)
+#define VL53L1_DEVICEREPORTSTATUS_REFERENCE_PHASE ((VL53L1_DeviceReportStatus) 4)
+#define VL53L1_DEVICEREPORTSTATUS_DSS1 ((VL53L1_DeviceReportStatus) 5)
+#define VL53L1_DEVICEREPORTSTATUS_DSS2 ((VL53L1_DeviceReportStatus) 6)
+#define VL53L1_DEVICEREPORTSTATUS_MM1 ((VL53L1_DeviceReportStatus) 7)
+#define VL53L1_DEVICEREPORTSTATUS_MM2 ((VL53L1_DeviceReportStatus) 8)
+#define VL53L1_DEVICEREPORTSTATUS_RANGE ((VL53L1_DeviceReportStatus) 9)
+#define VL53L1_DEVICEREPORTSTATUS_HISTOGRAM ((VL53L1_DeviceReportStatus) 10)
+
+/** @} end of VL53L1_DeviceReportStatus_group */
+
+/** @defgroup VL53L1_DeviceDssMode_group Dynamic SPAD Selection Mode
+ * @brief Selects the device Dynamic SPAD Selection Mode
+ * @{
+ */
+
+typedef uint8_t VL53L1_DeviceDssMode;
+
+#define VL53L1_DEVICEDSSMODE__DISABLED \
+ ((VL53L1_DeviceDssMode) 0)
+#define VL53L1_DEVICEDSSMODE__TARGET_RATE \
+ ((VL53L1_DeviceDssMode) 1)
+#define VL53L1_DEVICEDSSMODE__REQUESTED_EFFFECTIVE_SPADS \
+ ((VL53L1_DeviceDssMode) 2)
+#define VL53L1_DEVICEDSSMODE__BLOCK_SELECT \
+ ((VL53L1_DeviceDssMode) 3)
+
+/** @} end of VL53L1_DeviceDssMode_group */
+
+/** @defgroup VL53L1_DeviceConfigLevel_group Device Config Level
+ *
+ * @brief Defines the contents of the config & start range I2C multi byte transaction
+ * @{
+ */
+typedef uint8_t VL53L1_DeviceConfigLevel;
+
+#define VL53L1_DEVICECONFIGLEVEL_SYSTEM_CONTROL \
+ ((VL53L1_DeviceConfigLevel) 0)
+ /*!< Configs system control & start range */
+#define VL53L1_DEVICECONFIGLEVEL_DYNAMIC_ONWARDS \
+ ((VL53L1_DeviceConfigLevel) 1)
+ /*!< Dynamic config onwards (dynamic_config, system_control) & start range */
+#define VL53L1_DEVICECONFIGLEVEL_TIMING_ONWARDS \
+ ((VL53L1_DeviceConfigLevel) 2)
+ /*!< Dynamic config onwards (timing config, dynamic_config, system_control) &
+ start range */
+#define VL53L1_DEVICECONFIGLEVEL_GENERAL_ONWARDS \
+ ((VL53L1_DeviceConfigLevel) 3)
+ /*!< General config onwards (general_config, timing config, dynamic_config,
+ system_control) & start range */
+#define VL53L1_DEVICECONFIGLEVEL_STATIC_ONWARDS \
+ ((VL53L1_DeviceConfigLevel) 4)
+ /*!< Static config onwards (static_config, general_config, timing_config,
+ dynamic_config, system_control) & start range */
+#define VL53L1_DEVICECONFIGLEVEL_CUSTOMER_ONWARDS \
+ ((VL53L1_DeviceConfigLevel) 5)
+ /*!< Full device config (customer_nvm_managed, static_config, general_config,
+ timing config, dynamic_config, system_control) & start range */
+#define VL53L1_DEVICECONFIGLEVEL_FULL \
+ ((VL53L1_DeviceConfigLevel) 6)
+ /*!< Full device config (static_nvm_managed, customer_nvm_managed, static_config,
+ general_config, timing config, dynamic_config, system_control) & start range */
+
+/** @} end of VL53L1_DeviceConfigLevel_group */
+
+
+/** @defgroup VL53L1_DeviceResultsLevel_group Device Results Level
+ *
+ * @brief Defines the contents of the read results I2C multi byte transaction
+ * @{
+ */
+typedef uint8_t VL53L1_DeviceResultsLevel;
+
+#define VL53L1_DEVICERESULTSLEVEL_SYSTEM_RESULTS \
+ ((VL53L1_DeviceResultsLevel) 0)
+ /*!< Read just system_results */
+#define VL53L1_DEVICERESULTSLEVEL_UPTO_CORE \
+ ((VL53L1_DeviceResultsLevel) 1)
+ /*!< Read both system and core results */
+#define VL53L1_DEVICERESULTSLEVEL_FULL \
+ ((VL53L1_DeviceResultsLevel) 2)
+ /*!< Read system, core and debug results */
+
+/** @} end of VL53L1_DeviceResultsLevel_group */
+
+
+/** @defgroup VL53L1_DeviceTestMode_group Device Test Mode
+ *
+ * @brief Values below match the the TEST_MODE__CTRL register
+ * do not change
+ * @{
+ */
+
+typedef uint8_t VL53L1_DeviceTestMode;
+
+#define VL53L1_DEVICETESTMODE_NONE \
+ ((VL53L1_DeviceTestMode) 0x00)
+ /*!< Idle */
+#define VL53L1_DEVICETESTMODE_NVM_ZERO \
+ ((VL53L1_DeviceTestMode) 0x01)
+ /*!< NVM zero */
+#define VL53L1_DEVICETESTMODE_NVM_COPY \
+ ((VL53L1_DeviceTestMode) 0x02)
+ /*!< NVM copy */
+#define VL53L1_DEVICETESTMODE_PATCH \
+ ((VL53L1_DeviceTestMode) 0x03)
+ /*!< Patch */
+#define VL53L1_DEVICETESTMODE_DCR \
+ ((VL53L1_DeviceTestMode) 0x04)
+ /*!< DCR - SPAD Self-Check (Pass if Count Rate is less than Threshold) */
+#define VL53L1_DEVICETESTMODE_LCR_VCSEL_OFF \
+ ((VL53L1_DeviceTestMode) 0x05)
+ /*!< LCR - SPAD Self-Check (Pass if Count Rate is greater than Threshold
+ and VCSEL off) */
+#define VL53L1_DEVICETESTMODE_LCR_VCSEL_ON \
+ ((VL53L1_DeviceTestMode) 0x06)
+ /*!< LCR - SPAD Self-Check (Pass if Count Rate is greater than Threshold
+ and VCSEL on) */
+#define VL53L1_DEVICETESTMODE_SPOT_CENTRE_LOCATE \
+ ((VL53L1_DeviceTestMode) 0x07)
+ /*!< Spot centre locate */
+#define VL53L1_DEVICETESTMODE_REF_SPAD_CHAR_WITH_PRE_VHV \
+ ((VL53L1_DeviceTestMode) 0x08)
+ /*!<Reference SPAD Characterisation with pre-VHV */
+#define VL53L1_DEVICETESTMODE_REF_SPAD_CHAR_ONLY \
+ ((VL53L1_DeviceTestMode) 0x09)
+ /*!< Reference SPAD Characterisation Only */
+
+/** @} end of VL53L1_DeviceTestMode_group */
+
+
+/** @defgroup VL53L1_DeviceSscArray_group Device Test Mode
+ *
+ * @{
+ */
+
+typedef uint8_t VL53L1_DeviceSscArray;
+
+#define VL53L1_DEVICESSCARRAY_RTN ((VL53L1_DeviceSscArray) 0x00)
+ /*!<Return Array Rates */
+#define VL53L1_DEVICETESTMODE_REF ((VL53L1_DeviceSscArray) 0x01)
+ /*!< Reference Array Rates Only */
+
+/** @} end of VL53L1_DeviceSscArray_group */
+
+
+/** @defgroup VL53L1_SpadArraySelection_group SPAD Array Selection Functionality
+ * @brief SPAD array selection definitions
+ * @{
+ */
+
+#define VL53L1_RETURN_ARRAY_ONLY 0x01
+ /*!< Return SPAD Array only */
+#define VL53L1_REFERENCE_ARRAY_ONLY 0x10
+ /*!< Reference SPAD Array only */
+#define VL53L1_BOTH_RETURN_AND_REFERENCE_ARRAYS 0x11
+ /*!< Both Return and Reference SPAD Arrays */
+#define VL53L1_NEITHER_RETURN_AND_REFERENCE_ARRAYS 0x00
+ /*!< Neither Return or Reference SPAD Array */
+
+/** @} end of VL53L1_SpadArraySelection_group */
+
+/** @defgroup VL53L1_DeviceInterruptLevel_group Interrupt Level Functionality
+ * @brief Interrupt Output Level types
+ * @{
+ */
+
+#define VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_HIGH 0x00
+ /*!< Active High Interrupt */
+#define VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_LOW 0x10
+ /*!< Active Low Interrupt */
+#define VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_MASK 0x10
+ /*!< Active Bit Mask */
+
+/** @} end of VL53L1_DeviceInterruptLevel_group */
+
+/** @defgroup VL53L1_ApiCore_group Misc Functionality
+ * @brief API core specific definitions
+ * @{
+ */
+
+#define VL53L1_POLLING_DELAY_US 1000
+ /*!< 1000us delay for register polling */
+#define VL53L1_SOFTWARE_RESET_DURATION_US 100
+ /*!< 100us software reset duration */
+#define VL53L1_FIRMWARE_BOOT_TIME_US 1200
+ /*!< Duration of firmware boot time for which I2C
+ access is blocked. Real Device 1ms, FPGA 15ms */
+#define VL53L1_ENABLE_POWERFORCE_SETTLING_TIME_US 250
+ /*!< After enabling power force a delay is required
+ to bring regulator, bandgap, oscillator time
+ to power up and settle */
+#define VL53L1_SPAD_ARRAY_WIDTH 16
+ /*!< SPAD array width */
+#define VL53L1_SPAD_ARRAY_HEIGHT 16
+ /*!< SPAD array height */
+#define VL53L1_NVM_SIZE_IN_BYTES 512
+ /*!< NVM (OTP) size in bytes */
+#define VL53L1_NO_OF_SPAD_ENABLES 256
+ /*!< Number of SPADs each SPAD array */
+#define VL53L1_RTN_SPAD_BUFFER_SIZE 32
+ /*!< Number of Return SPAD enable registers (bytes) */
+#define VL53L1_REF_SPAD_BUFFER_SIZE 6
+ /*!< Number of Reference SPAD enable registers (bytes) */
+#define VL53L1_AMBIENT_WINDOW_VCSEL_PERIODS 256
+ /*!< Sigma Delta Ambient window in VCSEL Periods */
+#define VL53L1_RANGING_WINDOW_VCSEL_PERIODS 2048
+ /*!< Sigma Delta Ranging window in VCSEL periods */
+#define VL53L1_MACRO_PERIOD_VCSEL_PERIODS \
+ (VL53L1_AMBIENT_WINDOW_VCSEL_PERIODS + VL53L1_RANGING_WINDOW_VCSEL_PERIODS)
+ /*!< Macro Period in VCSEL periods */
+#define VL53L1_MAX_ALLOWED_PHASE 0xFFFF
+ /*!< Maximum Allowed phase 0xFFFF means 31.999 PLL Clocks */
+
+#define VL53L1_RTN_SPAD_UNITY_TRANSMISSION 0x0100
+ /*!< SPAD unity transmission value - 1.0 in 8.8 format */
+#define VL53L1_RTN_SPAD_APERTURE_TRANSMISSION 0x0038
+ /*!< Apertured SPAD transmission value - 8.8 format
+ Nominal: 5x -> 0.200000 * 256 = 51 = 0x33
+ Measured: 4.6x -> 0.217391 * 256 = 56 = 0x38 */
+
+#define VL53L1_SPAD_TOTAL_COUNT_MAX ((0x01 << 29) - 1)
+ /*!< Maximum SPAD count - 512Mcps * 1sec = 29bits) */
+#define VL53L1_SPAD_TOTAL_COUNT_RES_THRES (0x01 << 24)
+ /*!< SPAD count threshold for reduced 3-bit fractional resolution */
+#define VL53L1_COUNT_RATE_INTERNAL_MAX ((0x01 << 24) - 1)
+ /*!< Maximum internal count rate is a 17.7 (24-b) value */
+#define VL53L1_SPEED_OF_LIGHT_IN_AIR 299704
+ /*!< Speed of light in air in mm/sec */
+#define VL53L1_SPEED_OF_LIGHT_IN_AIR_DIV_8 (299704 >> 3)
+ /*!< Speed of light in air in divided by 8, 2 for round trip
+ and 4 as an additional scaling factor */
+
+/** @} end of VL53L1_ApiCore_group */
+
+/** @} end of VL53L1_DevSpecDefines_group */
+
+/** @defgroup VL53L1_GPIO_Interrupt_Mode_group Interrupt modes
+ * @brief Selects between four interrupt modes
+ * @{
+ */
+
+typedef uint8_t VL53L1_GPIO_Interrupt_Mode;
+
+#define VL53L1_GPIOINTMODE_LEVEL_LOW \
+ ((VL53L1_GPIO_Interrupt_Mode) 0)
+ /*!< Trigger interupt if value < thresh_low */
+#define VL53L1_GPIOINTMODE_LEVEL_HIGH \
+ ((VL53L1_GPIO_Interrupt_Mode) 1)
+ /*!< Trigger interupt if value > thresh_high */
+#define VL53L1_GPIOINTMODE_OUT_OF_WINDOW \
+ ((VL53L1_GPIO_Interrupt_Mode) 2)
+ /*!< Trigger interupt if value < thresh_low OR value > thresh_high */
+#define VL53L1_GPIOINTMODE_IN_WINDOW \
+ ((VL53L1_GPIO_Interrupt_Mode) 3)
+ /*!< Trigger interupt if value > thresh_low AND value < thresh_high */
+
+/** @} end of VL53L1_GPIO_Interrupt_Mode_group */
+
+/** @defgroup VL53L1_TuningParms_group Tuning Parameters
+ * @brief Selects specific tuning parameter inputs to get/set \
+ * Added as part of Patch_AddedTuningParms_11761
+ * @{
+ */
+
+typedef uint16_t VL53L1_TuningParms;
+
+#define VL53L1_TUNINGPARMS_LLD_PUBLIC_MIN_ADDRESS \
+ ((VL53L1_TuningParms) VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS)
+#define VL53L1_TUNINGPARMS_LLD_PUBLIC_MAX_ADDRESS \
+ ((VL53L1_TuningParms) VL53L1_TUNINGPARM_LOWPOWERAUTO_RANGE_CONFIG_TIMEOUT_US)
+
+#define VL53L1_TUNINGPARMS_LLD_PRIVATE_MIN_ADDRESS \
+ ((VL53L1_TuningParms) VL53L1_TUNINGPARM_PRIVATE_PAGE_BASE_ADDRESS)
+#define VL53L1_TUNINGPARMS_LLD_PRIVATE_MAX_ADDRESS \
+ ((VL53L1_TuningParms) VL53L1_TUNINGPARMS_LLD_PRIVATE_MIN_ADDRESS)
+
+#define VL53L1_TUNINGPARM_VERSION \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 0))
+#define VL53L1_TUNINGPARM_KEY_TABLE_VERSION \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 1))
+#define VL53L1_TUNINGPARM_LLD_VERSION \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 2))
+#define VL53L1_TUNINGPARM_CONSISTENCY_LITE_PHASE_TOLERANCE \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 3))
+#define VL53L1_TUNINGPARM_PHASECAL_TARGET \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 4))
+#define VL53L1_TUNINGPARM_LITE_CAL_REPEAT_RATE \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 5))
+#define VL53L1_TUNINGPARM_LITE_RANGING_GAIN_FACTOR \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 6))
+#define VL53L1_TUNINGPARM_LITE_MIN_CLIP_MM \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 7))
+#define VL53L1_TUNINGPARM_LITE_LONG_SIGMA_THRESH_MM \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 8))
+#define VL53L1_TUNINGPARM_LITE_MED_SIGMA_THRESH_MM \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 9))
+#define VL53L1_TUNINGPARM_LITE_SHORT_SIGMA_THRESH_MM \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 10))
+#define VL53L1_TUNINGPARM_LITE_LONG_MIN_COUNT_RATE_RTN_MCPS \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 11))
+#define VL53L1_TUNINGPARM_LITE_MED_MIN_COUNT_RATE_RTN_MCPS \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 12))
+#define VL53L1_TUNINGPARM_LITE_SHORT_MIN_COUNT_RATE_RTN_MCPS \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 13))
+#define VL53L1_TUNINGPARM_LITE_SIGMA_EST_PULSE_WIDTH \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 14))
+#define VL53L1_TUNINGPARM_LITE_SIGMA_EST_AMB_WIDTH_NS \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 15))
+#define VL53L1_TUNINGPARM_LITE_SIGMA_REF_MM \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 16))
+#define VL53L1_TUNINGPARM_LITE_RIT_MULT \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 17))
+#define VL53L1_TUNINGPARM_LITE_SEED_CONFIG \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 18))
+#define VL53L1_TUNINGPARM_LITE_QUANTIFIER \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 19))
+#define VL53L1_TUNINGPARM_LITE_FIRST_ORDER_SELECT \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 20))
+#define VL53L1_TUNINGPARM_LITE_XTALK_MARGIN_KCPS \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 21))
+#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_LONG_RANGE \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 22))
+#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_MED_RANGE \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 23))
+#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_SHORT_RANGE \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 24))
+#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_LONG_RANGE \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 25))
+#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_MED_RANGE \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 26))
+#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_SHORT_RANGE \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 27))
+#define VL53L1_TUNINGPARM_TIMED_SEED_CONFIG \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 28))
+#define VL53L1_TUNINGPARM_VHV_LOOPBOUND \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 29))
+#define VL53L1_TUNINGPARM_REFSPADCHAR_DEVICE_TEST_MODE \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 30))
+#define VL53L1_TUNINGPARM_REFSPADCHAR_VCSEL_PERIOD \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 31))
+#define VL53L1_TUNINGPARM_REFSPADCHAR_PHASECAL_TIMEOUT_US \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 32))
+#define VL53L1_TUNINGPARM_REFSPADCHAR_TARGET_COUNT_RATE_MCPS \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 33))
+#define VL53L1_TUNINGPARM_REFSPADCHAR_MIN_COUNTRATE_LIMIT_MCPS \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 34))
+#define VL53L1_TUNINGPARM_REFSPADCHAR_MAX_COUNTRATE_LIMIT_MCPS \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 35))
+#define VL53L1_TUNINGPARM_OFFSET_CAL_DSS_RATE_MCPS \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 36))
+#define VL53L1_TUNINGPARM_OFFSET_CAL_PHASECAL_TIMEOUT_US \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 37))
+#define VL53L1_TUNINGPARM_OFFSET_CAL_MM_TIMEOUT_US \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 38))
+#define VL53L1_TUNINGPARM_OFFSET_CAL_RANGE_TIMEOUT_US \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 39))
+#define VL53L1_TUNINGPARM_OFFSET_CAL_PRE_SAMPLES \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 40))
+#define VL53L1_TUNINGPARM_OFFSET_CAL_MM1_SAMPLES \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 41))
+#define VL53L1_TUNINGPARM_OFFSET_CAL_MM2_SAMPLES \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 42))
+#define VL53L1_TUNINGPARM_SPADMAP_VCSEL_PERIOD \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 43))
+#define VL53L1_TUNINGPARM_SPADMAP_VCSEL_START \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 44))
+#define VL53L1_TUNINGPARM_SPADMAP_RATE_LIMIT_MCPS \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 45))
+#define VL53L1_TUNINGPARM_LITE_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 46))
+#define VL53L1_TUNINGPARM_TIMED_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 47))
+#define VL53L1_TUNINGPARM_LITE_PHASECAL_CONFIG_TIMEOUT_US \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 48))
+#define VL53L1_TUNINGPARM_TIMED_PHASECAL_CONFIG_TIMEOUT_US \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 49))
+#define VL53L1_TUNINGPARM_LITE_MM_CONFIG_TIMEOUT_US \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 50))
+#define VL53L1_TUNINGPARM_TIMED_MM_CONFIG_TIMEOUT_US \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 51))
+#define VL53L1_TUNINGPARM_LITE_RANGE_CONFIG_TIMEOUT_US \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 52))
+#define VL53L1_TUNINGPARM_TIMED_RANGE_CONFIG_TIMEOUT_US \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 53))
+#define VL53L1_TUNINGPARM_LOWPOWERAUTO_VHV_LOOP_BOUND \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 54))
+#define VL53L1_TUNINGPARM_LOWPOWERAUTO_MM_CONFIG_TIMEOUT_US \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 55))
+#define VL53L1_TUNINGPARM_LOWPOWERAUTO_RANGE_CONFIG_TIMEOUT_US \
+ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 56))
+
+
+/** @} end of VL53L1_TuningParms_group */
+
+
+#endif
+
+/* _VL53L1_DEVICE_H_ */
+
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_nvm_map.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_nvm_map.h
new file mode 100644
index 0000000..b24832c
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_nvm_map.h
@@ -0,0 +1,3022 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_nvm_map.h
+ * @brief NVM Map definitions for EwokPlus25 NVM Interface Functions.
+ *
+ */
+
+/*
+ * Include platform specific and register map definitions
+ */
+
+
+#ifndef _VL53L1_NVM_MAP_H_
+#define _VL53L1_NVM_MAP_H_
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+/** @defgroup VL53L1_nvm_DefineRegisters_group Define Registers * @brief List of all the defined registers
+ * @{
+ */
+
+#define VL53L1_NVM__IDENTIFICATION__MODEL_ID 0x0008
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__identification_model_id
+*/
+#define VL53L1_NVM__IDENTIFICATION__MODULE_TYPE 0x000C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__identification_module_type
+*/
+#define VL53L1_NVM__IDENTIFICATION__REVISION_ID 0x000D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [3:0] = nvm__identification_revision_id
+*/
+#define VL53L1_NVM__IDENTIFICATION__MODULE_ID 0x000E
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [15:0] = nvm__identification_module_id
+*/
+#define VL53L1_NVM__I2C_VALID 0x0010
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__i2c_valid
+*/
+#define VL53L1_NVM__I2C_SLAVE__DEVICE_ADDRESS 0x0011
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__i2c_device_address_ews
+*/
+#define VL53L1_NVM__EWS__OSC_MEASURED__FAST_OSC_FREQUENCY 0x0014
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [15:0] = nvm__ews__fast_osc_frequency (fixed point 4.12)
+*/
+#define VL53L1_NVM__EWS__FAST_OSC_TRIM_MAX 0x0016
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [6:0] = nvm__ews__fast_osc_trim_max
+*/
+#define VL53L1_NVM__EWS__FAST_OSC_FREQ_SET 0x0017
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [2:0] = nvm__ews__fast_osc_freq_set
+*/
+#define VL53L1_NVM__EWS__SLOW_OSC_CALIBRATION 0x0018
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 9
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [9:0] = nvm__ews__slow_osc_calibration
+*/
+#define VL53L1_NVM__FMT__OSC_MEASURED__FAST_OSC_FREQUENCY 0x001C
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [15:0] = nvm__fmt__fast_osc_frequency (fixed point 4.12)
+*/
+#define VL53L1_NVM__FMT__FAST_OSC_TRIM_MAX 0x001E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [6:0] = nvm__fmt__fast_osc_trim_max
+*/
+#define VL53L1_NVM__FMT__FAST_OSC_FREQ_SET 0x001F
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [2:0] = nvm__fmt__fast_osc_freq_set
+*/
+#define VL53L1_NVM__FMT__SLOW_OSC_CALIBRATION 0x0020
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 9
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [9:0] = nvm__fmt__slow_osc_calibration
+*/
+#define VL53L1_NVM__VHV_CONFIG_UNLOCK 0x0028
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__vhv_config_unlock
+*/
+#define VL53L1_NVM__REF_SELVDDPIX 0x0029
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [3:0] = nvm__ref_selvddpix
+*/
+#define VL53L1_NVM__REF_SELVQUENCH 0x002A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 6
+ - lsb = 3
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [6:3] = nvm__ref_selvquench
+*/
+#define VL53L1_NVM__REGAVDD1V2_SEL_REGDVDD1V2_SEL 0x002B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [3:2] = nvm__regavdd1v2_sel
+ - [1:0] = nvm__regdvdd1v2_sel
+*/
+#define VL53L1_NVM__VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND 0x002C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [1:0] = nvm__vhv_timeout__macrop
+ - [7:2] = nvm__vhv_loop_bound
+*/
+#define VL53L1_NVM__VHV_CONFIG__COUNT_THRESH 0x002D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__vhv_count_threshold
+*/
+#define VL53L1_NVM__VHV_CONFIG__OFFSET 0x002E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [5:0] = nvm__vhv_offset
+*/
+#define VL53L1_NVM__VHV_CONFIG__INIT 0x002F
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7] = nvm__vhv_init_enable
+ - [5:0] = nvm__vhv_init_value
+*/
+#define VL53L1_NVM__LASER_SAFETY__VCSEL_TRIM_LL 0x0030
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [2:0] = nvm__laser_safety_vcsel_trim_ll
+*/
+#define VL53L1_NVM__LASER_SAFETY__VCSEL_SELION_LL 0x0031
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [5:0] = nvm__laser_safety_vcsel_selion_ll
+*/
+#define VL53L1_NVM__LASER_SAFETY__VCSEL_SELION_MAX_LL 0x0032
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [5:0] = nvm__laser_safety_vcsel_selion_max_ll
+*/
+#define VL53L1_NVM__LASER_SAFETY__MULT_LL 0x0034
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [5:0] = nvm__laser_safety_mult_ll
+*/
+#define VL53L1_NVM__LASER_SAFETY__CLIP_LL 0x0035
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [5:0] = nvm__laser_safety_clip_ll
+*/
+#define VL53L1_NVM__LASER_SAFETY__VCSEL_TRIM_LD 0x0038
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [2:0] = nvm__laser_safety_vcsel_trim_ld
+*/
+#define VL53L1_NVM__LASER_SAFETY__VCSEL_SELION_LD 0x0039
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [5:0] = nvm__laser_safety_vcsel_selion_ld
+*/
+#define VL53L1_NVM__LASER_SAFETY__VCSEL_SELION_MAX_LD 0x003A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [5:0] = nvm__laser_safety_vcsel_selion_max_ld
+*/
+#define VL53L1_NVM__LASER_SAFETY__MULT_LD 0x003C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [5:0] = nvm__laser_safety_mult_ld
+*/
+#define VL53L1_NVM__LASER_SAFETY__CLIP_LD 0x003D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [5:0] = nvm__laser_safety_clip_ld
+*/
+#define VL53L1_NVM__LASER_SAFETY_LOCK_BYTE 0x0040
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__laser_safety_lock_byte
+*/
+#define VL53L1_NVM__LASER_SAFETY_UNLOCK_BYTE 0x0044
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__laser_safety_unlock_byte
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_0_ 0x0048
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_0_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_1_ 0x0049
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_1_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_2_ 0x004A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_2_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_3_ 0x004B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_3_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_4_ 0x004C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_4_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_5_ 0x004D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_5_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_6_ 0x004E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_6_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_7_ 0x004F
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_7_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_8_ 0x0050
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_8_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_9_ 0x0051
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_9_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_10_ 0x0052
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_10_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_11_ 0x0053
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_11_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_12_ 0x0054
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_12_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_13_ 0x0055
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_13_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_14_ 0x0056
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_14_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_15_ 0x0057
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_15_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_16_ 0x0058
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_16_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_17_ 0x0059
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_17_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_18_ 0x005A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_18_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_19_ 0x005B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_19_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_20_ 0x005C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_20_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_21_ 0x005D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_21_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_22_ 0x005E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_22_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_23_ 0x005F
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_23_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_24_ 0x0060
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_24_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_25_ 0x0061
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_25_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_26_ 0x0062
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_26_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_27_ 0x0063
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_27_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_28_ 0x0064
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_28_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_29_ 0x0065
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_29_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_30_ 0x0066
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_30_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_RTN_31_ 0x0067
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_rtn_31_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC1_0_ 0x0068
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc1_0_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC1_1_ 0x0069
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc1_1_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC1_2_ 0x006A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc1_2_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC1_3_ 0x006B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc1_3_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC1_4_ 0x006C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc1_4_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC1_5_ 0x006D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc1_5_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC2_0_ 0x0070
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc2_0_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC2_1_ 0x0071
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc2_1_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC2_2_ 0x0072
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc2_2_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC2_3_ 0x0073
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc2_3_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC2_4_ 0x0074
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc2_4_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC2_5_ 0x0075
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc2_5_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC3_0_ 0x0078
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc3_0_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC3_1_ 0x0079
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc3_1_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC3_2_ 0x007A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc3_2_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC3_3_ 0x007B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc3_3_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC3_4_ 0x007C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc3_4_
+*/
+#define VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC3_5_ 0x007D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__spad_enables_ref__loc3_5_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_0_ 0x0080
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_0_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_1_ 0x0081
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_1_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_2_ 0x0082
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_2_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_3_ 0x0083
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_3_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_4_ 0x0084
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_4_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_5_ 0x0085
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_5_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_6_ 0x0086
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_6_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_7_ 0x0087
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_7_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_8_ 0x0088
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_8_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_9_ 0x0089
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_9_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_10_ 0x008A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_10_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_11_ 0x008B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_11_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_12_ 0x008C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_12_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_13_ 0x008D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_13_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_14_ 0x008E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_14_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_15_ 0x008F
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_15_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_16_ 0x0090
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_16_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_17_ 0x0091
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_17_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_18_ 0x0092
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_18_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_19_ 0x0093
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_19_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_20_ 0x0094
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_20_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_21_ 0x0095
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_21_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_22_ 0x0096
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_22_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_23_ 0x0097
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_23_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_24_ 0x0098
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_24_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_25_ 0x0099
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_25_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_26_ 0x009A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_26_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_27_ 0x009B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_27_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_28_ 0x009C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_28_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_29_ 0x009D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_29_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_30_ 0x009E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_30_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_RTN_31_ 0x009F
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_rtn_31_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC1_0_ 0x00A0
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc1_0_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC1_1_ 0x00A1
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc1_1_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC1_2_ 0x00A2
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc1_2_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC1_3_ 0x00A3
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc1_3_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC1_4_ 0x00A4
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc1_4_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC1_5_ 0x00A5
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc1_5_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC2_0_ 0x00A8
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc2_0_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC2_1_ 0x00A9
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc2_1_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC2_2_ 0x00AA
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc2_2_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC2_3_ 0x00AB
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc2_3_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC2_4_ 0x00AC
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc2_4_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC2_5_ 0x00AD
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc2_5_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC3_0_ 0x00B0
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc3_0_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC3_1_ 0x00B1
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc3_1_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC3_2_ 0x00B2
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc3_2_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC3_3_ 0x00B3
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc3_3_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC3_4_ 0x00B4
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc3_4_
+*/
+#define VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC3_5_ 0x00B5
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spad_enables_ref__loc3_5_
+*/
+#define VL53L1_NVM__FMT__ROI_CONFIG__MODE_ROI_CENTRE_SPAD 0x00B8
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__roi_config__mode_roi_centre_spad
+*/
+#define VL53L1_NVM__FMT__ROI_CONFIG__MODE_ROI_XY_SIZE 0x00B9
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:4] = nvm__fmt__roi_config__mode_roi_x_size
+ - [3:0] = nvm__fmt__roi_config__mode_roi_y_size
+*/
+#define VL53L1_NVM__FMT__REF_SPAD_APPLY__NUM_REQUESTED_REF_SPAD 0x00BC
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__ref_spad_apply__num_requested_ref_spad
+*/
+#define VL53L1_NVM__FMT__REF_SPAD_MAN__REF_LOCATION 0x00BD
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [1:0] = nvm__fmt__ref_spad_man__ref_location
+*/
+#define VL53L1_NVM__FMT__MM_CONFIG__INNER_OFFSET_MM 0x00C0
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [15:0] = nvm__fmt__mm_config__inner_offset_mm
+*/
+#define VL53L1_NVM__FMT__MM_CONFIG__OUTER_OFFSET_MM 0x00C2
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [15:0] = nvm__fmt__mm_config__outer_offset_mm
+*/
+#define VL53L1_NVM__FMT__ALGO__PART_TO_PART_RANGE_OFFSET_MM 0x00C4
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 11
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [11:0] = nvm__fmt__algo_part_to_part_range_offset_mm (fixed point 10.2)
+*/
+#define VL53L1_NVM__FMT__ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS 0x00C8
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [15:0] = nvm__fmt__algo__crosstalk_compensation_plane_offset_kcps (fixed point 7.9)
+*/
+#define VL53L1_NVM__FMT__ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS 0x00CA
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [15:0] = nvm__fmt__algo__crosstalk_compensation_x_plane_gradient_kcps (fixed point 5.11)
+*/
+#define VL53L1_NVM__FMT__ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS 0x00CC
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [15:0] = nvm__fmt__algo__crosstalk_compensation_y_plane_gradient_kcps (fixed point 5.11)
+*/
+#define VL53L1_NVM__FMT__SPARE_HOST_CONFIG__NVM_CONFIG_SPARE_0 0x00CE
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spare__host_config__nvm_config_spare_0
+*/
+#define VL53L1_NVM__FMT__SPARE_HOST_CONFIG__NVM_CONFIG_SPARE_1 0x00CF
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__spare__host_config__nvm_config_spare_1
+*/
+#define VL53L1_NVM__CUSTOMER_NVM_SPACE_PROGRAMMED 0x00E0
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__customer_space_programmed
+*/
+#define VL53L1_NVM__CUST__I2C_SLAVE__DEVICE_ADDRESS 0x00E4
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__cust__i2c_device_address
+*/
+#define VL53L1_NVM__CUST__REF_SPAD_APPLY__NUM_REQUESTED_REF_SPAD 0x00E8
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__cust__ref_spad_apply__num_requested_ref_spad
+*/
+#define VL53L1_NVM__CUST__REF_SPAD_MAN__REF_LOCATION 0x00E9
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [1:0] = nvm__cust__ref_spad_man__ref_location
+*/
+#define VL53L1_NVM__CUST__MM_CONFIG__INNER_OFFSET_MM 0x00EC
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [15:0] = nvm__cust__mm_config__inner_offset_mm
+*/
+#define VL53L1_NVM__CUST__MM_CONFIG__OUTER_OFFSET_MM 0x00EE
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [15:0] = nvm__cust__mm_config__outer_offset_mm
+*/
+#define VL53L1_NVM__CUST__ALGO__PART_TO_PART_RANGE_OFFSET_MM 0x00F0
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 11
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [11:0] = nvm__cust__algo_part_to_part_range_offset_mm (fixed point 10.2)
+*/
+#define VL53L1_NVM__CUST__ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS 0x00F4
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [15:0] = nvm__cust__algo__crosstalk_compensation_plane_offset_kcps (fixed point 7.9)
+*/
+#define VL53L1_NVM__CUST__ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS 0x00F6
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [15:0] = nvm__cust__algo__crosstalk_compensation_x_plane_gradient_kcps (fixed point 5.11)
+*/
+#define VL53L1_NVM__CUST__ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS 0x00F8
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [15:0] = nvm__cust__algo__crosstalk_compensation_y_plane_gradient_kcps (fixed point 5.11)
+*/
+#define VL53L1_NVM__CUST__SPARE_HOST_CONFIG__NVM_CONFIG_SPARE_0 0x00FA
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__cust__spare__host_config__nvm_config_spare_0
+*/
+#define VL53L1_NVM__CUST__SPARE_HOST_CONFIG__NVM_CONFIG_SPARE_1 0x00FB
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__cust__spare__host_config__nvm_config_spare_1
+*/
+#define VL53L1_NVM__FMT__FGC__BYTE_0 0x01DC
+/*!<
+ type: char \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 1
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:1] = nvm__fmt__fgc_0_
+*/
+#define VL53L1_NVM__FMT__FGC__BYTE_1 0x01DD
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 8
+ - lsb = 2
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [8:2] = nvm__fmt__fgc_1_
+*/
+#define VL53L1_NVM__FMT__FGC__BYTE_2 0x01DE
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 9
+ - lsb = 3
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [9:3] = nvm__fmt__fgc_2_
+*/
+#define VL53L1_NVM__FMT__FGC__BYTE_3 0x01DF
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 10
+ - lsb = 4
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [10:4] = nvm__fmt__fgc_3_
+*/
+#define VL53L1_NVM__FMT__FGC__BYTE_4 0x01E0
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 11
+ - lsb = 5
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [11:5] = nvm__fmt__fgc_4_
+*/
+#define VL53L1_NVM__FMT__FGC__BYTE_5 0x01E1
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 12
+ - lsb = 6
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [12:6] = nvm__fmt__fgc_5_
+*/
+#define VL53L1_NVM__FMT__FGC__BYTE_6 0x01E2
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 13
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [13:7] = nvm__fmt__fgc_6_
+ - [6:0] = nvm__fmt__fgc_7_
+*/
+#define VL53L1_NVM__FMT__FGC__BYTE_7 0x01E3
+/*!<
+ type: char \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 1
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:1] = nvm__fmt__fgc_8_
+*/
+#define VL53L1_NVM__FMT__FGC__BYTE_8 0x01E4
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 8
+ - lsb = 2
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [8:2] = nvm__fmt__fgc_9_
+*/
+#define VL53L1_NVM__FMT__FGC__BYTE_9 0x01E5
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 9
+ - lsb = 3
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [9:3] = nvm__fmt__fgc_10_
+*/
+#define VL53L1_NVM__FMT__FGC__BYTE_10 0x01E6
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 10
+ - lsb = 4
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [10:4] = nvm__fmt__fgc_11_
+*/
+#define VL53L1_NVM__FMT__FGC__BYTE_11 0x01E7
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 11
+ - lsb = 5
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [11:5] = nvm__fmt__fgc_12_
+*/
+#define VL53L1_NVM__FMT__FGC__BYTE_12 0x01E8
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 12
+ - lsb = 6
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [12:6] = nvm__fmt__fgc_13_
+*/
+#define VL53L1_NVM__FMT__FGC__BYTE_13 0x01E9
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 13
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [13:7] = nvm__fmt__fgc_14_
+ - [6:0] = nvm__fmt__fgc_15_
+*/
+#define VL53L1_NVM__FMT__FGC__BYTE_14 0x01EA
+/*!<
+ type: char \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 1
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:1] = nvm__fmt__fgc_16_
+*/
+#define VL53L1_NVM__FMT__FGC__BYTE_15 0x01EB
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 8
+ - lsb = 2
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [8:2] = nvm__fmt__fgc_17_
+*/
+#define VL53L1_NVM__FMT__TEST_PROGRAM_MAJOR_MINOR 0x01EC
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:5] = nvm__fmt__test_program_major
+ - [4:0] = nvm__fmt__test_program_minor
+*/
+#define VL53L1_NVM__FMT__MAP_MAJOR_MINOR 0x01ED
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:5] = nvm__fmt__map_major
+ - [4:0] = nvm__fmt__map_minor
+*/
+#define VL53L1_NVM__FMT__YEAR_MONTH 0x01EE
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:4] = nvm__fmt__year
+ - [3:0] = nvm__fmt__month
+*/
+#define VL53L1_NVM__FMT__DAY_MODULE_DATE_PHASE 0x01EF
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:3] = nvm__fmt__day
+ - [2:0] = nvm__fmt__module_date_phase
+*/
+#define VL53L1_NVM__FMT__TIME 0x01F0
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [15:0] = nvm__fmt__time
+*/
+#define VL53L1_NVM__FMT__TESTER_ID 0x01F2
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__tester_id
+*/
+#define VL53L1_NVM__FMT__SITE_ID 0x01F3
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__fmt__site_id
+*/
+#define VL53L1_NVM__EWS__TEST_PROGRAM_MAJOR_MINOR 0x01F4
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:5] = nvm__ews__test_program_major
+ - [4:0] = nvm__ews__test_program_minor
+*/
+#define VL53L1_NVM__EWS__PROBE_CARD_MAJOR_MINOR 0x01F5
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:4] = nvm__ews__probe_card_major
+ - [3:0] = nvm__ews__probe_card_minor
+*/
+#define VL53L1_NVM__EWS__TESTER_ID 0x01F6
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__tester_id
+*/
+#define VL53L1_NVM__EWS__LOT__BYTE_0 0x01F8
+/*!<
+ type: char \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 2
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:2] = nvm__ews__lot_6_
+*/
+#define VL53L1_NVM__EWS__LOT__BYTE_1 0x01F9
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 9
+ - lsb = 4
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [9:4] = nvm__ews__lot_5_
+*/
+#define VL53L1_NVM__EWS__LOT__BYTE_2 0x01FA
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 11
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [11:6] = nvm__ews__lot_4_
+ - [5:0] = nvm__ews__lot_3_
+*/
+#define VL53L1_NVM__EWS__LOT__BYTE_3 0x01FB
+/*!<
+ type: char \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 2
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:2] = nvm__ews__lot_2_
+*/
+#define VL53L1_NVM__EWS__LOT__BYTE_4 0x01FC
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 9
+ - lsb = 4
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [9:4] = nvm__ews__lot_1_
+*/
+#define VL53L1_NVM__EWS__LOT__BYTE_5 0x01FD
+/*!<
+ type: char \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 11
+ - lsb = 6
+ - i2c_size = 2
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [11:6] = nvm__ews__lot_0_
+*/
+#define VL53L1_NVM__EWS__WAFER 0x01FD
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 4
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [4:0] = nvm__ews__wafer
+*/
+#define VL53L1_NVM__EWS__XCOORD 0x01FE
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__xcoord
+*/
+#define VL53L1_NVM__EWS__YCOORD 0x01FF
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['decoded_nvm_data']
+
+ fields: \n
+ - [7:0] = nvm__ews__ycoord
+*/
+
+#define VL53L1_NVM__FMT__OPTICAL_CENTRE_DATA_INDEX 0x00B8
+#define VL53L1_NVM__FMT__OPTICAL_CENTRE_DATA_SIZE 4
+
+#define VL53L1_NVM__FMT__CAL_PEAK_RATE_MAP_DATA_INDEX 0x015C
+#define VL53L1_NVM__FMT__CAL_PEAK_RATE_MAP_DATA_SIZE 56
+
+#define VL53L1_NVM__FMT__ADDITIONAL_OFFSET_CAL_DATA_INDEX 0x0194
+#define VL53L1_NVM__FMT__ADDITIONAL_OFFSET_CAL_DATA_SIZE 8
+
+#define VL53L1_NVM__FMT__RANGE_RESULTS__140MM_MM_PRE_RANGE 0x019C
+#define VL53L1_NVM__FMT__RANGE_RESULTS__140MM_DARK 0x01AC
+#define VL53L1_NVM__FMT__RANGE_RESULTS__400MM_DARK 0x01BC
+#define VL53L1_NVM__FMT__RANGE_RESULTS__400MM_AMBIENT 0x01CC
+#define VL53L1_NVM__FMT__RANGE_RESULTS__SIZE_BYTES 16
+
+/** @} VL53L1_nvm_DefineRegisters_group */
+
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_preset_setup.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_preset_setup.h
new file mode 100644
index 0000000..eb41b56
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_preset_setup.h
@@ -0,0 +1,111 @@
+
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+#ifndef _VL53L1_PRESET_SETUP_H_
+#define _VL53L1_PRESET_SETUP_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* indexes for the bare driver tuning setting API function */
+enum VL53L1_Tuning_t {
+ VL53L1_TUNING_VERSION = 0,
+ VL53L1_TUNING_PROXY_MIN,
+ VL53L1_TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM,
+ VL53L1_TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER,
+ VL53L1_TUNING_MIN_AMBIENT_DMAX_VALID,
+ VL53L1_TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER,
+ VL53L1_TUNING_XTALK_FULL_ROI_TARGET_DISTANCE_MM,
+ VL53L1_TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT,
+
+ VL53L1_TUNING_MAX_TUNABLE_KEY
+};
+
+/* default values for the tuning settings parameters */
+#define TUNING_VERSION 0x0004
+
+#define TUNING_PROXY_MIN -30 /* min distance in mm */
+#define TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM 600
+/* Target distance in mm for single target Xtalk */
+#define TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER 50
+/* Number of sample used for single target Xtalk */
+#define TUNING_MIN_AMBIENT_DMAX_VALID 8
+/* Minimum ambient level to state the Dmax returned by the device is valid */
+#define TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER 50
+/* Maximum loops to perform simple offset calibration */
+#define TUNING_XTALK_FULL_ROI_TARGET_DISTANCE_MM 600
+/* Target distance in mm for target Xtalk from Bins method*/
+#define TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT 1
+/* Number of loops done during the simple offset calibration*/
+
+/* the following table should actually be defined as static and shall be part
+ * of the VL53L1_StaticInit() function code
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VL53L1_PRESET_SETUP_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_register_funcs.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_register_funcs.h
new file mode 100644
index 0000000..b7a1f05
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_register_funcs.h
@@ -0,0 +1,1635 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_register_funcs.h
+ * @brief VL53L1 Register Function declarations
+ */
+
+#ifndef _VL53L1_REGISTER_FUNCS_H_
+#define _VL53L1_REGISTER_FUNCS_H_
+
+#include "vl53l1_platform.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+/**
+ * @brief Encodes data structure VL53L1_static_nvm_managed_t into a I2C write buffer
+ *
+ * Buffer must be at least 11 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_static_nvm_managed_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+VL53L1_Error VL53L1_i2c_encode_static_nvm_managed(
+ VL53L1_static_nvm_managed_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes data structure VL53L1_static_nvm_managed_t from the input I2C read buffer
+ *
+ * Buffer must be at least 11 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_static_nvm_managed_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_i2c_decode_static_nvm_managed(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_static_nvm_managed_t *pdata);
+
+
+/**
+ * @brief Sets static_nvm_managed register group
+ *
+ * Serailises (encodes) VL53L1_static_nvm_managed_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_static_nvm_managed_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_static_nvm_managed(
+ VL53L1_DEV Dev,
+ VL53L1_static_nvm_managed_t *pdata);
+
+
+/**
+ * @brief Gets static_nvm_managed register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_static_nvm_managed_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_static_nvm_managed_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_static_nvm_managed(
+ VL53L1_DEV Dev,
+ VL53L1_static_nvm_managed_t *pdata);
+
+
+/**
+ * @brief Encodes data structure VL53L1_customer_nvm_managed_t into a I2C write buffer
+ *
+ * Buffer must be at least 23 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_customer_nvm_managed_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+VL53L1_Error VL53L1_i2c_encode_customer_nvm_managed(
+ VL53L1_customer_nvm_managed_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes data structure VL53L1_customer_nvm_managed_t from the input I2C read buffer
+ *
+ * Buffer must be at least 23 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_customer_nvm_managed_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_i2c_decode_customer_nvm_managed(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_customer_nvm_managed_t *pdata);
+
+
+/**
+ * @brief Sets customer_nvm_managed register group
+ *
+ * Serailises (encodes) VL53L1_customer_nvm_managed_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_customer_nvm_managed_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_customer_nvm_managed(
+ VL53L1_DEV Dev,
+ VL53L1_customer_nvm_managed_t *pdata);
+
+
+/**
+ * @brief Gets customer_nvm_managed register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_customer_nvm_managed_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_customer_nvm_managed_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_customer_nvm_managed(
+ VL53L1_DEV Dev,
+ VL53L1_customer_nvm_managed_t *pdata);
+
+
+/**
+ * @brief Encodes data structure VL53L1_static_config_t into a I2C write buffer
+ *
+ * Buffer must be at least 32 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_static_config_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+VL53L1_Error VL53L1_i2c_encode_static_config(
+ VL53L1_static_config_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes data structure VL53L1_static_config_t from the input I2C read buffer
+ *
+ * Buffer must be at least 32 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_static_config_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_i2c_decode_static_config(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_static_config_t *pdata);
+
+
+/**
+ * @brief Sets static_config register group
+ *
+ * Serailises (encodes) VL53L1_static_config_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_static_config_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_static_config(
+ VL53L1_DEV Dev,
+ VL53L1_static_config_t *pdata);
+
+
+/**
+ * @brief Gets static_config register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_static_config_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_static_config_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_get_static_config(
+ VL53L1_DEV Dev,
+ VL53L1_static_config_t *pdata);
+#endif
+
+
+/**
+ * @brief Encodes data structure VL53L1_general_config_t into a I2C write buffer
+ *
+ * Buffer must be at least 22 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_general_config_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+VL53L1_Error VL53L1_i2c_encode_general_config(
+ VL53L1_general_config_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes data structure VL53L1_general_config_t from the input I2C read buffer
+ *
+ * Buffer must be at least 22 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_general_config_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_i2c_decode_general_config(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_general_config_t *pdata);
+
+
+/**
+ * @brief Sets general_config register group
+ *
+ * Serailises (encodes) VL53L1_general_config_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_general_config_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_general_config(
+ VL53L1_DEV Dev,
+ VL53L1_general_config_t *pdata);
+
+
+/**
+ * @brief Gets general_config register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_general_config_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_general_config_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_get_general_config(
+ VL53L1_DEV Dev,
+ VL53L1_general_config_t *pdata);
+#endif
+
+
+/**
+ * @brief Encodes data structure VL53L1_timing_config_t into a I2C write buffer
+ *
+ * Buffer must be at least 23 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_timing_config_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+VL53L1_Error VL53L1_i2c_encode_timing_config(
+ VL53L1_timing_config_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes data structure VL53L1_timing_config_t from the input I2C read buffer
+ *
+ * Buffer must be at least 23 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_timing_config_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_decode_timing_config(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_timing_config_t *pdata);
+#endif
+
+
+/**
+ * @brief Sets timing_config register group
+ *
+ * Serailises (encodes) VL53L1_timing_config_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_timing_config_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_set_timing_config(
+ VL53L1_DEV Dev,
+ VL53L1_timing_config_t *pdata);
+#endif
+
+
+/**
+ * @brief Gets timing_config register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_timing_config_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_timing_config_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_get_timing_config(
+ VL53L1_DEV Dev,
+ VL53L1_timing_config_t *pdata);
+#endif
+
+
+/**
+ * @brief Encodes data structure VL53L1_dynamic_config_t into a I2C write buffer
+ *
+ * Buffer must be at least 18 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_dynamic_config_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+VL53L1_Error VL53L1_i2c_encode_dynamic_config(
+ VL53L1_dynamic_config_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes data structure VL53L1_dynamic_config_t from the input I2C read buffer
+ *
+ * Buffer must be at least 18 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_dynamic_config_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_decode_dynamic_config(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_dynamic_config_t *pdata);
+#endif
+
+
+/**
+ * @brief Sets dynamic_config register group
+ *
+ * Serailises (encodes) VL53L1_dynamic_config_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_dynamic_config_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_dynamic_config(
+ VL53L1_DEV Dev,
+ VL53L1_dynamic_config_t *pdata);
+
+
+/**
+ * @brief Gets dynamic_config register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_dynamic_config_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_dynamic_config_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_get_dynamic_config(
+ VL53L1_DEV Dev,
+ VL53L1_dynamic_config_t *pdata);
+#endif
+
+/**
+ * @brief Encodes data structure VL53L1_system_control_t into a I2C write buffer
+ *
+ * Buffer must be at least 5 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_system_control_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+VL53L1_Error VL53L1_i2c_encode_system_control(
+ VL53L1_system_control_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes data structure VL53L1_system_control_t from the input I2C read buffer
+ *
+ * Buffer must be at least 5 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_system_control_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_decode_system_control(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_system_control_t *pdata);
+#endif
+
+
+/**
+ * @brief Sets system_control register group
+ *
+ * Serailises (encodes) VL53L1_system_control_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_system_control_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_system_control(
+ VL53L1_DEV Dev,
+ VL53L1_system_control_t *pdata);
+
+
+/**
+ * @brief Gets system_control register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_system_control_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_system_control_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_get_system_control(
+ VL53L1_DEV Dev,
+ VL53L1_system_control_t *pdata);
+#endif
+
+
+/**
+ * @brief Encodes data structure VL53L1_system_results_t into a I2C write buffer
+ *
+ * Buffer must be at least 44 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_system_results_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_encode_system_results(
+ VL53L1_system_results_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+#endif
+
+
+/**
+ * @brief Decodes data structure VL53L1_system_results_t from the input I2C read buffer
+ *
+ * Buffer must be at least 44 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_system_results_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_i2c_decode_system_results(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_system_results_t *pdata);
+
+
+/**
+ * @brief Sets system_results register group
+ *
+ * Serailises (encodes) VL53L1_system_results_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_system_results_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_set_system_results(
+ VL53L1_DEV Dev,
+ VL53L1_system_results_t *pdata);
+#endif
+
+
+/**
+ * @brief Gets system_results register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_system_results_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_system_results_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_system_results(
+ VL53L1_DEV Dev,
+ VL53L1_system_results_t *pdata);
+
+
+/**
+ * @brief Encodes data structure VL53L1_core_results_t into a I2C write buffer
+ *
+ * Buffer must be at least 33 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_core_results_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_encode_core_results(
+ VL53L1_core_results_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+#endif
+
+
+/**
+ * @brief Decodes data structure VL53L1_core_results_t from the input I2C read buffer
+ *
+ * Buffer must be at least 33 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_core_results_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_i2c_decode_core_results(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_core_results_t *pdata);
+
+
+/**
+ * @brief Sets core_results register group
+ *
+ * Serailises (encodes) VL53L1_core_results_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_core_results_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_set_core_results(
+ VL53L1_DEV Dev,
+ VL53L1_core_results_t *pdata);
+#endif
+
+
+/**
+ * @brief Gets core_results register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_core_results_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_core_results_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_get_core_results(
+ VL53L1_DEV Dev,
+ VL53L1_core_results_t *pdata);
+#endif
+
+
+/**
+ * @brief Encodes data structure VL53L1_debug_results_t into a I2C write buffer
+ *
+ * Buffer must be at least 56 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_debug_results_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_i2c_encode_debug_results(
+ VL53L1_debug_results_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+#endif
+
+/**
+ * @brief Decodes data structure VL53L1_debug_results_t from the input I2C read buffer
+ *
+ * Buffer must be at least 56 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_debug_results_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_i2c_decode_debug_results(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_debug_results_t *pdata);
+
+
+/**
+ * @brief Sets debug_results register group
+ *
+ * Serailises (encodes) VL53L1_debug_results_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_debug_results_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_set_debug_results(
+ VL53L1_DEV Dev,
+ VL53L1_debug_results_t *pdata);
+
+/**
+ * @brief Gets debug_results register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_debug_results_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_debug_results_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_debug_results(
+ VL53L1_DEV Dev,
+ VL53L1_debug_results_t *pdata);
+
+#endif
+
+/**
+ * @brief Encodes data structure VL53L1_nvm_copy_data_t into a I2C write buffer
+ *
+ * Buffer must be at least 49 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_nvm_copy_data_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_encode_nvm_copy_data(
+ VL53L1_nvm_copy_data_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+#endif
+
+
+/**
+ * @brief Decodes data structure VL53L1_nvm_copy_data_t from the input I2C read buffer
+ *
+ * Buffer must be at least 49 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_nvm_copy_data_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_i2c_decode_nvm_copy_data(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_nvm_copy_data_t *pdata);
+
+
+/**
+ * @brief Sets nvm_copy_data register group
+ *
+ * Serailises (encodes) VL53L1_nvm_copy_data_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_nvm_copy_data_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_set_nvm_copy_data(
+ VL53L1_DEV Dev,
+ VL53L1_nvm_copy_data_t *pdata);
+#endif
+
+
+/**
+ * @brief Gets nvm_copy_data register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_nvm_copy_data_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_nvm_copy_data_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_nvm_copy_data(
+ VL53L1_DEV Dev,
+ VL53L1_nvm_copy_data_t *pdata);
+
+
+/**
+ * @brief Encodes data structure VL53L1_prev_shadow_system_results_t into a I2C write buffer
+ *
+ * Buffer must be at least 44 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_prev_shadow_system_results_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_i2c_encode_prev_shadow_system_results(
+ VL53L1_prev_shadow_system_results_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes data structure VL53L1_prev_shadow_system_results_t from the input I2C read buffer
+ *
+ * Buffer must be at least 44 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_prev_shadow_system_results_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_i2c_decode_prev_shadow_system_results(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_prev_shadow_system_results_t *pdata);
+
+
+/**
+ * @brief Sets prev_shadow_system_results register group
+ *
+ * Serailises (encodes) VL53L1_prev_shadow_system_results_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_prev_shadow_system_results_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_prev_shadow_system_results(
+ VL53L1_DEV Dev,
+ VL53L1_prev_shadow_system_results_t *pdata);
+
+
+/**
+ * @brief Gets prev_shadow_system_results register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_prev_shadow_system_results_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_prev_shadow_system_results_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_prev_shadow_system_results(
+ VL53L1_DEV Dev,
+ VL53L1_prev_shadow_system_results_t *pdata);
+
+/**
+ * @brief Encodes data structure VL53L1_prev_shadow_core_results_t into a I2C write buffer
+ *
+ * Buffer must be at least 33 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_prev_shadow_core_results_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+VL53L1_Error VL53L1_i2c_encode_prev_shadow_core_results(
+ VL53L1_prev_shadow_core_results_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes data structure VL53L1_prev_shadow_core_results_t from the input I2C read buffer
+ *
+ * Buffer must be at least 33 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_prev_shadow_core_results_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_i2c_decode_prev_shadow_core_results(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_prev_shadow_core_results_t *pdata);
+
+
+/**
+ * @brief Sets prev_shadow_core_results register group
+ *
+ * Serailises (encodes) VL53L1_prev_shadow_core_results_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_prev_shadow_core_results_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_prev_shadow_core_results(
+ VL53L1_DEV Dev,
+ VL53L1_prev_shadow_core_results_t *pdata);
+
+
+/**
+ * @brief Gets prev_shadow_core_results register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_prev_shadow_core_results_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_prev_shadow_core_results_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+VL53L1_Error VL53L1_get_prev_shadow_core_results(
+ VL53L1_DEV Dev,
+ VL53L1_prev_shadow_core_results_t *pdata);
+
+
+/**
+ * @brief Encodes data structure VL53L1_patch_debug_t into a I2C write buffer
+ *
+ * Buffer must be at least 2 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_patch_debug_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+VL53L1_Error VL53L1_i2c_encode_patch_debug(
+ VL53L1_patch_debug_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes data structure VL53L1_patch_debug_t from the input I2C read buffer
+ *
+ * Buffer must be at least 2 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_patch_debug_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_i2c_decode_patch_debug(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_patch_debug_t *pdata);
+
+
+/**
+ * @brief Sets patch_debug register group
+ *
+ * Serailises (encodes) VL53L1_patch_debug_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_patch_debug_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_patch_debug(
+ VL53L1_DEV Dev,
+ VL53L1_patch_debug_t *pdata);
+
+
+/**
+ * @brief Gets patch_debug register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_patch_debug_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_patch_debug_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_patch_debug(
+ VL53L1_DEV Dev,
+ VL53L1_patch_debug_t *pdata);
+
+#endif
+
+/**
+ * @brief Encodes data structure VL53L1_gph_general_config_t into a I2C write buffer
+ *
+ * Buffer must be at least 5 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_gph_general_config_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_encode_gph_general_config(
+ VL53L1_gph_general_config_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+#endif
+
+
+/**
+ * @brief Decodes data structure VL53L1_gph_general_config_t from the input I2C read buffer
+ *
+ * Buffer must be at least 5 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_gph_general_config_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_decode_gph_general_config(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_gph_general_config_t *pdata);
+#endif
+
+
+/**
+ * @brief Sets gph_general_config register group
+ *
+ * Serailises (encodes) VL53L1_gph_general_config_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_gph_general_config_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_set_gph_general_config(
+ VL53L1_DEV Dev,
+ VL53L1_gph_general_config_t *pdata);
+#endif
+
+/**
+ * @brief Gets gph_general_config register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_gph_general_config_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_gph_general_config_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_get_gph_general_config(
+ VL53L1_DEV Dev,
+ VL53L1_gph_general_config_t *pdata);
+#endif
+
+
+/**
+ * @brief Encodes data structure VL53L1_gph_static_config_t into a I2C write buffer
+ *
+ * Buffer must be at least 6 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_gph_static_config_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_encode_gph_static_config(
+ VL53L1_gph_static_config_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+#endif
+
+
+/**
+ * @brief Decodes data structure VL53L1_gph_static_config_t from the input I2C read buffer
+ *
+ * Buffer must be at least 6 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_gph_static_config_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_decode_gph_static_config(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_gph_static_config_t *pdata);
+#endif
+
+
+/**
+ * @brief Sets gph_static_config register group
+ *
+ * Serailises (encodes) VL53L1_gph_static_config_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_gph_static_config_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_set_gph_static_config(
+ VL53L1_DEV Dev,
+ VL53L1_gph_static_config_t *pdata);
+#endif
+
+
+/**
+ * @brief Gets gph_static_config register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_gph_static_config_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_gph_static_config_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_get_gph_static_config(
+ VL53L1_DEV Dev,
+ VL53L1_gph_static_config_t *pdata);
+#endif
+
+
+/**
+ * @brief Encodes data structure VL53L1_gph_timing_config_t into a I2C write buffer
+ *
+ * Buffer must be at least 16 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_gph_timing_config_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_encode_gph_timing_config(
+ VL53L1_gph_timing_config_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+#endif
+
+
+/**
+ * @brief Decodes data structure VL53L1_gph_timing_config_t from the input I2C read buffer
+ *
+ * Buffer must be at least 16 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_gph_timing_config_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_decode_gph_timing_config(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_gph_timing_config_t *pdata);
+#endif
+
+
+/**
+ * @brief Sets gph_timing_config register group
+ *
+ * Serailises (encodes) VL53L1_gph_timing_config_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_gph_timing_config_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_set_gph_timing_config(
+ VL53L1_DEV Dev,
+ VL53L1_gph_timing_config_t *pdata);
+#endif
+
+
+/**
+ * @brief Gets gph_timing_config register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_gph_timing_config_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_gph_timing_config_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_get_gph_timing_config(
+ VL53L1_DEV Dev,
+ VL53L1_gph_timing_config_t *pdata);
+#endif
+
+
+/**
+ * @brief Encodes data structure VL53L1_fw_internal_t into a I2C write buffer
+ *
+ * Buffer must be at least 2 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_fw_internal_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_i2c_encode_fw_internal(
+ VL53L1_fw_internal_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes data structure VL53L1_fw_internal_t from the input I2C read buffer
+ *
+ * Buffer must be at least 2 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_fw_internal_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_i2c_decode_fw_internal(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_fw_internal_t *pdata);
+
+
+/**
+ * @brief Sets fw_internal register group
+ *
+ * Serailises (encodes) VL53L1_fw_internal_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_fw_internal_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_fw_internal(
+ VL53L1_DEV Dev,
+ VL53L1_fw_internal_t *pdata);
+
+
+/**
+ * @brief Gets fw_internal register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_fw_internal_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_fw_internal_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_fw_internal(
+ VL53L1_DEV Dev,
+ VL53L1_fw_internal_t *pdata);
+
+
+
+/**
+ * @brief Encodes data structure VL53L1_patch_results_t into a I2C write buffer
+ *
+ * Buffer must be at least 90 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_patch_results_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+VL53L1_Error VL53L1_i2c_encode_patch_results(
+ VL53L1_patch_results_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes data structure VL53L1_patch_results_t from the input I2C read buffer
+ *
+ * Buffer must be at least 90 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_patch_results_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_i2c_decode_patch_results(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_patch_results_t *pdata);
+
+
+/**
+ * @brief Sets patch_results register group
+ *
+ * Serailises (encodes) VL53L1_patch_results_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_patch_results_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_patch_results(
+ VL53L1_DEV Dev,
+ VL53L1_patch_results_t *pdata);
+
+
+/**
+ * @brief Gets patch_results register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_patch_results_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_patch_results_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_patch_results(
+ VL53L1_DEV Dev,
+ VL53L1_patch_results_t *pdata);
+#endif
+
+
+/**
+ * @brief Encodes data structure VL53L1_shadow_system_results_t into a I2C write buffer
+ *
+ * Buffer must be at least 82 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_shadow_system_results_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_i2c_encode_shadow_system_results(
+ VL53L1_shadow_system_results_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes data structure VL53L1_shadow_system_results_t from the input I2C read buffer
+ *
+ * Buffer must be at least 82 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_shadow_system_results_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_i2c_decode_shadow_system_results(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_shadow_system_results_t *pdata);
+
+
+/**
+ * @brief Sets shadow_system_results register group
+ *
+ * Serailises (encodes) VL53L1_shadow_system_results_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_shadow_system_results_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_shadow_system_results(
+ VL53L1_DEV Dev,
+ VL53L1_shadow_system_results_t *pdata);
+
+
+/**
+ * @brief Gets shadow_system_results register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_shadow_system_results_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_shadow_system_results_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_shadow_system_results(
+ VL53L1_DEV Dev,
+ VL53L1_shadow_system_results_t *pdata);
+
+
+/**
+ * @brief Encodes data structure VL53L1_shadow_core_results_t into a I2C write buffer
+ *
+ * Buffer must be at least 33 bytes
+ *
+ * @param[in] pdata : pointer to VL53L1_shadow_core_results_t data structure
+ * @param[in] buf_size : size of input buffer
+ * @param[out] pbuffer : uint8_t buffer to write serialised data into (I2C Write Buffer)
+ */
+
+VL53L1_Error VL53L1_i2c_encode_shadow_core_results(
+ VL53L1_shadow_core_results_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer);
+
+
+/**
+ * @brief Decodes data structure VL53L1_shadow_core_results_t from the input I2C read buffer
+ *
+ * Buffer must be at least 33 bytes
+ *
+ * @param[in] buf_size : size of input buffer
+ * @param[in] pbuffer : uint8_t buffer contain input serialised data (I2C read buffer)
+ * @param[out] pdata : pointer to VL53L1_shadow_core_results_t data structure
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_i2c_decode_shadow_core_results(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_shadow_core_results_t *pdata);
+
+
+/**
+ * @brief Sets shadow_core_results register group
+ *
+ * Serailises (encodes) VL53L1_shadow_core_results_t structure into a I2C write data buffer
+ * and sends the buffer to the device via a multi byte I2C write transaction
+ *
+ * @param[in] Dev : device handle
+ * @param[in] pdata : pointer to VL53L1_shadow_core_results_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_set_shadow_core_results(
+ VL53L1_DEV Dev,
+ VL53L1_shadow_core_results_t *pdata);
+
+
+/**
+ * @brief Gets shadow_core_results register group
+ *
+ * Reads register info from the device via a multi byte I2C read transaction and
+ * deserialises (decodes) the data into the VL53L1_shadow_core_results_t structure
+ *
+ * @param[in] Dev : device handle
+ * @param[out] pdata : pointer to VL53L1_shadow_core_results_t
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_get_shadow_core_results(
+ VL53L1_DEV Dev,
+ VL53L1_shadow_core_results_t *pdata);
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_register_map.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_register_map.h
new file mode 100644
index 0000000..7810e3b
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_register_map.h
@@ -0,0 +1,11895 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_register_map.h
+ * @brief VL53L1 Register Map definitions
+ */
+
+#ifndef _VL53L1_REGISTER_MAP_H_
+#define _VL53L1_REGISTER_MAP_H_
+
+/** @defgroup VL53L1_register_DefineRegisters_group Define Registers * @brief List of all the defined registers
+ * @{
+ */
+
+#define VL53L1_SOFT_RESET 0x0000
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_I2C_SLAVE__DEVICE_ADDRESS 0x0001
+/*!<
+ type: uint8_t \n
+ default: EWOK_I2C_DEV_ADDR_DEFAULT \n
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_nvm_managed', 'system_config']
+
+ fields: \n
+ - [6:0] = i2c_slave_device_address
+*/
+#define VL53L1_ANA_CONFIG__VHV_REF_SEL_VDDPIX 0x0002
+/*!<
+ type: uint8_t \n
+ default: 0x02 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_nvm_managed', 'analog_config']
+
+ fields: \n
+ - [3:0] = ref_sel_vddpix
+*/
+#define VL53L1_ANA_CONFIG__VHV_REF_SEL_VQUENCH 0x0003
+/*!<
+ type: uint8_t \n
+ default: 0x10 \n
+ info: \n
+ - msb = 6
+ - lsb = 3
+ - i2c_size = 1
+
+ groups: \n
+ ['static_nvm_managed', 'analog_config']
+
+ fields: \n
+ - [6:3] = ref_sel_vquench
+*/
+#define VL53L1_ANA_CONFIG__REG_AVDD1V2_SEL 0x0004
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_nvm_managed', 'analog_config']
+
+ fields: \n
+ - [1:0] = reg_avdd1v2_sel
+*/
+#define VL53L1_ANA_CONFIG__FAST_OSC__TRIM 0x0005
+/*!<
+ type: uint8_t \n
+ default: 0x48 \n
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_nvm_managed', 'analog_config']
+
+ fields: \n
+ - [6:0] = fast_osc_trim
+*/
+#define VL53L1_OSC_MEASURED__FAST_OSC__FREQUENCY 0x0006
+/*!<
+ type: uint16_t \n
+ default: OSC_FREQUENCY \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['static_nvm_managed', 'analog_config']
+
+ fields: \n
+ - [15:0] = osc_frequency (fixed point 4.12)
+*/
+#define VL53L1_OSC_MEASURED__FAST_OSC__FREQUENCY_HI 0x0006
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_OSC_MEASURED__FAST_OSC__FREQUENCY_LO 0x0007
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND 0x0008
+/*!<
+ type: uint8_t \n
+ default: 0x81 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_nvm_managed', 'vhv_config']
+
+ fields: \n
+ - [1:0] = vhv_timeout__macrop
+ - [7:2] = vhv_loop_bound
+*/
+#define VL53L1_VHV_CONFIG__COUNT_THRESH 0x0009
+/*!<
+ type: uint8_t \n
+ default: 0x80 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_nvm_managed', 'vhv_config']
+
+ fields: \n
+ - [7:0] = vhv_count_thresh
+*/
+#define VL53L1_VHV_CONFIG__OFFSET 0x000A
+/*!<
+ type: uint8_t \n
+ default: 0x07 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_nvm_managed', 'vhv_config']
+
+ fields: \n
+ - [5:0] = vhv_step_val
+*/
+#define VL53L1_VHV_CONFIG__INIT 0x000B
+/*!<
+ type: uint8_t \n
+ default: 0x20 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_nvm_managed', 'vhv_config']
+
+ fields: \n
+ - [7] = vhv0_init_enable
+ - [5:0] = vhv0_init_value
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_REF_0 0x000D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['customer_nvm_managed', 'ref_spad_en']
+
+ fields: \n
+ - [7:0] = spad_enables_ref_0
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_REF_1 0x000E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['customer_nvm_managed', 'ref_spad_en']
+
+ fields: \n
+ - [7:0] = spad_enables_ref_1
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_REF_2 0x000F
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['customer_nvm_managed', 'ref_spad_en']
+
+ fields: \n
+ - [7:0] = spad_enables_ref_2
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_REF_3 0x0010
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['customer_nvm_managed', 'ref_spad_en']
+
+ fields: \n
+ - [7:0] = spad_enables_ref_3
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_REF_4 0x0011
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['customer_nvm_managed', 'ref_spad_en']
+
+ fields: \n
+ - [7:0] = spad_enables_ref_4
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_REF_5 0x0012
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['customer_nvm_managed', 'ref_spad_en']
+
+ fields: \n
+ - [3:0] = spad_enables_ref_5
+*/
+#define VL53L1_GLOBAL_CONFIG__REF_EN_START_SELECT 0x0013
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['customer_nvm_managed', 'ref_spad_start']
+
+ fields: \n
+ - [7:0] = ref_en_start_select
+*/
+#define VL53L1_REF_SPAD_MAN__NUM_REQUESTED_REF_SPADS 0x0014
+/*!<
+ type: uint8_t \n
+ default: 0x2C \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['customer_nvm_managed', 'ref_spad_config']
+
+ fields: \n
+ - [5:0] = ref_spad_man__num_requested_ref_spad
+*/
+#define VL53L1_REF_SPAD_MAN__REF_LOCATION 0x0015
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['customer_nvm_managed', 'ref_spad_config']
+
+ fields: \n
+ - [1:0] = ref_spad_man__ref_location
+*/
+#define VL53L1_ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS 0x0016
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['customer_nvm_managed', 'algo_config']
+
+ fields: \n
+ - [15:0] = crosstalk_compensation_plane_offset_kcps (fixed point 7.9)
+*/
+#define VL53L1_ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS_HI 0x0016
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS_LO 0x0017
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS 0x0018
+/*!<
+ type: int16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['customer_nvm_managed', 'algo_config']
+
+ fields: \n
+ - [15:0] = crosstalk_compensation_x_plane_gradient_kcps (fixed point 5.11)
+*/
+#define VL53L1_ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS_HI 0x0018
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS_LO 0x0019
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS 0x001A
+/*!<
+ type: int16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['customer_nvm_managed', 'algo_config']
+
+ fields: \n
+ - [15:0] = crosstalk_compensation_y_plane_gradient_kcps (fixed point 5.11)
+*/
+#define VL53L1_ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS_HI 0x001A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS_LO 0x001B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_REF_SPAD_CHAR__TOTAL_RATE_TARGET_MCPS 0x001C
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['customer_nvm_managed', 'ref_spad_char']
+
+ fields: \n
+ - [15:0] = ref_spad_char__total_rate_target_mcps (fixed point 9.7)
+*/
+#define VL53L1_REF_SPAD_CHAR__TOTAL_RATE_TARGET_MCPS_HI 0x001C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_REF_SPAD_CHAR__TOTAL_RATE_TARGET_MCPS_LO 0x001D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_ALGO__PART_TO_PART_RANGE_OFFSET_MM 0x001E
+/*!<
+ type: int16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 12
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['customer_nvm_managed', 'algo_config']
+
+ fields: \n
+ - [12:0] = part_to_part_offset_mm (fixed point 11.2)
+*/
+#define VL53L1_ALGO__PART_TO_PART_RANGE_OFFSET_MM_HI 0x001E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_ALGO__PART_TO_PART_RANGE_OFFSET_MM_LO 0x001F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MM_CONFIG__INNER_OFFSET_MM 0x0020
+/*!<
+ type: int16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['customer_nvm_managed', 'mm_config']
+
+ fields: \n
+ - [15:0] = mm_config__inner_offset_mm
+*/
+#define VL53L1_MM_CONFIG__INNER_OFFSET_MM_HI 0x0020
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MM_CONFIG__INNER_OFFSET_MM_LO 0x0021
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MM_CONFIG__OUTER_OFFSET_MM 0x0022
+/*!<
+ type: int16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['customer_nvm_managed', 'mm_config']
+
+ fields: \n
+ - [15:0] = mm_config__outer_offset_mm
+*/
+#define VL53L1_MM_CONFIG__OUTER_OFFSET_MM_HI 0x0022
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MM_CONFIG__OUTER_OFFSET_MM_LO 0x0023
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_DSS_CONFIG__TARGET_TOTAL_RATE_MCPS 0x0024
+/*!<
+ type: uint16_t \n
+ default: 0x0380 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['static_config', 'dss_config']
+
+ fields: \n
+ - [15:0] = dss_config__target_total_rate_mcps (fixed point 9.7)
+*/
+#define VL53L1_DSS_CONFIG__TARGET_TOTAL_RATE_MCPS_HI 0x0024
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_DSS_CONFIG__TARGET_TOTAL_RATE_MCPS_LO 0x0025
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_DEBUG__CTRL 0x0026
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'debug_config']
+
+ fields: \n
+ - [0] = enable_result_logging
+*/
+#define VL53L1_TEST_MODE__CTRL 0x0027
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'test_mode_config']
+
+ fields: \n
+ - [3:0] = test_mode__cmd
+*/
+#define VL53L1_CLK_GATING__CTRL 0x0028
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'clk_config']
+
+ fields: \n
+ - [0] = clk_gate_en__mcu_bank
+ - [1] = clk_gate_en__mcu_patch_ctrl
+ - [2] = clk_gate_en__mcu_timers
+ - [3] = clk_gate_en__mcu_mult_div
+*/
+#define VL53L1_NVM_BIST__CTRL 0x0029
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 4
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'nvm_bist_config']
+
+ fields: \n
+ - [2:0] = nvm_bist__cmd
+ - [4] = nvm_bist__ctrl
+*/
+#define VL53L1_NVM_BIST__NUM_NVM_WORDS 0x002A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'nvm_bist_config']
+
+ fields: \n
+ - [6:0] = nvm_bist__num_nvm_words
+*/
+#define VL53L1_NVM_BIST__START_ADDRESS 0x002B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'nvm_bist_config']
+
+ fields: \n
+ - [6:0] = nvm_bist__start_address
+*/
+#define VL53L1_HOST_IF__STATUS 0x002C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'system_status']
+
+ fields: \n
+ - [0] = host_interface
+*/
+#define VL53L1_PAD_I2C_HV__CONFIG 0x002D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'gpio_config']
+
+ fields: \n
+ - [0] = pad_scl_sda__vmodeint_hv
+ - [1] = i2c_pad__test_hv
+ - [2] = pad_scl__fpen_hv
+ - [4:3] = pad_scl__progdel_hv
+ - [5] = pad_sda__fpen_hv
+ - [7:6] = pad_sda__progdel_hv
+*/
+#define VL53L1_PAD_I2C_HV__EXTSUP_CONFIG 0x002E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'gpio_config']
+
+ fields: \n
+ - [0] = pad_scl_sda__extsup_hv
+*/
+#define VL53L1_GPIO_HV_PAD__CTRL 0x002F
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'gpio_config']
+
+ fields: \n
+ - [0] = gpio__extsup_hv
+ - [1] = gpio__vmodeint_hv
+*/
+#define VL53L1_GPIO_HV_MUX__CTRL 0x0030
+/*!<
+ type: uint8_t \n
+ default: 0x11 \n
+ info: \n
+ - msb = 4
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'gpio_config']
+
+ fields: \n
+ - [3:0] = gpio__mux_select_hv
+ - [4] = gpio__mux_active_high_hv
+*/
+#define VL53L1_GPIO__TIO_HV_STATUS 0x0031
+/*!<
+ type: uint8_t \n
+ default: 0x02 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'gpio_config']
+
+ fields: \n
+ - [0] = gpio__tio_hv
+ - [1] = fresh_out_of_reset
+*/
+#define VL53L1_GPIO__FIO_HV_STATUS 0x0032
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 1
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'gpio_config']
+
+ fields: \n
+ - [1] = gpio__fio_hv
+*/
+#define VL53L1_ANA_CONFIG__SPAD_SEL_PSWIDTH 0x0033
+/*!<
+ type: uint8_t \n
+ default: 0x02 \n
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'analog_config']
+
+ fields: \n
+ - [2:0] = spad_sel_pswidth
+*/
+#define VL53L1_ANA_CONFIG__VCSEL_PULSE_WIDTH_OFFSET 0x0034
+/*!<
+ type: uint8_t \n
+ default: 0x08 \n
+ info: \n
+ - msb = 4
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'analog_config']
+
+ fields: \n
+ - [4:0] = vcsel_pulse_width_offset (fixed point 1.4)
+*/
+#define VL53L1_ANA_CONFIG__FAST_OSC__CONFIG_CTRL 0x0035
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'analog_config']
+
+ fields: \n
+ - [0] = osc_config__latch_bypass
+*/
+#define VL53L1_SIGMA_ESTIMATOR__EFFECTIVE_PULSE_WIDTH_NS 0x0036
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'algo_config']
+
+ fields: \n
+ - [7:0] = sigma_estimator__eff_pulse_width
+*/
+#define VL53L1_SIGMA_ESTIMATOR__EFFECTIVE_AMBIENT_WIDTH_NS 0x0037
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'algo_config']
+
+ fields: \n
+ - [7:0] = sigma_estimator__eff_ambient_width
+*/
+#define VL53L1_SIGMA_ESTIMATOR__SIGMA_REF_MM 0x0038
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'algo_config']
+
+ fields: \n
+ - [7:0] = sigma_estimator__sigma_ref
+*/
+#define VL53L1_ALGO__CROSSTALK_COMPENSATION_VALID_HEIGHT_MM 0x0039
+/*!<
+ type: uint8_t \n
+ default: 0x14 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'algo_config']
+
+ fields: \n
+ - [7:0] = crosstalk_compensation_valid_height_mm
+*/
+#define VL53L1_SPARE_HOST_CONFIG__STATIC_CONFIG_SPARE_0 0x003A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'algo_config']
+
+ fields: \n
+ - [7:0] = static_config_spare_0
+*/
+#define VL53L1_SPARE_HOST_CONFIG__STATIC_CONFIG_SPARE_1 0x003B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'algo_config']
+
+ fields: \n
+ - [7:0] = static_config_spare_1
+*/
+#define VL53L1_ALGO__RANGE_IGNORE_THRESHOLD_MCPS 0x003C
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['static_config', 'algo_config']
+
+ fields: \n
+ - [15:0] = range_ignore_thresh_mcps (fixed point 3.13)
+*/
+#define VL53L1_ALGO__RANGE_IGNORE_THRESHOLD_MCPS_HI 0x003C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_ALGO__RANGE_IGNORE_THRESHOLD_MCPS_LO 0x003D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_ALGO__RANGE_IGNORE_VALID_HEIGHT_MM 0x003E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'algo_config']
+
+ fields: \n
+ - [7:0] = range_ignore_height_mm
+*/
+#define VL53L1_ALGO__RANGE_MIN_CLIP 0x003F
+/*!<
+ type: uint8_t \n
+ default: 0x8D \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'algo_config']
+
+ fields: \n
+ - [0] = algo__range_min_clip_enable
+ - [7:1] = algo__range_min_clip_value_mm
+*/
+#define VL53L1_ALGO__CONSISTENCY_CHECK__TOLERANCE 0x0040
+/*!<
+ type: uint8_t \n
+ default: 0x08 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'algo_config']
+
+ fields: \n
+ - [3:0] = consistency_check_tolerance (fixed point 1.3)
+*/
+#define VL53L1_SPARE_HOST_CONFIG__STATIC_CONFIG_SPARE_2 0x0041
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'algo_config']
+
+ fields: \n
+ - [7:0] = static_config_spare_2
+*/
+#define VL53L1_SD_CONFIG__RESET_STAGES_MSB 0x0042
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'sigmadelta_config']
+
+ fields: \n
+ - [3:0] = loop_init__clear_stage
+*/
+#define VL53L1_SD_CONFIG__RESET_STAGES_LSB 0x0043
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['static_config', 'sigmadelta_config']
+
+ fields: \n
+ - [7:4] = accum_reset__clear_stage
+ - [3:0] = count_reset__clear_stage
+*/
+#define VL53L1_GPH_CONFIG__STREAM_COUNT_UPDATE_VALUE 0x0044
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['general_config', 'roi_config']
+
+ fields: \n
+ - [7:0] = stream_count_update_value
+*/
+#define VL53L1_GLOBAL_CONFIG__STREAM_DIVIDER 0x0045
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['general_config', 'roi_config']
+
+ fields: \n
+ - [7:0] = stream_count_internal_div
+*/
+#define VL53L1_SYSTEM__INTERRUPT_CONFIG_GPIO 0x0046
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['general_config', 'gph_config']
+
+ fields: \n
+ - [1:0] = int_mode_distance
+ - [3:2] = int_mode_rate
+ - [4] = int_spare
+ - [5] = int_new_measure_ready
+ - [6] = int_no_target_en
+ - [7] = int_combined_mode
+*/
+#define VL53L1_CAL_CONFIG__VCSEL_START 0x0047
+/*!<
+ type: uint8_t \n
+ default: 0x0B \n
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['general_config', 'cal_config']
+
+ fields: \n
+ - [6:0] = cal_config__vcsel_start
+*/
+#define VL53L1_CAL_CONFIG__REPEAT_RATE 0x0048
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 11
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['general_config', 'cal_config']
+
+ fields: \n
+ - [11:0] = cal_config__repeat_rate
+*/
+#define VL53L1_CAL_CONFIG__REPEAT_RATE_HI 0x0048
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_CAL_CONFIG__REPEAT_RATE_LO 0x0049
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_GLOBAL_CONFIG__VCSEL_WIDTH 0x004A
+/*!<
+ type: uint8_t \n
+ default: 0x02 \n
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['general_config', 'global_config']
+
+ fields: \n
+ - [6:0] = global_config__vcsel_width
+*/
+#define VL53L1_PHASECAL_CONFIG__TIMEOUT_MACROP 0x004B
+/*!<
+ type: uint8_t \n
+ default: 0x04 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['general_config', 'phasecal_config']
+
+ fields: \n
+ - [7:0] = phasecal_config__timeout_macrop
+*/
+#define VL53L1_PHASECAL_CONFIG__TARGET 0x004C
+/*!<
+ type: uint8_t \n
+ default: 0x21 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['general_config', 'phasecal_config']
+
+ fields: \n
+ - [7:0] = algo_phasecal_lim
+*/
+#define VL53L1_PHASECAL_CONFIG__OVERRIDE 0x004D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['general_config', 'phasecal_config']
+
+ fields: \n
+ - [0] = phasecal_config__override
+*/
+#define VL53L1_DSS_CONFIG__ROI_MODE_CONTROL 0x004F
+/*!<
+ type: uint8_t \n
+ default: 0x01 \n
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['general_config', 'dss_config']
+
+ fields: \n
+ - [1:0] = dss_config__input_mode
+ - [2] = calculate_roi_enable
+*/
+#define VL53L1_SYSTEM__THRESH_RATE_HIGH 0x0050
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['general_config', 'gph_config']
+
+ fields: \n
+ - [15:0] = thresh_rate_high (fixed point 9.7)
+*/
+#define VL53L1_SYSTEM__THRESH_RATE_HIGH_HI 0x0050
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SYSTEM__THRESH_RATE_HIGH_LO 0x0051
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SYSTEM__THRESH_RATE_LOW 0x0052
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['general_config', 'gph_config']
+
+ fields: \n
+ - [15:0] = thresh_rate_low (fixed point 9.7)
+*/
+#define VL53L1_SYSTEM__THRESH_RATE_LOW_HI 0x0052
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SYSTEM__THRESH_RATE_LOW_LO 0x0053
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_DSS_CONFIG__MANUAL_EFFECTIVE_SPADS_SELECT 0x0054
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['general_config', 'dss_config']
+
+ fields: \n
+ - [15:0] = dss_config__manual_effective_spads_select
+*/
+#define VL53L1_DSS_CONFIG__MANUAL_EFFECTIVE_SPADS_SELECT_HI 0x0054
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_DSS_CONFIG__MANUAL_EFFECTIVE_SPADS_SELECT_LO 0x0055
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_DSS_CONFIG__MANUAL_BLOCK_SELECT 0x0056
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['general_config', 'dss_config']
+
+ fields: \n
+ - [7:0] = dss_config__manual_block_select
+*/
+#define VL53L1_DSS_CONFIG__APERTURE_ATTENUATION 0x0057
+/*!<
+ type: uint8_t \n
+ default: 0x33 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['general_config', 'dss_config']
+
+ fields: \n
+ - [7:0] = dss_config__aperture_attenuation
+*/
+#define VL53L1_DSS_CONFIG__MAX_SPADS_LIMIT 0x0058
+/*!<
+ type: uint8_t \n
+ default: 0xFF \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['general_config', 'dss_config']
+
+ fields: \n
+ - [7:0] = dss_config__max_spads_limit
+*/
+#define VL53L1_DSS_CONFIG__MIN_SPADS_LIMIT 0x0059
+/*!<
+ type: uint8_t \n
+ default: 0x01 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['general_config', 'dss_config']
+
+ fields: \n
+ - [7:0] = dss_config__min_spads_limit
+*/
+#define VL53L1_MM_CONFIG__TIMEOUT_MACROP_A_HI 0x005A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['timing_config', 'mm_config']
+
+ fields: \n
+ - [3:0] = mm_config__config_timeout_macrop_a_hi
+*/
+#define VL53L1_MM_CONFIG__TIMEOUT_MACROP_A_LO 0x005B
+/*!<
+ type: uint8_t \n
+ default: 0x06 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['timing_config', 'mm_config']
+
+ fields: \n
+ - [7:0] = mm_config__config_timeout_macrop_a_lo
+*/
+#define VL53L1_MM_CONFIG__TIMEOUT_MACROP_B_HI 0x005C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['timing_config', 'mm_config']
+
+ fields: \n
+ - [3:0] = mm_config__config_timeout_macrop_b_hi
+*/
+#define VL53L1_MM_CONFIG__TIMEOUT_MACROP_B_LO 0x005D
+/*!<
+ type: uint8_t \n
+ default: 0x06 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['timing_config', 'mm_config']
+
+ fields: \n
+ - [7:0] = mm_config__config_timeout_macrop_b_lo
+*/
+#define VL53L1_RANGE_CONFIG__TIMEOUT_MACROP_A_HI 0x005E
+/*!<
+ type: uint8_t \n
+ default: 0x01 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['timing_config', 'range_config']
+
+ fields: \n
+ - [3:0] = range_timeout_overall_periods_macrop_a_hi
+*/
+#define VL53L1_RANGE_CONFIG__TIMEOUT_MACROP_A_LO 0x005F
+/*!<
+ type: uint8_t \n
+ default: 0x92 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['timing_config', 'range_config']
+
+ fields: \n
+ - [7:0] = range_timeout_overall_periods_macrop_a_lo
+*/
+#define VL53L1_RANGE_CONFIG__VCSEL_PERIOD_A 0x0060
+/*!<
+ type: uint8_t \n
+ default: 0x0B \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['timing_config', 'range_config']
+
+ fields: \n
+ - [5:0] = range_config__vcsel_period_a
+*/
+#define VL53L1_RANGE_CONFIG__TIMEOUT_MACROP_B_HI 0x0061
+/*!<
+ type: uint8_t \n
+ default: 0x01 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['timing_config', 'range_config']
+
+ fields: \n
+ - [3:0] = range_timeout_overall_periods_macrop_b_hi
+*/
+#define VL53L1_RANGE_CONFIG__TIMEOUT_MACROP_B_LO 0x0062
+/*!<
+ type: uint8_t \n
+ default: 0x92 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['timing_config', 'range_config']
+
+ fields: \n
+ - [7:0] = range_timeout_overall_periods_macrop_b_lo
+*/
+#define VL53L1_RANGE_CONFIG__VCSEL_PERIOD_B 0x0063
+/*!<
+ type: uint8_t \n
+ default: 0x09 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['timing_config', 'range_config']
+
+ fields: \n
+ - [5:0] = range_config__vcsel_period_b
+*/
+#define VL53L1_RANGE_CONFIG__SIGMA_THRESH 0x0064
+/*!<
+ type: uint16_t \n
+ default: 0x0080 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['timing_config', 'range_config']
+
+ fields: \n
+ - [15:0] = range_config__sigma_thresh (fixed point 14.2)
+*/
+#define VL53L1_RANGE_CONFIG__SIGMA_THRESH_HI 0x0064
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGE_CONFIG__SIGMA_THRESH_LO 0x0065
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS 0x0066
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['timing_config', 'range_config']
+
+ fields: \n
+ - [15:0] = range_config__min_count_rate_rtn_limit_mcps (fixed point 9.7)
+*/
+#define VL53L1_RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS_HI 0x0066
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS_LO 0x0067
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGE_CONFIG__VALID_PHASE_LOW 0x0068
+/*!<
+ type: uint8_t \n
+ default: 0x08 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['timing_config', 'range_config']
+
+ fields: \n
+ - [7:0] = range_config__valid_phase_low (fixed point 5.3)
+*/
+#define VL53L1_RANGE_CONFIG__VALID_PHASE_HIGH 0x0069
+/*!<
+ type: uint8_t \n
+ default: 0x80 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['timing_config', 'range_config']
+
+ fields: \n
+ - [7:0] = range_config__valid_phase_high (fixed point 5.3)
+*/
+#define VL53L1_SYSTEM__INTERMEASUREMENT_PERIOD 0x006C
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['timing_config', 'system_config']
+
+ fields: \n
+ - [31:0] = intermeasurement_period
+*/
+#define VL53L1_SYSTEM__INTERMEASUREMENT_PERIOD_3 0x006C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SYSTEM__INTERMEASUREMENT_PERIOD_2 0x006D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SYSTEM__INTERMEASUREMENT_PERIOD_1 0x006E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SYSTEM__INTERMEASUREMENT_PERIOD_0 0x006F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SYSTEM__FRACTIONAL_ENABLE 0x0070
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['timing_config', 'system_config']
+
+ fields: \n
+ - [0] = range_fractional_enable
+*/
+#define VL53L1_SYSTEM__GROUPED_PARAMETER_HOLD_0 0x0071
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['dynamic_config', 'gph_config']
+
+ fields: \n
+ - [0] = grouped_parameter_hold
+ - [1] = grouped_parameter_hold_id
+*/
+#define VL53L1_SYSTEM__THRESH_HIGH 0x0072
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['dynamic_config', 'gph_config']
+
+ fields: \n
+ - [15:0] = thresh_high
+*/
+#define VL53L1_SYSTEM__THRESH_HIGH_HI 0x0072
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SYSTEM__THRESH_HIGH_LO 0x0073
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SYSTEM__THRESH_LOW 0x0074
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['dynamic_config', 'gph_config']
+
+ fields: \n
+ - [15:0] = thresh_low
+*/
+#define VL53L1_SYSTEM__THRESH_LOW_HI 0x0074
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SYSTEM__THRESH_LOW_LO 0x0075
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SYSTEM__ENABLE_XTALK_PER_QUADRANT 0x0076
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['dynamic_config', 'gph_config']
+
+ fields: \n
+ - [0] = system__enable_xtalk_per_quadrant
+*/
+#define VL53L1_SYSTEM__SEED_CONFIG 0x0077
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['dynamic_config', 'gph_config']
+
+ fields: \n
+ - [1:0] = system__seed_config
+ - [2] = system__fw_pause_ctrl
+*/
+#define VL53L1_SD_CONFIG__WOI_SD0 0x0078
+/*!<
+ type: uint8_t \n
+ default: 0x04 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['dynamic_config', 'gph_config']
+
+ fields: \n
+ - [7:0] = sd_config__woi_sd0
+*/
+#define VL53L1_SD_CONFIG__WOI_SD1 0x0079
+/*!<
+ type: uint8_t \n
+ default: 0x04 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['dynamic_config', 'gph_config']
+
+ fields: \n
+ - [7:0] = sd_config__woi_sd1
+*/
+#define VL53L1_SD_CONFIG__INITIAL_PHASE_SD0 0x007A
+/*!<
+ type: uint8_t \n
+ default: 0x03 \n
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['dynamic_config', 'gph_config']
+
+ fields: \n
+ - [6:0] = sd_config__initial_phase_sd0
+*/
+#define VL53L1_SD_CONFIG__INITIAL_PHASE_SD1 0x007B
+/*!<
+ type: uint8_t \n
+ default: 0x03 \n
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['dynamic_config', 'gph_config']
+
+ fields: \n
+ - [6:0] = sd_config__initial_phase_sd1
+*/
+#define VL53L1_SYSTEM__GROUPED_PARAMETER_HOLD_1 0x007C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['dynamic_config', 'gph_config']
+
+ fields: \n
+ - [0] = grouped_parameter_hold
+ - [1] = grouped_parameter_hold_id
+*/
+#define VL53L1_SD_CONFIG__FIRST_ORDER_SELECT 0x007D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['dynamic_config', 'gph_config']
+
+ fields: \n
+ - [0] = sd_config__first_order_select_rtn
+ - [1] = sd_config__first_order_select_ref
+*/
+#define VL53L1_SD_CONFIG__QUANTIFIER 0x007E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['dynamic_config', 'gph_config']
+
+ fields: \n
+ - [3:0] = sd_config__quantifier
+*/
+#define VL53L1_ROI_CONFIG__USER_ROI_CENTRE_SPAD 0x007F
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['dynamic_config', 'gph_config']
+
+ fields: \n
+ - [7:0] = user_roi_center_spad
+*/
+#define VL53L1_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE 0x0080
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['dynamic_config', 'gph_config']
+
+ fields: \n
+ - [7:0] = roi_config__user_roi_requested_global_xy_size
+*/
+#define VL53L1_SYSTEM__SEQUENCE_CONFIG 0x0081
+/*!<
+ type: uint8_t \n
+ default: 0xFF \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['dynamic_config', 'gph_config']
+
+ fields: \n
+ - [0] = sequence_vhv_en
+ - [1] = sequence_phasecal_en
+ - [2] = sequence_reference_phase_en
+ - [3] = sequence_dss1_en
+ - [4] = sequence_dss2_en
+ - [5] = sequence_mm1_en
+ - [6] = sequence_mm2_en
+ - [7] = sequence_range_en
+*/
+#define VL53L1_SYSTEM__GROUPED_PARAMETER_HOLD 0x0082
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['dynamic_config', 'gph_config']
+
+ fields: \n
+ - [0] = grouped_parameter_hold
+ - [1] = grouped_parameter_hold_id
+*/
+#define VL53L1_POWER_MANAGEMENT__GO1_POWER_FORCE 0x0083
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['system_control', 'pwrman_ctrl']
+
+ fields: \n
+ - [0] = go1_dig_powerforce
+*/
+#define VL53L1_SYSTEM__STREAM_COUNT_CTRL 0x0084
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['system_control', 'stream_ctrl']
+
+ fields: \n
+ - [0] = retain_stream_count
+*/
+#define VL53L1_FIRMWARE__ENABLE 0x0085
+/*!<
+ type: uint8_t \n
+ default: 0x01 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['system_control', 'firmware_ctrl']
+
+ fields: \n
+ - [0] = firmware_enable
+*/
+#define VL53L1_SYSTEM__INTERRUPT_CLEAR 0x0086
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['system_control', 'system_int_clr']
+
+ fields: \n
+ - [0] = sys_interrupt_clear_range
+ - [1] = sys_interrupt_clear_error
+*/
+#define VL53L1_SYSTEM__MODE_START 0x0087
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['system_control', 'system_start']
+
+ fields: \n
+ - [1:0] = scheduler_mode
+ - [3:2] = readout_mode
+ - [4] = mode_range__single_shot
+ - [5] = mode_range__back_to_back
+ - [6] = mode_range__timed
+ - [7] = mode_range__abort
+*/
+#define VL53L1_RESULT__INTERRUPT_STATUS 0x0088
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [2:0] = int_status
+ - [4:3] = int_error_status
+ - [5] = gph_id_gpio_status
+*/
+#define VL53L1_RESULT__RANGE_STATUS 0x0089
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [4:0] = range_status
+ - [5] = max_threshold_hit
+ - [6] = min_threshold_hit
+ - [7] = gph_id_range_status
+*/
+#define VL53L1_RESULT__REPORT_STATUS 0x008A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [3:0] = report_status
+*/
+#define VL53L1_RESULT__STREAM_COUNT 0x008B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [7:0] = result__stream_count
+*/
+#define VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0 0x008C
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__dss_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+#define VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0_HI 0x008C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0_LO 0x008D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD0 0x008E
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__peak_signal_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+#define VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD0_HI 0x008E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD0_LO 0x008F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__AMBIENT_COUNT_RATE_MCPS_SD0 0x0090
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__ambient_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+#define VL53L1_RESULT__AMBIENT_COUNT_RATE_MCPS_SD0_HI 0x0090
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__AMBIENT_COUNT_RATE_MCPS_SD0_LO 0x0091
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__SIGMA_SD0 0x0092
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__sigma_sd0 (fixed point 14.2)
+*/
+#define VL53L1_RESULT__SIGMA_SD0_HI 0x0092
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__SIGMA_SD0_LO 0x0093
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__PHASE_SD0 0x0094
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__phase_sd0 (fixed point 5.11)
+*/
+#define VL53L1_RESULT__PHASE_SD0_HI 0x0094
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__PHASE_SD0_LO 0x0095
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 0x0096
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__final_crosstalk_corrected_range_mm_sd0
+*/
+#define VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0_HI 0x0096
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0_LO 0x0097
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0 0x0098
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0 (fixed point 9.7)
+*/
+#define VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0_HI 0x0098
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0_LO 0x0099
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__MM_INNER_ACTUAL_EFFECTIVE_SPADS_SD0 0x009A
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__mm_inner_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+#define VL53L1_RESULT__MM_INNER_ACTUAL_EFFECTIVE_SPADS_SD0_HI 0x009A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__MM_INNER_ACTUAL_EFFECTIVE_SPADS_SD0_LO 0x009B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__MM_OUTER_ACTUAL_EFFECTIVE_SPADS_SD0 0x009C
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__mm_outer_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+#define VL53L1_RESULT__MM_OUTER_ACTUAL_EFFECTIVE_SPADS_SD0_HI 0x009C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__MM_OUTER_ACTUAL_EFFECTIVE_SPADS_SD0_LO 0x009D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__AVG_SIGNAL_COUNT_RATE_MCPS_SD0 0x009E
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__avg_signal_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+#define VL53L1_RESULT__AVG_SIGNAL_COUNT_RATE_MCPS_SD0_HI 0x009E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__AVG_SIGNAL_COUNT_RATE_MCPS_SD0_LO 0x009F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD1 0x00A0
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__dss_actual_effective_spads_sd1 (fixed point 8.8)
+*/
+#define VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD1_HI 0x00A0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD1_LO 0x00A1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD1 0x00A2
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__peak_signal_count_rate_mcps_sd1 (fixed point 9.7)
+*/
+#define VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD1_HI 0x00A2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD1_LO 0x00A3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__AMBIENT_COUNT_RATE_MCPS_SD1 0x00A4
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__ambient_count_rate_mcps_sd1 (fixed point 9.7)
+*/
+#define VL53L1_RESULT__AMBIENT_COUNT_RATE_MCPS_SD1_HI 0x00A4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__AMBIENT_COUNT_RATE_MCPS_SD1_LO 0x00A5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__SIGMA_SD1 0x00A6
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__sigma_sd1 (fixed point 14.2)
+*/
+#define VL53L1_RESULT__SIGMA_SD1_HI 0x00A6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__SIGMA_SD1_LO 0x00A7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__PHASE_SD1 0x00A8
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__phase_sd1 (fixed point 5.11)
+*/
+#define VL53L1_RESULT__PHASE_SD1_HI 0x00A8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__PHASE_SD1_LO 0x00A9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD1 0x00AA
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__final_crosstalk_corrected_range_mm_sd1
+*/
+#define VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD1_HI 0x00AA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD1_LO 0x00AB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__SPARE_0_SD1 0x00AC
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__spare_0_sd1
+*/
+#define VL53L1_RESULT__SPARE_0_SD1_HI 0x00AC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__SPARE_0_SD1_LO 0x00AD
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__SPARE_1_SD1 0x00AE
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__spare_1_sd1
+*/
+#define VL53L1_RESULT__SPARE_1_SD1_HI 0x00AE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__SPARE_1_SD1_LO 0x00AF
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__SPARE_2_SD1 0x00B0
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [15:0] = result__spare_2_sd1
+*/
+#define VL53L1_RESULT__SPARE_2_SD1_HI 0x00B0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__SPARE_2_SD1_LO 0x00B1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__SPARE_3_SD1 0x00B2
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [7:0] = result__spare_3_sd1
+*/
+#define VL53L1_RESULT__THRESH_INFO 0x00B3
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['system_results', 'results']
+
+ fields: \n
+ - [3:0] = result__distance_int_info
+ - [7:4] = result__rate_int_info
+*/
+#define VL53L1_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0 0x00B4
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = result_core__ambient_window_events_sd0
+*/
+#define VL53L1_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0_3 0x00B4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0_2 0x00B5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0_1 0x00B6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0_0 0x00B7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__RANGING_TOTAL_EVENTS_SD0 0x00B8
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = result_core__ranging_total_events_sd0
+*/
+#define VL53L1_RESULT_CORE__RANGING_TOTAL_EVENTS_SD0_3 0x00B8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__RANGING_TOTAL_EVENTS_SD0_2 0x00B9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__RANGING_TOTAL_EVENTS_SD0_1 0x00BA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__RANGING_TOTAL_EVENTS_SD0_0 0x00BB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD0 0x00BC
+/*!<
+ type: int32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = result_core__signal_total_events_sd0
+*/
+#define VL53L1_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD0_3 0x00BC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD0_2 0x00BD
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD0_1 0x00BE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD0_0 0x00BF
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD0 0x00C0
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = result_core__total_periods_elapsed_sd0
+*/
+#define VL53L1_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD0_3 0x00C0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD0_2 0x00C1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD0_1 0x00C2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD0_0 0x00C3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD1 0x00C4
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = result_core__ambient_window_events_sd1
+*/
+#define VL53L1_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD1_3 0x00C4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD1_2 0x00C5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD1_1 0x00C6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD1_0 0x00C7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__RANGING_TOTAL_EVENTS_SD1 0x00C8
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = result_core__ranging_total_events_sd1
+*/
+#define VL53L1_RESULT_CORE__RANGING_TOTAL_EVENTS_SD1_3 0x00C8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__RANGING_TOTAL_EVENTS_SD1_2 0x00C9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__RANGING_TOTAL_EVENTS_SD1_1 0x00CA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__RANGING_TOTAL_EVENTS_SD1_0 0x00CB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD1 0x00CC
+/*!<
+ type: int32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = result_core__signal_total_events_sd1
+*/
+#define VL53L1_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD1_3 0x00CC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD1_2 0x00CD
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD1_1 0x00CE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD1_0 0x00CF
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD1 0x00D0
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = result_core__total_periods_elapsed_sd1
+*/
+#define VL53L1_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD1_3 0x00D0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD1_2 0x00D1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD1_1 0x00D2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD1_0 0x00D3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT_CORE__SPARE_0 0x00D4
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['core_results', 'ranging_core_results']
+
+ fields: \n
+ - [7:0] = result_core__spare_0
+*/
+#define VL53L1_PHASECAL_RESULT__REFERENCE_PHASE 0x00D6
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['debug_results', 'phasecal_results']
+
+ fields: \n
+ - [15:0] = result_phasecal__reference_phase (fixed point 5.11)
+*/
+#define VL53L1_PHASECAL_RESULT__REFERENCE_PHASE_HI 0x00D6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PHASECAL_RESULT__REFERENCE_PHASE_LO 0x00D7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PHASECAL_RESULT__VCSEL_START 0x00D8
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'phasecal_results']
+
+ fields: \n
+ - [6:0] = result_phasecal__vcsel_start
+*/
+#define VL53L1_REF_SPAD_CHAR_RESULT__NUM_ACTUAL_REF_SPADS 0x00D9
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'ref_spad_status']
+
+ fields: \n
+ - [5:0] = ref_spad_char_result__num_actual_ref_spads
+*/
+#define VL53L1_REF_SPAD_CHAR_RESULT__REF_LOCATION 0x00DA
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'ref_spad_status']
+
+ fields: \n
+ - [1:0] = ref_spad_char_result__ref_location
+*/
+#define VL53L1_VHV_RESULT__COLDBOOT_STATUS 0x00DB
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'vhv_results']
+
+ fields: \n
+ - [0] = vhv_result__coldboot_status
+*/
+#define VL53L1_VHV_RESULT__SEARCH_RESULT 0x00DC
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'vhv_results']
+
+ fields: \n
+ - [5:0] = cp_sel_result
+*/
+#define VL53L1_VHV_RESULT__LATEST_SETTING 0x00DD
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'vhv_results']
+
+ fields: \n
+ - [5:0] = cp_sel_latest_setting
+*/
+#define VL53L1_RESULT__OSC_CALIBRATE_VAL 0x00DE
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 9
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['debug_results', 'misc_results']
+
+ fields: \n
+ - [9:0] = osc_calibrate_val
+*/
+#define VL53L1_RESULT__OSC_CALIBRATE_VAL_HI 0x00DE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RESULT__OSC_CALIBRATE_VAL_LO 0x00DF
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_ANA_CONFIG__POWERDOWN_GO1 0x00E0
+/*!<
+ type: uint8_t \n
+ default: 0x02 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'analog_config']
+
+ fields: \n
+ - [0] = go2_ref_bg_disable_avdd
+ - [1] = go2_regdvdd1v2_enable_avdd
+*/
+#define VL53L1_ANA_CONFIG__REF_BG_CTRL 0x00E1
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'analog_config']
+
+ fields: \n
+ - [0] = go2_ref_overdrvbg_avdd
+ - [1] = go2_ref_forcebgison_avdd
+*/
+#define VL53L1_ANA_CONFIG__REGDVDD1V2_CTRL 0x00E2
+/*!<
+ type: uint8_t \n
+ default: 0x01 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'analog_config']
+
+ fields: \n
+ - [0] = go2_regdvdd1v2_sel_pulldown_avdd
+ - [1] = go2_regdvdd1v2_sel_boost_avdd
+ - [3:2] = go2_regdvdd1v2_selv_avdd
+*/
+#define VL53L1_ANA_CONFIG__OSC_SLOW_CTRL 0x00E3
+/*!<
+ type: uint8_t \n
+ default: 0x02 \n
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'analog_config']
+
+ fields: \n
+ - [0] = osc_slow_en
+ - [1] = osc_slow_op_en
+ - [2] = osc_slow_freq_sel
+*/
+#define VL53L1_TEST_MODE__STATUS 0x00E4
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'test_mode_status']
+
+ fields: \n
+ - [0] = test_mode_status
+*/
+#define VL53L1_FIRMWARE__SYSTEM_STATUS 0x00E5
+/*!<
+ type: uint8_t \n
+ default: 0x02 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'firmware_status']
+
+ fields: \n
+ - [0] = firmware_bootup
+ - [1] = firmware_first_range
+*/
+#define VL53L1_FIRMWARE__MODE_STATUS 0x00E6
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'firmware_status']
+
+ fields: \n
+ - [7:0] = firmware_mode_status
+*/
+#define VL53L1_FIRMWARE__SECONDARY_MODE_STATUS 0x00E7
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'firmware_status']
+
+ fields: \n
+ - [7:0] = fw_secondary_mode_status
+*/
+#define VL53L1_FIRMWARE__CAL_REPEAT_RATE_COUNTER 0x00E8
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 11
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['debug_results', 'firmware_status']
+
+ fields: \n
+ - [11:0] = firmware_cal_repeat_rate
+*/
+#define VL53L1_FIRMWARE__CAL_REPEAT_RATE_COUNTER_HI 0x00E8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_FIRMWARE__CAL_REPEAT_RATE_COUNTER_LO 0x00E9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_FIRMWARE__HISTOGRAM_BIN 0x00EA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_GPH__SYSTEM__THRESH_HIGH 0x00EC
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['debug_results', 'gph_actual']
+
+ fields: \n
+ - [15:0] = shadow_thresh_high
+*/
+#define VL53L1_GPH__SYSTEM__THRESH_HIGH_HI 0x00EC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_GPH__SYSTEM__THRESH_HIGH_LO 0x00ED
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_GPH__SYSTEM__THRESH_LOW 0x00EE
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['debug_results', 'gph_actual']
+
+ fields: \n
+ - [15:0] = shadow_thresh_low
+*/
+#define VL53L1_GPH__SYSTEM__THRESH_LOW_HI 0x00EE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_GPH__SYSTEM__THRESH_LOW_LO 0x00EF
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_GPH__SYSTEM__ENABLE_XTALK_PER_QUADRANT 0x00F0
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'gph_actual']
+
+ fields: \n
+ - [0] = shadow__enable_xtalk_per_quadrant
+*/
+#define VL53L1_GPH__SPARE_0 0x00F1
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'gph_actual']
+
+ fields: \n
+ - [0] = fw_safe_to_disable
+ - [1] = shadow__spare_0
+ - [2] = shadow__spare_1
+*/
+#define VL53L1_GPH__SD_CONFIG__WOI_SD0 0x00F2
+/*!<
+ type: uint8_t \n
+ default: 0x04 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'gph_actual']
+
+ fields: \n
+ - [7:0] = shadow_sd_config__woi_sd0
+*/
+#define VL53L1_GPH__SD_CONFIG__WOI_SD1 0x00F3
+/*!<
+ type: uint8_t \n
+ default: 0x04 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'gph_actual']
+
+ fields: \n
+ - [7:0] = shadow_sd_config__woi_sd1
+*/
+#define VL53L1_GPH__SD_CONFIG__INITIAL_PHASE_SD0 0x00F4
+/*!<
+ type: uint8_t \n
+ default: 0x03 \n
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'gph_actual']
+
+ fields: \n
+ - [6:0] = shadow_sd_config__initial_phase_sd0
+*/
+#define VL53L1_GPH__SD_CONFIG__INITIAL_PHASE_SD1 0x00F5
+/*!<
+ type: uint8_t \n
+ default: 0x03 \n
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'gph_actual']
+
+ fields: \n
+ - [6:0] = shadow_sd_config__initial_phase_sd1
+*/
+#define VL53L1_GPH__SD_CONFIG__FIRST_ORDER_SELECT 0x00F6
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'gph_actual']
+
+ fields: \n
+ - [0] = shadow_sd_config__first_order_select_rtn
+ - [1] = shadow_sd_config__first_order_select_ref
+*/
+#define VL53L1_GPH__SD_CONFIG__QUANTIFIER 0x00F7
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'gph_actual']
+
+ fields: \n
+ - [3:0] = shadow_sd_config__quantifier
+*/
+#define VL53L1_GPH__ROI_CONFIG__USER_ROI_CENTRE_SPAD 0x00F8
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'gph_actual']
+
+ fields: \n
+ - [7:0] = shadow_user_roi_center_spad_q0
+*/
+#define VL53L1_GPH__ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE 0x00F9
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'gph_actual']
+
+ fields: \n
+ - [7:0] = shadow_user_roi_requested_global_xy_size
+*/
+#define VL53L1_GPH__SYSTEM__SEQUENCE_CONFIG 0x00FA
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'gph_actual']
+
+ fields: \n
+ - [0] = shadow_sequence_vhv_en
+ - [1] = shadow_sequence_phasecal_en
+ - [2] = shadow_sequence_reference_phase_en
+ - [3] = shadow_sequence_dss1_en
+ - [4] = shadow_sequence_dss2_en
+ - [5] = shadow_sequence_mm1_en
+ - [6] = shadow_sequence_mm2_en
+ - [7] = shadow_sequence_range_en
+*/
+#define VL53L1_GPH__GPH_ID 0x00FB
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'gph_actual']
+
+ fields: \n
+ - [0] = shadow_gph_id
+*/
+#define VL53L1_SYSTEM__INTERRUPT_SET 0x00FC
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'system_int_set']
+
+ fields: \n
+ - [0] = sys_interrupt_set_range
+ - [1] = sys_interrupt_set_error
+*/
+#define VL53L1_INTERRUPT_MANAGER__ENABLES 0x00FD
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 4
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'interrupt_manager']
+
+ fields: \n
+ - [0] = interrupt_enable__single_shot
+ - [1] = interrupt_enable__back_to_back
+ - [2] = interrupt_enable__timed
+ - [3] = interrupt_enable__abort
+ - [4] = interrupt_enable__test
+*/
+#define VL53L1_INTERRUPT_MANAGER__CLEAR 0x00FE
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 4
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'interrupt_manager']
+
+ fields: \n
+ - [0] = interrupt_clear__single_shot
+ - [1] = interrupt_clear__back_to_back
+ - [2] = interrupt_clear__timed
+ - [3] = interrupt_clear__abort
+ - [4] = interrupt_clear__test
+*/
+#define VL53L1_INTERRUPT_MANAGER__STATUS 0x00FF
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 4
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'interrupt_manager']
+
+ fields: \n
+ - [0] = interrupt_status__single_shot
+ - [1] = interrupt_status__back_to_back
+ - [2] = interrupt_status__timed
+ - [3] = interrupt_status__abort
+ - [4] = interrupt_status__test
+*/
+#define VL53L1_MCU_TO_HOST_BANK__WR_ACCESS_EN 0x0100
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'host_bank_ctrl']
+
+ fields: \n
+ - [0] = mcu_to_host_bank_wr_en
+*/
+#define VL53L1_POWER_MANAGEMENT__GO1_RESET_STATUS 0x0101
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'power_man_status']
+
+ fields: \n
+ - [0] = go1_status
+*/
+#define VL53L1_PAD_STARTUP_MODE__VALUE_RO 0x0102
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'pad_config']
+
+ fields: \n
+ - [0] = pad_atest1_val_ro
+ - [1] = pad_atest2_val_ro
+*/
+#define VL53L1_PAD_STARTUP_MODE__VALUE_CTRL 0x0103
+/*!<
+ type: uint8_t \n
+ default: 0x30 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'pad_config']
+
+ fields: \n
+ - [0] = pad_atest1_val
+ - [1] = pad_atest2_val
+ - [4] = pad_atest1_dig_enable
+ - [5] = pad_atest2_dig_enable
+*/
+#define VL53L1_PLL_PERIOD_US 0x0104
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 17
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['debug_results', 'pll_config']
+
+ fields: \n
+ - [17:0] = pll_period_us (fixed point 0.24)
+*/
+#define VL53L1_PLL_PERIOD_US_3 0x0104
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PLL_PERIOD_US_2 0x0105
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PLL_PERIOD_US_1 0x0106
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PLL_PERIOD_US_0 0x0107
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_INTERRUPT_SCHEDULER__DATA_OUT 0x0108
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['debug_results', 'debug_timer']
+
+ fields: \n
+ - [31:0] = interrupt_scheduler_data_out
+*/
+#define VL53L1_INTERRUPT_SCHEDULER__DATA_OUT_3 0x0108
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_INTERRUPT_SCHEDULER__DATA_OUT_2 0x0109
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_INTERRUPT_SCHEDULER__DATA_OUT_1 0x010A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_INTERRUPT_SCHEDULER__DATA_OUT_0 0x010B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_NVM_BIST__COMPLETE 0x010C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'nvm_bist_status']
+
+ fields: \n
+ - [0] = nvm_bist__complete
+*/
+#define VL53L1_NVM_BIST__STATUS 0x010D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['debug_results', 'nvm_bist_status']
+
+ fields: \n
+ - [0] = nvm_bist__status
+*/
+#define VL53L1_IDENTIFICATION__MODEL_ID 0x010F
+/*!<
+ type: uint8_t \n
+ default: 0xEA \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'identification']
+
+ fields: \n
+ - [7:0] = model_id
+*/
+#define VL53L1_IDENTIFICATION__MODULE_TYPE 0x0110
+/*!<
+ type: uint8_t \n
+ default: 0xAA \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'identification']
+
+ fields: \n
+ - [7:0] = module_type
+*/
+#define VL53L1_IDENTIFICATION__REVISION_ID 0x0111
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'identification']
+
+ fields: \n
+ - [3:0] = nvm_revision_id
+ - [7:4] = mask_revision_id
+*/
+#define VL53L1_IDENTIFICATION__MODULE_ID 0x0112
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['nvm_copy_data', 'identification']
+
+ fields: \n
+ - [15:0] = module_id
+*/
+#define VL53L1_IDENTIFICATION__MODULE_ID_HI 0x0112
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_IDENTIFICATION__MODULE_ID_LO 0x0113
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_ANA_CONFIG__FAST_OSC__TRIM_MAX 0x0114
+/*!<
+ type: uint8_t \n
+ default: OSC_TRIM_DEFAULT \n
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'analog_config']
+
+ fields: \n
+ - [6:0] = osc_trim_max
+*/
+#define VL53L1_ANA_CONFIG__FAST_OSC__FREQ_SET 0x0115
+/*!<
+ type: uint8_t \n
+ default: OSC_FREQ_SET_DEFAULT \n
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'analog_config']
+
+ fields: \n
+ - [2:0] = osc_freq_set
+*/
+#define VL53L1_ANA_CONFIG__VCSEL_TRIM 0x0116
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'analog_config']
+
+ fields: \n
+ - [2:0] = vcsel_trim
+*/
+#define VL53L1_ANA_CONFIG__VCSEL_SELION 0x0117
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'analog_config']
+
+ fields: \n
+ - [5:0] = vcsel_selion
+*/
+#define VL53L1_ANA_CONFIG__VCSEL_SELION_MAX 0x0118
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'analog_config']
+
+ fields: \n
+ - [5:0] = vcsel_selion_max
+*/
+#define VL53L1_PROTECTED_LASER_SAFETY__LOCK_BIT 0x0119
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'laser_safety']
+
+ fields: \n
+ - [0] = laser_safety__lock_bit
+*/
+#define VL53L1_LASER_SAFETY__KEY 0x011A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'laser_safety']
+
+ fields: \n
+ - [6:0] = laser_safety__key
+*/
+#define VL53L1_LASER_SAFETY__KEY_RO 0x011B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'laser_safety']
+
+ fields: \n
+ - [0] = laser_safety__key_ro
+*/
+#define VL53L1_LASER_SAFETY__CLIP 0x011C
+/*!<
+ type: uint8_t \n
+ default: 0x02 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'laser_safety']
+
+ fields: \n
+ - [5:0] = vcsel_pulse_width_clip
+*/
+#define VL53L1_LASER_SAFETY__MULT 0x011D
+/*!<
+ type: uint8_t \n
+ default: 0x32 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'laser_safety']
+
+ fields: \n
+ - [5:0] = vcsel_pulse_width_mult
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_0 0x011E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_0
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_1 0x011F
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_1
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_2 0x0120
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_2
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_3 0x0121
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_3
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_4 0x0122
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_4
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_5 0x0123
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_5
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_6 0x0124
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_6
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_7 0x0125
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_7
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_8 0x0126
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_8
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_9 0x0127
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_9
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_10 0x0128
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_10
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_11 0x0129
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_11
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_12 0x012A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_12
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_13 0x012B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_13
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_14 0x012C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_14
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_15 0x012D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_15
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_16 0x012E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_16
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_17 0x012F
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_17
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_18 0x0130
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_18
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_19 0x0131
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_19
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_20 0x0132
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_20
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_21 0x0133
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_21
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_22 0x0134
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_22
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_23 0x0135
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_23
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_24 0x0136
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_24
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_25 0x0137
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_25
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_26 0x0138
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_26
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_27 0x0139
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_27
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_28 0x013A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_28
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_29 0x013B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_29
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_30 0x013C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_30
+*/
+#define VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_RTN_31 0x013D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'ret_spad_config']
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_31
+*/
+#define VL53L1_ROI_CONFIG__MODE_ROI_CENTRE_SPAD 0x013E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'roi_config']
+
+ fields: \n
+ - [7:0] = mode_roi_center_spad
+*/
+#define VL53L1_ROI_CONFIG__MODE_ROI_XY_SIZE 0x013F
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['nvm_copy_data', 'roi_config']
+
+ fields: \n
+ - [7:0] = mode_roi_xy_size
+*/
+#define VL53L1_GO2_HOST_BANK_ACCESS__OVERRIDE 0x0300
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__MULTIPLICAND 0x0400
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__MULTIPLICAND_3 0x0400
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__MULTIPLICAND_2 0x0401
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__MULTIPLICAND_1 0x0402
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__MULTIPLICAND_0 0x0403
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__MULTIPLIER 0x0404
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__MULTIPLIER_3 0x0404
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__MULTIPLIER_2 0x0405
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__MULTIPLIER_1 0x0406
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__MULTIPLIER_0 0x0407
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__PRODUCT_HI 0x0408
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__PRODUCT_HI_3 0x0408
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__PRODUCT_HI_2 0x0409
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__PRODUCT_HI_1 0x040A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__PRODUCT_HI_0 0x040B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__PRODUCT_LO 0x040C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__PRODUCT_LO_3 0x040C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__PRODUCT_LO_2 0x040D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__PRODUCT_LO_1 0x040E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__PRODUCT_LO_0 0x040F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__START 0x0410
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_MULTIPLIER__STATUS 0x0411
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__START 0x0412
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__STATUS 0x0413
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__DIVIDEND 0x0414
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__DIVIDEND_3 0x0414
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__DIVIDEND_2 0x0415
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__DIVIDEND_1 0x0416
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__DIVIDEND_0 0x0417
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__DIVISOR 0x0418
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__DIVISOR_3 0x0418
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__DIVISOR_2 0x0419
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__DIVISOR_1 0x041A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__DIVISOR_0 0x041B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__QUOTIENT 0x041C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__QUOTIENT_3 0x041C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__QUOTIENT_2 0x041D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__QUOTIENT_1 0x041E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_UTIL_DIVIDER__QUOTIENT_0 0x041F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TIMER0__VALUE_IN 0x0420
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TIMER0__VALUE_IN_3 0x0420
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TIMER0__VALUE_IN_2 0x0421
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TIMER0__VALUE_IN_1 0x0422
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TIMER0__VALUE_IN_0 0x0423
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TIMER1__VALUE_IN 0x0424
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TIMER1__VALUE_IN_3 0x0424
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TIMER1__VALUE_IN_2 0x0425
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TIMER1__VALUE_IN_1 0x0426
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TIMER1__VALUE_IN_0 0x0427
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TIMER0__CTRL 0x0428
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TIMER1__CTRL 0x0429
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_GENERAL_PURPOSE__GP_0 0x042C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [7:0] = mcu_gp_0
+*/
+#define VL53L1_MCU_GENERAL_PURPOSE__GP_1 0x042D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [7:0] = mcu_gp_1
+*/
+#define VL53L1_MCU_GENERAL_PURPOSE__GP_2 0x042E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [7:0] = mcu_gp_2
+*/
+#define VL53L1_MCU_GENERAL_PURPOSE__GP_3 0x042F
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [7:0] = mcu_gp_3
+*/
+#define VL53L1_MCU_RANGE_CALC__CONFIG 0x0430
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [0] = fw_calc__sigma_delta_sel
+ - [2] = fw_calc__phase_output_en
+ - [3] = fw_calc__peak_signal_rate_en
+ - [4] = fw_calc__ambient_rate_en
+ - [5] = fw_calc__total_rate_per_spad_en
+ - [6] = fw_calc__snr_avg_signal_rate_en
+ - [7] = fw_calc__sigma_en
+*/
+#define VL53L1_MCU_RANGE_CALC__OFFSET_CORRECTED_RANGE 0x0432
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [15:0] = offset_corrected_range
+*/
+#define VL53L1_MCU_RANGE_CALC__OFFSET_CORRECTED_RANGE_HI 0x0432
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__OFFSET_CORRECTED_RANGE_LO 0x0433
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__SPARE_4 0x0434
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 16
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [16:0] = mcu_calc__spare_4
+*/
+#define VL53L1_MCU_RANGE_CALC__SPARE_4_3 0x0434
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__SPARE_4_2 0x0435
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__SPARE_4_1 0x0436
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__SPARE_4_0 0x0437
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__AMBIENT_DURATION_PRE_CALC 0x0438
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 13
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [13:0] = ambient_duration_prec_calc
+*/
+#define VL53L1_MCU_RANGE_CALC__AMBIENT_DURATION_PRE_CALC_HI 0x0438
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__AMBIENT_DURATION_PRE_CALC_LO 0x0439
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_VCSEL_PERIOD 0x043C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [7:0] = algo_vcsel_period
+*/
+#define VL53L1_MCU_RANGE_CALC__SPARE_5 0x043D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [7:0] = mcu_calc__spare_5
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_TOTAL_PERIODS 0x043E
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [15:0] = algo_total_periods
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_TOTAL_PERIODS_HI 0x043E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_TOTAL_PERIODS_LO 0x043F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_ACCUM_PHASE 0x0440
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [31:0] = algo_accum_phase
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_ACCUM_PHASE_3 0x0440
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_ACCUM_PHASE_2 0x0441
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_ACCUM_PHASE_1 0x0442
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_ACCUM_PHASE_0 0x0443
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_SIGNAL_EVENTS 0x0444
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [31:0] = algo_signal_events
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_SIGNAL_EVENTS_3 0x0444
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_SIGNAL_EVENTS_2 0x0445
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_SIGNAL_EVENTS_1 0x0446
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_SIGNAL_EVENTS_0 0x0447
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_AMBIENT_EVENTS 0x0448
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [31:0] = algo_ambient_events
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_AMBIENT_EVENTS_3 0x0448
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_AMBIENT_EVENTS_2 0x0449
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_AMBIENT_EVENTS_1 0x044A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_AMBIENT_EVENTS_0 0x044B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__SPARE_6 0x044C
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [15:0] = mcu_calc__spare_6
+*/
+#define VL53L1_MCU_RANGE_CALC__SPARE_6_HI 0x044C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__SPARE_6_LO 0x044D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_ADJUST_VCSEL_PERIOD 0x044E
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [15:0] = algo_adjust_vcsel_period
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_ADJUST_VCSEL_PERIOD_HI 0x044E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__ALGO_ADJUST_VCSEL_PERIOD_LO 0x044F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__NUM_SPADS 0x0450
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [15:0] = num_spads
+*/
+#define VL53L1_MCU_RANGE_CALC__NUM_SPADS_HI 0x0450
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__NUM_SPADS_LO 0x0451
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__PHASE_OUTPUT 0x0452
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [15:0] = phase_output
+*/
+#define VL53L1_MCU_RANGE_CALC__PHASE_OUTPUT_HI 0x0452
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__PHASE_OUTPUT_LO 0x0453
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__RATE_PER_SPAD_MCPS 0x0454
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 19
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [19:0] = rate_per_spad_mcps
+*/
+#define VL53L1_MCU_RANGE_CALC__RATE_PER_SPAD_MCPS_3 0x0454
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__RATE_PER_SPAD_MCPS_2 0x0455
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__RATE_PER_SPAD_MCPS_1 0x0456
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__RATE_PER_SPAD_MCPS_0 0x0457
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__SPARE_7 0x0458
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [7:0] = mcu_calc__spare_7
+*/
+#define VL53L1_MCU_RANGE_CALC__SPARE_8 0x0459
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [7:0] = mcu_calc__spare_8
+*/
+#define VL53L1_MCU_RANGE_CALC__PEAK_SIGNAL_RATE_MCPS 0x045A
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [15:0] = peak_signal_rate
+*/
+#define VL53L1_MCU_RANGE_CALC__PEAK_SIGNAL_RATE_MCPS_HI 0x045A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__PEAK_SIGNAL_RATE_MCPS_LO 0x045B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__AVG_SIGNAL_RATE_MCPS 0x045C
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [15:0] = avg_signal_rate
+*/
+#define VL53L1_MCU_RANGE_CALC__AVG_SIGNAL_RATE_MCPS_HI 0x045C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__AVG_SIGNAL_RATE_MCPS_LO 0x045D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__AMBIENT_RATE_MCPS 0x045E
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [15:0] = ambient_rate
+*/
+#define VL53L1_MCU_RANGE_CALC__AMBIENT_RATE_MCPS_HI 0x045E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__AMBIENT_RATE_MCPS_LO 0x045F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__XTALK 0x0460
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [15:0] = crosstalk (fixed point 9.7)
+*/
+#define VL53L1_MCU_RANGE_CALC__XTALK_HI 0x0460
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__XTALK_LO 0x0461
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__CALC_STATUS 0x0462
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [7:0] = calc_status
+*/
+#define VL53L1_MCU_RANGE_CALC__DEBUG 0x0463
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [0] = calc_debug__divide_by_zero
+*/
+#define VL53L1_MCU_RANGE_CALC__PEAK_SIGNAL_RATE_XTALK_CORR_MCPS 0x0464
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [15:0] = peak_signal_rate_xtalk_corr
+*/
+#define VL53L1_MCU_RANGE_CALC__PEAK_SIGNAL_RATE_XTALK_CORR_MCPS_HI 0x0464
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__PEAK_SIGNAL_RATE_XTALK_CORR_MCPS_LO 0x0465
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MCU_RANGE_CALC__SPARE_0 0x0468
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [7:0] = mcu_calc__spare_0
+*/
+#define VL53L1_MCU_RANGE_CALC__SPARE_1 0x0469
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [7:0] = mcu_calc__spare_1
+*/
+#define VL53L1_MCU_RANGE_CALC__SPARE_2 0x046A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [7:0] = mcu_calc__spare_2
+*/
+#define VL53L1_MCU_RANGE_CALC__SPARE_3 0x046B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [7:0] = mcu_calc__spare_3
+*/
+#define VL53L1_PATCH__CTRL 0x0470
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__JMP_ENABLES 0x0472
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__JMP_ENABLES_HI 0x0472
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__JMP_ENABLES_LO 0x0473
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__DATA_ENABLES 0x0474
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__DATA_ENABLES_HI 0x0474
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__DATA_ENABLES_LO 0x0475
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_0 0x0476
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_0_HI 0x0476
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_0_LO 0x0477
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_1 0x0478
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_1_HI 0x0478
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_1_LO 0x0479
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_2 0x047A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_2_HI 0x047A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_2_LO 0x047B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_3 0x047C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_3_HI 0x047C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_3_LO 0x047D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_4 0x047E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_4_HI 0x047E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_4_LO 0x047F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_5 0x0480
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_5_HI 0x0480
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_5_LO 0x0481
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_6 0x0482
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_6_HI 0x0482
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_6_LO 0x0483
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_7 0x0484
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_7_HI 0x0484
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_7_LO 0x0485
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_8 0x0486
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_8_HI 0x0486
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_8_LO 0x0487
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_9 0x0488
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_9_HI 0x0488
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_9_LO 0x0489
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_10 0x048A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_10_HI 0x048A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_10_LO 0x048B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_11 0x048C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_11_HI 0x048C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_11_LO 0x048D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_12 0x048E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_12_HI 0x048E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_12_LO 0x048F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_13 0x0490
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_13_HI 0x0490
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_13_LO 0x0491
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_14 0x0492
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_14_HI 0x0492
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_14_LO 0x0493
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_15 0x0494
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_15_HI 0x0494
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__OFFSET_15_LO 0x0495
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_0 0x0496
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_0_HI 0x0496
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_0_LO 0x0497
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_1 0x0498
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_1_HI 0x0498
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_1_LO 0x0499
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_2 0x049A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_2_HI 0x049A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_2_LO 0x049B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_3 0x049C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_3_HI 0x049C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_3_LO 0x049D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_4 0x049E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_4_HI 0x049E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_4_LO 0x049F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_5 0x04A0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_5_HI 0x04A0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_5_LO 0x04A1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_6 0x04A2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_6_HI 0x04A2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_6_LO 0x04A3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_7 0x04A4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_7_HI 0x04A4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_7_LO 0x04A5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_8 0x04A6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_8_HI 0x04A6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_8_LO 0x04A7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_9 0x04A8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_9_HI 0x04A8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_9_LO 0x04A9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_10 0x04AA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_10_HI 0x04AA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_10_LO 0x04AB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_11 0x04AC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_11_HI 0x04AC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_11_LO 0x04AD
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_12 0x04AE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_12_HI 0x04AE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_12_LO 0x04AF
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_13 0x04B0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_13_HI 0x04B0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_13_LO 0x04B1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_14 0x04B2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_14_HI 0x04B2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_14_LO 0x04B3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_15 0x04B4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_15_HI 0x04B4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PATCH__ADDRESS_15_LO 0x04B5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SPI_ASYNC_MUX__CTRL 0x04C0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_CLK__CONFIG 0x04C4
+/*!<
+ type: uint8_t \n
+ default: 0x01 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [0] = clk_mcu_en
+*/
+#define VL53L1_GPIO_LV_MUX__CTRL 0x04CC
+/*!<
+ type: uint8_t \n
+ default: 0x08 \n
+ info: \n
+ - msb = 4
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [3:0] = gpio__mux_select_lv
+ - [4] = gpio__mux_active_high_lv
+*/
+#define VL53L1_GPIO_LV_PAD__CTRL 0x04CD
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [0] = gpio__extsup_lv
+*/
+#define VL53L1_PAD_I2C_LV__CONFIG 0x04D0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PAD_STARTUP_MODE__VALUE_RO_GO1 0x04D4
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [0] = pad_spi_csn_val_ro
+*/
+#define VL53L1_HOST_IF__STATUS_GO1 0x04D5
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [0] = host_interface_lv
+*/
+#define VL53L1_MCU_CLK_GATING__CTRL 0x04D8
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['']
+
+ fields: \n
+ - [0] = clk_gate_en__go1_mcu_bank
+ - [1] = clk_gate_en__go1_mcu_patch_ctrl
+ - [2] = clk_gate_en__go1_mcu_timers
+ - [3] = clk_gate_en__go1_mcu_mult_div
+*/
+#define VL53L1_TEST__BIST_ROM_CTRL 0x04E0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__BIST_ROM_RESULT 0x04E1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__BIST_ROM_MCU_SIG 0x04E2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__BIST_ROM_MCU_SIG_HI 0x04E2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__BIST_ROM_MCU_SIG_LO 0x04E3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__BIST_RAM_CTRL 0x04E4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__BIST_RAM_RESULT 0x04E5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__TMC 0x04E8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__PLL_BIST_MIN_THRESHOLD 0x04F0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__PLL_BIST_MIN_THRESHOLD_HI 0x04F0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__PLL_BIST_MIN_THRESHOLD_LO 0x04F1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__PLL_BIST_MAX_THRESHOLD 0x04F2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__PLL_BIST_MAX_THRESHOLD_HI 0x04F2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__PLL_BIST_MAX_THRESHOLD_LO 0x04F3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__PLL_BIST_COUNT_OUT 0x04F4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__PLL_BIST_COUNT_OUT_HI 0x04F4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__PLL_BIST_COUNT_OUT_LO 0x04F5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__PLL_BIST_GONOGO 0x04F6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_TEST__PLL_BIST_CTRL 0x04F7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__DEVICE_ID 0x0680
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__REVISION_ID 0x0681
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__CLK_CTRL1 0x0683
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__CLK_CTRL2 0x0684
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__WOI_1 0x0685
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__WOI_REF_1 0x0686
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__START_RANGING 0x0687
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__LOW_LIMIT_1 0x0690
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__HIGH_LIMIT_1 0x0691
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__LOW_LIMIT_REF_1 0x0692
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__HIGH_LIMIT_REF_1 0x0693
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__QUANTIFIER_1_MSB 0x0694
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__QUANTIFIER_1_LSB 0x0695
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__QUANTIFIER_REF_1_MSB 0x0696
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__QUANTIFIER_REF_1_LSB 0x0697
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_OFFSET_1_MSB 0x0698
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_OFFSET_1_LSB 0x0699
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_OFFSET_REF_1_MSB 0x069A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_OFFSET_REF_1_LSB 0x069B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__FILTER_STRENGTH_1 0x069C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__FILTER_STRENGTH_REF_1 0x069D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SIGNAL_EVENT_LIMIT_1_MSB 0x069E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SIGNAL_EVENT_LIMIT_1_LSB 0x069F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SIGNAL_EVENT_LIMIT_REF_1_MSB 0x06A0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SIGNAL_EVENT_LIMIT_REF_1_LSB 0x06A1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__TIMEOUT_OVERALL_PERIODS_MSB 0x06A4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__TIMEOUT_OVERALL_PERIODS_LSB 0x06A5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__INVERT_HW 0x06A6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__FORCE_HW 0x06A7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__STATIC_HW_VALUE 0x06A8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__FORCE_CONTINUOUS_AMBIENT 0x06A9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__TEST_PHASE_SELECT_TO_FILTER 0x06AA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__TEST_PHASE_SELECT_TO_TIMING_GEN 0x06AB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__INITIAL_PHASE_VALUE_1 0x06AC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__INITIAL_PHASE_VALUE_REF_1 0x06AD
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__FORCE_UP_IN 0x06AE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__FORCE_DN_IN 0x06AF
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__STATIC_UP_VALUE_1 0x06B0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__STATIC_UP_VALUE_REF_1 0x06B1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__STATIC_DN_VALUE_1 0x06B2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__STATIC_DN_VALUE_REF_1 0x06B3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__MONITOR_UP_DN 0x06B4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__INVERT_UP_DN 0x06B5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__CPUMP_1 0x06B6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__CPUMP_2 0x06B7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__CPUMP_3 0x06B8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__OSC_1 0x06B9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__PLL_1 0x06BB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__PLL_2 0x06BC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__REFERENCE_1 0x06BD
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__REFERENCE_3 0x06BF
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__REFERENCE_4 0x06C0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__REFERENCE_5 0x06C1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__REGAVDD1V2 0x06C3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__CALIB_1 0x06C4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__CALIB_2 0x06C5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__CALIB_3 0x06C6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__TST_MUX_SEL1 0x06C9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__TST_MUX_SEL2 0x06CA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__TST_MUX 0x06CB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__GPIO_OUT_TESTMUX 0x06CC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__CUSTOM_FE 0x06CD
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__CUSTOM_FE_2 0x06CE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SPAD_READOUT 0x06CF
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SPAD_READOUT_1 0x06D0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SPAD_READOUT_2 0x06D1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SPAD_PS 0x06D2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__LASER_SAFETY_2 0x06D4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__MODE 0x0780
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__PDN 0x0781
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__PROGN 0x0782
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__READN 0x0783
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__PULSE_WIDTH_MSB 0x0784
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__PULSE_WIDTH_LSB 0x0785
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__HV_RISE_MSB 0x0786
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__HV_RISE_LSB 0x0787
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__HV_FALL_MSB 0x0788
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__HV_FALL_LSB 0x0789
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__TST 0x078A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__TESTREAD 0x078B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__DATAIN_MMM 0x078C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__DATAIN_LMM 0x078D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__DATAIN_LLM 0x078E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__DATAIN_LLL 0x078F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__DATAOUT_MMM 0x0790
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__DATAOUT_LMM 0x0791
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__DATAOUT_LLM 0x0792
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__DATAOUT_LLL 0x0793
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__ADDR 0x0794
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__NVM_CTRL__DATAOUT_ECC 0x0795
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_0 0x0796
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_1 0x0797
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_2 0x0798
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_3 0x0799
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_4 0x079A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_5 0x079B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_6 0x079C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_7 0x079D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_8 0x079E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_9 0x079F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_10 0x07A0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_11 0x07A1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_12 0x07A2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_13 0x07A3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_14 0x07A4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_15 0x07A5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_16 0x07A6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_17 0x07A7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SPAD_SHIFT_EN 0x07BA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SPAD_DISABLE_CTRL 0x07BB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SPAD_EN_SHIFT_OUT_DEBUG 0x07BC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SPI_MODE 0x07BD
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__GPIO_DIR 0x07BE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__VCSEL_PERIOD 0x0880
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__VCSEL_START 0x0881
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__VCSEL_STOP 0x0882
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__VCSEL_1 0x0885
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__VCSEL_STATUS 0x088D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__STATUS 0x0980
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__LASER_CONTINUITY_STATE 0x0981
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RANGE_1_MMM 0x0982
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RANGE_1_LMM 0x0983
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RANGE_1_LLM 0x0984
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RANGE_1_LLL 0x0985
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RANGE_REF_1_MMM 0x0986
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RANGE_REF_1_LMM 0x0987
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RANGE_REF_1_LLM 0x0988
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RANGE_REF_1_LLL 0x0989
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_WINDOW_EVENTS_1_MMM 0x098A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_WINDOW_EVENTS_1_LMM 0x098B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_WINDOW_EVENTS_1_LLM 0x098C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_WINDOW_EVENTS_1_LLL 0x098D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RANGING_TOTAL_EVENTS_1_MMM 0x098E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RANGING_TOTAL_EVENTS_1_LMM 0x098F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RANGING_TOTAL_EVENTS_1_LLM 0x0990
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RANGING_TOTAL_EVENTS_1_LLL 0x0991
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SIGNAL_TOTAL_EVENTS_1_MMM 0x0992
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SIGNAL_TOTAL_EVENTS_1_LMM 0x0993
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SIGNAL_TOTAL_EVENTS_1_LLM 0x0994
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SIGNAL_TOTAL_EVENTS_1_LLL 0x0995
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__TOTAL_PERIODS_ELAPSED_1_MM 0x0996
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__TOTAL_PERIODS_ELAPSED_1_LM 0x0997
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__TOTAL_PERIODS_ELAPSED_1_LL 0x0998
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_MISMATCH_MM 0x0999
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_MISMATCH_LM 0x099A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_MISMATCH_LL 0x099B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_WINDOW_EVENTS_REF_1_MMM 0x099C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_WINDOW_EVENTS_REF_1_LMM 0x099D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_WINDOW_EVENTS_REF_1_LLM 0x099E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_WINDOW_EVENTS_REF_1_LLL 0x099F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RANGING_TOTAL_EVENTS_REF_1_MMM 0x09A0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RANGING_TOTAL_EVENTS_REF_1_LMM 0x09A1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RANGING_TOTAL_EVENTS_REF_1_LLM 0x09A2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RANGING_TOTAL_EVENTS_REF_1_LLL 0x09A3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SIGNAL_TOTAL_EVENTS_REF_1_MMM 0x09A4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SIGNAL_TOTAL_EVENTS_REF_1_LMM 0x09A5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SIGNAL_TOTAL_EVENTS_REF_1_LLM 0x09A6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SIGNAL_TOTAL_EVENTS_REF_1_LLL 0x09A7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__TOTAL_PERIODS_ELAPSED_REF_1_MM 0x09A8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__TOTAL_PERIODS_ELAPSED_REF_1_LM 0x09A9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__TOTAL_PERIODS_ELAPSED_REF_1_LL 0x09AA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_MISMATCH_REF_MM 0x09AB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_MISMATCH_REF_LM 0x09AC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__AMBIENT_MISMATCH_REF_LL 0x09AD
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__GPIO_CONFIG__A0 0x0A00
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RESET_CONTROL__A0 0x0A01
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__INTR_MANAGER__A0 0x0A02
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__POWER_FSM_TIME_OSC__A0 0x0A06
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__VCSEL_ATEST__A0 0x0A07
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__VCSEL_PERIOD_CLIPPED__A0 0x0A08
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__VCSEL_STOP_CLIPPED__A0 0x0A09
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__CALIB_2__A0 0x0A0A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__STOP_CONDITION__A0 0x0A0B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__STATUS_RESET__A0 0x0A0C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__READOUT_CFG__A0 0x0A0D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__WINDOW_SETTING__A0 0x0A0E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__VCSEL_DELAY__A0 0x0A1A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__REFERENCE_2__A0 0x0A1B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__REGAVDD1V2__A0 0x0A1D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__TST_MUX__A0 0x0A1F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__CUSTOM_FE_2__A0 0x0A20
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SPAD_READOUT__A0 0x0A21
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__CPUMP_1__A0 0x0A22
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__SPARE_REGISTER__A0 0x0A23
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__VCSEL_CONT_STAGE5_BYPASS__A0 0x0A24
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_18 0x0A25
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_19 0x0A26
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_20 0x0A27
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_21 0x0A28
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_22 0x0A29
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_23 0x0A2A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_24 0x0A2B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_25 0x0A2C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_26 0x0A2D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_27 0x0A2E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_28 0x0A2F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_29 0x0A30
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_30 0x0A31
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__RET_SPAD_EN_31 0x0A32
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__REF_SPAD_EN_0__EWOK 0x0A33
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__REF_SPAD_EN_1__EWOK 0x0A34
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__REF_SPAD_EN_2__EWOK 0x0A35
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__REF_SPAD_EN_3__EWOK 0x0A36
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__REF_SPAD_EN_4__EWOK 0x0A37
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__REF_SPAD_EN_5__EWOK 0x0A38
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__REF_EN_START_SELECT 0x0A39
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGING_CORE__REGDVDD1V2_ATEST__EWOK 0x0A41
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SOFT_RESET_GO1 0x0B00
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PRIVATE__PATCH_BASE_ADDR_RSLV 0x0E00
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__INTERRUPT_STATUS 0x0ED0
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [2:0] = prev_shadow_int_status
+ - [4:3] = prev_shadow_int_error_status
+ - [5] = prev_shadow_gph_id_gpio_status
+*/
+#define VL53L1_PREV_SHADOW_RESULT__RANGE_STATUS 0x0ED1
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [4:0] = prev_shadow_range_status
+ - [5] = prev_shadow_max_threshold_hit
+ - [6] = prev_shadow_min_threshold_hit
+ - [7] = prev_shadow_gph_id_range_status
+*/
+#define VL53L1_PREV_SHADOW_RESULT__REPORT_STATUS 0x0ED2
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [3:0] = prev_shadow_report_status
+*/
+#define VL53L1_PREV_SHADOW_RESULT__STREAM_COUNT 0x0ED3
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [7:0] = prev_shadow_result__stream_count
+*/
+#define VL53L1_PREV_SHADOW_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0 0x0ED4
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__dss_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+#define VL53L1_PREV_SHADOW_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0_HI 0x0ED4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0_LO 0x0ED5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD0 0x0ED6
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__peak_signal_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+#define VL53L1_PREV_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD0_HI 0x0ED6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD0_LO 0x0ED7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__AMBIENT_COUNT_RATE_MCPS_SD0 0x0ED8
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__ambient_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+#define VL53L1_PREV_SHADOW_RESULT__AMBIENT_COUNT_RATE_MCPS_SD0_HI 0x0ED8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__AMBIENT_COUNT_RATE_MCPS_SD0_LO 0x0ED9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SIGMA_SD0 0x0EDA
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__sigma_sd0 (fixed point 14.2)
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SIGMA_SD0_HI 0x0EDA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SIGMA_SD0_LO 0x0EDB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__PHASE_SD0 0x0EDC
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__phase_sd0 (fixed point 5.11)
+*/
+#define VL53L1_PREV_SHADOW_RESULT__PHASE_SD0_HI 0x0EDC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__PHASE_SD0_LO 0x0EDD
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 0x0EDE
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__final_crosstalk_corrected_range_mm_sd0
+*/
+#define VL53L1_PREV_SHADOW_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0_HI 0x0EDE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0_LO 0x0EDF
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0 0x0EE0
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0 (fixed point 9.7)
+*/
+#define VL53L1_PREV_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0_HI 0x0EE0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0_LO 0x0EE1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__MM_INNER_ACTUAL_EFFECTIVE_SPADS_SD0 0x0EE2
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__mm_inner_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+#define VL53L1_PREV_SHADOW_RESULT__MM_INNER_ACTUAL_EFFECTIVE_SPADS_SD0_HI 0x0EE2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__MM_INNER_ACTUAL_EFFECTIVE_SPADS_SD0_LO 0x0EE3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__MM_OUTER_ACTUAL_EFFECTIVE_SPADS_SD0 0x0EE4
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__mm_outer_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+#define VL53L1_PREV_SHADOW_RESULT__MM_OUTER_ACTUAL_EFFECTIVE_SPADS_SD0_HI 0x0EE4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__MM_OUTER_ACTUAL_EFFECTIVE_SPADS_SD0_LO 0x0EE5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__AVG_SIGNAL_COUNT_RATE_MCPS_SD0 0x0EE6
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__avg_signal_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+#define VL53L1_PREV_SHADOW_RESULT__AVG_SIGNAL_COUNT_RATE_MCPS_SD0_HI 0x0EE6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__AVG_SIGNAL_COUNT_RATE_MCPS_SD0_LO 0x0EE7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD1 0x0EE8
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__dss_actual_effective_spads_sd1 (fixed point 8.8)
+*/
+#define VL53L1_PREV_SHADOW_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD1_HI 0x0EE8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD1_LO 0x0EE9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD1 0x0EEA
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__peak_signal_count_rate_mcps_sd1 (fixed point 9.7)
+*/
+#define VL53L1_PREV_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD1_HI 0x0EEA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD1_LO 0x0EEB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__AMBIENT_COUNT_RATE_MCPS_SD1 0x0EEC
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__ambient_count_rate_mcps_sd1 (fixed point 9.7)
+*/
+#define VL53L1_PREV_SHADOW_RESULT__AMBIENT_COUNT_RATE_MCPS_SD1_HI 0x0EEC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__AMBIENT_COUNT_RATE_MCPS_SD1_LO 0x0EED
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SIGMA_SD1 0x0EEE
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__sigma_sd1 (fixed point 14.2)
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SIGMA_SD1_HI 0x0EEE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SIGMA_SD1_LO 0x0EEF
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__PHASE_SD1 0x0EF0
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__phase_sd1 (fixed point 5.11)
+*/
+#define VL53L1_PREV_SHADOW_RESULT__PHASE_SD1_HI 0x0EF0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__PHASE_SD1_LO 0x0EF1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD1 0x0EF2
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__final_crosstalk_corrected_range_mm_sd1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD1_HI 0x0EF2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD1_LO 0x0EF3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SPARE_0_SD1 0x0EF4
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__spare_0_sd1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SPARE_0_SD1_HI 0x0EF4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SPARE_0_SD1_LO 0x0EF5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SPARE_1_SD1 0x0EF6
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__spare_1_sd1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SPARE_1_SD1_HI 0x0EF6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SPARE_1_SD1_LO 0x0EF7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SPARE_2_SD1 0x0EF8
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__spare_2_sd1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SPARE_2_SD1_HI 0x0EF8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SPARE_2_SD1_LO 0x0EF9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SPARE_3_SD1 0x0EFA
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['prev_shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = prev_shadow_result__spare_3_sd1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SPARE_3_SD1_HI 0x0EFA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT__SPARE_3_SD1_LO 0x0EFB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0 0x0EFC
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['prev_shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = prev_shadow_result_core__ambient_window_events_sd0
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0_3 0x0EFC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0_2 0x0EFD
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0_1 0x0EFE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0_0 0x0EFF
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD0 0x0F00
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['prev_shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = prev_shadow_result_core__ranging_total_events_sd0
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD0_3 0x0F00
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD0_2 0x0F01
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD0_1 0x0F02
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD0_0 0x0F03
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD0 0x0F04
+/*!<
+ type: int32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['prev_shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = prev_shadow_result_core__signal_total_events_sd0
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD0_3 0x0F04
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD0_2 0x0F05
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD0_1 0x0F06
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD0_0 0x0F07
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD0 0x0F08
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['prev_shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = prev_shadow_result_core__total_periods_elapsed_sd0
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD0_3 0x0F08
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD0_2 0x0F09
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD0_1 0x0F0A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD0_0 0x0F0B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD1 0x0F0C
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['prev_shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = prev_shadow_result_core__ambient_window_events_sd1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD1_3 0x0F0C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD1_2 0x0F0D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD1_1 0x0F0E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD1_0 0x0F0F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD1 0x0F10
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['prev_shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = prev_shadow_result_core__ranging_total_events_sd1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD1_3 0x0F10
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD1_2 0x0F11
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD1_1 0x0F12
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD1_0 0x0F13
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD1 0x0F14
+/*!<
+ type: int32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['prev_shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = prev_shadow_result_core__signal_total_events_sd1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD1_3 0x0F14
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD1_2 0x0F15
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD1_1 0x0F16
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD1_0 0x0F17
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD1 0x0F18
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['prev_shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = prev_shadow_result_core__total_periods_elapsed_sd1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD1_3 0x0F18
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD1_2 0x0F19
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD1_1 0x0F1A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD1_0 0x0F1B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PREV_SHADOW_RESULT_CORE__SPARE_0 0x0F1C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['prev_shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [7:0] = prev_shadow_result_core__spare_0
+*/
+#define VL53L1_RESULT__DEBUG_STATUS 0x0F20
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_debug', 'misc_results']
+
+ fields: \n
+ - [7:0] = result_debug_status
+*/
+#define VL53L1_RESULT__DEBUG_STAGE 0x0F21
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_debug', 'misc_results']
+
+ fields: \n
+ - [7:0] = result_debug_stage
+*/
+#define VL53L1_GPH__SYSTEM__THRESH_RATE_HIGH 0x0F24
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['gph_general_config', 'dss_config']
+
+ fields: \n
+ - [15:0] = gph__system_thresh_rate_high (fixed point 9.7)
+*/
+#define VL53L1_GPH__SYSTEM__THRESH_RATE_HIGH_HI 0x0F24
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_GPH__SYSTEM__THRESH_RATE_HIGH_LO 0x0F25
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_GPH__SYSTEM__THRESH_RATE_LOW 0x0F26
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['gph_general_config', 'dss_config']
+
+ fields: \n
+ - [15:0] = gph__system_thresh_rate_low (fixed point 9.7)
+*/
+#define VL53L1_GPH__SYSTEM__THRESH_RATE_LOW_HI 0x0F26
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_GPH__SYSTEM__THRESH_RATE_LOW_LO 0x0F27
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_GPH__SYSTEM__INTERRUPT_CONFIG_GPIO 0x0F28
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_general_config', 'gph_config']
+
+ fields: \n
+ - [1:0] = gph__int_mode_distance
+ - [3:2] = gph__int_mode_rate
+ - [4] = gph__int_spare
+ - [5] = gph__int_new_measure_ready
+ - [6] = gph__int_no_target_en
+ - [7] = gph__int_combined_mode
+*/
+#define VL53L1_GPH__DSS_CONFIG__ROI_MODE_CONTROL 0x0F2F
+/*!<
+ type: uint8_t \n
+ default: 0x01 \n
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_static_config', 'dss_config']
+
+ fields: \n
+ - [1:0] = gph__dss_config__input_mode
+ - [2] = gph__calculate_roi_enable
+*/
+#define VL53L1_GPH__DSS_CONFIG__MANUAL_EFFECTIVE_SPADS_SELECT 0x0F30
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['gph_static_config', 'dss_config']
+
+ fields: \n
+ - [15:0] = gph__dss_config__manual_effective_spads_select
+*/
+#define VL53L1_GPH__DSS_CONFIG__MANUAL_EFFECTIVE_SPADS_SELECT_HI 0x0F30
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_GPH__DSS_CONFIG__MANUAL_EFFECTIVE_SPADS_SELECT_LO 0x0F31
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_GPH__DSS_CONFIG__MANUAL_BLOCK_SELECT 0x0F32
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_static_config', 'dss_config']
+
+ fields: \n
+ - [7:0] = gph__dss_config__manual_block_select
+*/
+#define VL53L1_GPH__DSS_CONFIG__MAX_SPADS_LIMIT 0x0F33
+/*!<
+ type: uint8_t \n
+ default: 0xFF \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_static_config', 'dss_config']
+
+ fields: \n
+ - [7:0] = gph__dss_config__max_spads_limit
+*/
+#define VL53L1_GPH__DSS_CONFIG__MIN_SPADS_LIMIT 0x0F34
+/*!<
+ type: uint8_t \n
+ default: 0x01 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_static_config', 'dss_config']
+
+ fields: \n
+ - [7:0] = gph__dss_config__min_spads_limit
+*/
+#define VL53L1_GPH__MM_CONFIG__TIMEOUT_MACROP_A_HI 0x0F36
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_timing_config', 'mm_config']
+
+ fields: \n
+ - [3:0] = gph_mm_config__config_timeout_macrop_a_hi
+*/
+#define VL53L1_GPH__MM_CONFIG__TIMEOUT_MACROP_A_LO 0x0F37
+/*!<
+ type: uint8_t \n
+ default: 0x06 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_timing_config', 'mm_config']
+
+ fields: \n
+ - [7:0] = gph_mm_config__config_timeout_macrop_a_lo
+*/
+#define VL53L1_GPH__MM_CONFIG__TIMEOUT_MACROP_B_HI 0x0F38
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_timing_config', 'mm_config']
+
+ fields: \n
+ - [3:0] = gph_mm_config__config_timeout_macrop_b_hi
+*/
+#define VL53L1_GPH__MM_CONFIG__TIMEOUT_MACROP_B_LO 0x0F39
+/*!<
+ type: uint8_t \n
+ default: 0x06 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_timing_config', 'mm_config']
+
+ fields: \n
+ - [7:0] = gph_mm_config__config_timeout_macrop_b_lo
+*/
+#define VL53L1_GPH__RANGE_CONFIG__TIMEOUT_MACROP_A_HI 0x0F3A
+/*!<
+ type: uint8_t \n
+ default: 0x01 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_timing_config', 'range_config']
+
+ fields: \n
+ - [3:0] = gph_range_timeout_overall_periods_macrop_a_hi
+*/
+#define VL53L1_GPH__RANGE_CONFIG__TIMEOUT_MACROP_A_LO 0x0F3B
+/*!<
+ type: uint8_t \n
+ default: 0x92 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_timing_config', 'range_config']
+
+ fields: \n
+ - [7:0] = gph_range_timeout_overall_periods_macrop_a_lo
+*/
+#define VL53L1_GPH__RANGE_CONFIG__VCSEL_PERIOD_A 0x0F3C
+/*!<
+ type: uint8_t \n
+ default: 0x0B \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_timing_config', 'range_config']
+
+ fields: \n
+ - [5:0] = gph_range_config__vcsel_period_a
+*/
+#define VL53L1_GPH__RANGE_CONFIG__VCSEL_PERIOD_B 0x0F3D
+/*!<
+ type: uint8_t \n
+ default: 0x09 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_timing_config', 'range_config']
+
+ fields: \n
+ - [5:0] = gph_range_config__vcsel_period_b
+*/
+#define VL53L1_GPH__RANGE_CONFIG__TIMEOUT_MACROP_B_HI 0x0F3E
+/*!<
+ type: uint8_t \n
+ default: 0x01 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_timing_config', 'range_config']
+
+ fields: \n
+ - [3:0] = gph_range_timeout_overall_periods_macrop_b_hi
+*/
+#define VL53L1_GPH__RANGE_CONFIG__TIMEOUT_MACROP_B_LO 0x0F3F
+/*!<
+ type: uint8_t \n
+ default: 0x92 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_timing_config', 'range_config']
+
+ fields: \n
+ - [7:0] = gph_range_timeout_overall_periods_macrop_b_lo
+*/
+#define VL53L1_GPH__RANGE_CONFIG__SIGMA_THRESH 0x0F40
+/*!<
+ type: uint16_t \n
+ default: 0x0080 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['gph_timing_config', 'range_config']
+
+ fields: \n
+ - [15:0] = gph_range_config__sigma_thresh (fixed point 14.2)
+*/
+#define VL53L1_GPH__RANGE_CONFIG__SIGMA_THRESH_HI 0x0F40
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_GPH__RANGE_CONFIG__SIGMA_THRESH_LO 0x0F41
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_GPH__RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS 0x0F42
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['gph_timing_config', 'range_config']
+
+ fields: \n
+ - [15:0] = gph_range_config__min_count_rate_rtn_limit_mcps (fixed point 9.7)
+*/
+#define VL53L1_GPH__RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS_HI 0x0F42
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_GPH__RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS_LO 0x0F43
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_GPH__RANGE_CONFIG__VALID_PHASE_LOW 0x0F44
+/*!<
+ type: uint8_t \n
+ default: 0x08 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_timing_config', 'range_config']
+
+ fields: \n
+ - [7:0] = gph_range_config__valid_phase_low (fixed point 5.3)
+*/
+#define VL53L1_GPH__RANGE_CONFIG__VALID_PHASE_HIGH 0x0F45
+/*!<
+ type: uint8_t \n
+ default: 0x80 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['gph_timing_config', 'range_config']
+
+ fields: \n
+ - [7:0] = gph_range_config__valid_phase_high (fixed point 5.3)
+*/
+#define VL53L1_FIRMWARE__INTERNAL_STREAM_COUNT_DIV 0x0F46
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['fw_internal']
+
+ fields: \n
+ - [7:0] = fw__internal_stream_count_div
+*/
+#define VL53L1_FIRMWARE__INTERNAL_STREAM_COUNTER_VAL 0x0F47
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['fw_internal']
+
+ fields: \n
+ - [7:0] = fw__internal_stream_counter_val
+*/
+#define VL53L1_DSS_CALC__ROI_CTRL 0x0F54
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [0] = dss_calc__roi_intersect_enable
+ - [1] = dss_calc__roi_subtract_enable
+*/
+#define VL53L1_DSS_CALC__SPARE_1 0x0F55
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__spare_1
+*/
+#define VL53L1_DSS_CALC__SPARE_2 0x0F56
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__spare_2
+*/
+#define VL53L1_DSS_CALC__SPARE_3 0x0F57
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__spare_3
+*/
+#define VL53L1_DSS_CALC__SPARE_4 0x0F58
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__spare_4
+*/
+#define VL53L1_DSS_CALC__SPARE_5 0x0F59
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__spare_5
+*/
+#define VL53L1_DSS_CALC__SPARE_6 0x0F5A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__spare_6
+*/
+#define VL53L1_DSS_CALC__SPARE_7 0x0F5B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__spare_7
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_0 0x0F5C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_0
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_1 0x0F5D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_1
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_2 0x0F5E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_2
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_3 0x0F5F
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_3
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_4 0x0F60
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_4
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_5 0x0F61
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_5
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_6 0x0F62
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_6
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_7 0x0F63
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_7
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_8 0x0F64
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_8
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_9 0x0F65
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_9
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_10 0x0F66
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_10
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_11 0x0F67
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_11
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_12 0x0F68
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_12
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_13 0x0F69
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_13
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_14 0x0F6A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_14
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_15 0x0F6B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_15
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_16 0x0F6C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_16
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_17 0x0F6D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_17
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_18 0x0F6E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_18
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_19 0x0F6F
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_19
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_20 0x0F70
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_20
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_21 0x0F71
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_21
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_22 0x0F72
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_22
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_23 0x0F73
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_23
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_24 0x0F74
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_24
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_25 0x0F75
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_25
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_26 0x0F76
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_26
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_27 0x0F77
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_27
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_28 0x0F78
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_28
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_29 0x0F79
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_29
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_30 0x0F7A
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_30
+*/
+#define VL53L1_DSS_CALC__USER_ROI_SPAD_EN_31 0x0F7B
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_31
+*/
+#define VL53L1_DSS_CALC__USER_ROI_0 0x0F7C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_0
+*/
+#define VL53L1_DSS_CALC__USER_ROI_1 0x0F7D
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_1
+*/
+#define VL53L1_DSS_CALC__MODE_ROI_0 0x0F7E
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__mode_roi_0
+*/
+#define VL53L1_DSS_CALC__MODE_ROI_1 0x0F7F
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_calc']
+
+ fields: \n
+ - [7:0] = dss_calc__mode_roi_1
+*/
+#define VL53L1_SIGMA_ESTIMATOR_CALC__SPARE_0 0x0F80
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'sigma_est_spare']
+
+ fields: \n
+ - [7:0] = sigma_estimator_calc__spare_0
+*/
+#define VL53L1_VHV_RESULT__PEAK_SIGNAL_RATE_MCPS 0x0F82
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['patch_results', 'vhv_results']
+
+ fields: \n
+ - [15:0] = vhv_result__peak_signal_rate_mcps
+*/
+#define VL53L1_VHV_RESULT__PEAK_SIGNAL_RATE_MCPS_HI 0x0F82
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_VHV_RESULT__PEAK_SIGNAL_RATE_MCPS_LO 0x0F83
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_VHV_RESULT__SIGNAL_TOTAL_EVENTS_REF 0x0F84
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['patch_results', 'vhv_results']
+
+ fields: \n
+ - [31:0] = vhv_result__signal_total_events_ref
+*/
+#define VL53L1_VHV_RESULT__SIGNAL_TOTAL_EVENTS_REF_3 0x0F84
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_VHV_RESULT__SIGNAL_TOTAL_EVENTS_REF_2 0x0F85
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_VHV_RESULT__SIGNAL_TOTAL_EVENTS_REF_1 0x0F86
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_VHV_RESULT__SIGNAL_TOTAL_EVENTS_REF_0 0x0F87
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PHASECAL_RESULT__PHASE_OUTPUT_REF 0x0F88
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['patch_results', 'phasecal_results']
+
+ fields: \n
+ - [15:0] = phasecal_result__normalised_phase_ref
+*/
+#define VL53L1_PHASECAL_RESULT__PHASE_OUTPUT_REF_HI 0x0F88
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_PHASECAL_RESULT__PHASE_OUTPUT_REF_LO 0x0F89
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_DSS_RESULT__TOTAL_RATE_PER_SPAD 0x0F8A
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['patch_results', 'dss_results']
+
+ fields: \n
+ - [15:0] = dss_result__total_rate_per_spad
+*/
+#define VL53L1_DSS_RESULT__TOTAL_RATE_PER_SPAD_HI 0x0F8A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_DSS_RESULT__TOTAL_RATE_PER_SPAD_LO 0x0F8B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_DSS_RESULT__ENABLED_BLOCKS 0x0F8C
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['patch_results', 'dss_results']
+
+ fields: \n
+ - [7:0] = dss_result__enabled_blocks
+*/
+#define VL53L1_DSS_RESULT__NUM_REQUESTED_SPADS 0x0F8E
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['patch_results', 'dss_results']
+
+ fields: \n
+ - [15:0] = dss_result__num_requested_spads (fixed point 8.8)
+*/
+#define VL53L1_DSS_RESULT__NUM_REQUESTED_SPADS_HI 0x0F8E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_DSS_RESULT__NUM_REQUESTED_SPADS_LO 0x0F8F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MM_RESULT__INNER_INTERSECTION_RATE 0x0F92
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['patch_results', 'mm_results']
+
+ fields: \n
+ - [15:0] = mm_result__inner_intersection_rate
+*/
+#define VL53L1_MM_RESULT__INNER_INTERSECTION_RATE_HI 0x0F92
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MM_RESULT__INNER_INTERSECTION_RATE_LO 0x0F93
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MM_RESULT__OUTER_COMPLEMENT_RATE 0x0F94
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['patch_results', 'mm_results']
+
+ fields: \n
+ - [15:0] = mm_result__outer_complement_rate
+*/
+#define VL53L1_MM_RESULT__OUTER_COMPLEMENT_RATE_HI 0x0F94
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MM_RESULT__OUTER_COMPLEMENT_RATE_LO 0x0F95
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MM_RESULT__TOTAL_OFFSET 0x0F96
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['patch_results', 'mm_results']
+
+ fields: \n
+ - [15:0] = mm_result__total_offset
+*/
+#define VL53L1_MM_RESULT__TOTAL_OFFSET_HI 0x0F96
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_MM_RESULT__TOTAL_OFFSET_LO 0x0F97
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_XTALK_CALC__XTALK_FOR_ENABLED_SPADS 0x0F98
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 23
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['patch_results', 'xtalk_calc']
+
+ fields: \n
+ - [23:0] = xtalk_calc__xtalk_for_enabled_spads (fixed point 11.13)
+*/
+#define VL53L1_XTALK_CALC__XTALK_FOR_ENABLED_SPADS_3 0x0F98
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_XTALK_CALC__XTALK_FOR_ENABLED_SPADS_2 0x0F99
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_XTALK_CALC__XTALK_FOR_ENABLED_SPADS_1 0x0F9A
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_XTALK_CALC__XTALK_FOR_ENABLED_SPADS_0 0x0F9B
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_XTALK_RESULT__AVG_XTALK_USER_ROI_KCPS 0x0F9C
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 23
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['patch_results', 'xtalk_results']
+
+ fields: \n
+ - [23:0] = xtalk_result__avg_xtalk_user_roi_kcps (fixed point 11.13)
+*/
+#define VL53L1_XTALK_RESULT__AVG_XTALK_USER_ROI_KCPS_3 0x0F9C
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_XTALK_RESULT__AVG_XTALK_USER_ROI_KCPS_2 0x0F9D
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_XTALK_RESULT__AVG_XTALK_USER_ROI_KCPS_1 0x0F9E
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_XTALK_RESULT__AVG_XTALK_USER_ROI_KCPS_0 0x0F9F
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_XTALK_RESULT__AVG_XTALK_MM_INNER_ROI_KCPS 0x0FA0
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 23
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['patch_results', 'xtalk_results']
+
+ fields: \n
+ - [23:0] = xtalk_result__avg_xtalk_mm_inner_roi_kcps (fixed point 11.13)
+*/
+#define VL53L1_XTALK_RESULT__AVG_XTALK_MM_INNER_ROI_KCPS_3 0x0FA0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_XTALK_RESULT__AVG_XTALK_MM_INNER_ROI_KCPS_2 0x0FA1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_XTALK_RESULT__AVG_XTALK_MM_INNER_ROI_KCPS_1 0x0FA2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_XTALK_RESULT__AVG_XTALK_MM_INNER_ROI_KCPS_0 0x0FA3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_XTALK_RESULT__AVG_XTALK_MM_OUTER_ROI_KCPS 0x0FA4
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 23
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['patch_results', 'xtalk_results']
+
+ fields: \n
+ - [23:0] = xtalk_result__avg_xtalk_mm_outer_roi_kcps (fixed point 11.13)
+*/
+#define VL53L1_XTALK_RESULT__AVG_XTALK_MM_OUTER_ROI_KCPS_3 0x0FA4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_XTALK_RESULT__AVG_XTALK_MM_OUTER_ROI_KCPS_2 0x0FA5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_XTALK_RESULT__AVG_XTALK_MM_OUTER_ROI_KCPS_1 0x0FA6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_XTALK_RESULT__AVG_XTALK_MM_OUTER_ROI_KCPS_0 0x0FA7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGE_RESULT__ACCUM_PHASE 0x0FA8
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['patch_results', 'range_results']
+
+ fields: \n
+ - [31:0] = range_result__accum_phase
+*/
+#define VL53L1_RANGE_RESULT__ACCUM_PHASE_3 0x0FA8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGE_RESULT__ACCUM_PHASE_2 0x0FA9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGE_RESULT__ACCUM_PHASE_1 0x0FAA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGE_RESULT__ACCUM_PHASE_0 0x0FAB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGE_RESULT__OFFSET_CORRECTED_RANGE 0x0FAC
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['patch_results', 'range_results']
+
+ fields: \n
+ - [15:0] = range_result__offset_corrected_range
+*/
+#define VL53L1_RANGE_RESULT__OFFSET_CORRECTED_RANGE_HI 0x0FAC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_RANGE_RESULT__OFFSET_CORRECTED_RANGE_LO 0x0FAD
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_PHASECAL_RESULT__VCSEL_START 0x0FAE
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['shadow_system_results', 'histogram_results']
+
+ fields: \n
+ - [7:0] = shadow_phasecal_result__vcsel_start
+*/
+#define VL53L1_SHADOW_RESULT__INTERRUPT_STATUS 0x0FB0
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [2:0] = shadow_int_status
+ - [4:3] = shadow_int_error_status
+ - [5] = shadow_gph_id_gpio_status
+*/
+#define VL53L1_SHADOW_RESULT__RANGE_STATUS 0x0FB1
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [4:0] = shadow_range_status
+ - [5] = shadow_max_threshold_hit
+ - [6] = shadow_min_threshold_hit
+ - [7] = shadow_gph_id_range_status
+*/
+#define VL53L1_SHADOW_RESULT__REPORT_STATUS 0x0FB2
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [3:0] = shadow_report_status
+*/
+#define VL53L1_SHADOW_RESULT__STREAM_COUNT 0x0FB3
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [7:0] = shadow_result__stream_count
+*/
+#define VL53L1_SHADOW_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0 0x0FB4
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__dss_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+#define VL53L1_SHADOW_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0_HI 0x0FB4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0_LO 0x0FB5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD0 0x0FB6
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__peak_signal_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+#define VL53L1_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD0_HI 0x0FB6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD0_LO 0x0FB7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__AMBIENT_COUNT_RATE_MCPS_SD0 0x0FB8
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__ambient_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+#define VL53L1_SHADOW_RESULT__AMBIENT_COUNT_RATE_MCPS_SD0_HI 0x0FB8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__AMBIENT_COUNT_RATE_MCPS_SD0_LO 0x0FB9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__SIGMA_SD0 0x0FBA
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__sigma_sd0 (fixed point 14.2)
+*/
+#define VL53L1_SHADOW_RESULT__SIGMA_SD0_HI 0x0FBA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__SIGMA_SD0_LO 0x0FBB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__PHASE_SD0 0x0FBC
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__phase_sd0 (fixed point 5.11)
+*/
+#define VL53L1_SHADOW_RESULT__PHASE_SD0_HI 0x0FBC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__PHASE_SD0_LO 0x0FBD
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 0x0FBE
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__final_crosstalk_corrected_range_mm_sd0
+*/
+#define VL53L1_SHADOW_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0_HI 0x0FBE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0_LO 0x0FBF
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0 0x0FC0
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0 (fixed point 9.7)
+*/
+#define VL53L1_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0_HI 0x0FC0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0_LO 0x0FC1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__MM_INNER_ACTUAL_EFFECTIVE_SPADS_SD0 0x0FC2
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__mm_inner_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+#define VL53L1_SHADOW_RESULT__MM_INNER_ACTUAL_EFFECTIVE_SPADS_SD0_HI 0x0FC2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__MM_INNER_ACTUAL_EFFECTIVE_SPADS_SD0_LO 0x0FC3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__MM_OUTER_ACTUAL_EFFECTIVE_SPADS_SD0 0x0FC4
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__mm_outer_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+#define VL53L1_SHADOW_RESULT__MM_OUTER_ACTUAL_EFFECTIVE_SPADS_SD0_HI 0x0FC4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__MM_OUTER_ACTUAL_EFFECTIVE_SPADS_SD0_LO 0x0FC5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__AVG_SIGNAL_COUNT_RATE_MCPS_SD0 0x0FC6
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__avg_signal_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+#define VL53L1_SHADOW_RESULT__AVG_SIGNAL_COUNT_RATE_MCPS_SD0_HI 0x0FC6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__AVG_SIGNAL_COUNT_RATE_MCPS_SD0_LO 0x0FC7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD1 0x0FC8
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__dss_actual_effective_spads_sd1 (fixed point 8.8)
+*/
+#define VL53L1_SHADOW_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD1_HI 0x0FC8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD1_LO 0x0FC9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD1 0x0FCA
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__peak_signal_count_rate_mcps_sd1 (fixed point 9.7)
+*/
+#define VL53L1_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD1_HI 0x0FCA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__PEAK_SIGNAL_COUNT_RATE_MCPS_SD1_LO 0x0FCB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__AMBIENT_COUNT_RATE_MCPS_SD1 0x0FCC
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__ambient_count_rate_mcps_sd1 (fixed point 9.7)
+*/
+#define VL53L1_SHADOW_RESULT__AMBIENT_COUNT_RATE_MCPS_SD1_HI 0x0FCC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__AMBIENT_COUNT_RATE_MCPS_SD1_LO 0x0FCD
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__SIGMA_SD1 0x0FCE
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__sigma_sd1 (fixed point 14.2)
+*/
+#define VL53L1_SHADOW_RESULT__SIGMA_SD1_HI 0x0FCE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__SIGMA_SD1_LO 0x0FCF
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__PHASE_SD1 0x0FD0
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__phase_sd1 (fixed point 5.11)
+*/
+#define VL53L1_SHADOW_RESULT__PHASE_SD1_HI 0x0FD0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__PHASE_SD1_LO 0x0FD1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD1 0x0FD2
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__final_crosstalk_corrected_range_mm_sd1
+*/
+#define VL53L1_SHADOW_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD1_HI 0x0FD2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD1_LO 0x0FD3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__SPARE_0_SD1 0x0FD4
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__spare_0_sd1
+*/
+#define VL53L1_SHADOW_RESULT__SPARE_0_SD1_HI 0x0FD4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__SPARE_0_SD1_LO 0x0FD5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__SPARE_1_SD1 0x0FD6
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__spare_1_sd1
+*/
+#define VL53L1_SHADOW_RESULT__SPARE_1_SD1_HI 0x0FD6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__SPARE_1_SD1_LO 0x0FD7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__SPARE_2_SD1 0x0FD8
+/*!<
+ type: uint16_t \n
+ default: 0x0000 \n
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [15:0] = shadow_result__spare_2_sd1
+*/
+#define VL53L1_SHADOW_RESULT__SPARE_2_SD1_HI 0x0FD8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__SPARE_2_SD1_LO 0x0FD9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT__SPARE_3_SD1 0x0FDA
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [7:0] = shadow_result__spare_3_sd1
+*/
+#define VL53L1_SHADOW_RESULT__THRESH_INFO 0x0FDB
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['shadow_system_results', 'results']
+
+ fields: \n
+ - [3:0] = shadow_result__distance_int_info
+ - [7:4] = shadow_result__rate_int_info
+*/
+#define VL53L1_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0 0x0FDC
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = shadow_result_core__ambient_window_events_sd0
+*/
+#define VL53L1_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0_3 0x0FDC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0_2 0x0FDD
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0_1 0x0FDE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0_0 0x0FDF
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD0 0x0FE0
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = shadow_result_core__ranging_total_events_sd0
+*/
+#define VL53L1_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD0_3 0x0FE0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD0_2 0x0FE1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD0_1 0x0FE2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD0_0 0x0FE3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD0 0x0FE4
+/*!<
+ type: int32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = shadow_result_core__signal_total_events_sd0
+*/
+#define VL53L1_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD0_3 0x0FE4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD0_2 0x0FE5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD0_1 0x0FE6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD0_0 0x0FE7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD0 0x0FE8
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = shadow_result_core__total_periods_elapsed_sd0
+*/
+#define VL53L1_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD0_3 0x0FE8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD0_2 0x0FE9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD0_1 0x0FEA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD0_0 0x0FEB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD1 0x0FEC
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = shadow_result_core__ambient_window_events_sd1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD1_3 0x0FEC
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD1_2 0x0FED
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD1_1 0x0FEE
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD1_0 0x0FEF
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD1 0x0FF0
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = shadow_result_core__ranging_total_events_sd1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD1_3 0x0FF0
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD1_2 0x0FF1
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD1_1 0x0FF2
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__RANGING_TOTAL_EVENTS_SD1_0 0x0FF3
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD1 0x0FF4
+/*!<
+ type: int32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = shadow_result_core__signal_total_events_sd1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD1_3 0x0FF4
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD1_2 0x0FF5
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD1_1 0x0FF6
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__SIGNAL_TOTAL_EVENTS_SD1_0 0x0FF7
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD1 0x0FF8
+/*!<
+ type: uint32_t \n
+ default: 0x00000000 \n
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ groups: \n
+ ['shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [31:0] = shadow_result_core__total_periods_elapsed_sd1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD1_3 0x0FF8
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD1_2 0x0FF9
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD1_1 0x0FFA
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__TOTAL_PERIODS_ELAPSED_SD1_0 0x0FFB
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+*/
+#define VL53L1_SHADOW_RESULT_CORE__SPARE_0 0x0FFC
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['shadow_core_results', 'ranging_core_results']
+
+ fields: \n
+ - [7:0] = shadow_result_core__spare_0
+*/
+#define VL53L1_SHADOW_PHASECAL_RESULT__REFERENCE_PHASE_HI 0x0FFE
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['shadow_system_results', 'histogram_results']
+
+ fields: \n
+ - [7:0] = shadow_phasecal_result__reference_phase_hi
+*/
+#define VL53L1_SHADOW_PHASECAL_RESULT__REFERENCE_PHASE_LO 0x0FFF
+/*!<
+ type: uint8_t \n
+ default: 0x00 \n
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ groups: \n
+ ['shadow_system_results', 'histogram_results']
+
+ fields: \n
+ - [7:0] = shadow_phasecal_result__reference_phase_lo
+*/
+
+/** @} VL53L1_register_DefineRegisters_group */
+
+
+#endif
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_register_settings.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_register_settings.h
new file mode 100644
index 0000000..17abac2
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_register_settings.h
@@ -0,0 +1,222 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_register_settings.h
+ *
+ * @brief Device register setting defines.
+ */
+
+#ifndef _VL53L1_REGISTER_SETTINGS_H_
+#define _VL53L1_REGISTER_SETTINGS_H_
+
+
+/** @defgroup VL53L1_RegisterSettings_group Functionality
+ * @brief Defines the register settings for key device
+ * configuration registers
+ * @{
+ */
+
+/** @defgroup VL53L1_DeviceSchedulerMode_group - Pseudo, Streaming & Hist
+ * @brief Values below match the bit positions in the SYSTEM__MODE_START
+ * register do not change
+ * @{
+ */
+
+#define VL53L1_DEVICESCHEDULERMODE_PSEUDO_SOLO 0x00
+#define VL53L1_DEVICESCHEDULERMODE_STREAMING 0x01
+#define VL53L1_DEVICESCHEDULERMODE_HISTOGRAM 0x02
+
+/** @} end of VL53L1_DeviceReadoutMode_group */
+
+/** @defgroup VL53L1_DeviceReadoutMode_group - Single, Dual, Split & Manual
+ * @brief Values below match the bit positions in the SYSTEM__MODE_START
+ * register do not change
+ * @{
+ */
+
+#define VL53L1_DEVICEREADOUTMODE_SINGLE_SD (0x00 << 2)
+#define VL53L1_DEVICEREADOUTMODE_DUAL_SD (0x01 << 2)
+#define VL53L1_DEVICEREADOUTMODE_SPLIT_READOUT (0x02 << 2)
+#define VL53L1_DEVICEREADOUTMODE_SPLIT_MANUAL (0x03 << 2)
+
+/** @} end of VL53L1_DeviceReadoutMode_group */
+
+/** @defgroup VL53L1_DeviceMeasurementMode_group - SingleShot, BackToBack & timed
+ * @brief Values below match the bit positions in the SYSTEM__MODE_START
+ * register do not change
+ * @{
+ */
+
+/*
+#define VL53L1_DEVICEMEASUREMENTMODE_STOP 0x00
+#define VL53L1_DEVICEMEASUREMENTMODE_SINGLESHOT 0x10
+#define VL53L1_DEVICEMEASUREMENTMODE_BACKTOBACK 0x20
+#define VL53L1_DEVICEMEASUREMENTMODE_TIMED 0x40
+#define VL53L1_DEVICEMEASUREMENTMODE_ABORT 0x80
+*/
+#define VL53L1_DEVICEMEASUREMENTMODE_MODE_MASK 0xF0
+#define VL53L1_DEVICEMEASUREMENTMODE_STOP_MASK 0x0F
+
+#define VL53L1_GROUPEDPARAMETERHOLD_ID_MASK 0x02
+
+/** @} end of VL53L1_DeviceMeasurementMode_group */
+
+#define VL53L1_EWOK_I2C_DEV_ADDR_DEFAULT 0x29
+ /*!< Device default 7-bit I2C address */
+#define VL53L1_OSC_FREQUENCY 0x00
+#define VL53L1_OSC_TRIM_DEFAULT 0x00
+#define VL53L1_OSC_FREQ_SET_DEFAULT 0x00
+
+#define VL53L1_RANGE_HISTOGRAM_REF 0x08
+#define VL53L1_RANGE_HISTOGRAM_RET 0x10
+#define VL53L1_RANGE_HISTOGRAM_BOTH 0x18
+#define VL53L1_RANGE_HISTOGRAM_INIT 0x20
+#define VL53L1_RANGE_VHV_INIT 0x40
+
+/* Result Status */
+#define VL53L1_RESULT_RANGE_STATUS 0x1F
+
+/* */
+#define VL53L1_SYSTEM__SEED_CONFIG__MANUAL 0x00
+#define VL53L1_SYSTEM__SEED_CONFIG__STANDARD 0x01
+#define VL53L1_SYSTEM__SEED_CONFIG__EVEN_UPDATE_ONLY 0x02
+
+/* Interrupt Config */
+#define VL53L1_INTERRUPT_CONFIG_LEVEL_LOW 0x00
+#define VL53L1_INTERRUPT_CONFIG_LEVEL_HIGH 0x01
+#define VL53L1_INTERRUPT_CONFIG_OUT_OF_WINDOW 0x02
+#define VL53L1_INTERRUPT_CONFIG_IN_WINDOW 0x03
+#define VL53L1_INTERRUPT_CONFIG_NEW_SAMPLE_READY 0x20
+
+/* Interrupt Clear */
+#define VL53L1_CLEAR_RANGE_INT 0x01
+#define VL53L1_CLEAR_ERROR_INT 0x02
+
+/* Sequence Config */
+#define VL53L1_SEQUENCE_VHV_EN 0x01
+#define VL53L1_SEQUENCE_PHASECAL_EN 0x02
+#define VL53L1_SEQUENCE_REFERENCE_PHASE_EN 0x04
+#define VL53L1_SEQUENCE_DSS1_EN 0x08
+#define VL53L1_SEQUENCE_DSS2_EN 0x10
+#define VL53L1_SEQUENCE_MM1_EN 0x20
+#define VL53L1_SEQUENCE_MM2_EN 0x40
+#define VL53L1_SEQUENCE_RANGE_EN 0x80
+
+/* defines for DSS__ROI_CONTROL */
+#define VL53L1_DSS_CONTROL__ROI_SUBTRACT 0x20
+#define VL53L1_DSS_CONTROL__ROI_INTERSECT 0x10
+
+#define VL53L1_DSS_CONTROL__MODE_DISABLED 0x00
+#define VL53L1_DSS_CONTROL__MODE_TARGET_RATE 0x01
+#define VL53L1_DSS_CONTROL__MODE_EFFSPADS 0x02
+#define VL53L1_DSS_CONTROL__MODE_BLOCKSELECT 0x03
+
+/* SPAD Readout defines
+ *
+ * 7:6 - SPAD_IN_SEL_REF
+ * 5:4 - SPAD_IN_SEL_RTN
+ * 2 - SPAD_PS_BYPASS
+ * 0 - SPAD_EN_PULSE_EXTENDER
+ */
+
+#define VL53L1_RANGING_CORE__SPAD_READOUT__STANDARD 0x45
+#define VL53L1_RANGING_CORE__SPAD_READOUT__RETURN_ARRAY_ONLY 0x05
+#define VL53L1_RANGING_CORE__SPAD_READOUT__REFERENCE_ARRAY_ONLY 0x55
+#define VL53L1_RANGING_CORE__SPAD_READOUT__RETURN_SPLIT_ARRAY 0x25
+#define VL53L1_RANGING_CORE__SPAD_READOUT__CALIB_PULSES 0xF5
+
+
+#define VL53L1_LASER_SAFETY__KEY_VALUE 0x6C
+
+/* Range Status defines
+ *
+ * 7 - GPH ID
+ * 6 - Min threshold hit
+ * 5 - Max threshold hit
+ * 4:0 - Range Status
+ */
+
+#define VL53L1_RANGE_STATUS__RANGE_STATUS_MASK 0x1F
+#define VL53L1_RANGE_STATUS__MAX_THRESHOLD_HIT_MASK 0x20
+#define VL53L1_RANGE_STATUS__MIN_THRESHOLD_HIT_MASK 0x40
+#define VL53L1_RANGE_STATUS__GPH_ID_RANGE_STATUS_MASK 0x80
+
+/* Interrupt Status defines
+ *
+ * 5 - GPH ID
+ * 4:3 - Interrupt Error Status
+ * 2:0 - Interrupt Status
+ */
+
+#define VL53L1_INTERRUPT_STATUS__INT_STATUS_MASK 0x07
+#define VL53L1_INTERRUPT_STATUS__INT_ERROR_STATUS_MASK 0x18
+#define VL53L1_INTERRUPT_STATUS__GPH_ID_INT_STATUS_MASK 0x20
+
+/** @} end of VL53L1_RegisterSettings_group */
+
+
+#endif
+
+/* _VL53L1_REGISTER_SETTINGS_H_ */
+
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_register_structs.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_register_structs.h
new file mode 100644
index 0000000..b29cc3a
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_register_structs.h
@@ -0,0 +1,4402 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_register_structs.h
+ * @brief VL53L1 Register Structure definitions
+ */
+
+#ifndef _VL53L1_REGISTER_STRUCTS_H_
+#define _VL53L1_REGISTER_STRUCTS_H_
+
+#include "vl53l1_types.h"
+#include "vl53l1_register_map.h"
+
+#define VL53L1_STATIC_NVM_MANAGED_I2C_INDEX VL53L1_I2C_SLAVE__DEVICE_ADDRESS
+#define VL53L1_CUSTOMER_NVM_MANAGED_I2C_INDEX VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_REF_0
+#define VL53L1_STATIC_CONFIG_I2C_INDEX VL53L1_DSS_CONFIG__TARGET_TOTAL_RATE_MCPS
+#define VL53L1_GENERAL_CONFIG_I2C_INDEX VL53L1_GPH_CONFIG__STREAM_COUNT_UPDATE_VALUE
+#define VL53L1_TIMING_CONFIG_I2C_INDEX VL53L1_MM_CONFIG__TIMEOUT_MACROP_A_HI
+#define VL53L1_DYNAMIC_CONFIG_I2C_INDEX VL53L1_SYSTEM__GROUPED_PARAMETER_HOLD_0
+#define VL53L1_SYSTEM_CONTROL_I2C_INDEX VL53L1_POWER_MANAGEMENT__GO1_POWER_FORCE
+#define VL53L1_SYSTEM_RESULTS_I2C_INDEX VL53L1_RESULT__INTERRUPT_STATUS
+#define VL53L1_CORE_RESULTS_I2C_INDEX VL53L1_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0
+#define VL53L1_DEBUG_RESULTS_I2C_INDEX VL53L1_PHASECAL_RESULT__REFERENCE_PHASE
+#define VL53L1_NVM_COPY_DATA_I2C_INDEX VL53L1_IDENTIFICATION__MODEL_ID
+#define VL53L1_PREV_SHADOW_SYSTEM_RESULTS_I2C_INDEX VL53L1_PREV_SHADOW_RESULT__INTERRUPT_STATUS
+#define VL53L1_PREV_SHADOW_CORE_RESULTS_I2C_INDEX VL53L1_PREV_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0
+#define VL53L1_PATCH_DEBUG_I2C_INDEX VL53L1_RESULT__DEBUG_STATUS
+#define VL53L1_GPH_GENERAL_CONFIG_I2C_INDEX VL53L1_GPH__SYSTEM__THRESH_RATE_HIGH
+#define VL53L1_GPH_STATIC_CONFIG_I2C_INDEX VL53L1_GPH__DSS_CONFIG__ROI_MODE_CONTROL
+#define VL53L1_GPH_TIMING_CONFIG_I2C_INDEX VL53L1_GPH__MM_CONFIG__TIMEOUT_MACROP_A_HI
+#define VL53L1_FW_INTERNAL_I2C_INDEX VL53L1_FIRMWARE__INTERNAL_STREAM_COUNT_DIV
+#define VL53L1_PATCH_RESULTS_I2C_INDEX VL53L1_DSS_CALC__ROI_CTRL
+#define VL53L1_SHADOW_SYSTEM_RESULTS_I2C_INDEX VL53L1_SHADOW_PHASECAL_RESULT__VCSEL_START
+#define VL53L1_SHADOW_CORE_RESULTS_I2C_INDEX VL53L1_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0
+
+#define VL53L1_STATIC_NVM_MANAGED_I2C_SIZE_BYTES 11
+#define VL53L1_CUSTOMER_NVM_MANAGED_I2C_SIZE_BYTES 23
+#define VL53L1_STATIC_CONFIG_I2C_SIZE_BYTES 32
+#define VL53L1_GENERAL_CONFIG_I2C_SIZE_BYTES 22
+#define VL53L1_TIMING_CONFIG_I2C_SIZE_BYTES 23
+#define VL53L1_DYNAMIC_CONFIG_I2C_SIZE_BYTES 18
+#define VL53L1_SYSTEM_CONTROL_I2C_SIZE_BYTES 5
+#define VL53L1_SYSTEM_RESULTS_I2C_SIZE_BYTES 44
+#define VL53L1_CORE_RESULTS_I2C_SIZE_BYTES 33
+#define VL53L1_DEBUG_RESULTS_I2C_SIZE_BYTES 56
+#define VL53L1_NVM_COPY_DATA_I2C_SIZE_BYTES 49
+#define VL53L1_PREV_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES 44
+#define VL53L1_PREV_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES 33
+#define VL53L1_PATCH_DEBUG_I2C_SIZE_BYTES 2
+#define VL53L1_GPH_GENERAL_CONFIG_I2C_SIZE_BYTES 5
+#define VL53L1_GPH_STATIC_CONFIG_I2C_SIZE_BYTES 6
+#define VL53L1_GPH_TIMING_CONFIG_I2C_SIZE_BYTES 16
+#define VL53L1_FW_INTERNAL_I2C_SIZE_BYTES 2
+#define VL53L1_PATCH_RESULTS_I2C_SIZE_BYTES 90
+#define VL53L1_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES 82
+#define VL53L1_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES 33
+
+
+/**
+ * @struct VL53L1_static_nvm_managed_t
+ *
+ * - registers = 10
+ * - first_index = 1 (0x0001)
+ * - last _index = 11 (0x000B)
+ * - i2c_size = 11
+ */
+
+typedef struct {
+ uint8_t i2c_slave__device_address;
+/*!<
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [6:0] = i2c_slave_device_address
+*/
+ uint8_t ana_config__vhv_ref_sel_vddpix;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = ref_sel_vddpix
+*/
+ uint8_t ana_config__vhv_ref_sel_vquench;
+/*!<
+ info: \n
+ - msb = 6
+ - lsb = 3
+ - i2c_size = 1
+
+ fields: \n
+ - [6:3] = ref_sel_vquench
+*/
+ uint8_t ana_config__reg_avdd1v2_sel;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [1:0] = reg_avdd1v2_sel
+*/
+ uint8_t ana_config__fast_osc__trim;
+/*!<
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [6:0] = fast_osc_trim
+*/
+ uint16_t osc_measured__fast_osc__frequency;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = osc_frequency (fixed point 4.12)
+*/
+ uint8_t vhv_config__timeout_macrop_loop_bound;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [1:0] = vhv_timeout__macrop
+ - [7:2] = vhv_loop_bound
+*/
+ uint8_t vhv_config__count_thresh;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = vhv_count_thresh
+*/
+ uint8_t vhv_config__offset;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [5:0] = vhv_step_val
+*/
+ uint8_t vhv_config__init;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7] = vhv0_init_enable
+ - [5:0] = vhv0_init_value
+*/
+} VL53L1_static_nvm_managed_t;
+
+
+/**
+ * @struct VL53L1_customer_nvm_managed_t
+ *
+ * - registers = 16
+ * - first_index = 13 (0x000D)
+ * - last _index = 34 (0x0022)
+ * - i2c_size = 23
+ */
+
+typedef struct {
+ uint8_t global_config__spad_enables_ref_0;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_ref_0
+*/
+ uint8_t global_config__spad_enables_ref_1;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_ref_1
+*/
+ uint8_t global_config__spad_enables_ref_2;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_ref_2
+*/
+ uint8_t global_config__spad_enables_ref_3;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_ref_3
+*/
+ uint8_t global_config__spad_enables_ref_4;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_ref_4
+*/
+ uint8_t global_config__spad_enables_ref_5;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = spad_enables_ref_5
+*/
+ uint8_t global_config__ref_en_start_select;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = ref_en_start_select
+*/
+ uint8_t ref_spad_man__num_requested_ref_spads;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [5:0] = ref_spad_man__num_requested_ref_spad
+*/
+ uint8_t ref_spad_man__ref_location;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [1:0] = ref_spad_man__ref_location
+*/
+ uint16_t algo__crosstalk_compensation_plane_offset_kcps;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = crosstalk_compensation_plane_offset_kcps (fixed point 7.9)
+*/
+ int16_t algo__crosstalk_compensation_x_plane_gradient_kcps;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = crosstalk_compensation_x_plane_gradient_kcps (fixed point 5.11)
+*/
+ int16_t algo__crosstalk_compensation_y_plane_gradient_kcps;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = crosstalk_compensation_y_plane_gradient_kcps (fixed point 5.11)
+*/
+ uint16_t ref_spad_char__total_rate_target_mcps;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = ref_spad_char__total_rate_target_mcps (fixed point 9.7)
+*/
+ int16_t algo__part_to_part_range_offset_mm;
+/*!<
+ info: \n
+ - msb = 12
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [12:0] = part_to_part_offset_mm (fixed point 11.2)
+*/
+ int16_t mm_config__inner_offset_mm;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = mm_config__inner_offset_mm
+*/
+ int16_t mm_config__outer_offset_mm;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = mm_config__outer_offset_mm
+*/
+} VL53L1_customer_nvm_managed_t;
+
+
+/**
+ * @struct VL53L1_static_config_t
+ *
+ * - registers = 30
+ * - first_index = 36 (0x0024)
+ * - last _index = 67 (0x0043)
+ * - i2c_size = 32
+ */
+
+typedef struct {
+ uint16_t dss_config__target_total_rate_mcps;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = dss_config__target_total_rate_mcps (fixed point 9.7)
+*/
+ uint8_t debug__ctrl;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = enable_result_logging
+*/
+ uint8_t test_mode__ctrl;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = test_mode__cmd
+*/
+ uint8_t clk_gating__ctrl;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = clk_gate_en__mcu_bank
+ - [1] = clk_gate_en__mcu_patch_ctrl
+ - [2] = clk_gate_en__mcu_timers
+ - [3] = clk_gate_en__mcu_mult_div
+*/
+ uint8_t nvm_bist__ctrl;
+/*!<
+ info: \n
+ - msb = 4
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [2:0] = nvm_bist__cmd
+ - [4] = nvm_bist__ctrl
+*/
+ uint8_t nvm_bist__num_nvm_words;
+/*!<
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [6:0] = nvm_bist__num_nvm_words
+*/
+ uint8_t nvm_bist__start_address;
+/*!<
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [6:0] = nvm_bist__start_address
+*/
+ uint8_t host_if__status;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = host_interface
+*/
+ uint8_t pad_i2c_hv__config;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = pad_scl_sda__vmodeint_hv
+ - [1] = i2c_pad__test_hv
+ - [2] = pad_scl__fpen_hv
+ - [4:3] = pad_scl__progdel_hv
+ - [5] = pad_sda__fpen_hv
+ - [7:6] = pad_sda__progdel_hv
+*/
+ uint8_t pad_i2c_hv__extsup_config;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = pad_scl_sda__extsup_hv
+*/
+ uint8_t gpio_hv_pad__ctrl;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = gpio__extsup_hv
+ - [1] = gpio__vmodeint_hv
+*/
+ uint8_t gpio_hv_mux__ctrl;
+/*!<
+ info: \n
+ - msb = 4
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = gpio__mux_select_hv
+ - [4] = gpio__mux_active_high_hv
+*/
+ uint8_t gpio__tio_hv_status;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = gpio__tio_hv
+ - [1] = fresh_out_of_reset
+*/
+ uint8_t gpio__fio_hv_status;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 1
+ - i2c_size = 1
+
+ fields: \n
+ - [1] = gpio__fio_hv
+*/
+ uint8_t ana_config__spad_sel_pswidth;
+/*!<
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [2:0] = spad_sel_pswidth
+*/
+ uint8_t ana_config__vcsel_pulse_width_offset;
+/*!<
+ info: \n
+ - msb = 4
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [4:0] = vcsel_pulse_width_offset (fixed point 1.4)
+*/
+ uint8_t ana_config__fast_osc__config_ctrl;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = osc_config__latch_bypass
+*/
+ uint8_t sigma_estimator__effective_pulse_width_ns;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = sigma_estimator__eff_pulse_width
+*/
+ uint8_t sigma_estimator__effective_ambient_width_ns;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = sigma_estimator__eff_ambient_width
+*/
+ uint8_t sigma_estimator__sigma_ref_mm;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = sigma_estimator__sigma_ref
+*/
+ uint8_t algo__crosstalk_compensation_valid_height_mm;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = crosstalk_compensation_valid_height_mm
+*/
+ uint8_t spare_host_config__static_config_spare_0;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = static_config_spare_0
+*/
+ uint8_t spare_host_config__static_config_spare_1;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = static_config_spare_1
+*/
+ uint16_t algo__range_ignore_threshold_mcps;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = range_ignore_thresh_mcps (fixed point 3.13)
+*/
+ uint8_t algo__range_ignore_valid_height_mm;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = range_ignore_height_mm
+*/
+ uint8_t algo__range_min_clip;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = algo__range_min_clip_enable
+ - [7:1] = algo__range_min_clip_value_mm
+*/
+ uint8_t algo__consistency_check__tolerance;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = consistency_check_tolerance (fixed point 1.3)
+*/
+ uint8_t spare_host_config__static_config_spare_2;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = static_config_spare_2
+*/
+ uint8_t sd_config__reset_stages_msb;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = loop_init__clear_stage
+*/
+ uint8_t sd_config__reset_stages_lsb;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:4] = accum_reset__clear_stage
+ - [3:0] = count_reset__clear_stage
+*/
+} VL53L1_static_config_t;
+
+
+/**
+ * @struct VL53L1_general_config_t
+ *
+ * - registers = 17
+ * - first_index = 68 (0x0044)
+ * - last _index = 89 (0x0059)
+ * - i2c_size = 22
+ */
+
+typedef struct {
+ uint8_t gph_config__stream_count_update_value;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = stream_count_update_value
+*/
+ uint8_t global_config__stream_divider;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = stream_count_internal_div
+*/
+ uint8_t system__interrupt_config_gpio;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [1:0] = int_mode_distance
+ - [3:2] = int_mode_rate
+ - [4] = int_spare
+ - [5] = int_new_measure_ready
+ - [6] = int_no_target_en
+ - [7] = int_combined_mode
+*/
+ uint8_t cal_config__vcsel_start;
+/*!<
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [6:0] = cal_config__vcsel_start
+*/
+ uint16_t cal_config__repeat_rate;
+/*!<
+ info: \n
+ - msb = 11
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [11:0] = cal_config__repeat_rate
+*/
+ uint8_t global_config__vcsel_width;
+/*!<
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [6:0] = global_config__vcsel_width
+*/
+ uint8_t phasecal_config__timeout_macrop;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = phasecal_config__timeout_macrop
+*/
+ uint8_t phasecal_config__target;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = algo_phasecal_lim
+*/
+ uint8_t phasecal_config__override;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = phasecal_config__override
+*/
+ uint8_t dss_config__roi_mode_control;
+/*!<
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [1:0] = dss_config__input_mode
+ - [2] = calculate_roi_enable
+*/
+ uint16_t system__thresh_rate_high;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = thresh_rate_high (fixed point 9.7)
+*/
+ uint16_t system__thresh_rate_low;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = thresh_rate_low (fixed point 9.7)
+*/
+ uint16_t dss_config__manual_effective_spads_select;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = dss_config__manual_effective_spads_select
+*/
+ uint8_t dss_config__manual_block_select;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_config__manual_block_select
+*/
+ uint8_t dss_config__aperture_attenuation;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_config__aperture_attenuation
+*/
+ uint8_t dss_config__max_spads_limit;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_config__max_spads_limit
+*/
+ uint8_t dss_config__min_spads_limit;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_config__min_spads_limit
+*/
+} VL53L1_general_config_t;
+
+
+/**
+ * @struct VL53L1_timing_config_t
+ *
+ * - registers = 16
+ * - first_index = 90 (0x005A)
+ * - last _index = 112 (0x0070)
+ * - i2c_size = 23
+ */
+
+typedef struct {
+ uint8_t mm_config__timeout_macrop_a_hi;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = mm_config__config_timeout_macrop_a_hi
+*/
+ uint8_t mm_config__timeout_macrop_a_lo;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = mm_config__config_timeout_macrop_a_lo
+*/
+ uint8_t mm_config__timeout_macrop_b_hi;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = mm_config__config_timeout_macrop_b_hi
+*/
+ uint8_t mm_config__timeout_macrop_b_lo;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = mm_config__config_timeout_macrop_b_lo
+*/
+ uint8_t range_config__timeout_macrop_a_hi;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = range_timeout_overall_periods_macrop_a_hi
+*/
+ uint8_t range_config__timeout_macrop_a_lo;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = range_timeout_overall_periods_macrop_a_lo
+*/
+ uint8_t range_config__vcsel_period_a;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [5:0] = range_config__vcsel_period_a
+*/
+ uint8_t range_config__timeout_macrop_b_hi;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = range_timeout_overall_periods_macrop_b_hi
+*/
+ uint8_t range_config__timeout_macrop_b_lo;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = range_timeout_overall_periods_macrop_b_lo
+*/
+ uint8_t range_config__vcsel_period_b;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [5:0] = range_config__vcsel_period_b
+*/
+ uint16_t range_config__sigma_thresh;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = range_config__sigma_thresh (fixed point 14.2)
+*/
+ uint16_t range_config__min_count_rate_rtn_limit_mcps;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = range_config__min_count_rate_rtn_limit_mcps (fixed point 9.7)
+*/
+ uint8_t range_config__valid_phase_low;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = range_config__valid_phase_low (fixed point 5.3)
+*/
+ uint8_t range_config__valid_phase_high;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = range_config__valid_phase_high (fixed point 5.3)
+*/
+ uint32_t system__intermeasurement_period;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = intermeasurement_period
+*/
+ uint8_t system__fractional_enable;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = range_fractional_enable
+*/
+} VL53L1_timing_config_t;
+
+
+/**
+ * @struct VL53L1_dynamic_config_t
+ *
+ * - registers = 16
+ * - first_index = 113 (0x0071)
+ * - last _index = 130 (0x0082)
+ * - i2c_size = 18
+ */
+
+typedef struct {
+ uint8_t system__grouped_parameter_hold_0;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = grouped_parameter_hold
+ - [1] = grouped_parameter_hold_id
+*/
+ uint16_t system__thresh_high;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = thresh_high
+*/
+ uint16_t system__thresh_low;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = thresh_low
+*/
+ uint8_t system__enable_xtalk_per_quadrant;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = system__enable_xtalk_per_quadrant
+*/
+ uint8_t system__seed_config;
+/*!<
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [1:0] = system__seed_config
+ - [2] = system__fw_pause_ctrl
+*/
+ uint8_t sd_config__woi_sd0;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = sd_config__woi_sd0
+*/
+ uint8_t sd_config__woi_sd1;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = sd_config__woi_sd1
+*/
+ uint8_t sd_config__initial_phase_sd0;
+/*!<
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [6:0] = sd_config__initial_phase_sd0
+*/
+ uint8_t sd_config__initial_phase_sd1;
+/*!<
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [6:0] = sd_config__initial_phase_sd1
+*/
+ uint8_t system__grouped_parameter_hold_1;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = grouped_parameter_hold
+ - [1] = grouped_parameter_hold_id
+*/
+ uint8_t sd_config__first_order_select;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = sd_config__first_order_select_rtn
+ - [1] = sd_config__first_order_select_ref
+*/
+ uint8_t sd_config__quantifier;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = sd_config__quantifier
+*/
+ uint8_t roi_config__user_roi_centre_spad;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = user_roi_center_spad
+*/
+ uint8_t roi_config__user_roi_requested_global_xy_size;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = roi_config__user_roi_requested_global_xy_size
+*/
+ uint8_t system__sequence_config;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = sequence_vhv_en
+ - [1] = sequence_phasecal_en
+ - [2] = sequence_reference_phase_en
+ - [3] = sequence_dss1_en
+ - [4] = sequence_dss2_en
+ - [5] = sequence_mm1_en
+ - [6] = sequence_mm2_en
+ - [7] = sequence_range_en
+*/
+ uint8_t system__grouped_parameter_hold;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = grouped_parameter_hold
+ - [1] = grouped_parameter_hold_id
+*/
+} VL53L1_dynamic_config_t;
+
+
+/**
+ * @struct VL53L1_system_control_t
+ *
+ * - registers = 5
+ * - first_index = 131 (0x0083)
+ * - last _index = 135 (0x0087)
+ * - i2c_size = 5
+ */
+
+typedef struct {
+ uint8_t power_management__go1_power_force;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = go1_dig_powerforce
+*/
+ uint8_t system__stream_count_ctrl;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = retain_stream_count
+*/
+ uint8_t firmware__enable;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = firmware_enable
+*/
+ uint8_t system__interrupt_clear;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = sys_interrupt_clear_range
+ - [1] = sys_interrupt_clear_error
+*/
+ uint8_t system__mode_start;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [1:0] = scheduler_mode
+ - [3:2] = readout_mode
+ - [4] = mode_range__single_shot
+ - [5] = mode_range__back_to_back
+ - [6] = mode_range__timed
+ - [7] = mode_range__abort
+*/
+} VL53L1_system_control_t;
+
+
+/**
+ * @struct VL53L1_system_results_t
+ *
+ * - registers = 25
+ * - first_index = 136 (0x0088)
+ * - last _index = 179 (0x00B3)
+ * - i2c_size = 44
+ */
+
+typedef struct {
+ uint8_t result__interrupt_status;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [2:0] = int_status
+ - [4:3] = int_error_status
+ - [5] = gph_id_gpio_status
+*/
+ uint8_t result__range_status;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [4:0] = range_status
+ - [5] = max_threshold_hit
+ - [6] = min_threshold_hit
+ - [7] = gph_id_range_status
+*/
+ uint8_t result__report_status;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = report_status
+*/
+ uint8_t result__stream_count;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = result__stream_count
+*/
+ uint16_t result__dss_actual_effective_spads_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__dss_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+ uint16_t result__peak_signal_count_rate_mcps_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__peak_signal_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+ uint16_t result__ambient_count_rate_mcps_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__ambient_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+ uint16_t result__sigma_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__sigma_sd0 (fixed point 14.2)
+*/
+ uint16_t result__phase_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__phase_sd0 (fixed point 5.11)
+*/
+ uint16_t result__final_crosstalk_corrected_range_mm_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__final_crosstalk_corrected_range_mm_sd0
+*/
+ uint16_t result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0 (fixed point 9.7)
+*/
+ uint16_t result__mm_inner_actual_effective_spads_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__mm_inner_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+ uint16_t result__mm_outer_actual_effective_spads_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__mm_outer_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+ uint16_t result__avg_signal_count_rate_mcps_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__avg_signal_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+ uint16_t result__dss_actual_effective_spads_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__dss_actual_effective_spads_sd1 (fixed point 8.8)
+*/
+ uint16_t result__peak_signal_count_rate_mcps_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__peak_signal_count_rate_mcps_sd1 (fixed point 9.7)
+*/
+ uint16_t result__ambient_count_rate_mcps_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__ambient_count_rate_mcps_sd1 (fixed point 9.7)
+*/
+ uint16_t result__sigma_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__sigma_sd1 (fixed point 14.2)
+*/
+ uint16_t result__phase_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__phase_sd1 (fixed point 5.11)
+*/
+ uint16_t result__final_crosstalk_corrected_range_mm_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__final_crosstalk_corrected_range_mm_sd1
+*/
+ uint16_t result__spare_0_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__spare_0_sd1
+*/
+ uint16_t result__spare_1_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__spare_1_sd1
+*/
+ uint16_t result__spare_2_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result__spare_2_sd1
+*/
+ uint8_t result__spare_3_sd1;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = result__spare_3_sd1
+*/
+ uint8_t result__thresh_info;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = result__distance_int_info
+ - [7:4] = result__rate_int_info
+*/
+} VL53L1_system_results_t;
+
+
+/**
+ * @struct VL53L1_core_results_t
+ *
+ * - registers = 9
+ * - first_index = 180 (0x00B4)
+ * - last _index = 212 (0x00D4)
+ * - i2c_size = 33
+ */
+
+typedef struct {
+ uint32_t result_core__ambient_window_events_sd0;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = result_core__ambient_window_events_sd0
+*/
+ uint32_t result_core__ranging_total_events_sd0;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = result_core__ranging_total_events_sd0
+*/
+ int32_t result_core__signal_total_events_sd0;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = result_core__signal_total_events_sd0
+*/
+ uint32_t result_core__total_periods_elapsed_sd0;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = result_core__total_periods_elapsed_sd0
+*/
+ uint32_t result_core__ambient_window_events_sd1;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = result_core__ambient_window_events_sd1
+*/
+ uint32_t result_core__ranging_total_events_sd1;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = result_core__ranging_total_events_sd1
+*/
+ int32_t result_core__signal_total_events_sd1;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = result_core__signal_total_events_sd1
+*/
+ uint32_t result_core__total_periods_elapsed_sd1;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = result_core__total_periods_elapsed_sd1
+*/
+ uint8_t result_core__spare_0;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = result_core__spare_0
+*/
+} VL53L1_core_results_t;
+
+
+/**
+ * @struct VL53L1_debug_results_t
+ *
+ * - registers = 43
+ * - first_index = 214 (0x00D6)
+ * - last _index = 269 (0x010D)
+ * - i2c_size = 56
+ */
+
+typedef struct {
+ uint16_t phasecal_result__reference_phase;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = result_phasecal__reference_phase (fixed point 5.11)
+*/
+ uint8_t phasecal_result__vcsel_start;
+/*!<
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [6:0] = result_phasecal__vcsel_start
+*/
+ uint8_t ref_spad_char_result__num_actual_ref_spads;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [5:0] = ref_spad_char_result__num_actual_ref_spads
+*/
+ uint8_t ref_spad_char_result__ref_location;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [1:0] = ref_spad_char_result__ref_location
+*/
+ uint8_t vhv_result__coldboot_status;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = vhv_result__coldboot_status
+*/
+ uint8_t vhv_result__search_result;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [5:0] = cp_sel_result
+*/
+ uint8_t vhv_result__latest_setting;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [5:0] = cp_sel_latest_setting
+*/
+ uint16_t result__osc_calibrate_val;
+/*!<
+ info: \n
+ - msb = 9
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [9:0] = osc_calibrate_val
+*/
+ uint8_t ana_config__powerdown_go1;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = go2_ref_bg_disable_avdd
+ - [1] = go2_regdvdd1v2_enable_avdd
+*/
+ uint8_t ana_config__ref_bg_ctrl;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = go2_ref_overdrvbg_avdd
+ - [1] = go2_ref_forcebgison_avdd
+*/
+ uint8_t ana_config__regdvdd1v2_ctrl;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = go2_regdvdd1v2_sel_pulldown_avdd
+ - [1] = go2_regdvdd1v2_sel_boost_avdd
+ - [3:2] = go2_regdvdd1v2_selv_avdd
+*/
+ uint8_t ana_config__osc_slow_ctrl;
+/*!<
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = osc_slow_en
+ - [1] = osc_slow_op_en
+ - [2] = osc_slow_freq_sel
+*/
+ uint8_t test_mode__status;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = test_mode_status
+*/
+ uint8_t firmware__system_status;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = firmware_bootup
+ - [1] = firmware_first_range
+*/
+ uint8_t firmware__mode_status;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = firmware_mode_status
+*/
+ uint8_t firmware__secondary_mode_status;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = fw_secondary_mode_status
+*/
+ uint16_t firmware__cal_repeat_rate_counter;
+/*!<
+ info: \n
+ - msb = 11
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [11:0] = firmware_cal_repeat_rate
+*/
+ uint16_t gph__system__thresh_high;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_thresh_high
+*/
+ uint16_t gph__system__thresh_low;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_thresh_low
+*/
+ uint8_t gph__system__enable_xtalk_per_quadrant;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = shadow__enable_xtalk_per_quadrant
+*/
+ uint8_t gph__spare_0;
+/*!<
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = fw_safe_to_disable
+ - [1] = shadow__spare_0
+ - [2] = shadow__spare_1
+*/
+ uint8_t gph__sd_config__woi_sd0;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = shadow_sd_config__woi_sd0
+*/
+ uint8_t gph__sd_config__woi_sd1;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = shadow_sd_config__woi_sd1
+*/
+ uint8_t gph__sd_config__initial_phase_sd0;
+/*!<
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [6:0] = shadow_sd_config__initial_phase_sd0
+*/
+ uint8_t gph__sd_config__initial_phase_sd1;
+/*!<
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [6:0] = shadow_sd_config__initial_phase_sd1
+*/
+ uint8_t gph__sd_config__first_order_select;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = shadow_sd_config__first_order_select_rtn
+ - [1] = shadow_sd_config__first_order_select_ref
+*/
+ uint8_t gph__sd_config__quantifier;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = shadow_sd_config__quantifier
+*/
+ uint8_t gph__roi_config__user_roi_centre_spad;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = shadow_user_roi_center_spad_q0
+*/
+ uint8_t gph__roi_config__user_roi_requested_global_xy_size;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = shadow_user_roi_requested_global_xy_size
+*/
+ uint8_t gph__system__sequence_config;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = shadow_sequence_vhv_en
+ - [1] = shadow_sequence_phasecal_en
+ - [2] = shadow_sequence_reference_phase_en
+ - [3] = shadow_sequence_dss1_en
+ - [4] = shadow_sequence_dss2_en
+ - [5] = shadow_sequence_mm1_en
+ - [6] = shadow_sequence_mm2_en
+ - [7] = shadow_sequence_range_en
+*/
+ uint8_t gph__gph_id;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = shadow_gph_id
+*/
+ uint8_t system__interrupt_set;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = sys_interrupt_set_range
+ - [1] = sys_interrupt_set_error
+*/
+ uint8_t interrupt_manager__enables;
+/*!<
+ info: \n
+ - msb = 4
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = interrupt_enable__single_shot
+ - [1] = interrupt_enable__back_to_back
+ - [2] = interrupt_enable__timed
+ - [3] = interrupt_enable__abort
+ - [4] = interrupt_enable__test
+*/
+ uint8_t interrupt_manager__clear;
+/*!<
+ info: \n
+ - msb = 4
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = interrupt_clear__single_shot
+ - [1] = interrupt_clear__back_to_back
+ - [2] = interrupt_clear__timed
+ - [3] = interrupt_clear__abort
+ - [4] = interrupt_clear__test
+*/
+ uint8_t interrupt_manager__status;
+/*!<
+ info: \n
+ - msb = 4
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = interrupt_status__single_shot
+ - [1] = interrupt_status__back_to_back
+ - [2] = interrupt_status__timed
+ - [3] = interrupt_status__abort
+ - [4] = interrupt_status__test
+*/
+ uint8_t mcu_to_host_bank__wr_access_en;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = mcu_to_host_bank_wr_en
+*/
+ uint8_t power_management__go1_reset_status;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = go1_status
+*/
+ uint8_t pad_startup_mode__value_ro;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = pad_atest1_val_ro
+ - [1] = pad_atest2_val_ro
+*/
+ uint8_t pad_startup_mode__value_ctrl;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = pad_atest1_val
+ - [1] = pad_atest2_val
+ - [4] = pad_atest1_dig_enable
+ - [5] = pad_atest2_dig_enable
+*/
+ uint32_t pll_period_us;
+/*!<
+ info: \n
+ - msb = 17
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [17:0] = pll_period_us (fixed point 0.24)
+*/
+ uint32_t interrupt_scheduler__data_out;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = interrupt_scheduler_data_out
+*/
+ uint8_t nvm_bist__complete;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = nvm_bist__complete
+*/
+ uint8_t nvm_bist__status;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = nvm_bist__status
+*/
+} VL53L1_debug_results_t;
+
+
+/**
+ * @struct VL53L1_nvm_copy_data_t
+ *
+ * - registers = 48
+ * - first_index = 271 (0x010F)
+ * - last _index = 319 (0x013F)
+ * - i2c_size = 49
+ */
+
+typedef struct {
+ uint8_t identification__model_id;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = model_id
+*/
+ uint8_t identification__module_type;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = module_type
+*/
+ uint8_t identification__revision_id;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = nvm_revision_id
+ - [7:4] = mask_revision_id
+*/
+ uint16_t identification__module_id;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = module_id
+*/
+ uint8_t ana_config__fast_osc__trim_max;
+/*!<
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [6:0] = osc_trim_max
+*/
+ uint8_t ana_config__fast_osc__freq_set;
+/*!<
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [2:0] = osc_freq_set
+*/
+ uint8_t ana_config__vcsel_trim;
+/*!<
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [2:0] = vcsel_trim
+*/
+ uint8_t ana_config__vcsel_selion;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [5:0] = vcsel_selion
+*/
+ uint8_t ana_config__vcsel_selion_max;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [5:0] = vcsel_selion_max
+*/
+ uint8_t protected_laser_safety__lock_bit;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = laser_safety__lock_bit
+*/
+ uint8_t laser_safety__key;
+/*!<
+ info: \n
+ - msb = 6
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [6:0] = laser_safety__key
+*/
+ uint8_t laser_safety__key_ro;
+/*!<
+ info: \n
+ - msb = 0
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = laser_safety__key_ro
+*/
+ uint8_t laser_safety__clip;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [5:0] = vcsel_pulse_width_clip
+*/
+ uint8_t laser_safety__mult;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [5:0] = vcsel_pulse_width_mult
+*/
+ uint8_t global_config__spad_enables_rtn_0;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_0
+*/
+ uint8_t global_config__spad_enables_rtn_1;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_1
+*/
+ uint8_t global_config__spad_enables_rtn_2;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_2
+*/
+ uint8_t global_config__spad_enables_rtn_3;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_3
+*/
+ uint8_t global_config__spad_enables_rtn_4;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_4
+*/
+ uint8_t global_config__spad_enables_rtn_5;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_5
+*/
+ uint8_t global_config__spad_enables_rtn_6;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_6
+*/
+ uint8_t global_config__spad_enables_rtn_7;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_7
+*/
+ uint8_t global_config__spad_enables_rtn_8;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_8
+*/
+ uint8_t global_config__spad_enables_rtn_9;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_9
+*/
+ uint8_t global_config__spad_enables_rtn_10;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_10
+*/
+ uint8_t global_config__spad_enables_rtn_11;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_11
+*/
+ uint8_t global_config__spad_enables_rtn_12;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_12
+*/
+ uint8_t global_config__spad_enables_rtn_13;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_13
+*/
+ uint8_t global_config__spad_enables_rtn_14;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_14
+*/
+ uint8_t global_config__spad_enables_rtn_15;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_15
+*/
+ uint8_t global_config__spad_enables_rtn_16;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_16
+*/
+ uint8_t global_config__spad_enables_rtn_17;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_17
+*/
+ uint8_t global_config__spad_enables_rtn_18;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_18
+*/
+ uint8_t global_config__spad_enables_rtn_19;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_19
+*/
+ uint8_t global_config__spad_enables_rtn_20;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_20
+*/
+ uint8_t global_config__spad_enables_rtn_21;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_21
+*/
+ uint8_t global_config__spad_enables_rtn_22;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_22
+*/
+ uint8_t global_config__spad_enables_rtn_23;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_23
+*/
+ uint8_t global_config__spad_enables_rtn_24;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_24
+*/
+ uint8_t global_config__spad_enables_rtn_25;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_25
+*/
+ uint8_t global_config__spad_enables_rtn_26;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_26
+*/
+ uint8_t global_config__spad_enables_rtn_27;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_27
+*/
+ uint8_t global_config__spad_enables_rtn_28;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_28
+*/
+ uint8_t global_config__spad_enables_rtn_29;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_29
+*/
+ uint8_t global_config__spad_enables_rtn_30;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_30
+*/
+ uint8_t global_config__spad_enables_rtn_31;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = spad_enables_rtn_31
+*/
+ uint8_t roi_config__mode_roi_centre_spad;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = mode_roi_center_spad
+*/
+ uint8_t roi_config__mode_roi_xy_size;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = mode_roi_xy_size
+*/
+} VL53L1_nvm_copy_data_t;
+
+
+/**
+ * @struct VL53L1_prev_shadow_system_results_t
+ *
+ * - registers = 24
+ * - first_index = 3792 (0x0ED0)
+ * - last _index = 3834 (0x0EFA)
+ * - i2c_size = 44
+ */
+
+typedef struct {
+ uint8_t prev_shadow_result__interrupt_status;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [2:0] = prev_shadow_int_status
+ - [4:3] = prev_shadow_int_error_status
+ - [5] = prev_shadow_gph_id_gpio_status
+*/
+ uint8_t prev_shadow_result__range_status;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [4:0] = prev_shadow_range_status
+ - [5] = prev_shadow_max_threshold_hit
+ - [6] = prev_shadow_min_threshold_hit
+ - [7] = prev_shadow_gph_id_range_status
+*/
+ uint8_t prev_shadow_result__report_status;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = prev_shadow_report_status
+*/
+ uint8_t prev_shadow_result__stream_count;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = prev_shadow_result__stream_count
+*/
+ uint16_t prev_shadow_result__dss_actual_effective_spads_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__dss_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+ uint16_t prev_shadow_result__peak_signal_count_rate_mcps_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__peak_signal_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+ uint16_t prev_shadow_result__ambient_count_rate_mcps_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__ambient_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+ uint16_t prev_shadow_result__sigma_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__sigma_sd0 (fixed point 14.2)
+*/
+ uint16_t prev_shadow_result__phase_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__phase_sd0 (fixed point 5.11)
+*/
+ uint16_t prev_shadow_result__final_crosstalk_corrected_range_mm_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__final_crosstalk_corrected_range_mm_sd0
+*/
+ uint16_t prev_shadow_result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0 (fixed point 9.7)
+*/
+ uint16_t prev_shadow_result__mm_inner_actual_effective_spads_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__mm_inner_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+ uint16_t prev_shadow_result__mm_outer_actual_effective_spads_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__mm_outer_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+ uint16_t prev_shadow_result__avg_signal_count_rate_mcps_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__avg_signal_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+ uint16_t prev_shadow_result__dss_actual_effective_spads_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__dss_actual_effective_spads_sd1 (fixed point 8.8)
+*/
+ uint16_t prev_shadow_result__peak_signal_count_rate_mcps_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__peak_signal_count_rate_mcps_sd1 (fixed point 9.7)
+*/
+ uint16_t prev_shadow_result__ambient_count_rate_mcps_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__ambient_count_rate_mcps_sd1 (fixed point 9.7)
+*/
+ uint16_t prev_shadow_result__sigma_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__sigma_sd1 (fixed point 14.2)
+*/
+ uint16_t prev_shadow_result__phase_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__phase_sd1 (fixed point 5.11)
+*/
+ uint16_t prev_shadow_result__final_crosstalk_corrected_range_mm_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__final_crosstalk_corrected_range_mm_sd1
+*/
+ uint16_t prev_shadow_result__spare_0_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__spare_0_sd1
+*/
+ uint16_t prev_shadow_result__spare_1_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__spare_1_sd1
+*/
+ uint16_t prev_shadow_result__spare_2_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__spare_2_sd1
+*/
+ uint16_t prev_shadow_result__spare_3_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = prev_shadow_result__spare_3_sd1
+*/
+} VL53L1_prev_shadow_system_results_t;
+
+
+/**
+ * @struct VL53L1_prev_shadow_core_results_t
+ *
+ * - registers = 9
+ * - first_index = 3836 (0x0EFC)
+ * - last _index = 3868 (0x0F1C)
+ * - i2c_size = 33
+ */
+
+typedef struct {
+ uint32_t prev_shadow_result_core__ambient_window_events_sd0;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = prev_shadow_result_core__ambient_window_events_sd0
+*/
+ uint32_t prev_shadow_result_core__ranging_total_events_sd0;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = prev_shadow_result_core__ranging_total_events_sd0
+*/
+ int32_t prev_shadow_result_core__signal_total_events_sd0;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = prev_shadow_result_core__signal_total_events_sd0
+*/
+ uint32_t prev_shadow_result_core__total_periods_elapsed_sd0;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = prev_shadow_result_core__total_periods_elapsed_sd0
+*/
+ uint32_t prev_shadow_result_core__ambient_window_events_sd1;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = prev_shadow_result_core__ambient_window_events_sd1
+*/
+ uint32_t prev_shadow_result_core__ranging_total_events_sd1;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = prev_shadow_result_core__ranging_total_events_sd1
+*/
+ int32_t prev_shadow_result_core__signal_total_events_sd1;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = prev_shadow_result_core__signal_total_events_sd1
+*/
+ uint32_t prev_shadow_result_core__total_periods_elapsed_sd1;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = prev_shadow_result_core__total_periods_elapsed_sd1
+*/
+ uint8_t prev_shadow_result_core__spare_0;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = prev_shadow_result_core__spare_0
+*/
+} VL53L1_prev_shadow_core_results_t;
+
+
+/**
+ * @struct VL53L1_patch_debug_t
+ *
+ * - registers = 2
+ * - first_index = 3872 (0x0F20)
+ * - last _index = 3873 (0x0F21)
+ * - i2c_size = 2
+ */
+
+typedef struct {
+ uint8_t result__debug_status;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = result_debug_status
+*/
+ uint8_t result__debug_stage;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = result_debug_stage
+*/
+} VL53L1_patch_debug_t;
+
+
+/**
+ * @struct VL53L1_gph_general_config_t
+ *
+ * - registers = 3
+ * - first_index = 3876 (0x0F24)
+ * - last _index = 3880 (0x0F28)
+ * - i2c_size = 5
+ */
+
+typedef struct {
+ uint16_t gph__system__thresh_rate_high;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = gph__system_thresh_rate_high (fixed point 9.7)
+*/
+ uint16_t gph__system__thresh_rate_low;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = gph__system_thresh_rate_low (fixed point 9.7)
+*/
+ uint8_t gph__system__interrupt_config_gpio;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [1:0] = gph__int_mode_distance
+ - [3:2] = gph__int_mode_rate
+ - [4] = gph__int_spare
+ - [5] = gph__int_new_measure_ready
+ - [6] = gph__int_no_target_en
+ - [7] = gph__int_combined_mode
+*/
+} VL53L1_gph_general_config_t;
+
+
+/**
+ * @struct VL53L1_gph_static_config_t
+ *
+ * - registers = 5
+ * - first_index = 3887 (0x0F2F)
+ * - last _index = 3892 (0x0F34)
+ * - i2c_size = 6
+ */
+
+typedef struct {
+ uint8_t gph__dss_config__roi_mode_control;
+/*!<
+ info: \n
+ - msb = 2
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [1:0] = gph__dss_config__input_mode
+ - [2] = gph__calculate_roi_enable
+*/
+ uint16_t gph__dss_config__manual_effective_spads_select;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = gph__dss_config__manual_effective_spads_select
+*/
+ uint8_t gph__dss_config__manual_block_select;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = gph__dss_config__manual_block_select
+*/
+ uint8_t gph__dss_config__max_spads_limit;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = gph__dss_config__max_spads_limit
+*/
+ uint8_t gph__dss_config__min_spads_limit;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = gph__dss_config__min_spads_limit
+*/
+} VL53L1_gph_static_config_t;
+
+
+/**
+ * @struct VL53L1_gph_timing_config_t
+ *
+ * - registers = 14
+ * - first_index = 3894 (0x0F36)
+ * - last _index = 3909 (0x0F45)
+ * - i2c_size = 16
+ */
+
+typedef struct {
+ uint8_t gph__mm_config__timeout_macrop_a_hi;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = gph_mm_config__config_timeout_macrop_a_hi
+*/
+ uint8_t gph__mm_config__timeout_macrop_a_lo;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = gph_mm_config__config_timeout_macrop_a_lo
+*/
+ uint8_t gph__mm_config__timeout_macrop_b_hi;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = gph_mm_config__config_timeout_macrop_b_hi
+*/
+ uint8_t gph__mm_config__timeout_macrop_b_lo;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = gph_mm_config__config_timeout_macrop_b_lo
+*/
+ uint8_t gph__range_config__timeout_macrop_a_hi;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = gph_range_timeout_overall_periods_macrop_a_hi
+*/
+ uint8_t gph__range_config__timeout_macrop_a_lo;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = gph_range_timeout_overall_periods_macrop_a_lo
+*/
+ uint8_t gph__range_config__vcsel_period_a;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [5:0] = gph_range_config__vcsel_period_a
+*/
+ uint8_t gph__range_config__vcsel_period_b;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [5:0] = gph_range_config__vcsel_period_b
+*/
+ uint8_t gph__range_config__timeout_macrop_b_hi;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = gph_range_timeout_overall_periods_macrop_b_hi
+*/
+ uint8_t gph__range_config__timeout_macrop_b_lo;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = gph_range_timeout_overall_periods_macrop_b_lo
+*/
+ uint16_t gph__range_config__sigma_thresh;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = gph_range_config__sigma_thresh (fixed point 14.2)
+*/
+ uint16_t gph__range_config__min_count_rate_rtn_limit_mcps;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = gph_range_config__min_count_rate_rtn_limit_mcps (fixed point 9.7)
+*/
+ uint8_t gph__range_config__valid_phase_low;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = gph_range_config__valid_phase_low (fixed point 5.3)
+*/
+ uint8_t gph__range_config__valid_phase_high;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = gph_range_config__valid_phase_high (fixed point 5.3)
+*/
+} VL53L1_gph_timing_config_t;
+
+
+/**
+ * @struct VL53L1_fw_internal_t
+ *
+ * - registers = 2
+ * - first_index = 3910 (0x0F46)
+ * - last _index = 3911 (0x0F47)
+ * - i2c_size = 2
+ */
+
+typedef struct {
+ uint8_t firmware__internal_stream_count_div;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = fw__internal_stream_count_div
+*/
+ uint8_t firmware__internal_stream_counter_val;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = fw__internal_stream_counter_val
+*/
+} VL53L1_fw_internal_t;
+
+
+/**
+ * @struct VL53L1_patch_results_t
+ *
+ * - registers = 60
+ * - first_index = 3924 (0x0F54)
+ * - last _index = 4012 (0x0FAC)
+ * - i2c_size = 90
+ */
+
+typedef struct {
+ uint8_t dss_calc__roi_ctrl;
+/*!<
+ info: \n
+ - msb = 1
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [0] = dss_calc__roi_intersect_enable
+ - [1] = dss_calc__roi_subtract_enable
+*/
+ uint8_t dss_calc__spare_1;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__spare_1
+*/
+ uint8_t dss_calc__spare_2;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__spare_2
+*/
+ uint8_t dss_calc__spare_3;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__spare_3
+*/
+ uint8_t dss_calc__spare_4;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__spare_4
+*/
+ uint8_t dss_calc__spare_5;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__spare_5
+*/
+ uint8_t dss_calc__spare_6;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__spare_6
+*/
+ uint8_t dss_calc__spare_7;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__spare_7
+*/
+ uint8_t dss_calc__user_roi_spad_en_0;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_0
+*/
+ uint8_t dss_calc__user_roi_spad_en_1;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_1
+*/
+ uint8_t dss_calc__user_roi_spad_en_2;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_2
+*/
+ uint8_t dss_calc__user_roi_spad_en_3;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_3
+*/
+ uint8_t dss_calc__user_roi_spad_en_4;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_4
+*/
+ uint8_t dss_calc__user_roi_spad_en_5;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_5
+*/
+ uint8_t dss_calc__user_roi_spad_en_6;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_6
+*/
+ uint8_t dss_calc__user_roi_spad_en_7;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_7
+*/
+ uint8_t dss_calc__user_roi_spad_en_8;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_8
+*/
+ uint8_t dss_calc__user_roi_spad_en_9;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_9
+*/
+ uint8_t dss_calc__user_roi_spad_en_10;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_10
+*/
+ uint8_t dss_calc__user_roi_spad_en_11;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_11
+*/
+ uint8_t dss_calc__user_roi_spad_en_12;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_12
+*/
+ uint8_t dss_calc__user_roi_spad_en_13;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_13
+*/
+ uint8_t dss_calc__user_roi_spad_en_14;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_14
+*/
+ uint8_t dss_calc__user_roi_spad_en_15;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_15
+*/
+ uint8_t dss_calc__user_roi_spad_en_16;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_16
+*/
+ uint8_t dss_calc__user_roi_spad_en_17;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_17
+*/
+ uint8_t dss_calc__user_roi_spad_en_18;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_18
+*/
+ uint8_t dss_calc__user_roi_spad_en_19;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_19
+*/
+ uint8_t dss_calc__user_roi_spad_en_20;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_20
+*/
+ uint8_t dss_calc__user_roi_spad_en_21;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_21
+*/
+ uint8_t dss_calc__user_roi_spad_en_22;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_22
+*/
+ uint8_t dss_calc__user_roi_spad_en_23;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_23
+*/
+ uint8_t dss_calc__user_roi_spad_en_24;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_24
+*/
+ uint8_t dss_calc__user_roi_spad_en_25;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_25
+*/
+ uint8_t dss_calc__user_roi_spad_en_26;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_26
+*/
+ uint8_t dss_calc__user_roi_spad_en_27;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_27
+*/
+ uint8_t dss_calc__user_roi_spad_en_28;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_28
+*/
+ uint8_t dss_calc__user_roi_spad_en_29;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_29
+*/
+ uint8_t dss_calc__user_roi_spad_en_30;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_30
+*/
+ uint8_t dss_calc__user_roi_spad_en_31;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_spad_en_31
+*/
+ uint8_t dss_calc__user_roi_0;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_0
+*/
+ uint8_t dss_calc__user_roi_1;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__user_roi_1
+*/
+ uint8_t dss_calc__mode_roi_0;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__mode_roi_0
+*/
+ uint8_t dss_calc__mode_roi_1;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_calc__mode_roi_1
+*/
+ uint8_t sigma_estimator_calc__spare_0;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = sigma_estimator_calc__spare_0
+*/
+ uint16_t vhv_result__peak_signal_rate_mcps;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = vhv_result__peak_signal_rate_mcps
+*/
+ uint32_t vhv_result__signal_total_events_ref;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = vhv_result__signal_total_events_ref
+*/
+ uint16_t phasecal_result__phase_output_ref;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = phasecal_result__normalised_phase_ref
+*/
+ uint16_t dss_result__total_rate_per_spad;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = dss_result__total_rate_per_spad
+*/
+ uint8_t dss_result__enabled_blocks;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = dss_result__enabled_blocks
+*/
+ uint16_t dss_result__num_requested_spads;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = dss_result__num_requested_spads (fixed point 8.8)
+*/
+ uint16_t mm_result__inner_intersection_rate;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = mm_result__inner_intersection_rate
+*/
+ uint16_t mm_result__outer_complement_rate;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = mm_result__outer_complement_rate
+*/
+ uint16_t mm_result__total_offset;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = mm_result__total_offset
+*/
+ uint32_t xtalk_calc__xtalk_for_enabled_spads;
+/*!<
+ info: \n
+ - msb = 23
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [23:0] = xtalk_calc__xtalk_for_enabled_spads (fixed point 11.13)
+*/
+ uint32_t xtalk_result__avg_xtalk_user_roi_kcps;
+/*!<
+ info: \n
+ - msb = 23
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [23:0] = xtalk_result__avg_xtalk_user_roi_kcps (fixed point 11.13)
+*/
+ uint32_t xtalk_result__avg_xtalk_mm_inner_roi_kcps;
+/*!<
+ info: \n
+ - msb = 23
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [23:0] = xtalk_result__avg_xtalk_mm_inner_roi_kcps (fixed point 11.13)
+*/
+ uint32_t xtalk_result__avg_xtalk_mm_outer_roi_kcps;
+/*!<
+ info: \n
+ - msb = 23
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [23:0] = xtalk_result__avg_xtalk_mm_outer_roi_kcps (fixed point 11.13)
+*/
+ uint32_t range_result__accum_phase;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = range_result__accum_phase
+*/
+ uint16_t range_result__offset_corrected_range;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = range_result__offset_corrected_range
+*/
+} VL53L1_patch_results_t;
+
+
+/**
+ * @struct VL53L1_shadow_system_results_t
+ *
+ * - registers = 28
+ * - first_index = 4014 (0x0FAE)
+ * - last _index = 4095 (0x0FFF)
+ * - i2c_size = 82
+ */
+
+typedef struct {
+ uint8_t shadow_phasecal_result__vcsel_start;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = shadow_phasecal_result__vcsel_start
+*/
+ uint8_t shadow_result__interrupt_status;
+/*!<
+ info: \n
+ - msb = 5
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [2:0] = shadow_int_status
+ - [4:3] = shadow_int_error_status
+ - [5] = shadow_gph_id_gpio_status
+*/
+ uint8_t shadow_result__range_status;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [4:0] = shadow_range_status
+ - [5] = shadow_max_threshold_hit
+ - [6] = shadow_min_threshold_hit
+ - [7] = shadow_gph_id_range_status
+*/
+ uint8_t shadow_result__report_status;
+/*!<
+ info: \n
+ - msb = 3
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = shadow_report_status
+*/
+ uint8_t shadow_result__stream_count;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = shadow_result__stream_count
+*/
+ uint16_t shadow_result__dss_actual_effective_spads_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__dss_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+ uint16_t shadow_result__peak_signal_count_rate_mcps_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__peak_signal_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+ uint16_t shadow_result__ambient_count_rate_mcps_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__ambient_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+ uint16_t shadow_result__sigma_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__sigma_sd0 (fixed point 14.2)
+*/
+ uint16_t shadow_result__phase_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__phase_sd0 (fixed point 5.11)
+*/
+ uint16_t shadow_result__final_crosstalk_corrected_range_mm_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__final_crosstalk_corrected_range_mm_sd0
+*/
+ uint16_t shadow_result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0 (fixed point 9.7)
+*/
+ uint16_t shadow_result__mm_inner_actual_effective_spads_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__mm_inner_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+ uint16_t shadow_result__mm_outer_actual_effective_spads_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__mm_outer_actual_effective_spads_sd0 (fixed point 8.8)
+*/
+ uint16_t shadow_result__avg_signal_count_rate_mcps_sd0;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__avg_signal_count_rate_mcps_sd0 (fixed point 9.7)
+*/
+ uint16_t shadow_result__dss_actual_effective_spads_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__dss_actual_effective_spads_sd1 (fixed point 8.8)
+*/
+ uint16_t shadow_result__peak_signal_count_rate_mcps_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__peak_signal_count_rate_mcps_sd1 (fixed point 9.7)
+*/
+ uint16_t shadow_result__ambient_count_rate_mcps_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__ambient_count_rate_mcps_sd1 (fixed point 9.7)
+*/
+ uint16_t shadow_result__sigma_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__sigma_sd1 (fixed point 14.2)
+*/
+ uint16_t shadow_result__phase_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__phase_sd1 (fixed point 5.11)
+*/
+ uint16_t shadow_result__final_crosstalk_corrected_range_mm_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__final_crosstalk_corrected_range_mm_sd1
+*/
+ uint16_t shadow_result__spare_0_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__spare_0_sd1
+*/
+ uint16_t shadow_result__spare_1_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__spare_1_sd1
+*/
+ uint16_t shadow_result__spare_2_sd1;
+/*!<
+ info: \n
+ - msb = 15
+ - lsb = 0
+ - i2c_size = 2
+
+ fields: \n
+ - [15:0] = shadow_result__spare_2_sd1
+*/
+ uint8_t shadow_result__spare_3_sd1;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = shadow_result__spare_3_sd1
+*/
+ uint8_t shadow_result__thresh_info;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [3:0] = shadow_result__distance_int_info
+ - [7:4] = shadow_result__rate_int_info
+*/
+ uint8_t shadow_phasecal_result__reference_phase_hi;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = shadow_phasecal_result__reference_phase_hi
+*/
+ uint8_t shadow_phasecal_result__reference_phase_lo;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = shadow_phasecal_result__reference_phase_lo
+*/
+} VL53L1_shadow_system_results_t;
+
+
+/**
+ * @struct VL53L1_shadow_core_results_t
+ *
+ * - registers = 9
+ * - first_index = 4060 (0x0FDC)
+ * - last _index = 4092 (0x0FFC)
+ * - i2c_size = 33
+ */
+
+typedef struct {
+ uint32_t shadow_result_core__ambient_window_events_sd0;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = shadow_result_core__ambient_window_events_sd0
+*/
+ uint32_t shadow_result_core__ranging_total_events_sd0;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = shadow_result_core__ranging_total_events_sd0
+*/
+ int32_t shadow_result_core__signal_total_events_sd0;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = shadow_result_core__signal_total_events_sd0
+*/
+ uint32_t shadow_result_core__total_periods_elapsed_sd0;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = shadow_result_core__total_periods_elapsed_sd0
+*/
+ uint32_t shadow_result_core__ambient_window_events_sd1;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = shadow_result_core__ambient_window_events_sd1
+*/
+ uint32_t shadow_result_core__ranging_total_events_sd1;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = shadow_result_core__ranging_total_events_sd1
+*/
+ int32_t shadow_result_core__signal_total_events_sd1;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = shadow_result_core__signal_total_events_sd1
+*/
+ uint32_t shadow_result_core__total_periods_elapsed_sd1;
+/*!<
+ info: \n
+ - msb = 31
+ - lsb = 0
+ - i2c_size = 4
+
+ fields: \n
+ - [31:0] = shadow_result_core__total_periods_elapsed_sd1
+*/
+ uint8_t shadow_result_core__spare_0;
+/*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7:0] = shadow_result_core__spare_0
+*/
+} VL53L1_shadow_core_results_t;
+
+
+#endif
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_silicon_core.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_silicon_core.h
new file mode 100644
index 0000000..f17e284
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_silicon_core.h
@@ -0,0 +1,100 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_silicon_core.h
+ *
+ * @brief EwokPlus25 low level silicon specific API function definitions
+ */
+
+#ifndef _VL53L1_SILICON_CORE_H_
+#define _VL53L1_SILICON_CORE_H_
+
+#include "vl53l1_platform.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @brief Checks if the firmware is ready for ranging (Silicon variant)
+ *
+ * @param[in] Dev : Device Handle
+ * @param[out] pready : pointer to data ready flag \n
+ * 0 = firmware not ready \n
+ * 1 = firmware ready
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_is_firmware_ready_silicon(
+ VL53L1_DEV Dev,
+ uint8_t *pready);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VL53L1_SILICON_CORE_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_tuning_parm_defaults.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_tuning_parm_defaults.h
new file mode 100644
index 0000000..0a6a1b7
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_tuning_parm_defaults.h
@@ -0,0 +1,210 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_tuning_parm_defaults.h
+ *
+ * @brief Define defaults for tuning parm list
+ *
+ * - Ensures coherence of internal defaults to tuning table
+ * - Allows reduction of tuning parm list to only changes from the
+ * standard settings defined below
+ *
+ */
+
+
+#ifndef _VL53L1_TUNING_PARM_DEFAULTS_H_
+#define _VL53L1_TUNING_PARM_DEFAULTS_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @defgroup VL53L1_tuningparmdefault_group VL53L1 Defines
+ * @brief VL53L1 Tuning Parm Default Values
+ * @{
+ */
+
+#define VL53L1_TUNINGPARM_VERSION_DEFAULT \
+((uint16_t) 32771)
+#define VL53L1_TUNINGPARM_KEY_TABLE_VERSION_DEFAULT \
+((uint16_t) 32769)
+#define VL53L1_TUNINGPARM_LLD_VERSION_DEFAULT \
+((uint16_t) 32833)
+#define VL53L1_TUNINGPARM_CONSISTENCY_LITE_PHASE_TOLERANCE_DEFAULT \
+((uint8_t) 2)
+#define VL53L1_TUNINGPARM_PHASECAL_TARGET_DEFAULT \
+((uint8_t) 33)
+#define VL53L1_TUNINGPARM_LITE_CAL_REPEAT_RATE_DEFAULT \
+((uint16_t) 0)
+#define VL53L1_TUNINGPARM_LITE_RANGING_GAIN_FACTOR_DEFAULT \
+((uint16_t) 2011)
+#define VL53L1_TUNINGPARM_LITE_MIN_CLIP_MM_DEFAULT \
+((uint8_t) 0)
+#define VL53L1_TUNINGPARM_LITE_LONG_SIGMA_THRESH_MM_DEFAULT \
+((uint16_t) 360)
+#define VL53L1_TUNINGPARM_LITE_MED_SIGMA_THRESH_MM_DEFAULT \
+((uint16_t) 360)
+#define VL53L1_TUNINGPARM_LITE_SHORT_SIGMA_THRESH_MM_DEFAULT \
+((uint16_t) 360)
+#define VL53L1_TUNINGPARM_LITE_LONG_MIN_COUNT_RATE_RTN_MCPS_DEFAULT \
+((uint16_t) 192)
+#define VL53L1_TUNINGPARM_LITE_MED_MIN_COUNT_RATE_RTN_MCPS_DEFAULT \
+((uint16_t) 192)
+#define VL53L1_TUNINGPARM_LITE_SHORT_MIN_COUNT_RATE_RTN_MCPS_DEFAULT \
+((uint16_t) 192)
+#define VL53L1_TUNINGPARM_LITE_SIGMA_EST_PULSE_WIDTH_DEFAULT \
+((uint8_t) 8)
+#define VL53L1_TUNINGPARM_LITE_SIGMA_EST_AMB_WIDTH_NS_DEFAULT \
+((uint8_t) 16)
+#define VL53L1_TUNINGPARM_LITE_SIGMA_REF_MM_DEFAULT \
+((uint8_t) 1)
+#define VL53L1_TUNINGPARM_LITE_RIT_MULT_DEFAULT \
+((uint8_t) 64)
+#define VL53L1_TUNINGPARM_LITE_SEED_CONFIG_DEFAULT \
+((uint8_t) 2)
+#define VL53L1_TUNINGPARM_LITE_QUANTIFIER_DEFAULT \
+((uint8_t) 2)
+#define VL53L1_TUNINGPARM_LITE_FIRST_ORDER_SELECT_DEFAULT \
+((uint8_t) 0)
+#define VL53L1_TUNINGPARM_LITE_XTALK_MARGIN_KCPS_DEFAULT \
+((int16_t) 0)
+#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_LONG_RANGE_DEFAULT \
+((uint8_t) 14)
+#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_MED_RANGE_DEFAULT \
+((uint8_t) 10)
+#define VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_SHORT_RANGE_DEFAULT \
+((uint8_t) 6)
+#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_LONG_RANGE_DEFAULT \
+((uint8_t) 14)
+#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_MED_RANGE_DEFAULT \
+((uint8_t) 10)
+#define VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_SHORT_RANGE_DEFAULT \
+((uint8_t) 6)
+#define VL53L1_TUNINGPARM_TIMED_SEED_CONFIG_DEFAULT \
+((uint8_t) 1)
+#define VL53L1_TUNINGPARM_VHV_LOOPBOUND_DEFAULT \
+((uint8_t) 32)
+#define VL53L1_TUNINGPARM_REFSPADCHAR_DEVICE_TEST_MODE_DEFAULT \
+((uint8_t) 8)
+#define VL53L1_TUNINGPARM_REFSPADCHAR_VCSEL_PERIOD_DEFAULT \
+((uint8_t) 11)
+#define VL53L1_TUNINGPARM_REFSPADCHAR_PHASECAL_TIMEOUT_US_DEFAULT \
+((uint32_t) 1000)
+#define VL53L1_TUNINGPARM_REFSPADCHAR_TARGET_COUNT_RATE_MCPS_DEFAULT \
+((uint16_t) 2560)
+#define VL53L1_TUNINGPARM_REFSPADCHAR_MIN_COUNTRATE_LIMIT_MCPS_DEFAULT \
+((uint16_t) 1280)
+#define VL53L1_TUNINGPARM_REFSPADCHAR_MAX_COUNTRATE_LIMIT_MCPS_DEFAULT \
+((uint16_t) 5120)
+#define VL53L1_TUNINGPARM_OFFSET_CAL_DSS_RATE_MCPS_DEFAULT \
+((uint16_t) 2560)
+#define VL53L1_TUNINGPARM_OFFSET_CAL_PHASECAL_TIMEOUT_US_DEFAULT \
+((uint32_t) 1000)
+#define VL53L1_TUNINGPARM_OFFSET_CAL_MM_TIMEOUT_US_DEFAULT \
+((uint32_t) 13000)
+#define VL53L1_TUNINGPARM_OFFSET_CAL_RANGE_TIMEOUT_US_DEFAULT \
+((uint32_t) 13000)
+#define VL53L1_TUNINGPARM_OFFSET_CAL_PRE_SAMPLES_DEFAULT \
+((uint8_t) 8)
+#define VL53L1_TUNINGPARM_OFFSET_CAL_MM1_SAMPLES_DEFAULT \
+((uint8_t) 40)
+#define VL53L1_TUNINGPARM_OFFSET_CAL_MM2_SAMPLES_DEFAULT \
+((uint8_t) 9)
+#define VL53L1_TUNINGPARM_SPADMAP_VCSEL_PERIOD_DEFAULT \
+((uint8_t) 18)
+#define VL53L1_TUNINGPARM_SPADMAP_VCSEL_START_DEFAULT \
+((uint8_t) 15)
+#define VL53L1_TUNINGPARM_SPADMAP_RATE_LIMIT_MCPS_DEFAULT \
+((uint16_t) 12)
+#define VL53L1_TUNINGPARM_LITE_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS_DEFAULT \
+((uint16_t) 2560)
+#define VL53L1_TUNINGPARM_TIMED_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS_DEFAULT \
+((uint16_t) 2560)
+#define VL53L1_TUNINGPARM_LITE_PHASECAL_CONFIG_TIMEOUT_US_DEFAULT \
+((uint32_t) 1000)
+#define VL53L1_TUNINGPARM_TIMED_PHASECAL_CONFIG_TIMEOUT_US_DEFAULT \
+((uint32_t) 1000)
+#define VL53L1_TUNINGPARM_LITE_MM_CONFIG_TIMEOUT_US_DEFAULT \
+((uint32_t) 2000)
+#define VL53L1_TUNINGPARM_TIMED_MM_CONFIG_TIMEOUT_US_DEFAULT \
+((uint32_t) 2000)
+#define VL53L1_TUNINGPARM_LITE_RANGE_CONFIG_TIMEOUT_US_DEFAULT \
+((uint32_t) 63000)
+#define VL53L1_TUNINGPARM_TIMED_RANGE_CONFIG_TIMEOUT_US_DEFAULT \
+((uint32_t) 13000)
+#define VL53L1_TUNINGPARM_LOWPOWERAUTO_VHV_LOOP_BOUND_DEFAULT \
+((uint8_t) 3)
+#define VL53L1_TUNINGPARM_LOWPOWERAUTO_MM_CONFIG_TIMEOUT_US_DEFAULT \
+((uint32_t) 1)
+#define VL53L1_TUNINGPARM_LOWPOWERAUTO_RANGE_CONFIG_TIMEOUT_US_DEFAULT \
+((uint32_t) 8000)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VL53L1_LL_DEF_H_ */
+
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_wait.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_wait.h
new file mode 100644
index 0000000..a303a6e
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/inc/vl53l1_wait.h
@@ -0,0 +1,276 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_wait.h
+ *
+ * @brief EwokPlus25 low level Driver wait function definitions
+ */
+
+#ifndef _VL53L1_WAIT_H_
+#define _VL53L1_WAIT_H_
+
+#include "vl53l1_platform.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @brief Wait for initial firmware boot to finish
+ *
+ * Calls VL53L1_poll_for_boot_completion()
+ *
+ * @param[in] Dev : Device handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_wait_for_boot_completion(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Waits for initial firmware ready
+ *
+ * Only waits to see if the firmware is ready in timed and
+ * single shot modes.
+ *
+ * Calls VL53L1_poll_for_firmware_ready()
+ *
+ * @param[in] Dev : Device handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_wait_for_firmware_ready(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Waits for the next ranging interrupt
+ *
+ * Calls VL53L1_poll_for_range_completion()
+ *
+ * @param[in] Dev : Device handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_wait_for_range_completion(
+ VL53L1_DEV Dev);
+
+
+/**
+ * @brief Waits for a device test mode to complete.
+
+ * Calls VL53L1_poll_for_test_completion()
+ *
+ * @param[in] Dev : Device Handle
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_wait_for_test_completion(
+ VL53L1_DEV Dev);
+
+
+
+
+/**
+ * @brief Reads FIRMWARE__SYSTEM_STATUS register to detect if the
+ * firmware was finished booting
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] pready : pointer to data ready flag \n
+ * 0 = boot not complete \n
+ * 1 = boot complete
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_is_boot_complete(
+ VL53L1_DEV Dev,
+ uint8_t *pready);
+
+/**
+ * @brief Reads FIRMWARE__SYSTEM_STATUS register to detect if the
+ * firmware is ready for ranging.
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] pready : pointer to data ready flag \n
+ * 0 = firmware not ready \n
+ * 1 = firmware ready
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_is_firmware_ready(
+ VL53L1_DEV Dev,
+ uint8_t *pready);
+
+
+/**
+ * @brief Reads bit 0 of VL53L1_GPIO__TIO_HV_STATUS register to determine
+ * if new range data is ready (available).
+ *
+ * Interrupt may be either active high or active low. The behaviour of bit 0
+ * of the VL53L1_GPIO__TIO_HV_STATUS register is the same as the interrupt
+ * signal generated on the GPIO pin.
+ *
+ * pdev->stat_cfg.gpio_hv_mux_ctrl bit 4 is used to select required check level
+ *
+ *
+ * @param[in] Dev : Device handle
+ * @param[out] pready : pointer to data ready flag \n
+ * 0 = data not ready \n
+ * 1 = new range data available
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_is_new_data_ready(
+ VL53L1_DEV Dev,
+ uint8_t *pready);
+
+
+
+
+/**
+ * @brief Waits (polls) for initial firmware boot to finish
+ *
+ * After power on or a device reset via XSHUTDOWN EwokPlus25 firmware takes
+ * about 2ms to boot. During this boot sequence elected NVM data is copied
+ * to the device's Host & MCU G02 registers
+ *
+ * This function polls the FIRMWARE__SYSTEM_STATUS register to detect when
+ * firmware is ready.
+ *
+ * Polling is implemented using VL53L1_WaitValueMaskEx()
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] timeout_ms : Wait timeout in [ms]
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_poll_for_boot_completion(
+ VL53L1_DEV Dev,
+ uint32_t timeout_ms);
+
+
+/**
+ * @brief Waits (polls) for initial firmware ready
+ *
+ * Polling is implemented using VL53L1_WaitValueMaskEx()
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] timeout_ms : Wait timeout in [ms]
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_poll_for_firmware_ready(
+ VL53L1_DEV Dev,
+ uint32_t timeout_ms);
+
+
+/**
+ * @brief Polls bit 0 of VL53L1_GPIO__TIO_HV_STATUS register to determine
+ * the state of the GPIO (Interrupt) pin.
+ *
+ * Interrupt may be either active high or active low. The behaviour of bit 0
+ * of the VL53L1_GPIO__TIO_HV_STATUS register is the same as the interrupt
+ * signal generated on the GPIO pin.
+ *
+ * pdev->stat_cfg.gpio_hv_mux_ctrl bit 4 is used to select required check level
+ *
+ * Polling is implemented using VL53L1_WaitValueMaskEx()
+ *
+ * @param[in] Dev : Device handle
+ * @param[in] timeout_ms : Wait timeout in [ms]
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_poll_for_range_completion(
+ VL53L1_DEV Dev,
+ uint32_t timeout_ms);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VL53L1_WAIT_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api.c b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api.c
new file mode 100644
index 0000000..2a27fee
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api.c
@@ -0,0 +1,2909 @@
+
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+#include "vl53l1_api.h"
+#include "vl53l1_api_strings.h"
+#include "vl53l1_register_settings.h"
+#include "vl53l1_register_funcs.h"
+#include "vl53l1_core.h"
+#include "vl53l1_api_calibration.h"
+#include "vl53l1_wait.h"
+#include "vl53l1_preset_setup.h"
+#include "vl53l1_api_debug.h"
+#include "vl53l1_api_core.h"
+
+/* Check for minimum user zone requested by Xtalk calibration */
+/* no need for VL53L1_MAX_USER_ZONES check, set 5 to pass the test */
+#define ZONE_CHECK 5
+
+#if ZONE_CHECK < 5
+#error Must define at least 5 zones in MAX_USER_ZONES constant
+#endif
+
+
+#ifdef VL53L1_NOCALIB
+#define OFFSET_CALIB_EMPTY
+#endif
+
+#ifndef VL53L1_NOCALIB
+#define OFFSET_CALIB
+#endif
+
+#define LOG_FUNCTION_START(fmt, ...) \
+ _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
+#define LOG_FUNCTION_END(status, ...) \
+ _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_API, status, ##__VA_ARGS__)
+#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
+ _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_API, status, \
+ fmt, ##__VA_ARGS__)
+
+#ifdef VL53L1_LOG_ENABLE
+#define trace_print(level, ...) trace_print_module_function(\
+ VL53L1_TRACE_MODULE_API, level, VL53L1_TRACE_FUNCTION_NONE, \
+ ##__VA_ARGS__)
+#endif
+
+#ifndef MIN
+#define MIN(v1, v2) ((v1) < (v2) ? (v1) : (v2))
+#endif
+#ifndef MAX
+#define MAX(v1, v2) ((v1) < (v2) ? (v2) : (v1))
+#endif
+
+#define DMAX_REFLECTANCE_IDX 2
+/* Use Dmax index 2 because it's the 50% reflectance case by default */
+
+/* Following LOWPOWER_AUTO figures have been measured observing vcsel
+ * emissions on an actual device
+ */
+#define LOWPOWER_AUTO_VHV_LOOP_DURATION_US 245
+#define LOWPOWER_AUTO_OVERHEAD_BEFORE_A_RANGING 1448
+#define LOWPOWER_AUTO_OVERHEAD_BETWEEN_A_B_RANGING 2100
+
+#define FDA_MAX_TIMING_BUDGET_US 550000
+/* Maximum timing budget allowed codex #456189*/
+
+
+/* local static utilities functions */
+
+/* Bare Driver Tuning parameter table indexed with VL53L1_Tuning_t */
+static int32_t BDTable[VL53L1_TUNING_MAX_TUNABLE_KEY] = {
+ TUNING_VERSION,
+ TUNING_PROXY_MIN,
+ TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM,
+ TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER,
+ TUNING_MIN_AMBIENT_DMAX_VALID,
+ TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER,
+ TUNING_XTALK_FULL_ROI_TARGET_DISTANCE_MM,
+ TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT
+};
+
+
+#define VL53L1_NVM_POWER_UP_DELAY_US 50
+#define VL53L1_NVM_READ_TRIGGER_DELAY_US 5
+
+static VL53L1_Error VL53L1_nvm_enable(
+ VL53L1_DEV Dev,
+ uint16_t nvm_ctrl_pulse_width,
+ int32_t nvm_power_up_delay_us)
+{
+ /*
+ * Sequence below enables NVM for reading
+ *
+ * - Enable power force
+ * - Disable firmware
+ * - Power up NVM
+ * - Wait for 50us while the NVM powers up
+ * - Configure for reading and set the pulse width (16-bit)
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+
+ /* Disable Firmware */
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_disable_firmware(Dev);
+
+
+ /* Enable Power Force */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_powerforce(Dev);
+
+ /* Wait the required time for the regulators, bandgap,
+ * oscillator to wake up and settle
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WaitUs(
+ Dev,
+ VL53L1_ENABLE_POWERFORCE_SETTLING_TIME_US);
+
+ /* Power up NVM */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WrByte(
+ Dev,
+ VL53L1_RANGING_CORE__NVM_CTRL__PDN,
+ 0x01);
+
+ /* Enable NVM Clock */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WrByte(
+ Dev,
+ VL53L1_RANGING_CORE__CLK_CTRL1,
+ 0x05);
+
+ /* Wait the required time for NVM to power up*/
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WaitUs(
+ Dev,
+ nvm_power_up_delay_us);
+
+ /* Select read mode and set control pulse width */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WrByte(
+ Dev,
+ VL53L1_RANGING_CORE__NVM_CTRL__MODE,
+ 0x01);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WrWord(
+ Dev,
+ VL53L1_RANGING_CORE__NVM_CTRL__PULSE_WIDTH_MSB,
+ nvm_ctrl_pulse_width);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+
+}
+
+
+static VL53L1_Error VL53L1_nvm_read(
+ VL53L1_DEV Dev,
+ uint8_t start_address,
+ uint8_t count,
+ uint8_t *pdata)
+{
+ /*
+ * Sequence per 32-bit NVM read access:
+ *
+ * - Set up the 5-bit (0-127) NVM Address
+ * - Trigger the read of the NVM data by toggling NVM_CTRL__READN
+ * - Read the NVM data - 4 bytes wide read/write interface
+ * - Increment data byte pointer by 4 ready for the next loop
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t nvm_addr = 0;
+
+ LOG_FUNCTION_START("");
+
+ for (nvm_addr = start_address; nvm_addr < (start_address+count) ; nvm_addr++) {
+
+ /* Step 1 : set address */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WrByte(
+ Dev,
+ VL53L1_RANGING_CORE__NVM_CTRL__ADDR,
+ nvm_addr);
+
+ /* Step 2 : trigger reading of data */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WrByte(
+ Dev,
+ VL53L1_RANGING_CORE__NVM_CTRL__READN,
+ 0x00);
+
+ /* Step 3 : wait the required time */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WaitUs(
+ Dev,
+ VL53L1_NVM_READ_TRIGGER_DELAY_US);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WrByte(
+ Dev,
+ VL53L1_RANGING_CORE__NVM_CTRL__READN,
+ 0x01);
+
+ /* Step 3 : read 4-byte wide data register */
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_RANGING_CORE__NVM_CTRL__DATAOUT_MMM,
+ pdata,
+ 4);
+
+ /* Step 4 : increment byte buffer pointer */
+
+ pdata = pdata + 4;
+
+
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+static VL53L1_Error VL53L1_nvm_disable(
+ VL53L1_DEV Dev)
+{
+ /*
+ * Power down NVM (OTP) to extend lifetime
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_WrByte(
+ Dev,
+ VL53L1_RANGING_CORE__NVM_CTRL__READN,
+ 0x01);
+
+ /* Power down NVM */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WrByte(
+ Dev,
+ VL53L1_RANGING_CORE__NVM_CTRL__PDN,
+ 0x00);
+
+ /* Keep power force enabled */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_disable_powerforce(Dev);
+
+ /* (Re)Enable Firmware */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+
+}
+
+static VL53L1_Error VL53L1_read_nvm_raw_data(
+ VL53L1_DEV Dev,
+ uint8_t start_address,
+ uint8_t count,
+ uint8_t *pnvm_raw_data)
+{
+
+ /*
+ * Reads ALL 512 bytes of NVM data
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /*
+ * Enable NVM and set control pulse width
+ */
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_nvm_enable(
+ Dev,
+ 0x0004,
+ VL53L1_NVM_POWER_UP_DELAY_US);
+
+ /*
+ * Read the raw NVM data
+ * - currently all of 128 * 4 bytes = 512 bytes are read
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_nvm_read(
+ Dev,
+ start_address,
+ count,
+ pnvm_raw_data);
+
+ /*
+ * Disable NVM
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_nvm_disable(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+
+}
+
+static VL53L1_Error SingleTargetXTalkCalibration(VL53L1_DEV Dev)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ uint32_t sum_ranging = 0;
+ uint32_t sum_spads = 0;
+ FixPoint1616_t sum_signalRate = 0;
+ FixPoint1616_t total_count = 0;
+ uint8_t xtalk_meas = 0;
+ uint8_t xtalk_measmax =
+ BDTable[VL53L1_TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER];
+ VL53L1_RangingMeasurementData_t RMData;
+ FixPoint1616_t xTalkStoredMeanSignalRate;
+ FixPoint1616_t xTalkStoredMeanRange;
+ FixPoint1616_t xTalkStoredMeanRtnSpads;
+ uint32_t xTalkStoredMeanRtnSpadsAsInt;
+ uint32_t xTalkCalDistanceAsInt;
+ FixPoint1616_t XTalkCompensationRateMegaCps;
+ uint32_t signalXTalkTotalPerSpad;
+ VL53L1_PresetModes PresetMode;
+ VL53L1_CalibrationData_t CalibrationData;
+ VL53L1_CustomerNvmManaged_t *pC;
+
+
+ LOG_FUNCTION_START("");
+
+ /* check if the following are selected
+ * VL53L1_PRESETMODE_AUTONOMOUS,
+ * VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS
+ * VL53L1_PRESETMODE_LITE_RANGING
+ */
+ PresetMode = VL53L1DevDataGet(Dev, CurrentParameters.PresetMode);
+
+ if ((PresetMode != VL53L1_PRESETMODE_AUTONOMOUS) &&
+ (PresetMode != VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS) &&
+ (PresetMode != VL53L1_PRESETMODE_LITE_RANGING)) {
+ Status = VL53L1_ERROR_MODE_NOT_SUPPORTED;
+ goto ENDFUNC;
+ }
+
+ /* disable crosstalk calibration */
+ Status = VL53L1_disable_xtalk_compensation(Dev);
+ CHECK_ERROR_GO_ENDFUNC;
+
+ Status = VL53L1_StartMeasurement(Dev);
+ CHECK_ERROR_GO_ENDFUNC;
+
+ sum_ranging = 0;
+ sum_spads = 0;
+ sum_signalRate = 0;
+ total_count = 0;
+ for (xtalk_meas = 0; xtalk_meas < xtalk_measmax; xtalk_meas++) {
+ VL53L1_WaitMeasurementDataReady(Dev);
+ VL53L1_GetRangingMeasurementData(Dev, &RMData);
+ VL53L1_ClearInterruptAndStartMeasurement(Dev);
+ if (RMData.RangeStatus == VL53L1_RANGESTATUS_RANGE_VALID) {
+ sum_ranging += RMData.RangeMilliMeter;
+ sum_signalRate += RMData.SignalRateRtnMegaCps;
+ sum_spads += RMData.EffectiveSpadRtnCount / 256;
+ total_count++;
+ }
+ }
+ Status = VL53L1_StopMeasurement(Dev);
+
+ if (total_count > 0) {
+ /* FixPoint1616_t / uint16_t = FixPoint1616_t */
+ xTalkStoredMeanSignalRate = sum_signalRate / total_count;
+ xTalkStoredMeanRange = (FixPoint1616_t)(sum_ranging << 16);
+ xTalkStoredMeanRange /= total_count;
+ xTalkStoredMeanRtnSpads = (FixPoint1616_t)(sum_spads << 16);
+ xTalkStoredMeanRtnSpads /= total_count;
+
+ /* Round Mean Spads to Whole Number.
+ * Typically the calculated mean SPAD count is a whole number
+ * or very close to a whole
+ * number, therefore any truncation will not result in a
+ * significant loss in accuracy.
+ * Also, for a grey target at a typical distance of around
+ * 400mm, around 220 SPADs will
+ * be enabled, therefore, any truncation will result in a loss
+ * of accuracy of less than
+ * 0.5%.
+ */
+ xTalkStoredMeanRtnSpadsAsInt = (xTalkStoredMeanRtnSpads +
+ 0x8000) >> 16;
+
+ /* Round Cal Distance to Whole Number.
+ * Note that the cal distance is in mm, therefore no resolution
+ * is lost.
+ */
+ xTalkCalDistanceAsInt = ((uint32_t)BDTable[
+ VL53L1_TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM]);
+ if (xTalkStoredMeanRtnSpadsAsInt == 0 ||
+ xTalkCalDistanceAsInt == 0 ||
+ xTalkStoredMeanRange >= (xTalkCalDistanceAsInt << 16)) {
+ XTalkCompensationRateMegaCps = 0;
+ } else {
+ /* Apply division by mean spad count early in the
+ * calculation to keep the numbers small.
+ * This ensures we can maintain a 32bit calculation.
+ * Fixed1616 / int := Fixed1616
+ */
+ signalXTalkTotalPerSpad = (xTalkStoredMeanSignalRate) /
+ xTalkStoredMeanRtnSpadsAsInt;
+
+ /* Complete the calculation for total Signal XTalk per
+ * SPAD
+ * Fixed1616 * (Fixed1616 - Fixed1616/int) :=
+ * (2^16 * Fixed1616)
+ */
+ signalXTalkTotalPerSpad *= (((uint32_t)1 << 16) -
+ (xTalkStoredMeanRange / xTalkCalDistanceAsInt));
+
+ /* Round from 2^16 * Fixed1616, to Fixed1616. */
+ XTalkCompensationRateMegaCps = (signalXTalkTotalPerSpad
+ + 0x8000) >> 16;
+ }
+
+
+ Status = VL53L1_GetCalibrationData(Dev, &CalibrationData);
+ CHECK_ERROR_GO_ENDFUNC;
+
+ pC = &CalibrationData.customer;
+
+ pC->algo__crosstalk_compensation_plane_offset_kcps =
+ (uint32_t)(1000 * ((XTalkCompensationRateMegaCps +
+ ((uint32_t)1<<6)) >> (16-9)));
+
+ Status = VL53L1_SetCalibrationData(Dev, &CalibrationData);
+ CHECK_ERROR_GO_ENDFUNC;
+
+ Status = VL53L1_enable_xtalk_compensation(Dev);
+
+ } else
+ /* return error because no valid data found */
+ Status = VL53L1_ERROR_XTALK_EXTRACTION_NO_SAMPLE_FAIL;
+
+ENDFUNC:
+ LOG_FUNCTION_END(Status);
+ return Status;
+
+}
+
+/* Check Rectangle in user's coordinate system:
+ * 15 TL(x,y) o-----*
+ * ^ | |
+ * | *-----o BR(x,y)
+ * 0------------------------- >15
+ * check Rectangle definition conforms to the (0,15,15) coordinate system
+ * with a minimum of 4x4 size
+ */
+static VL53L1_Error CheckValidRectRoi(VL53L1_UserRoi_t ROI)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Negative check are not necessary because value is unsigned */
+ if ((ROI.TopLeftX > 15) || (ROI.TopLeftY > 15) ||
+ (ROI.BotRightX > 15) || (ROI.BotRightY > 15))
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+
+ if ((ROI.TopLeftX > ROI.BotRightX) || (ROI.TopLeftY < ROI.BotRightY))
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+static VL53L1_GPIO_Interrupt_Mode ConvertModeToLLD(VL53L1_Error *pStatus,
+ VL53L1_ThresholdMode CrossMode)
+{
+ VL53L1_GPIO_Interrupt_Mode Mode;
+
+ switch (CrossMode) {
+ case VL53L1_THRESHOLD_CROSSED_LOW:
+ Mode = VL53L1_GPIOINTMODE_LEVEL_LOW;
+ break;
+ case VL53L1_THRESHOLD_CROSSED_HIGH:
+ Mode = VL53L1_GPIOINTMODE_LEVEL_HIGH;
+ break;
+ case VL53L1_THRESHOLD_OUT_OF_WINDOW:
+ Mode = VL53L1_GPIOINTMODE_OUT_OF_WINDOW;
+ break;
+ case VL53L1_THRESHOLD_IN_WINDOW:
+ Mode = VL53L1_GPIOINTMODE_IN_WINDOW;
+ break;
+ default:
+ /* define Mode to avoid warning but actual value doesn't mind */
+ Mode = VL53L1_GPIOINTMODE_LEVEL_HIGH;
+ *pStatus = VL53L1_ERROR_INVALID_PARAMS;
+ }
+ return Mode;
+}
+
+static VL53L1_ThresholdMode ConvertModeFromLLD(VL53L1_Error *pStatus,
+ VL53L1_GPIO_Interrupt_Mode CrossMode)
+{
+ VL53L1_ThresholdMode Mode;
+
+ switch (CrossMode) {
+ case VL53L1_GPIOINTMODE_LEVEL_LOW:
+ Mode = VL53L1_THRESHOLD_CROSSED_LOW;
+ break;
+ case VL53L1_GPIOINTMODE_LEVEL_HIGH:
+ Mode = VL53L1_THRESHOLD_CROSSED_HIGH;
+ break;
+ case VL53L1_GPIOINTMODE_OUT_OF_WINDOW:
+ Mode = VL53L1_THRESHOLD_OUT_OF_WINDOW;
+ break;
+ case VL53L1_GPIOINTMODE_IN_WINDOW:
+ Mode = VL53L1_THRESHOLD_IN_WINDOW;
+ break;
+ default:
+ /* define Mode to avoid warning but actual value doesn't mind */
+ Mode = VL53L1_THRESHOLD_CROSSED_HIGH;
+ *pStatus = VL53L1_ERROR_UNDEFINED;
+ }
+ return Mode;
+}
+
+/* Group PAL General Functions */
+
+VL53L1_Error VL53L1_GetVersion(VL53L1_Version_t *pVersion)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ pVersion->major = VL53L1_IMPLEMENTATION_VER_MAJOR;
+ pVersion->minor = VL53L1_IMPLEMENTATION_VER_MINOR;
+ pVersion->build = VL53L1_IMPLEMENTATION_VER_SUB;
+
+ pVersion->revision = VL53L1_IMPLEMENTATION_VER_REVISION;
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_GetProductRevision(VL53L1_DEV Dev,
+ uint8_t *pProductRevisionMajor, uint8_t *pProductRevisionMinor)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint8_t revision_id;
+ VL53L1_LLDriverData_t *pLLData;
+
+ LOG_FUNCTION_START("");
+
+ pLLData = VL53L1DevStructGetLLDriverHandle(Dev);
+ revision_id = pLLData->nvm_copy_data.identification__revision_id;
+ *pProductRevisionMajor = 1;
+ *pProductRevisionMinor = (revision_id & 0xF0) >> 4;
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+
+}
+
+VL53L1_Error VL53L1_GetDeviceInfo(VL53L1_DEV Dev,
+ VL53L1_DeviceInfo_t *pVL53L1_DeviceInfo)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint8_t revision_id;
+ VL53L1_LLDriverData_t *pLLData;
+
+ LOG_FUNCTION_START("");
+
+ pLLData = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ strncpy(pVL53L1_DeviceInfo->ProductId, "",
+ VL53L1_DEVINFO_STRLEN-1);
+ pVL53L1_DeviceInfo->ProductType =
+ pLLData->nvm_copy_data.identification__module_type;
+
+ revision_id = pLLData->nvm_copy_data.identification__revision_id;
+ pVL53L1_DeviceInfo->ProductRevisionMajor = 1;
+ pVL53L1_DeviceInfo->ProductRevisionMinor = (revision_id & 0xF0) >> 4;
+
+#ifndef VL53L1_USE_EMPTY_STRING
+ if (pVL53L1_DeviceInfo->ProductRevisionMinor == 0)
+ strncpy(pVL53L1_DeviceInfo->Name,
+ VL53L1_STRING_DEVICE_INFO_NAME0,
+ VL53L1_DEVINFO_STRLEN-1);
+ else
+ strncpy(pVL53L1_DeviceInfo->Name,
+ VL53L1_STRING_DEVICE_INFO_NAME1,
+ VL53L1_DEVINFO_STRLEN-1);
+ strncpy(pVL53L1_DeviceInfo->Type,
+ VL53L1_STRING_DEVICE_INFO_TYPE,
+ VL53L1_DEVINFO_STRLEN-1);
+#else
+ pVL53L1_DeviceInfo->Name[0] = 0;
+ pVL53L1_DeviceInfo->Type[0] = 0;
+#endif
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+VL53L1_Error VL53L1_GetRangeStatusString(uint8_t RangeStatus,
+ char *pRangeStatusString)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ Status = VL53L1_get_range_status_string(RangeStatus,
+ pRangeStatusString);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_GetPalErrorString(VL53L1_Error PalErrorCode,
+ char *pPalErrorString)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ Status = VL53L1_get_pal_error_string(PalErrorCode, pPalErrorString);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_GetPalStateString(VL53L1_State PalStateCode,
+ char *pPalStateString)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ Status = VL53L1_get_pal_state_string(PalStateCode, pPalStateString);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_GetPalState(VL53L1_DEV Dev, VL53L1_State *pPalState)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ *pPalState = VL53L1DevDataGet(Dev, PalState);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+/* End Group PAL General Functions */
+
+/* Group PAL Init Functions */
+VL53L1_Error VL53L1_SetDeviceAddress(VL53L1_DEV Dev, uint8_t DeviceAddress)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ Status = VL53L1_WrByte(Dev, VL53L1_I2C_SLAVE__DEVICE_ADDRESS,
+ DeviceAddress / 2);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_DataInit(VL53L1_DEV Dev)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint8_t i;
+
+ LOG_FUNCTION_START("");
+
+ /* 2V8 power mode selection codex 447463 */
+#ifdef USE_I2C_2V8
+ Status = VL53L1_RdByte(Dev, VL53L1_PAD_I2C_HV__EXTSUP_CONFIG, &i);
+ if (Status == VL53L1_ERROR_NONE) {
+ i = (i & 0xfe) | 0x01;
+ Status = VL53L1_WrByte(Dev, VL53L1_PAD_I2C_HV__EXTSUP_CONFIG,
+ i);
+ }
+#endif
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_data_init(Dev, 1);
+
+ if (Status == VL53L1_ERROR_NONE) {
+ VL53L1DevDataSet(Dev, PalState, VL53L1_STATE_WAIT_STATICINIT);
+ VL53L1DevDataSet(Dev, CurrentParameters.PresetMode,
+ VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS);
+ }
+
+ /* Enable all check */
+ for (i = 0; i < VL53L1_CHECKENABLE_NUMBER_OF_CHECKS; i++) {
+ if (Status == VL53L1_ERROR_NONE)
+ Status |= VL53L1_SetLimitCheckEnable(Dev, i, 1);
+ else
+ break;
+
+ }
+
+ /* Limit default values */
+ if (Status == VL53L1_ERROR_NONE) {
+ Status = VL53L1_SetLimitCheckValue(Dev,
+ VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE,
+ (FixPoint1616_t)(18 * 65536));
+ }
+ if (Status == VL53L1_ERROR_NONE) {
+ Status = VL53L1_SetLimitCheckValue(Dev,
+ VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE,
+ (FixPoint1616_t)(25 * 65536 / 100));
+ /* 0.25 * 65536 */
+ }
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+VL53L1_Error VL53L1_StaticInit(VL53L1_DEV Dev)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint8_t measurement_mode;
+
+ LOG_FUNCTION_START("");
+
+ VL53L1DevDataSet(Dev, PalState, VL53L1_STATE_IDLE);
+
+ measurement_mode = VL53L1_DEVICEMEASUREMENTMODE_BACKTOBACK;
+ VL53L1DevDataSet(Dev, LLData.measurement_mode, measurement_mode);
+
+ VL53L1DevDataSet(Dev, CurrentParameters.NewDistanceMode,
+ VL53L1_DISTANCEMODE_LONG);
+
+ VL53L1DevDataSet(Dev, CurrentParameters.InternalDistanceMode,
+ VL53L1_DISTANCEMODE_LONG);
+
+ VL53L1DevDataSet(Dev, CurrentParameters.DistanceMode,
+ VL53L1_DISTANCEMODE_LONG);
+
+ /* ticket 472728 fix */
+ Status = VL53L1_SetPresetMode(Dev,
+ VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS);
+ /* end of ticket 472728 fix */
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_WaitDeviceBooted(VL53L1_DEV Dev)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ Status = VL53L1_poll_for_boot_completion(Dev,
+ VL53L1_BOOT_COMPLETION_POLLING_TIMEOUT_MS);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+/* End Group PAL Init Functions */
+
+/* Group PAL Parameters Functions */
+static VL53L1_Error ComputeDevicePresetMode(
+ VL53L1_PresetModes PresetMode,
+ VL53L1_DistanceModes DistanceMode,
+ VL53L1_DevicePresetModes *pDevicePresetMode)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ uint8_t DistIdx;
+ VL53L1_DevicePresetModes LightModes[3] = {
+ VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_SHORT_RANGE,
+ VL53L1_DEVICEPRESETMODE_STANDARD_RANGING,
+ VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_LONG_RANGE};
+
+
+ VL53L1_DevicePresetModes TimedModes[3] = {
+ VL53L1_DEVICEPRESETMODE_TIMED_RANGING_SHORT_RANGE,
+ VL53L1_DEVICEPRESETMODE_TIMED_RANGING,
+ VL53L1_DEVICEPRESETMODE_TIMED_RANGING_LONG_RANGE};
+
+ VL53L1_DevicePresetModes LowPowerTimedModes[3] = {
+ VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_SHORT_RANGE,
+ VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_MEDIUM_RANGE,
+ VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_LONG_RANGE};
+
+ *pDevicePresetMode = VL53L1_DEVICEPRESETMODE_STANDARD_RANGING;
+
+ switch (DistanceMode) {
+ case VL53L1_DISTANCEMODE_SHORT:
+ DistIdx = 0;
+ break;
+ case VL53L1_DISTANCEMODE_MEDIUM:
+ DistIdx = 1;
+ break;
+ default:
+ DistIdx = 2;
+ }
+
+ switch (PresetMode) {
+ case VL53L1_PRESETMODE_LITE_RANGING:
+ *pDevicePresetMode = LightModes[DistIdx];
+ break;
+
+
+ case VL53L1_PRESETMODE_AUTONOMOUS:
+ *pDevicePresetMode = TimedModes[DistIdx];
+ break;
+
+ case VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS:
+ *pDevicePresetMode = LowPowerTimedModes[DistIdx];
+ break;
+
+ default:
+ /* Unsupported mode */
+ Status = VL53L1_ERROR_MODE_NOT_SUPPORTED;
+ }
+
+ return Status;
+}
+
+static VL53L1_Error SetPresetMode(VL53L1_DEV Dev,
+ VL53L1_PresetModes PresetMode,
+ VL53L1_DistanceModes DistanceMode,
+ uint32_t inter_measurement_period_ms)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ VL53L1_DevicePresetModes device_preset_mode;
+ uint8_t measurement_mode;
+ uint16_t dss_config__target_total_rate_mcps;
+ uint32_t phasecal_config_timeout_us;
+ uint32_t mm_config_timeout_us;
+ uint32_t lld_range_config_timeout_us;
+
+ LOG_FUNCTION_START("%d", (int)PresetMode);
+
+ if ((PresetMode == VL53L1_PRESETMODE_AUTONOMOUS) ||
+ (PresetMode == VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS))
+ measurement_mode = VL53L1_DEVICEMEASUREMENTMODE_TIMED;
+ else
+ measurement_mode = VL53L1_DEVICEMEASUREMENTMODE_BACKTOBACK;
+
+
+ Status = ComputeDevicePresetMode(PresetMode, DistanceMode,
+ &device_preset_mode);
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_get_preset_mode_timing_cfg(Dev,
+ device_preset_mode,
+ &dss_config__target_total_rate_mcps,
+ &phasecal_config_timeout_us,
+ &mm_config_timeout_us,
+ &lld_range_config_timeout_us);
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_set_preset_mode(
+ Dev,
+ device_preset_mode,
+ dss_config__target_total_rate_mcps,
+ phasecal_config_timeout_us,
+ mm_config_timeout_us,
+ lld_range_config_timeout_us,
+ inter_measurement_period_ms);
+
+ if (Status == VL53L1_ERROR_NONE)
+ VL53L1DevDataSet(Dev, LLData.measurement_mode, measurement_mode);
+
+ if (Status == VL53L1_ERROR_NONE)
+ VL53L1DevDataSet(Dev, CurrentParameters.PresetMode, PresetMode);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_SetPresetMode(VL53L1_DEV Dev, VL53L1_PresetModes PresetMode)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ VL53L1_DistanceModes DistanceMode = VL53L1_DISTANCEMODE_LONG;
+
+ LOG_FUNCTION_START("%d", (int)PresetMode);
+
+ Status = SetPresetMode(Dev,
+ PresetMode,
+ DistanceMode,
+ 1000);
+
+ if (Status == VL53L1_ERROR_NONE) {
+ VL53L1DevDataSet(Dev, CurrentParameters.InternalDistanceMode,
+ DistanceMode);
+
+ VL53L1DevDataSet(Dev, CurrentParameters.NewDistanceMode,
+ DistanceMode);
+
+ if ((PresetMode == VL53L1_PRESETMODE_LITE_RANGING) ||
+ (PresetMode == VL53L1_PRESETMODE_AUTONOMOUS) ||
+ (PresetMode == VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS))
+ Status = VL53L1_SetMeasurementTimingBudgetMicroSeconds(
+ Dev, 41000);
+ else
+ /* Set default timing budget to 30Hz (33.33 ms)*/
+ Status = VL53L1_SetMeasurementTimingBudgetMicroSeconds(
+ Dev, 33333);
+ }
+
+ if (Status == VL53L1_ERROR_NONE) {
+ /* Set default intermeasurement period to 1000 ms */
+ Status = VL53L1_SetInterMeasurementPeriodMilliSeconds(Dev,
+ 1000);
+ }
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+VL53L1_Error VL53L1_GetPresetMode(VL53L1_DEV Dev,
+ VL53L1_PresetModes *pPresetMode)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ *pPresetMode = VL53L1DevDataGet(Dev, CurrentParameters.PresetMode);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_SetDistanceMode(VL53L1_DEV Dev,
+ VL53L1_DistanceModes DistanceMode)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ VL53L1_PresetModes PresetMode;
+ VL53L1_DistanceModes InternalDistanceMode;
+ uint32_t inter_measurement_period_ms;
+ uint32_t TimingBudget;
+ uint32_t MmTimeoutUs;
+ uint32_t PhaseCalTimeoutUs;
+ VL53L1_user_zone_t user_zone;
+
+ LOG_FUNCTION_START("%d", (int)DistanceMode);
+
+ PresetMode = VL53L1DevDataGet(Dev, CurrentParameters.PresetMode);
+
+ /* when the distance mode is valid:
+ * Manual Mode: all modes
+ * AUTO AUTO_LITE : LITE_RANGING, RANGING
+ */
+
+ if ((DistanceMode != VL53L1_DISTANCEMODE_SHORT) &&
+ (DistanceMode != VL53L1_DISTANCEMODE_MEDIUM) &&
+ (DistanceMode != VL53L1_DISTANCEMODE_LONG))
+ return VL53L1_ERROR_INVALID_PARAMS;
+
+ /* The internal distance mode is limited to Short, Medium or
+ * long only
+ */
+ if (Status == VL53L1_ERROR_NONE) {
+ if ((DistanceMode == VL53L1_DISTANCEMODE_SHORT) ||
+ (DistanceMode == VL53L1_DISTANCEMODE_MEDIUM))
+ InternalDistanceMode = DistanceMode;
+ else /* (DistanceMode == VL53L1_DISTANCEMODE_LONG) */
+ InternalDistanceMode = VL53L1_DISTANCEMODE_LONG;
+ }
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_get_user_zone(Dev, &user_zone);
+
+ inter_measurement_period_ms = VL53L1DevDataGet(Dev,
+ LLData.inter_measurement_period_ms);
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_get_timeouts_us(Dev, &PhaseCalTimeoutUs,
+ &MmTimeoutUs, &TimingBudget);
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = SetPresetMode(Dev,
+ PresetMode,
+ InternalDistanceMode,
+ inter_measurement_period_ms);
+
+ if (Status == VL53L1_ERROR_NONE) {
+ VL53L1DevDataSet(Dev, CurrentParameters.InternalDistanceMode,
+ InternalDistanceMode);
+ VL53L1DevDataSet(Dev, CurrentParameters.NewDistanceMode,
+ InternalDistanceMode);
+ VL53L1DevDataSet(Dev, CurrentParameters.DistanceMode,
+ DistanceMode);
+ }
+
+ if (Status == VL53L1_ERROR_NONE) {
+ Status = VL53L1_set_timeouts_us(Dev, PhaseCalTimeoutUs,
+ MmTimeoutUs, TimingBudget);
+
+ if (Status == VL53L1_ERROR_NONE)
+ VL53L1DevDataSet(Dev, LLData.range_config_timeout_us,
+ TimingBudget);
+ }
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_set_user_zone(Dev, &user_zone);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_GetDistanceMode(VL53L1_DEV Dev,
+ VL53L1_DistanceModes *pDistanceMode)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ *pDistanceMode = VL53L1DevDataGet(Dev, CurrentParameters.DistanceMode);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+
+
+VL53L1_Error VL53L1_SetMeasurementTimingBudgetMicroSeconds(VL53L1_DEV Dev,
+ uint32_t MeasurementTimingBudgetMicroSeconds)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint8_t Mm1Enabled;
+ uint8_t Mm2Enabled;
+ uint32_t TimingGuard;
+ uint32_t divisor;
+ uint32_t TimingBudget;
+ uint32_t MmTimeoutUs;
+ VL53L1_PresetModes PresetMode;
+ uint32_t PhaseCalTimeoutUs;
+ uint32_t vhv;
+ int32_t vhv_loops;
+ uint32_t FDAMaxTimingBudgetUs = FDA_MAX_TIMING_BUDGET_US;
+
+ LOG_FUNCTION_START("");
+
+ /* Timing budget is limited to 10 seconds */
+ if (MeasurementTimingBudgetMicroSeconds > 10000000)
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+
+ if (Status == VL53L1_ERROR_NONE) {
+ Status = VL53L1_GetSequenceStepEnable(Dev,
+ VL53L1_SEQUENCESTEP_MM1, &Mm1Enabled);
+ }
+
+ if (Status == VL53L1_ERROR_NONE) {
+ Status = VL53L1_GetSequenceStepEnable(Dev,
+ VL53L1_SEQUENCESTEP_MM2, &Mm2Enabled);
+ }
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_get_timeouts_us(Dev,
+ &PhaseCalTimeoutUs,
+ &MmTimeoutUs,
+ &TimingBudget);
+
+ if (Status == VL53L1_ERROR_NONE) {
+ PresetMode = VL53L1DevDataGet(Dev, CurrentParameters.PresetMode);
+
+ TimingGuard = 0;
+ divisor = 1;
+ switch (PresetMode) {
+ case VL53L1_PRESETMODE_LITE_RANGING:
+ if ((Mm1Enabled == 1) || (Mm2Enabled == 1))
+ TimingGuard = 5000;
+ else
+ TimingGuard = 1000;
+ break;
+
+ case VL53L1_PRESETMODE_AUTONOMOUS:
+ FDAMaxTimingBudgetUs *= 2;
+ if ((Mm1Enabled == 1) || (Mm2Enabled == 1))
+ TimingGuard = 26600;
+ else
+ TimingGuard = 21600;
+ divisor = 2;
+ break;
+
+ case VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS:
+ FDAMaxTimingBudgetUs *= 2;
+ vhv = LOWPOWER_AUTO_VHV_LOOP_DURATION_US;
+ VL53L1_get_tuning_parm(Dev,
+ VL53L1_TUNINGPARM_LOWPOWERAUTO_VHV_LOOP_BOUND,
+ &vhv_loops);
+ if (vhv_loops > 0) {
+ vhv += vhv_loops *
+ LOWPOWER_AUTO_VHV_LOOP_DURATION_US;
+ }
+ TimingGuard = LOWPOWER_AUTO_OVERHEAD_BEFORE_A_RANGING +
+ LOWPOWER_AUTO_OVERHEAD_BETWEEN_A_B_RANGING +
+ vhv;
+ divisor = 2;
+ break;
+
+ default:
+ /* Unsupported mode */
+ Status = VL53L1_ERROR_MODE_NOT_SUPPORTED;
+ }
+
+ if (MeasurementTimingBudgetMicroSeconds <= TimingGuard)
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ else {
+ TimingBudget = (MeasurementTimingBudgetMicroSeconds
+ - TimingGuard);
+ }
+
+ if (Status == VL53L1_ERROR_NONE) {
+ if (TimingBudget > FDAMaxTimingBudgetUs)
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ else {
+ TimingBudget /= divisor;
+ Status = VL53L1_set_timeouts_us(
+ Dev,
+ PhaseCalTimeoutUs,
+ MmTimeoutUs,
+ TimingBudget);
+ }
+
+ if (Status == VL53L1_ERROR_NONE)
+ VL53L1DevDataSet(Dev,
+ LLData.range_config_timeout_us,
+ TimingBudget);
+ }
+ }
+ if (Status == VL53L1_ERROR_NONE) {
+ VL53L1DevDataSet(Dev,
+ CurrentParameters.MeasurementTimingBudgetMicroSeconds,
+ MeasurementTimingBudgetMicroSeconds);
+ }
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+VL53L1_Error VL53L1_GetMeasurementTimingBudgetMicroSeconds(VL53L1_DEV Dev,
+ uint32_t *pMeasurementTimingBudgetMicroSeconds)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint8_t Mm1Enabled = 0;
+ uint8_t Mm2Enabled = 0;
+ uint32_t MmTimeoutUs = 0;
+ uint32_t RangeTimeoutUs = 0;
+ uint32_t MeasTimingBdg = 0;
+ uint32_t PhaseCalTimeoutUs = 0;
+ VL53L1_PresetModes PresetMode;
+ uint32_t TimingGuard;
+ uint32_t vhv;
+ int32_t vhv_loops;
+
+ LOG_FUNCTION_START("");
+
+ *pMeasurementTimingBudgetMicroSeconds = 0;
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_GetSequenceStepEnable(Dev,
+ VL53L1_SEQUENCESTEP_MM1, &Mm1Enabled);
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_GetSequenceStepEnable(Dev,
+ VL53L1_SEQUENCESTEP_MM2, &Mm2Enabled);
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_get_timeouts_us(Dev,
+ &PhaseCalTimeoutUs,
+ &MmTimeoutUs,
+ &RangeTimeoutUs);
+
+ if (Status == VL53L1_ERROR_NONE) {
+ PresetMode = VL53L1DevDataGet(Dev, CurrentParameters.PresetMode);
+
+ switch (PresetMode) {
+ case VL53L1_PRESETMODE_LITE_RANGING:
+ if ((Mm1Enabled == 1) || (Mm2Enabled == 1))
+ MeasTimingBdg = RangeTimeoutUs + 5000;
+ else
+ MeasTimingBdg = RangeTimeoutUs + 1000;
+
+ break;
+
+ case VL53L1_PRESETMODE_AUTONOMOUS:
+ if ((Mm1Enabled == 1) || (Mm2Enabled == 1))
+ MeasTimingBdg = 2 * RangeTimeoutUs + 26600;
+ else
+ MeasTimingBdg = 2 * RangeTimeoutUs + 21600;
+
+ break;
+
+ case VL53L1_PRESETMODE_LOWPOWER_AUTONOMOUS:
+ vhv = LOWPOWER_AUTO_VHV_LOOP_DURATION_US;
+ VL53L1_get_tuning_parm(Dev,
+ VL53L1_TUNINGPARM_LOWPOWERAUTO_VHV_LOOP_BOUND,
+ &vhv_loops);
+ if (vhv_loops > 0) {
+ vhv += vhv_loops *
+ LOWPOWER_AUTO_VHV_LOOP_DURATION_US;
+ }
+ TimingGuard = LOWPOWER_AUTO_OVERHEAD_BEFORE_A_RANGING +
+ LOWPOWER_AUTO_OVERHEAD_BETWEEN_A_B_RANGING +
+ vhv;
+ MeasTimingBdg = 2 * RangeTimeoutUs + TimingGuard;
+ break;
+
+ default:
+ /* Unsupported mode */
+ Status = VL53L1_ERROR_MODE_NOT_SUPPORTED;
+ }
+ }
+ if (Status == VL53L1_ERROR_NONE)
+ *pMeasurementTimingBudgetMicroSeconds = MeasTimingBdg;
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+
+VL53L1_Error VL53L1_SetInterMeasurementPeriodMilliSeconds(VL53L1_DEV Dev,
+ uint32_t InterMeasurementPeriodMilliSeconds)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint32_t adjustedIMP;
+
+ LOG_FUNCTION_START("");
+
+ /* Fix for Ticket 468205 actual measurement period shorter than set */
+ adjustedIMP = InterMeasurementPeriodMilliSeconds;
+ adjustedIMP += (adjustedIMP * 64) / 1000;
+ /* End of fix for Ticket 468205 */
+ Status = VL53L1_set_inter_measurement_period_ms(Dev,
+ adjustedIMP);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_GetInterMeasurementPeriodMilliSeconds(VL53L1_DEV Dev,
+ uint32_t *pInterMeasurementPeriodMilliSeconds)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint32_t adjustedIMP;
+
+ LOG_FUNCTION_START("");
+
+ Status = VL53L1_get_inter_measurement_period_ms(Dev, &adjustedIMP);
+ /* Fix for Ticket 468205 actual measurement period shorter than set */
+ adjustedIMP -= (adjustedIMP * 64) / 1000;
+ *pInterMeasurementPeriodMilliSeconds = adjustedIMP;
+ /* End of fix for Ticket 468205 */
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+/* End Group PAL Parameters Functions */
+
+
+/* Group Limit check Functions */
+
+VL53L1_Error VL53L1_GetNumberOfLimitCheck(uint16_t *pNumberOfLimitCheck)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ *pNumberOfLimitCheck = VL53L1_CHECKENABLE_NUMBER_OF_CHECKS;
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_GetLimitCheckInfo(uint16_t LimitCheckId,
+ char *pLimitCheckString)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ Status = VL53L1_get_limit_check_info(LimitCheckId,
+ pLimitCheckString);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_GetLimitCheckStatus(VL53L1_DEV Dev, uint16_t LimitCheckId,
+ uint8_t *pLimitCheckStatus)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint8_t Temp8;
+
+ LOG_FUNCTION_START("");
+
+ if (LimitCheckId >= VL53L1_CHECKENABLE_NUMBER_OF_CHECKS) {
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ } else {
+ VL53L1_GETARRAYPARAMETERFIELD(Dev, LimitChecksStatus,
+ LimitCheckId, Temp8);
+ *pLimitCheckStatus = Temp8;
+ }
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+static VL53L1_Error SetLimitValue(VL53L1_DEV Dev, uint16_t LimitCheckId,
+ FixPoint1616_t value)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint16_t tmpuint16; /* temporary variable */
+
+ LOG_FUNCTION_START("");
+
+ switch (LimitCheckId) {
+ case VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE:
+ tmpuint16 = VL53L1_FIXPOINT1616TOFIXPOINT142(value);
+ VL53L1_set_lite_sigma_threshold(Dev, tmpuint16);
+ break;
+ case VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE:
+ tmpuint16 = VL53L1_FIXPOINT1616TOFIXPOINT97(value);
+ VL53L1_set_lite_min_count_rate(Dev, tmpuint16);
+ break;
+ default:
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ }
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+VL53L1_Error VL53L1_SetLimitCheckEnable(VL53L1_DEV Dev, uint16_t LimitCheckId,
+ uint8_t LimitCheckEnable)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ FixPoint1616_t TempFix1616 = 0;
+
+ LOG_FUNCTION_START("");
+
+
+ if (LimitCheckId >= VL53L1_CHECKENABLE_NUMBER_OF_CHECKS) {
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ } else {
+ /* TempFix1616 contains either 0 or the limit value */
+ if (LimitCheckEnable == 0)
+ TempFix1616 = 0;
+ else
+ VL53L1_GETARRAYPARAMETERFIELD(Dev, LimitChecksValue,
+ LimitCheckId, TempFix1616);
+
+ Status = SetLimitValue(Dev, LimitCheckId, TempFix1616);
+ }
+
+ if (Status == VL53L1_ERROR_NONE)
+ VL53L1_SETARRAYPARAMETERFIELD(Dev,
+ LimitChecksEnable,
+ LimitCheckId,
+ ((LimitCheckEnable == 0) ? 0 : 1));
+
+
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_GetLimitCheckEnable(VL53L1_DEV Dev, uint16_t LimitCheckId,
+ uint8_t *pLimitCheckEnable)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint8_t Temp8;
+
+ LOG_FUNCTION_START("");
+
+ if (LimitCheckId >= VL53L1_CHECKENABLE_NUMBER_OF_CHECKS) {
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ *pLimitCheckEnable = 0;
+ } else {
+ VL53L1_GETARRAYPARAMETERFIELD(Dev, LimitChecksEnable,
+ LimitCheckId, Temp8);
+ *pLimitCheckEnable = Temp8;
+ }
+
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_SetLimitCheckValue(VL53L1_DEV Dev, uint16_t LimitCheckId,
+ FixPoint1616_t LimitCheckValue)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint8_t LimitChecksEnable;
+
+ LOG_FUNCTION_START("");
+
+ if (LimitCheckId >= VL53L1_CHECKENABLE_NUMBER_OF_CHECKS) {
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ } else {
+
+ VL53L1_GETARRAYPARAMETERFIELD(Dev, LimitChecksEnable,
+ LimitCheckId,
+ LimitChecksEnable);
+
+ if (LimitChecksEnable == 0) {
+ /* disabled write only internal value */
+ VL53L1_SETARRAYPARAMETERFIELD(Dev, LimitChecksValue,
+ LimitCheckId, LimitCheckValue);
+ } else {
+
+ Status = SetLimitValue(Dev, LimitCheckId,
+ LimitCheckValue);
+
+ if (Status == VL53L1_ERROR_NONE) {
+ VL53L1_SETARRAYPARAMETERFIELD(Dev,
+ LimitChecksValue,
+ LimitCheckId, LimitCheckValue);
+ }
+ }
+ }
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_GetLimitCheckValue(VL53L1_DEV Dev, uint16_t LimitCheckId,
+ FixPoint1616_t *pLimitCheckValue)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint16_t MinCountRate;
+ FixPoint1616_t TempFix1616;
+ uint16_t SigmaThresh;
+
+ LOG_FUNCTION_START("");
+
+ switch (LimitCheckId) {
+ case VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE:
+ Status = VL53L1_get_lite_sigma_threshold(Dev, &SigmaThresh);
+ TempFix1616 = VL53L1_FIXPOINT142TOFIXPOINT1616(SigmaThresh);
+ break;
+ case VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE:
+ Status = VL53L1_get_lite_min_count_rate(Dev, &MinCountRate);
+ TempFix1616 = VL53L1_FIXPOINT97TOFIXPOINT1616(MinCountRate);
+ break;
+ default:
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ }
+
+ if (Status == VL53L1_ERROR_NONE) {
+
+ if (TempFix1616 == 0) {
+ /* disabled: return value from memory */
+ VL53L1_GETARRAYPARAMETERFIELD(Dev,
+ LimitChecksValue, LimitCheckId,
+ TempFix1616);
+ *pLimitCheckValue = TempFix1616;
+ VL53L1_SETARRAYPARAMETERFIELD(Dev,
+ LimitChecksEnable, LimitCheckId, 0);
+ } else {
+ *pLimitCheckValue = TempFix1616;
+ VL53L1_SETARRAYPARAMETERFIELD(Dev,
+ LimitChecksValue, LimitCheckId,
+ TempFix1616);
+ VL53L1_SETARRAYPARAMETERFIELD(Dev,
+ LimitChecksEnable, LimitCheckId, 1);
+ }
+ }
+ LOG_FUNCTION_END(Status);
+ return Status;
+
+}
+
+VL53L1_Error VL53L1_GetLimitCheckCurrent(VL53L1_DEV Dev, uint16_t LimitCheckId,
+ FixPoint1616_t *pLimitCheckCurrent)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ FixPoint1616_t TempFix1616 = 0;
+
+ LOG_FUNCTION_START("");
+
+ if (LimitCheckId >= VL53L1_CHECKENABLE_NUMBER_OF_CHECKS) {
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ } else {
+ VL53L1_GETARRAYPARAMETERFIELD(Dev, LimitChecksCurrent,
+ LimitCheckId, TempFix1616);
+ *pLimitCheckCurrent = TempFix1616;
+ }
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+
+}
+
+/* End Group Limit check Functions */
+
+
+
+/* Group ROI Functions */
+
+VL53L1_Error VL53L1_SetUserROI(VL53L1_DEV Dev,
+ VL53L1_UserRoi_t *pRoi)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ VL53L1_user_zone_t user_zone;
+
+ Status = CheckValidRectRoi(*pRoi);
+ if (Status != VL53L1_ERROR_NONE)
+ return VL53L1_ERROR_INVALID_PARAMS;
+
+ user_zone.x_centre = (pRoi->BotRightX + pRoi->TopLeftX + 1) / 2;
+ user_zone.y_centre = (pRoi->TopLeftY + pRoi->BotRightY + 1) / 2;
+ user_zone.width = (pRoi->BotRightX - pRoi->TopLeftX);
+ user_zone.height = (pRoi->TopLeftY - pRoi->BotRightY);
+ if ((user_zone.width < 3) || (user_zone.height < 3))
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ else
+ Status = VL53L1_set_user_zone(Dev, &user_zone);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_GetUserROI(VL53L1_DEV Dev,
+ VL53L1_UserRoi_t *pRoi)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ VL53L1_user_zone_t user_zone;
+
+ Status = VL53L1_get_user_zone(Dev, &user_zone);
+
+ pRoi->TopLeftX = (2 * user_zone.x_centre - user_zone.width) >> 1;
+ pRoi->TopLeftY = (2 * user_zone.y_centre + user_zone.height) >> 1;
+ pRoi->BotRightX = (2 * user_zone.x_centre + user_zone.width) >> 1;
+ pRoi->BotRightY = (2 * user_zone.y_centre - user_zone.height) >> 1;
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+
+/* End Group ROI Functions */
+
+
+/* Group Sequence Step Functions */
+
+VL53L1_Error VL53L1_GetNumberOfSequenceSteps(VL53L1_DEV Dev,
+ uint8_t *pNumberOfSequenceSteps)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ SUPPRESS_UNUSED_WARNING(Dev);
+
+ LOG_FUNCTION_START("");
+
+ *pNumberOfSequenceSteps = VL53L1_SEQUENCESTEP_NUMBER_OF_ITEMS;
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_GetSequenceStepsInfo(VL53L1_SequenceStepId SequenceStepId,
+ char *pSequenceStepsString)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ Status = VL53L1_get_sequence_steps_info(
+ SequenceStepId,
+ pSequenceStepsString);
+
+ LOG_FUNCTION_END(Status);
+
+ return Status;
+}
+
+VL53L1_Error VL53L1_SetSequenceStepEnable(VL53L1_DEV Dev,
+ VL53L1_SequenceStepId SequenceStepId, uint8_t SequenceStepEnabled)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint32_t MeasurementTimingBudgetMicroSeconds;
+
+ LOG_FUNCTION_START("");
+
+ /* the VL53L1_SequenceStepId correspond to the LLD
+ * VL53L1_DeviceSequenceConfig
+ */
+
+ Status = VL53L1_set_sequence_config_bit(Dev,
+ (VL53L1_DeviceSequenceConfig)SequenceStepId,
+ SequenceStepEnabled);
+
+ /* Apply New Setting */
+ if (Status == VL53L1_ERROR_NONE) {
+
+ /* Recalculate timing budget */
+ MeasurementTimingBudgetMicroSeconds = VL53L1DevDataGet(Dev,
+ CurrentParameters.MeasurementTimingBudgetMicroSeconds);
+
+ VL53L1_SetMeasurementTimingBudgetMicroSeconds(Dev,
+ MeasurementTimingBudgetMicroSeconds);
+ }
+
+ LOG_FUNCTION_END(Status);
+
+ return Status;
+}
+
+
+VL53L1_Error VL53L1_GetSequenceStepEnable(VL53L1_DEV Dev,
+ VL53L1_SequenceStepId SequenceStepId, uint8_t *pSequenceStepEnabled)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ Status = VL53L1_get_sequence_config_bit(Dev,
+ (VL53L1_DeviceSequenceConfig)SequenceStepId,
+ pSequenceStepEnabled);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+/* End Group Sequence Step Functions Functions */
+
+
+
+/* Group PAL Measurement Functions */
+
+
+
+VL53L1_Error VL53L1_StartMeasurement(VL53L1_DEV Dev)
+{
+#define TIMED_MODE_TIMING_GUARD_MILLISECONDS 4
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint8_t DeviceMeasurementMode;
+ VL53L1_State CurrPalState;
+ VL53L1_Error lStatus;
+ uint32_t MTBus, IMPms;
+
+ LOG_FUNCTION_START("");
+
+ CurrPalState = VL53L1DevDataGet(Dev, PalState);
+ switch (CurrPalState) {
+ case VL53L1_STATE_IDLE:
+ Status = VL53L1_ERROR_NONE;
+ break;
+ case VL53L1_STATE_POWERDOWN:
+ case VL53L1_STATE_WAIT_STATICINIT:
+ case VL53L1_STATE_STANDBY:
+ case VL53L1_STATE_RUNNING:
+ case VL53L1_STATE_RESET:
+ case VL53L1_STATE_UNKNOWN:
+ case VL53L1_STATE_ERROR:
+ Status = VL53L1_ERROR_INVALID_COMMAND;
+ break;
+ default:
+ Status = VL53L1_ERROR_UNDEFINED;
+ }
+
+ DeviceMeasurementMode = VL53L1DevDataGet(Dev, LLData.measurement_mode);
+
+ /* Check timing configuration between timing budget and
+ * inter measurement period */
+ if ((Status == VL53L1_ERROR_NONE) &&
+ (DeviceMeasurementMode == VL53L1_DEVICEMEASUREMENTMODE_TIMED)) {
+ lStatus = VL53L1_GetMeasurementTimingBudgetMicroSeconds(Dev,
+ &MTBus);
+ /* convert timing budget in ms */
+ MTBus /= 1000;
+ lStatus = VL53L1_GetInterMeasurementPeriodMilliSeconds(Dev,
+ &IMPms);
+ /* trick to get rid of compiler "set but not used" warning */
+ SUPPRESS_UNUSED_WARNING(lStatus);
+ if (IMPms < MTBus + TIMED_MODE_TIMING_GUARD_MILLISECONDS)
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ }
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_init_and_start_range(
+ Dev,
+ DeviceMeasurementMode,
+ VL53L1_DEVICECONFIGLEVEL_FULL);
+
+ /* Set PAL State to Running */
+ if (Status == VL53L1_ERROR_NONE)
+ VL53L1DevDataSet(Dev, PalState, VL53L1_STATE_RUNNING);
+
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_StopMeasurement(VL53L1_DEV Dev)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ Status = VL53L1_stop_range(Dev);
+
+ /* Set PAL State to Idle */
+ if (Status == VL53L1_ERROR_NONE)
+ VL53L1DevDataSet(Dev, PalState, VL53L1_STATE_IDLE);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+static VL53L1_Error ChangePresetMode(VL53L1_DEV Dev)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ VL53L1_PresetModes PresetMode;
+ VL53L1_DistanceModes NewDistanceMode;
+ VL53L1_user_zone_t user_zone;
+ uint32_t TimingBudget;
+ uint32_t MmTimeoutUs;
+ uint32_t PhaseCalTimeoutUs;
+ uint8_t DeviceMeasurementMode;
+ uint32_t inter_measurement_period_ms;
+
+ LOG_FUNCTION_START("");
+
+ Status = VL53L1_get_user_zone(Dev, &user_zone);
+ /* Initialize variables fix ticket EwokP #475395 */
+ PresetMode = VL53L1DevDataGet(Dev,
+ CurrentParameters.PresetMode);
+ NewDistanceMode = VL53L1DevDataGet(Dev,
+ CurrentParameters.NewDistanceMode);
+ /* End of Initialize variables fix ticket EwokP #475395 */
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_get_timeouts_us(Dev, &PhaseCalTimeoutUs,
+ &MmTimeoutUs, &TimingBudget);
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_stop_range(Dev);
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_WaitUs(Dev, 500);
+
+ if (Status == VL53L1_ERROR_NONE) {
+ inter_measurement_period_ms = VL53L1DevDataGet(Dev,
+ LLData.inter_measurement_period_ms);
+
+ Status = SetPresetMode(Dev,
+ PresetMode,
+ NewDistanceMode,
+ inter_measurement_period_ms);
+ }
+
+ if (Status == VL53L1_ERROR_NONE) {
+ Status = VL53L1_set_timeouts_us(Dev, PhaseCalTimeoutUs,
+ MmTimeoutUs, TimingBudget);
+
+ if (Status == VL53L1_ERROR_NONE)
+ VL53L1DevDataSet(Dev, LLData.range_config_timeout_us,
+ TimingBudget);
+ }
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_set_user_zone(Dev, &user_zone);
+
+ if (Status == VL53L1_ERROR_NONE) {
+ DeviceMeasurementMode = VL53L1DevDataGet(Dev,
+ LLData.measurement_mode);
+
+ Status = VL53L1_init_and_start_range(
+ Dev,
+ DeviceMeasurementMode,
+ VL53L1_DEVICECONFIGLEVEL_FULL);
+ }
+
+ if (Status == VL53L1_ERROR_NONE)
+ VL53L1DevDataSet(Dev,
+ CurrentParameters.InternalDistanceMode,
+ NewDistanceMode);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+VL53L1_Error VL53L1_ClearInterruptAndStartMeasurement(VL53L1_DEV Dev)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint8_t DeviceMeasurementMode;
+ VL53L1_DistanceModes InternalDistanceMode;
+ VL53L1_DistanceModes NewDistanceMode;
+
+ LOG_FUNCTION_START("");
+
+ DeviceMeasurementMode = VL53L1DevDataGet(Dev, LLData.measurement_mode);
+ InternalDistanceMode = VL53L1DevDataGet(Dev,
+ CurrentParameters.InternalDistanceMode);
+ NewDistanceMode = VL53L1DevDataGet(Dev,
+ CurrentParameters.NewDistanceMode);
+
+ if (NewDistanceMode != InternalDistanceMode)
+ Status = ChangePresetMode(Dev);
+ else
+ Status = VL53L1_clear_interrupt_and_enable_next_range(
+ Dev,
+ DeviceMeasurementMode);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+VL53L1_Error VL53L1_GetMeasurementDataReady(VL53L1_DEV Dev,
+ uint8_t *pMeasurementDataReady)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ Status = VL53L1_is_new_data_ready(Dev, pMeasurementDataReady);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_WaitMeasurementDataReady(VL53L1_DEV Dev)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Note that the timeout is given by:
+ * VL53L1_RANGE_COMPLETION_POLLING_TIMEOUT_MS defined in def.h
+ */
+
+ Status = VL53L1_poll_for_range_completion(Dev,
+ VL53L1_RANGE_COMPLETION_POLLING_TIMEOUT_MS);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+
+static uint8_t ComputeRQL(uint8_t active_results,
+ uint8_t FilteredRangeStatus,
+ VL53L1_range_data_t *presults_data)
+{
+ int16_t SRL = 300;
+ uint16_t SRAS = 30;
+ FixPoint1616_t RAS;
+ FixPoint1616_t SRQL;
+ FixPoint1616_t GI = 7713587; /* 117.7 * 65536 */
+ FixPoint1616_t GGm = 3198157; /* 48.8 * 65536 */
+ FixPoint1616_t LRAP = 6554; /* 0.1 * 65536 */
+ FixPoint1616_t partial;
+ uint8_t finalvalue;
+ uint8_t returnvalue;
+
+ if (active_results == 0)
+ returnvalue = 0;
+ else if (FilteredRangeStatus == VL53L1_DEVICEERROR_PHASECONSISTENCY)
+ returnvalue = 50;
+ else {
+ if (presults_data->median_range_mm < SRL)
+ RAS = SRAS * 65536;
+ else
+ RAS = LRAP * presults_data->median_range_mm;
+
+ /* Fix1616 + (fix1616 * uint16_t / fix1616) * 65536 = fix1616 */
+ if (RAS != 0) {
+ partial = (GGm * presults_data->sigma_mm);
+ partial = partial + (RAS >> 1);
+ partial = partial / RAS;
+ partial = partial * 65536;
+ if (partial <= GI)
+ SRQL = GI - partial;
+ else
+ SRQL = 50 * 65536;
+ } else
+ SRQL = 100 * 65536;
+
+ finalvalue = (uint8_t)(SRQL >> 16);
+ returnvalue = MAX(50, MIN(100, finalvalue));
+ }
+
+ return returnvalue;
+}
+
+
+static uint8_t ConvertStatusLite(uint8_t FilteredRangeStatus)
+{
+ uint8_t RangeStatus;
+
+ switch (FilteredRangeStatus) {
+ case VL53L1_DEVICEERROR_GPHSTREAMCOUNT0READY:
+ RangeStatus = VL53L1_RANGESTATUS_SYNCRONISATION_INT;
+ break;
+ case VL53L1_DEVICEERROR_RANGECOMPLETE_NO_WRAP_CHECK:
+ RangeStatus = VL53L1_RANGESTATUS_RANGE_VALID_NO_WRAP_CHECK_FAIL;
+ break;
+ case VL53L1_DEVICEERROR_RANGEPHASECHECK:
+ RangeStatus = VL53L1_RANGESTATUS_OUTOFBOUNDS_FAIL;
+ break;
+ case VL53L1_DEVICEERROR_MSRCNOTARGET:
+ RangeStatus = VL53L1_RANGESTATUS_SIGNAL_FAIL;
+ break;
+ case VL53L1_DEVICEERROR_SIGMATHRESHOLDCHECK:
+ RangeStatus = VL53L1_RANGESTATUS_SIGMA_FAIL;
+ break;
+ case VL53L1_DEVICEERROR_PHASECONSISTENCY:
+ RangeStatus = VL53L1_RANGESTATUS_WRAP_TARGET_FAIL;
+ break;
+ case VL53L1_DEVICEERROR_RANGEIGNORETHRESHOLD:
+ RangeStatus = VL53L1_RANGESTATUS_XTALK_SIGNAL_FAIL;
+ break;
+ case VL53L1_DEVICEERROR_MINCLIP:
+ RangeStatus = VL53L1_RANGESTATUS_RANGE_VALID_MIN_RANGE_CLIPPED;
+ break;
+ case VL53L1_DEVICEERROR_RANGECOMPLETE:
+ RangeStatus = VL53L1_RANGESTATUS_RANGE_VALID;
+ break;
+ default:
+ RangeStatus = VL53L1_RANGESTATUS_NONE;
+ }
+
+ return RangeStatus;
+}
+
+
+
+static VL53L1_Error SetSimpleData(VL53L1_DEV Dev,
+ uint8_t active_results, uint8_t device_status,
+ VL53L1_range_data_t *presults_data,
+ VL53L1_RangingMeasurementData_t *pRangeData)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ uint8_t FilteredRangeStatus;
+ uint8_t SigmaLimitflag;
+ uint8_t SignalLimitflag;
+ uint8_t Temp8Enable;
+ uint8_t Temp8;
+ FixPoint1616_t AmbientRate;
+ FixPoint1616_t SignalRate;
+ FixPoint1616_t TempFix1616;
+ FixPoint1616_t LimitCheckValue;
+ int16_t Range;
+
+ pRangeData->TimeStamp = presults_data->time_stamp;
+
+ FilteredRangeStatus = presults_data->range_status & 0x1F;
+
+ pRangeData->RangeQualityLevel = ComputeRQL(active_results,
+ FilteredRangeStatus,
+ presults_data);
+
+ SignalRate = VL53L1_FIXPOINT97TOFIXPOINT1616(
+ presults_data->peak_signal_count_rate_mcps);
+ pRangeData->SignalRateRtnMegaCps
+ = SignalRate;
+
+ AmbientRate = VL53L1_FIXPOINT97TOFIXPOINT1616(
+ presults_data->ambient_count_rate_mcps);
+ pRangeData->AmbientRateRtnMegaCps = AmbientRate;
+
+ pRangeData->EffectiveSpadRtnCount =
+ presults_data->actual_effective_spads;
+
+ TempFix1616 = VL53L1_FIXPOINT97TOFIXPOINT1616(
+ presults_data->sigma_mm);
+
+ pRangeData->SigmaMilliMeter = TempFix1616;
+
+ pRangeData->RangeMilliMeter = presults_data->median_range_mm;
+
+ pRangeData->RangeFractionalPart = 0;
+
+ /* Treat device error status first */
+ switch (device_status) {
+ case VL53L1_DEVICEERROR_MULTCLIPFAIL:
+ case VL53L1_DEVICEERROR_VCSELWATCHDOGTESTFAILURE:
+ case VL53L1_DEVICEERROR_VCSELCONTINUITYTESTFAILURE:
+ case VL53L1_DEVICEERROR_NOVHVVALUEFOUND:
+ pRangeData->RangeStatus = VL53L1_RANGESTATUS_HARDWARE_FAIL;
+ break;
+ case VL53L1_DEVICEERROR_USERROICLIP:
+ pRangeData->RangeStatus = VL53L1_RANGESTATUS_MIN_RANGE_FAIL;
+ break;
+ default:
+ pRangeData->RangeStatus = VL53L1_RANGESTATUS_RANGE_VALID;
+ }
+
+ /* Now deal with range status according to the ranging preset */
+ if (pRangeData->RangeStatus == VL53L1_RANGESTATUS_RANGE_VALID) {
+ pRangeData->RangeStatus =
+ ConvertStatusLite(FilteredRangeStatus);
+ }
+
+ /* Update current Limit Check */
+ TempFix1616 = VL53L1_FIXPOINT97TOFIXPOINT1616(
+ presults_data->sigma_mm);
+ VL53L1_SETARRAYPARAMETERFIELD(Dev,
+ LimitChecksCurrent, VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE,
+ TempFix1616);
+
+ TempFix1616 = VL53L1_FIXPOINT97TOFIXPOINT1616(
+ presults_data->peak_signal_count_rate_mcps);
+ VL53L1_SETARRAYPARAMETERFIELD(Dev,
+ LimitChecksCurrent, VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE,
+ TempFix1616);
+
+ /* Update Limit Check Status */
+ /* Sigma */
+ VL53L1_GetLimitCheckValue(Dev,
+ VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE,
+ &LimitCheckValue);
+
+ SigmaLimitflag = (FilteredRangeStatus ==
+ VL53L1_DEVICEERROR_SIGMATHRESHOLDCHECK)
+ ? 1 : 0;
+
+ VL53L1_GetLimitCheckEnable(Dev,
+ VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE,
+ &Temp8Enable);
+
+ Temp8 = ((Temp8Enable == 1) && (SigmaLimitflag == 1)) ? 1 : 0;
+ VL53L1_SETARRAYPARAMETERFIELD(Dev, LimitChecksStatus,
+ VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE, Temp8);
+
+ /* Signal Rate */
+ VL53L1_GetLimitCheckValue(Dev,
+ VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE,
+ &LimitCheckValue);
+
+ SignalLimitflag = (FilteredRangeStatus ==
+ VL53L1_DEVICEERROR_MSRCNOTARGET)
+ ? 1 : 0;
+
+ VL53L1_GetLimitCheckEnable(Dev,
+ VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE,
+ &Temp8Enable);
+
+ Temp8 = ((Temp8Enable == 1) && (SignalLimitflag == 1)) ? 1 : 0;
+ VL53L1_SETARRAYPARAMETERFIELD(Dev, LimitChecksStatus,
+ VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE, Temp8);
+
+ Range = pRangeData->RangeMilliMeter;
+ if ((pRangeData->RangeStatus == VL53L1_RANGESTATUS_RANGE_VALID) &&
+ (Range < 0)) {
+ if (Range < BDTable[VL53L1_TUNING_PROXY_MIN])
+ pRangeData->RangeStatus =
+ VL53L1_RANGESTATUS_RANGE_INVALID;
+ else
+ pRangeData->RangeMilliMeter = 0;
+ }
+
+ return Status;
+}
+
+
+
+VL53L1_Error VL53L1_GetRangingMeasurementData(VL53L1_DEV Dev,
+ VL53L1_RangingMeasurementData_t *pRangingMeasurementData)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ VL53L1_range_results_t results;
+ VL53L1_range_results_t *presults = &results;
+ VL53L1_range_data_t *presults_data;
+
+ LOG_FUNCTION_START("");
+
+
+ /* Clear Ranging Data */
+ memset(pRangingMeasurementData, 0xFF,
+ sizeof(VL53L1_RangingMeasurementData_t));
+
+ /* Get Ranging Data */
+ Status = VL53L1_get_device_results(
+ Dev,
+ VL53L1_DEVICERESULTSLEVEL_FULL,
+ presults);
+
+ if (Status == VL53L1_ERROR_NONE) {
+ pRangingMeasurementData->StreamCount = presults->stream_count;
+
+ /* in case of lite ranging or autonomous the following function
+ * returns index = 0
+ */
+ presults_data = &(presults->data[0]);
+ Status = SetSimpleData(Dev, 1,
+ presults->device_status,
+ presults_data,
+ pRangingMeasurementData);
+ }
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+
+
+
+/* End Group PAL Measurement Functions */
+
+
+/* Group Calibration functions */
+VL53L1_Error VL53L1_SetTuningParameter(VL53L1_DEV Dev,
+ uint16_t TuningParameterId, int32_t TuningParameterValue)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+ if (TuningParameterId >= 32768)
+ Status = VL53L1_set_tuning_parm(Dev,
+ TuningParameterId,
+ TuningParameterValue);
+ else {
+ if (TuningParameterId < VL53L1_TUNING_MAX_TUNABLE_KEY)
+ BDTable[TuningParameterId] = TuningParameterValue;
+ else
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ }
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_GetTuningParameter(VL53L1_DEV Dev,
+ uint16_t TuningParameterId, int32_t *pTuningParameterValue)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (TuningParameterId >= 32768)
+ Status = VL53L1_get_tuning_parm(Dev,
+ TuningParameterId,
+ pTuningParameterValue);
+ else {
+ if (TuningParameterId < VL53L1_TUNING_MAX_TUNABLE_KEY)
+ *pTuningParameterValue = BDTable[TuningParameterId];
+ else
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ }
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+VL53L1_Error VL53L1_PerformRefSpadManagement(VL53L1_DEV Dev)
+{
+#ifdef VL53L1_NOCALIB
+ VL53L1_Error Status = VL53L1_ERROR_NOT_SUPPORTED;
+
+ SUPPRESS_UNUSED_WARNING(Dev);
+
+ LOG_FUNCTION_START("");
+#else
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ VL53L1_Error RawStatus;
+ uint8_t dcrbuffer[24];
+ uint8_t *comms_buffer;
+ uint8_t numloc[2] = {5,3};
+ VL53L1_LLDriverData_t *pdev;
+ VL53L1_customer_nvm_managed_t *pc;
+ VL53L1_PresetModes PresetMode;
+
+ LOG_FUNCTION_START("");
+
+ pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+ pc = &pdev->customer;
+
+ if (Status == VL53L1_ERROR_NONE)
+ {
+ PresetMode = VL53L1DevDataGet(Dev, CurrentParameters.PresetMode);
+ Status = VL53L1_run_ref_spad_char(Dev, &RawStatus);
+ /* We discovered RefSpad mngt badly breaks some preset mode
+ * The WA is to apply again the current one
+ */
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_SetPresetMode(Dev, PresetMode);
+ }
+
+ if (Status == VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH) {
+ /* Fix ticket #466282 RefSpad management error/warning -29
+ * force usage of location 3 and 5 refspads in registers
+ */
+ Status = VL53L1_read_nvm_raw_data(Dev,
+ (uint8_t)(0xA0 >> 2),
+ (uint8_t)(24 >> 2),
+ dcrbuffer);
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_WriteMulti( Dev,
+ VL53L1_REF_SPAD_MAN__NUM_REQUESTED_REF_SPADS,
+ numloc, 2);
+
+ if (Status == VL53L1_ERROR_NONE) {
+ pc->ref_spad_man__num_requested_ref_spads = numloc[0];
+ pc->ref_spad_man__ref_location = numloc[1];
+ }
+
+ if (Status == VL53L1_ERROR_NONE)
+ comms_buffer = &dcrbuffer[16];
+
+ /*
+ * update & copy reference SPAD enables to customer nvm managed
+ */
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_WriteMulti(Dev,
+ VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_REF_0,
+ comms_buffer, 6);
+
+ if (Status == VL53L1_ERROR_NONE) {
+ pc->global_config__spad_enables_ref_0 = comms_buffer[0];
+ pc->global_config__spad_enables_ref_1 = comms_buffer[1];
+ pc->global_config__spad_enables_ref_2 = comms_buffer[2];
+ pc->global_config__spad_enables_ref_3 = comms_buffer[3];
+ pc->global_config__spad_enables_ref_4 = comms_buffer[4];
+ pc->global_config__spad_enables_ref_5 = comms_buffer[5];
+ }
+ /* End of fix ticket #466282 */
+ }
+
+#endif
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+VL53L1_Error VL53L1_SetXTalkCompensationEnable(VL53L1_DEV Dev,
+ uint8_t XTalkCompensationEnable)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (XTalkCompensationEnable == 0)
+ Status = VL53L1_disable_xtalk_compensation(Dev);
+ else
+ Status = VL53L1_enable_xtalk_compensation(Dev);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+VL53L1_Error VL53L1_GetXTalkCompensationEnable(VL53L1_DEV Dev,
+ uint8_t *pXTalkCompensationEnable)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ VL53L1_get_xtalk_compensation_enable(
+ Dev,
+ pXTalkCompensationEnable);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_PerformSingleTargetXTalkCalibration(VL53L1_DEV Dev,
+ int32_t CalDistanceMilliMeter)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (CalDistanceMilliMeter > 0) {
+ BDTable[VL53L1_TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM] =
+ CalDistanceMilliMeter;
+ Status = SingleTargetXTalkCalibration(Dev);
+ } else
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+VL53L1_Error VL53L1_SetOffsetCalibrationMode(VL53L1_DEV Dev,
+ VL53L1_OffsetCalibrationModes OffsetCalibrationMode)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ VL53L1_OffsetCalibrationMode offset_cal_mode;
+
+ LOG_FUNCTION_START("");
+
+ if (OffsetCalibrationMode == VL53L1_OFFSETCALIBRATIONMODE_STANDARD) {
+ offset_cal_mode = VL53L1_DEVICEPRESETMODE_STANDARD_RANGING;
+ } else if (OffsetCalibrationMode ==
+ VL53L1_OFFSETCALIBRATIONMODE_PRERANGE_ONLY) {
+ offset_cal_mode =
+ VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD_PRE_RANGE_ONLY;
+ } else {
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ }
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_set_offset_calibration_mode(Dev,
+ offset_cal_mode);
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+#ifdef OFFSET_CALIB
+VL53L1_Error VL53L1_PerformOffsetCalibration(VL53L1_DEV Dev,
+ int32_t CalDistanceMilliMeter)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ VL53L1_Error UnfilteredStatus;
+ VL53L1_OffsetCalibrationMode offset_cal_mode;
+
+ LOG_FUNCTION_START("");
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_get_offset_calibration_mode(Dev,
+ &offset_cal_mode);
+
+ if (Status != VL53L1_ERROR_NONE) {
+ LOG_FUNCTION_END(Status);
+ return Status;
+ }
+
+ if ((offset_cal_mode ==
+ VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD) ||
+ (offset_cal_mode ==
+ VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD_PRE_RANGE_ONLY
+ )) {
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_run_offset_calibration(
+ Dev,
+ (int16_t)CalDistanceMilliMeter,
+ &UnfilteredStatus);
+ } else {
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ }
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+#endif
+#ifdef OFFSET_CALIB_EMPTY
+VL53L1_Error VL53L1_PerformOffsetCalibration(VL53L1_DEV Dev,
+ int32_t CalDistanceMilliMeter)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NOT_SUPPORTED;
+ SUPPRESS_UNUSED_WARNING(Dev);
+ SUPPRESS_UNUSED_WARNING(CalDistanceMilliMeter);
+ return Status;
+}
+#endif
+
+VL53L1_Error VL53L1_PerformOffsetSimpleCalibration(VL53L1_DEV Dev,
+ int32_t CalDistanceMilliMeter)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ int32_t sum_ranging;
+ uint8_t offset_meas;
+ int16_t Max, UnderMax, OverMax, Repeat;
+ int32_t total_count, inloopcount;
+ int32_t IncRounding;
+ int16_t meanDistance_mm;
+ int16_t offset;
+ VL53L1_RangingMeasurementData_t RangingMeasurementData;
+ VL53L1_LLDriverData_t *pdev;
+ uint8_t goodmeas;
+
+ LOG_FUNCTION_START("");
+
+ pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+ /* Disable any offsets */
+ pdev->customer.algo__part_to_part_range_offset_mm = 0;
+ pdev->customer.mm_config__inner_offset_mm = 0;
+ pdev->customer.mm_config__outer_offset_mm = 0;
+
+ Repeat=BDTable[VL53L1_TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT];
+ Max=BDTable[VL53L1_TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER];
+ UnderMax = 1 + (Max / 2);
+ OverMax = Max + (Max / 2);
+ sum_ranging = 0;
+ total_count = 0;
+
+ while ((Repeat > 0) && (Status == VL53L1_ERROR_NONE)) {
+ Status = VL53L1_StartMeasurement(Dev);
+ /* Very first ranging completion interrupt must be ignored */
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_WaitMeasurementDataReady(Dev);
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_GetRangingMeasurementData(Dev,
+ &RangingMeasurementData);
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_ClearInterruptAndStartMeasurement(Dev);
+ /* offset calibration main loop */
+ inloopcount = 0;
+ offset_meas = 0;
+ while ((Status == VL53L1_ERROR_NONE) && (inloopcount < Max) &&
+ (offset_meas < OverMax)) {
+ Status = VL53L1_WaitMeasurementDataReady(Dev);
+ if (Status == VL53L1_ERROR_NONE)
+ Status = VL53L1_GetRangingMeasurementData(Dev,
+ &RangingMeasurementData);
+ goodmeas = (RangingMeasurementData.RangeStatus ==
+ VL53L1_RANGESTATUS_RANGE_VALID);
+ if ((Status == VL53L1_ERROR_NONE) && goodmeas) {
+ sum_ranging = sum_ranging +
+ RangingMeasurementData.RangeMilliMeter;
+ inloopcount++;
+ }
+ if (Status == VL53L1_ERROR_NONE) {
+ Status = VL53L1_ClearInterruptAndStartMeasurement(
+ Dev);
+ }
+ offset_meas++;
+ }
+ total_count += inloopcount;
+
+ /* no enough valid values found */
+ if (inloopcount < UnderMax) {
+ Status = VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL;
+ }
+
+ VL53L1_StopMeasurement(Dev);
+
+ Repeat--;
+
+ }
+ /* check overflow (unlikely if target is near to the device) */
+ if ((sum_ranging < 0) ||
+ (sum_ranging > ((int32_t) total_count * 0xffff))) {
+ Status = VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH;
+ }
+
+ if ((Status == VL53L1_ERROR_NONE) && (total_count > 0)) {
+ IncRounding = total_count / 2;
+ meanDistance_mm = (int16_t)((sum_ranging + IncRounding)
+ / total_count);
+ offset = (int16_t)CalDistanceMilliMeter - meanDistance_mm;
+ pdev->customer.algo__part_to_part_range_offset_mm = 0;
+ pdev->customer.mm_config__inner_offset_mm = offset;
+ pdev->customer.mm_config__outer_offset_mm = offset;
+
+ Status = VL53L1_set_customer_nvm_managed(Dev,
+ &(pdev->customer));
+ }
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+VL53L1_Error VL53L1_SetCalibrationData(VL53L1_DEV Dev,
+ VL53L1_CalibrationData_t *pCalibrationData)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ VL53L1_CustomerNvmManaged_t *pC;
+ VL53L1_calibration_data_t cal_data;
+ uint32_t x;
+
+ LOG_FUNCTION_START("");
+
+ cal_data.struct_version = pCalibrationData->struct_version -
+ VL53L1_ADDITIONAL_CALIBRATION_DATA_STRUCT_VERSION;
+
+
+
+ /* memcpy(DEST, SRC, N) */
+ memcpy(
+ &(cal_data.add_off_cal_data),
+ &(pCalibrationData->add_off_cal_data),
+ sizeof(VL53L1_additional_offset_cal_data_t));
+
+ /* memcpy (DEST, SRC, N) */
+ memcpy(
+ &(cal_data.optical_centre),
+ &(pCalibrationData->optical_centre),
+ sizeof(VL53L1_optical_centre_t));
+
+ /* memcpy (DEST, SRC, N) */
+ memcpy(
+ &(cal_data.gain_cal),
+ &(pCalibrationData->gain_cal),
+ sizeof(VL53L1_gain_calibration_data_t));
+
+ /* memcpy (DEST, SRC, N) */
+ memcpy(
+ &(cal_data.cal_peak_rate_map),
+ &(pCalibrationData->cal_peak_rate_map),
+ sizeof(VL53L1_cal_peak_rate_map_t));
+
+ pC = &pCalibrationData->customer;
+ x = pC->algo__crosstalk_compensation_plane_offset_kcps;
+ cal_data.customer.algo__crosstalk_compensation_plane_offset_kcps =
+ (uint16_t)(x&0x0000FFFF);
+
+ cal_data.customer.global_config__spad_enables_ref_0 =
+ pC->global_config__spad_enables_ref_0;
+ cal_data.customer.global_config__spad_enables_ref_1 =
+ pC->global_config__spad_enables_ref_1;
+ cal_data.customer.global_config__spad_enables_ref_2 =
+ pC->global_config__spad_enables_ref_2;
+ cal_data.customer.global_config__spad_enables_ref_3 =
+ pC->global_config__spad_enables_ref_3;
+ cal_data.customer.global_config__spad_enables_ref_4 =
+ pC->global_config__spad_enables_ref_4;
+ cal_data.customer.global_config__spad_enables_ref_5 =
+ pC->global_config__spad_enables_ref_5;
+ cal_data.customer.global_config__ref_en_start_select =
+ pC->global_config__ref_en_start_select;
+ cal_data.customer.ref_spad_man__num_requested_ref_spads =
+ pC->ref_spad_man__num_requested_ref_spads;
+ cal_data.customer.ref_spad_man__ref_location =
+ pC->ref_spad_man__ref_location;
+ cal_data.customer.algo__crosstalk_compensation_x_plane_gradient_kcps =
+ pC->algo__crosstalk_compensation_x_plane_gradient_kcps;
+ cal_data.customer.algo__crosstalk_compensation_y_plane_gradient_kcps =
+ pC->algo__crosstalk_compensation_y_plane_gradient_kcps;
+ cal_data.customer.ref_spad_char__total_rate_target_mcps =
+ pC->ref_spad_char__total_rate_target_mcps;
+ cal_data.customer.algo__part_to_part_range_offset_mm =
+ pC->algo__part_to_part_range_offset_mm;
+ cal_data.customer.mm_config__inner_offset_mm =
+ pC->mm_config__inner_offset_mm;
+ cal_data.customer.mm_config__outer_offset_mm =
+ pC->mm_config__outer_offset_mm;
+
+ Status = VL53L1_set_part_to_part_data(Dev, &cal_data);
+ LOG_FUNCTION_END(Status);
+ return Status;
+
+}
+
+VL53L1_Error VL53L1_GetCalibrationData(VL53L1_DEV Dev,
+ VL53L1_CalibrationData_t *pCalibrationData)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ VL53L1_calibration_data_t cal_data;
+ VL53L1_CustomerNvmManaged_t *pC;
+ VL53L1_customer_nvm_managed_t *pC2;
+
+ LOG_FUNCTION_START("");
+
+ /* struct_version is filled inside get part to part function */
+ Status = VL53L1_get_part_to_part_data(Dev, &cal_data);
+
+ pCalibrationData->struct_version = cal_data.struct_version +
+ VL53L1_ADDITIONAL_CALIBRATION_DATA_STRUCT_VERSION;
+
+
+ /* memcpy(DEST, SRC, N) */
+ memcpy(
+ &(pCalibrationData->add_off_cal_data),
+ &(cal_data.add_off_cal_data),
+ sizeof(VL53L1_additional_offset_cal_data_t));
+
+ /* memcpy (DEST, SRC, N) */
+ memcpy(
+ &(pCalibrationData->optical_centre),
+ &(cal_data.optical_centre),
+ sizeof(VL53L1_optical_centre_t));
+
+ /* memcpy (DEST, SRC, N) */
+ memcpy(
+ &(pCalibrationData->gain_cal),
+ &(cal_data.gain_cal),
+ sizeof(VL53L1_gain_calibration_data_t));
+
+ /* memcpy (DEST, SRC, N) */
+ memcpy(
+ &(pCalibrationData->cal_peak_rate_map),
+ &(cal_data.cal_peak_rate_map),
+ sizeof(VL53L1_cal_peak_rate_map_t));
+
+
+ pC = &pCalibrationData->customer;
+ pC2 = &cal_data.customer;
+ pC->global_config__spad_enables_ref_0 =
+ pC2->global_config__spad_enables_ref_0;
+ pC->global_config__spad_enables_ref_1 =
+ pC2->global_config__spad_enables_ref_1;
+ pC->global_config__spad_enables_ref_2 =
+ pC2->global_config__spad_enables_ref_2;
+ pC->global_config__spad_enables_ref_3 =
+ pC2->global_config__spad_enables_ref_3;
+ pC->global_config__spad_enables_ref_4 =
+ pC2->global_config__spad_enables_ref_4;
+ pC->global_config__spad_enables_ref_5 =
+ pC2->global_config__spad_enables_ref_5;
+ pC->global_config__ref_en_start_select =
+ pC2->global_config__ref_en_start_select;
+ pC->ref_spad_man__num_requested_ref_spads =
+ pC2->ref_spad_man__num_requested_ref_spads;
+ pC->ref_spad_man__ref_location =
+ pC2->ref_spad_man__ref_location;
+ pC->algo__crosstalk_compensation_x_plane_gradient_kcps =
+ pC2->algo__crosstalk_compensation_x_plane_gradient_kcps;
+ pC->algo__crosstalk_compensation_y_plane_gradient_kcps =
+ pC2->algo__crosstalk_compensation_y_plane_gradient_kcps;
+ pC->ref_spad_char__total_rate_target_mcps =
+ pC2->ref_spad_char__total_rate_target_mcps;
+ pC->algo__part_to_part_range_offset_mm =
+ pC2->algo__part_to_part_range_offset_mm;
+ pC->mm_config__inner_offset_mm =
+ pC2->mm_config__inner_offset_mm;
+ pC->mm_config__outer_offset_mm =
+ pC2->mm_config__outer_offset_mm;
+
+ pC->algo__crosstalk_compensation_plane_offset_kcps =
+ (uint32_t)(
+ pC2->algo__crosstalk_compensation_plane_offset_kcps);
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+
+VL53L1_Error VL53L1_GetOpticalCenter(VL53L1_DEV Dev,
+ FixPoint1616_t *pOpticalCenterX,
+ FixPoint1616_t *pOpticalCenterY)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ VL53L1_calibration_data_t CalibrationData;
+
+ LOG_FUNCTION_START("");
+
+ *pOpticalCenterX = 0;
+ *pOpticalCenterY = 0;
+ Status = VL53L1_get_part_to_part_data(Dev, &CalibrationData);
+ if (Status == VL53L1_ERROR_NONE) {
+ *pOpticalCenterX = VL53L1_FIXPOINT44TOFIXPOINT1616(
+ CalibrationData.optical_centre.x_centre);
+ *pOpticalCenterY = VL53L1_FIXPOINT44TOFIXPOINT1616(
+ CalibrationData.optical_centre.y_centre);
+ }
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+/* END Group Calibration functions */
+
+
+/* Group PAL detection triggered events Functions */
+
+VL53L1_Error VL53L1_SetThresholdConfig(VL53L1_DEV Dev,
+ VL53L1_DetectionConfig_t *pConfig)
+{
+#define BADTHRESBOUNDS(T) \
+ (((T.CrossMode == VL53L1_THRESHOLD_OUT_OF_WINDOW) || \
+ (T.CrossMode == VL53L1_THRESHOLD_IN_WINDOW)) && (T.Low > T.High))
+
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ VL53L1_GPIO_interrupt_config_t Cfg;
+ uint16_t g;
+ FixPoint1616_t gain, high1616, low1616;
+ VL53L1_LLDriverData_t *pdev;
+
+ LOG_FUNCTION_START("");
+
+ pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ Status = VL53L1_get_GPIO_interrupt_config(Dev, &Cfg);
+ if (Status == VL53L1_ERROR_NONE) {
+ if (pConfig->DetectionMode == VL53L1_DETECTION_NORMAL_RUN) {
+ Cfg.intr_new_measure_ready = 1;
+ Status = VL53L1_set_GPIO_interrupt_config_struct(Dev,
+ Cfg);
+ } else {
+ if (BADTHRESBOUNDS(pConfig->Distance))
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ if ((Status == VL53L1_ERROR_NONE) &&
+ (BADTHRESBOUNDS(pConfig->Rate)))
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ if (Status == VL53L1_ERROR_NONE) {
+ Cfg.intr_new_measure_ready = 0;
+ Cfg.intr_no_target = pConfig->IntrNoTarget;
+ /* fix ticket 466238
+ * Apply invert distance gain to thresholds */
+ g = pdev->gain_cal.standard_ranging_gain_factor;
+ /* gain is ufix 5.11, convert to 16.16 */
+ gain = (FixPoint1616_t) ((uint32_t)g << 5);
+ high1616 = (FixPoint1616_t) ((uint32_t)
+ pConfig->Distance.High << 16);
+ low1616 = (FixPoint1616_t) ((uint32_t)
+ pConfig->Distance.Low << 16);
+ /* +32768 to round the results*/
+ high1616 = (high1616 + 32768) / gain;
+ low1616 = (low1616 + 32768) / gain;
+ Cfg.threshold_distance_high = (uint16_t)
+ (high1616 & 0xFFFF);
+ Cfg.threshold_distance_low = (uint16_t)
+ (low1616 & 0xFFFF);
+ /* end fix ticket 466238 */
+ Cfg.threshold_rate_high =
+ VL53L1_FIXPOINT1616TOFIXPOINT97(
+ pConfig->Rate.High);
+ Cfg.threshold_rate_low =
+ VL53L1_FIXPOINT1616TOFIXPOINT97(
+ pConfig->Rate.Low);
+
+ Cfg.intr_mode_distance = ConvertModeToLLD(
+ &Status,
+ pConfig->Distance.CrossMode);
+ if (Status == VL53L1_ERROR_NONE)
+ Cfg.intr_mode_rate = ConvertModeToLLD(
+ &Status,
+ pConfig->Rate.CrossMode);
+ }
+
+ /* Refine thresholds combination now */
+ if (Status == VL53L1_ERROR_NONE) {
+ Cfg.intr_combined_mode = 1;
+ switch (pConfig->DetectionMode) {
+ case VL53L1_DETECTION_DISTANCE_ONLY:
+ Cfg.threshold_rate_high = 0;
+ Cfg.threshold_rate_low = 0;
+ break;
+ case VL53L1_DETECTION_RATE_ONLY:
+ Cfg.threshold_distance_high = 0;
+ Cfg.threshold_distance_low = 0;
+ break;
+ case VL53L1_DETECTION_DISTANCE_OR_RATE:
+ /* Nothing to do all is already
+ * in place
+ */
+ break;
+ case VL53L1_DETECTION_DISTANCE_AND_RATE:
+ Cfg.intr_combined_mode = 0;
+ break;
+ default:
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ }
+ }
+
+ if (Status == VL53L1_ERROR_NONE)
+ Status =
+ VL53L1_set_GPIO_interrupt_config_struct(Dev,
+ Cfg);
+
+ }
+ }
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+VL53L1_Error VL53L1_GetThresholdConfig(VL53L1_DEV Dev,
+ VL53L1_DetectionConfig_t *pConfig)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+ VL53L1_GPIO_interrupt_config_t Cfg;
+
+ LOG_FUNCTION_START("");
+
+ Status = VL53L1_get_GPIO_interrupt_config(Dev, &Cfg);
+
+ if (Status != VL53L1_ERROR_NONE) {
+ LOG_FUNCTION_END(Status);
+ return Status;
+ }
+
+ pConfig->IntrNoTarget = Cfg.intr_no_target;
+ pConfig->Distance.High = Cfg.threshold_distance_high;
+ pConfig->Distance.Low = Cfg.threshold_distance_low;
+ pConfig->Rate.High =
+ VL53L1_FIXPOINT97TOFIXPOINT1616(
+ Cfg.threshold_rate_high);
+ pConfig->Rate.Low =
+ VL53L1_FIXPOINT97TOFIXPOINT1616(Cfg.threshold_rate_low);
+ pConfig->Distance.CrossMode =
+ ConvertModeFromLLD(&Status, Cfg.intr_mode_distance);
+ if (Status == VL53L1_ERROR_NONE)
+ pConfig->Rate.CrossMode =
+ ConvertModeFromLLD(&Status, Cfg.intr_mode_rate);
+
+ if (Cfg.intr_new_measure_ready == 1) {
+ pConfig->DetectionMode = VL53L1_DETECTION_NORMAL_RUN;
+ } else {
+ /* Refine thresholds combination now */
+ if (Status == VL53L1_ERROR_NONE) {
+ if (Cfg.intr_combined_mode == 0)
+ pConfig->DetectionMode =
+ VL53L1_DETECTION_DISTANCE_AND_RATE;
+ else {
+ if ((Cfg.threshold_distance_high == 0) &&
+ (Cfg.threshold_distance_low == 0))
+ pConfig->DetectionMode =
+ VL53L1_DETECTION_RATE_ONLY;
+ else if ((Cfg.threshold_rate_high == 0) &&
+ (Cfg.threshold_rate_low == 0))
+ pConfig->DetectionMode =
+ VL53L1_DETECTION_DISTANCE_ONLY;
+ else
+ pConfig->DetectionMode =
+ VL53L1_DETECTION_DISTANCE_OR_RATE;
+ }
+ }
+ }
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
+
+/* End Group PAL IRQ Triggered events Functions */
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api_calibration.c b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api_calibration.c
new file mode 100644
index 0000000..45608d9
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api_calibration.c
@@ -0,0 +1,876 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_api_core.c
+ *
+ * @brief EwokPlus25 low level API function definition
+ */
+
+
+#include "vl53l1_ll_def.h"
+#include "vl53l1_ll_device.h"
+#include "vl53l1_platform.h"
+#include "vl53l1_register_map.h"
+#include "vl53l1_register_funcs.h"
+#include "vl53l1_register_settings.h"
+#include "vl53l1_core.h"
+#include "vl53l1_wait.h"
+#include "vl53l1_api_preset_modes.h"
+#include "vl53l1_silicon_core.h"
+#include "vl53l1_api_core.h"
+#include "vl53l1_api_calibration.h"
+
+#ifdef VL53L1_LOG_ENABLE
+ #include "vl53l1_api_debug.h"
+#endif
+#ifdef VL53L1_LOGGING
+ #include "vl53l1_debug.h"
+#endif
+
+#define LOG_FUNCTION_START(fmt, ...) \
+ _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
+#define LOG_FUNCTION_END(status, ...) \
+ _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
+#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
+ _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE, status, \
+ fmt, ##__VA_ARGS__)
+
+#define trace_print(level, ...) \
+ _LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_CORE, \
+ level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
+
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_run_ref_spad_char(
+ VL53L1_DEV Dev,
+ VL53L1_Error *pcal_status)
+{
+ /*
+ * Runs Reference SPAD Characterisation
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint8_t comms_buffer[6];
+
+ VL53L1_refspadchar_config_t *prefspadchar = &(pdev->refspadchar);
+
+ LOG_FUNCTION_START("");
+
+ /*
+ * Ensure power force is enabled
+ */
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_enable_powerforce(Dev);
+
+ /*
+ * Configure device
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_set_ref_spad_char_config(
+ Dev,
+ prefspadchar->vcsel_period,
+ prefspadchar->timeout_us,
+ prefspadchar->target_count_rate_mcps,
+ prefspadchar->max_count_rate_limit_mcps,
+ prefspadchar->min_count_rate_limit_mcps,
+ pdev->stat_nvm.osc_measured__fast_osc__frequency);
+
+ /*
+ * Run device test
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_run_device_test(
+ Dev,
+ prefspadchar->device_test_mode);
+
+ /*
+ * Read results
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_ReadMulti(
+ Dev,
+ VL53L1_REF_SPAD_CHAR_RESULT__NUM_ACTUAL_REF_SPADS,
+ comms_buffer,
+ 2);
+
+ if (status == VL53L1_ERROR_NONE) {
+ pdev->dbg_results.ref_spad_char_result__num_actual_ref_spads =
+ comms_buffer[0];
+ pdev->dbg_results.ref_spad_char_result__ref_location =
+ comms_buffer[1];
+ }
+
+ /*
+ * copy results to customer nvm managed G02 registers
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_WriteMulti(
+ Dev,
+ VL53L1_REF_SPAD_MAN__NUM_REQUESTED_REF_SPADS,
+ comms_buffer,
+ 2);
+
+ if (status == VL53L1_ERROR_NONE) {
+ pdev->customer.ref_spad_man__num_requested_ref_spads =
+ comms_buffer[0];
+ pdev->customer.ref_spad_man__ref_location =
+ comms_buffer[1];
+ }
+
+ /* After Ref Spad Char the final set of good SPAD enables
+ * are stored in the NCY results registers below
+ *
+ * - RESULT__SPARE_0_SD_1
+ * - RESULT__SPARE_1_SD_1
+ * - RESULT__SPARE_2_SD_1
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_ReadMulti(
+ Dev,
+ VL53L1_RESULT__SPARE_0_SD1,
+ comms_buffer,
+ 6);
+
+ /*
+ * copy reference SPAD enables to customer nvm managed
+ * G02 registers
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_WriteMulti(
+ Dev,
+ VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_REF_0,
+ comms_buffer,
+ 6);
+
+ if (status == VL53L1_ERROR_NONE) {
+ pdev->customer.global_config__spad_enables_ref_0 =
+ comms_buffer[0];
+ pdev->customer.global_config__spad_enables_ref_1 =
+ comms_buffer[1];
+ pdev->customer.global_config__spad_enables_ref_2 =
+ comms_buffer[2];
+ pdev->customer.global_config__spad_enables_ref_3 =
+ comms_buffer[3];
+ pdev->customer.global_config__spad_enables_ref_4 =
+ comms_buffer[4];
+ pdev->customer.global_config__spad_enables_ref_5 =
+ comms_buffer[5];
+ }
+
+#ifdef VL53L1_LOG_ENABLE
+ /* Print customer nvm managed data */
+ if (status == VL53L1_ERROR_NONE)
+ VL53L1_print_customer_nvm_managed(
+ &(pdev->customer),
+ "run_ref_spad_char():pdev->lldata.customer.",
+ VL53L1_TRACE_MODULE_REF_SPAD_CHAR);
+#endif
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ switch (pdev->sys_results.result__range_status) {
+
+ case VL53L1_DEVICEERROR_REFSPADCHARNOTENOUGHDPADS:
+ status = VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS;
+ break;
+
+ case VL53L1_DEVICEERROR_REFSPADCHARMORETHANTARGET:
+ status = VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH;
+ break;
+
+ case VL53L1_DEVICEERROR_REFSPADCHARLESSTHANTARGET:
+ status = VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW;
+ break;
+ }
+ }
+
+ /*
+ * Save unfiltered status
+ */
+
+ *pcal_status = status;
+
+ /* Status exception code */
+
+ IGNORE_STATUS(
+ IGNORE_REF_SPAD_CHAR_NOT_ENOUGH_SPADS,
+ VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS,
+ status);
+
+ IGNORE_STATUS(
+ IGNORE_REF_SPAD_CHAR_RATE_TOO_HIGH,
+ VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH,
+ status);
+
+ IGNORE_STATUS(
+ IGNORE_REF_SPAD_CHAR_RATE_TOO_LOW,
+ VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW,
+ status);
+
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+VL53L1_Error VL53L1_run_offset_calibration(
+ VL53L1_DEV Dev,
+ int16_t cal_distance_mm,
+ VL53L1_Error *pcal_status)
+{
+ /*
+ * Runs offset calibration
+ *
+ * Recommended tuning parm settings:
+ *
+ * - pre_num_of_samples = 32
+ * - mm1_num_of_samples = 100
+ * - mm2_num_of_samples = 64
+ * - target_distance_mm = 140mm
+ * - target reflectance = 5%
+ *
+ * Standard Ranging (sigma delta mode):
+ * - dss_config__target_total_rate_mcps = 20.0 -40.0 Mcps
+ * - phasecal_config_timeout_us = 1000
+ * - range_config_timeout_us = 13000
+ * - mm_config_timeout_us = 13000
+ *
+ *
+ * Note: function parms simplified as part of
+ * Patch_CalFunctionSimplification_11791
+ *
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ VL53L1_DevicePresetModes device_preset_modes[VL53L1_MAX_OFFSET_RANGE_RESULTS];
+
+ VL53L1_range_results_t range_results;
+ VL53L1_range_results_t *prange_results = &range_results;
+ VL53L1_range_data_t *prange_data = NULL;
+ VL53L1_offset_range_data_t *poffset = NULL;
+
+ uint8_t i = 0;
+ uint8_t m = 0;
+ uint8_t measurement_mode =
+ VL53L1_DEVICEMEASUREMENTMODE_BACKTOBACK;
+ uint16_t manual_effective_spads =
+ pdev->gen_cfg.dss_config__manual_effective_spads_select;
+
+ uint8_t num_of_samples[VL53L1_MAX_OFFSET_RANGE_RESULTS];
+
+ LOG_FUNCTION_START("");
+
+ /* select requested offset calibration mode */
+
+ switch (pdev->offset_calibration_mode) {
+
+ default:
+ device_preset_modes[0] =
+ VL53L1_DEVICEPRESETMODE_STANDARD_RANGING;
+ device_preset_modes[1] =
+ VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM1_CAL;
+ device_preset_modes[2] =
+ VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM2_CAL;
+ break;
+ }
+
+ /* initialise num_of_samples */
+ /* Start Patch_CalFunctionSimplification_11791 */
+ num_of_samples[0] = pdev->offsetcal_cfg.pre_num_of_samples;
+ num_of_samples[1] = pdev->offsetcal_cfg.mm1_num_of_samples;
+ num_of_samples[2] = pdev->offsetcal_cfg.mm2_num_of_samples;
+ /* End Patch_CalFunctionSimplification_11791 */
+
+ /* force all offsets to zero */
+
+ switch (pdev->offset_calibration_mode) {
+
+ case VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD_PRE_RANGE_ONLY:
+ /* only run pre range */
+ pdev->offset_results.active_results = 1;
+
+ break;
+
+ default:
+
+ pdev->customer.mm_config__inner_offset_mm = 0;
+ pdev->customer.mm_config__outer_offset_mm = 0;
+ pdev->offset_results.active_results =
+ VL53L1_MAX_OFFSET_RANGE_RESULTS;
+
+ break;
+ }
+
+ pdev->customer.algo__part_to_part_range_offset_mm = 0;
+
+ /* initialise offset range results */
+
+ pdev->offset_results.max_results = VL53L1_MAX_OFFSET_RANGE_RESULTS;
+ pdev->offset_results.cal_distance_mm = cal_distance_mm;
+
+ for (m = 0 ; m < VL53L1_MAX_OFFSET_RANGE_RESULTS; m++) {
+
+ poffset = &(pdev->offset_results.data[m]);
+ poffset->preset_mode = 0;
+ poffset->no_of_samples = 0;
+ poffset->effective_spads = 0;
+ poffset->peak_rate_mcps = 0;
+ poffset->sigma_mm = 0;
+ poffset->median_range_mm = 0;
+ }
+
+ for (m = 0 ; m < pdev->offset_results.active_results ; m++) {
+
+ poffset = &(pdev->offset_results.data[m]);
+
+ poffset->preset_mode = device_preset_modes[m];
+
+ /* Apply preset mode */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_set_preset_mode(
+ Dev,
+ device_preset_modes[m],
+ /* Start Patch_CalFunctionSimplification_11791 */
+ pdev->offsetcal_cfg.dss_config__target_total_rate_mcps,
+ pdev->offsetcal_cfg.phasecal_config_timeout_us,
+ pdev->offsetcal_cfg.mm_config_timeout_us,
+ pdev->offsetcal_cfg.range_config_timeout_us,
+ /* End Patch_CalFunctionSimplification_11791 */
+ 100);
+
+ pdev->gen_cfg.dss_config__manual_effective_spads_select =
+ manual_effective_spads;
+
+ /* Initialise device and start range */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_init_and_start_range(
+ Dev,
+ measurement_mode,
+ VL53L1_DEVICECONFIGLEVEL_CUSTOMER_ONWARDS);
+
+ for (i = 0 ; i <= (num_of_samples[m]+2) ; i++) {
+
+ /* Wait for range completion */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_wait_for_range_completion(Dev);
+
+ /*
+ * Get Device Results
+ * - Checks the stream count is the expected one
+ * - Read device system results
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_get_device_results(
+ Dev,
+ VL53L1_DEVICERESULTSLEVEL_FULL,
+ prange_results);
+
+ /*
+ * Ignore 1st two ranges to give the sigma delta initial
+ * phase time to settle
+ *
+ * accummulate range results if range is successful
+ */
+
+ prange_data = &(prange_results->data[0]);
+
+ if (prange_results->stream_count > 1) {
+
+ if (prange_data->range_status ==
+ VL53L1_DEVICEERROR_RANGECOMPLETE) {
+
+ poffset->no_of_samples++;
+ poffset->effective_spads +=
+ (uint32_t)prange_data->actual_effective_spads;
+ poffset->peak_rate_mcps +=
+ (uint32_t)prange_data->peak_signal_count_rate_mcps;
+ poffset->sigma_mm +=
+ (uint32_t)prange_data->sigma_mm;
+ poffset->median_range_mm +=
+ (int32_t)prange_data->median_range_mm;
+
+ poffset->dss_config__roi_mode_control =
+ pdev->gen_cfg.dss_config__roi_mode_control;
+ poffset->dss_config__manual_effective_spads_select =
+ pdev->gen_cfg.dss_config__manual_effective_spads_select;
+ }
+ }
+
+ /*
+ * Conditional wait for firmware ready. Only waits for timed
+ * and single shot modes. Mode check is performed inside the
+ * wait function
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_wait_for_firmware_ready(Dev);
+
+ /*
+ * Send ranging handshake
+ *
+ * - Update Zone management
+ * - Update GPH registers
+ * - Clear current interrupt
+ * - Initialise SYSTEM__MODE_START for next range (if there is one!)
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_clear_interrupt_and_enable_next_range(
+ Dev,
+ measurement_mode);
+ }
+
+ /* Stop range */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_stop_range(Dev);
+
+ /* Wait for Stop (abort) range to complete */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WaitUs(Dev, 1000);
+
+ /* generate average values */
+ if (poffset->no_of_samples > 0) {
+
+ poffset->effective_spads += (poffset->no_of_samples/2);
+ poffset->effective_spads /= poffset->no_of_samples;
+
+ poffset->peak_rate_mcps += (poffset->no_of_samples/2);
+ poffset->peak_rate_mcps /= poffset->no_of_samples;
+
+ poffset->sigma_mm += (poffset->no_of_samples/2);
+ poffset->sigma_mm /= poffset->no_of_samples;
+
+ poffset->median_range_mm += (poffset->no_of_samples/2);
+ poffset->median_range_mm /= poffset->no_of_samples;
+
+ poffset->range_mm_offset = (int32_t)cal_distance_mm;
+ poffset->range_mm_offset -= poffset->median_range_mm;
+
+ /* remember the number of SPADs for standard ranging */
+ if (poffset->preset_mode ==
+ VL53L1_DEVICEPRESETMODE_STANDARD_RANGING)
+ manual_effective_spads =
+ (uint16_t)poffset->effective_spads;
+ }
+ }
+
+ /* Calculate offsets */
+
+ switch (pdev->offset_calibration_mode) {
+
+ case VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD_PRE_RANGE_ONLY:
+
+ /* copy offsets to customer data structure */
+ pdev->customer.mm_config__inner_offset_mm +=
+ (int16_t)pdev->offset_results.data[0].range_mm_offset;
+ pdev->customer.mm_config__outer_offset_mm +=
+ (int16_t)pdev->offset_results.data[0].range_mm_offset;
+ break;
+
+ default:
+ /* copy offsets to customer data structure */
+ pdev->customer.mm_config__inner_offset_mm =
+ (int16_t)pdev->offset_results.data[1].range_mm_offset;
+ pdev->customer.mm_config__outer_offset_mm =
+ (int16_t)pdev->offset_results.data[2].range_mm_offset;
+ pdev->customer.algo__part_to_part_range_offset_mm = 0;
+
+ /* copy average rate and effective SPAD count to
+ additional offset calibration data structure */
+
+ pdev->add_off_cal_data.result__mm_inner_actual_effective_spads =
+ (uint16_t)pdev->offset_results.data[1].effective_spads;
+ pdev->add_off_cal_data.result__mm_outer_actual_effective_spads =
+ (uint16_t)pdev->offset_results.data[2].effective_spads;
+
+ pdev->add_off_cal_data.result__mm_inner_peak_signal_count_rtn_mcps =
+ (uint16_t)pdev->offset_results.data[1].peak_rate_mcps;
+ pdev->add_off_cal_data.result__mm_outer_peak_signal_count_rtn_mcps =
+ (uint16_t)pdev->offset_results.data[2].peak_rate_mcps;
+
+ break;
+ }
+
+
+ /* apply to device */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_set_customer_nvm_managed(
+ Dev,
+ &(pdev->customer));
+
+ /*
+ * Check the peak rates, sigma, min spads for each stage
+ */
+
+ for (m = 0 ; m < pdev->offset_results.active_results ; m++) {
+
+ poffset = &(pdev->offset_results.data[m]);
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ pdev->offset_results.cal_report = m;
+
+ if (poffset->no_of_samples < num_of_samples[m])
+ status = VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES;
+
+ /* only check sigma for the pre-range as
+ * the it is not calculated by the device
+ * for the MM1 and MM2 stages
+ */
+ if (m == 0 && poffset->sigma_mm >
+ ((uint32_t)VL53L1_OFFSET_CAL_MAX_SIGMA_MM<<5))
+ status = VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH;
+
+ if (poffset->peak_rate_mcps >
+ VL53L1_OFFSET_CAL_MAX_PRE_PEAK_RATE_MCPS)
+ status = VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH;
+
+ if (poffset->dss_config__manual_effective_spads_select <
+ VL53L1_OFFSET_CAL_MIN_EFFECTIVE_SPADS)
+ status = VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW;
+
+ if (poffset->dss_config__manual_effective_spads_select == 0)
+ status = VL53L1_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL;
+
+ if (poffset->no_of_samples == 0)
+ status = VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL;
+ }
+ }
+
+ /*
+ * Save unfiltered status
+ */
+
+ pdev->offset_results.cal_status = status;
+ *pcal_status = pdev->offset_results.cal_status;
+
+ /* Status exception codes */
+
+ IGNORE_STATUS(
+ IGNORE_OFFSET_CAL_MISSING_SAMPLES,
+ VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES,
+ status);
+
+ IGNORE_STATUS(
+ IGNORE_OFFSET_CAL_SIGMA_TOO_HIGH,
+ VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH,
+ status);
+
+ IGNORE_STATUS(
+ IGNORE_OFFSET_CAL_RATE_TOO_HIGH,
+ VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH,
+ status);
+
+ IGNORE_STATUS(
+ IGNORE_OFFSET_CAL_SPAD_COUNT_TOO_LOW,
+ VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW,
+ status);
+
+#ifdef VL53L1_LOG_ENABLE
+
+ /* Prints out the offset calibration data for debug */
+
+ VL53L1_print_customer_nvm_managed(
+ &(pdev->customer),
+ "run_offset_calibration():pdev->lldata.customer.",
+ VL53L1_TRACE_MODULE_OFFSET_DATA);
+
+ VL53L1_print_additional_offset_cal_data(
+ &(pdev->add_off_cal_data),
+ "run_offset_calibration():pdev->lldata.add_off_cal_data.",
+ VL53L1_TRACE_MODULE_OFFSET_DATA);
+
+ VL53L1_print_offset_range_results(
+ &(pdev->offset_results),
+ "run_offset_calibration():pdev->lldata.offset_results.",
+ VL53L1_TRACE_MODULE_OFFSET_DATA);
+#endif
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_run_spad_rate_map(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceTestMode device_test_mode,
+ VL53L1_DeviceSscArray array_select,
+ uint32_t ssc_config_timeout_us,
+ VL53L1_spad_rate_data_t *pspad_rate_data)
+{
+
+ /**
+ * Runs SPAD Rate Map
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ /*
+ * Ensure power force is enabled
+ */
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_powerforce(Dev);
+
+ /*
+ * Configure the test
+ */
+
+ if (status == VL53L1_ERROR_NONE) {
+ pdev->ssc_cfg.array_select = array_select;
+ pdev->ssc_cfg.timeout_us = ssc_config_timeout_us;
+ status =
+ VL53L1_set_ssc_config(
+ Dev,
+ &(pdev->ssc_cfg),
+ pdev->stat_nvm.osc_measured__fast_osc__frequency);
+ }
+
+ /*
+ * Run device test
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_run_device_test(
+ Dev,
+ device_test_mode);
+
+ /*
+ * Read Rate Data from Patch Ram
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_get_spad_rate_data(
+ Dev,
+ pspad_rate_data);
+
+ if (device_test_mode == VL53L1_DEVICETESTMODE_LCR_VCSEL_ON)
+ pspad_rate_data->fractional_bits = 7;
+ else
+ pspad_rate_data->fractional_bits = 15;
+
+ /* Ensure power force is disabled */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_disable_powerforce(Dev);
+
+#ifdef VL53L1_LOG_ENABLE
+ /* Print return rate data and map */
+
+ if (status == VL53L1_ERROR_NONE) {
+ VL53L1_print_spad_rate_data(
+ pspad_rate_data,
+ "run_spad_rate_map():",
+ VL53L1_TRACE_MODULE_SPAD_RATE_MAP);
+ VL53L1_print_spad_rate_map(
+ pspad_rate_data,
+ "run_spad_rate_map():",
+ VL53L1_TRACE_MODULE_SPAD_RATE_MAP);
+ }
+#endif
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_run_device_test(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceTestMode device_test_mode)
+{
+ /*
+ * Runs the selected Device Test Mode
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint8_t comms_buffer[2];
+ uint8_t gpio_hv_mux__ctrl = 0;
+
+ LOG_FUNCTION_START("");
+
+ /*
+ * Get current interrupt config
+ */
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status =
+ VL53L1_RdByte(
+ Dev,
+ VL53L1_GPIO_HV_MUX__CTRL,
+ &gpio_hv_mux__ctrl);
+
+ if (status == VL53L1_ERROR_NONE)
+ pdev->stat_cfg.gpio_hv_mux__ctrl = gpio_hv_mux__ctrl;
+
+ /*
+ * Trigger the test
+ */
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_start_test(
+ Dev,
+ device_test_mode);
+
+ /*
+ * Wait for test completion
+ */
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_wait_for_test_completion(Dev);
+
+ /*
+ * Read range and report status
+ */
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_ReadMulti(
+ Dev,
+ VL53L1_RESULT__RANGE_STATUS,
+ comms_buffer,
+ 2);
+
+ if (status == VL53L1_ERROR_NONE) {
+ pdev->sys_results.result__range_status = comms_buffer[0];
+ pdev->sys_results.result__report_status = comms_buffer[1];
+ }
+
+ /* mask range status bits */
+
+ pdev->sys_results.result__range_status &=
+ VL53L1_RANGE_STATUS__RANGE_STATUS_MASK;
+
+ if (status == VL53L1_ERROR_NONE) {
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ " Device Test Complete:\n\t%-32s = %3u\n\t%-32s = %3u\n",
+ "result__range_status",
+ pdev->sys_results.result__range_status,
+ "result__report_status",
+ pdev->sys_results.result__report_status);
+
+ /*
+ * Clear interrupt
+ */
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_clear_interrupt(Dev);
+ }
+
+ /*
+ * Clear test mode register
+ * - required so that next test command will trigger
+ * internal MCU interrupt
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_start_test(
+ Dev,
+ 0x00);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api_core.c b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api_core.c
new file mode 100644
index 0000000..993af44
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api_core.c
@@ -0,0 +1,3540 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_api_core.c
+ *
+ * @brief EwokPlus25 low level API function definition
+ */
+
+
+#include "vl53l1_ll_def.h"
+#include "vl53l1_ll_device.h"
+#include "vl53l1_platform.h"
+#include "vl53l1_register_map.h"
+#include "vl53l1_register_settings.h"
+#include "vl53l1_register_funcs.h"
+#include "vl53l1_nvm_map.h"
+#include "vl53l1_core.h"
+#include "vl53l1_wait.h"
+#include "vl53l1_api_preset_modes.h"
+#include "vl53l1_silicon_core.h"
+#include "vl53l1_api_core.h"
+#include "vl53l1_tuning_parm_defaults.h"
+
+#ifdef VL53L1_LOG_ENABLE
+#include "vl53l1_api_debug.h"
+#endif
+
+#define LOG_FUNCTION_START(fmt, ...) \
+ _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
+#define LOG_FUNCTION_END(status, ...) \
+ _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
+#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
+ _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE, status, \
+ fmt, ##__VA_ARGS__)
+
+#define trace_print(level, ...) \
+ _LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_CORE, \
+ level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
+
+#define VL53L1_MAX_I2C_XFER_SIZE 256
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_get_version(
+ VL53L1_DEV Dev,
+ VL53L1_ll_version_t *pdata)
+{
+ /*
+ * respond with the #define values from version.h
+ * using memcpy(dst, src, size in bytes)
+ */
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ VL53L1_init_version(Dev);
+
+ memcpy(pdata, &(pdev->version), sizeof(VL53L1_ll_version_t));
+
+ return VL53L1_ERROR_NONE;
+}
+
+VL53L1_Error VL53L1_get_device_firmware_version(
+ VL53L1_DEV Dev,
+ uint16_t *pfw_version)
+{
+ /*
+ * Read Firmware version from device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_RdWord(
+ Dev,
+ VL53L1_MCU_GENERAL_PURPOSE__GP_0,
+ pfw_version);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_data_init(
+ VL53L1_DEV Dev,
+ uint8_t read_p2p_data)
+{
+ /*
+ * Initialise pdev data structure
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ VL53L1_init_ll_driver_state(
+ Dev,
+ VL53L1_DEVICESTATE_UNKNOWN);
+
+ pdev->wait_method = VL53L1_WAIT_METHOD_BLOCKING;
+ pdev->preset_mode = VL53L1_DEVICEPRESETMODE_STANDARD_RANGING;
+ pdev->measurement_mode = VL53L1_DEVICEMEASUREMENTMODE_STOP;
+
+ pdev->offset_calibration_mode =
+ VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD;
+ pdev->offset_correction_mode =
+ VL53L1_OFFSETCORRECTIONMODE__MM1_MM2_OFFSETS;
+
+ pdev->phasecal_config_timeout_us = 1000;
+ pdev->mm_config_timeout_us = 2000;
+ pdev->range_config_timeout_us = 13000;
+ pdev->inter_measurement_period_ms = 100;
+ pdev->dss_config__target_total_rate_mcps = 0x0A00;
+ pdev->debug_mode = 0x00;
+
+ /* initialise gain calibration values to tuning parameter values */
+
+ pdev->gain_cal.standard_ranging_gain_factor =
+ VL53L1_TUNINGPARM_LITE_RANGING_GAIN_FACTOR_DEFAULT;
+
+ /*
+ * Initialise version structure
+ */
+ VL53L1_init_version(Dev);
+
+ /*
+ * For C-API one time initialization only read device G02 registers
+ * containing data copied from NVM
+ *
+ * Contains the key NVM data e.g identification info fast oscillator
+ * freq, max trim and laser safety info
+ */
+
+ if (read_p2p_data > 0 && status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_read_p2p_data(Dev);
+
+ /* Initialise Ref SPAD Char configuration structure */
+#ifndef VL53L1_NOCALIB
+ status =
+ VL53L1_init_refspadchar_config_struct(
+ &(pdev->refspadchar));
+#endif
+
+ /* Initialise SPAD Self Check (SSC) configuration structure */
+#ifndef VL53L1_NOCALIB
+ status =
+ VL53L1_init_ssc_config_struct(
+ &(pdev->ssc_cfg));
+#endif
+
+ /* Initialise Private Xtalk configuration structure
+ * - Fill with customer NVM data to begin
+ */
+ status =
+ VL53L1_init_xtalk_config_struct(
+ &(pdev->customer),
+ &(pdev->xtalk_cfg));
+
+ /* Initialise Offset Calibration configuration structure
+ */
+#ifndef VL53L1_NOCALIB
+ status =
+ VL53L1_init_offset_cal_config_struct(
+ &(pdev->offsetcal_cfg));
+#endif
+
+ /* Initialise Tuning Parameter structure
+ * - Added as part of Patch_AddingTuningParmStorage_11821
+ */
+ status =
+ VL53L1_init_tuning_parm_storage_struct(
+ &(pdev->tuning_parms));
+
+ status = VL53L1_set_vhv_loopbound(Dev,
+ VL53L1_TUNINGPARM_VHV_LOOPBOUND_DEFAULT);
+
+ /*
+ * Initialise default settings - much happen *after*
+ * reading /setting of static_nvm_managed
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_set_preset_mode(
+ Dev,
+ pdev->preset_mode,
+ pdev->dss_config__target_total_rate_mcps, /* 9.7 format 20Mcps */
+ pdev->phasecal_config_timeout_us,
+ pdev->mm_config_timeout_us,
+ pdev->range_config_timeout_us,
+ pdev->inter_measurement_period_ms);
+
+ /* Initial Low Power Auto Mode data structures */
+ /* Added for Patch_LowPowerAutoMode */
+ VL53L1_low_power_auto_data_init(
+ Dev
+ );
+
+#ifdef VL53L1_LOG_ENABLE
+
+ /* Prints out the initial calibration data for debug */
+
+ VL53L1_print_static_nvm_managed(
+ &(pdev->stat_nvm),
+ "data_init():pdev->lldata.stat_nvm.",
+ VL53L1_TRACE_MODULE_DATA_INIT);
+
+ VL53L1_print_customer_nvm_managed(
+ &(pdev->customer),
+ "data_init():pdev->lldata.customer.",
+ VL53L1_TRACE_MODULE_DATA_INIT);
+
+ VL53L1_print_nvm_copy_data(
+ &(pdev->nvm_copy_data),
+ "data_init():pdev->lldata.nvm_copy_data.",
+ VL53L1_TRACE_MODULE_DATA_INIT);
+
+ VL53L1_print_additional_offset_cal_data(
+ &(pdev->add_off_cal_data),
+ "data_init():pdev->lldata.add_off_cal_data.",
+ VL53L1_TRACE_MODULE_DATA_INIT);
+
+ VL53L1_print_user_zone(
+ &(pdev->mm_roi),
+ "data_init():pdev->lldata.mm_roi.",
+ VL53L1_TRACE_MODULE_DATA_INIT);
+
+ VL53L1_print_optical_centre(
+ &(pdev->optical_centre),
+ "data_init():pdev->lldata.optical_centre.",
+ VL53L1_TRACE_MODULE_DATA_INIT);
+
+ VL53L1_print_cal_peak_rate_map(
+ &(pdev->cal_peak_rate_map),
+ "data_init():pdev->lldata.cal_peak_rate_map.",
+ VL53L1_TRACE_MODULE_DATA_INIT);
+
+#endif
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_read_p2p_data(
+ VL53L1_DEV Dev)
+{
+
+ /*
+ * For C-API one time initialization only reads device
+ * G02 registers containing data copied from NVM
+ *
+ * Contains the key NVM data e.g identification info
+ * fast oscillator freq, max trim and laser safety info
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_get_static_nvm_managed(
+ Dev,
+ &(pdev->stat_nvm));
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_get_customer_nvm_managed(
+ Dev,
+ &(pdev->customer));
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ status = VL53L1_get_nvm_copy_data(
+ Dev,
+ &(pdev->nvm_copy_data));
+
+ /* copy Return Good SPADs to buffer */
+ if (status == VL53L1_ERROR_NONE)
+ VL53L1_copy_rtn_good_spads_to_buffer(
+ &(pdev->nvm_copy_data),
+ &(pdev->rtn_good_spads[0]));
+ }
+
+ /*
+ * read slow osc calibration value
+ * counts per ms
+ */
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_RdWord(
+ Dev,
+ VL53L1_RESULT__OSC_CALIBRATE_VAL,
+ &(pdev->dbg_results.result__osc_calibrate_val));
+
+ /*
+ * Check if there a sensible value for osc_measured__fast_osc__frequency
+ */
+
+ if (pdev->stat_nvm.osc_measured__fast_osc__frequency < 0x1000) {
+ trace_print(
+ VL53L1_TRACE_LEVEL_WARNING,
+ "\nInvalid %s value (0x%04X) - forcing to 0x%04X\n\n",
+ "pdev->stat_nvm.osc_measured__fast_osc__frequency",
+ pdev->stat_nvm.osc_measured__fast_osc__frequency,
+ 0xBCCC);
+ pdev->stat_nvm.osc_measured__fast_osc__frequency = 0xBCCC;
+ }
+
+ /*
+ * Get MM ROI - contains optical centre as SPAD number
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_get_mode_mitigation_roi(
+ Dev,
+ &(pdev->mm_roi));
+
+ /* catch parts where the optical centre is
+ * no programmed in to the NVM
+ */
+
+ if (pdev->optical_centre.x_centre == 0 &&
+ pdev->optical_centre.y_centre == 0) {
+ pdev->optical_centre.x_centre =
+ pdev->mm_roi.x_centre << 4;
+ pdev->optical_centre.y_centre =
+ pdev->mm_roi.y_centre << 4;
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_software_reset(
+ VL53L1_DEV Dev)
+{
+ /**
+ * Sets and clears the software reset register VL53L1_SOFT_RESET.
+ * and waits for the firmware to boot
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* apply reset - note despite the name soft reset is active low! */
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_WrByte(
+ Dev,
+ VL53L1_SOFT_RESET,
+ 0x00);
+
+ /* wait for a while before releasing the reset */
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_WaitUs(
+ Dev,
+ VL53L1_SOFTWARE_RESET_DURATION_US);
+
+ /* release reset */
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WrByte(
+ Dev,
+ VL53L1_SOFT_RESET,
+ 0x01);
+
+ /* wait for firmware boot to complete */
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_wait_for_boot_completion(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_part_to_part_data(
+ VL53L1_DEV Dev,
+ VL53L1_calibration_data_t *pcal_data)
+{
+ /**
+ * Uses memcpy to copy input data to pdev->customer
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint32_t tempu32;
+
+ LOG_FUNCTION_START("");
+
+ if (pcal_data->struct_version !=
+ VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION) {
+ status = VL53L1_ERROR_INVALID_PARAMS;
+ }
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ /* memcpy(DEST, SRC, N) */
+ memcpy(
+ &(pdev->customer),
+ &(pcal_data->customer),
+ sizeof(VL53L1_customer_nvm_managed_t));
+
+ /* memcpy(DEST, SRC, N) */
+ memcpy(
+ &(pdev->add_off_cal_data),
+ &(pcal_data->add_off_cal_data),
+ sizeof(VL53L1_additional_offset_cal_data_t));
+
+ /* memcpy(DEST, SRC, N) */
+ memcpy(
+ &(pdev->gain_cal),
+ &(pcal_data->gain_cal),
+ sizeof(VL53L1_gain_calibration_data_t));
+
+ /* memcpy(DEST, SRC, N) */
+ memcpy(
+ &(pdev->cal_peak_rate_map),
+ &(pcal_data->cal_peak_rate_map),
+ sizeof(VL53L1_cal_peak_rate_map_t));
+
+ /*
+ * Update internal xtalk data structures
+ */
+
+ pdev->xtalk_cfg.algo__crosstalk_compensation_plane_offset_kcps =
+ pdev->customer.algo__crosstalk_compensation_plane_offset_kcps;
+ pdev->xtalk_cfg.algo__crosstalk_compensation_x_plane_gradient_kcps =
+ pdev->customer.algo__crosstalk_compensation_x_plane_gradient_kcps;
+ pdev->xtalk_cfg.algo__crosstalk_compensation_y_plane_gradient_kcps =
+ pdev->customer.algo__crosstalk_compensation_y_plane_gradient_kcps;
+
+ /* Assess and update customer packet xtalk parameters */
+
+ if (pdev->xtalk_cfg.global_crosstalk_compensation_enable == 0x00) {
+ pdev->customer.algo__crosstalk_compensation_plane_offset_kcps =
+ 0x00;
+ pdev->customer.algo__crosstalk_compensation_x_plane_gradient_kcps =
+ 0x00;
+ pdev->customer.algo__crosstalk_compensation_y_plane_gradient_kcps =
+ 0x00;
+ } else {
+ tempu32 = VL53L1_calc_crosstalk_plane_offset_with_margin(
+ pdev->xtalk_cfg.algo__crosstalk_compensation_plane_offset_kcps,
+ pdev->xtalk_cfg.lite_mode_crosstalk_margin_kcps);
+ if (tempu32 > 0xFFFF) { /* clip to 16 bits */
+ tempu32 = 0xFFFF;
+ }
+ pdev->customer.algo__crosstalk_compensation_plane_offset_kcps =
+ (uint16_t)tempu32;
+ }
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_get_part_to_part_data(
+ VL53L1_DEV Dev,
+ VL53L1_calibration_data_t *pcal_data)
+{
+ /**
+ * Uses memcpy to copy pdev->customer to output data
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ pcal_data->struct_version =
+ VL53L1_LL_CALIBRATION_DATA_STRUCT_VERSION;
+
+ /* memcpy(DEST, SRC, N) */
+ memcpy(
+ &(pcal_data->customer),
+ &(pdev->customer),
+ sizeof(VL53L1_customer_nvm_managed_t));
+
+ /* Overwrite Struct with xtalk config parameters */
+ /* - customer struct versions are not golden copy */
+
+ if (pdev->xtalk_cfg.algo__crosstalk_compensation_plane_offset_kcps > 0xFFFF) {
+ pcal_data->customer.algo__crosstalk_compensation_plane_offset_kcps =
+ 0xFFFF;
+ } else {
+ pcal_data->customer.algo__crosstalk_compensation_plane_offset_kcps =
+ (uint16_t)pdev->xtalk_cfg.algo__crosstalk_compensation_plane_offset_kcps;
+ }
+ pcal_data->customer.algo__crosstalk_compensation_x_plane_gradient_kcps =
+ pdev->xtalk_cfg.algo__crosstalk_compensation_x_plane_gradient_kcps;
+ pcal_data->customer.algo__crosstalk_compensation_y_plane_gradient_kcps =
+ pdev->xtalk_cfg.algo__crosstalk_compensation_y_plane_gradient_kcps;
+
+ /* memcpy(DEST, SRC, N) */
+ memcpy(
+ &(pcal_data->add_off_cal_data),
+ &(pdev->add_off_cal_data),
+ sizeof(VL53L1_additional_offset_cal_data_t));
+
+ /* memcpy(DEST, SRC, N) */
+ memcpy(
+ &(pcal_data->optical_centre),
+ &(pdev->optical_centre),
+ sizeof(VL53L1_optical_centre_t));
+
+ /* memcpy(DEST, SRC, N) */
+ memcpy(
+ &(pcal_data->gain_cal),
+ &(pdev->gain_cal),
+ sizeof(VL53L1_gain_calibration_data_t));
+
+ /* memcpy(DEST, SRC, N) */
+ memcpy(
+ &(pcal_data->cal_peak_rate_map),
+ &(pdev->cal_peak_rate_map),
+ sizeof(VL53L1_cal_peak_rate_map_t));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_inter_measurement_period_ms(
+ VL53L1_DEV Dev,
+ uint32_t inter_measurement_period_ms)
+{
+ /**
+ * Convenience function for setting the inter measurement period
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ if (pdev->dbg_results.result__osc_calibrate_val == 0)
+ status = VL53L1_ERROR_DIVISION_BY_ZERO;
+
+ if (status == VL53L1_ERROR_NONE) {
+ pdev->inter_measurement_period_ms = inter_measurement_period_ms;
+ pdev->tim_cfg.system__intermeasurement_period = \
+ inter_measurement_period_ms *
+ (uint32_t)pdev->dbg_results.result__osc_calibrate_val;
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_get_inter_measurement_period_ms(
+ VL53L1_DEV Dev,
+ uint32_t *pinter_measurement_period_ms)
+{
+ /**
+ * Convenience function for getting the inter measurement period
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ if (pdev->dbg_results.result__osc_calibrate_val == 0)
+ status = VL53L1_ERROR_DIVISION_BY_ZERO;
+
+ if (status == VL53L1_ERROR_NONE)
+ *pinter_measurement_period_ms = \
+ pdev->tim_cfg.system__intermeasurement_period /
+ (uint32_t)pdev->dbg_results.result__osc_calibrate_val;
+
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_timeouts_us(
+ VL53L1_DEV Dev,
+ uint32_t phasecal_config_timeout_us,
+ uint32_t mm_config_timeout_us,
+ uint32_t range_config_timeout_us)
+{
+ /**
+ * Convenience function for setting the MM and range
+ * timeouts
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ if (pdev->stat_nvm.osc_measured__fast_osc__frequency == 0)
+ status = VL53L1_ERROR_DIVISION_BY_ZERO;
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ pdev->phasecal_config_timeout_us = phasecal_config_timeout_us;
+ pdev->mm_config_timeout_us = mm_config_timeout_us;
+ pdev->range_config_timeout_us = range_config_timeout_us;
+
+ status =
+ VL53L1_calc_timeout_register_values(
+ phasecal_config_timeout_us,
+ mm_config_timeout_us,
+ range_config_timeout_us,
+ pdev->stat_nvm.osc_measured__fast_osc__frequency,
+ &(pdev->gen_cfg),
+ &(pdev->tim_cfg));
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_get_timeouts_us(
+ VL53L1_DEV Dev,
+ uint32_t *pphasecal_config_timeout_us,
+ uint32_t *pmm_config_timeout_us,
+ uint32_t *prange_config_timeout_us)
+{
+ /**
+ * Convenience function for getting the MM and range
+ * timeouts
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint32_t macro_period_us = 0;
+ uint16_t timeout_encoded = 0;
+
+ LOG_FUNCTION_START("");
+
+ if (pdev->stat_nvm.osc_measured__fast_osc__frequency == 0)
+ status = VL53L1_ERROR_DIVISION_BY_ZERO;
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ /* Update Macro Period for Range A VCSEL Period */
+ macro_period_us =
+ VL53L1_calc_macro_period_us(
+ pdev->stat_nvm.osc_measured__fast_osc__frequency,
+ pdev->tim_cfg.range_config__vcsel_period_a);
+
+ /* Get Phase Cal Timing A timeout */
+
+ *pphasecal_config_timeout_us =
+ VL53L1_calc_timeout_us(
+ (uint32_t)pdev->gen_cfg.phasecal_config__timeout_macrop,
+ macro_period_us);
+
+ /* Get MM Timing A timeout */
+
+ timeout_encoded =
+ (uint16_t)pdev->tim_cfg.mm_config__timeout_macrop_a_hi;
+ timeout_encoded = (timeout_encoded << 8) +
+ (uint16_t)pdev->tim_cfg.mm_config__timeout_macrop_a_lo;
+
+ *pmm_config_timeout_us =
+ VL53L1_calc_decoded_timeout_us(
+ timeout_encoded,
+ macro_period_us);
+
+ /* Get Range Timing A timeout */
+
+ timeout_encoded =
+ (uint16_t)pdev->tim_cfg.range_config__timeout_macrop_a_hi;
+ timeout_encoded = (timeout_encoded << 8) +
+ (uint16_t)pdev->tim_cfg.range_config__timeout_macrop_a_lo;
+
+ *prange_config_timeout_us =
+ VL53L1_calc_decoded_timeout_us(
+ timeout_encoded,
+ macro_period_us);
+
+ pdev->phasecal_config_timeout_us = *pphasecal_config_timeout_us;
+ pdev->mm_config_timeout_us = *pmm_config_timeout_us;
+ pdev->range_config_timeout_us = *prange_config_timeout_us;
+
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_calibration_repeat_period(
+ VL53L1_DEV Dev,
+ uint16_t cal_config__repeat_period)
+{
+ /**
+ * Convenience function for setting calibration repeat period
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ pdev->gen_cfg.cal_config__repeat_rate = cal_config__repeat_period;
+
+ return status;
+
+}
+
+
+VL53L1_Error VL53L1_get_calibration_repeat_period(
+ VL53L1_DEV Dev,
+ uint16_t *pcal_config__repeat_period)
+{
+ /**
+ * Convenience function for getting calibration repeat period
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ *pcal_config__repeat_period = pdev->gen_cfg.cal_config__repeat_rate;
+
+ return status;
+
+}
+
+
+VL53L1_Error VL53L1_set_sequence_config_bit(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceSequenceConfig bit_id,
+ uint8_t value)
+{
+ /**
+ * Convenience function for setting sequence
+ * config enable bits
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint8_t bit_mask = 0x01;
+ uint8_t clr_mask = 0xFF - bit_mask;
+ uint8_t bit_value = value & bit_mask;
+
+ if (bit_id <= VL53L1_DEVICESEQUENCECONFIG_RANGE) {
+
+ if (bit_id > 0) {
+ bit_mask = 0x01 << bit_id;
+ bit_value = bit_value << bit_id;
+ clr_mask = 0xFF - bit_mask;
+ }
+
+ pdev->dyn_cfg.system__sequence_config = \
+ (pdev->dyn_cfg.system__sequence_config & clr_mask) | \
+ bit_value;
+
+ } else {
+ status = VL53L1_ERROR_INVALID_PARAMS;
+ }
+
+ return status;
+
+}
+
+
+VL53L1_Error VL53L1_get_sequence_config_bit(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceSequenceConfig bit_id,
+ uint8_t *pvalue)
+{
+ /**
+ * Convenience function for getting sequence
+ * config enable bits
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint8_t bit_mask = 0x01;
+
+ if (bit_id <= VL53L1_DEVICESEQUENCECONFIG_RANGE) {
+
+ if (bit_id > 0) {
+ bit_mask = 0x01 << bit_id;
+ }
+
+ *pvalue =
+ pdev->dyn_cfg.system__sequence_config & bit_mask;
+
+ if (bit_id > 0) {
+ *pvalue = *pvalue >> bit_id;
+ }
+
+ } else {
+ status = VL53L1_ERROR_INVALID_PARAMS;
+ }
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_interrupt_polarity(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceInterruptPolarity interrupt_polarity)
+{
+ /**
+ * Convenience function for setting interrupt polarity
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ pdev->stat_cfg.gpio_hv_mux__ctrl = \
+ (pdev->stat_cfg.gpio_hv_mux__ctrl & \
+ VL53L1_DEVICEINTERRUPTPOLARITY_CLEAR_MASK) | \
+ (interrupt_polarity & \
+ VL53L1_DEVICEINTERRUPTPOLARITY_BIT_MASK);
+
+ return status;
+
+}
+
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_set_refspadchar_config_struct(
+ VL53L1_DEV Dev,
+ VL53L1_refspadchar_config_t *pdata)
+{
+ /*
+ * Allows user config of Ref SPAD Char data structure
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ pdev->refspadchar.device_test_mode = pdata->device_test_mode;
+ pdev->refspadchar.vcsel_period = pdata->vcsel_period;
+ pdev->refspadchar.timeout_us = pdata->timeout_us;
+ pdev->refspadchar.target_count_rate_mcps =
+ pdata->target_count_rate_mcps;
+ pdev->refspadchar.min_count_rate_limit_mcps =
+ pdata->min_count_rate_limit_mcps;
+ pdev->refspadchar.max_count_rate_limit_mcps =
+ pdata->max_count_rate_limit_mcps;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_get_refspadchar_config_struct(
+ VL53L1_DEV Dev,
+ VL53L1_refspadchar_config_t *pdata)
+{
+ /*
+ * Allows user config of Ref SPAD Char data structure
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ pdata->device_test_mode = pdev->refspadchar.device_test_mode;
+ pdata->vcsel_period = pdev->refspadchar.vcsel_period;
+ pdata->timeout_us = pdev->refspadchar.timeout_us;
+ pdata->target_count_rate_mcps = pdev->refspadchar.target_count_rate_mcps;
+ pdata->min_count_rate_limit_mcps =
+ pdev->refspadchar.min_count_rate_limit_mcps;
+ pdata->max_count_rate_limit_mcps =
+ pdev->refspadchar.max_count_rate_limit_mcps;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_set_range_ignore_threshold(
+ VL53L1_DEV Dev,
+ uint8_t range_ignore_thresh_mult,
+ uint16_t range_ignore_threshold_mcps)
+{
+ /**
+ * Convenience function for setting Range Ignore Threshold
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ pdev->xtalk_cfg.crosstalk_range_ignore_threshold_rate_mcps =
+ range_ignore_threshold_mcps;
+
+ pdev->xtalk_cfg.crosstalk_range_ignore_threshold_mult =
+ range_ignore_thresh_mult;
+
+ return status;
+
+}
+
+VL53L1_Error VL53L1_get_range_ignore_threshold(
+ VL53L1_DEV Dev,
+ uint8_t *prange_ignore_thresh_mult,
+ uint16_t *prange_ignore_threshold_mcps_internal,
+ uint16_t *prange_ignore_threshold_mcps_current)
+{
+ /**
+ * Convenience function for retrieving Range Ignore Threshold
+ * - Returns both the calculated internal value
+ * - and the value currently applied to device reg settings
+ *
+ * Values both in fixed point 3.13 Mcps per spad
+ *
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ *prange_ignore_thresh_mult =
+ pdev->xtalk_cfg.crosstalk_range_ignore_threshold_mult;
+
+ *prange_ignore_threshold_mcps_current =
+ pdev->stat_cfg.algo__range_ignore_threshold_mcps;
+
+ *prange_ignore_threshold_mcps_internal =
+ pdev->xtalk_cfg.crosstalk_range_ignore_threshold_rate_mcps;
+
+ return status;
+
+}
+
+
+
+VL53L1_Error VL53L1_get_interrupt_polarity(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceInterruptPolarity *pinterrupt_polarity)
+{
+ /**
+ * Convenience function for getting interrupt polarity
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ *pinterrupt_polarity = \
+ pdev->stat_cfg.gpio_hv_mux__ctrl & \
+ VL53L1_DEVICEINTERRUPTPOLARITY_BIT_MASK ;
+
+ return status;
+
+}
+
+
+VL53L1_Error VL53L1_set_user_zone(
+ VL53L1_DEV Dev,
+ VL53L1_user_zone_t *puser_zone)
+{
+ /**
+ * Convenience function for setting the user ROI
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ /* convert (row,col) location into a SPAD number */
+ VL53L1_encode_row_col(
+ puser_zone->y_centre,
+ puser_zone->x_centre,
+ &(pdev->dyn_cfg.roi_config__user_roi_centre_spad));
+
+ /* merge x and y sizes */
+ VL53L1_encode_zone_size(
+ puser_zone->width,
+ puser_zone->height,
+ &(pdev->dyn_cfg.roi_config__user_roi_requested_global_xy_size));
+
+ /* need to add checks to ensure ROI is within array */
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_get_user_zone(
+ VL53L1_DEV Dev,
+ VL53L1_user_zone_t *puser_zone)
+{
+ /**
+ * Convenience function for getting the user ROI
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ /* convert SPAD number into (row,col) location*/
+ VL53L1_decode_row_col(
+ pdev->dyn_cfg.roi_config__user_roi_centre_spad,
+ &(puser_zone->y_centre),
+ &(puser_zone->x_centre));
+
+ /* extract x and y sizes */
+ VL53L1_decode_zone_size(
+ pdev->dyn_cfg.roi_config__user_roi_requested_global_xy_size,
+ &(puser_zone->width),
+ &(puser_zone->height));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+
+VL53L1_Error VL53L1_get_mode_mitigation_roi(
+ VL53L1_DEV Dev,
+ VL53L1_user_zone_t *pmm_roi)
+{
+ /**
+ * Convenience function for getting the mode mitigation ROI
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint8_t x = 0;
+ uint8_t y = 0;
+ uint8_t xy_size = 0;
+
+ LOG_FUNCTION_START("");
+
+ /* convert SPAD number into (row,col) location */
+ VL53L1_decode_row_col(
+ pdev->nvm_copy_data.roi_config__mode_roi_centre_spad,
+ &y,
+ &x);
+
+ pmm_roi->x_centre = x;
+ pmm_roi->y_centre = y;
+
+ /* extract x and y sizes
+ *
+ * Important: the sense of the device width and height is swapped
+ * versus the API sense
+ *
+ * MS Nibble = height
+ * LS Nibble = width
+ */
+ xy_size = pdev->nvm_copy_data.roi_config__mode_roi_xy_size;
+
+ pmm_roi->height = xy_size >> 4;
+ pmm_roi->width = xy_size & 0x0F;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+VL53L1_Error VL53L1_get_preset_mode_timing_cfg(
+ VL53L1_DEV Dev,
+ VL53L1_DevicePresetModes device_preset_mode,
+ uint16_t *pdss_config__target_total_rate_mcps,
+ uint32_t *pphasecal_config_timeout_us,
+ uint32_t *pmm_config_timeout_us,
+ uint32_t *prange_config_timeout_us)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+
+ switch (device_preset_mode) {
+
+ case VL53L1_DEVICEPRESETMODE_STANDARD_RANGING:
+ case VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_SHORT_RANGE:
+ case VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_LONG_RANGE:
+ case VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM1_CAL:
+ case VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM2_CAL:
+ case VL53L1_DEVICEPRESETMODE_OLT:
+ *pdss_config__target_total_rate_mcps =
+ pdev->tuning_parms.tp_dss_target_lite_mcps;
+ *pphasecal_config_timeout_us =
+ pdev->tuning_parms.tp_phasecal_timeout_lite_us;
+ *pmm_config_timeout_us =
+ pdev->tuning_parms.tp_mm_timeout_lite_us;
+ *prange_config_timeout_us =
+ pdev->tuning_parms.tp_range_timeout_lite_us;
+ break;
+
+ case VL53L1_DEVICEPRESETMODE_TIMED_RANGING:
+ case VL53L1_DEVICEPRESETMODE_TIMED_RANGING_SHORT_RANGE:
+ case VL53L1_DEVICEPRESETMODE_TIMED_RANGING_LONG_RANGE:
+ case VL53L1_DEVICEPRESETMODE_SINGLESHOT_RANGING:
+ *pdss_config__target_total_rate_mcps =
+ pdev->tuning_parms.tp_dss_target_timed_mcps;
+ *pphasecal_config_timeout_us =
+ pdev->tuning_parms.tp_phasecal_timeout_timed_us;
+ *pmm_config_timeout_us =
+ pdev->tuning_parms.tp_mm_timeout_timed_us;
+ *prange_config_timeout_us =
+ pdev->tuning_parms.tp_range_timeout_timed_us;
+ break;
+
+ case VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_SHORT_RANGE:
+ case VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_MEDIUM_RANGE:
+ case VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_LONG_RANGE:
+ *pdss_config__target_total_rate_mcps =
+ pdev->tuning_parms.tp_dss_target_timed_mcps;
+ *pphasecal_config_timeout_us =
+ pdev->tuning_parms.tp_phasecal_timeout_timed_us;
+ *pmm_config_timeout_us =
+ pdev->tuning_parms.tp_mm_timeout_lpa_us;
+ *prange_config_timeout_us =
+ pdev->tuning_parms.tp_range_timeout_lpa_us;
+ break;
+
+ default:
+ status = VL53L1_ERROR_INVALID_PARAMS;
+ break;
+
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_preset_mode(
+ VL53L1_DEV Dev,
+ VL53L1_DevicePresetModes device_preset_mode,
+ uint16_t dss_config__target_total_rate_mcps,
+ uint32_t phasecal_config_timeout_us,
+ uint32_t mm_config_timeout_us,
+ uint32_t range_config_timeout_us,
+ uint32_t inter_measurement_period_ms)
+{
+ /**
+ * Initializes static and dynamic data structures for
+ * the provided preset mode
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ VL53L1_static_config_t *pstatic = &(pdev->stat_cfg);
+ VL53L1_general_config_t *pgeneral = &(pdev->gen_cfg);
+ VL53L1_timing_config_t *ptiming = &(pdev->tim_cfg);
+ VL53L1_dynamic_config_t *pdynamic = &(pdev->dyn_cfg);
+ VL53L1_system_control_t *psystem = &(pdev->sys_ctrl);
+ VL53L1_tuning_parm_storage_t *ptuning_parms = &(pdev->tuning_parms);
+ VL53L1_low_power_auto_data_t *plpadata =
+ &(pdev->low_power_auto_data);
+
+ LOG_FUNCTION_START("");
+
+ /* save input settings */
+ pdev->preset_mode = device_preset_mode;
+ pdev->mm_config_timeout_us = mm_config_timeout_us;
+ pdev->range_config_timeout_us = range_config_timeout_us;
+ pdev->inter_measurement_period_ms = inter_measurement_period_ms;
+
+ /* Reset LL Driver state variables */
+
+ VL53L1_init_ll_driver_state(
+ Dev,
+ VL53L1_DEVICESTATE_SW_STANDBY);
+
+ /* apply selected preset */
+
+ switch (device_preset_mode) {
+
+ case VL53L1_DEVICEPRESETMODE_STANDARD_RANGING:
+ status = VL53L1_preset_mode_standard_ranging(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+ break;
+
+ case VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_SHORT_RANGE:
+ status = VL53L1_preset_mode_standard_ranging_short_range(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+ break;
+
+ case VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_LONG_RANGE:
+ status = VL53L1_preset_mode_standard_ranging_long_range(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+ break;
+
+#ifndef VL53L1_NOCALIB
+ case VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM1_CAL:
+ status = VL53L1_preset_mode_standard_ranging_mm1_cal(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+ break;
+
+ case VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM2_CAL:
+ status = VL53L1_preset_mode_standard_ranging_mm2_cal(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+ break;
+#endif
+
+ case VL53L1_DEVICEPRESETMODE_TIMED_RANGING:
+ status = VL53L1_preset_mode_timed_ranging(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+ break;
+
+ case VL53L1_DEVICEPRESETMODE_TIMED_RANGING_SHORT_RANGE:
+ status = VL53L1_preset_mode_timed_ranging_short_range(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+ break;
+
+ case VL53L1_DEVICEPRESETMODE_TIMED_RANGING_LONG_RANGE:
+ status = VL53L1_preset_mode_timed_ranging_long_range(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+ break;
+
+ case VL53L1_DEVICEPRESETMODE_OLT:
+ status = VL53L1_preset_mode_olt(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+ break;
+
+ case VL53L1_DEVICEPRESETMODE_SINGLESHOT_RANGING:
+ status = VL53L1_preset_mode_singleshot_ranging(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+ break;
+
+ case VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_SHORT_RANGE:
+ status = VL53L1_preset_mode_low_power_auto_short_ranging(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms,
+ plpadata);
+ break;
+
+ case VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_MEDIUM_RANGE:
+ status = VL53L1_preset_mode_low_power_auto_ranging(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms,
+ plpadata);
+ break;
+
+ case VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_LONG_RANGE:
+ status = VL53L1_preset_mode_low_power_auto_long_ranging(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms,
+ plpadata);
+ break;
+
+ default:
+ status = VL53L1_ERROR_INVALID_PARAMS;
+ break;
+
+ }
+
+ /* update DSS target */
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ pstatic->dss_config__target_total_rate_mcps =
+ dss_config__target_total_rate_mcps;
+ pdev->dss_config__target_total_rate_mcps =
+ dss_config__target_total_rate_mcps;
+
+ }
+
+ /*
+ * Update the register timeout values based on input
+ * real time values and preset mode VCSEL periods
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_set_timeouts_us(
+ Dev,
+ phasecal_config_timeout_us,
+ mm_config_timeout_us,
+ range_config_timeout_us);
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_set_inter_measurement_period_ms(
+ Dev,
+ inter_measurement_period_ms);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_enable_xtalk_compensation(
+ VL53L1_DEV Dev)
+{
+ /**
+ * Currently a very simple function to copy
+ * private xtalk parms into customer section and apply to device
+ *
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint32_t tempu32;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ /* Fill Public customer NVM data with Xtalk parms */
+ tempu32 = VL53L1_calc_crosstalk_plane_offset_with_margin(
+ pdev->xtalk_cfg.algo__crosstalk_compensation_plane_offset_kcps,
+ pdev->xtalk_cfg.lite_mode_crosstalk_margin_kcps);
+ if (tempu32 > 0xFFFF) {
+ tempu32 = 0xFFFF;
+ }
+ pdev->customer.algo__crosstalk_compensation_plane_offset_kcps =
+ (uint16_t)tempu32;
+
+ pdev->customer.algo__crosstalk_compensation_x_plane_gradient_kcps =
+ pdev->xtalk_cfg.algo__crosstalk_compensation_x_plane_gradient_kcps;
+
+ pdev->customer.algo__crosstalk_compensation_y_plane_gradient_kcps =
+ pdev->xtalk_cfg.algo__crosstalk_compensation_y_plane_gradient_kcps;
+
+ /* Enable Xtalk compensation */
+ pdev->xtalk_cfg.global_crosstalk_compensation_enable = 0x01;
+
+ /* Update Range Ignore Threshold Xtalk Parameter */
+
+ if (status == VL53L1_ERROR_NONE) {
+ pdev->xtalk_cfg.crosstalk_range_ignore_threshold_rate_mcps =
+ VL53L1_calc_range_ignore_threshold(
+ pdev->xtalk_cfg.algo__crosstalk_compensation_plane_offset_kcps,
+ pdev->xtalk_cfg.algo__crosstalk_compensation_x_plane_gradient_kcps,
+ pdev->xtalk_cfg.algo__crosstalk_compensation_y_plane_gradient_kcps,
+ pdev->xtalk_cfg.crosstalk_range_ignore_threshold_mult);
+ }
+
+ /* Apply to device */
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status =
+ VL53L1_set_customer_nvm_managed(
+ Dev,
+ &(pdev->customer));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+
+}
+
+void VL53L1_get_xtalk_compensation_enable(
+ VL53L1_DEV Dev,
+ uint8_t *pcrosstalk_compensation_enable)
+{
+ /**
+ * Currently a very simple function to return
+ *
+ * - this flags whether xtalk compensation is enabled for all modes
+ * or not.
+ *
+ * #1 - Enabled
+ * #0 - Disabled
+ *
+ */
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ /* Extract Xtalk Compensation Enable Status*/
+
+ *pcrosstalk_compensation_enable =
+ pdev->xtalk_cfg.global_crosstalk_compensation_enable;
+
+}
+
+
+VL53L1_Error VL53L1_get_lite_xtalk_margin_kcps(
+ VL53L1_DEV Dev,
+ int16_t *pxtalk_margin)
+{
+
+ /*
+ * Gets the Xtalk Margin Factor in Kcps (fixed point 9.7)
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ *pxtalk_margin = pdev->xtalk_cfg.lite_mode_crosstalk_margin_kcps;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+
+}
+
+VL53L1_Error VL53L1_set_lite_xtalk_margin_kcps(
+ VL53L1_DEV Dev,
+ int16_t xtalk_margin)
+{
+
+ /*
+ * Sets the offset calibration mode
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ pdev->xtalk_cfg.lite_mode_crosstalk_margin_kcps = xtalk_margin;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_restore_xtalk_nvm_default(
+ VL53L1_DEV Dev)
+{
+
+ /*
+ * Returns xtalk rate values to defaults as extracted from device NVM
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ pdev->xtalk_cfg.algo__crosstalk_compensation_plane_offset_kcps =
+ pdev->xtalk_cfg.nvm_default__crosstalk_compensation_plane_offset_kcps;
+ pdev->xtalk_cfg.algo__crosstalk_compensation_x_plane_gradient_kcps =
+ pdev->xtalk_cfg.nvm_default__crosstalk_compensation_x_plane_gradient_kcps;
+ pdev->xtalk_cfg.algo__crosstalk_compensation_y_plane_gradient_kcps =
+ pdev->xtalk_cfg.nvm_default__crosstalk_compensation_y_plane_gradient_kcps;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+VL53L1_Error VL53L1_disable_xtalk_compensation(
+ VL53L1_DEV Dev)
+{
+ /**
+ * Currently a very simple function to clear
+ * customer xtalk parms and apply to device
+ *
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ /* Fill Public customer NVM data with Xtalk parms */
+ pdev->customer.algo__crosstalk_compensation_plane_offset_kcps =
+ 0x00;
+
+ pdev->customer.algo__crosstalk_compensation_x_plane_gradient_kcps =
+ 0x00;
+
+ pdev->customer.algo__crosstalk_compensation_y_plane_gradient_kcps =
+ 0x00;
+
+
+ /* Disable Global Xtalk comnpensation */
+ pdev->xtalk_cfg.global_crosstalk_compensation_enable = 0x00;
+
+ /* Update Range Ignore Threshold Xtalk Parameter */
+
+ if (status == VL53L1_ERROR_NONE) {
+ pdev->xtalk_cfg.crosstalk_range_ignore_threshold_rate_mcps =
+ 0x0000;
+ }
+
+ /* Apply to device */
+
+ if (status == VL53L1_ERROR_NONE) { /*lint !e774 always true*/
+ status =
+ VL53L1_set_customer_nvm_managed(
+ Dev,
+ &(pdev->customer));
+ }
+ LOG_FUNCTION_END(status);
+
+ return status;
+
+}
+
+VL53L1_Error VL53L1_get_lite_sigma_threshold(
+ VL53L1_DEV Dev,
+ uint16_t *plite_sigma)
+{
+
+ /*
+ * Gets the Sigma Threshold value for Lite Mode
+ *
+ * (fixed point 14.2)
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ *plite_sigma =
+ pdev->tim_cfg.range_config__sigma_thresh;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+
+}
+
+VL53L1_Error VL53L1_set_lite_sigma_threshold(
+ VL53L1_DEV Dev,
+ uint16_t lite_sigma)
+{
+
+ /*
+ * Sets the Sigma threshold value for Lite mode
+ *
+ * (fixed point 14.2)
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ pdev->tim_cfg.range_config__sigma_thresh = lite_sigma;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+
+}
+
+VL53L1_Error VL53L1_get_lite_min_count_rate(
+ VL53L1_DEV Dev,
+ uint16_t *plite_mincountrate)
+{
+
+ /*
+ * Gets the Min Count Rate value for Lite Mode
+ *
+ * (fixed point 9.7 Mcps)
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ *plite_mincountrate =
+ pdev->tim_cfg.range_config__min_count_rate_rtn_limit_mcps;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+
+}
+
+VL53L1_Error VL53L1_set_lite_min_count_rate(
+ VL53L1_DEV Dev,
+ uint16_t lite_mincountrate)
+{
+
+ /*
+ * Sets the Min COunt Rate value for Lite mode
+ *
+ * (fixed point 19.7Mcps)
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ pdev->tim_cfg.range_config__min_count_rate_rtn_limit_mcps =
+ lite_mincountrate;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+
+}
+
+VL53L1_Error VL53L1_get_vhv_loopbound(
+ VL53L1_DEV Dev,
+ uint8_t *pvhv_loopbound)
+{
+
+ /*
+ * Gets the VHV Loop bound parm
+ * - extracts only bits 7:2 from internal stat nvm parm
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ *pvhv_loopbound = pdev->stat_nvm.vhv_config__timeout_macrop_loop_bound / 4 ;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+
+}
+
+
+
+VL53L1_Error VL53L1_set_vhv_loopbound(
+ VL53L1_DEV Dev,
+ uint8_t vhv_loopbound)
+{
+
+ /*
+ * Sets the VHV Loop bound parm
+ * - sets only bits 7:2
+ * - bits 1:0 remain unchanged
+ * - ensure that any change here is followed by a
+ * init_and_start_range with full i2c packet
+ * configuration.
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ pdev->stat_nvm.vhv_config__timeout_macrop_loop_bound =
+ (pdev->stat_nvm.vhv_config__timeout_macrop_loop_bound & 0x03) +
+ (vhv_loopbound * 4);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+
+}
+
+
+
+VL53L1_Error VL53L1_get_vhv_config(
+ VL53L1_DEV Dev,
+ uint8_t *pvhv_init_en,
+ uint8_t *pvhv_init_value)
+{
+
+ /*
+ * Gets the VHV config init data
+ */
+
+ /*!<
+ info: \n
+ - msb = 7
+ - lsb = 0
+ - i2c_size = 1
+
+ fields: \n
+ - [7] = vhv0_init_enable
+ - [5:0] = vhv0_init_value
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ *pvhv_init_en = (pdev->stat_nvm.vhv_config__init & 0x80) >> 7;
+ *pvhv_init_value =
+ (pdev->stat_nvm.vhv_config__init & 0x7F);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+
+}
+
+
+
+VL53L1_Error VL53L1_set_vhv_config(
+ VL53L1_DEV Dev,
+ uint8_t vhv_init_en,
+ uint8_t vhv_init_value)
+{
+
+ /*
+ * Sets the VHV Config init
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ pdev->stat_nvm.vhv_config__init =
+ ((vhv_init_en & 0x01) << 7) +
+ (vhv_init_value & 0x7F);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+
+}
+
+
+
+VL53L1_Error VL53L1_init_and_start_range(
+ VL53L1_DEV Dev,
+ uint8_t measurement_mode,
+ VL53L1_DeviceConfigLevel device_config_level)
+{
+ /*
+ * Builds and sends a single I2C multiple byte transaction to
+ * initialize the device and start a range measurement.
+ *
+ * The level of initialization is controlled by the
+ * device_config_level input parameter
+ *
+ * system_control is always sent as the last byte of this
+ * register group (mode_start) either triggers the range
+ * or enables the next range
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint8_t buffer[VL53L1_MAX_I2C_XFER_SIZE];
+
+ VL53L1_static_nvm_managed_t *pstatic_nvm = &(pdev->stat_nvm);
+ VL53L1_customer_nvm_managed_t *pcustomer_nvm = &(pdev->customer);
+ VL53L1_static_config_t *pstatic = &(pdev->stat_cfg);
+ VL53L1_general_config_t *pgeneral = &(pdev->gen_cfg);
+ VL53L1_timing_config_t *ptiming = &(pdev->tim_cfg);
+ VL53L1_dynamic_config_t *pdynamic = &(pdev->dyn_cfg);
+ VL53L1_system_control_t *psystem = &(pdev->sys_ctrl);
+
+ VL53L1_ll_driver_state_t *pstate = &(pdev->ll_state);
+
+ uint8_t *pbuffer = &buffer[0];
+ uint16_t i = 0;
+ uint16_t i2c_index = 0;
+ uint16_t i2c_buffer_offset_bytes = 0;
+ uint16_t i2c_buffer_size_bytes = 0;
+
+ LOG_FUNCTION_START("");
+
+ /* save measurement mode */
+ pdev->measurement_mode = measurement_mode;
+
+ /* Merge measurement mode with mode_start */
+
+ psystem->system__mode_start =
+ (psystem->system__mode_start &
+ VL53L1_DEVICEMEASUREMENTMODE_STOP_MASK) |
+ measurement_mode;
+
+ /* copy in rit from xtalk config */
+
+ pdev->stat_cfg.algo__range_ignore_threshold_mcps =
+ pdev->xtalk_cfg.crosstalk_range_ignore_threshold_rate_mcps;
+
+ /* Start Patch_LowPowerAutoMode */
+
+ /* doing this ensures stop_range followed by a get_device_results does
+ * not mess up the counters */
+
+ if (pdev->low_power_auto_data.low_power_auto_range_count == 0xFF) {
+ pdev->low_power_auto_data.low_power_auto_range_count = 0x0;
+ }
+
+ /* For Presence. Override threshold config */
+ if ((pdev->low_power_auto_data.is_low_power_auto_mode == 1) &&
+ (pdev->low_power_auto_data.low_power_auto_range_count == 0)) {
+ /* save interrupt config */
+ pdev->low_power_auto_data.saved_interrupt_config =
+ pdev->gen_cfg.system__interrupt_config_gpio;
+ /* set intr_new_measure_ready */
+ pdev->gen_cfg.system__interrupt_config_gpio = 1 << 5;
+ /* check MM1/MM2 disabled? */
+ if ((pdev->dyn_cfg.system__sequence_config & (
+ VL53L1_SEQUENCE_MM1_EN | VL53L1_SEQUENCE_MM2_EN)) ==
+ 0x0) {
+ pdev->customer.algo__part_to_part_range_offset_mm =
+ pdev->customer.mm_config__outer_offset_mm * 4;
+ } else {
+ pdev->customer.algo__part_to_part_range_offset_mm = 0x0;
+ }
+
+ /* make sure config gets written out */
+ if (device_config_level <
+ VL53L1_DEVICECONFIGLEVEL_CUSTOMER_ONWARDS) {
+ device_config_level =
+ VL53L1_DEVICECONFIGLEVEL_CUSTOMER_ONWARDS;
+ }
+ }
+
+ if ((pdev->low_power_auto_data.is_low_power_auto_mode == 1) &&
+ (pdev->low_power_auto_data.low_power_auto_range_count == 1)) {
+ /* restore interrupt config */
+ pdev->gen_cfg.system__interrupt_config_gpio =
+ pdev->low_power_auto_data.saved_interrupt_config;
+
+ /* make sure config gets written out including VHV config */
+ device_config_level = VL53L1_DEVICECONFIGLEVEL_FULL;
+ }
+
+ /* End Patch_LowPowerAutoMode */
+
+ /*
+ * Determine Initial I2C index
+ */
+
+ switch (device_config_level) {
+ case VL53L1_DEVICECONFIGLEVEL_FULL:
+ i2c_index = VL53L1_STATIC_NVM_MANAGED_I2C_INDEX;
+ break;
+ case VL53L1_DEVICECONFIGLEVEL_CUSTOMER_ONWARDS:
+ i2c_index = VL53L1_CUSTOMER_NVM_MANAGED_I2C_INDEX;
+ break;
+ case VL53L1_DEVICECONFIGLEVEL_STATIC_ONWARDS:
+ i2c_index = VL53L1_STATIC_CONFIG_I2C_INDEX;
+ break;
+ case VL53L1_DEVICECONFIGLEVEL_GENERAL_ONWARDS:
+ i2c_index = VL53L1_GENERAL_CONFIG_I2C_INDEX;
+ break;
+ case VL53L1_DEVICECONFIGLEVEL_TIMING_ONWARDS:
+ i2c_index = VL53L1_TIMING_CONFIG_I2C_INDEX;
+ break;
+ case VL53L1_DEVICECONFIGLEVEL_DYNAMIC_ONWARDS:
+ i2c_index = VL53L1_DYNAMIC_CONFIG_I2C_INDEX;
+ break;
+ default:
+ i2c_index = VL53L1_SYSTEM_CONTROL_I2C_INDEX;
+ break;
+ }
+
+ /* I2C Buffer size */
+
+ i2c_buffer_size_bytes = \
+ (VL53L1_SYSTEM_CONTROL_I2C_INDEX +
+ VL53L1_SYSTEM_CONTROL_I2C_SIZE_BYTES) -
+ i2c_index;
+
+ /* Initialize buffer */
+
+ pbuffer = &buffer[0];
+ for (i = 0 ; i < i2c_buffer_size_bytes ; i++) {
+ *pbuffer++ = 0;
+ }
+
+ /* Build I2C buffer */
+
+ if (device_config_level >= VL53L1_DEVICECONFIGLEVEL_FULL &&
+ status == VL53L1_ERROR_NONE) {
+
+ i2c_buffer_offset_bytes = \
+ VL53L1_STATIC_NVM_MANAGED_I2C_INDEX - i2c_index;
+
+ status =
+ VL53L1_i2c_encode_static_nvm_managed(
+ pstatic_nvm,
+ VL53L1_STATIC_NVM_MANAGED_I2C_SIZE_BYTES,
+ &buffer[i2c_buffer_offset_bytes]);
+ }
+
+ if (device_config_level >= VL53L1_DEVICECONFIGLEVEL_CUSTOMER_ONWARDS &&
+ status == VL53L1_ERROR_NONE) {
+
+ i2c_buffer_offset_bytes = \
+ VL53L1_CUSTOMER_NVM_MANAGED_I2C_INDEX - i2c_index;
+
+ status =
+ VL53L1_i2c_encode_customer_nvm_managed(
+ pcustomer_nvm,
+ VL53L1_CUSTOMER_NVM_MANAGED_I2C_SIZE_BYTES,
+ &buffer[i2c_buffer_offset_bytes]);
+ }
+
+ if (device_config_level >= VL53L1_DEVICECONFIGLEVEL_STATIC_ONWARDS &&
+ status == VL53L1_ERROR_NONE) {
+
+ i2c_buffer_offset_bytes = \
+ VL53L1_STATIC_CONFIG_I2C_INDEX - i2c_index;
+
+ status =
+ VL53L1_i2c_encode_static_config(
+ pstatic,
+ VL53L1_STATIC_CONFIG_I2C_SIZE_BYTES,
+ &buffer[i2c_buffer_offset_bytes]);
+ }
+
+ if (device_config_level >= VL53L1_DEVICECONFIGLEVEL_GENERAL_ONWARDS &&
+ status == VL53L1_ERROR_NONE) {
+
+ i2c_buffer_offset_bytes =
+ VL53L1_GENERAL_CONFIG_I2C_INDEX - i2c_index;
+
+ status =
+ VL53L1_i2c_encode_general_config(
+ pgeneral,
+ VL53L1_GENERAL_CONFIG_I2C_SIZE_BYTES,
+ &buffer[i2c_buffer_offset_bytes]);
+ }
+
+ if (device_config_level >= VL53L1_DEVICECONFIGLEVEL_TIMING_ONWARDS &&
+ status == VL53L1_ERROR_NONE) {
+
+ i2c_buffer_offset_bytes = \
+ VL53L1_TIMING_CONFIG_I2C_INDEX - i2c_index;
+
+ status =
+ VL53L1_i2c_encode_timing_config(
+ ptiming,
+ VL53L1_TIMING_CONFIG_I2C_SIZE_BYTES,
+ &buffer[i2c_buffer_offset_bytes]);
+ }
+
+ if (device_config_level >= VL53L1_DEVICECONFIGLEVEL_DYNAMIC_ONWARDS &&
+ status == VL53L1_ERROR_NONE) {
+
+ i2c_buffer_offset_bytes = \
+ VL53L1_DYNAMIC_CONFIG_I2C_INDEX - i2c_index;
+
+ /* If in back to back mode, use GPH ID from cfg_state */
+ if ((psystem->system__mode_start &
+ VL53L1_DEVICEMEASUREMENTMODE_BACKTOBACK) ==
+ VL53L1_DEVICEMEASUREMENTMODE_BACKTOBACK) {
+ pdynamic->system__grouped_parameter_hold_0 = pstate->cfg_gph_id | 0x01;
+ pdynamic->system__grouped_parameter_hold_1 = pstate->cfg_gph_id | 0x01;
+ pdynamic->system__grouped_parameter_hold = pstate->cfg_gph_id;
+ }
+ status =
+ VL53L1_i2c_encode_dynamic_config(
+ pdynamic,
+ VL53L1_DYNAMIC_CONFIG_I2C_SIZE_BYTES,
+ &buffer[i2c_buffer_offset_bytes]);
+ }
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ i2c_buffer_offset_bytes = \
+ VL53L1_SYSTEM_CONTROL_I2C_INDEX - i2c_index;
+
+ status =
+ VL53L1_i2c_encode_system_control(
+ psystem,
+ VL53L1_SYSTEM_CONTROL_I2C_SIZE_BYTES,
+ &buffer[i2c_buffer_offset_bytes]);
+ }
+
+ /* Send I2C Buffer */
+
+ if (status == VL53L1_ERROR_NONE) {
+ status =
+ VL53L1_WriteMulti(
+ Dev,
+ i2c_index,
+ buffer,
+ (uint32_t)i2c_buffer_size_bytes);
+ }
+
+ /*
+ * Update LL Driver State
+ */
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_update_ll_driver_rd_state(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_update_ll_driver_cfg_state(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_stop_range(
+ VL53L1_DEV Dev)
+{
+ /*
+ * Stops any in process range using the ABORT command
+ * Also clears all of the measurement mode bits
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ /* Merge ABORT mode with mode_start */
+
+ pdev->sys_ctrl.system__mode_start =
+ (pdev->sys_ctrl.system__mode_start & VL53L1_DEVICEMEASUREMENTMODE_STOP_MASK) |
+ VL53L1_DEVICEMEASUREMENTMODE_ABORT;
+
+ status = VL53L1_set_system_control(
+ Dev,
+ &pdev->sys_ctrl);
+
+ /* Abort bit is auto clear so clear register group structure to match */
+ pdev->sys_ctrl.system__mode_start =
+ (pdev->sys_ctrl.system__mode_start & VL53L1_DEVICEMEASUREMENTMODE_STOP_MASK);
+
+ /* reset zone dynamic info */
+ VL53L1_init_ll_driver_state(
+ Dev,
+ VL53L1_DEVICESTATE_SW_STANDBY);
+
+ /* reset low power auto */
+ if (pdev->low_power_auto_data.is_low_power_auto_mode == 1)
+ VL53L1_low_power_auto_data_stop_range(Dev);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_get_measurement_results(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceResultsLevel device_results_level)
+{
+ /*
+ * Read via a single I2C multiple byte transaction all
+ * of the requested device measurement data results
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint8_t buffer[VL53L1_MAX_I2C_XFER_SIZE];
+
+ VL53L1_system_results_t *psystem_results = &(pdev->sys_results);
+ VL53L1_core_results_t *pcore_results = &(pdev->core_results);
+ VL53L1_debug_results_t *pdebug_results = &(pdev->dbg_results);
+
+ uint16_t i2c_index = VL53L1_SYSTEM_RESULTS_I2C_INDEX;
+ uint16_t i2c_buffer_offset_bytes = 0;
+ uint16_t i2c_buffer_size_bytes = 0;
+
+ LOG_FUNCTION_START("");
+
+ /* Determine multi byte read transaction size */
+
+ switch (device_results_level) {
+ case VL53L1_DEVICERESULTSLEVEL_FULL:
+ i2c_buffer_size_bytes =
+ (VL53L1_DEBUG_RESULTS_I2C_INDEX +
+ VL53L1_DEBUG_RESULTS_I2C_SIZE_BYTES) -
+ i2c_index;
+ break;
+ case VL53L1_DEVICERESULTSLEVEL_UPTO_CORE:
+ i2c_buffer_size_bytes =
+ (VL53L1_CORE_RESULTS_I2C_INDEX +
+ VL53L1_CORE_RESULTS_I2C_SIZE_BYTES) -
+ i2c_index;
+ break;
+ default:
+ i2c_buffer_size_bytes =
+ VL53L1_SYSTEM_RESULTS_I2C_SIZE_BYTES;
+ break;
+ }
+
+ /* Read Result Data */
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status =
+ VL53L1_ReadMulti(
+ Dev,
+ i2c_index,
+ buffer,
+ (uint32_t)i2c_buffer_size_bytes);
+
+ /* Decode I2C buffer */
+
+ if (device_results_level >= VL53L1_DEVICERESULTSLEVEL_FULL &&
+ status == VL53L1_ERROR_NONE) {
+
+ i2c_buffer_offset_bytes =
+ VL53L1_DEBUG_RESULTS_I2C_INDEX - i2c_index;
+
+ status =
+ VL53L1_i2c_decode_debug_results(
+ VL53L1_DEBUG_RESULTS_I2C_SIZE_BYTES,
+ &buffer[i2c_buffer_offset_bytes],
+ pdebug_results);
+ }
+
+ if (device_results_level >= VL53L1_DEVICERESULTSLEVEL_UPTO_CORE &&
+ status == VL53L1_ERROR_NONE) {
+
+ i2c_buffer_offset_bytes =
+ VL53L1_CORE_RESULTS_I2C_INDEX - i2c_index;
+
+ status =
+ VL53L1_i2c_decode_core_results(
+ VL53L1_CORE_RESULTS_I2C_SIZE_BYTES,
+ &buffer[i2c_buffer_offset_bytes],
+ pcore_results);
+ }
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ i2c_buffer_offset_bytes = 0;
+ status =
+ VL53L1_i2c_decode_system_results(
+ VL53L1_SYSTEM_RESULTS_I2C_SIZE_BYTES,
+ &buffer[i2c_buffer_offset_bytes],
+ psystem_results);
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_get_device_results(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceResultsLevel device_results_level,
+ VL53L1_range_results_t *prange_results)
+{
+ /*
+ * Wrapper function using the functions below
+ *
+ * VL53L1_get_measurement_results()
+ * VL53L1_init_and_start_range()
+ * VL53L1_copy_sys_and_core_results_to_range_results()
+ *
+ * The input measurement mode controls what happens next ...
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+ VL53L1_LLDriverResults_t *pres =
+ VL53L1DevStructGetLLResultsHandle(Dev);
+
+ VL53L1_range_results_t *presults = &(pres->range_results);
+
+ LOG_FUNCTION_START("");
+
+ /* Get device results */
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_get_measurement_results(
+ Dev,
+ device_results_level);
+
+ if (status == VL53L1_ERROR_NONE)
+ VL53L1_copy_sys_and_core_results_to_range_results(
+ (int32_t)pdev->gain_cal.standard_ranging_gain_factor,
+ &(pdev->sys_results),
+ &(pdev->core_results),
+ presults);
+
+ /* Start Patch_LowPowerAutoMode */
+ /* process results from first range of low power auto */
+ if (pdev->low_power_auto_data.is_low_power_auto_mode == 1) {
+ /* change to manual calibrations. Only needed on the
+ * first range out */
+ if ((status == VL53L1_ERROR_NONE) &&
+ (pdev->low_power_auto_data.low_power_auto_range_count == 0)) {
+ status = VL53L1_low_power_auto_setup_manual_calibration(
+ Dev);
+ pdev->low_power_auto_data.low_power_auto_range_count = 1;
+ } else if ((status == VL53L1_ERROR_NONE) &&
+ (pdev->low_power_auto_data.low_power_auto_range_count == 1)) {
+ pdev->low_power_auto_data.low_power_auto_range_count = 2;
+ }
+
+ /* perform DSS calculation. This can be performed every range */
+ if ((pdev->low_power_auto_data.low_power_auto_range_count != 0xFF) &&
+ (status == VL53L1_ERROR_NONE)) {
+ status = VL53L1_low_power_auto_update_DSS(
+ Dev);
+ }
+
+ }
+ /* End Patch_LowPowerAutoMode */
+
+ /* copy current state into results */
+
+ presults->cfg_device_state = pdev->ll_state.cfg_device_state;
+ presults->rd_device_state = pdev->ll_state.rd_device_state;
+
+ /* copy internal structure to supplied output pointer */
+
+ memcpy(
+ prange_results,
+ presults,
+ sizeof(VL53L1_range_results_t));
+
+ /*
+ * Check LL driver and Device are in Sync
+ * If not an error is raised
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_check_ll_driver_rd_state(Dev);
+
+#ifdef VL53L1_LOG_ENABLE
+ if (status == VL53L1_ERROR_NONE)
+ VL53L1_print_range_results(
+ presults,
+ "get_device_results():pdev->llresults.range_results.",
+ VL53L1_TRACE_MODULE_RANGE_RESULTS_DATA);
+#endif
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_clear_interrupt_and_enable_next_range(
+ VL53L1_DEV Dev,
+ uint8_t measurement_mode)
+{
+
+ /*
+ * Enable next range by sending handshake which
+ * clears the interrupt
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Dynamic Management */
+ /* Current results analysis and generate next settings */
+
+
+ /* Dynamic GPH Management */
+ /* Setup GPH absorption point and config values for next measurement */
+
+ /* Update GPH registers, clear interrupt and set measurement mode */
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_init_and_start_range(
+ Dev,
+ measurement_mode,
+ VL53L1_DEVICECONFIGLEVEL_GENERAL_ONWARDS);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+void VL53L1_copy_sys_and_core_results_to_range_results(
+ int32_t gain_factor,
+ VL53L1_system_results_t *psys,
+ VL53L1_core_results_t *pcore,
+ VL53L1_range_results_t *presults)
+{
+ uint8_t i = 0;
+
+ VL53L1_range_data_t *pdata;
+ int32_t range_mm = 0;
+ uint32_t tmpu32 = 0;
+
+ LOG_FUNCTION_START("");
+
+ /* copy results */
+
+ presults->stream_count = psys->result__stream_count;
+
+ pdata = &(presults->data[0]);
+
+ for (i = 0 ; i < 2 ; i++) {
+
+ pdata->range_id = i;
+ pdata->time_stamp = 0;
+
+ if ((psys->result__stream_count == 0) &&
+ ((psys->result__range_status & VL53L1_RANGE_STATUS__RANGE_STATUS_MASK) ==
+ VL53L1_DEVICEERROR_RANGECOMPLETE)) {
+ pdata->range_status = VL53L1_DEVICEERROR_RANGECOMPLETE_NO_WRAP_CHECK;
+ } else {
+ pdata->range_status =
+ psys->result__range_status & VL53L1_RANGE_STATUS__RANGE_STATUS_MASK;
+ }
+
+ switch (i) {
+
+ case 0:
+
+ if (psys->result__report_status == VL53L1_DEVICEREPORTSTATUS_MM1)
+ pdata->actual_effective_spads =
+ psys->result__mm_inner_actual_effective_spads_sd0;
+ else if (psys->result__report_status == VL53L1_DEVICEREPORTSTATUS_MM2)
+ pdata->actual_effective_spads =
+ psys->result__mm_outer_actual_effective_spads_sd0;
+ else
+ pdata->actual_effective_spads =
+ psys->result__dss_actual_effective_spads_sd0;
+
+ pdata->peak_signal_count_rate_mcps =
+ psys->result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0;
+ pdata->avg_signal_count_rate_mcps =
+ psys->result__avg_signal_count_rate_mcps_sd0;
+ pdata->ambient_count_rate_mcps =
+ psys->result__ambient_count_rate_mcps_sd0;
+
+ /* Start Patch_SigmaEstimateAccuracyImprovement */
+
+ /* shift up sigma estimate to 7 bit fractional and clip to 9 bit int */
+ tmpu32 = ((uint32_t)psys->result__sigma_sd0 << 5);
+ if (tmpu32 > 0xFFFF) {
+ tmpu32 = 0xFFFF;
+ }
+ pdata->sigma_mm = (uint16_t)tmpu32;
+
+ /* End Patch_SigmaEstimateAccuracyImprovement */
+
+ pdata->median_phase =
+ psys->result__phase_sd0;
+
+ range_mm =
+ (int32_t)psys->result__final_crosstalk_corrected_range_mm_sd0;
+
+ /* apply correction gain */
+ range_mm *= gain_factor;
+ range_mm += 0x0400;
+ range_mm /= 0x0800;
+
+ pdata->median_range_mm = (int16_t)range_mm;
+
+ pdata->ranging_total_events =
+ pcore->result_core__ranging_total_events_sd0;
+ pdata->signal_total_events =
+ pcore->result_core__signal_total_events_sd0;
+ pdata->total_periods_elapsed =
+ pcore->result_core__total_periods_elapsed_sd0;
+ pdata->ambient_window_events =
+ pcore->result_core__ambient_window_events_sd0;
+
+ break;
+ case 1:
+
+ pdata->actual_effective_spads =
+ psys->result__dss_actual_effective_spads_sd1;
+ pdata->peak_signal_count_rate_mcps =
+ psys->result__peak_signal_count_rate_mcps_sd1;
+ pdata->avg_signal_count_rate_mcps =
+ 0xFFFF;
+ pdata->ambient_count_rate_mcps =
+ psys->result__ambient_count_rate_mcps_sd1;
+
+ /* Start Patch_SigmaEstimateAccuracyImprovement */
+
+ /* shift up sigma estimate to 7 bit fractional and clip to 9 bit int */
+ tmpu32 = ((uint32_t)psys->result__sigma_sd1 << 5);
+ if (tmpu32 > 0xFFFF) {
+ tmpu32 = 0xFFFF;
+ }
+ pdata->sigma_mm = (uint16_t)tmpu32;
+
+ /* End Patch_SigmaEstimateAccuracyImprovement */
+
+ pdata->median_phase =
+ psys->result__phase_sd1;
+
+ range_mm =
+ (int32_t)psys->result__final_crosstalk_corrected_range_mm_sd1;
+
+ /* apply correction gain */
+ range_mm *= gain_factor;
+ range_mm += 0x0400;
+ range_mm /= 0x0800;
+
+ pdata->median_range_mm = (int16_t)range_mm;
+
+ pdata->ranging_total_events =
+ pcore->result_core__ranging_total_events_sd1;
+ pdata->signal_total_events =
+ pcore->result_core__signal_total_events_sd1;
+ pdata->total_periods_elapsed =
+ pcore->result_core__total_periods_elapsed_sd1;
+ pdata->ambient_window_events =
+ pcore->result_core__ambient_window_events_sd1;
+
+ break;
+ }
+
+ pdata++;
+ }
+
+ /* Update Global Device Status for results
+ * - Default to no update
+ */
+
+ presults->device_status = VL53L1_DEVICEERROR_NOUPDATE;
+
+ /* Check range status
+ * - If device error condition, update device status
+ * - Remove device status from range status output this should
+ * only contain information relating to range data
+ */
+
+ switch (psys->result__range_status &
+ VL53L1_RANGE_STATUS__RANGE_STATUS_MASK) {
+
+ case VL53L1_DEVICEERROR_VCSELCONTINUITYTESTFAILURE:
+ case VL53L1_DEVICEERROR_VCSELWATCHDOGTESTFAILURE:
+ case VL53L1_DEVICEERROR_NOVHVVALUEFOUND:
+ case VL53L1_DEVICEERROR_USERROICLIP:
+ case VL53L1_DEVICEERROR_MULTCLIPFAIL:
+
+ presults->device_status = (psys->result__range_status &
+ VL53L1_RANGE_STATUS__RANGE_STATUS_MASK);
+
+ presults->data[0].range_status = VL53L1_DEVICEERROR_NOUPDATE;
+ break;
+
+ }
+
+ LOG_FUNCTION_END(0);
+}
+
+/*
+ * Configure the GPIO interrupt config, from the given input
+ */
+
+VL53L1_Error VL53L1_set_GPIO_interrupt_config(
+ VL53L1_DEV Dev,
+ VL53L1_GPIO_Interrupt_Mode intr_mode_distance,
+ VL53L1_GPIO_Interrupt_Mode intr_mode_rate,
+ uint8_t intr_new_measure_ready,
+ uint8_t intr_no_target,
+ uint8_t intr_combined_mode,
+ uint16_t thresh_distance_high,
+ uint16_t thresh_distance_low,
+ uint16_t thresh_rate_high,
+ uint16_t thresh_rate_low
+ )
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+ VL53L1_GPIO_interrupt_config_t *pintconf = &(pdev->gpio_interrupt_config);
+
+ LOG_FUNCTION_START("");
+
+ /* update local data structure */
+ pintconf->intr_mode_distance = intr_mode_distance;
+ pintconf->intr_mode_rate = intr_mode_rate;
+ pintconf->intr_new_measure_ready = intr_new_measure_ready;
+ pintconf->intr_no_target = intr_no_target;
+ pintconf->intr_combined_mode = intr_combined_mode;
+ pintconf->threshold_distance_high = thresh_distance_high;
+ pintconf->threshold_distance_low = thresh_distance_low;
+ pintconf->threshold_rate_high = thresh_rate_high;
+ pintconf->threshold_rate_low = thresh_rate_low;
+
+ /* encoded interrupt config */
+ pdev->gen_cfg.system__interrupt_config_gpio =
+ VL53L1_encode_GPIO_interrupt_config(pintconf);
+
+
+ /* set thresholds */
+ status = VL53L1_set_GPIO_thresholds_from_struct(
+ Dev,
+ pintconf);
+
+ LOG_FUNCTION_END(status);
+ return status;
+}
+
+/*
+ * Configure the GPIO interrupt config, from the given structure
+ */
+
+VL53L1_Error VL53L1_set_GPIO_interrupt_config_struct(
+ VL53L1_DEV Dev,
+ VL53L1_GPIO_interrupt_config_t intconf)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+ VL53L1_GPIO_interrupt_config_t *pintconf = &(pdev->gpio_interrupt_config);
+
+ LOG_FUNCTION_START("");
+
+ /* using memcpy(dst, src, size in bytes) */
+ memcpy(pintconf, &(intconf), sizeof(VL53L1_GPIO_interrupt_config_t));
+
+ /* encoded interrupt config */
+ pdev->gen_cfg.system__interrupt_config_gpio =
+ VL53L1_encode_GPIO_interrupt_config(pintconf);
+
+ /* set thresholds */
+ status = VL53L1_set_GPIO_thresholds_from_struct(
+ Dev,
+ pintconf);
+
+ LOG_FUNCTION_END(status);
+ return status;
+}
+
+/*
+ * Retrieve GPIO interrupt config structure
+ */
+
+VL53L1_Error VL53L1_get_GPIO_interrupt_config(
+ VL53L1_DEV Dev,
+ VL53L1_GPIO_interrupt_config_t *pintconf)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ /*
+ * Decode the system__interrupt_config_gpio register
+ * This makes sure the structure is in line with the register
+ */
+ pdev->gpio_interrupt_config = VL53L1_decode_GPIO_interrupt_config(
+ pdev->gen_cfg.system__interrupt_config_gpio);
+
+ /*
+ * Readout the system thresholds
+ */
+ pdev->gpio_interrupt_config.threshold_distance_high =
+ pdev->dyn_cfg.system__thresh_high;
+ pdev->gpio_interrupt_config.threshold_distance_low =
+ pdev->dyn_cfg.system__thresh_low;
+
+ pdev->gpio_interrupt_config.threshold_rate_high =
+ pdev->gen_cfg.system__thresh_rate_high;
+ pdev->gpio_interrupt_config.threshold_rate_low =
+ pdev->gen_cfg.system__thresh_rate_low;
+
+ if (pintconf == &(pdev->gpio_interrupt_config)) {
+ /* Cowardly refusing to copy the same memory locations */
+ } else {
+
+ /* using memcpy(dst, src, size in bytes) */
+ memcpy(pintconf, &(pdev->gpio_interrupt_config),
+ sizeof(VL53L1_GPIO_interrupt_config_t));
+ }
+
+ LOG_FUNCTION_END(status);
+ return status;
+}
+
+VL53L1_Error VL53L1_set_offset_calibration_mode(
+ VL53L1_DEV Dev,
+ VL53L1_OffsetCalibrationMode offset_cal_mode)
+{
+
+ /*
+ * Sets the offset calibration mode
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ pdev->offset_calibration_mode = offset_cal_mode;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_get_offset_calibration_mode(
+ VL53L1_DEV Dev,
+ VL53L1_OffsetCalibrationMode *poffset_cal_mode)
+{
+
+ /*
+ * Gets the offset calibration mode
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ *poffset_cal_mode = pdev->offset_calibration_mode;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_offset_correction_mode(
+ VL53L1_DEV Dev,
+ VL53L1_OffsetCorrectionMode offset_cor_mode)
+{
+
+ /*
+ * Sets the offset correction mode
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ pdev->offset_correction_mode = offset_cor_mode;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_get_offset_correction_mode(
+ VL53L1_DEV Dev,
+ VL53L1_OffsetCorrectionMode *poffset_cor_mode)
+{
+
+ /*
+ * Gets the offset correction mode
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ *poffset_cor_mode = pdev->offset_correction_mode;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+/* Start Patch_AddedTuningParms_11761 */
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_get_tuning_debug_data(
+ VL53L1_DEV Dev,
+ VL53L1_tuning_parameters_t *ptun_data)
+{
+ /*
+ * Helper function to extract all tuning parm values
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ ptun_data->vl53l1_tuningparm_version =
+ pdev->tuning_parms.tp_tuning_parm_version;
+
+ ptun_data->vl53l1_tuningparm_key_table_version =
+ pdev->tuning_parms.tp_tuning_parm_key_table_version;
+
+
+ ptun_data->vl53l1_tuningparm_lld_version =
+ pdev->tuning_parms.tp_tuning_parm_lld_version;
+
+ ptun_data->vl53l1_tuningparm_lite_min_clip_mm =
+ pdev->tuning_parms.tp_lite_min_clip;
+
+ ptun_data->vl53l1_tuningparm_lite_long_sigma_thresh_mm =
+ pdev->tuning_parms.tp_lite_long_sigma_thresh_mm;
+
+ ptun_data->vl53l1_tuningparm_lite_med_sigma_thresh_mm =
+ pdev->tuning_parms.tp_lite_med_sigma_thresh_mm;
+
+ ptun_data->vl53l1_tuningparm_lite_short_sigma_thresh_mm =
+ pdev->tuning_parms.tp_lite_short_sigma_thresh_mm;
+
+ ptun_data->vl53l1_tuningparm_lite_long_min_count_rate_rtn_mcps =
+ pdev->tuning_parms.tp_lite_long_min_count_rate_rtn_mcps;
+
+ ptun_data->vl53l1_tuningparm_lite_med_min_count_rate_rtn_mcps =
+ pdev->tuning_parms.tp_lite_med_min_count_rate_rtn_mcps;
+
+ ptun_data->vl53l1_tuningparm_lite_short_min_count_rate_rtn_mcps =
+ pdev->tuning_parms.tp_lite_short_min_count_rate_rtn_mcps;
+
+ ptun_data->vl53l1_tuningparm_lite_sigma_est_pulse_width =
+ pdev->tuning_parms.tp_lite_sigma_est_pulse_width_ns;
+
+ ptun_data->vl53l1_tuningparm_lite_sigma_est_amb_width_ns =
+ pdev->tuning_parms.tp_lite_sigma_est_amb_width_ns;
+
+ ptun_data->vl53l1_tuningparm_lite_sigma_ref_mm =
+ pdev->tuning_parms.tp_lite_sigma_ref_mm;
+
+ ptun_data->vl53l1_tuningparm_lite_rit_mult =
+ pdev->xtalk_cfg.crosstalk_range_ignore_threshold_mult;
+
+ ptun_data->vl53l1_tuningparm_lite_seed_config =
+ pdev->tuning_parms.tp_lite_seed_cfg ;
+
+ ptun_data->vl53l1_tuningparm_lite_quantifier =
+ pdev->tuning_parms.tp_lite_quantifier;
+
+ ptun_data->vl53l1_tuningparm_lite_first_order_select =
+ pdev->tuning_parms.tp_lite_first_order_select;
+
+ ptun_data->vl53l1_tuningparm_lite_xtalk_margin_kcps =
+ pdev->xtalk_cfg.lite_mode_crosstalk_margin_kcps;
+
+ ptun_data->vl53l1_tuningparm_initial_phase_rtn_lite_long_range =
+ pdev->tuning_parms.tp_init_phase_rtn_lite_long;
+
+ ptun_data->vl53l1_tuningparm_initial_phase_rtn_lite_med_range =
+ pdev->tuning_parms.tp_init_phase_rtn_lite_med;
+
+ ptun_data->vl53l1_tuningparm_initial_phase_rtn_lite_short_range =
+ pdev->tuning_parms.tp_init_phase_rtn_lite_short;
+
+ ptun_data->vl53l1_tuningparm_initial_phase_ref_lite_long_range =
+ pdev->tuning_parms.tp_init_phase_ref_lite_long;
+
+ ptun_data->vl53l1_tuningparm_initial_phase_ref_lite_med_range =
+ pdev->tuning_parms.tp_init_phase_ref_lite_med;
+
+ ptun_data->vl53l1_tuningparm_initial_phase_ref_lite_short_range =
+ pdev->tuning_parms.tp_init_phase_ref_lite_short;
+
+ ptun_data->vl53l1_tuningparm_timed_seed_config =
+ pdev->tuning_parms.tp_timed_seed_cfg;
+
+ ptun_data->vl53l1_tuningparm_vhv_loopbound =
+ pdev->stat_nvm.vhv_config__timeout_macrop_loop_bound;
+
+ ptun_data->vl53l1_tuningparm_refspadchar_device_test_mode =
+ pdev->refspadchar.device_test_mode;
+
+ ptun_data->vl53l1_tuningparm_refspadchar_vcsel_period =
+ pdev->refspadchar.vcsel_period;
+
+ ptun_data->vl53l1_tuningparm_refspadchar_phasecal_timeout_us =
+ pdev->refspadchar.timeout_us;
+
+ ptun_data->vl53l1_tuningparm_refspadchar_target_count_rate_mcps =
+ pdev->refspadchar.target_count_rate_mcps;
+
+ ptun_data->vl53l1_tuningparm_refspadchar_min_countrate_limit_mcps =
+ pdev->refspadchar.min_count_rate_limit_mcps;
+
+ ptun_data->vl53l1_tuningparm_refspadchar_max_countrate_limit_mcps =
+ pdev->refspadchar.max_count_rate_limit_mcps;
+
+ ptun_data->vl53l1_tuningparm_offset_cal_dss_rate_mcps =
+ pdev->offsetcal_cfg.dss_config__target_total_rate_mcps;
+
+ ptun_data->vl53l1_tuningparm_offset_cal_phasecal_timeout_us =
+ pdev->offsetcal_cfg.phasecal_config_timeout_us;
+
+ ptun_data->vl53l1_tuningparm_offset_cal_mm_timeout_us =
+ pdev->offsetcal_cfg.mm_config_timeout_us;
+
+ ptun_data->vl53l1_tuningparm_offset_cal_range_timeout_us =
+ pdev->offsetcal_cfg.range_config_timeout_us;
+
+ ptun_data->vl53l1_tuningparm_offset_cal_pre_samples =
+ pdev->offsetcal_cfg.pre_num_of_samples;
+
+ ptun_data->vl53l1_tuningparm_offset_cal_mm1_samples =
+ pdev->offsetcal_cfg.mm1_num_of_samples;
+
+ ptun_data->vl53l1_tuningparm_offset_cal_mm2_samples =
+ pdev->offsetcal_cfg.mm2_num_of_samples;
+
+ ptun_data->vl53l1_tuningparm_spadmap_vcsel_period =
+ pdev->ssc_cfg.vcsel_period;
+
+ ptun_data->vl53l1_tuningparm_spadmap_vcsel_start =
+ pdev->ssc_cfg.vcsel_start;
+
+ ptun_data->vl53l1_tuningparm_spadmap_rate_limit_mcps =
+ pdev->ssc_cfg.rate_limit_mcps;
+
+ ptun_data->vl53l1_tuningparm_lite_dss_config_target_total_rate_mcps =
+ pdev->tuning_parms.tp_dss_target_lite_mcps;
+
+ ptun_data->vl53l1_tuningparm_timed_dss_config_target_total_rate_mcps =
+ pdev->tuning_parms.tp_dss_target_timed_mcps;
+
+ ptun_data->vl53l1_tuningparm_lite_phasecal_config_timeout_us =
+ pdev->tuning_parms.tp_phasecal_timeout_lite_us;
+
+ ptun_data->vl53l1_tuningparm_timed_phasecal_config_timeout_us =
+ pdev->tuning_parms.tp_phasecal_timeout_timed_us;
+
+ ptun_data->vl53l1_tuningparm_lite_mm_config_timeout_us =
+ pdev->tuning_parms.tp_mm_timeout_lite_us;
+
+ ptun_data->vl53l1_tuningparm_timed_mm_config_timeout_us =
+ pdev->tuning_parms.tp_mm_timeout_timed_us;
+
+ ptun_data->vl53l1_tuningparm_lite_range_config_timeout_us =
+ pdev->tuning_parms.tp_range_timeout_lite_us;
+
+ ptun_data->vl53l1_tuningparm_timed_range_config_timeout_us =
+ pdev->tuning_parms.tp_range_timeout_timed_us;
+
+ ptun_data->vl53l1_tuningparm_lowpowerauto_vhv_loop_bound =
+ pdev->low_power_auto_data.vhv_loop_bound;
+
+ ptun_data->vl53l1_tuningparm_lowpowerauto_mm_config_timeout_us =
+ pdev->tuning_parms.tp_mm_timeout_lpa_us;
+
+ ptun_data->vl53l1_tuningparm_lowpowerauto_range_config_timeout_us =
+ pdev->tuning_parms.tp_range_timeout_lpa_us;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+VL53L1_Error VL53L1_get_tuning_parm(
+ VL53L1_DEV Dev,
+ VL53L1_TuningParms tuning_parm_key,
+ int32_t *ptuning_parm_value)
+{
+
+ /*
+ * Gets the requested tuning parm value
+ * - Large case statement for returns
+ * - if key does not match, INVALID parm error returned
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ switch (tuning_parm_key) {
+
+ case VL53L1_TUNINGPARM_VERSION:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_tuning_parm_version;
+ break;
+ case VL53L1_TUNINGPARM_KEY_TABLE_VERSION:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_tuning_parm_key_table_version;
+ break;
+ case VL53L1_TUNINGPARM_LLD_VERSION:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_tuning_parm_lld_version;
+ break;
+ case VL53L1_TUNINGPARM_CONSISTENCY_LITE_PHASE_TOLERANCE:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_consistency_lite_phase_tolerance;
+ break;
+ case VL53L1_TUNINGPARM_PHASECAL_TARGET:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_phasecal_target;
+ break;
+ case VL53L1_TUNINGPARM_LITE_CAL_REPEAT_RATE:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_cal_repeat_rate;
+ break;
+ case VL53L1_TUNINGPARM_LITE_RANGING_GAIN_FACTOR:
+ *ptuning_parm_value =
+ (int32_t)pdev->gain_cal.standard_ranging_gain_factor;
+ break;
+ case VL53L1_TUNINGPARM_LITE_MIN_CLIP_MM:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_lite_min_clip;
+ break;
+ case VL53L1_TUNINGPARM_LITE_LONG_SIGMA_THRESH_MM:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_lite_long_sigma_thresh_mm;
+ break;
+ case VL53L1_TUNINGPARM_LITE_MED_SIGMA_THRESH_MM:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_lite_med_sigma_thresh_mm;
+ break;
+ case VL53L1_TUNINGPARM_LITE_SHORT_SIGMA_THRESH_MM:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_lite_short_sigma_thresh_mm;
+ break;
+ case VL53L1_TUNINGPARM_LITE_LONG_MIN_COUNT_RATE_RTN_MCPS:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_lite_long_min_count_rate_rtn_mcps;
+ break;
+ case VL53L1_TUNINGPARM_LITE_MED_MIN_COUNT_RATE_RTN_MCPS:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_lite_med_min_count_rate_rtn_mcps;
+ break;
+ case VL53L1_TUNINGPARM_LITE_SHORT_MIN_COUNT_RATE_RTN_MCPS:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_lite_short_min_count_rate_rtn_mcps;
+ break;
+ case VL53L1_TUNINGPARM_LITE_SIGMA_EST_PULSE_WIDTH:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_lite_sigma_est_pulse_width_ns;
+ break;
+ case VL53L1_TUNINGPARM_LITE_SIGMA_EST_AMB_WIDTH_NS:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_lite_sigma_est_amb_width_ns;
+ break;
+ case VL53L1_TUNINGPARM_LITE_SIGMA_REF_MM:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_lite_sigma_ref_mm;
+ break;
+ case VL53L1_TUNINGPARM_LITE_RIT_MULT:
+ *ptuning_parm_value =
+ (int32_t)pdev->xtalk_cfg.crosstalk_range_ignore_threshold_mult;
+ break;
+ case VL53L1_TUNINGPARM_LITE_SEED_CONFIG:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_lite_seed_cfg ;
+ break;
+ case VL53L1_TUNINGPARM_LITE_QUANTIFIER:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_lite_quantifier;
+ break;
+ case VL53L1_TUNINGPARM_LITE_FIRST_ORDER_SELECT:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_lite_first_order_select;
+ break;
+ case VL53L1_TUNINGPARM_LITE_XTALK_MARGIN_KCPS:
+ *ptuning_parm_value =
+ (int32_t)pdev->xtalk_cfg.lite_mode_crosstalk_margin_kcps;
+ break;
+ case VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_LONG_RANGE:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_init_phase_rtn_lite_long;
+ break;
+ case VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_MED_RANGE:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_init_phase_rtn_lite_med;
+ break;
+ case VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_SHORT_RANGE:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_init_phase_rtn_lite_short;
+ break;
+ case VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_LONG_RANGE:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_init_phase_ref_lite_long;
+ break;
+ case VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_MED_RANGE:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_init_phase_ref_lite_med;
+ break;
+ case VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_SHORT_RANGE:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_init_phase_ref_lite_short;
+ break;
+ case VL53L1_TUNINGPARM_TIMED_SEED_CONFIG:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_timed_seed_cfg;
+ break;
+ case VL53L1_TUNINGPARM_VHV_LOOPBOUND:
+ *ptuning_parm_value =
+ (int32_t)pdev->stat_nvm.vhv_config__timeout_macrop_loop_bound;
+ break;
+ case VL53L1_TUNINGPARM_REFSPADCHAR_DEVICE_TEST_MODE:
+ *ptuning_parm_value =
+ (int32_t)pdev->refspadchar.device_test_mode;
+ break;
+ case VL53L1_TUNINGPARM_REFSPADCHAR_VCSEL_PERIOD:
+ *ptuning_parm_value =
+ (int32_t)pdev->refspadchar.vcsel_period;
+ break;
+ case VL53L1_TUNINGPARM_REFSPADCHAR_PHASECAL_TIMEOUT_US:
+ *ptuning_parm_value =
+ (int32_t)pdev->refspadchar.timeout_us;
+ break;
+ case VL53L1_TUNINGPARM_REFSPADCHAR_TARGET_COUNT_RATE_MCPS:
+ *ptuning_parm_value =
+ (int32_t)pdev->refspadchar.target_count_rate_mcps;
+ break;
+ case VL53L1_TUNINGPARM_REFSPADCHAR_MIN_COUNTRATE_LIMIT_MCPS:
+ *ptuning_parm_value =
+ (int32_t)pdev->refspadchar.min_count_rate_limit_mcps;
+ break;
+ case VL53L1_TUNINGPARM_REFSPADCHAR_MAX_COUNTRATE_LIMIT_MCPS:
+ *ptuning_parm_value =
+ (int32_t)pdev->refspadchar.max_count_rate_limit_mcps;
+ break;
+ case VL53L1_TUNINGPARM_OFFSET_CAL_DSS_RATE_MCPS:
+ *ptuning_parm_value =
+ (int32_t)pdev->offsetcal_cfg.dss_config__target_total_rate_mcps;;
+ break;
+ case VL53L1_TUNINGPARM_OFFSET_CAL_PHASECAL_TIMEOUT_US:
+ *ptuning_parm_value =
+ (int32_t)pdev->offsetcal_cfg.phasecal_config_timeout_us;
+ break;
+ case VL53L1_TUNINGPARM_OFFSET_CAL_MM_TIMEOUT_US:
+ *ptuning_parm_value =
+ (int32_t)pdev->offsetcal_cfg.mm_config_timeout_us;
+ break;
+ case VL53L1_TUNINGPARM_OFFSET_CAL_RANGE_TIMEOUT_US:
+ *ptuning_parm_value =
+ (int32_t)pdev->offsetcal_cfg.range_config_timeout_us;
+ break;
+ case VL53L1_TUNINGPARM_OFFSET_CAL_PRE_SAMPLES:
+ *ptuning_parm_value =
+ (int32_t)pdev->offsetcal_cfg.pre_num_of_samples;
+ break;
+ case VL53L1_TUNINGPARM_OFFSET_CAL_MM1_SAMPLES:
+ *ptuning_parm_value =
+ (int32_t)pdev->offsetcal_cfg.mm1_num_of_samples;
+ break;
+ case VL53L1_TUNINGPARM_OFFSET_CAL_MM2_SAMPLES:
+ *ptuning_parm_value =
+ (int32_t)pdev->offsetcal_cfg.mm2_num_of_samples;
+ break;
+ case VL53L1_TUNINGPARM_SPADMAP_VCSEL_PERIOD:
+ *ptuning_parm_value =
+ (int32_t)pdev->ssc_cfg.vcsel_period;
+ break;
+ case VL53L1_TUNINGPARM_SPADMAP_VCSEL_START:
+ *ptuning_parm_value =
+ (int32_t)pdev->ssc_cfg.vcsel_start;
+ break;
+ case VL53L1_TUNINGPARM_SPADMAP_RATE_LIMIT_MCPS:
+ *ptuning_parm_value =
+ (int32_t)pdev->ssc_cfg.rate_limit_mcps;
+ break;
+ case VL53L1_TUNINGPARM_LITE_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_dss_target_lite_mcps;
+ break;
+ case VL53L1_TUNINGPARM_TIMED_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_dss_target_timed_mcps;
+ break;
+ case VL53L1_TUNINGPARM_LITE_PHASECAL_CONFIG_TIMEOUT_US:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_phasecal_timeout_lite_us;
+ break;
+ case VL53L1_TUNINGPARM_TIMED_PHASECAL_CONFIG_TIMEOUT_US:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_phasecal_timeout_timed_us;
+ break;
+ case VL53L1_TUNINGPARM_LITE_MM_CONFIG_TIMEOUT_US:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_mm_timeout_lite_us;
+ break;
+ case VL53L1_TUNINGPARM_TIMED_MM_CONFIG_TIMEOUT_US:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_mm_timeout_timed_us;
+ break;
+ case VL53L1_TUNINGPARM_LITE_RANGE_CONFIG_TIMEOUT_US:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_range_timeout_lite_us;
+ break;
+ case VL53L1_TUNINGPARM_TIMED_RANGE_CONFIG_TIMEOUT_US:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_range_timeout_timed_us;
+ break;
+ case VL53L1_TUNINGPARM_LOWPOWERAUTO_VHV_LOOP_BOUND:
+ *ptuning_parm_value =
+ (int32_t)pdev->low_power_auto_data.vhv_loop_bound;
+ break;
+ case VL53L1_TUNINGPARM_LOWPOWERAUTO_MM_CONFIG_TIMEOUT_US:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_mm_timeout_lpa_us;
+ break;
+ case VL53L1_TUNINGPARM_LOWPOWERAUTO_RANGE_CONFIG_TIMEOUT_US:
+ *ptuning_parm_value =
+ (int32_t)pdev->tuning_parms.tp_range_timeout_lpa_us;
+ break;
+
+
+ default:
+ *ptuning_parm_value = 0x7FFFFFFF;
+ status = VL53L1_ERROR_INVALID_PARAMS;
+ break;
+
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+VL53L1_Error VL53L1_set_tuning_parm(
+ VL53L1_DEV Dev,
+ VL53L1_TuningParms tuning_parm_key,
+ int32_t tuning_parm_value)
+{
+
+ /*
+ * Sets the requested tuning parm value
+ * - Large case statement for set value
+ * - if key does not match, INVALID parm error returned
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ switch (tuning_parm_key) {
+
+ case VL53L1_TUNINGPARM_VERSION:
+ pdev->tuning_parms.tp_tuning_parm_version =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_KEY_TABLE_VERSION:
+ pdev->tuning_parms.tp_tuning_parm_key_table_version =
+ (uint16_t)tuning_parm_value;
+
+ /* Perform Key Table Check
+ *
+ * - If does not match default, key table
+ * format does not match tuning file,
+ * error should be thrown
+ *
+ */
+
+ if ((uint16_t)tuning_parm_value
+ != VL53L1_TUNINGPARM_KEY_TABLE_VERSION_DEFAULT) {
+ status = VL53L1_ERROR_TUNING_PARM_KEY_MISMATCH;
+ }
+ break;
+ case VL53L1_TUNINGPARM_LLD_VERSION:
+ pdev->tuning_parms.tp_tuning_parm_lld_version =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_CONSISTENCY_LITE_PHASE_TOLERANCE:
+ pdev->tuning_parms.tp_consistency_lite_phase_tolerance =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_PHASECAL_TARGET:
+ pdev->tuning_parms.tp_phasecal_target =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_CAL_REPEAT_RATE:
+ pdev->tuning_parms.tp_cal_repeat_rate =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_RANGING_GAIN_FACTOR:
+ pdev->gain_cal.standard_ranging_gain_factor =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_MIN_CLIP_MM:
+ pdev->tuning_parms.tp_lite_min_clip =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_LONG_SIGMA_THRESH_MM:
+ pdev->tuning_parms.tp_lite_long_sigma_thresh_mm =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_MED_SIGMA_THRESH_MM:
+ pdev->tuning_parms.tp_lite_med_sigma_thresh_mm =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_SHORT_SIGMA_THRESH_MM:
+ pdev->tuning_parms.tp_lite_short_sigma_thresh_mm =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_LONG_MIN_COUNT_RATE_RTN_MCPS:
+ pdev->tuning_parms.tp_lite_long_min_count_rate_rtn_mcps =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_MED_MIN_COUNT_RATE_RTN_MCPS:
+ pdev->tuning_parms.tp_lite_med_min_count_rate_rtn_mcps =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_SHORT_MIN_COUNT_RATE_RTN_MCPS:
+ pdev->tuning_parms.tp_lite_short_min_count_rate_rtn_mcps =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_SIGMA_EST_PULSE_WIDTH:
+ pdev->tuning_parms.tp_lite_sigma_est_pulse_width_ns =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_SIGMA_EST_AMB_WIDTH_NS:
+ pdev->tuning_parms.tp_lite_sigma_est_amb_width_ns =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_SIGMA_REF_MM:
+ pdev->tuning_parms.tp_lite_sigma_ref_mm =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_RIT_MULT:
+ pdev->xtalk_cfg.crosstalk_range_ignore_threshold_mult =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_SEED_CONFIG:
+ pdev->tuning_parms.tp_lite_seed_cfg =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_QUANTIFIER:
+ pdev->tuning_parms.tp_lite_quantifier =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_FIRST_ORDER_SELECT:
+ pdev->tuning_parms.tp_lite_first_order_select =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_XTALK_MARGIN_KCPS:
+ pdev->xtalk_cfg.lite_mode_crosstalk_margin_kcps =
+ (int16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_LONG_RANGE:
+ pdev->tuning_parms.tp_init_phase_rtn_lite_long =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_MED_RANGE:
+ pdev->tuning_parms.tp_init_phase_rtn_lite_med =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_SHORT_RANGE:
+ pdev->tuning_parms.tp_init_phase_rtn_lite_short =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_LONG_RANGE:
+ pdev->tuning_parms.tp_init_phase_ref_lite_long =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_MED_RANGE:
+ pdev->tuning_parms.tp_init_phase_ref_lite_med =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_SHORT_RANGE:
+ pdev->tuning_parms.tp_init_phase_ref_lite_short =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_TIMED_SEED_CONFIG:
+ pdev->tuning_parms.tp_timed_seed_cfg =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_VHV_LOOPBOUND:
+ pdev->stat_nvm.vhv_config__timeout_macrop_loop_bound =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_REFSPADCHAR_DEVICE_TEST_MODE:
+ pdev->refspadchar.device_test_mode =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_REFSPADCHAR_VCSEL_PERIOD:
+ pdev->refspadchar.vcsel_period =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_REFSPADCHAR_PHASECAL_TIMEOUT_US:
+ pdev->refspadchar.timeout_us =
+ (uint32_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_REFSPADCHAR_TARGET_COUNT_RATE_MCPS:
+ pdev->refspadchar.target_count_rate_mcps =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_REFSPADCHAR_MIN_COUNTRATE_LIMIT_MCPS:
+ pdev->refspadchar.min_count_rate_limit_mcps =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_REFSPADCHAR_MAX_COUNTRATE_LIMIT_MCPS:
+ pdev->refspadchar.max_count_rate_limit_mcps =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_OFFSET_CAL_DSS_RATE_MCPS:
+ pdev->offsetcal_cfg.dss_config__target_total_rate_mcps =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_OFFSET_CAL_PHASECAL_TIMEOUT_US:
+ pdev->offsetcal_cfg.phasecal_config_timeout_us =
+ (uint32_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_OFFSET_CAL_MM_TIMEOUT_US:
+ pdev->offsetcal_cfg.mm_config_timeout_us =
+ (uint32_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_OFFSET_CAL_RANGE_TIMEOUT_US:
+ pdev->offsetcal_cfg.range_config_timeout_us =
+ (uint32_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_OFFSET_CAL_PRE_SAMPLES:
+ pdev->offsetcal_cfg.pre_num_of_samples =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_OFFSET_CAL_MM1_SAMPLES:
+ pdev->offsetcal_cfg.mm1_num_of_samples =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_OFFSET_CAL_MM2_SAMPLES:
+ pdev->offsetcal_cfg.mm2_num_of_samples =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_SPADMAP_VCSEL_PERIOD:
+ pdev->ssc_cfg.vcsel_period =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_SPADMAP_VCSEL_START:
+ pdev->ssc_cfg.vcsel_start =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_SPADMAP_RATE_LIMIT_MCPS:
+ pdev->ssc_cfg.rate_limit_mcps =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS:
+ pdev->tuning_parms.tp_dss_target_lite_mcps =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_TIMED_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS:
+ pdev->tuning_parms.tp_dss_target_timed_mcps =
+ (uint16_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_PHASECAL_CONFIG_TIMEOUT_US:
+ pdev->tuning_parms.tp_phasecal_timeout_lite_us =
+ (uint32_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_TIMED_PHASECAL_CONFIG_TIMEOUT_US:
+ pdev->tuning_parms.tp_phasecal_timeout_timed_us =
+ (uint32_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_MM_CONFIG_TIMEOUT_US:
+ pdev->tuning_parms.tp_mm_timeout_lite_us =
+ (uint32_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_TIMED_MM_CONFIG_TIMEOUT_US:
+ pdev->tuning_parms.tp_mm_timeout_timed_us =
+ (uint32_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LITE_RANGE_CONFIG_TIMEOUT_US:
+ pdev->tuning_parms.tp_range_timeout_lite_us =
+ (uint32_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_TIMED_RANGE_CONFIG_TIMEOUT_US:
+ pdev->tuning_parms.tp_range_timeout_timed_us =
+ (uint32_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LOWPOWERAUTO_VHV_LOOP_BOUND:
+ pdev->low_power_auto_data.vhv_loop_bound =
+ (uint8_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LOWPOWERAUTO_MM_CONFIG_TIMEOUT_US:
+ pdev->tuning_parms.tp_mm_timeout_lpa_us =
+ (uint32_t)tuning_parm_value;
+ break;
+ case VL53L1_TUNINGPARM_LOWPOWERAUTO_RANGE_CONFIG_TIMEOUT_US:
+ pdev->tuning_parms.tp_range_timeout_lpa_us =
+ (uint32_t)tuning_parm_value;
+ break;
+
+
+ default:
+ status = VL53L1_ERROR_INVALID_PARAMS;
+ break;
+
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+/* End Patch_AddedTuningParms_11761 */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api_debug.c b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api_debug.c
new file mode 100644
index 0000000..8aaf0b4
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api_debug.c
@@ -0,0 +1,1741 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_api_debug.c
+ * @brief EwokPlus25 low level Driver debug function definition
+ */
+
+#include "vl53l1_ll_def.h"
+#include "vl53l1_ll_device.h"
+#include "vl53l1_register_structs.h"
+#include "vl53l1_core.h"
+#include "vl53l1_api_debug.h"
+
+#define LOG_FUNCTION_START(fmt, ...) \
+ _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
+#define LOG_FUNCTION_END(status, ...) \
+ _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
+#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
+ _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE, status, \
+ fmt, ##__VA_ARGS__)
+
+#define trace_print(level, ...) \
+ _LOG_TRACE_PRINT(trace_flags, \
+ level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
+
+
+/* Start Patch_AdditionalDebugData_11823 */
+
+VL53L1_Error VL53L1_get_additional_data(
+ VL53L1_DEV Dev,
+ VL53L1_additional_data_t *pdata)
+{
+ /*
+ * Gets the addition debug data
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ /* get LL Driver configuration parameters */
+
+ pdata->preset_mode = pdev->preset_mode;
+ pdata->measurement_mode = pdev->measurement_mode;
+
+ pdata->phasecal_config_timeout_us = pdev->phasecal_config_timeout_us;
+ pdata->mm_config_timeout_us = pdev->mm_config_timeout_us;
+ pdata->range_config_timeout_us = pdev->range_config_timeout_us;
+ pdata->inter_measurement_period_ms = pdev->inter_measurement_period_ms;
+ pdata->dss_config__target_total_rate_mcps =
+ pdev->dss_config__target_total_rate_mcps;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+/* End Patch_AdditionalDebugData_11823 */
+
+#ifdef VL53L1_LOG_ENABLE
+
+void VL53L1_signed_fixed_point_sprintf(
+ int32_t signed_fp_value,
+ uint8_t frac_bits,
+ uint16_t buf_size,
+ char *pbuffer)
+{
+ /*
+ * Converts input signed fixed point number into a string
+ */
+
+ uint32_t fp_value = 0;
+ uint32_t unity_fp_value = 0;
+ uint32_t sign_bit = 0;
+ uint32_t int_part = 0;
+ uint32_t frac_part = 0;
+ uint32_t dec_points = 0;
+ uint32_t dec_scaler = 0;
+ uint32_t dec_part = 0;
+
+ uint64_t tmp_long_int = 0;
+
+ char fmt[VL53L1_MAX_STRING_LENGTH];
+
+ SUPPRESS_UNUSED_WARNING(buf_size);
+
+ /* split into integer and fractional values */
+
+ sign_bit = signed_fp_value >> 31;
+
+ if (sign_bit > 0) {
+ fp_value = 0x80000000 -
+ (0x7FFFFFFF & (uint32_t)signed_fp_value);
+ } else
+ fp_value = (uint32_t)signed_fp_value;
+
+ int_part = fp_value >> frac_bits;
+ unity_fp_value = 0x01 << frac_bits;
+ frac_part = fp_value & (unity_fp_value-1);
+
+ /* Calculate decimal scale factor and required decimal points
+ * min number of displayed places is 2
+ */
+ dec_points = 2;
+ dec_scaler = 100;
+
+ while (dec_scaler < unity_fp_value) {
+ dec_points++;
+ dec_scaler *= 10;
+ }
+
+ /* Build format string */
+ if (sign_bit > 0)
+ sprintf(fmt, "-%%u.%%0%uu", dec_points);
+ else
+ sprintf(fmt, "%%u.%%0%uu", dec_points);
+
+ /* Convert fractional part into a decimal
+ * need 64-bit head room at this point
+ */
+ tmp_long_int = (uint64_t)frac_part * (uint64_t)dec_scaler;
+ tmp_long_int += (uint64_t)unity_fp_value/2;
+
+ tmp_long_int = do_division_u(tmp_long_int, (uint64_t)unity_fp_value);
+
+ dec_part = (uint32_t)tmp_long_int;
+
+ /* Generate string for fixed point number */
+ sprintf(
+ pbuffer,
+ fmt,
+ int_part,
+ dec_part);
+}
+
+
+void VL53L1_print_static_nvm_managed(
+ VL53L1_static_nvm_managed_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags)
+{
+ /**
+ * Prints out VL53L1_static_nvm_managed_t for debug
+ */
+
+ char fp_text[VL53L1_MAX_STRING_LENGTH];
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = 0x%02X\n",
+ pprefix,
+ "i2c_slave__device_address",
+ pdata->i2c_slave__device_address);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "ana_config__vhv_ref_sel_vddpix",
+ pdata->ana_config__vhv_ref_sel_vddpix);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "ana_config__vhv_ref_sel_vquench",
+ pdata->ana_config__vhv_ref_sel_vquench);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "ana_config__reg_avdd1v2_sel",
+ pdata->ana_config__reg_avdd1v2_sel);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "ana_config__fast_osc__trim",
+ pdata->ana_config__fast_osc__trim);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->osc_measured__fast_osc__frequency,
+ 12,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "osc_measured__fast_osc__frequency",
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "vhv_config__timeout_macrop_loop_bound",
+ pdata->vhv_config__timeout_macrop_loop_bound);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "vhv_config__count_thresh",
+ pdata->vhv_config__count_thresh);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "vhv_config__offset",
+ pdata->vhv_config__offset);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "vhv_config__init",
+ pdata->vhv_config__init);
+}
+
+
+void VL53L1_print_customer_nvm_managed(
+ VL53L1_customer_nvm_managed_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags)
+{
+ /*
+ * Prints out VL53L1_customer_nvm_managed_t for debug
+ */
+
+ char fp_text[VL53L1_MAX_STRING_LENGTH];
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_ref_0",
+ pdata->global_config__spad_enables_ref_0);
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_ref_1",
+ pdata->global_config__spad_enables_ref_1);
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_ref_2",
+ pdata->global_config__spad_enables_ref_2);
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_ref_3",
+ pdata->global_config__spad_enables_ref_3);
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_ref_4",
+ pdata->global_config__spad_enables_ref_4);
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_ref_5",
+ pdata->global_config__spad_enables_ref_5);
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__ref_en_start_select",
+ pdata->global_config__ref_en_start_select);
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "ref_spad_man__num_requested_ref_spads",
+ pdata->ref_spad_man__num_requested_ref_spads);
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "ref_spad_man__ref_location",
+ pdata->ref_spad_man__ref_location);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->algo__crosstalk_compensation_plane_offset_kcps,
+ 9,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "algo__crosstalk_compensation_plane_offset_kcps",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->algo__crosstalk_compensation_x_plane_gradient_kcps,
+ 11,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "algo__crosstalk_compensation_x_plane_gradient_kcps",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->algo__crosstalk_compensation_y_plane_gradient_kcps,
+ 11,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "algo__crosstalk_compensation_y_plane_gradient_kcps",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->ref_spad_char__total_rate_target_mcps,
+ 7,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "ref_spad_char__total_rate_target_mcps",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->algo__part_to_part_range_offset_mm,
+ 2,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "algo__part_to_part_range_offset_mm",
+ fp_text);
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %d\n",
+ pprefix,
+ "mm_config__inner_offset_mm",
+ pdata->mm_config__inner_offset_mm);
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %d\n",
+ pprefix,
+ "mm_config__outer_offset_mm",
+ pdata->mm_config__outer_offset_mm);
+}
+
+
+void VL53L1_print_nvm_copy_data(
+ VL53L1_nvm_copy_data_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags)
+{
+ /**
+ * Prints out VL53L1_nvm_copy_data_t for debug
+ */
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "identification__model_id",
+ pdata->identification__model_id);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "identification__module_type",
+ pdata->identification__module_type);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "identification__revision_id",
+ pdata->identification__revision_id);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "identification__module_id",
+ pdata->identification__module_id);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "ana_config__fast_osc__trim_max",
+ pdata->ana_config__fast_osc__trim_max);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "ana_config__fast_osc__freq_set",
+ pdata->ana_config__fast_osc__freq_set);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "ana_config__vcsel_trim",
+ pdata->ana_config__vcsel_trim);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "ana_config__vcsel_selion",
+ pdata->ana_config__vcsel_selion);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "ana_config__vcsel_selion_max",
+ pdata->ana_config__vcsel_selion_max);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "protected_laser_safety__lock_bit",
+ pdata->protected_laser_safety__lock_bit);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "laser_safety__key",
+ pdata->laser_safety__key);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "laser_safety__key_ro",
+ pdata->laser_safety__key_ro);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "laser_safety__clip",
+ pdata->laser_safety__clip);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "laser_safety__mult",
+ pdata->laser_safety__mult);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_0",
+ pdata->global_config__spad_enables_rtn_0);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_1",
+ pdata->global_config__spad_enables_rtn_1);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_2",
+ pdata->global_config__spad_enables_rtn_2);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_3",
+ pdata->global_config__spad_enables_rtn_3);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_4",
+ pdata->global_config__spad_enables_rtn_4);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_5",
+ pdata->global_config__spad_enables_rtn_5);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_6",
+ pdata->global_config__spad_enables_rtn_6);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_7",
+ pdata->global_config__spad_enables_rtn_7);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_8",
+ pdata->global_config__spad_enables_rtn_8);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_9",
+ pdata->global_config__spad_enables_rtn_9);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_10",
+ pdata->global_config__spad_enables_rtn_10);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_11",
+ pdata->global_config__spad_enables_rtn_11);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_12",
+ pdata->global_config__spad_enables_rtn_12);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_13",
+ pdata->global_config__spad_enables_rtn_13);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_14",
+ pdata->global_config__spad_enables_rtn_14);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_15",
+ pdata->global_config__spad_enables_rtn_15);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_16",
+ pdata->global_config__spad_enables_rtn_16);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_17",
+ pdata->global_config__spad_enables_rtn_17);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_18",
+ pdata->global_config__spad_enables_rtn_18);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_19",
+ pdata->global_config__spad_enables_rtn_19);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_20",
+ pdata->global_config__spad_enables_rtn_20);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_21",
+ pdata->global_config__spad_enables_rtn_21);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_22",
+ pdata->global_config__spad_enables_rtn_22);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_23",
+ pdata->global_config__spad_enables_rtn_23);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_24",
+ pdata->global_config__spad_enables_rtn_24);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_25",
+ pdata->global_config__spad_enables_rtn_25);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_26",
+ pdata->global_config__spad_enables_rtn_26);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_27",
+ pdata->global_config__spad_enables_rtn_27);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_28",
+ pdata->global_config__spad_enables_rtn_28);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_29",
+ pdata->global_config__spad_enables_rtn_29);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_30",
+ pdata->global_config__spad_enables_rtn_30);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_config__spad_enables_rtn_31",
+ pdata->global_config__spad_enables_rtn_31);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "roi_config__mode_roi_centre_spad",
+ pdata->roi_config__mode_roi_centre_spad);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = 0x%02X\n",
+ pprefix,
+ "roi_config__mode_roi_xy_size",
+ pdata->roi_config__mode_roi_xy_size);
+}
+
+
+void VL53L1_print_range_data(
+ VL53L1_range_data_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags)
+{
+ /*
+ * Prints out the range data structure for debug
+ */
+
+ char fp_text[VL53L1_MAX_STRING_LENGTH];
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "range_id",
+ pdata->range_id);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "time_stamp",
+ pdata->time_stamp);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->width,
+ 4, VL53L1_MAX_STRING_LENGTH, fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "width",
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "woi",
+ pdata->woi);
+
+ /* Fast Oscillator Frequency */
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->fast_osc_frequency,
+ 12, VL53L1_MAX_STRING_LENGTH, fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "fast_osc_frequency",
+ fp_text);
+
+ /* Zero Distance Phase */
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->zero_distance_phase,
+ 11, VL53L1_MAX_STRING_LENGTH, fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "zero_distance_phase",
+ fp_text);
+
+ /* Actual effective SPAD count */
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->actual_effective_spads,
+ 8, VL53L1_MAX_STRING_LENGTH, fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "actual_effective_spad",
+ fp_text);
+
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "total_periods_elapsed",
+ pdata->total_periods_elapsed);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "peak_duration_us",
+ pdata->peak_duration_us);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "woi_duration_us",
+ pdata->woi_duration_us);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %d\n",
+ pprefix,
+ "ambient_window_events",
+ pdata->ambient_window_events);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %d\n",
+ pprefix,
+ "ranging_total_events",
+ pdata->ranging_total_events);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %d\n",
+ pprefix,
+ "signal_total_events",
+ pdata->signal_total_events);
+
+ /* Rates */
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->peak_signal_count_rate_mcps,
+ 7, VL53L1_MAX_STRING_LENGTH, fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "peak_signal_count_rate_mcps",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->avg_signal_count_rate_mcps,
+ 7, VL53L1_MAX_STRING_LENGTH, fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "avg_signal_count_rate_mcps",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->ambient_count_rate_mcps,
+ 7, VL53L1_MAX_STRING_LENGTH, fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "ambient_count_rate_mcps",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->total_rate_per_spad_mcps,
+ 13, VL53L1_MAX_STRING_LENGTH, fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "total_rate_per_spad_mcps",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->peak_rate_per_spad_kcps,
+ 11, VL53L1_MAX_STRING_LENGTH, fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "peak_rate_per_spad_kcps",
+ fp_text);
+
+ /* Sigma */
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->sigma_mm,
+ 2, VL53L1_MAX_STRING_LENGTH, fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "sigma_mm",
+ fp_text);
+
+ /* Phase */
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->median_phase,
+ 11, VL53L1_MAX_STRING_LENGTH, fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "median_phase",
+ fp_text);
+
+ /* Offset Corrected Range */
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %d\n",
+ pprefix,
+ "median_range_mm",
+ pdata->median_range_mm);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "range_status",
+ pdata->range_status);
+}
+
+
+void VL53L1_print_range_results(
+ VL53L1_range_results_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags)
+{
+ /*
+ * Prints out the range results data structure for debug
+ */
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "cfg_device_state",
+ pdata->cfg_device_state);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "rd_device_state",
+ pdata->rd_device_state);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "stream_count",
+ pdata->stream_count);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "device_status",
+ pdata->device_status);
+
+}
+
+void VL53L1_print_offset_range_results(
+ VL53L1_offset_range_results_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags)
+{
+ /*
+ * Prints out the offset range results data structure for debug
+ */
+
+ char pre_text[VL53L1_MAX_STRING_LENGTH];
+ char *ppre_text = &(pre_text[0]);
+
+ uint8_t i = 0;
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "cal_distance_mm",
+ pdata->cal_distance_mm);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "cal_status",
+ pdata->cal_status);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "cal_report",
+ pdata->cal_report);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "max_results",
+ pdata->max_results);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "active_results",
+ pdata->active_results);
+
+ for (i = 0 ; i < pdata->active_results ; i++) {
+ sprintf(ppre_text, "%sdata[%u].", pprefix, i);
+ VL53L1_print_offset_range_data(
+ &(pdata->data[i]),
+ ppre_text, trace_flags);
+ }
+}
+
+void VL53L1_print_offset_range_data(
+ VL53L1_offset_range_data_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags)
+{
+ /*
+ * Prints out the xtalk range (ROI) data structure for debug
+ */
+
+ char fp_text[VL53L1_MAX_STRING_LENGTH];
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "preset_mode",
+ pdata->preset_mode);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "dss_config__roi_mode_control",
+ pdata->dss_config__roi_mode_control);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->dss_config__manual_effective_spads_select,
+ 8,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "dss_config__manual_effective_spads_select",
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "no_of_samples",
+ pdata->no_of_samples);
+
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->effective_spads,
+ 8,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "effective_spads",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->peak_rate_mcps,
+ 7,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "peak_rate_mcps",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->sigma_mm,
+ 2,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "sigma_mm",
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %d\n",
+ pprefix,
+ "median_range_mm",
+ pdata->median_range_mm);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %d\n",
+ pprefix,
+ "range_mm_offset",
+ pdata->range_mm_offset);
+}
+
+void VL53L1_print_additional_offset_cal_data(
+ VL53L1_additional_offset_cal_data_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags)
+{
+ /*
+ * Prints out the xtalk range (ROI) data structure for debug
+ */
+
+ char fp_text[VL53L1_MAX_STRING_LENGTH];
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->result__mm_inner_actual_effective_spads,
+ 8,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "result__mm_inner_actual_effective_spads",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->result__mm_outer_actual_effective_spads,
+ 8,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "result__mm_outer_actual_effective_spads",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->result__mm_inner_peak_signal_count_rtn_mcps,
+ 7,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "result__mm_inner_peak_signal_count_rtn_mcps",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->result__mm_outer_peak_signal_count_rtn_mcps,
+ 7,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "result__mm_outer_peak_signal_count_rtn_mcps",
+ fp_text);
+}
+
+
+void VL53L1_print_cal_peak_rate_map(
+ VL53L1_cal_peak_rate_map_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags)
+{
+ /*
+ * Prints out peak rate map structure for debug
+ */
+
+ char fp_text[VL53L1_MAX_STRING_LENGTH];
+ char pre_text[VL53L1_MAX_STRING_LENGTH];
+ char *ppre_text = &(pre_text[0]);
+
+ uint8_t i = 0;
+ uint8_t x = 0;
+ uint8_t y = 0;
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->cal_distance_mm,
+ 2,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "cal_distance_mm",
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "max_samples",
+ pdata->max_samples);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "width",
+ pdata->width);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "height",
+ pdata->height);
+
+ i = 0;
+ for (y = 0 ; y < pdata->height ; y++) {
+ for (x = 0 ; x < pdata->width ; x++) {
+
+ sprintf(ppre_text, "%speak_rate_mcps[%u]", pprefix, i);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->peak_rate_mcps[i],
+ 7,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s = %s\n",
+ ppre_text,
+ fp_text);
+
+ i++;
+ }
+ }
+}
+
+void VL53L1_print_additional_data(
+ VL53L1_additional_data_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags)
+{
+
+ /*
+ * Prints out the Additional data structure for debug
+ */
+
+ char fp_text[VL53L1_MAX_STRING_LENGTH];
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "preset_mode",
+ pdata->preset_mode);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "measurement_mode",
+ pdata->measurement_mode);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "phasecal_config_timeout_us",
+ pdata->phasecal_config_timeout_us);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "mm_config_timeout_us",
+ pdata->mm_config_timeout_us);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "range_config_timeout_us",
+ pdata->range_config_timeout_us);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "inter_measurement_period_ms",
+ pdata->inter_measurement_period_ms);
+
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->dss_config__target_total_rate_mcps,
+ 7,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "dss_config__target_total_rate_mcps",
+ fp_text);
+
+}
+
+
+void VL53L1_print_gain_calibration_data(
+ VL53L1_gain_calibration_data_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags)
+{
+ /*
+ * Prints out the LL Driver state data for debug
+ */
+
+ char fp_text[VL53L1_MAX_STRING_LENGTH];
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->standard_ranging_gain_factor,
+ 11,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "standard_ranging_gain_factor",
+ fp_text);
+
+}
+
+
+void VL53L1_print_xtalk_config(
+ VL53L1_xtalk_config_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags)
+{
+ /*
+ * Prints out the xtalk config data structure for debug
+ */
+
+ char fp_text[VL53L1_MAX_STRING_LENGTH];
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->algo__crosstalk_compensation_plane_offset_kcps,
+ 9,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "algo__crosstalk_compensation_plane_offset_kcps",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->algo__crosstalk_compensation_x_plane_gradient_kcps,
+ 11,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "algo__crosstalk_compensation_x_plane_gradient_kcps",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->algo__crosstalk_compensation_y_plane_gradient_kcps,
+ 11,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "algo__crosstalk_compensation_y_plane_gradient_kcps",
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "global_crosstalk_compensation_enable",
+ pdata->global_crosstalk_compensation_enable);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->lite_mode_crosstalk_margin_kcps,
+ 9,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "lite_mode_crosstalk_margin_kcps",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->crosstalk_range_ignore_threshold_mult,
+ 5,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "crosstalk_range_ignore_threshold_mult",
+ fp_text);
+
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->crosstalk_range_ignore_threshold_rate_mcps,
+ 13,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "crosstalk_range_ignore_threshold_rate_mcps",
+ fp_text);
+
+}
+
+
+
+void VL53L1_print_optical_centre(
+ VL53L1_optical_centre_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags)
+{
+
+ /* Prints out the optical centre data structure for debug
+ */
+
+ char fp_text[VL53L1_MAX_STRING_LENGTH];
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->x_centre,
+ 4,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "x_centre",
+ fp_text);
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pdata->y_centre,
+ 4,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %s\n",
+ pprefix,
+ "y_centre",
+ fp_text);
+}
+
+
+void VL53L1_print_user_zone(
+ VL53L1_user_zone_t *pdata,
+ char *pprefix,
+ uint32_t trace_flags)
+{
+
+ /* Prints out the zone (ROI) data structure for debug
+ */
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "x_centre",
+ pdata->x_centre);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "y_centre",
+ pdata->y_centre);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "width",
+ pdata->width);
+
+ trace_print(VL53L1_TRACE_LEVEL_INFO,
+ "%s%s = %u\n",
+ pprefix,
+ "height",
+ pdata->height);
+}
+
+
+void VL53L1_print_spad_rate_data(
+ VL53L1_spad_rate_data_t *pspad_rates,
+ char *pprefix,
+ uint32_t trace_flags)
+{
+
+ /**
+ * Print per SPAD rates generated by SSC
+ */
+
+ uint16_t spad_no = 0;
+ uint8_t row = 0;
+ uint8_t col = 0;
+
+ char fp_text[VL53L1_MAX_STRING_LENGTH];
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%8s,%4s,%4s, %s\n",
+ pprefix,
+ "spad_no",
+ "row",
+ "col",
+ "peak_rate_mcps");
+
+ for (spad_no = 0 ; spad_no < pspad_rates->no_of_values ; spad_no++) {
+
+ /* generate row / col location from SPAD number */
+ VL53L1_decode_row_col(
+ (uint8_t)spad_no,
+ &row,
+ &col);
+
+ /* Convert fixed point rate value to string */
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pspad_rates->rate_data[spad_no],
+ pspad_rates->fractional_bits,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ /* Print data */
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%8u,%4u,%4u, %s\n",
+ pprefix,
+ spad_no,
+ row,
+ col,
+ fp_text);
+ }
+}
+
+
+void VL53L1_print_spad_rate_map(
+ VL53L1_spad_rate_data_t *pspad_rates,
+ char *pprefix,
+ uint32_t trace_flags)
+{
+
+ /**
+ * Print per SPAD rates generated by SSC as a map
+ */
+
+ uint8_t spad_no = 0;
+ uint8_t row = 0;
+ uint8_t col = 0;
+
+ char fp_text[VL53L1_MAX_STRING_LENGTH];
+
+ /* Print column headers */
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%4s",
+ pprefix,
+ " ");
+
+ for (col = 0 ; col < VL53L1_SPAD_ARRAY_WIDTH ; col++)
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ ",%8u",
+ col);
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "\n");
+
+ /* Print rate data */
+
+ for (row = 0 ; row < VL53L1_SPAD_ARRAY_HEIGHT ; row++) {
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "%s%4u",
+ pprefix,
+ row);
+
+ for (col = 0 ; col < VL53L1_SPAD_ARRAY_HEIGHT ; col++) {
+
+ /* generate SPAD number from (row, col) location */
+
+ VL53L1_encode_row_col(
+ row,
+ col,
+ &spad_no);
+
+ /* Convert fixed point rate value to string */
+
+ VL53L1_signed_fixed_point_sprintf(
+ (int32_t)pspad_rates->rate_data[spad_no],
+ pspad_rates->fractional_bits,
+ VL53L1_MAX_STRING_LENGTH,
+ fp_text);
+
+ /* Print data */
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ ",%8s",
+ fp_text);
+ }
+
+ trace_print(
+ VL53L1_TRACE_LEVEL_INFO,
+ "\n");
+ }
+}
+
+
+#endif /* VL53L1_LOG_ENABLE */
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api_preset_modes.c b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api_preset_modes.c
new file mode 100644
index 0000000..96ed46d
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api_preset_modes.c
@@ -0,0 +1,1407 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_api_preset_modes.c
+ *
+ * @brief EwokPlus25 API Preset Modes definitions
+ */
+
+#include "vl53l1_ll_def.h"
+#include "vl53l1_platform_log.h"
+#include "vl53l1_register_structs.h"
+#include "vl53l1_register_settings.h"
+#include "vl53l1_core.h"
+#include "vl53l1_api_preset_modes.h"
+#include "vl53l1_tuning_parm_defaults.h"
+
+
+#define LOG_FUNCTION_START(fmt, ...) \
+ _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
+#define LOG_FUNCTION_END(status, ...) \
+ _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_API, status, ##__VA_ARGS__)
+#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
+ _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_API, status, fmt, ##__VA_ARGS__)
+
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_init_refspadchar_config_struct(
+ VL53L1_refspadchar_config_t *pdata)
+{
+ /*
+ * Initializes Ref SPAD Char data structures preset mode
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Reference SPAD Char Configuration
+ *
+ * vcsel_period = 0x0B - 24 clock VCSEL period
+ * timeout_us = 1000 - Set 1000us phase cal timeout
+ * target_count_rate_mcps = 0x0A00 - 9.7 -> 20.0 Mcps
+ * min_count_rate_limit_mcps = 0x0500 - 9.7 -> 10.0 Mcps
+ * max_count_rate_limit_mcps = 0x1400 - 9.7 -> 40.0 Mcps
+ */
+
+ pdata->device_test_mode =
+ VL53L1_TUNINGPARM_REFSPADCHAR_DEVICE_TEST_MODE_DEFAULT;
+ pdata->vcsel_period =
+ VL53L1_TUNINGPARM_REFSPADCHAR_VCSEL_PERIOD_DEFAULT;
+ pdata->timeout_us =
+ VL53L1_TUNINGPARM_REFSPADCHAR_PHASECAL_TIMEOUT_US_DEFAULT;
+ pdata->target_count_rate_mcps =
+ VL53L1_TUNINGPARM_REFSPADCHAR_TARGET_COUNT_RATE_MCPS_DEFAULT;
+ pdata->min_count_rate_limit_mcps =
+ VL53L1_TUNINGPARM_REFSPADCHAR_MIN_COUNTRATE_LIMIT_MCPS_DEFAULT;
+ pdata->max_count_rate_limit_mcps =
+ VL53L1_TUNINGPARM_REFSPADCHAR_MAX_COUNTRATE_LIMIT_MCPS_DEFAULT;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_init_ssc_config_struct(
+ VL53L1_ssc_config_t *pdata)
+{
+ /*
+ * Initializes SPAD Self Check (SSC) data structure
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* SPAD Select Check Configuration */
+
+ /* 0 - store RTN count rates
+ * 1 - store REF count rates
+ */
+ pdata->array_select = VL53L1_DEVICESSCARRAY_RTN;
+
+ /* VCSEL period register value 0x12 (18) -> 38 VCSEL clocks */
+ pdata->vcsel_period =
+ VL53L1_TUNINGPARM_SPADMAP_VCSEL_PERIOD_DEFAULT;
+
+ /* VCSEL pulse start */
+ pdata->vcsel_start =
+ VL53L1_TUNINGPARM_SPADMAP_VCSEL_START_DEFAULT;
+
+ /* VCSEL pulse width */
+ pdata->vcsel_width = 0x02;
+
+ /* SSC timeout [us] */
+ pdata->timeout_us = 36000;
+
+ /* SSC rate limit [Mcps]
+ * - 9.7 for VCSEL ON
+ * - 1.15 for VCSEL OFF
+ */
+ pdata->rate_limit_mcps =
+ VL53L1_TUNINGPARM_SPADMAP_RATE_LIMIT_MCPS_DEFAULT;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_init_xtalk_config_struct(
+ VL53L1_customer_nvm_managed_t *pnvm,
+ VL53L1_xtalk_config_t *pdata)
+{
+ /*
+ * Initializes Xtalk Config structure
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Xtalk default configuration
+ *
+ * algo__crosstalk_compensation_plane_offset_kcps
+ * = pdev->customer.algo__crosstalk_compensation_plane_offset_kcps
+ * algo__crosstalk_compensation_x_plane_gradient_kcps
+ * = pdev->customer.algo__crosstalk_compensation_x_plane_gradient_kcps
+ * algo__crosstalk_compensation_y_plane_gradient_kcps
+ * = pdev->customer.algo__crosstalk_compensation_y_plane_gradient_kcps
+ *
+ */
+
+ /* Store xtalk data into golden copy */
+
+ pdata->algo__crosstalk_compensation_plane_offset_kcps =
+ pnvm->algo__crosstalk_compensation_plane_offset_kcps;
+ pdata->algo__crosstalk_compensation_x_plane_gradient_kcps =
+ pnvm->algo__crosstalk_compensation_x_plane_gradient_kcps;
+ pdata->algo__crosstalk_compensation_y_plane_gradient_kcps =
+ pnvm->algo__crosstalk_compensation_y_plane_gradient_kcps;
+
+ /* Store NVM defaults for later use */
+
+ pdata->nvm_default__crosstalk_compensation_plane_offset_kcps =
+ (uint32_t)pnvm->algo__crosstalk_compensation_plane_offset_kcps;
+ pdata->nvm_default__crosstalk_compensation_x_plane_gradient_kcps =
+ pnvm->algo__crosstalk_compensation_x_plane_gradient_kcps;
+ pdata->nvm_default__crosstalk_compensation_y_plane_gradient_kcps =
+ pnvm->algo__crosstalk_compensation_y_plane_gradient_kcps;
+
+ pdata->lite_mode_crosstalk_margin_kcps =
+ VL53L1_TUNINGPARM_LITE_XTALK_MARGIN_KCPS_DEFAULT;
+
+ /* Default for Range Ignore Threshold Mult = 2.0 */
+
+ pdata->crosstalk_range_ignore_threshold_mult =
+ VL53L1_TUNINGPARM_LITE_RIT_MULT_DEFAULT;
+
+ if ((pdata->algo__crosstalk_compensation_plane_offset_kcps == 0x00)
+ && (pdata->algo__crosstalk_compensation_x_plane_gradient_kcps == 0x00)
+ && (pdata->algo__crosstalk_compensation_y_plane_gradient_kcps == 0x00))
+ pdata->global_crosstalk_compensation_enable = 0x00;
+ else
+ pdata->global_crosstalk_compensation_enable = 0x01;
+
+
+ if ((status == VL53L1_ERROR_NONE) &&
+ (pdata->global_crosstalk_compensation_enable == 0x01)) {
+ pdata->crosstalk_range_ignore_threshold_rate_mcps =
+ VL53L1_calc_range_ignore_threshold(
+ pdata->algo__crosstalk_compensation_plane_offset_kcps,
+ pdata->algo__crosstalk_compensation_x_plane_gradient_kcps,
+ pdata->algo__crosstalk_compensation_y_plane_gradient_kcps,
+ pdata->crosstalk_range_ignore_threshold_mult);
+ } else {
+ pdata->crosstalk_range_ignore_threshold_rate_mcps = 0;
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_init_offset_cal_config_struct(
+ VL53L1_offsetcal_config_t *pdata)
+{
+ /*
+ * Initializes Offset Calibration Config structure
+ * - for use with VL53L1_run_offset_calibration()
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Preset Timeout and DSS defaults */
+
+ pdata->dss_config__target_total_rate_mcps =
+ VL53L1_TUNINGPARM_OFFSET_CAL_DSS_RATE_MCPS_DEFAULT;
+ /* 20.0 Mcps */
+ pdata->phasecal_config_timeout_us =
+ VL53L1_TUNINGPARM_OFFSET_CAL_PHASECAL_TIMEOUT_US_DEFAULT;
+ /* 1000 us */
+ pdata->range_config_timeout_us =
+ VL53L1_TUNINGPARM_OFFSET_CAL_RANGE_TIMEOUT_US_DEFAULT;
+ /* 13000 us */
+ pdata->mm_config_timeout_us =
+ VL53L1_TUNINGPARM_OFFSET_CAL_MM_TIMEOUT_US_DEFAULT;
+ /* 13000 us - Added as part of Patch_AddedOffsetCalMMTuningParm_11791 */
+
+ /* Init number of averaged samples */
+
+ pdata->pre_num_of_samples =
+ VL53L1_TUNINGPARM_OFFSET_CAL_PRE_SAMPLES_DEFAULT;
+ pdata->mm1_num_of_samples =
+ VL53L1_TUNINGPARM_OFFSET_CAL_MM1_SAMPLES_DEFAULT;
+ pdata->mm2_num_of_samples =
+ VL53L1_TUNINGPARM_OFFSET_CAL_MM2_SAMPLES_DEFAULT;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+VL53L1_Error VL53L1_init_tuning_parm_storage_struct(
+ VL53L1_tuning_parm_storage_t *pdata)
+{
+ /*
+ * Initializes Tuning Param storage structure
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Default configuration
+ *
+ * - Custom overwrite possible from vl53l1_set_tuning_parms()
+ * - via tuning file input
+ */
+
+ pdata->tp_tuning_parm_version =
+ VL53L1_TUNINGPARM_VERSION_DEFAULT;
+ pdata->tp_tuning_parm_key_table_version =
+ VL53L1_TUNINGPARM_KEY_TABLE_VERSION_DEFAULT;
+ pdata->tp_tuning_parm_lld_version =
+ VL53L1_TUNINGPARM_LLD_VERSION_DEFAULT;
+ pdata->tp_init_phase_rtn_lite_long =
+ VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_LONG_RANGE_DEFAULT;
+ pdata->tp_init_phase_rtn_lite_med =
+ VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_MED_RANGE_DEFAULT;
+ pdata->tp_init_phase_rtn_lite_short =
+ VL53L1_TUNINGPARM_INITIAL_PHASE_RTN_LITE_SHORT_RANGE_DEFAULT;
+ pdata->tp_init_phase_ref_lite_long =
+ VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_LONG_RANGE_DEFAULT;
+ pdata->tp_init_phase_ref_lite_med =
+ VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_MED_RANGE_DEFAULT;
+ pdata->tp_init_phase_ref_lite_short =
+ VL53L1_TUNINGPARM_INITIAL_PHASE_REF_LITE_SHORT_RANGE_DEFAULT;
+ pdata->tp_consistency_lite_phase_tolerance =
+ VL53L1_TUNINGPARM_CONSISTENCY_LITE_PHASE_TOLERANCE_DEFAULT;
+ pdata->tp_phasecal_target =
+ VL53L1_TUNINGPARM_PHASECAL_TARGET_DEFAULT;
+ pdata->tp_cal_repeat_rate =
+ VL53L1_TUNINGPARM_LITE_CAL_REPEAT_RATE_DEFAULT;
+ pdata->tp_lite_min_clip =
+ VL53L1_TUNINGPARM_LITE_MIN_CLIP_MM_DEFAULT;
+ pdata->tp_lite_long_sigma_thresh_mm =
+ VL53L1_TUNINGPARM_LITE_LONG_SIGMA_THRESH_MM_DEFAULT;
+ pdata->tp_lite_med_sigma_thresh_mm =
+ VL53L1_TUNINGPARM_LITE_MED_SIGMA_THRESH_MM_DEFAULT;
+ pdata->tp_lite_short_sigma_thresh_mm =
+ VL53L1_TUNINGPARM_LITE_SHORT_SIGMA_THRESH_MM_DEFAULT;
+ pdata->tp_lite_long_min_count_rate_rtn_mcps =
+ VL53L1_TUNINGPARM_LITE_LONG_MIN_COUNT_RATE_RTN_MCPS_DEFAULT;
+ pdata->tp_lite_med_min_count_rate_rtn_mcps =
+ VL53L1_TUNINGPARM_LITE_MED_MIN_COUNT_RATE_RTN_MCPS_DEFAULT;
+ pdata->tp_lite_short_min_count_rate_rtn_mcps =
+ VL53L1_TUNINGPARM_LITE_SHORT_MIN_COUNT_RATE_RTN_MCPS_DEFAULT;
+ pdata->tp_lite_sigma_est_pulse_width_ns =
+ VL53L1_TUNINGPARM_LITE_SIGMA_EST_PULSE_WIDTH_DEFAULT;
+ pdata->tp_lite_sigma_est_amb_width_ns =
+ VL53L1_TUNINGPARM_LITE_SIGMA_EST_AMB_WIDTH_NS_DEFAULT;
+ pdata->tp_lite_sigma_ref_mm =
+ VL53L1_TUNINGPARM_LITE_SIGMA_REF_MM_DEFAULT;
+ pdata->tp_lite_seed_cfg =
+ VL53L1_TUNINGPARM_LITE_SEED_CONFIG_DEFAULT;
+ pdata->tp_timed_seed_cfg =
+ VL53L1_TUNINGPARM_TIMED_SEED_CONFIG_DEFAULT;
+ pdata->tp_lite_quantifier =
+ VL53L1_TUNINGPARM_LITE_QUANTIFIER_DEFAULT;
+ pdata->tp_lite_first_order_select =
+ VL53L1_TUNINGPARM_LITE_FIRST_ORDER_SELECT_DEFAULT;
+
+ /* Preset Mode Configurations */
+ /* - New parms added as part of Patch_TuningParmPresetModeAddition_11839 */
+
+ pdata->tp_dss_target_lite_mcps =
+ VL53L1_TUNINGPARM_LITE_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS_DEFAULT;
+ pdata->tp_dss_target_timed_mcps =
+ VL53L1_TUNINGPARM_TIMED_DSS_CONFIG_TARGET_TOTAL_RATE_MCPS_DEFAULT;
+ pdata->tp_phasecal_timeout_lite_us =
+ VL53L1_TUNINGPARM_LITE_PHASECAL_CONFIG_TIMEOUT_US;
+ pdata->tp_phasecal_timeout_timed_us =
+ VL53L1_TUNINGPARM_TIMED_PHASECAL_CONFIG_TIMEOUT_US_DEFAULT;
+ pdata->tp_mm_timeout_lite_us =
+ VL53L1_TUNINGPARM_LITE_MM_CONFIG_TIMEOUT_US_DEFAULT;
+ pdata->tp_mm_timeout_timed_us =
+ VL53L1_TUNINGPARM_TIMED_MM_CONFIG_TIMEOUT_US_DEFAULT;
+ pdata->tp_range_timeout_lite_us =
+ VL53L1_TUNINGPARM_LITE_RANGE_CONFIG_TIMEOUT_US_DEFAULT;
+ pdata->tp_range_timeout_timed_us =
+ VL53L1_TUNINGPARM_TIMED_RANGE_CONFIG_TIMEOUT_US_DEFAULT;
+
+ /* Added for Patch_LowPowerAutoMode */
+
+ pdata->tp_mm_timeout_lpa_us =
+ VL53L1_TUNINGPARM_LOWPOWERAUTO_MM_CONFIG_TIMEOUT_US_DEFAULT;
+ pdata->tp_range_timeout_lpa_us =
+ VL53L1_TUNINGPARM_LOWPOWERAUTO_RANGE_CONFIG_TIMEOUT_US_DEFAULT;
+
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_preset_mode_standard_ranging(
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms)
+{
+ /*
+ * Initializes static and dynamic data structures fordevice preset mode
+ * VL53L1_DEVICEPRESETMODE_STANDARD_RANGING
+ *
+ * - streaming
+ * - single sigma delta
+ * - back to back
+ *
+ * PLEASE NOTE THE SETTINGS BELOW AT PROVISIONAL AND WILL CHANGE!
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Static Configuration */
+
+ /* dss_config__target_total_rate_mcps = 20.0 Mcps 9.7 fp */
+ pstatic->dss_config__target_total_rate_mcps = 0x0A00;
+ pstatic->debug__ctrl = 0x00;
+ pstatic->test_mode__ctrl = 0x00;
+ pstatic->clk_gating__ctrl = 0x00;
+ pstatic->nvm_bist__ctrl = 0x00;
+ pstatic->nvm_bist__num_nvm_words = 0x00;
+ pstatic->nvm_bist__start_address = 0x00;
+ pstatic->host_if__status = 0x00;
+ pstatic->pad_i2c_hv__config = 0x00;
+ pstatic->pad_i2c_hv__extsup_config = 0x00;
+
+ /*
+ * 0 - gpio__extsup_hv
+ * 1 - gpio__vmodeint_hv
+ */
+ pstatic->gpio_hv_pad__ctrl = 0x00;
+
+ /*
+ * Set interrupt active low
+ *
+ * 3:0 - gpio__mux_select_hv
+ * 4 - gpio__mux_active_high_hv
+ */
+ pstatic->gpio_hv_mux__ctrl = \
+ VL53L1_DEVICEINTERRUPTPOLARITY_ACTIVE_LOW | \
+ VL53L1_DEVICEGPIOMODE_OUTPUT_RANGE_AND_ERROR_INTERRUPTS;
+
+ pstatic->gpio__tio_hv_status = 0x02;
+ pstatic->gpio__fio_hv_status = 0x00;
+ pstatic->ana_config__spad_sel_pswidth = 0x02;
+ pstatic->ana_config__vcsel_pulse_width_offset = 0x08;
+ pstatic->ana_config__fast_osc__config_ctrl = 0x00;
+
+ pstatic->sigma_estimator__effective_pulse_width_ns =
+ ptuning_parms->tp_lite_sigma_est_pulse_width_ns;
+ pstatic->sigma_estimator__effective_ambient_width_ns =
+ ptuning_parms->tp_lite_sigma_est_amb_width_ns;
+ pstatic->sigma_estimator__sigma_ref_mm =
+ ptuning_parms->tp_lite_sigma_ref_mm;
+ /* Minimum allowable value of 1 - 0 disables the feature */
+ pstatic->algo__crosstalk_compensation_valid_height_mm = 0x01;
+ pstatic->spare_host_config__static_config_spare_0 = 0x00;
+ pstatic->spare_host_config__static_config_spare_1 = 0x00;
+
+ pstatic->algo__range_ignore_threshold_mcps = 0x0000;
+
+ /* set RIT distance to 20 mm */
+ pstatic->algo__range_ignore_valid_height_mm = 0xff;
+ pstatic->algo__range_min_clip =
+ ptuning_parms->tp_lite_min_clip;
+ /*
+ * Phase consistency check limit - format 1.3 fp
+ * 0x02 -> 0.25
+ * 0x08 -> 1.00
+ */
+ pstatic->algo__consistency_check__tolerance =
+ ptuning_parms->tp_consistency_lite_phase_tolerance;
+ pstatic->spare_host_config__static_config_spare_2 = 0x00;
+ pstatic->sd_config__reset_stages_msb = 0x00;
+ pstatic->sd_config__reset_stages_lsb = 0x00;
+
+ pgeneral->gph_config__stream_count_update_value = 0x00;
+ pgeneral->global_config__stream_divider = 0x00;
+ pgeneral->system__interrupt_config_gpio =
+ VL53L1_INTERRUPT_CONFIG_NEW_SAMPLE_READY;
+ pgeneral->cal_config__vcsel_start = 0x0B;
+
+ /*
+ * Set VHV / Phase Cal repeat rate to 1 every
+ * 60 * 60 ranges (once every minute @ 60Hz)
+ * 0 - disables
+ * 12-bit value -> 4095 max
+ */
+ pgeneral->cal_config__repeat_rate =
+ ptuning_parms->tp_cal_repeat_rate;
+ pgeneral->global_config__vcsel_width = 0x02;
+ /* 13 macro periods gives a timeout of 1ms */
+ pgeneral->phasecal_config__timeout_macrop = 0x0D;
+ /* Phase cal target phase 2.0625 - 4.4 fp -> 0x21*/
+ pgeneral->phasecal_config__target =
+ ptuning_parms->tp_phasecal_target;
+ pgeneral->phasecal_config__override = 0x00;
+ pgeneral->dss_config__roi_mode_control =
+ VL53L1_DEVICEDSSMODE__TARGET_RATE;
+ /* format for threshold high and low is 9.7 fp */
+ pgeneral->system__thresh_rate_high = 0x0000;
+ pgeneral->system__thresh_rate_low = 0x0000;
+ /* The format for manual effective spads is 8.8 -> 0x8C00 = 140.00 */
+ pgeneral->dss_config__manual_effective_spads_select = 0x8C00;
+ pgeneral->dss_config__manual_block_select = 0x00;
+
+ /*
+ * Aperture attenuation value - format 0.8
+ *
+ * Nominal: 5x -> 0.200000 * 256 = 51 = 0x33
+ * Measured: 4.6x -> 0.217391 * 256 = 56 = 0x38
+ */
+ pgeneral->dss_config__aperture_attenuation = 0x38;
+ pgeneral->dss_config__max_spads_limit = 0xFF;
+ pgeneral->dss_config__min_spads_limit = 0x01;
+
+ /* Timing Configuration */
+
+ /* Default timing of 2ms */
+ ptiming->mm_config__timeout_macrop_a_hi = 0x00;
+ ptiming->mm_config__timeout_macrop_a_lo = 0x1a;
+ ptiming->mm_config__timeout_macrop_b_hi = 0x00;
+ ptiming->mm_config__timeout_macrop_b_lo = 0x20;
+ /* Setup for 30ms default */
+ ptiming->range_config__timeout_macrop_a_hi = 0x01;
+ ptiming->range_config__timeout_macrop_a_lo = 0xCC;
+ /* register value 11 gives a 24 VCSEL period */
+ ptiming->range_config__vcsel_period_a = 0x0B;
+ /* Setup for 30ms default */
+ ptiming->range_config__timeout_macrop_b_hi = 0x01;
+ ptiming->range_config__timeout_macrop_b_lo = 0xF5;
+ /* register value 09 gives a 20 VCSEL period */
+ ptiming->range_config__vcsel_period_b = 0x09;
+ /*
+ * Sigma thresh register - format 14.2
+ *
+ * 0x003C -> 15.0 mm
+ * 0x0050 -> 20.0 mm
+ */
+ ptiming->range_config__sigma_thresh =
+ ptuning_parms->tp_lite_med_sigma_thresh_mm;
+ /*
+ * Rate Limit - format 9.7fp
+ * 0x0020 -> 0.250 Mcps
+ * 0x0080 -> 1.000 Mcps
+ */
+ ptiming->range_config__min_count_rate_rtn_limit_mcps =
+ ptuning_parms->tp_lite_med_min_count_rate_rtn_mcps;
+
+ /* Phase limit register formats = 5.3
+ * low = 0x08 -> 1.0
+ * high = 0x78 -> 15.0 -> 3.0m
+ */
+ ptiming->range_config__valid_phase_low = 0x08;
+ ptiming->range_config__valid_phase_high = 0x78;
+ ptiming->system__intermeasurement_period = 0x00000000;
+ ptiming->system__fractional_enable = 0x00;
+
+ /* Dynamic Configuration */
+
+ pdynamic->system__grouped_parameter_hold_0 = 0x01;
+
+ pdynamic->system__thresh_high = 0x0000;
+ pdynamic->system__thresh_low = 0x0000;
+ pdynamic->system__enable_xtalk_per_quadrant = 0x00;
+ pdynamic->system__seed_config =
+ ptuning_parms->tp_lite_seed_cfg;
+
+ /* Timing A */
+ pdynamic->sd_config__woi_sd0 = 0x0B;
+ /* Timing B */
+ pdynamic->sd_config__woi_sd1 = 0x09;
+
+ pdynamic->sd_config__initial_phase_sd0 =
+ ptuning_parms->tp_init_phase_rtn_lite_med;
+ pdynamic->sd_config__initial_phase_sd1 =
+ ptuning_parms->tp_init_phase_ref_lite_med;;
+
+ pdynamic->system__grouped_parameter_hold_1 = 0x01;
+
+ /*
+ * Quantifier settings
+ *
+ * sd_config__first_order_select
+ * bit 0 - return sigma delta
+ * bit 1 - reference sigma delta
+ *
+ * sd_config__first_order_select = 0x03 (1st order)
+ *
+ * sd_config__quantifier options
+ * 0
+ * 1 -> 64
+ * 2 -> 128
+ * 3 -> 256
+ *
+ * sd_config__first_order_select = 0x00 (2nd order)
+ *
+ * sd_config__quantifier options
+ * 0
+ * 1 -> 256
+ * 2 -> 1024
+ * 3 -> 4095
+ *
+ * Setting below 2nd order, Quantifier = 1024
+ */
+
+ pdynamic->sd_config__first_order_select =
+ ptuning_parms->tp_lite_first_order_select;
+ pdynamic->sd_config__quantifier =
+ ptuning_parms->tp_lite_quantifier;
+
+ /* Below defaults will be overwritten by zone_cfg
+ * Spad no = 199 (0xC7)
+ * Spad no = 63 (0x3F)
+ */
+ pdynamic->roi_config__user_roi_centre_spad = 0xC7;
+ /* 16x16 ROI */
+ pdynamic->roi_config__user_roi_requested_global_xy_size = 0xFF;
+
+
+ pdynamic->system__sequence_config = \
+ VL53L1_SEQUENCE_VHV_EN | \
+ VL53L1_SEQUENCE_PHASECAL_EN | \
+ VL53L1_SEQUENCE_DSS1_EN | \
+ VL53L1_SEQUENCE_DSS2_EN | \
+ VL53L1_SEQUENCE_MM2_EN | \
+ VL53L1_SEQUENCE_RANGE_EN;
+
+ pdynamic->system__grouped_parameter_hold = 0x02;
+
+ /* System control */
+
+
+ psystem->system__stream_count_ctrl = 0x00;
+ psystem->firmware__enable = 0x01;
+ psystem->system__interrupt_clear = \
+ VL53L1_CLEAR_RANGE_INT;
+
+ psystem->system__mode_start = \
+ VL53L1_DEVICESCHEDULERMODE_STREAMING | \
+ VL53L1_DEVICEREADOUTMODE_SINGLE_SD | \
+ VL53L1_DEVICEMEASUREMENTMODE_BACKTOBACK;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_preset_mode_standard_ranging_short_range(
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms)
+{
+ /*
+ * Initializes static and dynamic data structures for
+ * device preset mode
+ *
+ * VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_SHORT_RANGE
+ * (up to 1.4 metres)
+ *
+ * PLEASE NOTE THE SETTINGS BELOW AT PROVISIONAL AND WILL CHANGE!
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Call standard ranging configuration followed by
+ * overrides for the short range configuration
+ */
+
+ status = VL53L1_preset_mode_standard_ranging(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+
+ /* now override standard ranging specific registers */
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ /* Timing Configuration
+ *
+ * vcsel_period_a = 7 -> 16 period
+ * vcsel_period_b = 5 -> 12 period
+ * sigma_thresh = 0x003C -> 14.2fp -> 15.0 mm
+ * min_count_rate_rtn_limit_mcps = 0x0080 -> 9.7fp -> 1.0 Mcps
+ * valid_phase_low = 0x08 -> 5.3fp -> 1.0
+ * valid_phase_high = 0x38 -> 5.3fp -> 7.0 -> 1.4m
+ */
+
+ ptiming->range_config__vcsel_period_a = 0x07;
+ ptiming->range_config__vcsel_period_b = 0x05;
+ ptiming->range_config__sigma_thresh =
+ ptuning_parms->tp_lite_short_sigma_thresh_mm;
+ ptiming->range_config__min_count_rate_rtn_limit_mcps =
+ ptuning_parms->tp_lite_short_min_count_rate_rtn_mcps;
+ ptiming->range_config__valid_phase_low = 0x08;
+ ptiming->range_config__valid_phase_high = 0x38;
+
+ /* Dynamic Configuration
+ * SD0 -> Timing A
+ * SD1 -> Timing B
+ */
+
+ pdynamic->sd_config__woi_sd0 = 0x07;
+ pdynamic->sd_config__woi_sd1 = 0x05;
+ pdynamic->sd_config__initial_phase_sd0 =
+ ptuning_parms->tp_init_phase_rtn_lite_short;
+ pdynamic->sd_config__initial_phase_sd1 =
+ ptuning_parms->tp_init_phase_ref_lite_short;
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_preset_mode_standard_ranging_long_range(
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms)
+{
+ /*
+ * Initializes static and dynamic data structures for
+ * device preset mode
+ *
+ * VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_LONG_RANGE
+ * (up to 4.8 metres)
+ *
+ * PLEASE NOTE THE SETTINGS BELOW AT PROVISIONAL AND WILL CHANGE!
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Call standard ranging configuration with
+ * overrides for long range configuration
+ */
+
+ status = VL53L1_preset_mode_standard_ranging(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+
+ /* now override standard ranging specific registers */
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ /* Timing Configuration
+ *
+ * vcsel_period_a = 15 -> 32 period
+ * vcsel_period_b = 13 -> 28 period
+ * sigma_thresh = 0x003C -> 14.2fp -> 15.0 mm
+ * min_count_rate_rtn_limit_mcps = 0x0080 -> 9.7fp -> 1.0 Mcps
+ * valid_phase_low = 0x08 -> 5.3fp -> 1.0
+ * valid_phase_high = 0xB8 -> 5.3fp -> 23.0 -> 4.6m
+ */
+
+ ptiming->range_config__vcsel_period_a = 0x0F;
+ ptiming->range_config__vcsel_period_b = 0x0D;
+ ptiming->range_config__sigma_thresh =
+ ptuning_parms->tp_lite_long_sigma_thresh_mm;
+ ptiming->range_config__min_count_rate_rtn_limit_mcps =
+ ptuning_parms->tp_lite_long_min_count_rate_rtn_mcps;
+ ptiming->range_config__valid_phase_low = 0x08;
+ ptiming->range_config__valid_phase_high = 0xB8;
+
+ /* Dynamic Configuration
+ * SD0 -> Timing A
+ * SD1 -> Timing B
+ */
+
+ pdynamic->sd_config__woi_sd0 = 0x0F;
+ pdynamic->sd_config__woi_sd1 = 0x0D;
+ pdynamic->sd_config__initial_phase_sd0 =
+ ptuning_parms->tp_init_phase_rtn_lite_long;
+ pdynamic->sd_config__initial_phase_sd1 =
+ ptuning_parms->tp_init_phase_ref_lite_long;
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_preset_mode_standard_ranging_mm1_cal(
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms)
+{
+ /*
+ * Initializes static and dynamic data structures for
+ * device preset mode
+ *
+ * VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM1_CAL
+ *
+ * PLEASE NOTE THE SETTINGS BELOW AT PROVISIONAL AND WILL CHANGE!
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Call standard ranging configuration with
+ * overrides for long range configuration
+ */
+
+ status = VL53L1_preset_mode_standard_ranging(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+
+ /* now override standard ranging specific registers */
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ pgeneral->dss_config__roi_mode_control =
+ VL53L1_DEVICEDSSMODE__REQUESTED_EFFFECTIVE_SPADS;
+
+ pdynamic->system__sequence_config = \
+ VL53L1_SEQUENCE_VHV_EN | \
+ VL53L1_SEQUENCE_PHASECAL_EN | \
+ VL53L1_SEQUENCE_DSS1_EN | \
+ VL53L1_SEQUENCE_DSS2_EN | \
+ VL53L1_SEQUENCE_MM1_EN;
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_preset_mode_standard_ranging_mm2_cal(
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms)
+{
+ /*
+ * Initializes static and dynamic data structures for
+ * device preset mode
+ *
+ * VL53L1_DEVICEPRESETMODE_STANDARD_RANGING_MM2_CAL
+ *
+ * PLEASE NOTE THE SETTINGS BELOW AT PROVISIONAL AND WILL CHANGE!
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Call standard ranging configuration with
+ * overrides for long range configuration
+ */
+
+ status = VL53L1_preset_mode_standard_ranging(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+
+ /* now override standard ranging specific registers */
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ pgeneral->dss_config__roi_mode_control =
+ VL53L1_DEVICEDSSMODE__REQUESTED_EFFFECTIVE_SPADS;
+
+ pdynamic->system__sequence_config = \
+ VL53L1_SEQUENCE_VHV_EN | \
+ VL53L1_SEQUENCE_PHASECAL_EN | \
+ VL53L1_SEQUENCE_DSS1_EN | \
+ VL53L1_SEQUENCE_DSS2_EN | \
+ VL53L1_SEQUENCE_MM2_EN;
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_preset_mode_timed_ranging(
+
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms)
+{
+ /*
+ * Initializes static and dynamic data structures for
+ * device preset mode
+ *
+ * VL53L1_DEVICEPRESETMODE_TIMED_RANGING
+ *
+ * - pseudo-solo
+ * - single sigma delta
+ * - timed
+ *
+ * PLEASE NOTE THE SETTINGS BELOW AT PROVISIONAL AND WILL CHANGE!
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Call standard ranging configuration */
+
+ status = VL53L1_preset_mode_standard_ranging(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+
+ /* now override standard ranging specific registers */
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ /* Dynamic Configuration */
+
+ /* Disable GPH */
+ pdynamic->system__grouped_parameter_hold = 0x00;
+
+ /* Re-Configure timing budget default for 13ms */
+ ptiming->range_config__timeout_macrop_a_hi = 0x00;
+ ptiming->range_config__timeout_macrop_a_lo = 0xB1;
+ /* Setup for 13ms default */
+ ptiming->range_config__timeout_macrop_b_hi = 0x00;
+ ptiming->range_config__timeout_macrop_b_lo = 0xD4;
+
+ /* Timing Configuration */
+
+ ptiming->system__intermeasurement_period = 0x00000600;
+ pdynamic->system__seed_config =
+ ptuning_parms->tp_timed_seed_cfg;
+
+ /* System control */
+
+ /* Configure Timed/Psuedo-solo mode */
+ psystem->system__mode_start =
+ VL53L1_DEVICESCHEDULERMODE_PSEUDO_SOLO | \
+ VL53L1_DEVICEREADOUTMODE_SINGLE_SD | \
+ VL53L1_DEVICEMEASUREMENTMODE_TIMED;
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+VL53L1_Error VL53L1_preset_mode_timed_ranging_short_range(
+
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms)
+{
+ /*
+ * Initializes static and dynamic data structures for
+ * device preset mode
+ *
+ * VL53L1_DEVICEPRESETMODE_TIMED_RANGING_SHORT_RANGE
+ *
+ * - pseudo-solo
+ * - single sigma delta
+ * - timed
+ *
+ * PLEASE NOTE THE SETTINGS BELOW AT PROVISIONAL AND WILL CHANGE!
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Call standard ranging configuration */
+
+ status = VL53L1_preset_mode_standard_ranging_short_range(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+
+ /* now override standard ranging specific registers */
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ /* Dynamic Configuration */
+
+ /* Disable GPH */
+ pdynamic->system__grouped_parameter_hold = 0x00;
+
+
+ /* Timing Configuration */
+
+ /* Re-Configure timing budget default for 13ms */
+ ptiming->range_config__timeout_macrop_a_hi = 0x01;
+ ptiming->range_config__timeout_macrop_a_lo = 0x84;
+ /* Setup for 13ms default */
+ ptiming->range_config__timeout_macrop_b_hi = 0x01;
+ ptiming->range_config__timeout_macrop_b_lo = 0xB1;
+
+ ptiming->system__intermeasurement_period = 0x00000600;
+ pdynamic->system__seed_config =
+ ptuning_parms->tp_timed_seed_cfg;
+
+ /* System control */
+
+ /* Configure Timed/Psuedo-solo mode */
+ psystem->system__mode_start =
+ VL53L1_DEVICESCHEDULERMODE_PSEUDO_SOLO | \
+ VL53L1_DEVICEREADOUTMODE_SINGLE_SD | \
+ VL53L1_DEVICEMEASUREMENTMODE_TIMED;
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+VL53L1_Error VL53L1_preset_mode_timed_ranging_long_range(
+
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms)
+{
+ /*
+ * Initializes static and dynamic data structures for
+ * device preset mode
+ *
+ * VL53L1_DEVICEPRESETMODE_TIMED_RANGING_LONG_RANGE
+ *
+ * - pseudo-solo
+ * - single sigma delta
+ * - timed
+ *
+ * PLEASE NOTE THE SETTINGS BELOW AT PROVISIONAL AND WILL CHANGE!
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Call standard ranging configuration */
+
+ status = VL53L1_preset_mode_standard_ranging_long_range(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+
+ /* now override standard ranging specific registers */
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ /* Dynamic Configuration */
+
+ /* Disable GPH */
+ pdynamic->system__grouped_parameter_hold = 0x00;
+
+
+ /* Timing Configuration */
+
+ /* Re-Configure timing budget default for 13ms */
+ ptiming->range_config__timeout_macrop_a_hi = 0x00;
+ ptiming->range_config__timeout_macrop_a_lo = 0x97;
+ /* Setup for 13ms default */
+ ptiming->range_config__timeout_macrop_b_hi = 0x00;
+ ptiming->range_config__timeout_macrop_b_lo = 0xB1;
+
+ ptiming->system__intermeasurement_period = 0x00000600;
+ pdynamic->system__seed_config =
+ ptuning_parms->tp_timed_seed_cfg;
+
+ /* System control */
+
+ /* Configure Timed/Psuedo-solo mode */
+ psystem->system__mode_start =
+ VL53L1_DEVICESCHEDULERMODE_PSEUDO_SOLO | \
+ VL53L1_DEVICEREADOUTMODE_SINGLE_SD | \
+ VL53L1_DEVICEMEASUREMENTMODE_TIMED;
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+/* Start Patch_LowPowerAutoMode */
+VL53L1_Error VL53L1_preset_mode_low_power_auto_ranging(
+
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms,
+ VL53L1_low_power_auto_data_t *plpadata)
+{
+ /*
+ * Initializes static and dynamic data structures for
+ * device preset mode
+ *
+ * VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_MEDIUM_RANGE
+ *
+ * - pseudo-solo
+ * - single sigma delta
+ * - timed
+ * - special low power auto mode for Presence application
+ *
+ * PLEASE NOTE THE SETTINGS BELOW ARE PROVISIONAL AND WILL CHANGE!
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Call standard ranging configuration */
+
+ status = VL53L1_preset_mode_timed_ranging(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+
+ /* now setup the low power auto mode */
+
+ if (status == VL53L1_ERROR_NONE) {
+ status = VL53L1_config_low_power_auto_mode(
+ pgeneral,
+ pdynamic,
+ plpadata
+ );
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+VL53L1_Error VL53L1_preset_mode_low_power_auto_short_ranging(
+
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms,
+ VL53L1_low_power_auto_data_t *plpadata)
+{
+ /*
+ * Initializes static and dynamic data structures for
+ * device preset mode
+ *
+ * VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_SHORT_RANGE
+ *
+ * - pseudo-solo
+ * - single sigma delta
+ * - timed
+ * - special low power auto mode for Presence application
+ *
+ * PLEASE NOTE THE SETTINGS BELOW ARE PROVISIONAL AND WILL CHANGE!
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Call standard ranging configuration */
+
+ status = VL53L1_preset_mode_timed_ranging_short_range(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+
+ /* now setup the low power auto mode */
+
+ if (status == VL53L1_ERROR_NONE) {
+ status = VL53L1_config_low_power_auto_mode(
+ pgeneral,
+ pdynamic,
+ plpadata
+ );
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+VL53L1_Error VL53L1_preset_mode_low_power_auto_long_ranging(
+
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms,
+ VL53L1_low_power_auto_data_t *plpadata)
+{
+ /*
+ * Initializes static and dynamic data structures for
+ * device preset mode
+ *
+ * VL53L1_DEVICEPRESETMODE_LOWPOWERAUTO_LONG_RANGE
+ *
+ * - pseudo-solo
+ * - single sigma delta
+ * - timed
+ * - special low power auto mode for Presence application
+ *
+ * PLEASE NOTE THE SETTINGS BELOW ARE PROVISIONAL AND WILL CHANGE!
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Call standard ranging configuration */
+
+ status = VL53L1_preset_mode_timed_ranging_long_range(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+
+ /* now setup the low power auto mode */
+
+ if (status == VL53L1_ERROR_NONE) {
+ status = VL53L1_config_low_power_auto_mode(
+ pgeneral,
+ pdynamic,
+ plpadata
+ );
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+/* End Patch_LowPowerAutoMode */
+
+VL53L1_Error VL53L1_preset_mode_singleshot_ranging(
+
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms)
+{
+ /*
+ * Initializes static and dynamic data structures for device preset mode
+ * VL53L1_DEVICEPRESETMODE_TIMED_RANGING
+ *
+ * - pseudo-solo
+ * - single sigma delta
+ * - timed
+ *
+ * PLEASE NOTE THE SETTINGS BELOW AT PROVISIONAL AND WILL CHANGE!
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Call standard ranging configuration */
+
+ status = VL53L1_preset_mode_standard_ranging(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+
+ /* now override standard ranging specific registers */
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ /* Dynamic Configuration */
+
+ /* Disable GPH */
+ pdynamic->system__grouped_parameter_hold = 0x00;
+
+ /* Timing Configuration */
+
+ /* Re-Configure timing budget default for 13ms */
+ ptiming->range_config__timeout_macrop_a_hi = 0x00;
+ ptiming->range_config__timeout_macrop_a_lo = 0xB1;
+ /* Setup for 13ms default */
+ ptiming->range_config__timeout_macrop_b_hi = 0x00;
+ ptiming->range_config__timeout_macrop_b_lo = 0xD4;
+
+ pdynamic->system__seed_config =
+ ptuning_parms->tp_timed_seed_cfg;
+
+ /* System control */
+
+ /* Configure Timed/Psuedo-solo mode */
+ psystem->system__mode_start = \
+ VL53L1_DEVICESCHEDULERMODE_PSEUDO_SOLO | \
+ VL53L1_DEVICEREADOUTMODE_SINGLE_SD | \
+ VL53L1_DEVICEMEASUREMENTMODE_SINGLESHOT;
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_preset_mode_olt(
+ VL53L1_static_config_t *pstatic,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_system_control_t *psystem,
+ VL53L1_tuning_parm_storage_t *ptuning_parms)
+{
+ /**
+ * Initializes static and dynamic data structures for device preset mode
+ * VL53L1_DEVICEPRESETMODE_OLT
+ *
+ * PLEASE NOTE THE SETTINGS BELOW AT PROVISIONAL AND WILL CHANGE!
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* Call standard ranging configuration */
+
+ status = VL53L1_preset_mode_standard_ranging(
+ pstatic,
+ pgeneral,
+ ptiming,
+ pdynamic,
+ psystem,
+ ptuning_parms);
+
+ /* now override OLT specific registers */
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ /* Disables requirement for host handshake */
+ psystem->system__stream_count_ctrl = 0x01;
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api_strings.c b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api_strings.c
new file mode 100644
index 0000000..a0ff724
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_api_strings.c
@@ -0,0 +1,268 @@
+
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_api_strings.c
+ * @brief VL53L1 API functions for decoding error codes to a text string
+ */
+
+#include "vl53l1_api_core.h"
+#include "vl53l1_api_strings.h"
+#include "vl53l1_error_codes.h"
+#include "vl53l1_error_strings.h"
+
+#define LOG_FUNCTION_START(fmt, ...) \
+ _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
+#define LOG_FUNCTION_END(status, ...) \
+ _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_API, status, ##__VA_ARGS__)
+#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
+ _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_API, status, fmt, \
+ ##__VA_ARGS__)
+
+
+VL53L1_Error VL53L1_get_range_status_string(
+ uint8_t RangeStatus,
+ char *pRangeStatusString)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+#ifdef VL53L1_USE_EMPTY_STRING
+ VL53L1_COPYSTRING(pRangeStatusString, "");
+#else
+ switch (RangeStatus) {
+ case 0:
+ VL53L1_COPYSTRING(pRangeStatusString,
+ VL53L1_STRING_RANGESTATUS_RANGEVALID);
+ break;
+ case 1:
+ VL53L1_COPYSTRING(pRangeStatusString,
+ VL53L1_STRING_RANGESTATUS_SIGMA);
+ break;
+ case 2:
+ VL53L1_COPYSTRING(pRangeStatusString,
+ VL53L1_STRING_RANGESTATUS_SIGNAL);
+ break;
+ case 3:
+ VL53L1_COPYSTRING(pRangeStatusString,
+ VL53L1_STRING_RANGESTATUS_MINRANGE);
+ break;
+ case 4:
+ VL53L1_COPYSTRING(pRangeStatusString,
+ VL53L1_STRING_RANGESTATUS_PHASE);
+ break;
+ case 5:
+ VL53L1_COPYSTRING(pRangeStatusString,
+ VL53L1_STRING_RANGESTATUS_HW);
+ break;
+
+ default: /**/
+ VL53L1_COPYSTRING(pRangeStatusString,
+ VL53L1_STRING_RANGESTATUS_NONE);
+ }
+#endif
+
+ LOG_FUNCTION_END(status);
+ return status;
+}
+
+
+VL53L1_Error VL53L1_get_pal_state_string(
+ VL53L1_State PalStateCode,
+ char *pPalStateString)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+#ifdef VL53L1_USE_EMPTY_STRING
+ VL53L1_COPYSTRING(pPalStateString, "");
+#else
+ switch (PalStateCode) {
+ case VL53L1_STATE_POWERDOWN:
+ VL53L1_COPYSTRING(pPalStateString,
+ VL53L1_STRING_STATE_POWERDOWN);
+ break;
+ case VL53L1_STATE_WAIT_STATICINIT:
+ VL53L1_COPYSTRING(pPalStateString,
+ VL53L1_STRING_STATE_WAIT_STATICINIT);
+ break;
+ case VL53L1_STATE_STANDBY:
+ VL53L1_COPYSTRING(pPalStateString,
+ VL53L1_STRING_STATE_STANDBY);
+ break;
+ case VL53L1_STATE_IDLE:
+ VL53L1_COPYSTRING(pPalStateString,
+ VL53L1_STRING_STATE_IDLE);
+ break;
+ case VL53L1_STATE_RUNNING:
+ VL53L1_COPYSTRING(pPalStateString,
+ VL53L1_STRING_STATE_RUNNING);
+ break;
+ case VL53L1_STATE_RESET:
+ VL53L1_COPYSTRING(pPalStateString,
+ VL53L1_STRING_STATE_RESET);
+ break;
+ case VL53L1_STATE_UNKNOWN:
+ VL53L1_COPYSTRING(pPalStateString,
+ VL53L1_STRING_STATE_UNKNOWN);
+ break;
+ case VL53L1_STATE_ERROR:
+ VL53L1_COPYSTRING(pPalStateString,
+ VL53L1_STRING_STATE_ERROR);
+ break;
+
+ default:
+ VL53L1_COPYSTRING(pPalStateString,
+ VL53L1_STRING_STATE_UNKNOWN);
+ }
+#endif
+
+ LOG_FUNCTION_END(status);
+ return status;
+}
+
+VL53L1_Error VL53L1_get_sequence_steps_info(
+ VL53L1_SequenceStepId SequenceStepId,
+ char *pSequenceStepsString)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+#ifdef VL53L1_USE_EMPTY_STRING
+ VL53L1_COPYSTRING(pSequenceStepsString, "");
+#else
+ switch (SequenceStepId) {
+ case VL53L1_SEQUENCESTEP_VHV:
+ VL53L1_COPYSTRING(pSequenceStepsString,
+ VL53L1_STRING_SEQUENCESTEP_VHV);
+ break;
+ case VL53L1_SEQUENCESTEP_PHASECAL:
+ VL53L1_COPYSTRING(pSequenceStepsString,
+ VL53L1_STRING_SEQUENCESTEP_PHASECAL);
+ break;
+ case VL53L1_SEQUENCESTEP_REFPHASE:
+ VL53L1_COPYSTRING(pSequenceStepsString,
+ VL53L1_STRING_SEQUENCESTEP_DSS1);
+ break;
+ case VL53L1_SEQUENCESTEP_DSS1:
+ VL53L1_COPYSTRING(pSequenceStepsString,
+ VL53L1_STRING_SEQUENCESTEP_DSS1);
+ break;
+ case VL53L1_SEQUENCESTEP_DSS2:
+ VL53L1_COPYSTRING(pSequenceStepsString,
+ VL53L1_STRING_SEQUENCESTEP_DSS2);
+ break;
+ case VL53L1_SEQUENCESTEP_MM1:
+ VL53L1_COPYSTRING(pSequenceStepsString,
+ VL53L1_STRING_SEQUENCESTEP_MM1);
+ break;
+ case VL53L1_SEQUENCESTEP_MM2:
+ VL53L1_COPYSTRING(pSequenceStepsString,
+ VL53L1_STRING_SEQUENCESTEP_MM2);
+ break;
+ case VL53L1_SEQUENCESTEP_RANGE:
+ VL53L1_COPYSTRING(pSequenceStepsString,
+ VL53L1_STRING_SEQUENCESTEP_RANGE);
+ break;
+ default:
+ Status = VL53L1_ERROR_INVALID_PARAMS;
+ }
+#endif
+
+ LOG_FUNCTION_END(Status);
+
+ return Status;
+}
+
+VL53L1_Error VL53L1_get_limit_check_info(uint16_t LimitCheckId,
+ char *pLimitCheckString)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+#ifdef VL53L1_USE_EMPTY_STRING
+ VL53L1_COPYSTRING(pLimitCheckString, "");
+#else
+ switch (LimitCheckId) {
+ case VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE:
+ VL53L1_COPYSTRING(pLimitCheckString,
+ VL53L1_STRING_CHECKENABLE_SIGMA_FINAL_RANGE);
+ break;
+ case VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE:
+ VL53L1_COPYSTRING(pLimitCheckString,
+ VL53L1_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE);
+ break;
+ default:
+ VL53L1_COPYSTRING(pLimitCheckString,
+ VL53L1_STRING_UNKNOW_ERROR_CODE);
+ }
+#endif
+
+ LOG_FUNCTION_END(Status);
+ return Status;
+}
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_core.c b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_core.c
new file mode 100644
index 0000000..03e6c68
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_core.c
@@ -0,0 +1,2352 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_core.c
+ *
+ * @brief EwokPlus25 core function definition
+ */
+
+#include "vl53l1_ll_def.h"
+#include "vl53l1_ll_device.h"
+#include "vl53l1_platform.h"
+#include "vl53l1_register_map.h"
+#include "vl53l1_register_funcs.h"
+#include "vl53l1_register_settings.h"
+#include "vl53l1_api_preset_modes.h"
+#include "vl53l1_core.h"
+#include "vl53l1_tuning_parm_defaults.h"
+
+#ifdef VL53L1_LOGGING
+#include "vl53l1_api_debug.h"
+#include "vl53l1_debug.h"
+#include "vl53l1_register_debug.h"
+#endif
+
+#define LOG_FUNCTION_START(fmt, ...) \
+ _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
+#define LOG_FUNCTION_END(status, ...) \
+ _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
+#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
+ _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE, \
+ status, fmt, ##__VA_ARGS__)
+
+#define trace_print(level, ...) \
+ _LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_CORE, \
+ level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
+
+
+void VL53L1_init_version(
+ VL53L1_DEV Dev)
+{
+ /**
+ * Initialise version structure
+ */
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ pdev->version.ll_major = VL53L1_LL_API_IMPLEMENTATION_VER_MAJOR;
+ pdev->version.ll_minor = VL53L1_LL_API_IMPLEMENTATION_VER_MINOR;
+ pdev->version.ll_build = VL53L1_LL_API_IMPLEMENTATION_VER_SUB;
+ pdev->version.ll_revision = VL53L1_LL_API_IMPLEMENTATION_VER_REVISION;
+}
+
+
+void VL53L1_init_ll_driver_state(
+ VL53L1_DEV Dev,
+ VL53L1_DeviceState device_state)
+{
+ /**
+ * Initialise LL Driver state variables
+ */
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+ VL53L1_ll_driver_state_t *pstate = &(pdev->ll_state);
+
+ pstate->cfg_device_state = device_state;
+ pstate->cfg_stream_count = 0;
+ pstate->cfg_gph_id = VL53L1_GROUPEDPARAMETERHOLD_ID_MASK;
+ pstate->cfg_timing_status = 0;
+
+ pstate->rd_device_state = device_state;
+ pstate->rd_stream_count = 0;
+ pstate->rd_gph_id = VL53L1_GROUPEDPARAMETERHOLD_ID_MASK;
+ pstate->rd_timing_status = 0;
+
+}
+
+
+VL53L1_Error VL53L1_update_ll_driver_rd_state(
+ VL53L1_DEV Dev)
+{
+ /**
+ * State machine for read device state
+ *
+ * VL53L1_DEVICESTATE_SW_STANDBY
+ * VL53L1_DEVICESTATE_RANGING_WAIT_GPH_SYNC
+ * VL53L1_DEVICESTATE_RANGING_GATHER_DATA
+ * VL53L1_DEVICESTATE_RANGING_OUTPUT_DATA
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+ VL53L1_ll_driver_state_t *pstate = &(pdev->ll_state);
+
+ /* if top bits of mode start reset are zero then in standby state */
+
+ LOG_FUNCTION_START("");
+
+#ifdef VL53L1_LOGGING
+ VL53L1_print_ll_driver_state(pstate);
+#endif
+
+ if ((pdev->sys_ctrl.system__mode_start &
+ VL53L1_DEVICEMEASUREMENTMODE_MODE_MASK) == 0x00) {
+
+ pstate->rd_device_state = VL53L1_DEVICESTATE_SW_STANDBY;
+ pstate->rd_stream_count = 0;
+ pstate->rd_gph_id = VL53L1_GROUPEDPARAMETERHOLD_ID_MASK;
+ pstate->rd_timing_status = 0;
+
+ } else {
+
+ /*
+ * implement read stream count
+ */
+
+ if (pstate->rd_stream_count == 0xFF) {
+ pstate->rd_stream_count = 0x80;
+ } else {
+ pstate->rd_stream_count++;
+ }
+
+
+ /*
+ * Toggle grouped parameter hold ID
+ */
+
+ pstate->rd_gph_id ^= VL53L1_GROUPEDPARAMETERHOLD_ID_MASK;
+
+ /* Ok now ranging */
+
+ switch (pstate->rd_device_state) {
+
+ case VL53L1_DEVICESTATE_SW_STANDBY:
+
+ if ((pdev->dyn_cfg.system__grouped_parameter_hold &
+ VL53L1_GROUPEDPARAMETERHOLD_ID_MASK) > 0) {
+ pstate->rd_device_state =
+ VL53L1_DEVICESTATE_RANGING_WAIT_GPH_SYNC;
+ } else {
+ pstate->rd_device_state =
+ VL53L1_DEVICESTATE_RANGING_OUTPUT_DATA;
+ }
+
+ pstate->rd_stream_count = 0;
+ pstate->rd_timing_status = 0;
+
+ break;
+
+ case VL53L1_DEVICESTATE_RANGING_WAIT_GPH_SYNC:
+
+ pstate->rd_stream_count = 0;
+ pstate->rd_device_state =
+ VL53L1_DEVICESTATE_RANGING_OUTPUT_DATA;
+
+ break;
+
+ case VL53L1_DEVICESTATE_RANGING_GATHER_DATA:
+
+ pstate->rd_device_state =
+ VL53L1_DEVICESTATE_RANGING_OUTPUT_DATA;
+
+ break;
+
+ case VL53L1_DEVICESTATE_RANGING_OUTPUT_DATA:
+
+ pstate->rd_timing_status ^= 0x01;
+
+ pstate->rd_device_state =
+ VL53L1_DEVICESTATE_RANGING_OUTPUT_DATA;
+
+ break;
+
+ default:
+
+ pstate->rd_device_state =
+ VL53L1_DEVICESTATE_SW_STANDBY;
+ pstate->rd_stream_count = 0;
+ pstate->rd_gph_id = VL53L1_GROUPEDPARAMETERHOLD_ID_MASK;
+ pstate->rd_timing_status = 0;
+
+ break;
+ }
+ }
+
+#ifdef VL53L1_LOGGING
+ VL53L1_print_ll_driver_state(pstate);
+#endif
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_check_ll_driver_rd_state(
+ VL53L1_DEV Dev)
+{
+ /*
+ * Checks if the LL Driver Read state and expected stream count
+ * matches the state and stream count received from the device
+ *
+ * Check is only use in back to back mode
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ VL53L1_ll_driver_state_t *pstate = &(pdev->ll_state);
+ VL53L1_system_results_t *psys_results = &(pdev->sys_results);
+
+ uint8_t device_range_status = 0;
+ uint8_t device_stream_count = 0;
+ uint8_t device_gph_id = 0;
+
+ LOG_FUNCTION_START("");
+
+#ifdef VL53L1_LOGGING
+ VL53L1_print_ll_driver_state(pstate);
+#endif
+
+ device_range_status =
+ psys_results->result__range_status &
+ VL53L1_RANGE_STATUS__RANGE_STATUS_MASK;
+
+ device_stream_count = psys_results->result__stream_count;
+
+ /* load the correct GPH ID */
+ device_gph_id = (psys_results->result__interrupt_status &
+ VL53L1_INTERRUPT_STATUS__GPH_ID_INT_STATUS_MASK) >> 4;
+
+ /* only apply checks in back to back mode */
+
+ if ((pdev->sys_ctrl.system__mode_start &
+ VL53L1_DEVICEMEASUREMENTMODE_BACKTOBACK) ==
+ VL53L1_DEVICEMEASUREMENTMODE_BACKTOBACK) {
+
+ /* if read state is wait for GPH sync interrupt then check the
+ * device returns a GPH range status value otherwise check that
+ * the stream count matches
+ *
+ * In theory the stream count should zero for the GPH interrupt
+ * but that is not the case after at abort ....
+ */
+
+ if (pstate->rd_device_state ==
+ VL53L1_DEVICESTATE_RANGING_WAIT_GPH_SYNC) {
+
+ if (device_range_status !=
+ VL53L1_DEVICEERROR_GPHSTREAMCOUNT0READY) {
+ status = VL53L1_ERROR_GPH_SYNC_CHECK_FAIL;
+ }
+ } else {
+ if (pstate->rd_stream_count != device_stream_count) {
+ status = VL53L1_ERROR_STREAM_COUNT_CHECK_FAIL;
+ }
+
+ /*
+ * Check Read state GPH ID
+ */
+
+ if (pstate->rd_gph_id != device_gph_id) {
+ status = VL53L1_ERROR_GPH_ID_CHECK_FAIL;
+#ifdef VL53L1_LOGGING
+ trace_print(VL53L1_TRACE_LEVEL_ALL,
+ " RDSTATECHECK: Check failed: rd_gph_id: %d, device_gph_id: %d\n",
+ pstate->rd_gph_id,
+ device_gph_id);
+#endif
+ } else {
+#ifdef VL53L1_LOGGING
+ trace_print(VL53L1_TRACE_LEVEL_ALL,
+ " RDSTATECHECK: Check passed: rd_gph_id: %d, device_gph_id: %d\n",
+ pstate->rd_gph_id,
+ device_gph_id);
+#endif
+ }
+
+ } /* else (not in WAIT_GPH_SYNC) */
+
+ } /* if back to back */
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_update_ll_driver_cfg_state(
+ VL53L1_DEV Dev)
+{
+ /**
+ * State machine for configuration device state
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev =
+ VL53L1DevStructGetLLDriverHandle(Dev);
+
+ VL53L1_ll_driver_state_t *pstate = &(pdev->ll_state);
+
+ LOG_FUNCTION_START("");
+
+#ifdef VL53L1_LOGGING
+ VL53L1_print_ll_driver_state(pstate);
+#endif
+
+ /* if top bits of mode start reset are zero then in standby state */
+
+ if ((pdev->sys_ctrl.system__mode_start &
+ VL53L1_DEVICEMEASUREMENTMODE_MODE_MASK) == 0x00) {
+
+ pstate->cfg_device_state = VL53L1_DEVICESTATE_SW_STANDBY;
+ pstate->cfg_stream_count = 0;
+ pstate->cfg_gph_id = VL53L1_GROUPEDPARAMETERHOLD_ID_MASK;
+ pstate->cfg_timing_status = 0;
+
+ } else {
+
+ /*
+ * implement configuration stream count
+ */
+
+ if (pstate->cfg_stream_count == 0xFF) {
+ pstate->cfg_stream_count = 0x80;
+ } else {
+ pstate->cfg_stream_count++;
+ }
+
+ /*
+ * Toggle grouped parameter hold ID
+ */
+
+ pstate->cfg_gph_id ^= VL53L1_GROUPEDPARAMETERHOLD_ID_MASK;
+
+ /*
+ * Implement configuration state machine
+ */
+
+ switch (pstate->cfg_device_state) {
+
+ case VL53L1_DEVICESTATE_SW_STANDBY:
+
+ pstate->cfg_timing_status ^= 0x01;
+ pstate->cfg_stream_count = 1;
+
+ pstate->cfg_device_state = VL53L1_DEVICESTATE_RANGING_DSS_AUTO;
+ break;
+
+ case VL53L1_DEVICESTATE_RANGING_DSS_AUTO:
+
+ pstate->cfg_timing_status ^= 0x01;
+
+ break;
+
+ default:
+
+ pstate->cfg_device_state = VL53L1_DEVICESTATE_SW_STANDBY;
+ pstate->cfg_stream_count = 0;
+ pstate->cfg_gph_id = VL53L1_GROUPEDPARAMETERHOLD_ID_MASK;
+ pstate->cfg_timing_status = 0;
+
+ break;
+ }
+ }
+
+#ifdef VL53L1_LOGGING
+ VL53L1_print_ll_driver_state(pstate);
+#endif
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+void VL53L1_copy_rtn_good_spads_to_buffer(
+ VL53L1_nvm_copy_data_t *pdata,
+ uint8_t *pbuffer)
+{
+ /*
+ * Convenience function to copy return SPAD enables to buffer
+ */
+
+ *(pbuffer + 0) = pdata->global_config__spad_enables_rtn_0;
+ *(pbuffer + 1) = pdata->global_config__spad_enables_rtn_1;
+ *(pbuffer + 2) = pdata->global_config__spad_enables_rtn_2;
+ *(pbuffer + 3) = pdata->global_config__spad_enables_rtn_3;
+ *(pbuffer + 4) = pdata->global_config__spad_enables_rtn_4;
+ *(pbuffer + 5) = pdata->global_config__spad_enables_rtn_5;
+ *(pbuffer + 6) = pdata->global_config__spad_enables_rtn_6;
+ *(pbuffer + 7) = pdata->global_config__spad_enables_rtn_7;
+ *(pbuffer + 8) = pdata->global_config__spad_enables_rtn_8;
+ *(pbuffer + 9) = pdata->global_config__spad_enables_rtn_9;
+ *(pbuffer + 10) = pdata->global_config__spad_enables_rtn_10;
+ *(pbuffer + 11) = pdata->global_config__spad_enables_rtn_11;
+ *(pbuffer + 12) = pdata->global_config__spad_enables_rtn_12;
+ *(pbuffer + 13) = pdata->global_config__spad_enables_rtn_13;
+ *(pbuffer + 14) = pdata->global_config__spad_enables_rtn_14;
+ *(pbuffer + 15) = pdata->global_config__spad_enables_rtn_15;
+ *(pbuffer + 16) = pdata->global_config__spad_enables_rtn_16;
+ *(pbuffer + 17) = pdata->global_config__spad_enables_rtn_17;
+ *(pbuffer + 18) = pdata->global_config__spad_enables_rtn_18;
+ *(pbuffer + 19) = pdata->global_config__spad_enables_rtn_19;
+ *(pbuffer + 20) = pdata->global_config__spad_enables_rtn_20;
+ *(pbuffer + 21) = pdata->global_config__spad_enables_rtn_21;
+ *(pbuffer + 22) = pdata->global_config__spad_enables_rtn_22;
+ *(pbuffer + 23) = pdata->global_config__spad_enables_rtn_23;
+ *(pbuffer + 24) = pdata->global_config__spad_enables_rtn_24;
+ *(pbuffer + 25) = pdata->global_config__spad_enables_rtn_25;
+ *(pbuffer + 26) = pdata->global_config__spad_enables_rtn_26;
+ *(pbuffer + 27) = pdata->global_config__spad_enables_rtn_27;
+ *(pbuffer + 28) = pdata->global_config__spad_enables_rtn_28;
+ *(pbuffer + 29) = pdata->global_config__spad_enables_rtn_29;
+ *(pbuffer + 30) = pdata->global_config__spad_enables_rtn_30;
+ *(pbuffer + 31) = pdata->global_config__spad_enables_rtn_31;
+}
+
+
+void VL53L1_init_system_results(
+ VL53L1_system_results_t *pdata)
+{
+ /*
+ * Initialises the system results to all 0xFF just like the
+ * device firmware does a the start of a range
+ */
+
+ pdata->result__interrupt_status = 0xFF;
+ pdata->result__range_status = 0xFF;
+ pdata->result__report_status = 0xFF;
+ pdata->result__stream_count = 0xFF;
+
+ pdata->result__dss_actual_effective_spads_sd0 = 0xFFFF;
+ pdata->result__peak_signal_count_rate_mcps_sd0 = 0xFFFF;
+ pdata->result__ambient_count_rate_mcps_sd0 = 0xFFFF;
+ pdata->result__sigma_sd0 = 0xFFFF;
+ pdata->result__phase_sd0 = 0xFFFF;
+ pdata->result__final_crosstalk_corrected_range_mm_sd0 = 0xFFFF;
+ pdata->result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0 =
+ 0xFFFF;
+ pdata->result__mm_inner_actual_effective_spads_sd0 = 0xFFFF;
+ pdata->result__mm_outer_actual_effective_spads_sd0 = 0xFFFF;
+ pdata->result__avg_signal_count_rate_mcps_sd0 = 0xFFFF;
+
+ pdata->result__dss_actual_effective_spads_sd1 = 0xFFFF;
+ pdata->result__peak_signal_count_rate_mcps_sd1 = 0xFFFF;
+ pdata->result__ambient_count_rate_mcps_sd1 = 0xFFFF;
+ pdata->result__sigma_sd1 = 0xFFFF;
+ pdata->result__phase_sd1 = 0xFFFF;
+ pdata->result__final_crosstalk_corrected_range_mm_sd1 = 0xFFFF;
+ pdata->result__spare_0_sd1 = 0xFFFF;
+ pdata->result__spare_1_sd1 = 0xFFFF;
+ pdata->result__spare_2_sd1 = 0xFFFF;
+ pdata->result__spare_3_sd1 = 0xFF;
+
+}
+
+
+void VL53L1_i2c_encode_uint16_t(
+ uint16_t ip_value,
+ uint16_t count,
+ uint8_t *pbuffer)
+{
+ /*
+ * Encodes a uint16_t register value into an I2C write buffer
+ * MS byte first order (as per I2C register map.
+ */
+
+ uint16_t i = 0;
+ uint16_t data = 0;
+
+ data = ip_value;
+
+ for (i = 0; i < count ; i++) {
+ pbuffer[count-i-1] = (uint8_t)(data & 0x00FF);
+ data = data >> 8;
+ }
+}
+
+uint16_t VL53L1_i2c_decode_uint16_t(
+ uint16_t count,
+ uint8_t *pbuffer)
+{
+ /*
+ * Decodes a uint16_t from the input I2C read buffer
+ * (MS byte first order)
+ */
+
+ uint16_t value = 0x00;
+
+ while (count-- > 0) {
+ value = (value << 8) | (uint16_t)*pbuffer++;
+ }
+
+ return value;
+}
+
+
+void VL53L1_i2c_encode_int16_t(
+ int16_t ip_value,
+ uint16_t count,
+ uint8_t *pbuffer)
+{
+ /*
+ * Encodes a int16_t register value into an I2C write buffer
+ * MS byte first order (as per I2C register map.
+ */
+
+ uint16_t i = 0;
+ int16_t data = 0;
+
+ data = ip_value;
+
+ for (i = 0; i < count ; i++) {
+ pbuffer[count-i-1] = (uint8_t)(data & 0x00FF);
+ data = data >> 8;
+ }
+}
+
+int16_t VL53L1_i2c_decode_int16_t(
+ uint16_t count,
+ uint8_t *pbuffer)
+{
+ /*
+ * Decodes a int16_t from the input I2C read buffer
+ * (MS byte first order)
+ */
+
+ int16_t value = 0x00;
+
+ /* implement sign extension */
+ if (*pbuffer >= 0x80) {
+ value = 0xFFFF;
+ }
+
+ while (count-- > 0) {
+ value = (value << 8) | (int16_t)*pbuffer++;
+ }
+
+ return value;
+}
+
+void VL53L1_i2c_encode_uint32_t(
+ uint32_t ip_value,
+ uint16_t count,
+ uint8_t *pbuffer)
+{
+ /*
+ * Encodes a uint32_t register value into an I2C write buffer
+ * MS byte first order (as per I2C register map.
+ */
+
+ uint16_t i = 0;
+ uint32_t data = 0;
+
+ data = ip_value;
+
+ for (i = 0; i < count ; i++) {
+ pbuffer[count-i-1] = (uint8_t)(data & 0x00FF);
+ data = data >> 8;
+ }
+}
+
+uint32_t VL53L1_i2c_decode_uint32_t(
+ uint16_t count,
+ uint8_t *pbuffer)
+{
+ /*
+ * Decodes a uint32_t from the input I2C read buffer
+ * (MS byte first order)
+ */
+
+ uint32_t value = 0x00;
+
+ while (count-- > 0) {
+ value = (value << 8) | (uint32_t)*pbuffer++;
+ }
+
+ return value;
+}
+
+
+uint32_t VL53L1_i2c_decode_with_mask(
+ uint16_t count,
+ uint8_t *pbuffer,
+ uint32_t bit_mask,
+ uint32_t down_shift,
+ uint32_t offset)
+{
+ /*
+ * Decodes an integer from the input I2C read buffer
+ * (MS byte first order)
+ */
+
+ uint32_t value = 0x00;
+
+ /* extract from buffer */
+ while (count-- > 0) {
+ value = (value << 8) | (uint32_t)*pbuffer++;
+ }
+
+ /* Apply bit mask and down shift */
+ value = value & bit_mask;
+ if (down_shift > 0) {
+ value = value >> down_shift;
+ }
+
+ /* add offset */
+ value = value + offset;
+
+ return value;
+}
+
+
+void VL53L1_i2c_encode_int32_t(
+ int32_t ip_value,
+ uint16_t count,
+ uint8_t *pbuffer)
+{
+ /*
+ * Encodes a int32_t register value into an I2C write buffer
+ * MS byte first order (as per I2C register map.
+ */
+
+ uint16_t i = 0;
+ int32_t data = 0;
+
+ data = ip_value;
+
+ for (i = 0; i < count ; i++) {
+ pbuffer[count-i-1] = (uint8_t)(data & 0x00FF);
+ data = data >> 8;
+ }
+}
+
+int32_t VL53L1_i2c_decode_int32_t(
+ uint16_t count,
+ uint8_t *pbuffer)
+{
+ /*
+ * Decodes a int32_t from the input I2C read buffer
+ * (MS byte first order)
+ */
+
+ int32_t value = 0x00;
+
+ /* implement sign extension */
+ if (*pbuffer >= 0x80) {
+ value = 0xFFFFFFFF;
+ }
+
+ while (count-- > 0) {
+ value = (value << 8) | (int32_t)*pbuffer++;
+ }
+
+ return value;
+}
+
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_start_test(
+ VL53L1_DEV Dev,
+ uint8_t test_mode__ctrl)
+{
+ /*
+ * Triggers the start of a test mode
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) { /*lint !e774 always true*/
+ status = VL53L1_WrByte(
+ Dev,
+ VL53L1_TEST_MODE__CTRL,
+ test_mode__ctrl);
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_set_firmware_enable_register(
+ VL53L1_DEV Dev,
+ uint8_t value)
+{
+ /*
+ * Set FIRMWARE__ENABLE register
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ pdev->sys_ctrl.firmware__enable = value;
+
+ status = VL53L1_WrByte(
+ Dev,
+ VL53L1_FIRMWARE__ENABLE,
+ pdev->sys_ctrl.firmware__enable);
+
+ return status;
+}
+
+VL53L1_Error VL53L1_enable_firmware(
+ VL53L1_DEV Dev)
+{
+ /*
+ * Enable firmware
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ status = VL53L1_set_firmware_enable_register(Dev, 0x01);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_disable_firmware(
+ VL53L1_DEV Dev)
+{
+ /*
+ * Disable firmware
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ status = VL53L1_set_firmware_enable_register(Dev, 0x00);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_powerforce_register(
+ VL53L1_DEV Dev,
+ uint8_t value)
+{
+ /*
+ * Set power force register
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ pdev->sys_ctrl.power_management__go1_power_force = value;
+
+ status = VL53L1_WrByte(
+ Dev,
+ VL53L1_POWER_MANAGEMENT__GO1_POWER_FORCE,
+ pdev->sys_ctrl.power_management__go1_power_force);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_enable_powerforce(
+ VL53L1_DEV Dev)
+{
+ /*
+ * Enable power force
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ status = VL53L1_set_powerforce_register(Dev, 0x01);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_disable_powerforce(
+ VL53L1_DEV Dev)
+{
+ /*
+ * Disable power force
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ status = VL53L1_set_powerforce_register(Dev, 0x00);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_clear_interrupt(
+ VL53L1_DEV Dev)
+{
+ /*
+ * Clear Ranging interrupt by writing to
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ pdev->sys_ctrl.system__interrupt_clear = VL53L1_CLEAR_RANGE_INT;
+
+ status = VL53L1_WrByte(
+ Dev,
+ VL53L1_SYSTEM__INTERRUPT_CLEAR,
+ pdev->sys_ctrl.system__interrupt_clear);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_force_shadow_stream_count_to_zero(
+ VL53L1_DEV Dev)
+{
+ /*
+ * Forces shadow stream count to zero
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ if (status == VL53L1_ERROR_NONE) { /*lint !e774 always true*/
+ status = VL53L1_disable_firmware(Dev);
+ }
+
+ if (status == VL53L1_ERROR_NONE) {
+ status = VL53L1_WrByte(
+ Dev,
+ VL53L1_SHADOW_RESULT__STREAM_COUNT,
+ 0x00);
+ }
+
+ if (status == VL53L1_ERROR_NONE) {
+ status = VL53L1_enable_firmware(Dev);
+ }
+
+ return status;
+}
+#endif
+
+uint32_t VL53L1_calc_macro_period_us(
+ uint16_t fast_osc_frequency,
+ uint8_t vcsel_period)
+{
+ /* Calculates macro period in [us] from the input fast oscillator
+ * frequency and VCSEL period
+ *
+ * Macro period fixed point format = unsigned 12.12
+ * Maximum supported macro period = 4095.9999 us
+ */
+
+ uint32_t pll_period_us = 0;
+ uint8_t vcsel_period_pclks = 0;
+ uint32_t macro_period_us = 0;
+
+ LOG_FUNCTION_START("");
+
+ /* Calculate PLL period in [us] from the fast_osc_frequency
+ * Fast osc frequency fixed point format = unsigned 4.12
+ */
+
+ pll_period_us = VL53L1_calc_pll_period_us(fast_osc_frequency);
+
+ /* VCSEL period
+ * - the real VCSEL period in PLL clocks = 2*(VCSEL_PERIOD+1)
+ */
+
+ vcsel_period_pclks = VL53L1_decode_vcsel_period(vcsel_period);
+
+ /* Macro period
+ * - PLL period [us] = 0.24 format
+ * - for 1.0 MHz fast oscillator freq
+ * - max PLL period = 1/64 (6-bits)
+ * - i.e only the lower 18-bits of PLL Period value are used
+ * - Macro period [vclks] = 2304 (12-bits)
+ *
+ * Max bits (24 - 6) + 12 = 30-bits usage
+ *
+ * Downshift by 6 before multiplying by the VCSEL Period
+ */
+
+ macro_period_us =
+ (uint32_t)VL53L1_MACRO_PERIOD_VCSEL_PERIODS *
+ pll_period_us;
+ macro_period_us = macro_period_us >> 6;
+
+ macro_period_us = macro_period_us * (uint32_t)vcsel_period_pclks;
+ macro_period_us = macro_period_us >> 6;
+
+#ifdef VL53L1_LOGGING
+ trace_print(VL53L1_TRACE_LEVEL_DEBUG,
+ " %-48s : %10u\n", "pll_period_us",
+ pll_period_us);
+ trace_print(VL53L1_TRACE_LEVEL_DEBUG,
+ " %-48s : %10u\n", "vcsel_period_pclks",
+ vcsel_period_pclks);
+ trace_print(VL53L1_TRACE_LEVEL_DEBUG,
+ " %-48s : %10u\n", "macro_period_us",
+ macro_period_us);
+#endif
+
+ LOG_FUNCTION_END(0);
+
+ return macro_period_us;
+}
+
+
+uint16_t VL53L1_calc_range_ignore_threshold(
+ uint32_t central_rate,
+ int16_t x_gradient,
+ int16_t y_gradient,
+ uint8_t rate_mult)
+{
+ /* Calculates Range Ignore Threshold rate per spad
+ * in Mcps - 3.13 format
+ *
+ * Calculates worst case xtalk rate per spad in array corner
+ * based on input central xtalk and x and y gradients
+ *
+ * Worst case rate = central rate + (8*(magnitude(xgrad)) +
+ * (8*(magnitude(ygrad)))
+ *
+ * Range ignore threshold rate is then multiplied by user input
+ * rate_mult (in 3.5 fractional format)
+ *
+ */
+
+ int32_t range_ignore_thresh_int = 0;
+ uint16_t range_ignore_thresh_kcps = 0;
+ int32_t central_rate_int = 0;
+ int16_t x_gradient_int = 0;
+ int16_t y_gradient_int = 0;
+
+ LOG_FUNCTION_START("");
+
+ /* Shift central_rate to .13 fractional for simple addition */
+
+ central_rate_int = ((int32_t)central_rate * (1 << 4)) / (1000);
+
+ if (x_gradient < 0) {
+ x_gradient_int = x_gradient * -1;
+ }
+
+ if (y_gradient < 0) {
+ y_gradient_int = y_gradient * -1;
+ }
+
+ /* Calculate full rate per spad - worst case from measured xtalk */
+ /* Generated here from .11 fractional kcps */
+ /* Additional factor of 4 applied to bring fractional precision to .13 */
+
+ range_ignore_thresh_int = (8 * x_gradient_int * 4) + (8 * y_gradient_int * 4);
+
+ /* Convert Kcps to Mcps */
+
+ range_ignore_thresh_int = range_ignore_thresh_int / 1000;
+
+ /* Combine with Central Rate - Mcps .13 format*/
+
+ range_ignore_thresh_int = range_ignore_thresh_int + central_rate_int;
+
+ /* Mult by user input */
+
+ range_ignore_thresh_int = (int32_t)rate_mult * range_ignore_thresh_int;
+
+ range_ignore_thresh_int = (range_ignore_thresh_int + (1<<4)) / (1<<5);
+
+ /* Finally clip and output in correct format */
+
+ if (range_ignore_thresh_int > 0xFFFF) {
+ range_ignore_thresh_kcps = 0xFFFF;
+ } else {
+ range_ignore_thresh_kcps = (uint16_t)range_ignore_thresh_int;
+ }
+
+#ifdef VL53L1_LOGGING
+ trace_print(VL53L1_TRACE_LEVEL_DEBUG,
+ " %-48s : %10u\n", "range_ignore_thresh_kcps",
+ range_ignore_thresh_kcps);
+#endif
+
+ LOG_FUNCTION_END(0);
+
+ return range_ignore_thresh_kcps;
+}
+
+
+uint32_t VL53L1_calc_timeout_mclks(
+ uint32_t timeout_us,
+ uint32_t macro_period_us)
+{
+ /* Calculates the timeout value in macro periods based on the input
+ * timeout period in milliseconds and the macro period in [us]
+ *
+ * Max timeout supported is 1000000 us (1 sec) -> 20-bits
+ * Max timeout in 20.12 format = 32-bits
+ *
+ * Macro period [us] = 12.12 format
+ */
+
+ uint32_t timeout_mclks = 0;
+
+ LOG_FUNCTION_START("");
+
+ timeout_mclks =
+ ((timeout_us << 12) + (macro_period_us>>1)) /
+ macro_period_us;
+
+ LOG_FUNCTION_END(0);
+
+ return timeout_mclks;
+}
+
+
+uint16_t VL53L1_calc_encoded_timeout(
+ uint32_t timeout_us,
+ uint32_t macro_period_us)
+{
+ /* Calculates the encoded timeout register value based on the input
+ * timeout period in milliseconds and the macro period in [us]
+ *
+ * Max timeout supported is 1000000 us (1 sec) -> 20-bits
+ * Max timeout in 20.12 format = 32-bits
+ *
+ * Macro period [us] = 12.12 format
+ */
+
+ uint32_t timeout_mclks = 0;
+ uint16_t timeout_encoded = 0;
+
+ LOG_FUNCTION_START("");
+
+ timeout_mclks =
+ VL53L1_calc_timeout_mclks(timeout_us, macro_period_us);
+
+ timeout_encoded =
+ VL53L1_encode_timeout(timeout_mclks);
+
+#ifdef VL53L1_LOGGING
+ trace_print(VL53L1_TRACE_LEVEL_DEBUG,
+ " %-48s : %10u (0x%04X)\n", "timeout_mclks",
+ timeout_mclks, timeout_mclks);
+ trace_print(VL53L1_TRACE_LEVEL_DEBUG,
+ " %-48s : %10u (0x%04X)\n", "timeout_encoded",
+ timeout_encoded, timeout_encoded);
+#endif
+
+ LOG_FUNCTION_END(0);
+
+ return timeout_encoded;
+}
+
+
+uint32_t VL53L1_calc_timeout_us(
+ uint32_t timeout_mclks,
+ uint32_t macro_period_us)
+{
+ /* Calculates the timeout in [us] based on the input
+ * encoded timeout and the macro period in [us]
+ *
+ * Max timeout supported is 1000000 us (1 sec) -> 20-bits
+ * Max timeout in 20.12 format = 32-bits
+ *
+ * Macro period [us] = 12.12 format
+ */
+
+ uint32_t timeout_us = 0;
+ uint64_t tmp = 0;
+
+ LOG_FUNCTION_START("");
+
+ tmp = (uint64_t)timeout_mclks * (uint64_t)macro_period_us;
+ tmp += 0x00800;
+ tmp = tmp >> 12;
+
+ timeout_us = (uint32_t)tmp;
+
+#ifdef VL53L1_LOGGING
+ trace_print(VL53L1_TRACE_LEVEL_DEBUG,
+ " %-48s : %10u (0x%04X)\n", "timeout_mclks",
+ timeout_mclks, timeout_mclks);
+
+ trace_print(VL53L1_TRACE_LEVEL_DEBUG,
+ " %-48s : %10u us\n", "timeout_us",
+ timeout_us, timeout_us);
+#endif
+
+ LOG_FUNCTION_END(0);
+
+ return timeout_us;
+}
+
+uint32_t VL53L1_calc_crosstalk_plane_offset_with_margin(
+ uint32_t plane_offset_kcps,
+ int16_t margin_offset_kcps)
+{
+ uint32_t plane_offset_with_margin = 0;
+ int32_t plane_offset_kcps_temp = 0;
+
+ LOG_FUNCTION_START("");
+
+ plane_offset_kcps_temp =
+ (int32_t)plane_offset_kcps +
+ (int32_t)margin_offset_kcps;
+
+ if (plane_offset_kcps_temp < 0) {
+ plane_offset_kcps_temp = 0;
+ } else {
+ if (plane_offset_kcps_temp > 0x3FFFF) {
+ plane_offset_kcps_temp = 0x3FFFF;
+ }
+ }
+
+ plane_offset_with_margin = (uint32_t) plane_offset_kcps_temp;
+
+ LOG_FUNCTION_END(0);
+
+ return plane_offset_with_margin;
+
+}
+
+uint32_t VL53L1_calc_decoded_timeout_us(
+ uint16_t timeout_encoded,
+ uint32_t macro_period_us)
+{
+ /* Calculates the timeout in [us] based on the input
+ * encoded timeout and the macro period in [us]
+ *
+ * Max timeout supported is 1000000 us (1 sec) -> 20-bits
+ * Max timeout in 20.12 format = 32-bits
+ *
+ * Macro period [us] = 12.12 format
+ */
+
+ uint32_t timeout_mclks = 0;
+ uint32_t timeout_us = 0;
+
+ LOG_FUNCTION_START("");
+
+ timeout_mclks =
+ VL53L1_decode_timeout(timeout_encoded);
+
+ timeout_us =
+ VL53L1_calc_timeout_us(timeout_mclks, macro_period_us);
+
+ LOG_FUNCTION_END(0);
+
+ return timeout_us;
+}
+
+
+uint16_t VL53L1_encode_timeout(uint32_t timeout_mclks)
+{
+ /*
+ * Encode timeout in macro periods in (LSByte * 2^MSByte) + 1 format
+ */
+
+ uint16_t encoded_timeout = 0;
+ uint32_t ls_byte = 0;
+ uint16_t ms_byte = 0;
+
+ if (timeout_mclks > 0) {
+ ls_byte = timeout_mclks - 1;
+
+ while ((ls_byte & 0xFFFFFF00) > 0) {
+ ls_byte = ls_byte >> 1;
+ ms_byte++;
+ }
+
+ encoded_timeout = (ms_byte << 8)
+ + (uint16_t) (ls_byte & 0x000000FF);
+ }
+
+ return encoded_timeout;
+}
+
+
+uint32_t VL53L1_decode_timeout(uint16_t encoded_timeout)
+{
+ /*
+ * Decode 16-bit timeout register value
+ * format (LSByte * 2^MSByte) + 1
+ */
+
+ uint32_t timeout_macro_clks = 0;
+
+ timeout_macro_clks = ((uint32_t) (encoded_timeout & 0x00FF)
+ << (uint32_t) ((encoded_timeout & 0xFF00) >> 8)) + 1;
+
+ return timeout_macro_clks;
+}
+
+
+VL53L1_Error VL53L1_calc_timeout_register_values(
+ uint32_t phasecal_config_timeout_us,
+ uint32_t mm_config_timeout_us,
+ uint32_t range_config_timeout_us,
+ uint16_t fast_osc_frequency,
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_timing_config_t *ptiming)
+{
+ /*
+ * Converts the input MM and range timeouts in [us]
+ * into the appropriate register values
+ *
+ * Must also be run after the VCSEL period settings are changed
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ uint32_t macro_period_us = 0;
+ uint32_t timeout_mclks = 0;
+ uint16_t timeout_encoded = 0;
+
+ LOG_FUNCTION_START("");
+
+ if (fast_osc_frequency == 0) {
+ status = VL53L1_ERROR_DIVISION_BY_ZERO;
+ } else {
+ /* Update Macro Period for Range A VCSEL Period */
+ macro_period_us =
+ VL53L1_calc_macro_period_us(
+ fast_osc_frequency,
+ ptiming->range_config__vcsel_period_a);
+
+ /* Update Phase timeout - uses Timing A */
+ timeout_mclks =
+ VL53L1_calc_timeout_mclks(
+ phasecal_config_timeout_us,
+ macro_period_us);
+
+ /* clip as the phase cal timeout register is only 8-bits */
+ if (timeout_mclks > 0xFF)
+ timeout_mclks = 0xFF;
+
+ pgeneral->phasecal_config__timeout_macrop =
+ (uint8_t)timeout_mclks;
+
+ /* Update MM Timing A timeout */
+ timeout_encoded =
+ VL53L1_calc_encoded_timeout(
+ mm_config_timeout_us,
+ macro_period_us);
+
+ ptiming->mm_config__timeout_macrop_a_hi =
+ (uint8_t)((timeout_encoded & 0xFF00) >> 8);
+ ptiming->mm_config__timeout_macrop_a_lo =
+ (uint8_t) (timeout_encoded & 0x00FF);
+
+ /* Update Range Timing A timeout */
+ timeout_encoded =
+ VL53L1_calc_encoded_timeout(
+ range_config_timeout_us,
+ macro_period_us);
+
+ ptiming->range_config__timeout_macrop_a_hi =
+ (uint8_t)((timeout_encoded & 0xFF00) >> 8);
+ ptiming->range_config__timeout_macrop_a_lo =
+ (uint8_t) (timeout_encoded & 0x00FF);
+
+ /* Update Macro Period for Range B VCSEL Period */
+ macro_period_us =
+ VL53L1_calc_macro_period_us(
+ fast_osc_frequency,
+ ptiming->range_config__vcsel_period_b);
+
+ /* Update MM Timing B timeout */
+ timeout_encoded =
+ VL53L1_calc_encoded_timeout(
+ mm_config_timeout_us,
+ macro_period_us);
+
+ ptiming->mm_config__timeout_macrop_b_hi =
+ (uint8_t)((timeout_encoded & 0xFF00) >> 8);
+ ptiming->mm_config__timeout_macrop_b_lo =
+ (uint8_t) (timeout_encoded & 0x00FF);
+
+ /* Update Range Timing B timeout */
+ timeout_encoded = VL53L1_calc_encoded_timeout(
+ range_config_timeout_us,
+ macro_period_us);
+
+ ptiming->range_config__timeout_macrop_b_hi =
+ (uint8_t)((timeout_encoded & 0xFF00) >> 8);
+ ptiming->range_config__timeout_macrop_b_lo =
+ (uint8_t) (timeout_encoded & 0x00FF);
+ }
+
+ LOG_FUNCTION_END(0);
+
+ return status;
+
+}
+
+
+uint8_t VL53L1_encode_vcsel_period(uint8_t vcsel_period_pclks)
+{
+ /*
+ * Converts the encoded VCSEL period register value into
+ * the real period in PLL clocks
+ */
+
+ uint8_t vcsel_period_reg = 0;
+
+ vcsel_period_reg = (vcsel_period_pclks >> 1) - 1;
+
+ return vcsel_period_reg;
+}
+
+
+uint32_t VL53L1_decode_unsigned_integer(
+ uint8_t *pbuffer,
+ uint8_t no_of_bytes)
+{
+ /*
+ * Decodes a integer number from the buffer
+ */
+
+ uint8_t i = 0;
+ uint32_t decoded_value = 0;
+
+ for (i = 0 ; i < no_of_bytes ; i++) {
+ decoded_value = (decoded_value << 8) + (uint32_t)pbuffer[i];
+ }
+
+ return decoded_value;
+}
+
+
+void VL53L1_encode_unsigned_integer(
+ uint32_t ip_value,
+ uint8_t no_of_bytes,
+ uint8_t *pbuffer)
+{
+ /*
+ * Encodes an integer number into the buffer
+ */
+
+ uint8_t i = 0;
+ uint32_t data = 0;
+
+ data = ip_value;
+ for (i = 0; i < no_of_bytes ; i++) {
+ pbuffer[no_of_bytes-i-1] = data & 0x00FF;
+ data = data >> 8;
+ }
+}
+
+
+void VL53L1_spad_number_to_byte_bit_index(
+ uint8_t spad_number,
+ uint8_t *pbyte_index,
+ uint8_t *pbit_index,
+ uint8_t *pbit_mask)
+{
+
+ /**
+ * Converts the input SPAD number into the SPAD Enable byte index, bit index and bit mask
+ *
+ * byte_index = (spad_no >> 3)
+ * bit_index = spad_no & 0x07
+ * bit_mask = 0x01 << bit_index
+ */
+
+ *pbyte_index = spad_number >> 3;
+ *pbit_index = spad_number & 0x07;
+ *pbit_mask = 0x01 << *pbit_index;
+
+}
+
+
+void VL53L1_encode_row_col(
+ uint8_t row,
+ uint8_t col,
+ uint8_t *pspad_number)
+{
+ /**
+ * Encodes the input array(row,col) location as SPAD number.
+ */
+
+ if (row > 7) {
+ *pspad_number = 128 + (col << 3) + (15-row);
+ } else {
+ *pspad_number = ((15-col) << 3) + row;
+ }
+}
+
+
+void VL53L1_decode_zone_size(
+ uint8_t encoded_xy_size,
+ uint8_t *pwidth,
+ uint8_t *pheight)
+{
+
+ /* extract x and y sizes
+ *
+ * Important: the sense of the device width and height is swapped
+ * versus the API sense
+ *
+ * MS Nibble = height
+ * LS Nibble = width
+ */
+
+ *pheight = encoded_xy_size >> 4;
+ *pwidth = encoded_xy_size & 0x0F;
+
+}
+
+
+void VL53L1_encode_zone_size(
+ uint8_t width,
+ uint8_t height,
+ uint8_t *pencoded_xy_size)
+{
+ /* merge x and y sizes
+ *
+ * Important: the sense of the device width and height is swapped
+ * versus the API sense
+ *
+ * MS Nibble = height
+ * LS Nibble = width
+ */
+
+ *pencoded_xy_size = (height << 4) + width;
+
+}
+
+
+void VL53L1_decode_zone_limits(
+ uint8_t encoded_xy_centre,
+ uint8_t encoded_xy_size,
+ int16_t *px_ll,
+ int16_t *py_ll,
+ int16_t *px_ur,
+ int16_t *py_ur)
+{
+
+ /*
+ * compute zone lower left and upper right limits
+ *
+ * centre (8,8) width = 16, height = 16 -> (0,0) -> (15,15)
+ * centre (8,8) width = 14, height = 16 -> (1,0) -> (14,15)
+ */
+
+ uint8_t x_centre = 0;
+ uint8_t y_centre = 0;
+ uint8_t width = 0;
+ uint8_t height = 0;
+
+ /* decode zone centre and size information */
+
+ VL53L1_decode_row_col(
+ encoded_xy_centre,
+ &y_centre,
+ &x_centre);
+
+ VL53L1_decode_zone_size(
+ encoded_xy_size,
+ &width,
+ &height);
+
+ /* compute bounds and clip */
+
+ *px_ll = (int16_t)x_centre - ((int16_t)width + 1) / 2;
+ if (*px_ll < 0)
+ *px_ll = 0;
+
+ *px_ur = *px_ll + (int16_t)width;
+ if (*px_ur > (VL53L1_SPAD_ARRAY_WIDTH-1))
+ *px_ur = VL53L1_SPAD_ARRAY_WIDTH-1;
+
+ *py_ll = (int16_t)y_centre - ((int16_t)height + 1) / 2;
+ if (*py_ll < 0)
+ *py_ll = 0;
+
+ *py_ur = *py_ll + (int16_t)height;
+ if (*py_ur > (VL53L1_SPAD_ARRAY_HEIGHT-1))
+ *py_ur = VL53L1_SPAD_ARRAY_HEIGHT-1;
+}
+
+
+uint8_t VL53L1_is_aperture_location(
+ uint8_t row,
+ uint8_t col)
+{
+ /*
+ * Returns > 0 if input (row,col) location is an aperture
+ */
+
+ uint8_t is_aperture = 0;
+ uint8_t mod_row = row % 4;
+ uint8_t mod_col = col % 4;
+
+ if (mod_row == 0 && mod_col == 2)
+ is_aperture = 1;
+
+ if (mod_row == 2 && mod_col == 0)
+ is_aperture = 1;
+
+ return is_aperture;
+}
+
+
+void VL53L1_calc_mm_effective_spads(
+ uint8_t encoded_mm_roi_centre,
+ uint8_t encoded_mm_roi_size,
+ uint8_t encoded_zone_centre,
+ uint8_t encoded_zone_size,
+ uint8_t *pgood_spads,
+ uint16_t aperture_attenuation,
+ uint16_t *pmm_inner_effective_spads,
+ uint16_t *pmm_outer_effective_spads)
+{
+
+ /* Calculates the effective SPAD counts for the MM inner and outer
+ * regions based on the input MM ROI, Zone info and return good
+ * SPAD map
+ */
+
+ int16_t x = 0;
+ int16_t y = 0;
+
+ int16_t mm_x_ll = 0;
+ int16_t mm_y_ll = 0;
+ int16_t mm_x_ur = 0;
+ int16_t mm_y_ur = 0;
+
+ int16_t zone_x_ll = 0;
+ int16_t zone_y_ll = 0;
+ int16_t zone_x_ur = 0;
+ int16_t zone_y_ur = 0;
+
+ uint8_t spad_number = 0;
+ uint8_t byte_index = 0;
+ uint8_t bit_index = 0;
+ uint8_t bit_mask = 0;
+
+ uint8_t is_aperture = 0;
+ uint16_t spad_attenuation = 0;
+
+ /* decode the MM ROI and Zone limits */
+
+ VL53L1_decode_zone_limits(
+ encoded_mm_roi_centre,
+ encoded_mm_roi_size,
+ &mm_x_ll,
+ &mm_y_ll,
+ &mm_x_ur,
+ &mm_y_ur);
+
+ VL53L1_decode_zone_limits(
+ encoded_zone_centre,
+ encoded_zone_size,
+ &zone_x_ll,
+ &zone_y_ll,
+ &zone_x_ur,
+ &zone_y_ur);
+
+ /*
+ * Loop though all SPAD within the zone. Check if it is
+ * a good SPAD then add the transmission value to either
+ * the inner or outer effective SPAD count dependent if
+ * the SPAD lies within the MM ROI.
+ */
+
+ *pmm_inner_effective_spads = 0;
+ *pmm_outer_effective_spads = 0;
+
+ for (y = zone_y_ll ; y <= zone_y_ur ; y++) {
+ for (x = zone_x_ll ; x <= zone_x_ur ; x++) {
+
+ /* Convert location into SPAD number */
+
+ VL53L1_encode_row_col(
+ (uint8_t)y,
+ (uint8_t)x,
+ &spad_number);
+
+ /* Convert spad number into byte and bit index
+ * this is required to look up the appropriate
+ * SPAD enable bit with the 32-byte good SPAD
+ * enable buffer
+ */
+
+ VL53L1_spad_number_to_byte_bit_index(
+ spad_number,
+ &byte_index,
+ &bit_index,
+ &bit_mask);
+
+ /* If spad is good then add it */
+
+ if ((pgood_spads[byte_index] & bit_mask) > 0) {
+ /* determine if apertured SPAD or not */
+
+ is_aperture = VL53L1_is_aperture_location(
+ (uint8_t)y,
+ (uint8_t)x);
+
+ if (is_aperture > 0)
+ spad_attenuation = aperture_attenuation;
+ else
+ spad_attenuation = 0x0100;
+
+ /*
+ * if inside MM roi add to inner effective SPAD count
+ * otherwise add to outer effective SPAD Count
+ */
+
+ if (x >= mm_x_ll && x <= mm_x_ur &&
+ y >= mm_y_ll && y <= mm_y_ur)
+ *pmm_inner_effective_spads +=
+ spad_attenuation;
+ else
+ *pmm_outer_effective_spads +=
+ spad_attenuation;
+ }
+ }
+ }
+}
+
+
+/*
+ * Encodes VL53L1_GPIO_interrupt_config_t structure to FW register format
+ */
+
+uint8_t VL53L1_encode_GPIO_interrupt_config(
+ VL53L1_GPIO_interrupt_config_t *pintconf)
+{
+ uint8_t system__interrupt_config;
+
+ system__interrupt_config = pintconf->intr_mode_distance;
+ system__interrupt_config |= ((pintconf->intr_mode_rate) << 2);
+ system__interrupt_config |= ((pintconf->intr_new_measure_ready) << 5);
+ system__interrupt_config |= ((pintconf->intr_no_target) << 6);
+ system__interrupt_config |= ((pintconf->intr_combined_mode) << 7);
+
+ return system__interrupt_config;
+}
+
+/*
+ * Decodes FW register to VL53L1_GPIO_interrupt_config_t structure
+ */
+
+VL53L1_GPIO_interrupt_config_t VL53L1_decode_GPIO_interrupt_config(
+ uint8_t system__interrupt_config)
+{
+ VL53L1_GPIO_interrupt_config_t intconf;
+
+ intconf.intr_mode_distance = system__interrupt_config & 0x03;
+ intconf.intr_mode_rate = (system__interrupt_config >> 2) & 0x03;
+ intconf.intr_new_measure_ready = (system__interrupt_config >> 5) & 0x01;
+ intconf.intr_no_target = (system__interrupt_config >> 6) & 0x01;
+ intconf.intr_combined_mode = (system__interrupt_config >> 7) & 0x01;
+
+ /* set some default values */
+ intconf.threshold_rate_low = 0;
+ intconf.threshold_rate_high = 0;
+ intconf.threshold_distance_low = 0;
+ intconf.threshold_distance_high = 0;
+
+ return intconf;
+}
+
+/*
+ * Set GPIO distance threshold
+ */
+
+VL53L1_Error VL53L1_set_GPIO_distance_threshold(
+ VL53L1_DEV Dev,
+ uint16_t threshold_high,
+ uint16_t threshold_low)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ pdev->dyn_cfg.system__thresh_high = threshold_high;
+ pdev->dyn_cfg.system__thresh_low = threshold_low;
+
+ LOG_FUNCTION_END(status);
+ return status;
+}
+
+/*
+ * Set GPIO rate threshold
+ */
+
+VL53L1_Error VL53L1_set_GPIO_rate_threshold(
+ VL53L1_DEV Dev,
+ uint16_t threshold_high,
+ uint16_t threshold_low)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ pdev->gen_cfg.system__thresh_rate_high = threshold_high;
+ pdev->gen_cfg.system__thresh_rate_low = threshold_low;
+
+ LOG_FUNCTION_END(status);
+ return status;
+}
+
+/*
+ * Set GPIO thresholds from structure
+ */
+
+VL53L1_Error VL53L1_set_GPIO_thresholds_from_struct(
+ VL53L1_DEV Dev,
+ VL53L1_GPIO_interrupt_config_t *pintconf)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ status = VL53L1_set_GPIO_distance_threshold(
+ Dev,
+ pintconf->threshold_distance_high,
+ pintconf->threshold_distance_low);
+
+ if (status == VL53L1_ERROR_NONE) {
+ status =
+ VL53L1_set_GPIO_rate_threshold(
+ Dev,
+ pintconf->threshold_rate_high,
+ pintconf->threshold_rate_low);
+ }
+
+ LOG_FUNCTION_END(status);
+ return status;
+}
+
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_set_ref_spad_char_config(
+ VL53L1_DEV Dev,
+ uint8_t vcsel_period_a,
+ uint32_t phasecal_timeout_us,
+ uint16_t total_rate_target_mcps,
+ uint16_t max_count_rate_rtn_limit_mcps,
+ uint16_t min_count_rate_rtn_limit_mcps,
+ uint16_t fast_osc_frequency)
+{
+ /*
+ * Initialises the VCSEL period A and phasecal timeout registers
+ * for the Reference SPAD Characterisation test
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint8_t buffer[2];
+
+ uint32_t macro_period_us = 0;
+ uint32_t timeout_mclks = 0;
+
+ LOG_FUNCTION_START("");
+
+ /*
+ * Update Macro Period for Range A VCSEL Period
+ */
+ macro_period_us =
+ VL53L1_calc_macro_period_us(
+ fast_osc_frequency,
+ vcsel_period_a);
+
+ /*
+ * Calculate PhaseCal timeout and clip to max of 255 macro periods
+ */
+
+ timeout_mclks = phasecal_timeout_us << 12;
+ timeout_mclks = timeout_mclks + (macro_period_us>>1);
+ timeout_mclks = timeout_mclks / macro_period_us;
+
+ if (timeout_mclks > 0xFF)
+ pdev->gen_cfg.phasecal_config__timeout_macrop = 0xFF;
+ else
+ pdev->gen_cfg.phasecal_config__timeout_macrop =
+ (uint8_t)timeout_mclks;
+
+ pdev->tim_cfg.range_config__vcsel_period_a = vcsel_period_a;
+
+ /*
+ * Update device settings
+ */
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status =
+ VL53L1_WrByte(
+ Dev,
+ VL53L1_PHASECAL_CONFIG__TIMEOUT_MACROP,
+ pdev->gen_cfg.phasecal_config__timeout_macrop);
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_WrByte(
+ Dev,
+ VL53L1_RANGE_CONFIG__VCSEL_PERIOD_A,
+ pdev->tim_cfg.range_config__vcsel_period_a);
+
+ /*
+ * Copy vcsel register value to the WOI registers to ensure that
+ * it is correctly set for the specified VCSEL period
+ */
+
+ buffer[0] = pdev->tim_cfg.range_config__vcsel_period_a;
+ buffer[1] = pdev->tim_cfg.range_config__vcsel_period_a;
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_WriteMulti(
+ Dev,
+ VL53L1_SD_CONFIG__WOI_SD0,
+ buffer,
+ 2); /* It should be be replaced with a define */
+
+ /*
+ * Set min, target and max rate limits
+ */
+
+ pdev->customer.ref_spad_char__total_rate_target_mcps =
+ total_rate_target_mcps;
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_WrWord(
+ Dev,
+ VL53L1_REF_SPAD_CHAR__TOTAL_RATE_TARGET_MCPS,
+ total_rate_target_mcps); /* 9.7 format */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_WrWord(
+ Dev,
+ VL53L1_RANGE_CONFIG__SIGMA_THRESH,
+ max_count_rate_rtn_limit_mcps);
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_WrWord(
+ Dev,
+ VL53L1_RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS,
+ min_count_rate_rtn_limit_mcps);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_ssc_config(
+ VL53L1_DEV Dev,
+ VL53L1_ssc_config_t *pssc_cfg,
+ uint16_t fast_osc_frequency)
+{
+ /**
+ * Builds and sends a single I2C multiple byte transaction to
+ * initialize the device for SSC.
+ *
+ * The function also sets the WOI registers based on the input
+ * vcsel period register value.
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t buffer[5];
+
+ uint32_t macro_period_us = 0;
+ uint16_t timeout_encoded = 0;
+
+ LOG_FUNCTION_START("");
+
+ /*
+ * Update Macro Period for Range A VCSEL Period
+ */
+ macro_period_us =
+ VL53L1_calc_macro_period_us(
+ fast_osc_frequency,
+ pssc_cfg->vcsel_period);
+
+ /*
+ * Update MM Timing A timeout
+ */
+ timeout_encoded =
+ VL53L1_calc_encoded_timeout(
+ pssc_cfg->timeout_us,
+ macro_period_us);
+
+ /* update VCSEL timings */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_WrByte(
+ Dev,
+ VL53L1_CAL_CONFIG__VCSEL_START,
+ pssc_cfg->vcsel_start);
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_WrByte(
+ Dev,
+ VL53L1_GLOBAL_CONFIG__VCSEL_WIDTH,
+ pssc_cfg->vcsel_width);
+
+ /* build buffer for timeouts, period and rate limit */
+
+ buffer[0] = (uint8_t)((timeout_encoded & 0x0000FF00) >> 8);
+ buffer[1] = (uint8_t) (timeout_encoded & 0x000000FF);
+ buffer[2] = pssc_cfg->vcsel_period;
+ buffer[3] = (uint8_t)((pssc_cfg->rate_limit_mcps & 0x0000FF00) >> 8);
+ buffer[4] = (uint8_t) (pssc_cfg->rate_limit_mcps & 0x000000FF);
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_WriteMulti(
+ Dev,
+ VL53L1_RANGE_CONFIG__TIMEOUT_MACROP_B_HI,
+ buffer,
+ 5);
+
+ /*
+ * Copy vcsel register value to the WOI registers to ensure that
+ * it is correctly set for the specified VCSEL period
+ */
+
+ buffer[0] = pssc_cfg->vcsel_period;
+ buffer[1] = pssc_cfg->vcsel_period;
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_WriteMulti(
+ Dev,
+ VL53L1_SD_CONFIG__WOI_SD0,
+ buffer,
+ 2);
+
+ /*
+ * Write zero to NVM_BIST_CTRL to send RTN CountRate to Patch RAM
+ * or 1 to write REF CountRate to Patch RAM
+ */
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_WrByte(
+ Dev,
+ VL53L1_NVM_BIST__CTRL,
+ pssc_cfg->array_select);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifndef VL53L1_NOCALIB
+VL53L1_Error VL53L1_get_spad_rate_data(
+ VL53L1_DEV Dev,
+ VL53L1_spad_rate_data_t *pspad_rates)
+{
+
+ /**
+ * Gets the SSC rate map output
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ int i = 0;
+
+ uint8_t data[512];
+ uint8_t *pdata = &data[0];
+
+ LOG_FUNCTION_START("");
+
+ /* Disable Firmware to Read Patch Ram */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_disable_firmware(Dev);
+
+ /*
+ * Read Return SPADs Rates from patch RAM.
+ * Note : platform layer splits the I2C comms into smaller chunks
+ */
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_ReadMulti(
+ Dev,
+ VL53L1_PRIVATE__PATCH_BASE_ADDR_RSLV,
+ pdata,
+ 512);
+
+ /* now convert into 16-bit number */
+ pdata = &data[0];
+ for (i = 0 ; i < VL53L1_NO_OF_SPAD_ENABLES ; i++) {
+ pspad_rates->rate_data[i] =
+ (uint16_t)VL53L1_decode_unsigned_integer(pdata, 2);
+ pdata += 2;
+ }
+
+ /* Initialise structure info */
+
+ pspad_rates->buffer_size = VL53L1_NO_OF_SPAD_ENABLES;
+ pspad_rates->no_of_values = VL53L1_NO_OF_SPAD_ENABLES;
+ pspad_rates->fractional_bits = 15;
+
+ /* Re-enable Firmware */
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+/* Start Patch_LowPowerAutoMode */
+
+VL53L1_Error VL53L1_low_power_auto_data_init(
+ VL53L1_DEV Dev
+ )
+{
+
+ /*
+ * Initializes internal data structures for low power auto mode
+ */
+
+ /* don't really use this here */
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ pdev->low_power_auto_data.vhv_loop_bound =
+ VL53L1_TUNINGPARM_LOWPOWERAUTO_VHV_LOOP_BOUND_DEFAULT;
+ pdev->low_power_auto_data.is_low_power_auto_mode = 0;
+ pdev->low_power_auto_data.low_power_auto_range_count = 0;
+ pdev->low_power_auto_data.saved_interrupt_config = 0;
+ pdev->low_power_auto_data.saved_vhv_init = 0;
+ pdev->low_power_auto_data.saved_vhv_timeout = 0;
+ pdev->low_power_auto_data.first_run_phasecal_result = 0;
+ pdev->low_power_auto_data.dss__total_rate_per_spad_mcps = 0;
+ pdev->low_power_auto_data.dss__required_spads = 0;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+VL53L1_Error VL53L1_low_power_auto_data_stop_range(
+ VL53L1_DEV Dev
+ )
+{
+
+ /*
+ * Range has been paused but may continue later
+ */
+
+ /* don't really use this here */
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ /* doing this ensures stop_range followed by a get_device_results does
+ * not mess up the counters */
+
+ pdev->low_power_auto_data.low_power_auto_range_count = 0xFF;
+
+ pdev->low_power_auto_data.first_run_phasecal_result = 0;
+ pdev->low_power_auto_data.dss__total_rate_per_spad_mcps = 0;
+ pdev->low_power_auto_data.dss__required_spads = 0;
+
+ /* restore vhv configs */
+ if (pdev->low_power_auto_data.saved_vhv_init != 0)
+ pdev->stat_nvm.vhv_config__init =
+ pdev->low_power_auto_data.saved_vhv_init;
+ if (pdev->low_power_auto_data.saved_vhv_timeout != 0)
+ pdev->stat_nvm.vhv_config__timeout_macrop_loop_bound =
+ pdev->low_power_auto_data.saved_vhv_timeout;
+
+ /* remove phasecal override */
+ pdev->gen_cfg.phasecal_config__override = 0x00;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+VL53L1_Error VL53L1_config_low_power_auto_mode(
+ VL53L1_general_config_t *pgeneral,
+ VL53L1_dynamic_config_t *pdynamic,
+ VL53L1_low_power_auto_data_t *plpadata
+ )
+{
+
+ /*
+ * Initializes configs for when low power auto presets are selected
+ */
+
+ /* don't really use this here */
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* set low power auto mode */
+ plpadata->is_low_power_auto_mode = 1;
+
+ /* set low power range count to 0 */
+ plpadata->low_power_auto_range_count = 0;
+
+ /* Turn off MM1/MM2 and DSS2 */
+ pdynamic->system__sequence_config = \
+ VL53L1_SEQUENCE_VHV_EN | \
+ VL53L1_SEQUENCE_PHASECAL_EN | \
+ VL53L1_SEQUENCE_DSS1_EN | \
+ /* VL53L1_SEQUENCE_DSS2_EN | \*/
+ /* VL53L1_SEQUENCE_MM1_EN | \*/
+ /* VL53L1_SEQUENCE_MM2_EN | \*/
+ VL53L1_SEQUENCE_RANGE_EN;
+
+ /* Set DSS to manual/expected SPADs */
+ pgeneral->dss_config__manual_effective_spads_select = 200 << 8;
+ pgeneral->dss_config__roi_mode_control =
+ VL53L1_DEVICEDSSMODE__REQUESTED_EFFFECTIVE_SPADS;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+VL53L1_Error VL53L1_low_power_auto_setup_manual_calibration(
+ VL53L1_DEV Dev)
+{
+
+ /*
+ * Setup ranges after the first one in low power auto mode by turning
+ * off FW calibration steps and programming static values
+ */
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ /* don't really use this here */
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* save original vhv configs */
+ pdev->low_power_auto_data.saved_vhv_init =
+ pdev->stat_nvm.vhv_config__init;
+ pdev->low_power_auto_data.saved_vhv_timeout =
+ pdev->stat_nvm.vhv_config__timeout_macrop_loop_bound;
+
+ /* disable VHV init */
+ pdev->stat_nvm.vhv_config__init &= 0x7F;
+ /* set loop bound to tuning param */
+ pdev->stat_nvm.vhv_config__timeout_macrop_loop_bound =
+ (pdev->stat_nvm.vhv_config__timeout_macrop_loop_bound & 0x03) +
+ (pdev->low_power_auto_data.vhv_loop_bound << 2);
+ /* override phasecal */
+ pdev->gen_cfg.phasecal_config__override = 0x01;
+ pdev->low_power_auto_data.first_run_phasecal_result =
+ pdev->dbg_results.phasecal_result__vcsel_start;
+ pdev->gen_cfg.cal_config__vcsel_start =
+ pdev->low_power_auto_data.first_run_phasecal_result;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+VL53L1_Error VL53L1_low_power_auto_update_DSS(
+ VL53L1_DEV Dev)
+{
+
+ /*
+ * Do a DSS calculation and update manual config
+ */
+
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ /* don't really use this here */
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ uint32_t utemp32a;
+
+ LOG_FUNCTION_START("");
+
+ /* Calc total rate per spad */
+
+ /* 9.7 format */
+ utemp32a = pdev->sys_results.result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0 +
+ pdev->sys_results.result__ambient_count_rate_mcps_sd0;
+
+ /* clip to 16 bits */
+ if (utemp32a > 0xFFFF)
+ utemp32a = 0xFFFF;
+
+ /* shift up to take advantage of 32 bits */
+ /* 9.23 format */
+ utemp32a = utemp32a << 16;
+
+ /* check SPAD count */
+ if (pdev->sys_results.result__dss_actual_effective_spads_sd0 == 0)
+ status = VL53L1_ERROR_DIVISION_BY_ZERO;
+ else {
+ /* format 17.15 */
+ utemp32a = utemp32a /
+ pdev->sys_results.result__dss_actual_effective_spads_sd0;
+ /* save intermediate result */
+ pdev->low_power_auto_data.dss__total_rate_per_spad_mcps =
+ utemp32a;
+
+ /* get the target rate and shift up by 16
+ * format 9.23 */
+ utemp32a = pdev->stat_cfg.dss_config__target_total_rate_mcps <<
+ 16;
+
+ /* check for divide by zero */
+ if (pdev->low_power_auto_data.dss__total_rate_per_spad_mcps == 0)
+ status = VL53L1_ERROR_DIVISION_BY_ZERO;
+ else {
+ /* divide by rate per spad
+ * format 24.8 */
+ utemp32a = utemp32a /
+ pdev->low_power_auto_data.dss__total_rate_per_spad_mcps;
+
+ /* clip to 16 bit */
+ if (utemp32a > 0xFFFF)
+ utemp32a = 0xFFFF;
+
+ /* save result in low power auto data */
+ pdev->low_power_auto_data.dss__required_spads =
+ (uint16_t)utemp32a;
+
+ /* override DSS config */
+ pdev->gen_cfg.dss_config__manual_effective_spads_select =
+ pdev->low_power_auto_data.dss__required_spads;
+ pdev->gen_cfg.dss_config__roi_mode_control =
+ VL53L1_DEVICEDSSMODE__REQUESTED_EFFFECTIVE_SPADS;
+ }
+
+ }
+
+ if (status == VL53L1_ERROR_DIVISION_BY_ZERO) {
+ /* We want to gracefully set a spad target, not just exit with
+ * an error */
+
+ /* set target to mid point */
+ pdev->low_power_auto_data.dss__required_spads = 0x8000;
+
+ /* override DSS config */
+ pdev->gen_cfg.dss_config__manual_effective_spads_select =
+ pdev->low_power_auto_data.dss__required_spads;
+ pdev->gen_cfg.dss_config__roi_mode_control =
+ VL53L1_DEVICEDSSMODE__REQUESTED_EFFFECTIVE_SPADS;
+
+ /* reset error */
+ status = VL53L1_ERROR_NONE;
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+/* End Patch_LowPowerAutoMode */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_core_support.c b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_core_support.c
new file mode 100644
index 0000000..ceea63d
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_core_support.c
@@ -0,0 +1,445 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_core_support.c
+ *
+ * @brief EwokPlus25 core function definition
+ */
+
+#include "vl53l1_ll_def.h"
+#include "vl53l1_ll_device.h"
+#include "vl53l1_platform_log.h"
+#include "vl53l1_core_support.h"
+#include "vl53l1_platform_user_data.h"
+#include "vl53l1_platform_user_defines.h"
+
+#ifdef VL53L1_LOGGING
+#include "vl53l1_debug.h"
+#include "vl53l1_register_debug.h"
+#endif
+
+#define LOG_FUNCTION_START(fmt, ...) \
+ _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
+#define LOG_FUNCTION_END(status, ...) \
+ _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
+#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
+ _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE, \
+ status, fmt, ##__VA_ARGS__)
+
+#define trace_print(level, ...) \
+ _LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_CORE, \
+ level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
+
+
+uint32_t VL53L1_calc_pll_period_us(
+ uint16_t fast_osc_frequency)
+{
+ /* Calculates PLL frequency using NVM fast_osc_frequency
+ * Fast osc frequency fixed point format = unsigned 4.12
+ *
+ * PLL period fixed point format = unsigned 0.24
+ * Min input fast osc frequency = 1 MHz
+ * PLL Multiplier = 64 (fixed)
+ * Min PLL freq = 64.0MHz
+ * -> max PLL period = 1/ 64
+ * -> only the 18 LS bits are used
+ *
+ * 2^30 = (2^24) (1.0us) * 4096 (2^12) / 64 (PLL Multiplier)
+ */
+
+ uint32_t pll_period_us = 0;
+
+ LOG_FUNCTION_START("");
+
+ pll_period_us = (0x01 << 30) / fast_osc_frequency;
+
+#ifdef VL53L1_LOGGING
+ trace_print(VL53L1_TRACE_LEVEL_DEBUG,
+ " %-48s : %10u\n", "pll_period_us",
+ pll_period_us);
+#endif
+
+ LOG_FUNCTION_END(0);
+
+ return pll_period_us;
+}
+
+
+#ifdef PAL_EXTENDED
+uint32_t VL53L1_duration_maths(
+ uint32_t pll_period_us,
+ uint32_t vcsel_parm_pclks,
+ uint32_t window_vclks,
+ uint32_t elapsed_mclks)
+{
+ /*
+ * Generates the ranging duration in us
+ *
+ * duration_us = elapsed_mclks * vcsel_perm_pclks *
+ * window_vclks * pll_period_us
+ *
+ * returned value in [us] with no fraction bits
+ */
+
+ uint64_t tmp_long_int = 0;
+ uint32_t duration_us = 0;
+
+ /* PLL period us = 0.24 18 LS bits used
+ * window_vclks = 12.0 (2304 max)
+ * output 30b (6.24)
+ */
+ duration_us = window_vclks * pll_period_us;
+
+ /* down shift by 12
+ * output 18b (6.12)
+ */
+ duration_us = duration_us >> 12;
+
+ /* Save first part of the calc (#1) */
+ tmp_long_int = (uint64_t)duration_us;
+
+ /* Multiply elapsed macro periods (22-bit)
+ * by VCSEL parameter 6.4 (max 63.9999)
+ * output 32b (28.4)
+ */
+ duration_us = elapsed_mclks * vcsel_parm_pclks;
+
+ /* down shift by 4 to remove fractional bits (#2)
+ * output 28b (28.0)
+ */
+ duration_us = duration_us >> 4;
+
+ /* Multiply #1 18b (6.12) by #2 28b (28.0)
+ * output 46b (34.12)
+ */
+ tmp_long_int = tmp_long_int * (uint64_t)duration_us;
+
+ /* Remove fractional part
+ * output 34b (34.0)
+ */
+ tmp_long_int = tmp_long_int >> 12;
+
+ /* Clip to 32-bits */
+ if (tmp_long_int > 0xFFFFFFFF) {
+ tmp_long_int = 0xFFFFFFFF;
+ }
+
+ duration_us = (uint32_t)tmp_long_int;
+
+ return duration_us;
+}
+
+
+uint32_t VL53L1_isqrt(uint32_t num)
+{
+
+ /*
+ * Implements an integer square root
+ *
+ * From: http://en.wikipedia.org/wiki/Methods_of_computing_square_roots
+ */
+
+ uint32_t res = 0;
+ uint32_t bit = 1 << 30; /* The second-to-top bit is set: 1 << 14 for 16-bits, 1 << 30 for 32 bits */
+
+ /* "bit" starts at the highest power of four <= the argument. */
+ while (bit > num) {
+ bit >>= 2;
+ }
+
+ while (bit != 0) {
+ if (num >= res + bit) {
+ num -= res + bit;
+ res = (res >> 1) + bit;
+ } else {
+ res >>= 1;
+ }
+ bit >>= 2;
+ }
+
+ return res;
+}
+
+
+uint16_t VL53L1_rate_maths(
+ int32_t events,
+ uint32_t time_us)
+{
+ /*
+ * Converts events into count rate
+ *
+ * Max events = 512 Mcps * 1sec
+ * = 512,000,000 events
+ * = 29b
+ *
+ * If events > 2^24 use 3-bit fractional bits is used internally
+ * otherwise 7-bit fractional bits are used
+ */
+
+ uint32_t tmp_int = 0;
+ uint32_t frac_bits = 7;
+ uint16_t rate_mcps = 0; /* 9.7 format */
+
+ /*
+ * Clip input event range
+ */
+
+ if (events > VL53L1_SPAD_TOTAL_COUNT_MAX) {
+ tmp_int = VL53L1_SPAD_TOTAL_COUNT_MAX;
+ } else if (events > 0) {
+ tmp_int = (uint32_t)events;
+ }
+
+ /*
+ * if events > VL53L1_SPAD_TOTAL_COUNT_RES_THRES use 3 rather
+ * than 7 fractional bits internal to function
+ */
+
+ if (events > VL53L1_SPAD_TOTAL_COUNT_RES_THRES) {
+ frac_bits = 3;
+ } else {
+ frac_bits = 7;
+ }
+
+ /*
+ * Create 3 or 7 fractional bits
+ * output 32b (29.3 or 25.7)
+ * Divide by range duration in [us] - no fractional bits
+ */
+ if (time_us > 0) {
+ tmp_int = ((tmp_int << frac_bits) + (time_us / 2)) / time_us;
+ }
+
+ /*
+ * Re align if reduced resolution
+ */
+ if (events > VL53L1_SPAD_TOTAL_COUNT_RES_THRES) {
+ tmp_int = tmp_int << 4;
+ }
+
+ /*
+ * Firmware internal count is 17.7 (24b) but it this
+ * case clip to 16-bit value for reporting
+ */
+
+ if (tmp_int > 0xFFFF) {
+ tmp_int = 0xFFFF;
+ }
+
+ rate_mcps = (uint16_t)tmp_int;
+
+ return rate_mcps;
+}
+
+uint16_t VL53L1_rate_per_spad_maths(
+ uint32_t frac_bits,
+ uint32_t peak_count_rate,
+ uint16_t num_spads,
+ uint32_t max_output_value)
+{
+
+ uint32_t tmp_int = 0;
+
+ /* rate_per_spad Format varies with prog frac_bits */
+ uint16_t rate_per_spad = 0;
+
+ /* Calculate rate per spad with variable fractional bits */
+
+ /* Frac_bits should be programmed as final frac_bits - 7 as
+ * the pk_rate contains an inherent 7 bit resolution
+ */
+
+ if (num_spads > 0) {
+ tmp_int = (peak_count_rate << 8) << frac_bits;
+ tmp_int = (tmp_int + ((uint32_t)num_spads / 2)) / (uint32_t)num_spads;
+ } else {
+ tmp_int = ((peak_count_rate) << frac_bits);
+ }
+
+ /* Clip in case of overwrap - special code */
+
+ if (tmp_int > max_output_value) {
+ tmp_int = max_output_value;
+ }
+
+ rate_per_spad = (uint16_t)tmp_int;
+
+ return rate_per_spad;
+}
+
+int32_t VL53L1_range_maths(
+ uint16_t fast_osc_frequency,
+ uint16_t phase,
+ uint16_t zero_distance_phase,
+ uint8_t fractional_bits,
+ int32_t gain_factor,
+ int32_t range_offset_mm)
+{
+ /*
+ * Converts phase information into distance in [mm]
+ */
+
+ uint32_t pll_period_us = 0; /* 0.24 format */
+ int64_t tmp_long_int = 0;
+ int32_t range_mm = 0;
+
+ /* Calculate PLL period in [ps] */
+
+ pll_period_us = VL53L1_calc_pll_period_us(fast_osc_frequency);
+
+ /* Raw range in [mm]
+ *
+ * calculate the phase difference between return and reference phases
+ *
+ * phases 16b (5.11)
+ * output 17b including sign bit
+ */
+
+ tmp_long_int = (int64_t)phase - (int64_t)zero_distance_phase;
+
+ /*
+ * multiply by the PLL period
+ *
+ * PLL period 24bit (0.24) but only 18 LS bits used
+ *
+ * Output 35b (0.35) (17b + 18b)
+ */
+
+ tmp_long_int = tmp_long_int * (int64_t)pll_period_us;
+
+ /*
+ * Down shift by 9 - Output 26b (0.26)
+ */
+
+ tmp_long_int = tmp_long_int / (0x01 << 9);
+
+ /*
+ * multiply by speed of light in air divided by 8
+ * Factor of 8 includes 2 for the round trip and 4 scaling
+ *
+ * VL53L1_SPEED_OF_LIGHT_IN_AIR_DIV_8 = 16b (16.2)
+ *
+ * Output 42b (18.24) (16b + 26b)
+ */
+
+ tmp_long_int = tmp_long_int * VL53L1_SPEED_OF_LIGHT_IN_AIR_DIV_8;
+
+ /*
+ * Down shift by 22 - Output 20b (18.2)
+ */
+
+ tmp_long_int = tmp_long_int / (0x01 << 22);
+
+ /* Add range offset */
+ range_mm = (int32_t)tmp_long_int + range_offset_mm;
+
+ /* apply correction gain */
+ range_mm *= gain_factor;
+ range_mm += 0x0400;
+ range_mm /= 0x0800;
+
+ /* Remove fractional bits */
+ if (fractional_bits == 0)
+ range_mm = range_mm / (0x01 << 2);
+ else if (fractional_bits == 1)
+ range_mm = range_mm / (0x01 << 1);
+
+ return range_mm;
+}
+#endif
+
+uint8_t VL53L1_decode_vcsel_period(uint8_t vcsel_period_reg)
+{
+ /*
+ * Converts the encoded VCSEL period register value into
+ * the real period in PLL clocks
+ */
+
+ uint8_t vcsel_period_pclks = 0;
+
+ vcsel_period_pclks = (vcsel_period_reg + 1) << 1;
+
+ return vcsel_period_pclks;
+}
+
+
+void VL53L1_decode_row_col(
+ uint8_t spad_number,
+ uint8_t *prow,
+ uint8_t *pcol)
+{
+
+ /**
+ * Decodes the array (row,col) location from
+ * the input SPAD number
+ */
+
+ if (spad_number > 127) {
+ *prow = 8 + ((255-spad_number) & 0x07);
+ *pcol = (spad_number-128) >> 3;
+ } else {
+ *prow = spad_number & 0x07;
+ *pcol = (127-spad_number) >> 3;
+ }
+}
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_error_strings.c b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_error_strings.c
new file mode 100644
index 0000000..96c99c6
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_error_strings.c
@@ -0,0 +1,304 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_error_strings.c
+ * @brief VL53L1 API functions for decoding error codes to a text string
+ */
+
+#include "vl53l1_error_codes.h"
+#include "vl53l1_error_strings.h"
+#include "vl53l1_platform_log.h"
+#include "vl53l1_ll_def.h"
+
+#define LOG_FUNCTION_START(fmt, ...) \
+ _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
+#define LOG_FUNCTION_END(status, ...) \
+ _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_API, status, ##__VA_ARGS__)
+#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
+ _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_API, \
+ status, fmt, ##__VA_ARGS__)
+
+
+#ifndef VL53L1_DEBUG
+ #define VL53L1_USE_EMPTY_STRING
+#endif
+
+VL53L1_Error VL53L1_get_pal_error_string(
+ VL53L1_Error PalErrorCode,
+ char *pPalErrorString)
+{
+ VL53L1_Error Status = VL53L1_ERROR_NONE;
+
+#ifdef VL53L1_USE_EMPTY_STRING
+ SUPPRESS_UNUSED_WARNING(PalErrorCode);
+#endif
+
+ LOG_FUNCTION_START("");
+
+#ifdef VL53L1_USE_EMPTY_STRING
+ VL53L1_COPYSTRING(pPalErrorString, "");
+#else
+
+ switch (PalErrorCode) {
+ case VL53L1_ERROR_NONE:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_NONE);
+ break;
+ case VL53L1_ERROR_CALIBRATION_WARNING:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_CALIBRATION_WARNING);
+ break;
+ case VL53L1_ERROR_MIN_CLIPPED:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_MIN_CLIPPED);
+ break;
+ case VL53L1_ERROR_UNDEFINED:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_UNDEFINED);
+ break;
+ case VL53L1_ERROR_INVALID_PARAMS:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_INVALID_PARAMS);
+ break;
+ case VL53L1_ERROR_NOT_SUPPORTED:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_NOT_SUPPORTED);
+ break;
+ case VL53L1_ERROR_RANGE_ERROR:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_RANGE_ERROR);
+ break;
+ case VL53L1_ERROR_TIME_OUT:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_TIME_OUT);
+ break;
+ case VL53L1_ERROR_MODE_NOT_SUPPORTED:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_MODE_NOT_SUPPORTED);
+ break;
+ case VL53L1_ERROR_BUFFER_TOO_SMALL:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_BUFFER_TOO_SMALL);
+ break;
+ case VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_COMMS_BUFFER_TOO_SMALL);
+ break;
+ case VL53L1_ERROR_GPIO_NOT_EXISTING:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_GPIO_NOT_EXISTING);
+ break;
+ case VL53L1_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED);
+ break;
+ case VL53L1_ERROR_CONTROL_INTERFACE:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_CONTROL_INTERFACE);
+ break;
+ case VL53L1_ERROR_INVALID_COMMAND:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_INVALID_COMMAND);
+ break;
+ case VL53L1_ERROR_DIVISION_BY_ZERO:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_DIVISION_BY_ZERO);
+ break;
+ case VL53L1_ERROR_REF_SPAD_INIT:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_REF_SPAD_INIT);
+ break;
+ case VL53L1_ERROR_GPH_SYNC_CHECK_FAIL:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_GPH_SYNC_CHECK_FAIL);
+ break;
+ case VL53L1_ERROR_STREAM_COUNT_CHECK_FAIL:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_STREAM_COUNT_CHECK_FAIL);
+ break;
+ case VL53L1_ERROR_GPH_ID_CHECK_FAIL:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_GPH_ID_CHECK_FAIL);
+ break;
+ case VL53L1_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL);
+ break;
+ case VL53L1_ERROR_ZONE_GPH_ID_CHECK_FAIL:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_ZONE_GPH_ID_CHECK_FAIL);
+ break;
+
+ case VL53L1_ERROR_XTALK_EXTRACTION_NO_SAMPLE_FAIL:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_XTALK_EXTRACTION_NO_SAMPLES_FAIL);
+ break;
+ case VL53L1_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL);
+ break;
+
+ case VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL);
+ break;
+ case VL53L1_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL);
+ break;
+ case VL53L1_ERROR_ZONE_CAL_NO_SAMPLE_FAIL:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_ZONE_CAL_NO_SAMPLE_FAIL);
+ break;
+
+ case VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_WARNING_OFFSET_CAL_MISSING_SAMPLES);
+ break;
+ case VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH);
+ break;
+ case VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_WARNING_OFFSET_CAL_RATE_TOO_HIGH);
+ break;
+ case VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW);
+ break;
+
+ case VL53L1_WARNING_ZONE_CAL_MISSING_SAMPLES:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_WARNING_ZONE_CAL_MISSING_SAMPLES);
+ break;
+ case VL53L1_WARNING_ZONE_CAL_SIGMA_TOO_HIGH:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_WARNING_ZONE_CAL_SIGMA_TOO_HIGH);
+ break;
+ case VL53L1_WARNING_ZONE_CAL_RATE_TOO_HIGH:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_WARNING_ZONE_CAL_RATE_TOO_HIGH);
+ break;
+
+ case VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS);
+ break;
+ case VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH);
+ break;
+ case VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW);
+ break;
+
+ case VL53L1_WARNING_XTALK_MISSING_SAMPLES:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_WARNING_XTALK_MISSING_SAMPLES);
+ break;
+ case VL53L1_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT);
+ break;
+ case VL53L1_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT);
+ break;
+
+ case VL53L1_ERROR_DEVICE_FIRMWARE_TOO_OLD:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_DEVICE_FIRMWARE_TOO_OLD);
+ break;
+ case VL53L1_ERROR_DEVICE_FIRMWARE_TOO_NEW:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_DEVICE_FIRMWARE_TOO_NEW);
+ break;
+ case VL53L1_ERROR_UNIT_TEST_FAIL:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_UNIT_TEST_FAIL);
+ break;
+ case VL53L1_ERROR_FILE_READ_FAIL:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_FILE_READ_FAIL);
+ break;
+ case VL53L1_ERROR_FILE_WRITE_FAIL:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_FILE_WRITE_FAIL);
+ break;
+ case VL53L1_ERROR_NOT_IMPLEMENTED:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_ERROR_NOT_IMPLEMENTED);
+ break;
+ default:
+ VL53L1_COPYSTRING(pPalErrorString,
+ VL53L1_STRING_UNKNOW_ERROR_CODE);
+ }
+
+#endif
+
+ LOG_FUNCTION_END(Status);
+
+ return Status;
+}
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_register_funcs.c b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_register_funcs.c
new file mode 100644
index 0000000..09bf6d8
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_register_funcs.c
@@ -0,0 +1,4489 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_register_funcs.c
+ * @brief VL53L1 Register Function definitions
+ */
+
+#include "vl53l1_ll_def.h"
+#include "vl53l1_platform.h"
+#include "vl53l1_platform_log.h"
+#include "vl53l1_core.h"
+#include "vl53l1_register_map.h"
+#include "vl53l1_register_structs.h"
+#include "vl53l1_register_funcs.h"
+
+#define LOG_FUNCTION_START(fmt, ...) \
+ _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_REGISTERS, fmt, ##__VA_ARGS__)
+#define LOG_FUNCTION_END(status, ...) \
+ _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_REGISTERS, status, ##__VA_ARGS__)
+#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
+ _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_REGISTERS, status, fmt, ##__VA_ARGS__)
+
+
+VL53L1_Error VL53L1_i2c_encode_static_nvm_managed(
+ VL53L1_static_nvm_managed_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_static_nvm_managed_t into a I2C write buffer
+ * Buffer must be at least 11 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_STATIC_NVM_MANAGED_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ *(pbuffer + 0) =
+ pdata->i2c_slave__device_address & 0x7F;
+ *(pbuffer + 1) =
+ pdata->ana_config__vhv_ref_sel_vddpix & 0xF;
+ *(pbuffer + 2) =
+ pdata->ana_config__vhv_ref_sel_vquench & 0x7F;
+ *(pbuffer + 3) =
+ pdata->ana_config__reg_avdd1v2_sel & 0x3;
+ *(pbuffer + 4) =
+ pdata->ana_config__fast_osc__trim & 0x7F;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->osc_measured__fast_osc__frequency,
+ 2,
+ pbuffer + 5);
+ *(pbuffer + 7) =
+ pdata->vhv_config__timeout_macrop_loop_bound;
+ *(pbuffer + 8) =
+ pdata->vhv_config__count_thresh;
+ *(pbuffer + 9) =
+ pdata->vhv_config__offset & 0x3F;
+ *(pbuffer + 10) =
+ pdata->vhv_config__init;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_decode_static_nvm_managed(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_static_nvm_managed_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_static_nvm_managed_t from the input I2C read buffer
+ * Buffer must be at least 11 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_STATIC_NVM_MANAGED_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->i2c_slave__device_address =
+ (*(pbuffer + 0)) & 0x7F;
+ pdata->ana_config__vhv_ref_sel_vddpix =
+ (*(pbuffer + 1)) & 0xF;
+ pdata->ana_config__vhv_ref_sel_vquench =
+ (*(pbuffer + 2)) & 0x7F;
+ pdata->ana_config__reg_avdd1v2_sel =
+ (*(pbuffer + 3)) & 0x3;
+ pdata->ana_config__fast_osc__trim =
+ (*(pbuffer + 4)) & 0x7F;
+ pdata->osc_measured__fast_osc__frequency =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 5));
+ pdata->vhv_config__timeout_macrop_loop_bound =
+ (*(pbuffer + 7));
+ pdata->vhv_config__count_thresh =
+ (*(pbuffer + 8));
+ pdata->vhv_config__offset =
+ (*(pbuffer + 9)) & 0x3F;
+ pdata->vhv_config__init =
+ (*(pbuffer + 10));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_static_nvm_managed(
+ VL53L1_DEV Dev,
+ VL53L1_static_nvm_managed_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_static_nvm_managed_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_STATIC_NVM_MANAGED_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_static_nvm_managed(
+ pdata,
+ VL53L1_STATIC_NVM_MANAGED_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_I2C_SLAVE__DEVICE_ADDRESS,
+ comms_buffer,
+ VL53L1_STATIC_NVM_MANAGED_I2C_SIZE_BYTES);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_get_static_nvm_managed(
+ VL53L1_DEV Dev,
+ VL53L1_static_nvm_managed_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_static_nvm_managed_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_STATIC_NVM_MANAGED_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_I2C_SLAVE__DEVICE_ADDRESS,
+ comms_buffer,
+ VL53L1_STATIC_NVM_MANAGED_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_static_nvm_managed(
+ VL53L1_STATIC_NVM_MANAGED_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_encode_customer_nvm_managed(
+ VL53L1_customer_nvm_managed_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_customer_nvm_managed_t into a I2C write buffer
+ * Buffer must be at least 23 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_CUSTOMER_NVM_MANAGED_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ *(pbuffer + 0) =
+ pdata->global_config__spad_enables_ref_0;
+ *(pbuffer + 1) =
+ pdata->global_config__spad_enables_ref_1;
+ *(pbuffer + 2) =
+ pdata->global_config__spad_enables_ref_2;
+ *(pbuffer + 3) =
+ pdata->global_config__spad_enables_ref_3;
+ *(pbuffer + 4) =
+ pdata->global_config__spad_enables_ref_4;
+ *(pbuffer + 5) =
+ pdata->global_config__spad_enables_ref_5 & 0xF;
+ *(pbuffer + 6) =
+ pdata->global_config__ref_en_start_select;
+ *(pbuffer + 7) =
+ pdata->ref_spad_man__num_requested_ref_spads & 0x3F;
+ *(pbuffer + 8) =
+ pdata->ref_spad_man__ref_location & 0x3;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->algo__crosstalk_compensation_plane_offset_kcps,
+ 2,
+ pbuffer + 9);
+ VL53L1_i2c_encode_int16_t(
+ pdata->algo__crosstalk_compensation_x_plane_gradient_kcps,
+ 2,
+ pbuffer + 11);
+ VL53L1_i2c_encode_int16_t(
+ pdata->algo__crosstalk_compensation_y_plane_gradient_kcps,
+ 2,
+ pbuffer + 13);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->ref_spad_char__total_rate_target_mcps,
+ 2,
+ pbuffer + 15);
+ VL53L1_i2c_encode_int16_t(
+ pdata->algo__part_to_part_range_offset_mm & 0x1FFF,
+ 2,
+ pbuffer + 17);
+ VL53L1_i2c_encode_int16_t(
+ pdata->mm_config__inner_offset_mm,
+ 2,
+ pbuffer + 19);
+ VL53L1_i2c_encode_int16_t(
+ pdata->mm_config__outer_offset_mm,
+ 2,
+ pbuffer + 21);
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_decode_customer_nvm_managed(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_customer_nvm_managed_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_customer_nvm_managed_t from the input I2C read buffer
+ * Buffer must be at least 23 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_CUSTOMER_NVM_MANAGED_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->global_config__spad_enables_ref_0 =
+ (*(pbuffer + 0));
+ pdata->global_config__spad_enables_ref_1 =
+ (*(pbuffer + 1));
+ pdata->global_config__spad_enables_ref_2 =
+ (*(pbuffer + 2));
+ pdata->global_config__spad_enables_ref_3 =
+ (*(pbuffer + 3));
+ pdata->global_config__spad_enables_ref_4 =
+ (*(pbuffer + 4));
+ pdata->global_config__spad_enables_ref_5 =
+ (*(pbuffer + 5)) & 0xF;
+ pdata->global_config__ref_en_start_select =
+ (*(pbuffer + 6));
+ pdata->ref_spad_man__num_requested_ref_spads =
+ (*(pbuffer + 7)) & 0x3F;
+ pdata->ref_spad_man__ref_location =
+ (*(pbuffer + 8)) & 0x3;
+ pdata->algo__crosstalk_compensation_plane_offset_kcps =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 9));
+ pdata->algo__crosstalk_compensation_x_plane_gradient_kcps =
+ (VL53L1_i2c_decode_int16_t(2, pbuffer + 11));
+ pdata->algo__crosstalk_compensation_y_plane_gradient_kcps =
+ (VL53L1_i2c_decode_int16_t(2, pbuffer + 13));
+ pdata->ref_spad_char__total_rate_target_mcps =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 15));
+ pdata->algo__part_to_part_range_offset_mm =
+ (VL53L1_i2c_decode_int16_t(2, pbuffer + 17)) & 0x1FFF;
+ pdata->mm_config__inner_offset_mm =
+ (VL53L1_i2c_decode_int16_t(2, pbuffer + 19));
+ pdata->mm_config__outer_offset_mm =
+ (VL53L1_i2c_decode_int16_t(2, pbuffer + 21));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_customer_nvm_managed(
+ VL53L1_DEV Dev,
+ VL53L1_customer_nvm_managed_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_customer_nvm_managed_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_CUSTOMER_NVM_MANAGED_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_customer_nvm_managed(
+ pdata,
+ VL53L1_CUSTOMER_NVM_MANAGED_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_REF_0,
+ comms_buffer,
+ VL53L1_CUSTOMER_NVM_MANAGED_I2C_SIZE_BYTES);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_get_customer_nvm_managed(
+ VL53L1_DEV Dev,
+ VL53L1_customer_nvm_managed_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_customer_nvm_managed_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_CUSTOMER_NVM_MANAGED_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_GLOBAL_CONFIG__SPAD_ENABLES_REF_0,
+ comms_buffer,
+ VL53L1_CUSTOMER_NVM_MANAGED_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_customer_nvm_managed(
+ VL53L1_CUSTOMER_NVM_MANAGED_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_encode_static_config(
+ VL53L1_static_config_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_static_config_t into a I2C write buffer
+ * Buffer must be at least 32 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_STATIC_CONFIG_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ VL53L1_i2c_encode_uint16_t(
+ pdata->dss_config__target_total_rate_mcps,
+ 2,
+ pbuffer + 0);
+ *(pbuffer + 2) =
+ pdata->debug__ctrl & 0x1;
+ *(pbuffer + 3) =
+ pdata->test_mode__ctrl & 0xF;
+ *(pbuffer + 4) =
+ pdata->clk_gating__ctrl & 0xF;
+ *(pbuffer + 5) =
+ pdata->nvm_bist__ctrl & 0x1F;
+ *(pbuffer + 6) =
+ pdata->nvm_bist__num_nvm_words & 0x7F;
+ *(pbuffer + 7) =
+ pdata->nvm_bist__start_address & 0x7F;
+ *(pbuffer + 8) =
+ pdata->host_if__status & 0x1;
+ *(pbuffer + 9) =
+ pdata->pad_i2c_hv__config;
+ *(pbuffer + 10) =
+ pdata->pad_i2c_hv__extsup_config & 0x1;
+ *(pbuffer + 11) =
+ pdata->gpio_hv_pad__ctrl & 0x3;
+ *(pbuffer + 12) =
+ pdata->gpio_hv_mux__ctrl & 0x1F;
+ *(pbuffer + 13) =
+ pdata->gpio__tio_hv_status & 0x3;
+ *(pbuffer + 14) =
+ pdata->gpio__fio_hv_status & 0x3;
+ *(pbuffer + 15) =
+ pdata->ana_config__spad_sel_pswidth & 0x7;
+ *(pbuffer + 16) =
+ pdata->ana_config__vcsel_pulse_width_offset & 0x1F;
+ *(pbuffer + 17) =
+ pdata->ana_config__fast_osc__config_ctrl & 0x1;
+ *(pbuffer + 18) =
+ pdata->sigma_estimator__effective_pulse_width_ns;
+ *(pbuffer + 19) =
+ pdata->sigma_estimator__effective_ambient_width_ns;
+ *(pbuffer + 20) =
+ pdata->sigma_estimator__sigma_ref_mm;
+ *(pbuffer + 21) =
+ pdata->algo__crosstalk_compensation_valid_height_mm;
+ *(pbuffer + 22) =
+ pdata->spare_host_config__static_config_spare_0;
+ *(pbuffer + 23) =
+ pdata->spare_host_config__static_config_spare_1;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->algo__range_ignore_threshold_mcps,
+ 2,
+ pbuffer + 24);
+ *(pbuffer + 26) =
+ pdata->algo__range_ignore_valid_height_mm;
+ *(pbuffer + 27) =
+ pdata->algo__range_min_clip;
+ *(pbuffer + 28) =
+ pdata->algo__consistency_check__tolerance & 0xF;
+ *(pbuffer + 29) =
+ pdata->spare_host_config__static_config_spare_2;
+ *(pbuffer + 30) =
+ pdata->sd_config__reset_stages_msb & 0xF;
+ *(pbuffer + 31) =
+ pdata->sd_config__reset_stages_lsb;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_decode_static_config(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_static_config_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_static_config_t from the input I2C read buffer
+ * Buffer must be at least 32 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_STATIC_CONFIG_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->dss_config__target_total_rate_mcps =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 0));
+ pdata->debug__ctrl =
+ (*(pbuffer + 2)) & 0x1;
+ pdata->test_mode__ctrl =
+ (*(pbuffer + 3)) & 0xF;
+ pdata->clk_gating__ctrl =
+ (*(pbuffer + 4)) & 0xF;
+ pdata->nvm_bist__ctrl =
+ (*(pbuffer + 5)) & 0x1F;
+ pdata->nvm_bist__num_nvm_words =
+ (*(pbuffer + 6)) & 0x7F;
+ pdata->nvm_bist__start_address =
+ (*(pbuffer + 7)) & 0x7F;
+ pdata->host_if__status =
+ (*(pbuffer + 8)) & 0x1;
+ pdata->pad_i2c_hv__config =
+ (*(pbuffer + 9));
+ pdata->pad_i2c_hv__extsup_config =
+ (*(pbuffer + 10)) & 0x1;
+ pdata->gpio_hv_pad__ctrl =
+ (*(pbuffer + 11)) & 0x3;
+ pdata->gpio_hv_mux__ctrl =
+ (*(pbuffer + 12)) & 0x1F;
+ pdata->gpio__tio_hv_status =
+ (*(pbuffer + 13)) & 0x3;
+ pdata->gpio__fio_hv_status =
+ (*(pbuffer + 14)) & 0x3;
+ pdata->ana_config__spad_sel_pswidth =
+ (*(pbuffer + 15)) & 0x7;
+ pdata->ana_config__vcsel_pulse_width_offset =
+ (*(pbuffer + 16)) & 0x1F;
+ pdata->ana_config__fast_osc__config_ctrl =
+ (*(pbuffer + 17)) & 0x1;
+ pdata->sigma_estimator__effective_pulse_width_ns =
+ (*(pbuffer + 18));
+ pdata->sigma_estimator__effective_ambient_width_ns =
+ (*(pbuffer + 19));
+ pdata->sigma_estimator__sigma_ref_mm =
+ (*(pbuffer + 20));
+ pdata->algo__crosstalk_compensation_valid_height_mm =
+ (*(pbuffer + 21));
+ pdata->spare_host_config__static_config_spare_0 =
+ (*(pbuffer + 22));
+ pdata->spare_host_config__static_config_spare_1 =
+ (*(pbuffer + 23));
+ pdata->algo__range_ignore_threshold_mcps =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 24));
+ pdata->algo__range_ignore_valid_height_mm =
+ (*(pbuffer + 26));
+ pdata->algo__range_min_clip =
+ (*(pbuffer + 27));
+ pdata->algo__consistency_check__tolerance =
+ (*(pbuffer + 28)) & 0xF;
+ pdata->spare_host_config__static_config_spare_2 =
+ (*(pbuffer + 29));
+ pdata->sd_config__reset_stages_msb =
+ (*(pbuffer + 30)) & 0xF;
+ pdata->sd_config__reset_stages_lsb =
+ (*(pbuffer + 31));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_static_config(
+ VL53L1_DEV Dev,
+ VL53L1_static_config_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_static_config_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_STATIC_CONFIG_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_static_config(
+ pdata,
+ VL53L1_STATIC_CONFIG_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_DSS_CONFIG__TARGET_TOTAL_RATE_MCPS,
+ comms_buffer,
+ VL53L1_STATIC_CONFIG_I2C_SIZE_BYTES);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_get_static_config(
+ VL53L1_DEV Dev,
+ VL53L1_static_config_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_static_config_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_STATIC_CONFIG_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_DSS_CONFIG__TARGET_TOTAL_RATE_MCPS,
+ comms_buffer,
+ VL53L1_STATIC_CONFIG_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_static_config(
+ VL53L1_STATIC_CONFIG_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_i2c_encode_general_config(
+ VL53L1_general_config_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_general_config_t into a I2C write buffer
+ * Buffer must be at least 22 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_GENERAL_CONFIG_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ *(pbuffer + 0) =
+ pdata->gph_config__stream_count_update_value;
+ *(pbuffer + 1) =
+ pdata->global_config__stream_divider;
+ *(pbuffer + 2) =
+ pdata->system__interrupt_config_gpio;
+ *(pbuffer + 3) =
+ pdata->cal_config__vcsel_start & 0x7F;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->cal_config__repeat_rate & 0xFFF,
+ 2,
+ pbuffer + 4);
+ *(pbuffer + 6) =
+ pdata->global_config__vcsel_width & 0x7F;
+ *(pbuffer + 7) =
+ pdata->phasecal_config__timeout_macrop;
+ *(pbuffer + 8) =
+ pdata->phasecal_config__target;
+ *(pbuffer + 9) =
+ pdata->phasecal_config__override & 0x1;
+ *(pbuffer + 11) =
+ pdata->dss_config__roi_mode_control & 0x7;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->system__thresh_rate_high,
+ 2,
+ pbuffer + 12);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->system__thresh_rate_low,
+ 2,
+ pbuffer + 14);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->dss_config__manual_effective_spads_select,
+ 2,
+ pbuffer + 16);
+ *(pbuffer + 18) =
+ pdata->dss_config__manual_block_select;
+ *(pbuffer + 19) =
+ pdata->dss_config__aperture_attenuation;
+ *(pbuffer + 20) =
+ pdata->dss_config__max_spads_limit;
+ *(pbuffer + 21) =
+ pdata->dss_config__min_spads_limit;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_decode_general_config(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_general_config_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_general_config_t from the input I2C read buffer
+ * Buffer must be at least 22 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_GENERAL_CONFIG_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->gph_config__stream_count_update_value =
+ (*(pbuffer + 0));
+ pdata->global_config__stream_divider =
+ (*(pbuffer + 1));
+ pdata->system__interrupt_config_gpio =
+ (*(pbuffer + 2));
+ pdata->cal_config__vcsel_start =
+ (*(pbuffer + 3)) & 0x7F;
+ pdata->cal_config__repeat_rate =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 4)) & 0xFFF;
+ pdata->global_config__vcsel_width =
+ (*(pbuffer + 6)) & 0x7F;
+ pdata->phasecal_config__timeout_macrop =
+ (*(pbuffer + 7));
+ pdata->phasecal_config__target =
+ (*(pbuffer + 8));
+ pdata->phasecal_config__override =
+ (*(pbuffer + 9)) & 0x1;
+ pdata->dss_config__roi_mode_control =
+ (*(pbuffer + 11)) & 0x7;
+ pdata->system__thresh_rate_high =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 12));
+ pdata->system__thresh_rate_low =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 14));
+ pdata->dss_config__manual_effective_spads_select =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 16));
+ pdata->dss_config__manual_block_select =
+ (*(pbuffer + 18));
+ pdata->dss_config__aperture_attenuation =
+ (*(pbuffer + 19));
+ pdata->dss_config__max_spads_limit =
+ (*(pbuffer + 20));
+ pdata->dss_config__min_spads_limit =
+ (*(pbuffer + 21));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_general_config(
+ VL53L1_DEV Dev,
+ VL53L1_general_config_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_general_config_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_GENERAL_CONFIG_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_general_config(
+ pdata,
+ VL53L1_GENERAL_CONFIG_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_GPH_CONFIG__STREAM_COUNT_UPDATE_VALUE,
+ comms_buffer,
+ VL53L1_GENERAL_CONFIG_I2C_SIZE_BYTES);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_get_general_config(
+ VL53L1_DEV Dev,
+ VL53L1_general_config_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_general_config_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_GENERAL_CONFIG_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_GPH_CONFIG__STREAM_COUNT_UPDATE_VALUE,
+ comms_buffer,
+ VL53L1_GENERAL_CONFIG_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_general_config(
+ VL53L1_GENERAL_CONFIG_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_i2c_encode_timing_config(
+ VL53L1_timing_config_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_timing_config_t into a I2C write buffer
+ * Buffer must be at least 23 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_TIMING_CONFIG_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ *(pbuffer + 0) =
+ pdata->mm_config__timeout_macrop_a_hi & 0xF;
+ *(pbuffer + 1) =
+ pdata->mm_config__timeout_macrop_a_lo;
+ *(pbuffer + 2) =
+ pdata->mm_config__timeout_macrop_b_hi & 0xF;
+ *(pbuffer + 3) =
+ pdata->mm_config__timeout_macrop_b_lo;
+ *(pbuffer + 4) =
+ pdata->range_config__timeout_macrop_a_hi & 0xF;
+ *(pbuffer + 5) =
+ pdata->range_config__timeout_macrop_a_lo;
+ *(pbuffer + 6) =
+ pdata->range_config__vcsel_period_a & 0x3F;
+ *(pbuffer + 7) =
+ pdata->range_config__timeout_macrop_b_hi & 0xF;
+ *(pbuffer + 8) =
+ pdata->range_config__timeout_macrop_b_lo;
+ *(pbuffer + 9) =
+ pdata->range_config__vcsel_period_b & 0x3F;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->range_config__sigma_thresh,
+ 2,
+ pbuffer + 10);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->range_config__min_count_rate_rtn_limit_mcps,
+ 2,
+ pbuffer + 12);
+ *(pbuffer + 14) =
+ pdata->range_config__valid_phase_low;
+ *(pbuffer + 15) =
+ pdata->range_config__valid_phase_high;
+ VL53L1_i2c_encode_uint32_t(
+ pdata->system__intermeasurement_period,
+ 4,
+ pbuffer + 18);
+ *(pbuffer + 22) =
+ pdata->system__fractional_enable & 0x1;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_decode_timing_config(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_timing_config_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_timing_config_t from the input I2C read buffer
+ * Buffer must be at least 23 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_TIMING_CONFIG_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->mm_config__timeout_macrop_a_hi =
+ (*(pbuffer + 0)) & 0xF;
+ pdata->mm_config__timeout_macrop_a_lo =
+ (*(pbuffer + 1));
+ pdata->mm_config__timeout_macrop_b_hi =
+ (*(pbuffer + 2)) & 0xF;
+ pdata->mm_config__timeout_macrop_b_lo =
+ (*(pbuffer + 3));
+ pdata->range_config__timeout_macrop_a_hi =
+ (*(pbuffer + 4)) & 0xF;
+ pdata->range_config__timeout_macrop_a_lo =
+ (*(pbuffer + 5));
+ pdata->range_config__vcsel_period_a =
+ (*(pbuffer + 6)) & 0x3F;
+ pdata->range_config__timeout_macrop_b_hi =
+ (*(pbuffer + 7)) & 0xF;
+ pdata->range_config__timeout_macrop_b_lo =
+ (*(pbuffer + 8));
+ pdata->range_config__vcsel_period_b =
+ (*(pbuffer + 9)) & 0x3F;
+ pdata->range_config__sigma_thresh =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 10));
+ pdata->range_config__min_count_rate_rtn_limit_mcps =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 12));
+ pdata->range_config__valid_phase_low =
+ (*(pbuffer + 14));
+ pdata->range_config__valid_phase_high =
+ (*(pbuffer + 15));
+ pdata->system__intermeasurement_period =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 18));
+ pdata->system__fractional_enable =
+ (*(pbuffer + 22)) & 0x1;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_set_timing_config(
+ VL53L1_DEV Dev,
+ VL53L1_timing_config_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_timing_config_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_TIMING_CONFIG_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_timing_config(
+ pdata,
+ VL53L1_TIMING_CONFIG_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_MM_CONFIG__TIMEOUT_MACROP_A_HI,
+ comms_buffer,
+ VL53L1_TIMING_CONFIG_I2C_SIZE_BYTES);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_get_timing_config(
+ VL53L1_DEV Dev,
+ VL53L1_timing_config_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_timing_config_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_TIMING_CONFIG_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_MM_CONFIG__TIMEOUT_MACROP_A_HI,
+ comms_buffer,
+ VL53L1_TIMING_CONFIG_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_timing_config(
+ VL53L1_TIMING_CONFIG_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_i2c_encode_dynamic_config(
+ VL53L1_dynamic_config_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_dynamic_config_t into a I2C write buffer
+ * Buffer must be at least 18 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_DYNAMIC_CONFIG_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ *(pbuffer + 0) =
+ pdata->system__grouped_parameter_hold_0 & 0x3;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->system__thresh_high,
+ 2,
+ pbuffer + 1);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->system__thresh_low,
+ 2,
+ pbuffer + 3);
+ *(pbuffer + 5) =
+ pdata->system__enable_xtalk_per_quadrant & 0x1;
+ *(pbuffer + 6) =
+ pdata->system__seed_config & 0x7;
+ *(pbuffer + 7) =
+ pdata->sd_config__woi_sd0;
+ *(pbuffer + 8) =
+ pdata->sd_config__woi_sd1;
+ *(pbuffer + 9) =
+ pdata->sd_config__initial_phase_sd0 & 0x7F;
+ *(pbuffer + 10) =
+ pdata->sd_config__initial_phase_sd1 & 0x7F;
+ *(pbuffer + 11) =
+ pdata->system__grouped_parameter_hold_1 & 0x3;
+ *(pbuffer + 12) =
+ pdata->sd_config__first_order_select & 0x3;
+ *(pbuffer + 13) =
+ pdata->sd_config__quantifier & 0xF;
+ *(pbuffer + 14) =
+ pdata->roi_config__user_roi_centre_spad;
+ *(pbuffer + 15) =
+ pdata->roi_config__user_roi_requested_global_xy_size;
+ *(pbuffer + 16) =
+ pdata->system__sequence_config;
+ *(pbuffer + 17) =
+ pdata->system__grouped_parameter_hold & 0x3;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_decode_dynamic_config(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_dynamic_config_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_dynamic_config_t from the input I2C read buffer
+ * Buffer must be at least 18 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_DYNAMIC_CONFIG_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->system__grouped_parameter_hold_0 =
+ (*(pbuffer + 0)) & 0x3;
+ pdata->system__thresh_high =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 1));
+ pdata->system__thresh_low =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 3));
+ pdata->system__enable_xtalk_per_quadrant =
+ (*(pbuffer + 5)) & 0x1;
+ pdata->system__seed_config =
+ (*(pbuffer + 6)) & 0x7;
+ pdata->sd_config__woi_sd0 =
+ (*(pbuffer + 7));
+ pdata->sd_config__woi_sd1 =
+ (*(pbuffer + 8));
+ pdata->sd_config__initial_phase_sd0 =
+ (*(pbuffer + 9)) & 0x7F;
+ pdata->sd_config__initial_phase_sd1 =
+ (*(pbuffer + 10)) & 0x7F;
+ pdata->system__grouped_parameter_hold_1 =
+ (*(pbuffer + 11)) & 0x3;
+ pdata->sd_config__first_order_select =
+ (*(pbuffer + 12)) & 0x3;
+ pdata->sd_config__quantifier =
+ (*(pbuffer + 13)) & 0xF;
+ pdata->roi_config__user_roi_centre_spad =
+ (*(pbuffer + 14));
+ pdata->roi_config__user_roi_requested_global_xy_size =
+ (*(pbuffer + 15));
+ pdata->system__sequence_config =
+ (*(pbuffer + 16));
+ pdata->system__grouped_parameter_hold =
+ (*(pbuffer + 17)) & 0x3;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_set_dynamic_config(
+ VL53L1_DEV Dev,
+ VL53L1_dynamic_config_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_dynamic_config_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_DYNAMIC_CONFIG_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_dynamic_config(
+ pdata,
+ VL53L1_DYNAMIC_CONFIG_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_SYSTEM__GROUPED_PARAMETER_HOLD_0,
+ comms_buffer,
+ VL53L1_DYNAMIC_CONFIG_I2C_SIZE_BYTES);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_get_dynamic_config(
+ VL53L1_DEV Dev,
+ VL53L1_dynamic_config_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_dynamic_config_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_DYNAMIC_CONFIG_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_SYSTEM__GROUPED_PARAMETER_HOLD_0,
+ comms_buffer,
+ VL53L1_DYNAMIC_CONFIG_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_dynamic_config(
+ VL53L1_DYNAMIC_CONFIG_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_i2c_encode_system_control(
+ VL53L1_system_control_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_system_control_t into a I2C write buffer
+ * Buffer must be at least 5 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_SYSTEM_CONTROL_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ *(pbuffer + 0) =
+ pdata->power_management__go1_power_force & 0x1;
+ *(pbuffer + 1) =
+ pdata->system__stream_count_ctrl & 0x1;
+ *(pbuffer + 2) =
+ pdata->firmware__enable & 0x1;
+ *(pbuffer + 3) =
+ pdata->system__interrupt_clear & 0x3;
+ *(pbuffer + 4) =
+ pdata->system__mode_start;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_decode_system_control(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_system_control_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_system_control_t from the input I2C read buffer
+ * Buffer must be at least 5 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_SYSTEM_CONTROL_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->power_management__go1_power_force =
+ (*(pbuffer + 0)) & 0x1;
+ pdata->system__stream_count_ctrl =
+ (*(pbuffer + 1)) & 0x1;
+ pdata->firmware__enable =
+ (*(pbuffer + 2)) & 0x1;
+ pdata->system__interrupt_clear =
+ (*(pbuffer + 3)) & 0x3;
+ pdata->system__mode_start =
+ (*(pbuffer + 4));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_set_system_control(
+ VL53L1_DEV Dev,
+ VL53L1_system_control_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_system_control_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_SYSTEM_CONTROL_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_system_control(
+ pdata,
+ VL53L1_SYSTEM_CONTROL_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_POWER_MANAGEMENT__GO1_POWER_FORCE,
+ comms_buffer,
+ VL53L1_SYSTEM_CONTROL_I2C_SIZE_BYTES);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_get_system_control(
+ VL53L1_DEV Dev,
+ VL53L1_system_control_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_system_control_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_SYSTEM_CONTROL_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_POWER_MANAGEMENT__GO1_POWER_FORCE,
+ comms_buffer,
+ VL53L1_SYSTEM_CONTROL_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_system_control(
+ VL53L1_SYSTEM_CONTROL_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_encode_system_results(
+ VL53L1_system_results_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_system_results_t into a I2C write buffer
+ * Buffer must be at least 44 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_SYSTEM_RESULTS_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ *(pbuffer + 0) =
+ pdata->result__interrupt_status & 0x3F;
+ *(pbuffer + 1) =
+ pdata->result__range_status;
+ *(pbuffer + 2) =
+ pdata->result__report_status & 0xF;
+ *(pbuffer + 3) =
+ pdata->result__stream_count;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__dss_actual_effective_spads_sd0,
+ 2,
+ pbuffer + 4);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__peak_signal_count_rate_mcps_sd0,
+ 2,
+ pbuffer + 6);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__ambient_count_rate_mcps_sd0,
+ 2,
+ pbuffer + 8);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__sigma_sd0,
+ 2,
+ pbuffer + 10);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__phase_sd0,
+ 2,
+ pbuffer + 12);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__final_crosstalk_corrected_range_mm_sd0,
+ 2,
+ pbuffer + 14);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0,
+ 2,
+ pbuffer + 16);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__mm_inner_actual_effective_spads_sd0,
+ 2,
+ pbuffer + 18);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__mm_outer_actual_effective_spads_sd0,
+ 2,
+ pbuffer + 20);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__avg_signal_count_rate_mcps_sd0,
+ 2,
+ pbuffer + 22);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__dss_actual_effective_spads_sd1,
+ 2,
+ pbuffer + 24);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__peak_signal_count_rate_mcps_sd1,
+ 2,
+ pbuffer + 26);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__ambient_count_rate_mcps_sd1,
+ 2,
+ pbuffer + 28);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__sigma_sd1,
+ 2,
+ pbuffer + 30);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__phase_sd1,
+ 2,
+ pbuffer + 32);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__final_crosstalk_corrected_range_mm_sd1,
+ 2,
+ pbuffer + 34);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__spare_0_sd1,
+ 2,
+ pbuffer + 36);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__spare_1_sd1,
+ 2,
+ pbuffer + 38);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__spare_2_sd1,
+ 2,
+ pbuffer + 40);
+ *(pbuffer + 42) =
+ pdata->result__spare_3_sd1;
+ *(pbuffer + 43) =
+ pdata->result__thresh_info;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_i2c_decode_system_results(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_system_results_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_system_results_t from the input I2C read buffer
+ * Buffer must be at least 44 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_SYSTEM_RESULTS_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->result__interrupt_status =
+ (*(pbuffer + 0)) & 0x3F;
+ pdata->result__range_status =
+ (*(pbuffer + 1));
+ pdata->result__report_status =
+ (*(pbuffer + 2)) & 0xF;
+ pdata->result__stream_count =
+ (*(pbuffer + 3));
+ pdata->result__dss_actual_effective_spads_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 4));
+ pdata->result__peak_signal_count_rate_mcps_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 6));
+ pdata->result__ambient_count_rate_mcps_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 8));
+ pdata->result__sigma_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 10));
+ pdata->result__phase_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 12));
+ pdata->result__final_crosstalk_corrected_range_mm_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 14));
+ pdata->result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 16));
+ pdata->result__mm_inner_actual_effective_spads_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 18));
+ pdata->result__mm_outer_actual_effective_spads_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 20));
+ pdata->result__avg_signal_count_rate_mcps_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 22));
+ pdata->result__dss_actual_effective_spads_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 24));
+ pdata->result__peak_signal_count_rate_mcps_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 26));
+ pdata->result__ambient_count_rate_mcps_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 28));
+ pdata->result__sigma_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 30));
+ pdata->result__phase_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 32));
+ pdata->result__final_crosstalk_corrected_range_mm_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 34));
+ pdata->result__spare_0_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 36));
+ pdata->result__spare_1_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 38));
+ pdata->result__spare_2_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 40));
+ pdata->result__spare_3_sd1 =
+ (*(pbuffer + 42));
+ pdata->result__thresh_info =
+ (*(pbuffer + 43));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_set_system_results(
+ VL53L1_DEV Dev,
+ VL53L1_system_results_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_system_results_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_SYSTEM_RESULTS_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_system_results(
+ pdata,
+ VL53L1_SYSTEM_RESULTS_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_RESULT__INTERRUPT_STATUS,
+ comms_buffer,
+ VL53L1_SYSTEM_RESULTS_I2C_SIZE_BYTES);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_get_system_results(
+ VL53L1_DEV Dev,
+ VL53L1_system_results_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_system_results_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_SYSTEM_RESULTS_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_RESULT__INTERRUPT_STATUS,
+ comms_buffer,
+ VL53L1_SYSTEM_RESULTS_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_system_results(
+ VL53L1_SYSTEM_RESULTS_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_encode_core_results(
+ VL53L1_core_results_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_core_results_t into a I2C write buffer
+ * Buffer must be at least 33 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_CORE_RESULTS_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ VL53L1_i2c_encode_uint32_t(
+ pdata->result_core__ambient_window_events_sd0,
+ 4,
+ pbuffer + 0);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->result_core__ranging_total_events_sd0,
+ 4,
+ pbuffer + 4);
+ VL53L1_i2c_encode_int32_t(
+ pdata->result_core__signal_total_events_sd0,
+ 4,
+ pbuffer + 8);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->result_core__total_periods_elapsed_sd0,
+ 4,
+ pbuffer + 12);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->result_core__ambient_window_events_sd1,
+ 4,
+ pbuffer + 16);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->result_core__ranging_total_events_sd1,
+ 4,
+ pbuffer + 20);
+ VL53L1_i2c_encode_int32_t(
+ pdata->result_core__signal_total_events_sd1,
+ 4,
+ pbuffer + 24);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->result_core__total_periods_elapsed_sd1,
+ 4,
+ pbuffer + 28);
+ *(pbuffer + 32) =
+ pdata->result_core__spare_0;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_i2c_decode_core_results(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_core_results_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_core_results_t from the input I2C read buffer
+ * Buffer must be at least 33 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_CORE_RESULTS_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->result_core__ambient_window_events_sd0 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 0));
+ pdata->result_core__ranging_total_events_sd0 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 4));
+ pdata->result_core__signal_total_events_sd0 =
+ (VL53L1_i2c_decode_int32_t(4, pbuffer + 8));
+ pdata->result_core__total_periods_elapsed_sd0 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 12));
+ pdata->result_core__ambient_window_events_sd1 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 16));
+ pdata->result_core__ranging_total_events_sd1 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 20));
+ pdata->result_core__signal_total_events_sd1 =
+ (VL53L1_i2c_decode_int32_t(4, pbuffer + 24));
+ pdata->result_core__total_periods_elapsed_sd1 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 28));
+ pdata->result_core__spare_0 =
+ (*(pbuffer + 32));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_set_core_results(
+ VL53L1_DEV Dev,
+ VL53L1_core_results_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_core_results_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_CORE_RESULTS_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_core_results(
+ pdata,
+ VL53L1_CORE_RESULTS_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0,
+ comms_buffer,
+ VL53L1_CORE_RESULTS_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_get_core_results(
+ VL53L1_DEV Dev,
+ VL53L1_core_results_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_core_results_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_CORE_RESULTS_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0,
+ comms_buffer,
+ VL53L1_CORE_RESULTS_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_core_results(
+ VL53L1_CORE_RESULTS_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_i2c_encode_debug_results(
+ VL53L1_debug_results_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_debug_results_t into a I2C write buffer
+ * Buffer must be at least 56 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_DEBUG_RESULTS_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ VL53L1_i2c_encode_uint16_t(
+ pdata->phasecal_result__reference_phase,
+ 2,
+ pbuffer + 0);
+ *(pbuffer + 2) =
+ pdata->phasecal_result__vcsel_start & 0x7F;
+ *(pbuffer + 3) =
+ pdata->ref_spad_char_result__num_actual_ref_spads & 0x3F;
+ *(pbuffer + 4) =
+ pdata->ref_spad_char_result__ref_location & 0x3;
+ *(pbuffer + 5) =
+ pdata->vhv_result__coldboot_status & 0x1;
+ *(pbuffer + 6) =
+ pdata->vhv_result__search_result & 0x3F;
+ *(pbuffer + 7) =
+ pdata->vhv_result__latest_setting & 0x3F;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->result__osc_calibrate_val & 0x3FF,
+ 2,
+ pbuffer + 8);
+ *(pbuffer + 10) =
+ pdata->ana_config__powerdown_go1 & 0x3;
+ *(pbuffer + 11) =
+ pdata->ana_config__ref_bg_ctrl & 0x3;
+ *(pbuffer + 12) =
+ pdata->ana_config__regdvdd1v2_ctrl & 0xF;
+ *(pbuffer + 13) =
+ pdata->ana_config__osc_slow_ctrl & 0x7;
+ *(pbuffer + 14) =
+ pdata->test_mode__status & 0x1;
+ *(pbuffer + 15) =
+ pdata->firmware__system_status & 0x3;
+ *(pbuffer + 16) =
+ pdata->firmware__mode_status;
+ *(pbuffer + 17) =
+ pdata->firmware__secondary_mode_status;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->firmware__cal_repeat_rate_counter & 0xFFF,
+ 2,
+ pbuffer + 18);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->gph__system__thresh_high,
+ 2,
+ pbuffer + 22);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->gph__system__thresh_low,
+ 2,
+ pbuffer + 24);
+ *(pbuffer + 26) =
+ pdata->gph__system__enable_xtalk_per_quadrant & 0x1;
+ *(pbuffer + 27) =
+ pdata->gph__spare_0 & 0x7;
+ *(pbuffer + 28) =
+ pdata->gph__sd_config__woi_sd0;
+ *(pbuffer + 29) =
+ pdata->gph__sd_config__woi_sd1;
+ *(pbuffer + 30) =
+ pdata->gph__sd_config__initial_phase_sd0 & 0x7F;
+ *(pbuffer + 31) =
+ pdata->gph__sd_config__initial_phase_sd1 & 0x7F;
+ *(pbuffer + 32) =
+ pdata->gph__sd_config__first_order_select & 0x3;
+ *(pbuffer + 33) =
+ pdata->gph__sd_config__quantifier & 0xF;
+ *(pbuffer + 34) =
+ pdata->gph__roi_config__user_roi_centre_spad;
+ *(pbuffer + 35) =
+ pdata->gph__roi_config__user_roi_requested_global_xy_size;
+ *(pbuffer + 36) =
+ pdata->gph__system__sequence_config;
+ *(pbuffer + 37) =
+ pdata->gph__gph_id & 0x1;
+ *(pbuffer + 38) =
+ pdata->system__interrupt_set & 0x3;
+ *(pbuffer + 39) =
+ pdata->interrupt_manager__enables & 0x1F;
+ *(pbuffer + 40) =
+ pdata->interrupt_manager__clear & 0x1F;
+ *(pbuffer + 41) =
+ pdata->interrupt_manager__status & 0x1F;
+ *(pbuffer + 42) =
+ pdata->mcu_to_host_bank__wr_access_en & 0x1;
+ *(pbuffer + 43) =
+ pdata->power_management__go1_reset_status & 0x1;
+ *(pbuffer + 44) =
+ pdata->pad_startup_mode__value_ro & 0x3;
+ *(pbuffer + 45) =
+ pdata->pad_startup_mode__value_ctrl & 0x3F;
+ VL53L1_i2c_encode_uint32_t(
+ pdata->pll_period_us & 0x3FFFF,
+ 4,
+ pbuffer + 46);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->interrupt_scheduler__data_out,
+ 4,
+ pbuffer + 50);
+ *(pbuffer + 54) =
+ pdata->nvm_bist__complete & 0x1;
+ *(pbuffer + 55) =
+ pdata->nvm_bist__status & 0x1;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_i2c_decode_debug_results(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_debug_results_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_debug_results_t from the input I2C read buffer
+ * Buffer must be at least 56 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_DEBUG_RESULTS_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->phasecal_result__reference_phase =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 0));
+ pdata->phasecal_result__vcsel_start =
+ (*(pbuffer + 2)) & 0x7F;
+ pdata->ref_spad_char_result__num_actual_ref_spads =
+ (*(pbuffer + 3)) & 0x3F;
+ pdata->ref_spad_char_result__ref_location =
+ (*(pbuffer + 4)) & 0x3;
+ pdata->vhv_result__coldboot_status =
+ (*(pbuffer + 5)) & 0x1;
+ pdata->vhv_result__search_result =
+ (*(pbuffer + 6)) & 0x3F;
+ pdata->vhv_result__latest_setting =
+ (*(pbuffer + 7)) & 0x3F;
+ pdata->result__osc_calibrate_val =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 8)) & 0x3FF;
+ pdata->ana_config__powerdown_go1 =
+ (*(pbuffer + 10)) & 0x3;
+ pdata->ana_config__ref_bg_ctrl =
+ (*(pbuffer + 11)) & 0x3;
+ pdata->ana_config__regdvdd1v2_ctrl =
+ (*(pbuffer + 12)) & 0xF;
+ pdata->ana_config__osc_slow_ctrl =
+ (*(pbuffer + 13)) & 0x7;
+ pdata->test_mode__status =
+ (*(pbuffer + 14)) & 0x1;
+ pdata->firmware__system_status =
+ (*(pbuffer + 15)) & 0x3;
+ pdata->firmware__mode_status =
+ (*(pbuffer + 16));
+ pdata->firmware__secondary_mode_status =
+ (*(pbuffer + 17));
+ pdata->firmware__cal_repeat_rate_counter =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 18)) & 0xFFF;
+ pdata->gph__system__thresh_high =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 22));
+ pdata->gph__system__thresh_low =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 24));
+ pdata->gph__system__enable_xtalk_per_quadrant =
+ (*(pbuffer + 26)) & 0x1;
+ pdata->gph__spare_0 =
+ (*(pbuffer + 27)) & 0x7;
+ pdata->gph__sd_config__woi_sd0 =
+ (*(pbuffer + 28));
+ pdata->gph__sd_config__woi_sd1 =
+ (*(pbuffer + 29));
+ pdata->gph__sd_config__initial_phase_sd0 =
+ (*(pbuffer + 30)) & 0x7F;
+ pdata->gph__sd_config__initial_phase_sd1 =
+ (*(pbuffer + 31)) & 0x7F;
+ pdata->gph__sd_config__first_order_select =
+ (*(pbuffer + 32)) & 0x3;
+ pdata->gph__sd_config__quantifier =
+ (*(pbuffer + 33)) & 0xF;
+ pdata->gph__roi_config__user_roi_centre_spad =
+ (*(pbuffer + 34));
+ pdata->gph__roi_config__user_roi_requested_global_xy_size =
+ (*(pbuffer + 35));
+ pdata->gph__system__sequence_config =
+ (*(pbuffer + 36));
+ pdata->gph__gph_id =
+ (*(pbuffer + 37)) & 0x1;
+ pdata->system__interrupt_set =
+ (*(pbuffer + 38)) & 0x3;
+ pdata->interrupt_manager__enables =
+ (*(pbuffer + 39)) & 0x1F;
+ pdata->interrupt_manager__clear =
+ (*(pbuffer + 40)) & 0x1F;
+ pdata->interrupt_manager__status =
+ (*(pbuffer + 41)) & 0x1F;
+ pdata->mcu_to_host_bank__wr_access_en =
+ (*(pbuffer + 42)) & 0x1;
+ pdata->power_management__go1_reset_status =
+ (*(pbuffer + 43)) & 0x1;
+ pdata->pad_startup_mode__value_ro =
+ (*(pbuffer + 44)) & 0x3;
+ pdata->pad_startup_mode__value_ctrl =
+ (*(pbuffer + 45)) & 0x3F;
+ pdata->pll_period_us =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 46)) & 0x3FFFF;
+ pdata->interrupt_scheduler__data_out =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 50));
+ pdata->nvm_bist__complete =
+ (*(pbuffer + 54)) & 0x1;
+ pdata->nvm_bist__status =
+ (*(pbuffer + 55)) & 0x1;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_set_debug_results(
+ VL53L1_DEV Dev,
+ VL53L1_debug_results_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_debug_results_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_DEBUG_RESULTS_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_debug_results(
+ pdata,
+ VL53L1_DEBUG_RESULTS_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_PHASECAL_RESULT__REFERENCE_PHASE,
+ comms_buffer,
+ VL53L1_DEBUG_RESULTS_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_get_debug_results(
+ VL53L1_DEV Dev,
+ VL53L1_debug_results_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_debug_results_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_DEBUG_RESULTS_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_PHASECAL_RESULT__REFERENCE_PHASE,
+ comms_buffer,
+ VL53L1_DEBUG_RESULTS_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_debug_results(
+ VL53L1_DEBUG_RESULTS_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_encode_nvm_copy_data(
+ VL53L1_nvm_copy_data_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_nvm_copy_data_t into a I2C write buffer
+ * Buffer must be at least 49 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_NVM_COPY_DATA_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ *(pbuffer + 0) =
+ pdata->identification__model_id;
+ *(pbuffer + 1) =
+ pdata->identification__module_type;
+ *(pbuffer + 2) =
+ pdata->identification__revision_id;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->identification__module_id,
+ 2,
+ pbuffer + 3);
+ *(pbuffer + 5) =
+ pdata->ana_config__fast_osc__trim_max & 0x7F;
+ *(pbuffer + 6) =
+ pdata->ana_config__fast_osc__freq_set & 0x7;
+ *(pbuffer + 7) =
+ pdata->ana_config__vcsel_trim & 0x7;
+ *(pbuffer + 8) =
+ pdata->ana_config__vcsel_selion & 0x3F;
+ *(pbuffer + 9) =
+ pdata->ana_config__vcsel_selion_max & 0x3F;
+ *(pbuffer + 10) =
+ pdata->protected_laser_safety__lock_bit & 0x1;
+ *(pbuffer + 11) =
+ pdata->laser_safety__key & 0x7F;
+ *(pbuffer + 12) =
+ pdata->laser_safety__key_ro & 0x1;
+ *(pbuffer + 13) =
+ pdata->laser_safety__clip & 0x3F;
+ *(pbuffer + 14) =
+ pdata->laser_safety__mult & 0x3F;
+ *(pbuffer + 15) =
+ pdata->global_config__spad_enables_rtn_0;
+ *(pbuffer + 16) =
+ pdata->global_config__spad_enables_rtn_1;
+ *(pbuffer + 17) =
+ pdata->global_config__spad_enables_rtn_2;
+ *(pbuffer + 18) =
+ pdata->global_config__spad_enables_rtn_3;
+ *(pbuffer + 19) =
+ pdata->global_config__spad_enables_rtn_4;
+ *(pbuffer + 20) =
+ pdata->global_config__spad_enables_rtn_5;
+ *(pbuffer + 21) =
+ pdata->global_config__spad_enables_rtn_6;
+ *(pbuffer + 22) =
+ pdata->global_config__spad_enables_rtn_7;
+ *(pbuffer + 23) =
+ pdata->global_config__spad_enables_rtn_8;
+ *(pbuffer + 24) =
+ pdata->global_config__spad_enables_rtn_9;
+ *(pbuffer + 25) =
+ pdata->global_config__spad_enables_rtn_10;
+ *(pbuffer + 26) =
+ pdata->global_config__spad_enables_rtn_11;
+ *(pbuffer + 27) =
+ pdata->global_config__spad_enables_rtn_12;
+ *(pbuffer + 28) =
+ pdata->global_config__spad_enables_rtn_13;
+ *(pbuffer + 29) =
+ pdata->global_config__spad_enables_rtn_14;
+ *(pbuffer + 30) =
+ pdata->global_config__spad_enables_rtn_15;
+ *(pbuffer + 31) =
+ pdata->global_config__spad_enables_rtn_16;
+ *(pbuffer + 32) =
+ pdata->global_config__spad_enables_rtn_17;
+ *(pbuffer + 33) =
+ pdata->global_config__spad_enables_rtn_18;
+ *(pbuffer + 34) =
+ pdata->global_config__spad_enables_rtn_19;
+ *(pbuffer + 35) =
+ pdata->global_config__spad_enables_rtn_20;
+ *(pbuffer + 36) =
+ pdata->global_config__spad_enables_rtn_21;
+ *(pbuffer + 37) =
+ pdata->global_config__spad_enables_rtn_22;
+ *(pbuffer + 38) =
+ pdata->global_config__spad_enables_rtn_23;
+ *(pbuffer + 39) =
+ pdata->global_config__spad_enables_rtn_24;
+ *(pbuffer + 40) =
+ pdata->global_config__spad_enables_rtn_25;
+ *(pbuffer + 41) =
+ pdata->global_config__spad_enables_rtn_26;
+ *(pbuffer + 42) =
+ pdata->global_config__spad_enables_rtn_27;
+ *(pbuffer + 43) =
+ pdata->global_config__spad_enables_rtn_28;
+ *(pbuffer + 44) =
+ pdata->global_config__spad_enables_rtn_29;
+ *(pbuffer + 45) =
+ pdata->global_config__spad_enables_rtn_30;
+ *(pbuffer + 46) =
+ pdata->global_config__spad_enables_rtn_31;
+ *(pbuffer + 47) =
+ pdata->roi_config__mode_roi_centre_spad;
+ *(pbuffer + 48) =
+ pdata->roi_config__mode_roi_xy_size;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_i2c_decode_nvm_copy_data(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_nvm_copy_data_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_nvm_copy_data_t from the input I2C read buffer
+ * Buffer must be at least 49 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_NVM_COPY_DATA_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->identification__model_id =
+ (*(pbuffer + 0));
+ pdata->identification__module_type =
+ (*(pbuffer + 1));
+ pdata->identification__revision_id =
+ (*(pbuffer + 2));
+ pdata->identification__module_id =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 3));
+ pdata->ana_config__fast_osc__trim_max =
+ (*(pbuffer + 5)) & 0x7F;
+ pdata->ana_config__fast_osc__freq_set =
+ (*(pbuffer + 6)) & 0x7;
+ pdata->ana_config__vcsel_trim =
+ (*(pbuffer + 7)) & 0x7;
+ pdata->ana_config__vcsel_selion =
+ (*(pbuffer + 8)) & 0x3F;
+ pdata->ana_config__vcsel_selion_max =
+ (*(pbuffer + 9)) & 0x3F;
+ pdata->protected_laser_safety__lock_bit =
+ (*(pbuffer + 10)) & 0x1;
+ pdata->laser_safety__key =
+ (*(pbuffer + 11)) & 0x7F;
+ pdata->laser_safety__key_ro =
+ (*(pbuffer + 12)) & 0x1;
+ pdata->laser_safety__clip =
+ (*(pbuffer + 13)) & 0x3F;
+ pdata->laser_safety__mult =
+ (*(pbuffer + 14)) & 0x3F;
+ pdata->global_config__spad_enables_rtn_0 =
+ (*(pbuffer + 15));
+ pdata->global_config__spad_enables_rtn_1 =
+ (*(pbuffer + 16));
+ pdata->global_config__spad_enables_rtn_2 =
+ (*(pbuffer + 17));
+ pdata->global_config__spad_enables_rtn_3 =
+ (*(pbuffer + 18));
+ pdata->global_config__spad_enables_rtn_4 =
+ (*(pbuffer + 19));
+ pdata->global_config__spad_enables_rtn_5 =
+ (*(pbuffer + 20));
+ pdata->global_config__spad_enables_rtn_6 =
+ (*(pbuffer + 21));
+ pdata->global_config__spad_enables_rtn_7 =
+ (*(pbuffer + 22));
+ pdata->global_config__spad_enables_rtn_8 =
+ (*(pbuffer + 23));
+ pdata->global_config__spad_enables_rtn_9 =
+ (*(pbuffer + 24));
+ pdata->global_config__spad_enables_rtn_10 =
+ (*(pbuffer + 25));
+ pdata->global_config__spad_enables_rtn_11 =
+ (*(pbuffer + 26));
+ pdata->global_config__spad_enables_rtn_12 =
+ (*(pbuffer + 27));
+ pdata->global_config__spad_enables_rtn_13 =
+ (*(pbuffer + 28));
+ pdata->global_config__spad_enables_rtn_14 =
+ (*(pbuffer + 29));
+ pdata->global_config__spad_enables_rtn_15 =
+ (*(pbuffer + 30));
+ pdata->global_config__spad_enables_rtn_16 =
+ (*(pbuffer + 31));
+ pdata->global_config__spad_enables_rtn_17 =
+ (*(pbuffer + 32));
+ pdata->global_config__spad_enables_rtn_18 =
+ (*(pbuffer + 33));
+ pdata->global_config__spad_enables_rtn_19 =
+ (*(pbuffer + 34));
+ pdata->global_config__spad_enables_rtn_20 =
+ (*(pbuffer + 35));
+ pdata->global_config__spad_enables_rtn_21 =
+ (*(pbuffer + 36));
+ pdata->global_config__spad_enables_rtn_22 =
+ (*(pbuffer + 37));
+ pdata->global_config__spad_enables_rtn_23 =
+ (*(pbuffer + 38));
+ pdata->global_config__spad_enables_rtn_24 =
+ (*(pbuffer + 39));
+ pdata->global_config__spad_enables_rtn_25 =
+ (*(pbuffer + 40));
+ pdata->global_config__spad_enables_rtn_26 =
+ (*(pbuffer + 41));
+ pdata->global_config__spad_enables_rtn_27 =
+ (*(pbuffer + 42));
+ pdata->global_config__spad_enables_rtn_28 =
+ (*(pbuffer + 43));
+ pdata->global_config__spad_enables_rtn_29 =
+ (*(pbuffer + 44));
+ pdata->global_config__spad_enables_rtn_30 =
+ (*(pbuffer + 45));
+ pdata->global_config__spad_enables_rtn_31 =
+ (*(pbuffer + 46));
+ pdata->roi_config__mode_roi_centre_spad =
+ (*(pbuffer + 47));
+ pdata->roi_config__mode_roi_xy_size =
+ (*(pbuffer + 48));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_set_nvm_copy_data(
+ VL53L1_DEV Dev,
+ VL53L1_nvm_copy_data_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_nvm_copy_data_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_NVM_COPY_DATA_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_nvm_copy_data(
+ pdata,
+ VL53L1_NVM_COPY_DATA_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_IDENTIFICATION__MODEL_ID,
+ comms_buffer,
+ VL53L1_NVM_COPY_DATA_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+VL53L1_Error VL53L1_get_nvm_copy_data(
+ VL53L1_DEV Dev,
+ VL53L1_nvm_copy_data_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_nvm_copy_data_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_NVM_COPY_DATA_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_IDENTIFICATION__MODEL_ID,
+ comms_buffer,
+ VL53L1_NVM_COPY_DATA_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_nvm_copy_data(
+ VL53L1_NVM_COPY_DATA_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_i2c_encode_prev_shadow_system_results(
+ VL53L1_prev_shadow_system_results_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_prev_shadow_system_results_t into a I2C write buffer
+ * Buffer must be at least 44 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_PREV_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ *(pbuffer + 0) =
+ pdata->prev_shadow_result__interrupt_status & 0x3F;
+ *(pbuffer + 1) =
+ pdata->prev_shadow_result__range_status;
+ *(pbuffer + 2) =
+ pdata->prev_shadow_result__report_status & 0xF;
+ *(pbuffer + 3) =
+ pdata->prev_shadow_result__stream_count;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__dss_actual_effective_spads_sd0,
+ 2,
+ pbuffer + 4);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__peak_signal_count_rate_mcps_sd0,
+ 2,
+ pbuffer + 6);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__ambient_count_rate_mcps_sd0,
+ 2,
+ pbuffer + 8);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__sigma_sd0,
+ 2,
+ pbuffer + 10);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__phase_sd0,
+ 2,
+ pbuffer + 12);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__final_crosstalk_corrected_range_mm_sd0,
+ 2,
+ pbuffer + 14);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0,
+ 2,
+ pbuffer + 16);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__mm_inner_actual_effective_spads_sd0,
+ 2,
+ pbuffer + 18);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__mm_outer_actual_effective_spads_sd0,
+ 2,
+ pbuffer + 20);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__avg_signal_count_rate_mcps_sd0,
+ 2,
+ pbuffer + 22);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__dss_actual_effective_spads_sd1,
+ 2,
+ pbuffer + 24);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__peak_signal_count_rate_mcps_sd1,
+ 2,
+ pbuffer + 26);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__ambient_count_rate_mcps_sd1,
+ 2,
+ pbuffer + 28);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__sigma_sd1,
+ 2,
+ pbuffer + 30);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__phase_sd1,
+ 2,
+ pbuffer + 32);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__final_crosstalk_corrected_range_mm_sd1,
+ 2,
+ pbuffer + 34);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__spare_0_sd1,
+ 2,
+ pbuffer + 36);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__spare_1_sd1,
+ 2,
+ pbuffer + 38);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__spare_2_sd1,
+ 2,
+ pbuffer + 40);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->prev_shadow_result__spare_3_sd1,
+ 2,
+ pbuffer + 42);
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_decode_prev_shadow_system_results(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_prev_shadow_system_results_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_prev_shadow_system_results_t from the input I2C read buffer
+ * Buffer must be at least 44 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_PREV_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->prev_shadow_result__interrupt_status =
+ (*(pbuffer + 0)) & 0x3F;
+ pdata->prev_shadow_result__range_status =
+ (*(pbuffer + 1));
+ pdata->prev_shadow_result__report_status =
+ (*(pbuffer + 2)) & 0xF;
+ pdata->prev_shadow_result__stream_count =
+ (*(pbuffer + 3));
+ pdata->prev_shadow_result__dss_actual_effective_spads_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 4));
+ pdata->prev_shadow_result__peak_signal_count_rate_mcps_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 6));
+ pdata->prev_shadow_result__ambient_count_rate_mcps_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 8));
+ pdata->prev_shadow_result__sigma_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 10));
+ pdata->prev_shadow_result__phase_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 12));
+ pdata->prev_shadow_result__final_crosstalk_corrected_range_mm_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 14));
+ pdata->prev_shadow_result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 16));
+ pdata->prev_shadow_result__mm_inner_actual_effective_spads_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 18));
+ pdata->prev_shadow_result__mm_outer_actual_effective_spads_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 20));
+ pdata->prev_shadow_result__avg_signal_count_rate_mcps_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 22));
+ pdata->prev_shadow_result__dss_actual_effective_spads_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 24));
+ pdata->prev_shadow_result__peak_signal_count_rate_mcps_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 26));
+ pdata->prev_shadow_result__ambient_count_rate_mcps_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 28));
+ pdata->prev_shadow_result__sigma_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 30));
+ pdata->prev_shadow_result__phase_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 32));
+ pdata->prev_shadow_result__final_crosstalk_corrected_range_mm_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 34));
+ pdata->prev_shadow_result__spare_0_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 36));
+ pdata->prev_shadow_result__spare_1_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 38));
+ pdata->prev_shadow_result__spare_2_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 40));
+ pdata->prev_shadow_result__spare_3_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 42));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_prev_shadow_system_results(
+ VL53L1_DEV Dev,
+ VL53L1_prev_shadow_system_results_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_prev_shadow_system_results_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_PREV_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_prev_shadow_system_results(
+ pdata,
+ VL53L1_PREV_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_PREV_SHADOW_RESULT__INTERRUPT_STATUS,
+ comms_buffer,
+ VL53L1_PREV_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_get_prev_shadow_system_results(
+ VL53L1_DEV Dev,
+ VL53L1_prev_shadow_system_results_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_prev_shadow_system_results_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_PREV_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_PREV_SHADOW_RESULT__INTERRUPT_STATUS,
+ comms_buffer,
+ VL53L1_PREV_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_prev_shadow_system_results(
+ VL53L1_PREV_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_encode_prev_shadow_core_results(
+ VL53L1_prev_shadow_core_results_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_prev_shadow_core_results_t into a I2C write buffer
+ * Buffer must be at least 33 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_PREV_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ VL53L1_i2c_encode_uint32_t(
+ pdata->prev_shadow_result_core__ambient_window_events_sd0,
+ 4,
+ pbuffer + 0);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->prev_shadow_result_core__ranging_total_events_sd0,
+ 4,
+ pbuffer + 4);
+ VL53L1_i2c_encode_int32_t(
+ pdata->prev_shadow_result_core__signal_total_events_sd0,
+ 4,
+ pbuffer + 8);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->prev_shadow_result_core__total_periods_elapsed_sd0,
+ 4,
+ pbuffer + 12);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->prev_shadow_result_core__ambient_window_events_sd1,
+ 4,
+ pbuffer + 16);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->prev_shadow_result_core__ranging_total_events_sd1,
+ 4,
+ pbuffer + 20);
+ VL53L1_i2c_encode_int32_t(
+ pdata->prev_shadow_result_core__signal_total_events_sd1,
+ 4,
+ pbuffer + 24);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->prev_shadow_result_core__total_periods_elapsed_sd1,
+ 4,
+ pbuffer + 28);
+ *(pbuffer + 32) =
+ pdata->prev_shadow_result_core__spare_0;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_decode_prev_shadow_core_results(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_prev_shadow_core_results_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_prev_shadow_core_results_t from the input I2C read buffer
+ * Buffer must be at least 33 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_PREV_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->prev_shadow_result_core__ambient_window_events_sd0 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 0));
+ pdata->prev_shadow_result_core__ranging_total_events_sd0 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 4));
+ pdata->prev_shadow_result_core__signal_total_events_sd0 =
+ (VL53L1_i2c_decode_int32_t(4, pbuffer + 8));
+ pdata->prev_shadow_result_core__total_periods_elapsed_sd0 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 12));
+ pdata->prev_shadow_result_core__ambient_window_events_sd1 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 16));
+ pdata->prev_shadow_result_core__ranging_total_events_sd1 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 20));
+ pdata->prev_shadow_result_core__signal_total_events_sd1 =
+ (VL53L1_i2c_decode_int32_t(4, pbuffer + 24));
+ pdata->prev_shadow_result_core__total_periods_elapsed_sd1 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 28));
+ pdata->prev_shadow_result_core__spare_0 =
+ (*(pbuffer + 32));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_prev_shadow_core_results(
+ VL53L1_DEV Dev,
+ VL53L1_prev_shadow_core_results_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_prev_shadow_core_results_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_PREV_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_prev_shadow_core_results(
+ pdata,
+ VL53L1_PREV_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_PREV_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0,
+ comms_buffer,
+ VL53L1_PREV_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_get_prev_shadow_core_results(
+ VL53L1_DEV Dev,
+ VL53L1_prev_shadow_core_results_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_prev_shadow_core_results_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_PREV_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_PREV_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0,
+ comms_buffer,
+ VL53L1_PREV_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_prev_shadow_core_results(
+ VL53L1_PREV_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_encode_patch_debug(
+ VL53L1_patch_debug_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_patch_debug_t into a I2C write buffer
+ * Buffer must be at least 2 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_PATCH_DEBUG_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ *(pbuffer + 0) =
+ pdata->result__debug_status;
+ *(pbuffer + 1) =
+ pdata->result__debug_stage;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+
+VL53L1_Error VL53L1_i2c_decode_patch_debug(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_patch_debug_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_patch_debug_t from the input I2C read buffer
+ * Buffer must be at least 2 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_PATCH_DEBUG_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->result__debug_status =
+ (*(pbuffer + 0));
+ pdata->result__debug_stage =
+ (*(pbuffer + 1));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_patch_debug(
+ VL53L1_DEV Dev,
+ VL53L1_patch_debug_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_patch_debug_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_PATCH_DEBUG_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_patch_debug(
+ pdata,
+ VL53L1_PATCH_DEBUG_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_RESULT__DEBUG_STATUS,
+ comms_buffer,
+ VL53L1_PATCH_DEBUG_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_get_patch_debug(
+ VL53L1_DEV Dev,
+ VL53L1_patch_debug_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_patch_debug_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_PATCH_DEBUG_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_RESULT__DEBUG_STATUS,
+ comms_buffer,
+ VL53L1_PATCH_DEBUG_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_patch_debug(
+ VL53L1_PATCH_DEBUG_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_encode_gph_general_config(
+ VL53L1_gph_general_config_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_gph_general_config_t into a I2C write buffer
+ * Buffer must be at least 5 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_GPH_GENERAL_CONFIG_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ VL53L1_i2c_encode_uint16_t(
+ pdata->gph__system__thresh_rate_high,
+ 2,
+ pbuffer + 0);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->gph__system__thresh_rate_low,
+ 2,
+ pbuffer + 2);
+ *(pbuffer + 4) =
+ pdata->gph__system__interrupt_config_gpio;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+#endif
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_decode_gph_general_config(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_gph_general_config_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_gph_general_config_t from the input I2C read buffer
+ * Buffer must be at least 5 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_GPH_GENERAL_CONFIG_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->gph__system__thresh_rate_high =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 0));
+ pdata->gph__system__thresh_rate_low =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 2));
+ pdata->gph__system__interrupt_config_gpio =
+ (*(pbuffer + 4));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_set_gph_general_config(
+ VL53L1_DEV Dev,
+ VL53L1_gph_general_config_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_gph_general_config_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_GPH_GENERAL_CONFIG_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_gph_general_config(
+ pdata,
+ VL53L1_GPH_GENERAL_CONFIG_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_GPH__SYSTEM__THRESH_RATE_HIGH,
+ comms_buffer,
+ VL53L1_GPH_GENERAL_CONFIG_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_get_gph_general_config(
+ VL53L1_DEV Dev,
+ VL53L1_gph_general_config_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_gph_general_config_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_GPH_GENERAL_CONFIG_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_GPH__SYSTEM__THRESH_RATE_HIGH,
+ comms_buffer,
+ VL53L1_GPH_GENERAL_CONFIG_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_gph_general_config(
+ VL53L1_GPH_GENERAL_CONFIG_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_encode_gph_static_config(
+ VL53L1_gph_static_config_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_gph_static_config_t into a I2C write buffer
+ * Buffer must be at least 6 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_GPH_STATIC_CONFIG_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ *(pbuffer + 0) =
+ pdata->gph__dss_config__roi_mode_control & 0x7;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->gph__dss_config__manual_effective_spads_select,
+ 2,
+ pbuffer + 1);
+ *(pbuffer + 3) =
+ pdata->gph__dss_config__manual_block_select;
+ *(pbuffer + 4) =
+ pdata->gph__dss_config__max_spads_limit;
+ *(pbuffer + 5) =
+ pdata->gph__dss_config__min_spads_limit;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+#endif
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_decode_gph_static_config(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_gph_static_config_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_gph_static_config_t from the input I2C read buffer
+ * Buffer must be at least 6 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_GPH_STATIC_CONFIG_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->gph__dss_config__roi_mode_control =
+ (*(pbuffer + 0)) & 0x7;
+ pdata->gph__dss_config__manual_effective_spads_select =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 1));
+ pdata->gph__dss_config__manual_block_select =
+ (*(pbuffer + 3));
+ pdata->gph__dss_config__max_spads_limit =
+ (*(pbuffer + 4));
+ pdata->gph__dss_config__min_spads_limit =
+ (*(pbuffer + 5));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_set_gph_static_config(
+ VL53L1_DEV Dev,
+ VL53L1_gph_static_config_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_gph_static_config_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_GPH_STATIC_CONFIG_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_gph_static_config(
+ pdata,
+ VL53L1_GPH_STATIC_CONFIG_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_GPH__DSS_CONFIG__ROI_MODE_CONTROL,
+ comms_buffer,
+ VL53L1_GPH_STATIC_CONFIG_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_get_gph_static_config(
+ VL53L1_DEV Dev,
+ VL53L1_gph_static_config_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_gph_static_config_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_GPH_STATIC_CONFIG_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_GPH__DSS_CONFIG__ROI_MODE_CONTROL,
+ comms_buffer,
+ VL53L1_GPH_STATIC_CONFIG_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_gph_static_config(
+ VL53L1_GPH_STATIC_CONFIG_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_encode_gph_timing_config(
+ VL53L1_gph_timing_config_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_gph_timing_config_t into a I2C write buffer
+ * Buffer must be at least 16 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_GPH_TIMING_CONFIG_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ *(pbuffer + 0) =
+ pdata->gph__mm_config__timeout_macrop_a_hi & 0xF;
+ *(pbuffer + 1) =
+ pdata->gph__mm_config__timeout_macrop_a_lo;
+ *(pbuffer + 2) =
+ pdata->gph__mm_config__timeout_macrop_b_hi & 0xF;
+ *(pbuffer + 3) =
+ pdata->gph__mm_config__timeout_macrop_b_lo;
+ *(pbuffer + 4) =
+ pdata->gph__range_config__timeout_macrop_a_hi & 0xF;
+ *(pbuffer + 5) =
+ pdata->gph__range_config__timeout_macrop_a_lo;
+ *(pbuffer + 6) =
+ pdata->gph__range_config__vcsel_period_a & 0x3F;
+ *(pbuffer + 7) =
+ pdata->gph__range_config__vcsel_period_b & 0x3F;
+ *(pbuffer + 8) =
+ pdata->gph__range_config__timeout_macrop_b_hi & 0xF;
+ *(pbuffer + 9) =
+ pdata->gph__range_config__timeout_macrop_b_lo;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->gph__range_config__sigma_thresh,
+ 2,
+ pbuffer + 10);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->gph__range_config__min_count_rate_rtn_limit_mcps,
+ 2,
+ pbuffer + 12);
+ *(pbuffer + 14) =
+ pdata->gph__range_config__valid_phase_low;
+ *(pbuffer + 15) =
+ pdata->gph__range_config__valid_phase_high;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+#endif
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_i2c_decode_gph_timing_config(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_gph_timing_config_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_gph_timing_config_t from the input I2C read buffer
+ * Buffer must be at least 16 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_GPH_TIMING_CONFIG_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->gph__mm_config__timeout_macrop_a_hi =
+ (*(pbuffer + 0)) & 0xF;
+ pdata->gph__mm_config__timeout_macrop_a_lo =
+ (*(pbuffer + 1));
+ pdata->gph__mm_config__timeout_macrop_b_hi =
+ (*(pbuffer + 2)) & 0xF;
+ pdata->gph__mm_config__timeout_macrop_b_lo =
+ (*(pbuffer + 3));
+ pdata->gph__range_config__timeout_macrop_a_hi =
+ (*(pbuffer + 4)) & 0xF;
+ pdata->gph__range_config__timeout_macrop_a_lo =
+ (*(pbuffer + 5));
+ pdata->gph__range_config__vcsel_period_a =
+ (*(pbuffer + 6)) & 0x3F;
+ pdata->gph__range_config__vcsel_period_b =
+ (*(pbuffer + 7)) & 0x3F;
+ pdata->gph__range_config__timeout_macrop_b_hi =
+ (*(pbuffer + 8)) & 0xF;
+ pdata->gph__range_config__timeout_macrop_b_lo =
+ (*(pbuffer + 9));
+ pdata->gph__range_config__sigma_thresh =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 10));
+ pdata->gph__range_config__min_count_rate_rtn_limit_mcps =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 12));
+ pdata->gph__range_config__valid_phase_low =
+ (*(pbuffer + 14));
+ pdata->gph__range_config__valid_phase_high =
+ (*(pbuffer + 15));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_set_gph_timing_config(
+ VL53L1_DEV Dev,
+ VL53L1_gph_timing_config_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_gph_timing_config_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_GPH_TIMING_CONFIG_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_gph_timing_config(
+ pdata,
+ VL53L1_GPH_TIMING_CONFIG_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_GPH__MM_CONFIG__TIMEOUT_MACROP_A_HI,
+ comms_buffer,
+ VL53L1_GPH_TIMING_CONFIG_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifdef PAL_EXTENDED
+VL53L1_Error VL53L1_get_gph_timing_config(
+ VL53L1_DEV Dev,
+ VL53L1_gph_timing_config_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_gph_timing_config_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_GPH_TIMING_CONFIG_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_GPH__MM_CONFIG__TIMEOUT_MACROP_A_HI,
+ comms_buffer,
+ VL53L1_GPH_TIMING_CONFIG_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_gph_timing_config(
+ VL53L1_GPH_TIMING_CONFIG_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
+
+
+#ifdef VL53L1_DEBUG
+VL53L1_Error VL53L1_i2c_encode_fw_internal(
+ VL53L1_fw_internal_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_fw_internal_t into a I2C write buffer
+ * Buffer must be at least 2 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_FW_INTERNAL_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ *(pbuffer + 0) =
+ pdata->firmware__internal_stream_count_div;
+ *(pbuffer + 1) =
+ pdata->firmware__internal_stream_counter_val;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_decode_fw_internal(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_fw_internal_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_fw_internal_t from the input I2C read buffer
+ * Buffer must be at least 2 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_FW_INTERNAL_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->firmware__internal_stream_count_div =
+ (*(pbuffer + 0));
+ pdata->firmware__internal_stream_counter_val =
+ (*(pbuffer + 1));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_fw_internal(
+ VL53L1_DEV Dev,
+ VL53L1_fw_internal_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_fw_internal_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_FW_INTERNAL_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_fw_internal(
+ pdata,
+ VL53L1_FW_INTERNAL_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_FIRMWARE__INTERNAL_STREAM_COUNT_DIV,
+ comms_buffer,
+ VL53L1_FW_INTERNAL_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+VL53L1_Error VL53L1_get_fw_internal(
+ VL53L1_DEV Dev,
+ VL53L1_fw_internal_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_fw_internal_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_FW_INTERNAL_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_FIRMWARE__INTERNAL_STREAM_COUNT_DIV,
+ comms_buffer,
+ VL53L1_FW_INTERNAL_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_fw_internal(
+ VL53L1_FW_INTERNAL_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_encode_patch_results(
+ VL53L1_patch_results_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_patch_results_t into a I2C write buffer
+ * Buffer must be at least 90 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_PATCH_RESULTS_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ *(pbuffer + 0) =
+ pdata->dss_calc__roi_ctrl & 0x3;
+ *(pbuffer + 1) =
+ pdata->dss_calc__spare_1;
+ *(pbuffer + 2) =
+ pdata->dss_calc__spare_2;
+ *(pbuffer + 3) =
+ pdata->dss_calc__spare_3;
+ *(pbuffer + 4) =
+ pdata->dss_calc__spare_4;
+ *(pbuffer + 5) =
+ pdata->dss_calc__spare_5;
+ *(pbuffer + 6) =
+ pdata->dss_calc__spare_6;
+ *(pbuffer + 7) =
+ pdata->dss_calc__spare_7;
+ *(pbuffer + 8) =
+ pdata->dss_calc__user_roi_spad_en_0;
+ *(pbuffer + 9) =
+ pdata->dss_calc__user_roi_spad_en_1;
+ *(pbuffer + 10) =
+ pdata->dss_calc__user_roi_spad_en_2;
+ *(pbuffer + 11) =
+ pdata->dss_calc__user_roi_spad_en_3;
+ *(pbuffer + 12) =
+ pdata->dss_calc__user_roi_spad_en_4;
+ *(pbuffer + 13) =
+ pdata->dss_calc__user_roi_spad_en_5;
+ *(pbuffer + 14) =
+ pdata->dss_calc__user_roi_spad_en_6;
+ *(pbuffer + 15) =
+ pdata->dss_calc__user_roi_spad_en_7;
+ *(pbuffer + 16) =
+ pdata->dss_calc__user_roi_spad_en_8;
+ *(pbuffer + 17) =
+ pdata->dss_calc__user_roi_spad_en_9;
+ *(pbuffer + 18) =
+ pdata->dss_calc__user_roi_spad_en_10;
+ *(pbuffer + 19) =
+ pdata->dss_calc__user_roi_spad_en_11;
+ *(pbuffer + 20) =
+ pdata->dss_calc__user_roi_spad_en_12;
+ *(pbuffer + 21) =
+ pdata->dss_calc__user_roi_spad_en_13;
+ *(pbuffer + 22) =
+ pdata->dss_calc__user_roi_spad_en_14;
+ *(pbuffer + 23) =
+ pdata->dss_calc__user_roi_spad_en_15;
+ *(pbuffer + 24) =
+ pdata->dss_calc__user_roi_spad_en_16;
+ *(pbuffer + 25) =
+ pdata->dss_calc__user_roi_spad_en_17;
+ *(pbuffer + 26) =
+ pdata->dss_calc__user_roi_spad_en_18;
+ *(pbuffer + 27) =
+ pdata->dss_calc__user_roi_spad_en_19;
+ *(pbuffer + 28) =
+ pdata->dss_calc__user_roi_spad_en_20;
+ *(pbuffer + 29) =
+ pdata->dss_calc__user_roi_spad_en_21;
+ *(pbuffer + 30) =
+ pdata->dss_calc__user_roi_spad_en_22;
+ *(pbuffer + 31) =
+ pdata->dss_calc__user_roi_spad_en_23;
+ *(pbuffer + 32) =
+ pdata->dss_calc__user_roi_spad_en_24;
+ *(pbuffer + 33) =
+ pdata->dss_calc__user_roi_spad_en_25;
+ *(pbuffer + 34) =
+ pdata->dss_calc__user_roi_spad_en_26;
+ *(pbuffer + 35) =
+ pdata->dss_calc__user_roi_spad_en_27;
+ *(pbuffer + 36) =
+ pdata->dss_calc__user_roi_spad_en_28;
+ *(pbuffer + 37) =
+ pdata->dss_calc__user_roi_spad_en_29;
+ *(pbuffer + 38) =
+ pdata->dss_calc__user_roi_spad_en_30;
+ *(pbuffer + 39) =
+ pdata->dss_calc__user_roi_spad_en_31;
+ *(pbuffer + 40) =
+ pdata->dss_calc__user_roi_0;
+ *(pbuffer + 41) =
+ pdata->dss_calc__user_roi_1;
+ *(pbuffer + 42) =
+ pdata->dss_calc__mode_roi_0;
+ *(pbuffer + 43) =
+ pdata->dss_calc__mode_roi_1;
+ *(pbuffer + 44) =
+ pdata->sigma_estimator_calc__spare_0;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->vhv_result__peak_signal_rate_mcps,
+ 2,
+ pbuffer + 46);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->vhv_result__signal_total_events_ref,
+ 4,
+ pbuffer + 48);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->phasecal_result__phase_output_ref,
+ 2,
+ pbuffer + 52);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->dss_result__total_rate_per_spad,
+ 2,
+ pbuffer + 54);
+ *(pbuffer + 56) =
+ pdata->dss_result__enabled_blocks;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->dss_result__num_requested_spads,
+ 2,
+ pbuffer + 58);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->mm_result__inner_intersection_rate,
+ 2,
+ pbuffer + 62);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->mm_result__outer_complement_rate,
+ 2,
+ pbuffer + 64);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->mm_result__total_offset,
+ 2,
+ pbuffer + 66);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->xtalk_calc__xtalk_for_enabled_spads & 0xFFFFFF,
+ 4,
+ pbuffer + 68);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->xtalk_result__avg_xtalk_user_roi_kcps & 0xFFFFFF,
+ 4,
+ pbuffer + 72);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->xtalk_result__avg_xtalk_mm_inner_roi_kcps & 0xFFFFFF,
+ 4,
+ pbuffer + 76);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->xtalk_result__avg_xtalk_mm_outer_roi_kcps & 0xFFFFFF,
+ 4,
+ pbuffer + 80);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->range_result__accum_phase,
+ 4,
+ pbuffer + 84);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->range_result__offset_corrected_range,
+ 2,
+ pbuffer + 88);
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_decode_patch_results(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_patch_results_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_patch_results_t from the input I2C read buffer
+ * Buffer must be at least 90 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_PATCH_RESULTS_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->dss_calc__roi_ctrl =
+ (*(pbuffer + 0)) & 0x3;
+ pdata->dss_calc__spare_1 =
+ (*(pbuffer + 1));
+ pdata->dss_calc__spare_2 =
+ (*(pbuffer + 2));
+ pdata->dss_calc__spare_3 =
+ (*(pbuffer + 3));
+ pdata->dss_calc__spare_4 =
+ (*(pbuffer + 4));
+ pdata->dss_calc__spare_5 =
+ (*(pbuffer + 5));
+ pdata->dss_calc__spare_6 =
+ (*(pbuffer + 6));
+ pdata->dss_calc__spare_7 =
+ (*(pbuffer + 7));
+ pdata->dss_calc__user_roi_spad_en_0 =
+ (*(pbuffer + 8));
+ pdata->dss_calc__user_roi_spad_en_1 =
+ (*(pbuffer + 9));
+ pdata->dss_calc__user_roi_spad_en_2 =
+ (*(pbuffer + 10));
+ pdata->dss_calc__user_roi_spad_en_3 =
+ (*(pbuffer + 11));
+ pdata->dss_calc__user_roi_spad_en_4 =
+ (*(pbuffer + 12));
+ pdata->dss_calc__user_roi_spad_en_5 =
+ (*(pbuffer + 13));
+ pdata->dss_calc__user_roi_spad_en_6 =
+ (*(pbuffer + 14));
+ pdata->dss_calc__user_roi_spad_en_7 =
+ (*(pbuffer + 15));
+ pdata->dss_calc__user_roi_spad_en_8 =
+ (*(pbuffer + 16));
+ pdata->dss_calc__user_roi_spad_en_9 =
+ (*(pbuffer + 17));
+ pdata->dss_calc__user_roi_spad_en_10 =
+ (*(pbuffer + 18));
+ pdata->dss_calc__user_roi_spad_en_11 =
+ (*(pbuffer + 19));
+ pdata->dss_calc__user_roi_spad_en_12 =
+ (*(pbuffer + 20));
+ pdata->dss_calc__user_roi_spad_en_13 =
+ (*(pbuffer + 21));
+ pdata->dss_calc__user_roi_spad_en_14 =
+ (*(pbuffer + 22));
+ pdata->dss_calc__user_roi_spad_en_15 =
+ (*(pbuffer + 23));
+ pdata->dss_calc__user_roi_spad_en_16 =
+ (*(pbuffer + 24));
+ pdata->dss_calc__user_roi_spad_en_17 =
+ (*(pbuffer + 25));
+ pdata->dss_calc__user_roi_spad_en_18 =
+ (*(pbuffer + 26));
+ pdata->dss_calc__user_roi_spad_en_19 =
+ (*(pbuffer + 27));
+ pdata->dss_calc__user_roi_spad_en_20 =
+ (*(pbuffer + 28));
+ pdata->dss_calc__user_roi_spad_en_21 =
+ (*(pbuffer + 29));
+ pdata->dss_calc__user_roi_spad_en_22 =
+ (*(pbuffer + 30));
+ pdata->dss_calc__user_roi_spad_en_23 =
+ (*(pbuffer + 31));
+ pdata->dss_calc__user_roi_spad_en_24 =
+ (*(pbuffer + 32));
+ pdata->dss_calc__user_roi_spad_en_25 =
+ (*(pbuffer + 33));
+ pdata->dss_calc__user_roi_spad_en_26 =
+ (*(pbuffer + 34));
+ pdata->dss_calc__user_roi_spad_en_27 =
+ (*(pbuffer + 35));
+ pdata->dss_calc__user_roi_spad_en_28 =
+ (*(pbuffer + 36));
+ pdata->dss_calc__user_roi_spad_en_29 =
+ (*(pbuffer + 37));
+ pdata->dss_calc__user_roi_spad_en_30 =
+ (*(pbuffer + 38));
+ pdata->dss_calc__user_roi_spad_en_31 =
+ (*(pbuffer + 39));
+ pdata->dss_calc__user_roi_0 =
+ (*(pbuffer + 40));
+ pdata->dss_calc__user_roi_1 =
+ (*(pbuffer + 41));
+ pdata->dss_calc__mode_roi_0 =
+ (*(pbuffer + 42));
+ pdata->dss_calc__mode_roi_1 =
+ (*(pbuffer + 43));
+ pdata->sigma_estimator_calc__spare_0 =
+ (*(pbuffer + 44));
+ pdata->vhv_result__peak_signal_rate_mcps =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 46));
+ pdata->vhv_result__signal_total_events_ref =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 48));
+ pdata->phasecal_result__phase_output_ref =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 52));
+ pdata->dss_result__total_rate_per_spad =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 54));
+ pdata->dss_result__enabled_blocks =
+ (*(pbuffer + 56));
+ pdata->dss_result__num_requested_spads =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 58));
+ pdata->mm_result__inner_intersection_rate =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 62));
+ pdata->mm_result__outer_complement_rate =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 64));
+ pdata->mm_result__total_offset =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 66));
+ pdata->xtalk_calc__xtalk_for_enabled_spads =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 68)) & 0xFFFFFF;
+ pdata->xtalk_result__avg_xtalk_user_roi_kcps =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 72)) & 0xFFFFFF;
+ pdata->xtalk_result__avg_xtalk_mm_inner_roi_kcps =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 76)) & 0xFFFFFF;
+ pdata->xtalk_result__avg_xtalk_mm_outer_roi_kcps =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 80)) & 0xFFFFFF;
+ pdata->range_result__accum_phase =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 84));
+ pdata->range_result__offset_corrected_range =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 88));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_patch_results(
+ VL53L1_DEV Dev,
+ VL53L1_patch_results_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_patch_results_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_PATCH_RESULTS_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_patch_results(
+ pdata,
+ VL53L1_PATCH_RESULTS_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_DSS_CALC__ROI_CTRL,
+ comms_buffer,
+ VL53L1_PATCH_RESULTS_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+VL53L1_Error VL53L1_get_patch_results(
+ VL53L1_DEV Dev,
+ VL53L1_patch_results_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_patch_results_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_PATCH_RESULTS_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_DSS_CALC__ROI_CTRL,
+ comms_buffer,
+ VL53L1_PATCH_RESULTS_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_patch_results(
+ VL53L1_PATCH_RESULTS_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_encode_shadow_system_results(
+ VL53L1_shadow_system_results_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_shadow_system_results_t into a I2C write buffer
+ * Buffer must be at least 82 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ *(pbuffer + 0) =
+ pdata->shadow_phasecal_result__vcsel_start;
+ *(pbuffer + 2) =
+ pdata->shadow_result__interrupt_status & 0x3F;
+ *(pbuffer + 3) =
+ pdata->shadow_result__range_status;
+ *(pbuffer + 4) =
+ pdata->shadow_result__report_status & 0xF;
+ *(pbuffer + 5) =
+ pdata->shadow_result__stream_count;
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__dss_actual_effective_spads_sd0,
+ 2,
+ pbuffer + 6);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__peak_signal_count_rate_mcps_sd0,
+ 2,
+ pbuffer + 8);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__ambient_count_rate_mcps_sd0,
+ 2,
+ pbuffer + 10);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__sigma_sd0,
+ 2,
+ pbuffer + 12);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__phase_sd0,
+ 2,
+ pbuffer + 14);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__final_crosstalk_corrected_range_mm_sd0,
+ 2,
+ pbuffer + 16);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0,
+ 2,
+ pbuffer + 18);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__mm_inner_actual_effective_spads_sd0,
+ 2,
+ pbuffer + 20);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__mm_outer_actual_effective_spads_sd0,
+ 2,
+ pbuffer + 22);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__avg_signal_count_rate_mcps_sd0,
+ 2,
+ pbuffer + 24);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__dss_actual_effective_spads_sd1,
+ 2,
+ pbuffer + 26);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__peak_signal_count_rate_mcps_sd1,
+ 2,
+ pbuffer + 28);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__ambient_count_rate_mcps_sd1,
+ 2,
+ pbuffer + 30);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__sigma_sd1,
+ 2,
+ pbuffer + 32);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__phase_sd1,
+ 2,
+ pbuffer + 34);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__final_crosstalk_corrected_range_mm_sd1,
+ 2,
+ pbuffer + 36);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__spare_0_sd1,
+ 2,
+ pbuffer + 38);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__spare_1_sd1,
+ 2,
+ pbuffer + 40);
+ VL53L1_i2c_encode_uint16_t(
+ pdata->shadow_result__spare_2_sd1,
+ 2,
+ pbuffer + 42);
+ *(pbuffer + 44) =
+ pdata->shadow_result__spare_3_sd1;
+ *(pbuffer + 45) =
+ pdata->shadow_result__thresh_info;
+ *(pbuffer + 80) =
+ pdata->shadow_phasecal_result__reference_phase_hi;
+ *(pbuffer + 81) =
+ pdata->shadow_phasecal_result__reference_phase_lo;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_decode_shadow_system_results(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_shadow_system_results_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_shadow_system_results_t from the input I2C read buffer
+ * Buffer must be at least 82 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->shadow_phasecal_result__vcsel_start =
+ (*(pbuffer + 0));
+ pdata->shadow_result__interrupt_status =
+ (*(pbuffer + 2)) & 0x3F;
+ pdata->shadow_result__range_status =
+ (*(pbuffer + 3));
+ pdata->shadow_result__report_status =
+ (*(pbuffer + 4)) & 0xF;
+ pdata->shadow_result__stream_count =
+ (*(pbuffer + 5));
+ pdata->shadow_result__dss_actual_effective_spads_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 6));
+ pdata->shadow_result__peak_signal_count_rate_mcps_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 8));
+ pdata->shadow_result__ambient_count_rate_mcps_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 10));
+ pdata->shadow_result__sigma_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 12));
+ pdata->shadow_result__phase_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 14));
+ pdata->shadow_result__final_crosstalk_corrected_range_mm_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 16));
+ pdata->shadow_result__peak_signal_count_rate_crosstalk_corrected_mcps_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 18));
+ pdata->shadow_result__mm_inner_actual_effective_spads_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 20));
+ pdata->shadow_result__mm_outer_actual_effective_spads_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 22));
+ pdata->shadow_result__avg_signal_count_rate_mcps_sd0 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 24));
+ pdata->shadow_result__dss_actual_effective_spads_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 26));
+ pdata->shadow_result__peak_signal_count_rate_mcps_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 28));
+ pdata->shadow_result__ambient_count_rate_mcps_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 30));
+ pdata->shadow_result__sigma_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 32));
+ pdata->shadow_result__phase_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 34));
+ pdata->shadow_result__final_crosstalk_corrected_range_mm_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 36));
+ pdata->shadow_result__spare_0_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 38));
+ pdata->shadow_result__spare_1_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 40));
+ pdata->shadow_result__spare_2_sd1 =
+ (VL53L1_i2c_decode_uint16_t(2, pbuffer + 42));
+ pdata->shadow_result__spare_3_sd1 =
+ (*(pbuffer + 44));
+ pdata->shadow_result__thresh_info =
+ (*(pbuffer + 45));
+ pdata->shadow_phasecal_result__reference_phase_hi =
+ (*(pbuffer + 80));
+ pdata->shadow_phasecal_result__reference_phase_lo =
+ (*(pbuffer + 81));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_shadow_system_results(
+ VL53L1_DEV Dev,
+ VL53L1_shadow_system_results_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_shadow_system_results_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_shadow_system_results(
+ pdata,
+ VL53L1_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_SHADOW_PHASECAL_RESULT__VCSEL_START,
+ comms_buffer,
+ VL53L1_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+VL53L1_Error VL53L1_get_shadow_system_results(
+ VL53L1_DEV Dev,
+ VL53L1_shadow_system_results_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_shadow_system_results_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_SHADOW_PHASECAL_RESULT__VCSEL_START,
+ comms_buffer,
+ VL53L1_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_shadow_system_results(
+ VL53L1_SHADOW_SYSTEM_RESULTS_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_encode_shadow_core_results(
+ VL53L1_shadow_core_results_t *pdata,
+ uint16_t buf_size,
+ uint8_t *pbuffer)
+{
+ /**
+ * Encodes data structure VL53L1_shadow_core_results_t into a I2C write buffer
+ * Buffer must be at least 33 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ VL53L1_i2c_encode_uint32_t(
+ pdata->shadow_result_core__ambient_window_events_sd0,
+ 4,
+ pbuffer + 0);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->shadow_result_core__ranging_total_events_sd0,
+ 4,
+ pbuffer + 4);
+ VL53L1_i2c_encode_int32_t(
+ pdata->shadow_result_core__signal_total_events_sd0,
+ 4,
+ pbuffer + 8);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->shadow_result_core__total_periods_elapsed_sd0,
+ 4,
+ pbuffer + 12);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->shadow_result_core__ambient_window_events_sd1,
+ 4,
+ pbuffer + 16);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->shadow_result_core__ranging_total_events_sd1,
+ 4,
+ pbuffer + 20);
+ VL53L1_i2c_encode_int32_t(
+ pdata->shadow_result_core__signal_total_events_sd1,
+ 4,
+ pbuffer + 24);
+ VL53L1_i2c_encode_uint32_t(
+ pdata->shadow_result_core__total_periods_elapsed_sd1,
+ 4,
+ pbuffer + 28);
+ *(pbuffer + 32) =
+ pdata->shadow_result_core__spare_0;
+ LOG_FUNCTION_END(status);
+
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_i2c_decode_shadow_core_results(
+ uint16_t buf_size,
+ uint8_t *pbuffer,
+ VL53L1_shadow_core_results_t *pdata)
+{
+ /**
+ * Decodes data structure VL53L1_shadow_core_results_t from the input I2C read buffer
+ * Buffer must be at least 33 bytes
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ if (VL53L1_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES > buf_size)
+ return VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL;
+
+ pdata->shadow_result_core__ambient_window_events_sd0 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 0));
+ pdata->shadow_result_core__ranging_total_events_sd0 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 4));
+ pdata->shadow_result_core__signal_total_events_sd0 =
+ (VL53L1_i2c_decode_int32_t(4, pbuffer + 8));
+ pdata->shadow_result_core__total_periods_elapsed_sd0 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 12));
+ pdata->shadow_result_core__ambient_window_events_sd1 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 16));
+ pdata->shadow_result_core__ranging_total_events_sd1 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 20));
+ pdata->shadow_result_core__signal_total_events_sd1 =
+ (VL53L1_i2c_decode_int32_t(4, pbuffer + 24));
+ pdata->shadow_result_core__total_periods_elapsed_sd1 =
+ (VL53L1_i2c_decode_uint32_t(4, pbuffer + 28));
+ pdata->shadow_result_core__spare_0 =
+ (*(pbuffer + 32));
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_set_shadow_core_results(
+ VL53L1_DEV Dev,
+ VL53L1_shadow_core_results_t *pdata)
+{
+ /**
+ * Serialises and sends the contents of VL53L1_shadow_core_results_t
+ * data structure to the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_i2c_encode_shadow_core_results(
+ pdata,
+ VL53L1_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES,
+ comms_buffer);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_WriteMulti(
+ Dev,
+ VL53L1_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0,
+ comms_buffer,
+ VL53L1_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_get_shadow_core_results(
+ VL53L1_DEV Dev,
+ VL53L1_shadow_core_results_t *pdata)
+{
+ /**
+ * Reads and de-serialises the contents of VL53L1_shadow_core_results_t
+ * data structure from the device
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t comms_buffer[VL53L1_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES];
+
+ LOG_FUNCTION_START("");
+
+ if (status == VL53L1_ERROR_NONE) /*lint !e774 always true*/
+ status = VL53L1_disable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_SHADOW_RESULT_CORE__AMBIENT_WINDOW_EVENTS_SD0,
+ comms_buffer,
+ VL53L1_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_enable_firmware(Dev);
+
+ if (status == VL53L1_ERROR_NONE)
+ status = VL53L1_i2c_decode_shadow_core_results(
+ VL53L1_SHADOW_CORE_RESULTS_I2C_SIZE_BYTES,
+ comms_buffer,
+ pdata);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+#endif
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_silicon_core.c b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_silicon_core.c
new file mode 100644
index 0000000..9c72cb1
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_silicon_core.c
@@ -0,0 +1,146 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_silicon_core.c
+ *
+ * @brief EwokPlus25 low level silicon LL Driver function definition
+ */
+
+
+#include "vl53l1_ll_def.h"
+#include "vl53l1_platform.h"
+#include "vl53l1_register_map.h"
+#include "vl53l1_core.h"
+#include "vl53l1_silicon_core.h"
+
+
+#define LOG_FUNCTION_START(fmt, ...) \
+ _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
+#define LOG_FUNCTION_END(status, ...) \
+ _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
+#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
+ _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE, status, fmt, ##__VA_ARGS__)
+
+
+VL53L1_Error VL53L1_is_firmware_ready_silicon(
+ VL53L1_DEV Dev,
+ uint8_t *pready)
+{
+ /**
+ * Determines if the firmware is ready to range
+ *
+ * There are 2 different behaviors depending on whether
+ * power force is enabled or not
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint8_t comms_buffer[5];
+
+ LOG_FUNCTION_START("");
+
+ /* read interrupt and power force reset status */
+
+ status = VL53L1_ReadMulti(
+ Dev,
+ VL53L1_INTERRUPT_MANAGER__ENABLES,
+ comms_buffer,
+ 5);
+
+ if (status == VL53L1_ERROR_NONE) {
+
+ pdev->dbg_results.interrupt_manager__enables =
+ comms_buffer[0];
+ pdev->dbg_results.interrupt_manager__clear =
+ comms_buffer[1];
+ pdev->dbg_results.interrupt_manager__status =
+ comms_buffer[2];
+ pdev->dbg_results.mcu_to_host_bank__wr_access_en =
+ comms_buffer[3];
+ pdev->dbg_results.power_management__go1_reset_status =
+ comms_buffer[4];
+
+ if ((pdev->sys_ctrl.power_management__go1_power_force & 0x01) == 0x01) {
+
+ if (((pdev->dbg_results.interrupt_manager__enables & 0x1F) == 0x1F) &&
+ ((pdev->dbg_results.interrupt_manager__clear & 0x1F) == 0x1F))
+ *pready = 0x01;
+ else
+ *pready = 0x00;
+
+ } else {
+
+ /* set ready flag if bit 0 is zero i.g G01 is in reset */
+ if ((pdev->dbg_results.power_management__go1_reset_status & 0x01) == 0x00)
+ *pready = 0x01;
+ else
+ *pready = 0x00;
+ }
+
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_wait.c b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_wait.c
new file mode 100644
index 0000000..d1c29e9
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/core/src/vl53l1_wait.c
@@ -0,0 +1,558 @@
+/*
+* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
+*
+* This file is part of VL53L1 Core and is dual licensed,
+* either 'STMicroelectronics
+* Proprietary license'
+* or 'BSD 3-clause "New" or "Revised" License' , at your option.
+*
+********************************************************************************
+*
+* 'STMicroelectronics Proprietary license'
+*
+********************************************************************************
+*
+* License terms: STMicroelectronics Proprietary in accordance with licensing
+* terms at www.st.com/sla0081
+*
+* STMicroelectronics confidential
+* Reproduction and Communication of this document is strictly prohibited unless
+* specifically authorized in writing by STMicroelectronics.
+*
+*
+********************************************************************************
+*
+* Alternatively, VL53L1 Core may be distributed under the terms of
+* 'BSD 3-clause "New" or "Revised" License', in which case the following
+* provisions apply instead of the ones mentioned above :
+*
+********************************************************************************
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*
+********************************************************************************
+*
+*/
+
+/**
+ * @file vl53l1_wait.c
+ *
+ * @brief EwokPlus25 low level Driver wait function definition
+ */
+
+
+#include "vl53l1_ll_def.h"
+#include "vl53l1_ll_device.h"
+#include "vl53l1_platform.h"
+#include "vl53l1_core.h"
+#include "vl53l1_silicon_core.h"
+#include "vl53l1_wait.h"
+#include "vl53l1_register_settings.h"
+
+
+#define LOG_FUNCTION_START(fmt, ...) \
+ _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
+#define LOG_FUNCTION_END(status, ...) \
+ _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
+#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
+ _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE, status, \
+ fmt, ##__VA_ARGS__)
+
+
+VL53L1_Error VL53L1_wait_for_boot_completion(
+ VL53L1_DEV Dev)
+{
+
+ /* Waits for firmware boot to finish
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint8_t fw_ready = 0;
+
+ LOG_FUNCTION_START("");
+
+ if (pdev->wait_method == VL53L1_WAIT_METHOD_BLOCKING) {
+
+ /* blocking version */
+
+ status =
+ VL53L1_poll_for_boot_completion(
+ Dev,
+ VL53L1_BOOT_COMPLETION_POLLING_TIMEOUT_MS);
+
+ } else {
+
+ /* implement non blocking version below */
+
+ fw_ready = 0;
+ while (fw_ready == 0x00 && status == VL53L1_ERROR_NONE) {
+ status = VL53L1_is_boot_complete(
+ Dev,
+ &fw_ready);
+
+ if (status == VL53L1_ERROR_NONE) {
+ status = VL53L1_WaitMs(
+ Dev,
+ VL53L1_POLLING_DELAY_MS);
+ }
+ }
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+
+}
+
+
+VL53L1_Error VL53L1_wait_for_firmware_ready(
+ VL53L1_DEV Dev)
+{
+
+ /* If in timed mode or single shot then check firmware is ready
+ * before sending handshake
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint8_t fw_ready = 0;
+ uint8_t mode_start = 0;
+
+ LOG_FUNCTION_START("");
+
+ /* Filter out tje measure mode part of the mode
+ * start register
+ */
+ mode_start =
+ pdev->sys_ctrl.system__mode_start &
+ VL53L1_DEVICEMEASUREMENTMODE_MODE_MASK;
+
+ /*
+ * conditional wait for firmware ready
+ * only waits for timed and single shot modes
+ */
+
+ if ((mode_start == VL53L1_DEVICEMEASUREMENTMODE_TIMED) ||
+ (mode_start == VL53L1_DEVICEMEASUREMENTMODE_SINGLESHOT)) {
+
+ if (pdev->wait_method == VL53L1_WAIT_METHOD_BLOCKING) {
+
+ /* blocking version */
+
+ status =
+ VL53L1_poll_for_firmware_ready(
+ Dev,
+ VL53L1_RANGE_COMPLETION_POLLING_TIMEOUT_MS);
+
+ } else {
+
+ /* implement non blocking version below */
+
+ fw_ready = 0;
+ while (fw_ready == 0x00 && status == VL53L1_ERROR_NONE) {
+ status = VL53L1_is_firmware_ready(
+ Dev,
+ &fw_ready);
+
+ if (status == VL53L1_ERROR_NONE) {
+ status = VL53L1_WaitMs(
+ Dev,
+ VL53L1_POLLING_DELAY_MS);
+ }
+ }
+ }
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_wait_for_range_completion(
+ VL53L1_DEV Dev)
+{
+
+ /* Wrapper function for waiting for range completion
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint8_t data_ready = 0;
+
+ LOG_FUNCTION_START("");
+
+ if (pdev->wait_method == VL53L1_WAIT_METHOD_BLOCKING) {
+
+ /* blocking version */
+
+ status =
+ VL53L1_poll_for_range_completion(
+ Dev,
+ VL53L1_RANGE_COMPLETION_POLLING_TIMEOUT_MS);
+
+ } else {
+
+ /* implement non blocking version below */
+
+ data_ready = 0;
+ while (data_ready == 0x00 && status == VL53L1_ERROR_NONE) {
+ status = VL53L1_is_new_data_ready(
+ Dev,
+ &data_ready);
+
+ if (status == VL53L1_ERROR_NONE) {
+ status = VL53L1_WaitMs(
+ Dev,
+ VL53L1_POLLING_DELAY_MS);
+ }
+ }
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_wait_for_test_completion(
+ VL53L1_DEV Dev)
+{
+
+ /* Wrapper function for waiting for test mode completion
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint8_t data_ready = 0;
+
+ LOG_FUNCTION_START("");
+
+ if (pdev->wait_method == VL53L1_WAIT_METHOD_BLOCKING) {
+
+ /* blocking version */
+
+ status =
+ VL53L1_poll_for_range_completion(
+ Dev,
+ VL53L1_TEST_COMPLETION_POLLING_TIMEOUT_MS);
+
+ } else {
+
+ /* implement non blocking version below */
+
+ data_ready = 0;
+ while (data_ready == 0x00 && status == VL53L1_ERROR_NONE) {
+ status = VL53L1_is_new_data_ready(
+ Dev,
+ &data_ready);
+
+ if (status == VL53L1_ERROR_NONE) {
+ status = VL53L1_WaitMs(
+ Dev,
+ VL53L1_POLLING_DELAY_MS);
+ }
+ }
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+
+
+VL53L1_Error VL53L1_is_boot_complete(
+ VL53L1_DEV Dev,
+ uint8_t *pready)
+{
+ /**
+ * Determines if the firmware finished booting by reading
+ * bit 0 of firmware__system_status register
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t firmware__system_status = 0;
+
+ LOG_FUNCTION_START("");
+
+ /* read current range interrupt state */
+
+ status =
+ VL53L1_RdByte(
+ Dev,
+ VL53L1_FIRMWARE__SYSTEM_STATUS,
+ &firmware__system_status);
+
+ /* set *pready = 1 if new range data ready complete
+ * zero otherwise
+ */
+
+ if ((firmware__system_status & 0x01) == 0x01) {
+ *pready = 0x01;
+ VL53L1_init_ll_driver_state(
+ Dev,
+ VL53L1_DEVICESTATE_SW_STANDBY);
+ } else {
+ *pready = 0x00;
+ VL53L1_init_ll_driver_state(
+ Dev,
+ VL53L1_DEVICESTATE_FW_COLDBOOT);
+ }
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_is_firmware_ready(
+ VL53L1_DEV Dev,
+ uint8_t *pready)
+{
+ /**
+ * Determines if the firmware is ready to range
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ LOG_FUNCTION_START("");
+
+ status = VL53L1_is_firmware_ready_silicon(
+ Dev,
+ pready);
+
+ pdev->fw_ready = *pready;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_is_new_data_ready(
+ VL53L1_DEV Dev,
+ uint8_t *pready)
+{
+ /**
+ * Determines if new range data is ready by reading bit 0 of
+ * VL53L1_GPIO__TIO_HV_STATUS to determine the current state
+ * of output interrupt pin
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint8_t gpio__mux_active_high_hv = 0;
+ uint8_t gpio__tio_hv_status = 0;
+ uint8_t interrupt_ready = 0;
+
+ LOG_FUNCTION_START("");
+
+ gpio__mux_active_high_hv =
+ pdev->stat_cfg.gpio_hv_mux__ctrl &
+ VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_MASK;
+
+ if (gpio__mux_active_high_hv == VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_HIGH)
+ interrupt_ready = 0x01;
+ else
+ interrupt_ready = 0x00;
+
+ /* read current range interrupt state */
+
+ status = VL53L1_RdByte(
+ Dev,
+ VL53L1_GPIO__TIO_HV_STATUS,
+ &gpio__tio_hv_status);
+
+ /* set *pready = 1 if new range data ready complete zero otherwise */
+
+ if ((gpio__tio_hv_status & 0x01) == interrupt_ready)
+ *pready = 0x01;
+ else
+ *pready = 0x00;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+
+
+VL53L1_Error VL53L1_poll_for_boot_completion(
+ VL53L1_DEV Dev,
+ uint32_t timeout_ms)
+{
+ /**
+ * Polls the bit 0 of the FIRMWARE__SYSTEM_STATUS register to see if
+ * the firmware is ready.
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ LOG_FUNCTION_START("");
+
+ /* after reset for the firmware blocks I2C access while
+ * it copies the NVM data into the G02 host register banks
+ * The host must wait the required time to allow the copy
+ * to complete before attempting to read the firmware status
+ */
+
+ status = VL53L1_WaitUs(
+ Dev,
+ VL53L1_FIRMWARE_BOOT_TIME_US);
+
+ if (status == VL53L1_ERROR_NONE)
+ status =
+ VL53L1_WaitValueMaskEx(
+ Dev,
+ timeout_ms,
+ VL53L1_FIRMWARE__SYSTEM_STATUS,
+ 0x01,
+ 0x01,
+ VL53L1_POLLING_DELAY_MS);
+
+ if (status == VL53L1_ERROR_NONE)
+ VL53L1_init_ll_driver_state(Dev, VL53L1_DEVICESTATE_SW_STANDBY);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_poll_for_firmware_ready(
+ VL53L1_DEV Dev,
+ uint32_t timeout_ms)
+{
+ /**
+ * Polls the bit 0 of the FIRMWARE__SYSTEM_STATUS register to see if
+ * the firmware is ready.
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint32_t start_time_ms = 0;
+ uint32_t current_time_ms = 0;
+ int32_t poll_delay_ms = VL53L1_POLLING_DELAY_MS;
+ uint8_t fw_ready = 0;
+
+ /* calculate time limit in absolute time */
+
+ VL53L1_GetTickCount(&start_time_ms); /*lint !e534 ignoring return*/
+ pdev->fw_ready_poll_duration_ms = 0;
+
+ /* wait until firmware is ready, timeout reached on error occurred */
+
+ while ((status == VL53L1_ERROR_NONE) &&
+ (pdev->fw_ready_poll_duration_ms < timeout_ms) &&
+ (fw_ready == 0)) {
+
+ status = VL53L1_is_firmware_ready(
+ Dev,
+ &fw_ready);
+
+ if (status == VL53L1_ERROR_NONE &&
+ fw_ready == 0 &&
+ poll_delay_ms > 0) {
+ status = VL53L1_WaitMs(
+ Dev,
+ poll_delay_ms);
+ }
+
+ /*
+ * Update polling time (Compare difference rather than
+ * absolute to negate 32bit wrap around issue)
+ */
+ VL53L1_GetTickCount(&current_time_ms); /*lint !e534 ignoring return*/
+ pdev->fw_ready_poll_duration_ms =
+ current_time_ms - start_time_ms;
+ }
+
+ if (fw_ready == 0 && status == VL53L1_ERROR_NONE)
+ status = VL53L1_ERROR_TIME_OUT;
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_poll_for_range_completion(
+ VL53L1_DEV Dev,
+ uint32_t timeout_ms)
+{
+ /**
+ * Polls bit 0 of VL53L1_GPIO__TIO_HV_STATUS to determine
+ * the state of output interrupt pin
+ *
+ * Interrupt may be either active high or active low. Use active_high to
+ * select the required level check
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
+
+ uint8_t gpio__mux_active_high_hv = 0;
+ uint8_t interrupt_ready = 0;
+
+ LOG_FUNCTION_START("");
+
+ gpio__mux_active_high_hv =
+ pdev->stat_cfg.gpio_hv_mux__ctrl &
+ VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_MASK;
+
+ if (gpio__mux_active_high_hv == VL53L1_DEVICEINTERRUPTLEVEL_ACTIVE_HIGH)
+ interrupt_ready = 0x01;
+ else
+ interrupt_ready = 0x00;
+
+ status =
+ VL53L1_WaitValueMaskEx(
+ Dev,
+ timeout_ms,
+ VL53L1_GPIO__TIO_HV_STATUS,
+ interrupt_ready,
+ 0x01,
+ VL53L1_POLLING_DELAY_MS);
+
+ LOG_FUNCTION_END(status);
+
+ return status;
+}
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_platform.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_platform.h
new file mode 100644
index 0000000..96fe884
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_platform.h
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ Copyright (C) 2016, STMicroelectronics International N.V.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of STMicroelectronics nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
+ NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
+ IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ******************************************************************************/
+
+
+#ifndef _VL53L1_PLATFORM_H_
+#define _VL53L1_PLATFORM_H_
+
+#include "vl53l1x.h"
+#include "vl53l1_platform_log.h"
+
+#endif
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_platform_log.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_platform_log.h
new file mode 100644
index 0000000..5bff5bd
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_platform_log.h
@@ -0,0 +1,223 @@
+/*******************************************************************************
+Copyright (C) 2015, STMicroelectronics International N.V.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of STMicroelectronics nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
+NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
+IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+********************************************************************************/
+
+/**
+ * @file vl53l1_platform_log.h
+ *
+ * @brief EwokPlus25 platform logging function definition
+ */
+
+
+#ifndef _VL53L1_PLATFORM_LOG_H_
+#define _VL53L1_PLATFORM_LOG_H_
+
+
+#ifdef VL53L1_LOG_ENABLE
+ #include "vl53l1_platform_user_config.h"
+
+ #ifdef _MSC_VER
+ # define EWOKPLUS_EXPORTS __declspec(dllexport)
+ #else
+ # define EWOKPLUS_EXPORTS
+ #endif
+
+ #include "vl53l1_types.h"
+
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
+ #include <time.h>
+
+ /**
+ * @brief Set the level, output and specific functions for module logging.
+ *
+ *
+ * @param filename - full path of output log file, NULL for print to stdout
+ *
+ * @param modules - Module or None or All to trace
+ * VL53L1_TRACE_MODULE_NONE
+ * VL53L1_TRACE_MODULE_API
+ * VL53L1_TRACE_MODULE_CORE
+ * VL53L1_TRACE_MODULE_TUNING
+ * VL53L1_TRACE_MODULE_CHARACTERISATION
+ * VL53L1_TRACE_MODULE_PLATFORM
+ * VL53L1_TRACE_MODULE_ALL
+ *
+ * @param level - trace level
+ * VL53L1_TRACE_LEVEL_NONE
+ * VL53L1_TRACE_LEVEL_ERRORS
+ * VL53L1_TRACE_LEVEL_WARNING
+ * VL53L1_TRACE_LEVEL_INFO
+ * VL53L1_TRACE_LEVEL_DEBUG
+ * VL53L1_TRACE_LEVEL_ALL
+ * VL53L1_TRACE_LEVEL_IGNORE
+ *
+ * @param functions - function level to trace;
+ * VL53L1_TRACE_FUNCTION_NONE
+ * VL53L1_TRACE_FUNCTION_I2C
+ * VL53L1_TRACE_FUNCTION_ALL
+ *
+ * @return status - always VL53L1_ERROR_NONE
+ *
+ */
+
+ #define VL53L1_TRACE_LEVEL_NONE 0x00000000
+ #define VL53L1_TRACE_LEVEL_ERRORS 0x00000001
+ #define VL53L1_TRACE_LEVEL_WARNING 0x00000002
+ #define VL53L1_TRACE_LEVEL_INFO 0x00000004
+ #define VL53L1_TRACE_LEVEL_DEBUG 0x00000008
+ #define VL53L1_TRACE_LEVEL_ALL 0x00000010
+ #define VL53L1_TRACE_LEVEL_IGNORE 0x00000020
+
+ #define VL53L1_TRACE_FUNCTION_NONE 0x00000000
+ #define VL53L1_TRACE_FUNCTION_I2C 0x00000001
+ #define VL53L1_TRACE_FUNCTION_ALL 0x7fffffff
+
+ #define VL53L1_TRACE_MODULE_NONE 0x00000000
+ #define VL53L1_TRACE_MODULE_API 0x00000001
+ #define VL53L1_TRACE_MODULE_CORE 0x00000002
+ #define VL53L1_TRACE_MODULE_PROTECTED 0x00000004
+ #define VL53L1_TRACE_MODULE_HISTOGRAM 0x00000008
+ #define VL53L1_TRACE_MODULE_REGISTERS 0x00000010
+ #define VL53L1_TRACE_MODULE_PLATFORM 0x00000020
+ #define VL53L1_TRACE_MODULE_NVM 0x00000040
+ #define VL53L1_TRACE_MODULE_CALIBRATION_DATA 0x00000080
+ #define VL53L1_TRACE_MODULE_NVM_DATA 0x00000100
+ #define VL53L1_TRACE_MODULE_HISTOGRAM_DATA 0x00000200
+ #define VL53L1_TRACE_MODULE_RANGE_RESULTS_DATA 0x00000400
+ #define VL53L1_TRACE_MODULE_XTALK_DATA 0x00000800
+ #define VL53L1_TRACE_MODULE_OFFSET_DATA 0x00001000
+ #define VL53L1_TRACE_MODULE_DATA_INIT 0x00002000
+ #define VL53L1_TRACE_MODULE_REF_SPAD_CHAR 0x00004000
+ #define VL53L1_TRACE_MODULE_SPAD_RATE_MAP 0x00008000
+ #ifdef PAL_EXTENDED
+ #define VL53L1_TRACE_MODULE_SPAD 0x01000000
+ #define VL53L1_TRACE_MODULE_FMT 0x02000000
+ #define VL53L1_TRACE_MODULE_UTILS 0x04000000
+ #define VL53L1_TRACE_MODULE_BENCH_FUNCS 0x08000000
+ #endif
+ #define VL53L1_TRACE_MODULE_CUSTOMER_API 0x40000000
+ #define VL53L1_TRACE_MODULE_ALL 0x7fffffff
+
+
+ extern uint32_t _trace_level;
+
+ /*
+ * NOTE: dynamically exported if we enable logging.
+ * this way, Python interfaces can access this function, but we don't
+ * need to include it in the .def files.
+ */
+ EWOKPLUS_EXPORTS int8_t VL53L1_trace_config(
+ char *filename,
+ uint32_t modules,
+ uint32_t level,
+ uint32_t functions);
+
+ /**
+ * @brief Print trace module function.
+ *
+ * @param module - ??
+ * @param level - ??
+ * @param function - ??
+ * @param format - ??
+ *
+ */
+
+ EWOKPLUS_EXPORTS void VL53L1_trace_print_module_function(
+ uint32_t module,
+ uint32_t level,
+ uint32_t function,
+ const char *format, ...);
+
+ /**
+ * @brief Get global _trace_functions parameter
+ *
+ * @return _trace_functions
+ */
+
+ uint32_t VL53L1_get_trace_functions(void);
+
+ /**
+ * @brief Set global _trace_functions parameter
+ *
+ * @param[in] function : new function code
+ */
+
+ void VL53L1_set_trace_functions(uint32_t function);
+
+
+ /*
+ * @brief Returns the current system tick count in [ms]
+ *
+ * @return time_ms : current time in [ms]
+ *
+ */
+
+ uint32_t VL53L1_clock(void);
+
+ #define LOG_GET_TIME() \
+ ((int)VL53L1_clock())
+
+ #define _LOG_TRACE_PRINT(module, level, function, ...) \
+ VL53L1_trace_print_module_function(module, level, function, ##__VA_ARGS__);
+
+ #define _LOG_FUNCTION_START(module, fmt, ...) \
+ VL53L1_trace_print_module_function(module, _trace_level, VL53L1_TRACE_FUNCTION_ALL, "%6ld <START> %s "fmt"\n", LOG_GET_TIME(), __FUNCTION__, ##__VA_ARGS__);
+
+ #define _LOG_FUNCTION_END(module, status, ...)\
+ VL53L1_trace_print_module_function(module, _trace_level, VL53L1_TRACE_FUNCTION_ALL, "%6ld <END> %s %d\n", LOG_GET_TIME(), __FUNCTION__, (int)status, ##__VA_ARGS__)
+
+ #define _LOG_FUNCTION_END_FMT(module, status, fmt, ...)\
+ VL53L1_trace_print_module_function(module, _trace_level, VL53L1_TRACE_FUNCTION_ALL, "%6ld <END> %s %d "fmt"\n", LOG_GET_TIME(), __FUNCTION__, (int)status, ##__VA_ARGS__)
+
+ #define _LOG_GET_TRACE_FUNCTIONS()\
+ VL53L1_get_trace_functions()
+
+ #define _LOG_SET_TRACE_FUNCTIONS(functions)\
+ VL53L1_set_trace_functions(functions)
+
+ #define _LOG_STRING_BUFFER(x) char x[VL53L1_MAX_STRING_LENGTH]
+
+ #ifdef __cplusplus
+ }
+ #endif
+
+#else /* VL53L1_LOG_ENABLE - no logging */
+
+ #define _LOG_TRACE_PRINT(module, level, function, ...)
+ #define _LOG_FUNCTION_START(module, fmt, ...)
+ #define _LOG_FUNCTION_END(module, status, ...)
+ #define _LOG_FUNCTION_END_FMT(module, status, fmt, ...)
+ #define _LOG_GET_TRACE_FUNCTIONS() 0
+ #define _LOG_SET_TRACE_FUNCTIONS(functions)
+ #define _LOG_STRING_BUFFER(x)
+
+#endif /* VL53L1_LOG_ENABLE */
+
+#endif /* _VL53L1_PLATFORM_LOG_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_platform_user_config.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_platform_user_config.h
new file mode 100644
index 0000000..166a023
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_platform_user_config.h
@@ -0,0 +1,84 @@
+/*******************************************************************************
+Copyright (C) 2015, STMicroelectronics International N.V.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of STMicroelectronics nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
+NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
+IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+********************************************************************************/
+
+/**
+ * @file vl53l1_platform_user_config.h
+ *
+ * @brief EwokPlus compile time user modifiable configuration
+ */
+
+
+#ifndef _VL53L1_PLATFORM_USER_CONFIG_H_
+#define _VL53L1_PLATFORM_USER_CONFIG_H_
+
+#define VL53L1_BYTES_PER_WORD 2
+#define VL53L1_BYTES_PER_DWORD 4
+
+/* Define polling delays */
+#define VL53L1_BOOT_COMPLETION_POLLING_TIMEOUT_MS 500
+#define VL53L1_RANGE_COMPLETION_POLLING_TIMEOUT_MS 2000
+#define VL53L1_TEST_COMPLETION_POLLING_TIMEOUT_MS 60000
+
+#define VL53L1_POLLING_DELAY_MS 1
+
+/* Define LLD TuningParms Page Base Address
+ * - Part of Patch_AddedTuningParms_11761
+ */
+#define VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS 0x8000
+#define VL53L1_TUNINGPARM_PRIVATE_PAGE_BASE_ADDRESS 0xC000
+
+#define VL53L1_GAIN_FACTOR__STANDARD_DEFAULT 0x0800
+ /*!< Default standard ranging gain correction factor
+ 1.11 format. 1.0 = 0x0800, 0.980 = 0x07D7 */
+
+#define VL53L1_OFFSET_CAL_MIN_EFFECTIVE_SPADS 0x0500
+ /*!< Lower Limit for the MM1 effective SPAD count during offset
+ calibration Format 8.8 0x0500 -> 5.0 effective SPADs */
+
+#define VL53L1_OFFSET_CAL_MAX_PRE_PEAK_RATE_MCPS 0x1900
+ /*!< Max Limit for the pre range peak rate during offset
+ calibration Format 9.7 0x1900 -> 50.0 Mcps.
+ If larger then in pile up */
+
+#define VL53L1_OFFSET_CAL_MAX_SIGMA_MM 0x0040
+ /*!< Max sigma estimate limit during offset calibration
+ Check applies to pre-range, mm1 and mm2 ranges
+ Format 14.2 0x0040 -> 16.0mm. */
+
+#define VL53L1_MAX_USER_ZONES 169
+ /*!< Max number of user Zones - maximal limitation from
+ FW stream divide - value of 254 */
+
+#define VL53L1_MAX_RANGE_RESULTS 2
+ /*!< Allocates storage for return and reference restults */
+
+
+#define VL53L1_MAX_STRING_LENGTH 512
+
+#endif /* _VL53L1_PLATFORM_USER_CONFIG_H_ */
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_platform_user_data.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_platform_user_data.h
new file mode 100644
index 0000000..30db13b
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_platform_user_data.h
@@ -0,0 +1,70 @@
+
+/*
+* This file is part of VL53L1 Platform
+*
+* Copyright (c) 2016, STMicroelectronics - All Rights Reserved
+*
+* License terms: BSD 3-clause "New" or "Revised" License.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+* 1. Redistributions of source code must retain the above copyright notice, this
+* list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and/or other materials provided with the distribution.
+*
+* 3. Neither the name of the copyright holder nor the names of its contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+* SERVICES; LOSS OF USE, DATA, OR PROFIT S; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+#ifndef _VL53L1_PLATFORM_USER_DATA_H_
+#define _VL53L1_PLATFORM_USER_DATA_H_
+
+#include "vl53l1_def.h"
+#include "i2cdev.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef struct {
+
+ VL53L1_DevData_t Data;
+
+ uint8_t I2cDevAddr;
+ uint8_t comms_type;
+ uint16_t comms_speed_khz;
+ uint32_t new_data_ready_poll_duration_ms;
+ I2C_Dev *I2Cx;
+
+ // I2C_HandleTypeDef *I2cHandle;
+
+} VL53L1_Dev_t;
+
+typedef VL53L1_Dev_t *VL53L1_DEV;
+
+#define VL53L1DevDataGet(Dev, field) (Dev->Data.field)
+#define VL53L1DevDataSet(Dev, field, VL53L1_PRM_00005) ((Dev->Data.field) = (VL53L1_PRM_00005))
+#define VL53L1DevStructGetLLDriverHandle(Dev) (&Dev->Data.LLData)
+#define VL53L1DevStructGetLLResultsHandle(Dev) (&Dev->Data.llresults)
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_platform_user_defines.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_platform_user_defines.h
new file mode 100644
index 0000000..04ad850
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_platform_user_defines.h
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ Copyright (C) 2016, STMicroelectronics International N.V.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of STMicroelectronics nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
+ NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
+ IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ******************************************************************************/
+
+
+#ifndef _VL53L1_PLATFORM_USER_DEFINES_H_
+#define _VL53L1_PLATFORM_USER_DEFINES_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @file vl53l1_platform_user_defines.h
+ *
+ * @brief All end user OS/platform/application definitions
+ */
+
+
+/**
+ * @def do_division_u
+ * @brief customer supplied division operation - 64-bit unsigned
+ *
+ * @param dividend unsigned 64-bit numerator
+ * @param divisor unsigned 64-bit denominator
+ */
+#define do_division_u(dividend, divisor) (dividend / divisor)
+
+
+/**
+ * @def do_division_s
+ * @brief customer supplied division operation - 64-bit signed
+ *
+ * @param dividend signed 64-bit numerator
+ * @param divisor signed 64-bit denominator
+ */
+#define do_division_s(dividend, divisor) (dividend / divisor)
+
+
+/**
+ * @def WARN_OVERRIDE_STATUS
+ * @brief customer supplied macro to optionally output info when a specific
+ error has been overridden with success within the EwokPlus driver
+ *
+ * @param __X__ the macro which enabled the suppression
+ */
+#define WARN_OVERRIDE_STATUS(__X__)\
+ trace_print (VL53L1_TRACE_LEVEL_WARNING, #__X__);
+
+
+#ifdef _MSC_VER
+#define DISABLE_WARNINGS() { \
+ __pragma (warning (push)); \
+ __pragma (warning (disable:4127)); \
+ }
+#define ENABLE_WARNINGS() { \
+ __pragma (warning (pop)); \
+ }
+#else
+ #define DISABLE_WARNINGS()
+ #define ENABLE_WARNINGS()
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _VL53L1_PLATFORM_USER_DEFINES_H_
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_types.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_types.h
new file mode 100644
index 0000000..c0603b7
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1_types.h
@@ -0,0 +1,114 @@
+/*******************************************************************************
+Copyright (C) 2015, STMicroelectronics International N.V.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of STMicroelectronics nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
+NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
+IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+********************************************************************************/
+/**
+ * @file vl53l1_types.h
+ * @brief VL53L1 types definition
+ */
+
+#ifndef _VL53L1_TYPES_H_
+#define _VL53L1_TYPES_H_
+
+/** @defgroup porting_type Basic type definition
+ * @ingroup api_platform
+ *
+ * @brief file vl53l1_types.h files hold basic type definition that may requires porting
+ *
+ * contains type that must be defined for the platform\n
+ * when target platform and compiler provide stdint.h and stddef.h it is enough to include it.\n
+ * If stdint.h is not available review and adapt all signed and unsigned 8/16/32 bits basic types. \n
+ * If stddef.h is not available review and adapt NULL definition .
+ */
+#include <stdint.h>
+#include <stddef.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifndef NULL
+#error "Error NULL definition should be done. Please add required include "
+#endif
+
+
+#if !defined(STDINT_H) && !defined(_STDINT_H) && !defined(_GCC_STDINT_H) && !defined(__STDINT_DECLS) && !defined(_GCC_WRAP_STDINT_H) && !defined(_STDINT)
+
+ #pragma message("Please review type definition of STDINT define for your platform and add to list above ")
+
+ /*
+ * target platform do not provide stdint or use a different #define than above
+ * to avoid seeing the message below addapt the #define list above or implement
+ * all type and delete these pragma
+ */
+
+/** \ingroup VL53L1_portingType_group
+ * @{
+ */
+
+
+typedef unsigned long long uint64_t;
+
+
+/** @brief Typedef defining 32 bit unsigned int type.\n
+ * The developer should modify this to suit the platform being deployed.
+ */
+typedef unsigned int uint32_t;
+
+/** @brief Typedef defining 32 bit int type.\n
+ * The developer should modify this to suit the platform being deployed.
+ */
+typedef int int32_t;
+
+/** @brief Typedef defining 16 bit unsigned short type.\n
+ * The developer should modify this to suit the platform being deployed.
+ */
+typedef unsigned short uint16_t;
+
+/** @brief Typedef defining 16 bit short type.\n
+ * The developer should modify this to suit the platform being deployed.
+ */
+typedef short int16_t;
+
+/** @brief Typedef defining 8 bit unsigned char type.\n
+ * The developer should modify this to suit the platform being deployed.
+ */
+typedef unsigned char uint8_t;
+
+/** @brief Typedef defining 8 bit char type.\n
+ * The developer should modify this to suit the platform being deployed.
+ */
+typedef signed char int8_t;
+
+/** @} */
+#endif /* _STDINT_H */
+
+
+/** use where fractional values are expected
+ *
+ * Given a floating point value f it's .16 bit point is (int)(f*(1<<16))*/
+typedef uint32_t FixPoint1616_t;
+
+#endif /* VL53L1_TYPES_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1x.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1x.h
new file mode 100644
index 0000000..c10ec7f
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/vl53l1x.h
@@ -0,0 +1,284 @@
+/*******************************************************************************
+ Copyright (C) 2016, STMicroelectronics International N.V.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of STMicroelectronics nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
+ NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
+ IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ******************************************************************************/
+
+
+#ifndef _VL53L1X_H_
+#define _VL53L1X_H_
+
+#include "vl53l1_ll_def.h"
+#include "vl53l1_platform_user_data.h"
+#include "vl53l1_api.h"
+#include "i2cdev.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define VL53L1X_DEFAULT_ADDRESS 0b0101001
+#define VL53L1X_ID 0xEACC
+
+#define USE_I2C_2V8
+
+/**
+ * @file vl53l1_platform.h
+ *
+ * @brief All end user OS/platform/application porting
+ */
+
+bool vl53l1xInit(VL53L1_Dev_t *pdev, I2C_Dev *I2cHandle);
+
+bool vl53l1xTestConnection(VL53L1_Dev_t* pdev);
+
+VL53L1_Error vl53l1xSetI2CAddress(VL53L1_Dev_t* pdev, uint8_t address);
+
+/**
+ * @brief Writes the supplied byte buffer to the device
+ *
+ * @param[in] pdev : pointer to device structure (device handle)
+ * @param[in] index : uint16_t register index value
+ * @param[in] pdata : pointer to uint8_t (byte) buffer containing the data to be written
+ * @param[in] count : number of bytes in the supplied byte buffer
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_WriteMulti(
+ VL53L1_Dev_t *pdev,
+ uint16_t index,
+ uint8_t *pdata,
+ uint32_t count);
+
+
+/**
+ * @brief Reads the requested number of bytes from the device
+ *
+ * @param[in] pdev : pointer to device structure (device handle)
+ * @param[in] index : uint16_t register index value
+ * @param[out] pdata : pointer to the uint8_t (byte) buffer to store read data
+ * @param[in] count : number of bytes to read
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_ReadMulti(
+ VL53L1_Dev_t *pdev,
+ uint16_t index,
+ uint8_t *pdata,
+ uint32_t count);
+
+
+/**
+ * @brief Writes a single byte to the device
+ *
+ * @param[in] pdev : pointer to device structure (device handle)
+ * @param[in] index : uint16_t register index value
+ * @param[in] data : uint8_t data value to write
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_WrByte(
+ VL53L1_Dev_t *pdev,
+ uint16_t index,
+ uint8_t data);
+
+
+/**
+ * @brief Writes a single word (16-bit unsigned) to the device
+ *
+ * Manages the big-endian nature of the device register map
+ * (first byte written is the MS byte).
+ *
+ * @param[in] pdev : pointer to device structure (device handle)
+ * @param[in] index : uint16_t register index value
+ * @param[in] data : uin16_t data value write
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_WrWord(
+ VL53L1_Dev_t *pdev,
+ uint16_t index,
+ uint16_t data);
+
+
+/**
+ * @brief Writes a single dword (32-bit unsigned) to the device
+ *
+ * Manages the big-endian nature of the device register map
+ * (first byte written is the MS byte).
+ *
+ * @param[in] pdev : pointer to device structure (device handle)
+ * @param[in] index : uint16_t register index value
+ * @param[in] data : uint32_t data value to write
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_WrDWord(
+ VL53L1_Dev_t *pdev,
+ uint16_t index,
+ uint32_t data);
+
+
+
+/**
+ * @brief Reads a single byte from the device
+ *
+ * @param[in] pdev : pointer to device structure (device handle)
+ * @param[in] index : uint16_t register index
+ * @param[out] pdata : pointer to uint8_t data value
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ *
+ */
+
+VL53L1_Error VL53L1_RdByte(
+ VL53L1_Dev_t *pdev,
+ uint16_t index,
+ uint8_t *pdata);
+
+
+/**
+ * @brief Reads a single word (16-bit unsigned) from the device
+ *
+ * Manages the big-endian nature of the device (first byte read is the MS byte).
+ *
+ * @param[in] pdev : pointer to device structure (device handle)
+ * @param[in] index : uint16_t register index value
+ * @param[out] pdata : pointer to uint16_t data value
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_RdWord(
+ VL53L1_Dev_t *pdev,
+ uint16_t index,
+ uint16_t *pdata);
+
+
+/**
+ * @brief Reads a single dword (32-bit unsigned) from the device
+ *
+ * Manages the big-endian nature of the device (first byte read is the MS byte).
+ *
+ * @param[in] pdev : pointer to device structure (device handle)
+ * @param[in] index : uint16_t register index value
+ * @param[out] pdata : pointer to uint32_t data value
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_RdDWord(
+ VL53L1_Dev_t *pdev,
+ uint16_t index,
+ uint32_t *pdata);
+
+
+
+/**
+ * @brief Implements a programmable wait in us
+ *
+ * @param[in] pdev : pointer to device structure (device handle)
+ * @param[in] wait_us : integer wait in micro seconds
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_WaitUs(
+ VL53L1_Dev_t *pdev,
+ int32_t wait_us);
+
+
+/**
+ * @brief Implements a programmable wait in ms
+ *
+ * @param[in] pdev : pointer to device structure (device handle)
+ * @param[in] wait_ms : integer wait in milliseconds
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_WaitMs(
+ VL53L1_Dev_t *pdev,
+ int32_t wait_ms);
+
+/*
+ * @brief Gets current system tick count in [ms]
+ *
+ * @return time_ms : current time in [ms]
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_GetTickCount(
+ uint32_t *ptime_ms);
+
+
+/**
+ * @brief Register "wait for value" polling routine
+ *
+ * Port of the V2WReg Script function WaitValueMaskEx()
+ *
+ * @param[in] pdev : pointer to device structure (device handle)
+ * @param[in] timeout_ms : timeout in [ms]
+ * @param[in] index : uint16_t register index value
+ * @param[in] value : value to wait for
+ * @param[in] mask : mask to be applied before comparison with value
+ * @param[in] poll_delay_ms : polling delay been each read transaction in [ms]
+ *
+ * @return VL53L1_ERROR_NONE Success
+ * @return "Other error code" See ::VL53L1_Error
+ */
+
+VL53L1_Error VL53L1_WaitValueMaskEx(
+ VL53L1_Dev_t *pdev,
+ uint32_t timeout_ms,
+ uint16_t index,
+ uint8_t value,
+ uint8_t mask,
+ uint32_t poll_delay_ms);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/zranger2.h b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/zranger2.h
new file mode 100644
index 0000000..d5d481a
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/include/zranger2.h
@@ -0,0 +1,34 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2012 BitCraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * zranger.h: Z-Ranger deck driver
+ */
+
+#ifndef _ZRANGER2_H_
+#define _ZRANGER2_H_
+
+#include "stabilizer_types.h"
+//#include "deck_core.h"
+
+void zRanger2Init(void);
+
+bool zRanger2Test(void);
+void zRanger2Task(void* arg);
+
+#endif /* _ZRANGER2_H_ */
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/vl53l1x.c b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/vl53l1x.c
new file mode 100644
index 0000000..8104759
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/vl53l1x.c
@@ -0,0 +1,407 @@
+/*******************************************************************************
+ Copyright (C) 2016, STMicroelectronics International N.V.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of STMicroelectronics nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
+ NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
+ IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ******************************************************************************/
+
+/**
+ * @file vl53l1_platform.c
+ * @brief Code function definitions for Crazyflie
+ *
+ */
+#include <stdio.h> // sprintf(), vsnprintf(), printf()
+#include <stdint.h>
+#include <string.h> // strncpy(), strnlen()
+
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+
+#include "i2cdev.h"
+#include "vl53l1x.h"
+#define DEBUG_MODULE "VLX1"
+#include "debug_cf.h"
+
+#ifdef PAL_EXTENDED
+ #include "vl53l1_register_strings.h"
+#else
+ #define VL53L1_get_register_name(a,b)
+#endif
+
+// Set the start address 8 step after the VL53L0 dynamic addresses
+//static int nextI2CAddress = VL53L1X_DEFAULT_ADDRESS+8;
+
+
+bool vl53l1xInit(VL53L1_Dev_t *pdev, I2C_Dev *I2cHandle)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ pdev->I2cDevAddr = VL53L1X_DEFAULT_ADDRESS;
+ pdev->I2Cx = I2cHandle;
+ i2cdevInit(pdev->I2Cx);
+
+ /* Move initialized sensor to a new I2C address */
+ //int newAddress;
+
+ //taskENTER_CRITICAL();
+ //newAddress = nextI2CAddress++;
+ //taskEXIT_CRITICAL();
+
+ //vl53l1xSetI2CAddress(pdev, newAddress);
+
+ uint8_t byteData;
+ uint16_t wordData;
+ VL53L1_RdByte(pdev, 0x010F, &byteData);
+ DEBUG_PRINT( "VL53L1X Model_ID: %02X\n\r", byteData);
+ VL53L1_RdByte(pdev, 0x0110, &byteData);
+ DEBUG_PRINT( "VL53L1X Module_Type: %02X\n\r", byteData);
+ VL53L1_RdWord(pdev, 0x010F, &wordData);
+ DEBUG_PRINT( "VL53L1X: %02X\n\r", wordData);
+
+ status = VL53L1_WaitDeviceBooted(pdev);
+ if (status == VL53L1_ERROR_NONE)
+ {
+ status = VL53L1_DataInit(pdev);
+
+ if (status == VL53L1_ERROR_NONE)
+ {
+ status = VL53L1_StaticInit(pdev);
+ }
+ }
+
+#ifdef SET_VL53LX_ROI
+ VL53L1_UserRoi_t Roi0;
+ Roi0.TopLeftX = 0; //set ROI according to requirement
+ Roi0.TopLeftY = 15;
+ Roi0.BotRightX = 15;
+ Roi0.BotRightY = 0;
+ status = VL53L1_SetUserROI(pdev, &Roi0); //SET region of interest
+#endif
+ //Restart sensor remove to zranger task
+ //VL53L1_StopMeasurement(pdev);
+ //status = VL53L1_SetDistanceMode(pdev,VL53L1_DISTANCEMODE_LONG);
+ //status = VL53L1_SetMeasurementTimingBudgetMicroSeconds(pdev, 160000);
+ //status = VL53L1_SetInterMeasurementPeriodMilliSeconds(pdev, 200);
+ //status = VL53L1_StartMeasurement(pdev);
+
+ return status == VL53L1_ERROR_NONE;
+}
+
+bool vl53l1xTestConnection(VL53L1_Dev_t* pdev)
+{
+ VL53L1_DeviceInfo_t info;
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ status = VL53L1_GetDeviceInfo(pdev, &info);
+
+ return status == VL53L1_ERROR_NONE;
+}
+
+/** Set I2C address
+ * Any subsequent communication will be on the new address
+ * The address passed is the 7bit I2C address from LSB (ie. without the
+ * read/write bit)
+ */
+VL53L1_Error vl53l1xSetI2CAddress(VL53L1_Dev_t* pdev, uint8_t address)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ status = VL53L1_SetDeviceAddress(pdev, address);
+ pdev->I2cDevAddr = address;
+ return status;
+}
+
+
+/*
+ * ----------------- COMMS FUNCTIONS -----------------
+ */
+
+VL53L1_Error VL53L1_WriteMulti(
+ VL53L1_Dev_t *pdev,
+ uint16_t index,
+ uint8_t *pdata,
+ uint32_t count)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ if (!i2cdevWrite16(pdev->I2Cx, pdev->I2cDevAddr, index, count, pdata))
+ {
+ status = VL53L1_ERROR_CONTROL_INTERFACE;
+ }
+
+ return status;
+}
+
+VL53L1_Error VL53L1_ReadMulti(
+ VL53L1_Dev_t *pdev,
+ uint16_t index,
+ uint8_t *pdata,
+ uint32_t count)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ if (!i2cdevRead16(pdev->I2Cx, pdev->I2cDevAddr, index, count, pdata))
+ {
+ status = VL53L1_ERROR_CONTROL_INTERFACE;
+ }
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_WrByte(
+ VL53L1_Dev_t *pdev,
+ uint16_t index,
+ uint8_t data)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ if (!i2cdevWrite16(pdev->I2Cx, pdev->I2cDevAddr, index, 1, &data))
+ {
+ status = VL53L1_ERROR_CONTROL_INTERFACE;
+ }
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_WrWord(
+ VL53L1_Dev_t *pdev,
+ uint16_t index,
+ uint16_t data)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t _I2CBuffer[2];
+ _I2CBuffer[0] = data >> 8;
+ _I2CBuffer[1] = data & 0x00FF;
+ if (!i2cdevWrite16(pdev->I2Cx, pdev->I2cDevAddr, index, 2, (uint8_t *)_I2CBuffer))
+ {
+ status = VL53L1_ERROR_CONTROL_INTERFACE;
+ }
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_WrDWord(
+ VL53L1_Dev_t *pdev,
+ uint16_t index,
+ uint32_t data)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t _I2CBuffer[4];
+ _I2CBuffer[0] = (data >> 24) & 0xFF;
+ _I2CBuffer[1] = (data >> 16) & 0xFF;
+ _I2CBuffer[2] = (data >> 8) & 0xFF;
+ _I2CBuffer[3] = (data >> 0) & 0xFF;
+
+ if (!i2cdevWrite16(pdev->I2Cx, pdev->I2cDevAddr, index, 4, (uint8_t *)_I2CBuffer))
+ {
+ status = VL53L1_ERROR_CONTROL_INTERFACE;
+ }
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_RdByte(
+ VL53L1_Dev_t *pdev,
+ uint16_t index,
+ uint8_t *pdata)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+
+ if (!i2cdevRead16(pdev->I2Cx, pdev->I2cDevAddr, index, 1, pdata))
+ {
+ status = VL53L1_ERROR_CONTROL_INTERFACE;
+ }
+
+ return status;
+}
+
+VL53L1_Error VL53L1_RdWord(
+ VL53L1_Dev_t *pdev,
+ uint16_t index,
+ uint16_t *pdata)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t _I2CBuffer[2];
+
+ if (!i2cdevRead16(pdev->I2Cx, pdev->I2cDevAddr, index, 2, (uint8_t *)_I2CBuffer))
+ {
+ status = VL53L1_ERROR_CONTROL_INTERFACE;
+ }
+ *pdata = ((uint16_t)_I2CBuffer[0] << 8) + (uint16_t)_I2CBuffer[1];
+ return status;
+}
+
+VL53L1_Error VL53L1_RdDWord(
+ VL53L1_Dev_t *pdev,
+ uint16_t index,
+ uint32_t *pdata)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint8_t _I2CBuffer[4];
+ if (!i2cdevRead16(pdev->I2Cx, pdev->I2cDevAddr, index, 4, (uint8_t *)_I2CBuffer))
+ {
+ status = VL53L1_ERROR_CONTROL_INTERFACE;
+ }
+ *pdata = ((uint32_t)_I2CBuffer[0] << 24) + ((uint32_t)_I2CBuffer[1] << 16) + ((uint32_t)_I2CBuffer[2] << 8) + (uint32_t)_I2CBuffer[3];
+ return status;
+}
+
+/*
+ * ----------------- HOST TIMING FUNCTIONS -----------------
+ */
+
+VL53L1_Error VL53L1_WaitUs(
+ VL53L1_Dev_t *pdev,
+ int32_t wait_us)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint32_t delay_ms = (wait_us + 900) / 1000;
+
+ if(delay_ms == 0)
+ {
+ delay_ms = 1;
+ }
+
+ vTaskDelay(M2T(delay_ms));
+
+ return status;
+}
+
+
+VL53L1_Error VL53L1_WaitMs(
+ VL53L1_Dev_t *pdev,
+ int32_t wait_ms)
+{
+ vTaskDelay(M2T(wait_ms));
+
+ return VL53L1_ERROR_NONE;
+}
+
+/*
+ * ----------------- DEVICE TIMING FUNCTIONS -----------------
+ */
+
+VL53L1_Error VL53L1_GetTickCount(
+ uint32_t *ptick_count_ms)
+{
+ /* Returns current tick count in [ms] */
+ *ptick_count_ms = xTaskGetTickCount();
+
+ return VL53L1_ERROR_NONE;
+}
+
+
+VL53L1_Error VL53L1_WaitValueMaskEx(
+ VL53L1_Dev_t *pdev,
+ uint32_t timeout_ms,
+ uint16_t index,
+ uint8_t value,
+ uint8_t mask,
+ uint32_t poll_delay_ms)
+{
+ /*
+ * Platform implementation of WaitValueMaskEx V2WReg script command
+ *
+ * WaitValueMaskEx(
+ * duration_ms,
+ * index,
+ * value,
+ * mask,
+ * poll_delay_ms);
+ */
+
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ uint32_t start_time_ms = 0;
+ uint32_t current_time_ms = 0;
+ uint8_t byte_value = 0;
+ uint8_t found = 0;
+#ifdef VL53L1_LOG_ENABLE
+ uint32_t trace_functions = 0;
+#endif
+
+ SUPPRESS_UNUSED_WARNING(poll_delay_ms);
+
+#ifdef VL53L1_LOG_ENABLE
+ /* look up register name */
+ VL53L1_get_register_name(
+ index,
+ register_name);
+
+ /* Output to I2C logger for FMT/DFT */
+ trace_i2c("WaitValueMaskEx(%5d, %s, 0x%02X, 0x%02X, %5d);\n",
+ timeout_ms, register_name, value, mask, poll_delay_ms);
+#endif // VL53L1_LOG_ENABLE
+
+ /* calculate time limit in absolute time */
+
+ VL53L1_GetTickCount(&start_time_ms);
+ pdev->new_data_ready_poll_duration_ms = 0;
+
+ /* remember current trace functions and temporarily disable
+ * function logging
+ */
+
+#ifdef VL53L1_LOG_ENABLE
+ trace_functions = _LOG_GET_TRACE_FUNCTIONS();
+#endif
+
+ /* wait until value is found, timeout reached on error occurred */
+
+ while ((status == VL53L1_ERROR_NONE) &&
+ (pdev->new_data_ready_poll_duration_ms < timeout_ms) &&
+ (found == 0))
+ {
+ status = VL53L1_RdByte(
+ pdev,
+ index,
+ &byte_value);
+
+ if ((byte_value & mask) == value)
+ {
+ found = 1;
+ }
+
+ if (status == VL53L1_ERROR_NONE &&
+ found == 0 &&
+ poll_delay_ms > 0)
+ status = VL53L1_WaitMs(
+ pdev,
+ poll_delay_ms);
+
+ /* Update polling time (Compare difference rather than absolute to
+ negate 32bit wrap around issue) */
+ VL53L1_GetTickCount(&current_time_ms);
+ pdev->new_data_ready_poll_duration_ms = current_time_ms - start_time_ms;
+ }
+
+ if (found == 0 && status == VL53L1_ERROR_NONE)
+ status = VL53L1_ERROR_TIME_OUT;
+
+ return status;
+}
+
diff --git a/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/zranger2.c b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/zranger2.c
new file mode 100644
index 0000000..4570d39
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/i2c_devices/vl53l1/zranger2.c
@@ -0,0 +1,147 @@
+/**
+* || ____ _ __
+ * +------+ / __ )(_) /_______________ _____ ___
+ * | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
+ * +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
+ * || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2012 BitCraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * vl53l1x.c: Time-of-flight distance sensor driver
+ */
+
+
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+
+#include "config.h"
+#include "system.h"
+#include "log.h"
+#include "param.h"
+#include "range.h"
+#include "i2cdev.h"
+#include "zranger2.h"
+#include "vl53l1x.h"
+#include "cf_math.h"
+#define DEBUG_MODULE "ZR2"
+#include "debug_cf.h"
+
+// Measurement noise model
+static const float expPointA = 2.5f;
+static const float expStdA = 0.0025f; // STD at elevation expPointA [m]
+static const float expPointB = 4.0f;
+static const float expStdB = 0.2f; // STD at elevation expPointB [m]
+static float expCoeff;
+
+#define RANGE_OUTLIER_LIMIT 5000 // the measured range is in [mm]
+
+static int16_t range_last = 0;
+
+static bool isInit;
+
+static VL53L1_Dev_t dev;
+
+static uint16_t zRanger2GetMeasurementAndRestart(VL53L1_Dev_t *dev)
+{
+ VL53L1_Error status = VL53L1_ERROR_NONE;
+ VL53L1_RangingMeasurementData_t rangingData;
+ uint8_t dataReady = 0;
+ uint16_t range;
+
+ while (dataReady == 0)
+ {
+ status = VL53L1_GetMeasurementDataReady(dev, &dataReady);
+ vTaskDelay(M2T(1));
+ }
+
+ status = VL53L1_GetRangingMeasurementData(dev, &rangingData);
+ range = rangingData.RangeMilliMeter;
+
+ VL53L1_StopMeasurement(dev);
+ status = VL53L1_StartMeasurement(dev);
+ status = status;
+
+ return range;
+}
+
+void zRanger2Init(void)
+{
+ if (isInit)
+ return;
+
+ if (vl53l1xInit(&dev, I2C1_DEV))
+ {
+ DEBUG_PRINTI("Z-down sensor [OK]\n");
+ }
+ else
+ {
+ DEBUG_PRINTW("Z-down sensor [FAIL]\n");
+ return;
+ }
+
+ xTaskCreate(zRanger2Task, ZRANGER2_TASK_NAME, ZRANGER2_TASK_STACKSIZE, NULL, ZRANGER2_TASK_PRI, NULL);
+
+ // pre-compute constant in the measurement noise model for kalman
+ expCoeff = logf(expStdB / expStdA) / (expPointB - expPointA);
+
+ isInit = true;
+}
+
+bool zRanger2Test(void)
+{
+ if (!isInit)
+ return false;
+
+ return true;
+}
+
+void zRanger2Task(void* arg)
+{
+ TickType_t lastWakeTime;
+
+ systemWaitStart();
+
+ // Restart sensor
+ VL53L1_StopMeasurement(&dev);
+ VL53L1_SetDistanceMode(&dev, VL53L1_DISTANCEMODE_MEDIUM);
+ VL53L1_SetMeasurementTimingBudgetMicroSeconds(&dev, 25000);
+
+ VL53L1_StartMeasurement(&dev);
+
+ lastWakeTime = xTaskGetTickCount();
+
+ while (1) {
+ vTaskDelayUntil(&lastWakeTime, M2T(25));
+
+ range_last = zRanger2GetMeasurementAndRestart(&dev);
+ rangeSet(rangeDown, range_last / 1000.0f);
+
+ // check if range is feasible and push into the estimator
+ // the sensor should not be able to measure >5 [m], and outliers typically
+ // occur as >8 [m] measurements
+ if (range_last < RANGE_OUTLIER_LIMIT) {
+ float distance = (float)range_last * 0.001f; // Scale from [mm] to [m]
+ float stdDev = expStdA * (1.0f + expf( expCoeff * (distance - expPointA)));
+ rangeEnqueueDownRangeInEstimator(distance, stdDev, xTaskGetTickCount());
+ }
+ }
+}
+
+PARAM_GROUP_START(deck)
+PARAM_ADD(PARAM_UINT8 | PARAM_RONLY, bcZRanger2, &isInit)
+PARAM_GROUP_STOP(deck)
diff --git a/Firmware/esp-drone/components/drivers/spi_devices/pmw3901/CMakeLists.txt b/Firmware/esp-drone/components/drivers/spi_devices/pmw3901/CMakeLists.txt
new file mode 100644
index 0000000..52bd408
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/spi_devices/pmw3901/CMakeLists.txt
@@ -0,0 +1,3 @@
+idf_component_register(SRCS "flowdeck_v1v2.c" "pmw3901.c"
+ INCLUDE_DIRS "include"
+ PRIV_REQUIRES crazyflie config deck)
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/spi_devices/pmw3901/flowdeck_v1v2.c b/Firmware/esp-drone/components/drivers/spi_devices/pmw3901/flowdeck_v1v2.c
new file mode 100644
index 0000000..c54fc4b
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/spi_devices/pmw3901/flowdeck_v1v2.c
@@ -0,0 +1,252 @@
+/*
+ * || ____ _ __
+ * +------+ / __ )(_) /_______________ _____ ___
+ * | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
+ * +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
+ * || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
+ *
+ * LPS node firmware.
+ *
+ * Copyright 2017, Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Foobar 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+/* flowdeck.c: Flow deck driver */
+#include <stdlib.h>
+
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+
+#include "pmw3901.h"
+#include "system.h"
+#include "log.h"
+#include "param.h"
+#include "sleepus.h"
+#include "config.h"
+#include "stabilizer_types.h"
+#include "estimator.h"
+#include "cf_math.h"
+#define DEBUG_MODULE "FLOW"
+#include "debug_cf.h"
+
+#define AVERAGE_HISTORY_LENGTH 4
+#define OULIER_LIMIT 100
+#define LP_CONSTANT 0.8f
+//#define USE_LP_FILTER
+//#define USE_MA_SMOOTHING
+
+#if defined(USE_MA_SMOOTHING)
+static struct {
+ float32_t averageX[AVERAGE_HISTORY_LENGTH];
+ float32_t averageY[AVERAGE_HISTORY_LENGTH];
+ size_t ptr;
+} pixelAverages;
+#endif
+
+float dpixelx_previous = 0;
+float dpixely_previous = 0;
+
+static uint8_t outlierCount = 0;
+static float stdFlow = 2.0f;
+
+static bool isInit1 = false;
+static bool isInit2 = false;
+
+motionBurst_t currentMotion;
+
+// Disables pushing the flow measurement in the EKF
+static bool useFlowDisabled = false;
+
+// Turn on adaptive standard deviation for the kalman filter
+static bool useAdaptiveStd = true;
+
+// Set standard deviation flow
+// (will not work if useAdaptiveStd is on)
+static float flowStdFixed = 2.0f;
+
+#define NCS_PIN CONFIG_SPI_PIN_CS0
+
+
+static void flowdeckTask(void *param)
+{
+ systemWaitStart();
+ initUsecTimer();
+ uint64_t lastTime = usecTimestamp();
+
+ while (1) {
+// if task watchdog triggered,flow frequency should set lower
+#ifdef CONFIG_IDF_TARGET_ESP32S2
+ vTaskDelay(10);
+#elif defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32)
+ vTaskDelay(5);
+#endif
+
+ pmw3901ReadMotion(NCS_PIN, &currentMotion);
+
+ // Flip motion information to comply with sensor mounting
+ // (might need to be changed if mounted differently)
+ int16_t accpx = -currentMotion.deltaY;
+ int16_t accpy = -currentMotion.deltaX;
+
+ // Outlier removal
+ if (abs(accpx) < OULIER_LIMIT && abs(accpy) < OULIER_LIMIT) {
+ if (useAdaptiveStd)
+ {
+ // The standard deviation is fitted by measurements flying over low and high texture
+ // and looking at the shutter time
+ float shutter_f = (float)currentMotion.shutter;
+ stdFlow=0.0007984f *shutter_f + 0.4335f;
+
+
+ // The formula with the amount of features instead
+ /*float squal_f = (float)currentMotion.squal;
+ stdFlow = -0.01257f * squal_f + 4.406f; */
+ if (stdFlow < 0.1f) stdFlow=0.1f;
+ } else {
+ stdFlow = flowStdFixed;
+ }
+ // Form flow measurement struct and push into the EKF
+ flowMeasurement_t flowData;
+ flowData.stdDevX = stdFlow; // [pixels] should perhaps be made larger?
+ flowData.stdDevY = stdFlow; // [pixels] should perhaps be made larger?
+
+// if task watchdog triggered,flow frequency should set lower
+#ifdef CONFIG_IDF_TARGET_ESP32S2
+ flowData.dt = 0.01;
+#elif defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32)
+ flowData.dt = 0.005;
+#endif
+
+#if defined(USE_MA_SMOOTHING)
+ // Use MA Smoothing
+ pixelAverages.averageX[pixelAverages.ptr] = (float32_t)accpx;
+ pixelAverages.averageY[pixelAverages.ptr] = (float32_t)accpy;
+
+ float32_t meanX;
+ float32_t meanY;
+
+ xtensa_mean_f32(pixelAverages.averageX, AVERAGE_HISTORY_LENGTH, &meanX);
+ xtensa_mean_f32(pixelAverages.averageY, AVERAGE_HISTORY_LENGTH, &meanY);
+
+ pixelAverages.ptr = (pixelAverages.ptr + 1) % AVERAGE_HISTORY_LENGTH;
+
+ flowData.dpixelx = (float)meanX; // [pixels]
+ flowData.dpixely = (float)meanY; // [pixels]
+#elif defined(USE_LP_FILTER)
+ // Use LP filter measurements
+ flowData.dpixelx = LP_CONSTANT * dpixelx_previous + (1.0f - LP_CONSTANT) * (float)accpx;
+ flowData.dpixely = LP_CONSTANT * dpixely_previous + (1.0f - LP_CONSTANT) * (float)accpy;
+ dpixelx_previous = flowData.dpixelx;
+ dpixely_previous = flowData.dpixely;
+#else
+ // Use raw measurements
+ flowData.dpixelx = (float)accpx;
+ flowData.dpixely = (float)accpy;
+#endif
+
+ // Push measurements into the estimator
+ if (!useFlowDisabled && currentMotion.motion == 0xB0) {
+ flowData.dt = (float)(usecTimestamp()-lastTime)/1000000.0f;
+ lastTime = usecTimestamp();
+ estimatorEnqueueFlow(&flowData);
+ }
+ } else {
+ outlierCount++;
+ }
+ }
+}
+
+// static void flowdeck1Init()
+// {
+// if (isInit1 || isInit2) {
+// return;
+// }
+
+// // Initialize the VL53L0 sensor using the zRanger deck driver
+// const DeckDriver *zRanger = deckFindDriverByName("bcZRanger");
+// zRanger->init(NULL);
+
+// if (pmw3901Init(NCS_PIN))
+// {
+// xTaskCreate(flowdeckTask, FLOW_TASK_NAME, FLOW_TASK_STACKSIZE, NULL,
+// FLOW_TASK_PRI, NULL);
+
+// isInit1 = true;
+// }
+// }
+
+// static bool flowdeck1Test()
+// {
+// if (!isInit1) {
+// DEBUG_PRINTD("Error while initializing the PMW3901 sensor\n");
+// }
+
+// // Test the VL53L0 driver
+// const DeckDriver *zRanger = deckFindDriverByName("bcZRanger");
+
+// return zRanger->test();
+// }
+
+void flowdeck2Init()
+{
+ if (isInit1 || isInit2) {
+ return;
+ }
+
+ // Initialize the VL53L1 sensor using the zRanger deck driver
+ // const DeckDriver *zRanger = deckFindDriverByName("bcZRanger2");
+ // zRanger->init(NULL);
+
+ if (pmw3901Init(NCS_PIN)) {
+ xTaskCreate(flowdeckTask, FLOW_TASK_NAME, FLOW_TASK_STACKSIZE, NULL, FLOW_TASK_PRI, NULL);
+
+ isInit2 = true;
+ }
+}
+
+bool flowdeck2Test()
+{
+ if (!isInit2) {
+ DEBUG_PRINTD("Error while initializing the PMW3901 sensor\n");
+ }
+
+ // Test the VL53L1 driver
+ //const DeckDriver *zRanger = deckFindDriverByName("bcZRanger2");
+
+ return isInit2;//zRanger->test();
+}
+
+LOG_GROUP_START(motion)
+LOG_ADD(LOG_UINT8, motion, &currentMotion.motion)
+LOG_ADD(LOG_INT16, deltaX, &currentMotion.deltaX)
+LOG_ADD(LOG_INT16, deltaY, &currentMotion.deltaY)
+LOG_ADD(LOG_UINT16, shutter, &currentMotion.shutter)
+LOG_ADD(LOG_UINT8, maxRaw, &currentMotion.maxRawData)
+LOG_ADD(LOG_UINT8, minRaw, &currentMotion.minRawData)
+LOG_ADD(LOG_UINT8, Rawsum, &currentMotion.rawDataSum)
+LOG_ADD(LOG_UINT8, outlierCount, &outlierCount)
+LOG_ADD(LOG_UINT8, squal, &currentMotion.squal)
+LOG_ADD(LOG_FLOAT, std, &stdFlow)
+LOG_GROUP_STOP(motion)
+
+PARAM_GROUP_START(motion)
+PARAM_ADD(PARAM_UINT8, disable, &useFlowDisabled)
+PARAM_ADD(PARAM_UINT8, adaptive, &useAdaptiveStd)
+PARAM_ADD(PARAM_FLOAT, flowStdFixed, &flowStdFixed)
+PARAM_GROUP_STOP(motion)
+
+PARAM_GROUP_START(deck)
+PARAM_ADD(PARAM_UINT8 | PARAM_RONLY, bcFlow, &isInit1)
+PARAM_ADD(PARAM_UINT8 | PARAM_RONLY, bcFlow2, &isInit2)
+PARAM_GROUP_STOP(deck)
diff --git a/Firmware/esp-drone/components/drivers/spi_devices/pmw3901/include/flowdeck_v1v2.h b/Firmware/esp-drone/components/drivers/spi_devices/pmw3901/include/flowdeck_v1v2.h
new file mode 100644
index 0000000..21b75e1
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/spi_devices/pmw3901/include/flowdeck_v1v2.h
@@ -0,0 +1,8 @@
+#ifndef FLOWDECKV1V2_H_
+#define FLOWDECKV1V2_H_
+
+
+void flowdeck2Init();
+bool flowdeck2Test();
+
+#endif
\ No newline at end of file
diff --git a/Firmware/esp-drone/components/drivers/spi_devices/pmw3901/include/pmw3901.h b/Firmware/esp-drone/components/drivers/spi_devices/pmw3901/include/pmw3901.h
new file mode 100644
index 0000000..cab7e4a
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/spi_devices/pmw3901/include/pmw3901.h
@@ -0,0 +1,72 @@
+/**
+ *
+ * ESP-Drone Firmware
+ *
+ * Copyright 2019-2020 Espressif Systems (Shanghai)
+ * Copyright (C) 2011-2012 Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, in version 3.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * pmw3901.h - Header file for pmw3901 driver
+ */
+
+#ifndef PMW3901_H_
+#define PMW3901_H_
+
+#include <stdint.h>
+
+typedef struct motionBurst_s {
+ union {
+ uint8_t motion;
+ struct {
+ uint8_t frameFrom0 : 1;
+ uint8_t runMode : 2;
+ uint8_t reserved1 : 1;
+ uint8_t rawFrom0 : 1;
+ uint8_t reserved2 : 2;
+ uint8_t motionOccured : 1;
+ };
+ };
+
+ uint8_t observation;
+ int16_t deltaX;
+ int16_t deltaY;
+
+ uint8_t squal;
+
+ uint8_t rawDataSum;
+ uint8_t maxRawData;
+ uint8_t minRawData;
+
+ uint16_t shutter;
+} __attribute__((packed)) motionBurst_t;
+
+/**
+ * Initialize the PMW3901 sensor
+ *
+ * @param csPin Chip Select pin as defined in deck pinout driver.
+ *
+ * @return true if init successful else false.
+ */
+bool pmw3901Init(uint32_t csPin);
+
+/**
+ * Read the current accumulated motion.
+ *
+ * @param csPin Chip Select pin as defined in deck pinout driver.
+ * @param motion A filled in motionBurst_t structure with the latest motion information
+ */
+void pmw3901ReadMotion(uint32_t csPin, motionBurst_t *motion);
+
+
+#endif /* PMW3901_H_ */
diff --git a/Firmware/esp-drone/components/drivers/spi_devices/pmw3901/pmw3901.c b/Firmware/esp-drone/components/drivers/spi_devices/pmw3901/pmw3901.c
new file mode 100644
index 0000000..4bcaedf
--- /dev/null
+++ b/Firmware/esp-drone/components/drivers/spi_devices/pmw3901/pmw3901.c
@@ -0,0 +1,235 @@
+/*
+ *
+ *
+ * LPS node firmware.
+ *
+ * Copyright 2017, Bitcraze AB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Foobar 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+/* pwm3901.c: PMW3901 driver */
+
+
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+
+#include "pmw3901.h"
+#include "system.h"
+#include "log.h"
+#include "param.h"
+#include "sleepus.h"
+#include "deck_digital.h"
+#include "deck_spi.h"
+#include "stm32_legacy.h"
+#define DEBUG_MODULE "PMW"
+#include "debug_cf.h"
+
+static bool isInit = false;
+
+static void registerWrite(uint32_t csPin, uint8_t reg, uint8_t value)
+{
+ // Set MSB to 1 for write
+ reg |= 0x80u;
+
+ spiBeginTransaction(SPI_BAUDRATE_2MHZ);
+ digitalWrite(csPin, LOW);
+
+ sleepus(50);
+
+ spiExchange(1, 1, &reg, &reg);
+ sleepus(50);
+ spiExchange(1, 1, &value, &value);
+
+ sleepus(50);
+
+ digitalWrite(csPin, HIGH);
+ spiEndTransaction();
+ sleepus(200);
+}
+
+static uint8_t registerRead(uint32_t csPin, uint8_t reg)
+{
+ uint8_t data = 0;
+ uint8_t dummy = 0;
+
+ // Set MSB to 0 for read
+ reg &= ~0x80u;
+
+ spiBeginTransaction(SPI_BAUDRATE_2MHZ);
+ digitalWrite(csPin, LOW);
+
+ sleepus(50);
+
+ spiExchange(1, 1, &reg, &reg);
+ sleepus(500);
+ spiExchange(1, 0, &dummy, &data);
+
+ sleepus(50);
+
+ digitalWrite(csPin, HIGH);
+ spiEndTransaction();
+ sleepus(200);
+
+ return data;
+}
+
+static void InitRegisters(uint32_t csPin)
+{
+ registerWrite(csPin, 0x7F, 0x00);
+ registerWrite(csPin, 0x61, 0xAD);
+ registerWrite(csPin, 0x7F, 0x03);
+ registerWrite(csPin, 0x40, 0x00);
+ registerWrite(csPin, 0x7F, 0x05);
+ registerWrite(csPin, 0x41, 0xB3);
+ registerWrite(csPin, 0x43, 0xF1);
+ registerWrite(csPin, 0x45, 0x14);
+ registerWrite(csPin, 0x5B, 0x32);
+ registerWrite(csPin, 0x5F, 0x34);
+ registerWrite(csPin, 0x7B, 0x08);
+ registerWrite(csPin, 0x7F, 0x06);
+ registerWrite(csPin, 0x44, 0x1B);
+ registerWrite(csPin, 0x40, 0xBF);
+ registerWrite(csPin, 0x4E, 0x3F);
+ registerWrite(csPin, 0x7F, 0x08);
+ registerWrite(csPin, 0x65, 0x20);
+ registerWrite(csPin, 0x6A, 0x18);
+ registerWrite(csPin, 0x7F, 0x09);
+ registerWrite(csPin, 0x4F, 0xAF);
+ registerWrite(csPin, 0x5F, 0x40);
+ registerWrite(csPin, 0x48, 0x80);
+ registerWrite(csPin, 0x49, 0x80);
+ registerWrite(csPin, 0x57, 0x77);
+ registerWrite(csPin, 0x60, 0x78);
+ registerWrite(csPin, 0x61, 0x78);
+ registerWrite(csPin, 0x62, 0x08);
+ registerWrite(csPin, 0x63, 0x50);
+ registerWrite(csPin, 0x7F, 0x0A);
+ registerWrite(csPin, 0x45, 0x60);
+ registerWrite(csPin, 0x7F, 0x00);
+ registerWrite(csPin, 0x4D, 0x11);
+ registerWrite(csPin, 0x55, 0x80);
+ registerWrite(csPin, 0x74, 0x1F);
+ registerWrite(csPin, 0x75, 0x1F);
+ registerWrite(csPin, 0x4A, 0x78);
+ registerWrite(csPin, 0x4B, 0x78);
+ registerWrite(csPin, 0x44, 0x08);
+ registerWrite(csPin, 0x45, 0x50);
+ registerWrite(csPin, 0x64, 0xFF);
+ registerWrite(csPin, 0x65, 0x1F);
+ registerWrite(csPin, 0x7F, 0x14);
+ registerWrite(csPin, 0x65, 0x67);
+ registerWrite(csPin, 0x66, 0x08);
+ registerWrite(csPin, 0x63, 0x70);
+ registerWrite(csPin, 0x7F, 0x15);
+ registerWrite(csPin, 0x48, 0x48);
+ registerWrite(csPin, 0x7F, 0x07);
+ registerWrite(csPin, 0x41, 0x0D);
+ registerWrite(csPin, 0x43, 0x14);
+ registerWrite(csPin, 0x4B, 0x0E);
+ registerWrite(csPin, 0x45, 0x0F);
+ registerWrite(csPin, 0x44, 0x42);
+ registerWrite(csPin, 0x4C, 0x80);
+ registerWrite(csPin, 0x7F, 0x10);
+ registerWrite(csPin, 0x5B, 0x02);
+ registerWrite(csPin, 0x7F, 0x07);
+ registerWrite(csPin, 0x40, 0x41);
+ registerWrite(csPin, 0x70, 0x00);
+
+ vTaskDelay(M2T(10)); // delay 10ms
+
+ registerWrite(csPin, 0x32, 0x44);
+ registerWrite(csPin, 0x7F, 0x07);
+ registerWrite(csPin, 0x40, 0x40);
+ registerWrite(csPin, 0x7F, 0x06);
+ registerWrite(csPin, 0x62, 0xF0);
+ registerWrite(csPin, 0x63, 0x00);
+ registerWrite(csPin, 0x7F, 0x0D);
+ registerWrite(csPin, 0x48, 0xC0);
+ registerWrite(csPin, 0x6F, 0xD5);
+ registerWrite(csPin, 0x7F, 0x00);
+ registerWrite(csPin, 0x5B, 0xA0);
+ registerWrite(csPin, 0x4E, 0xA8);
+ registerWrite(csPin, 0x5A, 0x50);
+ registerWrite(csPin, 0x40, 0x80);
+
+ registerWrite(csPin, 0x7F, 0x00);
+ registerWrite(csPin, 0x5A, 0x10);
+ registerWrite(csPin, 0x54, 0x00);
+}
+
+bool pmw3901Init(uint32_t csPin)
+{
+ if (isInit) {
+ return true;
+ }
+
+ // Initialize CS Pin
+ pinMode(csPin, OUTPUT);
+ digitalWrite(csPin, HIGH);
+
+ spiBegin();
+ vTaskDelay(M2T(40));
+
+ digitalWrite(csPin, HIGH);
+ vTaskDelay(M2T(2));
+ digitalWrite(csPin, LOW);
+ vTaskDelay(M2T(2));
+ digitalWrite(csPin, HIGH);
+ vTaskDelay(M2T(2));
+
+ uint8_t chipId = registerRead(csPin, 0x00);
+ uint8_t invChipId = registerRead(csPin, 0x5f);
+
+ DEBUG_PRINTD("Motion chip id: 0x%x:0x%x\n", chipId, invChipId);
+
+ if (chipId == 0x49 || invChipId == 0xB6) {
+ // Power on reset
+ registerWrite(csPin, 0x3a, 0x5a);
+ vTaskDelay(M2T(5));
+
+ // Reading the motion registers one time
+ registerRead(csPin, 0x02);
+ registerRead(csPin, 0x03);
+ registerRead(csPin, 0x04);
+ registerRead(csPin, 0x05);
+ registerRead(csPin, 0x06);
+ vTaskDelay(M2T(1));
+
+ InitRegisters(csPin);
+
+ isInit = true;
+ }
+
+ return isInit;
+}
+
+void pmw3901ReadMotion(uint32_t csPin, motionBurst_t *motion)
+{
+ uint8_t address = 0x16;
+
+ spiBeginTransaction(SPI_BAUDRATE_2MHZ);
+ digitalWrite(csPin, LOW);
+ sleepus(50);
+ spiExchange(1, 1, &address, &address);
+ sleepus(50);
+ spiExchange(sizeof(motionBurst_t), 0, (uint8_t *)motion, (uint8_t *)motion);
+ sleepus(50);
+ digitalWrite(csPin, HIGH);
+ spiEndTransaction();
+ sleepus(50);
+
+ uint16_t realShutter = (motion->shutter >> 8) & 0x0FF;
+ realShutter |= (motion->shutter & 0x0ff) << 8;
+ motion->shutter = realShutter;
+}