2.3 Master Write Mode
Master Write Mode means that the master is going to transmit data to the slave. The USI is set up to sample a byte on the data line.
When the byte has been shifted in successfully, the slave sends an ACK to the master. After storing the data in the buffer, and setting up USI to sample the next byte, the application waits for one USI clock to test if there has been sent a STOP condition from the master. If there is a STOP condition, the receive buffer is tagged as full. And the interface is reset. If not then the transmission is continued.
These actions will terminate and reset any transmission:
- The address in the message is not zero, nor the defined TWI address
- The master returns a NACK on a slave transmission
- The master sends a STOP Condition, after the slave sends a ACK
- The master sends a START Condition
- The master requests data, but the transmit buffer is empty
- The master sends data, but the receive buffer is full
Optionally one can also add more buffer control and the same response if the master requests/sends more information then the size of the transmit/receive buffers. This buffer control can be enabled by setting a define in the driver header file.