EasyManua.ls Logo

Microsemi SmartFusion2 - Page 583

Microsemi SmartFusion2
829 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Inter-Integrated Circuit Peripherals
UG0331 User Guide Revision 15.0 549
15.3.2.2 Use Model 2: Configuring I
2
C as a Slave
The I
2
C peripheral can be configured to Slave mode. In Slave mode, the I2C_0 responds to the
commands received by the I
2
C master device.
Refer to the Design Flow, page 544 to configure I2C_0 in the application.
15.3.2.2.1 Software Design Flow
I
2
C Slave Mode
The I
2
C instance I2C_0 can be initialized by using the MSS_I2C_init API. The slave device address
should be specified while initializing.
Write Operation
Following are the steps to complete the write transaction:
Set the slave receive buffer
The data receive buffer is used to store the data received when the I
2
C slave is the target of an I
2
C
write transaction. Use the MSS_I2C_set_slave_rx_buffer API.
Register the write handler
The handler function must be called on completion of the I
2
C write transaction. MSS_I2C_regis-
ter_write_handler API can be used to register the write handler function.
Enable the slave
The MSS_I2C_enable_slave API can be used to enable the slave.
Read Operation
Following are the steps to complete the read transaction:
Set the slave transmit buffer
The data buffer is transmitted when the I
2
C slave is the target of an I
2
C read transaction. Here, use
the MSS_I2C_set_slave_tx_buffer API.
Enable the slave
MSS_I2C_enable_slave API can be used to enable the slave.
15.3.2.3 Use Model 3: I
2
C Loopback Mode
I2C_0 and I2C_1 are internally connected in Loopback mode, as shown in the following figure. The
MSS_I2CLOOPBACK bit of the LOOPBACK_CR System register is used to enable the Loopback mode.
Following are the steps to configure I2C_0 and I2C_1 in Loopback mode to verify the data transfer
between I
2
C peripherals.
Enable the I2C_0 and I2C_1 in the MSS configurator of the Libero SoC design project.
Initialize I2C_0 and I2C_1 in the SoftConsole application.
Set the MSS_I2CLOOPBACK bit of the LOOPBACK_CR System register in the SoftConsole
application. For further details, refer to the System Register Block, page 670.
•Use I
2
C read and write APIs from the MSS I
2
C driver to send and receive the data. While using APIs
from the MSS I
2
C driver, ensure that either I2C_0 or I2C_1 is in Master mode.
The data traffic from I2C_0 is looped back to I2C_1, and vice versa.

Table of Contents

Other manuals for Microsemi SmartFusion2

Related product manuals