Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
vl53l1_hist_char.c
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 00069 #include <stdio.h> 00070 #include <stdlib.h> 00071 00072 00073 00074 #include "vl53l1_core.h" 00075 #include "vl53l1_register_settings.h" 00076 #include "vl53l1_hist_char.h" 00077 00078 #define LOG_FUNCTION_START(fmt, ...) \ 00079 _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_HISTOGRAM, fmt, ##__VA_ARGS__) 00080 #define LOG_FUNCTION_END(status, ...) \ 00081 _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_HISTOGRAM, status, ##__VA_ARGS__) 00082 #define LOG_FUNCTION_END_FMT(status, fmt, ...) \ 00083 _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_HISTOGRAM,\ 00084 status, fmt, ##__VA_ARGS__) 00085 00086 00087 VL53L1_Error VL53L1_set_calib_config( 00088 VL53L1_DEV Dev, 00089 uint8_t vcsel_delay__a0, 00090 uint8_t calib_1, 00091 uint8_t calib_2, 00092 uint8_t calib_3, 00093 uint8_t calib_2__a0, 00094 uint8_t spad_readout) 00095 { 00096 00097 00098 VL53L1_Error status = VL53L1_ERROR_NONE; 00099 uint8_t comms_buffer[3]; 00100 00101 LOG_FUNCTION_START(""); 00102 00103 00104 00105 status = VL53L1_enable_powerforce(Dev); 00106 00107 00108 if (status == VL53L1_ERROR_NONE) 00109 status = VL53L1_disable_firmware(Dev); 00110 00111 00112 00113 00114 if (status == VL53L1_ERROR_NONE) { 00115 status = VL53L1_WrByte( 00116 Dev, 00117 VL53L1_RANGING_CORE__VCSEL_DELAY__A0, 00118 vcsel_delay__a0); 00119 } 00120 00121 00122 00123 if (status == VL53L1_ERROR_NONE) { 00124 00125 00126 comms_buffer[0] = calib_1; 00127 comms_buffer[1] = calib_2; 00128 comms_buffer[2] = calib_3; 00129 00130 status = VL53L1_WriteMulti( 00131 Dev, 00132 VL53L1_RANGING_CORE__CALIB_1, 00133 comms_buffer, 00134 3); 00135 } 00136 00137 00138 00139 if (status == VL53L1_ERROR_NONE) 00140 status = VL53L1_WrByte( 00141 Dev, 00142 VL53L1_RANGING_CORE__CALIB_2__A0, 00143 calib_2__a0); 00144 00145 00146 00147 if (status == VL53L1_ERROR_NONE) 00148 status = VL53L1_WrByte( 00149 Dev, 00150 VL53L1_RANGING_CORE__SPAD_READOUT, 00151 spad_readout); 00152 00153 00154 00155 if (status == VL53L1_ERROR_NONE) 00156 status = VL53L1_enable_firmware(Dev); 00157 00158 LOG_FUNCTION_END(status); 00159 00160 return status; 00161 } 00162 00163 00164 00165 VL53L1_Error VL53L1_set_hist_calib_pulse_delay( 00166 VL53L1_DEV Dev, 00167 uint8_t calib_delay) 00168 { 00169 00170 00171 VL53L1_Error status = VL53L1_ERROR_NONE; 00172 00173 LOG_FUNCTION_START(""); 00174 00175 status = 00176 VL53L1_set_calib_config( 00177 Dev, 00178 0x01, 00179 calib_delay, 00180 0x04, 00181 0x08, 00182 0x14, 00183 VL53L1_RANGING_CORE__SPAD_READOUT__CALIB_PULSES); 00184 00185 LOG_FUNCTION_END(status); 00186 00187 return status; 00188 } 00189 00190 00191 VL53L1_Error VL53L1_disable_calib_pulse_delay( 00192 VL53L1_DEV Dev) 00193 { 00194 00195 00196 VL53L1_Error status = VL53L1_ERROR_NONE; 00197 00198 LOG_FUNCTION_START(""); 00199 00200 status = 00201 VL53L1_set_calib_config( 00202 Dev, 00203 0x00, 00204 0x00, 00205 0x00, 00206 0x00, 00207 0x00, 00208 VL53L1_RANGING_CORE__SPAD_READOUT__STANDARD); 00209 00210 LOG_FUNCTION_END(status); 00211 00212 return status; 00213 } 00214 00215 00216
Generated on Tue Jul 12 2022 20:07:14 by
1.7.2