The VL53L1CB proximity sensor, based on ST’s FlightSense™, Time-of-Flight technology.

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   VL53L1CB_noshield_1sensor_polls_auton VL53L1CB_noshield_1sensor_interrupt_auton X_NUCLEO_53L1A2

Based on VL53L1 library, this is a library for the VL53L1CB ToF chip.

Committer:
lugandc
Date:
Wed Jul 21 17:06:38 2021 +0200
Revision:
18:0696efe39d08
Parent:
7:1add29d51e72
Cleanup i2c functions, removed all bad references to L1X
Cleanup VL53L1CB class:
- i2c device object is passed in a consistent way in MyDevice structure
- removed useless functions
Updated VL53L1CB component driver with bare driver release 6.6.7 content

Who changed what in which revision?

UserRevisionLine numberNew contents of line
charlesmn 0:3ac96e360672 1
Charles MacNeill 7:1add29d51e72 2 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
Charles MacNeill 7:1add29d51e72 3 /******************************************************************************
charlesmn 0:3ac96e360672 4 * Copyright (c) 2020, STMicroelectronics - All Rights Reserved
charlesmn 0:3ac96e360672 5
Charles MacNeill 7:1add29d51e72 6 This file is part of VL53L1 and is dual licensed,
Charles MacNeill 7:1add29d51e72 7 either GPL-2.0+
charlesmn 0:3ac96e360672 8 or 'BSD 3-clause "New" or "Revised" License' , at your option.
Charles MacNeill 7:1add29d51e72 9 ******************************************************************************
Charles MacNeill 7:1add29d51e72 10 */
charlesmn 0:3ac96e360672 11
charlesmn 0:3ac96e360672 12
charlesmn 0:3ac96e360672 13
charlesmn 0:3ac96e360672 14
charlesmn 0:3ac96e360672 15 #include "vl53l1_error_codes.h"
charlesmn 0:3ac96e360672 16 #include "vl53l1_error_strings.h"
charlesmn 0:3ac96e360672 17 #include "vl53l1_platform_log.h"
charlesmn 0:3ac96e360672 18 #include "vl53l1_ll_def.h"
charlesmn 0:3ac96e360672 19
charlesmn 0:3ac96e360672 20 #define LOG_FUNCTION_START(fmt, ...) \
charlesmn 0:3ac96e360672 21 _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
charlesmn 0:3ac96e360672 22 #define LOG_FUNCTION_END(status, ...) \
charlesmn 0:3ac96e360672 23 _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_API, status, ##__VA_ARGS__)
charlesmn 0:3ac96e360672 24 #define LOG_FUNCTION_END_FMT(status, fmt, ...) \
charlesmn 0:3ac96e360672 25 _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_API, \
charlesmn 0:3ac96e360672 26 status, fmt, ##__VA_ARGS__)
charlesmn 0:3ac96e360672 27
charlesmn 0:3ac96e360672 28
charlesmn 0:3ac96e360672 29 VL53L1_Error VL53L1_get_pal_error_string(
charlesmn 0:3ac96e360672 30 VL53L1_Error PalErrorCode,
charlesmn 0:3ac96e360672 31 char *pPalErrorString)
charlesmn 0:3ac96e360672 32 {
charlesmn 0:3ac96e360672 33 VL53L1_Error Status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 34
charlesmn 0:3ac96e360672 35 #ifdef VL53L1_USE_EMPTY_STRING
charlesmn 0:3ac96e360672 36 SUPPRESS_UNUSED_WARNING(PalErrorCode);
charlesmn 0:3ac96e360672 37 #endif
charlesmn 0:3ac96e360672 38
charlesmn 0:3ac96e360672 39 LOG_FUNCTION_START("");
charlesmn 0:3ac96e360672 40
charlesmn 0:3ac96e360672 41 #ifdef VL53L1_USE_EMPTY_STRING
charlesmn 0:3ac96e360672 42 VL53L1_COPYSTRING(pPalErrorString, "");
charlesmn 0:3ac96e360672 43 #else
charlesmn 0:3ac96e360672 44
charlesmn 0:3ac96e360672 45 switch (PalErrorCode) {
charlesmn 0:3ac96e360672 46 case VL53L1_ERROR_NONE:
charlesmn 0:3ac96e360672 47 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 48 VL53L1_STRING_ERROR_NONE);
charlesmn 0:3ac96e360672 49 break;
charlesmn 0:3ac96e360672 50 case VL53L1_ERROR_CALIBRATION_WARNING:
charlesmn 0:3ac96e360672 51 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 52 VL53L1_STRING_ERROR_CALIBRATION_WARNING);
charlesmn 0:3ac96e360672 53 break;
charlesmn 0:3ac96e360672 54 case VL53L1_ERROR_MIN_CLIPPED:
charlesmn 0:3ac96e360672 55 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 56 VL53L1_STRING_ERROR_MIN_CLIPPED);
charlesmn 0:3ac96e360672 57 break;
charlesmn 0:3ac96e360672 58 case VL53L1_ERROR_UNDEFINED:
charlesmn 0:3ac96e360672 59 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 60 VL53L1_STRING_ERROR_UNDEFINED);
charlesmn 0:3ac96e360672 61 break;
charlesmn 0:3ac96e360672 62 case VL53L1_ERROR_INVALID_PARAMS:
charlesmn 0:3ac96e360672 63 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 64 VL53L1_STRING_ERROR_INVALID_PARAMS);
charlesmn 0:3ac96e360672 65 break;
charlesmn 0:3ac96e360672 66 case VL53L1_ERROR_NOT_SUPPORTED:
charlesmn 0:3ac96e360672 67 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 68 VL53L1_STRING_ERROR_NOT_SUPPORTED);
charlesmn 0:3ac96e360672 69 break;
charlesmn 0:3ac96e360672 70 case VL53L1_ERROR_RANGE_ERROR:
charlesmn 0:3ac96e360672 71 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 72 VL53L1_STRING_ERROR_RANGE_ERROR);
charlesmn 0:3ac96e360672 73 break;
charlesmn 0:3ac96e360672 74 case VL53L1_ERROR_TIME_OUT:
charlesmn 0:3ac96e360672 75 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 76 VL53L1_STRING_ERROR_TIME_OUT);
charlesmn 0:3ac96e360672 77 break;
charlesmn 0:3ac96e360672 78 case VL53L1_ERROR_MODE_NOT_SUPPORTED:
charlesmn 0:3ac96e360672 79 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 80 VL53L1_STRING_ERROR_MODE_NOT_SUPPORTED);
charlesmn 0:3ac96e360672 81 break;
charlesmn 0:3ac96e360672 82 case VL53L1_ERROR_BUFFER_TOO_SMALL:
charlesmn 0:3ac96e360672 83 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 84 VL53L1_STRING_ERROR_BUFFER_TOO_SMALL);
charlesmn 0:3ac96e360672 85 break;
charlesmn 0:3ac96e360672 86 case VL53L1_ERROR_COMMS_BUFFER_TOO_SMALL:
charlesmn 0:3ac96e360672 87 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 88 VL53L1_STRING_ERROR_COMMS_BUFFER_TOO_SMALL);
charlesmn 0:3ac96e360672 89 break;
charlesmn 0:3ac96e360672 90 case VL53L1_ERROR_GPIO_NOT_EXISTING:
charlesmn 0:3ac96e360672 91 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 92 VL53L1_STRING_ERROR_GPIO_NOT_EXISTING);
charlesmn 0:3ac96e360672 93 break;
charlesmn 0:3ac96e360672 94 case VL53L1_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED:
charlesmn 0:3ac96e360672 95 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 96 VL53L1_STRING_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED);
charlesmn 0:3ac96e360672 97 break;
charlesmn 0:3ac96e360672 98 case VL53L1_ERROR_CONTROL_INTERFACE:
charlesmn 0:3ac96e360672 99 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 100 VL53L1_STRING_ERROR_CONTROL_INTERFACE);
charlesmn 0:3ac96e360672 101 break;
charlesmn 0:3ac96e360672 102 case VL53L1_ERROR_INVALID_COMMAND:
charlesmn 0:3ac96e360672 103 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 104 VL53L1_STRING_ERROR_INVALID_COMMAND);
charlesmn 0:3ac96e360672 105 break;
charlesmn 0:3ac96e360672 106 case VL53L1_ERROR_DIVISION_BY_ZERO:
charlesmn 0:3ac96e360672 107 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 108 VL53L1_STRING_ERROR_DIVISION_BY_ZERO);
charlesmn 0:3ac96e360672 109 break;
charlesmn 0:3ac96e360672 110 case VL53L1_ERROR_REF_SPAD_INIT:
charlesmn 0:3ac96e360672 111 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 112 VL53L1_STRING_ERROR_REF_SPAD_INIT);
charlesmn 0:3ac96e360672 113 break;
charlesmn 0:3ac96e360672 114 case VL53L1_ERROR_GPH_SYNC_CHECK_FAIL:
charlesmn 0:3ac96e360672 115 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 116 VL53L1_STRING_ERROR_GPH_SYNC_CHECK_FAIL);
charlesmn 0:3ac96e360672 117 break;
charlesmn 0:3ac96e360672 118 case VL53L1_ERROR_STREAM_COUNT_CHECK_FAIL:
charlesmn 0:3ac96e360672 119 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 120 VL53L1_STRING_ERROR_STREAM_COUNT_CHECK_FAIL);
charlesmn 0:3ac96e360672 121 break;
charlesmn 0:3ac96e360672 122 case VL53L1_ERROR_GPH_ID_CHECK_FAIL:
charlesmn 0:3ac96e360672 123 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 124 VL53L1_STRING_ERROR_GPH_ID_CHECK_FAIL);
charlesmn 0:3ac96e360672 125 break;
charlesmn 0:3ac96e360672 126 case VL53L1_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL:
charlesmn 0:3ac96e360672 127 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 128 VL53L1_STRING_ERROR_ZONE_STREAM_COUNT_CHECK_FAIL);
charlesmn 0:3ac96e360672 129 break;
charlesmn 0:3ac96e360672 130 case VL53L1_ERROR_ZONE_GPH_ID_CHECK_FAIL:
charlesmn 0:3ac96e360672 131 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 132 VL53L1_STRING_ERROR_ZONE_GPH_ID_CHECK_FAIL);
charlesmn 0:3ac96e360672 133 break;
charlesmn 0:3ac96e360672 134
charlesmn 0:3ac96e360672 135 case VL53L1_ERROR_XTALK_EXTRACTION_NO_SAMPLE_FAIL:
charlesmn 0:3ac96e360672 136 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 137 VL53L1_STRING_ERROR_XTALK_EXTRACTION_NO_SAMPLES_FAIL);
charlesmn 0:3ac96e360672 138 break;
charlesmn 0:3ac96e360672 139 case VL53L1_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL:
charlesmn 0:3ac96e360672 140 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 141 VL53L1_STRING_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL);
charlesmn 0:3ac96e360672 142 break;
charlesmn 0:3ac96e360672 143
charlesmn 0:3ac96e360672 144 case VL53L1_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL:
charlesmn 0:3ac96e360672 145 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 146 VL53L1_STRING_ERROR_OFFSET_CAL_NO_SAMPLE_FAIL);
charlesmn 0:3ac96e360672 147 break;
charlesmn 0:3ac96e360672 148 case VL53L1_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL:
charlesmn 0:3ac96e360672 149 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 150 VL53L1_STRING_ERROR_OFFSET_CAL_NO_SPADS_ENABLED_FAIL);
charlesmn 0:3ac96e360672 151 break;
charlesmn 0:3ac96e360672 152 case VL53L1_ERROR_ZONE_CAL_NO_SAMPLE_FAIL:
charlesmn 0:3ac96e360672 153 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 154 VL53L1_STRING_ERROR_ZONE_CAL_NO_SAMPLE_FAIL);
charlesmn 0:3ac96e360672 155 break;
charlesmn 0:3ac96e360672 156
charlesmn 0:3ac96e360672 157 case VL53L1_WARNING_OFFSET_CAL_MISSING_SAMPLES:
charlesmn 0:3ac96e360672 158 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 159 VL53L1_STRING_WARNING_OFFSET_CAL_MISSING_SAMPLES);
charlesmn 0:3ac96e360672 160 break;
charlesmn 0:3ac96e360672 161 case VL53L1_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH:
charlesmn 0:3ac96e360672 162 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 163 VL53L1_STRING_WARNING_OFFSET_CAL_SIGMA_TOO_HIGH);
charlesmn 0:3ac96e360672 164 break;
charlesmn 0:3ac96e360672 165 case VL53L1_WARNING_OFFSET_CAL_RATE_TOO_HIGH:
charlesmn 0:3ac96e360672 166 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 167 VL53L1_STRING_WARNING_OFFSET_CAL_RATE_TOO_HIGH);
charlesmn 0:3ac96e360672 168 break;
charlesmn 0:3ac96e360672 169 case VL53L1_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW:
charlesmn 0:3ac96e360672 170 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 171 VL53L1_STRING_WARNING_OFFSET_CAL_SPAD_COUNT_TOO_LOW);
charlesmn 0:3ac96e360672 172 break;
charlesmn 0:3ac96e360672 173
charlesmn 0:3ac96e360672 174 case VL53L1_WARNING_ZONE_CAL_MISSING_SAMPLES:
charlesmn 0:3ac96e360672 175 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 176 VL53L1_STRING_WARNING_ZONE_CAL_MISSING_SAMPLES);
charlesmn 0:3ac96e360672 177 break;
charlesmn 0:3ac96e360672 178 case VL53L1_WARNING_ZONE_CAL_SIGMA_TOO_HIGH:
charlesmn 0:3ac96e360672 179 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 180 VL53L1_STRING_WARNING_ZONE_CAL_SIGMA_TOO_HIGH);
charlesmn 0:3ac96e360672 181 break;
charlesmn 0:3ac96e360672 182 case VL53L1_WARNING_ZONE_CAL_RATE_TOO_HIGH:
charlesmn 0:3ac96e360672 183 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 184 VL53L1_STRING_WARNING_ZONE_CAL_RATE_TOO_HIGH);
charlesmn 0:3ac96e360672 185 break;
charlesmn 0:3ac96e360672 186
charlesmn 0:3ac96e360672 187 case VL53L1_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS:
charlesmn 0:3ac96e360672 188 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 189 VL53L1_STRING_WARNING_REF_SPAD_CHAR_NOT_ENOUGH_SPADS);
charlesmn 0:3ac96e360672 190 break;
charlesmn 0:3ac96e360672 191 case VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH:
charlesmn 0:3ac96e360672 192 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 193 VL53L1_STRING_WARNING_REF_SPAD_CHAR_RATE_TOO_HIGH);
charlesmn 0:3ac96e360672 194 break;
charlesmn 0:3ac96e360672 195 case VL53L1_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW:
charlesmn 0:3ac96e360672 196 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 197 VL53L1_STRING_WARNING_REF_SPAD_CHAR_RATE_TOO_LOW);
charlesmn 0:3ac96e360672 198 break;
charlesmn 0:3ac96e360672 199
charlesmn 0:3ac96e360672 200 case VL53L1_WARNING_XTALK_MISSING_SAMPLES:
charlesmn 0:3ac96e360672 201 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 202 VL53L1_STRING_WARNING_XTALK_MISSING_SAMPLES);
charlesmn 0:3ac96e360672 203 break;
charlesmn 0:3ac96e360672 204 case VL53L1_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT:
charlesmn 0:3ac96e360672 205 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 206 VL53L1_STRING_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT);
charlesmn 0:3ac96e360672 207 break;
charlesmn 0:3ac96e360672 208 case VL53L1_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT:
charlesmn 0:3ac96e360672 209 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 210 VL53L1_STRING_WARNING_XTALK_SIGMA_LIMIT_FOR_GRADIENT);
charlesmn 0:3ac96e360672 211 break;
charlesmn 0:3ac96e360672 212
charlesmn 0:3ac96e360672 213 case VL53L1_ERROR_DEVICE_FIRMWARE_TOO_OLD:
charlesmn 0:3ac96e360672 214 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 215 VL53L1_STRING_ERROR_DEVICE_FIRMWARE_TOO_OLD);
charlesmn 0:3ac96e360672 216 break;
charlesmn 0:3ac96e360672 217 case VL53L1_ERROR_DEVICE_FIRMWARE_TOO_NEW:
charlesmn 0:3ac96e360672 218 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 219 VL53L1_STRING_ERROR_DEVICE_FIRMWARE_TOO_NEW);
charlesmn 0:3ac96e360672 220 break;
charlesmn 0:3ac96e360672 221 case VL53L1_ERROR_UNIT_TEST_FAIL:
charlesmn 0:3ac96e360672 222 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 223 VL53L1_STRING_ERROR_UNIT_TEST_FAIL);
charlesmn 0:3ac96e360672 224 break;
charlesmn 0:3ac96e360672 225 case VL53L1_ERROR_FILE_READ_FAIL:
charlesmn 0:3ac96e360672 226 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 227 VL53L1_STRING_ERROR_FILE_READ_FAIL);
charlesmn 0:3ac96e360672 228 break;
charlesmn 0:3ac96e360672 229 case VL53L1_ERROR_FILE_WRITE_FAIL:
charlesmn 0:3ac96e360672 230 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 231 VL53L1_STRING_ERROR_FILE_WRITE_FAIL);
charlesmn 0:3ac96e360672 232 break;
charlesmn 0:3ac96e360672 233 case VL53L1_ERROR_NOT_IMPLEMENTED:
charlesmn 0:3ac96e360672 234 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 235 VL53L1_STRING_ERROR_NOT_IMPLEMENTED);
charlesmn 0:3ac96e360672 236 break;
charlesmn 0:3ac96e360672 237 default:
charlesmn 0:3ac96e360672 238 VL53L1_COPYSTRING(pPalErrorString,
charlesmn 0:3ac96e360672 239 VL53L1_STRING_UNKNOW_ERROR_CODE);
charlesmn 0:3ac96e360672 240 }
charlesmn 0:3ac96e360672 241
charlesmn 0:3ac96e360672 242 #endif
charlesmn 0:3ac96e360672 243
charlesmn 0:3ac96e360672 244 LOG_FUNCTION_END(Status);
charlesmn 0:3ac96e360672 245
charlesmn 0:3ac96e360672 246 return Status;
charlesmn 0:3ac96e360672 247 }
charlesmn 0:3ac96e360672 248