Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
vl53l5cx_api.h
Go to the documentation of this file.
1 
17 #ifndef VL53L5CX_API_H_
18 #define VL53L5CX_API_H_
19 
20 #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION < 6010050)
21 #pragma anon_unions
22 #endif
23 
24 
25 
27 
32 #define VL53L5CX_API_REVISION "VL53L5CX_1.3.10"
33 
39 #define VL53L5CX_DEFAULT_I2C_ADDRESS ((uint16_t)0x52)
40 
47 #define VL53L5CX_RESOLUTION_4X4 ((uint8_t) 16U)
48 #define VL53L5CX_RESOLUTION_8X8 ((uint8_t) 64U)
49 
50 
56 #define VL53L5CX_TARGET_ORDER_CLOSEST ((uint8_t) 1U)
57 #define VL53L5CX_TARGET_ORDER_STRONGEST ((uint8_t) 2U)
58 
66 #define VL53L5CX_RANGING_MODE_CONTINUOUS ((uint8_t) 1U)
67 #define VL53L5CX_RANGING_MODE_AUTONOMOUS ((uint8_t) 3U)
68 
76 #define VL53L5CX_POWER_MODE_SLEEP ((uint8_t) 0U)
77 #define VL53L5CX_POWER_MODE_WAKEUP ((uint8_t) 1U)
78 
85 #define VL53L5CX_STATUS_OK ((uint8_t) 0U)
86 #define VL53L5CX_STATUS_TIMEOUT_ERROR ((uint8_t) 1U)
87 #define VL53L5CX_STATUS_CORRUPTED_FRAME ((uint8_t) 2U)
88 #define VL53L5CX_STATUS_CRC_CSUM_FAILED ((uint8_t) 3U)
89 #define VL53L5CX_STATUS_XTALK_FAILED ((uint8_t) 4U)
90 #define VL53L5CX_MCU_ERROR ((uint8_t) 66U)
91 #define VL53L5CX_STATUS_INVALID_PARAM ((uint8_t) 127U)
92 #define VL53L5CX_STATUS_ERROR ((uint8_t) 255U)
93 
98 #if VL53L5CX_NB_TARGET_PER_ZONE == 1
99 
100 #define VL53L5CX_START_BH ((uint32_t)0x0000000DU)
101 #define VL53L5CX_METADATA_BH ((uint32_t)0x54B400C0U)
102 #define VL53L5CX_COMMONDATA_BH ((uint32_t)0x54C00040U)
103 #define VL53L5CX_AMBIENT_RATE_BH ((uint32_t)0x54D00104U)
104 #define VL53L5CX_SPAD_COUNT_BH ((uint32_t)0x55D00404U)
105 #define VL53L5CX_NB_TARGET_DETECTED_BH ((uint32_t)0xDB840401U)
106 #define VL53L5CX_SIGNAL_RATE_BH ((uint32_t)0xDBC40404U)
107 #define VL53L5CX_RANGE_SIGMA_MM_BH ((uint32_t)0xDEC40402U)
108 #define VL53L5CX_DISTANCE_BH ((uint32_t)0xDF440402U)
109 #define VL53L5CX_REFLECTANCE_BH ((uint32_t)0xE0440401U)
110 #define VL53L5CX_TARGET_STATUS_BH ((uint32_t)0xE0840401U)
111 #define VL53L5CX_MOTION_DETECT_BH ((uint32_t)0xD85808C0U)
112 
113 #define VL53L5CX_METADATA_IDX ((uint16_t)0x54B4U)
114 #define VL53L5CX_SPAD_COUNT_IDX ((uint16_t)0x55D0U)
115 #define VL53L5CX_AMBIENT_RATE_IDX ((uint16_t)0x54D0U)
116 #define VL53L5CX_NB_TARGET_DETECTED_IDX ((uint16_t)0xDB84U)
117 #define VL53L5CX_SIGNAL_RATE_IDX ((uint16_t)0xDBC4U)
118 #define VL53L5CX_RANGE_SIGMA_MM_IDX ((uint16_t)0xDEC4U)
119 #define VL53L5CX_DISTANCE_IDX ((uint16_t)0xDF44U)
120 #define VL53L5CX_REFLECTANCE_EST_PC_IDX ((uint16_t)0xE044U)
121 #define VL53L5CX_TARGET_STATUS_IDX ((uint16_t)0xE084U)
122 #define VL53L5CX_MOTION_DETEC_IDX ((uint16_t)0xD858U)
123 
124 #else
125 #define VL53L5CX_START_BH ((uint32_t)0x0000000DU)
126 #define VL53L5CX_METADATA_BH ((uint32_t)0x54B400C0U)
127 #define VL53L5CX_COMMONDATA_BH ((uint32_t)0x54C00040U)
128 #define VL53L5CX_AMBIENT_RATE_BH ((uint32_t)0x54D00104U)
129 #define VL53L5CX_NB_TARGET_DETECTED_BH ((uint32_t)0x57D00401U)
130 #define VL53L5CX_SPAD_COUNT_BH ((uint32_t)0x55D00404U)
131 #define VL53L5CX_SIGNAL_RATE_BH ((uint32_t)0x58900404U)
132 #define VL53L5CX_RANGE_SIGMA_MM_BH ((uint32_t)0x64900402U)
133 #define VL53L5CX_DISTANCE_BH ((uint32_t)0x66900402U)
134 #define VL53L5CX_REFLECTANCE_BH ((uint32_t)0x6A900401U)
135 #define VL53L5CX_TARGET_STATUS_BH ((uint32_t)0x6B900401U)
136 #define VL53L5CX_MOTION_DETECT_BH ((uint32_t)0xCC5008C0U)
137 
138 #define VL53L5CX_METADATA_IDX ((uint16_t)0x54B4U)
139 #define VL53L5CX_SPAD_COUNT_IDX ((uint16_t)0x55D0U)
140 #define VL53L5CX_AMBIENT_RATE_IDX ((uint16_t)0x54D0U)
141 #define VL53L5CX_NB_TARGET_DETECTED_IDX ((uint16_t)0x57D0U)
142 #define VL53L5CX_SIGNAL_RATE_IDX ((uint16_t)0x5890U)
143 #define VL53L5CX_RANGE_SIGMA_MM_IDX ((uint16_t)0x6490U)
144 #define VL53L5CX_DISTANCE_IDX ((uint16_t)0x6690U)
145 #define VL53L5CX_REFLECTANCE_EST_PC_IDX ((uint16_t)0x6A90U)
146 #define VL53L5CX_TARGET_STATUS_IDX ((uint16_t)0x6B90U)
147 #define VL53L5CX_MOTION_DETEC_IDX ((uint16_t)0xCC50U)
148 #endif
149 
150 
155 #define VL53L5CX_NVM_DATA_SIZE ((uint16_t)492U)
156 #define VL53L5CX_CONFIGURATION_SIZE ((uint16_t)972U)
157 #define VL53L5CX_OFFSET_BUFFER_SIZE ((uint16_t)488U)
158 #define VL53L5CX_XTALK_BUFFER_SIZE ((uint16_t)776U)
159 
160 #define VL53L5CX_DCI_ZONE_CONFIG ((uint16_t)0x5450U)
161 #define VL53L5CX_DCI_FREQ_HZ ((uint16_t)0x5458U)
162 #define VL53L5CX_DCI_INT_TIME ((uint16_t)0x545CU)
163 #define VL53L5CX_DCI_FW_NB_TARGET ((uint16_t)0x5478)
164 #define VL53L5CX_DCI_RANGING_MODE ((uint16_t)0xAD30U)
165 #define VL53L5CX_DCI_DSS_CONFIG ((uint16_t)0xAD38U)
166 #define VL53L5CX_DCI_TARGET_ORDER ((uint16_t)0xAE64U)
167 #define VL53L5CX_DCI_SHARPENER ((uint16_t)0xAED8U)
168 #define VL53L5CX_DCI_INTERNAL_CP ((uint16_t)0xB39CU)
169 #define VL53L5CX_DCI_SYNC_PIN ((uint16_t)0xB5F0U)
170 #define VL53L5CX_DCI_MOTION_DETECTOR_CFG ((uint16_t)0xBFACU)
171 #define VL53L5CX_DCI_SINGLE_RANGE ((uint16_t)0xD964U)
172 #define VL53L5CX_DCI_OUTPUT_CONFIG ((uint16_t)0xD968U)
173 #define VL53L5CX_DCI_OUTPUT_ENABLES ((uint16_t)0xD970U)
174 #define VL53L5CX_DCI_OUTPUT_LIST ((uint16_t)0xD980U)
175 #define VL53L5CX_DCI_PIPE_CONTROL ((uint16_t)0xDB80U)
176 #define VL53L5CX_GLARE_FILTER ((uint16_t)0xE108U)
177 
178 
179 #define VL53L5CX_UI_CMD_STATUS ((uint16_t)0x2C00U)
180 #define VL53L5CX_UI_CMD_START ((uint16_t)0x2C04U)
181 #define VL53L5CX_UI_CMD_END ((uint16_t)0x2FFFU)
182 
187 #ifndef VL53L5CX_DISABLE_AMBIENT_PER_SPAD
188 #define L5CX_AMB_SIZE 260U
189 #else
190 #define L5CX_AMB_SIZE 0U
191 #endif
192 
193 #ifndef VL53L5CX_DISABLE_NB_SPADS_ENABLED
194 #define L5CX_SPAD_SIZE 260U
195 #else
196 #define L5CX_SPAD_SIZE 0U
197 #endif
198 
199 #ifndef VL53L5CX_DISABLE_NB_TARGET_DETECTED
200 #define L5CX_NTAR_SIZE 68U
201 #else
202 #define L5CX_NTAR_SIZE 0U
203 #endif
204 
205 #ifndef VL53L5CX_DISABLE_SIGNAL_PER_SPAD
206 #define L5CX_SPS_SIZE ((256U * VL53L5CX_NB_TARGET_PER_ZONE) + 4U)
207 #else
208 #define L5CX_SPS_SIZE 0U
209 #endif
210 
211 #ifndef VL53L5CX_DISABLE_RANGE_SIGMA_MM
212 #define L5CX_SIGR_SIZE ((128U * VL53L5CX_NB_TARGET_PER_ZONE) + 4U)
213 #else
214 #define L5CX_SIGR_SIZE 0U
215 #endif
216 
217 #ifndef VL53L5CX_DISABLE_DISTANCE_MM
218 #define L5CX_DIST_SIZE ((128U * VL53L5CX_NB_TARGET_PER_ZONE) + 4U)
219 #else
220 #define L5CX_DIST_SIZE 0U
221 #endif
222 
223 #ifndef VL53L5CX_DISABLE_REFLECTANCE_PERCENT
224 #define L5CX_RFLEST_SIZE ((64U *VL53L5CX_NB_TARGET_PER_ZONE) + 4U)
225 #else
226 #define L5CX_RFLEST_SIZE 0U
227 #endif
228 
229 #ifndef VL53L5CX_DISABLE_TARGET_STATUS
230 #define L5CX_STA_SIZE ((64U *VL53L5CX_NB_TARGET_PER_ZONE) + 4U)
231 #else
232 #define L5CX_STA_SIZE 0U
233 #endif
234 
235 #ifndef VL53L5CX_DISABLE_MOTION_INDICATOR
236 #define L5CX_MOT_SIZE 144U
237 #else
238 #define L5CX_MOT_SIZE 0U
239 #endif
240 
247 #define VL53L5CX_MAX_RESULTS_SIZE ( 40U \
248  + L5CX_AMB_SIZE + L5CX_SPAD_SIZE + L5CX_NTAR_SIZE + L5CX_SPS_SIZE \
249  + L5CX_SIGR_SIZE + L5CX_DIST_SIZE + L5CX_RFLEST_SIZE + L5CX_STA_SIZE \
250  + L5CX_MOT_SIZE + 20U)
251 
258 #if VL53L5CX_MAX_RESULTS_SIZE < 1024U
259 #define VL53L5CX_TEMPORARY_BUFFER_SIZE ((uint32_t) 1024U)
260 #else
261 #define VL53L5CX_TEMPORARY_BUFFER_SIZE ((uint32_t) VL53L5CX_MAX_RESULTS_SIZE)
262 #endif
263 
264 
270 typedef struct
271 {
272  /* Platform, filled by customer into the 'platform.h' file */
274  /* Results streamcount, value auto-incremented at each range */
276  /* Size of data read though I2C */
278  /* Address of default configuration buffer */
280  /* Address of default Xtalk buffer */
282  /* Offset buffer */
284  /* Xtalk buffer */
286  /* Temporary buffer used for internal driver processing */
288  /* Auto-stop flag for stopping the sensor */
291 
292 
304 typedef struct
305 {
306  /* Internal sensor silicon temperature */
308 
309  /* Ambient noise in kcps/spads */
310 #ifndef VL53L5CX_DISABLE_AMBIENT_PER_SPAD
312 #endif
313 
314  /* Number of valid target detected for 1 zone */
315 #ifndef VL53L5CX_DISABLE_NB_TARGET_DETECTED
316  uint8_t nb_target_detected[VL53L5CX_RESOLUTION_8X8];
317 #endif
318 
319  /* Number of spads enabled for this ranging */
320 #ifndef VL53L5CX_DISABLE_NB_SPADS_ENABLED
322 #endif
323 
324  /* Signal returned to the sensor in kcps/spads */
325 #ifndef VL53L5CX_DISABLE_SIGNAL_PER_SPAD
328 #endif
329 
330  /* Sigma of the current distance in mm */
331 #ifndef VL53L5CX_DISABLE_RANGE_SIGMA_MM
334 #endif
335 
336  /* Measured distance in mm */
337 #ifndef VL53L5CX_DISABLE_DISTANCE_MM
340 #endif
341 
342  /* Estimated reflectance in percent */
343 #ifndef VL53L5CX_DISABLE_REFLECTANCE_PERCENT
346 #endif
347 
348  /* Status indicating the measurement validity (5 & 9 means ranging OK)*/
349 #ifndef VL53L5CX_DISABLE_TARGET_STATUS
352 #endif
353 
354  /* Motion detector results */
355 #ifndef VL53L5CX_DISABLE_MOTION_INDICATOR
356  struct
357  {
358  uint32_t global_indicator_1;
359  uint32_t global_indicator_2;
360  uint8_t status;
361  uint8_t nb_of_detected_aggregates;
362  uint8_t nb_of_aggregates;
363  uint8_t spare;
364  uint32_t motion[32];
365  } motion_indicator;
366 #endif
367 
369 
370 
373  struct {
374  uint32_t type : 4;
375  uint32_t size : 12;
376  uint32_t idx : 16;
377  };
378 };
379 
381  VL53L5CX_Configuration *p_dev,
382  uint8_t *p_is_alive);
383 
393  VL53L5CX_Configuration *p_dev);
394 
405  VL53L5CX_Configuration *p_dev,
406  uint16_t i2c_address);
407 
419  VL53L5CX_Configuration *p_dev,
420  uint8_t *p_power_mode);
421 
436  VL53L5CX_Configuration *p_dev,
437  uint8_t power_mode);
438 
447  VL53L5CX_Configuration *p_dev);
448 
457  VL53L5CX_Configuration *p_dev);
458 
469  VL53L5CX_Configuration *p_dev,
470  uint8_t *p_isReady);
471 
481  VL53L5CX_Configuration *p_dev,
482  VL53L5CX_ResultsData *p_results);
483 
493  VL53L5CX_Configuration *p_dev,
494  uint8_t *p_resolution);
495 
505  VL53L5CX_Configuration *p_dev,
506  uint8_t resolution);
507 
517  VL53L5CX_Configuration *p_dev,
518  uint8_t *p_frequency_hz);
519 
533  VL53L5CX_Configuration *p_dev,
534  uint8_t frequency_hz);
535 
544  VL53L5CX_Configuration *p_dev,
545  uint32_t *p_time_ms);
546 
559  VL53L5CX_Configuration *p_dev,
560  uint32_t integration_time_ms);
561 
571  VL53L5CX_Configuration *p_dev,
572  uint8_t *p_sharpener_percent);
573 
584  VL53L5CX_Configuration *p_dev,
585  uint8_t sharpener_percent);
586 
595  VL53L5CX_Configuration *p_dev,
596  uint8_t *p_target_order);
597 
610  VL53L5CX_Configuration *p_dev,
611  uint8_t target_order);
612 
623  VL53L5CX_Configuration *p_dev,
624  uint8_t *p_ranging_mode);
625 
637  VL53L5CX_Configuration *p_dev,
638  uint8_t ranging_mode);
639 
647  VL53L5CX_Configuration *p_dev);
648 
649 
657  VL53L5CX_Configuration *p_dev);
658 
673  VL53L5CX_Configuration *p_dev,
674  uint8_t *data,
675  uint32_t index,
676  uint16_t data_size);
677 
692  VL53L5CX_Configuration *p_dev,
693  uint8_t *data,
694  uint32_t index,
695  uint16_t data_size);
696 
714  VL53L5CX_Configuration *p_dev,
715  uint8_t *data,
716  uint32_t index,
717  uint16_t data_size,
718  uint8_t *new_data,
719  uint16_t new_data_size,
720  uint16_t new_data_pos);
721 
722 #endif //VL53L5CX_API_H_
static uint32_t idx
uint8_t status
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
Definition: vl53l1_types.h:88
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98
signed char int8_t
Typedef defining 8 bit char type.
Definition: vl53l1_types.h:103
uint8_t vl53l5cx_get_power_mode(VL53L5CX_Configuration *p_dev, uint8_t *p_power_mode)
This function is used to get the current sensor power mode.
Definition: vl53l5cx_api.c:426
uint8_t vl53l5cx_dci_read_data(VL53L5CX_Configuration *p_dev, uint8_t *data, uint32_t index, uint16_t data_size)
This function can be used to read 'extra data' from DCI.
#define VL53L5CX_XTALK_BUFFER_SIZE
Definition: vl53l5cx_api.h:158
uint8_t vl53l5cx_set_i2c_address(VL53L5CX_Configuration *p_dev, uint16_t i2c_address)
This function is used to change the I2C address of the sensor.
Definition: vl53l5cx_api.c:412
uint8_t vl53l5cx_disable_internal_cp(VL53L5CX_Configuration *p_dev)
This function is used to disable the VCSEL charge pump This optimizes the power consumption of the de...
uint8_t vl53l5cx_set_ranging_frequency_hz(VL53L5CX_Configuration *p_dev, uint8_t frequency_hz)
This function sets a new ranging frequency in Hz.
Definition: vl53l5cx_api.c:976
uint8_t vl53l5cx_get_ranging_mode(VL53L5CX_Configuration *p_dev, uint8_t *p_ranging_mode)
This function is used to get the ranging mode.
uint8_t vl53l5cx_get_sharpener_percent(VL53L5CX_Configuration *p_dev, uint8_t *p_sharpener_percent)
This function gets the current sharpener in percent.
#define VL53L5CX_TEMPORARY_BUFFER_SIZE
Macro VL53L5CX_TEMPORARY_BUFFER_SIZE can be used to know the size of the temporary buffer.
Definition: vl53l5cx_api.h:259
uint8_t vl53l5cx_is_alive(VL53L5CX_Configuration *p_dev, uint8_t *p_is_alive)
Definition: vl53l5cx_api.c:221
uint8_t vl53l5cx_set_power_mode(VL53L5CX_Configuration *p_dev, uint8_t power_mode)
This function is used to set the sensor in Low Power mode, for example if the sensor is not used duri...
Definition: vl53l5cx_api.c:455
uint8_t vl53l5cx_set_integration_time_ms(VL53L5CX_Configuration *p_dev, uint32_t integration_time_ms)
This function sets a new integration time in ms.
uint8_t vl53l5cx_dci_replace_data(VL53L5CX_Configuration *p_dev, uint8_t *data, uint32_t index, uint16_t data_size, uint8_t *new_data, uint16_t new_data_size, uint16_t new_data_pos)
This function can be used to replace 'extra data' in DCI.
uint8_t vl53l5cx_get_integration_time_ms(VL53L5CX_Configuration *p_dev, uint32_t *p_time_ms)
This function gets the current integration time in ms.
Definition: vl53l5cx_api.c:989
uint32_t bytes
Definition: vl53l5cx_api.h:372
uint8_t vl53l5cx_get_ranging_data(VL53L5CX_Configuration *p_dev, VL53L5CX_ResultsData *p_results)
This function gets the ranging data, using the selected output and the resolution.
Definition: vl53l5cx_api.c:712
#define VL53L5CX_RESOLUTION_8X8
Definition: vl53l5cx_api.h:48
uint8_t vl53l5cx_init(VL53L5CX_Configuration *p_dev)
Mandatory function used to initialize the sensor.
Definition: vl53l5cx_api.c:245
uint8_t * default_configuration
Definition: vl53l5cx_api.h:279
uint8_t vl53l5cx_start_ranging(VL53L5CX_Configuration *p_dev)
This function starts a ranging session.
Definition: vl53l5cx_api.c:490
VL53L5CX_Platform platform
Definition: vl53l5cx_api.h:273
uint8_t vl53l5cx_check_data_ready(VL53L5CX_Configuration *p_dev, uint8_t *p_isReady)
This function checks if a new data is ready by polling I2C.
Definition: vl53l5cx_api.c:681
uint8_t vl53l5cx_set_target_order(VL53L5CX_Configuration *p_dev, uint8_t target_order)
This function sets a new target order.
uint8_t vl53l5cx_set_ranging_mode(VL53L5CX_Configuration *p_dev, uint8_t ranging_mode)
This function is used to set the ranging mode.
uint8_t vl53l5cx_get_ranging_frequency_hz(VL53L5CX_Configuration *p_dev, uint8_t *p_frequency_hz)
This function gets the current ranging frequency in Hz.
Definition: vl53l5cx_api.c:963
uint8_t vl53l5cx_get_resolution(VL53L5CX_Configuration *p_dev, uint8_t *p_resolution)
This function gets the current resolution (4x4 or 8x8).
Definition: vl53l5cx_api.c:883
uint8_t vl53l5cx_dci_write_data(VL53L5CX_Configuration *p_dev, uint8_t *data, uint32_t index, uint16_t data_size)
This function can be used to write 'extra data' to DCI.
uint8_t vl53l5cx_set_resolution(VL53L5CX_Configuration *p_dev, uint8_t resolution)
This function sets a new resolution (4x4 or 8x8).
Definition: vl53l5cx_api.c:898
#define VL53L5CX_OFFSET_BUFFER_SIZE
Definition: vl53l5cx_api.h:157
uint8_t vl53l5cx_stop_ranging(VL53L5CX_Configuration *p_dev)
This function stops the ranging session.
Definition: vl53l5cx_api.c:627
uint8_t vl53l5cx_set_sharpener_percent(VL53L5CX_Configuration *p_dev, uint8_t sharpener_percent)
This function sets a new sharpener value in percent.
uint8_t vl53l5cx_enable_internal_cp(VL53L5CX_Configuration *p_dev)
This function is used to disable the VCSEL charge pump This optimizes the power consumption of the de...
uint8_t vl53l5cx_get_target_order(VL53L5CX_Configuration *p_dev, uint8_t *p_target_order)
This function gets the current target order (closest or strongest).
Structure VL53L5CX_Configuration contains the sensor configuration.
Definition: vl53l5cx_api.h:271
Structure VL53L5CX_ResultsData contains the ranging results of VL53L5CX.
Definition: vl53l5cx_api.h:305
#define VL53L5CX_NB_TARGET_PER_ZONE
Structure VL53L5CX_Platform needs to be filled by the customer, depending on his platform.