![FTDI FT51A Скачать руководство пользователя страница 50](http://html1.mh-extra.com/html/ftdi/ft51a/ft51a_application-note_2341158050.webp)
Application Note
AN_289 FT51A Programming Guide
Version 1.0
Document Reference No.: FT_000962 Clearance No.: FTDI# 483
49
Copyright © 2015 Future Technology Devices International Limited
1
TREQ
R
0
The I
2
C Slave has been addressed for
a read operation by the I
2
C Master
and must send a byte of data. This bit
is automatically cleared by a write to
I2CSBUF.
0
RREQ
R
0
The I
2
C Slave has been addressed for
a write operation by the I
2
C Master
and must receive a byte of data. This
bit is automatically cleared by a read
from I2CSBUF.
Table 2.53 I
2
C Slave Status Register
When the
SENDFIN
and
RECFIN
bits are set then the I
2
C Slave asserts an interrupt to the EIE SFR.
2.6.4
I2CSBUF
Bit
Position
Bit Field Name
Type
Reset
Description
7..0
data
R/W
0
Data register.
Table 2.54 I
2
C Slave Data Buffer Register
Writing to the I
2
C Slave Data register when
TREQ
is set in the I2CSCR register will send the byte of
data to the I
2
C Master. Conversely, reading the I
2
C Slave Data register when
RREQ
is set will
acknowledge a transmission from the I
2
C Master.
2.6.5
Use Case
The I
2
C Slave can process single bytes or bursts of an indeterminate length from the I
2
C Master.
The interrupts generated by the I
2
C Slave are for
RECFIN
and
SENDFIN
. These can be used for
chaining burst reads and writes efficiently using an interrupt handler. However, to detect when a
master has addressed the I
2
C Slave interface it is necessary to poll the
TREQ
and
RREQ
bits in the
I2CSSR register.
2.6.5.1
Interface Setup
To setup the I
2
C Slave the Own Address register must be written before the interface is activated.
Write the slave address to the
I2CSOA register
.
Enable the I
2
C Slave function by setting
DA
and clearing
RSTB
in the
I2CSCR
register. The
value 0x7F can be used.
2.6.5.2
Send Data
To send data to an I
2
C Master the following procedure is used:
For each byte of data:
o
If
I2CSCR
register bit
TREQ
set to ‘1’:
Write byte of data to
I2CSBUF
.
o
If
I2CSSR
register bit
SENDFIN
set to ‘1’:
Clear
SENDFIN
bit setting
SENDFINCLR
bit in write to
I2CSCR
.
Finish transaction.
This will allow a burst read to occur on the I
2
C Master. The master controls how many bytes will be
read from the I
2
C Slave.