Skip to content

Commit ac10b6a

Browse files
authored
Merge pull request #544 from jamesmunns/james/explain-i2c-7bit
Add an explanation of how 7-bit addresses should be aligned within a u8
2 parents f7f3c11 + 5051c5b commit ac10b6a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

embedded-hal/src/i2c.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,17 @@ impl<T: ErrorType + ?Sized> ErrorType for &mut T {
268268
pub trait AddressMode: private::Sealed + 'static {}
269269

270270
/// 7-bit address mode type.
271+
///
272+
/// Note that 7-bit addresses defined by drivers should be specified in **right-aligned** form,
273+
/// e.g. in the range `0x00..=0x7F`.
274+
///
275+
/// For example, a device that has the seven bit address of `0b011_0010`, and therefore is addressed on the wire using:
276+
///
277+
/// * `0b0110010_0` or `0x64` for *writes*
278+
/// * `0b0110010_1` or `0x65` for *reads*
279+
///
280+
/// Should be specified as `0b0011_0010` or `0x32`, NOT `0x64` or `0x65`. Care should be taken by both HAL and driver
281+
/// crate writers to use this scheme consistently.
271282
pub type SevenBitAddress = u8;
272283

273284
/// 10-bit address mode type.

0 commit comments

Comments
 (0)