⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 开发工具用EMBEST IDE进行开发,该程序是一个S3C44B0直接驱动网卡的程序,包括8019初始化,物理层收包发包,UDP的接收和发送,IP的发送和接收.已及ARM的地址解板,整个程序是自顶而下
💻 C
字号:
/*********************************************************************************************
* File:	main.c
* Author:	embest
* Desc:	c main entry
* History:	
*********************************************************************************************/

/*--- include files ---*/
#include "44blib.h"
#include "44b.h"
#include "ethernet.h"
#include "def.h"

#include "string.h"
//#include "stdlib.h"
#include "stdio.h"
#include "ip.h"
#include "arp.h"
#include "icmp.h"
#include "udp.h"



// Global variables
unsigned short volatile event_word;
char  text[20];  
unsigned char  debug;
unsigned char  rcve_buf_allocated;
unsigned short event_word_copy;
unsigned char * inbuf;
// This sets my hardware address to 00:01:02:03:04:05
unsigned char  my_hwaddr[6] = {0x08, 0x07, 0x06, 0x05, 0x04, 0x03}; 

// Hardware addr to send a broadcast
unsigned char  broadcast_hwaddr[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

// This sets my IP address to 192.168.0.10
unsigned long   my_ipaddr = 0xc0a8000a;

// This sets my subnet mask to 255.255.255.0
unsigned long   my_subnet = 0xFFFFFF00;

// Set to 0 if no gateway is present on network
unsigned long   gateway_ipaddr = 0xc0a80001;

//--------------------------------------------------------------------------
// Initialize the memory management routines
// Initialize variables declared in main
//--------------------------------------------------------------------------

unsigned short Count1msInc;
unsigned char Count1ms,Count10ms,Count1s;
unsigned char TimeSecond,TimeMinute;

extern char  net_out_data[1536];
extern char  net_in_data[1536];


void init_main(void)
{
	// Start the memory pool for incoming and outgoing Ethernet
	// frames at 1000, with length = 1500 bytes. Memory below 500
	// is used for program variables
	//init_mempool((void  *)1000, 1500);
	memset(net_out_data,0,1536);
	memset(net_in_data,0,1536);
	memset(text, 0, sizeof(text));
	event_word = 0;
	rcve_buf_allocated = FALSE;
	debug = 1;
}






/*--- function declare ---*/
void main(void);

/*--- extern function ---*/
//extern void Tftp_Test(void);

/*--- function code ---*/
/*********************************************************************************************
* name:		main
* func:		c code entry
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void Main(void)
{
//	unsigned short event_word_copy;
//	unsigned char * inbuf;
 	rI_ISPC = 0xffffffff;			/* clear all interrupt pend	*/
	Port_Init();					/* Initial 44B0X's I/O port */
	Delay(0);						/* delay time				*/
	Uart_Init(0,115200);			/* Initial Serial port 1	*/
	
	/******************/
	/* user interface */
	/******************/
	Uart_Printf("\n\rEmbest 44B0Xqhy(S3CEV40)");
//	Uart_Printf("\n\rEthernet tx and dx programe  Example\n");
	init_main();
	init_arp();

//	NicInit();
//	NetInit();
//	Tftp_Test();
	init_8019();
	while(1)
	{
	 query_8019();
	 
	event_word_copy = event_word;

      if (event_word_copy & EVENT_ETH_ARRIVED)
      {
       //  EA = 0;
         event_word &= (~EVENT_ETH_ARRIVED);
         //EA = 1;
         
         // Allocate a buffer and read frame from CS8900A
        inbuf = rcve_frame();
      
         if (inbuf != NULL)
         {
      
            eth_rcve(inbuf); 
 	
            if (rcve_buf_allocated)
            {
               free(inbuf);
               rcve_buf_allocated = FALSE;
               Uart_Printf("\n\r all data inbuf space is free finish   \n");   
            }
         }
      }
      
 
      // See if ARP retransmit timer has expired
 		else if (event_word_copy & EVENT_ARP_RETRANSMIT)
      {
         //EA = 0;
         event_word &= (~EVENT_ARP_RETRANSMIT);
         	Uart_Printf("\n\r RETRANSMIT()   \n");  
         //EA = 1;
         arp_retransmit();
		}

      // See if it is time to age the ARP cache
      else if (event_word_copy & EVENT_AGE_ARP_CACHE)
      {
         //EA = 0;
         event_word &= (~EVENT_AGE_ARP_CACHE);
		//	EA = 1;
		Uart_Printf("\n\r AGE_ARP -CHCHE()   \n");  
         age_arp_cache();
		}

		Delay(100);
	}
}


                  


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -