The VL53L1CB proximity sensor, based on ST’s FlightSense™, Time-of-Flight technology.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: VL53L1CB_noshield_1sensor_polls_auton VL53L1CB_noshield_1sensor_interrupt_auton X_NUCLEO_53L1A2
Based on VL53L1 library, this is a library for the VL53L1CB ToF chip.
src/vl53l1_platform_ipp.c@0:3ac96e360672, 2020-11-06 (annotated)
- Committer:
- charlesmn
- Date:
- Fri Nov 06 10:06:37 2020 +0000
- Revision:
- 0:3ac96e360672
- Child:
- 18:0696efe39d08
Library for ST Vl53L1A1 time of flight sensor.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
charlesmn | 0:3ac96e360672 | 1 | |
charlesmn | 0:3ac96e360672 | 2 | /******************************************************************************* |
charlesmn | 0:3ac96e360672 | 3 | This file is part of VL53L1 Platform |
charlesmn | 0:3ac96e360672 | 4 | |
charlesmn | 0:3ac96e360672 | 5 | Copyright (c) 2020, STMicroelectronics - All Rights Reserved |
charlesmn | 0:3ac96e360672 | 6 | |
charlesmn | 0:3ac96e360672 | 7 | License terms: BSD 3-clause "New" or "Revised" License. |
charlesmn | 0:3ac96e360672 | 8 | |
charlesmn | 0:3ac96e360672 | 9 | Redistribution and use in source and binary forms, with or without |
charlesmn | 0:3ac96e360672 | 10 | modification, are permitted provided that the following conditions are met: |
charlesmn | 0:3ac96e360672 | 11 | |
charlesmn | 0:3ac96e360672 | 12 | 1. Redistributions of source code must retain the above copyright notice, this |
charlesmn | 0:3ac96e360672 | 13 | list of conditions and the following disclaimer. |
charlesmn | 0:3ac96e360672 | 14 | |
charlesmn | 0:3ac96e360672 | 15 | 2. Redistributions in binary form must reproduce the above copyright notice, |
charlesmn | 0:3ac96e360672 | 16 | this list of conditions and the following disclaimer in the documentation |
charlesmn | 0:3ac96e360672 | 17 | and/or other materials provided with the distribution. |
charlesmn | 0:3ac96e360672 | 18 | |
charlesmn | 0:3ac96e360672 | 19 | 3. Neither the name of the copyright holder nor the names of its contributors |
charlesmn | 0:3ac96e360672 | 20 | may be used to endorse or promote products derived from this software |
charlesmn | 0:3ac96e360672 | 21 | without specific prior written permission. |
charlesmn | 0:3ac96e360672 | 22 | |
charlesmn | 0:3ac96e360672 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
charlesmn | 0:3ac96e360672 | 24 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
charlesmn | 0:3ac96e360672 | 25 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
charlesmn | 0:3ac96e360672 | 26 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
charlesmn | 0:3ac96e360672 | 27 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
charlesmn | 0:3ac96e360672 | 28 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
charlesmn | 0:3ac96e360672 | 29 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
charlesmn | 0:3ac96e360672 | 30 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
charlesmn | 0:3ac96e360672 | 31 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
charlesmn | 0:3ac96e360672 | 32 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
charlesmn | 0:3ac96e360672 | 33 | |
charlesmn | 0:3ac96e360672 | 34 | */ |
charlesmn | 0:3ac96e360672 | 35 | |
charlesmn | 0:3ac96e360672 | 36 | |
charlesmn | 0:3ac96e360672 | 37 | |
charlesmn | 0:3ac96e360672 | 38 | |
charlesmn | 0:3ac96e360672 | 39 | |
charlesmn | 0:3ac96e360672 | 40 | #include "vl53l1_ll_def.h" |
charlesmn | 0:3ac96e360672 | 41 | #include "vl53l1_platform_user_data.h" |
charlesmn | 0:3ac96e360672 | 42 | #include "vl53l1_hist_structs.h" |
charlesmn | 0:3ac96e360672 | 43 | #include "vl53l1_hist_funcs.h" |
charlesmn | 0:3ac96e360672 | 44 | #include "vl53l1_xtalk.h" |
charlesmn | 0:3ac96e360672 | 45 | #include "vl53l1_platform_ipp.h" |
charlesmn | 0:3ac96e360672 | 46 | |
charlesmn | 0:3ac96e360672 | 47 | |
charlesmn | 0:3ac96e360672 | 48 | #define LOG_FUNCTION_START(fmt, ...) \ |
charlesmn | 0:3ac96e360672 | 49 | _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__) |
charlesmn | 0:3ac96e360672 | 50 | #define LOG_FUNCTION_END(status, ...) \ |
charlesmn | 0:3ac96e360672 | 51 | _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__) |
charlesmn | 0:3ac96e360672 | 52 | |
charlesmn | 0:3ac96e360672 | 53 | |
charlesmn | 0:3ac96e360672 | 54 | VL53L1_Error VL53L1_ipp_hist_process_data( |
charlesmn | 0:3ac96e360672 | 55 | VL53L1_DEV Dev, |
charlesmn | 0:3ac96e360672 | 56 | VL53L1_dmax_calibration_data_t *pdmax_cal, |
charlesmn | 0:3ac96e360672 | 57 | VL53L1_hist_gen3_dmax_config_t *pdmax_cfg, |
charlesmn | 0:3ac96e360672 | 58 | VL53L1_hist_post_process_config_t *ppost_cfg, |
charlesmn | 0:3ac96e360672 | 59 | VL53L1_histogram_bin_data_t *pbins, |
charlesmn | 0:3ac96e360672 | 60 | VL53L1_xtalk_histogram_data_t *pxtalk, |
charlesmn | 0:3ac96e360672 | 61 | uint8_t *pArea1, |
charlesmn | 0:3ac96e360672 | 62 | uint8_t *pArea2, |
charlesmn | 0:3ac96e360672 | 63 | uint8_t *phisto_merge_nb, |
charlesmn | 0:3ac96e360672 | 64 | VL53L1_range_results_t *presults) |
charlesmn | 0:3ac96e360672 | 65 | { |
charlesmn | 0:3ac96e360672 | 66 | |
charlesmn | 0:3ac96e360672 | 67 | |
charlesmn | 0:3ac96e360672 | 68 | |
charlesmn | 0:3ac96e360672 | 69 | VL53L1_Error status = VL53L1_ERROR_NONE; |
charlesmn | 0:3ac96e360672 | 70 | |
charlesmn | 0:3ac96e360672 | 71 | SUPPRESS_UNUSED_WARNING(Dev); |
charlesmn | 0:3ac96e360672 | 72 | |
charlesmn | 0:3ac96e360672 | 73 | status = |
charlesmn | 0:3ac96e360672 | 74 | VL53L1_hist_process_data( |
charlesmn | 0:3ac96e360672 | 75 | pdmax_cal, |
charlesmn | 0:3ac96e360672 | 76 | pdmax_cfg, |
charlesmn | 0:3ac96e360672 | 77 | ppost_cfg, |
charlesmn | 0:3ac96e360672 | 78 | pbins, |
charlesmn | 0:3ac96e360672 | 79 | pxtalk, |
charlesmn | 0:3ac96e360672 | 80 | pArea1, |
charlesmn | 0:3ac96e360672 | 81 | pArea2, |
charlesmn | 0:3ac96e360672 | 82 | presults, |
charlesmn | 0:3ac96e360672 | 83 | phisto_merge_nb); |
charlesmn | 0:3ac96e360672 | 84 | |
charlesmn | 0:3ac96e360672 | 85 | return status; |
charlesmn | 0:3ac96e360672 | 86 | } |
charlesmn | 0:3ac96e360672 | 87 | |
charlesmn | 0:3ac96e360672 | 88 | |
charlesmn | 0:3ac96e360672 | 89 | VL53L1_Error VL53L1_ipp_hist_ambient_dmax( |
charlesmn | 0:3ac96e360672 | 90 | VL53L1_DEV Dev, |
charlesmn | 0:3ac96e360672 | 91 | uint16_t target_reflectance, |
charlesmn | 0:3ac96e360672 | 92 | VL53L1_dmax_calibration_data_t *pdmax_cal, |
charlesmn | 0:3ac96e360672 | 93 | VL53L1_hist_gen3_dmax_config_t *pdmax_cfg, |
charlesmn | 0:3ac96e360672 | 94 | VL53L1_histogram_bin_data_t *pbins, |
charlesmn | 0:3ac96e360672 | 95 | int16_t *pambient_dmax_mm) |
charlesmn | 0:3ac96e360672 | 96 | { |
charlesmn | 0:3ac96e360672 | 97 | |
charlesmn | 0:3ac96e360672 | 98 | |
charlesmn | 0:3ac96e360672 | 99 | |
charlesmn | 0:3ac96e360672 | 100 | VL53L1_Error status = VL53L1_ERROR_NONE; |
charlesmn | 0:3ac96e360672 | 101 | |
charlesmn | 0:3ac96e360672 | 102 | SUPPRESS_UNUSED_WARNING(Dev); |
charlesmn | 0:3ac96e360672 | 103 | |
charlesmn | 0:3ac96e360672 | 104 | status = |
charlesmn | 0:3ac96e360672 | 105 | VL53L1_hist_ambient_dmax( |
charlesmn | 0:3ac96e360672 | 106 | target_reflectance, |
charlesmn | 0:3ac96e360672 | 107 | pdmax_cal, |
charlesmn | 0:3ac96e360672 | 108 | pdmax_cfg, |
charlesmn | 0:3ac96e360672 | 109 | pbins, |
charlesmn | 0:3ac96e360672 | 110 | pambient_dmax_mm); |
charlesmn | 0:3ac96e360672 | 111 | |
charlesmn | 0:3ac96e360672 | 112 | return status; |
charlesmn | 0:3ac96e360672 | 113 | } |
charlesmn | 0:3ac96e360672 | 114 | |
charlesmn | 0:3ac96e360672 | 115 | |
charlesmn | 0:3ac96e360672 | 116 | VL53L1_Error VL53L1_ipp_xtalk_calibration_process_data( |
charlesmn | 0:3ac96e360672 | 117 | VL53L1_DEV Dev, |
charlesmn | 0:3ac96e360672 | 118 | VL53L1_xtalk_range_results_t *pxtalk_ranges, |
charlesmn | 0:3ac96e360672 | 119 | VL53L1_xtalk_histogram_data_t *pxtalk_shape, |
charlesmn | 0:3ac96e360672 | 120 | VL53L1_xtalk_calibration_results_t *pxtalk_cal) |
charlesmn | 0:3ac96e360672 | 121 | { |
charlesmn | 0:3ac96e360672 | 122 | |
charlesmn | 0:3ac96e360672 | 123 | |
charlesmn | 0:3ac96e360672 | 124 | |
charlesmn | 0:3ac96e360672 | 125 | VL53L1_Error status = VL53L1_ERROR_NONE; |
charlesmn | 0:3ac96e360672 | 126 | |
charlesmn | 0:3ac96e360672 | 127 | SUPPRESS_UNUSED_WARNING(Dev); |
charlesmn | 0:3ac96e360672 | 128 | |
charlesmn | 0:3ac96e360672 | 129 | status = |
charlesmn | 0:3ac96e360672 | 130 | VL53L1_xtalk_calibration_process_data( |
charlesmn | 0:3ac96e360672 | 131 | pxtalk_ranges, |
charlesmn | 0:3ac96e360672 | 132 | pxtalk_shape, |
charlesmn | 0:3ac96e360672 | 133 | pxtalk_cal); |
charlesmn | 0:3ac96e360672 | 134 | |
charlesmn | 0:3ac96e360672 | 135 | return status; |
charlesmn | 0:3ac96e360672 | 136 | } |
charlesmn | 0:3ac96e360672 | 137 | |
charlesmn | 0:3ac96e360672 | 138 | |
charlesmn | 0:3ac96e360672 | 139 | VL53L1_Error VL53L1_ipp_hist_xtalk_correction( |
charlesmn | 0:3ac96e360672 | 140 | VL53L1_DEV Dev, |
charlesmn | 0:3ac96e360672 | 141 | VL53L1_customer_nvm_managed_t *pcustomer, |
charlesmn | 0:3ac96e360672 | 142 | VL53L1_dynamic_config_t *pdyn_cfg, |
charlesmn | 0:3ac96e360672 | 143 | VL53L1_xtalk_histogram_data_t *pxtalk_shape, |
charlesmn | 0:3ac96e360672 | 144 | VL53L1_histogram_bin_data_t *pip_hist_data, |
charlesmn | 0:3ac96e360672 | 145 | VL53L1_histogram_bin_data_t *pop_hist_data, |
charlesmn | 0:3ac96e360672 | 146 | VL53L1_histogram_bin_data_t *pxtalk_count_data) |
charlesmn | 0:3ac96e360672 | 147 | { |
charlesmn | 0:3ac96e360672 | 148 | |
charlesmn | 0:3ac96e360672 | 149 | |
charlesmn | 0:3ac96e360672 | 150 | |
charlesmn | 0:3ac96e360672 | 151 | VL53L1_Error status = VL53L1_ERROR_NONE; |
charlesmn | 0:3ac96e360672 | 152 | |
charlesmn | 0:3ac96e360672 | 153 | SUPPRESS_UNUSED_WARNING(Dev); |
charlesmn | 0:3ac96e360672 | 154 | |
charlesmn | 0:3ac96e360672 | 155 | status = |
charlesmn | 0:3ac96e360672 | 156 | VL53L1_f_054( |
charlesmn | 0:3ac96e360672 | 157 | pcustomer, |
charlesmn | 0:3ac96e360672 | 158 | pdyn_cfg, |
charlesmn | 0:3ac96e360672 | 159 | pxtalk_shape, |
charlesmn | 0:3ac96e360672 | 160 | pip_hist_data, |
charlesmn | 0:3ac96e360672 | 161 | pop_hist_data, |
charlesmn | 0:3ac96e360672 | 162 | pxtalk_count_data); |
charlesmn | 0:3ac96e360672 | 163 | |
charlesmn | 0:3ac96e360672 | 164 | return status; |
charlesmn | 0:3ac96e360672 | 165 | } |
charlesmn | 0:3ac96e360672 | 166 | |
charlesmn | 0:3ac96e360672 | 167 | VL53L1_Error VL53L1_ipp_generate_dual_reflectance_xtalk_samples( |
charlesmn | 0:3ac96e360672 | 168 | VL53L1_DEV Dev, |
charlesmn | 0:3ac96e360672 | 169 | VL53L1_xtalk_range_results_t *pxtalk_results, |
charlesmn | 0:3ac96e360672 | 170 | uint16_t expected_target_distance_mm, |
charlesmn | 0:3ac96e360672 | 171 | uint8_t higher_reflectance, |
charlesmn | 0:3ac96e360672 | 172 | VL53L1_histogram_bin_data_t *pxtalk_avg_samples) |
charlesmn | 0:3ac96e360672 | 173 | { |
charlesmn | 0:3ac96e360672 | 174 | |
charlesmn | 0:3ac96e360672 | 175 | |
charlesmn | 0:3ac96e360672 | 176 | VL53L1_Error status = VL53L1_ERROR_NONE; |
charlesmn | 0:3ac96e360672 | 177 | |
charlesmn | 0:3ac96e360672 | 178 | SUPPRESS_UNUSED_WARNING(Dev); |
charlesmn | 0:3ac96e360672 | 179 | |
charlesmn | 0:3ac96e360672 | 180 | status = VL53L1_generate_dual_reflectance_xtalk_samples( |
charlesmn | 0:3ac96e360672 | 181 | pxtalk_results, |
charlesmn | 0:3ac96e360672 | 182 | expected_target_distance_mm, |
charlesmn | 0:3ac96e360672 | 183 | higher_reflectance, |
charlesmn | 0:3ac96e360672 | 184 | pxtalk_avg_samples); |
charlesmn | 0:3ac96e360672 | 185 | |
charlesmn | 0:3ac96e360672 | 186 | return status; |
charlesmn | 0:3ac96e360672 | 187 | |
charlesmn | 0:3ac96e360672 | 188 | } |
charlesmn | 0:3ac96e360672 | 189 | |
charlesmn | 0:3ac96e360672 | 190 |