更多的关于SMBus如何工作(与I2C相比)。由于I2C没有定义数据包的任何结构,这允许设备实现自动增加(或自动递减)I2C设备存储器的连续读取。然而,面向命令的SMBus结构不允许这样做。每个命令都有一个定义的数据格式,它可以是字节、字或块。SMBus规范的最新版本现在包括用于在一个事务中读取和写入32位和64位的协议。SMBus设备数据表定义与每个命令相关联的数据。因此,例如,设置输出电压的命令可以将数据作为具有1 mV/比特的固定分辨率的16位整数。或者它可能具有从从设备支持的预定义输出电压表中选择的8位值。无论数据和格式如何,都要在SMBus设备数据表中描述。这是由编写系统主代码的人来理解每个SMBus设备的命令和数据格式,并使用正确的SMBus协议(例如,写Word)来发送命令和写入DAT。A(或读取单词以读取16位值)。这就是为什么在使用读块协议时,从属发送字节数的原因。对于使用读块协议的命令,SMBus从设备数据表将定义将返回多少字节以及这些字节中包含的每一个字节。当主控制器为读块协议发送以下序列:MART:START条件主机:7位从属地址寄存器:R/W×位=0(作为命令写入)从:ACK(在SMBus奴隶必须总是自己的地址)主控:使用读组的命令的8位命令代码k协议从:AkMist:重复启动主机:7位从属地址主机:R/W=1(告诉主从请求数据)。哪些数据?由于没有停止条件,事务继续,并且从属知道主要与先前发送的命令代码相关联的数据)从属:Ac从属:块CONTHMARE:ACK(ACK),只有当块计数匹配主机期望的数据字节数时才ACK(ACK)。如果存在不匹配,则主控器应声明一个故障和错误,并结束事务,并使用NACK和停止条件)从属设备:由从属设备的数据主控器定义的第一个数据字节:ACK……从属器持续发送数据,因为主控器一直在驱动时钟从属:最后一个数据旁路器:NAC。K(NACK告诉奴隶主正在读取数据,事务正在结束)主:停止条件(结束事务)让我知道这是否有帮助。
以上来自于百度翻译
以下为原文
A bit more on how SMBus works (compared to I2C).
Since I2C does not define any structure to the packets, that allows devices to implement auto-incrementing (or auto-decrementing) successive reads of an I2C device memory.
However, the command oriented structure of SMBus does not really allow this. Each command has a defined data format, which can be byte, word, or block. The most recent version of the SMBus specification now includes protocols for reading and writing 32 and 64 bits in one transaction.
The SMBus device data sheet defines the the data associated with each command. So, for example, a command to set the output voltage might have the data as a 16 bit integer with a fixed resolution of 1 mV/bit. Or it might have an 8 bit value that selects from a table of pre-defined output voltages supported by the slave device. Whatever the data and its format, it is to be described in the SMBus device data sheet.
It is up to the person writing the code for the system master to understand each SMBus device's commands and data formats and use the right SMBus protocol (for example, WRITE WORD) to send a command and write data (or READ WORD to read back a 16 bit value).
This is why when using the READ BLOCK protocol the slave sends the number of bytes. For a command that uses the READ BLOCK protocol, the SMBus slave device data sheet will define how many bytes will be returned and what each of those bytes contains. When the master sends the following sequence for a READ BLOCK protocol:
Master: START condition
Master: 7 bit slave address
Master: R/W# bit = 0 (as a command is being written)
Slave: ACK (in SMBus slaves must always ACK their own address)
Master: 8 bit command code for a command that uses the READ BLOCK protocol
Slave: ACK
Master: REPEATED START
Master: 7 bit slave address
Master: R/W# = 1 (tells the slave that the master is requesting data. Which data? As there was no STOP condition the transaction continues and the slave knows that the master wants the data associated with the previously send command code)
Slave: ACK
Slave: Block count
Master: ACK (ACK only if the block count matches the number of data bytes the master is expecting. If there is a mismatch, then the master should declare a fault/error and end the transaction with a NACK and STOP condition)
Slave: First data byte as defined by the slave device's data sheet
Master: ACK
....Slave keeps sending data as the master keeps driving the clock
Slave: Last data byte
Master: NACK (the NACK tells the slave that the master is done reading data and the transaction is ending)
Master: STOP condition (ends the transaction)
Let me know if this is helpful.