MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / FGmac_ReadPHYRegister

Function FGmac_ReadPHYRegister

bsp/ft2004/libraries/bsp/ft_gmac/ft_gmac_hw.c:58–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58s32 FGmac_ReadPHYRegister(FGmac_Config_t *Config, u16 PHYReg, u32 *RegValue)
59{
60 u32 TmpReg;
61 u32 Wait_Counter = 0;
62
63 TmpReg = 0;
64 TmpReg |= GMAC_MII_ADDR_CR(Config->clkMDC);
65 TmpReg |= GMAC_MII_ADDR_PA(Config->PhyAddr); /* Set the PHY device address */
66 TmpReg |= GMAC_MII_ADDR_GR(PHYReg); /* Set the PHY register address */
67 TmpReg &= ~GMAC_MII_ADDR_GW; /* Set the read mode */
68 TmpReg |= GMAC_MII_ADDR_GB; /* Set the MII Busy bit */
69
70 while ((Ft_in32(Config->BaseAddress + GMAC_MII_ADDR_OFFSET) & GMAC_MII_ADDR_GB) == GMAC_MII_ADDR_GB)
71 {
72 if (10000000 <= ++Wait_Counter)
73 {
74 GMAC_HW_DEBUG_E("wait GMAC_MII_ADDR_GB is error \r\n");
75 *RegValue = 0xffff;
76 return FST_ERROR_COUNT_MAX;
77 }
78 }
79
80 Ft_out32(Config->BaseAddress + GMAC_MII_ADDR_OFFSET, TmpReg);
81
82 while ((Ft_in32(Config->BaseAddress + GMAC_MII_ADDR_OFFSET) & GMAC_MII_ADDR_GB) == GMAC_MII_ADDR_GB)
83 {
84 if (10000000 <= ++Wait_Counter)
85 {
86 GMAC_HW_DEBUG_E("wait GMAC_MII_ADDR_GB 2 is error \r\n");
87 *RegValue = 0xffff;
88 return FST_ERROR_COUNT_MAX;
89 }
90 }
91 *RegValue = Ft_in32(Config->BaseAddress + GMAC_MII_DATA_OFFSET);
92 return FST_SUCCESS;
93}
94
95static s32 FGmac_PhyAddrGet(FGmac_Config_t *Config)
96{

Callers 2

FGmac_PhyAddrGetFunction · 0.85
FGmac_InitializeHwFunction · 0.85

Calls 2

Ft_in32Function · 0.85
Ft_out32Function · 0.85

Tested by

no test coverage detected