Determining read/write as an I2C slave

kelnos
Posts: 1
Joined: Thu May 26, 2022 8:55 am

Determining read/write as an I2C slave

Postby kelnos » Thu May 26, 2022 9:09 am

Hi all,

I'm trying to use ESP32's I2C functionality as a slave. When the I2C master wants to read/write data from/to the slave, it sets the lowest bit of the I2C address to either 0 (write) or 1 (read). However, I can't seem to figure out how to get this value from ESP-IDF's I2C slave functions.

As an example, the master, when it wants to read SMBus register 0x45 from the slave device with address 0x53, will write to the bus (each line is a byte, and I've left out start and ack/nack bits):

Code: Select all

(0x53 << 1) | 0x1
0x45
The slave is expected to check that last bit of the address to know whether or not the master wants to write or read from register 0x45. However, when I call i2c_slave_read_buffer(), I just receive a single byte, the 0x45, and I'm unable to check the read/write bit of the address byte. I can't seem to find any out-of-band function to read this state. Am I missing something here, or is this an omission in the API?

Who is online

Users browsing this forum: cdollar and 140 guests