SMBus协议总结

完美分割SMBus协议总结
本文将对SMBUS协议进行总结。本文针对该协议的所有修订版(包括1.0,1.1,2.0)。具体的协议特性将在本文最后进行介绍。
一些I2C适配器仅仅兼容SMBus协议(System Management Bus,系统管理总线)。而SMBus只是I2C协议的子集。幸运的是,大部分设备使用相同的子集,故可以将它们放置同一个SMBus中。
如果你为一个I2C设备写驱动程序,而该设备仅仅使用I2C协议的子集,那么推荐你尽可能使用SMBus协议的命令。这样这个驱动程序既可以在SMBus适配器上使用,也可以在I2C适配器上使用(当在I2C适配器上时,SMBus格式会自动转换为I2C格式,而SMBus适配器大多无法处理单纯的I2C格式)。
下文将列举SMBus的操作时序,以及执行该时序的函数。注意,一下使用的函数名称可能会因不同的SMBus协议规格而不尽相同。
每个处理都对应一个标识。在调用处理函数是,驱动程序应该总要检查一次对应的标识以确保底层的I2C适配器支持改处理。具体详见。
各个字符的描述
功能标识:I2C_FUNC_SMBUS_QUICK
即可实现操作,对其他设备,可以在使用SMBus指定了寄存器地址后使用该函数实现对同一个寄存器的重复读取。
功能标识:I2C_FUNC_SMBUS_READ_BYTE
功能标识:I2C_FUNC_SMBUS_READ_BYTE_DATA应用系统运维
注意:还有一个读取字寄存器的函数i2c_smbus_read_word_swapped,使用于当寄存器两个字节排列方式不同时的情况。虽然与SMBus不兼容,但使用得十分普遍。    功能标识:I2C_FUNC_SMBUS_WRITE_WORD_DATA  注意:还有一个写字寄存器的函数i2c_smbus_write_word_swapped,使用于当寄存器两个字节排列方式不同时的情况。虽然与SMBus不兼容,但使用得十分普遍。
功能标识:flag: I2C_FUNC_SMBUS_PROC_CALL
该函数向设备读取多于32字节的块数据。由Comm指定寄存器地址,设备通过Count说明要读取的字节数。
功能标识:I2C_FUNC_SMBUS_READ_BLOCK_DATA
与“块读取”函数功能相反,Comm指定需要写入的寄存器地址,Count说明写入的字
功能标识:I2C_FUNC_SMBUS_WRITE_BLOCK_DATA
该函数包含于修订版2.0中。  该函数通过Comm指定寄存器地址,向设备写入1到31个字节,之后返回1到31个
该函数由设备发送,通知主机即将转变主从角。设备成为主机,主机成为设备。该函数与“写16位字”函数类似,只是将命令码替换为设备地址。  包错误校验包含于修订版1.1中。该功能在传完数据之后,结束位之前添加CRC-8校验码。
分配功能。所有ARP通信使用0x61从地址并且需要包错误校验。
警报功能由修订版1.0引入。该功能允许设备公用同一个主机的中断引脚,而主机依旧可以辨别出是哪个设备触发中断。  在Linux内核中应该使用以下方法使用该功能:  *支持SMBus报警的I2C总线驱动程序,应通过调用i2c_setup_smbus_alert()设置SMBus警报。  *支持SMBus报警的I2C总线驱动程序可选择是否响应alert()回调。
以下I2C块处理也被SMBus层支持,为了文档的完整性,在下文进行说明。注意它们并未在SMBus中被声明。  I2C块处理中并未对块大小进行限定,但SMBus将块大小限制在32字节内。
功能标识:I2C_FUNC_SMBUS_READ_I2C_BLOCK
该函数与“I2C块读取”函数功能相反,向指定寄存器写入块数据。注意,由于数据长功能标识:I2C_FUNC_SMBUS_WRITE_I2C_BLOCK
Translated By B4
英文原文:
SMBus Protocol Summary ======================
The following is a summary of the SMBus protocol. It applies to all revisions of the protocol (1.0, 1.1, and 2.0).
Certain protocol features which are not supported by
this package are briefly described at the end of this document.
Some adapters understand only the SMBus (System Management Bus) protocol, which is a subset from the I2C protocol. Fortunately, many devices use only the same subset, which makes it possible to put them on an SMBus.
If you write a driver for some I2C device, please try to use the SMBus commands if at all possible (if the device uses only that subset of the I2C protocol). This makes it possible to use the device driver on both
SMBus adapters and I2C adapters (the SMBus command set is automatically translated to I2C on I2C adapters, but plain I2C commands can not be handled at all on most pure SMBus adapters).
Below is a list of SMBus protocol operations, and the functions executing
them.  Note that the names used in the SMBus protocol specifications usually don't match these function names.  For some of the operations which pass a single data byte, the functions using SMBus protocol operation names execute a different protocol operation entirely.
Each transaction type corresponds to a functionality flag. Before calling a transaction function, a device driver should always check (just once) for the corresponding functionality flag to ensure that the underlying I2C adapter supports the transaction in question. See
for the details.
Key to symbols ==============
S    (1 bit) : Start bit P    (1 bit) : Stop bit
Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. A, NA (1 bit) : Accept and reverse accept bit.
Addr  (7 bits): I2C 7 bit address. Note that this can be expanded as usual to                  get a 10 bit I2C address.
超滤膜壳
Comm  (8 bits): Command byte, a data byte which often selects a register on                the device.
Data  (8 bits): A plain data byte. Sometimes, I write DataLow, DataHigh                for 16 bit data.微型吸尘器
Count (8 bits): A data byte containing the length of a block operation.
[..]: Data sent by I2C device, as opposed to data sent by the host adapter.
SMBus Quick Command ===================球墨铸铁铸造
This sends a single bit to the device, at the place of the Rd/Wr bit.
A Addr Rd/Wr [A] P复合树脂补牙
Functionality flag: I2C_FUNC_SMBUS_QUICK
SMBus Receive Byte:  i2c_smbus_read_byte() ==========================================
This reads a single byte from a device, without specifying a device register. Some devices are so simple that this interface is enough; for others, it is a shorthand if you want to read the same register as in the previous SMBus command.

本文发布于:2024-09-24 22:34:34,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/1/109772.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

上一篇:MMS协议解析
下一篇:OBD-II通讯协议
标签:设备   使用   寄存器   函数   功能   协议   驱动程序   标识
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议