zynq-gem分析

本文档介绍了如何在ZynQ平台上配置以太网接口,包括使用xemac_add函数添加网络接口,设置MAC地址,初始化MAC控制器以及处理PHY设备。代码示例展示了从初始化到添加网络接口的详细步骤,涉及Xilinx EMACPS的初始化、设置MAC地址、探测PHY设备和设置速率等操作。
摘要由CSDN通过智能技术生成
static struct netif server_netif;
echo_netif = &server_netif;
if (!xemac_add(echo_netif, 
                    &ipaddr, &netmask,&gw, mac_ethernet_address,
						PLATFORM_EMAC_BASEADDR)) {
		xil_printf("Error adding N/W interface\n\r");
		return -1;
	}

/*
 * 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
 */
struct netif *xemac_add(struct netif *netif,
	            ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw, unsigned char *mac_ethernet_address,
	unsigned mac_baseaddr)
{
	int i;
	/* set mac address */
	netif->hwaddr_len = 6;
	for (i = 0; i < 6; i++)
		netif->hwaddr[i] = mac_ethernet_address[i];

	/* initialize based on MAC type */
		switch (find_mac_type(mac_baseaddr)) {
			case xemac_type_emacps:
				return netif_add(netif, ipaddr, netmask, gw,
						(void*)(UINTPTR)mac_baseaddr,
						xemacpsif_init,
#if NO_SYS
						ethernet_input
#else
						tcpip_input
#endif
						);
	}
}


struct netif *
netif_add(struct netif *netif,
#if LWIP_IPV4
          const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw,
#endi
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值