lightranger8 2.0.0.0
LightRanger 8 Click Driver

API for configuring and manipulating LightRanger 8 Click driver. More...

Topics

 LightRanger 8 Registers List
 List of registers of LightRanger 8 Click driver.
 
 LightRanger 8 MikroBUS Map
 MikroBUS pin mapping of LightRanger 8 Click driver.
 
 Lightranger8_set
 
 Distance_mode
 
 Ranging_mode
 
 Lightranger8_resp
 
 8 error_code
 

Functions

void lightranger8_cfg_setup (lightranger8_cfg_t *cfg)
 LightRanger 8 configuration object setup function.
 
err_t lightranger8_init (lightranger8_t *ctx, lightranger8_cfg_t *cfg)
 LightRanger 8 initialization function.
 
err_t lightranger8_default_cfg (lightranger8_t *ctx)
 LightRanger 8 default configuration function.
 
err_t lightranger8_generic_write (lightranger8_t *ctx, uint16_t reg, uint8_t *tx_buf, uint8_t tx_len)
 LightRanger 8 I2C writing function.
 
err_t lightranger8_generic_read (lightranger8_t *ctx, uint16_t reg, uint8_t *rx_buf, uint8_t rx_len)
 LightRanger 8 I2C reading function.
 
void lightranger8_software_reset (lightranger8_t *ctx)
 LightRanger 8 software reset function.
 
void lightranger8_system_interrupt_clear (lightranger8_t *ctx)
 LightRanger 8 system interrupt clear function.
 
void lightranger8_start_ranging_cmd (lightranger8_t *ctx, uint8_t ranging_mode)
 LightRanger 8 start ranging function.
 
void lightranger8_start_measurement (lightranger8_t *ctx, uint32_t period_ms)
 LightRanger 8 start measurement function.
 
void lightranger8_stop_measurement (lightranger8_t *ctx)
 LightRanger 8 stop measurement function.
 
uint8_t lightranger8_new_data_ready (lightranger8_t *ctx)
 LightRanger 8 data ready function.
 
uint16_t lightranger8_get_distance (lightranger8_t *ctx)
 LightRanger 8 get distance function.
 
uint16_t lightranger8_get_signal_rate (lightranger8_t *ctx)
 LightRanger 8 get signal rate function.
 
uint8_t lightranger8_set_distance_mode (lightranger8_t *ctx, uint8_t mode)
 LightRanger 8 set distance mode function.
 
uint8_t lightranger8_get_range_status (lightranger8_t *ctx)
 LightRanger 8 get range status function.
 
uint8_t lightranger8_get_roi_center (lightranger8_t *ctx)
 LightRanger 8 get roi center function.
 
void lightranger8_set_roi_center (lightranger8_t *ctx, uint8_t roi_center)
 LightRanger 8 set roi center function.
 
void lightranger8_set_roi (lightranger8_t *ctx, uint16_t x, uint16_t y)
 LightRanger 8 set roi function.
 
void lightranger8_get_roi (lightranger8_t *ctx, uint16_t *roi_x, uint16_t *roi_y)
 LightRanger 8 get roi function.
 
void lightranger8_set_offset (lightranger8_t *ctx, int16_t offset_value)
 LightRanger 8 set offset function.
 
void lightranger8_calibrate_offset (lightranger8_t *ctx, uint16_t target_distance_mm, uint32_t period_ms, int16_t *offset)
 LightRanger 8 calibrate offset function.
 
err_t lightranger8_set_measurement_timing_budget (lightranger8_t *ctx, uint32_t budget_us)
 LightRanger 8 set measurement timing budget function.
 
uint8_t lightranger8_get_interrupt_state (lightranger8_t *ctx)
 LightRanger 8 get int pin state function.
 
void lightranger8_set_xshut_pin (lightranger8_t *ctx, uint8_t state)
 LightRanger 8 set xshut pin function.
 
void lightranger8_power_on (lightranger8_t *ctx)
 LightRanger 8 power on function.
 
uint32_t lightranger8_get_timing_budget (lightranger8_t *ctx)
 LightRanger 8 get timing budget function.
 
uint16_t lightranger8_get_measurement_period (lightranger8_t *ctx)
 LightRanger 8 get intermeasurement period function.
 

Detailed Description

API for configuring and manipulating LightRanger 8 Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ lightranger8_calibrate_offset()

void lightranger8_calibrate_offset ( lightranger8_t * ctx,
uint16_t target_distance_mm,
uint32_t period_ms,
int16_t * offset )

LightRanger 8 calibrate offset function.

This function calibrates the offset which affects the final corrected measurement from the VL53Lx ranging sensor. The averaging is concluded 50 times before the actual measurement sets in place. The target distance value is in milimeters. Period should be set at the same value as inteded measurement later on.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
[in]target_distance_mm: Target distance value in milimeters.
[in]period_ms: Intermeasurement period in miliseconds.
[out]offset: Calibrated offset value.
Note
None.

◆ lightranger8_cfg_setup()

void lightranger8_cfg_setup ( lightranger8_cfg_t * cfg)

LightRanger 8 configuration object setup function.

This function initializes click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See lightranger8_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ lightranger8_default_cfg()

err_t lightranger8_default_cfg ( lightranger8_t * ctx)

LightRanger 8 default configuration function.

This function executes a default configuration of LightRanger 8 click board.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
Returns
  • 0x01 ( LIGHTRANGER8_RESP_DEVICE_ERROR_ID_IS_NOT_VALID ) - ID error,
  • 0x02 ( LIGHTRANGER8_RESP_FIRMWARE_TIMEOUT_ERROR ) - Firmware timeout error,
  • 0x00 ( LIGHTRANGER8_RESP_INIT_IS_SUCCESSFUL ) - Success.
See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ lightranger8_generic_read()

err_t lightranger8_generic_read ( lightranger8_t * ctx,
uint16_t reg,
uint8_t * rx_buf,
uint8_t rx_len )

LightRanger 8 I2C reading function.

This function reads a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
[in]reg: Start register address.
[out]rx_buf: Output read data.
[in]rx_len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ lightranger8_generic_write()

err_t lightranger8_generic_write ( lightranger8_t * ctx,
uint16_t reg,
uint8_t * tx_buf,
uint8_t tx_len )

LightRanger 8 I2C writing function.

This function writes a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
[in]reg: Start register address.
[in]tx_buf: Data to be written.
[in]tx_len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ lightranger8_get_distance()

uint16_t lightranger8_get_distance ( lightranger8_t * ctx)

LightRanger 8 get distance function.

This function returns the corrected measured distance from the VL53Lx ranging sensor described in milimeters.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
Returns
Corrected distance in milimeters.
Note
None.

◆ lightranger8_get_interrupt_state()

uint8_t lightranger8_get_interrupt_state ( lightranger8_t * ctx)

LightRanger 8 get int pin state function.

This function checks the interrupt pin state.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
Returns
INT pin state.
Note
None.

◆ lightranger8_get_measurement_period()

uint16_t lightranger8_get_measurement_period ( lightranger8_t * ctx)

LightRanger 8 get intermeasurement period function.

This function returns the intermeasurement period in miliseconds currently set in the VL53Lx ranging sensor.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
Returns
Intermeasurement period in miliseconds.
Note
None.

◆ lightranger8_get_range_status()

uint8_t lightranger8_get_range_status ( lightranger8_t * ctx)

LightRanger 8 get range status function.

This function returns the range result status of the VL53Lx ranging sensor.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
Returns
LightRanger 8 response code.
Note
None.

◆ lightranger8_get_roi()

void lightranger8_get_roi ( lightranger8_t * ctx,
uint16_t * roi_x,
uint16_t * roi_y )

LightRanger 8 get roi function.

This function forwards the roi x and y coords of the VL53Lx ranging sensor.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
[out]roi_x: X coord value.
[out]roi_y: Y coord value.
Note
None.

◆ lightranger8_get_roi_center()

uint8_t lightranger8_get_roi_center ( lightranger8_t * ctx)

LightRanger 8 get roi center function.

This function returns the roi center value of the VL53Lx ranging sensor.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
Returns
ROI center.
Note
None.

◆ lightranger8_get_signal_rate()

uint16_t lightranger8_get_signal_rate ( lightranger8_t * ctx)

LightRanger 8 get signal rate function.

This function returns the corrected signal rate MCPS from the VL53Lx ranging sensor.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
Returns
Signal rate.
Note
None.

◆ lightranger8_get_timing_budget()

uint32_t lightranger8_get_timing_budget ( lightranger8_t * ctx)

LightRanger 8 get timing budget function.

This function returns the timing budget in microseconds currently set in the VL53Lx ranging sensor.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
Returns
Timing budget in microseconds.
Note
None.

◆ lightranger8_init()

err_t lightranger8_init ( lightranger8_t * ctx,
lightranger8_cfg_t * cfg )

LightRanger 8 initialization function.

This function initializes all necessary pins and peripherals used for this click board.

Parameters
[out]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See lightranger8_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ lightranger8_new_data_ready()

uint8_t lightranger8_new_data_ready ( lightranger8_t * ctx)

LightRanger 8 data ready function.

This function returns the information if new data is ready for acquiring the distance measured.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
Returns
  • 0 - New data ready,
  • 1 - Still measuring.
Note
None.

◆ lightranger8_power_on()

void lightranger8_power_on ( lightranger8_t * ctx)

LightRanger 8 power on function.

This function powers on the VL53Lx ranging sensor.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
Note
None.

◆ lightranger8_set_distance_mode()

uint8_t lightranger8_set_distance_mode ( lightranger8_t * ctx,
uint8_t mode )

LightRanger 8 set distance mode function.

This function sets the distance mode of the VL53Lx ranging sensor with three possible modes.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
[in]mode: Distance mode.
  • 0x00 ( LIGHTRANGER8_DISTANCE_MODE_SHORT ) - Short distance mode,
  • 0x01 ( LIGHTRANGER8_DISTANCE_MODE_MEDIUM ) - Medium distance mode,
  • 0x02 ( LIGHTRANGER8_DISTANCE_MODE_LONG ) - Long distance mode.
Returns
  • 0x00 ( LIGHTRANGER8_RESP_MODE_SUCCESSFULLY_SET )- Distance mode successfully set,
  • 0x01 ( LIGHTRANGER8_RESP_WRONG_MODE )- Wrong distance mode.
Note
None.

◆ lightranger8_set_measurement_timing_budget()

err_t lightranger8_set_measurement_timing_budget ( lightranger8_t * ctx,
uint32_t budget_us )

LightRanger 8 set measurement timing budget function.

This function sets the timing budget of the VL53Lx ranging sensor. This is the time allocated by the user to perform one range measurement.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
[in]budget_us: Timing budget in microseconds.
Returns
  • 0x02 ( LIGHTRANGER8_RESP_INSUFFICIENT_BUDGET ) - Low budget error,
  • 0x01 ( LIGHTRANGER8_RESP_TOO_HIGH_BUDGET ) - High budget error,
  • 0x00 ( LIGHTRANGER8_RESP_BUDGET_IS_SUCCESSFULLY_SET ) - Success.
Note
None.

◆ lightranger8_set_offset()

void lightranger8_set_offset ( lightranger8_t * ctx,
int16_t offset_value )

LightRanger 8 set offset function.

This function sets the offset of the final corrected measurement from the VL53Lx ranging sensor. The offset value is in milimeters.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
[in]offset_value: Offset value in milimeters.
Note
None.

◆ lightranger8_set_roi()

void lightranger8_set_roi ( lightranger8_t * ctx,
uint16_t x,
uint16_t y )

LightRanger 8 set roi function.

This function sets the roi x and y coords of the VL53Lx ranging sensor.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
[in]x: Desired x coord value.
[in]y: Desired y coord value.
Note
None.

◆ lightranger8_set_roi_center()

void lightranger8_set_roi_center ( lightranger8_t * ctx,
uint8_t roi_center )

LightRanger 8 set roi center function.

This function sets the roi center value of the VL53Lx ranging sensor.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
[in]roi_center: Desired roi center value.
Note
None.

◆ lightranger8_set_xshut_pin()

void lightranger8_set_xshut_pin ( lightranger8_t * ctx,
uint8_t state )

LightRanger 8 set xshut pin function.

This function sets the state of EN pin.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
[in]state:
  • 0 - Sets EN pin low.
  • 1 - Sets EN pin high.
Note
None.

◆ lightranger8_software_reset()

void lightranger8_software_reset ( lightranger8_t * ctx)

LightRanger 8 software reset function.

This function performs a software reset of the VL53Lx ranging sensor.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
Note
None.

◆ lightranger8_start_measurement()

void lightranger8_start_measurement ( lightranger8_t * ctx,
uint32_t period_ms )

LightRanger 8 start measurement function.

This function enables the range measuring with the adjusted intermeasurement period.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
[in]period_ms: Intermeasurement period in miliseconds.
Note
None.

◆ lightranger8_start_ranging_cmd()

void lightranger8_start_ranging_cmd ( lightranger8_t * ctx,
uint8_t ranging_mode )

LightRanger 8 start ranging function.

This function sends either ranging enable or ranging disable depending on the ranging mode parameter.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
[in]ranging_mode: Ranging mode setting option.
  • 0x40 ( DEV_CMD_RANGING_ENABLE ) - Ranging mode enable,
  • 0x00 ( DEV_CMD_RANGING_DISABLE ) - Ranging mode disable.
Note
None.

◆ lightranger8_stop_measurement()

void lightranger8_stop_measurement ( lightranger8_t * ctx)

LightRanger 8 stop measurement function.

This function stops the measurement of the VL53Lx ranging sensor.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
Note
None.

◆ lightranger8_system_interrupt_clear()

void lightranger8_system_interrupt_clear ( lightranger8_t * ctx)

LightRanger 8 system interrupt clear function.

This function clears the system interrupt bit of the VL53Lx ranging sensor.

Parameters
[in]ctx: Click context object. See lightranger8_t object definition for detailed explanation.
Note
None.