Updates to follow mbed SDK coding style guidelines.

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON

Dependents:   53L0A1_Satellites_with_Interrupts_OS5 Display_53L0A1_OS5

Fork of X_NUCLEO_53L0A1 by ST

Embed: (wiki syntax)

« Back to documentation index

VL53L0X Class Reference

VL53L0X Class Reference

Class representing a VL53L0 sensor component. More...

#include <vl53l0x_class.h>

Public Member Functions

 VL53L0X (DevI2C &i2c, DigitalOut &pin, PinName pin_gpio1, uint8_t dev_addr=DEFAULT_DEVICE_ADDRESS)
 Constructor.
 VL53L0X (DevI2C &i2c, Stmpe1600DigiOut &pin, PinName pin_gpio1, uint8_t dev_addr=DEFAULT_DEVICE_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.
unsigned present ()
 Check the sensor presence.
int wait_device_booted ()
 Wait for device booted after chip enable (hardware standby)
virtual int init (void *init)
 One time device initialization.
int setup_gpio1 (uint8_t InitFunction, int ActiveHigh)
 Configure GPIO1 function and set polarity.
int prepare ()
 Prepare device for operation.
int range_start_continuous_mode ()
 Start continuous ranging mode.
int range_start_single_shot ()
 Start single shot ranging measure.
int range_set_max_convergence_time (uint8_t max_con_time_msec)
 Set maximum convergence time.
int range_poll_measurement (VL53L0X_RangingMeasurementData_t *p_range_data)
 Single shot Range measurement in polling mode.
int range_get_measurement_if_ready (VL53L0X_RangingMeasurementData_t *p_range_data)
 Check for measure readiness and get it if ready.
int range_get_measurement (VL53L0X_RangingMeasurementData_t *p_range_data)
 Retrieve range measurements set from device.
virtual int get_distance (uint32_t *p_data)
 Get ranging result and only that.
int range_config_interrupt (uint8_t config_gpio_int)
 Configure ranging interrupt reported to application.
int range_get_interrupt_status (uint8_t *p_status)
 Return ranging error interrupt status.
int static_init ()
 Low level ranging and ALS register static settings (you should call VL6180x_Prepare() function instead)
int range_wait_device_deady (int max_loop)
 Wait for device to be ready (before a new ranging command can be issued by application)
int range_set_inter_meas_period (uint32_t inter_meas_time_msec)
 Program Inter measurement period (used only in continuous mode)
int upscale_set_scaling (uint8_t scaling)
 Set device ranging scaling factor.
int upscale_get_scaling ()
 Get current ranging scaling factor.
uint16_t get_upper_limit ()
 Get the maximal distance for actual scaling.
int range_set_thresholds (uint16_t low, uint16_t high, int safe_hold)
 Apply low and high ranging thresholds that are considered only in continuous mode.
int range_get_thresholds (uint16_t *low, uint16_t *high)
 Get scaled high and low threshold from device.
int range_set_raw_thresholds (uint8_t low, uint8_t high)
 Set ranging raw thresholds (scaling not considered so not recommended to use it)
int range_set_ece_factor (uint16_t factor_m, uint16_t factor_d)
 Set Early Convergence Estimate ratio.
int range_set_ece_state (int enable)
 Set Early Convergence Estimate state (See SYSRANGE_RANGE_CHECK_ENABLES register)
int filter_set_state (int state)
 Set activation state of the wrap around filter.
int filter_get_state ()
 Get activation state of the wrap around filter.
int dmax_set_state (int state)
 Set activation state of DMax computation.
int dmax_get_state ()
 Get activation state of DMax computation.
int range_set_system_mode (uint8_t mode)
 Set ranging mode and start/stop measure (use high level functions instead : VL6180x_RangeStartSingleShot() or VL6180x_RangeStartContinuousMode())
int8_t get_offset_calibration_data ()
 Get part to part calibration offset.
void set_offset_calibration_data (int8_t offset)
 Set or over-write part to part calibration offset.
int set_xtalk_compensation_rate (uint16_t rate)
 Set Cross talk compensation rate.
int set_device_address (int new_addr)
 Set new device i2c address.
int setup_gpiox (int pin, uint8_t int_function, int active_high)
 Fully configure gpio 0/1 pin : polarity and functionality.
int set_gpiox_polarity (int pin, int active_high)
 Set interrupt pin polarity for the given GPIO.
int set_gpiox_functionality (int pin, uint8_t functionality)
 Select interrupt functionality for the given GPIO.
int disable_gpiox_out (int pin)
 brief Disable and turn to Hi-Z gpio output pin
int get_interrupt_status (uint8_t *status)
 Get all interrupts cause.
int clear_interrupt (uint8_t int_clear)
 Clear given system interrupt condition.

Detailed Description

Class representing a VL53L0 sensor component.

Definition at line 297 of file vl53l0x_class.h.


Constructor & Destructor Documentation

VL53L0X ( DevI2C &  i2c,
DigitalOut &  pin,
PinName  pin_gpio1,
uint8_t  dev_addr = DEFAULT_DEVICE_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 305 of file vl53l0x_class.h.

VL53L0X ( DevI2C &  i2c,
Stmpe1600DigiOut pin,
PinName  pin_gpio1,
uint8_t  dev_addr = DEFAULT_DEVICE_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 326 of file vl53l0x_class.h.

virtual ~VL53L0X (  ) [virtual]

Destructor.

Definition at line 343 of file vl53l0x_class.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 441 of file vl53l0x_class.h.

int disable_gpiox_out ( int  pin )

brief Disable and turn to Hi-Z gpio output pin

Parameters:
pinThe pin number to disable 0 or 1
Returns:
0 on success

Definition at line 1094 of file vl53l0x_class.h.

void disable_interrupt_measure_detection_irq ( void   )

Disable interrupt measure IRQ.

Returns:
0 on Success

Definition at line 430 of file vl53l0x_class.h.

void enable_interrupt_measure_detection_irq ( void   )

Enable interrupt measure IRQ.

Returns:
0 on Success

Definition at line 421 of file vl53l0x_class.h.

unsigned present (  )

Check the sensor presence.

Returns:
1 when device is present

Definition at line 450 of file vl53l0x_class.h.

int set_device_address ( int  new_addr )

Set new device i2c address.

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

See also:
AN4478: Using multiple VL6180X's in a single design
Parameters:
new_addrThe new i2c address (7bit)
Returns:
0 on success

Definition at line 1037 of file vl53l0x_class.h.

int set_gpiox_functionality ( int  pin,
uint8_t  functionality 
)

Select interrupt functionality for the given GPIO.

Function Description
Functionality refer to SYSTEM_MODE_GPIO0
Parameters:
pinPin to configure 0 or 1 (gpio0 or gpio1) that gpio0 is chip enable at power up !
functionalityPin functionality : either GPIOx_SELECT_OFF or GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT (refer to SYSTEM_MODE_GPIO1 register definition)
Returns:
0 on success

Definition at line 1083 of file vl53l0x_class.h.

int set_gpiox_polarity ( int  pin,
int  active_high 
)

Set interrupt pin polarity for the given GPIO.

Parameters:
pinPin 0 or 1
active_highselect active high or low polarity using IntrPol_e
Returns:
0 on success

Definition at line 1068 of file vl53l0x_class.h.

int setup_gpiox ( int  pin,
uint8_t  int_function,
int  active_high 
)

Fully configure gpio 0/1 pin : polarity and functionality.

Parameters:
pingpio pin 0 or 1
int_functionPin functionality : either GPIOx_SELECT_OFF or GPIOx_SELECT_GPIO_INTERRUPT_OUTPUT (refer to SYSTEM_MODE_GPIO1 register definition)
active_highSet active high polarity, or active low see IntrPol_e
Returns:
0 on success

Definition at line 1056 of file vl53l0x_class.h.

void vl53l0x_off ( void   )

PowerOff the sensor.

Returns:
void

Definition at line 371 of file vl53l0x_class.h.

void vl53l0x_on ( void   )

PowerOn the sensor.

Returns:
void

Definition at line 357 of file vl53l0x_class.h.