42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
66#define LIGHTRANGER3_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
76#define LIGHTRANGER3_RETVAL uint8_t
78#define LIGHTRANGER3_OK 0x00
79#define LIGHTRANGER3_INIT_ERROR 0xFF
86#define LIGHTRANGER3_REG_ICSR 0x00
87#define LIGHTRANGER3_REG_IER 0x02
88#define LIGHTRANGER3_REG_CMD 0x04
89#define LIGHTRANGER3_REG_DEV_STATUS 0x06
90#define LIGHTRANGER3_REG_RESULT 0x08
91#define LIGHTRANGER3_REG_RESULT_CONFIG 0x0A
92#define LIGHTRANGER3_REG_CMD_CONFIG_A 0x0C
93#define LIGHTRANGER3_REG_CMD_CONFIG_B 0x0E
94#define LIGHTRANGER3_REG_HOST_TO_MCPU_MBX 0x10
95#define LIGHTRANGER3_REG_MCPU_TO_HOST_MBX 0x12
96#define LIGHTRANGER3_REG_PMU_CONFIG 0x14
97#define LIGHTRANGER3_REG_I2C_ADDR_PTR 0x18
98#define LIGHTRANGER3_REG_I2C_DATA_PTR 0x1A
99#define LIGHTRANGER3_REG_I2C_INIT_CFG 0x1C
100#define LIGHTRANGER3_REG_MCPU_PM_CTRL 0x1E
101#define LIGHTRANGER3_REG_HW_FW_CONFIG_0 0x20
102#define LIGHTRANGER3_REG_HW_FW_CONFIG_1 0x22
103#define LIGHTRANGER3_REG_HW_FW_CONFIG_2 0x24
104#define LIGHTRANGER3_REG_HW_FW_CONFIG_3 0x26
105#define LIGHTRANGER3_REG_DEVICE_ID 0x28
106#define LIGHTRANGER3_REG_PTCH_MEMORY_CFG 0x2A
113#define LIGHTRANGER3_STANDBY_MODE 0x90
114#define LIGHTRANGER3_OFF_MODE 0x91
115#define LIGHTRANGER3_ON_MODE 0x92
116#define LIGHTRANGER3_MEASUREMENT_MODE 0x81
123#define LIGHTRANGER3_ERROR 0x01
124#define DISTANCE_IS_GOOD 0x7FFF
#define LIGHTRANGER3_RETVAL
Definition lightranger3.h:76
uint16_t lightranger3_get_distance(lightranger3_t *ctx)
Functions for reads distance.
uint16_t lightranger3_read_data(lightranger3_t *ctx, uint8_t reg)
Functions for read data from register.
void lightranger3_write_data(lightranger3_t *ctx, uint8_t reg, uint16_t w_data)
Functions for write data in register.
uint16_t lightranger3_get_confidence_value(lightranger3_t *ctx)
Functions for reads confidence value.
uint8_t lightranger3_get_interrupt(lightranger3_t *ctx)
Functions for reads interrupt pin.
uint8_t lightranger3_device_init(lightranger3_t *ctx)
Functions for initializes chip.
uint8_t lightranger3_set_on_mode(lightranger3_t *ctx)
Functions for go to ON mode.
uint8_t lightranger3_set_measurement_mode(lightranger3_t *ctx)
Functions for go to measurement mode.
void lightranger3_cfg_setup(lightranger3_cfg_t *cfg)
Config Object Initialization function.
uint8_t lightranger3_set_standby_mode(lightranger3_t *ctx)
Functions for go to standby mode.
void lightranger3_generic_write(lightranger3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint8_t lightranger3_set_off_mode(lightranger3_t *ctx)
Functions for go to OFF mode.
uint8_t lightranger3_read_byte(lightranger3_t *ctx, uint8_t reg)
Functions for read one byte from register.
void lightranger3_generic_read(lightranger3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
uint8_t lightranger3_take_single_measurement(lightranger3_t *ctx)
Functions for measurement.
void lightranger3_write_byte(lightranger3_t *ctx, uint8_t reg, uint8_t w_data)
Functions for write one byte in register.
uint16_t lightranger3_get_device_id(lightranger3_t *ctx)
Functions for reads device ID.
LIGHTRANGER3_RETVAL lightranger3_init(lightranger3_t *ctx, lightranger3_cfg_t *cfg)
Initialization function.
void lightranger3_soft_reset(lightranger3_t *ctx)
Functions for soft reset.
Click configuration structure definition.
Definition lightranger3.h:160
uint16_t dev_confidence_value
Definition lightranger3.h:175
uint32_t i2c_speed
Definition lightranger3.h:172
uint16_t dev_distance
Definition lightranger3.h:176
pin_name_t scl
Definition lightranger3.h:163
pin_name_t int_pin
Definition lightranger3.h:168
pin_name_t sda
Definition lightranger3.h:164
uint8_t i2c_address
Definition lightranger3.h:173
Click ctx object definition.
Definition lightranger3.h:138
uint16_t confidence_value
Definition lightranger3.h:151
uint16_t distance
Definition lightranger3.h:152
digital_in_t int_pin
Definition lightranger3.h:141
i2c_master_t i2c
Definition lightranger3.h:145
uint8_t slave_address
Definition lightranger3.h:149