3 sensors, polling

Dependencies:   X_NUCLEO_53L1A2

Files at this revision

API Documentation at this revision

Comitter:
johnAlexander
Date:
Thu May 13 09:17:02 2021 +0000
Parent:
9:0a3e1affe004
Commit message:
debug trials

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 0a3e1affe004 -r cf7d563200fc X_NUCLEO_53L1A2.lib
--- a/X_NUCLEO_53L1A2.lib	Fri May 07 13:45:18 2021 +0000
+++ b/X_NUCLEO_53L1A2.lib	Thu May 13 09:17:02 2021 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/teams/ST-Expansion-SW-Team/code/X_NUCLEO_53L1A2/#070884954aae
+https://os.mbed.com/teams/ST-Expansion-SW-Team/code/X_NUCLEO_53L1A2/#57998dc85ed4
diff -r 0a3e1affe004 -r cf7d563200fc main.cpp
--- a/main.cpp	Fri May 07 13:45:18 2021 +0000
+++ b/main.cpp	Thu May 13 09:17:02 2021 +0000
@@ -79,53 +79,90 @@
     printf("board initiated! - %d\r\n", status);
   // create the sensor controller classes                                              
 
-
-
+    VL53L1_RoiConfig_t roiConfig;
+    
+    roiConfig.NumberOfRoi =3;
+    
+    roiConfig.UserRois[0].TopLeftX = 0;
+    roiConfig.UserRois[0].TopLeftY = 9; 
+    roiConfig.UserRois[0].BotRightX = 4;
+    roiConfig.UserRois[0].BotRightY = 5; 
+    
+    roiConfig.UserRois[1].TopLeftX = 5;
+    roiConfig.UserRois[1].TopLeftY = 9; 
+    roiConfig.UserRois[1].BotRightX = 9;
+    roiConfig.UserRois[1].BotRightY = 4; 
+    
+    roiConfig.UserRois[2].TopLeftX = 11;
+    roiConfig.UserRois[2].TopLeftY = 9; 
+    roiConfig.UserRois[2].BotRightX = 15;
+    roiConfig.UserRois[2].BotRightY = 5; 
+    
+// start of setup of central sensor
     Dev=&devCentre;
-    Sensor=board->sensor_centre;
-    Dev->i2c_slave_address = NEW_SENSOR_CENTRE_ADDRESS;
-    printf("configuring centre channel \n");
-
     
 // configure the sensors
     Dev->comms_speed_khz = 400;
-
     Dev->comms_type = 1;
+    Dev->i2c_slave_address = NEW_SENSOR_CENTRE_ADDRESS;
+    devCentre.i2c_slave_address = NEW_SENSOR_CENTRE_ADDRESS;
+    
+    Sensor=board->sensor_centre;
 
-    Sensor->VL53L1_RdWord(Dev, 0x01, &wordData);
-    printf("VL53L1X: %02X   %d\n\r", wordData,Dev->i2c_slave_address);
+    printf("configuring centre channel \n");
+    
+//    Sensor->VL53L1_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);
-
+    
     
-    VL53L1_RoiConfig_t roiConfig;
-    roiConfig.NumberOfRoi =3;
-    roiConfig.UserRois[0].TopLeftX = 0;
-    roiConfig.UserRois[0].TopLeftY = 9; 
-    roiConfig.UserRois[0].BotRightX = 4;
-    roiConfig.UserRois[0].BotRightY = 5; 
-    roiConfig.UserRois[1].TopLeftX = 5;
-    roiConfig.UserRois[1].TopLeftY = 9; 
-    roiConfig.UserRois[1].BotRightX = 9;
-    roiConfig.UserRois[1].BotRightY = 4; 
-    roiConfig.UserRois[2].TopLeftX = 11;
-    roiConfig.UserRois[2].TopLeftY = 9; 
-    roiConfig.UserRois[2].BotRightX = 15;
-    roiConfig.UserRois[2].BotRightY = 5; 
     status = Sensor->vl53L1_SetROI( &roiConfig);
+    
     printf("VL53L1_SetROI %d \n",status);
 
-    devCentre.i2c_slave_address = NEW_SENSOR_CENTRE_ADDRESS;
     status = board->sensor_centre->vl53L1_StartMeasurement();  
+        
 
-       // looping polling for results
+// start of setup of left satellite
+    Dev=&devLeft;
+    
+// configure the sensors
+    Dev->comms_speed_khz = 400;
+    Dev->comms_type = 1;
+    Dev->i2c_slave_address = NEW_SENSOR_LEFT_ADDRESS;
+    devLeft.i2c_slave_address = NEW_SENSOR_LEFT_ADDRESS;
+    
+    Sensor=board->sensor_left;
+
+    printf("configuring centre channel \n");
+    
+//    Sensor->VL53L1_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->vl53L1_SetROI( &roiConfig);
+    
+    printf("VL53L1_SetROI %d \n",status);
+
+    status = board->sensor_left->vl53L1_StartMeasurement();  
+        
+
+    VL53L1_MultiRangingData_t MultiRangingData;
+    VL53L1_MultiRangingData_t *pMultiRangingData = &MultiRangingData;    
+    
+    // looping polling for results
     while (1)
     {
-        VL53L1_MultiRangingData_t MultiRangingData;
-        VL53L1_MultiRangingData_t *pMultiRangingData = &MultiRangingData;    
+        pMultiRangingData = &MultiRangingData;    
         
         // wait for result
         status = board->sensor_centre->vl53L1_WaitMeasurementDataReady();  
@@ -134,15 +171,29 @@
         // if valid, print it
         if(status==0) {
             print_results(devCentre.i2c_slave_address, pMultiRangingData );
-             status = board->sensor_centre->vl53L1_ClearInterruptAndStartMeasurement();
+            status = board->sensor_centre->vl53L1_ClearInterruptAndStartMeasurement();
 
         } //if(status==0) 
         else
         {
             printf("VL53L1_GetMultiRangingData centre %d \n",status);
         }
-                
-        wait_ms( 1 * 10);                   
+        
+        // wait for result
+        status = board->sensor_left->vl53L1_WaitMeasurementDataReady();  
+        // get the result
+        status = board->sensor_left->vl53L1_GetMultiRangingData( pMultiRangingData);
+        // if valid, print it
+        if(status==0) {
+            print_results(devLeft.i2c_slave_address, pMultiRangingData );
+            status = board->sensor_left->vl53L1_ClearInterruptAndStartMeasurement();
+
+        } //if(status==0) 
+        else
+        {
+            printf("VL53L1_GetMultiRangingData centre %d \n",status);
+        }
+        
     }
 }