Is an I2C slave when transmitting to a master allowed to NACK?
It seems from the spec (2.1) there is no way for a slave to realistically send a NACK to a master while transmitting, i.e. sending data from the slave to the master. I have scoured the net and can't find any help either way here.
Why? I am implementing an I2C master device in AVR Atmega8. I want to cover all use cases. I have a user who has noted that when an I2C slave device sends a NACK when in SLA+R mode, the master ignores it.
As far as I am aware, the master device that has initiated SLA+R is the only party allowed to NACK a packet. The slave must keep sending packets on the master clock. However, a snippet in the Arduino wire library implies that the slave can send NACK to a master. https://github.com/arduino/Arduino/blob/master/libraries/Wire/utility/twi.c#L503
- What should happen if the slave wants to send 2 packets but the master clocks for 3
- Can the slave send a NACK in slave transmitter mode?
- Is there any other way to indicate to the master there is no more data?