Changes to the library related to interrupt mode.

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON

Dependents:   Display_53L0A1_IntSatelites Display_53L0A1_InterruptMode

Fork of X_NUCLEO_53L0A1 by ST

Revision:
9:367d1f390cb2
Parent:
8:8d27ebb4e1eb
Child:
10:faf8d62ce6d1
--- a/Components/VL53L0X/vl53l0x_class.h	Wed Dec 07 14:49:50 2016 +0000
+++ b/Components/VL53L0X/vl53l0x_class.h	Wed Jun 07 12:53:53 2017 +0000
@@ -1,5 +1,5 @@
 /*******************************************************************************
- Copyright © 2016, STMicroelectronics International N.V.
+ Copyright © 2016, STMicroelectronics International N.V.
  All rights reserved.
 
  Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,6 @@
 
 
 /* Includes ------------------------------------------------------------------*/
-#include "mbed.h"
 #include "RangeSensor.h"
 #include "DevI2C.h" 
 
@@ -61,7 +60,7 @@
 #define STATUS_FAIL            0x01
 
 
-#define VL53L0X_OsDelay(...) wait_ms(2) // 2 msec delay. can also use wait(float secs)/wait_us(int)
+#define VL53L0X_OsDelay(...) HAL_Delay(2)
 
 #ifdef USE_EMPTY_STRING
 	#define  VL53L0X_STRING_DEVICE_INFO_NAME                             ""
@@ -328,7 +327,7 @@
        Device=&MyDevice;
        gpio0=NULL;		
        if (pin_gpio1 != NC) { gpio1Int = new InterruptIn(pin_gpio1); }
-       	else { gpio1Int = NULL; }
+       	else { gpio1Int = NULL; } 		 
     }  	 
     
    /** Destructor
@@ -352,7 +351,7 @@
 	          *gpio0 = 1;
         else if (expgpio0) 
             *expgpio0 = 1;
-        wait_ms(1);
+        wait_ms(10);
     } 
 
 	/**
@@ -366,14 +365,22 @@
 	          *gpio0 = 0;
         else if (expgpio0) 
             *expgpio0 = 0;
-        wait_ms(1);
+        wait_ms(10);
     }
     
 	/**
 	 * @brief       Initialize the sensor with default values
 	 * @return      0 on Success
-	 */
+	 */					 
     int InitSensor(uint8_t NewAddr);
+    
+    int RawInitSensor(void);
+    int initDevice(VL53L0X_DEV Dev);
+    int setLongRangePresets(VL53L0X_DEV Dev);
+    int DoRanging(VL53L0X_Dev_t *pMyDevice);
+
+
+
 
 	/**
 	 * @brief       Start the measure indicated by operating mode
@@ -486,9 +493,12 @@
  * @param void
  * @return     0 on success,  @a #CALIBRATION_WARNING if failed
  */		
-    virtual int Init(void * NewAddr)
+    virtual int Init(void *init)
+//    virtual int Init()
     {
-       return VL53L0X_DataInit(Device);
+       return VL53L0X_DataInit(&MyDevice);
+//       return VL53L0X_DataInit(Device);
+//			return 1;
     }
 
 /**
@@ -529,6 +539,7 @@
   */		
     int Prepare()
     {
+//       return VL6180x_Prepare(Device);
 			// taken from rangingTest() in vl53l0x_SingleRanging_Example.c
 		VL53L0X_Error Status = VL53L0X_ERROR_NONE;
         uint32_t refSpadCount;
@@ -680,24 +691,10 @@
  * @return           0 on success
  */		
     virtual int GetDistance(uint32_t *piData)
+//    virtual int GetRange(int32_t *piData)
     {
-        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;
+//       return VL6180x_RangeGetResult(Device, piData);
+			return 1;
     }
 		
 /**
@@ -1332,6 +1329,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);
@@ -1358,8 +1356,9 @@
     int IsPresent()
     {
        int status;
+       uint8_t id=0;
 			
-       status=ReadID((uint8_t *)MyDevice.I2cDevAddr);
+       status=ReadID(&id);
        if(status)
           VL53L0X_ErrLog("Failed to read ID device. Device not present!\n\r");
        return status;
@@ -1378,6 +1377,9 @@
 		
     /* IO Device */
     DevI2C &dev_i2c;
+    /* GPIO expander */
+//    STMPE1600 &io_expander;
+//    ExpGpioPinName xshutdown;
     /* Digital out pin */
     DigitalOut *gpio0;
     /* GPIO expander */
@@ -1393,3 +1395,5 @@
 #endif /* _VL53L0X_CLASS_H_ */
 
 
+
+