Go to the documentation of this file.
35 #ifndef LIGHTRANGER2_H
36 #define LIGHTRANGER2_H
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
55 #define LIGHTRANGER2_MAP_MIKROBUS( cfg, mikrobus ) \
56 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
57 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
58 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
59 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
66 #define LIGHTRANGER2_RETVAL uint8_t
68 #define LIGHTRANGER2_OK 0x00
69 #define LIGHTRANGER2_INIT_ERROR 0xFF
76 #define LIGHTRANGER2_I2C_ADDR 0x29
83 #define LIGHTRANGER2_SYSRANGE_START 0x00
90 #define LIGHTRANGER2_SYSTEM_THRESH_HIGH 0x0C
91 #define LIGHTRANGER2_SYSTEM_THRESH_LOW 0x0E
98 #define LIGHTRANGER2_SYSTEM_SEQUENCE_CONFIG 0x01
99 #define LIGHTRANGER2_SYSTEM_RANGE_CONFIG 0x09
100 #define LIGHTRANGER2_SYSTEM_INTERMEASUREMENT_PERIOD 0x04
107 #define LIGHTRANGER2_SYSTEM_INTERRUPT_CONFIG_GPIO 0x0A
114 #define LIGHTRANGER2_GPIO_HV_MUX_ACTIVE_HIGH 0x84
121 #define LIGHTRANGER2_SYSTEM_INTERRUPT_CLEAR 0x0B
128 #define LIGHTRANGER2_RESULT_INTERRUPT_STATUS 0x13
129 #define LIGHTRANGER2_RESULT_RANGE_STATUS 0x14
136 #define LIGHTRANGER2_RESULT_CORE_AMBIENT_WINDOW_EVENTS_RTN 0xBC
137 #define LIGHTRANGER2_RESULT_CORE_RANGING_TOTAL_EVENTS_RTN 0xC0
138 #define LIGHTRANGER2_RESULT_CORE_AMBIENT_WINDOW_EVENTS_REF 0xD0
139 #define LIGHTRANGER2_RESULT_CORE_RANGING_TOTAL_EVENTS_REF 0xD4
140 #define LIGHTRANGER2_RESULT_PEAK_SIGNAL_RATE_REF 0xB6
147 #define LIGHTRANGER2_ALGO_PART_TO_PART_RANGE_OFFSET_MM 0x28
154 #define LIGHTRANGER2_MSRC_CONFIG_CONTROL 0x60
161 #define LIGHTRANGER2_PRE_RANGE_CONFIG_MIN_SNR 0x27
162 #define LIGHTRANGER2_PRE_RANGE_CONFIG_VALID_PHASE_LOW 0x56
163 #define LIGHTRANGER2_PRE_RANGE_CONFIG_VALID_PHASE_HIGH 0x57
164 #define LIGHTRANGER2_PRE_RANGE_MIN_COUNT_RATE_RTN_LIMIT 0x64
171 #define LIGHTRANGER2_FINAL_RANGE_CONFIG_MIN_SNR 0x67
172 #define LIGHTRANGER2_FINAL_RANGE_CONFIG_VALID_PHASE_LOW 0x47
173 #define LIGHTRANGER2_FINAL_RANGE_CONFIG_VALID_PHASE_HIGH 0x48
174 #define LIGHTRANGER2_FINAL_RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT 0x44
181 #define LIGHTRANGER2_PRE_RANGE_CONFIG_SIGMA_THRESH_HI 0x61
182 #define LIGHTRANGER2_PRE_RANGE_CONFIG_SIGMA_THRESH_LO 0x62
189 #define LIGHTRANGER2_PRE_RANGE_CONFIG_VCSEL_PERIOD 0x50
190 #define LIGHTRANGER2_PRE_RANGE_CONFIG_TIMEOUT_MACROP_HI 0x51
191 #define LIGHTRANGER2_PRE_RANGE_CONFIG_TIMEOUT_MACROP_LO 0x52
198 #define LIGHTRANGER2_SYSTEM_HISTOGRAM_BIN 0x81
199 #define LIGHTRANGER2_HISTOGRAM_CONFIG_INITIAL_PHASE_SELECT 0x33
200 #define LIGHTRANGER2_HISTOGRAM_CONFIG_READOUT_CTRL 0x55
207 #define LIGHTRANGER2_FINAL_RANGE_CONFIG_VCSEL_PERIOD 0x70
208 #define LIGHTRANGER2_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_HI 0x71
209 #define LIGHTRANGER2_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_LO 0x72
210 #define LIGHTRANGER2_CROSSTALK_COMPENSATION_PEAK_RATE_MCPS 0x20
217 #define LIGHTRANGER2_MSRC_CONFIG_TIMEOUT_MACROP 0x46
224 #define LIGHTRANGER2_SOFT_RESET_GO2_SOFT_RESET_N 0xBF
225 #define LIGHTRANGER2_IDENTIFICATION_MODEL_ID 0xC0
226 #define LIGHTRANGER2_IDENTIFICATION_REVISION_ID 0xC2
233 #define LIGHTRANGER2_OSC_CALIBRATE_VAL 0xF8
240 #define LIGHTRANGER2_GLOBAL_CONFIG_VCSEL_WIDTH 0x32
241 #define LIGHTRANGER2_GLOBAL_CONFIG_SPAD_ENABLES_REF_0 0xB0
242 #define LIGHTRANGER2_GLOBAL_CONFIG_SPAD_ENABLES_REF_1 0xB1
243 #define LIGHTRANGER2_GLOBAL_CONFIG_SPAD_ENABLES_REF_2 0xB2
244 #define LIGHTRANGER2_GLOBAL_CONFIG_SPAD_ENABLES_REF_3 0xB3
245 #define LIGHTRANGER2_GLOBAL_CONFIG_SPAD_ENABLES_REF_4 0xB4
246 #define LIGHTRANGER2_GLOBAL_CONFIG_SPAD_ENABLES_REF_5 0xB5
253 #define LIGHTRANGER2_GLOBAL_CONFIG_REF_EN_START_SELECT 0xB6
254 #define LIGHTRANGER2_DYNAMIC_SPAD_NUM_REQUESTED_REF_SPAD 0x4E
255 #define LIGHTRANGER2_DYNAMIC_SPAD_REF_EN_START_OFFSET 0x4F
256 #define LIGHTRANGER2_POWER_MANAGEMENT_GO1_POWER_FORCE 0x80
263 #define LIGHTRANGER2_VHV_CONFIG_PAD_SCL_SDA__EXTSUP_HV 0x89
270 #define LIGHTRANGER2_ALGO_PHASECAL_LIM 0x30
271 #define LIGHTRANGER2_ALGO_PHASECAL_CONFIG_TIMEOUT 0x30
278 #define LIGHTRANGER2_STATUS_ERR 0x00
279 #define LIGHTRANGER2_STATUS_OK 0x01
589 uint8_t* aperture_type );
606 uint8_t vhv_init_byte );
639 #endif // _LIGHTRANGER2_H_
LIGHTRANGER2_RETVAL lightranger2_init(lightranger2_t *ctx, lightranger2_cfg_t *cfg)
Initialization function.
i2c_master_t i2c
Definition: lightranger2.h:303
uint16_t io_timeout
Definition: lightranger2.h:310
void lightranger2_write_bytes(lightranger2_t *ctx, uint8_t reg_address, uint8_t *write_data, uint8_t n_bytes)
Generic sequential data write function.
void lightranger2_disable(lightranger2_t *ctx)
Disable function.
float lightranger2_get_signal_rate_limit(lightranger2_t *ctx)
Get the signal rate limit check value function.
LIGHTRANGER2_RETVAL lightranger2_get_spad_info(lightranger2_t *ctx, uint8_t *count_data, uint8_t *aperture_type)
Get reference SPAD ( single photon avalanche diode ) function.
void lightranger2_cfg_setup(lightranger2_cfg_t *cfg)
Config Object Initialization function.
uint16_t timeout_start_ms
Definition: lightranger2.h:312
uint8_t slave_address
Definition: lightranger2.h:307
Click configuration structure definition.
Definition: lightranger2.h:320
pin_name_t int_pin
Definition: lightranger2.h:331
void lightranger2_hw_reset(lightranger2_t *ctx)
Hardware reset function.
uint32_t i2c_speed
Definition: lightranger2.h:335
uint32_t milliseconds_counter
Definition: lightranger2.h:309
LIGHTRANGER2_RETVAL lightranger2_set_signal_rate_limit(lightranger2_t *ctx, float limit_mcps)
Set the signal rate limit check value function.
digital_out_t en
Definition: lightranger2.h:297
LIGHTRANGER2_RETVAL lightranger2_single_calibration(lightranger2_t *ctx, uint8_t vhv_init_byte)
Perform single reference calibration function.
uint16_t lightranger2_get_range_continuous(lightranger2_t *ctx)
Get a range measurement ( continuous mode ) function.
void lightranger2_write_byte(lightranger2_t *ctx, uint8_t reg_address, uint8_t write_data)
Click Default Configuration function.
uint8_t lightranger2_get_interrupt(lightranger2_t *ctx)
Get interrupt state function.
#define LIGHTRANGER2_RETVAL
Definition: lightranger2.h:66
pin_name_t sda
Definition: lightranger2.h:324
uint8_t lightranger2_read_byte(lightranger2_t *ctx, uint8_t reg_address)
Click Default Configuration function.
Click ctx object definition.
Definition: lightranger2.h:295
uint16_t lightranger2_get_range_single(lightranger2_t *ctx)
Get a range measurement ( single mode ) function.
void lightranger2_write_data(lightranger2_t *ctx, uint8_t reg_address, uint16_t write_data)
Click Default Configuration function.
uint8_t i2c_address
Definition: lightranger2.h:336
void lightranger2_start_continuous(lightranger2_t *ctx, uint32_t period_ms)
Start continuous ranging measurements function.
void lightranger2_stop_continuous(lightranger2_t *ctx)
Stop continuous measurements function.
uint16_t lightranger2_read_data(lightranger2_t *ctx, uint8_t reg_address)
Click Default Configuration function.
pin_name_t scl
Definition: lightranger2.h:323
LIGHTRANGER2_RETVAL lightranger2_default_cfg(lightranger2_t *ctx)
Click Default Configuration function.
pin_name_t en
Definition: lightranger2.h:329
uint8_t did_timeout
Definition: lightranger2.h:311
digital_in_t int_pin
Definition: lightranger2.h:299
void lightranger2_read_bytes(lightranger2_t *ctx, uint8_t reg_address, uint8_t *read_data, uint8_t n_bytes)
Generic sequential data read function.
void lightranger2_enable(lightranger2_t *ctx)
Enable function.