A sample program getting measurements from a VL53L1CB ToF sensors which are connected thru a shield to the STM32F401. Copes with one sensor. Polling mode. VL53L1 is operated in multizone mode. MBed V6.

Dependencies:   X_NUCLEO_53L1A2

Revision:
6:a71567e36ab4
Parent:
5:5916ff386a94
--- a/main.cpp	Tue Nov 10 08:46:48 2020 +0000
+++ b/main.cpp	Mon Jun 14 08:31:48 2021 +0000
@@ -26,13 +26,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;
@@ -46,7 +46,7 @@
 int main()
 {   
     int status;
-    VL53L1 * Sensor;
+    VL53L1CB * Sensor;
     uint16_t wordData;
 
 
@@ -85,13 +85,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;
@@ -108,11 +108,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)
@@ -121,13 +121,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