- 论坛徽章:
- 0
|
下面这两个函数是以太网收发器DP83848PHY中寄存器读/写函数,其中phyadd为phy地址,phyreg为PHY寄存器地址,我想如果要想给PHY中写数据,直接找到PHY中的寄存器地址就行,这个PHY地址感觉没有什么作用?各位有什么好的想法没?讨论一下
uint32 ReadPHY( uint16 phyadd,uint32 PHYReg )
{
uint32 i32;
MAC_MCMD = 0x0001; /* read command */
i32 = (phyadd<< | PHYReg; /* [12:8] == PHY addr, [4:0]=0x00(BMCR) register addr */
MAC_MADR = i32;
while ( MAC_MIND != 0 );
MAC_MCMD = 0x0000;
return( MAC_MRDD );
}
void Write_PHY (uint16 phyadd,int PhyReg, int Value)
{
unsigned int tout;
MAC_MADR = (phyadd<< | PhyReg;
MAC_MWTD = Value;
/* Wait utill operation completed */
tout = 0;
for (tout = 0; tout < 50000; tout++) {
if ((MAC_MIND & 1) == 0) {
break;
}
}
} |
|