While analyzing why the following tests in tests/periph_i2c/tests/04__periph_i2c_flags fail for esp32-wroom-32
I was wondering why the second i2c_read_bytes call should fail?
In section 3.1.10, the I2C standard only specifies:
"A data transfer is always terminated by a STOP condition (P) generated by the master. However, if a master still wishes to communicate on the bus, it can generate a repeated START condition (Sr) and address another slave without first generating a STOP condition. Various combinations of read/write formats are then possible within such a transfer."
From my point of view, "address another slave ..." doesn't mean necessarily that a second read with the same slave address should fail. It just says, that the master can continue the communication on the bus with another slave. In fact, the slave address in combined format is the same and only the direction is changed. Furthermore, "Various combinations ..." does not imply that the combined read after write transfer must be the only one.
Furthermore, according to Note 4 in section 3.1.10
"I2C-bus compatible devices must reset their bus logic on receipt of a START or repeated START condition such that they all anticipate the sending of a slave address"
That is, all slaves including the former one should await an address field after a repeated start. So why shouldn't it be the same address as before?
Although it might not make sense to have consecutive read transfers from the same slave, the standard does not forbid this.
I have tested it with a chip PCF8575 chip from NXP, the owner of the I2C standard. The chip accepts consecutive i2c_read_bytes calls with repeated START conditions. So IMHO, the ESP32 I2C behaves correctly.
While analyzing why the following tests in tests/periph_i2c/tests/04__periph_i2c_flags fail for
esp32-wroom-32Repeated Start Read Bytes 0 Should SucceedRobotFW-tests/tests/periph_i2c/tests/04__periph_i2c_flags.robot
Lines 29 to 34 in 9d418dd
Repeated Start Read Bytes 0xFF Should SucceedRobotFW-tests/tests/periph_i2c/tests/04__periph_i2c_flags.robot
Lines 36 to 41 in 9d418dd
I was wondering why the second
i2c_read_bytescall should fail?In section 3.1.10, the I2C standard only specifies:
"A data transfer is always terminated by a STOP condition (P) generated by the master. However, if a master still wishes to communicate on the bus, it can generate a repeated START condition (Sr) and address another slave without first generating a STOP condition. Various combinations of read/write formats are then possible within such a transfer."
From my point of view, "address another slave ..." doesn't mean necessarily that a second read with the same slave address should fail. It just says, that the master can continue the communication on the bus with another slave. In fact, the slave address in combined format is the same and only the direction is changed. Furthermore, "Various combinations ..." does not imply that the combined read after write transfer must be the only one.
Furthermore, according to Note 4 in section 3.1.10
"I2C-bus compatible devices must reset their bus logic on receipt of a START or repeated START condition such that they all anticipate the sending of a slave address"
That is, all slaves including the former one should await an address field after a repeated start. So why shouldn't it be the same address as before?
Although it might not make sense to have consecutive read transfers from the same slave, the standard does not forbid this.
I have tested it with a chip PCF8575 chip from NXP, the owner of the I2C standard. The chip accepts consecutive
i2c_read_bytescalls with repeated START conditions. So IMHO, the ESP32 I2C behaves correctly.