Sample MBed program for use with ST XNucleo VL53L1CB board. Uses interrupts to cope with up to 3 sensors in multizone mode. Includes MBed V6.4

Dependencies:   X_NUCLEO_53L1A2

Files at this revision

API Documentation at this revision

Comitter:
charlesmn
Date:
Sun Jun 13 14:14:07 2021 +0000
Parent:
3:09f23aad108a
Commit message:
Compile with VL53L1CB class

Changed in this revision

X_NUCLEO_53L1A2.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 09f23aad108a -r 738d308ed16e X_NUCLEO_53L1A2.lib
--- a/X_NUCLEO_53L1A2.lib	Thu May 13 08:31:52 2021 +0000
+++ b/X_NUCLEO_53L1A2.lib	Sun Jun 13 14:14:07 2021 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/teams/ST-Expansion-SW-Team/code/X_NUCLEO_53L1A2/#57998dc85ed4
+https://os.mbed.com/teams/ST-Expansion-SW-Team/code/X_NUCLEO_53L1A2/#3b787555bfb0
diff -r 09f23aad108a -r 738d308ed16e main.cpp
--- a/main.cpp	Thu May 13 08:31:52 2021 +0000
+++ b/main.cpp	Sun Jun 13 14:14:07 2021 +0000
@@ -73,7 +73,7 @@
     InterruptIn stop_button(SW2);
 #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 );
 
 
@@ -146,14 +146,14 @@
     if (centerSensor) {
         centerSensor = false;
 
-        status = board->sensor_centre->VL53L1_GetDistance(&distance);
+        status = board->sensor_centre->VL53L1CB_GetDistance(&distance);
         
         current = (currentSensor == 0);
         if (current) {
             printf("Centre: %d\r\n", distance);
         }
         
-        status = board->sensor_centre->VL53L1_ClearInterrupt();
+        status = board->sensor_centre->VL53L1CB_ClearInterrupt();
         board->sensor_centre->enable_interrupt_measure_detection_irq();        
         
     }
@@ -162,13 +162,13 @@
     if (leftSensor) {
         leftSensor = false;
         
-        status = board->sensor_left->VL53L1_GetDistance(&distance);
+        status = board->sensor_left->VL53L1CB_GetDistance(&distance);
         
         current = (installedSensors[currentSensor] == 'L');
         if (current) {
             printf("Left: %d\r\n", distance);
         }
-        status = board->sensor_left->VL53L1_ClearInterrupt();
+        status = board->sensor_left->VL53L1CB_ClearInterrupt();
         board->sensor_left->enable_interrupt_measure_detection_irq();
         
     }
@@ -177,26 +177,26 @@
     if (rightSensor) {
         rightSensor = false;
         
-        status = board->sensor_right->VL53L1_GetDistance(&distance);
+        status = board->sensor_right->VL53L1CB_GetDistance(&distance);
         
         current = (installedSensors[currentSensor] == 'R');
         if (current) {
             printf("Right: %d\r\n", distance);
         }
-        status = board->sensor_right->VL53L1_ClearInterrupt();
+        status = board->sensor_right->VL53L1CB_ClearInterrupt();
         board->sensor_right->enable_interrupt_measure_detection_irq();
         
     }    
 }
 
-int configure_sensor(VL53L1 *Sensor)
+int configure_sensor(VL53L1CB *Sensor)
 {
     int status = 0;
     
 // Device Initialization and setting 
-    status = Sensor->vl53L1_DataInit();
-    status = Sensor->vl53L1_StaticInit();
-    status = Sensor->vl53L1_SetPresetMode( VL53L1_PRESETMODE_MULTIZONES_SCANNING);
+    status = Sensor->VL53L1CB_DataInit();
+    status = Sensor->VL53L1CB_StaticInit();
+    status = Sensor->VL53L1CB_SetPresetMode( VL53L1_PRESETMODE_MULTIZONES_SCANNING);
     
     //configure the regions of interest for each sensor
     VL53L1_RoiConfig_t roiConfig;
@@ -214,10 +214,10 @@
     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);
     
     
-    status = Sensor->vl53L1_SetDistanceMode( VL53L1_DISTANCEMODE_LONG);
+    status = Sensor->VL53L1CB_SetDistanceMode( VL53L1_DISTANCEMODE_LONG);
 //       status = Sensor->VL53L1_SetMeasurementTimingBudgetMicroSeconds( 100 * 500); // error -21 is because of this. Don't know why
 
     return status;
@@ -229,7 +229,7 @@
 int init_sensors_array()
 {
     int status = 0;
-    VL53L1 *Sensor;
+    VL53L1CB *Sensor;
     uint8_t ToFSensor = 1; // 0=Left, 1=Center(default), 2=Right
 
     sensorCnt = 0;