lightranger13 2.2.0
Loading...
Searching...
No Matches
LightRanger 13 Click Driver

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

Topics

 LightRanger 13 Registers List
 List of registers of LightRanger 13 Click driver.
 LightRanger 13 Registers Settings
 Settings for registers of LightRanger 13 Click driver.
 LightRanger 13 MikroBUS Map
 MikroBUS pin mapping of LightRanger 13 Click driver.

Functions

void lightranger13_cfg_setup (lightranger13_cfg_t *cfg)
 LightRanger 13 configuration object setup function.
err_t lightranger13_init (lightranger13_t *ctx, lightranger13_cfg_t *cfg)
 LightRanger 13 initialization function.
err_t lightranger13_default_cfg (lightranger13_t *ctx)
 LightRanger 13 default configuration function.
err_t lightranger13_write_regs (lightranger13_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 LightRanger 13 write regs function.
err_t lightranger13_read_regs (lightranger13_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 LightRanger 13 read regs function.
err_t lightranger13_write_reg (lightranger13_t *ctx, uint8_t reg, uint8_t data_in)
 LightRanger 13 write reg function.
err_t lightranger13_read_reg (lightranger13_t *ctx, uint8_t reg, uint8_t *data_out)
 LightRanger 13 read reg function.
err_t lightranger13_send_cmd (lightranger13_t *ctx, uint8_t cmd, uint8_t *payload, uint8_t payload_len, uint16_t timeout_ms)
 LightRanger 13 send cmd function.
err_t lightranger13_wait_reg_state (lightranger13_t *ctx, uint8_t reg, uint8_t mask, uint8_t state, uint16_t timeout_ms)
 LightRanger 13 wait reg state function.
void lightranger13_enable_device (lightranger13_t *ctx)
 LightRanger 13 enable device function.
void lightranger13_disable_device (lightranger13_t *ctx)
 LightRanger 13 disable device function.
uint8_t lightranger13_get_int_pin (lightranger13_t *ctx)
 LightRanger 13 get int pin function.
err_t lightranger13_power_up (lightranger13_t *ctx)
 LightRanger 13 power up function.
err_t lightranger13_read_info (lightranger13_t *ctx)
 LightRanger 13 read info function.
err_t lightranger13_clear_interrupts (lightranger13_t *ctx)
 LightRanger 13 clear interrupts function.
err_t lightranger13_factory_calib (lightranger13_t *ctx)
 LightRanger 13 factory calib function.
err_t lightranger13_set_threshold (lightranger13_t *ctx, uint16_t t_low, uint16_t t_high, uint8_t persistance)
 LightRanger 13 set threshold function.
err_t lightranger13_start_measurement (lightranger13_t *ctx)
 LightRanger 13 start measurement function.
err_t lightranger13_stop_measurement (lightranger13_t *ctx)
 LightRanger 13 stop measurement function.
err_t lightranger13_read_result (lightranger13_t *ctx, lightranger13_meas_result_t *result)
 LightRanger 13 read result function.

Detailed Description

API for configuring and manipulating LightRanger 13 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

◆ lightranger13_cfg_setup()

void lightranger13_cfg_setup ( lightranger13_cfg_t * cfg)

LightRanger 13 configuration object setup function.

This function initializes Click configuration structure to initial values.

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

◆ lightranger13_clear_interrupts()

err_t lightranger13_clear_interrupts ( lightranger13_t * ctx)

LightRanger 13 clear interrupts function.

This function reads and clears the interrupt status register.

Parameters
[in]ctx: Click context object. See lightranger13_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ lightranger13_default_cfg()

err_t lightranger13_default_cfg ( lightranger13_t * ctx)

LightRanger 13 default configuration function.

This function executes a default configuration of LightRanger 13 Click board.

Parameters
[in]ctx: Click context object. See lightranger13_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ lightranger13_disable_device()

void lightranger13_disable_device ( lightranger13_t * ctx)

LightRanger 13 disable device function.

This function disables the device by setting the EN pin to low logic state.

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

◆ lightranger13_enable_device()

void lightranger13_enable_device ( lightranger13_t * ctx)

LightRanger 13 enable device function.

This function enables the device by setting the EN pin to high logic state.

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

◆ lightranger13_factory_calib()

err_t lightranger13_factory_calib ( lightranger13_t * ctx)

LightRanger 13 factory calib function.

This function performs a factory calibration.

Parameters
[in]ctx: Click context object. See lightranger13_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Calibration environment: Device has to be in the final (correct) optical stack. Cover glass (no smudge on the glass) in front of the device. No target in front of the device within 40cm. Dark room or low ambient light.

◆ lightranger13_get_int_pin()

uint8_t lightranger13_get_int_pin ( lightranger13_t * ctx)

LightRanger 13 get int pin function.

This function returns the INT pin logic state.

Parameters
[in]ctx: Click context object. See lightranger13_t object definition for detailed explanation.
Returns
Pin logic state.
Note
None.

◆ lightranger13_init()

err_t lightranger13_init ( lightranger13_t * ctx,
lightranger13_cfg_t * cfg )

LightRanger 13 initialization function.

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

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

◆ lightranger13_power_up()

err_t lightranger13_power_up ( lightranger13_t * ctx)

LightRanger 13 power up function.

This function enables the device and switches it to ROM application state.

Parameters
[in]ctx: Click context object. See lightranger13_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ lightranger13_read_info()

err_t lightranger13_read_info ( lightranger13_t * ctx)

LightRanger 13 read info function.

This function reads the device information and stores it in ctx->info structure.

Parameters
[in]ctx: Click context object. See lightranger13_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ lightranger13_read_reg()

err_t lightranger13_read_reg ( lightranger13_t * ctx,
uint8_t reg,
uint8_t * data_out )

LightRanger 13 read reg function.

This function reads data from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See lightranger13_t object definition for detailed explanation.
[in]reg: Register address.
[out]data_out: Output read data.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ lightranger13_read_regs()

err_t lightranger13_read_regs ( lightranger13_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

LightRanger 13 read regs 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 lightranger13_t object definition for detailed explanation.
[in]reg: Start register address.
[out]data_out: Output read data.
[in]len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ lightranger13_read_result()

err_t lightranger13_read_result ( lightranger13_t * ctx,
lightranger13_meas_result_t * result )

LightRanger 13 read result function.

This function reads the measurement results.

Parameters
[in]ctx: Click context object. See lightranger13_t object definition for detailed explanation.
[in]result: Click context object. See lightranger13_meas_result_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ lightranger13_send_cmd()

err_t lightranger13_send_cmd ( lightranger13_t * ctx,
uint8_t cmd,
uint8_t * payload,
uint8_t payload_len,
uint16_t timeout_ms )

LightRanger 13 send cmd function.

This function sends a desired App0 command with or without payload, and waits a desired period for a command execution.

Parameters
[in]ctx: Click context object. See lightranger13_t object definition for detailed explanation.
[in]cmd: App0 command list.
[in]payload: Command payload buffer.
[in]payload_len: Command payload len.
[in]timeout_ms: Response timeout in milliseconds.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ lightranger13_set_threshold()

err_t lightranger13_set_threshold ( lightranger13_t * ctx,
uint16_t t_low,
uint16_t t_high,
uint8_t persistance )

LightRanger 13 set threshold function.

This function sets a threshold level and interrupt persistance.

Parameters
[in]ctx: Click context object. See lightranger13_t object definition for detailed explanation.
[in]t_low: Threshold low in millimeters.
[in]t_high: Threshold high in millimeters.
[in]persistance: 0 - ignore threshold, >=1 - number of consecutive results in threshold range.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ lightranger13_start_measurement()

err_t lightranger13_start_measurement ( lightranger13_t * ctx)

LightRanger 13 start measurement function.

This function starts a measurement (the configuration, factory calibration and state data are used from context object).

Parameters
[in]ctx: Click context object. See lightranger13_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ lightranger13_stop_measurement()

err_t lightranger13_stop_measurement ( lightranger13_t * ctx)

LightRanger 13 stop measurement function.

This function stops a measurement.

Parameters
[in]ctx: Click context object. See lightranger13_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ lightranger13_wait_reg_state()

err_t lightranger13_wait_reg_state ( lightranger13_t * ctx,
uint8_t reg,
uint8_t mask,
uint8_t state,
uint16_t timeout_ms )

LightRanger 13 wait reg state function.

This function waits a desired period for selected register bit mask state.

Parameters
[in]ctx: Click context object. See lightranger13_t object definition for detailed explanation.
[in]reg: Register address.
[in]mask: Register bit mask.
[in]state: Register bit state.
[in]timeout_ms: Response timeout in milliseconds.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ lightranger13_write_reg()

err_t lightranger13_write_reg ( lightranger13_t * ctx,
uint8_t reg,
uint8_t data_in )

LightRanger 13 write reg function.

This function writes a desired data to the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See lightranger13_t object definition for detailed explanation.
[in]reg: Register address.
[in]data_in: Data to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ lightranger13_write_regs()

err_t lightranger13_write_regs ( lightranger13_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

LightRanger 13 write regs 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 lightranger13_t object definition for detailed explanation.
[in]reg: Start register address.
[in]data_in: Data to be written.
[in]len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.