|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
代码用的是Uboot的dm9000x驱动,按照需要做了适当修改。初始化函数如下:
/*--------------------------------------------------------------------------------------*/
/* Initilize dm9000 board
*/
int
eth_init( const char *ps_mac )
{
int i, oft, lnk;
unsigned char u8_byte = 0;
unsigned char sa_mac[ 6 ] = { 0 };
DM9000_DBG("eth_init()\r\n");
/* RESET device */
dm9000_reset();
dm9000_probe();
/* NIC Type: FASTETHER, HOMERUN, LONGRUN */
identify_nic();
/* GPIO0 on pre-activate PHY */
DM9000_iow(DM9000_GPR, 0x00); /*REG_1F bit0 activate phyxcer */
/* Set PHY */
set_PHY_mode();
/* Program operating register */
DM9000_iow(DM9000_NCR, 0x0); /* only intern phy supported by now */
DM9000_iow(DM9000_TCR, 0); /* TX Polling clear */
DM9000_iow(DM9000_BPTR, 0x3f); /* Less 3Kb, 200us */
DM9000_iow(DM9000_FCTR, FCTR_HWOT(3) | FCTR_LWOT(8)); /* Flow Control : High/Low Water */
DM9000_iow(DM9000_FCR, 0x0); /* SH FIXME: This looks strange! Flow Control */
DM9000_iow(DM9000_SMCR, 0); /* Special Mode */
DM9000_iow(DM9000_NSR, NSR_WAKEST | NSR_TX2END | NSR_TX1END); /* clear TX status */
DM9000_iow(DM9000_ISR, 0x0f); /* Clear interrupt status */
if( ps_mac != 0 )
{
memcpy( sa_mac, ps_mac, 6 );
/* Set Node address */
DM9000_DBG("MAC: %02x:%02x:%02x:%02x:%02x:%02x\r\n", sa_mac[0],
sa_mac[1], sa_mac[2], sa_mac[3], sa_mac[4], sa_mac[5]);
for (i = 0, oft = 0x10; i < 6; i++, oft++)
DM9000_iow(oft, sa_mac[i]);
for (i = 0, oft = 0x16; i < 8; i++, oft++)
DM9000_iow(oft, 0xff);
/* read back mac, just to be sure */
for (i = 0, oft = 0x10; i < 6; i++, oft++)
DM9000_DBG("%02x:", DM9000_ior(oft));
DM9000_DBG("\r\n");
}
/* Activate DM9000 */
DM9000_iow(DM9000_RCR, RCR_DIS_LONG | RCR_DIS_CRC | RCR_RXEN); /* RX enable */
//DM9000_iow(DM9000_IMR, IMR_PAR); /* Enable TX/RX interrupt mask */
DM9000_iow( DM9000_IMR, 0x81 );
u8_byte = DM9000_ior( DM9000_NSR );
DM9000_DBG( "DM9000_NSR = 0x%02x\r\n", u8_byte );
i = 0;
while (!(phy_read(1) & 0x20)) { /* autonegation complete bit */
mdelay(1);
i++;
if (i == 10000) {
//xil_printf("could not establish link\r\n");
return 0;
}
}
/* see what we've got */
lnk = phy_read(17) >> 12;
xil_printf("operating at ");
switch (lnk) {
case 1:
xil_printf("10M half duplex ");
break;
case 2:
xil_printf("10M full duplex ");
break;
case 4:
xil_printf("100M half duplex ");
break;
case 8:
xil_printf("100M full duplex ");
break;
default:
xil_printf("unknown: %d ", lnk);
break;
}
xil_printf("mode\r\n");
return 0;
}
/*--------------------------------------------------------------------------------------*/
初始化代码中已经清了中断,并启用了接受中断,但为什么收到数据的时候,INT脚竟然没有信号输出?ISR中断寄存器都已经有中断位重置了呀。还请高手指点,谢谢! |
|