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:
Charles MacNeill
Date:
Tue Jun 08 10:34:47 2021 +0100
Revision:
7:1add29d51e72
Parent:
0:3ac96e360672
Update to v6.6.5 of bare_driver

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
charlesmn 0:3ac96e360672 16
charlesmn 0:3ac96e360672 17 #include "vl53l1_api_core.h"
charlesmn 0:3ac96e360672 18 #include "vl53l1_api_strings.h"
charlesmn 0:3ac96e360672 19 #include "vl53l1_error_codes.h"
charlesmn 0:3ac96e360672 20 #include "vl53l1_error_strings.h"
charlesmn 0:3ac96e360672 21
charlesmn 0:3ac96e360672 22 #define LOG_FUNCTION_START(fmt, ...) \
charlesmn 0:3ac96e360672 23 _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
charlesmn 0:3ac96e360672 24 #define LOG_FUNCTION_END(status, ...) \
charlesmn 0:3ac96e360672 25 _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_API, status, ##__VA_ARGS__)
charlesmn 0:3ac96e360672 26 #define LOG_FUNCTION_END_FMT(status, fmt, ...) \
charlesmn 0:3ac96e360672 27 _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_API, status, fmt, \
charlesmn 0:3ac96e360672 28 ##__VA_ARGS__)
charlesmn 0:3ac96e360672 29
charlesmn 0:3ac96e360672 30
charlesmn 0:3ac96e360672 31 VL53L1_Error VL53L1_get_range_status_string(
charlesmn 0:3ac96e360672 32 uint8_t RangeStatus,
charlesmn 0:3ac96e360672 33 char *pRangeStatusString)
charlesmn 0:3ac96e360672 34 {
charlesmn 0:3ac96e360672 35 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 36
charlesmn 0:3ac96e360672 37 LOG_FUNCTION_START("");
charlesmn 0:3ac96e360672 38
charlesmn 0:3ac96e360672 39 #ifdef VL53L1_USE_EMPTY_STRING
charlesmn 0:3ac96e360672 40 SUPPRESS_UNUSED_WARNING(RangeStatus);
charlesmn 0:3ac96e360672 41 VL53L1_COPYSTRING(pRangeStatusString, "");
charlesmn 0:3ac96e360672 42 #else
charlesmn 0:3ac96e360672 43 switch (RangeStatus) {
charlesmn 0:3ac96e360672 44 case 0:
charlesmn 0:3ac96e360672 45 VL53L1_COPYSTRING(pRangeStatusString,
charlesmn 0:3ac96e360672 46 VL53L1_STRING_RANGESTATUS_RANGEVALID);
charlesmn 0:3ac96e360672 47 break;
charlesmn 0:3ac96e360672 48 case 1:
charlesmn 0:3ac96e360672 49 VL53L1_COPYSTRING(pRangeStatusString,
charlesmn 0:3ac96e360672 50 VL53L1_STRING_RANGESTATUS_SIGMA);
charlesmn 0:3ac96e360672 51 break;
charlesmn 0:3ac96e360672 52 case 2:
charlesmn 0:3ac96e360672 53 VL53L1_COPYSTRING(pRangeStatusString,
charlesmn 0:3ac96e360672 54 VL53L1_STRING_RANGESTATUS_SIGNAL);
charlesmn 0:3ac96e360672 55 break;
charlesmn 0:3ac96e360672 56 case 3:
charlesmn 0:3ac96e360672 57 VL53L1_COPYSTRING(pRangeStatusString,
charlesmn 0:3ac96e360672 58 VL53L1_STRING_RANGESTATUS_MINRANGE);
charlesmn 0:3ac96e360672 59 break;
charlesmn 0:3ac96e360672 60 case 4:
charlesmn 0:3ac96e360672 61 VL53L1_COPYSTRING(pRangeStatusString,
charlesmn 0:3ac96e360672 62 VL53L1_STRING_RANGESTATUS_PHASE);
charlesmn 0:3ac96e360672 63 break;
charlesmn 0:3ac96e360672 64 case 5:
charlesmn 0:3ac96e360672 65 VL53L1_COPYSTRING(pRangeStatusString,
charlesmn 0:3ac96e360672 66 VL53L1_STRING_RANGESTATUS_HW);
charlesmn 0:3ac96e360672 67 break;
charlesmn 0:3ac96e360672 68
charlesmn 0:3ac96e360672 69 default:
charlesmn 0:3ac96e360672 70 VL53L1_COPYSTRING(pRangeStatusString,
charlesmn 0:3ac96e360672 71 VL53L1_STRING_RANGESTATUS_NONE);
charlesmn 0:3ac96e360672 72 }
charlesmn 0:3ac96e360672 73 #endif
charlesmn 0:3ac96e360672 74
charlesmn 0:3ac96e360672 75 LOG_FUNCTION_END(status);
charlesmn 0:3ac96e360672 76 return status;
charlesmn 0:3ac96e360672 77 }
charlesmn 0:3ac96e360672 78
charlesmn 0:3ac96e360672 79
charlesmn 0:3ac96e360672 80 VL53L1_Error VL53L1_get_pal_state_string(
charlesmn 0:3ac96e360672 81 VL53L1_State PalStateCode,
charlesmn 0:3ac96e360672 82 char *pPalStateString)
charlesmn 0:3ac96e360672 83 {
charlesmn 0:3ac96e360672 84 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 85
charlesmn 0:3ac96e360672 86 LOG_FUNCTION_START("");
charlesmn 0:3ac96e360672 87
charlesmn 0:3ac96e360672 88 #ifdef VL53L1_USE_EMPTY_STRING
charlesmn 0:3ac96e360672 89 SUPPRESS_UNUSED_WARNING(PalStateCode);
charlesmn 0:3ac96e360672 90 VL53L1_COPYSTRING(pPalStateString, "");
charlesmn 0:3ac96e360672 91 #else
charlesmn 0:3ac96e360672 92 switch (PalStateCode) {
charlesmn 0:3ac96e360672 93 case VL53L1_STATE_POWERDOWN:
charlesmn 0:3ac96e360672 94 VL53L1_COPYSTRING(pPalStateString,
charlesmn 0:3ac96e360672 95 VL53L1_STRING_STATE_POWERDOWN);
charlesmn 0:3ac96e360672 96 break;
charlesmn 0:3ac96e360672 97 case VL53L1_STATE_WAIT_STATICINIT:
charlesmn 0:3ac96e360672 98 VL53L1_COPYSTRING(pPalStateString,
charlesmn 0:3ac96e360672 99 VL53L1_STRING_STATE_WAIT_STATICINIT);
charlesmn 0:3ac96e360672 100 break;
charlesmn 0:3ac96e360672 101 case VL53L1_STATE_STANDBY:
charlesmn 0:3ac96e360672 102 VL53L1_COPYSTRING(pPalStateString,
charlesmn 0:3ac96e360672 103 VL53L1_STRING_STATE_STANDBY);
charlesmn 0:3ac96e360672 104 break;
charlesmn 0:3ac96e360672 105 case VL53L1_STATE_IDLE:
charlesmn 0:3ac96e360672 106 VL53L1_COPYSTRING(pPalStateString,
charlesmn 0:3ac96e360672 107 VL53L1_STRING_STATE_IDLE);
charlesmn 0:3ac96e360672 108 break;
charlesmn 0:3ac96e360672 109 case VL53L1_STATE_RUNNING:
charlesmn 0:3ac96e360672 110 VL53L1_COPYSTRING(pPalStateString,
charlesmn 0:3ac96e360672 111 VL53L1_STRING_STATE_RUNNING);
charlesmn 0:3ac96e360672 112 break;
charlesmn 0:3ac96e360672 113 case VL53L1_STATE_RESET:
charlesmn 0:3ac96e360672 114 VL53L1_COPYSTRING(pPalStateString,
charlesmn 0:3ac96e360672 115 VL53L1_STRING_STATE_RESET);
charlesmn 0:3ac96e360672 116 break;
charlesmn 0:3ac96e360672 117 case VL53L1_STATE_UNKNOWN:
charlesmn 0:3ac96e360672 118 VL53L1_COPYSTRING(pPalStateString,
charlesmn 0:3ac96e360672 119 VL53L1_STRING_STATE_UNKNOWN);
charlesmn 0:3ac96e360672 120 break;
charlesmn 0:3ac96e360672 121 case VL53L1_STATE_ERROR:
charlesmn 0:3ac96e360672 122 VL53L1_COPYSTRING(pPalStateString,
charlesmn 0:3ac96e360672 123 VL53L1_STRING_STATE_ERROR);
charlesmn 0:3ac96e360672 124 break;
charlesmn 0:3ac96e360672 125
charlesmn 0:3ac96e360672 126 default:
charlesmn 0:3ac96e360672 127 VL53L1_COPYSTRING(pPalStateString,
charlesmn 0:3ac96e360672 128 VL53L1_STRING_STATE_UNKNOWN);
charlesmn 0:3ac96e360672 129 }
charlesmn 0:3ac96e360672 130 #endif
charlesmn 0:3ac96e360672 131
charlesmn 0:3ac96e360672 132 LOG_FUNCTION_END(status);
charlesmn 0:3ac96e360672 133 return status;
charlesmn 0:3ac96e360672 134 }
charlesmn 0:3ac96e360672 135
charlesmn 0:3ac96e360672 136 VL53L1_Error VL53L1_get_sequence_steps_info(
charlesmn 0:3ac96e360672 137 VL53L1_SequenceStepId SequenceStepId,
charlesmn 0:3ac96e360672 138 char *pSequenceStepsString)
charlesmn 0:3ac96e360672 139 {
charlesmn 0:3ac96e360672 140 VL53L1_Error Status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 141
charlesmn 0:3ac96e360672 142 LOG_FUNCTION_START("");
charlesmn 0:3ac96e360672 143
charlesmn 0:3ac96e360672 144 #ifdef VL53L1_USE_EMPTY_STRING
charlesmn 0:3ac96e360672 145 SUPPRESS_UNUSED_WARNING(SequenceStepId);
charlesmn 0:3ac96e360672 146 VL53L1_COPYSTRING(pSequenceStepsString, "");
charlesmn 0:3ac96e360672 147 #else
charlesmn 0:3ac96e360672 148 switch (SequenceStepId) {
charlesmn 0:3ac96e360672 149 case VL53L1_SEQUENCESTEP_VHV:
charlesmn 0:3ac96e360672 150 VL53L1_COPYSTRING(pSequenceStepsString,
charlesmn 0:3ac96e360672 151 VL53L1_STRING_SEQUENCESTEP_VHV);
charlesmn 0:3ac96e360672 152 break;
charlesmn 0:3ac96e360672 153 case VL53L1_SEQUENCESTEP_PHASECAL:
charlesmn 0:3ac96e360672 154 VL53L1_COPYSTRING(pSequenceStepsString,
charlesmn 0:3ac96e360672 155 VL53L1_STRING_SEQUENCESTEP_PHASECAL);
charlesmn 0:3ac96e360672 156 break;
charlesmn 0:3ac96e360672 157 case VL53L1_SEQUENCESTEP_REFPHASE:
charlesmn 0:3ac96e360672 158 VL53L1_COPYSTRING(pSequenceStepsString,
charlesmn 0:3ac96e360672 159 VL53L1_STRING_SEQUENCESTEP_DSS1);
charlesmn 0:3ac96e360672 160 break;
charlesmn 0:3ac96e360672 161 case VL53L1_SEQUENCESTEP_DSS1:
charlesmn 0:3ac96e360672 162 VL53L1_COPYSTRING(pSequenceStepsString,
charlesmn 0:3ac96e360672 163 VL53L1_STRING_SEQUENCESTEP_DSS1);
charlesmn 0:3ac96e360672 164 break;
charlesmn 0:3ac96e360672 165 case VL53L1_SEQUENCESTEP_DSS2:
charlesmn 0:3ac96e360672 166 VL53L1_COPYSTRING(pSequenceStepsString,
charlesmn 0:3ac96e360672 167 VL53L1_STRING_SEQUENCESTEP_DSS2);
charlesmn 0:3ac96e360672 168 break;
charlesmn 0:3ac96e360672 169 case VL53L1_SEQUENCESTEP_MM1:
charlesmn 0:3ac96e360672 170 VL53L1_COPYSTRING(pSequenceStepsString,
charlesmn 0:3ac96e360672 171 VL53L1_STRING_SEQUENCESTEP_MM1);
charlesmn 0:3ac96e360672 172 break;
charlesmn 0:3ac96e360672 173 case VL53L1_SEQUENCESTEP_MM2:
charlesmn 0:3ac96e360672 174 VL53L1_COPYSTRING(pSequenceStepsString,
charlesmn 0:3ac96e360672 175 VL53L1_STRING_SEQUENCESTEP_MM2);
charlesmn 0:3ac96e360672 176 break;
charlesmn 0:3ac96e360672 177 case VL53L1_SEQUENCESTEP_RANGE:
charlesmn 0:3ac96e360672 178 VL53L1_COPYSTRING(pSequenceStepsString,
charlesmn 0:3ac96e360672 179 VL53L1_STRING_SEQUENCESTEP_RANGE);
charlesmn 0:3ac96e360672 180 break;
charlesmn 0:3ac96e360672 181 default:
charlesmn 0:3ac96e360672 182 Status = VL53L1_ERROR_INVALID_PARAMS;
charlesmn 0:3ac96e360672 183 }
charlesmn 0:3ac96e360672 184 #endif
charlesmn 0:3ac96e360672 185
charlesmn 0:3ac96e360672 186 LOG_FUNCTION_END(Status);
charlesmn 0:3ac96e360672 187
charlesmn 0:3ac96e360672 188 return Status;
charlesmn 0:3ac96e360672 189 }
charlesmn 0:3ac96e360672 190
charlesmn 0:3ac96e360672 191 VL53L1_Error VL53L1_get_limit_check_info(uint16_t LimitCheckId,
charlesmn 0:3ac96e360672 192 char *pLimitCheckString)
charlesmn 0:3ac96e360672 193 {
charlesmn 0:3ac96e360672 194 VL53L1_Error Status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 195
charlesmn 0:3ac96e360672 196 LOG_FUNCTION_START("");
charlesmn 0:3ac96e360672 197
charlesmn 0:3ac96e360672 198 #ifdef VL53L1_USE_EMPTY_STRING
charlesmn 0:3ac96e360672 199 SUPPRESS_UNUSED_WARNING(LimitCheckId);
charlesmn 0:3ac96e360672 200 VL53L1_COPYSTRING(pLimitCheckString, "");
charlesmn 0:3ac96e360672 201 #else
charlesmn 0:3ac96e360672 202 switch (LimitCheckId) {
charlesmn 0:3ac96e360672 203 case VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE:
charlesmn 0:3ac96e360672 204 VL53L1_COPYSTRING(pLimitCheckString,
charlesmn 0:3ac96e360672 205 VL53L1_STRING_CHECKENABLE_SIGMA_FINAL_RANGE);
charlesmn 0:3ac96e360672 206 break;
charlesmn 0:3ac96e360672 207 case VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE:
charlesmn 0:3ac96e360672 208 VL53L1_COPYSTRING(pLimitCheckString,
charlesmn 0:3ac96e360672 209 VL53L1_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE);
charlesmn 0:3ac96e360672 210 break;
charlesmn 0:3ac96e360672 211 default:
charlesmn 0:3ac96e360672 212 VL53L1_COPYSTRING(pLimitCheckString,
charlesmn 0:3ac96e360672 213 VL53L1_STRING_UNKNOW_ERROR_CODE);
charlesmn 0:3ac96e360672 214 }
charlesmn 0:3ac96e360672 215 #endif
charlesmn 0:3ac96e360672 216
charlesmn 0:3ac96e360672 217 LOG_FUNCTION_END(Status);
charlesmn 0:3ac96e360672 218 return Status;
charlesmn 0:3ac96e360672 219 }
charlesmn 0:3ac96e360672 220
charlesmn 0:3ac96e360672 221