配置SA1L和SA1H寄存器時(shí),假如MAC地址是00:11:22:33:44:55,即At91EnetAddr[6]={0x00,0x11,0x22,0x33,0x44,0x55},則正確的賦值方式是:
for (i = 0; i < 6; ++i) {
pDrvCtrl->enetAddr[i] = At91EnetAddr[i];
}
pEmac->EMAC_SA1L = ((int)At91EnetAddr[2] << 24)
| ((int)At91EnetAddr[3] << 16) | ((int)At91EnetAddr[4] << 8) |
At91EnetAddr[5];
pEmac->EMAC_SA1H =
((int)At91EnetAddr[0] << 8) |
At91EnetAddr[1];
其中pDrvCtrl為指向EMAC控制結(jié)構(gòu)AT91_DRV_CTRL的指針。