Chinaunix首页 | 论坛 | 博客
  • 博客访问: 324755
  • 博文数量: 135
  • 博客积分: 867
  • 博客等级: 准尉
  • 技术积分: 865
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-15 14:50
文章分类

全部博文(135)

文章存档

2012年(135)

分类:

2012-09-19 11:39:40

原文地址:UBOOT 网口测试 作者:iibull

static inline
int xn_net_probe(struct xn_tool *tool)
{
unsigned char s_buf[]= {0xff,0xff,0xff,0xff,0xff,0xff,0x8,0x0, \
0x3e,0x26,0xa,0xd8,0x8,0x6,0x0,0x1, \
0x8,0x0,0x6,0x4,0x0,0x1,0x8,0x0, \
0x3e,0x26,0xa,0xd8,0xc0,0xa8,0x3,0xac, \
0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0xa8, \
0x3,0x93};
char r_buf[1024] = {0};
unsigned long timeo = CFG_HZ * 2;
int per_len = 0,recv_len = 0;

printf("\nNet Probe:\n");
bd_t *bd = gd->bd;
if(!eth_linkok()) {
printf("cs8900 eth_linkok error\n");
goto error;
}
eth_halt();
eth_init(bd);
eth_test_mode_reginit();
eth_send(s_buf,sizeof(s_buf));
reset_timer();

while(recv_len < sizeof(s_buf)) {  
per_len = eth_recv(r_buf + recv_len,sizeof(s_buf) - recv_len);
recv_len += per_len;
if (get_timer(0) > timeo) {
printf("cs8900 read timeout\n");
break;
}
}
if(recv_len != sizeof(s_buf) || memcmp(s_buf,r_buf,sizeof(s_buf))) {
printf("recv data error\n");
goto error;
}

printf("CS8900...............................................[OK]\n");
wait_user_ack(tool);
return 0;
error:
printf("CS8900...............................................[ERROR]\n");
wait_user_ack(tool);
return 0;
}
阅读(788) | 评论(0) | 转发(0) |
0

上一篇:UBOOT WDT驱动流程

下一篇:UBOOT ADC 驱动流程

给主人留下些什么吧!~~