I2c驱动i2c_master_send()和i2c_master_recv()用法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010164190/article/details/84647084
struct i2c_client *client
unsigned char buf[2] = {0};
int ret;

buf[0]=0x30;//寄存器地址
buf[1]=0x05;//设置的值

//设置寄存器
ret = i2c_master_send(client, buf, 2);
if(ret < 0)
    printk(KERN_ERR "Write data failed\n");

//读取寄存器
ret = i2c_master_recv(client, buf, 1);
if(ret < 0)
    printk(KERN_ERR "Read data failed\n");

猜你喜欢

转载自blog.csdn.net/u010164190/article/details/84647084
I2C
今日推荐