I2C传输大小问题

一次 I2C transfer有两种模式:单开始信号和重复开始信号。

每个硬件平台不同,I2C 控制器限制了一次 I2C transfer的大小。例如MTK平台:最大不能超过8字节。

在调试每一个I2C device时候,需要根据I2C device datasheet的要求:如果必须在一次transfer内传输一个块数据(大于8字节)的话,则只能使用I2C DMA传输。但是有些硬件平台支持:一次I2C transfer传输更多的数据,例如255字节等。这样就不需要DMA传输了。

把一个255字节块数据分割成8字节块数据传输是有问题的。因为每一个8字节块都需要i2c_msg来传输。但是构造i2c_msg对象时需要设置设备地址,读写模式等。所以分割后的8字节块数据是有问题的。


函数解释:

i2c_transfer();

执行一个或多个i2c msgs。在触发STOP信号之前,执行多个i2c msgs,每一个i2c msg以START信号开始。


i2c_msgs

 * Except when I2C "protocol mangling" is used, all I2C adapters implement
 * the standard rules for I2C transactions.  Each transaction begins with a
 * START.  That is followed by the slave address, and a bit encoding read
 * versus write.  Then follow all the data bytes, possibly including a byte
 * with SMBus PEC.  The transfer terminates with a NAK, or when all those
 * bytes have been transferred and ACKed.  If this is the last message in a
 * group, it is followed by a STOP.  Otherwise it is followed by the next
 * @i2c_msg transaction segment, beginning with a (repeated) START.





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值