i2c driver for VL6180x distance sensor

Dependents:   m3Dpi

Committer:
sillevl
Date:
Thu Dec 03 07:58:19 2015 +0000
Revision:
0:84c73bed7d92
Child:
1:6a00afc8dc84
initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sillevl 0:84c73bed7d92 1 #pragma once
sillevl 0:84c73bed7d92 2
sillevl 0:84c73bed7d92 3 #include "mbed.h"
sillevl 0:84c73bed7d92 4
sillevl 0:84c73bed7d92 5 class VL6180x
sillevl 0:84c73bed7d92 6 {
sillevl 0:84c73bed7d92 7
sillevl 0:84c73bed7d92 8 public:
sillevl 0:84c73bed7d92 9 struct Identification {
sillevl 0:84c73bed7d92 10 char model;
sillevl 0:84c73bed7d92 11 char modelRevMajor;
sillevl 0:84c73bed7d92 12 char modelRevMinor;
sillevl 0:84c73bed7d92 13 char moduleRevMajor;
sillevl 0:84c73bed7d92 14 char moduleRevMinor;
sillevl 0:84c73bed7d92 15 int date;
sillevl 0:84c73bed7d92 16 int time;
sillevl 0:84c73bed7d92 17 };
sillevl 0:84c73bed7d92 18
sillevl 0:84c73bed7d92 19 VL6180x(PinName sda, PinName scl, char _address = 0xE0);
sillevl 0:84c73bed7d92 20 //VL6180x(I2C &i2c, char address = 0xE0 );
sillevl 0:84c73bed7d92 21 void initialize();
sillevl 0:84c73bed7d92 22
sillevl 0:84c73bed7d92 23 int getDistance();
sillevl 0:84c73bed7d92 24 float getAmbientLight();
sillevl 0:84c73bed7d92 25 Identification getIdentification();
sillevl 0:84c73bed7d92 26 static void printIdentification(Identification id);
sillevl 0:84c73bed7d92 27
sillevl 0:84c73bed7d92 28 void setRegister(int register, int value);
sillevl 0:84c73bed7d92 29 int getRegister(int reg);
sillevl 0:84c73bed7d92 30
sillevl 0:84c73bed7d92 31 void setAddress(int address);
sillevl 0:84c73bed7d92 32
sillevl 0:84c73bed7d92 33 protected:
sillevl 0:84c73bed7d92 34 int address;
sillevl 0:84c73bed7d92 35 I2C i2c;
sillevl 0:84c73bed7d92 36
sillevl 0:84c73bed7d92 37
sillevl 0:84c73bed7d92 38
sillevl 0:84c73bed7d92 39 static const int I2C_SLAVE_DEFAULT_ADDRESS = 0x52;
sillevl 0:84c73bed7d92 40 static const int I2C_SLAVE_DEVICE_ADDRESS = 0x212;
sillevl 0:84c73bed7d92 41
sillevl 0:84c73bed7d92 42 static const int INTERLEAVED_MODE_ENABLE = 0x2A3;
sillevl 0:84c73bed7d92 43
sillevl 0:84c73bed7d92 44 };