modified to work with MultiTech mDot on UDK2.0

Dependents:   HelloWorld_53L0A1 unh-hackathon-example unh-hackathon-example-raw

Fork of X_NUCLEO_53L0A1 by ST

Revision:
4:4e1576541eed
Parent:
0:c523920bcc09
Child:
7:35ecf3e060c3
--- a/Components/VL53L0X/vl53l0x_class.h	Mon Nov 28 14:52:49 2016 +0000
+++ b/Components/VL53L0X/vl53l0x_class.h	Mon Dec 05 11:03:50 2016 +0000
@@ -42,6 +42,7 @@
 
 
 /* Includes ------------------------------------------------------------------*/
+#include "mbed.h"
 #include "RangeSensor.h"
 #include "DevI2C.h" 
 
@@ -372,10 +373,10 @@
 	 */					 
     int InitSensor(uint8_t NewAddr);
     
-    int RawInitSensor(void);
-    int initDevice(VL53L0X_DEV Dev);
-    int setLongRangePresets(VL53L0X_DEV Dev);
-    int DoRanging(VL53L0X_Dev_t *pMyDevice);
+//    int RawInitSensor(void);
+//    int initDevice(VL53L0X_DEV Dev);
+//    int setLongRangePresets(VL53L0X_DEV Dev);
+//    int DoRanging(VL53L0X_Dev_t *pMyDevice);
 
 
 
@@ -491,10 +492,11 @@
  * @param void
  * @return     0 on success,  @a #CALIBRATION_WARNING if failed
  */		
-    virtual int Init() 
+//    virtual int Init()
+    virtual int Init(void *NewAddr)
     {
-       return VL53L0X_DataInit(&MyDevice);
-//       return VL53L0X_DataInit(Device);
+//       return VL53L0X_DataInit(&MyDevice);
+       return VL53L0X_DataInit(Device);
 //			return 1;
     }
 
@@ -687,10 +689,25 @@
  * @param pRange_mm  Pointer to range distance
  * @return           0 on success
  */		
-    virtual int GetRange(int32_t *piData)
+    virtual int GetDistance(uint32_t *piData)
     {
-//       return VL6180x_RangeGetResult(Device, piData);
-			return 1;
+        int status=0;
+        VL53L0X_RangingMeasurementData_t pRangingMeasurementData;
+
+        status=StartMeasurement(range_single_shot_polling, NULL);
+        if (!status) {
+            status=GetMeasurement(range_single_shot_polling, &pRangingMeasurementData);
+        }
+        if (pRangingMeasurementData.RangeStatus == 0) {
+        // we have a valid range.
+            *piData = pRangingMeasurementData.RangeMilliMeter;
+        }
+        else {
+            *piData = 0;
+            status = VL53L0X_ERROR_RANGE_ERROR;
+        }
+        StopMeasurement(range_single_shot_polling);
+        return status;
     }
 		
 /**
@@ -1325,7 +1342,7 @@
     		VL53L0X_DeviceInfo_t *pVL53L0X_DeviceInfo);
 
     /* Read function of the ID device */
-    virtual int ReadID();
+    virtual int ReadID(uint8_t *id);
     
     VL53L0X_Error WaitMeasurementDataReady(VL53L0X_DEV Dev);
     VL53L0X_Error WaitStopCompleted(VL53L0X_DEV Dev);
@@ -1352,7 +1369,7 @@
     {
        int status;
 			
-       status=ReadID();
+       status=ReadID((uint8_t *)MyDevice.I2cDevAddr);
        if(status)
           VL53L0X_ErrLog("Failed to read ID device. Device not present!\n\r");
        return status;