The I2C trait's transaction contract in embedded-hal currently states:
If the last operation is a Read the master does not send an acknowledge for the last byte.
This statement is ambiguous and doesn't accurately reflect I2C protocol requirements, potentially leading to implementation errors.
Proposed Clarification
The contract should specify that a NACK (No Acknowledge) must be sent at the end of every read operation within a transaction, not just the final one that is followed by a stop condition. This includes read operations that are followed by a repeated start condition.
Rationale
In I2C protocol, a master must signal the end of a read operation by sending a NACK after the last byte it wishes to receive. This NACK is crucial because:
It informs the slave to stop sending data and release the SDA (data) line.
It allows the master to regain control of the SDA line, necessary for generating either a stop condition or a repeated start condition.
Without a NACK, the slave might continue holding the SDA line low, preventing the master from properly terminating the current operation or initiating the next one.
Issue Description
The I2C trait's transaction contract in
embedded-hal
currently states:This statement is ambiguous and doesn't accurately reflect I2C protocol requirements, potentially leading to implementation errors.
Proposed Clarification
The contract should specify that a NACK (No Acknowledge) must be sent at the end of every read operation within a transaction, not just the final one that is followed by a stop condition. This includes read operations that are followed by a repeated start condition.
Rationale
In I2C protocol, a master must signal the end of a read operation by sending a NACK after the last byte it wishes to receive. This NACK is crucial because:
Without a NACK, the slave might continue holding the SDA line low, preventing the master from properly terminating the current operation or initiating the next one.