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.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
vl53l1_hist_char.c
00001 00002 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause 00003 /****************************************************************************** 00004 * Copyright (c) 2020, STMicroelectronics - All Rights Reserved 00005 00006 This file is part of VL53L1 and is dual licensed, 00007 either GPL-2.0+ 00008 or 'BSD 3-clause "New" or "Revised" License' , at your option. 00009 ****************************************************************************** 00010 */ 00011 00012 00013 00014 00015 00016 #include <stdio.h> 00017 #include <stdlib.h> 00018 00019 00020 00021 #include "vl53l1_core.h" 00022 #include "vl53l1_register_settings.h" 00023 #include "vl53l1_hist_char.h" 00024 00025 #define LOG_FUNCTION_START(fmt, ...) \ 00026 _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_HISTOGRAM, fmt, ##__VA_ARGS__) 00027 #define LOG_FUNCTION_END(status, ...) \ 00028 _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_HISTOGRAM, status, ##__VA_ARGS__) 00029 #define LOG_FUNCTION_END_FMT(status, fmt, ...) \ 00030 _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_HISTOGRAM,\ 00031 status, fmt, ##__VA_ARGS__) 00032 00033 00034 VL53L1_Error VL53L1_set_calib_config( 00035 VL53L1_DEV Dev, 00036 uint8_t vcsel_delay__a0, 00037 uint8_t calib_1, 00038 uint8_t calib_2, 00039 uint8_t calib_3, 00040 uint8_t calib_2__a0, 00041 uint8_t spad_readout) 00042 { 00043 00044 00045 VL53L1_Error status = VL53L1_ERROR_NONE; 00046 uint8_t comms_buffer[3]; 00047 00048 LOG_FUNCTION_START(""); 00049 00050 00051 00052 status = VL53L1_enable_powerforce(Dev); 00053 00054 00055 if (status == VL53L1_ERROR_NONE) 00056 status = VL53L1_disable_firmware(Dev); 00057 00058 00059 00060 00061 if (status == VL53L1_ERROR_NONE) { 00062 status = VL53L1_WrByte( 00063 Dev, 00064 VL53L1_RANGING_CORE__VCSEL_DELAY__A0, 00065 vcsel_delay__a0); 00066 } 00067 00068 00069 00070 if (status == VL53L1_ERROR_NONE) { 00071 00072 00073 comms_buffer[0] = calib_1; 00074 comms_buffer[1] = calib_2; 00075 comms_buffer[2] = calib_3; 00076 00077 status = VL53L1_WriteMulti( 00078 Dev, 00079 VL53L1_RANGING_CORE__CALIB_1, 00080 comms_buffer, 00081 3); 00082 } 00083 00084 00085 00086 if (status == VL53L1_ERROR_NONE) 00087 status = VL53L1_WrByte( 00088 Dev, 00089 VL53L1_RANGING_CORE__CALIB_2__A0, 00090 calib_2__a0); 00091 00092 00093 00094 if (status == VL53L1_ERROR_NONE) 00095 status = VL53L1_WrByte( 00096 Dev, 00097 VL53L1_RANGING_CORE__SPAD_READOUT, 00098 spad_readout); 00099 00100 00101 00102 if (status == VL53L1_ERROR_NONE) 00103 status = VL53L1_enable_firmware(Dev); 00104 00105 LOG_FUNCTION_END(status); 00106 00107 return status; 00108 } 00109 00110 00111 00112 VL53L1_Error VL53L1_set_hist_calib_pulse_delay( 00113 VL53L1_DEV Dev, 00114 uint8_t calib_delay) 00115 { 00116 00117 00118 VL53L1_Error status = VL53L1_ERROR_NONE; 00119 00120 LOG_FUNCTION_START(""); 00121 00122 status = 00123 VL53L1_set_calib_config( 00124 Dev, 00125 0x01, 00126 calib_delay, 00127 0x04, 00128 0x08, 00129 0x14, 00130 VL53L1_RANGING_CORE__SPAD_READOUT__CALIB_PULSES); 00131 00132 LOG_FUNCTION_END(status); 00133 00134 return status; 00135 } 00136 00137 00138 VL53L1_Error VL53L1_disable_calib_pulse_delay( 00139 VL53L1_DEV Dev) 00140 { 00141 00142 00143 VL53L1_Error status = VL53L1_ERROR_NONE; 00144 00145 LOG_FUNCTION_START(""); 00146 00147 status = 00148 VL53L1_set_calib_config( 00149 Dev, 00150 0x00, 00151 0x00, 00152 0x00, 00153 0x00, 00154 0x00, 00155 VL53L1_RANGING_CORE__SPAD_READOUT__STANDARD); 00156 00157 LOG_FUNCTION_END(status); 00158 00159 return status; 00160 } 00161 00162
Generated on Thu Jul 14 2022 10:20:22 by
1.7.2