ST / VL53L0X

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   HelloWorld_ST_Sensors mbed-os-mqtt-client Multi_VL53L0X DISCO-IOT01_HomeEnv ... more

Fork of VL53L0X by Nicola Capovilla

Embed: (wiki syntax)

« Back to documentation index

VL53L0X Class Reference

VL53L0X Class Reference

Class representing a VL53L0 sensor component. More...

#include <VL53L0X.h>

Public Member Functions

 VL53L0X (DevI2C *i2c, DigitalOut *pin, PinName pin_gpio1, uint8_t dev_addr=VL53L0X_DEFAULT_ADDRESS)
 Constructor.
 VL53L0X (DevI2C *i2c, Stmpe1600DigiOut *pin, PinName pin_gpio1, uint8_t dev_addr=VL53L0X_DEFAULT_ADDRESS)
 Constructor 2 (STMPE1600DigiOut)
virtual ~VL53L0X ()
 Destructor.
void VL53L0X_on (void)
 PowerOn the sensor.
void VL53L0X_off (void)
 PowerOff the sensor.
int init_sensor (uint8_t new_addr)
 Initialize the sensor with default values.
int start_measurement (OperatingMode operating_mode, void(*fptr)(void))
 Start the measure indicated by operating mode.
int get_measurement (OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *p_data)
 Get results for the measure indicated by operating mode.
int stop_measurement (OperatingMode operating_mode)
 Stop the currently running measure indicate by operating_mode.
int handle_irq (OperatingMode operating_mode, VL53L0X_RangingMeasurementData_t *data)
 Interrupt handling func to be called by user after an INT is occourred.
void enable_interrupt_measure_detection_irq (void)
 Enable interrupt measure IRQ.
void disable_interrupt_measure_detection_irq (void)
 Disable interrupt measure IRQ.
void attach_interrupt_measure_detection_irq (void(*fptr)(void))
 Attach a function to call when an interrupt is detected, i.e.
virtual int init (void *init)
 One time device initialization.
int prepare ()
 Prepare device for operation.
int range_start_continuous_mode ()
 Start continuous ranging mode.
virtual int get_distance (uint32_t *p_data)
 Get ranging result and only that.
int set_device_address (int new_addr)
 Set new device i2c address.
int clear_interrupt (uint8_t int_clear)
 Clear given system interrupt condition.
VL53L0X_Error vl53l0x_get_device (VL53L0X_DEV *dev)
 Get the 53L0 device.
VL53L0X_Error VL53L0X_data_init (VL53L0X_DEV dev)
 One time device initialization.
VL53L0X_Error VL53L0X_static_init (VL53L0X_DEV dev)
 Do basic device init (and eventually patch loading) This function will change the VL53L0X_State from VL53L0X_STATE_WAIT_STATICINIT to VL53L0X_STATE_IDLE.
VL53L0X_Error VL53L0X_perform_ref_calibration (VL53L0X_DEV dev, uint8_t *p_vhv_settings, uint8_t *p_phase_cal)
 Perform Reference Calibration.
VL53L0X_Error VL53L0X_get_ref_calibration (VL53L0X_DEV dev, uint8_t *p_vhv_settings, uint8_t *p_phase_cal)
 Get Reference Calibration Parameters.
VL53L0X_Error VL53L0X_perform_ref_spad_management (VL53L0X_DEV dev, uint32_t *ref_spad_count, uint8_t *is_aperture_spads)
 Performs Reference Spad Management.
VL53L0X_Error VL53L0X_set_reference_spads (VL53L0X_DEV dev, uint32_t refSpadCount, uint8_t is_aperture_spads)
 Applies Reference SPAD configuration.
VL53L0X_Error VL53L0X_get_reference_spads (VL53L0X_DEV dev, uint32_t *p_spad_count, uint8_t *p_is_aperture_spads)
 Retrieves SPAD configuration.
VL53L0X_Error VL53L0X_get_offset_calibration_data_micro_meter (VL53L0X_DEV dev, int32_t *p_offset_calibration_data_micro_meter)
 Get part to part calibration offset.
VL53L0X_Error VL53L0X_set_offset_calibration_data_micro_meter (VL53L0X_DEV dev, int32_t offset_calibration_data_micro_meter)
 Set or over-hide part to part calibration offset.
VL53L0X_Error VL53L0X_perform_xtalk_measurement (VL53L0X_DEV dev, uint32_t timeout_ms, FixPoint1616_t *p_xtalk_per_spad, uint8_t *p_ambient_too_high)
 Perform XTalk Measurement.
VL53L0X_Error VL53L0X_set_x_talk_compensation_enable (VL53L0X_DEV dev, uint8_t x_talk_compensation_enable)
 Enable/Disable Cross talk compensation feature.
VL53L0X_Error VL53L0X_get_x_talk_compensation_enable (VL53L0X_DEV dev, uint8_t *p_x_talk_compensation_enable)
 Get Cross talk compensation rate.
VL53L0X_Error VL53L0X_set_x_talk_compensation_rate_mega_cps (VL53L0X_DEV dev, FixPoint1616_t x_talk_compensation_rate_mega_cps)
 Set Cross talk compensation rate.
VL53L0X_Error VL53L0X_get_x_talk_compensation_rate_mega_cps (VL53L0X_DEV dev, FixPoint1616_t *p_xtalk_compensation_rate_mega_cps)
 Get Cross talk compensation rate.
VL53L0X_Error VL53L0X_set_device_mode (VL53L0X_DEV dev, VL53L0X_DeviceModes device_mode)
 Set a new device mode.
VL53L0X_Error VL53L0X_get_device_mode (VL53L0X_DEV dev, VL53L0X_DeviceModes *p_device_mode)
 Get current new device mode.
VL53L0X_Error VL53L0X_get_gpio_config (VL53L0X_DEV dev, uint8_t pin, VL53L0X_DeviceModes *p_device_mode, VL53L0X_GpioFunctionality *p_functionality, VL53L0X_InterruptPolarity *p_polarity)
 Get current configuration for GPIO pin for a given device.
VL53L0X_Error VL53L0X_set_gpio_config (VL53L0X_DEV dev, uint8_t pin, VL53L0X_DeviceModes device_mode, VL53L0X_GpioFunctionality functionality, VL53L0X_InterruptPolarity polarity)
 Set the configuration of GPIO pin for a given device.
VL53L0X_Error VL53L0X_start_measurement (VL53L0X_DEV dev)
 Start device measurement.
VL53L0X_Error VL53L0X_stop_measurement (VL53L0X_DEV dev)
 Stop device measurement.
VL53L0X_Error VL53L0X_get_stop_completed_status (VL53L0X_DEV dev, uint32_t *p_stop_status)
 Return device stop completion status.
VL53L0X_Error VL53L0X_get_measurement_data_ready (VL53L0X_DEV dev, uint8_t *p_measurement_data_ready)
 Return Measurement Data Ready.
VL53L0X_Error VL53L0X_get_ranging_measurement_data (VL53L0X_DEV dev, VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data)
 Retrieve the measurements from device for a given setup.
VL53L0X_Error VL53L0X_clear_interrupt_mask (VL53L0X_DEV dev, uint32_t interrupt_mask)
 Clear given system interrupt condition.
VL53L0X_Error VL53L0X_get_interrupt_mask_status (VL53L0X_DEV dev, uint32_t *p_interrupt_mask_status)
 Return device interrupt status.
VL53L0X_Error VL53L0X_perform_single_ranging_measurement (VL53L0X_DEV dev, VL53L0X_RangingMeasurementData_t *p_ranging_measurement_data)
 Performs a single ranging measurement and retrieve the ranging measurement data.
VL53L0X_Error VL53L0X_perform_single_measurement (VL53L0X_DEV dev)
 Single shot measurement.
VL53L0X_Error VL53L0X_get_device_error_status (VL53L0X_DEV dev, VL53L0X_DeviceError *p_device_error_status)
 Read current status of the error register for the selected device.
VL53L0X_Error VL53L0X_get_device_error_string (VL53L0X_DeviceError error_code, char *p_device_error_string)
 Human readable error string for a given Error Code.
VL53L0X_Error VL53L0X_get_range_status_string (uint8_t range_status, char *p_range_status_string)
 Human readable Range Status string for a given RangeStatus.
VL53L0X_Error VL53L0X_get_measurement_timing_budget_micro_seconds (VL53L0X_DEV dev, uint32_t *p_measurement_timing_budget_micro_seconds)
 Get Ranging Timing Budget in microseconds.
VL53L0X_Error VL53L0X_set_measurement_timing_budget_micro_seconds (VL53L0X_DEV dev, uint32_t measurement_timing_budget_micro_seconds)
 Set Ranging Timing Budget in microseconds.
VL53L0X_Error VL53L0X_get_limit_check_enable (VL53L0X_DEV dev, uint16_t limit_check_id, uint8_t *p_limit_check_enable)
 Get specific limit check enable state.
VL53L0X_Error VL53L0X_set_limit_check_enable (VL53L0X_DEV dev, uint16_t limit_check_id, uint8_t limit_check_enable)
 Enable/Disable a specific limit check.
VL53L0X_Error VL53L0X_get_limit_check_value (VL53L0X_DEV dev, uint16_t limit_check_id, FixPoint1616_t *p_limit_check_value)
 Get a specific limit check value.
VL53L0X_Error VL53L0X_set_limit_check_value (VL53L0X_DEV dev, uint16_t limit_check_id, FixPoint1616_t limit_check_value)
 Set a specific limit check value.
VL53L0X_Error VL53L0X_get_limit_check_current (VL53L0X_DEV dev, uint16_t limit_check_id, FixPoint1616_t *p_limit_check_current)
 Get the current value of the signal used for the limit check.
VL53L0X_Error VL53L0X_get_limit_check_status (VL53L0X_DEV dev, uint16_t limit_check_id, uint8_t *p_limit_check_status)
 Return a the Status of the specified check limit.
VL53L0X_Error VL53L0X_get_inter_measurement_period_milli_seconds (VL53L0X_DEV dev, uint32_t *p_inter_measurement_period_milli_seconds)
 Get continuous mode Inter-Measurement period in milliseconds.
VL53L0X_Error VL53L0X_set_inter_measurement_period_milli_seconds (VL53L0X_DEV dev, uint32_t inter_measurement_period_milli_seconds)
 Program continuous mode Inter-Measurement period in milliseconds.
VL53L0X_Error VL53L0X_set_device_address (VL53L0X_DEV dev, uint8_t device_address)
 Set new device address.
VL53L0X_Error VL53L0X_reset_device (VL53L0X_DEV dev)
 Do an hard reset or soft reset (depending on implementation) of the device call of this function, device must be in same state as right after a power-up sequence.This function will change the VL53L0X_State to VL53L0X_STATE_POWERDOWN.
VL53L0X_Error VL53L0X_get_wrap_around_check_enable (VL53L0X_DEV dev, uint8_t *p_wrap_around_check_enable)
 Get setup of Wrap around Check.
VL53L0X_Error VL53L0X_set_wrap_around_check_enable (VL53L0X_DEV dev, uint8_t wrap_around_check_enable)
 Enable (or disable) Wrap around Check.
VL53L0X_Error VL53L0X_get_vcsel_pulse_period (VL53L0X_DEV dev, VL53L0X_VcselPeriod vcsel_period_type, uint8_t *p_vcsel_pulse_period_pclk)
 Gets the VCSEL pulse period.
VL53L0X_Error VL53L0X_set_vcsel_pulse_period (VL53L0X_DEV dev, VL53L0X_VcselPeriod vcsel_period_type, uint8_t vcsel_pulse_period)
 Sets the VCSEL pulse period.
VL53L0X_Error VL53L0X_set_interrupt_thresholds (VL53L0X_DEV dev, VL53L0X_DeviceModes device_mode, FixPoint1616_t threshold_low, FixPoint1616_t threshold_high)
 Set low and high Interrupt thresholds for a given mode (ranging, ALS, ...) for a given device.
VL53L0X_Error VL53L0X_get_interrupt_thresholds (VL53L0X_DEV dev, VL53L0X_DeviceModes device_mode, FixPoint1616_t *p_threshold_low, FixPoint1616_t *p_threshold_high)
 Get high and low Interrupt thresholds for a given mode (ranging, ALS, ...) for a given device.
VL53L0X_Error VL53L0X_get_device_info (VL53L0X_DEV dev, VL53L0X_DeviceInfo_t *p_VL53L0X_device_info)
 Reads the Device information for given Device.
VL53L0X_Error VL53L0X_get_sequence_step_enables (VL53L0X_DEV dev, VL53L0X_SchedulerSequenceSteps_t *p_scheduler_sequence_steps)
 Gets the (on/off) state of all sequence steps.
VL53L0X_Error VL53L0X_set_sequence_step_enable (VL53L0X_DEV dev, VL53L0X_SequenceStepId sequence_step_id, uint8_t sequence_step_enabled)
 Sets the (on/off) state of a requested sequence step.
VL53L0X_Error VL53L0X_get_fraction_enable (VL53L0X_DEV dev, uint8_t *p_enabled)
 Gets the fraction enable parameter indicating the resolution of range measurements.
VL53L0X_Error VL53L0X_set_range_fraction_enable (VL53L0X_DEV dev, uint8_t enable)
 Sets the resolution of range measurements.
VL53L0X_Error VL53L0X_get_version (VL53L0X_Version_t *p_version)
 Return the VL53L0X PAL Implementation Version.
VL53L0X_Error VL53L0X_get_product_revision (VL53L0X_DEV dev, uint8_t *p_product_revision_major, uint8_t *p_product_revision_minor)
 Reads the Product Revision for a for given Device This function can be used to distinguish cut1.0 from cut1.1.
VL53L0X_Error VL53L0X_get_device_parameters (VL53L0X_DEV dev, VL53L0X_DeviceParameters_t *p_device_parameters)
 Retrieve current device parameters.
VL53L0X_Error VL53L0X_get_pal_error_string (VL53L0X_Error pal_error_code, char *p_pal_error_string)
 Human readable error string for current PAL error status.
VL53L0X_Error VL53L0X_get_pal_spec_version (VL53L0X_Version_t *p_pal_spec_version)
 Return the PAL Specification Version used for the current implementation.
VL53L0X_Error VL53L0X_get_pal_state (VL53L0X_DEV dev, VL53L0X_State *p_pal_state)
 Reads the internal state of the PAL for a given Device.
VL53L0X_Error VL53L0X_get_pal_state_string (VL53L0X_State pal_state_code, char *p_pal_state_string)
 Human readable PAL State string.

Detailed Description

Class representing a VL53L0 sensor component.

Definition at line 292 of file VL53L0X.h.


Constructor & Destructor Documentation

VL53L0X ( DevI2C *  i2c,
DigitalOut *  pin,
PinName  pin_gpio1,
uint8_t  dev_addr = VL53L0X_DEFAULT_ADDRESS 
)

Constructor.

Parameters:
[in]&i2cdevice I2C to be used for communication
[in]&pin_gpio1pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
[in]dev_addrdevice address, 0x29 by default

Definition at line 300 of file VL53L0X.h.

VL53L0X ( DevI2C *  i2c,
Stmpe1600DigiOut pin,
PinName  pin_gpio1,
uint8_t  dev_addr = VL53L0X_DEFAULT_ADDRESS 
)

Constructor 2 (STMPE1600DigiOut)

Parameters:
[in]i2cdevice I2C to be used for communication
[in]&pinGpio Expander STMPE1600DigiOut pin to be used as component GPIO_0 CE
[in]pin_gpio1pin Mbed InterruptIn PinName to be used as component GPIO_1 INT
[in]deviceaddress, 0x29 by default

Definition at line 321 of file VL53L0X.h.

virtual ~VL53L0X (  ) [virtual]

Destructor.

Definition at line 338 of file VL53L0X.h.


Member Function Documentation

void attach_interrupt_measure_detection_irq ( void(*)(void)  fptr )

Attach a function to call when an interrupt is detected, i.e.

measurement is ready

Parameters:
[in]fptrpointer to call back function to be called whenever an interrupt occours
Returns:
"0" on success

Definition at line 446 of file VL53L0X.h.

int clear_interrupt ( uint8_t  int_clear )

Clear given system interrupt condition.

Function Description
Clear given interrupt cause by writing into register SYSTEM_INTERRUPT_CLEAR register.
Parameters:
devThe device
int_clearWhich interrupt source to clear. Use any combinations of INTERRUPT_CLEAR_RANGING , INTERRUPT_CLEAR_ALS , INTERRUPT_CLEAR_ERROR.
Returns:
"0" on success

Definition at line 606 of file VL53L0X.h.

void disable_interrupt_measure_detection_irq ( void   )

Disable interrupt measure IRQ.

Returns:
"0" on success

Definition at line 434 of file VL53L0X.h.

void enable_interrupt_measure_detection_irq ( void   )

Enable interrupt measure IRQ.

Returns:
"0" on success

Definition at line 423 of file VL53L0X.h.

int set_device_address ( int  new_addr )

Set new device i2c address.

After completion the device will answer to the new address programmed.

Parameters:
new_addrThe new i2c address (7bit)
Returns:
"0" on success

Definition at line 585 of file VL53L0X.h.

VL53L0X_Error VL53L0X_clear_interrupt_mask ( VL53L0X_DEV  dev,
uint32_t  interrupt_mask 
)

Clear given system interrupt condition.

Function Description
Clear given interrupt(s).
Note:
This function Access to the device
Parameters:
devDevice Handle
interrupt_maskMask of interrupts to clear
Returns:
VL53L0X_ERROR_NONE Success
VL53L0X_ERROR_INTERRUPT_NOT_CLEARED Cannot clear interrupts
"Other error code" See VL53L0X_Error

Definition at line 1878 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_data_init ( VL53L0X_DEV  dev )

One time device initialization.

To be called once and only once after device is brought out of reset (Chip enable) and booted see VL53L0X_WaitDeviceBooted()

Function Description
When not used after a fresh device "power up" or reset, it may return VL53L0X_ERROR_CALIBRATION_WARNING meaning wrong calibration data may have been fetched from device that can result in ranging offset error
If application cannot execute device reset or need to run VL53L0X_DataInit multiple time then it must ensure proper offset calibration saving and restore on its own by using VL53L0X_GetOffsetCalibrationData() on first power up and then VL53L0X_SetOffsetCalibrationData() in all subsequent init This function will change the VL53L0X_State from VL53L0X_STATE_POWERDOWN to VL53L0X_STATE_WAIT_STATICINIT.
Note:
This function accesses to the device
Parameters:
devDevice Handle
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

Definition at line 1546 of file VL53L0X.cpp.

VL53L0X_Error vl53l0x_get_device ( VL53L0X_DEV dev )

Get the 53L0 device.

To be called to retrive the internal device descriptor to allow usage of low level API having device as parameter. To be called after set_device_address() (if any).

Function Description
To be called if low level API usage is needed as those functions requires device as a parameter.TICINIT.
Note:
This function return a pointer to an object internal structure
Parameters:
devptr to ptr to Device Handle
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

Definition at line 629 of file VL53L0X.h.

VL53L0X_Error VL53L0X_get_device_error_status ( VL53L0X_DEV  dev,
VL53L0X_DeviceError *  p_device_error_status 
)

Read current status of the error register for the selected device.

Note:
This function Access to the device
Parameters:
devDevice Handle
p_device_error_statusPointer to current error code of the device
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_get_device_error_string ( VL53L0X_DeviceError  error_code,
char *  p_device_error_string 
)

Human readable error string for a given Error Code.

Note:
This function doesn't access to the device
Parameters:
error_codeThe error code as stored on VL53L0X_DeviceError
p_device_error_stringThe error string corresponding to the ErrorCode
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_get_device_info ( VL53L0X_DEV  dev,
VL53L0X_DeviceInfo_t p_VL53L0X_device_info 
)

Reads the Device information for given Device.

Note:
This function Access to the device
Parameters:
devDevice Handle
p_VL53L0X_device_infoPointer to current device info for a given Device
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

Definition at line 1767 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_get_device_mode ( VL53L0X_DEV  dev,
VL53L0X_DeviceModes *  p_device_mode 
)

Get current new device mode.

Function Description
Get actual mode of the device(ranging, histogram ...)
Note:
This function doesn't Access to the device
Parameters:
devDevice Handle
p_device_modePointer to current apply mode value Valid values are: VL53L0X_DEVICEMODE_SINGLE_RANGING VL53L0X_DEVICEMODE_CONTINUOUS_RANGING VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY VL53L0X_HISTOGRAMMODE_RETURN_ONLY VL53L0X_HISTOGRAMMODE_BOTH
Returns:
VL53L0X_ERROR_NONE Success
VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when DeviceMode is not in the supported list

Definition at line 519 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_get_device_parameters ( VL53L0X_DEV  dev,
VL53L0X_DeviceParameters_t p_device_parameters 
)

Retrieve current device parameters.

Function Description
Get actual parameters of the device
  • Then start ranging operation.
Note:
This function Access to the device
Parameters:
devDevice Handle
p_device_parametersPointer to store current device parameters.
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

Definition at line 1404 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_get_gpio_config ( VL53L0X_DEV  dev,
uint8_t  pin,
VL53L0X_DeviceModes *  p_device_mode,
VL53L0X_GpioFunctionality *  p_functionality,
VL53L0X_InterruptPolarity *  p_polarity 
)

Get current configuration for GPIO pin for a given device.

Note:
This function Access to the device
Parameters:
devDevice Handle
pinID of the GPIO Pin
p_device_modePointer to Device Mode associated to the Gpio.
p_functionalityPointer to Pin functionality. Refer to VL53L0X_GpioFunctionality
p_polarityPointer to interrupt polarity. Active high or active low see VL53L0X_InterruptPolarity
Returns:
VL53L0X_ERROR_NONE Success
VL53L0X_ERROR_GPIO_NOT_EXISTING Only Pin=0 is accepted.
VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED This error occurs when Funcionality programmed is not in the supported list: Supported value are: VL53L0X_GPIOFUNCTIONALITY_OFF, VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_LOW, VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_HIGH, VL53L0X_GPIOFUNCTIONALITY_THRESHOLD_CROSSED_OUT, VL53L0X_GPIOFUNCTIONALITY_NEW_MEASURE_READY
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_get_inter_measurement_period_milli_seconds ( VL53L0X_DEV  dev,
uint32_t *  p_inter_measurement_period_milli_seconds 
)

Get continuous mode Inter-Measurement period in milliseconds.

Function Description
When trying to set too short time return INVALID_PARAMS minimal value
Note:
This function Access to the device
Parameters:
devDevice Handle
p_inter_measurement_period_milli_secondsPointer to programmed Inter-Measurement Period in milliseconds.
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

Definition at line 531 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_get_interrupt_mask_status ( VL53L0X_DEV  dev,
uint32_t *  p_interrupt_mask_status 
)

Return device interrupt status.

Function Description
Returns currently raised interrupts by the device. User shall be able to activate/deactivate interrupts through VL53L0X_SetGpioConfig()
Note:
This function Access to the device
Parameters:
devDevice Handle
p_interrupt_mask_statusPointer to status variable to update
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

Definition at line 1779 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_get_interrupt_thresholds ( VL53L0X_DEV  dev,
VL53L0X_DeviceModes  device_mode,
FixPoint1616_t *  p_threshold_low,
FixPoint1616_t *  p_threshold_high 
)

Get high and low Interrupt thresholds for a given mode (ranging, ALS, ...) for a given device.

Function Description
Get high and low Interrupt thresholds for a given mode (ranging, ALS, ...) for a given device
Note:
This function Access to the device
DeviceMode is ignored for the current device
Parameters:
devDevice Handle
device_modeDevice Mode from which read thresholds
p_threshold_lowLow threshold (mm, lux ..., depending on the mode)
p_threshold_highHigh threshold (mm, lux ..., depending on the mode)
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

Definition at line 2333 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_get_limit_check_current ( VL53L0X_DEV  dev,
uint16_t  limit_check_id,
FixPoint1616_t *  p_limit_check_current 
)

Get the current value of the signal used for the limit check.

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 ranging before. The value reported is linked to the limit check identified with the LimitCheckId.
Note:
This function Access to the device
Parameters:
devDevice Handle
limit_check_idLimit Check ID (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
p_limit_check_currentPointer to current Value for a given LimitCheckId.
Returns:
VL53L0X_ERROR_NONE Success
VL53L0X_ERROR_INVALID_PARAMS This error is returned when LimitCheckId value is out of range.
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_get_limit_check_enable ( VL53L0X_DEV  dev,
uint16_t  limit_check_id,
uint8_t *  p_limit_check_enable 
)

Get specific limit check enable state.

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
Parameters:
devDevice Handle
limit_check_idLimit Check ID (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
p_limit_check_enablePointer to the check limit enable value. if 1 the check limit corresponding to LimitCheckId is Enabled if 0 the check limit corresponding to LimitCheckId is disabled
Returns:
VL53L0X_ERROR_NONE Success
VL53L0X_ERROR_INVALID_PARAMS This error is returned when LimitCheckId value is out of range.
"Other error code" See VL53L0X_Error

Definition at line 689 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_get_limit_check_status ( VL53L0X_DEV  dev,
uint16_t  limit_check_id,
uint8_t *  p_limit_check_status 
)

Return a the Status of the specified check limit.

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.
Note:
This function doesn't Access to the device
Parameters:
devDevice Handle
limit_check_idLimit Check ID (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
p_limit_check_statusPointer to the Limit Check Status of the given check limit. LimitCheckStatus : 0 the check is not fail 1 the check if fail or not enabled
Returns:
VL53L0X_ERROR_NONE Success
VL53L0X_ERROR_INVALID_PARAMS This error is returned when LimitCheckId value is out of range.
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_get_limit_check_value ( VL53L0X_DEV  dev,
uint16_t  limit_check_id,
FixPoint1616_t *  p_limit_check_value 
)

Get a specific limit check value.

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 Access to the device
Parameters:
devDevice Handle
limit_check_idLimit Check ID (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
p_limit_check_valuePointer to Limit check Value for a given LimitCheckId.
Returns:
VL53L0X_ERROR_NONE Success
VL53L0X_ERROR_INVALID_PARAMS This error is returned when LimitCheckId value is out of range.
"Other error code" See VL53L0X_Error

Definition at line 596 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_get_measurement_data_ready ( VL53L0X_DEV  dev,
uint8_t *  p_measurement_data_ready 
)

Return Measurement Data Ready.

Function Description
This function indicate that a measurement data is ready. This function check if interrupt mode is used then check is done accordingly. If perform function clear the interrupt, this function will not work, like in case of VL53L0X_PerformSingleRangingMeasurement(). The previous function is blocking function, VL53L0X_GetMeasurementDataReady is used for non-blocking capture.
Note:
This function Access to the device
Parameters:
devDevice Handle
p_measurement_data_readyPointer to Measurement Data Ready. 0=data not ready, 1 = data ready
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

Definition at line 1797 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_get_measurement_timing_budget_micro_seconds ( VL53L0X_DEV  dev,
uint32_t *  p_measurement_timing_budget_micro_seconds 
)

Get Ranging Timing Budget in microseconds.

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 ...)
Note:
This function Access to the device
Parameters:
devDevice Handle
p_measurement_timing_budget_micro_secondsMax measurement time in microseconds. Valid values are: >= 17000 microsecs when wraparound enabled >= 12000 microsecs when wraparound disabled
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

Definition at line 1391 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_get_offset_calibration_data_micro_meter ( VL53L0X_DEV  dev,
int32_t *  p_offset_calibration_data_micro_meter 
)

Get part to part calibration offset.

Function Description
Should only be used after a successful call to VL53L0X_DataInit to backup device NVM value
Note:
This function Access to the device
Parameters:
devDevice Handle
p_offset_calibration_data_micro_meterReturn part to part calibration offset from device (microns)
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

Definition at line 413 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_get_pal_error_string ( VL53L0X_Error  pal_error_code,
char *  p_pal_error_string 
)

Human readable error string for current PAL error status.

Note:
This function doesn't access to the device
Parameters:
pal_error_codeThe error code as stored on VL53L0X_Error
p_pal_error_stringThe error string corresponding to the PalErrorCode
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_get_pal_spec_version ( VL53L0X_Version_t p_pal_spec_version )

Return the PAL Specification Version used for the current implementation.

Note:
This function doesn't access to the device
Parameters:
p_pal_spec_versionPointer to current PAL Specification Version
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_get_pal_state ( VL53L0X_DEV  dev,
VL53L0X_State *  p_pal_state 
)

Reads the internal state of the PAL for a given Device.

Note:
This function doesn't access to the device
Parameters:
devDevice Handle
p_pal_statePointer to current state of the PAL for a given Device
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_get_pal_state_string ( VL53L0X_State  pal_state_code,
char *  p_pal_state_string 
)

Human readable PAL State string.

Note:
This function doesn't access to the device
Parameters:
pal_state_codeThe State code as stored on VL53L0X_State
p_pal_state_stringThe State string corresponding to the PalStateCode
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_get_product_revision ( VL53L0X_DEV  dev,
uint8_t *  p_product_revision_major,
uint8_t *  p_product_revision_minor 
)

Reads the Product Revision for a for given Device This function can be used to distinguish cut1.0 from cut1.1.

Note:
This function Access to the device
Parameters:
devDevice Handle
p_product_revision_majorPointer to Product Revision Major for a given Device
p_product_revision_minorPointer to Product Revision Minor for a given Device
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_get_range_status_string ( uint8_t  range_status,
char *  p_range_status_string 
)

Human readable Range Status string for a given RangeStatus.

Note:
This function doesn't access to the device
Parameters:
range_statusThe RangeStatus code as stored on VL53L0X_RangingMeasurementData_t
p_range_status_stringThe returned RangeStatus string.
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_get_ref_calibration ( VL53L0X_DEV  dev,
uint8_t *  p_vhv_settings,
uint8_t *  p_phase_cal 
)

Get Reference Calibration Parameters.

Function Description
Get Reference Calibration Parameters.
Note:
This function Access to the device
Parameters:
devDevice Handle
p_vhv_settingsPointer to VHV parameter
p_phase_calPointer to PhaseCal Parameter
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_get_reference_spads ( VL53L0X_DEV  dev,
uint32_t *  p_spad_count,
uint8_t *  p_is_aperture_spads 
)

Retrieves SPAD configuration.

Function Description
This function retrieves the current number of applied reference spads and also their type : Aperture or Non-Aperture.
Note:
This function Access to the device
Parameters:
devDevice Handle
p_spad_countNumber ref Spad Count
p_is_aperture_spadsReports if spads are of type aperture or non-aperture. 1:=aperture, 0:=Non-Aperture
Returns:
VL53L0X_ERROR_NONE Success
VL53L0X_ERROR_REF_SPAD_INIT Error in the in the reference spad configuration.
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_get_sequence_step_enables ( VL53L0X_DEV  dev,
VL53L0X_SchedulerSequenceSteps_t *  p_scheduler_sequence_steps 
)

Gets the (on/off) state of all sequence steps.

Function Description
This function retrieves the state of all sequence step in the scheduler.
Note:
This function Accesses the device
Parameters:
devDevice Handle
p_scheduler_sequence_stepsPointer to struct containing result.
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

Definition at line 768 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_get_vcsel_pulse_period ( VL53L0X_DEV  dev,
VL53L0X_VcselPeriod  vcsel_period_type,
uint8_t *  p_vcsel_pulse_period_pclk 
)

Gets the VCSEL pulse period.

Function Description
This function retrieves the VCSEL pulse period for the given period type.
Note:
This function Accesses the device
Parameters:
devDevice Handle
vcsel_period_typeVCSEL period identifier (pre-range|final).
p_vcsel_pulse_period_pclkPointer to VCSEL period value.
Returns:
VL53L0X_ERROR_NONE Success
VL53L0X_ERROR_INVALID_PARAMS Error VcselPeriodType parameter not supported.
"Other error code" See VL53L0X_Error

Definition at line 1128 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_get_version ( VL53L0X_Version_t p_version )

Return the VL53L0X PAL Implementation Version.

Note:
This function doesn't access to the device
Parameters:
p_versionPointer to current PAL Implementation Version
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_get_wrap_around_check_enable ( VL53L0X_DEV  dev,
uint8_t *  p_wrap_around_check_enable 
)

Get setup of Wrap around Check.

Function Description
This function get the wrapAround check enable parameters
Note:
This function Access to the device
Parameters:
devDevice Handle
p_wrap_around_check_enablePointer to the Wrap around Check state 0=disabled or 1 = enabled
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

Definition at line 710 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_get_x_talk_compensation_enable ( VL53L0X_DEV  dev,
uint8_t *  p_x_talk_compensation_enable 
)

Get Cross talk compensation rate.

Note:
This function is not Implemented. Enable/Disable Cross Talk by set to zero the Cross Talk value by using VL53L0X_SetXTalkCompensationRateMegaCps().
Parameters:
devDevice Handle
p_x_talk_compensation_enablePointer to the Cross talk compensation state 0=disabled or 1 = enabled
Returns:
VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented

Definition at line 2611 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_get_x_talk_compensation_rate_mega_cps ( VL53L0X_DEV  dev,
FixPoint1616_t *  p_xtalk_compensation_rate_mega_cps 
)

Get Cross talk compensation rate.

Function Description
Get Cross talk compensation rate.
Note:
This function Access to the device
Parameters:
devDevice Handle
p_xtalk_compensation_rate_mega_cpsPointer to Compensation rate in Mega counts per second (16.16 fix point) see datasheet for details
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

Definition at line 563 of file VL53L0X.cpp.

void VL53L0X_off ( void   )

PowerOff the sensor.

Returns:
void

Definition at line 369 of file VL53L0X.h.

void VL53L0X_on ( void   )

PowerOn the sensor.

Returns:
void

Definition at line 352 of file VL53L0X.h.

VL53L0X_Error VL53L0X_perform_single_measurement ( VL53L0X_DEV  dev )

Single shot measurement.

Function Description
Perform simple measurement sequence (Start measure, Wait measure to end, and returns when measurement is done). Once function returns, user can get valid data by calling VL53L0X_GetRangingMeasurement or VL53L0X_GetHistogramMeasurement depending on defined measurement mode User should Clear the interrupt in case this are enabled by using the function VL53L0X_ClearInterruptMask().
Warning:
This function is a blocking function
Note:
This function Access to the device
Parameters:
devDevice Handle
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

Definition at line 2577 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_perform_xtalk_measurement ( VL53L0X_DEV  dev,
uint32_t  timeout_ms,
FixPoint1616_t *  p_xtalk_per_spad,
uint8_t *  p_ambient_too_high 
)

Perform XTalk Measurement.

Measures the current cross talk from glass in front of the sensor. This functions performs a histogram measurement and uses the results to measure the crosstalk. For the function to be successful, there must be no target in front of the sensor.

Warning:
This function is a blocking function
This function is not supported when the final range vcsel clock period is set below 10 PCLKS.
Note:
This function Access to the device
Parameters:
devDevice Handle
timeout_msHistogram measurement duration.
p_xtalk_per_spadOutput parameter containing the crosstalk measurement result, in MCPS/Spad. Format fixpoint 16:16.
p_ambient_too_highOutput parameter which indicate that pXtalkPerSpad is not good if the Ambient is too high.
Returns:
VL53L0X_ERROR_NONE Success
VL53L0X_ERROR_INVALID_PARAMS vcsel clock period not supported for this operation. Must not be less than 10PCLKS.
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_reset_device ( VL53L0X_DEV  dev )

Do an hard reset or soft reset (depending on implementation) of the device call of this function, device must be in same state as right after a power-up sequence.This function will change the VL53L0X_State to VL53L0X_STATE_POWERDOWN.

Note:
This function Access to the device
Parameters:
devDevice Handle
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_set_device_mode ( VL53L0X_DEV  dev,
VL53L0X_DeviceModes  device_mode 
)

Set a new device mode.

Function Description
Set device to a new mode (ranging, histogram ...)
Note:
This function doesn't Access to the device
Parameters:
devDevice Handle
device_modeNew device mode to apply Valid values are: VL53L0X_DEVICEMODE_SINGLE_RANGING VL53L0X_DEVICEMODE_CONTINUOUS_RANGING VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING VL53L0X_DEVICEMODE_SINGLE_HISTOGRAM VL53L0X_HISTOGRAMMODE_REFERENCE_ONLY VL53L0X_HISTOGRAMMODE_RETURN_ONLY VL53L0X_HISTOGRAMMODE_BOTH
Returns:
VL53L0X_ERROR_NONE Success
VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when DeviceMode is not in the supported list

Definition at line 2285 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_set_inter_measurement_period_milli_seconds ( VL53L0X_DEV  dev,
uint32_t  inter_measurement_period_milli_seconds 
)

Program continuous mode Inter-Measurement period in milliseconds.

Function Description
When trying to set too short time return INVALID_PARAMS minimal value
Note:
This function Access to the device
Parameters:
devDevice Handle
inter_measurement_period_milli_secondsInter-Measurement Period in ms.
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_set_interrupt_thresholds ( VL53L0X_DEV  dev,
VL53L0X_DeviceModes  device_mode,
FixPoint1616_t  threshold_low,
FixPoint1616_t  threshold_high 
)

Set low and high Interrupt thresholds for a given mode (ranging, ALS, ...) for a given device.

Function Description
Set low and high Interrupt thresholds for a given mode (ranging, ALS, ...) for a given device
Note:
This function Access to the device
DeviceMode is ignored for the current device
Parameters:
devDevice Handle
device_modeDevice Mode for which change thresholds
threshold_lowLow threshold (mm, lux ..., depending on the mode)
threshold_highHigh threshold (mm, lux ..., depending on the mode)
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

Definition at line 2309 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_set_limit_check_value ( VL53L0X_DEV  dev,
uint16_t  limit_check_id,
FixPoint1616_t  limit_check_value 
)

Set a specific limit check value.

Function Description
This function set a specific limit check value. The limit check is identified with the LimitCheckId.
Note:
This function Access to the device
Parameters:
devDevice Handle
limit_check_idLimit Check ID (0<= LimitCheckId < VL53L0X_GetNumberOfLimitCheck() ).
limit_check_valueLimit check Value for a given LimitCheckId
Returns:
VL53L0X_ERROR_NONE Success
VL53L0X_ERROR_INVALID_PARAMS This error is returned when either LimitCheckId or LimitCheckValue value is out of range.
"Other error code" See VL53L0X_Error

Definition at line 1469 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_set_offset_calibration_data_micro_meter ( VL53L0X_DEV  dev,
int32_t  offset_calibration_data_micro_meter 
)

Set or over-hide part to part calibration offset.

See also:
VL53L0X_DataInit() VL53L0X_GetOffsetCalibrationDataMicroMeter()
Note:
This function Access to the device
Parameters:
devDevice Handle
p_offset_calibration_data_micro_meterOffset (microns)
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

Definition at line 466 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_set_range_fraction_enable ( VL53L0X_DEV  dev,
uint8_t  enable 
)

Sets the resolution of range measurements.

Function Description
Set resolution of range measurements to either 0.25mm if fraction enabled or 1mm if not enabled.
Note:
This function Accesses the device
Parameters:
devDevice Handle
enableEnable high resolution
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_set_vcsel_pulse_period ( VL53L0X_DEV  dev,
VL53L0X_VcselPeriod  vcsel_period_type,
uint8_t  vcsel_pulse_period 
)

Sets the VCSEL pulse period.

Function Description
This function retrieves the VCSEL pulse period for the given period type.
Note:
This function Accesses the device
Parameters:
devDevice Handle
vcsel_period_typeVCSEL period identifier (pre-range|final).
vcsel_pulse_periodVCSEL period value
Returns:
VL53L0X_ERROR_NONE Success
VL53L0X_ERROR_INVALID_PARAMS Error VcselPeriodType parameter not supported.
"Other error code" See VL53L0X_Error

Definition at line 1087 of file VL53L0X.cpp.

VL53L0X_Error VL53L0X_set_wrap_around_check_enable ( VL53L0X_DEV  dev,
uint8_t  wrap_around_check_enable 
)

Enable (or disable) Wrap around Check.

Note:
This function Access to the device
Parameters:
devDevice Handle
wrap_around_check_enableWrap around Check to be set 0=disabled, other = enabled
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_set_x_talk_compensation_enable ( VL53L0X_DEV  dev,
uint8_t  x_talk_compensation_enable 
)

Enable/Disable Cross talk compensation feature.

Note:
This function is not Implemented. Enable/Disable Cross Talk by set to zero the Cross Talk value by using VL53L0X_SetXTalkCompensationRateMegaCps().
Parameters:
devDevice Handle
x_talk_compensation_enableCross talk compensation to be set 0=disabled else = enabled
Returns:
VL53L0X_ERROR_NOT_IMPLEMENTED Not implemented
VL53L0X_Error VL53L0X_set_x_talk_compensation_rate_mega_cps ( VL53L0X_DEV  dev,
FixPoint1616_t  x_talk_compensation_rate_mega_cps 
)

Set Cross talk compensation rate.

Function Description
Set Cross talk compensation rate.
Note:
This function Access to the device
Parameters:
devDevice Handle
x_talk_compensation_rate_mega_cpsCompensation rate in Mega counts per second (16.16 fix point) see datasheet for details
Returns:
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error
VL53L0X_Error VL53L0X_start_measurement ( VL53L0X_DEV  dev )

Start device measurement.

Started measurement will depend on device parameters set through VL53L0X_SetParameters() This is a non-blocking function. This function will change the VL53L0X_State from VL53L0X_STATE_IDLE to VL53L0X_STATE_RUNNING.

Note:
This function Access to the device
Parameters:
devDevice Handle
Returns:
VL53L0X_ERROR_NONE Success
VL53L0X_ERROR_MODE_NOT_SUPPORTED This error occurs when DeviceMode programmed with VL53L0X_SetDeviceMode is not in the supported list: Supported mode are: VL53L0X_DEVICEMODE_SINGLE_RANGING, VL53L0X_DEVICEMODE_CONTINUOUS_RANGING, VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING
VL53L0X_ERROR_TIME_OUT Time out on start measurement
"Other error code" See VL53L0X_Error

Definition at line 2490 of file VL53L0X.cpp.