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
zynq-gem分析
于 2022-03-08 15:50:16 首次发布
本文档介绍了如何在ZynQ平台上配置以太网接口,包括使用xemac_add函数添加网络接口,设置MAC地址,初始化MAC控制器以及处理PHY设备。代码示例展示了从初始化到添加网络接口的详细步骤,涉及Xilinx EMACPS的初始化、设置MAC地址、探测PHY设备和设置速率等操作。
摘要由CSDN通过智能技术生成