phy的寄存器的读写函数

vxworks:phy寄存器读写的函数:

void phyRead(int unit,int addr,int reg)
{
VXB_DEVICE_ID pDev;
FUNCPTR phyRead1 = NULL;
UINT16 data;

pDev = vxbInstByNameFind("gem",unit);
phyRead1 = vxbDevMethodGet(pDev,(UINT32)&miiRead_desc);
phyRead1(pDev,addr,reg,&data);

printf("unit %d,addr %d,reg(0x%x)=0x%x\n",unit,addr,reg,data);
}
void phyWrite(int unit,int addr,int reg,UINT16 data)
{
VXB_DEVICE_ID pDev;
FUNCPTR phyWrite1 = NULL;


pDev = vxbInstByNameFind("gem",unit);
phyWrite1 = vxbDevMethodGet(pDev,(UINT32)&miiWrite_desc);
phyWrite1(pDev,addr,reg,data);


}


void testphyReg(void)
{
int i=0;
for(i=0;i<=31;i++)
{
phyRead(0,7,i);

}
}

你可能感兴趣的:(phy的寄存器的读写函数)