10.5.2 SECDED Features for TSEMAC Buffers

The 4 KB TX buffer and 8 KB RX buffer are protected with the SECDED feature. Use the EDAC configurator to enable the SECDED feature independently for TX and RX buffers. The following figure shows how to enable or disable the SECDED feature for the EMAC TX and RX buffers. Interrupts for single bit error, dual bit error, or both single bit and dual bit errors can be enabled.

To clear these interrupts and to take necessary actions in case of dual bit error, register the interrupt handler in the application code.

Figure 10-11. SECDED Configurator with Ethernet TX RAM and Ethernet RX RAM Configuration Options

Microchip provides TSEMAC firmware drivers to use with the application development. Download the SmartFusion 2 TSEMAC firmware drivers from the Firmware Catalog. The TSEMAC firmware drivers provides APIs-to-TSEMAC services. See the SmartFusion 2 TSEMAC Driver User Guide for the list of APIs and their descriptions.

The TSEMAC driver package includes sample projects to show the usage of TSEMAC. The sample projects are available for three different tool chains: IAR Embedded Work, Keil MDK, and SoftConsole. The following figure shows a sample project that gets generated by right-clicking the system services driver and selecting Generate sample project.

Figure 10-12. Firmware Catalog Showing the Generation of Sample Project for TSEMAC

Microchip provides the device drivers for the TSEMAC controller for SmartFusion 2 device and recommends using these drivers for the application development.

The following table lists the APIs available in TSEMAC firmware drivers for initialization and configuration.

Table 10-8. TSEMAC Firmware Drivers for Initialization and Configuration
APIDescription
MSS_MAC_cfg_struct_def_initThe MSS_MAC_cfg_struct_def_init() function initializes a mss_mac_cfg_t configuration data structure to default values. The default configuration uses the MII interface connected to a PHY at address 0x00 which is set to auto-negotiate all the available speeds up to 1000 Mbps. This default configuration can then be used as parameter to MSS_MAC_init(). Typically, the default configuration would be modified to suit the application before being passed to MSS_MAC_init().
MSS_MAC_initThe MSS_MAC_init() function initializes the Ethernet MAC hardware and driver internal data structures. The MSS_MAC_init() function takes a pointer to a configuration data structure of type mss_mac_cfg_t as parameter. This configuration data structure contains all the information required to configure the Ethernet MAC. The MSS_MAC_init() function initializes the descriptor rings and their pointers to initial values. The MSS_MAC_init() function enables DMA Rx packet received and Tx packet sent interrupts.

The configuration passed to the MSS_MAC_init() function specifies the type of interface used to connect the Ethernet MAC and Ethernet PHY as well as the PHY MII management interface address. It also specifies the allowed link speed and duplex mode. It is at this point that the application chooses if the link speed and duplex mode will be auto-negotiate with the link partner or forced to a specific speed and duplex mode.

The following table lists the APIs available in TSEMAC firmware drivers for Ethernet PHY management.

Table 10-9. TSEMAC Firmware Drivers for Ethernet PHY Management
APIDescription
MSS_MAC_read_phy_regThe MSS_MAC_read_phy_reg() function reads the Ethernet PHY register specified as parameter. It uses the MII management interface to communicate with the Ethernet PHY. This function is used part of the Ethernet PHY drivers provided alongside the Ethernet MAC driver. You only need to use this function if writing your own Ethernet PHY driver.
MSS_MAC_write_phy_regThe MSS_MAC_write_phy_reg() function writes a 16-bit value to the specified Ethernet PHY register. It uses the MII management interface to communicate with the Ethernet PHY. This function is used part of the Ethernet PHY drivers provided alongside the Ethernet MAC driver. You only need to use this function if writing your own Ethernet PHY driver.

The following table lists the APIs available in TSEMAC firmware drivers for transmit and receive operations.

Table 10-10. TSEMAC Firmware Drivers for Transmit and Receive Operations
APIDescription
MSS_MAC_send_pktThe MSS_MAC_send_pkt() function initiates the transmission of a packet. It places the buffer containing the packet to send into one of the Ethernet MAC’s transmit descriptors. This function is non-blocking. It will return immediately without waiting for the packet to be sent. The Ethernet MAC driver indicates that the packet is sent by calling the transmit completion handler registered by a call to MSS_MAC_set_tx_callback().
MSS_MAC_receive_pktThe MSS_MAC_receive_pkt() function assigns a buffer to one of the Ethernet MAC’s receive descriptors. The receive buffer specified as parameter will be used to receive one single packet. The receive buffer will be handed back to the application via a call to the receive callback function assigned through a call to MSS_MAC_set_rx_callback(). The MSS_MAC_receive_pkt() function needs to be called again pointing to the same buffer if more packets are received into this same buffer after the packet has been processed by the application.

The MSS_MAC_receive_pkt() function is non-blocking. It will return immediately and does not wait for a packet to be received. The application needs to implement a receive callback function to be notified that a packet has been received.

The p_user_data parameter can be optionally used to point to a memory management data structure managed by the application.

MSS_MAC_set_tx_callbackThe MSS_MAC_set_tx_callback() function registers the function called by the Ethernet MAC driver when a packet has been sent.
MSS_MAC_set_rx_callbackThe MSS_MAC_set_rx_callback() function registers the function called by the Ethernet MAC driver when a packet is received.

The following table lists the APIs available in TSEMAC firmware drivers for reading status and statistics.

Table 10-11. TSEMAC Firmware Drivers for Reading Status and Statistics
APIDescription
MSS_MAC_read_statThe MSS_MAC_read_stat() function reads the transmit and receive statistics of the Ethernet MAC. This function can be used to read one of 17 receiver statistics, 20 transmitter statistics, and 7 frame type statistics as defined in the mss_mac_stat_t enumeration.
MSS_MAC_clear_statisticsThe MSS_MAC_clear_statistics() function clears all the statistics counter registers.
MSS_MAC_get_link_statusThe MSS_MAC_get_link_status() function retrieves the status of the link from the Ethernet PHY. It returns the current state of the Ethernet link. The speed and duplex mode of the link is also returned via the two pointers passed as parameter if the link is up.

This function also adjusts the Ethernet MAC’s internal configuration if some of the link characteristics have changed since the previous call to this function.

For more information on the API detailed description and parameters to the APIs, see MSS Ethernet MAC Driver User's Guide.

Important: The MSS Ethernet does not support full behavioral simulation models. For more information, see SmartFusion2 MSS BFM Simulation User Guide.