HPM SDK
HPMicro Software Development Kit
hpm_rtl8201.h File Reference

RTL8201 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  rtl8201_config_t
 RTL8201 PHY configuration structure. More...
 

Macros

#define RTL8201_ADDR   (2U)
 Default PHY address for RTL8201. More...
 
#define RTL8201_ID1   (0x001CU)
 RTL8201 PHY ID register 1 value (OUI MSB) More...
 
#define RTL8201_ID2   (0x32U)
 RTL8201 PHY ID register 2 value (OUI LSB) More...
 

Enumerations

enum  rtl8201_config_refclk_direction_t { rtl8201_config_refclk_output = 0 , rtl8201_config_refclk_input }
 RTL8201 reference clock direction configuration. More...
 

Functions

bool rtl8201_reset (ENET_Type *ptr, uint32_t phy_addr)
 Reset RTL8201 PHY chip. More...
 
void rtl8201_basic_mode_default_config (ENET_Type *ptr, rtl8201_config_t *config)
 Set default configuration for RTL8201 PHY basic mode. More...
 
bool rtl8201_basic_mode_init (ENET_Type *ptr, uint32_t phy_addr, rtl8201_config_t *config)
 Initialize RTL8201 PHY chip in basic mode. More...
 
void rtl8201_get_phy_status (ENET_Type *ptr, uint32_t phy_addr, enet_phy_status_t *status)
 Get RTL8201 PHY status. More...
 
void rtl8201_set_rmii_refclk_direction (ENET_Type *ptr, uint32_t phy_addr, uint8_t dir)
 Set RMII reference clock direction for RTL8201 PHY. More...
 

Detailed Description

RTL8201 Ethernet PHY driver header file.

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

Macro Definition Documentation

◆ RTL8201_ADDR

#define RTL8201_ADDR   (2U)

Default PHY address for RTL8201.

◆ RTL8201_ID1

#define RTL8201_ID1   (0x001CU)

RTL8201 PHY ID register 1 value (OUI MSB)

◆ RTL8201_ID2

#define RTL8201_ID2   (0x32U)

RTL8201 PHY ID register 2 value (OUI LSB)

Enumeration Type Documentation

◆ rtl8201_config_refclk_direction_t

RTL8201 reference clock direction configuration.

Enumerator
rtl8201_config_refclk_output 

Reference clock output mode

rtl8201_config_refclk_input 

Reference clock input mode

Function Documentation

◆ rtl8201_basic_mode_default_config()

void rtl8201_basic_mode_default_config ( ENET_Type ptr,
rtl8201_config_t config 
)

Set default configuration for RTL8201 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)

◆ rtl8201_basic_mode_init()

bool rtl8201_basic_mode_init ( ENET_Type ptr,
uint32_t  phy_addr,
rtl8201_config_t config 
)

Initialize RTL8201 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 RTL8201 chip
  • Configures the PHY according to the provided configuration
  • Sets up loopback mode, auto-negotiation, speed, and duplex settings

◆ rtl8201_get_phy_status()

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

Get RTL8201 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 or 100 Mbps)
  • Duplex mode (half or full)

◆ rtl8201_reset()

bool rtl8201_reset ( ENET_Type ptr,
uint32_t  phy_addr 
)

Reset RTL8201 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)

◆ rtl8201_set_rmii_refclk_direction()

void rtl8201_set_rmii_refclk_direction ( ENET_Type ptr,
uint32_t  phy_addr,
uint8_t  dir 
)

Set RMII reference clock direction for RTL8201 PHY.

Parameters
[in]ptrPointer to the ENET peripheral base address
[in]phy_addrPHY address
[in]dirReference clock direction: rtl8201_config_refclk_direction_t

This function configures whether the RTL8201 PHY provides the reference clock (output mode) or receives it (input mode) for RMII interface.