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:
charlesmn
Date:
Fri Nov 06 10:06:37 2020 +0000
Revision:
0:3ac96e360672
Child:
7:1add29d51e72
Library for ST Vl53L1A1 time of flight sensor.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
charlesmn 0:3ac96e360672 1
charlesmn 0:3ac96e360672 2 /*******************************************************************************
charlesmn 0:3ac96e360672 3 * Copyright (c) 2020, STMicroelectronics - All Rights Reserved
charlesmn 0:3ac96e360672 4
charlesmn 0:3ac96e360672 5 This file is part of VL53L1 Core and is dual licensed,
charlesmn 0:3ac96e360672 6 either 'STMicroelectronics
charlesmn 0:3ac96e360672 7 Proprietary license'
charlesmn 0:3ac96e360672 8 or 'BSD 3-clause "New" or "Revised" License' , at your option.
charlesmn 0:3ac96e360672 9
charlesmn 0:3ac96e360672 10 ********************************************************************************
charlesmn 0:3ac96e360672 11
charlesmn 0:3ac96e360672 12 'STMicroelectronics Proprietary license'
charlesmn 0:3ac96e360672 13
charlesmn 0:3ac96e360672 14 ********************************************************************************
charlesmn 0:3ac96e360672 15
charlesmn 0:3ac96e360672 16 License terms: STMicroelectronics Proprietary in accordance with licensing
charlesmn 0:3ac96e360672 17 terms at www.st.com/sla0081
charlesmn 0:3ac96e360672 18
charlesmn 0:3ac96e360672 19 STMicroelectronics confidential
charlesmn 0:3ac96e360672 20 Reproduction and Communication of this document is strictly prohibited unless
charlesmn 0:3ac96e360672 21 specifically authorized in writing by STMicroelectronics.
charlesmn 0:3ac96e360672 22
charlesmn 0:3ac96e360672 23
charlesmn 0:3ac96e360672 24 ********************************************************************************
charlesmn 0:3ac96e360672 25
charlesmn 0:3ac96e360672 26 Alternatively, VL53L1 Core may be distributed under the terms of
charlesmn 0:3ac96e360672 27 'BSD 3-clause "New" or "Revised" License', in which case the following
charlesmn 0:3ac96e360672 28 provisions apply instead of the ones
charlesmn 0:3ac96e360672 29 mentioned above :
charlesmn 0:3ac96e360672 30
charlesmn 0:3ac96e360672 31 ********************************************************************************
charlesmn 0:3ac96e360672 32
charlesmn 0:3ac96e360672 33 License terms: BSD 3-clause "New" or "Revised" License.
charlesmn 0:3ac96e360672 34
charlesmn 0:3ac96e360672 35 Redistribution and use in source and binary forms, with or without
charlesmn 0:3ac96e360672 36 modification, are permitted provided that the following conditions are met:
charlesmn 0:3ac96e360672 37
charlesmn 0:3ac96e360672 38 1. Redistributions of source code must retain the above copyright notice, this
charlesmn 0:3ac96e360672 39 list of conditions and the following disclaimer.
charlesmn 0:3ac96e360672 40
charlesmn 0:3ac96e360672 41 2. Redistributions in binary form must reproduce the above copyright notice,
charlesmn 0:3ac96e360672 42 this list of conditions and the following disclaimer in the documentation
charlesmn 0:3ac96e360672 43 and/or other materials provided with the distribution.
charlesmn 0:3ac96e360672 44
charlesmn 0:3ac96e360672 45 3. Neither the name of the copyright holder nor the names of its contributors
charlesmn 0:3ac96e360672 46 may be used to endorse or promote products derived from this software
charlesmn 0:3ac96e360672 47 without specific prior written permission.
charlesmn 0:3ac96e360672 48
charlesmn 0:3ac96e360672 49 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
charlesmn 0:3ac96e360672 50 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
charlesmn 0:3ac96e360672 51 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
charlesmn 0:3ac96e360672 52 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
charlesmn 0:3ac96e360672 53 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
charlesmn 0:3ac96e360672 54 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
charlesmn 0:3ac96e360672 55 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
charlesmn 0:3ac96e360672 56 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
charlesmn 0:3ac96e360672 57 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
charlesmn 0:3ac96e360672 58 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
charlesmn 0:3ac96e360672 59
charlesmn 0:3ac96e360672 60
charlesmn 0:3ac96e360672 61 ********************************************************************************
charlesmn 0:3ac96e360672 62
charlesmn 0:3ac96e360672 63 */
charlesmn 0:3ac96e360672 64
charlesmn 0:3ac96e360672 65
charlesmn 0:3ac96e360672 66
charlesmn 0:3ac96e360672 67
charlesmn 0:3ac96e360672 68
charlesmn 0:3ac96e360672 69 #ifdef _MSC_VER
charlesmn 0:3ac96e360672 70 #define snprintf _snprintf
charlesmn 0:3ac96e360672 71 #endif
charlesmn 0:3ac96e360672 72
charlesmn 0:3ac96e360672 73
charlesmn 0:3ac96e360672 74
charlesmn 0:3ac96e360672 75 #include "vl53l1_ll_def.h"
charlesmn 0:3ac96e360672 76 #include "vl53l1_platform.h"
charlesmn 0:3ac96e360672 77 #include "vl53l1_platform_log.h"
charlesmn 0:3ac96e360672 78 #include "vl53l1_register_map.h"
charlesmn 0:3ac96e360672 79 #include "vl53l1_core.h"
charlesmn 0:3ac96e360672 80 #include "vl53l1_nvm_structs.h"
charlesmn 0:3ac96e360672 81 #include "vl53l1_nvm_map.h"
charlesmn 0:3ac96e360672 82 #include "vl53l1_nvm.h"
charlesmn 0:3ac96e360672 83
charlesmn 0:3ac96e360672 84
charlesmn 0:3ac96e360672 85
charlesmn 0:3ac96e360672 86 #define LOG_FUNCTION_START(fmt, ...) \
charlesmn 0:3ac96e360672 87 _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_NVM, fmt, ##__VA_ARGS__)
charlesmn 0:3ac96e360672 88 #define LOG_FUNCTION_END(status, ...) \
charlesmn 0:3ac96e360672 89 _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_NVM, status, ##__VA_ARGS__)
charlesmn 0:3ac96e360672 90 #define LOG_FUNCTION_END_FMT(status, fmt, ...) \
charlesmn 0:3ac96e360672 91 _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_NVM,\
charlesmn 0:3ac96e360672 92 status, fmt, ##__VA_ARGS__)
charlesmn 0:3ac96e360672 93
charlesmn 0:3ac96e360672 94 #define trace_print(level, ...) \
charlesmn 0:3ac96e360672 95 _LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_NVM, \
charlesmn 0:3ac96e360672 96 level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
charlesmn 0:3ac96e360672 97
charlesmn 0:3ac96e360672 98
charlesmn 0:3ac96e360672 99 VL53L1_Error VL53L1_nvm_enable(
charlesmn 0:3ac96e360672 100 VL53L1_DEV Dev,
charlesmn 0:3ac96e360672 101 uint16_t nvm_ctrl_pulse_width,
charlesmn 0:3ac96e360672 102 int32_t nvm_power_up_delay_us)
charlesmn 0:3ac96e360672 103 {
charlesmn 0:3ac96e360672 104
charlesmn 0:3ac96e360672 105
charlesmn 0:3ac96e360672 106 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 107
charlesmn 0:3ac96e360672 108 LOG_FUNCTION_START("");
charlesmn 0:3ac96e360672 109
charlesmn 0:3ac96e360672 110
charlesmn 0:3ac96e360672 111
charlesmn 0:3ac96e360672 112
charlesmn 0:3ac96e360672 113 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 114 status = VL53L1_disable_firmware(Dev);
charlesmn 0:3ac96e360672 115
charlesmn 0:3ac96e360672 116
charlesmn 0:3ac96e360672 117
charlesmn 0:3ac96e360672 118
charlesmn 0:3ac96e360672 119 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 120 status = VL53L1_enable_powerforce(Dev);
charlesmn 0:3ac96e360672 121
charlesmn 0:3ac96e360672 122
charlesmn 0:3ac96e360672 123
charlesmn 0:3ac96e360672 124 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 125 status = VL53L1_WaitUs(
charlesmn 0:3ac96e360672 126 Dev,
charlesmn 0:3ac96e360672 127 VL53L1_ENABLE_POWERFORCE_SETTLING_TIME_US);
charlesmn 0:3ac96e360672 128
charlesmn 0:3ac96e360672 129
charlesmn 0:3ac96e360672 130
charlesmn 0:3ac96e360672 131 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 132 status = VL53L1_WrByte(
charlesmn 0:3ac96e360672 133 Dev,
charlesmn 0:3ac96e360672 134 VL53L1_RANGING_CORE__NVM_CTRL__PDN,
charlesmn 0:3ac96e360672 135 0x01);
charlesmn 0:3ac96e360672 136
charlesmn 0:3ac96e360672 137
charlesmn 0:3ac96e360672 138
charlesmn 0:3ac96e360672 139 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 140 status = VL53L1_WrByte(
charlesmn 0:3ac96e360672 141 Dev,
charlesmn 0:3ac96e360672 142 VL53L1_RANGING_CORE__CLK_CTRL1,
charlesmn 0:3ac96e360672 143 0x05);
charlesmn 0:3ac96e360672 144
charlesmn 0:3ac96e360672 145
charlesmn 0:3ac96e360672 146
charlesmn 0:3ac96e360672 147 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 148 status = VL53L1_WaitUs(
charlesmn 0:3ac96e360672 149 Dev,
charlesmn 0:3ac96e360672 150 nvm_power_up_delay_us);
charlesmn 0:3ac96e360672 151
charlesmn 0:3ac96e360672 152
charlesmn 0:3ac96e360672 153
charlesmn 0:3ac96e360672 154 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 155 status = VL53L1_WrByte(
charlesmn 0:3ac96e360672 156 Dev,
charlesmn 0:3ac96e360672 157 VL53L1_RANGING_CORE__NVM_CTRL__MODE,
charlesmn 0:3ac96e360672 158 0x01);
charlesmn 0:3ac96e360672 159
charlesmn 0:3ac96e360672 160 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 161 status = VL53L1_WrWord(
charlesmn 0:3ac96e360672 162 Dev,
charlesmn 0:3ac96e360672 163 VL53L1_RANGING_CORE__NVM_CTRL__PULSE_WIDTH_MSB,
charlesmn 0:3ac96e360672 164 nvm_ctrl_pulse_width);
charlesmn 0:3ac96e360672 165
charlesmn 0:3ac96e360672 166 LOG_FUNCTION_END(status);
charlesmn 0:3ac96e360672 167
charlesmn 0:3ac96e360672 168 return status;
charlesmn 0:3ac96e360672 169
charlesmn 0:3ac96e360672 170 }
charlesmn 0:3ac96e360672 171
charlesmn 0:3ac96e360672 172
charlesmn 0:3ac96e360672 173 VL53L1_Error VL53L1_nvm_read(
charlesmn 0:3ac96e360672 174 VL53L1_DEV Dev,
charlesmn 0:3ac96e360672 175 uint8_t start_address,
charlesmn 0:3ac96e360672 176 uint8_t count,
charlesmn 0:3ac96e360672 177 uint8_t *pdata)
charlesmn 0:3ac96e360672 178 {
charlesmn 0:3ac96e360672 179
charlesmn 0:3ac96e360672 180
charlesmn 0:3ac96e360672 181 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 182 uint8_t nvm_addr = 0;
charlesmn 0:3ac96e360672 183
charlesmn 0:3ac96e360672 184 LOG_FUNCTION_START("");
charlesmn 0:3ac96e360672 185
charlesmn 0:3ac96e360672 186 trace_print(
charlesmn 0:3ac96e360672 187 VL53L1_TRACE_LEVEL_INFO,
charlesmn 0:3ac96e360672 188 "%-12s = 0x%02X (%3u)\n",
charlesmn 0:3ac96e360672 189 "nvm_addr", nvm_addr, nvm_addr);
charlesmn 0:3ac96e360672 190
charlesmn 0:3ac96e360672 191 trace_print(
charlesmn 0:3ac96e360672 192 VL53L1_TRACE_LEVEL_INFO,
charlesmn 0:3ac96e360672 193 "%-12s = 0x%02X (%3u)\n",
charlesmn 0:3ac96e360672 194 "count", count, count);
charlesmn 0:3ac96e360672 195
charlesmn 0:3ac96e360672 196 for (nvm_addr = start_address;
charlesmn 0:3ac96e360672 197 nvm_addr < (start_address+count) ; nvm_addr++) {
charlesmn 0:3ac96e360672 198
charlesmn 0:3ac96e360672 199
charlesmn 0:3ac96e360672 200
charlesmn 0:3ac96e360672 201 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 202 status = VL53L1_WrByte(
charlesmn 0:3ac96e360672 203 Dev,
charlesmn 0:3ac96e360672 204 VL53L1_RANGING_CORE__NVM_CTRL__ADDR,
charlesmn 0:3ac96e360672 205 nvm_addr);
charlesmn 0:3ac96e360672 206
charlesmn 0:3ac96e360672 207
charlesmn 0:3ac96e360672 208
charlesmn 0:3ac96e360672 209 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 210 status = VL53L1_WrByte(
charlesmn 0:3ac96e360672 211 Dev,
charlesmn 0:3ac96e360672 212 VL53L1_RANGING_CORE__NVM_CTRL__READN,
charlesmn 0:3ac96e360672 213 0x00);
charlesmn 0:3ac96e360672 214
charlesmn 0:3ac96e360672 215
charlesmn 0:3ac96e360672 216
charlesmn 0:3ac96e360672 217 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 218 status = VL53L1_WaitUs(
charlesmn 0:3ac96e360672 219 Dev,
charlesmn 0:3ac96e360672 220 VL53L1_NVM_READ_TRIGGER_DELAY_US);
charlesmn 0:3ac96e360672 221
charlesmn 0:3ac96e360672 222 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 223 status = VL53L1_WrByte(
charlesmn 0:3ac96e360672 224 Dev,
charlesmn 0:3ac96e360672 225 VL53L1_RANGING_CORE__NVM_CTRL__READN,
charlesmn 0:3ac96e360672 226 0x01);
charlesmn 0:3ac96e360672 227
charlesmn 0:3ac96e360672 228
charlesmn 0:3ac96e360672 229 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 230 status = VL53L1_ReadMulti(
charlesmn 0:3ac96e360672 231 Dev,
charlesmn 0:3ac96e360672 232 VL53L1_RANGING_CORE__NVM_CTRL__DATAOUT_MMM,
charlesmn 0:3ac96e360672 233 pdata,
charlesmn 0:3ac96e360672 234 4);
charlesmn 0:3ac96e360672 235
charlesmn 0:3ac96e360672 236 trace_print(
charlesmn 0:3ac96e360672 237 VL53L1_TRACE_LEVEL_INFO,
charlesmn 0:3ac96e360672 238 "NVM address : 0x%02X = 0x%02X%02X%02X%02X\n",
charlesmn 0:3ac96e360672 239 nvm_addr, *pdata, *(pdata+1), *(pdata+2), *(pdata+3));
charlesmn 0:3ac96e360672 240
charlesmn 0:3ac96e360672 241
charlesmn 0:3ac96e360672 242
charlesmn 0:3ac96e360672 243 pdata = pdata + 4;
charlesmn 0:3ac96e360672 244
charlesmn 0:3ac96e360672 245
charlesmn 0:3ac96e360672 246 }
charlesmn 0:3ac96e360672 247
charlesmn 0:3ac96e360672 248 LOG_FUNCTION_END(status);
charlesmn 0:3ac96e360672 249
charlesmn 0:3ac96e360672 250 return status;
charlesmn 0:3ac96e360672 251 }
charlesmn 0:3ac96e360672 252
charlesmn 0:3ac96e360672 253
charlesmn 0:3ac96e360672 254 VL53L1_Error VL53L1_nvm_disable(
charlesmn 0:3ac96e360672 255 VL53L1_DEV Dev)
charlesmn 0:3ac96e360672 256 {
charlesmn 0:3ac96e360672 257
charlesmn 0:3ac96e360672 258
charlesmn 0:3ac96e360672 259 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 260
charlesmn 0:3ac96e360672 261 LOG_FUNCTION_START("");
charlesmn 0:3ac96e360672 262
charlesmn 0:3ac96e360672 263 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 264 status = VL53L1_WrByte(
charlesmn 0:3ac96e360672 265 Dev,
charlesmn 0:3ac96e360672 266 VL53L1_RANGING_CORE__NVM_CTRL__READN,
charlesmn 0:3ac96e360672 267 0x01);
charlesmn 0:3ac96e360672 268
charlesmn 0:3ac96e360672 269
charlesmn 0:3ac96e360672 270
charlesmn 0:3ac96e360672 271 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 272 status = VL53L1_WrByte(
charlesmn 0:3ac96e360672 273 Dev,
charlesmn 0:3ac96e360672 274 VL53L1_RANGING_CORE__NVM_CTRL__PDN,
charlesmn 0:3ac96e360672 275 0x00);
charlesmn 0:3ac96e360672 276
charlesmn 0:3ac96e360672 277
charlesmn 0:3ac96e360672 278
charlesmn 0:3ac96e360672 279 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 280 status = VL53L1_disable_powerforce(Dev);
charlesmn 0:3ac96e360672 281
charlesmn 0:3ac96e360672 282
charlesmn 0:3ac96e360672 283
charlesmn 0:3ac96e360672 284 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 285 status = VL53L1_enable_firmware(Dev);
charlesmn 0:3ac96e360672 286
charlesmn 0:3ac96e360672 287 LOG_FUNCTION_END(status);
charlesmn 0:3ac96e360672 288
charlesmn 0:3ac96e360672 289 return status;
charlesmn 0:3ac96e360672 290
charlesmn 0:3ac96e360672 291 }
charlesmn 0:3ac96e360672 292
charlesmn 0:3ac96e360672 293
charlesmn 0:3ac96e360672 294 VL53L1_Error VL53L1_nvm_format_decode(
charlesmn 0:3ac96e360672 295 uint16_t buf_size,
charlesmn 0:3ac96e360672 296 uint8_t *pbuffer,
charlesmn 0:3ac96e360672 297 VL53L1_decoded_nvm_data_t *pdata)
charlesmn 0:3ac96e360672 298 {
charlesmn 0:3ac96e360672 299
charlesmn 0:3ac96e360672 300
charlesmn 0:3ac96e360672 301
charlesmn 0:3ac96e360672 302 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 303
charlesmn 0:3ac96e360672 304 uint8_t i = 0;
charlesmn 0:3ac96e360672 305 uint8_t *ptmp = NULL;
charlesmn 0:3ac96e360672 306 int pptmp[VL53L1_NVM_MAX_FMT_RANGE_DATA];
charlesmn 0:3ac96e360672 307
charlesmn 0:3ac96e360672 308 LOG_FUNCTION_START("");
charlesmn 0:3ac96e360672 309
charlesmn 0:3ac96e360672 310 if (buf_size < VL53L1_NVM_SIZE_IN_BYTES)
charlesmn 0:3ac96e360672 311 return VL53L1_ERROR_BUFFER_TOO_SMALL;
charlesmn 0:3ac96e360672 312
charlesmn 0:3ac96e360672 313 pdata->nvm__identification_model_id =
charlesmn 0:3ac96e360672 314 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 315 1,
charlesmn 0:3ac96e360672 316 pbuffer + VL53L1_NVM__IDENTIFICATION__MODEL_ID,
charlesmn 0:3ac96e360672 317 0x000000FF,
charlesmn 0:3ac96e360672 318 0,
charlesmn 0:3ac96e360672 319 0);
charlesmn 0:3ac96e360672 320 pdata->nvm__identification_module_type =
charlesmn 0:3ac96e360672 321 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 322 1,
charlesmn 0:3ac96e360672 323 pbuffer + VL53L1_NVM__IDENTIFICATION__MODULE_TYPE,
charlesmn 0:3ac96e360672 324 0x000000FF,
charlesmn 0:3ac96e360672 325 0,
charlesmn 0:3ac96e360672 326 0);
charlesmn 0:3ac96e360672 327 pdata->nvm__identification_revision_id =
charlesmn 0:3ac96e360672 328 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 329 1,
charlesmn 0:3ac96e360672 330 pbuffer + VL53L1_NVM__IDENTIFICATION__REVISION_ID,
charlesmn 0:3ac96e360672 331 0x0000000F,
charlesmn 0:3ac96e360672 332 0,
charlesmn 0:3ac96e360672 333 0);
charlesmn 0:3ac96e360672 334 pdata->nvm__identification_module_id =
charlesmn 0:3ac96e360672 335 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 336 2,
charlesmn 0:3ac96e360672 337 pbuffer + VL53L1_NVM__IDENTIFICATION__MODULE_ID,
charlesmn 0:3ac96e360672 338 0x0000FFFF,
charlesmn 0:3ac96e360672 339 0,
charlesmn 0:3ac96e360672 340 0);
charlesmn 0:3ac96e360672 341 pdata->nvm__i2c_valid =
charlesmn 0:3ac96e360672 342 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 343 1,
charlesmn 0:3ac96e360672 344 pbuffer + VL53L1_NVM__I2C_VALID,
charlesmn 0:3ac96e360672 345 0x000000FF,
charlesmn 0:3ac96e360672 346 0,
charlesmn 0:3ac96e360672 347 0);
charlesmn 0:3ac96e360672 348 pdata->nvm__i2c_device_address_ews =
charlesmn 0:3ac96e360672 349 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 350 1,
charlesmn 0:3ac96e360672 351 pbuffer + VL53L1_NVM__I2C_SLAVE__DEVICE_ADDRESS,
charlesmn 0:3ac96e360672 352 0x000000FF,
charlesmn 0:3ac96e360672 353 0,
charlesmn 0:3ac96e360672 354 0);
charlesmn 0:3ac96e360672 355 pdata->nvm__ews__fast_osc_frequency =
charlesmn 0:3ac96e360672 356 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 357 2,
charlesmn 0:3ac96e360672 358 pbuffer +
charlesmn 0:3ac96e360672 359 VL53L1_NVM__EWS__OSC_MEASURED__FAST_OSC_FREQUENCY,
charlesmn 0:3ac96e360672 360 0x0000FFFF,
charlesmn 0:3ac96e360672 361 0,
charlesmn 0:3ac96e360672 362 0);
charlesmn 0:3ac96e360672 363 pdata->nvm__ews__fast_osc_trim_max =
charlesmn 0:3ac96e360672 364 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 365 1,
charlesmn 0:3ac96e360672 366 pbuffer + VL53L1_NVM__EWS__FAST_OSC_TRIM_MAX,
charlesmn 0:3ac96e360672 367 0x0000007F,
charlesmn 0:3ac96e360672 368 0,
charlesmn 0:3ac96e360672 369 0);
charlesmn 0:3ac96e360672 370 pdata->nvm__ews__fast_osc_freq_set =
charlesmn 0:3ac96e360672 371 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 372 1,
charlesmn 0:3ac96e360672 373 pbuffer + VL53L1_NVM__EWS__FAST_OSC_FREQ_SET,
charlesmn 0:3ac96e360672 374 0x00000007,
charlesmn 0:3ac96e360672 375 0,
charlesmn 0:3ac96e360672 376 0);
charlesmn 0:3ac96e360672 377 pdata->nvm__ews__slow_osc_calibration =
charlesmn 0:3ac96e360672 378 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 379 2,
charlesmn 0:3ac96e360672 380 pbuffer + VL53L1_NVM__EWS__SLOW_OSC_CALIBRATION,
charlesmn 0:3ac96e360672 381 0x000003FF,
charlesmn 0:3ac96e360672 382 0,
charlesmn 0:3ac96e360672 383 0);
charlesmn 0:3ac96e360672 384 pdata->nvm__fmt__fast_osc_frequency =
charlesmn 0:3ac96e360672 385 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 386 2,
charlesmn 0:3ac96e360672 387 pbuffer +
charlesmn 0:3ac96e360672 388 VL53L1_NVM__FMT__OSC_MEASURED__FAST_OSC_FREQUENCY,
charlesmn 0:3ac96e360672 389 0x0000FFFF,
charlesmn 0:3ac96e360672 390 0,
charlesmn 0:3ac96e360672 391 0);
charlesmn 0:3ac96e360672 392 pdata->nvm__fmt__fast_osc_trim_max =
charlesmn 0:3ac96e360672 393 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 394 1,
charlesmn 0:3ac96e360672 395 pbuffer + VL53L1_NVM__FMT__FAST_OSC_TRIM_MAX,
charlesmn 0:3ac96e360672 396 0x0000007F,
charlesmn 0:3ac96e360672 397 0,
charlesmn 0:3ac96e360672 398 0);
charlesmn 0:3ac96e360672 399 pdata->nvm__fmt__fast_osc_freq_set =
charlesmn 0:3ac96e360672 400 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 401 1,
charlesmn 0:3ac96e360672 402 pbuffer + VL53L1_NVM__FMT__FAST_OSC_FREQ_SET,
charlesmn 0:3ac96e360672 403 0x00000007,
charlesmn 0:3ac96e360672 404 0,
charlesmn 0:3ac96e360672 405 0);
charlesmn 0:3ac96e360672 406 pdata->nvm__fmt__slow_osc_calibration =
charlesmn 0:3ac96e360672 407 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 408 2,
charlesmn 0:3ac96e360672 409 pbuffer + VL53L1_NVM__FMT__SLOW_OSC_CALIBRATION,
charlesmn 0:3ac96e360672 410 0x000003FF,
charlesmn 0:3ac96e360672 411 0,
charlesmn 0:3ac96e360672 412 0);
charlesmn 0:3ac96e360672 413 pdata->nvm__vhv_config_unlock =
charlesmn 0:3ac96e360672 414 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 415 1,
charlesmn 0:3ac96e360672 416 pbuffer + VL53L1_NVM__VHV_CONFIG_UNLOCK,
charlesmn 0:3ac96e360672 417 0x000000FF,
charlesmn 0:3ac96e360672 418 0,
charlesmn 0:3ac96e360672 419 0);
charlesmn 0:3ac96e360672 420 pdata->nvm__ref_selvddpix =
charlesmn 0:3ac96e360672 421 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 422 1,
charlesmn 0:3ac96e360672 423 pbuffer + VL53L1_NVM__REF_SELVDDPIX,
charlesmn 0:3ac96e360672 424 0x0000000F,
charlesmn 0:3ac96e360672 425 0,
charlesmn 0:3ac96e360672 426 0);
charlesmn 0:3ac96e360672 427 pdata->nvm__ref_selvquench =
charlesmn 0:3ac96e360672 428 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 429 1,
charlesmn 0:3ac96e360672 430 pbuffer + VL53L1_NVM__REF_SELVQUENCH,
charlesmn 0:3ac96e360672 431 0x00000078,
charlesmn 0:3ac96e360672 432 3,
charlesmn 0:3ac96e360672 433 0);
charlesmn 0:3ac96e360672 434 pdata->nvm__regavdd1v2_sel =
charlesmn 0:3ac96e360672 435 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 436 1,
charlesmn 0:3ac96e360672 437 pbuffer + VL53L1_NVM__REGAVDD1V2_SEL_REGDVDD1V2_SEL,
charlesmn 0:3ac96e360672 438 0x0000000C,
charlesmn 0:3ac96e360672 439 2,
charlesmn 0:3ac96e360672 440 0);
charlesmn 0:3ac96e360672 441 pdata->nvm__regdvdd1v2_sel =
charlesmn 0:3ac96e360672 442 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 443 1,
charlesmn 0:3ac96e360672 444 pbuffer + VL53L1_NVM__REGAVDD1V2_SEL_REGDVDD1V2_SEL,
charlesmn 0:3ac96e360672 445 0x00000003,
charlesmn 0:3ac96e360672 446 0,
charlesmn 0:3ac96e360672 447 0);
charlesmn 0:3ac96e360672 448 pdata->nvm__vhv_timeout__macrop =
charlesmn 0:3ac96e360672 449 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 450 1,
charlesmn 0:3ac96e360672 451 pbuffer +
charlesmn 0:3ac96e360672 452 VL53L1_NVM__VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND,
charlesmn 0:3ac96e360672 453 0x00000003,
charlesmn 0:3ac96e360672 454 0,
charlesmn 0:3ac96e360672 455 0);
charlesmn 0:3ac96e360672 456 pdata->nvm__vhv_loop_bound =
charlesmn 0:3ac96e360672 457 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 458 1,
charlesmn 0:3ac96e360672 459 pbuffer +
charlesmn 0:3ac96e360672 460 VL53L1_NVM__VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND,
charlesmn 0:3ac96e360672 461 0x000000FC,
charlesmn 0:3ac96e360672 462 2,
charlesmn 0:3ac96e360672 463 0);
charlesmn 0:3ac96e360672 464 pdata->nvm__vhv_count_threshold =
charlesmn 0:3ac96e360672 465 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 466 1,
charlesmn 0:3ac96e360672 467 pbuffer + VL53L1_NVM__VHV_CONFIG__COUNT_THRESH,
charlesmn 0:3ac96e360672 468 0x000000FF,
charlesmn 0:3ac96e360672 469 0,
charlesmn 0:3ac96e360672 470 0);
charlesmn 0:3ac96e360672 471 pdata->nvm__vhv_offset =
charlesmn 0:3ac96e360672 472 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 473 1,
charlesmn 0:3ac96e360672 474 pbuffer + VL53L1_NVM__VHV_CONFIG__OFFSET,
charlesmn 0:3ac96e360672 475 0x0000003F,
charlesmn 0:3ac96e360672 476 0,
charlesmn 0:3ac96e360672 477 0);
charlesmn 0:3ac96e360672 478 pdata->nvm__vhv_init_enable =
charlesmn 0:3ac96e360672 479 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 480 1,
charlesmn 0:3ac96e360672 481 pbuffer + VL53L1_NVM__VHV_CONFIG__INIT,
charlesmn 0:3ac96e360672 482 0x00000080,
charlesmn 0:3ac96e360672 483 7,
charlesmn 0:3ac96e360672 484 0);
charlesmn 0:3ac96e360672 485 pdata->nvm__vhv_init_value =
charlesmn 0:3ac96e360672 486 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 487 1,
charlesmn 0:3ac96e360672 488 pbuffer + VL53L1_NVM__VHV_CONFIG__INIT,
charlesmn 0:3ac96e360672 489 0x0000003F,
charlesmn 0:3ac96e360672 490 0,
charlesmn 0:3ac96e360672 491 0);
charlesmn 0:3ac96e360672 492 pdata->nvm__laser_safety_vcsel_trim_ll =
charlesmn 0:3ac96e360672 493 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 494 1,
charlesmn 0:3ac96e360672 495 pbuffer + VL53L1_NVM__LASER_SAFETY__VCSEL_TRIM_LL,
charlesmn 0:3ac96e360672 496 0x00000007,
charlesmn 0:3ac96e360672 497 0,
charlesmn 0:3ac96e360672 498 0);
charlesmn 0:3ac96e360672 499 pdata->nvm__laser_safety_vcsel_selion_ll =
charlesmn 0:3ac96e360672 500 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 501 1,
charlesmn 0:3ac96e360672 502 pbuffer + VL53L1_NVM__LASER_SAFETY__VCSEL_SELION_LL,
charlesmn 0:3ac96e360672 503 0x0000003F,
charlesmn 0:3ac96e360672 504 0,
charlesmn 0:3ac96e360672 505 0);
charlesmn 0:3ac96e360672 506 pdata->nvm__laser_safety_vcsel_selion_max_ll =
charlesmn 0:3ac96e360672 507 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 508 1,
charlesmn 0:3ac96e360672 509 pbuffer + VL53L1_NVM__LASER_SAFETY__VCSEL_SELION_MAX_LL,
charlesmn 0:3ac96e360672 510 0x0000003F,
charlesmn 0:3ac96e360672 511 0,
charlesmn 0:3ac96e360672 512 0);
charlesmn 0:3ac96e360672 513 pdata->nvm__laser_safety_mult_ll =
charlesmn 0:3ac96e360672 514 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 515 1,
charlesmn 0:3ac96e360672 516 pbuffer + VL53L1_NVM__LASER_SAFETY__MULT_LL,
charlesmn 0:3ac96e360672 517 0x0000003F,
charlesmn 0:3ac96e360672 518 0,
charlesmn 0:3ac96e360672 519 0);
charlesmn 0:3ac96e360672 520 pdata->nvm__laser_safety_clip_ll =
charlesmn 0:3ac96e360672 521 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 522 1,
charlesmn 0:3ac96e360672 523 pbuffer + VL53L1_NVM__LASER_SAFETY__CLIP_LL,
charlesmn 0:3ac96e360672 524 0x0000003F,
charlesmn 0:3ac96e360672 525 0,
charlesmn 0:3ac96e360672 526 0);
charlesmn 0:3ac96e360672 527 pdata->nvm__laser_safety_vcsel_trim_ld =
charlesmn 0:3ac96e360672 528 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 529 1,
charlesmn 0:3ac96e360672 530 pbuffer + VL53L1_NVM__LASER_SAFETY__VCSEL_TRIM_LD,
charlesmn 0:3ac96e360672 531 0x00000007,
charlesmn 0:3ac96e360672 532 0,
charlesmn 0:3ac96e360672 533 0);
charlesmn 0:3ac96e360672 534 pdata->nvm__laser_safety_vcsel_selion_ld =
charlesmn 0:3ac96e360672 535 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 536 1,
charlesmn 0:3ac96e360672 537 pbuffer + VL53L1_NVM__LASER_SAFETY__VCSEL_SELION_LD,
charlesmn 0:3ac96e360672 538 0x0000003F,
charlesmn 0:3ac96e360672 539 0,
charlesmn 0:3ac96e360672 540 0);
charlesmn 0:3ac96e360672 541 pdata->nvm__laser_safety_vcsel_selion_max_ld =
charlesmn 0:3ac96e360672 542 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 543 1,
charlesmn 0:3ac96e360672 544 pbuffer + VL53L1_NVM__LASER_SAFETY__VCSEL_SELION_MAX_LD,
charlesmn 0:3ac96e360672 545 0x0000003F,
charlesmn 0:3ac96e360672 546 0,
charlesmn 0:3ac96e360672 547 0);
charlesmn 0:3ac96e360672 548 pdata->nvm__laser_safety_mult_ld =
charlesmn 0:3ac96e360672 549 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 550 1,
charlesmn 0:3ac96e360672 551 pbuffer + VL53L1_NVM__LASER_SAFETY__MULT_LD,
charlesmn 0:3ac96e360672 552 0x0000003F,
charlesmn 0:3ac96e360672 553 0,
charlesmn 0:3ac96e360672 554 0);
charlesmn 0:3ac96e360672 555 pdata->nvm__laser_safety_clip_ld =
charlesmn 0:3ac96e360672 556 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 557 1,
charlesmn 0:3ac96e360672 558 pbuffer + VL53L1_NVM__LASER_SAFETY__CLIP_LD,
charlesmn 0:3ac96e360672 559 0x0000003F,
charlesmn 0:3ac96e360672 560 0,
charlesmn 0:3ac96e360672 561 0);
charlesmn 0:3ac96e360672 562 pdata->nvm__laser_safety_lock_byte =
charlesmn 0:3ac96e360672 563 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 564 1,
charlesmn 0:3ac96e360672 565 pbuffer + VL53L1_NVM__LASER_SAFETY_LOCK_BYTE,
charlesmn 0:3ac96e360672 566 0x000000FF,
charlesmn 0:3ac96e360672 567 0,
charlesmn 0:3ac96e360672 568 0);
charlesmn 0:3ac96e360672 569 pdata->nvm__laser_safety_unlock_byte =
charlesmn 0:3ac96e360672 570 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 571 1,
charlesmn 0:3ac96e360672 572 pbuffer + VL53L1_NVM__LASER_SAFETY_UNLOCK_BYTE,
charlesmn 0:3ac96e360672 573 0x000000FF,
charlesmn 0:3ac96e360672 574 0,
charlesmn 0:3ac96e360672 575 0);
charlesmn 0:3ac96e360672 576
charlesmn 0:3ac96e360672 577
charlesmn 0:3ac96e360672 578
charlesmn 0:3ac96e360672 579 ptmp = pbuffer + VL53L1_NVM__EWS__SPAD_ENABLES_RTN_0_;
charlesmn 0:3ac96e360672 580 for (i = 0 ; i < VL53L1_RTN_SPAD_BUFFER_SIZE ; i++)
charlesmn 0:3ac96e360672 581 pdata->nvm__ews__spad_enables_rtn[i] = *ptmp++;
charlesmn 0:3ac96e360672 582
charlesmn 0:3ac96e360672 583 ptmp = pbuffer + VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC1_0_;
charlesmn 0:3ac96e360672 584 for (i = 0 ; i < VL53L1_REF_SPAD_BUFFER_SIZE ; i++)
charlesmn 0:3ac96e360672 585 pdata->nvm__ews__spad_enables_ref__loc1[i] = *ptmp++;
charlesmn 0:3ac96e360672 586
charlesmn 0:3ac96e360672 587 ptmp = pbuffer + VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC2_0_;
charlesmn 0:3ac96e360672 588 for (i = 0 ; i < VL53L1_REF_SPAD_BUFFER_SIZE ; i++)
charlesmn 0:3ac96e360672 589 pdata->nvm__ews__spad_enables_ref__loc2[i] = *ptmp++;
charlesmn 0:3ac96e360672 590
charlesmn 0:3ac96e360672 591 ptmp = pbuffer + VL53L1_NVM__EWS__SPAD_ENABLES_REF__LOC3_0_;
charlesmn 0:3ac96e360672 592 for (i = 0 ; i < VL53L1_REF_SPAD_BUFFER_SIZE ; i++)
charlesmn 0:3ac96e360672 593 pdata->nvm__ews__spad_enables_ref__loc3[i] = *ptmp++;
charlesmn 0:3ac96e360672 594
charlesmn 0:3ac96e360672 595
charlesmn 0:3ac96e360672 596
charlesmn 0:3ac96e360672 597 ptmp = pbuffer + VL53L1_NVM__FMT__SPAD_ENABLES_RTN_0_;
charlesmn 0:3ac96e360672 598 for (i = 0 ; i < VL53L1_RTN_SPAD_BUFFER_SIZE ; i++)
charlesmn 0:3ac96e360672 599 pdata->nvm__fmt__spad_enables_rtn[i] = *ptmp++;
charlesmn 0:3ac96e360672 600
charlesmn 0:3ac96e360672 601 ptmp = pbuffer + VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC1_0_;
charlesmn 0:3ac96e360672 602 for (i = 0 ; i < VL53L1_REF_SPAD_BUFFER_SIZE ; i++)
charlesmn 0:3ac96e360672 603 pdata->nvm__fmt__spad_enables_ref__loc1[i] = *ptmp++;
charlesmn 0:3ac96e360672 604
charlesmn 0:3ac96e360672 605 ptmp = pbuffer + VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC2_0_;
charlesmn 0:3ac96e360672 606 for (i = 0 ; i < VL53L1_REF_SPAD_BUFFER_SIZE ; i++)
charlesmn 0:3ac96e360672 607 pdata->nvm__fmt__spad_enables_ref__loc2[i] = *ptmp++;
charlesmn 0:3ac96e360672 608
charlesmn 0:3ac96e360672 609 ptmp = pbuffer + VL53L1_NVM__FMT__SPAD_ENABLES_REF__LOC3_0_;
charlesmn 0:3ac96e360672 610 for (i = 0 ; i < VL53L1_REF_SPAD_BUFFER_SIZE ; i++)
charlesmn 0:3ac96e360672 611 pdata->nvm__fmt__spad_enables_ref__loc3[i] = *ptmp++;
charlesmn 0:3ac96e360672 612
charlesmn 0:3ac96e360672 613
charlesmn 0:3ac96e360672 614 pdata->nvm__fmt__roi_config__mode_roi_centre_spad =
charlesmn 0:3ac96e360672 615 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 616 1,
charlesmn 0:3ac96e360672 617 pbuffer +
charlesmn 0:3ac96e360672 618 VL53L1_NVM__FMT__ROI_CONFIG__MODE_ROI_CENTRE_SPAD,
charlesmn 0:3ac96e360672 619 0x000000FF,
charlesmn 0:3ac96e360672 620 0,
charlesmn 0:3ac96e360672 621 0);
charlesmn 0:3ac96e360672 622 pdata->nvm__fmt__roi_config__mode_roi_x_size =
charlesmn 0:3ac96e360672 623 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 624 1,
charlesmn 0:3ac96e360672 625 pbuffer +
charlesmn 0:3ac96e360672 626 VL53L1_NVM__FMT__ROI_CONFIG__MODE_ROI_XY_SIZE,
charlesmn 0:3ac96e360672 627 0x000000F0,
charlesmn 0:3ac96e360672 628 4,
charlesmn 0:3ac96e360672 629 0);
charlesmn 0:3ac96e360672 630 pdata->nvm__fmt__roi_config__mode_roi_y_size =
charlesmn 0:3ac96e360672 631 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 632 1,
charlesmn 0:3ac96e360672 633 pbuffer + VL53L1_NVM__FMT__ROI_CONFIG__MODE_ROI_XY_SIZE,
charlesmn 0:3ac96e360672 634 0x0000000F,
charlesmn 0:3ac96e360672 635 0,
charlesmn 0:3ac96e360672 636 0);
charlesmn 0:3ac96e360672 637 pdata->nvm__fmt__ref_spad_apply__num_requested_ref_spad =
charlesmn 0:3ac96e360672 638 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 639 1,
charlesmn 0:3ac96e360672 640 pbuffer +
charlesmn 0:3ac96e360672 641 VL53L1_NVM__FMT__REF_SPAD_APPLY__NUM_REQUESTED_REF_SPAD,
charlesmn 0:3ac96e360672 642 0x000000FF,
charlesmn 0:3ac96e360672 643 0,
charlesmn 0:3ac96e360672 644 0);
charlesmn 0:3ac96e360672 645 pdata->nvm__fmt__ref_spad_man__ref_location =
charlesmn 0:3ac96e360672 646 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 647 1,
charlesmn 0:3ac96e360672 648 pbuffer + VL53L1_NVM__FMT__REF_SPAD_MAN__REF_LOCATION,
charlesmn 0:3ac96e360672 649 0x00000003,
charlesmn 0:3ac96e360672 650 0,
charlesmn 0:3ac96e360672 651 0);
charlesmn 0:3ac96e360672 652 pdata->nvm__fmt__mm_config__inner_offset_mm =
charlesmn 0:3ac96e360672 653 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 654 2,
charlesmn 0:3ac96e360672 655 pbuffer + VL53L1_NVM__FMT__MM_CONFIG__INNER_OFFSET_MM,
charlesmn 0:3ac96e360672 656 0x0000FFFF,
charlesmn 0:3ac96e360672 657 0,
charlesmn 0:3ac96e360672 658 0);
charlesmn 0:3ac96e360672 659 pdata->nvm__fmt__mm_config__outer_offset_mm =
charlesmn 0:3ac96e360672 660 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 661 2,
charlesmn 0:3ac96e360672 662 pbuffer + VL53L1_NVM__FMT__MM_CONFIG__OUTER_OFFSET_MM,
charlesmn 0:3ac96e360672 663 0x0000FFFF,
charlesmn 0:3ac96e360672 664 0,
charlesmn 0:3ac96e360672 665 0);
charlesmn 0:3ac96e360672 666 pdata->nvm__fmt__algo_part_to_part_range_offset_mm =
charlesmn 0:3ac96e360672 667 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 668 2,
charlesmn 0:3ac96e360672 669 pbuffer +
charlesmn 0:3ac96e360672 670 VL53L1_NVM__FMT__ALGO__PART_TO_PART_RANGE_OFFSET_MM,
charlesmn 0:3ac96e360672 671 0x00000FFF,
charlesmn 0:3ac96e360672 672 0,
charlesmn 0:3ac96e360672 673 0);
charlesmn 0:3ac96e360672 674 pdata->nvm__fmt__algo__crosstalk_compensation_plane_offset_kcps =
charlesmn 0:3ac96e360672 675 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 676 2,
charlesmn 0:3ac96e360672 677 pbuffer +
charlesmn 0:3ac96e360672 678 VL53L1_NVM__FMT__ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS,
charlesmn 0:3ac96e360672 679 0x0000FFFF,
charlesmn 0:3ac96e360672 680 0,
charlesmn 0:3ac96e360672 681 0);
charlesmn 0:3ac96e360672 682 pdata->nvm__fmt__algo__crosstalk_compensation_x_plane_gradient_kcps =
charlesmn 0:3ac96e360672 683 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 684 2,
charlesmn 0:3ac96e360672 685 pbuffer +
charlesmn 0:3ac96e360672 686 VL53L1_NVM__FMT__ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS,
charlesmn 0:3ac96e360672 687 0x0000FFFF,
charlesmn 0:3ac96e360672 688 0,
charlesmn 0:3ac96e360672 689 0);
charlesmn 0:3ac96e360672 690 pdata->nvm__fmt__algo__crosstalk_compensation_y_plane_gradient_kcps =
charlesmn 0:3ac96e360672 691 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 692 2,
charlesmn 0:3ac96e360672 693 pbuffer +
charlesmn 0:3ac96e360672 694 VL53L1_NVM__FMT__ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS,
charlesmn 0:3ac96e360672 695 0x0000FFFF,
charlesmn 0:3ac96e360672 696 0,
charlesmn 0:3ac96e360672 697 0);
charlesmn 0:3ac96e360672 698 pdata->nvm__fmt__spare__host_config__nvm_config_spare_0 =
charlesmn 0:3ac96e360672 699 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 700 1,
charlesmn 0:3ac96e360672 701 pbuffer +
charlesmn 0:3ac96e360672 702 VL53L1_NVM__FMT__SPARE_HOST_CONFIG__NVM_CONFIG_SPARE_0,
charlesmn 0:3ac96e360672 703 0x000000FF,
charlesmn 0:3ac96e360672 704 0,
charlesmn 0:3ac96e360672 705 0);
charlesmn 0:3ac96e360672 706 pdata->nvm__fmt__spare__host_config__nvm_config_spare_1 =
charlesmn 0:3ac96e360672 707 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 708 1,
charlesmn 0:3ac96e360672 709 pbuffer +
charlesmn 0:3ac96e360672 710 VL53L1_NVM__FMT__SPARE_HOST_CONFIG__NVM_CONFIG_SPARE_1,
charlesmn 0:3ac96e360672 711 0x000000FF,
charlesmn 0:3ac96e360672 712 0,
charlesmn 0:3ac96e360672 713 0);
charlesmn 0:3ac96e360672 714 pdata->nvm__customer_space_programmed =
charlesmn 0:3ac96e360672 715 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 716 1,
charlesmn 0:3ac96e360672 717 pbuffer + VL53L1_NVM__CUSTOMER_NVM_SPACE_PROGRAMMED,
charlesmn 0:3ac96e360672 718 0x000000FF,
charlesmn 0:3ac96e360672 719 0,
charlesmn 0:3ac96e360672 720 0);
charlesmn 0:3ac96e360672 721 pdata->nvm__cust__i2c_device_address =
charlesmn 0:3ac96e360672 722 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 723 1,
charlesmn 0:3ac96e360672 724 pbuffer + VL53L1_NVM__CUST__I2C_SLAVE__DEVICE_ADDRESS,
charlesmn 0:3ac96e360672 725 0x000000FF,
charlesmn 0:3ac96e360672 726 0,
charlesmn 0:3ac96e360672 727 0);
charlesmn 0:3ac96e360672 728 pdata->nvm__cust__ref_spad_apply__num_requested_ref_spad =
charlesmn 0:3ac96e360672 729 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 730 1,
charlesmn 0:3ac96e360672 731 pbuffer +
charlesmn 0:3ac96e360672 732 VL53L1_NVM__CUST__REF_SPAD_APPLY__NUM_REQUESTED_REF_SPAD,
charlesmn 0:3ac96e360672 733 0x000000FF,
charlesmn 0:3ac96e360672 734 0,
charlesmn 0:3ac96e360672 735 0);
charlesmn 0:3ac96e360672 736 pdata->nvm__cust__ref_spad_man__ref_location =
charlesmn 0:3ac96e360672 737 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 738 1,
charlesmn 0:3ac96e360672 739 pbuffer + VL53L1_NVM__CUST__REF_SPAD_MAN__REF_LOCATION,
charlesmn 0:3ac96e360672 740 0x00000003,
charlesmn 0:3ac96e360672 741 0,
charlesmn 0:3ac96e360672 742 0);
charlesmn 0:3ac96e360672 743 pdata->nvm__cust__mm_config__inner_offset_mm =
charlesmn 0:3ac96e360672 744 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 745 2,
charlesmn 0:3ac96e360672 746 pbuffer + VL53L1_NVM__CUST__MM_CONFIG__INNER_OFFSET_MM,
charlesmn 0:3ac96e360672 747 0x0000FFFF,
charlesmn 0:3ac96e360672 748 0,
charlesmn 0:3ac96e360672 749 0);
charlesmn 0:3ac96e360672 750 pdata->nvm__cust__mm_config__outer_offset_mm =
charlesmn 0:3ac96e360672 751 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 752 2,
charlesmn 0:3ac96e360672 753 pbuffer + VL53L1_NVM__CUST__MM_CONFIG__OUTER_OFFSET_MM,
charlesmn 0:3ac96e360672 754 0x0000FFFF,
charlesmn 0:3ac96e360672 755 0,
charlesmn 0:3ac96e360672 756 0);
charlesmn 0:3ac96e360672 757 pdata->nvm__cust__algo_part_to_part_range_offset_mm =
charlesmn 0:3ac96e360672 758 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 759 2,
charlesmn 0:3ac96e360672 760 pbuffer +
charlesmn 0:3ac96e360672 761 VL53L1_NVM__CUST__ALGO__PART_TO_PART_RANGE_OFFSET_MM,
charlesmn 0:3ac96e360672 762 0x00000FFF,
charlesmn 0:3ac96e360672 763 0,
charlesmn 0:3ac96e360672 764 0);
charlesmn 0:3ac96e360672 765 pdata->nvm__cust__algo__crosstalk_compensation_plane_offset_kcps =
charlesmn 0:3ac96e360672 766 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 767 2,
charlesmn 0:3ac96e360672 768 pbuffer +
charlesmn 0:3ac96e360672 769 VL53L1_NVM__CUST__ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS,
charlesmn 0:3ac96e360672 770 0x0000FFFF,
charlesmn 0:3ac96e360672 771 0,
charlesmn 0:3ac96e360672 772 0);
charlesmn 0:3ac96e360672 773 pdata->nvm__cust__algo__crosstalk_compensation_x_plane_gradient_kcps =
charlesmn 0:3ac96e360672 774 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 775 2,
charlesmn 0:3ac96e360672 776 pbuffer +
charlesmn 0:3ac96e360672 777 VL53L1_NVM__CUST__ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS,
charlesmn 0:3ac96e360672 778 0x0000FFFF,
charlesmn 0:3ac96e360672 779 0,
charlesmn 0:3ac96e360672 780 0);
charlesmn 0:3ac96e360672 781 pdata->nvm__cust__algo__crosstalk_compensation_y_plane_gradient_kcps =
charlesmn 0:3ac96e360672 782 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 783 2,
charlesmn 0:3ac96e360672 784 pbuffer +
charlesmn 0:3ac96e360672 785 VL53L1_NVM__CUST__ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS,
charlesmn 0:3ac96e360672 786 0x0000FFFF,
charlesmn 0:3ac96e360672 787 0,
charlesmn 0:3ac96e360672 788 0);
charlesmn 0:3ac96e360672 789 pdata->nvm__cust__spare__host_config__nvm_config_spare_0 =
charlesmn 0:3ac96e360672 790 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 791 1,
charlesmn 0:3ac96e360672 792 pbuffer + VL53L1_NVM__CUST__SPARE_HOST_CONFIG__NVM_CONFIG_SPARE_0,
charlesmn 0:3ac96e360672 793 0x000000FF,
charlesmn 0:3ac96e360672 794 0,
charlesmn 0:3ac96e360672 795 0);
charlesmn 0:3ac96e360672 796 pdata->nvm__cust__spare__host_config__nvm_config_spare_1 =
charlesmn 0:3ac96e360672 797 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 798 1,
charlesmn 0:3ac96e360672 799 pbuffer +
charlesmn 0:3ac96e360672 800 VL53L1_NVM__CUST__SPARE_HOST_CONFIG__NVM_CONFIG_SPARE_1,
charlesmn 0:3ac96e360672 801 0x000000FF,
charlesmn 0:3ac96e360672 802 0,
charlesmn 0:3ac96e360672 803 0);
charlesmn 0:3ac96e360672 804
charlesmn 0:3ac96e360672 805
charlesmn 0:3ac96e360672 806
charlesmn 0:3ac96e360672 807 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 808 status =
charlesmn 0:3ac96e360672 809 VL53L1_nvm_decode_optical_centre(
charlesmn 0:3ac96e360672 810 buf_size,
charlesmn 0:3ac96e360672 811 pbuffer + VL53L1_NVM__FMT__OPTICAL_CENTRE_DATA_INDEX,
charlesmn 0:3ac96e360672 812 &(pdata->fmt_optical_centre));
charlesmn 0:3ac96e360672 813
charlesmn 0:3ac96e360672 814
charlesmn 0:3ac96e360672 815
charlesmn 0:3ac96e360672 816 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 817 status =
charlesmn 0:3ac96e360672 818 VL53L1_nvm_decode_cal_peak_rate_map(
charlesmn 0:3ac96e360672 819 buf_size,
charlesmn 0:3ac96e360672 820 pbuffer + VL53L1_NVM__FMT__CAL_PEAK_RATE_MAP_DATA_INDEX,
charlesmn 0:3ac96e360672 821 &(pdata->fmt_peak_rate_map));
charlesmn 0:3ac96e360672 822
charlesmn 0:3ac96e360672 823
charlesmn 0:3ac96e360672 824
charlesmn 0:3ac96e360672 825 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 826 status =
charlesmn 0:3ac96e360672 827 VL53L1_nvm_decode_additional_offset_cal_data(
charlesmn 0:3ac96e360672 828 buf_size,
charlesmn 0:3ac96e360672 829 pbuffer +
charlesmn 0:3ac96e360672 830 VL53L1_NVM__FMT__ADDITIONAL_OFFSET_CAL_DATA_INDEX,
charlesmn 0:3ac96e360672 831 &(pdata->fmt_add_offset_data));
charlesmn 0:3ac96e360672 832
charlesmn 0:3ac96e360672 833
charlesmn 0:3ac96e360672 834
charlesmn 0:3ac96e360672 835 pptmp[0] = VL53L1_NVM__FMT__RANGE_RESULTS__140MM_MM_PRE_RANGE;
charlesmn 0:3ac96e360672 836 pptmp[1] = VL53L1_NVM__FMT__RANGE_RESULTS__140MM_DARK;
charlesmn 0:3ac96e360672 837 pptmp[2] = VL53L1_NVM__FMT__RANGE_RESULTS__400MM_DARK;
charlesmn 0:3ac96e360672 838 pptmp[3] = VL53L1_NVM__FMT__RANGE_RESULTS__400MM_AMBIENT;
charlesmn 0:3ac96e360672 839
charlesmn 0:3ac96e360672 840 for (i = 0 ; i < VL53L1_NVM_MAX_FMT_RANGE_DATA ; i++) {
charlesmn 0:3ac96e360672 841 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 842 status =
charlesmn 0:3ac96e360672 843 VL53L1_nvm_decode_fmt_range_results_data(
charlesmn 0:3ac96e360672 844 buf_size,
charlesmn 0:3ac96e360672 845 pbuffer + pptmp[i],
charlesmn 0:3ac96e360672 846 &(pdata->fmt_range_data[i]));
charlesmn 0:3ac96e360672 847 }
charlesmn 0:3ac96e360672 848
charlesmn 0:3ac96e360672 849
charlesmn 0:3ac96e360672 850 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 851 status =
charlesmn 0:3ac96e360672 852 VL53L1_nvm_decode_fmt_info(
charlesmn 0:3ac96e360672 853 buf_size,
charlesmn 0:3ac96e360672 854 pbuffer,
charlesmn 0:3ac96e360672 855 &(pdata->fmt_info));
charlesmn 0:3ac96e360672 856
charlesmn 0:3ac96e360672 857 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 858 status =
charlesmn 0:3ac96e360672 859 VL53L1_nvm_decode_ews_info(
charlesmn 0:3ac96e360672 860 buf_size,
charlesmn 0:3ac96e360672 861 pbuffer,
charlesmn 0:3ac96e360672 862 &(pdata->ews_info));
charlesmn 0:3ac96e360672 863
charlesmn 0:3ac96e360672 864 LOG_FUNCTION_END(status);
charlesmn 0:3ac96e360672 865
charlesmn 0:3ac96e360672 866 return status;
charlesmn 0:3ac96e360672 867
charlesmn 0:3ac96e360672 868 }
charlesmn 0:3ac96e360672 869
charlesmn 0:3ac96e360672 870
charlesmn 0:3ac96e360672 871 VL53L1_Error VL53L1_nvm_decode_optical_centre(
charlesmn 0:3ac96e360672 872 uint16_t buf_size,
charlesmn 0:3ac96e360672 873 uint8_t *pbuffer,
charlesmn 0:3ac96e360672 874 VL53L1_optical_centre_t *pdata)
charlesmn 0:3ac96e360672 875 {
charlesmn 0:3ac96e360672 876
charlesmn 0:3ac96e360672 877 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 878
charlesmn 0:3ac96e360672 879 uint16_t tmp = 0;
charlesmn 0:3ac96e360672 880
charlesmn 0:3ac96e360672 881 if (buf_size < VL53L1_NVM__FMT__OPTICAL_CENTRE_DATA_SIZE)
charlesmn 0:3ac96e360672 882 return VL53L1_ERROR_BUFFER_TOO_SMALL;
charlesmn 0:3ac96e360672 883
charlesmn 0:3ac96e360672 884
charlesmn 0:3ac96e360672 885 tmp = 0x0100;
charlesmn 0:3ac96e360672 886 tmp -= (uint16_t)*(pbuffer + 2);
charlesmn 0:3ac96e360672 887 if (tmp > 0x0FF)
charlesmn 0:3ac96e360672 888 tmp = 0;
charlesmn 0:3ac96e360672 889
charlesmn 0:3ac96e360672 890 pdata->x_centre = (uint8_t)tmp;
charlesmn 0:3ac96e360672 891 pdata->y_centre = *(pbuffer + 3);
charlesmn 0:3ac96e360672 892
charlesmn 0:3ac96e360672 893 return status;
charlesmn 0:3ac96e360672 894 }
charlesmn 0:3ac96e360672 895
charlesmn 0:3ac96e360672 896
charlesmn 0:3ac96e360672 897 VL53L1_Error VL53L1_nvm_decode_cal_peak_rate_map(
charlesmn 0:3ac96e360672 898 uint16_t buf_size,
charlesmn 0:3ac96e360672 899 uint8_t *pbuffer,
charlesmn 0:3ac96e360672 900 VL53L1_cal_peak_rate_map_t *pdata)
charlesmn 0:3ac96e360672 901 {
charlesmn 0:3ac96e360672 902
charlesmn 0:3ac96e360672 903 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 904
charlesmn 0:3ac96e360672 905 uint8_t *ptmp = NULL;
charlesmn 0:3ac96e360672 906 uint8_t i = 0;
charlesmn 0:3ac96e360672 907
charlesmn 0:3ac96e360672 908 if (buf_size < VL53L1_NVM__FMT__CAL_PEAK_RATE_MAP_DATA_SIZE)
charlesmn 0:3ac96e360672 909 return VL53L1_ERROR_BUFFER_TOO_SMALL;
charlesmn 0:3ac96e360672 910
charlesmn 0:3ac96e360672 911 pdata->cal_distance_mm =
charlesmn 0:3ac96e360672 912 (uint16_t)VL53L1_i2c_decode_uint16_t(2, pbuffer);
charlesmn 0:3ac96e360672 913
charlesmn 0:3ac96e360672 914 pdata->cal_reflectance_pc =
charlesmn 0:3ac96e360672 915 (uint16_t)VL53L1_i2c_decode_uint16_t(2, pbuffer + 2);
charlesmn 0:3ac96e360672 916 pdata->cal_reflectance_pc =
charlesmn 0:3ac96e360672 917 pdata->cal_reflectance_pc >> 6;
charlesmn 0:3ac96e360672 918
charlesmn 0:3ac96e360672 919 pdata->max_samples = VL53L1_NVM_PEAK_RATE_MAP_SAMPLES;
charlesmn 0:3ac96e360672 920 pdata->width = VL53L1_NVM_PEAK_RATE_MAP_WIDTH;
charlesmn 0:3ac96e360672 921 pdata->height = VL53L1_NVM_PEAK_RATE_MAP_HEIGHT;
charlesmn 0:3ac96e360672 922
charlesmn 0:3ac96e360672 923 ptmp = pbuffer + 4;
charlesmn 0:3ac96e360672 924 for (i = 0 ; i < VL53L1_NVM_PEAK_RATE_MAP_SAMPLES ; i++) {
charlesmn 0:3ac96e360672 925 pdata->peak_rate_mcps[i] =
charlesmn 0:3ac96e360672 926 (uint16_t)VL53L1_i2c_decode_uint16_t(2, ptmp);
charlesmn 0:3ac96e360672 927 ptmp += 2;
charlesmn 0:3ac96e360672 928 }
charlesmn 0:3ac96e360672 929
charlesmn 0:3ac96e360672 930 return status;
charlesmn 0:3ac96e360672 931 }
charlesmn 0:3ac96e360672 932
charlesmn 0:3ac96e360672 933
charlesmn 0:3ac96e360672 934 VL53L1_Error VL53L1_nvm_decode_additional_offset_cal_data(
charlesmn 0:3ac96e360672 935 uint16_t buf_size,
charlesmn 0:3ac96e360672 936 uint8_t *pbuffer,
charlesmn 0:3ac96e360672 937 VL53L1_additional_offset_cal_data_t *pdata)
charlesmn 0:3ac96e360672 938 {
charlesmn 0:3ac96e360672 939
charlesmn 0:3ac96e360672 940 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 941
charlesmn 0:3ac96e360672 942 if (buf_size < VL53L1_NVM__FMT__ADDITIONAL_OFFSET_CAL_DATA_SIZE)
charlesmn 0:3ac96e360672 943 return VL53L1_ERROR_BUFFER_TOO_SMALL;
charlesmn 0:3ac96e360672 944
charlesmn 0:3ac96e360672 945 pdata->result__mm_inner_actual_effective_spads =
charlesmn 0:3ac96e360672 946 (uint16_t)VL53L1_i2c_decode_uint16_t(2, pbuffer);
charlesmn 0:3ac96e360672 947
charlesmn 0:3ac96e360672 948 pdata->result__mm_outer_actual_effective_spads =
charlesmn 0:3ac96e360672 949 (uint16_t)VL53L1_i2c_decode_uint16_t(2, pbuffer + 2);
charlesmn 0:3ac96e360672 950
charlesmn 0:3ac96e360672 951 pdata->result__mm_inner_peak_signal_count_rtn_mcps =
charlesmn 0:3ac96e360672 952 (uint16_t)VL53L1_i2c_decode_uint16_t(2, pbuffer + 4);
charlesmn 0:3ac96e360672 953
charlesmn 0:3ac96e360672 954 pdata->result__mm_outer_peak_signal_count_rtn_mcps =
charlesmn 0:3ac96e360672 955 (uint16_t)VL53L1_i2c_decode_uint16_t(2, pbuffer + 6);
charlesmn 0:3ac96e360672 956
charlesmn 0:3ac96e360672 957 return status;
charlesmn 0:3ac96e360672 958 }
charlesmn 0:3ac96e360672 959
charlesmn 0:3ac96e360672 960
charlesmn 0:3ac96e360672 961 VL53L1_Error VL53L1_nvm_decode_fmt_range_results_data(
charlesmn 0:3ac96e360672 962 uint16_t buf_size,
charlesmn 0:3ac96e360672 963 uint8_t *pbuffer,
charlesmn 0:3ac96e360672 964 VL53L1_decoded_nvm_fmt_range_data_t *pdata)
charlesmn 0:3ac96e360672 965 {
charlesmn 0:3ac96e360672 966
charlesmn 0:3ac96e360672 967 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 968
charlesmn 0:3ac96e360672 969 if (buf_size < VL53L1_NVM__FMT__RANGE_RESULTS__SIZE_BYTES)
charlesmn 0:3ac96e360672 970 return VL53L1_ERROR_BUFFER_TOO_SMALL;
charlesmn 0:3ac96e360672 971
charlesmn 0:3ac96e360672 972 pdata->result__actual_effective_rtn_spads =
charlesmn 0:3ac96e360672 973 (uint16_t)VL53L1_i2c_decode_uint16_t(2, pbuffer);
charlesmn 0:3ac96e360672 974
charlesmn 0:3ac96e360672 975 pdata->ref_spad_array__num_requested_ref_spads =
charlesmn 0:3ac96e360672 976 *(pbuffer+2);
charlesmn 0:3ac96e360672 977
charlesmn 0:3ac96e360672 978 pdata->ref_spad_array__ref_location =
charlesmn 0:3ac96e360672 979 *(pbuffer+3);
charlesmn 0:3ac96e360672 980
charlesmn 0:3ac96e360672 981 pdata->result__peak_signal_count_rate_rtn_mcps =
charlesmn 0:3ac96e360672 982 (uint16_t)VL53L1_i2c_decode_uint16_t(2, pbuffer + 4);
charlesmn 0:3ac96e360672 983
charlesmn 0:3ac96e360672 984 pdata->result__ambient_count_rate_rtn_mcps =
charlesmn 0:3ac96e360672 985 (uint16_t)VL53L1_i2c_decode_uint16_t(2, pbuffer + 6);
charlesmn 0:3ac96e360672 986
charlesmn 0:3ac96e360672 987 pdata->result__peak_signal_count_rate_ref_mcps =
charlesmn 0:3ac96e360672 988 (uint16_t)VL53L1_i2c_decode_uint16_t(2, pbuffer + 8);
charlesmn 0:3ac96e360672 989
charlesmn 0:3ac96e360672 990 pdata->result__ambient_count_rate_ref_mcps =
charlesmn 0:3ac96e360672 991 (uint16_t)VL53L1_i2c_decode_uint16_t(2, pbuffer + 10);
charlesmn 0:3ac96e360672 992
charlesmn 0:3ac96e360672 993 pdata->measured_distance_mm =
charlesmn 0:3ac96e360672 994 (uint16_t)VL53L1_i2c_decode_uint16_t(2, pbuffer + 12);
charlesmn 0:3ac96e360672 995
charlesmn 0:3ac96e360672 996 pdata->measured_distance_stdev_mm =
charlesmn 0:3ac96e360672 997 (uint16_t)VL53L1_i2c_decode_uint16_t(2, pbuffer + 14);
charlesmn 0:3ac96e360672 998
charlesmn 0:3ac96e360672 999 return status;
charlesmn 0:3ac96e360672 1000 }
charlesmn 0:3ac96e360672 1001
charlesmn 0:3ac96e360672 1002
charlesmn 0:3ac96e360672 1003 VL53L1_Error VL53L1_nvm_decode_fmt_info(
charlesmn 0:3ac96e360672 1004 uint16_t buf_size,
charlesmn 0:3ac96e360672 1005 uint8_t *pbuffer,
charlesmn 0:3ac96e360672 1006 VL53L1_decoded_nvm_fmt_info_t *pdata)
charlesmn 0:3ac96e360672 1007 {
charlesmn 0:3ac96e360672 1008
charlesmn 0:3ac96e360672 1009 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 1010
charlesmn 0:3ac96e360672 1011 if (buf_size < VL53L1_NVM_SIZE_IN_BYTES)
charlesmn 0:3ac96e360672 1012 return VL53L1_ERROR_BUFFER_TOO_SMALL;
charlesmn 0:3ac96e360672 1013
charlesmn 0:3ac96e360672 1014 pdata->nvm__fmt__fgc[0] =
charlesmn 0:3ac96e360672 1015 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1016 1,
charlesmn 0:3ac96e360672 1017 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_0,
charlesmn 0:3ac96e360672 1018 0x000000FE,
charlesmn 0:3ac96e360672 1019 1,
charlesmn 0:3ac96e360672 1020 0);
charlesmn 0:3ac96e360672 1021 pdata->nvm__fmt__fgc[1] =
charlesmn 0:3ac96e360672 1022 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1023 1,
charlesmn 0:3ac96e360672 1024 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_1,
charlesmn 0:3ac96e360672 1025 0x000001FC,
charlesmn 0:3ac96e360672 1026 2,
charlesmn 0:3ac96e360672 1027 0);
charlesmn 0:3ac96e360672 1028 pdata->nvm__fmt__fgc[2] =
charlesmn 0:3ac96e360672 1029 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1030 1,
charlesmn 0:3ac96e360672 1031 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_2 - 1,
charlesmn 0:3ac96e360672 1032 0x000003F8,
charlesmn 0:3ac96e360672 1033 3,
charlesmn 0:3ac96e360672 1034 0);
charlesmn 0:3ac96e360672 1035 pdata->nvm__fmt__fgc[3] =
charlesmn 0:3ac96e360672 1036 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1037 1,
charlesmn 0:3ac96e360672 1038 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_3 - 1,
charlesmn 0:3ac96e360672 1039 0x000007F0,
charlesmn 0:3ac96e360672 1040 4,
charlesmn 0:3ac96e360672 1041 0);
charlesmn 0:3ac96e360672 1042 pdata->nvm__fmt__fgc[4] =
charlesmn 0:3ac96e360672 1043 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1044 1,
charlesmn 0:3ac96e360672 1045 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_4 - 1,
charlesmn 0:3ac96e360672 1046 0x00000FE0,
charlesmn 0:3ac96e360672 1047 5,
charlesmn 0:3ac96e360672 1048 0);
charlesmn 0:3ac96e360672 1049 pdata->nvm__fmt__fgc[5] =
charlesmn 0:3ac96e360672 1050 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1051 1,
charlesmn 0:3ac96e360672 1052 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_5 - 1,
charlesmn 0:3ac96e360672 1053 0x00001FC0,
charlesmn 0:3ac96e360672 1054 6,
charlesmn 0:3ac96e360672 1055 0);
charlesmn 0:3ac96e360672 1056 pdata->nvm__fmt__fgc[6] =
charlesmn 0:3ac96e360672 1057 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1058 1,
charlesmn 0:3ac96e360672 1059 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_6 - 1,
charlesmn 0:3ac96e360672 1060 0x00003F80,
charlesmn 0:3ac96e360672 1061 7,
charlesmn 0:3ac96e360672 1062 0);
charlesmn 0:3ac96e360672 1063 pdata->nvm__fmt__fgc[7] =
charlesmn 0:3ac96e360672 1064 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1065 1,
charlesmn 0:3ac96e360672 1066 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_6,
charlesmn 0:3ac96e360672 1067 0x0000007F,
charlesmn 0:3ac96e360672 1068 0,
charlesmn 0:3ac96e360672 1069 0);
charlesmn 0:3ac96e360672 1070 pdata->nvm__fmt__fgc[8] =
charlesmn 0:3ac96e360672 1071 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1072 1,
charlesmn 0:3ac96e360672 1073 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_7,
charlesmn 0:3ac96e360672 1074 0x000000FE,
charlesmn 0:3ac96e360672 1075 1,
charlesmn 0:3ac96e360672 1076 0);
charlesmn 0:3ac96e360672 1077 pdata->nvm__fmt__fgc[9] =
charlesmn 0:3ac96e360672 1078 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1079 1,
charlesmn 0:3ac96e360672 1080 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_8,
charlesmn 0:3ac96e360672 1081 0x000001FC,
charlesmn 0:3ac96e360672 1082 2,
charlesmn 0:3ac96e360672 1083 0);
charlesmn 0:3ac96e360672 1084 pdata->nvm__fmt__fgc[10] =
charlesmn 0:3ac96e360672 1085 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1086 1,
charlesmn 0:3ac96e360672 1087 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_9 - 1,
charlesmn 0:3ac96e360672 1088 0x000003F8,
charlesmn 0:3ac96e360672 1089 3,
charlesmn 0:3ac96e360672 1090 0);
charlesmn 0:3ac96e360672 1091 pdata->nvm__fmt__fgc[11] =
charlesmn 0:3ac96e360672 1092 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1093 1,
charlesmn 0:3ac96e360672 1094 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_10 - 1,
charlesmn 0:3ac96e360672 1095 0x000007F0,
charlesmn 0:3ac96e360672 1096 4,
charlesmn 0:3ac96e360672 1097 0);
charlesmn 0:3ac96e360672 1098 pdata->nvm__fmt__fgc[12] =
charlesmn 0:3ac96e360672 1099 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1100 1,
charlesmn 0:3ac96e360672 1101 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_11 - 1,
charlesmn 0:3ac96e360672 1102 0x00000FE0,
charlesmn 0:3ac96e360672 1103 5,
charlesmn 0:3ac96e360672 1104 0);
charlesmn 0:3ac96e360672 1105 pdata->nvm__fmt__fgc[13] =
charlesmn 0:3ac96e360672 1106 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1107 1,
charlesmn 0:3ac96e360672 1108 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_12 - 1,
charlesmn 0:3ac96e360672 1109 0x00001FC0,
charlesmn 0:3ac96e360672 1110 6,
charlesmn 0:3ac96e360672 1111 0);
charlesmn 0:3ac96e360672 1112 pdata->nvm__fmt__fgc[14] =
charlesmn 0:3ac96e360672 1113 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1114 1,
charlesmn 0:3ac96e360672 1115 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_13 - 1,
charlesmn 0:3ac96e360672 1116 0x00003F80,
charlesmn 0:3ac96e360672 1117 7,
charlesmn 0:3ac96e360672 1118 0);
charlesmn 0:3ac96e360672 1119 pdata->nvm__fmt__fgc[15] =
charlesmn 0:3ac96e360672 1120 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1121 1,
charlesmn 0:3ac96e360672 1122 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_13,
charlesmn 0:3ac96e360672 1123 0x0000007F,
charlesmn 0:3ac96e360672 1124 0,
charlesmn 0:3ac96e360672 1125 0);
charlesmn 0:3ac96e360672 1126 pdata->nvm__fmt__fgc[16] =
charlesmn 0:3ac96e360672 1127 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1128 1,
charlesmn 0:3ac96e360672 1129 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_14,
charlesmn 0:3ac96e360672 1130 0x000000FE,
charlesmn 0:3ac96e360672 1131 1,
charlesmn 0:3ac96e360672 1132 0);
charlesmn 0:3ac96e360672 1133 pdata->nvm__fmt__fgc[17] =
charlesmn 0:3ac96e360672 1134 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1135 1,
charlesmn 0:3ac96e360672 1136 pbuffer + VL53L1_NVM__FMT__FGC__BYTE_15,
charlesmn 0:3ac96e360672 1137 0x000001FC,
charlesmn 0:3ac96e360672 1138 2,
charlesmn 0:3ac96e360672 1139 0);
charlesmn 0:3ac96e360672 1140 pdata->nvm__fmt__fgc[18] = 0x00;
charlesmn 0:3ac96e360672 1141
charlesmn 0:3ac96e360672 1142 pdata->nvm__fmt__test_program_major =
charlesmn 0:3ac96e360672 1143 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1144 1,
charlesmn 0:3ac96e360672 1145 pbuffer + VL53L1_NVM__FMT__TEST_PROGRAM_MAJOR_MINOR,
charlesmn 0:3ac96e360672 1146 0x000000E0,
charlesmn 0:3ac96e360672 1147 5,
charlesmn 0:3ac96e360672 1148 0);
charlesmn 0:3ac96e360672 1149 pdata->nvm__fmt__test_program_minor =
charlesmn 0:3ac96e360672 1150 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1151 1,
charlesmn 0:3ac96e360672 1152 pbuffer + VL53L1_NVM__FMT__TEST_PROGRAM_MAJOR_MINOR,
charlesmn 0:3ac96e360672 1153 0x0000001F,
charlesmn 0:3ac96e360672 1154 0,
charlesmn 0:3ac96e360672 1155 0);
charlesmn 0:3ac96e360672 1156 pdata->nvm__fmt__map_major =
charlesmn 0:3ac96e360672 1157 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1158 1,
charlesmn 0:3ac96e360672 1159 pbuffer + VL53L1_NVM__FMT__MAP_MAJOR_MINOR,
charlesmn 0:3ac96e360672 1160 0x000000E0,
charlesmn 0:3ac96e360672 1161 5,
charlesmn 0:3ac96e360672 1162 0);
charlesmn 0:3ac96e360672 1163 pdata->nvm__fmt__map_minor =
charlesmn 0:3ac96e360672 1164 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1165 1,
charlesmn 0:3ac96e360672 1166 pbuffer + VL53L1_NVM__FMT__MAP_MAJOR_MINOR,
charlesmn 0:3ac96e360672 1167 0x0000001F,
charlesmn 0:3ac96e360672 1168 0,
charlesmn 0:3ac96e360672 1169 0);
charlesmn 0:3ac96e360672 1170 pdata->nvm__fmt__year =
charlesmn 0:3ac96e360672 1171 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1172 1,
charlesmn 0:3ac96e360672 1173 pbuffer + VL53L1_NVM__FMT__YEAR_MONTH,
charlesmn 0:3ac96e360672 1174 0x000000F0,
charlesmn 0:3ac96e360672 1175 4,
charlesmn 0:3ac96e360672 1176 0);
charlesmn 0:3ac96e360672 1177 pdata->nvm__fmt__month =
charlesmn 0:3ac96e360672 1178 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1179 1,
charlesmn 0:3ac96e360672 1180 pbuffer + VL53L1_NVM__FMT__YEAR_MONTH,
charlesmn 0:3ac96e360672 1181 0x0000000F,
charlesmn 0:3ac96e360672 1182 0,
charlesmn 0:3ac96e360672 1183 0);
charlesmn 0:3ac96e360672 1184 pdata->nvm__fmt__day =
charlesmn 0:3ac96e360672 1185 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1186 1,
charlesmn 0:3ac96e360672 1187 pbuffer + VL53L1_NVM__FMT__DAY_MODULE_DATE_PHASE,
charlesmn 0:3ac96e360672 1188 0x000000F8,
charlesmn 0:3ac96e360672 1189 3,
charlesmn 0:3ac96e360672 1190 0);
charlesmn 0:3ac96e360672 1191 pdata->nvm__fmt__module_date_phase =
charlesmn 0:3ac96e360672 1192 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1193 1,
charlesmn 0:3ac96e360672 1194 pbuffer + VL53L1_NVM__FMT__DAY_MODULE_DATE_PHASE,
charlesmn 0:3ac96e360672 1195 0x00000007,
charlesmn 0:3ac96e360672 1196 0,
charlesmn 0:3ac96e360672 1197 0);
charlesmn 0:3ac96e360672 1198 pdata->nvm__fmt__time =
charlesmn 0:3ac96e360672 1199 (uint16_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1200 2,
charlesmn 0:3ac96e360672 1201 pbuffer + VL53L1_NVM__FMT__TIME,
charlesmn 0:3ac96e360672 1202 0x0000FFFF,
charlesmn 0:3ac96e360672 1203 0,
charlesmn 0:3ac96e360672 1204 0);
charlesmn 0:3ac96e360672 1205 pdata->nvm__fmt__tester_id =
charlesmn 0:3ac96e360672 1206 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1207 1,
charlesmn 0:3ac96e360672 1208 pbuffer + VL53L1_NVM__FMT__TESTER_ID,
charlesmn 0:3ac96e360672 1209 0x000000FF,
charlesmn 0:3ac96e360672 1210 0,
charlesmn 0:3ac96e360672 1211 0);
charlesmn 0:3ac96e360672 1212 pdata->nvm__fmt__site_id =
charlesmn 0:3ac96e360672 1213 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1214 1,
charlesmn 0:3ac96e360672 1215 pbuffer + VL53L1_NVM__FMT__SITE_ID,
charlesmn 0:3ac96e360672 1216 0x000000FF,
charlesmn 0:3ac96e360672 1217 0,
charlesmn 0:3ac96e360672 1218 0);
charlesmn 0:3ac96e360672 1219
charlesmn 0:3ac96e360672 1220 return status;
charlesmn 0:3ac96e360672 1221 }
charlesmn 0:3ac96e360672 1222
charlesmn 0:3ac96e360672 1223
charlesmn 0:3ac96e360672 1224 VL53L1_Error VL53L1_nvm_decode_ews_info(
charlesmn 0:3ac96e360672 1225 uint16_t buf_size,
charlesmn 0:3ac96e360672 1226 uint8_t *pbuffer,
charlesmn 0:3ac96e360672 1227 VL53L1_decoded_nvm_ews_info_t *pdata)
charlesmn 0:3ac96e360672 1228 {
charlesmn 0:3ac96e360672 1229
charlesmn 0:3ac96e360672 1230 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 1231
charlesmn 0:3ac96e360672 1232 if (buf_size < VL53L1_NVM_SIZE_IN_BYTES)
charlesmn 0:3ac96e360672 1233 return VL53L1_ERROR_BUFFER_TOO_SMALL;
charlesmn 0:3ac96e360672 1234
charlesmn 0:3ac96e360672 1235 pdata->nvm__ews__test_program_major =
charlesmn 0:3ac96e360672 1236 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1237 1,
charlesmn 0:3ac96e360672 1238 pbuffer + VL53L1_NVM__EWS__TEST_PROGRAM_MAJOR_MINOR,
charlesmn 0:3ac96e360672 1239 0x000000E0,
charlesmn 0:3ac96e360672 1240 5,
charlesmn 0:3ac96e360672 1241 0);
charlesmn 0:3ac96e360672 1242 pdata->nvm__ews__test_program_minor =
charlesmn 0:3ac96e360672 1243 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1244 1,
charlesmn 0:3ac96e360672 1245 pbuffer + VL53L1_NVM__EWS__TEST_PROGRAM_MAJOR_MINOR,
charlesmn 0:3ac96e360672 1246 0x0000001F,
charlesmn 0:3ac96e360672 1247 0,
charlesmn 0:3ac96e360672 1248 0);
charlesmn 0:3ac96e360672 1249 pdata->nvm__ews__probe_card_major =
charlesmn 0:3ac96e360672 1250 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1251 1,
charlesmn 0:3ac96e360672 1252 pbuffer + VL53L1_NVM__EWS__PROBE_CARD_MAJOR_MINOR,
charlesmn 0:3ac96e360672 1253 0x000000F0,
charlesmn 0:3ac96e360672 1254 4,
charlesmn 0:3ac96e360672 1255 0);
charlesmn 0:3ac96e360672 1256 pdata->nvm__ews__probe_card_minor =
charlesmn 0:3ac96e360672 1257 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1258 1,
charlesmn 0:3ac96e360672 1259 pbuffer + VL53L1_NVM__EWS__PROBE_CARD_MAJOR_MINOR,
charlesmn 0:3ac96e360672 1260 0x0000000F,
charlesmn 0:3ac96e360672 1261 0,
charlesmn 0:3ac96e360672 1262 0);
charlesmn 0:3ac96e360672 1263 pdata->nvm__ews__tester_id =
charlesmn 0:3ac96e360672 1264 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1265 1,
charlesmn 0:3ac96e360672 1266 pbuffer + VL53L1_NVM__EWS__TESTER_ID,
charlesmn 0:3ac96e360672 1267 0x000000FF,
charlesmn 0:3ac96e360672 1268 0,
charlesmn 0:3ac96e360672 1269 0);
charlesmn 0:3ac96e360672 1270 pdata->nvm__ews__lot[0] =
charlesmn 0:3ac96e360672 1271 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1272 1,
charlesmn 0:3ac96e360672 1273 pbuffer + VL53L1_NVM__EWS__LOT__BYTE_0,
charlesmn 0:3ac96e360672 1274 0x000000FC,
charlesmn 0:3ac96e360672 1275 2,
charlesmn 0:3ac96e360672 1276 32);
charlesmn 0:3ac96e360672 1277 pdata->nvm__ews__lot[1] =
charlesmn 0:3ac96e360672 1278 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1279 2,
charlesmn 0:3ac96e360672 1280 pbuffer + VL53L1_NVM__EWS__LOT__BYTE_1 - 1,
charlesmn 0:3ac96e360672 1281 0x000003F0,
charlesmn 0:3ac96e360672 1282 4,
charlesmn 0:3ac96e360672 1283 32);
charlesmn 0:3ac96e360672 1284 pdata->nvm__ews__lot[2] =
charlesmn 0:3ac96e360672 1285 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1286 2,
charlesmn 0:3ac96e360672 1287 pbuffer + VL53L1_NVM__EWS__LOT__BYTE_2 - 1,
charlesmn 0:3ac96e360672 1288 0x00000FC0,
charlesmn 0:3ac96e360672 1289 6,
charlesmn 0:3ac96e360672 1290 32);
charlesmn 0:3ac96e360672 1291 pdata->nvm__ews__lot[3] =
charlesmn 0:3ac96e360672 1292 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1293 1,
charlesmn 0:3ac96e360672 1294 pbuffer + VL53L1_NVM__EWS__LOT__BYTE_2,
charlesmn 0:3ac96e360672 1295 0x0000003F,
charlesmn 0:3ac96e360672 1296 0,
charlesmn 0:3ac96e360672 1297 32);
charlesmn 0:3ac96e360672 1298 pdata->nvm__ews__lot[4] =
charlesmn 0:3ac96e360672 1299 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1300 1,
charlesmn 0:3ac96e360672 1301 pbuffer + VL53L1_NVM__EWS__LOT__BYTE_3,
charlesmn 0:3ac96e360672 1302 0x000000FC,
charlesmn 0:3ac96e360672 1303 2,
charlesmn 0:3ac96e360672 1304 32);
charlesmn 0:3ac96e360672 1305 pdata->nvm__ews__lot[5] =
charlesmn 0:3ac96e360672 1306 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1307 2,
charlesmn 0:3ac96e360672 1308 pbuffer + VL53L1_NVM__EWS__LOT__BYTE_4 - 1,
charlesmn 0:3ac96e360672 1309 0x000003F0,
charlesmn 0:3ac96e360672 1310 4,
charlesmn 0:3ac96e360672 1311 32);
charlesmn 0:3ac96e360672 1312 pdata->nvm__ews__lot[6] =
charlesmn 0:3ac96e360672 1313 (char)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1314 2,
charlesmn 0:3ac96e360672 1315 pbuffer + VL53L1_NVM__EWS__LOT__BYTE_5 - 1,
charlesmn 0:3ac96e360672 1316 0x00000FC0,
charlesmn 0:3ac96e360672 1317 6,
charlesmn 0:3ac96e360672 1318 32);
charlesmn 0:3ac96e360672 1319
charlesmn 0:3ac96e360672 1320 pdata->nvm__ews__lot[7] = 0x00;
charlesmn 0:3ac96e360672 1321
charlesmn 0:3ac96e360672 1322 pdata->nvm__ews__wafer =
charlesmn 0:3ac96e360672 1323 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1324 1,
charlesmn 0:3ac96e360672 1325 pbuffer + VL53L1_NVM__EWS__WAFER,
charlesmn 0:3ac96e360672 1326 0x0000001F,
charlesmn 0:3ac96e360672 1327 0,
charlesmn 0:3ac96e360672 1328 0);
charlesmn 0:3ac96e360672 1329 pdata->nvm__ews__xcoord =
charlesmn 0:3ac96e360672 1330 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1331 1,
charlesmn 0:3ac96e360672 1332 pbuffer + VL53L1_NVM__EWS__XCOORD,
charlesmn 0:3ac96e360672 1333 0x000000FF,
charlesmn 0:3ac96e360672 1334 0,
charlesmn 0:3ac96e360672 1335 0);
charlesmn 0:3ac96e360672 1336 pdata->nvm__ews__ycoord =
charlesmn 0:3ac96e360672 1337 (uint8_t)VL53L1_i2c_decode_with_mask(
charlesmn 0:3ac96e360672 1338 1,
charlesmn 0:3ac96e360672 1339 pbuffer + VL53L1_NVM__EWS__YCOORD,
charlesmn 0:3ac96e360672 1340 0x000000FF,
charlesmn 0:3ac96e360672 1341 0,
charlesmn 0:3ac96e360672 1342 0);
charlesmn 0:3ac96e360672 1343
charlesmn 0:3ac96e360672 1344 return status;
charlesmn 0:3ac96e360672 1345
charlesmn 0:3ac96e360672 1346 }
charlesmn 0:3ac96e360672 1347
charlesmn 0:3ac96e360672 1348
charlesmn 0:3ac96e360672 1349 void VL53L1_nvm_format_encode(
charlesmn 0:3ac96e360672 1350 VL53L1_decoded_nvm_data_t *pnvm_info,
charlesmn 0:3ac96e360672 1351 uint8_t *pnvm_data)
charlesmn 0:3ac96e360672 1352 {
charlesmn 0:3ac96e360672 1353 SUPPRESS_UNUSED_WARNING(pnvm_info);
charlesmn 0:3ac96e360672 1354 SUPPRESS_UNUSED_WARNING(pnvm_data);
charlesmn 0:3ac96e360672 1355 }
charlesmn 0:3ac96e360672 1356
charlesmn 0:3ac96e360672 1357
charlesmn 0:3ac96e360672 1358 VL53L1_Error VL53L1_read_nvm_raw_data(
charlesmn 0:3ac96e360672 1359 VL53L1_DEV Dev,
charlesmn 0:3ac96e360672 1360 uint8_t start_address,
charlesmn 0:3ac96e360672 1361 uint8_t count,
charlesmn 0:3ac96e360672 1362 uint8_t *pnvm_raw_data)
charlesmn 0:3ac96e360672 1363 {
charlesmn 0:3ac96e360672 1364
charlesmn 0:3ac96e360672 1365
charlesmn 0:3ac96e360672 1366
charlesmn 0:3ac96e360672 1367 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 1368
charlesmn 0:3ac96e360672 1369 LOG_FUNCTION_START("");
charlesmn 0:3ac96e360672 1370
charlesmn 0:3ac96e360672 1371
charlesmn 0:3ac96e360672 1372
charlesmn 0:3ac96e360672 1373 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 1374 status = VL53L1_nvm_enable(
charlesmn 0:3ac96e360672 1375 Dev,
charlesmn 0:3ac96e360672 1376 0x0004,
charlesmn 0:3ac96e360672 1377 VL53L1_NVM_POWER_UP_DELAY_US);
charlesmn 0:3ac96e360672 1378
charlesmn 0:3ac96e360672 1379
charlesmn 0:3ac96e360672 1380
charlesmn 0:3ac96e360672 1381 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 1382 status = VL53L1_nvm_read(
charlesmn 0:3ac96e360672 1383 Dev,
charlesmn 0:3ac96e360672 1384 start_address,
charlesmn 0:3ac96e360672 1385 count,
charlesmn 0:3ac96e360672 1386 pnvm_raw_data);
charlesmn 0:3ac96e360672 1387
charlesmn 0:3ac96e360672 1388
charlesmn 0:3ac96e360672 1389
charlesmn 0:3ac96e360672 1390 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 1391 status = VL53L1_nvm_disable(Dev);
charlesmn 0:3ac96e360672 1392
charlesmn 0:3ac96e360672 1393 LOG_FUNCTION_END(status);
charlesmn 0:3ac96e360672 1394
charlesmn 0:3ac96e360672 1395 return status;
charlesmn 0:3ac96e360672 1396
charlesmn 0:3ac96e360672 1397 }
charlesmn 0:3ac96e360672 1398
charlesmn 0:3ac96e360672 1399
charlesmn 0:3ac96e360672 1400 VL53L1_Error VL53L1_read_nvm(
charlesmn 0:3ac96e360672 1401 VL53L1_DEV Dev,
charlesmn 0:3ac96e360672 1402 uint8_t nvm_format,
charlesmn 0:3ac96e360672 1403 VL53L1_decoded_nvm_data_t *pnvm_info)
charlesmn 0:3ac96e360672 1404 {
charlesmn 0:3ac96e360672 1405
charlesmn 0:3ac96e360672 1406
charlesmn 0:3ac96e360672 1407
charlesmn 0:3ac96e360672 1408 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 1409
charlesmn 0:3ac96e360672 1410 uint8_t nvm_data[VL53L1_NVM_SIZE_IN_BYTES];
charlesmn 0:3ac96e360672 1411
charlesmn 0:3ac96e360672 1412 LOG_FUNCTION_START("");
charlesmn 0:3ac96e360672 1413
charlesmn 0:3ac96e360672 1414 SUPPRESS_UNUSED_WARNING(nvm_format);
charlesmn 0:3ac96e360672 1415
charlesmn 0:3ac96e360672 1416
charlesmn 0:3ac96e360672 1417
charlesmn 0:3ac96e360672 1418 status = VL53L1_read_nvm_raw_data(
charlesmn 0:3ac96e360672 1419 Dev,
charlesmn 0:3ac96e360672 1420 0,
charlesmn 0:3ac96e360672 1421 VL53L1_NVM_SIZE_IN_BYTES >> 2,
charlesmn 0:3ac96e360672 1422 nvm_data);
charlesmn 0:3ac96e360672 1423
charlesmn 0:3ac96e360672 1424
charlesmn 0:3ac96e360672 1425
charlesmn 0:3ac96e360672 1426
charlesmn 0:3ac96e360672 1427
charlesmn 0:3ac96e360672 1428 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 1429 status = VL53L1_nvm_format_decode(
charlesmn 0:3ac96e360672 1430 VL53L1_NVM_SIZE_IN_BYTES,
charlesmn 0:3ac96e360672 1431 nvm_data,
charlesmn 0:3ac96e360672 1432 pnvm_info);
charlesmn 0:3ac96e360672 1433
charlesmn 0:3ac96e360672 1434 LOG_FUNCTION_END(status);
charlesmn 0:3ac96e360672 1435
charlesmn 0:3ac96e360672 1436 return status;
charlesmn 0:3ac96e360672 1437
charlesmn 0:3ac96e360672 1438 }
charlesmn 0:3ac96e360672 1439
charlesmn 0:3ac96e360672 1440
charlesmn 0:3ac96e360672 1441 VL53L1_Error VL53L1_read_nvm_optical_centre(
charlesmn 0:3ac96e360672 1442 VL53L1_DEV Dev,
charlesmn 0:3ac96e360672 1443 VL53L1_optical_centre_t *pcentre)
charlesmn 0:3ac96e360672 1444 {
charlesmn 0:3ac96e360672 1445
charlesmn 0:3ac96e360672 1446
charlesmn 0:3ac96e360672 1447 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 1448
charlesmn 0:3ac96e360672 1449 uint8_t nvm_data[VL53L1_NVM__FMT__OPTICAL_CENTRE_DATA_SIZE];
charlesmn 0:3ac96e360672 1450
charlesmn 0:3ac96e360672 1451 LOG_FUNCTION_START("");
charlesmn 0:3ac96e360672 1452
charlesmn 0:3ac96e360672 1453
charlesmn 0:3ac96e360672 1454
charlesmn 0:3ac96e360672 1455 status =
charlesmn 0:3ac96e360672 1456 VL53L1_read_nvm_raw_data(
charlesmn 0:3ac96e360672 1457 Dev,
charlesmn 0:3ac96e360672 1458 (uint8_t)(VL53L1_NVM__FMT__OPTICAL_CENTRE_DATA_INDEX
charlesmn 0:3ac96e360672 1459 >> 2),
charlesmn 0:3ac96e360672 1460 (uint8_t)(VL53L1_NVM__FMT__OPTICAL_CENTRE_DATA_SIZE
charlesmn 0:3ac96e360672 1461 >> 2),
charlesmn 0:3ac96e360672 1462 nvm_data);
charlesmn 0:3ac96e360672 1463
charlesmn 0:3ac96e360672 1464
charlesmn 0:3ac96e360672 1465
charlesmn 0:3ac96e360672 1466 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 1467 status =
charlesmn 0:3ac96e360672 1468 VL53L1_nvm_decode_optical_centre(
charlesmn 0:3ac96e360672 1469 VL53L1_NVM__FMT__OPTICAL_CENTRE_DATA_SIZE,
charlesmn 0:3ac96e360672 1470 nvm_data,
charlesmn 0:3ac96e360672 1471 pcentre);
charlesmn 0:3ac96e360672 1472
charlesmn 0:3ac96e360672 1473 LOG_FUNCTION_END(status);
charlesmn 0:3ac96e360672 1474
charlesmn 0:3ac96e360672 1475 return status;
charlesmn 0:3ac96e360672 1476 }
charlesmn 0:3ac96e360672 1477
charlesmn 0:3ac96e360672 1478
charlesmn 0:3ac96e360672 1479 VL53L1_Error VL53L1_read_nvm_cal_peak_rate_map(
charlesmn 0:3ac96e360672 1480 VL53L1_DEV Dev,
charlesmn 0:3ac96e360672 1481 VL53L1_cal_peak_rate_map_t *pcal_data)
charlesmn 0:3ac96e360672 1482 {
charlesmn 0:3ac96e360672 1483
charlesmn 0:3ac96e360672 1484
charlesmn 0:3ac96e360672 1485 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 1486
charlesmn 0:3ac96e360672 1487 uint8_t nvm_data[VL53L1_NVM__FMT__CAL_PEAK_RATE_MAP_DATA_SIZE];
charlesmn 0:3ac96e360672 1488
charlesmn 0:3ac96e360672 1489 LOG_FUNCTION_START("");
charlesmn 0:3ac96e360672 1490
charlesmn 0:3ac96e360672 1491
charlesmn 0:3ac96e360672 1492
charlesmn 0:3ac96e360672 1493 status =
charlesmn 0:3ac96e360672 1494 VL53L1_read_nvm_raw_data(
charlesmn 0:3ac96e360672 1495 Dev,
charlesmn 0:3ac96e360672 1496 (uint8_t)(VL53L1_NVM__FMT__CAL_PEAK_RATE_MAP_DATA_INDEX
charlesmn 0:3ac96e360672 1497 >> 2),
charlesmn 0:3ac96e360672 1498 (uint8_t)(VL53L1_NVM__FMT__CAL_PEAK_RATE_MAP_DATA_SIZE
charlesmn 0:3ac96e360672 1499 >> 2),
charlesmn 0:3ac96e360672 1500 nvm_data);
charlesmn 0:3ac96e360672 1501
charlesmn 0:3ac96e360672 1502
charlesmn 0:3ac96e360672 1503
charlesmn 0:3ac96e360672 1504 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 1505 status =
charlesmn 0:3ac96e360672 1506 VL53L1_nvm_decode_cal_peak_rate_map(
charlesmn 0:3ac96e360672 1507 VL53L1_NVM__FMT__CAL_PEAK_RATE_MAP_DATA_SIZE,
charlesmn 0:3ac96e360672 1508 nvm_data,
charlesmn 0:3ac96e360672 1509 pcal_data);
charlesmn 0:3ac96e360672 1510
charlesmn 0:3ac96e360672 1511 LOG_FUNCTION_END(status);
charlesmn 0:3ac96e360672 1512
charlesmn 0:3ac96e360672 1513 return status;
charlesmn 0:3ac96e360672 1514 }
charlesmn 0:3ac96e360672 1515
charlesmn 0:3ac96e360672 1516
charlesmn 0:3ac96e360672 1517 VL53L1_Error VL53L1_read_nvm_additional_offset_cal_data(
charlesmn 0:3ac96e360672 1518 VL53L1_DEV Dev,
charlesmn 0:3ac96e360672 1519 VL53L1_additional_offset_cal_data_t *pcal_data)
charlesmn 0:3ac96e360672 1520 {
charlesmn 0:3ac96e360672 1521
charlesmn 0:3ac96e360672 1522
charlesmn 0:3ac96e360672 1523
charlesmn 0:3ac96e360672 1524 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 1525
charlesmn 0:3ac96e360672 1526 uint8_t nvm_data[VL53L1_NVM__FMT__ADDITIONAL_OFFSET_CAL_DATA_SIZE];
charlesmn 0:3ac96e360672 1527
charlesmn 0:3ac96e360672 1528 LOG_FUNCTION_START("");
charlesmn 0:3ac96e360672 1529
charlesmn 0:3ac96e360672 1530
charlesmn 0:3ac96e360672 1531
charlesmn 0:3ac96e360672 1532 status =
charlesmn 0:3ac96e360672 1533 VL53L1_read_nvm_raw_data(
charlesmn 0:3ac96e360672 1534 Dev,
charlesmn 0:3ac96e360672 1535 (uint8_t)(
charlesmn 0:3ac96e360672 1536 VL53L1_NVM__FMT__ADDITIONAL_OFFSET_CAL_DATA_INDEX >> 2),
charlesmn 0:3ac96e360672 1537 (uint8_t)(
charlesmn 0:3ac96e360672 1538 VL53L1_NVM__FMT__ADDITIONAL_OFFSET_CAL_DATA_SIZE >> 2),
charlesmn 0:3ac96e360672 1539 nvm_data);
charlesmn 0:3ac96e360672 1540
charlesmn 0:3ac96e360672 1541
charlesmn 0:3ac96e360672 1542
charlesmn 0:3ac96e360672 1543 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 1544 status = VL53L1_nvm_decode_additional_offset_cal_data(
charlesmn 0:3ac96e360672 1545 VL53L1_NVM__FMT__ADDITIONAL_OFFSET_CAL_DATA_SIZE,
charlesmn 0:3ac96e360672 1546 nvm_data,
charlesmn 0:3ac96e360672 1547 pcal_data);
charlesmn 0:3ac96e360672 1548
charlesmn 0:3ac96e360672 1549 LOG_FUNCTION_END(status);
charlesmn 0:3ac96e360672 1550
charlesmn 0:3ac96e360672 1551 return status;
charlesmn 0:3ac96e360672 1552
charlesmn 0:3ac96e360672 1553 }
charlesmn 0:3ac96e360672 1554
charlesmn 0:3ac96e360672 1555
charlesmn 0:3ac96e360672 1556 VL53L1_Error VL53L1_read_nvm_fmt_range_results_data(
charlesmn 0:3ac96e360672 1557 VL53L1_DEV Dev,
charlesmn 0:3ac96e360672 1558 uint16_t range_results_select,
charlesmn 0:3ac96e360672 1559 VL53L1_decoded_nvm_fmt_range_data_t *prange_data)
charlesmn 0:3ac96e360672 1560 {
charlesmn 0:3ac96e360672 1561
charlesmn 0:3ac96e360672 1562
charlesmn 0:3ac96e360672 1563
charlesmn 0:3ac96e360672 1564 VL53L1_Error status = VL53L1_ERROR_NONE;
charlesmn 0:3ac96e360672 1565
charlesmn 0:3ac96e360672 1566 uint8_t nvm_data[VL53L1_NVM__FMT__RANGE_RESULTS__SIZE_BYTES];
charlesmn 0:3ac96e360672 1567
charlesmn 0:3ac96e360672 1568 LOG_FUNCTION_START("");
charlesmn 0:3ac96e360672 1569
charlesmn 0:3ac96e360672 1570
charlesmn 0:3ac96e360672 1571
charlesmn 0:3ac96e360672 1572 status = VL53L1_read_nvm_raw_data(
charlesmn 0:3ac96e360672 1573 Dev,
charlesmn 0:3ac96e360672 1574 (uint8_t)(range_results_select >> 2),
charlesmn 0:3ac96e360672 1575 (uint8_t)(VL53L1_NVM__FMT__RANGE_RESULTS__SIZE_BYTES >> 2),
charlesmn 0:3ac96e360672 1576 nvm_data);
charlesmn 0:3ac96e360672 1577
charlesmn 0:3ac96e360672 1578
charlesmn 0:3ac96e360672 1579
charlesmn 0:3ac96e360672 1580 if (status == VL53L1_ERROR_NONE)
charlesmn 0:3ac96e360672 1581 status =
charlesmn 0:3ac96e360672 1582 VL53L1_nvm_decode_fmt_range_results_data(
charlesmn 0:3ac96e360672 1583 VL53L1_NVM__FMT__RANGE_RESULTS__SIZE_BYTES,
charlesmn 0:3ac96e360672 1584 nvm_data,
charlesmn 0:3ac96e360672 1585 prange_data);
charlesmn 0:3ac96e360672 1586
charlesmn 0:3ac96e360672 1587 LOG_FUNCTION_END(status);
charlesmn 0:3ac96e360672 1588
charlesmn 0:3ac96e360672 1589 return status;
charlesmn 0:3ac96e360672 1590
charlesmn 0:3ac96e360672 1591 }
charlesmn 0:3ac96e360672 1592
charlesmn 0:3ac96e360672 1593
charlesmn 0:3ac96e360672 1594