UINT8 GetPhyLinkState(void)
{
UINT16 phy_reg = 0;
phy_reg = ReadPHYRegX(PHY_BMSR); //读取PHY状态寄存器
if(phy_reg&0x04)
{
//printf("link connect ok....rn");
return 1;
}
//printf("link disconnect ok....rn");
return 0;
}
static UINT16 ReadPHYRegX(UINT8 reg_add)
{
UINT8 reg_op=0;
UINT16 read_reg_val = 0xffff;
reg_op = reg_add&RB_ETH_MIREGADR_MIRDL;
R8_ETH_MIREGADR = RB_ETH_MIREGADR_MIIWR|reg_op;
read_reg_val = R16_ETH_MIRD;
return read_reg_val;
}
您好,您可以参考这段代码。
UINT8 GetPhyLinkState(void)
{
UINT16 phy_reg = 0;
phy_reg = ReadPHYRegX(PHY_BMSR); //读取PHY状态寄存器
if(phy_reg&0x04)
{
//printf("link connect ok....rn");
return 1;
}
//printf("link disconnect ok....rn");
return 0;
}
static UINT16 ReadPHYRegX(UINT8 reg_add)
{
UINT8 reg_op=0;
UINT16 read_reg_val = 0xffff;
reg_op = reg_add&RB_ETH_MIREGADR_MIRDL;
R8_ETH_MIREGADR = RB_ETH_MIREGADR_MIIWR|reg_op;
read_reg_val = R16_ETH_MIRD;
return read_reg_val;
}
您好,您可以参考这段代码。
举报