完成上面的过程之后,网卡还不能正确的接收数据包,因为我们还没有对网卡的物理地址(网卡地址,48位的地址)进行设置。网卡还不知道它应该什么地址的数据包。要对网卡的物理地址进行设置,就必须知道网卡的物理地址是多少。
读取网卡的物理地址的子程序:
union u {uint word; struct{uchar high;uchar low;}bytes;}; //我定义的数据结构,为两个字节的结构 //,可以按照uint(unsigned int)来读取,也可以按照高低字节high和low来读取。
union u mynodeid[3];//存储网卡的物理地址
union u protocal; //临时变量
void readmynodeid()
{uchar data i,temp;
page(0);
reg09=0;//寄存器RSAR1 dma read highaddress=0
reg08=0;//RSAR0 dma read lowaddress=0;
reg0b=0; //RBCR1 read count high
reg0a=12;//RBCR0 count low
reg00=0x0a;//dma read and start
for (i=0;i<6;i++)
{ temp=reg10;//读取一个字节
if (i % 2==0)
{protocal.bytes.high=temp;}
else {protocal.bytes.low=temp;mynodeid[i/2].word=protocal.word;}
temp=reg10;//读取一个重复的字节&#