HPM SDK
HPMicro Software Development Kit
hpm_rtl8211.h File Reference

RTL8211 Ethernet PHY driver header file. More...

#include "hpm_enet_phy.h"
#include "hpm_common.h"
#include "hpm_enet_regs.h"

Go to the source code of this file.

Data Structures

struct  rtl8211_config_t
 RTL8211 PHY configuration structure. More...
 

Macros

#define RTL8211_ADDR   (2U)
 Default PHY address for RTL8211. More...
 
#define RTL8211_ID1   (0x001CU)
 RTL8211 PHY ID register 1 value (OUI MSB) More...
 
#define RTL8211_ID2   (0x32U)
 RTL8211 PHY ID register 2 value (OUI LSB) More...
 

Functions

bool rtl8211_reset (ENET_Type *ptr, uint32_t phy_addr)
 Reset RTL8211 PHY chip. More...
 
void rtl8211_basic_mode_default_config (ENET_Type *ptr, rtl8211_config_t *config)
 Set default configuration for RTL8211 PHY basic mode. More...
 
bool rtl8211_basic_mode_init (ENET_Type *ptr, uint32_t phy_addr, rtl8211_config_t *config)
 Initialize RTL8211 PHY chip in basic mode. More...
 
void rtl8211_get_phy_status (ENET_Type *ptr, uint32_t phy_addr, enet_phy_status_t *status)
 Get RTL8211 PHY status. More...
 

Detailed Description

RTL8211 Ethernet PHY driver header file.

This file provides the API definitions for the RTL8211 Ethernet PHY chip driver. The RTL8211 is a single-port 10/100-Mbps Ethernet physical layer transceiver.

Macro Definition Documentation

◆ RTL8211_ADDR

#define RTL8211_ADDR   (2U)

Default PHY address for RTL8211.

◆ RTL8211_ID1

#define RTL8211_ID1   (0x001CU)

RTL8211 PHY ID register 1 value (OUI MSB)

◆ RTL8211_ID2

#define RTL8211_ID2   (0x32U)

RTL8211 PHY ID register 2 value (OUI LSB)

Function Documentation

◆ rtl8211_basic_mode_default_config()

void rtl8211_basic_mode_default_config ( ENET_Type ptr,
rtl8211_config_t config 
)

Set default configuration for RTL8211 PHY basic mode.

Parameters
[in]ptrPointer to the ENET peripheral base address
[out]configPointer to the configuration structure to be initialized

This function initializes the configuration structure with default values:

  • Loopback: disabled
  • Auto-negotiation: enabled (unless __DISABLE_AUTO_NEGO is defined)
  • Speed: 100 Mbps (when auto-negotiation is disabled)
  • Duplex: full duplex (when auto-negotiation is disabled)

◆ rtl8211_basic_mode_init()

bool rtl8211_basic_mode_init ( ENET_Type ptr,
uint32_t  phy_addr,
rtl8211_config_t config 
)

Initialize RTL8211 PHY chip in basic mode.

Parameters
[in]ptrPointer to the ENET peripheral base address
[in]phy_addrPHY address
[in]configPointer to the PHY configuration structure
Return values
trueInitialization completed successfully
falseInitialization failed (PHY ID check failed)

This function performs the following operations:

  • Verifies the PHY ID to ensure it's a RTL8211 chip
  • Configures the PHY according to the provided configuration
  • Sets up loopback mode, auto-negotiation, speed, and duplex settings

◆ rtl8211_get_phy_status()

void rtl8211_get_phy_status ( ENET_Type ptr,
uint32_t  phy_addr,
enet_phy_status_t status 
)

Get RTL8211 PHY status.

Parameters
[in]ptrPointer to the ENET peripheral base address
[in]phy_addrPHY address
[out]statusPointer to the status structure to store PHY status

This function reads the PHY status register and extracts:

  • Link status (up/down)
  • Port speed (10 Mbps, 100 Mbps, or 1000 Mbps)
  • Duplex mode (half or full)

◆ rtl8211_reset()

bool rtl8211_reset ( ENET_Type ptr,
uint32_t  phy_addr 
)

Reset RTL8211 PHY chip.

Parameters
[in]ptrPointer to the ENET peripheral base address
[in]phy_addrPHY address
Return values
trueReset operation completed successfully
falseReset operation failed (timeout)