modified to work with MultiTech mDot on UDK2.0

Dependencies:   X_NUCLEO_53L0A1 mbed

Fork of HelloWorld_53L0A1 by ST

Files at this revision

API Documentation at this revision

Comitter:
johnAlexander
Date:
Thu Dec 01 14:19:01 2016 +0000
Parent:
2:c0280060189b
Child:
4:c8932fb926d6
Commit message:
Simplify example, to be simplest possible ranging example. Print range measurements rather than send them to the 4-digit display.

Changed in this revision

X_NUCLEO_53L0A1.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/X_NUCLEO_53L0A1.lib	Tue Nov 29 09:15:05 2016 +0000
+++ b/X_NUCLEO_53L0A1.lib	Thu Dec 01 14:19:01 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/ST-Expansion-SW-Team/code/X_NUCLEO_53L0A1/#01b8004bc0a7
+https://developer.mbed.org/teams/ST-Expansion-SW-Team/code/X_NUCLEO_53L0A1/#58b5e9097aa3
--- a/main.cpp	Tue Nov 29 09:15:05 2016 +0000
+++ b/main.cpp	Thu Dec 01 14:19:01 2016 +0000
@@ -22,95 +22,27 @@
 #define VL53L0_I2C_SDA   D14 
 #define VL53L0_I2C_SCL   D15 
 
-#define RANGE   0
-
 static X_NUCLEO_53L0A1 *board=NULL;
-VL53L0X_RangingMeasurementData_t data_sensor_centre;
-OperatingMode operating_mode;
-	
-/* flags that handle interrupt request */
-bool int_sensor_centre=false, int_stop_measure=false;	
-
-/* ISR callback function of the sensor_centre */
-void SensorTopIRQ(void)
-{
-   int_sensor_centre=true;
-   board->sensor_centre->DisableInterruptMeasureDetectionIRQ();
-}	
-
-/* ISR callback function of the user blue button to stop program */
-void StopMeasureIRQ(void)
-{
-   int_stop_measure=true;
-}
 
-/* On board 4 digit local display refresh */
-void DisplayRefresh(OperatingMode op_mode)
-{   
-   char str[5];
-   
-   if (op_mode==range_single_shot_polling || op_mode==range_continuous_interrupt || op_mode==range_continuous_polling)
-   {
-	  if (data_sensor_centre.RangeStatus == 0) // we have a valid range.
-      {
-         sprintf(str,"%d",data_sensor_centre.RangeMilliMeter);
-      }
-      else
-      {
-         sprintf(str,"%s","----");
-      }
-   }
-	 
-   board->display->DisplayString(str);
-}
-
-void RangeMeasure(DevI2C *device_i2c) {
-   int status;
-
-   /* creates the 53L0A1 expansion board singleton obj */
-   board=X_NUCLEO_53L0A1::Instance(device_i2c, A2, D8, D2);
-	
-   board->display->DisplayString("53L0");
-   /* init the 53L0A1 expansion board with default values */
-   status=board->InitBoard();
-   if(status)
-      printf("Failed to init board!\n\r");   
-//   operating_mode=range_continuous_polling;
-   operating_mode=range_single_shot_polling;
-   /* start the measure on sensor top */
-   status=board->sensor_centre->StartMeasurement(operating_mode, SensorTopIRQ);
-   if(!status)
-   {
-      while(1)
-      {
-         status=board->sensor_centre->GetMeasurement(operating_mode, &data_sensor_centre);
-         DisplayRefresh(operating_mode);
-         if(int_stop_measure) // Blue Button isr was triggered
-         {
-            status=board->sensor_centre->StopMeasurement(operating_mode); // stop the measure and exit
-   			int_stop_measure = false;
-            printf("\nProgram stopped!\n\n\r");
-            break;
-         }
-      }
-   }
-   board->display->DisplayString("BYE");
-   delete board;	    
-}	 
 
 /*=================================== Main ==================================
- Press the blue user button to stop the measurements in progress 	
 =============================================================================*/
 int main()
 {   
-#if USER_BUTTON==PC_13  // we are cross compiling for Nucleo-f401 
-   InterruptIn stop_button (USER_BUTTON);
-   stop_button.rise (&StopMeasureIRQ);	
-#endif   
-   DevI2C *device_i2c =new DevI2C(VL53L0_I2C_SDA, VL53L0_I2C_SCL);     
-		
-   RangeMeasure(device_i2c);  // start continuous measures
+    int status;
+    uint32_t distance;
+    DevI2C *device_i2c =new DevI2C(VL53L0_I2C_SDA, VL53L0_I2C_SCL);
+
+    /* creates the 53L0A1 expansion board singleton obj */
+    board=X_NUCLEO_53L0A1::Instance(device_i2c, A2, D8, D2);
+
+    /* init the 53L0A1 expansion board with default values */
+    status=board->InitBoard();
+    if(status) { printf("Failed to init board!\n\r"); return 0; }
+    while(1)
+    {
+        board->sensor_centre->GetDistance(&distance);
+        printf("Distance : %ld\n", distance);
+    }
 }
 
-
-
--- a/mbed.bld	Tue Nov 29 09:15:05 2016 +0000
+++ b/mbed.bld	Thu Dec 01 14:19:01 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/d75b3fe1f5cb
\ No newline at end of file