ST Expansion SW Team / VL53L1CB

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   VL53L1CB_noshield_1sensor_polls_auton VL53L1CB_noshield_1sensor_interrupt_auton X_NUCLEO_53L1A2

Revision:
18:0696efe39d08
Parent:
7:1add29d51e72
--- a/src/vl53l1_api_calibration.c	Wed Jun 23 12:57:26 2021 +0000
+++ b/src/vl53l1_api_calibration.c	Wed Jul 21 17:06:38 2021 +0200
@@ -1300,7 +1300,14 @@
 			VL53L1_p_017 -= (2048 *
 			(uint32_t)pdev->hist_data.cal_config__vcsel_start);
 
-			VL53L1_p_017  = VL53L1_p_017 % period;
+			if (period != 0) {
+				VL53L1_p_017  = VL53L1_p_017 % period;
+			}
+			else {
+				status =
+				VL53L1_ERROR_DIVISION_BY_ZERO;
+				VL53L1_p_017 = 0;
+			}
 
 			phasecal_result__reference_phase += (uint32_t)(
 			pdev->hist_data.phasecal_result__reference_phase);
@@ -2082,23 +2089,22 @@
 				status =
 				VL53L1_clear_interrupt_and_enable_next_range(
 					Dev, measurement_mode);
-
-
-			if (status == VL53L1_ERROR_NONE)
-				status =
-				VL53L1_hist_xtalk_extract_fini(
-					&(pdev->hist_data),
-					&(pdev->xtalk_extract),
-					&(pdev->xtalk_cal),
-					&(pdev->xtalk_shapes.xtalk_shape));
-			if (status != VL53L1_ERROR_NONE)
-				goto LOOPOUT;
+		}
+
+
+		if (status == VL53L1_ERROR_NONE)
+			status =
+			VL53L1_hist_xtalk_extract_fini(
+				&(pdev->hist_data),
+				&(pdev->xtalk_extract),
+				&(pdev->xtalk_cal),
+				&(pdev->xtalk_shapes.xtalk_shape));
+		if (status == VL53L1_ERROR_NONE) {
 			pXC->algo__xtalk_cpo_HistoMerge_kcps[k * MaxId] =
 			pXC->algo__crosstalk_compensation_plane_offset_kcps;
 		}
 	}
 
-LOOPOUT:
 
 	VL53L1_stop_range(Dev);