I2C - Do I use 8 bit or 7 bit addresses?

It isn’t super clear to me which format I am suppose to use. Could someone clarify how the address argument works under the hood? Do I need to do any bit shifting like addr << 1?

Ahoj,

in the documentation of mbed’s i2c api is a Note

Note: The Arm Mbed API uses 8 bit addresses, so make sure to left-shift 7 bit addresses by 1 bit before passing them.

Technically the 8bit i2c address does not exist, it is always 7bit address and 1bit for setting of direction read/write and together it is a byte. Some times it is represented as two 8bit addresses, one for each direction.
But in this case is used one byte of Int where need to by fill 7bit address and shifted by 1 because this 8th bit is for direction and it is changed automaticaly by the i2c api/driver according to what method (read/write) you call.

When you want to have it clear, fill the 7 bit address and then make a bit shifting like you wrote. Or you can place already bit shifted value.

int address = 0x48 << 1;
//or
int address = 0x90;

BR, Jan