i2c驱动中的传输函数
来源:互联网 发布:骚男的辣条淘宝店网址 编辑:程序博客网 时间:2024/04/30 20:45
I2C设备驱动编写中要用到信息传输的函数,有很多种,以下以写消息为例。
一、i2c_smbus_write_byte_data
这是在内核中拷贝的该函数的实现代码,value为字节数据,将value写如client代表的设备。函数中的i2c_smbus_xfer最终调用了smbus_xfer函数进行消息的写入。每次传送均为一个字节。
/**
* i2c_smbus_write_byte_data - SMBus "write byte" protocol* @client: Handle to slave device
* @command: Byte interpreted by slave
* @value: Byte being written
*
* This executes the SMBus "write byte" protocol, returning negative errno
* else zero on success.
*/
s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value)
{
union i2c_smbus_data data;
data.byte = value;
return i2c_smbus_xfer(client->adapter,client->addr,client->flags,
I2C_SMBUS_WRITE,command,
I2C_SMBUS_BYTE_DATA,&data);
}
二、i2c_master_send
该函数每次传送一个消息,消息长度是count个字节,将buf开始的count个字节写入client代表的设备。该函数最终调用i2c_transfer传输一条消息。
/**
* i2c_master_send - issue a single I2C message in master transmit mode
* @client: Handle to slave device
* @buf: Data that will be written to the slave
* @count: How many bytes to write
*
* Returns negative errno, or else the number of bytes written.
*/
int i2c_master_send(struct i2c_client *client,const char *buf ,int count)
{
int ret;
struct i2c_adapter *adap=client->adapter;
struct i2c_msg msg;
msg.addr = client->addr;
msg.flags = client->flags & I2C_M_TEN;
msg.len = count; //消息的长度
msg.buf = (char *)buf; //消息的内容
ret = i2c_transfer(adap, &msg, 1); //参数1代表一条消息
/* If everything went ok (i.e. 1 msg transmitted), return #bytes
transmitted, else error code. */
return (ret == 1) ? count : ret;
}
- i2c驱动中的传输函数
- linux的i2c驱动中的函数和数据结构的分析
- uclinux内核中的I2C驱动
- linux驱动——内核通知链(探究i2c-dev.c 中的bus_register_notifier函数所得)
- i2c设备驱动probe函数中platform_data
- uclinux内核中的I2C驱动学习
- uclinux内核中的I2C驱动学习
- 浅谈linux内核中的I2c驱动(1)
- 浅谈linux内核中的I2c驱动(2)
- 设备驱动中的i2c(kernel-4.7)
- i2c驱动--i2c总线接口
- i2c驱动
- I2C驱动
- I2C 驱动
- I2C驱动
- i2c驱动
- I2C驱动
- I2C驱动
- GPFS文件系统分析
- linux进程控制
- 大数据:“人工特征工程+线性模型”的尽头
- python 文件目录操作
- hdfs基本操作,上传、下载、删除
- i2c驱动中的传输函数
- linux防火墙关闭开启
- 对差分约束问题的理解
- zoj 3696 Alien's Organ
- 美国CS面试经验分享
- 二叉树非递归后序遍历
- VIM快捷键
- 爱自黑的明星们继甄嬛体走红网络以后
- 程序员的出路之一