|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
本帖最后由 huoyanchang 于 2016-1-11 09:28 编辑
运行时老是停在xemac_add(echo_netif, &ipaddr, &netmask,&gw, mac_ethernet_address,PLATFORM_EMAC_BASEADDR)部分,在debug下调试,没有报错,也没有现象,求大神解救
- #include <stdio.h>
- #include "xparameters.h"
- #include "netif/xadapter.h"
- #include "platform.h"
- #include "platform_config.h"
- #ifdef __arm__
- #include "xil_printf.h"
- #endif
- /* defined by each RAW mode application */
- void print_app_header();
- int start_application();
- int transfer_data();
- /* missing declaration in lwIP */
- void lwip_init();
- static struct netif server_netif;
- struct netif *echo_netif;
- void
- print_ip(char *msg, struct ip_addr *ip)
- {
- print(msg);
- xil_printf("%d.%d.%d.%d\n\r", ip4_addr1(ip), ip4_addr2(ip),
- ip4_addr3(ip), ip4_addr4(ip));
- }
- void
- print_ip_settings(struct ip_addr *ip, struct ip_addr *mask, struct ip_addr *gw)
- {
- print_ip("Board IP: ", ip);
- print_ip("Netmask : ", mask);
- print_ip("Gateway : ", gw);
- }
- 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;
- init_platform();
- /* 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);
- print_app_header();
- print_ip_settings(&ipaddr, &netmask, &gw);
- lwip_init();
- /* Add network interface to the netif_list, and set it as default */
- 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;
- }
- netif_set_default(echo_netif);
- /* Create a new DHCP client for this interface.
- * Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at
- * the predefined regular intervals after starting the client.
- */
- /* dhcp_start(echo_netif); */
- /* now enable interrupts */
- platform_enable_interrupts();
- /* specify that the network if is up */
- netif_set_up(echo_netif);
- /* start the application (web server, rxtest, txtest, etc..) */
- start_application();
- /* receive and process packets */
- while (1) {
- xemacif_input(echo_netif);
- transfer_data();
- }
-
- /* never reached */
- cleanup_platform();
- return 0;
- }
复制代码 |
|