Initial release. Mbed library for VL53L1CB
Embed:
(wiki syntax)
Show/hide line numbers
vl53l1_core.h
00001 00002 /******************************************************************************* 00003 * Copyright (c) 2020, STMicroelectronics - All Rights Reserved 00004 00005 This file is part of VL53L1 Core and is dual licensed, 00006 either 'STMicroelectronics 00007 Proprietary license' 00008 or 'BSD 3-clause "New" or "Revised" License' , at your option. 00009 00010 ******************************************************************************** 00011 00012 'STMicroelectronics Proprietary license' 00013 00014 ******************************************************************************** 00015 00016 License terms: STMicroelectronics Proprietary in accordance with licensing 00017 terms at www.st.com/sla0081 00018 00019 STMicroelectronics confidential 00020 Reproduction and Communication of this document is strictly prohibited unless 00021 specifically authorized in writing by STMicroelectronics. 00022 00023 00024 ******************************************************************************** 00025 00026 Alternatively, VL53L1 Core may be distributed under the terms of 00027 'BSD 3-clause "New" or "Revised" License', in which case the following 00028 provisions apply instead of the ones 00029 mentioned above : 00030 00031 ******************************************************************************** 00032 00033 License terms: BSD 3-clause "New" or "Revised" License. 00034 00035 Redistribution and use in source and binary forms, with or without 00036 modification, are permitted provided that the following conditions are met: 00037 00038 1. Redistributions of source code must retain the above copyright notice, this 00039 list of conditions and the following disclaimer. 00040 00041 2. Redistributions in binary form must reproduce the above copyright notice, 00042 this list of conditions and the following disclaimer in the documentation 00043 and/or other materials provided with the distribution. 00044 00045 3. Neither the name of the copyright holder nor the names of its contributors 00046 may be used to endorse or promote products derived from this software 00047 without specific prior written permission. 00048 00049 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00050 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00051 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00052 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00053 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00054 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00055 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00056 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00057 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00058 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00059 00060 00061 ******************************************************************************** 00062 00063 */ 00064 00065 00066 00067 00068 #ifndef _VL53L1_CORE_H_ 00069 #define _VL53L1_CORE_H_ 00070 00071 #include "vl53l1_platform.h" 00072 #include "vl53l1_core_support.h" 00073 00074 #ifdef __cplusplus 00075 extern "C" { 00076 #endif 00077 00078 00079 00080 00081 void VL53L1_init_version( 00082 VL53L1_DEV Dev); 00083 00084 00085 00086 00087 void VL53L1_init_ll_driver_state( 00088 VL53L1_DEV Dev, 00089 VL53L1_DeviceState ll_state); 00090 00091 00092 00093 00094 VL53L1_Error VL53L1_update_ll_driver_rd_state( 00095 VL53L1_DEV Dev); 00096 00097 00098 00099 00100 VL53L1_Error VL53L1_check_ll_driver_rd_state( 00101 VL53L1_DEV Dev); 00102 00103 00104 00105 00106 VL53L1_Error VL53L1_update_ll_driver_cfg_state( 00107 VL53L1_DEV Dev); 00108 00109 00110 00111 00112 void VL53L1_copy_rtn_good_spads_to_buffer( 00113 VL53L1_nvm_copy_data_t *pdata, 00114 uint8_t *pbuffer); 00115 00116 00117 00118 00119 void VL53L1_init_system_results( 00120 VL53L1_system_results_t *pdata); 00121 00122 00123 00124 00125 void V53L1_init_zone_results_structure( 00126 uint8_t active_zones, 00127 VL53L1_zone_results_t *pdata); 00128 00129 00130 00131 00132 void V53L1_init_zone_dss_configs( 00133 VL53L1_DEV Dev); 00134 00135 00136 00137 00138 void VL53L1_init_histogram_config_structure( 00139 uint8_t even_bin0, 00140 uint8_t even_bin1, 00141 uint8_t even_bin2, 00142 uint8_t even_bin3, 00143 uint8_t even_bin4, 00144 uint8_t even_bin5, 00145 uint8_t odd_bin0, 00146 uint8_t odd_bin1, 00147 uint8_t odd_bin2, 00148 uint8_t odd_bin3, 00149 uint8_t odd_bin4, 00150 uint8_t odd_bin5, 00151 VL53L1_histogram_config_t *pdata); 00152 00153 00154 00155 void VL53L1_init_histogram_multizone_config_structure( 00156 uint8_t even_bin0, 00157 uint8_t even_bin1, 00158 uint8_t even_bin2, 00159 uint8_t even_bin3, 00160 uint8_t even_bin4, 00161 uint8_t even_bin5, 00162 uint8_t odd_bin0, 00163 uint8_t odd_bin1, 00164 uint8_t odd_bin2, 00165 uint8_t odd_bin3, 00166 uint8_t odd_bin4, 00167 uint8_t odd_bin5, 00168 VL53L1_histogram_config_t *pdata); 00169 00170 00171 00172 00173 void VL53L1_init_xtalk_bin_data_struct( 00174 uint32_t bin_value, 00175 uint16_t VL53L1_p_024, 00176 VL53L1_xtalk_histogram_shape_t *pdata); 00177 00178 00179 00180 00181 void VL53L1_i2c_encode_uint16_t( 00182 uint16_t ip_value, 00183 uint16_t count, 00184 uint8_t *pbuffer); 00185 00186 00187 00188 00189 uint16_t VL53L1_i2c_decode_uint16_t( 00190 uint16_t count, 00191 uint8_t *pbuffer); 00192 00193 00194 00195 00196 void VL53L1_i2c_encode_int16_t( 00197 int16_t ip_value, 00198 uint16_t count, 00199 uint8_t *pbuffer); 00200 00201 00202 00203 00204 int16_t VL53L1_i2c_decode_int16_t( 00205 uint16_t count, 00206 uint8_t *pbuffer); 00207 00208 00209 00210 00211 void VL53L1_i2c_encode_uint32_t( 00212 uint32_t ip_value, 00213 uint16_t count, 00214 uint8_t *pbuffer); 00215 00216 00217 00218 00219 uint32_t VL53L1_i2c_decode_uint32_t( 00220 uint16_t count, 00221 uint8_t *pbuffer); 00222 00223 00224 00225 00226 uint32_t VL53L1_i2c_decode_with_mask( 00227 uint16_t count, 00228 uint8_t *pbuffer, 00229 uint32_t bit_mask, 00230 uint32_t down_shift, 00231 uint32_t offset); 00232 00233 00234 00235 00236 void VL53L1_i2c_encode_int32_t( 00237 int32_t ip_value, 00238 uint16_t count, 00239 uint8_t *pbuffer); 00240 00241 00242 00243 00244 int32_t VL53L1_i2c_decode_int32_t( 00245 uint16_t count, 00246 uint8_t *pbuffer); 00247 00248 00249 00250 00251 VL53L1_Error VL53L1_start_test( 00252 VL53L1_DEV Dev, 00253 uint8_t test_mode__ctrl); 00254 00255 00256 00257 00258 VL53L1_Error VL53L1_set_firmware_enable_register( 00259 VL53L1_DEV Dev, 00260 uint8_t value); 00261 00262 00263 00264 00265 VL53L1_Error VL53L1_enable_firmware( 00266 VL53L1_DEV Dev); 00267 00268 00269 00270 00271 VL53L1_Error VL53L1_disable_firmware( 00272 VL53L1_DEV Dev); 00273 00274 00275 00276 00277 VL53L1_Error VL53L1_set_powerforce_register( 00278 VL53L1_DEV Dev, 00279 uint8_t value); 00280 00281 00282 00283 00284 00285 VL53L1_Error VL53L1_enable_powerforce( 00286 VL53L1_DEV Dev); 00287 00288 00289 00290 VL53L1_Error VL53L1_disable_powerforce( 00291 VL53L1_DEV Dev); 00292 00293 00294 00295 00296 00297 VL53L1_Error VL53L1_clear_interrupt( 00298 VL53L1_DEV Dev); 00299 00300 00301 00302 00303 00304 VL53L1_Error VL53L1_force_shadow_stream_count_to_zero( 00305 VL53L1_DEV Dev); 00306 00307 00308 00309 00310 uint32_t VL53L1_calc_macro_period_us( 00311 uint16_t fast_osc_frequency, 00312 uint8_t VL53L1_p_009); 00313 00314 00315 00316 00317 uint16_t VL53L1_calc_range_ignore_threshold( 00318 uint32_t central_rate, 00319 int16_t x_gradient, 00320 int16_t y_gradient, 00321 uint8_t rate_mult); 00322 00323 00324 00325 00326 uint32_t VL53L1_calc_timeout_mclks( 00327 uint32_t timeout_us, 00328 uint32_t macro_period_us); 00329 00330 00331 00332 uint16_t VL53L1_calc_encoded_timeout( 00333 uint32_t timeout_us, 00334 uint32_t macro_period_us); 00335 00336 00337 00338 00339 uint32_t VL53L1_calc_timeout_us( 00340 uint32_t timeout_mclks, 00341 uint32_t macro_period_us); 00342 00343 00344 00345 uint32_t VL53L1_calc_decoded_timeout_us( 00346 uint16_t timeout_encoded, 00347 uint32_t macro_period_us); 00348 00349 00350 00351 00352 uint16_t VL53L1_encode_timeout( 00353 uint32_t timeout_mclks); 00354 00355 00356 00357 00358 uint32_t VL53L1_decode_timeout( 00359 uint16_t encoded_timeout); 00360 00361 00362 00363 00364 VL53L1_Error VL53L1_calc_timeout_register_values( 00365 uint32_t phasecal_config_timeout_us, 00366 uint32_t mm_config_timeout_us, 00367 uint32_t range_config_timeout_us, 00368 uint16_t fast_osc_frequency, 00369 VL53L1_general_config_t *pgeneral, 00370 VL53L1_timing_config_t *ptiming); 00371 00372 00373 00374 00375 uint8_t VL53L1_encode_vcsel_period( 00376 uint8_t VL53L1_p_031); 00377 00378 00379 00380 00381 uint32_t VL53L1_decode_unsigned_integer( 00382 uint8_t *pbuffer, 00383 uint8_t no_of_bytes); 00384 00385 00386 00387 00388 void VL53L1_encode_unsigned_integer( 00389 uint32_t ip_value, 00390 uint8_t no_of_bytes, 00391 uint8_t *pbuffer); 00392 00393 00394 00395 00396 VL53L1_Error VL53L1_hist_copy_and_scale_ambient_info( 00397 VL53L1_zone_hist_info_t *pidata, 00398 VL53L1_histogram_bin_data_t *podata); 00399 00400 00401 00402 00403 void VL53L1_hist_get_bin_sequence_config( 00404 VL53L1_DEV Dev, 00405 VL53L1_histogram_bin_data_t *pdata); 00406 00407 00408 00409 00410 VL53L1_Error VL53L1_hist_phase_consistency_check( 00411 VL53L1_DEV Dev, 00412 VL53L1_zone_hist_info_t *phist_prev, 00413 VL53L1_zone_objects_t *prange_prev, 00414 VL53L1_range_results_t *prange_curr); 00415 00416 00417 00418 00419 00420 00421 00422 VL53L1_Error VL53L1_hist_events_consistency_check( 00423 uint8_t event_sigma, 00424 uint16_t min_effective_spad_count, 00425 VL53L1_zone_hist_info_t *phist_prev, 00426 VL53L1_object_data_t *prange_prev, 00427 VL53L1_range_data_t *prange_curr, 00428 int32_t *pevents_tolerance, 00429 int32_t *pevents_delta, 00430 VL53L1_DeviceError *prange_status); 00431 00432 00433 00434 00435 00436 00437 00438 VL53L1_Error VL53L1_hist_merged_pulse_check( 00439 int16_t min_max_tolerance_mm, 00440 VL53L1_range_data_t *pdata, 00441 VL53L1_DeviceError *prange_status); 00442 00443 00444 00445 00446 00447 00448 VL53L1_Error VL53L1_hist_xmonitor_consistency_check( 00449 VL53L1_DEV Dev, 00450 VL53L1_zone_hist_info_t *phist_prev, 00451 VL53L1_zone_objects_t *prange_prev, 00452 VL53L1_range_data_t *prange_curr); 00453 00454 00455 00456 00457 00458 00459 VL53L1_Error VL53L1_hist_wrap_dmax( 00460 VL53L1_hist_post_process_config_t *phistpostprocess, 00461 VL53L1_histogram_bin_data_t *pcurrent, 00462 int16_t *pwrap_dmax_mm); 00463 00464 00465 00466 00467 void VL53L1_hist_combine_mm1_mm2_offsets( 00468 int16_t mm1_offset_mm, 00469 int16_t mm2_offset_mm, 00470 uint8_t encoded_mm_roi_centre, 00471 uint8_t encoded_mm_roi_size, 00472 uint8_t encoded_zone_centre, 00473 uint8_t encoded_zone_size, 00474 VL53L1_additional_offset_cal_data_t *pcal_data, 00475 uint8_t *pgood_spads, 00476 uint16_t aperture_attenuation, 00477 int16_t *prange_offset_mm); 00478 00479 00480 00481 00482 VL53L1_Error VL53L1_hist_xtalk_extract_calc_window( 00483 int16_t target_distance_mm, 00484 uint16_t target_width_oversize, 00485 VL53L1_histogram_bin_data_t *phist_bins, 00486 VL53L1_hist_xtalk_extract_data_t *pxtalk_data); 00487 00488 00489 00490 00491 VL53L1_Error VL53L1_hist_xtalk_extract_calc_event_sums( 00492 VL53L1_histogram_bin_data_t *phist_bins, 00493 VL53L1_hist_xtalk_extract_data_t *pxtalk_data); 00494 00495 00496 00497 00498 VL53L1_Error VL53L1_hist_xtalk_extract_calc_rate_per_spad( 00499 VL53L1_hist_xtalk_extract_data_t *pxtalk_data); 00500 00501 00502 00503 VL53L1_Error VL53L1_hist_xtalk_extract_calc_shape( 00504 VL53L1_hist_xtalk_extract_data_t *pxtalk_data, 00505 VL53L1_xtalk_histogram_shape_t *pxtalk_shape); 00506 00507 00508 00509 VL53L1_Error VL53L1_hist_xtalk_shape_model( 00510 uint16_t events_per_bin, 00511 uint16_t pulse_centre, 00512 uint16_t pulse_width, 00513 VL53L1_xtalk_histogram_shape_t *pxtalk_shape); 00514 00515 00516 00517 00518 uint16_t VL53L1_hist_xtalk_shape_model_interp( 00519 uint16_t events_per_bin, 00520 uint32_t phase_delta); 00521 00522 00523 00524 00525 void VL53L1_spad_number_to_byte_bit_index( 00526 uint8_t spad_number, 00527 uint8_t *pbyte_index, 00528 uint8_t *pbit_index, 00529 uint8_t *pbit_mask); 00530 00531 00532 00533 00534 void VL53L1_encode_row_col( 00535 uint8_t row, 00536 uint8_t col, 00537 uint8_t *pspad_number); 00538 00539 00540 00541 00542 void VL53L1_decode_zone_size( 00543 uint8_t encoded_xy_size, 00544 uint8_t *pwidth, 00545 uint8_t *pheight); 00546 00547 00548 00549 00550 void VL53L1_encode_zone_size( 00551 uint8_t width, 00552 uint8_t height, 00553 uint8_t *pencoded_xy_size); 00554 00555 00556 00557 00558 void VL53L1_decode_zone_limits( 00559 uint8_t encoded_xy_centre, 00560 uint8_t encoded_xy_size, 00561 int16_t *px_ll, 00562 int16_t *py_ll, 00563 int16_t *px_ur, 00564 int16_t *py_ur); 00565 00566 00567 00568 00569 uint8_t VL53L1_is_aperture_location( 00570 uint8_t row, 00571 uint8_t col); 00572 00573 00574 00575 00576 void VL53L1_calc_max_effective_spads( 00577 uint8_t encoded_zone_centre, 00578 uint8_t encoded_zone_size, 00579 uint8_t *pgood_spads, 00580 uint16_t aperture_attenuation, 00581 uint16_t *pmax_effective_spads); 00582 00583 00584 00585 00586 void VL53L1_calc_mm_effective_spads( 00587 uint8_t encoded_mm_roi_centre, 00588 uint8_t encoded_mm_roi_size, 00589 uint8_t encoded_zone_centre, 00590 uint8_t encoded_zone_size, 00591 uint8_t *pgood_spads, 00592 uint16_t aperture_attenuation, 00593 uint16_t *pmm_inner_effective_spads, 00594 uint16_t *pmm_outer_effective_spads); 00595 00596 00597 00598 00599 void VL53L1_hist_copy_results_to_sys_and_core( 00600 VL53L1_histogram_bin_data_t *pbins, 00601 VL53L1_range_results_t *phist, 00602 VL53L1_system_results_t *psys, 00603 VL53L1_core_results_t *pcore); 00604 00605 00606 00607 00608 VL53L1_Error VL53L1_sum_histogram_data( 00609 VL53L1_histogram_bin_data_t *phist_input, 00610 VL53L1_histogram_bin_data_t *phist_output); 00611 00612 00613 00614 00615 VL53L1_Error VL53L1_avg_histogram_data( 00616 uint8_t no_of_samples, 00617 VL53L1_histogram_bin_data_t *phist_sum, 00618 VL53L1_histogram_bin_data_t *phist_avg); 00619 00620 00621 00622 00623 VL53L1_Error VL53L1_save_cfg_data( 00624 VL53L1_DEV Dev); 00625 00626 00627 00628 00629 VL53L1_Error VL53L1_dynamic_zone_update( 00630 VL53L1_DEV Dev, 00631 VL53L1_range_results_t *presults); 00632 00633 00634 00635 00636 VL53L1_Error VL53L1_update_internal_stream_counters( 00637 VL53L1_DEV Dev, 00638 uint8_t external_stream_count, 00639 uint8_t *pinternal_stream_count, 00640 uint8_t *pinternal_stream_count_val 00641 ); 00642 00643 00644 00645 VL53L1_Error VL53L1_multizone_hist_bins_update( 00646 VL53L1_DEV Dev); 00647 00648 00649 00650 VL53L1_Error VL53L1_set_histogram_multizone_initial_bin_config( 00651 VL53L1_zone_config_t *pzone_cfg, 00652 VL53L1_histogram_config_t *phist_cfg, 00653 VL53L1_histogram_config_t *pmulti_hist 00654 ); 00655 00656 00657 00658 uint8_t VL53L1_encode_GPIO_interrupt_config( 00659 VL53L1_GPIO_interrupt_config_t *pintconf); 00660 00661 00662 00663 VL53L1_GPIO_interrupt_config_t VL53L1_decode_GPIO_interrupt_config( 00664 uint8_t system__interrupt_config); 00665 00666 00667 00668 VL53L1_Error VL53L1_set_GPIO_distance_threshold( 00669 VL53L1_DEV Dev, 00670 uint16_t threshold_high, 00671 uint16_t threshold_low); 00672 00673 00674 00675 VL53L1_Error VL53L1_set_GPIO_rate_threshold( 00676 VL53L1_DEV Dev, 00677 uint16_t threshold_high, 00678 uint16_t threshold_low); 00679 00680 00681 00682 VL53L1_Error VL53L1_set_GPIO_thresholds_from_struct( 00683 VL53L1_DEV Dev, 00684 VL53L1_GPIO_interrupt_config_t *pintconf); 00685 00686 00687 00688 00689 00690 VL53L1_Error VL53L1_set_ref_spad_char_config( 00691 VL53L1_DEV Dev, 00692 uint8_t vcsel_period_a, 00693 uint32_t phasecal_timeout_us, 00694 uint16_t total_rate_target_mcps, 00695 uint16_t max_count_rate_rtn_limit_mcps, 00696 uint16_t min_count_rate_rtn_limit_mcps, 00697 uint16_t fast_osc_frequency); 00698 00699 00700 00701 00702 VL53L1_Error VL53L1_set_ssc_config( 00703 VL53L1_DEV Dev, 00704 VL53L1_ssc_config_t *pssc_cfg, 00705 uint16_t fast_osc_frequency); 00706 00707 00708 00709 00710 VL53L1_Error VL53L1_get_spad_rate_data( 00711 VL53L1_DEV Dev, 00712 VL53L1_spad_rate_data_t *pspad_rates); 00713 00714 00715 00716 uint32_t VL53L1_calc_crosstalk_plane_offset_with_margin( 00717 uint32_t plane_offset_kcps, 00718 int16_t margin_offset_kcps); 00719 00720 00721 00722 VL53L1_Error VL53L1_low_power_auto_data_init( 00723 VL53L1_DEV Dev 00724 ); 00725 00726 00727 00728 VL53L1_Error VL53L1_low_power_auto_data_stop_range( 00729 VL53L1_DEV Dev 00730 ); 00731 00732 00733 00734 00735 VL53L1_Error VL53L1_dynamic_xtalk_correction_calc_required_samples( 00736 VL53L1_DEV Dev 00737 ); 00738 00739 00740 00741 VL53L1_Error VL53L1_dynamic_xtalk_correction_calc_new_xtalk( 00742 VL53L1_DEV Dev, 00743 uint32_t xtalk_offset_out, 00744 VL53L1_smudge_corrector_config_t *pconfig, 00745 VL53L1_smudge_corrector_data_t *pout, 00746 uint8_t add_smudge, 00747 uint8_t soft_update 00748 ); 00749 00750 00751 00752 VL53L1_Error VL53L1_dynamic_xtalk_correction_corrector( 00753 VL53L1_DEV Dev 00754 ); 00755 00756 00757 00758 VL53L1_Error VL53L1_dynamic_xtalk_correction_data_init( 00759 VL53L1_DEV Dev 00760 ); 00761 00762 00763 00764 VL53L1_Error VL53L1_dynamic_xtalk_correction_output_init( 00765 VL53L1_LLDriverResults_t *pres 00766 ); 00767 00768 00769 00770 VL53L1_Error VL53L1_xtalk_cal_data_init( 00771 VL53L1_DEV Dev 00772 ); 00773 00774 00775 00776 VL53L1_Error VL53L1_config_low_power_auto_mode( 00777 VL53L1_general_config_t *pgeneral, 00778 VL53L1_dynamic_config_t *pdynamic, 00779 VL53L1_low_power_auto_data_t *plpadata 00780 ); 00781 00782 00783 00784 VL53L1_Error VL53L1_low_power_auto_setup_manual_calibration( 00785 VL53L1_DEV Dev); 00786 00787 00788 00789 VL53L1_Error VL53L1_low_power_auto_update_DSS( 00790 VL53L1_DEV Dev); 00791 00792 00793 VL53L1_Error VL53L1_compute_histo_merge_nb( 00794 VL53L1_DEV Dev, uint8_t *histo_merge_nb); 00795 00796 #ifdef __cplusplus 00797 } 00798 #endif 00799 00800 #endif 00801 00802
Generated on Tue Jul 12 2022 20:07:14 by 1.7.2