本文主要是介绍I2c驱动i2c_master_send()和i2c_master_recv()用法(八),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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");
这篇关于I2c驱动i2c_master_send()和i2c_master_recv()用法(八)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!