1 
2 /* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
3 /******************************************************************************
4  * Copyright (c) 2020, STMicroelectronics - All Rights Reserved
5 
6  This file is part of VL53L1 and is dual licensed,
7  either GPL-2.0+
8  or 'BSD 3-clause "New" or "Revised" License' , at your option.
9  ******************************************************************************
10  */
11 
12 #ifndef _VL53L1_PRESET_SETUP_H_
13 #define _VL53L1_PRESET_SETUP_H_
14 
15 #ifdef __cplusplus
16 extern "C"
17 {
18 #endif
19 
20 /* indexes for the bare driver tuning setting API function */
21 enum VL53L1_Tuning_t {
22 	VL53L1_TUNING_VERSION = 0,
23 	VL53L1_TUNING_PROXY_MIN,
24 	VL53L1_TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM,
25 	VL53L1_TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER,
26 	VL53L1_TUNING_MIN_AMBIENT_DMAX_VALID,
27 	VL53L1_TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER,
28 	VL53L1_TUNING_XTALK_FULL_ROI_TARGET_DISTANCE_MM,
29 	VL53L1_TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT,
30 	VL53L1_TUNING_XTALK_FULL_ROI_BIN_SUM_MARGIN,
31 	VL53L1_TUNING_XTALK_FULL_ROI_DEFAULT_OFFSET,
32 	VL53L1_TUNING_ZERO_DISTANCE_OFFSET_NON_LINEAR_FACTOR,
33 	VL53L1_TUNING_PHASECAL_PATCH_POWER,
34 	VL53L1_TUNING_MAX_TUNABLE_KEY
35 };
36 
37 /* default values for the tuning settings parameters */
38 #define TUNING_VERSION	0x0007
39 
40 #define TUNING_PROXY_MIN -30 /* min distance in mm */
41 #define TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM 600
42 /* Target distance in mm for single target Xtalk */
43 #define TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER 50
44 /* Number of sample used for single target Xtalk */
45 #define TUNING_MIN_AMBIENT_DMAX_VALID 8
46 /* Minimum ambient level to state the Dmax returned by the device is valid */
47 #define TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER 50
48 /* Maximum loops to perform simple offset calibration */
49 #define TUNING_XTALK_FULL_ROI_TARGET_DISTANCE_MM 600
50 /* Target distance in mm for target Xtalk from Bins method*/
51 #define TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT 1
52 /* Number of loops done during the simple offset calibration*/
53 #define TUNING_ZERO_DISTANCE_OFFSET_NON_LINEAR_FACTOR_DEFAULT 9
54 /* zero distance offset calibration non linear compensation default value */
55 
56 /* The following settings are related to the fix for ticket EwokP #558410 */
57 #define TUNING_XTALK_FULL_ROI_BIN_SUM_MARGIN 24
58 /* Acceptance margin for the xtalk_shape bin_data sum computation */
59 #define TUNING_XTALK_FULL_ROI_DEFAULT_OFFSET 50
60 /* Recovery value for Xtalk compensation plane offset in kcps */
61 /* 50 stands for ~0.10 kcps cover glass in 7.9 format */
62 /* End of settings related to the fix for ticket EwokP #558410 */
63 #define TUNING_PHASECAL_PATCH_POWER 0
64 /* PhaseCal duration patch tuning param
65  * 0 default duration 15ms, 1 leads to 60ms, 2 for 240ms and 3 for 3580ms
66  */
67 
68 #ifdef __cplusplus
69 }
70 #endif
71 
72 #endif /* _VL53L1_PRESET_SETUP_H_ */
73