1. 程式人生 > >rk3288 i2c 寫雙位元組地址

rk3288 i2c 寫雙位元組地址

        struct i2c_adapter *adap;
struct i2c_msg msgs[2];


char reg;
        char reg2[2];
        reg = 0x04;
reg2[1] = 0x00;
        reg2[0] = 0x00;

adap = i2c->adapter;



msgs[0].addr = i2c->addr;
msgs[0].buf = reg2;
msgs[0].flags = i2c->flags;
msgs[0].len = 2;
msgs[0].scl_rate = 200000;


msgs[1].buf = ®
msgs[1].addr = i2c->addr;
msgs[1].flags =  i2c->flags | I2C_M_RD;
msgs[1].len = 1;
msgs[1].scl_rate = 200000;


ret = i2c_transfer(adap, msgs, 2);


printk("***run in %s %x  %x\n", __func__, i2c->addr, *(msgs[1].buf));