lightranger4 2.0.0.0

Functions

void lightranger4_cfg_setup (lightranger4_cfg_t *cfg)
 Config Object Initialization function.
 
LIGHTRANGER4_RETVAL lightranger4_init (lightranger4_t *ctx, lightranger4_cfg_t *cfg)
 Initialization function.
 
LIGHTRANGER4_RETVAL lightranger4_default_cfg (lightranger4_t *ctx)
 Click Default Configuration function.
 
void lightranger4_generic_write (lightranger4_t *ctx, uint16_t reg, uint8_t *data_buf, uint8_t len)
 Generic write function.
 
void lightranger4_generic_read (lightranger4_t *ctx, uint16_t reg, uint8_t *data_buf, uint8_t len)
 Generic read function.
 
void lightranger4_software_reset (lightranger4_t *ctx)
 Function for software reset.
 
void lightranger4_start_measurement (lightranger4_t *ctx, uint32_t period_ms)
 Functions for start measurement.
 
uint8_t lightranger4_new_data_ready (lightranger4_t *ctx)
 Function that checks whether the new data is ready for reading.
 
uint16_t lightranger4_get_distance (lightranger4_t *ctx)
 Function reads distance of the object in front of the sensor.
 
uint16_t lightranger4_get_signal_rate (lightranger4_t *ctx)
 Function reads signal rate.
 
uint8_t lightranger4_set_distance_mode (lightranger4_t *ctx, uint8_t mode)
 Functions for sets distance measurement mode.
 
uint8_t lightranger4_get_range_status (lightranger4_t *ctx)
 Function reads range status.
 
void lightranger4_set_center (lightranger4_t *ctx, uint8_t center_x, uint8_t center_y)
 Functions for set center position.
 
void lightranger4_set_zone_size (lightranger4_t *ctx, uint8_t width, uint8_t height)
 Functions for sets zone size.
 
void lightranger4_set_user_roi (lightranger4_t *ctx, lightranger4_user_roi_t *roi)
 Functions for sets user Roi.
 
LIGHTRANGER4_RETVAL lightranger4_set_measurement_timing_budget (lightranger4_t *ctx, uint32_t budget_us)
 Functions for sets measurement timing budget.
 
uint8_t lightranger4_get_intrrupt_state (lightranger4_t *ctx)
 Function reads interrupt pin state.
 
void lightranger4_set_xshut_pin (lightranger4_t *ctx, uint8_t state)
 Function for sets XSHUT pin.
 
void lightranger4_power_on (lightranger4_t *ctx)
 Function for starts power ON procedure.
 

Detailed Description

Function Documentation

◆ lightranger4_cfg_setup()

void lightranger4_cfg_setup ( lightranger4_cfg_t * cfg)

Config Object Initialization function.

Parameters
cfgClick configuration structure.

@description This function initializes click configuration structure to init state.

Note
All used pins will be set to unconnected state.

◆ lightranger4_default_cfg()

LIGHTRANGER4_RETVAL lightranger4_default_cfg ( lightranger4_t * ctx)

Click Default Configuration function.

Parameters
ctxClick object.
Return values
Functionreturn device error status (_ID_IS_NOT_VALID or _FIRMWARE_TIMEOUT_ERROR) or device ok status (_INIT_IS_SUCCESSFUL)
Note
This function should be called in the start program after the power on procedure, in order to check the chip communication and configure the chip for the operation.

@description This function executes default configuration for LightRanger4 click.

◆ lightranger4_generic_read()

void lightranger4_generic_read ( lightranger4_t * ctx,
uint16_t reg,
uint8_t * data_buf,
uint8_t len )

Generic read function.

Parameters
ctxClick object.
regRegister address.
data_bufOutput data buf
lenNumber of the bytes to be read

@description This function reads data from the desired register.

◆ lightranger4_generic_write()

void lightranger4_generic_write ( lightranger4_t * ctx,
uint16_t reg,
uint8_t * data_buf,
uint8_t len )

Generic write function.

Parameters
ctxClick object.
regRegister address.
data_bufData buf to be written.
lenNumber of the bytes in data buf.

@description This function writes data to the desired register.

◆ lightranger4_get_distance()

uint16_t lightranger4_get_distance ( lightranger4_t * ctx)

Function reads distance of the object in front of the sensor.

Parameters
ctxClick object.
Return values
Distancein mm
Note
Distance depends on the set distance measurement mode,
  • In _DISTANCE_MODE_SHORT the maximum measurement distance is 1300mm,
  • in _DISTANCE_MODE_MEDIUM the maximum measurement distance is 3000mm, and
  • in _DISTANCE_MODE_LONG the maximum measurement distance is 4000mm.

◆ lightranger4_get_intrrupt_state()

uint8_t lightranger4_get_intrrupt_state ( lightranger4_t * ctx)

Function reads interrupt pin state.

Parameters
ctxClick object.
Return values
Interruptpin state

◆ lightranger4_get_range_status()

uint8_t lightranger4_get_range_status ( lightranger4_t * ctx)

Function reads range status.

Parameters
ctxClick object.
Return values
Rangestatus

◆ lightranger4_get_signal_rate()

uint16_t lightranger4_get_signal_rate ( lightranger4_t * ctx)

Function reads signal rate.

Parameters
ctxClick object.
Return values
signalrate

◆ lightranger4_init()

LIGHTRANGER4_RETVAL lightranger4_init ( lightranger4_t * ctx,
lightranger4_cfg_t * cfg )

Initialization function.

Parameters
lightranger4Click object.
cfgClick configuration structure.

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

◆ lightranger4_new_data_ready()

uint8_t lightranger4_new_data_ready ( lightranger4_t * ctx)

Function that checks whether the new data is ready for reading.

Parameters
ctxClick object.
Return values
Funstionreturn information about new data (0 - if new data is ready or 1 - if new data is not ready)
Note
Call this function before measuring the distance.

◆ lightranger4_power_on()

void lightranger4_power_on ( lightranger4_t * ctx)

Function for starts power ON procedure.

Parameters
ctxClick object.

◆ lightranger4_set_center()

void lightranger4_set_center ( lightranger4_t * ctx,
uint8_t center_x,
uint8_t center_y )

Functions for set center position.

Parameters
ctxClick object.
center_xCenter X position
center_yCenter Y position

◆ lightranger4_set_distance_mode()

uint8_t lightranger4_set_distance_mode ( lightranger4_t * ctx,
uint8_t mode )

Functions for sets distance measurement mode.

Parameters
ctxClick object.
modeDistance measurement mode
Note
Distance mode:
  • _DISTANCE_MODE_SHORT the maximum measurement distance is 1300mm
  • _DISTANCE_MODE_MEDIUM the maximum measurement distance is 3000mm
  • _DISTANCE_MODE_LONG the maximum measurement distance is 4000mm

◆ lightranger4_set_measurement_timing_budget()

LIGHTRANGER4_RETVAL lightranger4_set_measurement_timing_budget ( lightranger4_t * ctx,
uint32_t budget_us )

Functions for sets measurement timing budget.

Parameters
ctxClick object.
budget_usMeasurement timing budget in us
Return values
Functionreturn error status (_INSUFFICIENT_BUDGET or _TOO_HIGH_BUDGET) or device ok status (_BUDGET_IS_SUCCESSFULLY_SET)

◆ lightranger4_set_user_roi()

void lightranger4_set_user_roi ( lightranger4_t * ctx,
lightranger4_user_roi_t * roi )

Functions for sets user Roi.

Parameters
ctxClick object.
(struct)roiUser Roi

◆ lightranger4_set_xshut_pin()

void lightranger4_set_xshut_pin ( lightranger4_t * ctx,
uint8_t state )

Function for sets XSHUT pin.

Parameters
ctxClick object.
statePin state
Note
Xshutdown pin - active low

◆ lightranger4_set_zone_size()

void lightranger4_set_zone_size ( lightranger4_t * ctx,
uint8_t width,
uint8_t height )

Functions for sets zone size.

Parameters
ctxClick object.
widthWidth zone size min(4) and max(16)
heightHeight zone size min(4) and max(16)

◆ lightranger4_software_reset()

void lightranger4_software_reset ( lightranger4_t * ctx)

Function for software reset.

Parameters
ctxClick object.

◆ lightranger4_start_measurement()

void lightranger4_start_measurement ( lightranger4_t * ctx,
uint32_t period_ms )

Functions for start measurement.

Parameters
ctxClick object.
perion_msInter measurement period in ms
Note
This function should be called in the start program after the device configuration, in order to sets chip for start measurement.