CMSIS Driver  Version 1.10 - Preliminary
Middleware Driver API for microcontroller peripherals
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Ethernet Interface

Ethernet common definitions (Driver_ETH.h) More...

Content

 Ethernet MAC Interface
 Driver API for Ethernet MAC Peripheral (Driver_ETH_MAC.h)
 
 Ethernet PHY Interface
 Driver API for Ethernet PHY Peripheral (Driver_ETH_PHY.h)
 

Data Structures

struct  ARM_ETH_LINK_INFO
 Ethernet link information. More...
 
struct  ARM_ETH_MAC_ADDR
 Ethernet MAC Address. More...
 

Enumerations

enum  ARM_ETH_STATUS {
  ARM_ETH_OK = 0,
  ARM_ETH_ERROR = 1,
  ARM_ETH_ERROR_UNSUPPORTED = 2
}
 Status code for Ethernet functions. More...
 
enum  ARM_ETH_INTERFACE {
  ARM_ETH_INTERFACE_MII,
  ARM_ETH_INTERFACE_RMII,
  ARM_ETH_INTERFACE_SMII
}
 Ethernet Media Interface type. More...
 
enum  ARM_ETH_DUPLEX {
  ARM_ETH_DUPLEX_HALF,
  ARM_ETH_DUPLEX_FULL
}
 Ethernet duplex operating mode. More...
 
enum  ARM_ETH_SPEED {
  ARM_ETH_SPEED_10M,
  ARM_ETH_SPEED_100M,
  ARM_ETH_SPEED_1G
}
 Ethernet speed. More...
 
enum  ARM_ETH_MODE {
  ARM_ETH_MODE_AUTO_NEGOTIATE,
  ARM_ETH_MODE_10M_FULL_DUPLEX,
  ARM_ETH_MODE_10M_HALF_DUPLEX,
  ARM_ETH_MODE_100M_FULL_DUPLEX,
  ARM_ETH_MODE_100M_HALF_DUPLEX,
  ARM_ETH_MODE_1G_FULL_DUPLEX,
  ARM_ETH_MODE_1G_HALF_DUPLEX,
  ARM_ETH_MODE_LOOPBACK,
  ARM_ETH_MODE_ISOLATE
}
 Ethernet mode. More...
 
enum  ARM_ETH_LINK_STATE {
  ARM_ETH_LINK_DOWN,
  ARM_ETH_LINK_UP
}
 Ethernet link state. More...
 

Description

Ethernet common definitions (Driver_ETH.h)

Ethernet is a networking technology for exchanging data packages between computer systems. Several microcontrollers integrate an Ethernet MAC (Media Access Control) data-link layer that interfaces to an Ethernet PHY (Physical Interface Transceiver).

Wikipedia offers more information about the Ethernet.

Ethernet Structure

The Ethernet PHY connects typically to the Ethernet MAC using an MII (Media Independent Interface) or RMII (Reduced Media Independent Interface).


EthernetSchematic.png
Block Diagram of a typical Ethernet Interface

Ethernet API

The following header files define the Application Programming Interface (API) for the Ethernet interface:

The driver implementation of the Ethernet MAC is a typical part of a Device Family Pack (DFP) that supports the peripherals of the microcontroller family. The driver implementation of the Ethernet PHY is a typical part of a Network Software Pack, since PHY is typically not integrated into the microcontroller.

Driver Functions

The driver functions are published in the access struct as explained in Driver Functions

Both drivers are used in combination and usually the Ethernet MAC provides a media interface to the Ethernet PHY (see ARM_ETH_INTERFACE). A typical setup sequence for the drivers is shown below:

Example Code:

extern ARM_DRIVER_ETH_MAC ARM_Driver_ETH_MAC0;
extern ARM_DRIVER_ETH_PHY ARM_Driver_ETH_PHY0;
static ARM_DRIVER_ETH_MAC *mac;
static ARM_DRIVER_ETH_PHY *phy;
static ARM_ETH_MAC_ADDR own_mac_address;
static ARM_ETH_MAC_CAPABILITIES capabilities;
void ethernet_mac_notify (ARM_ETH_MAC_EVENT event) {
switch (event) {
:
}
}
void initialize_ethernet_interface (void) {
mac = &ARM_Driver_ETH_MAC0;
phy = &ARM_Driver_ETH_PHY0;
// Initialize Media Access Controller
capabilities = mac->GetCapabilities ();
if (capabilities.mac_address == 0) {
// populate own_mac_address with the address to use
}
mac->Initialize ((capabilities.event_rx_frame) ? ethernet_mac_notify : NULL,
&own_mac_address);
// Initialize Physical Media Interface
if (phy->Initialize (mac->PHY_Read, mac->PHY_Write) == ARM_ETH_OK) {
phy->SetInterface ((ARM_ETH_INTERFACE)eth->capabilities.media_interface);
}
:
:
}
static ARM_ETH_LINK_STATE ethernet_link; // current link status
static void ethernet_check_link_status (void) {
link = phy->GetLinkState ();
if (link == ethernet_link) {
return; // link state unchanged
}
// link state changed
ethernet_link = link;
if (eth->link == ARM_ETH_LINK_UP) { // start transfer
mac->EnableTx (true);
mac->EnableRx (true);
}
else { // stop transfer
mac->EnableRx (false);
mac->EnableTx (false);
}
}

Data Structure Documentation

struct ARM_ETH_LINK_INFO

Ethernet link information.

The Ethernet Link information provides parameters about the current established communication.

Returned by:

Data Fields
uint8_t duplex: 1 Duplex mode: 0= Half, 1= Full (see ARM_ETH_DUPLEX)
uint8_t speed: 2 Link speed: 0= 10 MBit, 1= 100 MBit, 2= 1 GBit (see ARM_ETH_SPEED)
struct ARM_ETH_MAC_ADDR

Ethernet MAC Address.

Stores the MAC Address of the Ethernet interface as defined by IEEE 802. Wikipedia offers more information about the MAC Address.

Parameter for:

Data Fields
uint8_t b MAC Address (6 bytes), MSB first.

Enumeration Type Documentation

Ethernet duplex operating mode.

Lists the supported duplex operating types for MAC.

Parameter for:

Enumerator:
ARM_ETH_DUPLEX_HALF 

Half duplex link.

ARM_ETH_DUPLEX_FULL 

Full duplex link.

Ethernet Media Interface type.

Encodes the supported media interface between Ethernet MAC and Ethernet PHY.

The function ARM_ETH_MAC_GetCapabilities retrieves the media interface type encoded in the bitfield media_interface of the struct ARM_ETH_MAC_CAPABILITIES.

Parameter for:

Enumerator:
ARM_ETH_INTERFACE_MII 

Media Independent Interface (MII)

ARM_ETH_INTERFACE_RMII 

Reduced Media Independent Interface (RMII)

ARM_ETH_INTERFACE_SMII 

Serial Media Independent Interface (SMII)

Ethernet link state.

The Ethernet Link status shows if the communication is currently established (up) or interrupted (down).

Returned by:

Enumerator:
ARM_ETH_LINK_DOWN 

Link is down.

ARM_ETH_LINK_UP 

Link is up.

Ethernet mode.

Lists the supported operating modes for PHY.

Parameter for:

Enumerator:
ARM_ETH_MODE_AUTO_NEGOTIATE 

Auto Negotiation mode.

ARM_ETH_MODE_10M_FULL_DUPLEX 

10 MBit full duplex mode

ARM_ETH_MODE_10M_HALF_DUPLEX 

10 MBit half duplex mode

ARM_ETH_MODE_100M_FULL_DUPLEX 

100 MBit full duplex mode

ARM_ETH_MODE_100M_HALF_DUPLEX 

100 MBit half duplex mode

ARM_ETH_MODE_1G_FULL_DUPLEX 

1 GBit full duplex mode

ARM_ETH_MODE_1G_HALF_DUPLEX 

1 GBit half duplex mode

ARM_ETH_MODE_LOOPBACK 

Loop-back test mode.

ARM_ETH_MODE_ISOLATE 

Isolate PHY from MII interface.

Ethernet speed.

Lists the supported operating speeds for MAC.

Parameter for:

Enumerator:
ARM_ETH_SPEED_10M 

10 Mbps link speed

ARM_ETH_SPEED_100M 

100 Mbps link speed

ARM_ETH_SPEED_1G 

1 Gpbs link speed

Status code for Ethernet functions.

Defines status and error codes that are returned by most of the Ethernet MAC and Ethernet PHY driver functions.

Returned by:

Enumerator:
ARM_ETH_OK 

Operation succeeded.

ARM_ETH_ERROR 

Unspecified error.

ARM_ETH_ERROR_UNSUPPORTED 

Operation not supported.