cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
marquesni
Visitor
Visitor
2,488 Views
Registered: ‎12-02-2009

XAPP1026 "Lightweight IP" problem P2p and interrupt

Hello,

I use the application XAPP1026 "Lightweight IP" as an example. I cut the soft part to having only one application which sends UDP packets. I will read an area of RAM and I sent in UDP.

I have two questions in relation to this application:

1) I want to know what is the bus P2P (point to point) connected between the DDR2 RAM Mac IP and Ethernet?

2) Is it possible to trigger the function of sending data via an interrupt generated by HARD.

Below you find the code that I use for sending UDP packets:

 

#include <stdio.h>

#include <string.h>

 

#include "lwip/err.h"

#include "lwip/udp.h"

#include "xparameters.h"

#include "xutil.h"

#include "xio.h"

 

#define BUFSIZE (1400)

static Xuint32 buf[BUFSIZE];

 

 

#define ddr_BASEADDR 0x51000000

static unsigned eth_port = 5001;

static eth_server_started = 0;

 

static struct udp_pcb *connected_pcb = NULL;

static struct pbuf *pbuf_to_be_sent = NULL;

int z=0;

 

int 

transfer_eth_data() {

int copy = 1;

err_t err;

struct udp_pcb *pcb = connected_pcb;

static int id;

int *payload;

int i,j;

 

if (!connected_pcb) {

                xil_printf("!connected_pcb\n\r");

return -1;

}

memcpy(pbuf_to_be_sent->payload, ddr_BASEADDR, BUFSIZE); 

pbuf_to_be_sent->len =BUFSIZE;

 

if (!pbuf_to_be_sent) {

return -1;

}

 

// always increment the id 

payload = (int*)(pbuf_to_be_sent->payload);

*payload = id++;

 

err = udp_send(pcb, pbuf_to_be_sent);

if (err != ERR_OK) {

xil_printf("Error on udp_send: %d\n\r", err);

return -1;

}

 

 

#if ALLOC_PBUF_ON_TRANSFER

pbuf_free(pbuf_to_be_sent);

#endif

return 0;

}

 

void 

print_eth_app_header()

{

     xil_printf("%20s %6d %s\n\r", "eth server",eth_port,"$ tftp -i 192.168.1.100 PUT <source-file>");

}

 

int 

start_eth_application()

{

struct udp_pcb *pcb;

struct ip_addr ipaddr;

err_t err;

u16_t port;

int j,i;

Xuint8 dataIn;

// create a udp socket 

pcb = udp_new();

if (!pcb) {

xil_printf("Error creating PCB. Out of Memory\n\r");

return -1;

}

 

/* bind local address */

if ((err = udp_bind(pcb, IP_ADDR_ANY, 0)) != ERR_OK) {

xil_printf("error on udp_bind: %x\n\r", err);

}

// connect to iperf server 

 

IP4_ADDR(&ipaddr,   192, 168, 1 ,100); // iperf server address /

port = eth_port;                            // iperf default port 

err = udp_connect(pcb, &ipaddr, port);

 

for (j = 0; j < BUFSIZE ; j++)

{

XIo_Out32(ddr_BASEADDR+j,    0x11112222);

}

xil_printf("chargement ram ok");

 

connected_pcb = pcb;

pbuf_to_be_sent = pbuf_alloc(PBUF_RAW, BUFSIZE, PBUF_POOL);//

 

return 0;

}  

0 Kudos
0 Replies