lightranger5 2.0.0.0
lightranger5.h File Reference

This file contains API for LightRanger 5 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_i2c_master.h"

Go to the source code of this file.

Data Structures

struct  lightranger5_t
 LightRanger 5 Click context object. More...
 
struct  lightranger5_cfg_t
 LightRanger 5 Click configuration object. More...
 

Macros

#define LIGHTRANGER5_REG_APPID   0x00
 LightRanger 5 description register.
 
#define LIGHTRANGER5_REG_APPREQID   0x02
 
#define LIGHTRANGER5_REG_APPREV_MAJOR   0x01
 
#define LIGHTRANGER5_REG_APPREV_MINOR   0x12
 
#define LIGHTRANGER5_REG_APPREV_PATCH   0x13
 
#define LIGHTRANGER5_REG_CMD_DATA9   0x06
 
#define LIGHTRANGER5_REG_CMD_DATA8   0x07
 
#define LIGHTRANGER5_REG_CMD_DATA7   0x08
 
#define LIGHTRANGER5_REG_CMD_DATA6   0x09
 
#define LIGHTRANGER5_REG_CMD_DATA5   0x0A
 
#define LIGHTRANGER5_REG_CMD_DATA4   0x0B
 
#define LIGHTRANGER5_REG_CMD_DATA3   0x0C
 
#define LIGHTRANGER5_REG_CMD_DATA2   0x0D
 
#define LIGHTRANGER5_REG_CMD_DATA1   0x0E
 
#define LIGHTRANGER5_REG_CMD_DATA0   0x0F
 
#define LIGHTRANGER5_REG_COMMAND   0x10
 
#define LIGHTRANGER5_REG_PREVIOUS   0x11
 
#define LIGHTRANGER5_REG_STATUS   0x1D
 
#define LIGHTRANGER5_REG_REGISTER_CONTENTS   0x1E
 
#define LIGHTRANGER5_REG_TID   0x1F
 
#define LIGHTRANGER5_REG_RESULT_NUMBER   0x20
 
#define LIGHTRANGER5_REG_RESULT_INFO   0x21
 
#define LIGHTRANGER5_REG_DISTANCE_PEAK_0   0x22
 
#define LIGHTRANGER5_REG_DISTANCE_PEAK_1   0x23
 
#define LIGHTRANGER5_REG_SYS_CLOCK_0   0x24
 
#define LIGHTRANGER5_REG_SYS_CLOCK_1   0x25
 
#define LIGHTRANGER5_REG_SYS_CLOCK_2   0x26
 
#define LIGHTRANGER5_REG_SYS_CLOCK_3   0x27
 
#define LIGHTRANGER5_REG_STATE_DATA_0   0x28
 
#define LIGHTRANGER5_REG_STATE_DATA_1   0x29
 
#define LIGHTRANGER5_REG_STATE_DATA_2   0x2A
 
#define LIGHTRANGER5_REG_STATE_DATA_3   0x2B
 
#define LIGHTRANGER5_REG_STATE_DATA_4   0x2C
 
#define LIGHTRANGER5_REG_STATE_DATA_5   0x2D
 
#define LIGHTRANGER5_REG_STATE_DATA_6   0x2E
 
#define LIGHTRANGER5_REG_STATE_DATA_7   0x2F
 
#define LIGHTRANGER5_REG_STATE_DATA_8_XTALK_MSB   0x30
 
#define LIGHTRANGER5_REG_STATE_DATA_9_XTALK_LSB   0x31
 
#define LIGHTRANGER5_REG_STATE_DATA_10_TJ   0x32
 
#define LIGHTRANGER5_REG_REFERENCE_HITS_0   0x33
 
#define LIGHTRANGER5_REG_REFERENCE_HITS_1   0x34
 
#define LIGHTRANGER5_REG_REFERENCE_HITS_2   0x35
 
#define LIGHTRANGER5_REG_REFERENCE_HITS_3   0x36
 
#define LIGHTRANGER5_REG_OBJECT_HITS_0   0x37
 
#define LIGHTRANGER5_REG_OBJECT_HITS_1   0x38
 
#define LIGHTRANGER5_REG_OBJECT_HITS_2   0x39
 
#define LIGHTRANGER5_REG_OBJECT_HITS_3   0x3A
 
#define LIGHTRANGER5_REG_FACTORY_CALIB_0   0x20
 
#define LIGHTRANGER5_REG_STATE_DATA_WR_0   0x2E
 
#define LIGHTRANGER5_REG_ENABLE   0xE0
 
#define LIGHTRANGER5_REG_INT_STATUS   0xE1
 
#define LIGHTRANGER5_REG_INT_ENAB   0xE2
 
#define LIGHTRANGER5_REG_DEVICE_ID   0xE3
 
#define LIGHTRANGER5_REG_REVID   0xE4
 
#define LIGHTRANGER5_CMD_NO_COMMAND   0x00
 LightRanger 5 description setting.
 
#define LIGHTRANGER5_CMD_DISTANCE_MEASURE_MODE_1   0x02
 
#define LIGHTRANGER5_CMD_FACTORY_CALIB   0x0A
 
#define LIGHTRANGER5_CMD_DL_CALIB_AND_STATE   0x0B
 
#define LIGHTRANGER5_CMD_RESULT   0x55
 
#define LIGHTRANGER5_APPID_MEASUREMENT   0xC0
 LightRanger 5 device app mode setting.
 
#define LIGHTRANGER5_APPID_BOOTLOADER   0x80
 
#define LIGHTRANGER5_EXPECTED_ID   0x07
 
#define LIGHTRANGER5_CALIB_DATA   0x0A
 
#define LIGHTRANGER5_SERIAL_NUMBER   0x47
 
#define LIGHTRANGER5_BIT_CPU_RDY   0x40
 
#define LIGHTRANGER5_ENABLE_RESET   0x80
 
#define LIGHTRANGER5_SET_DEV_ADDR   0x41
 LightRanger 5 device address setting.
 
#define LIGHTRANGER5_STATUS_IDLE   0x00
 LightRanger 5 status data.
 
#define LIGHTRANGER5_STATUS_DIAGNOSTIC   0x01
 
#define LIGHTRANGER5_STATUS_START   0x02
 
#define LIGHTRANGER5_STATUS_CALIBRATION   0x03
 
#define LIGHTRANGER5_STATUS_LIGHTCOL   0x04
 
#define LIGHTRANGER5_STATUS_ALGORITHM   0x05
 
#define LIGHTRANGER5_STATUS_STARTUP   0x06
 
#define LIGHTRANGER5_STATUS_OK   0x0F
 
#define LIGHTRANGER5_STATUS_VCSEL_PWR_FAIL   0x10
 
#define LIGHTRANGER5_STATUS_VCSEL_LED_A_FAIL   0x11
 
#define LIGHTRANGER5_STATUS_VCSEL_LED_K_FAIL   0x12
 
#define LIGHTRANGER5_STATUS_INVALID_PARAM   0x18
 
#define LIGHTRANGER5_STATUS_INVALID_DEVICE   0x19
 
#define LIGHTRANGER5_STATUS_CALIB_ERROR   0x1B
 
#define LIGHTRANGER5_STATUS_INVALID_COMMAND   0x1C
 
#define LIGHTRANGER5_STATUS_INVALID_STATE   0x1D
 
#define LIGHTRANGER5_STATUS_ERR_ALGORITHM   0x1F
 
#define LIGHTRANGER5_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  lightranger5_return_value_t { LIGHTRANGER5_OK = 0 , LIGHTRANGER5_ERROR = -1 }
 LightRanger 5 Click return value data. More...
 
enum  lightranger5_return_data_ready_t { LIGHTRANGER5_DATA_NOT_READY = 0 , LIGHTRANGER5_DATA_IS_READY = 1 }
 LightRanger 5 Click return data ready. More...
 

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

This file contains API for LightRanger 5 Click Driver.

Enumeration Type Documentation

◆ lightranger5_return_data_ready_t

LightRanger 5 Click return data ready.

Predefined enum values for driver return data ready values.

Enumerator
LIGHTRANGER5_DATA_NOT_READY 
LIGHTRANGER5_DATA_IS_READY 

◆ lightranger5_return_value_t

LightRanger 5 Click return value data.

Predefined enum values for driver return values.

Enumerator
LIGHTRANGER5_OK 
LIGHTRANGER5_ERROR