VL6180X传感器驱动

来源:互联网 发布:江苏语音网络系统注册 编辑:程序博客网 时间:2024/05/04 08:57

vl6180x_i2c.c

#include "vl6180x_i2c.h"#include <softi2c.h>uint8 data_reg=0;/***********************************************************************************************************   函 数 名: VL6180X_CheckID*   功能说明: 获取VL6180X的ID*   返 回 值: VL6180X_ID**********************************************************************************************************/uint8 VL6180X_CheckID(void){    uint8 data_ID;    data_ID = VL6180x_ReadBytes(DEV_ADDR, VL6180X_IDENTIFICATION_MODEL_ID);    return data_ID;}void VL6180X_Init(void){    uint8 reset=0, timeOut=0;    GPIO_0_OUTPUT;    GPIO_1_OUTPUT;//    Power_PIN_OUTPUT;//    Power_PIN_PORT=0;//    GPIO_0_PIN_PORT = 0;//    GPIO_1_PIN_PORT = 0;//    DelayMS(5);//    Power_PIN_PORT=1;//    DelayMS(5);//    GPIO_0_PIN_PORT = 1;//    GPIO_1_PIN_PORT = 1;//    DelayMS(5);    GPIO_0_PIN_PORT = 0;    GPIO_1_PIN_PORT = 0;    DelayMS(10);    GPIO_0_PIN_PORT = 1;    GPIO_1_PIN_PORT = 1;    DelayMS(1);    while(!(VL6180X_CheckID() == 0xB4));    DelayMS(5);    VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSTEM_FRESH_OUT_OF_RESET, 0x01);      while (reset!=1 && timeOut<100) {        reset = VL6180x_ReadBytes(DEV_ADDR, VL6180X_SYSTEM_FRESH_OUT_OF_RESET);  // read fresh_out_of_reset bit        if(reset == 1) {  // if if fresh_out_of_reset bit set, then device has been freshly initialized            // SR03 settings AN4545 24/27 DocID026571 Rev 19 SR03 settings            // http://www.st.com/st-web-ui/static/active/en/resource/technical/document/application_note/DM00122600.pdf            // Below are the recommended settings required to be loaded onto the VL6180X during the            // initialisation of the device (see Section 1.3).            // Mandatory : private registers            VL6180X_WriteBytes(DEV_ADDR, 0x0207, 0x01);            data_reg = VL6180x_ReadBytes(DEV_ADDR, 0x0207);            VL6180X_WriteBytes(DEV_ADDR, 0x0208, 0x01);            VL6180X_WriteBytes(DEV_ADDR, 0x0096, 0x00);            VL6180X_WriteBytes(DEV_ADDR, 0x0097, 0xFD);            VL6180X_WriteBytes(DEV_ADDR, 0x00e3, 0x00);            VL6180X_WriteBytes(DEV_ADDR, 0x00e4, 0x04);            data_reg = VL6180x_ReadBytes(DEV_ADDR, 0x00e4);            VL6180X_WriteBytes(DEV_ADDR, 0x00e5, 0x02);            VL6180X_WriteBytes(DEV_ADDR, 0x00e6, 0x01);            VL6180X_WriteBytes(DEV_ADDR, 0x00e7, 0x03);            VL6180X_WriteBytes(DEV_ADDR, 0x00f5, 0x02);            VL6180X_WriteBytes(DEV_ADDR, 0x00d9, 0x05);            VL6180X_WriteBytes(DEV_ADDR, 0x00db, 0xce);            VL6180X_WriteBytes(DEV_ADDR, 0x00dc, 0x03);            VL6180X_WriteBytes(DEV_ADDR, 0x00dd, 0xf8);            VL6180X_WriteBytes(DEV_ADDR, 0x009f, 0x00);            VL6180X_WriteBytes(DEV_ADDR, 0x00a3, 0x3c);            VL6180X_WriteBytes(DEV_ADDR, 0x00b7, 0x00);            VL6180X_WriteBytes(DEV_ADDR, 0x00bb, 0x3c);            VL6180X_WriteBytes(DEV_ADDR, 0x00b2, 0x09);            VL6180X_WriteBytes(DEV_ADDR, 0x00ca, 0x09);            VL6180X_WriteBytes(DEV_ADDR, 0x0198, 0x01);            VL6180X_WriteBytes(DEV_ADDR, 0x01b0, 0x17);            VL6180X_WriteBytes(DEV_ADDR, 0x01ad, 0x00);            VL6180X_WriteBytes(DEV_ADDR, 0x00ff, 0x05);            VL6180X_WriteBytes(DEV_ADDR, 0x0100, 0x05);            VL6180X_WriteBytes(DEV_ADDR, 0x0199, 0x05);            VL6180X_WriteBytes(DEV_ADDR, 0x01a6, 0x1b);            VL6180X_WriteBytes(DEV_ADDR, 0x01ac, 0x3e);            VL6180X_WriteBytes(DEV_ADDR, 0x01a7, 0x1f);            VL6180X_WriteBytes(DEV_ADDR, 0x0030, 0x00);            data_reg = VL6180x_ReadBytes(DEV_ADDR, 0x0030);            // configure range measurement for low power            // Specify range measurement interval in units of 10 ms from 0 (= 10 ms) - 254 (= 2.55 s)            VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSRANGE_INTERMEASUREMENT_PERIOD, 0x0A); // 100 ms interval in steps of 10 ms            VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSRANGE_VHV_REPEAT_RATE, 0xFF); // sets number of range measurements after which autocalibrate is performed            VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSRANGE_VHV_RECALIBRATE, 0x01); // perform temperature calibration of the ranging sensor            // Set Early Convergence Estimate for lower power consumption            VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSRANGE_MAX_CONVERGENCE_TIME, 0x32); // set max convergence time to 50 ms (steps of 1 ms)            VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSRANGE_RANGE_CHECK_ENABLES, 0x10 | 0x01);  // enable (0x01) early convergence estimate            // This ECE is calculated as follows:            // [(1 - % below threshold) x 0.5 x 15630]/ range max convergence time            // This is ~123 ms for 50 ms max convergence time and 80% below threshold            // This is a sixteen bit (2 byte) register with the first byte MSByte and the second LSByte            VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSRANGE_EARLY_CONVERGENCE_ESTIMATE, 0x00); // set early convergence estimate to 5%            VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSRANGE_EARLY_CONVERGENCE_ESTIMATE + 1, 0x7B); // set early convergence estimate to 5%            // Configure ALS            VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSALS_INTERMEASUREMENT_PERIOD, 0x0A);   // set to 100 ms            data_reg = VL6180x_ReadBytes(DEV_ADDR, VL6180X_SYSALS_INTERMEASUREMENT_PERIOD);            // Following is a 16-bit register with the first MSByte reserved            VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSALS_INTEGRATION_PERIOD, 0x00);            VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSALS_INTEGRATION_PERIOD+1, 0x63);        // set ALS integration time to 100 ms in steps of 1 ms            // The internal readout averaging sample period can be adjusted from 0 to 255. Increasing the sampling            // period decreases noise but also reduces the effective max convergence time and increases power consumption:            // Effective max convergence time = max convergence time - readout averaging period (see            // Section 2.5: Range timing). Each unit sample period corresponds to around 64.5 ?s additional            // processing time. The recommended setting is 48 which equates to around 4.3 ms            VL6180X_WriteBytes(DEV_ADDR, VL6180X_READOUT_AVERAGING_SAMPLE_PERIOD, 0x30);  // compromise between low noise and increased execution time            // Gain can be 0 = 20, 1 = 10, 2 = 5, 3 = 2.5, 4 = 1.67, 5 = 1.25, 6 = 1.0 and 7 = 40            // These are value possible for the lower nibble. The upper nibble must be 4            VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSALS_ANALOGUE_GAIN, 0x40 | 1);   // Sets light and dark gain (don't change upper nibble)            data_reg = VL6180x_ReadBytes(DEV_ADDR, VL6180X_SYSALS_ANALOGUE_GAIN);            // Scalar (1 - 32, bits 4:0) to multiply raw ALS count for additonal gain, if necessary            VL6180X_WriteBytes(DEV_ADDR, VL6180X_FIRMWARE_RESULT_SCALER, 0x01);            // Configure the interrupts            VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSTEM_MODE_GPIO0, 0x00);                // set up GPIO 0 (set to high impedence for now)            VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSTEM_MODE_GPIO1, 0x00);                // set up GPIO 1 (set to high impedence for now)            VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSTEM_INTERRUPT_CONFIG_GPIO, 0x24);     // enable sample ready interrupt#if 0            // enable continuous range mode            if(VL6180XMode == contRangeMode) {                VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSRANGE_START, 0x03);  // start auto range mode            }            // enable continuous ALS mode            if(VL6180XMode == contALSMode) {                // Configure ALS                VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSALS_INTERMEASUREMENT_PERIOD, 0x32);   // set to 100 ms                // Following is a 16-bit register with the first MSByte reserved                VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSALS_INTEGRATION_PERIOD+1, 0x32);        // set ALS integration time to 50 ms in steps of 1 ms                VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSALS_START, 0x03);                     // start auto range mode            }#endif            // Clear reset bit            VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSTEM_FRESH_OUT_OF_RESET, 0x00);        // reset fresh_out_of_reset bit to zero        } else {            timeOut++;        }    }    reset=0;}uint8 RangePollingRead(void){    uint8 status;    uint8  distance;    /* Wait for device ready. */    do {        status = VL6180x_ReadBytes(DEV_ADDR, VL6180X_RESULT_RANGE_STATUS);    } while ((status & (1 << 0)) == 0);    VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSRANGE_START, START_SINGLE_MODE);    data_reg = VL6180x_ReadBytes(DEV_ADDR, VL6180X_SYSRANGE_START);    status = VL6180x_ReadBytes(DEV_ADDR, VL6180X_RESULT_INTERRUPT_STATUS_GPIO);    status = status & RANGE_SINGLE_MODE_MASK;     /* Wait for measurement ready. */    while (status != RANGE_SINGLE_MODE_READY) {        status = VL6180x_ReadBytes(DEV_ADDR, VL6180X_RESULT_INTERRUPT_STATUS_GPIO);        status = status & RANGE_SINGLE_MODE_MASK;        DelayMS(1);    }    DelayMS(10);    distance = VL6180x_ReadBytes(DEV_ADDR, VL6180X_RESULT_RANGE_VAL);    VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSTEM_INTERRUPT_CLEAR, CLEAR_ALS_INT);    return distance;}uint16 ligthPollingRead(void) {    uint8 status;    uint16 alsraw;    /* Wait for device ready. */    do {        status = VL6180x_ReadBytes(DEV_ADDR, VL6180X_RESULT_ALS_STATUS);    } while ((status & (1 << 0)) == 0);    VL6180X_WriteBytes(DEV_ADDR,VL6180X_SYSALS_START, START_SINGLE_MODE);    data_reg = VL6180x_ReadBytes(DEV_ADDR, VL6180X_SYSALS_START);    status = VL6180x_ReadBytes(DEV_ADDR,VL6180X_RESULT_INTERRUPT_STATUS_GPIO);    status = status & ALS_SINGLE_MODE_MASK;//     while (status != ALS_SINGLE_MODE_READY) {//        status =  VL6180x_ReadBytes(DEV_ADDR, VL6180X_RESULT_INTERRUPT_STATUS_GPIO);//        status = status & ALS_SINGLE_MODE_MASK;//        DelayMS(1);//    }    alsraw = VL6180x_Read_Two_Bytes(DEV_ADDR, VL6180X_RESULT_ALS_VAL);    //als = 0.32f * ((float) alsraw / 10.32) * (100.0f/100.0f);    VL6180X_WriteBytes(DEV_ADDR, VL6180X_SYSTEM_INTERRUPT_CLEAR, CLEAR_ALS_INT);    return alsraw;}/* * 通过I2C总线向某一寄存器写入一个字节数据 *  成功 0 *  失败 1  */uint8 VL6180X_WriteBytes(uint8 I2C_addr,uint16 index,uint8 dat){    uint8 Index_H = (uint8)(index >> 8);        uint8 Index_L = (uint8)(index & 0xff);    start();    iic_write(I2C_addr | 0X00); //WRITE i2c    if (check_ack()==0) {        goto err;    }    iic_write(Index_H); //TDOS'register    if (check_ack()==0) {        goto err;    }        iic_write(Index_L); //TDOS'register    if (check_ack()==0) {        goto err;    }    iic_write(dat); //发送数据字节    if (check_ack()==0) {        goto err;    }        stop();        return 0;err:    stop();        return 1;}/* * 通过I2C总线读出某一寄存器的数据 */uint8 VL6180x_ReadBytes(uint8 I2C_addr, uint16 index) {    uint8 dat;        uint8 Index_H = (uint8)(index >> 8);        uint8 Index_L = (uint8)(index & 0xff);    start();    iic_write(I2C_addr | 0X00); //WRITE i2c    if (check_ack()==0) {        goto err;    }    iic_write(Index_H); //TDOS'register    if (check_ack()==0) {        goto err;    }        iic_write(Index_L); //TDOS'register    if (check_ack()==0) {        goto err;    }    start(); //重发起动信号    iic_write(I2C_addr | 0X01); //READ    if (check_ack()==0) {        goto err;    }    dat = iic_read();   //接收读出的数据    stop();        return dat;err:    stop();    return 0;}/* * 通过I2C总线读出某一寄存器的数据 */uint16 VL6180x_Read_Two_Bytes(uint8 I2C_addr, uint16 index) {    uint8 t;        uint16 data_res;    uint8 Index_H = (uint8)(index >> 8);        uint8 Index_L = (uint8)(index & 0xff);    start();    iic_write(I2C_addr | 0X00); //WRITE i2c    if (check_ack()==0) {        goto err;    }    iic_write(Index_H); //TDOS'register    if (check_ack()==0) {        goto err;    }        iic_write(Index_L); //TDOS'register    if (check_ack()==0) {        goto err;    }        stop();    start(); //重发起动信号    iic_write(I2C_addr | 0X01); //READ    if (check_ack()==0) {        goto err;    }    t = iic_read(); //接收读出的数据    send_ack();              data_res = t;     t = iic_read(); //接收读出的数据    send_ack();               data_res = ((data_res<<8) | t);//  t = iic_read(); //接收读出的数据     //  send_ack();   //        data_res = ((data_res<<16) | t);//        //        t = iic_read();   //接收读出的数据     //  send_ack();   //        data_res = ((data_res<<24) | t);    stop();        return data_res;err:    stop();    return 0;}

vl6180x_i2c.h

#ifndef VL6180_I2C_H_#define VL6180_I2C_H_#include "softi2c.h"#define GPIO_0_PIN_PORT                 P1_0#define GPIO_1_PIN_PORT                         P1_1#define Power_PIN_PORT                          P1_2#define GPIO_0_OUTPUT                           (P1DIR |= BIT0)#define GPIO_1_OUTPUT                       (P1DIR |= BIT1)#define Power_PIN_OUTPUT                (P1DIR |= BIT2)#define DEV_ADDR                                    (0X29<<1)//This read-only register contains the device identifier, set to B4#define VL6180X_IDENTIFICATION_MODEL_ID_RETURN             0xB4// VL6180X registers#define VL6180X_WHO_AM_I                             0x0000   // should be 0xB4#define VL6180X_IDENTIFICATION_MODEL_ID              0x0000#define VL6180X_IDENTIFICATION_MODEL_REV_MAJOR       0x0001#define VL6180X_IDENTIFICATION_MODEL_REV_MINOR       0x0002#define VL6180X_IDENTIFICATION_MODULE_REV_MAJOR      0x0003#define VL6180X_IDENTIFICATION_MODULE_REV_MINOR      0x0004#define VL6180X_IDENTIFICATION_DATE_HI               0x0006#define VL6180X_IDENTIFICATION_DATE_LO               0x0007#define VL6180X_IDENTIFICATION_TIME_HI               0x0008#define VL6180X_IDENTIFICATION_TIME_LO               0x0009#define VL6180X_SYSTEM_MODE_GPIO0                    0x0010#define VL6180X_SYSTEM_MODE_GPIO1                    0x0011#define VL6180X_SYSTEM_HISTORY_CTRL                  0x0012/*[5:3] als_int_mode: Interrupt mode source for ALS readings:0: Disabled1: Level Low (value < thresh_low)2: Level High (value > thresh_high)3: Out Of Window (value < thresh_low OR value > thresh_high)4: New sample ready[2:0] range_int_mode: Interrupt mode source for Range readings:0: Disabled1: Level Low (value < thresh_low)2: Level High (value > thresh_high)3: Out Of Window (value */#define VL6180X_SYSTEM_INTERRUPT_CONFIG_GPIO         0x0014#define VL6180X_SYSTEM_INTERRUPT_CLEAR               0x0015#define VL6180X_SYSTEM_FRESH_OUT_OF_RESET            0x0016#define VL6180X_SYSTEM_GROUPED_PARAMETER_HOLD        0x0017/*[1] sysrange__mode_select: Device Mode select0: Ranging Mode Single-Shot1: Ranging Mode Continuous[0] sysrange__startstop: StartStop trigger based on current mode and system configuration ofdevice_ready. FW clears register automatically.Setting this bit to 1 in single-shot mode starts a single measurement.Setting this bit to 1 in continuous mode will either start continuous operation (if stopped) or haltcontinuous operation (if started).This bit is auto-cleared in both modes of operation. */#define VL6180X_SYSRANGE_START                       0x0018#define VL6180X_SYSRANGE_THRESH_HIGH                 0x0019#define VL6180X_SYSRANGE_THRESH_LOW                  0x001A#define VL6180X_SYSRANGE_INTERMEASUREMENT_PERIOD     0x001B#define VL6180X_SYSRANGE_MAX_CONVERGENCE_TIME        0x001C#define VL6180X_SYSRANGE_CROSSTALK_COMPENSATION_RATE 0x001E#define VL6180X_SYSRANGE_CROSSTALK_VALID_HEIGHT      0x0021#define VL6180X_SYSRANGE_EARLY_CONVERGENCE_ESTIMATE  0x0022#define VL6180X_SYSRANGE_PART_TO_PART_RANGE_OFFSET   0x0024#define VL6180X_SYSRANGE_RANGE_IGNORE_VALID_HEIGHT   0x0025#define VL6180X_SYSRANGE_RANGE_IGNORE_THRESHOLD      0x0026#define VL6180X_SYSRANGE_MAX_AMBIENT_LEVEL_MULT      0x002C#define VL6180X_SYSRANGE_RANGE_CHECK_ENABLES         0x002D#define VL6180X_SYSRANGE_VHV_RECALIBRATE             0x002E#define VL6180X_SYSRANGE_VHV_REPEAT_RATE             0x0031/*[1] sysals__mode_select: Device Mode select0: ALS Mode Single-Shot1: ALS Mode Continuous[0] VL6180X_SYSALS_STARTstop: Start/Stop trigger based on current mode and system configuration ofdevice_ready. FW clears register automatically.Setting this bit to 1 in single-shot mode starts a single measurement.Setting this bit to 1 in continuous mode will either start continuous operation (if stopped) or haltcontinuous operation (if started).This bit is auto-cleared in both modes of operation.See 6.2.56: INTERLEAVED_MODE__ENABLE for combined ALS and Range operation. */#define VL6180X_SYSALS_START                         0x038#define VL6180X_SYSALS_THRESH_HIGH                   0x003A#define VL6180X_SYSALS_THRESH_LOW                    0x003C#define VL6180X_SYSALS_INTERMEASUREMENT_PERIOD       0x003E/*VL6180X_SYSALS_ANALOGUE_GAIN_light: ALS analogue gain (light channel)0: ALS Gain = 201: ALS Gain = 102: ALS Gain = 5.03: ALS Gain = 2.54: ALS Gain = 1.675: ALS Gain = 1.256: ALS Gain = 1.07: ALS Gain = 40Controls the 搇ight?channel gain.Note: Upper nibble should be set to 0x4 i.e. For ALS gain of 1.0 write 0x46. */#define VL6180X_SYSALS_ANALOGUE_GAIN                 0x003F#define VL6180X_SYSALS_INTEGRATION_PERIOD            0x0040#define VL6180X_RESULT_RANGE_STATUS                  0x004D#define VL6180X_RESULT_ALS_STATUS                    0x004E/*[7:6] result_int_error_gpio: Interrupt bits for Error:0: No error reported1: Laser Safety Error2: PLL error (either PLL1 or PLL2)[5:3] result_int_als_gpio: Interrupt bits for ALS:0: No threshold events reported1: Level Low threshold event2: Level High threshold event3: Out Of Window threshold event4: New Sample Ready threshold event[2:0] result_int_range_gpio: Interrupt bits for Range:0: No threshold events reported1: Level Low threshold event2: Level High threshold event3: Out Of Window threshold event4: New Sample Ready threshold event */#define VL6180X_RESULT_INTERRUPT_STATUS_GPIO         0x004F#define VL6180X_RESULT_ALS_VAL                       0x0050#define VL6180X_RESULT_HISTORY_BUFFER0               0x0052 // This is a FIFO buffer that can store 8 range values or 16 ALS values#define VL6180X_RESULT_HISTORY_BUFFER1               0x0053 // It would be read in burst mode so all that is#define VL6180X_RESULT_HISTORY_BUFFER2               0x0054 // needed would be to reference the first address#define VL6180X_RESULT_HISTORY_BUFFER3               0x0055#define VL6180X_RESULT_HISTORY_BUFFER4               0x0056#define VL6180X_RESULT_HISTORY_BUFFER5               0x0057#define VL6180X_RESULT_HISTORY_BUFFER6               0x0058#define VL6180X_RESULT_HISTORY_BUFFER7               0x0059#define VL6180X_RESULT_HISTORY_BUFFER8               0x0060  // end of FIFO/*[7:0] result__range_val: Final range result value presented to the user for use. Unit is in mm. */#define VL6180X_RESULT_RANGE_VAL                     0x0062#define VL6180X_RESULT_RANGE_RAW                     0x0064#define VL6180X_RESULT_RANGE_RETURN_RATE             0x0066#define VL6180X_RESULT_RANGE_REFERENCE_RATE          0x0068#define VL6180X_RESULT_RANGE_RETURN_SIGNAL_COUNT     0x006C#define VL6180X_RESULT_RANGE_REFERENCE_SIGNAL_COUNT  0x0070#define VL6180X_RESULT_RANGE_RETURN_AMB_COUNT        0x0074#define VL6180X_RESULT_RANGE_REFERENCE_AMB_COUNT     0x0078#define VL6180X_RESULT_RANGE_RETURN_CONV_TIME        0x007C#define VL6180X_RESULT_RANGE_REFERENCE_CONV_TIME     0x0080#define VL6180X_READOUT_AVERAGING_SAMPLE_PERIOD      0x010A#define VL6180X_FIRMWARE_BOOTUP                      0x0119#define VL6180X_FIRMWARE_RESULT_SCALER               0x0120#define VL6180X_I2C_SLAVE_DEVICE_ADDRESS             0x0212#define VL6180X_INTERLEAVED_MODE_ENABLE              0x02A3#define START_SINGLE_MODE                            0x01#define START_CONTINUOUS_MODE                        0x02#define ALS_SINGLE_MODE_MASK                         0x38#define ALS_SINGLE_MODE_READY                        0x20#define RANGE_SINGLE_MODE_MASK                       0x07#define RANGE_SINGLE_MODE_READY                      0x04#define CLEAR_RANGE_INT                              0x01#define CLEAR_ALS_INT                                0x02#define CLEAR_ERROR_INT                              0x04#define contRangeMode                                0#define contALSMode                                  1#define VL6180XMode                                  0void VL6180X_Init(void);uint8 RangePollingRead(void);uint16 ligthPollingRead(void);uint8 VL6180X_WriteBytes(uint8 I2C_addr,uint16 index,uint8 dat);uint8 VL6180x_ReadBytes(uint8 I2C_addr, uint16 index) ;uint16 VL6180x_Read_Two_Bytes(uint8 I2C_addr, uint16 index);#endif

GitHub工程源代码:

https://github.com/lanhaixuan/CC2541_VL6180X_BMA250

原创粉丝点击