ST Expansion SW Team / VL53L1

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   X_NUCLEO_53L1CB

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers vl53l1_api_strings.c Source File

vl53l1_api_strings.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 
00017 #include "vl53l1_api_core.h"
00018 #include "vl53l1_api_strings.h"
00019 #include "vl53l1_error_codes.h"
00020 #include "vl53l1_error_strings.h"
00021 
00022 #define LOG_FUNCTION_START(fmt, ...) \
00023     _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
00024 #define LOG_FUNCTION_END(status, ...) \
00025     _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_API, status, ##__VA_ARGS__)
00026 #define LOG_FUNCTION_END_FMT(status, fmt, ...) \
00027     _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_API, status, fmt, \
00028             ##__VA_ARGS__)
00029 
00030 
00031 VL53L1_Error VL53L1_get_range_status_string(
00032     uint8_t   RangeStatus,
00033     char    *pRangeStatusString)
00034 {
00035     VL53L1_Error status = VL53L1_ERROR_NONE;
00036 
00037     LOG_FUNCTION_START("");
00038 
00039 #ifdef VL53L1_USE_EMPTY_STRING
00040     SUPPRESS_UNUSED_WARNING(RangeStatus);
00041     VL53L1_COPYSTRING(pRangeStatusString, "");
00042 #else
00043     switch (RangeStatus) {
00044     case 0:
00045         VL53L1_COPYSTRING(pRangeStatusString,
00046             VL53L1_STRING_RANGESTATUS_RANGEVALID);
00047     break;
00048     case 1:
00049         VL53L1_COPYSTRING(pRangeStatusString,
00050             VL53L1_STRING_RANGESTATUS_SIGMA);
00051     break;
00052     case 2:
00053         VL53L1_COPYSTRING(pRangeStatusString,
00054             VL53L1_STRING_RANGESTATUS_SIGNAL);
00055     break;
00056     case 3:
00057         VL53L1_COPYSTRING(pRangeStatusString,
00058             VL53L1_STRING_RANGESTATUS_MINRANGE);
00059     break;
00060     case 4:
00061         VL53L1_COPYSTRING(pRangeStatusString,
00062             VL53L1_STRING_RANGESTATUS_PHASE);
00063     break;
00064     case 5:
00065         VL53L1_COPYSTRING(pRangeStatusString,
00066             VL53L1_STRING_RANGESTATUS_HW);
00067     break;
00068 
00069     default:
00070         VL53L1_COPYSTRING(pRangeStatusString,
00071             VL53L1_STRING_RANGESTATUS_NONE);
00072     }
00073 #endif
00074 
00075     LOG_FUNCTION_END(status);
00076     return status;
00077 }
00078 
00079 
00080 VL53L1_Error VL53L1_get_pal_state_string(
00081     VL53L1_State PalStateCode,
00082     char *pPalStateString)
00083 {
00084     VL53L1_Error status = VL53L1_ERROR_NONE;
00085 
00086     LOG_FUNCTION_START("");
00087 
00088 #ifdef VL53L1_USE_EMPTY_STRING
00089     SUPPRESS_UNUSED_WARNING(PalStateCode);
00090     VL53L1_COPYSTRING(pPalStateString, "");
00091 #else
00092     switch (PalStateCode) {
00093     case VL53L1_STATE_POWERDOWN:
00094         VL53L1_COPYSTRING(pPalStateString,
00095             VL53L1_STRING_STATE_POWERDOWN);
00096     break;
00097     case VL53L1_STATE_WAIT_STATICINIT:
00098         VL53L1_COPYSTRING(pPalStateString,
00099             VL53L1_STRING_STATE_WAIT_STATICINIT);
00100     break;
00101     case VL53L1_STATE_STANDBY:
00102         VL53L1_COPYSTRING(pPalStateString,
00103             VL53L1_STRING_STATE_STANDBY);
00104     break;
00105     case VL53L1_STATE_IDLE:
00106         VL53L1_COPYSTRING(pPalStateString,
00107             VL53L1_STRING_STATE_IDLE);
00108     break;
00109     case VL53L1_STATE_RUNNING:
00110         VL53L1_COPYSTRING(pPalStateString,
00111             VL53L1_STRING_STATE_RUNNING);
00112     break;
00113     case VL53L1_STATE_RESET:
00114         VL53L1_COPYSTRING(pPalStateString,
00115             VL53L1_STRING_STATE_RESET);
00116     break;
00117     case VL53L1_STATE_UNKNOWN:
00118         VL53L1_COPYSTRING(pPalStateString,
00119             VL53L1_STRING_STATE_UNKNOWN);
00120     break;
00121     case VL53L1_STATE_ERROR:
00122         VL53L1_COPYSTRING(pPalStateString,
00123             VL53L1_STRING_STATE_ERROR);
00124     break;
00125 
00126     default:
00127         VL53L1_COPYSTRING(pPalStateString,
00128             VL53L1_STRING_STATE_UNKNOWN);
00129     }
00130 #endif
00131 
00132     LOG_FUNCTION_END(status);
00133     return status;
00134 }
00135 
00136 VL53L1_Error VL53L1_get_sequence_steps_info(
00137         VL53L1_SequenceStepId SequenceStepId,
00138         char *pSequenceStepsString)
00139 {
00140     VL53L1_Error Status = VL53L1_ERROR_NONE;
00141 
00142     LOG_FUNCTION_START("");
00143 
00144 #ifdef VL53L1_USE_EMPTY_STRING
00145     SUPPRESS_UNUSED_WARNING(SequenceStepId);
00146     VL53L1_COPYSTRING(pSequenceStepsString, "");
00147 #else
00148     switch (SequenceStepId) {
00149     case VL53L1_SEQUENCESTEP_VHV:
00150         VL53L1_COPYSTRING(pSequenceStepsString,
00151                 VL53L1_STRING_SEQUENCESTEP_VHV);
00152     break;
00153     case VL53L1_SEQUENCESTEP_PHASECAL:
00154         VL53L1_COPYSTRING(pSequenceStepsString,
00155                 VL53L1_STRING_SEQUENCESTEP_PHASECAL);
00156     break;
00157     case VL53L1_SEQUENCESTEP_REFPHASE:
00158         VL53L1_COPYSTRING(pSequenceStepsString,
00159                 VL53L1_STRING_SEQUENCESTEP_DSS1);
00160     break;
00161     case VL53L1_SEQUENCESTEP_DSS1:
00162         VL53L1_COPYSTRING(pSequenceStepsString,
00163                 VL53L1_STRING_SEQUENCESTEP_DSS1);
00164     break;
00165     case VL53L1_SEQUENCESTEP_DSS2:
00166         VL53L1_COPYSTRING(pSequenceStepsString,
00167                 VL53L1_STRING_SEQUENCESTEP_DSS2);
00168     break;
00169     case VL53L1_SEQUENCESTEP_MM1:
00170         VL53L1_COPYSTRING(pSequenceStepsString,
00171                 VL53L1_STRING_SEQUENCESTEP_MM1);
00172     break;
00173     case VL53L1_SEQUENCESTEP_MM2:
00174         VL53L1_COPYSTRING(pSequenceStepsString,
00175                 VL53L1_STRING_SEQUENCESTEP_MM2);
00176     break;
00177     case VL53L1_SEQUENCESTEP_RANGE:
00178         VL53L1_COPYSTRING(pSequenceStepsString,
00179                 VL53L1_STRING_SEQUENCESTEP_RANGE);
00180     break;
00181     default:
00182         Status = VL53L1_ERROR_INVALID_PARAMS;
00183     }
00184 #endif
00185 
00186     LOG_FUNCTION_END(Status);
00187 
00188     return Status;
00189 }
00190 
00191 VL53L1_Error VL53L1_get_limit_check_info(uint16_t LimitCheckId,
00192     char *pLimitCheckString)
00193 {
00194     VL53L1_Error Status = VL53L1_ERROR_NONE;
00195 
00196     LOG_FUNCTION_START("");
00197 
00198 #ifdef VL53L1_USE_EMPTY_STRING
00199     SUPPRESS_UNUSED_WARNING(LimitCheckId);
00200     VL53L1_COPYSTRING(pLimitCheckString, "");
00201 #else
00202     switch (LimitCheckId) {
00203     case VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE:
00204         VL53L1_COPYSTRING(pLimitCheckString,
00205             VL53L1_STRING_CHECKENABLE_SIGMA_FINAL_RANGE);
00206     break;
00207     case VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE:
00208         VL53L1_COPYSTRING(pLimitCheckString,
00209             VL53L1_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE);
00210     break;
00211     default:
00212         VL53L1_COPYSTRING(pLimitCheckString,
00213             VL53L1_STRING_UNKNOW_ERROR_CODE);
00214     }
00215 #endif
00216 
00217     LOG_FUNCTION_END(Status);
00218     return Status;
00219 }
00220 
00221