SOFT564Z Group 3 / Mbed 2 deprecated SOFT564Z_Group_3v3

Dependencies:   mbed Servo ros_lib_kinetic

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TOF.h Source File

TOF.h

00001 /*--------------------------------------------------------------------------------
00002 Filename: TOF.h
00003 Description: Header file for adafruit VL_6180X TOF sensor
00004 --------------------------------------------------------------------------------*/
00005 #ifndef TOF_H
00006 #define TOF_H
00007 
00008 /*--------------------------------------------------------------------------------
00009 ---------------------------------DEFINES------------------------------------------
00010 --------------------------------------------------------------------------------*/
00011 
00012 //Sensor addresses
00013 #define DEFAULT_ADDR 0x52
00014 #define ADDR1    0x29
00015 #define ADDR4    0x2A
00016 #define ADDR6    0x2C
00017 #define ADDR7    0x2E
00018 
00019 //Device model identification number
00020 #define MODEL_ID                        0x000
00021 
00022 //Interrupt configuration
00023 #define INTERRUPT_CONFIG                0x014
00024 
00025 //Interrupt clear bits
00026 #define INTERRUPT_CLEAR                 0x015
00027 
00028 //Fresh out of reset bit
00029 #define FRESH_OUT_OF_RESET              0x016
00030 
00031 //Trigger Ranging
00032 #define SYSRANGE_START                  0x018
00033 
00034 //Trigger Lux Reading
00035 #define SYSALS_START                    0x038
00036 
00037 //Lux reading gain
00038 #define SYSALS_ANALOGUE_GAIN            0x03F
00039 
00040 //Integration period for ALS mode, high byte
00041 #define SYSALS_INTEGRATION_PERIOD_HI    0x040
00042 
00043 //Integration period for ALS mode, low byte
00044 #define SYSALS_INTEGRATION_PERIOD_LO    0x041
00045 
00046 //Specific error codes
00047 #define RESULT_RANGE_STATUS             0x04d
00048 
00049 //Interrupt status
00050 #define RESULT_INTERRUPT_STATUS_GPIO    0x04f
00051 
00052 //Light reading value
00053 #define RESULT_ALS_VAL                  0x050
00054 
00055 //Ranging reading value
00056 #define RESULT_RANGE_VAL                0x062
00057 
00058 #define ALS_GAIN_1         0x06  // 1x gain
00059 #define ALS_GAIN_1_25      0x05  // 1.25x gain
00060 #define ALS_GAIN_1_67      0x04  // 1.67x gain
00061 #define ALS_GAIN_2_5       0x03  // 2.5x gain
00062 #define ALS_GAIN_5         0x02  // 5x gain
00063 #define ALS_GAIN_10        0x01  // 10x gain
00064 #define ALS_GAIN_20        0x00  // 20x gain
00065 #define ALS_GAIN_40        0x07  // 40x gain
00066 
00067 #define ERROR_NONE         0   // Success!
00068 #define ERROR_SYSERR_1     1   // System error
00069 #define ERROR_SYSERR_5     5   // Sysem error
00070 #define ERROR_ECEFAIL      6   // Early convergence estimate fail
00071 #define ERROR_NOCONVERGE   7   // No target detected
00072 #define ERROR_RANGEIGNORE  8   // Ignore threshold check failed
00073 #define ERROR_SNR          11  // Ambient conditions too high
00074 #define ERROR_RAWUFLOW     12  // Raw range algo underflow
00075 #define ERROR_RAWOFLOW     13  // Raw range algo overflow
00076 #define ERROR_RANGEUFLOW   14  // Raw range algo underflow
00077 #define ERROR_RANGEOFLOW   15  // Raw range algo overflow
00078 
00079 /*--------------------------------------------------------------------------------
00080 ---------------------------------CLASSES------------------------------------------
00081 --------------------------------------------------------------------------------*/
00082 
00083 // Class for managing connection and state to a VL6180X sensor
00084 
00085 class cAdafruit_VL6180X
00086 {
00087 public:
00088     cAdafruit_VL6180X(DigitalOut sensor1, DigitalOut sensor2, DigitalOut sensor3, DigitalOut sensor4);  //Constructor, initialises the 4 input sensors
00089     int Init(uint8_t address);              //Initialisation routine
00090     int Start_Range(uint8_t address);       //Start measurements command
00091     int Poll_Range(uint8_t address);        //Poll for measurement
00092     int Read_Range(uint8_t address);        //Read and return measurement
00093     int Clear_Interrupts(uint8_t address);  //Clear all interrupts
00094     void Setup(uint8_t address, uint8_t newaddress);//Address configuration routiune
00095 private:
00096     void WriteByte(uint8_t address, wchar_t reg,char data);  //Write byte via I2C libraries
00097     char ReadByte(uint8_t address, wchar_t reg);             //Read byte via I2C libraries (first write to target address then read the byte)
00098 
00099 };
00100 
00101 /*--------------------------------------------------------------------------------
00102 -----------------------------------Functions---------------------------------------
00103 --------------------------------------------------------------------------------*/
00104 uint8_t serviceTOF(cAdafruit_VL6180X VL6180X, uint8_t address); //Perform a read of the targeted TOF sensor
00105 
00106 /*--------------------------------------------------------------------------------
00107 --------------------------------External Variables--------------------------------
00108 --------------------------------------------------------------------------------*/
00109 
00110 #endif