HPM SDK
HPMicro Software Development Kit
hpm_rtl8201.c File Reference
#include "hpm_enet_drv.h"
#include "hpm_rtl8201_regs.h"
#include "hpm_rtl8201.h"

Functions

static bool rtl8201_check_id (ENET_Type *ptr, uint32_t phy_addr)
 
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...
 

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_check_id()

static bool rtl8201_check_id ( ENET_Type ptr,
uint32_t  phy_addr 
)
static

◆ 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.