Skip to content

Commit 64d8227

Browse files
committed
Clarify I2C transaction contract for NACK behavior
Update the I2C trait documentation in both embedded-hal and embedded-hal-async to clarify the NACK (No Acknowledge) behavior during read operations. The previous wording suggested that a NACK was only sent for the last byte of the final read operation in a transaction. This has been corrected to specify that a NACK should be sent at the end of each read operation, whether it's followed by a stop condition or a repeated start condition. This change ensures correct implementation of the I2C protocol across different scenarios and prevents potential communication errors. Changes: - Updated comment in embedded-hal/src/i2c.rs - Updated comment in embedded-hal-async/src/i2c.rs
1 parent 987dc68 commit 64d8227

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

embedded-hal-async/src/i2c.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
112112
/// - Data from adjacent operations of the same type are sent after each other without an SP or SR.
113113
/// - Between adjacent operations of a different type an SR and SAD+R/W is sent.
114114
/// - After executing the last operation an SP is sent automatically.
115-
/// - If the last operation is a `Read` the master does not send an acknowledge for the last byte.
115+
/// - At the end of each read operation (before SP or SR), the master does not send an acknowledge for the last byte.
116116
///
117117
/// - `ST` = start condition
118118
/// - `SAD+R/W` = slave address followed by bit 1 to indicate reading or 0 to indicate writing

embedded-hal/src/i2c.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
392392
/// - Data from adjacent operations of the same type are sent after each other without an SP or SR.
393393
/// - Between adjacent operations of a different type an SR and SAD+R/W is sent.
394394
/// - After executing the last operation an SP is sent automatically.
395-
/// - If the last operation is a `Read` the master does not send an acknowledge for the last byte.
395+
/// - At the end of each read operation (before SP or SR), the master does not send an acknowledge for the last byte.
396396
///
397397
/// - `ST` = start condition
398398
/// - `SAD+R/W` = slave address followed by bit 1 to indicate reading or 0 to indicate writing

0 commit comments

Comments
 (0)