Go to the documentation of this file.
28 #ifndef LIGHTRANGER9_H
29 #define LIGHTRANGER9_H
35 #include "mikrosdk_version.h"
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
70 #define LIGHTRANGER9_REG_APPID 0x00
71 #define LIGHTRANGER9_REG_MINOR 0x01
72 #define LIGHTRANGER9_REG_ENABLE 0xE0
73 #define LIGHTRANGER9_REG_INT_STATUS 0xE1
74 #define LIGHTRANGER9_REG_INT_ENAB 0xE2
75 #define LIGHTRANGER9_REG_ID 0xE3
76 #define LIGHTRANGER9_REG_REVID 0xE4
83 #define LIGHTRANGER9_REG_PATCH 0x02
84 #define LIGHTRANGER9_REG_BUILD_TYPE 0x03
85 #define LIGHTRANGER9_REG_APPLICATION_STATUS 0x04
86 #define LIGHTRANGER9_REG_MEASURE_STATUS 0x05
87 #define LIGHTRANGER9_REG_ALGORITHM_STATUS 0x06
88 #define LIGHTRANGER9_REG_CALIBRATION_STATUS 0x07
89 #define LIGHTRANGER9_REG_CMD_STAT 0x08
90 #define LIGHTRANGER9_REG_PREV_CMD 0x09
91 #define LIGHTRANGER9_REG_MODE 0x10
92 #define LIGHTRANGER9_REG_LIVE_BEAT 0x0A
93 #define LIGHTRANGER9_REG_ACTIVE_RANGE 0x19
94 #define LIGHTRANGER9_REG_SERIAL_NUMBER_0 0x1C
95 #define LIGHTRANGER9_REG_SERIAL_NUMBER_1 0x1D
96 #define LIGHTRANGER9_REG_SERIAL_NUMBER_2 0x1E
97 #define LIGHTRANGER9_REG_SERIAL_NUMBER_3 0x1F
98 #define LIGHTRANGER9_REG_CONFIG_RESULT 0x20
99 #define LIGHTRANGER9_REG_TID 0x21
100 #define LIGHTRANGER9_REG_SIZE_LSB 0x22
101 #define LIGHTRANGER9_REG_SIZE_MSB 0x23
108 #define LIGHTRANGER9_REG_BLOCKREAD 0x20
109 #define LIGHTRANGER9_REG_RESULT_NUMBER 0x24
110 #define LIGHTRANGER9_REG_TEMPERATURE 0x25
111 #define LIGHTRANGER9_REG_NUMBER_VALID_RESULTS 0x26
112 #define LIGHTRANGER9_REG_AMBIENT_LIGHT_0 0x28
113 #define LIGHTRANGER9_REG_AMBIENT_LIGHT_1 0x29
114 #define LIGHTRANGER9_REG_AMBIENT_LIGHT_2 0x2A
115 #define LIGHTRANGER9_REG_AMBIENT_LIGHT_3 0x2B
116 #define LIGHTRANGER9_REG_PHOTON_COUNT_0 0x2C
117 #define LIGHTRANGER9_REG_PHOTON_COUNT_1 0x2D
118 #define LIGHTRANGER9_REG_PHOTON_COUNT_2 0x2E
119 #define LIGHTRANGER9_REG_PHOTON_COUNT_3 0x2F
120 #define LIGHTRANGER9_REG_REFERENCE_COUNT_0 0x30
121 #define LIGHTRANGER9_REG_REFERENCE_COUNT_1 0x31
122 #define LIGHTRANGER9_REG_REFERENCE_COUNT_2 0x32
123 #define LIGHTRANGER9_REG_REFERENCE_COUNT_3 0x33
124 #define LIGHTRANGER9_REG_SYS_TICK_0 0x34
125 #define LIGHTRANGER9_REG_SYS_TICK_1 0x35
126 #define LIGHTRANGER9_REG_SYS_TICK_2 0x36
127 #define LIGHTRANGER9_REG_SYS_TICK_3 0x37
128 #define LIGHTRANGER9_REG_RES_CONFIDENCE_0 0x38
129 #define LIGHTRANGER9_REG_RES_DISTANCE_0_LSB 0x39
130 #define LIGHTRANGER9_REG_RES_DISTANCE_0_MSB 0x3A
131 #define LIGHTRANGER9_REG_RES_CONFIDENCE_1 0x3B
132 #define LIGHTRANGER9_REG_RES_DISTANCE_1_LSB 0x3C
133 #define LIGHTRANGER9_REG_RES_DISTANCE_1_MSB 0x3D
134 #define LIGHTRANGER9_REG_RES_CONFIDENCE_2 0x3E
135 #define LIGHTRANGER9_REG_RES_DISTANCE_2_LSB 0x3F
136 #define LIGHTRANGER9_REG_RES_DISTANCE_2_MSB 0x40
137 #define LIGHTRANGER9_REG_RES_CONFIDENCE_3 0x41
138 #define LIGHTRANGER9_REG_RES_DISTANCE_3_LSB 0x42
139 #define LIGHTRANGER9_REG_RES_DISTANCE_3_MSB 0x43
140 #define LIGHTRANGER9_REG_RES_CONFIDENCE_4 0x44
141 #define LIGHTRANGER9_REG_RES_DISTANCE_4_LSB 0x45
142 #define LIGHTRANGER9_REG_RES_DISTANCE_4_MSB 0x46
143 #define LIGHTRANGER9_REG_RES_CONFIDENCE_5 0x47
144 #define LIGHTRANGER9_REG_RES_DISTANCE_5_LSB 0x48
145 #define LIGHTRANGER9_REG_RES_DISTANCE_5_MSB 0x49
146 #define LIGHTRANGER9_REG_RES_CONFIDENCE_6 0x4A
147 #define LIGHTRANGER9_REG_RES_DISTANCE_6_LSB 0x4B
148 #define LIGHTRANGER9_REG_RES_DISTANCE_6_MSB 0x4C
149 #define LIGHTRANGER9_REG_RES_CONFIDENCE_7 0x4D
150 #define LIGHTRANGER9_REG_RES_DISTANCE_7_LSB 0x4E
151 #define LIGHTRANGER9_REG_RES_DISTANCE_7_MSB 0x4F
152 #define LIGHTRANGER9_REG_RES_CONFIDENCE_8 0x50
153 #define LIGHTRANGER9_REG_RES_DISTANCE_8_LSB 0x51
154 #define LIGHTRANGER9_REG_RES_DISTANCE_8_MSB 0x52
155 #define LIGHTRANGER9_REG_RES_CONFIDENCE_9 0x53
156 #define LIGHTRANGER9_REG_RES_DISTANCE_9_LSB 0x54
157 #define LIGHTRANGER9_REG_RES_DISTANCE_9_MSB 0x55
158 #define LIGHTRANGER9_REG_RES_CONFIDENCE_10 0x56
159 #define LIGHTRANGER9_REG_RES_DISTANCE_10_LSB 0x57
160 #define LIGHTRANGER9_REG_RES_DISTANCE_10_MSB 0x58
161 #define LIGHTRANGER9_REG_RES_CONFIDENCE_11 0x59
162 #define LIGHTRANGER9_REG_RES_DISTANCE_11_LSB 0x5A
163 #define LIGHTRANGER9_REG_RES_DISTANCE_11_MSB 0x5B
164 #define LIGHTRANGER9_REG_RES_CONFIDENCE_12 0x5C
165 #define LIGHTRANGER9_REG_RES_DISTANCE_12_LSB 0x5D
166 #define LIGHTRANGER9_REG_RES_DISTANCE_12_MSB 0x5E
167 #define LIGHTRANGER9_REG_RES_CONFIDENCE_13 0x5F
168 #define LIGHTRANGER9_REG_RES_DISTANCE_13_LSB 0x60
169 #define LIGHTRANGER9_REG_RES_DISTANCE_13_MSB 0x61
170 #define LIGHTRANGER9_REG_RES_CONFIDENCE_14 0x62
171 #define LIGHTRANGER9_REG_RES_DISTANCE_14_LSB 0x63
172 #define LIGHTRANGER9_REG_RES_DISTANCE_14_MSB 0x64
173 #define LIGHTRANGER9_REG_RES_CONFIDENCE_15 0x65
174 #define LIGHTRANGER9_REG_RES_DISTANCE_15_LSB 0x66
175 #define LIGHTRANGER9_REG_RES_DISTANCE_15_MSB 0x67
176 #define LIGHTRANGER9_REG_RES_CONFIDENCE_16 0x68
177 #define LIGHTRANGER9_REG_RES_DISTANCE_16_LSB 0x69
178 #define LIGHTRANGER9_REG_RES_DISTANCE_16_MSB 0x6A
179 #define LIGHTRANGER9_REG_RES_CONFIDENCE_17 0x6B
180 #define LIGHTRANGER9_REG_RES_DISTANCE_17_LSB 0x6C
181 #define LIGHTRANGER9_REG_RES_DISTANCE_17_MSB 0x6D
182 #define LIGHTRANGER9_REG_RES_CONFIDENCE_18 0x6E
183 #define LIGHTRANGER9_REG_RES_DISTANCE_18_LSB 0x6F
184 #define LIGHTRANGER9_REG_RES_DISTANCE_18_MSB 0x70
185 #define LIGHTRANGER9_REG_RES_CONFIDENCE_19 0x71
186 #define LIGHTRANGER9_REG_RES_DISTANCE_19_LSB 0x72
187 #define LIGHTRANGER9_REG_RES_DISTANCE_19_MSB 0x73
188 #define LIGHTRANGER9_REG_RES_CONFIDENCE_20 0x74
189 #define LIGHTRANGER9_REG_RES_DISTANCE_20_LSB 0x75
190 #define LIGHTRANGER9_REG_RES_DISTANCE_20_MSB 0x76
191 #define LIGHTRANGER9_REG_RES_CONFIDENCE_21 0x77
192 #define LIGHTRANGER9_REG_RES_DISTANCE_21_LSB 0x78
193 #define LIGHTRANGER9_REG_RES_DISTANCE_21_MSB 0x79
194 #define LIGHTRANGER9_REG_RES_CONFIDENCE_22 0x7A
195 #define LIGHTRANGER9_REG_RES_DISTANCE_22_LSB 0x7B
196 #define LIGHTRANGER9_REG_RES_DISTANCE_22_MSB 0x7C
197 #define LIGHTRANGER9_REG_RES_CONFIDENCE_23 0x7D
198 #define LIGHTRANGER9_REG_RES_DISTANCE_23_LSB 0x7E
199 #define LIGHTRANGER9_REG_RES_DISTANCE_23_MSB 0x7F
200 #define LIGHTRANGER9_REG_RES_CONFIDENCE_24 0x80
201 #define LIGHTRANGER9_REG_RES_DISTANCE_24_LSB 0x81
202 #define LIGHTRANGER9_REG_RES_DISTANCE_24_MSB 0x82
203 #define LIGHTRANGER9_REG_RES_CONFIDENCE_25 0x83
204 #define LIGHTRANGER9_REG_RES_DISTANCE_25_LSB 0x84
205 #define LIGHTRANGER9_REG_RES_DISTANCE_25_MSB 0x85
206 #define LIGHTRANGER9_REG_RES_CONFIDENCE_26 0x86
207 #define LIGHTRANGER9_REG_RES_DISTANCE_26_LSB 0x87
208 #define LIGHTRANGER9_REG_RES_DISTANCE_26_MSB 0x88
209 #define LIGHTRANGER9_REG_RES_CONFIDENCE_27 0x89
210 #define LIGHTRANGER9_REG_RES_DISTANCE_27_LSB 0x8A
211 #define LIGHTRANGER9_REG_RES_DISTANCE_27_MSB 0x8B
212 #define LIGHTRANGER9_REG_RES_CONFIDENCE_28 0x8C
213 #define LIGHTRANGER9_REG_RES_DISTANCE_28_LSB 0x8D
214 #define LIGHTRANGER9_REG_RES_DISTANCE_28_MSB 0x8E
215 #define LIGHTRANGER9_REG_RES_CONFIDENCE_29 0x8F
216 #define LIGHTRANGER9_REG_RES_DISTANCE_29_LSB 0x90
217 #define LIGHTRANGER9_REG_RES_DISTANCE_29_MSB 0x91
218 #define LIGHTRANGER9_REG_RES_CONFIDENCE_30 0x92
219 #define LIGHTRANGER9_REG_RES_DISTANCE_30_LSB 0x93
220 #define LIGHTRANGER9_REG_RES_DISTANCE_30_MSB 0x94
221 #define LIGHTRANGER9_REG_RES_CONFIDENCE_31 0x95
222 #define LIGHTRANGER9_REG_RES_DISTANCE_31_LSB 0x96
223 #define LIGHTRANGER9_REG_RES_DISTANCE_31_MSB 0x97
224 #define LIGHTRANGER9_REG_RES_CONFIDENCE_32 0x98
225 #define LIGHTRANGER9_REG_RES_DISTANCE_32_LSB 0x99
226 #define LIGHTRANGER9_REG_RES_DISTANCE_32_MSB 0x9A
227 #define LIGHTRANGER9_REG_RES_CONFIDENCE_33 0x9B
228 #define LIGHTRANGER9_REG_RES_DISTANCE_33_LSB 0x9C
229 #define LIGHTRANGER9_REG_RES_DISTANCE_33_MSB 0x9D
230 #define LIGHTRANGER9_REG_RES_CONFIDENCE_34 0x9E
231 #define LIGHTRANGER9_REG_RES_DISTANCE_34_LSB 0x9F
232 #define LIGHTRANGER9_REG_RES_DISTANCE_34_MSB 0xA0
233 #define LIGHTRANGER9_REG_RES_CONFIDENCE_35 0xA1
234 #define LIGHTRANGER9_REG_RES_DISTANCE_35_LSB 0xA2
235 #define LIGHTRANGER9_REG_RES_DISTANCE_35_MSB 0xA3
242 #define LIGHTRANGER9_REG_PERIOD_MS_LSB 0x24
243 #define LIGHTRANGER9_REG_PERIOD_MS_MSB 0x25
244 #define LIGHTRANGER9_REG_KILO_ITERATIONS_LSB 0x26
245 #define LIGHTRANGER9_REG_KILO_ITERATIONS_MSB 0x27
246 #define LIGHTRANGER9_REG_INT_THRESHOLD_LOW_LSB 0x28
247 #define LIGHTRANGER9_REG_INT_THRESHOLD_LOW_MSB 0x29
248 #define LIGHTRANGER9_REG_INT_THRESHOLD_HIGH_LSB 0x2A
249 #define LIGHTRANGER9_REG_INT_THRESHOLD_HIGH_MSB 0x2B
250 #define LIGHTRANGER9_REG_INT_ZONE_MASK_0 0x2C
251 #define LIGHTRANGER9_REG_INT_ZONE_MASK_1 0x2D
252 #define LIGHTRANGER9_REG_INT_ZONE_MASK_2 0x2E
253 #define LIGHTRANGER9_REG_INT_PERSISTANCE 0x2F
254 #define LIGHTRANGER9_REG_CONFIDENCE_THRESHOLD 0x30
255 #define LIGHTRANGER9_REG_GPIO_0 0x31
256 #define LIGHTRANGER9_REG_GPIO_1 0x32
257 #define LIGHTRANGER9_REG_POWER_CFG 0x33
258 #define LIGHTRANGER9_REG_SPAD_MAP_ID 0x34
259 #define LIGHTRANGER9_REG_ALG_SETTING_0 0x35
260 #define LIGHTRANGER9_REG_HIST_DUMP 0x39
261 #define LIGHTRANGER9_REG_SPREAD_SPECTRUM 0x3A
262 #define LIGHTRANGER9_REG_I2C_SLAVE_ADDRESS 0x3B
263 #define LIGHTRANGER9_REG_OSC_TRIM_VALUE_LSB 0x3C
264 #define LIGHTRANGER9_REG_OSC_TRIM_VALUE_MSB 0x3D
265 #define LIGHTRANGER9_REG_I2C_ADDR_CHANGE 0x3E
272 #define LIGHTRANGER9_REG_SPAD_ENABLE_FIRST 0x24
273 #define LIGHTRANGER9_REG_SPAD_ENABLE_LAST 0x41
274 #define LIGHTRANGER9_REG_SPAD_TDC_FIRST 0x42
275 #define LIGHTRANGER9_REG_SPAD_TDC_LAST 0x8C
276 #define LIGHTRANGER9_REG_SPAD_X_OFFSET_2 0x8D
277 #define LIGHTRANGER9_REG_SPAD_Y_OFFSET_2 0x8E
278 #define LIGHTRANGER9_REG_SPAD_X_SIZE 0x8F
279 #define LIGHTRANGER9_REG_SPAD_Y_SIZE 0x90
286 #define LIGHTRANGER9_REG_FACTORY_CALIBRATION_FIRST 0x24
287 #define LIGHTRANGER9_REG_CROSSTALK_ZONE1 0x60
288 #define LIGHTRANGER9_REG_CROSSTALK_ZONE2 0x64
289 #define LIGHTRANGER9_REG_CROSSTALK_ZONE3 0x68
290 #define LIGHTRANGER9_REG_CROSSTALK_ZONE4 0x6C
291 #define LIGHTRANGER9_REG_CROSSTALK_ZONE5 0x70
292 #define LIGHTRANGER9_REG_CROSSTALK_ZONE6 0x74
293 #define LIGHTRANGER9_REG_CROSSTALK_ZONE7 0x78
294 #define LIGHTRANGER9_REG_CROSSTALK_ZONE8 0x7C
295 #define LIGHTRANGER9_REG_CROSSTALK_ZONE9 0x80
296 #define LIGHTRANGER9_REG_CROSSTALK_ZONE1_TMUX 0xB8
297 #define LIGHTRANGER9_REG_CROSSTALK_ZONE2_TMUX 0xBC
298 #define LIGHTRANGER9_REG_CROSSTALK_ZONE3_TMUX 0xC0
299 #define LIGHTRANGER9_REG_CROSSTALK_ZONE4_TMUX 0xC4
300 #define LIGHTRANGER9_REG_CROSSTALK_ZONE5_TMUX 0xC8
301 #define LIGHTRANGER9_REG_CROSSTALK_ZONE6_TMUX 0xCC
302 #define LIGHTRANGER9_REG_CROSSTALK_ZONE7_TMUX 0xD0
303 #define LIGHTRANGER9_REG_CROSSTALK_ZONE8_TMUX 0xD4
304 #define LIGHTRANGER9_REG_CROSSTALK_ZONE9_TMUX 0xD8
305 #define LIGHTRANGER9_REG_CALIBRATION_STATUS_FC 0xDC
306 #define LIGHTRANGER9_REG_FACTORY_CALIBRATION_LAST 0xDF
313 #define LIGHTRANGER9_REG_SUBPACKET_NUMBER 0x24
314 #define LIGHTRANGER9_REG_SUBPACKET_PAYLOAD 0x25
315 #define LIGHTRANGER9_REG_SUBPACKET_CONFIG 0x26
316 #define LIGHTRANGER9_REG_SUBPACKET_DATA0 0x27
317 #define LIGHTRANGER9_REG_SUBPACKET_DATA127 0xA6
324 #define LIGHTRANGER9_REG_BL_CMD_STAT 0x08
325 #define LIGHTRANGER9_REG_BL_SIZE 0x09
326 #define LIGHTRANGER9_REG_BL_DATA 0x0A
344 #define LIGHTRANGER9_TIMEOUT 5000
350 #define LIGHTRANGER9_ENABLE_CPU_READY 0x40
351 #define LIGHTRANGER9_ENABLE_POWERUP_BL 0x00
352 #define LIGHTRANGER9_ENABLE_POWERUP_BL_NO_SLP 0x10
353 #define LIGHTRANGER9_ENABLE_POWERUP_RAM 0x20
354 #define LIGHTRANGER9_ENABLE_PON 0x01
360 #define LIGHTRANGER9_INT_ENAB_REG_STATUS 0x40
361 #define LIGHTRANGER9_INT_ENAB_COMMAND 0x20
362 #define LIGHTRANGER9_INT_ENAB_HIST_READY 0x08
363 #define LIGHTRANGER9_INT_ENAB_MEAS_READY 0x02
369 #define LIGHTRANGER9_INT_STATUS_REG_STATUS 0x40
370 #define LIGHTRANGER9_INT_STATUS_COMMAND 0x20
371 #define LIGHTRANGER9_INT_STATUS_HIST_READY 0x08
372 #define LIGHTRANGER9_INT_STATUS_MEAS_READY 0x02
378 #define LIGHTRANGER9_CMD_STAT_MEASURE 0x10
379 #define LIGHTRANGER9_CMD_STAT_CLEAR_STATUS 0x11
380 #define LIGHTRANGER9_CMD_STAT_GPIO 0x12
381 #define LIGHTRANGER9_CMD_STAT_WRITE_CFG_PAGE 0x15
382 #define LIGHTRANGER9_CMD_STAT_LOAD_CFG_PAGE_COMMON 0x16
383 #define LIGHTRANGER9_CMD_STAT_LOAD_CFG_PAGE_SPAD_1 0x17
384 #define LIGHTRANGER9_CMD_STAT_LOAD_CFG_PAGE_SPAD_2 0x18
385 #define LIGHTRANGER9_CMD_STAT_LOAD_CFG_PAGE_F_Y_CAL 0x19
386 #define LIGHTRANGER9_CMD_STAT_FACTORY_CALIBRATION 0x20
387 #define LIGHTRANGER9_CMD_STAT_I2C_SLAVE_ADDRESS 0x21
388 #define LIGHTRANGER9_CMD_STAT_FORCE_TMF8820 0x65
389 #define LIGHTRANGER9_CMD_STAT_FORCE_TMF8828 0x6C
390 #define LIGHTRANGER9_CMD_STAT_RESET 0xFE
391 #define LIGHTRANGER9_CMD_STAT_STOP 0xFF
397 #define LIGHTRANGER9_CMD_STAT_OK 0x00
398 #define LIGHTRANGER9_CMD_STAT_ACCEPTED 0x01
399 #define LIGHTRANGER9_CMD_ERR_CONFIG 0x02
400 #define LIGHTRANGER9_CMD_ERR_APPLICATION 0x03
401 #define LIGHTRANGER9_CMD_ERR_WAKEUP_TIMED 0x04
402 #define LIGHTRANGER9_CMD_ERR_RESET_UNEXPECTED 0x05
403 #define LIGHTRANGER9_CMD_ERR_UNKNOWN_CMD 0x06
404 #define LIGHTRANGER9_CMD_ERR_NO_REF_SPAD 0x07
405 #define LIGHTRANGER9_CMD_ERR_UNKNOWN_CID 0x09
406 #define LIGHTRANGER9_CMD_WARNING_CFG_SPAD_1 0x0A
407 #define LIGHTRANGER9_CMD_WARNING_CFG_SPAD_2 0x0B
408 #define LIGHTRANGER9_CMD_WARNING_OSC_TRIP 0x0C
409 #define LIGHTRANGER9_CMD_WARNING_I2C_ADDRESS 0x0D
410 #define LIGHTRANGER9_CMD_ERR_UNKNOWN_MODE 0x0E
416 #define LIGHTRANGER9_CONFIG_RESULT_MEAS 0x10
417 #define LIGHTRANGER9_CONFIG_RESULT_COMMON_CID 0x16
418 #define LIGHTRANGER9_CONFIG_RESULT_SPAD_1_CID 0x17
419 #define LIGHTRANGER9_CONFIG_RESULT_SPAD_2_CID 0x18
420 #define LIGHTRANGER9_CONFIG_RESULT_FAC_CALIB_CID 0x19
421 #define LIGHTRANGER9_CONFIG_RESULT_HIST_RAW_CID 0x81
427 #define LIGHTRANGER9_BL_CMD_RAMREMAP_RESET 0x11
428 #define LIGHTRANGER9_BL_CMD_DOWNLOAD_INIT 0x14
429 #define LIGHTRANGER9_BL_CMD_RAM_BIST 0x2A
430 #define LIGHTRANGER9_BL_CMD_I2C_BIST 0x2C
431 #define LIGHTRANGER9_BL_CMD_W_RAM 0x41
432 #define LIGHTRANGER9_BL_CMD_ADDR_RAM 0x43
438 #define LIGHTRANGER9_BL_CMD_STAT_READY 0x00
439 #define LIGHTRANGER9_BL_CMD_STAT_ERR_SIZE 0x01
440 #define LIGHTRANGER9_BL_CMD_STAT_ERR_CSUM 0x02
441 #define LIGHTRANGER9_BL_CMD_STAT_ERR_RANGE 0x03
442 #define LIGHTRANGER9_BL_CMD_STAT_ERR_MORE 0x04
448 #define LIGHTRANGER9_APP_ID_BOOTLOADER 0x80
449 #define LIGHTRANGER9_APP_ID_MEASUREMENT 0x03
455 #define LIGHTRANGER9_BLOCKREAD_SIZE 132
456 #define LIGHTRANGER9_MAX_MEAS_RESULTS 36
457 #define LIGHTRANGER9_SUBCAPTURE_0 0
458 #define LIGHTRANGER9_SUBCAPTURE_1 1
459 #define LIGHTRANGER9_SUBCAPTURE_2 2
460 #define LIGHTRANGER9_SUBCAPTURE_3 3
461 #define LIGHTRANGER9_SUBCAPTURE_MASK 0x03
462 #define LIGHTRANGER9_RESULT_NUMBER_MASK 0x3F
463 #define LIGHTRANGER9_SYS_TICK_TO_SEC 0.0000002
464 #define LIGHTRANGER9_OBJECT_MAP_SIZE 64
470 #define LIGHTRANGER9_DEFAULT_MEASUREMENT_PERIOD_MS 500
471 #define LIGHTRANGER9_CONFIDENCE_THRESHOLD 100
477 #define LIGHTRANGER9_DEVICE_ID 0x08
484 #define LIGHTRANGER9_DEVICE_ADDRESS 0x41
502 #define LIGHTRANGER9_MAP_MIKROBUS( cfg, mikrobus ) \
503 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
504 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
505 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
506 cfg.gpio0 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
507 cfg.gpio1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
508 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
835 #endif // LIGHTRANGER9_H
int8_t temperature
Definition: lightranger9.h:573
err_t lightranger9_clear_interrupts(lightranger9_t *ctx)
LightRanger 9 clear interrupts function.
lightranger9_return_value_t
LightRanger 9 Click return value data.
Definition: lightranger9.h:588
pin_name_t gpio1
Definition: lightranger9.h:546
digital_out_t en
Definition: lightranger9.h:520
uint8_t valid_results
Definition: lightranger9.h:574
err_t lightranger9_default_cfg(lightranger9_t *ctx)
LightRanger 9 default configuration function.
uint32_t reference_count
Definition: lightranger9.h:577
uint32_t ambient_light
Definition: lightranger9.h:575
err_t lightranger9_download_fw_bin(lightranger9_t *ctx)
LightRanger 9 download fw bin function.
err_t lightranger9_read_bl_cmd_status(lightranger9_t *ctx, uint8_t *status)
LightRanger 9 read bl cmd status function.
err_t lightranger9_write_bl_cmd(lightranger9_t *ctx, uint8_t cmd, uint8_t *data_in, uint8_t len)
LightRanger 9 write bl cmd function.
pin_name_t scl
Definition: lightranger9.h:541
err_t lightranger9_check_communication(lightranger9_t *ctx)
LightRanger 9 check communication function.
LightRanger 9 Click configuration object.
Definition: lightranger9.h:540
void lightranger9_set_gpio1_pin(lightranger9_t *ctx, uint8_t state)
LightRanger 9 set gpio1 pin function.
uint8_t i2c_address
Definition: lightranger9.h:550
err_t lightranger9_generic_write(lightranger9_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
LightRanger 9 I2C writing function.
void lightranger9_enable_device(lightranger9_t *ctx)
LightRanger 9 enable device function.
float sys_tick_sec
Definition: lightranger9.h:578
void lightranger9_cfg_setup(lightranger9_cfg_t *cfg)
LightRanger 9 configuration object setup function.
err_t lightranger9_read_register(lightranger9_t *ctx, uint8_t reg, uint8_t *data_out)
LightRanger 9 read register function.
pin_name_t en
Definition: lightranger9.h:544
uint32_t photon_count
Definition: lightranger9.h:576
uint8_t confidence
Definition: lightranger9.h:560
err_t lightranger9_write_register(lightranger9_t *ctx, uint8_t reg, uint8_t data_in)
LightRanger 9 write register function.
err_t lightranger9_init(lightranger9_t *ctx, lightranger9_cfg_t *cfg)
LightRanger 9 initialization function.
pin_name_t gpio0
Definition: lightranger9.h:545
void lightranger9_disable_device(lightranger9_t *ctx)
LightRanger 9 disable device function.
pin_name_t sda
Definition: lightranger9.h:542
@ LIGHTRANGER9_ERROR
Definition: lightranger9.h:590
uint16_t distance_mm
Definition: lightranger9.h:561
uint8_t slave_address
Definition: lightranger9.h:531
void lightranger9_set_gpio0_pin(lightranger9_t *ctx, uint8_t state)
LightRanger 9 set gpio0 pin function.
err_t lightranger9_generic_read(lightranger9_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
LightRanger 9 I2C reading function.
digital_in_t int_pin
Definition: lightranger9.h:525
err_t lightranger9_get_capture(lightranger9_t *ctx, lightranger9_capture_t *capture)
LightRanger 9 get capture function.
uint8_t sub_capture
Definition: lightranger9.h:571
LightRanger 9 measurement result data object.
Definition: lightranger9.h:559
LightRanger 9 capture data object.
Definition: lightranger9.h:570
uint8_t lightranger9_get_int_pin(lightranger9_t *ctx)
LightRanger 9 get int pin function.
uint8_t result_number
Definition: lightranger9.h:572
i2c_master_t i2c
Definition: lightranger9.h:528
@ LIGHTRANGER9_OK
Definition: lightranger9.h:589
LightRanger 9 Click context object.
Definition: lightranger9.h:518
digital_out_t gpio0
Definition: lightranger9.h:521
digital_out_t gpio1
Definition: lightranger9.h:522
uint32_t i2c_speed
Definition: lightranger9.h:549
pin_name_t int_pin
Definition: lightranger9.h:547
#define LIGHTRANGER9_MAX_MEAS_RESULTS
Definition: lightranger9.h:456