hh

Dependents:   VL53L0X-mbedOS-master VL53L0X-mbedOS-masterbb

Committer:
mjarvisal
Date:
Tue Aug 23 05:14:05 2016 +0000
Revision:
0:e6fcdb78a136
Initial release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mjarvisal 0:e6fcdb78a136 1 /*******************************************************************************
mjarvisal 0:e6fcdb78a136 2 Copyright © 2016, STMicroelectronics International N.V.
mjarvisal 0:e6fcdb78a136 3 All rights reserved.
mjarvisal 0:e6fcdb78a136 4
mjarvisal 0:e6fcdb78a136 5 Redistribution and use in source and binary forms, with or without
mjarvisal 0:e6fcdb78a136 6 modification, are permitted provided that the following conditions are met:
mjarvisal 0:e6fcdb78a136 7 * Redistributions of source code must retain the above copyright
mjarvisal 0:e6fcdb78a136 8 notice, this list of conditions and the following disclaimer.
mjarvisal 0:e6fcdb78a136 9 * Redistributions in binary form must reproduce the above copyright
mjarvisal 0:e6fcdb78a136 10 notice, this list of conditions and the following disclaimer in the
mjarvisal 0:e6fcdb78a136 11 documentation and/or other materials provided with the distribution.
mjarvisal 0:e6fcdb78a136 12 * Neither the name of STMicroelectronics nor the
mjarvisal 0:e6fcdb78a136 13 names of its contributors may be used to endorse or promote products
mjarvisal 0:e6fcdb78a136 14 derived from this software without specific prior written permission.
mjarvisal 0:e6fcdb78a136 15
mjarvisal 0:e6fcdb78a136 16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mjarvisal 0:e6fcdb78a136 17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mjarvisal 0:e6fcdb78a136 18 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
mjarvisal 0:e6fcdb78a136 19 NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED.
mjarvisal 0:e6fcdb78a136 20 IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY
mjarvisal 0:e6fcdb78a136 21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mjarvisal 0:e6fcdb78a136 22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mjarvisal 0:e6fcdb78a136 23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
mjarvisal 0:e6fcdb78a136 24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mjarvisal 0:e6fcdb78a136 25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mjarvisal 0:e6fcdb78a136 26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mjarvisal 0:e6fcdb78a136 27 ******************************************************************************/
mjarvisal 0:e6fcdb78a136 28
mjarvisal 0:e6fcdb78a136 29 #include "vl53l0x_api.h"
mjarvisal 0:e6fcdb78a136 30 #include "vl53l0x_api_core.h"
mjarvisal 0:e6fcdb78a136 31 #include "vl53l0x_api_strings.h"
mjarvisal 0:e6fcdb78a136 32
mjarvisal 0:e6fcdb78a136 33 #ifndef __KERNEL__
mjarvisal 0:e6fcdb78a136 34 #include <stdlib.h>
mjarvisal 0:e6fcdb78a136 35 #endif
mjarvisal 0:e6fcdb78a136 36
mjarvisal 0:e6fcdb78a136 37 #define LOG_FUNCTION_START(fmt, ...) \
mjarvisal 0:e6fcdb78a136 38 _LOG_FUNCTION_START(TRACE_MODULE_API, fmt, ##__VA_ARGS__)
mjarvisal 0:e6fcdb78a136 39 #define LOG_FUNCTION_END(status, ...) \
mjarvisal 0:e6fcdb78a136 40 _LOG_FUNCTION_END(TRACE_MODULE_API, status, ##__VA_ARGS__)
mjarvisal 0:e6fcdb78a136 41 #define LOG_FUNCTION_END_FMT(status, fmt, ...) \
mjarvisal 0:e6fcdb78a136 42 _LOG_FUNCTION_END_FMT(TRACE_MODULE_API, status, fmt, ##__VA_ARGS__)
mjarvisal 0:e6fcdb78a136 43
mjarvisal 0:e6fcdb78a136 44
mjarvisal 0:e6fcdb78a136 45 VL53L0X_Error VL53L0X_check_part_used(VL53L0X_DEV Dev,
mjarvisal 0:e6fcdb78a136 46 uint8_t *Revision,
mjarvisal 0:e6fcdb78a136 47 VL53L0X_DeviceInfo_t *pVL53L0X_DeviceInfo)
mjarvisal 0:e6fcdb78a136 48 {
mjarvisal 0:e6fcdb78a136 49 VL53L0X_Error Status = VL53L0X_ERROR_NONE;
mjarvisal 0:e6fcdb78a136 50 uint8_t ModuleIdInt;
mjarvisal 0:e6fcdb78a136 51 char *ProductId_tmp;
mjarvisal 0:e6fcdb78a136 52
mjarvisal 0:e6fcdb78a136 53 LOG_FUNCTION_START("");
mjarvisal 0:e6fcdb78a136 54
mjarvisal 0:e6fcdb78a136 55 Status = VL53L0X_get_info_from_device(Dev, 2);
mjarvisal 0:e6fcdb78a136 56
mjarvisal 0:e6fcdb78a136 57 if (Status == VL53L0X_ERROR_NONE) {
mjarvisal 0:e6fcdb78a136 58 ModuleIdInt = VL53L0X_GETDEVICESPECIFICPARAMETER(Dev, ModuleId);
mjarvisal 0:e6fcdb78a136 59
mjarvisal 0:e6fcdb78a136 60 if (ModuleIdInt == 0) {
mjarvisal 0:e6fcdb78a136 61 *Revision = 0;
mjarvisal 0:e6fcdb78a136 62 VL53L0X_COPYSTRING(pVL53L0X_DeviceInfo->ProductId, "");
mjarvisal 0:e6fcdb78a136 63 } else {
mjarvisal 0:e6fcdb78a136 64 *Revision = VL53L0X_GETDEVICESPECIFICPARAMETER(Dev, Revision);
mjarvisal 0:e6fcdb78a136 65 ProductId_tmp = VL53L0X_GETDEVICESPECIFICPARAMETER(Dev,
mjarvisal 0:e6fcdb78a136 66 ProductId);
mjarvisal 0:e6fcdb78a136 67 VL53L0X_COPYSTRING(pVL53L0X_DeviceInfo->ProductId, ProductId_tmp);
mjarvisal 0:e6fcdb78a136 68 }
mjarvisal 0:e6fcdb78a136 69 }
mjarvisal 0:e6fcdb78a136 70
mjarvisal 0:e6fcdb78a136 71 LOG_FUNCTION_END(Status);
mjarvisal 0:e6fcdb78a136 72 return Status;
mjarvisal 0:e6fcdb78a136 73 }
mjarvisal 0:e6fcdb78a136 74
mjarvisal 0:e6fcdb78a136 75
mjarvisal 0:e6fcdb78a136 76 VL53L0X_Error VL53L0X_get_device_info(VL53L0X_DEV Dev,
mjarvisal 0:e6fcdb78a136 77 VL53L0X_DeviceInfo_t *pVL53L0X_DeviceInfo)
mjarvisal 0:e6fcdb78a136 78 {
mjarvisal 0:e6fcdb78a136 79 VL53L0X_Error Status = VL53L0X_ERROR_NONE;
mjarvisal 0:e6fcdb78a136 80 uint8_t revision_id;
mjarvisal 0:e6fcdb78a136 81 uint8_t Revision;
mjarvisal 0:e6fcdb78a136 82
mjarvisal 0:e6fcdb78a136 83 Status = VL53L0X_check_part_used(Dev, &Revision, pVL53L0X_DeviceInfo);
mjarvisal 0:e6fcdb78a136 84
mjarvisal 0:e6fcdb78a136 85 if (Status == VL53L0X_ERROR_NONE) {
mjarvisal 0:e6fcdb78a136 86 if (Revision == 0) {
mjarvisal 0:e6fcdb78a136 87 VL53L0X_COPYSTRING(pVL53L0X_DeviceInfo->Name,
mjarvisal 0:e6fcdb78a136 88 VL53L0X_STRING_DEVICE_INFO_NAME_TS0);
mjarvisal 0:e6fcdb78a136 89 } else if ((Revision <= 34) && (Revision != 32)) {
mjarvisal 0:e6fcdb78a136 90 VL53L0X_COPYSTRING(pVL53L0X_DeviceInfo->Name,
mjarvisal 0:e6fcdb78a136 91 VL53L0X_STRING_DEVICE_INFO_NAME_TS1);
mjarvisal 0:e6fcdb78a136 92 } else if (Revision < 39) {
mjarvisal 0:e6fcdb78a136 93 VL53L0X_COPYSTRING(pVL53L0X_DeviceInfo->Name,
mjarvisal 0:e6fcdb78a136 94 VL53L0X_STRING_DEVICE_INFO_NAME_TS2);
mjarvisal 0:e6fcdb78a136 95 } else {
mjarvisal 0:e6fcdb78a136 96 VL53L0X_COPYSTRING(pVL53L0X_DeviceInfo->Name,
mjarvisal 0:e6fcdb78a136 97 VL53L0X_STRING_DEVICE_INFO_NAME_ES1);
mjarvisal 0:e6fcdb78a136 98 }
mjarvisal 0:e6fcdb78a136 99
mjarvisal 0:e6fcdb78a136 100 VL53L0X_COPYSTRING(pVL53L0X_DeviceInfo->Type,
mjarvisal 0:e6fcdb78a136 101 VL53L0X_STRING_DEVICE_INFO_TYPE);
mjarvisal 0:e6fcdb78a136 102
mjarvisal 0:e6fcdb78a136 103 }
mjarvisal 0:e6fcdb78a136 104
mjarvisal 0:e6fcdb78a136 105 if (Status == VL53L0X_ERROR_NONE) {
mjarvisal 0:e6fcdb78a136 106 Status = VL53L0X_RdByte(Dev, VL53L0X_REG_IDENTIFICATION_MODEL_ID,
mjarvisal 0:e6fcdb78a136 107 &pVL53L0X_DeviceInfo->ProductType);
mjarvisal 0:e6fcdb78a136 108 }
mjarvisal 0:e6fcdb78a136 109
mjarvisal 0:e6fcdb78a136 110 if (Status == VL53L0X_ERROR_NONE) {
mjarvisal 0:e6fcdb78a136 111 Status = VL53L0X_RdByte(Dev,
mjarvisal 0:e6fcdb78a136 112 VL53L0X_REG_IDENTIFICATION_REVISION_ID,
mjarvisal 0:e6fcdb78a136 113 &revision_id);
mjarvisal 0:e6fcdb78a136 114 pVL53L0X_DeviceInfo->ProductRevisionMajor = 1;
mjarvisal 0:e6fcdb78a136 115 pVL53L0X_DeviceInfo->ProductRevisionMinor =
mjarvisal 0:e6fcdb78a136 116 (revision_id & 0xF0) >> 4;
mjarvisal 0:e6fcdb78a136 117 }
mjarvisal 0:e6fcdb78a136 118
mjarvisal 0:e6fcdb78a136 119 return Status;
mjarvisal 0:e6fcdb78a136 120 }
mjarvisal 0:e6fcdb78a136 121
mjarvisal 0:e6fcdb78a136 122
mjarvisal 0:e6fcdb78a136 123 VL53L0X_Error VL53L0X_get_device_error_string(VL53L0X_DeviceError ErrorCode,
mjarvisal 0:e6fcdb78a136 124 char *pDeviceErrorString)
mjarvisal 0:e6fcdb78a136 125 {
mjarvisal 0:e6fcdb78a136 126 VL53L0X_Error Status = VL53L0X_ERROR_NONE;
mjarvisal 0:e6fcdb78a136 127
mjarvisal 0:e6fcdb78a136 128 LOG_FUNCTION_START("");
mjarvisal 0:e6fcdb78a136 129
mjarvisal 0:e6fcdb78a136 130 switch (ErrorCode) {
mjarvisal 0:e6fcdb78a136 131 case VL53L0X_DEVICEERROR_NONE:
mjarvisal 0:e6fcdb78a136 132 VL53L0X_COPYSTRING(pDeviceErrorString,
mjarvisal 0:e6fcdb78a136 133 VL53L0X_STRING_DEVICEERROR_NONE);
mjarvisal 0:e6fcdb78a136 134 break;
mjarvisal 0:e6fcdb78a136 135 case VL53L0X_DEVICEERROR_VCSELCONTINUITYTESTFAILURE:
mjarvisal 0:e6fcdb78a136 136 VL53L0X_COPYSTRING(pDeviceErrorString,
mjarvisal 0:e6fcdb78a136 137 VL53L0X_STRING_DEVICEERROR_VCSELCONTINUITYTESTFAILURE);
mjarvisal 0:e6fcdb78a136 138 break;
mjarvisal 0:e6fcdb78a136 139 case VL53L0X_DEVICEERROR_VCSELWATCHDOGTESTFAILURE:
mjarvisal 0:e6fcdb78a136 140 VL53L0X_COPYSTRING(pDeviceErrorString,
mjarvisal 0:e6fcdb78a136 141 VL53L0X_STRING_DEVICEERROR_VCSELWATCHDOGTESTFAILURE);
mjarvisal 0:e6fcdb78a136 142 break;
mjarvisal 0:e6fcdb78a136 143 case VL53L0X_DEVICEERROR_NOVHVVALUEFOUND:
mjarvisal 0:e6fcdb78a136 144 VL53L0X_COPYSTRING(pDeviceErrorString,
mjarvisal 0:e6fcdb78a136 145 VL53L0X_STRING_DEVICEERROR_NOVHVVALUEFOUND);
mjarvisal 0:e6fcdb78a136 146 break;
mjarvisal 0:e6fcdb78a136 147 case VL53L0X_DEVICEERROR_MSRCNOTARGET:
mjarvisal 0:e6fcdb78a136 148 VL53L0X_COPYSTRING(pDeviceErrorString,
mjarvisal 0:e6fcdb78a136 149 VL53L0X_STRING_DEVICEERROR_MSRCNOTARGET);
mjarvisal 0:e6fcdb78a136 150 break;
mjarvisal 0:e6fcdb78a136 151 case VL53L0X_DEVICEERROR_SNRCHECK:
mjarvisal 0:e6fcdb78a136 152 VL53L0X_COPYSTRING(pDeviceErrorString,
mjarvisal 0:e6fcdb78a136 153 VL53L0X_STRING_DEVICEERROR_SNRCHECK);
mjarvisal 0:e6fcdb78a136 154 break;
mjarvisal 0:e6fcdb78a136 155 case VL53L0X_DEVICEERROR_RANGEPHASECHECK:
mjarvisal 0:e6fcdb78a136 156 VL53L0X_COPYSTRING(pDeviceErrorString,
mjarvisal 0:e6fcdb78a136 157 VL53L0X_STRING_DEVICEERROR_RANGEPHASECHECK);
mjarvisal 0:e6fcdb78a136 158 break;
mjarvisal 0:e6fcdb78a136 159 case VL53L0X_DEVICEERROR_SIGMATHRESHOLDCHECK:
mjarvisal 0:e6fcdb78a136 160 VL53L0X_COPYSTRING(pDeviceErrorString,
mjarvisal 0:e6fcdb78a136 161 VL53L0X_STRING_DEVICEERROR_SIGMATHRESHOLDCHECK);
mjarvisal 0:e6fcdb78a136 162 break;
mjarvisal 0:e6fcdb78a136 163 case VL53L0X_DEVICEERROR_TCC:
mjarvisal 0:e6fcdb78a136 164 VL53L0X_COPYSTRING(pDeviceErrorString,
mjarvisal 0:e6fcdb78a136 165 VL53L0X_STRING_DEVICEERROR_TCC);
mjarvisal 0:e6fcdb78a136 166 break;
mjarvisal 0:e6fcdb78a136 167 case VL53L0X_DEVICEERROR_PHASECONSISTENCY:
mjarvisal 0:e6fcdb78a136 168 VL53L0X_COPYSTRING(pDeviceErrorString,
mjarvisal 0:e6fcdb78a136 169 VL53L0X_STRING_DEVICEERROR_PHASECONSISTENCY);
mjarvisal 0:e6fcdb78a136 170 break;
mjarvisal 0:e6fcdb78a136 171 case VL53L0X_DEVICEERROR_MINCLIP:
mjarvisal 0:e6fcdb78a136 172 VL53L0X_COPYSTRING(pDeviceErrorString,
mjarvisal 0:e6fcdb78a136 173 VL53L0X_STRING_DEVICEERROR_MINCLIP);
mjarvisal 0:e6fcdb78a136 174 break;
mjarvisal 0:e6fcdb78a136 175 case VL53L0X_DEVICEERROR_RANGECOMPLETE:
mjarvisal 0:e6fcdb78a136 176 VL53L0X_COPYSTRING(pDeviceErrorString,
mjarvisal 0:e6fcdb78a136 177 VL53L0X_STRING_DEVICEERROR_RANGECOMPLETE);
mjarvisal 0:e6fcdb78a136 178 break;
mjarvisal 0:e6fcdb78a136 179 case VL53L0X_DEVICEERROR_ALGOUNDERFLOW:
mjarvisal 0:e6fcdb78a136 180 VL53L0X_COPYSTRING(pDeviceErrorString,
mjarvisal 0:e6fcdb78a136 181 VL53L0X_STRING_DEVICEERROR_ALGOUNDERFLOW);
mjarvisal 0:e6fcdb78a136 182 break;
mjarvisal 0:e6fcdb78a136 183 case VL53L0X_DEVICEERROR_ALGOOVERFLOW:
mjarvisal 0:e6fcdb78a136 184 VL53L0X_COPYSTRING(pDeviceErrorString,
mjarvisal 0:e6fcdb78a136 185 VL53L0X_STRING_DEVICEERROR_ALGOOVERFLOW);
mjarvisal 0:e6fcdb78a136 186 break;
mjarvisal 0:e6fcdb78a136 187 case VL53L0X_DEVICEERROR_RANGEIGNORETHRESHOLD:
mjarvisal 0:e6fcdb78a136 188 VL53L0X_COPYSTRING(pDeviceErrorString,
mjarvisal 0:e6fcdb78a136 189 VL53L0X_STRING_DEVICEERROR_RANGEIGNORETHRESHOLD);
mjarvisal 0:e6fcdb78a136 190 break;
mjarvisal 0:e6fcdb78a136 191
mjarvisal 0:e6fcdb78a136 192 default:
mjarvisal 0:e6fcdb78a136 193 VL53L0X_COPYSTRING(pDeviceErrorString,
mjarvisal 0:e6fcdb78a136 194 VL53L0X_STRING_UNKNOW_ERROR_CODE);
mjarvisal 0:e6fcdb78a136 195
mjarvisal 0:e6fcdb78a136 196 }
mjarvisal 0:e6fcdb78a136 197
mjarvisal 0:e6fcdb78a136 198 LOG_FUNCTION_END(Status);
mjarvisal 0:e6fcdb78a136 199 return Status;
mjarvisal 0:e6fcdb78a136 200 }
mjarvisal 0:e6fcdb78a136 201
mjarvisal 0:e6fcdb78a136 202 VL53L0X_Error VL53L0X_get_range_status_string(uint8_t RangeStatus,
mjarvisal 0:e6fcdb78a136 203 char *pRangeStatusString)
mjarvisal 0:e6fcdb78a136 204 {
mjarvisal 0:e6fcdb78a136 205 VL53L0X_Error Status = VL53L0X_ERROR_NONE;
mjarvisal 0:e6fcdb78a136 206
mjarvisal 0:e6fcdb78a136 207 LOG_FUNCTION_START("");
mjarvisal 0:e6fcdb78a136 208
mjarvisal 0:e6fcdb78a136 209 switch (RangeStatus) {
mjarvisal 0:e6fcdb78a136 210 case 0:
mjarvisal 0:e6fcdb78a136 211 VL53L0X_COPYSTRING(pRangeStatusString,
mjarvisal 0:e6fcdb78a136 212 VL53L0X_STRING_RANGESTATUS_RANGEVALID);
mjarvisal 0:e6fcdb78a136 213 break;
mjarvisal 0:e6fcdb78a136 214 case 1:
mjarvisal 0:e6fcdb78a136 215 VL53L0X_COPYSTRING(pRangeStatusString,
mjarvisal 0:e6fcdb78a136 216 VL53L0X_STRING_RANGESTATUS_SIGMA);
mjarvisal 0:e6fcdb78a136 217 break;
mjarvisal 0:e6fcdb78a136 218 case 2:
mjarvisal 0:e6fcdb78a136 219 VL53L0X_COPYSTRING(pRangeStatusString,
mjarvisal 0:e6fcdb78a136 220 VL53L0X_STRING_RANGESTATUS_SIGNAL);
mjarvisal 0:e6fcdb78a136 221 break;
mjarvisal 0:e6fcdb78a136 222 case 3:
mjarvisal 0:e6fcdb78a136 223 VL53L0X_COPYSTRING(pRangeStatusString,
mjarvisal 0:e6fcdb78a136 224 VL53L0X_STRING_RANGESTATUS_MINRANGE);
mjarvisal 0:e6fcdb78a136 225 break;
mjarvisal 0:e6fcdb78a136 226 case 4:
mjarvisal 0:e6fcdb78a136 227 VL53L0X_COPYSTRING(pRangeStatusString,
mjarvisal 0:e6fcdb78a136 228 VL53L0X_STRING_RANGESTATUS_PHASE);
mjarvisal 0:e6fcdb78a136 229 break;
mjarvisal 0:e6fcdb78a136 230 case 5:
mjarvisal 0:e6fcdb78a136 231 VL53L0X_COPYSTRING(pRangeStatusString,
mjarvisal 0:e6fcdb78a136 232 VL53L0X_STRING_RANGESTATUS_HW);
mjarvisal 0:e6fcdb78a136 233 break;
mjarvisal 0:e6fcdb78a136 234
mjarvisal 0:e6fcdb78a136 235 default: /**/
mjarvisal 0:e6fcdb78a136 236 VL53L0X_COPYSTRING(pRangeStatusString,
mjarvisal 0:e6fcdb78a136 237 VL53L0X_STRING_RANGESTATUS_NONE);
mjarvisal 0:e6fcdb78a136 238 }
mjarvisal 0:e6fcdb78a136 239
mjarvisal 0:e6fcdb78a136 240 LOG_FUNCTION_END(Status);
mjarvisal 0:e6fcdb78a136 241 return Status;
mjarvisal 0:e6fcdb78a136 242 }
mjarvisal 0:e6fcdb78a136 243
mjarvisal 0:e6fcdb78a136 244 VL53L0X_Error VL53L0X_get_pal_error_string(VL53L0X_Error PalErrorCode,
mjarvisal 0:e6fcdb78a136 245 char *pPalErrorString)
mjarvisal 0:e6fcdb78a136 246 {
mjarvisal 0:e6fcdb78a136 247 VL53L0X_Error Status = VL53L0X_ERROR_NONE;
mjarvisal 0:e6fcdb78a136 248
mjarvisal 0:e6fcdb78a136 249 LOG_FUNCTION_START("");
mjarvisal 0:e6fcdb78a136 250
mjarvisal 0:e6fcdb78a136 251 switch (PalErrorCode) {
mjarvisal 0:e6fcdb78a136 252 case VL53L0X_ERROR_NONE:
mjarvisal 0:e6fcdb78a136 253 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 254 VL53L0X_STRING_ERROR_NONE);
mjarvisal 0:e6fcdb78a136 255 break;
mjarvisal 0:e6fcdb78a136 256 case VL53L0X_ERROR_CALIBRATION_WARNING:
mjarvisal 0:e6fcdb78a136 257 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 258 VL53L0X_STRING_ERROR_CALIBRATION_WARNING);
mjarvisal 0:e6fcdb78a136 259 break;
mjarvisal 0:e6fcdb78a136 260 case VL53L0X_ERROR_MIN_CLIPPED:
mjarvisal 0:e6fcdb78a136 261 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 262 VL53L0X_STRING_ERROR_MIN_CLIPPED);
mjarvisal 0:e6fcdb78a136 263 break;
mjarvisal 0:e6fcdb78a136 264 case VL53L0X_ERROR_UNDEFINED:
mjarvisal 0:e6fcdb78a136 265 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 266 VL53L0X_STRING_ERROR_UNDEFINED);
mjarvisal 0:e6fcdb78a136 267 break;
mjarvisal 0:e6fcdb78a136 268 case VL53L0X_ERROR_INVALID_PARAMS:
mjarvisal 0:e6fcdb78a136 269 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 270 VL53L0X_STRING_ERROR_INVALID_PARAMS);
mjarvisal 0:e6fcdb78a136 271 break;
mjarvisal 0:e6fcdb78a136 272 case VL53L0X_ERROR_NOT_SUPPORTED:
mjarvisal 0:e6fcdb78a136 273 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 274 VL53L0X_STRING_ERROR_NOT_SUPPORTED);
mjarvisal 0:e6fcdb78a136 275 break;
mjarvisal 0:e6fcdb78a136 276 case VL53L0X_ERROR_INTERRUPT_NOT_CLEARED:
mjarvisal 0:e6fcdb78a136 277 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 278 VL53L0X_STRING_ERROR_INTERRUPT_NOT_CLEARED);
mjarvisal 0:e6fcdb78a136 279 break;
mjarvisal 0:e6fcdb78a136 280 case VL53L0X_ERROR_RANGE_ERROR:
mjarvisal 0:e6fcdb78a136 281 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 282 VL53L0X_STRING_ERROR_RANGE_ERROR);
mjarvisal 0:e6fcdb78a136 283 break;
mjarvisal 0:e6fcdb78a136 284 case VL53L0X_ERROR_TIME_OUT:
mjarvisal 0:e6fcdb78a136 285 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 286 VL53L0X_STRING_ERROR_TIME_OUT);
mjarvisal 0:e6fcdb78a136 287 break;
mjarvisal 0:e6fcdb78a136 288 case VL53L0X_ERROR_MODE_NOT_SUPPORTED:
mjarvisal 0:e6fcdb78a136 289 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 290 VL53L0X_STRING_ERROR_MODE_NOT_SUPPORTED);
mjarvisal 0:e6fcdb78a136 291 break;
mjarvisal 0:e6fcdb78a136 292 case VL53L0X_ERROR_BUFFER_TOO_SMALL:
mjarvisal 0:e6fcdb78a136 293 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 294 VL53L0X_STRING_ERROR_BUFFER_TOO_SMALL);
mjarvisal 0:e6fcdb78a136 295 break;
mjarvisal 0:e6fcdb78a136 296 case VL53L0X_ERROR_GPIO_NOT_EXISTING:
mjarvisal 0:e6fcdb78a136 297 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 298 VL53L0X_STRING_ERROR_GPIO_NOT_EXISTING);
mjarvisal 0:e6fcdb78a136 299 break;
mjarvisal 0:e6fcdb78a136 300 case VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED:
mjarvisal 0:e6fcdb78a136 301 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 302 VL53L0X_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED);
mjarvisal 0:e6fcdb78a136 303 break;
mjarvisal 0:e6fcdb78a136 304 case VL53L0X_ERROR_CONTROL_INTERFACE:
mjarvisal 0:e6fcdb78a136 305 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 306 VL53L0X_STRING_ERROR_CONTROL_INTERFACE);
mjarvisal 0:e6fcdb78a136 307 break;
mjarvisal 0:e6fcdb78a136 308 case VL53L0X_ERROR_INVALID_COMMAND:
mjarvisal 0:e6fcdb78a136 309 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 310 VL53L0X_STRING_ERROR_INVALID_COMMAND);
mjarvisal 0:e6fcdb78a136 311 break;
mjarvisal 0:e6fcdb78a136 312 case VL53L0X_ERROR_DIVISION_BY_ZERO:
mjarvisal 0:e6fcdb78a136 313 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 314 VL53L0X_STRING_ERROR_DIVISION_BY_ZERO);
mjarvisal 0:e6fcdb78a136 315 break;
mjarvisal 0:e6fcdb78a136 316 case VL53L0X_ERROR_REF_SPAD_INIT:
mjarvisal 0:e6fcdb78a136 317 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 318 VL53L0X_STRING_ERROR_REF_SPAD_INIT);
mjarvisal 0:e6fcdb78a136 319 break;
mjarvisal 0:e6fcdb78a136 320 case VL53L0X_ERROR_NOT_IMPLEMENTED:
mjarvisal 0:e6fcdb78a136 321 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 322 VL53L0X_STRING_ERROR_NOT_IMPLEMENTED);
mjarvisal 0:e6fcdb78a136 323 break;
mjarvisal 0:e6fcdb78a136 324
mjarvisal 0:e6fcdb78a136 325 default:
mjarvisal 0:e6fcdb78a136 326 VL53L0X_COPYSTRING(pPalErrorString,
mjarvisal 0:e6fcdb78a136 327 VL53L0X_STRING_UNKNOW_ERROR_CODE);
mjarvisal 0:e6fcdb78a136 328 }
mjarvisal 0:e6fcdb78a136 329
mjarvisal 0:e6fcdb78a136 330 LOG_FUNCTION_END(Status);
mjarvisal 0:e6fcdb78a136 331 return Status;
mjarvisal 0:e6fcdb78a136 332 }
mjarvisal 0:e6fcdb78a136 333
mjarvisal 0:e6fcdb78a136 334 VL53L0X_Error VL53L0X_get_pal_state_string(VL53L0X_State PalStateCode,
mjarvisal 0:e6fcdb78a136 335 char *pPalStateString)
mjarvisal 0:e6fcdb78a136 336 {
mjarvisal 0:e6fcdb78a136 337 VL53L0X_Error Status = VL53L0X_ERROR_NONE;
mjarvisal 0:e6fcdb78a136 338
mjarvisal 0:e6fcdb78a136 339 LOG_FUNCTION_START("");
mjarvisal 0:e6fcdb78a136 340
mjarvisal 0:e6fcdb78a136 341 switch (PalStateCode) {
mjarvisal 0:e6fcdb78a136 342 case VL53L0X_STATE_POWERDOWN:
mjarvisal 0:e6fcdb78a136 343 VL53L0X_COPYSTRING(pPalStateString,
mjarvisal 0:e6fcdb78a136 344 VL53L0X_STRING_STATE_POWERDOWN);
mjarvisal 0:e6fcdb78a136 345 break;
mjarvisal 0:e6fcdb78a136 346 case VL53L0X_STATE_WAIT_STATICINIT:
mjarvisal 0:e6fcdb78a136 347 VL53L0X_COPYSTRING(pPalStateString,
mjarvisal 0:e6fcdb78a136 348 VL53L0X_STRING_STATE_WAIT_STATICINIT);
mjarvisal 0:e6fcdb78a136 349 break;
mjarvisal 0:e6fcdb78a136 350 case VL53L0X_STATE_STANDBY:
mjarvisal 0:e6fcdb78a136 351 VL53L0X_COPYSTRING(pPalStateString,
mjarvisal 0:e6fcdb78a136 352 VL53L0X_STRING_STATE_STANDBY);
mjarvisal 0:e6fcdb78a136 353 break;
mjarvisal 0:e6fcdb78a136 354 case VL53L0X_STATE_IDLE:
mjarvisal 0:e6fcdb78a136 355 VL53L0X_COPYSTRING(pPalStateString,
mjarvisal 0:e6fcdb78a136 356 VL53L0X_STRING_STATE_IDLE);
mjarvisal 0:e6fcdb78a136 357 break;
mjarvisal 0:e6fcdb78a136 358 case VL53L0X_STATE_RUNNING:
mjarvisal 0:e6fcdb78a136 359 VL53L0X_COPYSTRING(pPalStateString,
mjarvisal 0:e6fcdb78a136 360 VL53L0X_STRING_STATE_RUNNING);
mjarvisal 0:e6fcdb78a136 361 break;
mjarvisal 0:e6fcdb78a136 362 case VL53L0X_STATE_UNKNOWN:
mjarvisal 0:e6fcdb78a136 363 VL53L0X_COPYSTRING(pPalStateString,
mjarvisal 0:e6fcdb78a136 364 VL53L0X_STRING_STATE_UNKNOWN);
mjarvisal 0:e6fcdb78a136 365 break;
mjarvisal 0:e6fcdb78a136 366 case VL53L0X_STATE_ERROR:
mjarvisal 0:e6fcdb78a136 367 VL53L0X_COPYSTRING(pPalStateString,
mjarvisal 0:e6fcdb78a136 368 VL53L0X_STRING_STATE_ERROR);
mjarvisal 0:e6fcdb78a136 369 break;
mjarvisal 0:e6fcdb78a136 370
mjarvisal 0:e6fcdb78a136 371 default:
mjarvisal 0:e6fcdb78a136 372 VL53L0X_COPYSTRING(pPalStateString,
mjarvisal 0:e6fcdb78a136 373 VL53L0X_STRING_STATE_UNKNOWN);
mjarvisal 0:e6fcdb78a136 374 }
mjarvisal 0:e6fcdb78a136 375
mjarvisal 0:e6fcdb78a136 376 LOG_FUNCTION_END(Status);
mjarvisal 0:e6fcdb78a136 377 return Status;
mjarvisal 0:e6fcdb78a136 378 }
mjarvisal 0:e6fcdb78a136 379
mjarvisal 0:e6fcdb78a136 380 VL53L0X_Error VL53L0X_get_sequence_steps_info(
mjarvisal 0:e6fcdb78a136 381 VL53L0X_SequenceStepId SequenceStepId,
mjarvisal 0:e6fcdb78a136 382 char *pSequenceStepsString)
mjarvisal 0:e6fcdb78a136 383 {
mjarvisal 0:e6fcdb78a136 384 VL53L0X_Error Status = VL53L0X_ERROR_NONE;
mjarvisal 0:e6fcdb78a136 385 LOG_FUNCTION_START("");
mjarvisal 0:e6fcdb78a136 386
mjarvisal 0:e6fcdb78a136 387 switch (SequenceStepId) {
mjarvisal 0:e6fcdb78a136 388 case VL53L0X_SEQUENCESTEP_TCC:
mjarvisal 0:e6fcdb78a136 389 VL53L0X_COPYSTRING(pSequenceStepsString,
mjarvisal 0:e6fcdb78a136 390 VL53L0X_STRING_SEQUENCESTEP_TCC);
mjarvisal 0:e6fcdb78a136 391 break;
mjarvisal 0:e6fcdb78a136 392 case VL53L0X_SEQUENCESTEP_DSS:
mjarvisal 0:e6fcdb78a136 393 VL53L0X_COPYSTRING(pSequenceStepsString,
mjarvisal 0:e6fcdb78a136 394 VL53L0X_STRING_SEQUENCESTEP_DSS);
mjarvisal 0:e6fcdb78a136 395 break;
mjarvisal 0:e6fcdb78a136 396 case VL53L0X_SEQUENCESTEP_MSRC:
mjarvisal 0:e6fcdb78a136 397 VL53L0X_COPYSTRING(pSequenceStepsString,
mjarvisal 0:e6fcdb78a136 398 VL53L0X_STRING_SEQUENCESTEP_MSRC);
mjarvisal 0:e6fcdb78a136 399 break;
mjarvisal 0:e6fcdb78a136 400 case VL53L0X_SEQUENCESTEP_PRE_RANGE:
mjarvisal 0:e6fcdb78a136 401 VL53L0X_COPYSTRING(pSequenceStepsString,
mjarvisal 0:e6fcdb78a136 402 VL53L0X_STRING_SEQUENCESTEP_PRE_RANGE);
mjarvisal 0:e6fcdb78a136 403 break;
mjarvisal 0:e6fcdb78a136 404 case VL53L0X_SEQUENCESTEP_FINAL_RANGE:
mjarvisal 0:e6fcdb78a136 405 VL53L0X_COPYSTRING(pSequenceStepsString,
mjarvisal 0:e6fcdb78a136 406 VL53L0X_STRING_SEQUENCESTEP_FINAL_RANGE);
mjarvisal 0:e6fcdb78a136 407 break;
mjarvisal 0:e6fcdb78a136 408
mjarvisal 0:e6fcdb78a136 409 default:
mjarvisal 0:e6fcdb78a136 410 Status = VL53L0X_ERROR_INVALID_PARAMS;
mjarvisal 0:e6fcdb78a136 411 }
mjarvisal 0:e6fcdb78a136 412
mjarvisal 0:e6fcdb78a136 413 LOG_FUNCTION_END(Status);
mjarvisal 0:e6fcdb78a136 414
mjarvisal 0:e6fcdb78a136 415 return Status;
mjarvisal 0:e6fcdb78a136 416 }
mjarvisal 0:e6fcdb78a136 417
mjarvisal 0:e6fcdb78a136 418
mjarvisal 0:e6fcdb78a136 419 VL53L0X_Error VL53L0X_get_limit_check_info(VL53L0X_DEV Dev, uint16_t LimitCheckId,
mjarvisal 0:e6fcdb78a136 420 char *pLimitCheckString)
mjarvisal 0:e6fcdb78a136 421 {
mjarvisal 0:e6fcdb78a136 422 VL53L0X_Error Status = VL53L0X_ERROR_NONE;
mjarvisal 0:e6fcdb78a136 423
mjarvisal 0:e6fcdb78a136 424 LOG_FUNCTION_START("");
mjarvisal 0:e6fcdb78a136 425
mjarvisal 0:e6fcdb78a136 426 switch (LimitCheckId) {
mjarvisal 0:e6fcdb78a136 427 case VL53L0X_CHECKENABLE_SIGMA_FINAL_RANGE:
mjarvisal 0:e6fcdb78a136 428 VL53L0X_COPYSTRING(pLimitCheckString,
mjarvisal 0:e6fcdb78a136 429 VL53L0X_STRING_CHECKENABLE_SIGMA_FINAL_RANGE);
mjarvisal 0:e6fcdb78a136 430 break;
mjarvisal 0:e6fcdb78a136 431 case VL53L0X_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE:
mjarvisal 0:e6fcdb78a136 432 VL53L0X_COPYSTRING(pLimitCheckString,
mjarvisal 0:e6fcdb78a136 433 VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE);
mjarvisal 0:e6fcdb78a136 434 break;
mjarvisal 0:e6fcdb78a136 435 case VL53L0X_CHECKENABLE_SIGNAL_REF_CLIP:
mjarvisal 0:e6fcdb78a136 436 VL53L0X_COPYSTRING(pLimitCheckString,
mjarvisal 0:e6fcdb78a136 437 VL53L0X_STRING_CHECKENABLE_SIGNAL_REF_CLIP);
mjarvisal 0:e6fcdb78a136 438 break;
mjarvisal 0:e6fcdb78a136 439 case VL53L0X_CHECKENABLE_RANGE_IGNORE_THRESHOLD:
mjarvisal 0:e6fcdb78a136 440 VL53L0X_COPYSTRING(pLimitCheckString,
mjarvisal 0:e6fcdb78a136 441 VL53L0X_STRING_CHECKENABLE_RANGE_IGNORE_THRESHOLD);
mjarvisal 0:e6fcdb78a136 442 break;
mjarvisal 0:e6fcdb78a136 443
mjarvisal 0:e6fcdb78a136 444 case VL53L0X_CHECKENABLE_SIGNAL_RATE_MSRC:
mjarvisal 0:e6fcdb78a136 445 VL53L0X_COPYSTRING(pLimitCheckString,
mjarvisal 0:e6fcdb78a136 446 VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_MSRC);
mjarvisal 0:e6fcdb78a136 447 break;
mjarvisal 0:e6fcdb78a136 448
mjarvisal 0:e6fcdb78a136 449 case VL53L0X_CHECKENABLE_SIGNAL_RATE_PRE_RANGE:
mjarvisal 0:e6fcdb78a136 450 VL53L0X_COPYSTRING(pLimitCheckString,
mjarvisal 0:e6fcdb78a136 451 VL53L0X_STRING_CHECKENABLE_SIGNAL_RATE_PRE_RANGE);
mjarvisal 0:e6fcdb78a136 452 break;
mjarvisal 0:e6fcdb78a136 453
mjarvisal 0:e6fcdb78a136 454 default:
mjarvisal 0:e6fcdb78a136 455 VL53L0X_COPYSTRING(pLimitCheckString,
mjarvisal 0:e6fcdb78a136 456 VL53L0X_STRING_UNKNOW_ERROR_CODE);
mjarvisal 0:e6fcdb78a136 457
mjarvisal 0:e6fcdb78a136 458 }
mjarvisal 0:e6fcdb78a136 459
mjarvisal 0:e6fcdb78a136 460 LOG_FUNCTION_END(Status);
mjarvisal 0:e6fcdb78a136 461 return Status;
mjarvisal 0:e6fcdb78a136 462 }