The I2C official specification describes that in a 7-bit addressing mode, the 8th bit is used for specifying a read (1) operation or a write (0) operation.
Silly me thought that I had to manually do this by masking the address appropriately (addr & 0xFE) vs (addr | 0x01). This is in fact totally wrong. Behind the scenes, the I2C library will shift the address up 1 bit and then mark the 8th bit appropriately for read/write operations.
Example:
// What I was doing
(0x42 | 0x01) // This becomes 0x43
(0x43 << 1) | 1 // This is what the library does, and it results in 0x87
// What would be correct
0x42 // Leave the address alone
(0x42 << 1) | 1 // The address is dealt with by the library and becomes 0x85
Please remove all the read_addr() and write_addr() macros in all the libraries within fetcher. Let the library handle addresses!
The I2C official specification describes that in a 7-bit addressing mode, the 8th bit is used for specifying a read (1) operation or a write (0) operation.
Silly me thought that I had to manually do this by masking the address appropriately
(addr & 0xFE)
vs(addr | 0x01)
. This is in fact totally wrong. Behind the scenes, the I2C library will shift the address up 1 bit and then mark the 8th bit appropriately for read/write operations.Example:
Please remove all the
read_addr()
andwrite_addr()
macros in all the libraries within fetcher. Let the library handle addresses!