DECS_UIRP_2019_1st_semester / VL53L1X
Committer:
ink0513
Date:
Thu Aug 22 08:04:58 2019 +0000
Revision:
7:798b42aae185
Parent:
6:621552ff1de9
tof; OS2_Operation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ink0513 7:798b42aae185 1
jvfausto 0:03b7e8deb3ee 2 #ifndef VL53L1X_H
jvfausto 0:03b7e8deb3ee 3 #define VL53L1X_H
jvfausto 0:03b7e8deb3ee 4
jvfausto 0:03b7e8deb3ee 5 #include "mbed.h"
jvfausto 0:03b7e8deb3ee 6
jvfausto 0:03b7e8deb3ee 7 #include "VL53L1X_register_map.h"
jvfausto 0:03b7e8deb3ee 8
jvfausto 0:03b7e8deb3ee 9 #define I2C_BUFFER_LENGTH 32
jvfausto 0:03b7e8deb3ee 10
jvfausto 0:03b7e8deb3ee 11 const char defaultAddress_VL53L1X = 0x29;
jvfausto 0:03b7e8deb3ee 12
jvfausto 0:03b7e8deb3ee 13 class VL53L1X {
jvfausto 0:03b7e8deb3ee 14 public:
jvfausto 0:03b7e8deb3ee 15 VL53L1X(PinName SDA, PinName SCL);
jvfausto 6:621552ff1de9 16 bool begin();
jvfausto 0:03b7e8deb3ee 17 void softReset(); //Reset the sensor via software
jvfausto 0:03b7e8deb3ee 18 void startMeasurement(uint8_t offset = 0); //Write a block of bytes to the sensor to configure it to take a measurement
jvfausto 0:03b7e8deb3ee 19 bool newDataReady(); //Polls the measurement completion bit
jvfausto 0:03b7e8deb3ee 20 uint16_t getDistance(); //Returns the results from the last measurement, distance in mm
jvfausto 0:03b7e8deb3ee 21 uint16_t getSignalRate(); //Returns the results from the last measurement, signal rate
jvfausto 0:03b7e8deb3ee 22 void setDistanceMode(uint8_t mode = 2);//Defaults to long range
jvfausto 0:03b7e8deb3ee 23 uint8_t getDistanceMode();
jvfausto 0:03b7e8deb3ee 24 uint8_t getRangeStatus(); //Returns the results from the last measurement, 0 = valid
jvfausto 0:03b7e8deb3ee 25
jvfausto 0:03b7e8deb3ee 26 uint8_t readRegister(uint16_t addr); //Read a byte from a 16-bit address
jvfausto 0:03b7e8deb3ee 27 uint16_t readRegister16(uint16_t addr); //Read two bytes from a 16-bit address
jvfausto 0:03b7e8deb3ee 28 void writeRegister(uint16_t addr, uint8_t val); //Write a byte to a spot
jvfausto 0:03b7e8deb3ee 29 void writeRegister16(uint16_t addr, uint16_t val); //Write two bytes to a spot
jvfausto 0:03b7e8deb3ee 30
jvfausto 0:03b7e8deb3ee 31 private:
jvfausto 0:03b7e8deb3ee 32 I2C _i2c;
jvfausto 0:03b7e8deb3ee 33
jvfausto 0:03b7e8deb3ee 34 uint8_t _deviceAddress;
jvfausto 0:03b7e8deb3ee 35 uint8_t _distanceMode;// = 0; <--- might cause a problem
jvfausto 0:03b7e8deb3ee 36 };
jvfausto 0:03b7e8deb3ee 37
jvfausto 0:03b7e8deb3ee 38
jvfausto 0:03b7e8deb3ee 39 #endif