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.

Revision:
18:0696efe39d08
Parent:
7:1add29d51e72
--- a/src/vl53l1_api.c	Wed Jun 23 12:57:26 2021 +0000
+++ b/src/vl53l1_api.c	Wed Jul 21 17:06:38 2021 +0200
@@ -638,10 +638,10 @@
 	VL53L1_Error Status = VL53L1_ERROR_NONE;
 	VL53L1_DevicePresetModes   device_preset_mode;
 	uint8_t measurement_mode;
-	uint16_t dss_config__target_total_rate_mcps;
-	uint32_t phasecal_config_timeout_us;
-	uint32_t mm_config_timeout_us;
-	uint32_t lld_range_config_timeout_us;
+	uint16_t dss_config__target_total_rate_mcps = 0;
+	uint32_t phasecal_config_timeout_us = 0;
+	uint32_t mm_config_timeout_us = 0;
+	uint32_t lld_range_config_timeout_us = 0;
 
 	LOG_FUNCTION_START("%d", (int)PresetMode);
 
@@ -746,9 +746,9 @@
 	VL53L1_Error Status = VL53L1_ERROR_NONE;
 	VL53L1_PresetModes PresetMode;
 	uint32_t inter_measurement_period_ms;
-	uint32_t TimingBudget;
-	uint32_t MmTimeoutUs;
-	uint32_t PhaseCalTimeoutUs;
+	uint32_t TimingBudget = 0;
+	uint32_t MmTimeoutUs = 0;
+	uint32_t PhaseCalTimeoutUs = 0;
 	VL53L1_zone_config_t zone_config;
 
 	LOG_FUNCTION_START("%d", (int)DistanceMode);
@@ -851,14 +851,14 @@
 	uint32_t MeasurementTimingBudgetMicroSeconds)
 {
 	VL53L1_Error Status = VL53L1_ERROR_NONE;
-	uint8_t Mm1Enabled;
-	uint8_t Mm2Enabled;
+	uint8_t Mm1Enabled = 0;
+	uint8_t Mm2Enabled = 0;
 	uint32_t TimingGuard;
 	uint32_t divisor;
-	uint32_t TimingBudget;
-	uint32_t MmTimeoutUs;
+	uint32_t TimingBudget = 0;
+	uint32_t MmTimeoutUs = 0;
 	VL53L1_PresetModes PresetMode;
-	uint32_t PhaseCalTimeoutUs;
+	uint32_t PhaseCalTimeoutUs = 0;
 	uint32_t vhv;
 	int32_t vhv_loops;
 	uint32_t FDAMaxTimingBudgetUs = FDA_MAX_TIMING_BUDGET_US;
@@ -1171,6 +1171,7 @@
 		dmax_mode = VL53L1_DEVICEDMAXMODE__PER_ZONE_CAL_DATA;
 		break;
 	default:
+		dmax_mode = VL53L1_DEVICEDMAXMODE__CUST_CAL_DATA;
 		Status = VL53L1_ERROR_INVALID_PARAMS;
 		break;
 	}
@@ -1388,7 +1389,7 @@
 {
 	VL53L1_Error Status = VL53L1_ERROR_NONE;
 	uint16_t MinCountRate;
-	FixPoint1616_t TempFix1616;
+	FixPoint1616_t TempFix1616 = 0;
 	uint16_t SigmaThresh;
 
 	LOG_FUNCTION_START("");
@@ -2171,6 +2172,8 @@
 	int32_t ExtendedRangeEnabled = 0;
 	uint8_t uwr_status;
 	int16_t AddOffset;
+	int32_t TuningMinValidSignal;
+	FixPoint1616_t MinValidSignal;
 
 	FilteredRangeStatus = presults_data->range_status & 0x1F;
 
@@ -2297,6 +2300,18 @@
 	}
 
 
+	VL53L1_get_tuning_parm(Dev,
+		VL53L1_TUNINGPARM_MIN_SIGNAL_SECONDARY_TARGETS,
+		&TuningMinValidSignal);
+	MinValidSignal = (FixPoint1616_t)TuningMinValidSignal;
+	if ((iteration > 0) &&
+		(pRangeData->RangeStatus ==  VL53L1_RANGESTATUS_RANGE_VALID) &&
+		(pRangeData->SignalRateRtnMegaCps < MinValidSignal))
+		pRangeData->RangeStatus =
+			VL53L1_RANGESTATUS_TARGET_PRESENT_LACK_OF_SIGNAL;
+
+
+
 
 	VL53L1_get_tuning_parm(Dev, VL53L1_TUNINGPARM_UWR_ENABLE,
 			&ExtendedRangeEnabled);
@@ -2413,17 +2428,6 @@
 					tp->tp_uwr_med_corr_z_6_rangea;
 				}
 				else
-
-
-
-
-
-
-
-
-
-
-
 					uwr_status = 0;
 				break;
 
@@ -2812,10 +2816,7 @@
 			pc->ref_spad_man__ref_location = numloc[1];
 		}
 
-		if (Status == VL53L1_ERROR_NONE)
-			commbuf = &dcrbuffer[16];
-
-
+		commbuf = &dcrbuffer[16];
 
 		if (Status == VL53L1_ERROR_NONE)
 			Status = VL53L1_WriteMulti(Dev,
@@ -3019,6 +3020,9 @@
 
 	LOG_FUNCTION_START("");
 
+	offset_cal_mode =
+		VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD;
+
 	if (OffsetCalibrationMode == VL53L1_OFFSETCALIBRATIONMODE_STANDARD) {
 		offset_cal_mode =
 			VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD;
@@ -3050,6 +3054,8 @@
 
 	LOG_FUNCTION_START("");
 
+	offset_cor_mode =
+			VL53L1_OFFSETCORRECTIONMODE__MM1_MM2_OFFSETS;
 	if (OffsetCorrectionMode == VL53L1_OFFSETCORRECTIONMODE_STANDARD) {
 		offset_cor_mode =
 				VL53L1_OFFSETCORRECTIONMODE__MM1_MM2_OFFSETS;
@@ -3091,9 +3097,8 @@
 	CalReflectancePercent_int =
 			VL53L1_FIXPOINT1616TOFIXPOINT72(CalReflectancePercent);
 
-	if (Status == VL53L1_ERROR_NONE)
-		Status =  VL53L1_get_offset_calibration_mode(Dev,
-				&offset_cal_mode);
+	Status =  VL53L1_get_offset_calibration_mode(Dev,
+			&offset_cal_mode);
 
 	if (Status != VL53L1_ERROR_NONE) {
 		LOG_FUNCTION_END(Status);