Fork, renaming of VL53L1CB-2

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   X_NUCLEO_53L1CB

Committer:
charlesmn
Date:
Fri Nov 06 10:06:37 2020 +0000
Revision:
0:3ac96e360672
Child:
7:1add29d51e72
Library for ST Vl53L1A1 time of flight sensor.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
charlesmn 0:3ac96e360672 1
charlesmn 0:3ac96e360672 2 /*******************************************************************************
charlesmn 0:3ac96e360672 3 * Copyright (c) 2020, STMicroelectronics - All Rights Reserved
charlesmn 0:3ac96e360672 4
charlesmn 0:3ac96e360672 5 This file is part of VL53L1 Core and is dual licensed,
charlesmn 0:3ac96e360672 6 either 'STMicroelectronics
charlesmn 0:3ac96e360672 7 Proprietary license'
charlesmn 0:3ac96e360672 8 or 'BSD 3-clause "New" or "Revised" License' , at your option.
charlesmn 0:3ac96e360672 9
charlesmn 0:3ac96e360672 10 ********************************************************************************
charlesmn 0:3ac96e360672 11
charlesmn 0:3ac96e360672 12 'STMicroelectronics Proprietary license'
charlesmn 0:3ac96e360672 13
charlesmn 0:3ac96e360672 14 ********************************************************************************
charlesmn 0:3ac96e360672 15
charlesmn 0:3ac96e360672 16 License terms: STMicroelectronics Proprietary in accordance with licensing
charlesmn 0:3ac96e360672 17 terms at www.st.com/sla0081
charlesmn 0:3ac96e360672 18
charlesmn 0:3ac96e360672 19 STMicroelectronics confidential
charlesmn 0:3ac96e360672 20 Reproduction and Communication of this document is strictly prohibited unless
charlesmn 0:3ac96e360672 21 specifically authorized in writing by STMicroelectronics.
charlesmn 0:3ac96e360672 22
charlesmn 0:3ac96e360672 23
charlesmn 0:3ac96e360672 24 ********************************************************************************
charlesmn 0:3ac96e360672 25
charlesmn 0:3ac96e360672 26 Alternatively, VL53L1 Core may be distributed under the terms of
charlesmn 0:3ac96e360672 27 'BSD 3-clause "New" or "Revised" License', in which case the following
charlesmn 0:3ac96e360672 28 provisions apply instead of the ones
charlesmn 0:3ac96e360672 29 mentioned above :
charlesmn 0:3ac96e360672 30
charlesmn 0:3ac96e360672 31 ********************************************************************************
charlesmn 0:3ac96e360672 32
charlesmn 0:3ac96e360672 33 License terms: BSD 3-clause "New" or "Revised" License.
charlesmn 0:3ac96e360672 34
charlesmn 0:3ac96e360672 35 Redistribution and use in source and binary forms, with or without
charlesmn 0:3ac96e360672 36 modification, are permitted provided that the following conditions are met:
charlesmn 0:3ac96e360672 37
charlesmn 0:3ac96e360672 38 1. Redistributions of source code must retain the above copyright notice, this
charlesmn 0:3ac96e360672 39 list of conditions and the following disclaimer.
charlesmn 0:3ac96e360672 40
charlesmn 0:3ac96e360672 41 2. Redistributions in binary form must reproduce the above copyright notice,
charlesmn 0:3ac96e360672 42 this list of conditions and the following disclaimer in the documentation
charlesmn 0:3ac96e360672 43 and/or other materials provided with the distribution.
charlesmn 0:3ac96e360672 44
charlesmn 0:3ac96e360672 45 3. Neither the name of the copyright holder nor the names of its contributors
charlesmn 0:3ac96e360672 46 may be used to endorse or promote products derived from this software
charlesmn 0:3ac96e360672 47 without specific prior written permission.
charlesmn 0:3ac96e360672 48
charlesmn 0:3ac96e360672 49 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
charlesmn 0:3ac96e360672 50 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
charlesmn 0:3ac96e360672 51 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
charlesmn 0:3ac96e360672 52 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
charlesmn 0:3ac96e360672 53 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
charlesmn 0:3ac96e360672 54 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
charlesmn 0:3ac96e360672 55 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
charlesmn 0:3ac96e360672 56 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
charlesmn 0:3ac96e360672 57 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
charlesmn 0:3ac96e360672 58 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
charlesmn 0:3ac96e360672 59
charlesmn 0:3ac96e360672 60
charlesmn 0:3ac96e360672 61 ********************************************************************************
charlesmn 0:3ac96e360672 62
charlesmn 0:3ac96e360672 63 */
charlesmn 0:3ac96e360672 64
charlesmn 0:3ac96e360672 65
charlesmn 0:3ac96e360672 66
charlesmn 0:3ac96e360672 67
charlesmn 0:3ac96e360672 68
charlesmn 0:3ac96e360672 69 #ifndef _VL53L1_HIST_STRUCTS_H_
charlesmn 0:3ac96e360672 70 #define _VL53L1_HIST_STRUCTS_H_
charlesmn 0:3ac96e360672 71
charlesmn 0:3ac96e360672 72 #include "vl53l1_ll_device.h"
charlesmn 0:3ac96e360672 73 #include "vl53l1_dmax_structs.h"
charlesmn 0:3ac96e360672 74
charlesmn 0:3ac96e360672 75 #ifdef __cplusplus
charlesmn 0:3ac96e360672 76 extern "C"
charlesmn 0:3ac96e360672 77 {
charlesmn 0:3ac96e360672 78 #endif
charlesmn 0:3ac96e360672 79
charlesmn 0:3ac96e360672 80 #define VL53L1_MAX_BIN_SEQUENCE_LENGTH 6
charlesmn 0:3ac96e360672 81 #define VL53L1_MAX_BIN_SEQUENCE_CODE 15
charlesmn 0:3ac96e360672 82 #define VL53L1_HISTOGRAM_BUFFER_SIZE 24
charlesmn 0:3ac96e360672 83 #define VL53L1_XTALK_HISTO_BINS 12
charlesmn 0:3ac96e360672 84
charlesmn 0:3ac96e360672 85
charlesmn 0:3ac96e360672 86
charlesmn 0:3ac96e360672 87 typedef struct {
charlesmn 0:3ac96e360672 88
charlesmn 0:3ac96e360672 89 uint8_t histogram_config__spad_array_selection;
charlesmn 0:3ac96e360672 90
charlesmn 0:3ac96e360672 91 uint8_t histogram_config__low_amb_even_bin_0_1;
charlesmn 0:3ac96e360672 92 uint8_t histogram_config__low_amb_even_bin_2_3;
charlesmn 0:3ac96e360672 93 uint8_t histogram_config__low_amb_even_bin_4_5;
charlesmn 0:3ac96e360672 94
charlesmn 0:3ac96e360672 95 uint8_t histogram_config__low_amb_odd_bin_0_1;
charlesmn 0:3ac96e360672 96 uint8_t histogram_config__low_amb_odd_bin_2_3;
charlesmn 0:3ac96e360672 97 uint8_t histogram_config__low_amb_odd_bin_4_5;
charlesmn 0:3ac96e360672 98
charlesmn 0:3ac96e360672 99 uint8_t histogram_config__mid_amb_even_bin_0_1;
charlesmn 0:3ac96e360672 100 uint8_t histogram_config__mid_amb_even_bin_2_3;
charlesmn 0:3ac96e360672 101 uint8_t histogram_config__mid_amb_even_bin_4_5;
charlesmn 0:3ac96e360672 102
charlesmn 0:3ac96e360672 103 uint8_t histogram_config__mid_amb_odd_bin_0_1;
charlesmn 0:3ac96e360672 104 uint8_t histogram_config__mid_amb_odd_bin_2;
charlesmn 0:3ac96e360672 105 uint8_t histogram_config__mid_amb_odd_bin_3_4;
charlesmn 0:3ac96e360672 106 uint8_t histogram_config__mid_amb_odd_bin_5;
charlesmn 0:3ac96e360672 107
charlesmn 0:3ac96e360672 108 uint8_t histogram_config__user_bin_offset;
charlesmn 0:3ac96e360672 109
charlesmn 0:3ac96e360672 110 uint8_t histogram_config__high_amb_even_bin_0_1;
charlesmn 0:3ac96e360672 111 uint8_t histogram_config__high_amb_even_bin_2_3;
charlesmn 0:3ac96e360672 112 uint8_t histogram_config__high_amb_even_bin_4_5;
charlesmn 0:3ac96e360672 113
charlesmn 0:3ac96e360672 114 uint8_t histogram_config__high_amb_odd_bin_0_1;
charlesmn 0:3ac96e360672 115 uint8_t histogram_config__high_amb_odd_bin_2_3;
charlesmn 0:3ac96e360672 116 uint8_t histogram_config__high_amb_odd_bin_4_5;
charlesmn 0:3ac96e360672 117
charlesmn 0:3ac96e360672 118 uint16_t histogram_config__amb_thresh_low;
charlesmn 0:3ac96e360672 119
charlesmn 0:3ac96e360672 120 uint16_t histogram_config__amb_thresh_high;
charlesmn 0:3ac96e360672 121
charlesmn 0:3ac96e360672 122
charlesmn 0:3ac96e360672 123 } VL53L1_histogram_config_t;
charlesmn 0:3ac96e360672 124
charlesmn 0:3ac96e360672 125
charlesmn 0:3ac96e360672 126
charlesmn 0:3ac96e360672 127
charlesmn 0:3ac96e360672 128 typedef struct {
charlesmn 0:3ac96e360672 129
charlesmn 0:3ac96e360672 130 VL53L1_HistAlgoSelect hist_algo_select;
charlesmn 0:3ac96e360672 131
charlesmn 0:3ac96e360672 132
charlesmn 0:3ac96e360672 133 VL53L1_HistTargetOrder hist_target_order;
charlesmn 0:3ac96e360672 134
charlesmn 0:3ac96e360672 135
charlesmn 0:3ac96e360672 136 uint8_t filter_woi0;
charlesmn 0:3ac96e360672 137
charlesmn 0:3ac96e360672 138 uint8_t filter_woi1;
charlesmn 0:3ac96e360672 139
charlesmn 0:3ac96e360672 140
charlesmn 0:3ac96e360672 141 VL53L1_HistAmbEstMethod hist_amb_est_method;
charlesmn 0:3ac96e360672 142
charlesmn 0:3ac96e360672 143 uint8_t ambient_thresh_sigma0;
charlesmn 0:3ac96e360672 144
charlesmn 0:3ac96e360672 145 uint8_t ambient_thresh_sigma1;
charlesmn 0:3ac96e360672 146
charlesmn 0:3ac96e360672 147
charlesmn 0:3ac96e360672 148
charlesmn 0:3ac96e360672 149 uint16_t ambient_thresh_events_scaler;
charlesmn 0:3ac96e360672 150
charlesmn 0:3ac96e360672 151
charlesmn 0:3ac96e360672 152
charlesmn 0:3ac96e360672 153 int32_t min_ambient_thresh_events;
charlesmn 0:3ac96e360672 154
charlesmn 0:3ac96e360672 155 uint16_t noise_threshold;
charlesmn 0:3ac96e360672 156
charlesmn 0:3ac96e360672 157
charlesmn 0:3ac96e360672 158 int32_t signal_total_events_limit;
charlesmn 0:3ac96e360672 159
charlesmn 0:3ac96e360672 160 uint8_t sigma_estimator__sigma_ref_mm;
charlesmn 0:3ac96e360672 161
charlesmn 0:3ac96e360672 162 uint16_t sigma_thresh;
charlesmn 0:3ac96e360672 163
charlesmn 0:3ac96e360672 164 int16_t range_offset_mm;
charlesmn 0:3ac96e360672 165
charlesmn 0:3ac96e360672 166 uint16_t gain_factor;
charlesmn 0:3ac96e360672 167
charlesmn 0:3ac96e360672 168
charlesmn 0:3ac96e360672 169 uint8_t valid_phase_low;
charlesmn 0:3ac96e360672 170
charlesmn 0:3ac96e360672 171 uint8_t valid_phase_high;
charlesmn 0:3ac96e360672 172
charlesmn 0:3ac96e360672 173 uint8_t algo__consistency_check__phase_tolerance;
charlesmn 0:3ac96e360672 174
charlesmn 0:3ac96e360672 175 uint8_t algo__consistency_check__event_sigma;
charlesmn 0:3ac96e360672 176
charlesmn 0:3ac96e360672 177
charlesmn 0:3ac96e360672 178
charlesmn 0:3ac96e360672 179 uint16_t algo__consistency_check__event_min_spad_count;
charlesmn 0:3ac96e360672 180
charlesmn 0:3ac96e360672 181
charlesmn 0:3ac96e360672 182
charlesmn 0:3ac96e360672 183 uint16_t algo__consistency_check__min_max_tolerance;
charlesmn 0:3ac96e360672 184
charlesmn 0:3ac96e360672 185
charlesmn 0:3ac96e360672 186 uint8_t algo__crosstalk_compensation_enable;
charlesmn 0:3ac96e360672 187
charlesmn 0:3ac96e360672 188 uint32_t algo__crosstalk_compensation_plane_offset_kcps;
charlesmn 0:3ac96e360672 189
charlesmn 0:3ac96e360672 190 int16_t algo__crosstalk_compensation_x_plane_gradient_kcps;
charlesmn 0:3ac96e360672 191
charlesmn 0:3ac96e360672 192 int16_t algo__crosstalk_compensation_y_plane_gradient_kcps;
charlesmn 0:3ac96e360672 193
charlesmn 0:3ac96e360672 194
charlesmn 0:3ac96e360672 195 int16_t algo__crosstalk_detect_min_valid_range_mm;
charlesmn 0:3ac96e360672 196
charlesmn 0:3ac96e360672 197 int16_t algo__crosstalk_detect_max_valid_range_mm;
charlesmn 0:3ac96e360672 198
charlesmn 0:3ac96e360672 199 uint16_t algo__crosstalk_detect_max_valid_rate_kcps;
charlesmn 0:3ac96e360672 200
charlesmn 0:3ac96e360672 201 uint16_t algo__crosstalk_detect_max_sigma_mm;
charlesmn 0:3ac96e360672 202
charlesmn 0:3ac96e360672 203
charlesmn 0:3ac96e360672 204
charlesmn 0:3ac96e360672 205 uint8_t algo__crosstalk_detect_event_sigma;
charlesmn 0:3ac96e360672 206
charlesmn 0:3ac96e360672 207
charlesmn 0:3ac96e360672 208
charlesmn 0:3ac96e360672 209 uint16_t algo__crosstalk_detect_min_max_tolerance;
charlesmn 0:3ac96e360672 210
charlesmn 0:3ac96e360672 211
charlesmn 0:3ac96e360672 212 } VL53L1_hist_post_process_config_t;
charlesmn 0:3ac96e360672 213
charlesmn 0:3ac96e360672 214
charlesmn 0:3ac96e360672 215
charlesmn 0:3ac96e360672 216 typedef struct {
charlesmn 0:3ac96e360672 217
charlesmn 0:3ac96e360672 218
charlesmn 0:3ac96e360672 219 VL53L1_DeviceState cfg_device_state;
charlesmn 0:3ac96e360672 220
charlesmn 0:3ac96e360672 221 VL53L1_DeviceState rd_device_state;
charlesmn 0:3ac96e360672 222
charlesmn 0:3ac96e360672 223
charlesmn 0:3ac96e360672 224 uint8_t zone_id;
charlesmn 0:3ac96e360672 225
charlesmn 0:3ac96e360672 226 uint32_t time_stamp;
charlesmn 0:3ac96e360672 227
charlesmn 0:3ac96e360672 228
charlesmn 0:3ac96e360672 229 uint8_t VL53L1_p_022;
charlesmn 0:3ac96e360672 230
charlesmn 0:3ac96e360672 231 uint8_t VL53L1_p_023;
charlesmn 0:3ac96e360672 232
charlesmn 0:3ac96e360672 233 uint8_t VL53L1_p_024;
charlesmn 0:3ac96e360672 234
charlesmn 0:3ac96e360672 235 uint8_t number_of_ambient_bins;
charlesmn 0:3ac96e360672 236
charlesmn 0:3ac96e360672 237 uint8_t bin_seq[VL53L1_MAX_BIN_SEQUENCE_LENGTH];
charlesmn 0:3ac96e360672 238
charlesmn 0:3ac96e360672 239 uint8_t bin_rep[VL53L1_MAX_BIN_SEQUENCE_LENGTH];
charlesmn 0:3ac96e360672 240
charlesmn 0:3ac96e360672 241 int32_t bin_data[VL53L1_HISTOGRAM_BUFFER_SIZE];
charlesmn 0:3ac96e360672 242
charlesmn 0:3ac96e360672 243
charlesmn 0:3ac96e360672 244 uint8_t result__interrupt_status;
charlesmn 0:3ac96e360672 245
charlesmn 0:3ac96e360672 246 uint8_t result__range_status;
charlesmn 0:3ac96e360672 247
charlesmn 0:3ac96e360672 248 uint8_t result__report_status;
charlesmn 0:3ac96e360672 249
charlesmn 0:3ac96e360672 250 uint8_t result__stream_count;
charlesmn 0:3ac96e360672 251
charlesmn 0:3ac96e360672 252 uint16_t result__dss_actual_effective_spads;
charlesmn 0:3ac96e360672 253
charlesmn 0:3ac96e360672 254
charlesmn 0:3ac96e360672 255 uint16_t phasecal_result__reference_phase;
charlesmn 0:3ac96e360672 256
charlesmn 0:3ac96e360672 257 uint8_t phasecal_result__vcsel_start;
charlesmn 0:3ac96e360672 258
charlesmn 0:3ac96e360672 259 uint8_t cal_config__vcsel_start;
charlesmn 0:3ac96e360672 260
charlesmn 0:3ac96e360672 261 uint16_t vcsel_width;
charlesmn 0:3ac96e360672 262
charlesmn 0:3ac96e360672 263 uint8_t VL53L1_p_009;
charlesmn 0:3ac96e360672 264
charlesmn 0:3ac96e360672 265 uint16_t VL53L1_p_019;
charlesmn 0:3ac96e360672 266
charlesmn 0:3ac96e360672 267 uint32_t total_periods_elapsed;
charlesmn 0:3ac96e360672 268
charlesmn 0:3ac96e360672 269
charlesmn 0:3ac96e360672 270 uint32_t peak_duration_us;
charlesmn 0:3ac96e360672 271
charlesmn 0:3ac96e360672 272 uint32_t woi_duration_us;
charlesmn 0:3ac96e360672 273
charlesmn 0:3ac96e360672 274
charlesmn 0:3ac96e360672 275 int32_t min_bin_value;
charlesmn 0:3ac96e360672 276
charlesmn 0:3ac96e360672 277 int32_t max_bin_value;
charlesmn 0:3ac96e360672 278
charlesmn 0:3ac96e360672 279
charlesmn 0:3ac96e360672 280 uint16_t zero_distance_phase;
charlesmn 0:3ac96e360672 281
charlesmn 0:3ac96e360672 282 uint8_t number_of_ambient_samples;
charlesmn 0:3ac96e360672 283
charlesmn 0:3ac96e360672 284 int32_t ambient_events_sum;
charlesmn 0:3ac96e360672 285
charlesmn 0:3ac96e360672 286 int32_t VL53L1_p_004;
charlesmn 0:3ac96e360672 287
charlesmn 0:3ac96e360672 288
charlesmn 0:3ac96e360672 289 uint8_t roi_config__user_roi_centre_spad;
charlesmn 0:3ac96e360672 290
charlesmn 0:3ac96e360672 291 uint8_t roi_config__user_roi_requested_global_xy_size;
charlesmn 0:3ac96e360672 292
charlesmn 0:3ac96e360672 293
charlesmn 0:3ac96e360672 294 } VL53L1_histogram_bin_data_t;
charlesmn 0:3ac96e360672 295
charlesmn 0:3ac96e360672 296
charlesmn 0:3ac96e360672 297
charlesmn 0:3ac96e360672 298
charlesmn 0:3ac96e360672 299 typedef struct {
charlesmn 0:3ac96e360672 300
charlesmn 0:3ac96e360672 301
charlesmn 0:3ac96e360672 302 uint8_t zone_id;
charlesmn 0:3ac96e360672 303
charlesmn 0:3ac96e360672 304 uint32_t time_stamp;
charlesmn 0:3ac96e360672 305
charlesmn 0:3ac96e360672 306
charlesmn 0:3ac96e360672 307 uint8_t VL53L1_p_022;
charlesmn 0:3ac96e360672 308
charlesmn 0:3ac96e360672 309 uint8_t VL53L1_p_023;
charlesmn 0:3ac96e360672 310
charlesmn 0:3ac96e360672 311 uint8_t VL53L1_p_024;
charlesmn 0:3ac96e360672 312
charlesmn 0:3ac96e360672 313 uint32_t bin_data[VL53L1_XTALK_HISTO_BINS];
charlesmn 0:3ac96e360672 314
charlesmn 0:3ac96e360672 315
charlesmn 0:3ac96e360672 316
charlesmn 0:3ac96e360672 317 uint16_t phasecal_result__reference_phase;
charlesmn 0:3ac96e360672 318
charlesmn 0:3ac96e360672 319 uint8_t phasecal_result__vcsel_start;
charlesmn 0:3ac96e360672 320
charlesmn 0:3ac96e360672 321 uint8_t cal_config__vcsel_start;
charlesmn 0:3ac96e360672 322
charlesmn 0:3ac96e360672 323 uint16_t vcsel_width;
charlesmn 0:3ac96e360672 324
charlesmn 0:3ac96e360672 325 uint16_t VL53L1_p_019;
charlesmn 0:3ac96e360672 326
charlesmn 0:3ac96e360672 327 uint16_t zero_distance_phase;
charlesmn 0:3ac96e360672 328
charlesmn 0:3ac96e360672 329
charlesmn 0:3ac96e360672 330 } VL53L1_xtalk_histogram_shape_t;
charlesmn 0:3ac96e360672 331
charlesmn 0:3ac96e360672 332
charlesmn 0:3ac96e360672 333
charlesmn 0:3ac96e360672 334
charlesmn 0:3ac96e360672 335 typedef struct {
charlesmn 0:3ac96e360672 336
charlesmn 0:3ac96e360672 337
charlesmn 0:3ac96e360672 338 VL53L1_xtalk_histogram_shape_t xtalk_shape;
charlesmn 0:3ac96e360672 339
charlesmn 0:3ac96e360672 340 VL53L1_histogram_bin_data_t xtalk_hist_removed;
charlesmn 0:3ac96e360672 341
charlesmn 0:3ac96e360672 342 } VL53L1_xtalk_histogram_data_t;
charlesmn 0:3ac96e360672 343
charlesmn 0:3ac96e360672 344
charlesmn 0:3ac96e360672 345
charlesmn 0:3ac96e360672 346
charlesmn 0:3ac96e360672 347 #ifdef __cplusplus
charlesmn 0:3ac96e360672 348 }
charlesmn 0:3ac96e360672 349 #endif
charlesmn 0:3ac96e360672 350
charlesmn 0:3ac96e360672 351 #endif
charlesmn 0:3ac96e360672 352
charlesmn 0:3ac96e360672 353