28#ifndef LIGHTRANGER11_H
29#define LIGHTRANGER11_H
39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
73#define LIGHTRANGER11_DCI_ZONE_CONFIG 0x5450
74#define LIGHTRANGER11_DCI_FREQ_HZ 0x5458
75#define LIGHTRANGER11_DCI_INT_TIME 0x545C
76#define LIGHTRANGER11_DCI_FW_NB_TARGET 0x5478
77#define LIGHTRANGER11_DCI_RANGING_MODE 0xAD30
78#define LIGHTRANGER11_DCI_DSS_CONFIG 0xAD38
79#define LIGHTRANGER11_DCI_TARGET_ORDER 0xAE64
80#define LIGHTRANGER11_DCI_SHARPENER 0xAED8
81#define LIGHTRANGER11_DCI_INTERNAL_CP 0xB39C
82#define LIGHTRANGER11_DCI_MOTION_DETECTOR_CFG 0xBFAC
83#define LIGHTRANGER11_DCI_SINGLE_RANGE 0xCD5C
84#define LIGHTRANGER11_DCI_OUTPUT_CONFIG 0xCD60
85#define LIGHTRANGER11_DCI_OUTPUT_ENABLES 0xCD68
86#define LIGHTRANGER11_DCI_OUTPUT_LIST 0xCD78
87#define LIGHTRANGER11_DCI_PIPE_CONTROL 0xCF78
93#define LIGHTRANGER11_UI_CMD_STATUS 0x2C00
94#define LIGHTRANGER11_UI_CMD_START 0x2C04
95#define LIGHTRANGER11_UI_CMD_END 0x2FFF
113#define LIGHTRANGER11_TEMP_BUFFER_SIZE 1024
114#define LIGHTRANGER11_NVM_DATA_SIZE 492
115#define LIGHTRANGER11_OFFSET_BUFFER_SIZE 488
116#define LIGHTRANGER11_XTALK_BUFFER_SIZE 776
122#define LIGHTRANGER11_RESOLUTION_4X4 16
123#define LIGHTRANGER11_RESOLUTION_8X8 64
129#define LIGHTRANGER11_RANGING_MODE_CONTINUOUS 1
130#define LIGHTRANGER11_RANGING_MODE_AUTONOMOUS 3
136#define LIGHTRANGER11_START_BH 0x0000000Dul
137#define LIGHTRANGER11_METADATA_BH 0x54B400C0ul
138#define LIGHTRANGER11_COMMONDATA_BH 0x54C00040ul
139#define LIGHTRANGER11_AMBIENT_RATE_BH 0x54D00104ul
140#define LIGHTRANGER11_SPAD_COUNT_BH 0x55D00404ul
141#define LIGHTRANGER11_NB_TARGET_DETECTED_BH 0xCF7C0401ul
142#define LIGHTRANGER11_SIGNAL_RATE_BH 0xCFBC0404ul
143#define LIGHTRANGER11_RANGE_SIGMA_MM_BH 0xD2BC0402ul
144#define LIGHTRANGER11_DISTANCE_BH 0xD33C0402ul
145#define LIGHTRANGER11_REFLECTANCE_BH 0xD43C0401ul
146#define LIGHTRANGER11_TARGET_STATUS_BH 0xD47C0401ul
147#define LIGHTRANGER11_MOTION_DETECT_BH 0xCC5008C0ul
148#define LIGHTRANGER11_METADATA_IDX 0x54B4
149#define LIGHTRANGER11_SPAD_COUNT_IDX 0x55D0
150#define LIGHTRANGER11_AMBIENT_RATE_IDX 0x54D0
151#define LIGHTRANGER11_NB_TARGET_DETECTED_IDX 0xCF7C
152#define LIGHTRANGER11_SIGNAL_RATE_IDX 0xCFBC
153#define LIGHTRANGER11_RANGE_SIGMA_MM_IDX 0xD2BC
154#define LIGHTRANGER11_DISTANCE_IDX 0xD33C
155#define LIGHTRANGER11_REFLECTANCE_EST_PC_IDX 0xD43C
156#define LIGHTRANGER11_TARGET_STATUS_IDX 0xD47C
157#define LIGHTRANGER11_MOTION_DETEC_IDX 0xCC50
163#define LIGHTRANGER11_DEF_RESOLUTION LIGHTRANGER11_RESOLUTION_8X8
164#define LIGHTRANGER11_DEF_RANGING_FREQ_HZ 2
165#define LIGHTRANGER11_DEF_RANGING_MODE LIGHTRANGER11_RANGING_MODE_AUTONOMOUS
166#define LIGHTRANGER11_DEF_INTEGRATION_TIME_MS 20
173#define LIGHTRANGER11_DEVICE_ADDRESS 0x29
191#define LIGHTRANGER11_MAP_MIKROBUS( cfg, mikrobus ) \
192 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
193 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
194 cfg.rsc = MIKROBUS( mikrobus, MIKROBUS_RST ); \
195 cfg.lp = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
196 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
259 uint8_t nb_target_detected[ 64 ];
262 int16_t distance_mm[ 64 ];
265 uint8_t target_status[ 64 ];
498 uint16_t data_size );
518 uint16_t data_size );
538 uint16_t data_size, uint8_t *new_data,
539 uint16_t new_data_size, uint16_t new_data_pos );
#define LIGHTRANGER11_OFFSET_BUFFER_SIZE
Definition lightranger11.h:115
#define LIGHTRANGER11_TEMP_BUFFER_SIZE
LightRanger 11 buffers size setting.
Definition lightranger11.h:113
err_t lightranger11_get_ranging_mode(lightranger11_t *ctx, uint8_t *ranging_mode)
LightRanger 11 get ranging mode function.
err_t lightranger11_get_ranging_data(lightranger11_t *ctx, lightranger11_results_data_t *results)
LightRanger 11 get ranging data function.
err_t lightranger11_dci_read_data(lightranger11_t *ctx, uint16_t index, uint8_t *data_out, uint16_t data_size)
LightRanger 11 dci read data function.
err_t lightranger11_get_integ_time_ms(lightranger11_t *ctx, uint32_t *integration_time_ms)
LightRanger 11 get integration time ms function.
err_t lightranger11_set_integ_time_ms(lightranger11_t *ctx, uint32_t integration_time_ms)
LightRanger 11 set integration time ms function.
err_t lightranger11_set_resolution(lightranger11_t *ctx, uint8_t resolution)
LightRanger 11 set resolution function.
void lightranger11_cfg_setup(lightranger11_cfg_t *cfg)
LightRanger 11 configuration object setup function.
err_t lightranger11_check_comm(lightranger11_t *ctx)
LightRanger 11 check communication function.
err_t lightranger11_write_data(lightranger11_t *ctx, uint8_t *data_in, uint16_t len)
LightRanger 11 write data function.
void lightranger11_reset_i2c(lightranger11_t *ctx)
LightRanger 11 reset i2c function.
err_t lightranger11_dci_write_data(lightranger11_t *ctx, uint16_t index, uint8_t *data_in, uint16_t data_size)
LightRanger 11 dci write data function.
void lightranger11_set_i2c_rst_pin(lightranger11_t *ctx, uint8_t state)
LightRanger 11 set i2c rst function.
uint8_t lightranger11_get_int_pin(lightranger11_t *ctx)
LightRanger 11 get int pin function.
err_t lightranger11_set_rang_freq_hz(lightranger11_t *ctx, uint8_t frequency_hz)
LightRanger 11 set ranging frequency hz function.
err_t lightranger11_init(lightranger11_t *ctx, lightranger11_cfg_t *cfg)
LightRanger 11 initialization function.
err_t lightranger11_default_cfg(lightranger11_t *ctx)
LightRanger 11 default configuration function.
err_t lightranger11_read_byte(lightranger11_t *ctx, uint16_t reg, uint8_t *data_out)
LightRanger 11 read byte function.
err_t lightranger11_read_multi(lightranger11_t *ctx, uint16_t reg, uint8_t *data_out, uint16_t len)
LightRanger 11 read multi function.
err_t lightranger11_get_rang_freq_hz(lightranger11_t *ctx, uint8_t *frequency_hz)
LightRanger 11 get ranging frequency hz function.
err_t lightranger11_sensor_init(lightranger11_t *ctx)
LightRanger 11 sensor init function.
err_t lightranger11_set_ranging_mode(lightranger11_t *ctx, uint8_t ranging_mode)
LightRanger 11 set ranging mode function.
err_t lightranger11_dci_replace_data(lightranger11_t *ctx, uint16_t index, uint8_t *data_in, uint16_t data_size, uint8_t *new_data, uint16_t new_data_size, uint16_t new_data_pos)
LightRanger 11 dci replace data function.
err_t lightranger11_start_ranging(lightranger11_t *ctx)
LightRanger 11 start ranging function.
err_t lightranger11_write_byte(lightranger11_t *ctx, uint16_t reg, uint8_t data_in)
LightRanger 11 write byte function.
void lightranger11_set_lpn_pin(lightranger11_t *ctx, uint8_t state)
LightRanger 11 set lpn function.
err_t lightranger11_write_multi(lightranger11_t *ctx, uint16_t reg, uint8_t *data_in, uint8_t len)
LightRanger 11 write multi function.
err_t lightranger11_stop_ranging(lightranger11_t *ctx)
LightRanger 11 stop ranging function.
err_t lightranger11_get_resolution(lightranger11_t *ctx, uint8_t *resolution)
LightRanger 11 get resolution function.
lightranger11_return_value_t
LightRanger 11 Click return value data.
Definition lightranger11.h:274
@ LIGHTRANGER11_OK
Definition lightranger11.h:275
@ LIGHTRANGER11_ERROR
Definition lightranger11.h:276
LightRanger 11 Click configuration object.
Definition lightranger11.h:236
uint32_t i2c_speed
Definition lightranger11.h:244
pin_name_t rsc
Definition lightranger11.h:240
pin_name_t lp
Definition lightranger11.h:241
pin_name_t scl
Definition lightranger11.h:237
pin_name_t int_pin
Definition lightranger11.h:242
pin_name_t sda
Definition lightranger11.h:238
uint8_t i2c_address
Definition lightranger11.h:245
LightRanger 11 Click block header union data definition.
Definition lightranger11.h:254
int8_t silicon_temp_degc
Definition lightranger11.h:256
LightRanger 11 Click context object.
Definition lightranger11.h:206
uint32_t data_read_size
Definition lightranger11.h:223
digital_out_t lp
Definition lightranger11.h:209
digital_out_t rsc
Definition lightranger11.h:208
uint8_t stream_count
Definition lightranger11.h:221
digital_in_t int_pin
Definition lightranger11.h:212
i2c_master_t i2c
Definition lightranger11.h:215
uint8_t slave_address
Definition lightranger11.h:218