CP2120
Rev. 0.4
17
6.4. I2C Receive Buffer Size
Bytes received from I2C transactions are stored in the 255-byte data buffer. The number of bytes currently stored
inside this buffer is saved in the RXBUFF Internal Register.
Internal Register Definition 6. RXBUFF: Receive Buffer Size Register
6.5. I2C Commands
SPI commands initiate all I2C transactions. The CP2120 executes I2C transactions only after every byte of the
command has been successfully received across the SPI bus. Once the CP2120 has completed the I2C
transaction prompted by the command, the INT pin will be pulled low to indicate that command execution has
completed. If an I2C command is issued while an I2C command is in progress, the second I2C command will be
ignored.
6.5.1. Write Bytes to I2C
This command transmits data to an I2C slave device. The command begins with the command byte (0x00),
followed by the number of bytes to be transmitted across I2C, which can range from 1 to 255, and the address of
the I2C Slave. The SPI master then sends the data to be transmitted across I2C. Sending more or fewer bytes than
was indicated by the second byte of the command will result in an error condition, and the I2C transaction will not
be initiated.
Once the I2C transaction completes, the CP2120 pulls the INT pin low and sets the internal register according to
the results of the transaction.
6.5.2. Read Bytes from I2C
This command attempts to retrieve bytes from an I2C Slave device. The command begins with the command byte,
0x01, followed by the number of bytes to read (1 to 255) and the address of the I2C slave device.
Once the I2C transaction completes, the CP2120 pulls the INT pin low and sets I2CSTAT according to the results of
the transaction. The CP2120 saves the number of bytes stored in the buffer in the internal register named
RXBUFF. A Read Buffer command can be issued to retrieve the bytes from the buffer.
Note that if the SPI Master issues a second Read Bytes from I2C command before issuing a Read Buffer
command, the bytes stored in the CP2120's buffer will be overwritten.
Internal Register Address:
0x06
Reset Value:
0x00
Bit 7-0:
RXB7-0: Receive Buffer Size
Indicates the number of bytes received during the last I2C read transaction.
RR
R
RXB7
RXB6
RXB5
RXB4
RXB3
RXB2
RXB1
RXB0
Bit 7
Bit 6
Bit 5
Bit 4
Bit3
Bit 2
Bit 1
Bit 0
DATA
BYTE1
DATA
BYTE N
NUMBER
OF BYTES
COMMAND
0x00
SLAVE
ADDRESS +W
...
SPI Master
NUMBER
OF BYTES
COMMAND
0x01
SLAVE ADDRESS
+R
SPI Master