xilinx zynq的lwip的官方例程解析

20181025  vivado2016.4  sdk

花了两天时间看的,总算是看懂了一点,不过主要看的是以太网怎样接收数据和发送数据的,其他的还不是很懂,将看懂的记录下,给需要的人一点参考。

这个官方例子应该是通过以太网中断接收数据,并且回传接收的数据。这里timer中断的作用还没看明白。

不用看懂所有代码,只需要看有注释的地方。没几句,看着很简单,但是自己去看程序的时候就没那么顺利。拿来主义是最简单的,自己看这些,太花时间。以前拿来的太多,还是多还点吧。

main函数之前都是库的调用和通用配置就不讲了

int main()
{
	struct ip_addr ipaddr, netmask, gw;

	/* the mac address of the board. this should be unique per board */
	unsigned char mac_ethernet_address[] =
	{ 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 };

	echo_netif = &server_netif;
#if defined (__arm__) && !defined (ARMR5)
#if XPAR_GIGE_PCS_PMA_SGMII_CORE_PRESENT == 1 || XPAR_GIGE_PCS_PMA_1000BASEX_CORE_PRESENT == 1
	ProgramSi5324();
	ProgramSfpPhy();
#endif
#endif

/* Define this board specific macro in order perform PHY reset on ZCU102 */
#ifdef XPS_BOARD_ZCU102
	IicPhyReset();
#endif

	init_platform();//timer中断初始化

init_platform()函数原型  在platform_zynq.c中

main函数
#if LWIP_DHCP==1
    ipaddr.addr = 0;
	gw.addr = 0;
	netmask.addr = 0;
#else
	/* initliaze IP addresses to be used */
	IP4_ADDR(&ipaddr,  192, 168,   1, 10);
	IP4_ADDR(&netmask, 255, 255, 255,  0);
	IP4_ADDR(&gw,      192, 168,   1,  1);
#endif	
	print_app_header();

	lwip_init();

  	/* Add network interface to the netif_list, and set it as default */
//最重要,以太网中断函数在这里指定
	if (!xemac_add(echo_netif, &ipaddr, &netmask,//引用xemacpsif_init()函数,引用以太网的中断函数
						&gw, mac_ethernet_address,
						PLATFORM_EMAC_BASEADDR)) {
		xil_printf("Error adding N/W interface\n\r");
		return -1;
	}

选中xemac_add函数鼠标右击选择Open Declaration,可以查看xemac_add

/*
 * xemac_add: this is a wrapper around lwIP's netif_add function.
 * The objective is to provide portability between the different Xilinx MAC's
 * This function can be used to add both xps_ethernetlite and xps_ll_temac
 * based interfaces  xemacpsif_init
 */
struct netif *
xemac_add(struct netif *netif,
	struct ip_addr *ipadd
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值