/* * * * * */ #include #include #include #include #include #include "system.h" #include "DM9000A.H" #include "DM9000A.C" //#include "sys/alt_irq.h" #include <../src/alt_irq_register.c> #if 0 unsigned int rx_len,i,packet_num,rx_cnt,tx_cnt; #define data_lenght 1468 // Maximun Data lenght 1468 bytes #define flenght (data_lenght+0x2E) //Total packet lenght unsigned char SND[flenght]; // Payload buffer unsigned char RX_DATA[flenght]; // Payload buffer //------------------------------------------------------------------------- /* DM9000_init I/O routine */ //------------------------------------------------------------------------- //------------------------------------------------------------------------- //------------------------------------------------------------------------- void UDP_Init(void) { unsigned int IPsource_1,IPsource_2,IPsource_3,IPsource_4; unsigned int IPdestination_1,IPdestination_2,IPdestination_3,IPdestination_4; unsigned int IPchecksum1,IPchecksum2,IPchecksum3,IPchecksum4,IPchecksum5; unsigned int Mac_source1, Mac_source2, Mac_source3, Mac_source4, Mac_source5, Mac_source6; unsigned int Mac_dest1, Mac_dest2, Mac_dest3, Mac_dest4, Mac_dest5, Mac_dest6; unsigned int lenght_h, lenght_l; unsigned int IPlenght_h, IPlenght_l, IPlenght; IPsource_1 = 192; // Assign ie: 192.168.0.44 IP for the CD0 IPsource_2 = 168; IPsource_3 = 0; IPsource_4 = 44; IPdestination_1 = 192; // Insert your IP data here IPdestination_2 = 168; IPdestination_3 = 0; IPdestination_4 = 55; Mac_dest1 = 0xF4; // Insert your MAC address data here Mac_dest2 = 0x6D; Mac_dest3 = 0x04; Mac_dest4 = 0x20; Mac_dest5 = 0x9F; Mac_dest6 = 0xF1; // Mac_dest1 = 0XFF; // Insert your MAC address data here // Mac_dest2 = 0xFF; // Mac_dest3 = 0xFF; // Mac_dest4 = 0xFF; // Mac_dest5 = 0xFF; // Mac_dest6 = 0xFF; Mac_source1 = 0x01; // Assign an MAC address for DE2 Mac_source2 = 0x60; Mac_source3 = 0x6E; Mac_source4 = 0x11; Mac_source5 = 0x02; Mac_source6 = 0x0F; lenght_h = ((data_lenght+8) & 0xFF00)>>8; // Convert in H byte and L byte lenght_l = ((data_lenght+8) & 0x00FF); IPlenght = data_lenght + 8 + 20; // IP Lenght for IP header IPlenght_h = (IPlenght & 0xFF00)>>8; // Convert in H byte and L byte IPlenght_l = (IPlenght & 0x00FF); // Calculating the IP checksum IPchecksum1 = 0x0000C511 + (IPsource_1<<8)+IPsource_2+(IPsource_3<<8)+IPsource_4+ (IPdestination_1<<8)+IPdestination_2+(IPdestination_3<<8)+(IPdestination_4)+ (IPlenght_h<<8) + IPlenght_l; IPchecksum2 = ((IPchecksum1&0x0000FFFF)+(IPchecksum1>>16)); IPchecksum3 = 0x0000FFFF - IPchecksum2; IPchecksum4 = (IPchecksum3 & 0xFF00)>>8; IPchecksum5 = (IPchecksum3 & 0x00FF); unsigned char TXT[flenght] = { Mac_dest1, Mac_dest2, Mac_dest3, Mac_dest4 ,Mac_dest5, Mac_dest6, Mac_source1, Mac_source2, Mac_source3, Mac_source4, Mac_source5, Mac_source6, 0x08, 0x00, 0x45, 0x00, IPlenght_h, IPlenght_l, 0x00, 0x00, 0x00, 0x00, 0x80, 0x11, IPchecksum4, IPchecksum5, IPsource_1, IPsource_2, IPsource_3, IPsource_4, IPdestination_1, IPdestination_2, IPdestination_3, IPdestination_4, 0x04, 0x00, 0x04, 0x00, lenght_h, lenght_l, 0x00, 0x00}; for (i = 0; i < 42; i++) // Load the TXT[] in the SND (ethernet packet). SND[i] = TXT[i]; for (i = 42; i < flenght-4; i++) // generating the data to send. SND[i] = i-42; SND[i++] = 0x35; // This checksum is not correct... but also the net recieve the packets correctly. SND[i++] = 0x15; // To do, calculate checksum. SND[i++] = 0xF0; SND[i++] = 0x13; } void ethernet_interrupts(void) { ReceivePacket(RX_DATA,&rx_len); rx_cnt++; int j; for(j=0;j