Go to the documentation of this file.
35 #ifndef LIGHTRANGER2_H
36 #define LIGHTRANGER2_H
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"
69 #define LIGHTRANGER2_MAP_MIKROBUS( cfg, mikrobus ) \
70 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
71 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
72 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
73 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
80 #define LIGHTRANGER2_RETVAL uint8_t
82 #define LIGHTRANGER2_OK 0x00
83 #define LIGHTRANGER2_INIT_ERROR 0xFF
90 #define LIGHTRANGER2_I2C_ADDR 0x29
97 #define LIGHTRANGER2_SYSRANGE_START 0x00
104 #define LIGHTRANGER2_SYSTEM_THRESH_HIGH 0x0C
105 #define LIGHTRANGER2_SYSTEM_THRESH_LOW 0x0E
112 #define LIGHTRANGER2_SYSTEM_SEQUENCE_CONFIG 0x01
113 #define LIGHTRANGER2_SYSTEM_RANGE_CONFIG 0x09
114 #define LIGHTRANGER2_SYSTEM_INTERMEASUREMENT_PERIOD 0x04
121 #define LIGHTRANGER2_SYSTEM_INTERRUPT_CONFIG_GPIO 0x0A
128 #define LIGHTRANGER2_GPIO_HV_MUX_ACTIVE_HIGH 0x84
135 #define LIGHTRANGER2_SYSTEM_INTERRUPT_CLEAR 0x0B
142 #define LIGHTRANGER2_RESULT_INTERRUPT_STATUS 0x13
143 #define LIGHTRANGER2_RESULT_RANGE_STATUS 0x14
150 #define LIGHTRANGER2_RESULT_CORE_AMBIENT_WINDOW_EVENTS_RTN 0xBC
151 #define LIGHTRANGER2_RESULT_CORE_RANGING_TOTAL_EVENTS_RTN 0xC0
152 #define LIGHTRANGER2_RESULT_CORE_AMBIENT_WINDOW_EVENTS_REF 0xD0
153 #define LIGHTRANGER2_RESULT_CORE_RANGING_TOTAL_EVENTS_REF 0xD4
154 #define LIGHTRANGER2_RESULT_PEAK_SIGNAL_RATE_REF 0xB6
161 #define LIGHTRANGER2_ALGO_PART_TO_PART_RANGE_OFFSET_MM 0x28
168 #define LIGHTRANGER2_MSRC_CONFIG_CONTROL 0x60
175 #define LIGHTRANGER2_PRE_RANGE_CONFIG_MIN_SNR 0x27
176 #define LIGHTRANGER2_PRE_RANGE_CONFIG_VALID_PHASE_LOW 0x56
177 #define LIGHTRANGER2_PRE_RANGE_CONFIG_VALID_PHASE_HIGH 0x57
178 #define LIGHTRANGER2_PRE_RANGE_MIN_COUNT_RATE_RTN_LIMIT 0x64
185 #define LIGHTRANGER2_FINAL_RANGE_CONFIG_MIN_SNR 0x67
186 #define LIGHTRANGER2_FINAL_RANGE_CONFIG_VALID_PHASE_LOW 0x47
187 #define LIGHTRANGER2_FINAL_RANGE_CONFIG_VALID_PHASE_HIGH 0x48
188 #define LIGHTRANGER2_FINAL_RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT 0x44
195 #define LIGHTRANGER2_PRE_RANGE_CONFIG_SIGMA_THRESH_HI 0x61
196 #define LIGHTRANGER2_PRE_RANGE_CONFIG_SIGMA_THRESH_LO 0x62
203 #define LIGHTRANGER2_PRE_RANGE_CONFIG_VCSEL_PERIOD 0x50
204 #define LIGHTRANGER2_PRE_RANGE_CONFIG_TIMEOUT_MACROP_HI 0x51
205 #define LIGHTRANGER2_PRE_RANGE_CONFIG_TIMEOUT_MACROP_LO 0x52
212 #define LIGHTRANGER2_SYSTEM_HISTOGRAM_BIN 0x81
213 #define LIGHTRANGER2_HISTOGRAM_CONFIG_INITIAL_PHASE_SELECT 0x33
214 #define LIGHTRANGER2_HISTOGRAM_CONFIG_READOUT_CTRL 0x55
221 #define LIGHTRANGER2_FINAL_RANGE_CONFIG_VCSEL_PERIOD 0x70
222 #define LIGHTRANGER2_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_HI 0x71
223 #define LIGHTRANGER2_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_LO 0x72
224 #define LIGHTRANGER2_CROSSTALK_COMPENSATION_PEAK_RATE_MCPS 0x20
231 #define LIGHTRANGER2_MSRC_CONFIG_TIMEOUT_MACROP 0x46
238 #define LIGHTRANGER2_SOFT_RESET_GO2_SOFT_RESET_N 0xBF
239 #define LIGHTRANGER2_IDENTIFICATION_MODEL_ID 0xC0
240 #define LIGHTRANGER2_IDENTIFICATION_REVISION_ID 0xC2
247 #define LIGHTRANGER2_OSC_CALIBRATE_VAL 0xF8
254 #define LIGHTRANGER2_GLOBAL_CONFIG_VCSEL_WIDTH 0x32
255 #define LIGHTRANGER2_GLOBAL_CONFIG_SPAD_ENABLES_REF_0 0xB0
256 #define LIGHTRANGER2_GLOBAL_CONFIG_SPAD_ENABLES_REF_1 0xB1
257 #define LIGHTRANGER2_GLOBAL_CONFIG_SPAD_ENABLES_REF_2 0xB2
258 #define LIGHTRANGER2_GLOBAL_CONFIG_SPAD_ENABLES_REF_3 0xB3
259 #define LIGHTRANGER2_GLOBAL_CONFIG_SPAD_ENABLES_REF_4 0xB4
260 #define LIGHTRANGER2_GLOBAL_CONFIG_SPAD_ENABLES_REF_5 0xB5
267 #define LIGHTRANGER2_GLOBAL_CONFIG_REF_EN_START_SELECT 0xB6
268 #define LIGHTRANGER2_DYNAMIC_SPAD_NUM_REQUESTED_REF_SPAD 0x4E
269 #define LIGHTRANGER2_DYNAMIC_SPAD_REF_EN_START_OFFSET 0x4F
270 #define LIGHTRANGER2_POWER_MANAGEMENT_GO1_POWER_FORCE 0x80
277 #define LIGHTRANGER2_VHV_CONFIG_PAD_SCL_SDA__EXTSUP_HV 0x89
284 #define LIGHTRANGER2_ALGO_PHASECAL_LIM 0x30
285 #define LIGHTRANGER2_ALGO_PHASECAL_CONFIG_TIMEOUT 0x30
292 #define LIGHTRANGER2_STATUS_ERR 0x00
293 #define LIGHTRANGER2_STATUS_OK 0x01
603 uint8_t* aperture_type );
620 uint8_t vhv_init_byte );
653 #endif // _LIGHTRANGER2_H_
LIGHTRANGER2_RETVAL lightranger2_init(lightranger2_t *ctx, lightranger2_cfg_t *cfg)
Initialization function.
i2c_master_t i2c
Definition: lightranger2.h:317
uint16_t io_timeout
Definition: lightranger2.h:324
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:326
uint8_t slave_address
Definition: lightranger2.h:321
Click configuration structure definition.
Definition: lightranger2.h:334
pin_name_t int_pin
Definition: lightranger2.h:345
void lightranger2_hw_reset(lightranger2_t *ctx)
Hardware reset function.
uint32_t i2c_speed
Definition: lightranger2.h:349
uint32_t milliseconds_counter
Definition: lightranger2.h:323
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:311
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:80
pin_name_t sda
Definition: lightranger2.h:338
uint8_t lightranger2_read_byte(lightranger2_t *ctx, uint8_t reg_address)
Click Default Configuration function.
Click ctx object definition.
Definition: lightranger2.h:309
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:350
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:337
LIGHTRANGER2_RETVAL lightranger2_default_cfg(lightranger2_t *ctx)
Click Default Configuration function.
pin_name_t en
Definition: lightranger2.h:343
uint8_t did_timeout
Definition: lightranger2.h:325
digital_in_t int_pin
Definition: lightranger2.h:313
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.