57 }
while ((p_dev->
temp_buffer[pos] & mask) != expected_value);
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};
113 (void)memcpy(&(p_dev->
temp_buffer[0x10]), dss_4x4,
sizeof(dss_4x4));
115 (void)memcpy(signal_grid,&(p_dev->
temp_buffer[0x3C]),
116 sizeof(signal_grid));
117 (void)memcpy(range_grid,&(p_dev->
temp_buffer[0x140]),
120 for (j = 0; j < (
int8_t)4; j++)
122 for (i = 0; i < (
int8_t)4 ; i++)
124 signal_grid[i+(4*j)] =
125 (signal_grid[(2*i)+(16*j)+ (
int8_t)0]
126 + signal_grid[(2*i)+(16*j)+(
int8_t)1]
127 + signal_grid[(2*i)+(16*j)+(
int8_t)8]
128 + signal_grid[(2*i)+(16*j)+(
int8_t)9])
130 range_grid[i+(4*j)] =
131 (range_grid[(2*i)+(16*j)]
132 + range_grid[(2*i)+(16*j)+1]
133 + range_grid[(2*i)+(16*j)+8]
134 + range_grid[(2*i)+(16*j)+9])
138 (void)memset(&range_grid[0x10], 0, (
uint16_t)96);
139 (void)memset(&signal_grid[0x10], 0, (
uint16_t)192);
141 signal_grid,
sizeof(signal_grid));
143 range_grid,
sizeof(range_grid));
152 (void)memcpy(&(p_dev->
temp_buffer[0x1E0]), footer, 8);
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};
173 uint8_t profile_4x4[] = {0xA0, 0xFC, 0x01, 0x00};
184 res4x4,
sizeof(res4x4));
186 dss_4x4,
sizeof(dss_4x4));
189 (void)memcpy(signal_grid, &(p_dev->
temp_buffer[0x34]),
190 sizeof(signal_grid));
192 for (j = 0; j < (
int8_t)4; j++)
194 for (i = 0; i < (
int8_t)4 ; i++)
196 signal_grid[i+(4*j)] =
197 (signal_grid[(2*i)+(16*j)+0]
198 + signal_grid[(2*i)+(16*j)+1]
199 + signal_grid[(2*i)+(16*j)+8]
200 + signal_grid[(2*i)+(16*j)+9])/(
uint32_t)4;
203 (void)memset(&signal_grid[0x10], 0, (
uint32_t)192);
205 signal_grid,
sizeof(signal_grid));
208 profile_4x4,
sizeof(profile_4x4));
226 uint8_t device_id = 0, revision_id = 0;
233 if((device_id == (
uint8_t)0xF0) && (revision_id == (
uint8_t)0x02))
391 #if VL53L5CX_NB_TARGET_PER_ZONE != 1
462 if(power_mode != current_power_mode)
470 p_dev, 1, 0, 0x06, 0x01, 1);
477 p_dev, 1, 0, 0x06, 0x01, 0);
499 uint8_t cmd[] = {0x00, 0x03, 0x00, 0x00};
527 #ifndef VL53L5CX_DISABLE_AMBIENT_PER_SPAD
530 #ifndef VL53L5CX_DISABLE_NB_SPADS_ENABLED
531 output_bh_enable[0] += (
uint32_t)16;
533 #ifndef VL53L5CX_DISABLE_NB_TARGET_DETECTED
534 output_bh_enable[0] += (
uint32_t)32;
536 #ifndef VL53L5CX_DISABLE_SIGNAL_PER_SPAD
537 output_bh_enable[0] += (
uint32_t)64;
539 #ifndef VL53L5CX_DISABLE_RANGE_SIGMA_MM
540 output_bh_enable[0] += (
uint32_t)128;
542 #ifndef VL53L5CX_DISABLE_DISTANCE_MM
543 output_bh_enable[0] += (
uint32_t)256;
545 #ifndef VL53L5CX_DISABLE_REFLECTANCE_PERCENT
546 output_bh_enable[0] += (
uint32_t)512;
548 #ifndef VL53L5CX_DISABLE_TARGET_STATUS
549 output_bh_enable[0] += (
uint32_t)1024;
551 #ifndef VL53L5CX_DISABLE_MOTION_INDICATOR
552 output_bh_enable[0] += (
uint32_t)2048;
559 || ((output_bh_enable[i/(
uint32_t)32]
569 if ((bh_ptr->idx >= (
uint16_t)0x54d0)
570 && (bh_ptr->idx < (
uint16_t)(0x54d0 + 960)))
572 bh_ptr->size = resolution;
602 (
uint16_t)
sizeof(output_bh_enable));
618 (void)memcpy(&tmp, &(p_dev->
temp_buffer[0x8]),
sizeof(tmp));
635 0x2FFC, (
uint8_t*)&auto_stop_flag, 4);
636 if((auto_stop_flag != (
uint32_t)0x4FF)
734 msize = bh_ptr->type * bh_ptr->size;
738 msize = bh_ptr->size;
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
875 if(header_id != footer_id)
984 (
uint8_t*)&frequency_hz, 1, 0x01);
998 (void)memcpy(p_time_ms, &(p_dev->
temp_buffer[0x0]), 4);
1009 uint32_t integration = integration_time_ms;
1022 (
uint8_t*)&integration, 4, 0x00);
1050 if(sharpener_percent >= (
uint8_t)100)
1059 (
uint8_t*)&sharpener, 1, 0xD);
1089 (
uint8_t*)&target_order, 1, 0x0);
1129 switch(ranging_mode)
1134 single_range = 0x00;
1140 single_range = 0x01;
1163 uint8_t analog_dynamic_pad_0 = 0;
1167 (
uint8_t*)&vcsel_bootup_fsm, 1, 0x0A);
1171 (
uint8_t*)&analog_dynamic_pad_0, 1, 0x0E);
1181 uint8_t analog_dynamic_pad_0 = 1;
1185 (
uint8_t*)&vcsel_bootup_fsm, 1, 0x0A);
1189 (
uint8_t*)&analog_dynamic_pad_0, 1, 0x0E);
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);
1232 for(i = 0 ; i < (
int16_t)data_size;i++){
1249 uint8_t headers[] = {0x00, 0x00, 0x00, 0x00};
1250 uint8_t footer[] = {0x00, 0x00, 0x00, 0x0f, 0x05, 0x01,
1265 headers[0] = (
uint8_t)(index >> 8);
1278 (void)memcpy(&p_dev->
temp_buffer[0], headers,
sizeof(headers));
1280 footer,
sizeof(footer));
1307 (void)memcpy(&(data[new_data_pos]), new_data, new_data_size);
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
uint8_t xtalk_data[VL53L5CX_XTALK_BUFFER_SIZE]
#define VL53L5CX_MCU_ERROR
uint16_t range_sigma_mm[(VL53L5CX_RESOLUTION_8X8 *VL53L5CX_NB_TARGET_PER_ZONE)]
#define VL53L5CX_AMBIENT_RATE_BH
uint8_t target_status[(VL53L5CX_RESOLUTION_8X8 *VL53L5CX_NB_TARGET_PER_ZONE)]
#define VL53L5CX_XTALK_BUFFER_SIZE
#define VL53L5CX_STATUS_CORRUPTED_FRAME
#define VL53L5CX_DCI_ZONE_CONFIG
uint32_t nb_spads_enabled[VL53L5CX_RESOLUTION_8X8]
#define VL53L5CX_DCI_RANGING_MODE
int16_t distance_mm[(VL53L5CX_RESOLUTION_8X8 *VL53L5CX_NB_TARGET_PER_ZONE)]
#define VL53L5CX_DISTANCE_IDX
#define VL53L5CX_DCI_OUTPUT_LIST
struct VL53L5CX_ResultsData::@352 motion_indicator
#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.
uint8_t nb_target_detected[VL53L5CX_RESOLUTION_8X8]
#define VL53L5CX_TARGET_STATUS_IDX
#define VL53L5CX_DCI_FREQ_HZ
#define VL53L5CX_RANGE_SIGMA_MM_BH
uint8_t temp_buffer[VL53L5CX_TEMPORARY_BUFFER_SIZE]
#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
uint32_t signal_per_spad[(VL53L5CX_RESOLUTION_8X8 *VL53L5CX_NB_TARGET_PER_ZONE)]
#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
uint32_t ambient_per_spad[VL53L5CX_RESOLUTION_8X8]
#define VL53L5CX_RANGING_MODE_CONTINUOUS
Macro VL53L5CX_RANGING_MODE_CONTINUOUS and VL53L5CX_RANGING_MODE_AUTONOMOUS are used to change the ra...
uint8_t * default_configuration
#define VL53L5CX_COMMONDATA_BH
#define VL53L5CX_UI_CMD_START
#define VL53L5CX_DCI_TARGET_ORDER
#define VL53L5CX_DCI_PIPE_CONTROL
VL53L5CX_Platform platform
#define VL53L5CX_SPAD_COUNT_BH
#define VL53L5CX_UI_CMD_STATUS
#define VL53L5CX_STATUS_ERROR
#define VL53L5CX_NVM_DATA_SIZE
Inner Macro for API.
uint8_t is_auto_stop_enabled
uint8_t offset_data[VL53L5CX_OFFSET_BUFFER_SIZE]
#define VL53L5CX_TARGET_STATUS_BH
#define VL53L5CX_GLARE_FILTER
uint8_t reflectance[(VL53L5CX_RESOLUTION_8X8 *VL53L5CX_NB_TARGET_PER_ZONE)]
#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.