13.3.1 Design Flow
The following steps are used to enable SPI in the application by using Libero SoC.
- Enable SPI_0 and/or SPI_1 instance by using the MSS configurator in the application, as shown in the following figure.
- Configure the number of Slaves to 1 and the ports of enabled SPI_0 instance to an I/O or Fabric by using MSS SPI_0 Configurator as shown in the following figures. Click the highlighted Users Guide button to find more information on SPI configuration details.
- The SPI_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 about generation of the component, see the latest SmartDesign User Guide on Libero SoC Documentation page. The firmware driver folder and SoftConsole workspace are included into the project. Click the Configure firmware button highlighted in the following figure to find the SPI driver information.
- Click Generate Bitstream under Program
Design to complete the
.fdb
file generation. - Double-click the 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_spi firmware driver. The firmware driver, mss_spi
(
mss_spi.c
andmss_spi.h
), which provides a set of functions for controlling the MSS SPIs can also be downloaded from the Microchip Firmware Catalog. - The following table lists main APIs for
SPI. For complete information on the APIs, see SmartFusion2_MSS_SPI_Driver_UG as
shown in the preceding figure.
Table 13-6. MSS SPI APIs Category API Description Initialization and configuration functions MSS_SPI_init() Initializes the SPI MSS_SPI_configure_master_mode() Configures the protocol mode, serial clock speed and frame size for a specific target SPI slave device MSS_SPI_configure_slave_mode() Configures a MSS SPI block for operations as a SPI slave device Data transfer functions MSS_SPI_set_slave_select() Selects a specific slave by a MSS SPI master MSS_SPI_transfer_frame() Used by a MSS SPI master to transmit and receive a frame up to 32 bits long MSS_SPI_transfer_block() Used by MSS SPI masters to transmit and receive blocks of data MSS_SPI_clear_slave_select() To deselect a specific slave by a MSS SPI master MSS_SPI_set_slave_tx_frame() Used by MSS SPI slaves to specify the frame that will be transmitted MSS_SPI_set_frame_rx_handler() Used by MSS SPI slaves to specify the receive handler function DMA block transfer functions MSS_SPI_disable() To temporarily disable a MSS SPI MSS_SPI_set_transfer_byte_count() Specifies the number of bytes MSS_SPI_enable() To re-enable a MSS SPI MSS_SPI_tx_done() To find out if a DMA controlled transfer has completed - For more information on SPI usage, the sample projects are available and can be generated, as shown in the following figure.
Important: The MSS SPI does not support full behavioral
simulation models. For more information, see SmartFusion2 MSS BFM Simulation User Guide.