14.3.1 Design Flow
The following steps are used to enable I2C in the application by using Libero SoC.
- Enable I2C_0 and/or I2C_1 instance by using the MSS configurator in the application, as shown in the following figure.
- Configure the ports of enabled I2C_0 instance to an I/O by using MSS I2C_0 Configurator as shown in the following figure. Click the highlighted Users Guide button to find more information on I2C configuration details.
- The I2C_0 interface signals in the MSS component are shown in the following figure.
- Generate the component by clicking Generate Component or by selecting . For more information on generation of the component, see the latest SmartDesign User Guide on Libero SoC Documentation. The firmware driver folder and SoftConsole workspace are included into the project. Click Configure firmware, as shown in the following figure to find the I2C driver information.
- Click Generate Bitstream under Program
Design to complete
*.fdb
file generation. - Double click Export
Firmware under Handoff Design for
Firmware Development in the Libero SoC design flow window to
generate the SoftConsole Firmware Project. The SoftConsole folder contains the mss_i2c
firmware driver. The firmware driver, mss_i2c (
mss_i2c.c
andmss_i2c.h
) which provides a set of functions for controlling the MSS I2Cs can also be downloaded from the Microchip firmware catalog. The following table lists the main APIs for I2C. For more information on APIs, see the SmartFusion2_MSS_I2C_Driver_UG, as shown in the preceding figure.Table 14-3. MSS I2C APIs Category API Description and Usage Initialization and configuration function MSS_I2C_init() Initializes and configures the I2C with MSS I2C's configuration as parameters I2C master operation functions MSS_I2C_write() Initiates an I2C master write transaction MSS_I2C_read() Initiates an I2C master read transaction MSS_I2C_write_read() Initiates an I2C write-read transaction MSS_I2C_wait_complete() Waits for the current I2C transaction to complete MSS_I2C_get_status() Gets the current state of an MSS I2C instance I2C slave operation functions MSS_I2C_set_slave_tx_buffer() Specifies the memory buffer holding the data that will be sent to the I2C master MSS_I2C_set_slave_rx_buffer() Specifies the memory buffer that will be used by the MSS I2C slave instance to receive data MSS_I2C_set_slave_mem_offset_length() Specifies the number of bytes expected as part of the write phase of a write-read transaction MSS_I2C_register_write_handler() Registers the function that is called to process the data written to MSS I2C instance when it is the slave in an I2C write transaction MSS_I2C_enable_slave() Enables the MSS I2C slave MSS_I2C_disable_slave() Disables the MSS I2C slave SMBus control functions MSS_I2C_smbus_init() Initializes SMBus timeouts and status logics MSS_I2C_suspend_smbus_slave() Forces slave devices into power-down or suspend mode MSS_I2C_set_smbus_alert() Used to force master communication by an I2C slave device MSS_I2C_enable_smbus_irq() Enables interrupt related to SMBus which can be either SMBSUS or SMBALERT interrupt MSS_I2C_disable_smbus_irq() Disables interrupt related to SMBus which can be either SMBSUS or SMBALERT interrupt - For more information on I2C usage, the sample projects are available and can be generated, as shown in the following figure.
Important: The MSS I2C does not support full
behavioral simulation models. For more information, see SmartFusion2 MSS BFM Simulation User Guide.