1/27/16 updated JJ

Committer:
j_j205
Date:
Wed Jan 27 20:48:49 2016 +0000
Revision:
0:375445d76687
1/27/16 updated JJ

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j_j205 0:375445d76687 1 #pragma once
j_j205 0:375445d76687 2
j_j205 0:375445d76687 3 #include "mbed.h"
j_j205 0:375445d76687 4
j_j205 0:375445d76687 5 class VL6180x
j_j205 0:375445d76687 6 {
j_j205 0:375445d76687 7
j_j205 0:375445d76687 8 public:
j_j205 0:375445d76687 9 struct Identification {
j_j205 0:375445d76687 10 char model;
j_j205 0:375445d76687 11 char modelRevMajor;
j_j205 0:375445d76687 12 char modelRevMinor;
j_j205 0:375445d76687 13 char moduleRevMajor;
j_j205 0:375445d76687 14 char moduleRevMinor;
j_j205 0:375445d76687 15 int date;
j_j205 0:375445d76687 16 int time;
j_j205 0:375445d76687 17 };
j_j205 0:375445d76687 18
j_j205 0:375445d76687 19 VL6180x(PinName sda, PinName scl, char _address = 0xE0);
j_j205 0:375445d76687 20 VL6180x(I2C &i2c, char address = 0xE0 );
j_j205 0:375445d76687 21 void initialize();
j_j205 0:375445d76687 22
j_j205 0:375445d76687 23 int getDistance();
j_j205 0:375445d76687 24 int getSingleDistance();
j_j205 0:375445d76687 25 float getAmbientLight();
j_j205 0:375445d76687 26 Identification getIdentification();
j_j205 0:375445d76687 27 static void printIdentification(Identification id);
j_j205 0:375445d76687 28 void startContinuousOperation();
j_j205 0:375445d76687 29
j_j205 0:375445d76687 30 void setRegister(int register, int value);
j_j205 0:375445d76687 31 int getRegister(int reg);
j_j205 0:375445d76687 32
j_j205 0:375445d76687 33 void setAddress(int address);
j_j205 0:375445d76687 34
j_j205 0:375445d76687 35 protected:
j_j205 0:375445d76687 36 int address;
j_j205 0:375445d76687 37 I2C i2c;
j_j205 0:375445d76687 38
j_j205 0:375445d76687 39 static const int I2C_SLAVE_DEFAULT_ADDRESS = 0x52;
j_j205 0:375445d76687 40
j_j205 0:375445d76687 41 static const int IDENTIFICATION_MODEL_ID = 0x000;
j_j205 0:375445d76687 42 static const int IDENTIFICATION_MODEL_REV_MAJOR = 0x001;
j_j205 0:375445d76687 43 static const int IDENTIFICATION_MODEL_REV_MINOR = 0x002;
j_j205 0:375445d76687 44 static const int IDENTIFICATION_MODULE_REV_MAJOR = 0x003;
j_j205 0:375445d76687 45 static const int IDENTIFICATION_MODULE_REV_MINOR = 0x004;
j_j205 0:375445d76687 46 static const int IDENTIFICATION_DATE_HI = 0x006;
j_j205 0:375445d76687 47 static const int IDENTIFICATION_DATE_LO = 0x007;
j_j205 0:375445d76687 48 static const int IDENTIFICATION_TIME = 0x008;
j_j205 0:375445d76687 49 static const int SYSTEM_MODE_GPIO0 = 0x010;
j_j205 0:375445d76687 50 static const int SYSTEM_MODE_GPIO1 = 0x011;
j_j205 0:375445d76687 51 static const int SYSTEM_HISTORY_CTRL = 0x012;
j_j205 0:375445d76687 52 static const int SYSTEM_INTERRUPT_CONFIG_GPIO = 0x014;
j_j205 0:375445d76687 53 static const int SYSTEM_INTERRUPT_CLEAR = 0x015;
j_j205 0:375445d76687 54 static const int SYSTEM_FRESH_OUT_OF_RESET = 0x016;
j_j205 0:375445d76687 55 static const int SYSTEM_GROUPED_PARAMETER_HOLD = 0x017;
j_j205 0:375445d76687 56 static const int SYSRANGE_START = 0x018;
j_j205 0:375445d76687 57 static const int SYSRANGE_THRESH_HIGH = 0x019;
j_j205 0:375445d76687 58 static const int SYSRANGE_THRESH_LOW = 0x01A;
j_j205 0:375445d76687 59 static const int SYSRANGE_INTERMEASUREMENT_PERIOD = 0x01B;
j_j205 0:375445d76687 60 static const int SYSRANGE_MAX_CONVERGENCE_TIME = 0x01C;
j_j205 0:375445d76687 61 static const int SYSRANGE_CROSSTALK_COMPENSATION_RATE = 0x01E;
j_j205 0:375445d76687 62 static const int SYSRANGE_CROSSTALK_VALID_HEIGHT = 0x021;
j_j205 0:375445d76687 63 static const int SYSRANGE_EARLY_CONVERGENCE_ESTIMATE = 0x022;
j_j205 0:375445d76687 64 static const int SYSRANGE_PART_TO_PART_RANGE_OFFSET = 0x024;
j_j205 0:375445d76687 65 static const int SYSRANGE_RANGE_IGNORE_VALID_HEIGHT = 0x025;
j_j205 0:375445d76687 66 static const int SYSRANGE_RANGE_IGNORE_THRESHOLD = 0x026;
j_j205 0:375445d76687 67 static const int SYSRANGE_MAX_AMBIENT_LEVEL_MULT = 0x02C;
j_j205 0:375445d76687 68 static const int SYSRANGE_RANGE_CHECK_ENABLES = 0x02D;
j_j205 0:375445d76687 69 static const int SYSRANGE_VHV_RECALIBRATE = 0x02E;
j_j205 0:375445d76687 70 static const int SYSRANGE_VHV_REPEAT_RATE = 0x031;
j_j205 0:375445d76687 71 static const int SYSALS_START = 0x038;
j_j205 0:375445d76687 72 static const int SYSALS_THRESH_HIGH = 0x03A;
j_j205 0:375445d76687 73 static const int SYSALS_THRESH_LOW = 0x03C;
j_j205 0:375445d76687 74 static const int SYSALS_INTERMEASUREMENT_PERIOD = 0x03E;
j_j205 0:375445d76687 75 static const int SYSALS_ANALOGUE_GAIN = 0x03F;
j_j205 0:375445d76687 76 static const int SYSALS_INTEGRATION_PERIOD = 0x040;
j_j205 0:375445d76687 77 static const int RESULT_RANGE_STATUS = 0x04D;
j_j205 0:375445d76687 78 static const int RESULT_ALS_STATUS = 0x04E;
j_j205 0:375445d76687 79 static const int RESULT_INTERRUPT_STATUS_GPIO = 0x04F;
j_j205 0:375445d76687 80 static const int RESULT_ALS_VAL = 0x050;
j_j205 0:375445d76687 81 static const int RESULT_HISTORY_BUFFER_0 = 0x052;
j_j205 0:375445d76687 82 static const int RESULT_HISTORY_BUFFER_1 = 0x054;
j_j205 0:375445d76687 83 static const int RESULT_HISTORY_BUFFER_2 = 0x056;
j_j205 0:375445d76687 84 static const int RESULT_HISTORY_BUFFER_3 = 0x058;
j_j205 0:375445d76687 85 static const int RESULT_HISTORY_BUFFER_4 = 0x05A;
j_j205 0:375445d76687 86 static const int RESULT_HISTORY_BUFFER_5 = 0x05C;
j_j205 0:375445d76687 87 static const int RESULT_HISTORY_BUFFER_6 = 0x05E;
j_j205 0:375445d76687 88 static const int RESULT_HISTORY_BUFFER_7 = 0x060;
j_j205 0:375445d76687 89 static const int RESULT_RANGE_VAL = 0x062;
j_j205 0:375445d76687 90 static const int RESULT_RANGE_RAW = 0x064;
j_j205 0:375445d76687 91 static const int RESULT_RANGE_RETURN_RATE = 0x066;
j_j205 0:375445d76687 92 static const int RESULT_RANGE_REFERENCE_RATE = 0x068;
j_j205 0:375445d76687 93 static const int RESULT_RANGE_RETURN_SIGNAL_COUNT = 0x06C;
j_j205 0:375445d76687 94 static const int RESULT_RANGE_REFERENCE_SIGNAL_COUNT = 0x070;
j_j205 0:375445d76687 95 static const int RESULT_RANGE_RETURN_AMB_COUNT = 0x074;
j_j205 0:375445d76687 96 static const int RESULT_RANGE_REFERENCE_AMB_COUNT = 0x078;
j_j205 0:375445d76687 97 static const int RESULT_RANGE_RETURN_CONV_TIME = 0x07C;
j_j205 0:375445d76687 98 static const int RESULT_RANGE_REFERENCE_CONV_TIME = 0x080;
j_j205 0:375445d76687 99 static const int READOUT_AVERAGING_SAMPLE_PERIOD = 0x10A;
j_j205 0:375445d76687 100 static const int FIRMWARE_BOOTUP = 0x119;
j_j205 0:375445d76687 101 static const int FIRMWARE_RESULT_SCALER = 0x120;
j_j205 0:375445d76687 102 static const int I2C_SLAVE_DEVICE_ADDRESS = 0x212;
j_j205 0:375445d76687 103 static const int INTERLEAVED_MODE_ENABLE = 0x2A3;
j_j205 0:375445d76687 104 };