ULTRA96/tof_demo/src/vl53l0x_i2c.c
//
// internal routine for writing a buffer of bytes
//
internal routine for writing a buffer of bytes
internal routine for writing a buffer of bytes
static void __i2c_write( int file, uint8_t sad, uint8_t reg, uint8_t *buff, size_t siz )
{
    unsigned char *outbuf;
    struct i2c_rdwr_ioctl_data packets;
    struct i2c_msg messages[1];
    outbuf = malloc(siz+1);
    outbuf[0] = reg;
    memcpy(&outbuf[1], buff, siz);
    messages[0].addr  = sad;
    messages[0].flags = 0;
    messages[0].len   = siz+1;
    messages[0].buf   = outbuf;
    packets.msgs  = messages;
    packets.nmsgs = 1;
    ioctl(file, I2C_RDWR, &packets);
    free(outbuf);
}
static void __i2c_write ( int file , uint8_t sad , uint8_t reg , uint8_t * buff , size_t siz ) { unsigned char * outbuf ; struct i2c_rdwr_ioctl_data packets ; struct i2c_msg messages [ 1 ] ; outbuf = malloc ( siz + 1 ) ; outbuf [ 0 ] = reg ; memcpy ( & outbuf [ 1 ] , buff , siz ) ; messages [ 0 ] . addr = sad ; messages [ 0 ] . flags = 0 ; messages [ 0 ] . len = siz + 1 ; messages [ 0 ] . buf = outbuf ; packets . msgs = messages ; packets . nmsgs = 1 ; ioctl ( file , I2C_RDWR , & packets ) ; free ( outbuf ) ; }
internal routine for writing a buffer of bytes
internal routine for writing a buffer of bytes