The Ethernet PHY connects typically to the Ethernet MAC using an MII (Media Independent Interface) or RMII (Reduced Media Independent Interface).
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.
Both drivers are used in combination and usually the Ethernet MAC provides a media interface to the Ethernet PHY. A typical setup sequence for the drivers is shown below:
The following example code shows the usage of the Ethernet interface.
void ethernet_mac_notify (uint32_t event) {
switch (event) {
:
}
}
void initialize_ethernet_interface (void) {
mac = &Driver_ETH_MAC0;
phy = &Driver_ETH_PHY0;
}
else {
}
}
:
:
}
void ethernet_check_link_status (void) {
if (link == ethernet_link) {
return;
}
ethernet_link = link;
}
else {
}
}
@ ARM_POWER_FULL
Power on: full operation at maximum performance.
Definition: Driver_Common.h:66
@ ARM_ETH_LINK_UP
Link is up.
Definition: Driver_ETH.h:68
#define ARM_ETH_MAC_DUPLEX_Pos
Definition: Driver_ETH_MAC.h:86
#define ARM_ETH_MAC_SPEED_Pos
Definition: Driver_ETH_MAC.h:81
uint32_t speed
Link speed: 0= 10 MBit, 1= 100 MBit, 2= 1 GBit.
Definition: Driver_ETH.h:75
uint32_t duplex
Duplex mode: 0= Half, 1= Full.
Definition: Driver_ETH.h:76
ARM_ETH_LINK_STATE
Ethernet link state.
Definition: Driver_ETH.h:66
Ethernet link information.
Definition: Driver_ETH.h:74
Ethernet MAC Address.
Definition: Driver_ETH.h:83
#define ARM_ETH_MAC_ADDRESS_BROADCAST
Accept frames with Broadcast address.
#define ARM_ETH_MAC_CONTROL_TX
Transmitter; arg: 0=disabled (default), 1=enabled.
#define ARM_ETH_MAC_FLUSH
Flush buffer; arg = ARM_ETH_MAC_FLUSH_...
#define ARM_ETH_MAC_CONFIGURE
Configure MAC; arg = configuration.
#define ARM_ETH_MAC_CONTROL_RX
Receiver; arg: 0=disabled (default), 1=enabled.
#define ARM_ETH_MAC_FLUSH_TX
Flush Transmit buffer.
#define ARM_ETH_MAC_FLUSH_RX
Flush Receive buffer.
int32_t(* PowerControl)(ARM_POWER_STATE state)
Pointer to ARM_ETH_MAC_PowerControl : Control Ethernet MAC Device Power.
Definition: Driver_ETH_MAC.h:290
int32_t(* GetMacAddress)(ARM_ETH_MAC_ADDR *ptr_addr)
Pointer to ARM_ETH_MAC_GetMacAddress : Get Ethernet MAC Address.
Definition: Driver_ETH_MAC.h:291
uint32_t media_interface
Ethernet Media Interface type.
Definition: Driver_ETH_MAC.h:272
int32_t(* PHY_Write)(uint8_t phy_addr, uint8_t reg_addr, uint16_t data)
Pointer to ARM_ETH_MAC_PHY_Write : Write Ethernet PHY Register through Management Interface.
Definition: Driver_ETH_MAC.h:302
int32_t(* Control)(uint32_t control, uint32_t arg)
Pointer to ARM_ETH_MAC_Control : Control Ethernet Interface.
Definition: Driver_ETH_MAC.h:300
ARM_ETH_MAC_CAPABILITIES(* GetCapabilities)(void)
Pointer to ARM_ETH_MAC_GetCapabilities : Get driver capabilities.
Definition: Driver_ETH_MAC.h:287
uint32_t mac_address
1 = driver provides initial valid MAC address
Definition: Driver_ETH_MAC.h:273
int32_t(* SetMacAddress)(const ARM_ETH_MAC_ADDR *ptr_addr)
Pointer to ARM_ETH_MAC_SetMacAddress : Set Ethernet MAC Address.
Definition: Driver_ETH_MAC.h:292
int32_t(* PHY_Read)(uint8_t phy_addr, uint8_t reg_addr, uint16_t *data)
Pointer to ARM_ETH_MAC_PHY_Read : Read Ethernet PHY Register through Management Interface.
Definition: Driver_ETH_MAC.h:301
int32_t(* Initialize)(ARM_ETH_MAC_SignalEvent_t cb_event)
Pointer to ARM_ETH_MAC_Initialize : Initialize Ethernet MAC Device.
Definition: Driver_ETH_MAC.h:288
Access structure of the Ethernet MAC Driver.
Definition: Driver_ETH_MAC.h:285
Ethernet MAC Capabilities.
Definition: Driver_ETH_MAC.h:261
int32_t(* Initialize)(ARM_ETH_PHY_Read_t fn_read, ARM_ETH_PHY_Write_t fn_write)
Pointer to ARM_ETH_PHY_Initialize : Initialize PHY Device.
Definition: Driver_ETH_PHY.h:129
int32_t(* SetMode)(uint32_t mode)
Pointer to ARM_ETH_PHY_SetMode : Set Ethernet PHY Device Operation mode.
Definition: Driver_ETH_PHY.h:134
int32_t(* PowerControl)(ARM_POWER_STATE state)
Pointer to ARM_ETH_PHY_PowerControl : Control PHY Device Power.
Definition: Driver_ETH_PHY.h:132
ARM_ETH_LINK_INFO(* GetLinkInfo)(void)
Pointer to ARM_ETH_PHY_GetLinkInfo : Get Ethernet PHY Device Link information.
Definition: Driver_ETH_PHY.h:136
int32_t(* SetInterface)(uint32_t interface)
Pointer to ARM_ETH_PHY_SetInterface : Set Ethernet Media Interface.
Definition: Driver_ETH_PHY.h:133
ARM_ETH_LINK_STATE(* GetLinkState)(void)
Pointer to ARM_ETH_PHY_GetLinkState : Get Ethernet PHY Device Link state.
Definition: Driver_ETH_PHY.h:135
Access structure of the Ethernet PHY Driver.
Definition: Driver_ETH_PHY.h:127
#define ARM_ETH_PHY_AUTO_NEGOTIATE
Auto Negotiation mode.
#define ARM_DRIVER_OK
Operation succeeded.