Initial release. Mbed library for VL53L1CB
Embed:
(wiki syntax)
Show/hide line numbers
vl53l1_api_strings.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 "vl53l1_api_core.h" 00070 #include "vl53l1_api_strings.h" 00071 #include "vl53l1_error_codes.h" 00072 #include "vl53l1_error_strings.h" 00073 00074 #define LOG_FUNCTION_START(fmt, ...) \ 00075 _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_API, fmt, ##__VA_ARGS__) 00076 #define LOG_FUNCTION_END(status, ...) \ 00077 _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_API, status, ##__VA_ARGS__) 00078 #define LOG_FUNCTION_END_FMT(status, fmt, ...) \ 00079 _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_API, status, fmt, \ 00080 ##__VA_ARGS__) 00081 00082 00083 VL53L1_Error VL53L1_get_range_status_string( 00084 uint8_t RangeStatus, 00085 char *pRangeStatusString) 00086 { 00087 VL53L1_Error status = VL53L1_ERROR_NONE; 00088 00089 LOG_FUNCTION_START(""); 00090 00091 #ifdef VL53L1_USE_EMPTY_STRING 00092 SUPPRESS_UNUSED_WARNING(RangeStatus); 00093 VL53L1_COPYSTRING(pRangeStatusString, ""); 00094 #else 00095 switch (RangeStatus) { 00096 case 0: 00097 VL53L1_COPYSTRING(pRangeStatusString, 00098 VL53L1_STRING_RANGESTATUS_RANGEVALID); 00099 break; 00100 case 1: 00101 VL53L1_COPYSTRING(pRangeStatusString, 00102 VL53L1_STRING_RANGESTATUS_SIGMA); 00103 break; 00104 case 2: 00105 VL53L1_COPYSTRING(pRangeStatusString, 00106 VL53L1_STRING_RANGESTATUS_SIGNAL); 00107 break; 00108 case 3: 00109 VL53L1_COPYSTRING(pRangeStatusString, 00110 VL53L1_STRING_RANGESTATUS_MINRANGE); 00111 break; 00112 case 4: 00113 VL53L1_COPYSTRING(pRangeStatusString, 00114 VL53L1_STRING_RANGESTATUS_PHASE); 00115 break; 00116 case 5: 00117 VL53L1_COPYSTRING(pRangeStatusString, 00118 VL53L1_STRING_RANGESTATUS_HW); 00119 break; 00120 00121 default: 00122 VL53L1_COPYSTRING(pRangeStatusString, 00123 VL53L1_STRING_RANGESTATUS_NONE); 00124 } 00125 #endif 00126 00127 LOG_FUNCTION_END(status); 00128 return status; 00129 } 00130 00131 00132 VL53L1_Error VL53L1_get_pal_state_string( 00133 VL53L1_State PalStateCode, 00134 char *pPalStateString) 00135 { 00136 VL53L1_Error status = VL53L1_ERROR_NONE; 00137 00138 LOG_FUNCTION_START(""); 00139 00140 #ifdef VL53L1_USE_EMPTY_STRING 00141 SUPPRESS_UNUSED_WARNING(PalStateCode); 00142 VL53L1_COPYSTRING(pPalStateString, ""); 00143 #else 00144 switch (PalStateCode) { 00145 case VL53L1_STATE_POWERDOWN: 00146 VL53L1_COPYSTRING(pPalStateString, 00147 VL53L1_STRING_STATE_POWERDOWN); 00148 break; 00149 case VL53L1_STATE_WAIT_STATICINIT: 00150 VL53L1_COPYSTRING(pPalStateString, 00151 VL53L1_STRING_STATE_WAIT_STATICINIT); 00152 break; 00153 case VL53L1_STATE_STANDBY: 00154 VL53L1_COPYSTRING(pPalStateString, 00155 VL53L1_STRING_STATE_STANDBY); 00156 break; 00157 case VL53L1_STATE_IDLE: 00158 VL53L1_COPYSTRING(pPalStateString, 00159 VL53L1_STRING_STATE_IDLE); 00160 break; 00161 case VL53L1_STATE_RUNNING: 00162 VL53L1_COPYSTRING(pPalStateString, 00163 VL53L1_STRING_STATE_RUNNING); 00164 break; 00165 case VL53L1_STATE_RESET: 00166 VL53L1_COPYSTRING(pPalStateString, 00167 VL53L1_STRING_STATE_RESET); 00168 break; 00169 case VL53L1_STATE_UNKNOWN: 00170 VL53L1_COPYSTRING(pPalStateString, 00171 VL53L1_STRING_STATE_UNKNOWN); 00172 break; 00173 case VL53L1_STATE_ERROR: 00174 VL53L1_COPYSTRING(pPalStateString, 00175 VL53L1_STRING_STATE_ERROR); 00176 break; 00177 00178 default: 00179 VL53L1_COPYSTRING(pPalStateString, 00180 VL53L1_STRING_STATE_UNKNOWN); 00181 } 00182 #endif 00183 00184 LOG_FUNCTION_END(status); 00185 return status; 00186 } 00187 00188 VL53L1_Error VL53L1_get_sequence_steps_info( 00189 VL53L1_SequenceStepId SequenceStepId, 00190 char *pSequenceStepsString) 00191 { 00192 VL53L1_Error Status = VL53L1_ERROR_NONE; 00193 00194 LOG_FUNCTION_START(""); 00195 00196 #ifdef VL53L1_USE_EMPTY_STRING 00197 SUPPRESS_UNUSED_WARNING(SequenceStepId); 00198 VL53L1_COPYSTRING(pSequenceStepsString, ""); 00199 #else 00200 switch (SequenceStepId) { 00201 case VL53L1_SEQUENCESTEP_VHV: 00202 VL53L1_COPYSTRING(pSequenceStepsString, 00203 VL53L1_STRING_SEQUENCESTEP_VHV); 00204 break; 00205 case VL53L1_SEQUENCESTEP_PHASECAL: 00206 VL53L1_COPYSTRING(pSequenceStepsString, 00207 VL53L1_STRING_SEQUENCESTEP_PHASECAL); 00208 break; 00209 case VL53L1_SEQUENCESTEP_REFPHASE: 00210 VL53L1_COPYSTRING(pSequenceStepsString, 00211 VL53L1_STRING_SEQUENCESTEP_DSS1); 00212 break; 00213 case VL53L1_SEQUENCESTEP_DSS1: 00214 VL53L1_COPYSTRING(pSequenceStepsString, 00215 VL53L1_STRING_SEQUENCESTEP_DSS1); 00216 break; 00217 case VL53L1_SEQUENCESTEP_DSS2: 00218 VL53L1_COPYSTRING(pSequenceStepsString, 00219 VL53L1_STRING_SEQUENCESTEP_DSS2); 00220 break; 00221 case VL53L1_SEQUENCESTEP_MM1: 00222 VL53L1_COPYSTRING(pSequenceStepsString, 00223 VL53L1_STRING_SEQUENCESTEP_MM1); 00224 break; 00225 case VL53L1_SEQUENCESTEP_MM2: 00226 VL53L1_COPYSTRING(pSequenceStepsString, 00227 VL53L1_STRING_SEQUENCESTEP_MM2); 00228 break; 00229 case VL53L1_SEQUENCESTEP_RANGE: 00230 VL53L1_COPYSTRING(pSequenceStepsString, 00231 VL53L1_STRING_SEQUENCESTEP_RANGE); 00232 break; 00233 default: 00234 Status = VL53L1_ERROR_INVALID_PARAMS; 00235 } 00236 #endif 00237 00238 LOG_FUNCTION_END(Status); 00239 00240 return Status; 00241 } 00242 00243 VL53L1_Error VL53L1_get_limit_check_info(uint16_t LimitCheckId, 00244 char *pLimitCheckString) 00245 { 00246 VL53L1_Error Status = VL53L1_ERROR_NONE; 00247 00248 LOG_FUNCTION_START(""); 00249 00250 #ifdef VL53L1_USE_EMPTY_STRING 00251 SUPPRESS_UNUSED_WARNING(LimitCheckId); 00252 VL53L1_COPYSTRING(pLimitCheckString, ""); 00253 #else 00254 switch (LimitCheckId) { 00255 case VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE: 00256 VL53L1_COPYSTRING(pLimitCheckString, 00257 VL53L1_STRING_CHECKENABLE_SIGMA_FINAL_RANGE); 00258 break; 00259 case VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE: 00260 VL53L1_COPYSTRING(pLimitCheckString, 00261 VL53L1_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE); 00262 break; 00263 default: 00264 VL53L1_COPYSTRING(pLimitCheckString, 00265 VL53L1_STRING_UNKNOW_ERROR_CODE); 00266 } 00267 #endif 00268 00269 LOG_FUNCTION_END(Status); 00270 return Status; 00271 } 00272 00273 00274
Generated on Tue Jul 12 2022 20:07:14 by 1.7.2