A sample program to control one VL53L1 ToF sensor in multizone mode using polling to find out if a measurement is available. Mbed V6.3 but will run any MBed version by dropping replacing this one. Maint6 release.

Dependencies:   X_NUCLEO_53L1A2

Revision:
12:3dd44d06629c
Parent:
11:eafe2b5c130e
Child:
13:2cf61951ea62
--- a/main.cpp	Fri May 21 09:08:32 2021 +0000
+++ b/main.cpp	Wed Jun 09 21:30:02 2021 +0100
@@ -71,7 +71,7 @@
 VL53L1_Dev_t devCentre;
 VL53L1_DEV Dev = &devCentre;
 
-VL53L1 *Sensor;
+VL53L1CB *Sensor;
 
 
 
@@ -102,8 +102,8 @@
     printf("configuring centre channel \n");
 
     /* Device Initialization and setting */
-    status = Sensor->vl53L1_DataInit();
-    status = Sensor->vl53L1_StaticInit();
+    status = Sensor->VL53L1CB_DataInit();
+    status = Sensor->VL53L1CB_StaticInit();
 
     VL53L1_RoiConfig_t RoiConfig;
 
@@ -124,12 +124,12 @@
     RoiConfig.UserRois[2].BotRightX = 13;
     RoiConfig.UserRois[2].BotRightY = 6;
 
-    status = Sensor->vl53L1_SetPresetMode(VL53L1_PRESETMODE_MULTIZONES_SCANNING);
-    status = Sensor->vl53L1_SetDistanceMode(VL53L1_DISTANCEMODE_LONG);
+    status = Sensor->VL53L1CB_SetPresetMode(VL53L1_PRESETMODE_MULTIZONES_SCANNING);
+    status = Sensor->VL53L1CB_SetDistanceMode(VL53L1_DISTANCEMODE_LONG);
 
-    status = Sensor->vl53L1_SetROI(&RoiConfig);
+    status = Sensor->VL53L1CB_SetROI(&RoiConfig);
 
-    status = Sensor->vl53L1_SetMeasurementTimingBudgetMicroSeconds(17000);
+    status = Sensor->VL53L1CB_SetMeasurementTimingBudgetMicroSeconds(17000);
 
 
     // create interrupt handler and start measurements
@@ -139,7 +139,7 @@
             return status;
         }
 
-        status = Sensor->vl53L1_StartMeasurement();
+        status = Sensor->VL53L1CB_StartMeasurement();
         if (status != 0) {
             return status;
         }
@@ -195,12 +195,12 @@
     while (true) {
         pMultiRangingData = &MultiRangingData;
 
-        status = board->sensor_centre->vl53L1_WaitMeasurementDataReady();
-        status = board->sensor_centre->vl53L1_GetMultiRangingData( pMultiRangingData);
+        status = board->sensor_centre->VL53L1CB_WaitMeasurementDataReady();
+        status = board->sensor_centre->VL53L1CB_GetMultiRangingData( pMultiRangingData);
 
         print_results( devCentre.i2c_slave_address, pMultiRangingData );
 
-        status = board->sensor_centre->VL53L1_ClearInterrupt();
+        status = board->sensor_centre->VL53L1CB_ClearInterrupt();
     }
 
     printf("Terminating.\n");