17#ifndef VL53L5CX_API_H_ 
   18#define VL53L5CX_API_H_ 
   20#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION < 6010050) 
   32#define VL53L5CX_API_REVISION     "VL53L5CX_1.3.10" 
   39#define VL53L5CX_DEFAULT_I2C_ADDRESS          ((uint16_t)0x52) 
   47#define VL53L5CX_RESOLUTION_4X4     ((uint8_t) 16U) 
   48#define VL53L5CX_RESOLUTION_8X8     ((uint8_t) 64U) 
   56#define VL53L5CX_TARGET_ORDER_CLOSEST   ((uint8_t) 1U) 
   57#define VL53L5CX_TARGET_ORDER_STRONGEST   ((uint8_t) 2U) 
   66#define VL53L5CX_RANGING_MODE_CONTINUOUS  ((uint8_t) 1U) 
   67#define VL53L5CX_RANGING_MODE_AUTONOMOUS  ((uint8_t) 3U) 
   76#define VL53L5CX_POWER_MODE_SLEEP   ((uint8_t) 0U) 
   77#define VL53L5CX_POWER_MODE_WAKEUP    ((uint8_t) 1U) 
   85#define VL53L5CX_STATUS_OK      ((uint8_t) 0U) 
   86#define VL53L5CX_STATUS_TIMEOUT_ERROR   ((uint8_t) 1U) 
   87#define VL53L5CX_STATUS_CORRUPTED_FRAME   ((uint8_t) 2U) 
   88#define VL53L5CX_STATUS_CRC_CSUM_FAILED   ((uint8_t) 3U) 
   89#define VL53L5CX_STATUS_XTALK_FAILED    ((uint8_t) 4U) 
   90#define VL53L5CX_MCU_ERROR      ((uint8_t) 66U) 
   91#define VL53L5CX_STATUS_INVALID_PARAM   ((uint8_t) 127U) 
   92#define VL53L5CX_STATUS_ERROR     ((uint8_t) 255U) 
   98#if VL53L5CX_NB_TARGET_PER_ZONE == 1 
  100#define VL53L5CX_START_BH       ((uint32_t)0x0000000DU) 
  101#define VL53L5CX_METADATA_BH      ((uint32_t)0x54B400C0U) 
  102#define VL53L5CX_COMMONDATA_BH      ((uint32_t)0x54C00040U) 
  103#define VL53L5CX_AMBIENT_RATE_BH    ((uint32_t)0x54D00104U) 
  104#define VL53L5CX_SPAD_COUNT_BH      ((uint32_t)0x55D00404U) 
  105#define VL53L5CX_NB_TARGET_DETECTED_BH  ((uint32_t)0xDB840401U) 
  106#define VL53L5CX_SIGNAL_RATE_BH     ((uint32_t)0xDBC40404U) 
  107#define VL53L5CX_RANGE_SIGMA_MM_BH    ((uint32_t)0xDEC40402U) 
  108#define VL53L5CX_DISTANCE_BH      ((uint32_t)0xDF440402U) 
  109#define VL53L5CX_REFLECTANCE_BH     ((uint32_t)0xE0440401U) 
  110#define VL53L5CX_TARGET_STATUS_BH   ((uint32_t)0xE0840401U) 
  111#define VL53L5CX_MOTION_DETECT_BH   ((uint32_t)0xD85808C0U) 
  113#define VL53L5CX_METADATA_IDX     ((uint16_t)0x54B4U) 
  114#define VL53L5CX_SPAD_COUNT_IDX     ((uint16_t)0x55D0U) 
  115#define VL53L5CX_AMBIENT_RATE_IDX   ((uint16_t)0x54D0U) 
  116#define VL53L5CX_NB_TARGET_DETECTED_IDX ((uint16_t)0xDB84U) 
  117#define VL53L5CX_SIGNAL_RATE_IDX    ((uint16_t)0xDBC4U) 
  118#define VL53L5CX_RANGE_SIGMA_MM_IDX   ((uint16_t)0xDEC4U) 
  119#define VL53L5CX_DISTANCE_IDX     ((uint16_t)0xDF44U) 
  120#define VL53L5CX_REFLECTANCE_EST_PC_IDX ((uint16_t)0xE044U) 
  121#define VL53L5CX_TARGET_STATUS_IDX    ((uint16_t)0xE084U) 
  122#define VL53L5CX_MOTION_DETEC_IDX   ((uint16_t)0xD858U) 
  125#define VL53L5CX_START_BH       ((uint32_t)0x0000000DU) 
  126#define VL53L5CX_METADATA_BH      ((uint32_t)0x54B400C0U) 
  127#define VL53L5CX_COMMONDATA_BH      ((uint32_t)0x54C00040U) 
  128#define VL53L5CX_AMBIENT_RATE_BH    ((uint32_t)0x54D00104U) 
  129#define VL53L5CX_NB_TARGET_DETECTED_BH  ((uint32_t)0x57D00401U) 
  130#define VL53L5CX_SPAD_COUNT_BH      ((uint32_t)0x55D00404U) 
  131#define VL53L5CX_SIGNAL_RATE_BH     ((uint32_t)0x58900404U) 
  132#define VL53L5CX_RANGE_SIGMA_MM_BH    ((uint32_t)0x64900402U) 
  133#define VL53L5CX_DISTANCE_BH      ((uint32_t)0x66900402U) 
  134#define VL53L5CX_REFLECTANCE_BH     ((uint32_t)0x6A900401U) 
  135#define VL53L5CX_TARGET_STATUS_BH   ((uint32_t)0x6B900401U) 
  136#define VL53L5CX_MOTION_DETECT_BH   ((uint32_t)0xCC5008C0U) 
  138#define VL53L5CX_METADATA_IDX     ((uint16_t)0x54B4U) 
  139#define VL53L5CX_SPAD_COUNT_IDX     ((uint16_t)0x55D0U) 
  140#define VL53L5CX_AMBIENT_RATE_IDX   ((uint16_t)0x54D0U) 
  141#define VL53L5CX_NB_TARGET_DETECTED_IDX ((uint16_t)0x57D0U) 
  142#define VL53L5CX_SIGNAL_RATE_IDX    ((uint16_t)0x5890U) 
  143#define VL53L5CX_RANGE_SIGMA_MM_IDX   ((uint16_t)0x6490U) 
  144#define VL53L5CX_DISTANCE_IDX     ((uint16_t)0x6690U) 
  145#define VL53L5CX_REFLECTANCE_EST_PC_IDX ((uint16_t)0x6A90U) 
  146#define VL53L5CX_TARGET_STATUS_IDX    ((uint16_t)0x6B90U) 
  147#define VL53L5CX_MOTION_DETEC_IDX   ((uint16_t)0xCC50U) 
  155#define VL53L5CX_NVM_DATA_SIZE      ((uint16_t)492U) 
  156#define VL53L5CX_CONFIGURATION_SIZE   ((uint16_t)972U) 
  157#define VL53L5CX_OFFSET_BUFFER_SIZE   ((uint16_t)488U) 
  158#define VL53L5CX_XTALK_BUFFER_SIZE    ((uint16_t)776U) 
  160#define VL53L5CX_DCI_ZONE_CONFIG    ((uint16_t)0x5450U) 
  161#define VL53L5CX_DCI_FREQ_HZ      ((uint16_t)0x5458U) 
  162#define VL53L5CX_DCI_INT_TIME     ((uint16_t)0x545CU) 
  163#define VL53L5CX_DCI_FW_NB_TARGET   ((uint16_t)0x5478) 
  164#define VL53L5CX_DCI_RANGING_MODE   ((uint16_t)0xAD30U) 
  165#define VL53L5CX_DCI_DSS_CONFIG     ((uint16_t)0xAD38U) 
  166#define VL53L5CX_DCI_TARGET_ORDER   ((uint16_t)0xAE64U) 
  167#define VL53L5CX_DCI_SHARPENER      ((uint16_t)0xAED8U) 
  168#define VL53L5CX_DCI_INTERNAL_CP    ((uint16_t)0xB39CU) 
  169#define VL53L5CX_DCI_SYNC_PIN     ((uint16_t)0xB5F0U) 
  170#define VL53L5CX_DCI_MOTION_DETECTOR_CFG ((uint16_t)0xBFACU) 
  171#define VL53L5CX_DCI_SINGLE_RANGE   ((uint16_t)0xD964U) 
  172#define VL53L5CX_DCI_OUTPUT_CONFIG    ((uint16_t)0xD968U) 
  173#define VL53L5CX_DCI_OUTPUT_ENABLES   ((uint16_t)0xD970U) 
  174#define VL53L5CX_DCI_OUTPUT_LIST    ((uint16_t)0xD980U) 
  175#define VL53L5CX_DCI_PIPE_CONTROL   ((uint16_t)0xDB80U) 
  176#define VL53L5CX_GLARE_FILTER     ((uint16_t)0xE108U) 
  179#define VL53L5CX_UI_CMD_STATUS      ((uint16_t)0x2C00U) 
  180#define VL53L5CX_UI_CMD_START     ((uint16_t)0x2C04U) 
  181#define VL53L5CX_UI_CMD_END       ((uint16_t)0x2FFFU) 
  187#ifndef VL53L5CX_DISABLE_AMBIENT_PER_SPAD 
  188#define L5CX_AMB_SIZE 260U 
  190#define L5CX_AMB_SIZE 0U 
  193#ifndef VL53L5CX_DISABLE_NB_SPADS_ENABLED 
  194#define L5CX_SPAD_SIZE  260U 
  196#define L5CX_SPAD_SIZE  0U 
  199#ifndef VL53L5CX_DISABLE_NB_TARGET_DETECTED 
  200#define L5CX_NTAR_SIZE  68U 
  202#define L5CX_NTAR_SIZE  0U 
  205#ifndef VL53L5CX_DISABLE_SIGNAL_PER_SPAD 
  206#define L5CX_SPS_SIZE ((256U * VL53L5CX_NB_TARGET_PER_ZONE) + 4U) 
  208#define L5CX_SPS_SIZE 0U 
  211#ifndef VL53L5CX_DISABLE_RANGE_SIGMA_MM 
  212#define L5CX_SIGR_SIZE ((128U * VL53L5CX_NB_TARGET_PER_ZONE) + 4U) 
  214#define L5CX_SIGR_SIZE  0U 
  217#ifndef VL53L5CX_DISABLE_DISTANCE_MM 
  218#define L5CX_DIST_SIZE ((128U * VL53L5CX_NB_TARGET_PER_ZONE) + 4U) 
  220#define L5CX_DIST_SIZE  0U 
  223#ifndef VL53L5CX_DISABLE_REFLECTANCE_PERCENT 
  224#define L5CX_RFLEST_SIZE ((64U *VL53L5CX_NB_TARGET_PER_ZONE) + 4U) 
  226#define L5CX_RFLEST_SIZE  0U 
  229#ifndef VL53L5CX_DISABLE_TARGET_STATUS 
  230#define L5CX_STA_SIZE ((64U  *VL53L5CX_NB_TARGET_PER_ZONE) + 4U) 
  232#define L5CX_STA_SIZE 0U 
  235#ifndef VL53L5CX_DISABLE_MOTION_INDICATOR 
  236#define L5CX_MOT_SIZE 144U 
  238#define L5CX_MOT_SIZE 0U 
  247#define VL53L5CX_MAX_RESULTS_SIZE ( 40U \ 
  248  + L5CX_AMB_SIZE + L5CX_SPAD_SIZE + L5CX_NTAR_SIZE + L5CX_SPS_SIZE \ 
  249  + L5CX_SIGR_SIZE + L5CX_DIST_SIZE + L5CX_RFLEST_SIZE + L5CX_STA_SIZE \ 
  250  + L5CX_MOT_SIZE + 20U) 
 
  258#if VL53L5CX_MAX_RESULTS_SIZE < 1024U 
  259#define VL53L5CX_TEMPORARY_BUFFER_SIZE ((uint32_t) 1024U) 
  261#define VL53L5CX_TEMPORARY_BUFFER_SIZE ((uint32_t) VL53L5CX_MAX_RESULTS_SIZE) 
  310#ifndef VL53L5CX_DISABLE_AMBIENT_PER_SPAD 
  315#ifndef VL53L5CX_DISABLE_NB_TARGET_DETECTED 
  320#ifndef VL53L5CX_DISABLE_NB_SPADS_ENABLED 
  325#ifndef VL53L5CX_DISABLE_SIGNAL_PER_SPAD 
  331#ifndef VL53L5CX_DISABLE_RANGE_SIGMA_MM 
  337#ifndef VL53L5CX_DISABLE_DISTANCE_MM 
  343#ifndef VL53L5CX_DISABLE_REFLECTANCE_PERCENT 
  349#ifndef VL53L5CX_DISABLE_TARGET_STATUS 
  355#ifndef VL53L5CX_DISABLE_MOTION_INDICATOR 
  361    uint8_t  nb_of_detected_aggregates;
 
 
 
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.
#define VL53L5CX_XTALK_BUFFER_SIZE
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.
#define VL53L5CX_TEMPORARY_BUFFER_SIZE
Macro VL53L5CX_TEMPORARY_BUFFER_SIZE can be used to know the size of the temporary buffer.
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.
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.
#define VL53L5CX_RESOLUTION_8X8
uint8_t vl53l5cx_init(VL53L5CX_Configuration *p_dev)
Mandatory function used to initialize the sensor.
uint8_t * default_configuration
uint8_t vl53l5cx_start_ranging(VL53L5CX_Configuration *p_dev)
This function starts a ranging session.
VL53L5CX_Platform platform
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 is_auto_stop_enabled
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).
#define VL53L5CX_OFFSET_BUFFER_SIZE
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).
Structure VL53L5CX_Configuration contains the sensor configuration.
Structure VL53L5CX_ResultsData contains the ranging results of VL53L5CX.