ULTRA96/tof_demo/src/vl53l0x_i2c.c
//
// internal routine to read a buffer of bytes
//
internal routine to read a buffer of bytes
internal routine to read a buffer of bytes
static uint8_t __i2c_read( int file, uint8_t sad, uint8_t reg, uint8_t *buff, size_t siz )
{
    struct i2c_rdwr_ioctl_data packets;
    struct i2c_msg             messages[2];
    unsigned char              outbuf;
    int i;
    outbuf = reg;
    messages[0].addr  = sad;
    messages[0].flags = 0;
    messages[0].len   = sizeof(outbuf);
    messages[0].buf   = &outbuf;
    messages[1].addr  = sad;
    messages[1].flags = I2C_M_RD;
    messages[1].len   = siz;
    messages[1].buf   = buff;
    packets.msgs      = messages;
    packets.nmsgs     = 2;
    i = ioctl(file, I2C_RDWR, &packets);
    if(i < 0)
        return -1;
    return 1;
}
static uint8_t __i2c_read ( int file , uint8_t sad , uint8_t reg , uint8_t * buff , size_t siz ) { struct i2c_rdwr_ioctl_data packets ; struct i2c_msg messages [ 2 ] ; unsigned char outbuf ; int i ; outbuf = reg ; messages [ 0 ] . addr = sad ; messages [ 0 ] . flags = 0 ; messages [ 0 ] . len = sizeof ( outbuf ) ; messages [ 0 ] . buf = & outbuf ; messages [ 1 ] . addr = sad ; messages [ 1 ] . flags = I2C_M_RD ; messages [ 1 ] . len = siz ; messages [ 1 ] . buf = buff ; packets . msgs = messages ; packets . nmsgs = 2 ; i = ioctl ( file , I2C_RDWR , & packets ) ; if ( i < 0 ) return -1 ; return 1 ; }
internal routine to read a buffer of bytes
internal routine to read a buffer of bytes