8 years, 9 months ago.

Should i2c_slave_receive return ACK?

I'm trying to port mbed to a new target platform. I'd like to clarify whether the i2c API i2c_slave_receive() is expected to return ACK or not? If not, when is the device expected to return ACK for an address match? Before the next read/write?

Yes the slave will send ACK or NACK. There is a number of sources of information referring to the specification of I2C do a web search. i2c.info, i2c-bus.org and NXP to name a few.

posted by David Fletcher 13 Aug 2015

1 Answer

8 years, 9 months ago.

I suspect you mistyped i2c_slave_receive? As this function has this declaration:

/** Check to see if the I2C slave has been addressed.
 *  @param obj The I2C object
 *  @return The status - 1 - read addresses, 2 - write to all slaves,
 *         3 write addressed, 0 - the slave has not been addressed
 */
int  i2c_slave_receive(i2c_t *obj);

No, sorry for the misunderstanding! I asked whether we should return ACK (to the actual master device) in the implementation of i2c_slave_receive, not about the return value of function.

posted by Vimalraj Rajashekharan 13 Aug 2015

Ok I see your point. I havent used yet i2c slave. From looking at sources quickly now, looks like most of the implementation just reads registers to get a status and return it.

posted by Martin Kojtal 13 Aug 2015

Okay Martin! I'll proceed with the implementation as if it's just a status check only. If you get more info, please let me know. Thank you!

posted by Vimalraj Rajashekharan 13 Aug 2015