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:
16:9fd42eb225c5
Parent:
15:ce041cbc8727
Child:
18:2d1f16e92a8e
--- a/main.cpp	Mon Nov 09 17:44:46 2020 +0000
+++ b/main.cpp	Sun Jun 13 13:31:20 2021 +0000
@@ -38,13 +38,13 @@
 
 static XNucleo53L1A2 *board=NULL;
 #if (MBED_VERSION  > 60300) 
-UnbufferedSerial  pc(SERIAL_TX, SERIAL_RX); 
+UnbufferedSerial  pc(USBTX, USBRX); 
 extern "C" void wait_ms(int ms);
 #else
 Serial pc(SERIAL_TX, SERIAL_RX); 
 #endif
 
-void process_interrupt( VL53L1 * sensor,VL53L1_DEV dev );
+void process_interrupt( VL53L1CB * sensor,VL53L1_DEV dev );
 void print_results( int devSpiNumber, VL53L1_MultiRangingData_t *pMultiRangingData );
 
 VL53L1_Dev_t                   devCentre;
@@ -58,7 +58,7 @@
 int main()
 {   
     int status;
-    VL53L1 * Sensor;
+    VL53L1CB * Sensor;
     uint16_t wordData;
 
 
@@ -97,13 +97,13 @@
 
     Dev->comms_type = 1;
 
-    Sensor->VL53L1_RdWord(Dev, 0x01, &wordData);
+    Sensor->VL53L1CB_RdWord(Dev, 0x01, &wordData);
     printf("VL53L1X: %02X   %d\n\r", wordData,Dev->i2c_slave_address);
 /* Device Initialization and setting */  
-    status = Sensor->vl53L1_DataInit();
-    status = Sensor->vl53L1_StaticInit();
-    status = Sensor->vl53L1_SetPresetMode( VL53L1_PRESETMODE_MULTIZONES_SCANNING);
-    status = Sensor->vl53L1_SetDistanceMode( VL53L1_DISTANCEMODE_LONG);
+    status = Sensor->VL53L1CB_DataInit();
+    status = Sensor->VL53L1CB_StaticInit();
+    status = Sensor->VL53L1CB_SetPresetMode( VL53L1_PRESETMODE_MULTIZONES_SCANNING);
+    status = Sensor->VL53L1CB_SetDistanceMode( VL53L1_DISTANCEMODE_LONG);
 
     
     VL53L1_RoiConfig_t roiConfig;
@@ -120,11 +120,11 @@
     roiConfig.UserRois[2].TopLeftY = 9; 
     roiConfig.UserRois[2].BotRightX = 15;
     roiConfig.UserRois[2].BotRightY = 5; 
-    status = Sensor->vl53L1_SetROI( &roiConfig);
+    status = Sensor->VL53L1CB_SetROI( &roiConfig);
     printf("VL53L1_SetROI %d \n",status);
 
     devCentre.i2c_slave_address = NEW_SENSOR_CENTRE_ADDRESS;
-    status = board->sensor_centre->vl53L1_StartMeasurement();  
+    status = board->sensor_centre->VL53L1CB_StartMeasurement();  
 
        // looping polling for results
     while (1)
@@ -133,13 +133,13 @@
         VL53L1_MultiRangingData_t *pMultiRangingData = &MultiRangingData;    
         
         // wait for result
-        status = board->sensor_centre->vl53L1_WaitMeasurementDataReady();  
+        status = board->sensor_centre->VL53L1CB_WaitMeasurementDataReady();  
         // get the result
-        status = board->sensor_centre->vl53L1_GetMultiRangingData( pMultiRangingData);
+        status = board->sensor_centre->VL53L1CB_GetMultiRangingData( pMultiRangingData);
         // if valid, print it
         if(status==0) {
             print_results(devCentre.i2c_slave_address, pMultiRangingData );
-             status = board->sensor_centre->vl53L1_ClearInterruptAndStartMeasurement();
+             status = board->sensor_centre->VL53L1CB_ClearInterruptAndStartMeasurement();
 
         } //if(status==0) 
         else