13.3.1 Design Flow

The following steps are used to enable SPI in the application by using Libero SoC.

  1. Enable SPI_0 and/or SPI_1 instance by using the MSS configurator in the application, as shown in the following figure.
    Figure 13-16. Enable SPI
  2. 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.
    Figure 13-17. MSS SPI Configurator - Connection Type I/O
    Figure 13-18. MSS SPI Configurator - Connection Type Fabric
  3. The SPI_0 interface signals in the MSS component are shown in the following figure.
    Figure 13-19. SPI Interface Signals - Connection Type I/O
    Figure 13-20. SPI Interface Signals - Connection Type Fabric
  4. Generate the component by clicking Generate Component or by selecting SmartDesign > Generate Component. 
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.
    Figure 13-21. SPI Driver User's Guide
  5. Click Generate Bitstream under Program Design to complete the .fdb file generation.
  6. 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 and mss_spi.h), which provides a set of functions for controlling the MSS SPIs can also be downloaded from the Microchip Firmware Catalog.
  7. 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
  8. For more information on SPI usage, the sample projects are available and can be generated, as shown in the following figure.
    Figure 13-22. SPI Sample Project
Important: The MSS SPI does not support full behavioral simulation models. For more information, see SmartFusion2 MSS BFM Simulation User Guide.