i2c driver for VL6180x distance sensor

Dependents:   m3Dpi

Revision:
0:84c73bed7d92
Child:
1:6a00afc8dc84
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vl6180x.h	Thu Dec 03 07:58:19 2015 +0000
@@ -0,0 +1,44 @@
+#pragma once
+
+#include "mbed.h"
+
+class VL6180x
+{
+
+public:
+    struct Identification {
+        char model;
+        char modelRevMajor;
+        char modelRevMinor;
+        char moduleRevMajor;
+        char moduleRevMinor;
+        int date;
+        int time;
+    };
+
+    VL6180x(PinName sda, PinName scl, char _address = 0xE0);
+    //VL6180x(I2C &i2c, char address = 0xE0 );
+    void initialize();
+
+    int getDistance();
+    float getAmbientLight();
+    Identification getIdentification();
+    static void printIdentification(Identification id);
+    
+    void setRegister(int register, int value);
+    int getRegister(int reg);
+
+    void setAddress(int address);
+
+protected:
+    int address;
+    I2C i2c;
+    
+
+
+    static const int I2C_SLAVE_DEFAULT_ADDRESS = 0x52;
+    static const int I2C_SLAVE_DEVICE_ADDRESS = 0x212;
+    
+    static const int INTERLEAVED_MODE_ENABLE = 0x2A3;
+
+};
\ No newline at end of file