INSAT Mini Project

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON

Fork of X_NUCLEO_6180XA1 by ST

Revision:
48:e799ad44dab7
Parent:
46:116dadbc80f1
Child:
50:18e064bfb156
--- a/Components/VL6180X/vl6180x_class.h	Mon May 23 09:59:39 2016 +0000
+++ b/Components/VL6180X/vl6180x_class.h	Tue Jun 07 14:56:36 2016 +0200
@@ -133,7 +133,8 @@
     */
     virtual ~VL6180X(){ 
     	if (gpio1Int != NULL) delete gpio1Int;
-    }     
+    }  
+    
     /* warning: VL6180X class inherits from GenericSensor, RangeSensor and LightSensor, that haven`t a destructor.
        The warning should request to introduce a virtual destructor to make sure to delete the object */
 
@@ -150,6 +151,9 @@
 	  *gpio0=1;
        else if(expgpio0) 
 	  *expgpio0=1;
+       
+       MyDevice.I2cAddr=DEFAULT_DEVICE_ADDRESS;
+       MyDevice.Ready=0;       
     } 
 
 	/**
@@ -162,9 +166,11 @@
        if(gpio0) 
 	  *gpio0=0;
        else if(expgpio0) 
-	  *expgpio0=0;			
-    }
-    
+	  *expgpio0=0;	
+       
+       MyDevice.I2cAddr=DEFAULT_DEVICE_ADDRESS;
+       MyDevice.Ready=0;       
+    }   
     
 	/**
 	 * @brief       Start the measure indicated by operating mode
@@ -283,9 +289,11 @@
  
    VL6180x_Off();
    VL6180x_On();
+   
    status=VL6180x_WaitDeviceBooted(Device);
-   if(status)
-      VL6180x_ErrLog("WaitDeviceBooted fail\n\r");
+   if(status) {
+      VL6180x_ErrLog("WaitDeviceBooted fail\n\r");      
+   }  
    status=IsPresent();
    if(!status)
    {
@@ -311,11 +319,6 @@
             return status;
          }
       }
-      else
-      {
-         printf("Invalid new address!\n\r");
-         return INVALID_PARAMS;
-      }
       Device->Ready=1;
    }
    return status; 
@@ -1186,16 +1189,7 @@
     int VL6180x_I2CWrite(uint8_t DeviceAddr, uint16_t RegisterAddr, uint8_t *pBuffer, uint16_t NumByteToWrite);
     int VL6180x_I2CRead(uint8_t DeviceAddr, uint16_t RegisterAddr, uint8_t *pBuffer, uint16_t NumByteToRead);
 		
-		
-    int IsPresent()
-    {
-       int status; uint8_t id;
-			
-       status=ReadID(&id);
-       if(status)
-          VL6180x_ErrLog("Failed to read ID device. Device not present!\n\r");
-       return status;
-    }	
+    int IsPresent();
     int StopRangeMeasurement(OperatingMode operating_mode);
     int StopAlsMeasurement(OperatingMode operating_mode);
     int GetRangeMeas(OperatingMode operating_mode, MeasureData_t *Data);