CRINSA-team2025 V1
Documentation du Club Robot INSA Rennes 2025
Chargement...
Recherche...
Aucune correspondance
vl53l5cx_api.h
1
12
13#ifndef VL53L5CX_API_H_
14#define VL53L5CX_API_H_
15
16#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION < 6010050)
17#pragma anon_unions
18#endif
19
20
21
22#include "platform.h"
23
27
28#define VL53L5CX_API_REVISION "VL53L5CX_2.0.0"
29
34
35#define VL53L5CX_DEFAULT_I2C_ADDRESS ((uint16_t)0x52)
36
42
43#define VL53L5CX_RESOLUTION_4X4 ((uint8_t) 16U)
44#define VL53L5CX_RESOLUTION_8X8 ((uint8_t) 64U)
45
46
51
52#define VL53L5CX_TARGET_ORDER_CLOSEST ((uint8_t) 1U)
53#define VL53L5CX_TARGET_ORDER_STRONGEST ((uint8_t) 2U)
54
61
62#define VL53L5CX_RANGING_MODE_CONTINUOUS ((uint8_t) 1U)
63#define VL53L5CX_RANGING_MODE_AUTONOMOUS ((uint8_t) 3U)
64
71
72#define VL53L5CX_POWER_MODE_SLEEP ((uint8_t) 0U)
73#define VL53L5CX_POWER_MODE_WAKEUP ((uint8_t) 1U)
74
80
81#define VL53L5CX_STATUS_OK ((uint8_t) 0U)
82#define VL53L5CX_STATUS_TIMEOUT_ERROR ((uint8_t) 1U)
83#define VL53L5CX_STATUS_CORRUPTED_FRAME ((uint8_t) 2U)
84#define VL53L5CX_STATUS_CRC_CSUM_FAILED ((uint8_t) 3U)
85#define VL53L5CX_STATUS_XTALK_FAILED ((uint8_t) 4U)
86#define VL53L5CX_MCU_ERROR ((uint8_t) 66U)
87#define VL53L5CX_STATUS_INVALID_PARAM ((uint8_t) 127U)
88#define VL53L5CX_STATUS_ERROR ((uint8_t) 255U)
89
93
94#if VL53L5CX_NB_TARGET_PER_ZONE == 1
95
96#define VL53L5CX_START_BH ((uint32_t)0x0000000DU)
97#define VL53L5CX_METADATA_BH ((uint32_t)0x54B400C0U)
98#define VL53L5CX_COMMONDATA_BH ((uint32_t)0x54C00040U)
99#define VL53L5CX_AMBIENT_RATE_BH ((uint32_t)0x54D00104U)
100#define VL53L5CX_SPAD_COUNT_BH ((uint32_t)0x55D00404U)
101#define VL53L5CX_NB_TARGET_DETECTED_BH ((uint32_t)0xDB840401U)
102#define VL53L5CX_SIGNAL_RATE_BH ((uint32_t)0xDBC40404U)
103#define VL53L5CX_RANGE_SIGMA_MM_BH ((uint32_t)0xDEC40402U)
104#define VL53L5CX_DISTANCE_BH ((uint32_t)0xDF440402U)
105#define VL53L5CX_REFLECTANCE_BH ((uint32_t)0xE0440401U)
106#define VL53L5CX_TARGET_STATUS_BH ((uint32_t)0xE0840401U)
107#define VL53L5CX_MOTION_DETECT_BH ((uint32_t)0xD85808C0U)
108
109#define VL53L5CX_METADATA_IDX ((uint16_t)0x54B4U)
110#define VL53L5CX_SPAD_COUNT_IDX ((uint16_t)0x55D0U)
111#define VL53L5CX_AMBIENT_RATE_IDX ((uint16_t)0x54D0U)
112#define VL53L5CX_NB_TARGET_DETECTED_IDX ((uint16_t)0xDB84U)
113#define VL53L5CX_SIGNAL_RATE_IDX ((uint16_t)0xDBC4U)
114#define VL53L5CX_RANGE_SIGMA_MM_IDX ((uint16_t)0xDEC4U)
115#define VL53L5CX_DISTANCE_IDX ((uint16_t)0xDF44U)
116#define VL53L5CX_REFLECTANCE_EST_PC_IDX ((uint16_t)0xE044U)
117#define VL53L5CX_TARGET_STATUS_IDX ((uint16_t)0xE084U)
118#define VL53L5CX_MOTION_DETEC_IDX ((uint16_t)0xD858U)
119
120#else
121#define VL53L5CX_START_BH ((uint32_t)0x0000000DU)
122#define VL53L5CX_METADATA_BH ((uint32_t)0x54B400C0U)
123#define VL53L5CX_COMMONDATA_BH ((uint32_t)0x54C00040U)
124#define VL53L5CX_AMBIENT_RATE_BH ((uint32_t)0x54D00104U)
125#define VL53L5CX_NB_TARGET_DETECTED_BH ((uint32_t)0x57D00401U)
126#define VL53L5CX_SPAD_COUNT_BH ((uint32_t)0x55D00404U)
127#define VL53L5CX_SIGNAL_RATE_BH ((uint32_t)0x58900404U)
128#define VL53L5CX_RANGE_SIGMA_MM_BH ((uint32_t)0x64900402U)
129#define VL53L5CX_DISTANCE_BH ((uint32_t)0x66900402U)
130#define VL53L5CX_REFLECTANCE_BH ((uint32_t)0x6A900401U)
131#define VL53L5CX_TARGET_STATUS_BH ((uint32_t)0x6B900401U)
132#define VL53L5CX_MOTION_DETECT_BH ((uint32_t)0xCC5008C0U)
133
134#define VL53L5CX_METADATA_IDX ((uint16_t)0x54B4U)
135#define VL53L5CX_SPAD_COUNT_IDX ((uint16_t)0x55D0U)
136#define VL53L5CX_AMBIENT_RATE_IDX ((uint16_t)0x54D0U)
137#define VL53L5CX_NB_TARGET_DETECTED_IDX ((uint16_t)0x57D0U)
138#define VL53L5CX_SIGNAL_RATE_IDX ((uint16_t)0x5890U)
139#define VL53L5CX_RANGE_SIGMA_MM_IDX ((uint16_t)0x6490U)
140#define VL53L5CX_DISTANCE_IDX ((uint16_t)0x6690U)
141#define VL53L5CX_REFLECTANCE_EST_PC_IDX ((uint16_t)0x6A90U)
142#define VL53L5CX_TARGET_STATUS_IDX ((uint16_t)0x6B90U)
143#define VL53L5CX_MOTION_DETEC_IDX ((uint16_t)0xCC50U)
144#endif
145
146
150
151#define VL53L5CX_NVM_DATA_SIZE ((uint16_t)492U)
152#define VL53L5CX_CONFIGURATION_SIZE ((uint16_t)972U)
153#define VL53L5CX_OFFSET_BUFFER_SIZE ((uint16_t)488U)
154#define VL53L5CX_XTALK_BUFFER_SIZE ((uint16_t)776U)
155
156#define VL53L5CX_DCI_ZONE_CONFIG ((uint16_t)0x5450U)
157#define VL53L5CX_DCI_FREQ_HZ ((uint16_t)0x5458U)
158#define VL53L5CX_DCI_INT_TIME ((uint16_t)0x545CU)
159#define VL53L5CX_DCI_FW_NB_TARGET ((uint16_t)0x5478)
160#define VL53L5CX_DCI_RANGING_MODE ((uint16_t)0xAD30U)
161#define VL53L5CX_DCI_DSS_CONFIG ((uint16_t)0xAD38U)
162#define VL53L5CX_DCI_VHV_CONFIG ((uint16_t)0xAD60U)
163#define VL53L5CX_DCI_TARGET_ORDER ((uint16_t)0xAE64U)
164#define VL53L5CX_DCI_SHARPENER ((uint16_t)0xAED8U)
165#define VL53L5CX_DCI_INTERNAL_CP ((uint16_t)0xB39CU)
166#define VL53L5CX_DCI_SYNC_PIN ((uint16_t)0xB5F0U)
167#define VL53L5CX_DCI_MOTION_DETECTOR_CFG ((uint16_t)0xBFACU)
168#define VL53L5CX_DCI_SINGLE_RANGE ((uint16_t)0xD964U)
169#define VL53L5CX_DCI_OUTPUT_CONFIG ((uint16_t)0xD968U)
170#define VL53L5CX_DCI_OUTPUT_ENABLES ((uint16_t)0xD970U)
171#define VL53L5CX_DCI_OUTPUT_LIST ((uint16_t)0xD980U)
172#define VL53L5CX_DCI_PIPE_CONTROL ((uint16_t)0xDB80U)
173#define VL53L5CX_GLARE_FILTER ((uint16_t)0xE108U)
174
175
176#define VL53L5CX_UI_CMD_STATUS ((uint16_t)0x2C00U)
177#define VL53L5CX_UI_CMD_START ((uint16_t)0x2C04U)
178#define VL53L5CX_UI_CMD_END ((uint16_t)0x2FFFU)
179
183
184#ifndef VL53L5CX_DISABLE_AMBIENT_PER_SPAD
185#define L5CX_AMB_SIZE 260U
186#else
187#define L5CX_AMB_SIZE 0U
188#endif
189
190#ifndef VL53L5CX_DISABLE_NB_SPADS_ENABLED
191#define L5CX_SPAD_SIZE 260U
192#else
193#define L5CX_SPAD_SIZE 0U
194#endif
195
196#ifndef VL53L5CX_DISABLE_NB_TARGET_DETECTED
197#define L5CX_NTAR_SIZE 68U
198#else
199#define L5CX_NTAR_SIZE 0U
200#endif
201
202#ifndef VL53L5CX_DISABLE_SIGNAL_PER_SPAD
203#define L5CX_SPS_SIZE ((256U * VL53L5CX_NB_TARGET_PER_ZONE) + 4U)
204#else
205#define L5CX_SPS_SIZE 0U
206#endif
207
208#ifndef VL53L5CX_DISABLE_RANGE_SIGMA_MM
209#define L5CX_SIGR_SIZE ((128U * VL53L5CX_NB_TARGET_PER_ZONE) + 4U)
210#else
211#define L5CX_SIGR_SIZE 0U
212#endif
213
214#ifndef VL53L5CX_DISABLE_DISTANCE_MM
215#define L5CX_DIST_SIZE ((128U * VL53L5CX_NB_TARGET_PER_ZONE) + 4U)
216#else
217#define L5CX_DIST_SIZE 0U
218#endif
219
220#ifndef VL53L5CX_DISABLE_REFLECTANCE_PERCENT
221#define L5CX_RFLEST_SIZE ((64U *VL53L5CX_NB_TARGET_PER_ZONE) + 4U)
222#else
223#define L5CX_RFLEST_SIZE 0U
224#endif
225
226#ifndef VL53L5CX_DISABLE_TARGET_STATUS
227#define L5CX_STA_SIZE ((64U *VL53L5CX_NB_TARGET_PER_ZONE) + 4U)
228#else
229#define L5CX_STA_SIZE 0U
230#endif
231
232#ifndef VL53L5CX_DISABLE_MOTION_INDICATOR
233#define L5CX_MOT_SIZE 144U
234#else
235#define L5CX_MOT_SIZE 0U
236#endif
237
243
244#define VL53L5CX_MAX_RESULTS_SIZE ( 40U \
245 + L5CX_AMB_SIZE + L5CX_SPAD_SIZE + L5CX_NTAR_SIZE + L5CX_SPS_SIZE \
246 + L5CX_SIGR_SIZE + L5CX_DIST_SIZE + L5CX_RFLEST_SIZE + L5CX_STA_SIZE \
247 + L5CX_MOT_SIZE + 20U)
248
254
255#if VL53L5CX_MAX_RESULTS_SIZE < 1024U
256#define VL53L5CX_TEMPORARY_BUFFER_SIZE ((uint32_t) 1024U)
257#else
258#define VL53L5CX_TEMPORARY_BUFFER_SIZE ((uint32_t) VL53L5CX_MAX_RESULTS_SIZE)
259#endif
260
261
266
267typedef struct
268{
269 /* Platform, filled by customer into the 'platform.h' file */
270 VL53L5CX_Platform platform;
271 /* Results streamcount, value auto-incremented at each range */
272 uint8_t streamcount;
273 /* Size of data read though I2C */
274 uint32_t data_read_size;
275 /* Address of default configuration buffer */
276 uint8_t *default_configuration;
277 /* Address of default Xtalk buffer */
278 uint8_t *default_xtalk;
279 /* Offset buffer */
280 uint8_t offset_data[VL53L5CX_OFFSET_BUFFER_SIZE];
281 /* Xtalk buffer */
282 uint8_t xtalk_data[VL53L5CX_XTALK_BUFFER_SIZE];
283 /* Temporary buffer used for internal driver processing */
284 uint8_t temp_buffer[VL53L5CX_TEMPORARY_BUFFER_SIZE];
285 /* Auto-stop flag for stopping the sensor */
286 uint8_t is_auto_stop_enabled;
288
289
300
301typedef struct
302{
303 /* Internal sensor silicon temperature */
304 int8_t silicon_temp_degc;
305
306 /* Ambient noise in kcps/spads */
307#ifndef VL53L5CX_DISABLE_AMBIENT_PER_SPAD
308 uint32_t ambient_per_spad[VL53L5CX_RESOLUTION_8X8];
309#endif
310
311 /* Number of valid target detected for 1 zone */
312#ifndef VL53L5CX_DISABLE_NB_TARGET_DETECTED
313 uint8_t nb_target_detected[VL53L5CX_RESOLUTION_8X8];
314#endif
315
316 /* Number of spads enabled for this ranging */
317#ifndef VL53L5CX_DISABLE_NB_SPADS_ENABLED
318 uint32_t nb_spads_enabled[VL53L5CX_RESOLUTION_8X8];
319#endif
320
321 /* Signal returned to the sensor in kcps/spads */
322#ifndef VL53L5CX_DISABLE_SIGNAL_PER_SPAD
323 uint32_t signal_per_spad[(VL53L5CX_RESOLUTION_8X8
324 *VL53L5CX_NB_TARGET_PER_ZONE)];
325#endif
326
327 /* Sigma of the current distance in mm */
328#ifndef VL53L5CX_DISABLE_RANGE_SIGMA_MM
329 uint16_t range_sigma_mm[(VL53L5CX_RESOLUTION_8X8
330 *VL53L5CX_NB_TARGET_PER_ZONE)];
331#endif
332
333 /* Measured distance in mm */
334#ifndef VL53L5CX_DISABLE_DISTANCE_MM
335 int16_t distance_mm[(VL53L5CX_RESOLUTION_8X8
336 *VL53L5CX_NB_TARGET_PER_ZONE)];
337#endif
338
339 /* Estimated reflectance in percent */
340#ifndef VL53L5CX_DISABLE_REFLECTANCE_PERCENT
341 uint8_t reflectance[(VL53L5CX_RESOLUTION_8X8
342 *VL53L5CX_NB_TARGET_PER_ZONE)];
343#endif
344
345 /* Status indicating the measurement validity (5 & 9 means ranging OK)*/
346#ifndef VL53L5CX_DISABLE_TARGET_STATUS
347 uint8_t target_status[(VL53L5CX_RESOLUTION_8X8
348 *VL53L5CX_NB_TARGET_PER_ZONE)];
349#endif
350
351 /* Motion detector results */
352#ifndef VL53L5CX_DISABLE_MOTION_INDICATOR
353 struct
354 {
355 uint32_t global_indicator_1;
356 uint32_t global_indicator_2;
357 uint8_t status;
358 uint8_t nb_of_detected_aggregates;
359 uint8_t nb_of_aggregates;
360 uint8_t spare;
361 uint32_t motion[32];
362 } motion_indicator;
363#endif
364
366
367
369 uint32_t bytes;
370 struct {
371 uint32_t type : 4;
372 uint32_t size : 12;
373 uint32_t idx : 16;
374 };
375};
376
377#endif //VL53L5CX_API_H_
Structure VL53L5CX_Configuration contains the sensor configuration. User MUST not manually change the...
Definition vl53l5cx_api.h:268
Structure VL53L5CX_Platform needs to be filled by the customer, depending on his platform....
Definition platform.h:28
Structure VL53L5CX_ResultsData contains the ranging results of VL53L5CX. If user wants more than 1 ta...
Definition vl53l5cx_api.h:302
Definition vl53l5cx_api.h:368