gupta123 wrote on Wednesday, June 20, 2012:
I am Facing a issue while calling xemacif_input(netif)in FreeRTOS task using TCP and UDP Connection establishment.This is a example of LWIP echo sever.
Regards
Anurag Gupta
################################ main.c ################################
#include <stdio.h>
#include “xenv_standalone.h”
#include “xparameters.h”
#include “netif/xadapter.h”
#ifdef XPAR_EMACLITE_0_BASEADDR
#define EMAC_BASEADDR XPAR_EMACLITE_0_BASEADDR
#elif XPAR_LLTEMAC_0_BASEADDR
#define EMAC_BASEADDR XPAR_LLTEMAC_0_BASEADDR
#else
#error
#endif
int start_application();
int transfer_data();
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 netif *netif, server_netif;
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, 0x01, 0xC2, 0x5C};
netif = &server_netif;
#ifdef __MICROBLAZE__
microblaze_init_icache_range(0, XPAR_MICROBLAZE_0_CACHE_BYTE_SIZE);
microblaze_init_dcache_range(0, XPAR_MICROBLAZE_0_DCACHE_BYTE_SIZE);
#endif
/* enable caches */
XCACHE_ENABLE_ICACHE();
XCACHE_ENABLE_DCACHE();
//platform_setup_interrupts();
/* initliaze IP addresses to be used */
IP4_ADDR(&ipaddr, 131, 169, 117, 2);
IP4_ADDR(&netmask, 255, 255, 255, 0);
IP4_ADDR(&gw, 0, 0, 0, 0);
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(netif, &ipaddr, &netmask, &gw, mac_ethernet_address, EMAC_BASEADDR))
{
xil_printf(“Error adding N/W interface\n\r”);
return -1;
}
netif_set_default(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(netif); */
/* now enable interrupts */
platform_enable_interrupts();
/* specify that the network if is up */
netif_set_up(netif);
/* start the application (web server, rxtest, txtest, etc…) */
start_application();
/* receive and process packets */
while (1)
{
xemacif_input(netif);
transfer_data();
}
XCACHE_DISABLE_DCACHE();
XCACHE_DISABLE_ICACHE();
#ifdef __MICROBLAZE__
microblaze_init_dcache_range(0, XPAR_MICROBLAZE_0_DCACHE_BYTE_SIZE);
microblaze_init_icache_range(0, XPAR_MICROBLAZE_0_CACHE_BYTE_SIZE);
#endif
return 0;
}