Statistics
| Branch: | Tag: | Revision:

amiro-lld / drivers / VL53L1X / v1 / api / core / vl53l1_api_debug.c @ 4dba9195

History | View | Annotate | Download (37.417 KB)

1
/*
2
* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
3
*
4
* This file is part of VL53L1 Core and is dual licensed,
5
* either 'STMicroelectronics
6
* Proprietary license'
7
* or 'BSD 3-clause "New" or "Revised" License' , at your option.
8
*
9
********************************************************************************
10
*
11
* 'STMicroelectronics Proprietary license'
12
*
13
********************************************************************************
14
*
15
* License terms: STMicroelectronics Proprietary in accordance with licensing
16
* terms at www.st.com/sla0081
17
*
18
* STMicroelectronics confidential
19
* Reproduction and Communication of this document is strictly prohibited unless
20
* specifically authorized in writing by STMicroelectronics.
21
*
22
*
23
********************************************************************************
24
*
25
* Alternatively, VL53L1 Core may be distributed under the terms of
26
* 'BSD 3-clause "New" or "Revised" License', in which case the following
27
* provisions apply instead of the ones mentioned above :
28
*
29
********************************************************************************
30
*
31
* License terms: BSD 3-clause "New" or "Revised" License.
32
*
33
* Redistribution and use in source and binary forms, with or without
34
* modification, are permitted provided that the following conditions are met:
35
*
36
* 1. Redistributions of source code must retain the above copyright notice, this
37
* list of conditions and the following disclaimer.
38
*
39
* 2. Redistributions in binary form must reproduce the above copyright notice,
40
* this list of conditions and the following disclaimer in the documentation
41
* and/or other materials provided with the distribution.
42
*
43
* 3. Neither the name of the copyright holder nor the names of its contributors
44
* may be used to endorse or promote products derived from this software
45
* without specific prior written permission.
46
*
47
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57
*
58
*
59
********************************************************************************
60
*
61
*/
62

    
63
/**
64
 * @file  vl53l1_api_debug.c
65
 * @brief EwokPlus25 low level Driver debug function definition
66
 */
67

    
68
#include "vl53l1_ll_def.h"
69
#include "vl53l1_ll_device.h"
70
#include "vl53l1_register_structs.h"
71
#include "vl53l1_core.h"
72
#include "vl53l1_api_debug.h"
73

    
74
#define LOG_FUNCTION_START(fmt, ...) \
75
        _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_CORE, fmt, ##__VA_ARGS__)
76
#define LOG_FUNCTION_END(status, ...) \
77
        _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_CORE, status, ##__VA_ARGS__)
78
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
79
        _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_CORE, status, \
80
        fmt, ##__VA_ARGS__)
81

    
82
#define trace_print(level, ...) \
83
        _LOG_TRACE_PRINT(trace_flags, \
84
        level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
85

    
86

    
87
/* Start Patch_AdditionalDebugData_11823 */
88

    
89
VL53L1_Error VL53L1_get_additional_data(
90
        VL53L1_DEV                       Dev,
91
        VL53L1_additional_data_t        *pdata)
92
{
93
        /*
94
         * Gets the addition debug data
95
         */
96

    
97
        VL53L1_Error  status = VL53L1_ERROR_NONE;
98

    
99
        VL53L1_LLDriverData_t *pdev = VL53L1DevStructGetLLDriverHandle(Dev);
100

    
101
        LOG_FUNCTION_START("");
102

    
103
        /* get LL Driver configuration parameters */
104

    
105
        pdata->preset_mode             = pdev->preset_mode;
106
        pdata->measurement_mode        = pdev->measurement_mode;
107

    
108
        pdata->phasecal_config_timeout_us  = pdev->phasecal_config_timeout_us;
109
        pdata->mm_config_timeout_us        = pdev->mm_config_timeout_us;
110
        pdata->range_config_timeout_us     = pdev->range_config_timeout_us;
111
        pdata->inter_measurement_period_ms = pdev->inter_measurement_period_ms;
112
        pdata->dss_config__target_total_rate_mcps =
113
                        pdev->dss_config__target_total_rate_mcps;
114

    
115
        LOG_FUNCTION_END(status);
116

    
117
        return status;
118
}
119

    
120
/* End Patch_AdditionalDebugData_11823 */
121

    
122
#ifdef VL53L1_LOG_ENABLE
123

    
124
void  VL53L1_signed_fixed_point_sprintf(
125
        int32_t    signed_fp_value,
126
        uint8_t    frac_bits,
127
        uint16_t   buf_size,
128
        char      *pbuffer)
129
{
130
        /*
131
         * Converts input signed fixed point number into a string
132
         */
133

    
134
        uint32_t  fp_value      = 0;
135
        uint32_t  unity_fp_value = 0;
136
        uint32_t  sign_bit       = 0;
137
        uint32_t  int_part       = 0;
138
        uint32_t  frac_part      = 0;
139
        uint32_t  dec_points     = 0;
140
        uint32_t  dec_scaler     = 0;
141
        uint32_t  dec_part       = 0;
142

    
143
        uint64_t  tmp_long_int   = 0;
144

    
145
        char  fmt[VL53L1_MAX_STRING_LENGTH];
146

    
147
        SUPPRESS_UNUSED_WARNING(buf_size);
148

    
149
        /* split into integer and fractional values */
150

    
151
        sign_bit       =  signed_fp_value >> 31;
152

    
153
        if (sign_bit > 0) {
154
                fp_value = 0x80000000 -
155
                        (0x7FFFFFFF & (uint32_t)signed_fp_value);
156
        } else
157
                fp_value = (uint32_t)signed_fp_value;
158

    
159
        int_part       =  fp_value >> frac_bits;
160
        unity_fp_value =  0x01 << frac_bits;
161
        frac_part      =  fp_value & (unity_fp_value-1);
162

    
163
        /* Calculate decimal scale factor and required decimal points
164
         * min number of displayed places is 2
165
         */
166
        dec_points =   2;
167
        dec_scaler = 100;
168

    
169
        while (dec_scaler < unity_fp_value) {
170
                dec_points++;
171
                dec_scaler *= 10;
172
        }
173

    
174
        /* Build format string */
175
        if (sign_bit > 0)
176
                sprintf(fmt, "-%%u.%%0%uu", dec_points);
177
        else
178
                sprintf(fmt,  "%%u.%%0%uu", dec_points);
179

    
180
        /* Convert fractional part into a decimal
181
         * need 64-bit head room at this point
182
         */
183
        tmp_long_int  = (uint64_t)frac_part * (uint64_t)dec_scaler;
184
        tmp_long_int += (uint64_t)unity_fp_value/2;
185

    
186
        tmp_long_int = do_division_u(tmp_long_int, (uint64_t)unity_fp_value);
187

    
188
        dec_part = (uint32_t)tmp_long_int;
189

    
190
        /* Generate string for fixed point number */
191
        sprintf(
192
                pbuffer,
193
                fmt,
194
                int_part,
195
                dec_part);
196
}
197

    
198

    
199
void VL53L1_print_static_nvm_managed(
200
        VL53L1_static_nvm_managed_t   *pdata,
201
        char                          *pprefix,
202
        uint32_t                       trace_flags)
203
{
204
        /**
205
         * Prints out VL53L1_static_nvm_managed_t for debug
206
        */
207

    
208
        char  fp_text[VL53L1_MAX_STRING_LENGTH];
209

    
210
        trace_print(
211
                VL53L1_TRACE_LEVEL_INFO,
212
                "%s%s = 0x%02X\n",
213
                pprefix,
214
                "i2c_slave__device_address",
215
                pdata->i2c_slave__device_address);
216

    
217
        trace_print(
218
                VL53L1_TRACE_LEVEL_INFO,
219
                "%s%s = %u\n",
220
                pprefix,
221
                "ana_config__vhv_ref_sel_vddpix",
222
                pdata->ana_config__vhv_ref_sel_vddpix);
223

    
224
        trace_print(
225
                VL53L1_TRACE_LEVEL_INFO,
226
                "%s%s = %u\n",
227
                pprefix,
228
                "ana_config__vhv_ref_sel_vquench",
229
                pdata->ana_config__vhv_ref_sel_vquench);
230

    
231
        trace_print(
232
                VL53L1_TRACE_LEVEL_INFO,
233
                "%s%s = %u\n",
234
                pprefix,
235
                "ana_config__reg_avdd1v2_sel",
236
                pdata->ana_config__reg_avdd1v2_sel);
237

    
238
        trace_print(
239
                VL53L1_TRACE_LEVEL_INFO,
240
                "%s%s = %u\n",
241
                pprefix,
242
                "ana_config__fast_osc__trim",
243
                pdata->ana_config__fast_osc__trim);
244

    
245
        VL53L1_signed_fixed_point_sprintf(
246
                (int32_t)pdata->osc_measured__fast_osc__frequency,
247
                12,
248
                VL53L1_MAX_STRING_LENGTH,
249
                fp_text);
250

    
251
        trace_print(
252
                VL53L1_TRACE_LEVEL_INFO,
253
                "%s%s = %s\n",
254
                pprefix,
255
                "osc_measured__fast_osc__frequency",
256
                fp_text);
257

    
258
        trace_print(
259
                VL53L1_TRACE_LEVEL_INFO,
260
                "%s%s = %u\n",
261
                pprefix,
262
                "vhv_config__timeout_macrop_loop_bound",
263
                pdata->vhv_config__timeout_macrop_loop_bound);
264

    
265
        trace_print(
266
                VL53L1_TRACE_LEVEL_INFO,
267
                "%s%s = %u\n",
268
                pprefix,
269
                "vhv_config__count_thresh",
270
                pdata->vhv_config__count_thresh);
271

    
272
        trace_print(
273
                VL53L1_TRACE_LEVEL_INFO,
274
                "%s%s = %u\n",
275
                pprefix,
276
                "vhv_config__offset",
277
                pdata->vhv_config__offset);
278

    
279
        trace_print(
280
                VL53L1_TRACE_LEVEL_INFO,
281
                "%s%s = %u\n",
282
                pprefix,
283
                "vhv_config__init",
284
                pdata->vhv_config__init);
285
}
286

    
287

    
288
void VL53L1_print_customer_nvm_managed(
289
        VL53L1_customer_nvm_managed_t *pdata,
290
        char                          *pprefix,
291
        uint32_t                       trace_flags)
292
{
293
        /*
294
         * Prints out VL53L1_customer_nvm_managed_t for debug
295
         */
296

    
297
        char  fp_text[VL53L1_MAX_STRING_LENGTH];
298

    
299
        trace_print(VL53L1_TRACE_LEVEL_INFO,
300
                "%s%s = %u\n",
301
                pprefix,
302
                "global_config__spad_enables_ref_0",
303
                pdata->global_config__spad_enables_ref_0);
304

    
305
        trace_print(VL53L1_TRACE_LEVEL_INFO,
306
                "%s%s = %u\n",
307
                pprefix,
308
                "global_config__spad_enables_ref_1",
309
                pdata->global_config__spad_enables_ref_1);
310

    
311
        trace_print(VL53L1_TRACE_LEVEL_INFO,
312
                "%s%s = %u\n",
313
                pprefix,
314
                "global_config__spad_enables_ref_2",
315
                pdata->global_config__spad_enables_ref_2);
316

    
317
        trace_print(VL53L1_TRACE_LEVEL_INFO,
318
                "%s%s = %u\n",
319
                pprefix,
320
                "global_config__spad_enables_ref_3",
321
                pdata->global_config__spad_enables_ref_3);
322

    
323
        trace_print(VL53L1_TRACE_LEVEL_INFO,
324
                "%s%s = %u\n",
325
                pprefix,
326
                "global_config__spad_enables_ref_4",
327
                pdata->global_config__spad_enables_ref_4);
328

    
329
        trace_print(VL53L1_TRACE_LEVEL_INFO,
330
                "%s%s = %u\n",
331
                pprefix,
332
                "global_config__spad_enables_ref_5",
333
                pdata->global_config__spad_enables_ref_5);
334

    
335
        trace_print(VL53L1_TRACE_LEVEL_INFO,
336
                "%s%s = %u\n",
337
                pprefix,
338
                "global_config__ref_en_start_select",
339
                pdata->global_config__ref_en_start_select);
340

    
341
        trace_print(VL53L1_TRACE_LEVEL_INFO,
342
                "%s%s = %u\n",
343
                pprefix,
344
                "ref_spad_man__num_requested_ref_spads",
345
                pdata->ref_spad_man__num_requested_ref_spads);
346

    
347
        trace_print(VL53L1_TRACE_LEVEL_INFO,
348
                "%s%s = %u\n",
349
                pprefix,
350
                "ref_spad_man__ref_location",
351
                pdata->ref_spad_man__ref_location);
352

    
353
        VL53L1_signed_fixed_point_sprintf(
354
                (int32_t)pdata->algo__crosstalk_compensation_plane_offset_kcps,
355
                9,
356
                VL53L1_MAX_STRING_LENGTH,
357
                fp_text);
358

    
359
        trace_print(VL53L1_TRACE_LEVEL_INFO,
360
                "%s%s = %s\n",
361
                pprefix,
362
                "algo__crosstalk_compensation_plane_offset_kcps",
363
                fp_text);
364

    
365
        VL53L1_signed_fixed_point_sprintf(
366
                (int32_t)pdata->algo__crosstalk_compensation_x_plane_gradient_kcps,
367
                11,
368
                VL53L1_MAX_STRING_LENGTH,
369
                fp_text);
370

    
371
        trace_print(VL53L1_TRACE_LEVEL_INFO,
372
                "%s%s = %s\n",
373
                pprefix,
374
                "algo__crosstalk_compensation_x_plane_gradient_kcps",
375
                fp_text);
376

    
377
        VL53L1_signed_fixed_point_sprintf(
378
                (int32_t)pdata->algo__crosstalk_compensation_y_plane_gradient_kcps,
379
                11,
380
                VL53L1_MAX_STRING_LENGTH,
381
                fp_text);
382

    
383
        trace_print(VL53L1_TRACE_LEVEL_INFO,
384
                "%s%s = %s\n",
385
                pprefix,
386
                "algo__crosstalk_compensation_y_plane_gradient_kcps",
387
                fp_text);
388

    
389
        VL53L1_signed_fixed_point_sprintf(
390
                (int32_t)pdata->ref_spad_char__total_rate_target_mcps,
391
                7,
392
                VL53L1_MAX_STRING_LENGTH,
393
                fp_text);
394

    
395
        trace_print(VL53L1_TRACE_LEVEL_INFO,
396
                "%s%s = %s\n",
397
                pprefix,
398
                "ref_spad_char__total_rate_target_mcps",
399
                fp_text);
400

    
401
        VL53L1_signed_fixed_point_sprintf(
402
                (int32_t)pdata->algo__part_to_part_range_offset_mm,
403
                2,
404
                VL53L1_MAX_STRING_LENGTH,
405
                fp_text);
406

    
407
        trace_print(VL53L1_TRACE_LEVEL_INFO,
408
                "%s%s = %s\n",
409
                pprefix,
410
                "algo__part_to_part_range_offset_mm",
411
                fp_text);
412

    
413
        trace_print(VL53L1_TRACE_LEVEL_INFO,
414
                "%s%s = %d\n",
415
                pprefix,
416
                "mm_config__inner_offset_mm",
417
                pdata->mm_config__inner_offset_mm);
418

    
419
        trace_print(VL53L1_TRACE_LEVEL_INFO,
420
                "%s%s = %d\n",
421
                pprefix,
422
                "mm_config__outer_offset_mm",
423
                pdata->mm_config__outer_offset_mm);
424
}
425

    
426

    
427
void VL53L1_print_nvm_copy_data(
428
        VL53L1_nvm_copy_data_t      *pdata,
429
        char                        *pprefix,
430
        uint32_t                     trace_flags)
431
{
432
        /**
433
         * Prints out VL53L1_nvm_copy_data_t for debug
434
         */
435

    
436
        trace_print(
437
                VL53L1_TRACE_LEVEL_INFO,
438
                "%s%s = %u\n",
439
                pprefix,
440
                "identification__model_id",
441
                pdata->identification__model_id);
442

    
443
        trace_print(
444
                VL53L1_TRACE_LEVEL_INFO,
445
                "%s%s = %u\n",
446
                pprefix,
447
                "identification__module_type",
448
                pdata->identification__module_type);
449

    
450
        trace_print(
451
                VL53L1_TRACE_LEVEL_INFO,
452
                "%s%s = %u\n",
453
                pprefix,
454
                "identification__revision_id",
455
                pdata->identification__revision_id);
456

    
457
        trace_print(
458
                VL53L1_TRACE_LEVEL_INFO,
459
                "%s%s = %u\n",
460
                pprefix,
461
                "identification__module_id",
462
                pdata->identification__module_id);
463

    
464
        trace_print(
465
                VL53L1_TRACE_LEVEL_INFO,
466
                "%s%s = %u\n",
467
                pprefix,
468
                "ana_config__fast_osc__trim_max",
469
                pdata->ana_config__fast_osc__trim_max);
470

    
471
        trace_print(
472
                VL53L1_TRACE_LEVEL_INFO,
473
                "%s%s = %u\n",
474
                pprefix,
475
                "ana_config__fast_osc__freq_set",
476
                pdata->ana_config__fast_osc__freq_set);
477

    
478
        trace_print(
479
                VL53L1_TRACE_LEVEL_INFO,
480
                "%s%s = %u\n",
481
                pprefix,
482
                "ana_config__vcsel_trim",
483
                pdata->ana_config__vcsel_trim);
484

    
485
        trace_print(
486
                VL53L1_TRACE_LEVEL_INFO,
487
                "%s%s = %u\n",
488
                pprefix,
489
                "ana_config__vcsel_selion",
490
                pdata->ana_config__vcsel_selion);
491

    
492
        trace_print(
493
                VL53L1_TRACE_LEVEL_INFO,
494
                "%s%s = %u\n",
495
                pprefix,
496
                "ana_config__vcsel_selion_max",
497
                pdata->ana_config__vcsel_selion_max);
498

    
499
        trace_print(
500
                VL53L1_TRACE_LEVEL_INFO,
501
                "%s%s = %u\n",
502
                pprefix,
503
                "protected_laser_safety__lock_bit",
504
                pdata->protected_laser_safety__lock_bit);
505

    
506
        trace_print(
507
                VL53L1_TRACE_LEVEL_INFO,
508
                "%s%s = %u\n",
509
                pprefix,
510
                "laser_safety__key",
511
                pdata->laser_safety__key);
512

    
513
        trace_print(
514
                VL53L1_TRACE_LEVEL_INFO,
515
                "%s%s = %u\n",
516
                pprefix,
517
                "laser_safety__key_ro",
518
                pdata->laser_safety__key_ro);
519

    
520
        trace_print(
521
                VL53L1_TRACE_LEVEL_INFO,
522
                "%s%s = %u\n",
523
                pprefix,
524
                "laser_safety__clip",
525
                pdata->laser_safety__clip);
526

    
527
        trace_print(
528
                VL53L1_TRACE_LEVEL_INFO,
529
                "%s%s = %u\n",
530
                pprefix,
531
                "laser_safety__mult",
532
                pdata->laser_safety__mult);
533

    
534
        trace_print(
535
                VL53L1_TRACE_LEVEL_INFO,
536
                "%s%s = %u\n",
537
                pprefix,
538
                "global_config__spad_enables_rtn_0",
539
                pdata->global_config__spad_enables_rtn_0);
540

    
541
        trace_print(
542
                VL53L1_TRACE_LEVEL_INFO,
543
                "%s%s = %u\n",
544
                pprefix,
545
                "global_config__spad_enables_rtn_1",
546
                pdata->global_config__spad_enables_rtn_1);
547

    
548
        trace_print(
549
                VL53L1_TRACE_LEVEL_INFO,
550
                "%s%s = %u\n",
551
                pprefix,
552
                "global_config__spad_enables_rtn_2",
553
                pdata->global_config__spad_enables_rtn_2);
554

    
555
        trace_print(
556
                VL53L1_TRACE_LEVEL_INFO,
557
                "%s%s = %u\n",
558
                pprefix,
559
                "global_config__spad_enables_rtn_3",
560
                pdata->global_config__spad_enables_rtn_3);
561

    
562
        trace_print(
563
                VL53L1_TRACE_LEVEL_INFO,
564
                "%s%s = %u\n",
565
                pprefix,
566
                "global_config__spad_enables_rtn_4",
567
                pdata->global_config__spad_enables_rtn_4);
568

    
569
        trace_print(
570
                VL53L1_TRACE_LEVEL_INFO,
571
                "%s%s = %u\n",
572
                pprefix,
573
                "global_config__spad_enables_rtn_5",
574
                pdata->global_config__spad_enables_rtn_5);
575

    
576
        trace_print(
577
                VL53L1_TRACE_LEVEL_INFO,
578
                "%s%s = %u\n",
579
                pprefix,
580
                "global_config__spad_enables_rtn_6",
581
                pdata->global_config__spad_enables_rtn_6);
582

    
583
        trace_print(
584
                VL53L1_TRACE_LEVEL_INFO,
585
                "%s%s = %u\n",
586
                pprefix,
587
                "global_config__spad_enables_rtn_7",
588
                pdata->global_config__spad_enables_rtn_7);
589

    
590
        trace_print(
591
                VL53L1_TRACE_LEVEL_INFO,
592
                "%s%s = %u\n",
593
                pprefix,
594
                "global_config__spad_enables_rtn_8",
595
                pdata->global_config__spad_enables_rtn_8);
596

    
597
        trace_print(
598
                VL53L1_TRACE_LEVEL_INFO,
599
                "%s%s = %u\n",
600
                pprefix,
601
                "global_config__spad_enables_rtn_9",
602
                pdata->global_config__spad_enables_rtn_9);
603

    
604
        trace_print(
605
                VL53L1_TRACE_LEVEL_INFO,
606
                "%s%s = %u\n",
607
                pprefix,
608
                "global_config__spad_enables_rtn_10",
609
                pdata->global_config__spad_enables_rtn_10);
610

    
611
        trace_print(
612
                VL53L1_TRACE_LEVEL_INFO,
613
                "%s%s = %u\n",
614
                pprefix,
615
                "global_config__spad_enables_rtn_11",
616
                pdata->global_config__spad_enables_rtn_11);
617

    
618
        trace_print(
619
                VL53L1_TRACE_LEVEL_INFO,
620
                "%s%s = %u\n",
621
                pprefix,
622
                "global_config__spad_enables_rtn_12",
623
                pdata->global_config__spad_enables_rtn_12);
624

    
625
        trace_print(
626
                VL53L1_TRACE_LEVEL_INFO,
627
                "%s%s = %u\n",
628
                pprefix,
629
                "global_config__spad_enables_rtn_13",
630
                pdata->global_config__spad_enables_rtn_13);
631

    
632
        trace_print(
633
                VL53L1_TRACE_LEVEL_INFO,
634
                "%s%s = %u\n",
635
                pprefix,
636
                "global_config__spad_enables_rtn_14",
637
                pdata->global_config__spad_enables_rtn_14);
638

    
639
        trace_print(
640
                VL53L1_TRACE_LEVEL_INFO,
641
                "%s%s = %u\n",
642
                pprefix,
643
                "global_config__spad_enables_rtn_15",
644
                pdata->global_config__spad_enables_rtn_15);
645

    
646
        trace_print(
647
                VL53L1_TRACE_LEVEL_INFO,
648
                "%s%s = %u\n",
649
                pprefix,
650
                "global_config__spad_enables_rtn_16",
651
                pdata->global_config__spad_enables_rtn_16);
652

    
653
        trace_print(
654
                VL53L1_TRACE_LEVEL_INFO,
655
                "%s%s = %u\n",
656
                pprefix,
657
                "global_config__spad_enables_rtn_17",
658
                pdata->global_config__spad_enables_rtn_17);
659

    
660
        trace_print(
661
                VL53L1_TRACE_LEVEL_INFO,
662
                "%s%s = %u\n",
663
                pprefix,
664
                "global_config__spad_enables_rtn_18",
665
                pdata->global_config__spad_enables_rtn_18);
666

    
667
        trace_print(
668
                VL53L1_TRACE_LEVEL_INFO,
669
                "%s%s = %u\n",
670
                pprefix,
671
                "global_config__spad_enables_rtn_19",
672
                pdata->global_config__spad_enables_rtn_19);
673

    
674
        trace_print(
675
                VL53L1_TRACE_LEVEL_INFO,
676
                "%s%s = %u\n",
677
                pprefix,
678
                "global_config__spad_enables_rtn_20",
679
                pdata->global_config__spad_enables_rtn_20);
680

    
681
        trace_print(
682
                VL53L1_TRACE_LEVEL_INFO,
683
                "%s%s = %u\n",
684
                pprefix,
685
                "global_config__spad_enables_rtn_21",
686
                pdata->global_config__spad_enables_rtn_21);
687

    
688
        trace_print(
689
                VL53L1_TRACE_LEVEL_INFO,
690
                "%s%s = %u\n",
691
                pprefix,
692
                "global_config__spad_enables_rtn_22",
693
                pdata->global_config__spad_enables_rtn_22);
694

    
695
        trace_print(
696
                VL53L1_TRACE_LEVEL_INFO,
697
                "%s%s = %u\n",
698
                pprefix,
699
                "global_config__spad_enables_rtn_23",
700
                pdata->global_config__spad_enables_rtn_23);
701

    
702
        trace_print(
703
                VL53L1_TRACE_LEVEL_INFO,
704
                "%s%s = %u\n",
705
                pprefix,
706
                "global_config__spad_enables_rtn_24",
707
                pdata->global_config__spad_enables_rtn_24);
708

    
709
        trace_print(
710
                VL53L1_TRACE_LEVEL_INFO,
711
                "%s%s = %u\n",
712
                pprefix,
713
                "global_config__spad_enables_rtn_25",
714
                pdata->global_config__spad_enables_rtn_25);
715

    
716
        trace_print(
717
                VL53L1_TRACE_LEVEL_INFO,
718
                "%s%s = %u\n",
719
                pprefix,
720
                "global_config__spad_enables_rtn_26",
721
                pdata->global_config__spad_enables_rtn_26);
722

    
723
        trace_print(
724
                VL53L1_TRACE_LEVEL_INFO,
725
                "%s%s = %u\n",
726
                pprefix,
727
                "global_config__spad_enables_rtn_27",
728
                pdata->global_config__spad_enables_rtn_27);
729

    
730
        trace_print(
731
                VL53L1_TRACE_LEVEL_INFO,
732
                "%s%s = %u\n",
733
                pprefix,
734
                "global_config__spad_enables_rtn_28",
735
                pdata->global_config__spad_enables_rtn_28);
736

    
737
        trace_print(
738
                VL53L1_TRACE_LEVEL_INFO,
739
                "%s%s = %u\n",
740
                pprefix,
741
                "global_config__spad_enables_rtn_29",
742
                pdata->global_config__spad_enables_rtn_29);
743

    
744
        trace_print(
745
                VL53L1_TRACE_LEVEL_INFO,
746
                "%s%s = %u\n",
747
                pprefix,
748
                "global_config__spad_enables_rtn_30",
749
                pdata->global_config__spad_enables_rtn_30);
750

    
751
        trace_print(
752
                VL53L1_TRACE_LEVEL_INFO,
753
                "%s%s = %u\n",
754
                pprefix,
755
                "global_config__spad_enables_rtn_31",
756
                pdata->global_config__spad_enables_rtn_31);
757

    
758
        trace_print(
759
                VL53L1_TRACE_LEVEL_INFO,
760
                "%s%s = %u\n",
761
                pprefix,
762
                "roi_config__mode_roi_centre_spad",
763
                pdata->roi_config__mode_roi_centre_spad);
764

    
765
        trace_print(
766
                VL53L1_TRACE_LEVEL_INFO,
767
                "%s%s = 0x%02X\n",
768
                pprefix,
769
                "roi_config__mode_roi_xy_size",
770
                pdata->roi_config__mode_roi_xy_size);
771
}
772

    
773

    
774
void VL53L1_print_range_data(
775
        VL53L1_range_data_t *pdata,
776
        char                *pprefix,
777
        uint32_t             trace_flags)
778
{
779
        /*
780
         * Prints out the range data structure for debug
781
         */
782

    
783
        char  fp_text[VL53L1_MAX_STRING_LENGTH];
784

    
785
        trace_print(
786
                VL53L1_TRACE_LEVEL_INFO,
787
                "%s%s = %u\n",
788
                pprefix,
789
                "range_id",
790
                pdata->range_id);
791

    
792
        trace_print(
793
                VL53L1_TRACE_LEVEL_INFO,
794
                "%s%s = %u\n",
795
                pprefix,
796
                "time_stamp",
797
                pdata->time_stamp);
798

    
799
        VL53L1_signed_fixed_point_sprintf(
800
                (int32_t)pdata->width,
801
                 4,        VL53L1_MAX_STRING_LENGTH, fp_text);
802

    
803
        trace_print(
804
                VL53L1_TRACE_LEVEL_INFO,
805
                "%s%s = %s\n",
806
                pprefix,
807
                "width",
808
                fp_text);
809

    
810
        trace_print(
811
                VL53L1_TRACE_LEVEL_INFO,
812
                "%s%s = %u\n",
813
                pprefix,
814
                "woi",
815
                pdata->woi);
816

    
817
        /* Fast Oscillator Frequency */
818

    
819
        VL53L1_signed_fixed_point_sprintf(
820
                (int32_t)pdata->fast_osc_frequency,
821
                12,        VL53L1_MAX_STRING_LENGTH, fp_text);
822

    
823
        trace_print(
824
                VL53L1_TRACE_LEVEL_INFO,
825
                "%s%s = %s\n",
826
                pprefix,
827
                "fast_osc_frequency",
828
                fp_text);
829

    
830
        /* Zero Distance Phase */
831

    
832
        VL53L1_signed_fixed_point_sprintf(
833
                (int32_t)pdata->zero_distance_phase,
834
                11, VL53L1_MAX_STRING_LENGTH, fp_text);
835

    
836
        trace_print(
837
                VL53L1_TRACE_LEVEL_INFO,
838
                "%s%s = %s\n",
839
                pprefix,
840
                "zero_distance_phase",
841
                fp_text);
842

    
843
        /* Actual effective SPAD count */
844

    
845
        VL53L1_signed_fixed_point_sprintf(
846
                (int32_t)pdata->actual_effective_spads,
847
                8, VL53L1_MAX_STRING_LENGTH, fp_text);
848

    
849
        trace_print(
850
                VL53L1_TRACE_LEVEL_INFO,
851
                "%s%s = %s\n",
852
                pprefix,
853
                "actual_effective_spad",
854
                fp_text);
855

    
856

    
857
        trace_print(VL53L1_TRACE_LEVEL_INFO,
858
                "%s%s = %u\n",
859
                pprefix,
860
                "total_periods_elapsed",
861
                pdata->total_periods_elapsed);
862

    
863
        trace_print(
864
                VL53L1_TRACE_LEVEL_INFO,
865
                "%s%s = %u\n",
866
                pprefix,
867
                "peak_duration_us",
868
                pdata->peak_duration_us);
869

    
870
        trace_print(
871
                VL53L1_TRACE_LEVEL_INFO,
872
                "%s%s = %u\n",
873
                pprefix,
874
                "woi_duration_us",
875
                pdata->woi_duration_us);
876

    
877
        trace_print(
878
                        VL53L1_TRACE_LEVEL_INFO,
879
                "%s%s = %d\n",
880
                pprefix,
881
                        "ambient_window_events",
882
                        pdata->ambient_window_events);
883

    
884
        trace_print(
885
                        VL53L1_TRACE_LEVEL_INFO,
886
                "%s%s = %d\n",
887
                pprefix,
888
                        "ranging_total_events",
889
                        pdata->ranging_total_events);
890

    
891
        trace_print(
892
                        VL53L1_TRACE_LEVEL_INFO,
893
                "%s%s = %d\n",
894
                pprefix,
895
                        "signal_total_events",
896
                        pdata->signal_total_events);
897

    
898
        /* Rates */
899

    
900
        VL53L1_signed_fixed_point_sprintf(
901
                (int32_t)pdata->peak_signal_count_rate_mcps,
902
                7, VL53L1_MAX_STRING_LENGTH, fp_text);
903

    
904
        trace_print(
905
                VL53L1_TRACE_LEVEL_INFO,
906
                "%s%s = %s\n",
907
                pprefix,
908
                "peak_signal_count_rate_mcps",
909
                fp_text);
910

    
911
        VL53L1_signed_fixed_point_sprintf(
912
                (int32_t)pdata->avg_signal_count_rate_mcps,
913
                7, VL53L1_MAX_STRING_LENGTH, fp_text);
914

    
915
        trace_print(
916
                VL53L1_TRACE_LEVEL_INFO,
917
                "%s%s = %s\n",
918
                pprefix,
919
                "avg_signal_count_rate_mcps",
920
                fp_text);
921

    
922
        VL53L1_signed_fixed_point_sprintf(
923
                (int32_t)pdata->ambient_count_rate_mcps,
924
                7, VL53L1_MAX_STRING_LENGTH, fp_text);
925

    
926
        trace_print(
927
                VL53L1_TRACE_LEVEL_INFO,
928
                "%s%s = %s\n",
929
                pprefix,
930
                "ambient_count_rate_mcps",
931
                fp_text);
932

    
933
        VL53L1_signed_fixed_point_sprintf(
934
                (int32_t)pdata->total_rate_per_spad_mcps,
935
                13, VL53L1_MAX_STRING_LENGTH, fp_text);
936

    
937
        trace_print(
938
                VL53L1_TRACE_LEVEL_INFO,
939
                "%s%s = %s\n",
940
                pprefix,
941
                "total_rate_per_spad_mcps",
942
                fp_text);
943

    
944
        VL53L1_signed_fixed_point_sprintf(
945
                (int32_t)pdata->peak_rate_per_spad_kcps,
946
                11, VL53L1_MAX_STRING_LENGTH, fp_text);
947

    
948
        trace_print(
949
                VL53L1_TRACE_LEVEL_INFO,
950
                "%s%s = %s\n",
951
                pprefix,
952
                "peak_rate_per_spad_kcps",
953
                fp_text);
954

    
955
        /* Sigma */
956

    
957
        VL53L1_signed_fixed_point_sprintf(
958
                (int32_t)pdata->sigma_mm,
959
                 2,        VL53L1_MAX_STRING_LENGTH, fp_text);
960

    
961
        trace_print(
962
                VL53L1_TRACE_LEVEL_INFO,
963
                "%s%s = %s\n",
964
                pprefix,
965
                "sigma_mm",
966
                fp_text);
967

    
968
        /* Phase */
969

    
970
        VL53L1_signed_fixed_point_sprintf(
971
                (int32_t)pdata->median_phase,
972
                11,        VL53L1_MAX_STRING_LENGTH, fp_text);
973

    
974
        trace_print(
975
                VL53L1_TRACE_LEVEL_INFO,
976
                "%s%s = %s\n",
977
                pprefix,
978
                "median_phase",
979
                fp_text);
980

    
981
        /* Offset Corrected Range */
982

    
983
        trace_print(
984
                VL53L1_TRACE_LEVEL_INFO,
985
                "%s%s = %d\n",
986
                pprefix,
987
                "median_range_mm",
988
                pdata->median_range_mm);
989

    
990
        trace_print(
991
                VL53L1_TRACE_LEVEL_INFO,
992
                "%s%s = %u\n",
993
                pprefix,
994
                "range_status",
995
                pdata->range_status);
996
}
997

    
998

    
999
void VL53L1_print_range_results(
1000
        VL53L1_range_results_t *pdata,
1001
        char                   *pprefix,
1002
        uint32_t                trace_flags)
1003
{
1004
        /*
1005
         * Prints out the range results data structure for debug
1006
         */
1007

    
1008
        trace_print(
1009
                VL53L1_TRACE_LEVEL_INFO,
1010
                "%s%s = %u\n",
1011
                pprefix,
1012
                "cfg_device_state",
1013
                pdata->cfg_device_state);
1014

    
1015
        trace_print(
1016
                VL53L1_TRACE_LEVEL_INFO,
1017
                "%s%s = %u\n",
1018
                pprefix,
1019
                "rd_device_state",
1020
                pdata->rd_device_state);
1021

    
1022
        trace_print(
1023
                VL53L1_TRACE_LEVEL_INFO,
1024
                "%s%s = %u\n",
1025
                pprefix,
1026
                "stream_count",
1027
                pdata->stream_count);
1028

    
1029
        trace_print(
1030
                        VL53L1_TRACE_LEVEL_INFO,
1031
                        "%s%s = %u\n",
1032
                        pprefix,
1033
                        "device_status",
1034
                        pdata->device_status);
1035

    
1036
}
1037

    
1038
void VL53L1_print_offset_range_results(
1039
        VL53L1_offset_range_results_t *pdata,
1040
        char                          *pprefix,
1041
        uint32_t                       trace_flags)
1042
{
1043
        /*
1044
         * Prints out the offset range results data structure for debug
1045
         */
1046

    
1047
        char  pre_text[VL53L1_MAX_STRING_LENGTH];
1048
        char *ppre_text = &(pre_text[0]);
1049

    
1050
        uint8_t  i = 0;
1051

    
1052
        trace_print(
1053
                VL53L1_TRACE_LEVEL_INFO,
1054
                "%s%s = %u\n",
1055
                pprefix,
1056
                "cal_distance_mm",
1057
                pdata->cal_distance_mm);
1058

    
1059
        trace_print(
1060
                VL53L1_TRACE_LEVEL_INFO,
1061
                "%s%s = %u\n",
1062
                pprefix,
1063
                "cal_status",
1064
                pdata->cal_status);
1065

    
1066
        trace_print(
1067
                VL53L1_TRACE_LEVEL_INFO,
1068
                "%s%s = %u\n",
1069
                pprefix,
1070
                "cal_report",
1071
                pdata->cal_report);
1072

    
1073
        trace_print(
1074
                VL53L1_TRACE_LEVEL_INFO,
1075
                "%s%s = %u\n",
1076
                pprefix,
1077
                "max_results",
1078
                pdata->max_results);
1079

    
1080
        trace_print(
1081
                VL53L1_TRACE_LEVEL_INFO,
1082
                "%s%s = %u\n",
1083
                pprefix,
1084
                "active_results",
1085
                pdata->active_results);
1086

    
1087
        for (i = 0 ; i < pdata->active_results ; i++) {
1088
                sprintf(ppre_text, "%sdata[%u].", pprefix, i);
1089
                VL53L1_print_offset_range_data(
1090
                        &(pdata->data[i]),
1091
                        ppre_text, trace_flags);
1092
        }
1093
}
1094

    
1095
void VL53L1_print_offset_range_data(
1096
        VL53L1_offset_range_data_t *pdata,
1097
        char                       *pprefix,
1098
        uint32_t                    trace_flags)
1099
{
1100
        /*
1101
         * Prints out the xtalk range (ROI) data structure for debug
1102
         */
1103

    
1104
        char  fp_text[VL53L1_MAX_STRING_LENGTH];
1105

    
1106
        trace_print(
1107
                VL53L1_TRACE_LEVEL_INFO,
1108
                "%s%s = %u\n",
1109
                pprefix,
1110
                "preset_mode",
1111
                pdata->preset_mode);
1112

    
1113
        trace_print(
1114
                VL53L1_TRACE_LEVEL_INFO,
1115
                "%s%s = %u\n",
1116
                pprefix,
1117
                "dss_config__roi_mode_control",
1118
                pdata->dss_config__roi_mode_control);
1119

    
1120
        VL53L1_signed_fixed_point_sprintf(
1121
                (int32_t)pdata->dss_config__manual_effective_spads_select,
1122
                8,
1123
                VL53L1_MAX_STRING_LENGTH,
1124
                fp_text);
1125

    
1126
        trace_print(
1127
                VL53L1_TRACE_LEVEL_INFO,
1128
                "%s%s = %s\n",
1129
                pprefix,
1130
                "dss_config__manual_effective_spads_select",
1131
                fp_text);
1132

    
1133
        trace_print(
1134
                VL53L1_TRACE_LEVEL_INFO,
1135
                "%s%s = %u\n",
1136
                pprefix,
1137
                "no_of_samples",
1138
                pdata->no_of_samples);
1139

    
1140

    
1141
        VL53L1_signed_fixed_point_sprintf(
1142
                (int32_t)pdata->effective_spads,
1143
                8,
1144
                VL53L1_MAX_STRING_LENGTH,
1145
                fp_text);
1146

    
1147
        trace_print(
1148
                VL53L1_TRACE_LEVEL_INFO,
1149
                "%s%s = %s\n",
1150
                pprefix,
1151
                "effective_spads",
1152
                fp_text);
1153

    
1154
        VL53L1_signed_fixed_point_sprintf(
1155
                (int32_t)pdata->peak_rate_mcps,
1156
                7,
1157
                VL53L1_MAX_STRING_LENGTH,
1158
                fp_text);
1159

    
1160
        trace_print(
1161
                VL53L1_TRACE_LEVEL_INFO,
1162
                "%s%s = %s\n",
1163
                pprefix,
1164
                "peak_rate_mcps",
1165
                fp_text);
1166

    
1167
        VL53L1_signed_fixed_point_sprintf(
1168
                (int32_t)pdata->sigma_mm,
1169
                2,
1170
                VL53L1_MAX_STRING_LENGTH,
1171
                fp_text);
1172

    
1173
        trace_print(
1174
                VL53L1_TRACE_LEVEL_INFO,
1175
                "%s%s = %s\n",
1176
                pprefix,
1177
                "sigma_mm",
1178
                fp_text);
1179

    
1180
        trace_print(
1181
                VL53L1_TRACE_LEVEL_INFO,
1182
                "%s%s = %d\n",
1183
                pprefix,
1184
                "median_range_mm",
1185
                pdata->median_range_mm);
1186

    
1187
        trace_print(
1188
                VL53L1_TRACE_LEVEL_INFO,
1189
                "%s%s = %d\n",
1190
                pprefix,
1191
                "range_mm_offset",
1192
                pdata->range_mm_offset);
1193
}
1194

    
1195
void VL53L1_print_additional_offset_cal_data(
1196
        VL53L1_additional_offset_cal_data_t *pdata,
1197
        char                                *pprefix,
1198
        uint32_t                             trace_flags)
1199
{
1200
        /*
1201
         * Prints out the xtalk range (ROI) data structure for debug
1202
         */
1203

    
1204
        char  fp_text[VL53L1_MAX_STRING_LENGTH];
1205

    
1206
        VL53L1_signed_fixed_point_sprintf(
1207
                (int32_t)pdata->result__mm_inner_actual_effective_spads,
1208
                8,
1209
                VL53L1_MAX_STRING_LENGTH,
1210
                fp_text);
1211

    
1212
        trace_print(
1213
                VL53L1_TRACE_LEVEL_INFO,
1214
                "%s%s = %s\n",
1215
                pprefix,
1216
                "result__mm_inner_actual_effective_spads",
1217
                fp_text);
1218

    
1219
        VL53L1_signed_fixed_point_sprintf(
1220
                (int32_t)pdata->result__mm_outer_actual_effective_spads,
1221
                8,
1222
                VL53L1_MAX_STRING_LENGTH,
1223
                fp_text);
1224

    
1225
        trace_print(
1226
                VL53L1_TRACE_LEVEL_INFO,
1227
                "%s%s = %s\n",
1228
                pprefix,
1229
                "result__mm_outer_actual_effective_spads",
1230
                fp_text);
1231

    
1232
        VL53L1_signed_fixed_point_sprintf(
1233
                (int32_t)pdata->result__mm_inner_peak_signal_count_rtn_mcps,
1234
                7,
1235
                VL53L1_MAX_STRING_LENGTH,
1236
                fp_text);
1237

    
1238
        trace_print(
1239
                VL53L1_TRACE_LEVEL_INFO,
1240
                "%s%s = %s\n",
1241
                pprefix,
1242
                "result__mm_inner_peak_signal_count_rtn_mcps",
1243
                fp_text);
1244

    
1245
        VL53L1_signed_fixed_point_sprintf(
1246
                (int32_t)pdata->result__mm_outer_peak_signal_count_rtn_mcps,
1247
                7,
1248
                VL53L1_MAX_STRING_LENGTH,
1249
                fp_text);
1250

    
1251
        trace_print(
1252
                VL53L1_TRACE_LEVEL_INFO,
1253
                "%s%s = %s\n",
1254
                pprefix,
1255
                "result__mm_outer_peak_signal_count_rtn_mcps",
1256
                fp_text);
1257
}
1258

    
1259

    
1260
void VL53L1_print_cal_peak_rate_map(
1261
        VL53L1_cal_peak_rate_map_t *pdata,
1262
        char                       *pprefix,
1263
        uint32_t                    trace_flags)
1264
{
1265
        /*
1266
         * Prints out peak rate map structure for debug
1267
         */
1268

    
1269
        char  fp_text[VL53L1_MAX_STRING_LENGTH];
1270
        char  pre_text[VL53L1_MAX_STRING_LENGTH];
1271
        char *ppre_text = &(pre_text[0]);
1272

    
1273
        uint8_t   i = 0;
1274
        uint8_t   x = 0;
1275
        uint8_t   y = 0;
1276

    
1277
        VL53L1_signed_fixed_point_sprintf(
1278
                (int32_t)pdata->cal_distance_mm,
1279
                2,
1280
                VL53L1_MAX_STRING_LENGTH,
1281
                fp_text);
1282

    
1283
        trace_print(
1284
                VL53L1_TRACE_LEVEL_INFO,
1285
                "%s%s = %s\n",
1286
                pprefix,
1287
                "cal_distance_mm",
1288
                fp_text);
1289

    
1290
        trace_print(
1291
                VL53L1_TRACE_LEVEL_INFO,
1292
                "%s%s = %u\n",
1293
                pprefix,
1294
                "max_samples",
1295
                pdata->max_samples);
1296

    
1297
        trace_print(
1298
                VL53L1_TRACE_LEVEL_INFO,
1299
                "%s%s = %u\n",
1300
                pprefix,
1301
                "width",
1302
                pdata->width);
1303

    
1304
        trace_print(
1305
        VL53L1_TRACE_LEVEL_INFO,
1306
        "%s%s = %u\n",
1307
        pprefix,
1308
        "height",
1309
        pdata->height);
1310

    
1311
        i = 0;
1312
        for (y = 0 ; y < pdata->height ; y++) {
1313
                for (x = 0 ; x < pdata->width ; x++) {
1314

    
1315
                        sprintf(ppre_text, "%speak_rate_mcps[%u]", pprefix, i);
1316

    
1317
                        VL53L1_signed_fixed_point_sprintf(
1318
                                (int32_t)pdata->peak_rate_mcps[i],
1319
                                7,
1320
                                VL53L1_MAX_STRING_LENGTH,
1321
                                fp_text);
1322

    
1323
                        trace_print(
1324
                                VL53L1_TRACE_LEVEL_INFO,
1325
                                "%s = %s\n",
1326
                                ppre_text,
1327
                                fp_text);
1328

    
1329
                        i++;
1330
                }
1331
        }
1332
}
1333

    
1334
void VL53L1_print_additional_data(
1335
        VL53L1_additional_data_t *pdata,
1336
        char                     *pprefix,
1337
        uint32_t                 trace_flags)
1338
{
1339

    
1340
        /*
1341
         * Prints out the Additional data structure for debug
1342
         */
1343

    
1344
        char  fp_text[VL53L1_MAX_STRING_LENGTH];
1345

    
1346
        trace_print(
1347
                VL53L1_TRACE_LEVEL_INFO,
1348
                "%s%s = %u\n",
1349
                pprefix,
1350
                "preset_mode",
1351
                pdata->preset_mode);
1352

    
1353
        trace_print(
1354
                VL53L1_TRACE_LEVEL_INFO,
1355
                "%s%s = %u\n",
1356
                pprefix,
1357
                "measurement_mode",
1358
                pdata->measurement_mode);
1359

    
1360
        trace_print(
1361
                VL53L1_TRACE_LEVEL_INFO,
1362
                "%s%s = %u\n",
1363
                pprefix,
1364
                "phasecal_config_timeout_us",
1365
                pdata->phasecal_config_timeout_us);
1366

    
1367
        trace_print(
1368
                VL53L1_TRACE_LEVEL_INFO,
1369
                "%s%s = %u\n",
1370
                pprefix,
1371
                "mm_config_timeout_us",
1372
                pdata->mm_config_timeout_us);
1373

    
1374
        trace_print(
1375
                VL53L1_TRACE_LEVEL_INFO,
1376
                "%s%s = %u\n",
1377
                pprefix,
1378
                "range_config_timeout_us",
1379
                pdata->range_config_timeout_us);
1380

    
1381
        trace_print(
1382
                VL53L1_TRACE_LEVEL_INFO,
1383
                "%s%s = %u\n",
1384
                pprefix,
1385
                "inter_measurement_period_ms",
1386
                pdata->inter_measurement_period_ms);
1387

    
1388

    
1389
        VL53L1_signed_fixed_point_sprintf(
1390
                (int32_t)pdata->dss_config__target_total_rate_mcps,
1391
                7,
1392
                VL53L1_MAX_STRING_LENGTH,
1393
                fp_text);
1394

    
1395
        trace_print(
1396
                VL53L1_TRACE_LEVEL_INFO,
1397
                "%s%s = %s\n",
1398
                pprefix,
1399
                "dss_config__target_total_rate_mcps",
1400
                fp_text);
1401

    
1402
}
1403

    
1404

    
1405
void VL53L1_print_gain_calibration_data(
1406
        VL53L1_gain_calibration_data_t *pdata,
1407
        char                           *pprefix,
1408
        uint32_t                        trace_flags)
1409
{
1410
        /*
1411
         * Prints out the LL Driver state data for debug
1412
         */
1413

    
1414
        char  fp_text[VL53L1_MAX_STRING_LENGTH];
1415

    
1416
        VL53L1_signed_fixed_point_sprintf(
1417
                (int32_t)pdata->standard_ranging_gain_factor,
1418
                11,
1419
                VL53L1_MAX_STRING_LENGTH,
1420
                fp_text);
1421

    
1422
        trace_print(
1423
                VL53L1_TRACE_LEVEL_INFO,
1424
                "%s%s = %s\n",
1425
                pprefix,
1426
                "standard_ranging_gain_factor",
1427
                fp_text);
1428

    
1429
}
1430

    
1431

    
1432
void VL53L1_print_xtalk_config(
1433
        VL53L1_xtalk_config_t *pdata,
1434
        char                  *pprefix,
1435
        uint32_t               trace_flags)
1436
{
1437
        /*
1438
         * Prints out the xtalk config data structure for debug
1439
         */
1440

    
1441
        char  fp_text[VL53L1_MAX_STRING_LENGTH];
1442

    
1443
        VL53L1_signed_fixed_point_sprintf(
1444
                (int32_t)pdata->algo__crosstalk_compensation_plane_offset_kcps,
1445
                9,
1446
                VL53L1_MAX_STRING_LENGTH,
1447
                fp_text);
1448

    
1449
        trace_print(
1450
                VL53L1_TRACE_LEVEL_INFO,
1451
                "%s%s = %s\n",
1452
                pprefix,
1453
                "algo__crosstalk_compensation_plane_offset_kcps",
1454
                fp_text);
1455

    
1456
        VL53L1_signed_fixed_point_sprintf(
1457
                (int32_t)pdata->algo__crosstalk_compensation_x_plane_gradient_kcps,
1458
                11,
1459
                VL53L1_MAX_STRING_LENGTH,
1460
                fp_text);
1461

    
1462
        trace_print(
1463
                VL53L1_TRACE_LEVEL_INFO,
1464
                "%s%s = %s\n",
1465
                pprefix,
1466
                "algo__crosstalk_compensation_x_plane_gradient_kcps",
1467
                fp_text);
1468

    
1469
        VL53L1_signed_fixed_point_sprintf(
1470
                (int32_t)pdata->algo__crosstalk_compensation_y_plane_gradient_kcps,
1471
                11,
1472
                VL53L1_MAX_STRING_LENGTH,
1473
                fp_text);
1474

    
1475
        trace_print(
1476
                VL53L1_TRACE_LEVEL_INFO,
1477
                "%s%s = %s\n",
1478
                pprefix,
1479
                "algo__crosstalk_compensation_y_plane_gradient_kcps",
1480
                fp_text);
1481

    
1482
        trace_print(
1483
                VL53L1_TRACE_LEVEL_INFO,
1484
                "%s%s = %u\n",
1485
                pprefix,
1486
                "global_crosstalk_compensation_enable",
1487
                pdata->global_crosstalk_compensation_enable);
1488

    
1489
        VL53L1_signed_fixed_point_sprintf(
1490
                (int32_t)pdata->lite_mode_crosstalk_margin_kcps,
1491
                9,
1492
                VL53L1_MAX_STRING_LENGTH,
1493
                fp_text);
1494

    
1495
        trace_print(
1496
                VL53L1_TRACE_LEVEL_INFO,
1497
                "%s%s = %s\n",
1498
                pprefix,
1499
                "lite_mode_crosstalk_margin_kcps",
1500
                fp_text);
1501

    
1502
        VL53L1_signed_fixed_point_sprintf(
1503
                (int32_t)pdata->crosstalk_range_ignore_threshold_mult,
1504
                5,
1505
                VL53L1_MAX_STRING_LENGTH,
1506
                fp_text);
1507

    
1508
        trace_print(
1509
                VL53L1_TRACE_LEVEL_INFO,
1510
                "%s%s = %s\n",
1511
                pprefix,
1512
                "crosstalk_range_ignore_threshold_mult",
1513
                fp_text);
1514

    
1515

    
1516
        VL53L1_signed_fixed_point_sprintf(
1517
                (int32_t)pdata->crosstalk_range_ignore_threshold_rate_mcps,
1518
                13,
1519
                VL53L1_MAX_STRING_LENGTH,
1520
                fp_text);
1521

    
1522
        trace_print(
1523
                VL53L1_TRACE_LEVEL_INFO,
1524
                "%s%s = %s\n",
1525
                pprefix,
1526
                "crosstalk_range_ignore_threshold_rate_mcps",
1527
                fp_text);
1528

    
1529
}
1530

    
1531

    
1532

    
1533
void VL53L1_print_optical_centre(
1534
        VL53L1_optical_centre_t  *pdata,
1535
        char                     *pprefix,
1536
        uint32_t                  trace_flags)
1537
{
1538

    
1539
        /* Prints out the optical centre data structure for debug
1540
         */
1541

    
1542
        char  fp_text[VL53L1_MAX_STRING_LENGTH];
1543

    
1544
        VL53L1_signed_fixed_point_sprintf(
1545
                (int32_t)pdata->x_centre,
1546
                4,
1547
                VL53L1_MAX_STRING_LENGTH,
1548
                fp_text);
1549

    
1550
        trace_print(
1551
                VL53L1_TRACE_LEVEL_INFO,
1552
                "%s%s = %s\n",
1553
                pprefix,
1554
                "x_centre",
1555
                fp_text);
1556

    
1557
        VL53L1_signed_fixed_point_sprintf(
1558
                (int32_t)pdata->y_centre,
1559
                4,
1560
                VL53L1_MAX_STRING_LENGTH,
1561
                fp_text);
1562

    
1563
        trace_print(
1564
                VL53L1_TRACE_LEVEL_INFO,
1565
                "%s%s = %s\n",
1566
                pprefix,
1567
                "y_centre",
1568
                fp_text);
1569
}
1570

    
1571

    
1572
void VL53L1_print_user_zone(
1573
        VL53L1_user_zone_t   *pdata,
1574
        char                 *pprefix,
1575
        uint32_t              trace_flags)
1576
{
1577

    
1578
        /* Prints out the zone (ROI) data structure for debug
1579
         */
1580

    
1581
        trace_print(
1582
                VL53L1_TRACE_LEVEL_INFO,
1583
                "%s%s = %u\n",
1584
                pprefix,
1585
                "x_centre",
1586
                pdata->x_centre);
1587

    
1588
        trace_print(
1589
                VL53L1_TRACE_LEVEL_INFO,
1590
                "%s%s = %u\n",
1591
                pprefix,
1592
                "y_centre",
1593
                pdata->y_centre);
1594

    
1595
        trace_print(
1596
                VL53L1_TRACE_LEVEL_INFO,
1597
                "%s%s = %u\n",
1598
                pprefix,
1599
                "width",
1600
                pdata->width);
1601

    
1602
        trace_print(VL53L1_TRACE_LEVEL_INFO,
1603
                "%s%s = %u\n",
1604
                pprefix,
1605
                "height",
1606
                pdata->height);
1607
}
1608

    
1609

    
1610
void VL53L1_print_spad_rate_data(
1611
        VL53L1_spad_rate_data_t  *pspad_rates,
1612
        char                     *pprefix,
1613
        uint32_t                  trace_flags)
1614
{
1615

    
1616
    /**
1617
     *  Print per SPAD rates generated by SSC
1618
     */
1619

    
1620
        uint16_t spad_no = 0;
1621
        uint8_t  row     = 0;
1622
        uint8_t  col     = 0;
1623

    
1624
        char  fp_text[VL53L1_MAX_STRING_LENGTH];
1625

    
1626
    trace_print(
1627
                VL53L1_TRACE_LEVEL_INFO,
1628
                "%s%8s,%4s,%4s, %s\n",
1629
                pprefix,
1630
                "spad_no",
1631
                "row",
1632
                "col",
1633
                "peak_rate_mcps");
1634

    
1635
    for (spad_no = 0 ; spad_no < pspad_rates->no_of_values ; spad_no++) {
1636

    
1637
                /* generate row / col location from SPAD number  */
1638
                VL53L1_decode_row_col(
1639
                        (uint8_t)spad_no,
1640
                        &row,
1641
                        &col);
1642

    
1643
                /* Convert fixed point rate value to string */
1644

    
1645
                VL53L1_signed_fixed_point_sprintf(
1646
                        (int32_t)pspad_rates->rate_data[spad_no],
1647
                        pspad_rates->fractional_bits,
1648
                        VL53L1_MAX_STRING_LENGTH,
1649
                        fp_text);
1650

    
1651
                /* Print data */
1652

    
1653
                trace_print(
1654
                        VL53L1_TRACE_LEVEL_INFO,
1655
                        "%s%8u,%4u,%4u, %s\n",
1656
                        pprefix,
1657
                        spad_no,
1658
                        row,
1659
                        col,
1660
                        fp_text);
1661
    }
1662
}
1663

    
1664

    
1665
void VL53L1_print_spad_rate_map(
1666
        VL53L1_spad_rate_data_t  *pspad_rates,
1667
        char                     *pprefix,
1668
        uint32_t                  trace_flags)
1669
{
1670

    
1671
    /**
1672
     *  Print per SPAD rates generated by SSC as a map
1673
     */
1674

    
1675
        uint8_t  spad_no = 0;
1676
        uint8_t  row     = 0;
1677
        uint8_t  col     = 0;
1678

    
1679
        char  fp_text[VL53L1_MAX_STRING_LENGTH];
1680

    
1681
        /* Print column headers  */
1682
        trace_print(
1683
                VL53L1_TRACE_LEVEL_INFO,
1684
                "%s%4s",
1685
                pprefix,
1686
                " ");
1687

    
1688
    for (col = 0 ;  col < VL53L1_SPAD_ARRAY_WIDTH ; col++)
1689
                trace_print(
1690
                        VL53L1_TRACE_LEVEL_INFO,
1691
                        ",%8u",
1692
                        col);
1693

    
1694
        trace_print(
1695
                VL53L1_TRACE_LEVEL_INFO,
1696
                "\n");
1697

    
1698
    /* Print rate data  */
1699

    
1700
    for (row = 0 ;  row < VL53L1_SPAD_ARRAY_HEIGHT ; row++) {
1701

    
1702
                trace_print(
1703
                        VL53L1_TRACE_LEVEL_INFO,
1704
                        "%s%4u",
1705
                        pprefix,
1706
                        row);
1707

    
1708
                for (col = 0 ;  col < VL53L1_SPAD_ARRAY_HEIGHT ; col++) {
1709

    
1710
                        /* generate SPAD number from (row, col) location */
1711

    
1712
                        VL53L1_encode_row_col(
1713
                                row,
1714
                                col,
1715
                                &spad_no);
1716

    
1717
                        /* Convert fixed point rate value to string */
1718

    
1719
                        VL53L1_signed_fixed_point_sprintf(
1720
                                (int32_t)pspad_rates->rate_data[spad_no],
1721
                                pspad_rates->fractional_bits,
1722
                                VL53L1_MAX_STRING_LENGTH,
1723
                                fp_text);
1724

    
1725
                        /* Print data */
1726

    
1727
                        trace_print(
1728
                                VL53L1_TRACE_LEVEL_INFO,
1729
                                ",%8s",
1730
                                fp_text);
1731
                }
1732

    
1733
                trace_print(
1734
                        VL53L1_TRACE_LEVEL_INFO,
1735
                        "\n");
1736
    }
1737
}
1738

    
1739

    
1740
#endif /* VL53L1_LOG_ENABLE */
1741