lightranger5 2.0.0.0
LightRanger 5 Click Driver

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

Topics

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

Functions

void lightranger5_cfg_setup (lightranger5_cfg_t *cfg)
 LightRanger 5 configuration object setup function.
 
err_t lightranger5_init (lightranger5_t *ctx, lightranger5_cfg_t *cfg)
 LightRanger 5 initialization function.
 
err_t lightranger5_default_cfg (lightranger5_t *ctx)
 LightRanger 5 default configuration function.
 
err_t lightranger5_generic_write (lightranger5_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
 LightRanger 5 I2C writing function.
 
err_t lightranger5_generic_read (lightranger5_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
 LightRanger 5 I2C reading function.
 
err_t lightranger5_enable_device (lightranger5_t *ctx)
 LightRanger 5 enable device function.
 
err_t lightranger5_disable_device (lightranger5_t *ctx)
 LightRanger 5 disable device function.
 
err_t lightranger5_set_pin_state_io0 (lightranger5_t *ctx, uint8_t io0_state)
 LightRanger 5 set IO0 pin state function.
 
err_t lightranger5_set_pin_state_io1 (lightranger5_t *ctx, uint8_t io1_state)
 LightRanger 5 set IO1 pin state function.
 
err_t lightranger5_device_reset (lightranger5_t *ctx)
 LightRanger 5 device reset function.
 
err_t lightranger5_load_app (lightranger5_t *ctx)
 LightRanger 5 load app function.
 
err_t lightranger5_start_calib_cmd (lightranger5_t *ctx)
 LightRanger 5 start calibration function.
 
err_t lightranger5_check_factory_calibration (lightranger5_t *ctx)
 LightRanger 5 check factory calibration function.
 
err_t lightranger5_get_status (lightranger5_t *ctx, uint8_t *status)
 LightRanger 5 get status function.
 
err_t lightranger5_set_command (lightranger5_t *ctx, uint8_t cmd)
 LightRanger 5 set command function.
 
err_t lightranger5_set_factory_calib_data (lightranger5_t *ctx, uint8_t *factory_calib_data)
 LightRanger 5 set factory calib data function.
 
err_t lightranger5_get_factory_calib_data (lightranger5_t *ctx, uint8_t *factory_calib_data)
 LightRanger 5 get factory calib data function.
 
err_t lightranger5_set_algorithm_state_data (lightranger5_t *ctx, uint8_t *alg_state_data)
 LightRanger 5 set algorithm state data function.
 
err_t lightranger5_set_command_data (lightranger5_t *ctx, uint8_t *cmd_data)
 LightRanger 5 set command data function.
 
err_t lightranger5_check_previous_command (lightranger5_t *ctx, uint8_t *previous_cmd)
 LightRanger 5 check previous command function.
 
err_t lightranger5_get_currently_run_app (lightranger5_t *ctx, uint8_t *appid_data)
 LightRanger 5 get currently running application function.
 
lightranger5_return_data_ready_t lightranger5_check_data_ready (lightranger5_t *ctx)
 LightRanger 5 check data ready function.
 
uint16_t lightranger5_measure_distance (lightranger5_t *ctx)
 LightRanger 5 measure distance function.
 
uint8_t lightranger5_check_int (lightranger5_t *ctx)
 LightRanger 5 check interrupt state function.
 

Detailed Description

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

◆ lightranger5_cfg_setup()

void lightranger5_cfg_setup ( lightranger5_cfg_t * cfg)

LightRanger 5 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ lightranger5_check_data_ready()

lightranger5_return_data_ready_t lightranger5_check_data_ready ( lightranger5_t * ctx)

LightRanger 5 check data ready function.

This function check is new data ready of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

Parameters
[in]ctx: Click context object. See lightranger5_t object definition for detailed explanation.
Returns
  • 0x00 ( LIGHTRANGER5_DATA_NOT_READY ) - Data not ready,
  • 0x01 ( LIGHTRANGER5_DATA_IS_READY ) - Data is ready.
See #err_t definition for detailed explanation.
Note
None.

◆ lightranger5_check_factory_calibration()

err_t lightranger5_check_factory_calibration ( lightranger5_t * ctx)

LightRanger 5 check factory calibration function.

This function check the factory calibration, check device ID and currently running application status of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

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

◆ lightranger5_check_int()

uint8_t lightranger5_check_int ( lightranger5_t * ctx)

LightRanger 5 check interrupt state function.

This function check the interrupt state of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

Parameters
[in]ctx: Click context object. See lightranger5_t object definition for detailed explanation.
Returns
  • 0 - INT pin state low,
  • 1 - INT pin state high.
See #err_t definition for detailed explanation.
Note
None.

◆ lightranger5_check_previous_command()

err_t lightranger5_check_previous_command ( lightranger5_t * ctx,
uint8_t * previous_cmd )

LightRanger 5 check previous command function.

This function check the previous command that was executed or current if continues mode is selected of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

Parameters
[in]ctx: Click context object. See lightranger5_t object definition for detailed explanation.
[out]previous_cmd:
  • 0 - Command that was executed,
  • 1 - Current if continues mode is selected.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ lightranger5_default_cfg()

err_t lightranger5_default_cfg ( lightranger5_t * ctx)

LightRanger 5 default configuration function.

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

Parameters
[in]ctx: Click context object. See lightranger5_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.

◆ lightranger5_device_reset()

err_t lightranger5_device_reset ( lightranger5_t * ctx)

LightRanger 5 device reset function.

This function performs a software reset device and fully resetting CPU and all CPU registers of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

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

◆ lightranger5_disable_device()

err_t lightranger5_disable_device ( lightranger5_t * ctx)

LightRanger 5 disable device function.

This function disables the device by sets EN ( CS ) pin to low state of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

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

◆ lightranger5_enable_device()

err_t lightranger5_enable_device ( lightranger5_t * ctx)

LightRanger 5 enable device function.

This function enables the device by sets EN ( CS ) pin to high state of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

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

◆ lightranger5_generic_read()

err_t lightranger5_generic_read ( lightranger5_t * ctx,
uint8_t reg,
uint8_t * rx_buf,
uint8_t rx_len )

LightRanger 5 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 lightranger5_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.

◆ lightranger5_generic_write()

err_t lightranger5_generic_write ( lightranger5_t * ctx,
uint8_t reg,
uint8_t * tx_buf,
uint8_t tx_len )

LightRanger 5 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 lightranger5_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.

◆ lightranger5_get_currently_run_app()

err_t lightranger5_get_currently_run_app ( lightranger5_t * ctx,
uint8_t * appid_data )

LightRanger 5 get currently running application function.

This function get currently running application mode of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

Parameters
[in]ctx: Click context object. See lightranger5_t object definition for detailed explanation.
[out]appid_data:
  • 0xC0 ( LIGHTRANGER5_APPID_MEASUREMENT ) - Measurement application running,
  • 0x80 ( LIGHTRANGER5_APPID_BOOTLOADER ) - Bootloader running.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ lightranger5_get_factory_calib_data()

err_t lightranger5_get_factory_calib_data ( lightranger5_t * ctx,
uint8_t * factory_calib_data )

LightRanger 5 get factory calib data function.

This function get the factory calibration data of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

Parameters
[in]ctx: Click context object. See lightranger5_t object definition for detailed explanation.
[out]factory_calib_data: Pointer to the memory location where factory calibration data be stored.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
This function shall be pre-loaded by the host before command LIGHTRANGER5_CMD_DISTANCE_MEASURE_MODE_1 or LIGHTRANGER5_CMD_DL_CALIB_AND_STATE.

◆ lightranger5_get_status()

err_t lightranger5_get_status ( lightranger5_t * ctx,
uint8_t * status )

LightRanger 5 get status function.

This function get status data of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

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

◆ lightranger5_init()

err_t lightranger5_init ( lightranger5_t * ctx,
lightranger5_cfg_t * cfg )

LightRanger 5 initialization function.

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

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

◆ lightranger5_load_app()

err_t lightranger5_load_app ( lightranger5_t * ctx)

LightRanger 5 load app function.

This function set application that shall be started, set this to measurement app mode of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

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

◆ lightranger5_measure_distance()

uint16_t lightranger5_measure_distance ( lightranger5_t * ctx)

LightRanger 5 measure distance function.

This function measure the distance of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

Parameters
[in]ctx: Click context object. See lightranger5_t object definition for detailed explanation.
Returns
Distance in mm.

See #err_t definition for detailed explanation.

Note
None.

◆ lightranger5_set_algorithm_state_data()

err_t lightranger5_set_algorithm_state_data ( lightranger5_t * ctx,
uint8_t * alg_state_data )

LightRanger 5 set algorithm state data function.

This function set algorithm state data array of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

Parameters
[in]ctx: Click context object. See lightranger5_t object definition for detailed explanation.
[in]alg_state_data: Pointer to the memory location where factory algorithm state data be stored.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
If only algorithm state data and no calibration data is sent to TMF8801, pre-load algorithm state data starting from address LIGHTRANGER5_REG_FACTORY_CALIB_0 instead of LIGHTRANGER5_REG_STATE_DATA_WR_0.

◆ lightranger5_set_command()

err_t lightranger5_set_command ( lightranger5_t * ctx,
uint8_t cmd )

LightRanger 5 set command function.

This function set the command of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

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

◆ lightranger5_set_command_data()

err_t lightranger5_set_command_data ( lightranger5_t * ctx,
uint8_t * cmd_data )

LightRanger 5 set command data function.

This function set command data array of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

Parameters
[in]ctx: Click context object. See lightranger5_t object definition for detailed explanation.
[in]cmd_data: Pointer to the memory location where command data be stored.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
Only available if appid measurement mode ( LIGHTRANGER5_APPID_MEASUREMENT ).

◆ lightranger5_set_factory_calib_data()

err_t lightranger5_set_factory_calib_data ( lightranger5_t * ctx,
uint8_t * factory_calib_data )

LightRanger 5 set factory calib data function.

This function set the factory calibration data of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

Parameters
[in]ctx: Click context object. See lightranger5_t object definition for detailed explanation.
[in]factory_calib_data: Pointer to the memory location where factory calibration data be stored.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
This function shall be pre-loaded by the host before command LIGHTRANGER5_CMD_DISTANCE_MEASURE_MODE_1 or LIGHTRANGER5_CMD_DL_CALIB_AND_STATE.

◆ lightranger5_set_pin_state_io0()

err_t lightranger5_set_pin_state_io0 ( lightranger5_t * ctx,
uint8_t io0_state )

LightRanger 5 set IO0 pin state function.

This function sets the state of the IO0 ( RST ) pin of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

Parameters
[in]ctx: Click context object. See lightranger5_t object definition for detailed explanation.
[in]io0_state:
  • 0 - Low pin state,
  • 1 - High pin state.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ lightranger5_set_pin_state_io1()

err_t lightranger5_set_pin_state_io1 ( lightranger5_t * ctx,
uint8_t io1_state )

LightRanger 5 set IO1 pin state function.

This function sets the state of the IO1 ( PWM ) pin of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

Parameters
[in]ctx: Click context object. See lightranger5_t object definition for detailed explanation.
[in]io1_state:
  • 0 - Low pin state,
  • 1 - High pin state.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ lightranger5_start_calib_cmd()

err_t lightranger5_start_calib_cmd ( lightranger5_t * ctx)

LightRanger 5 start calibration function.

This function start the calibration of the TMF8801, Time-of-Flight Sensor on the LightRanger 5 click board™.

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