HPM SDK
HPMicro Software Development Kit
hpm_lan8720.c File Reference
#include "hpm_enet_drv.h"
#include "hpm_lan8720_regs.h"
#include "hpm_lan8720.h"

Functions

static bool lan8720_check_id (ENET_Type *ptr, uint32_t phy_addr)
 
bool lan8720_reset (ENET_Type *ptr, uint32_t phy_addr)
 Reset LAN8720 PHY chip. More...
 
void lan8720_basic_mode_default_config (ENET_Type *ptr, lan8720_config_t *config)
 Set default configuration for LAN8720 PHY basic mode. More...
 
bool lan8720_basic_mode_init (ENET_Type *ptr, uint32_t phy_addr, lan8720_config_t *config)
 Initialize LAN8720 PHY chip in basic mode. More...
 
void lan8720_get_phy_status (ENET_Type *ptr, uint32_t phy_addr, enet_phy_status_t *status)
 Get LAN8720 PHY status. More...
 

Function Documentation

◆ lan8720_basic_mode_default_config()

void lan8720_basic_mode_default_config ( ENET_Type ptr,
lan8720_config_t config 
)

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

◆ lan8720_basic_mode_init()

bool lan8720_basic_mode_init ( ENET_Type ptr,
uint32_t  phy_addr,
lan8720_config_t config 
)

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

◆ lan8720_check_id()

static bool lan8720_check_id ( ENET_Type ptr,
uint32_t  phy_addr 
)
static

◆ lan8720_get_phy_status()

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

Get LAN8720 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)

◆ lan8720_reset()

bool lan8720_reset ( ENET_Type ptr,
uint32_t  phy_addr 
)

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