40 p_dev->temp_buffer, size);
103 uint8_t dss_4x4[] = {0x0F, 0x04, 0x04, 0x00, 0x08, 0x10, 0x10, 0x07};
104 uint8_t footer[] = {0x00, 0x00, 0x00, 0x0F, 0x03, 0x01, 0x01, 0xE4};
122 for (i = 0; i < (
int8_t)4 ; i++)
171 uint8_t res4x4[] = {0x0F, 0x04, 0x04, 0x17, 0x08, 0x10, 0x10, 0x07};
172 uint8_t dss_4x4[] = {0x00, 0x78, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08};
194 for (i = 0; i < (
int8_t)4 ; i++)
384 p_dev->default_configuration,
391#if VL53L5CX_NB_TARGET_PER_ZONE != 1
470 p_dev, 1, 0, 0x06, 0x01, 1);
477 p_dev, 1, 0, 0x06, 0x01, 0);
499 uint8_t cmd[] = {0x00, 0x03, 0x00, 0x00};
502 p_dev->data_read_size = 0;
503 p_dev->streamcount = 255;
527#ifndef VL53L5CX_DISABLE_AMBIENT_PER_SPAD
530#ifndef VL53L5CX_DISABLE_NB_SPADS_ENABLED
533#ifndef VL53L5CX_DISABLE_NB_TARGET_DETECTED
536#ifndef VL53L5CX_DISABLE_SIGNAL_PER_SPAD
539#ifndef VL53L5CX_DISABLE_RANGE_SIGMA_MM
542#ifndef VL53L5CX_DISABLE_DISTANCE_MM
545#ifndef VL53L5CX_DISABLE_REFLECTANCE_PERCENT
548#ifndef VL53L5CX_DISABLE_TARGET_STATUS
551#ifndef VL53L5CX_DISABLE_MOTION_INDICATOR
572 bh_ptr->size = resolution;
689 if((
p_dev->temp_buffer[0] !=
p_dev->streamcount)
747#ifndef VL53L5CX_DISABLE_AMBIENT_PER_SPAD
753#ifndef VL53L5CX_DISABLE_NB_SPADS_ENABLED
759#ifndef VL53L5CX_DISABLE_NB_TARGET_DETECTED
765#ifndef VL53L5CX_DISABLE_SIGNAL_PER_SPAD
771#ifndef VL53L5CX_DISABLE_RANGE_SIGMA_MM
777#ifndef VL53L5CX_DISABLE_DISTANCE_MM
783#ifndef VL53L5CX_DISABLE_REFLECTANCE_PERCENT
789#ifndef VL53L5CX_DISABLE_TARGET_STATUS
795#ifndef VL53L5CX_DISABLE_MOTION_INDICATOR
807#ifndef VL53L5CX_USE_RAW_FORMAT
810#ifndef VL53L5CX_DISABLE_AMBIENT_PER_SPAD
820#ifndef VL53L5CX_DISABLE_DISTANCE_MM
827#ifndef VL53L5CX_DISABLE_REFLECTANCE_PERCENT
830#ifndef VL53L5CX_DISABLE_RANGE_SIGMA_MM
833#ifndef VL53L5CX_DISABLE_SIGNAL_PER_SPAD
839#ifndef VL53L5CX_DISABLE_NB_TARGET_DETECTED
846#ifndef VL53L5CX_DISABLE_TARGET_STATUS
856#ifndef VL53L5CX_DISABLE_MOTION_INDICATOR
909 p_dev->temp_buffer[0x04] = 64;
910 p_dev->temp_buffer[0x06] = 64;
911 p_dev->temp_buffer[0x09] = 4;
919 p_dev->temp_buffer[0x00] = 4;
920 p_dev->temp_buffer[0x01] = 4;
921 p_dev->temp_buffer[0x04] = 8;
922 p_dev->temp_buffer[0x05] = 8;
932 p_dev->temp_buffer[0x04] = 16;
933 p_dev->temp_buffer[0x06] = 16;
934 p_dev->temp_buffer[0x09] = 1;
942 p_dev->temp_buffer[0x00] = 8;
943 p_dev->temp_buffer[0x01] = 8;
944 p_dev->temp_buffer[0x04] = 4;
945 p_dev->temp_buffer[0x05] = 4;
984 (
uint8_t*)&frequency_hz, 1, 0x01);
1132 p_dev->temp_buffer[0x01] = 0x1;
1133 p_dev->temp_buffer[0x03] = 0x3;
1138 p_dev->temp_buffer[0x01] = 0x3;
1139 p_dev->temp_buffer[0x03] = 0x2;
1203 uint8_t cmd[] = {0x00, 0x00, 0x00, 0x00,
1204 0x00, 0x00, 0x00, 0x0f,
1205 0x00, 0x02, 0x00, 0x08};
1214 cmd[0] = (
uint8_t)(index >> 8);
1233 data[i] =
p_dev->temp_buffer[i + 4];
1274 p_dev->temp_buffer[i + 4] = data[i];
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
signed char int8_t
Typedef defining 8 bit char type.
uint8_t vl53l5cx_get_power_mode(VL53L5CX_Configuration *p_dev, uint8_t *p_power_mode)
This function is used to get the current sensor power mode.
uint8_t vl53l5cx_dci_read_data(VL53L5CX_Configuration *p_dev, uint8_t *data, uint32_t index, uint16_t data_size)
This function can be used to read 'extra data' from DCI.
uint8_t vl53l5cx_set_i2c_address(VL53L5CX_Configuration *p_dev, uint16_t i2c_address)
This function is used to change the I2C address of the sensor.
uint8_t vl53l5cx_disable_internal_cp(VL53L5CX_Configuration *p_dev)
This function is used to disable the VCSEL charge pump This optimizes the power consumption of the de...
uint8_t vl53l5cx_set_ranging_frequency_hz(VL53L5CX_Configuration *p_dev, uint8_t frequency_hz)
This function sets a new ranging frequency in Hz.
uint8_t vl53l5cx_get_ranging_mode(VL53L5CX_Configuration *p_dev, uint8_t *p_ranging_mode)
This function is used to get the ranging mode.
uint8_t vl53l5cx_get_sharpener_percent(VL53L5CX_Configuration *p_dev, uint8_t *p_sharpener_percent)
This function gets the current sharpener in percent.
uint8_t vl53l5cx_is_alive(VL53L5CX_Configuration *p_dev, uint8_t *p_is_alive)
uint8_t vl53l5cx_set_power_mode(VL53L5CX_Configuration *p_dev, uint8_t power_mode)
This function is used to set the sensor in Low Power mode, for example if the sensor is not used duri...
uint8_t vl53l5cx_set_integration_time_ms(VL53L5CX_Configuration *p_dev, uint32_t integration_time_ms)
This function sets a new integration time in ms.
static uint8_t _vl53l5cx_send_offset_data(VL53L5CX_Configuration *p_dev, uint8_t resolution)
Inner function, not available outside this file.
uint8_t vl53l5cx_dci_replace_data(VL53L5CX_Configuration *p_dev, uint8_t *data, uint32_t index, uint16_t data_size, uint8_t *new_data, uint16_t new_data_size, uint16_t new_data_pos)
This function can be used to replace 'extra data' in DCI.
uint8_t vl53l5cx_get_integration_time_ms(VL53L5CX_Configuration *p_dev, uint32_t *p_time_ms)
This function gets the current integration time in ms.
uint8_t vl53l5cx_get_ranging_data(VL53L5CX_Configuration *p_dev, VL53L5CX_ResultsData *p_results)
This function gets the ranging data, using the selected output and the resolution.
static uint8_t _vl53l5cx_send_xtalk_data(VL53L5CX_Configuration *p_dev, uint8_t resolution)
Inner function, not available outside this file.
static uint8_t _vl53l5cx_poll_for_answer(VL53L5CX_Configuration *p_dev, uint8_t size, uint8_t pos, uint16_t address, uint8_t mask, uint8_t expected_value)
Copyright (c) 2021 STMicroelectronics.
uint8_t vl53l5cx_init(VL53L5CX_Configuration *p_dev)
Mandatory function used to initialize the sensor.
static uint8_t _vl53l5cx_poll_for_mcu_boot(VL53L5CX_Configuration *p_dev)
uint8_t vl53l5cx_start_ranging(VL53L5CX_Configuration *p_dev)
This function starts a ranging session.
uint8_t vl53l5cx_check_data_ready(VL53L5CX_Configuration *p_dev, uint8_t *p_isReady)
This function checks if a new data is ready by polling I2C.
uint8_t vl53l5cx_set_target_order(VL53L5CX_Configuration *p_dev, uint8_t target_order)
This function sets a new target order.
uint8_t vl53l5cx_set_ranging_mode(VL53L5CX_Configuration *p_dev, uint8_t ranging_mode)
This function is used to set the ranging mode.
uint8_t vl53l5cx_get_ranging_frequency_hz(VL53L5CX_Configuration *p_dev, uint8_t *p_frequency_hz)
This function gets the current ranging frequency in Hz.
uint8_t vl53l5cx_get_resolution(VL53L5CX_Configuration *p_dev, uint8_t *p_resolution)
This function gets the current resolution (4x4 or 8x8).
uint8_t vl53l5cx_dci_write_data(VL53L5CX_Configuration *p_dev, uint8_t *data, uint32_t index, uint16_t data_size)
This function can be used to write 'extra data' to DCI.
uint8_t vl53l5cx_set_resolution(VL53L5CX_Configuration *p_dev, uint8_t resolution)
This function sets a new resolution (4x4 or 8x8).
uint8_t vl53l5cx_stop_ranging(VL53L5CX_Configuration *p_dev)
This function stops the ranging session.
uint8_t vl53l5cx_set_sharpener_percent(VL53L5CX_Configuration *p_dev, uint8_t sharpener_percent)
This function sets a new sharpener value in percent.
uint8_t vl53l5cx_enable_internal_cp(VL53L5CX_Configuration *p_dev)
This function is used to disable the VCSEL charge pump This optimizes the power consumption of the de...
uint8_t vl53l5cx_get_target_order(VL53L5CX_Configuration *p_dev, uint8_t *p_target_order)
This function gets the current target order (closest or strongest).
#define VL53L5CX_DCI_INT_TIME
#define VL53L5CX_MOTION_DETEC_IDX
#define VL53L5CX_SPAD_COUNT_IDX
#define VL53L5CX_DISTANCE_BH
#define VL53L5CX_STATUS_INVALID_PARAM
#define VL53L5CX_MCU_ERROR
#define VL53L5CX_AMBIENT_RATE_BH
#define VL53L5CX_XTALK_BUFFER_SIZE
#define VL53L5CX_STATUS_CORRUPTED_FRAME
#define VL53L5CX_DCI_ZONE_CONFIG
#define VL53L5CX_DCI_RANGING_MODE
#define VL53L5CX_DISTANCE_IDX
#define VL53L5CX_DCI_OUTPUT_LIST
#define VL53L5CX_POWER_MODE_WAKEUP
#define VL53L5CX_STATUS_OK
Macro VL53L5CX_STATUS_OK indicates that VL53L5 sensor has no error.
#define VL53L5CX_DCI_SHARPENER
#define VL53L5CX_METADATA_BH
#define VL53L5CX_TEMPORARY_BUFFER_SIZE
Macro VL53L5CX_TEMPORARY_BUFFER_SIZE can be used to know the size of the temporary buffer.
#define VL53L5CX_TARGET_STATUS_IDX
#define VL53L5CX_DCI_FREQ_HZ
#define VL53L5CX_RANGE_SIGMA_MM_BH
#define VL53L5CX_POWER_MODE_SLEEP
The default power mode is VL53L5CX_POWER_MODE_WAKEUP.
#define VL53L5CX_SIGNAL_RATE_IDX
#define VL53L5CX_RANGE_SIGMA_MM_IDX
#define VL53L5CX_DCI_FW_NB_TARGET
#define VL53L5CX_TARGET_ORDER_CLOSEST
Macro VL53L5CX_TARGET_ORDER_STRONGEST or VL53L5CX_TARGET_ORDER_CLOSEST are used to select the target ...
#define VL53L5CX_DCI_SINGLE_RANGE
#define VL53L5CX_DCI_DSS_CONFIG
#define VL53L5CX_REFLECTANCE_BH
#define VL53L5CX_MOTION_DETECT_BH
#define VL53L5CX_METADATA_IDX
#define VL53L5CX_DCI_OUTPUT_CONFIG
#define VL53L5CX_RESOLUTION_4X4
Macro VL53L5CX_RESOLUTION_4X4 or VL53L5CX_RESOLUTION_8X8 allows setting sensor in 4x4 mode or 8x8 mod...
#define VL53L5CX_NB_TARGET_DETECTED_BH
#define VL53L5CX_START_BH
Definitions for Range results block headers.
#define VL53L5CX_RESOLUTION_8X8
#define VL53L5CX_NB_TARGET_DETECTED_IDX
#define VL53L5CX_RANGING_MODE_CONTINUOUS
Macro VL53L5CX_RANGING_MODE_CONTINUOUS and VL53L5CX_RANGING_MODE_AUTONOMOUS are used to change the ra...
#define VL53L5CX_COMMONDATA_BH
#define VL53L5CX_UI_CMD_START
#define VL53L5CX_DCI_TARGET_ORDER
#define VL53L5CX_DCI_PIPE_CONTROL
#define VL53L5CX_SPAD_COUNT_BH
#define VL53L5CX_UI_CMD_STATUS
#define VL53L5CX_STATUS_ERROR
#define VL53L5CX_NVM_DATA_SIZE
Inner Macro for API.
#define VL53L5CX_TARGET_STATUS_BH
#define VL53L5CX_GLARE_FILTER
#define VL53L5CX_DCI_OUTPUT_ENABLES
#define VL53L5CX_AMBIENT_RATE_IDX
#define VL53L5CX_SIGNAL_RATE_BH
#define VL53L5CX_DCI_INTERNAL_CP
#define VL53L5CX_REFLECTANCE_EST_PC_IDX
#define VL53L5CX_UI_CMD_END
#define VL53L5CX_OFFSET_BUFFER_SIZE
#define VL53L5CX_RANGING_MODE_AUTONOMOUS
#define VL53L5CX_TARGET_ORDER_STRONGEST
#define VL53L5CX_STATUS_TIMEOUT_ERROR
Structure VL53L5CX_Configuration contains the sensor configuration.
Structure VL53L5CX_ResultsData contains the ranging results of VL53L5CX.
const uint8_t VL53L5CX_DEFAULT_CONFIGURATION[]
This buffer contains the VL53L5CX default configuration.
const uint8_t VL53L5CX_FIRMWARE[]
This buffer contains the VL53L5CX firmware (MM1.5)
const uint8_t VL53L5CX_DEFAULT_XTALK[]
This buffer contains the VL53L5CX default Xtalk data.
const uint8_t VL53L5CX_GET_NVM_CMD[]
This buffer is used to get NVM data.