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

📄 ip.h

📁 8900系列底曾程序!希望能够对大家提供借鉴
💻 H
字号:
#define		RTL8019BASE		0x3700

#define		Reg00	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x00)))
#define		Reg01	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x01)))
#define		Reg02	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x02)))
#define		Reg03	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x03)))
#define		Reg04	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x04)))
#define		Reg05	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x05)))
#define		Reg06	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x06)))
#define		Reg07	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x07)))
#define		Reg08	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x08)))
#define		Reg09	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x09)))
#define		Reg0a	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x0a)))
#define		Reg0b	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x0b)))
#define		Reg0c	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x0c)))
#define		Reg0d	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x0d)))
#define		Reg0e	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x0e)))
#define		Reg0f	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x0f)))
#define		Reg10	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x10)))

#define	  	SetData			GpioDataRegs.GPFDAT.bit.GPIOF0 = 1
#define	  	ClrData   		GpioDataRegs.GPFDAT.bit.GPIOF0 = 0
#define	  	SetClk			GpioDataRegs.GPFDAT.bit.GPIOF2 = 1
#define	  	ClrClk			GpioDataRegs.GPFDAT.bit.GPIOF2 = 0
#define	  	LedReg		    (*((volatile  unsigned  int *)0x23FF))
#define	  	Led8Reg  		(*((volatile  unsigned  int *)0x25FF)) 

#define		SetFmq				0x40
#define		ClrFmq				0xBF
#define  	Set485OE		 	0x20
#define  	Clr485OE		 	0xDF
#define	 	Set8019RST		 	0x10
#define		Clr8019RST		 	0xEF
#define  	SetSPICS		 	0x08 
#define  	ClrSPICS		 	0xF7 
#define	 	SetAICCS		 	0x04  
#define  	ClrAICCS		 	0xFB 	
#define  	SetSIDIN		 	0x02  
#define	 	ClrSIDIN		 	0xFD  
#define  	SetSCLK		 		0x01  
#define  	ClrSCLK		 		0xFE  

#define MY_TCP_PORT    	     1024
#define MY_UDP_PORT  	     1025

#define ETH_HEADER_START     0
#define IP_HEADER_START      7
#define ARP_HEADER_START     7
#define TCP_HEADER_START     17
#define UDP_HEADER_START     17
#define ICMP_HEADER_START    17
#define USER_DATA_START      27

#define RTL8019_HEADER_SIZE  2 
#define ETH_HEADER_SIZE      7
#define IP_HEADER_SIZE       10
#define TCP_HEADER_SIZE      10
#define UDP_HEADER_SIZE      4
#define ARP_FRAME_SIZE       14
#define ICMP_HEADER_SIZE     2
#define DUMMY_HEADER_SIZE    6
#define MY_MAX_SEG_SIZE      1460

#define Frame_ARP            0x0806
#define Frame_IP             0x0800
#define Ip_Edition           0x4500              //Ip 版本和IP首部长度
#define DEFUALT_TTL          128
#define ICMP_ECHO            8
#define ICMP_ECHO_REPLY      0
//ARP

#define HARDW_ETH            1
#define IP_HLEN_PLEN         0x0604
#define OP_ARP_REQUEST       1
#define OP_ARP_ANSWER        2

#define PROTOCOL_ICMP        1
#define PROTOCOL_TCP         6
#define PROTOCOL_UDP         17

/////TCP define

#define TCP_MAX_RE_TXDNUM    8

#define TCP_CODE_FIN         0x0001
#define TCP_CODE_SYN         0x0002
#define TCP_CODE_RST         0x0004
#define TCP_CODE_PSH         0x0008
#define TCP_CODE_ACK         0x0010
#define TCP_CODE_URG         0x0020

#define 	TCP_STATE_LISTEN        0
#define 	TCP_STATE_SYN_RCVD      1
#define 	TCP_STATE_SYN_SENT      2
#define 	TCP_STATE_ESTABLISHED   3
#define 	TCP_STATE_FIN_WAIT1     4
#define 	TCP_STATE_FIN_WAIT2     5
#define 	TCP_STATE_CLOSING       6
#define 	TCP_STATE_CLOSE_WAIT    7
#define 	TCP_STATE_LAST_ACK      8
#define 	TCP_STATE_CLOSED        9
#define 	TCP_STATE_TIME_WAIT     10
	
extern	void	SendFrame(Uint16	*buf,Uint16	len);
extern	Uint16	SwapWord(Uint16	data);

//prototypes

void TCP_Listen(void);
void TCP_Syn_Rec(void);
void TCP_Syn_Sent(void);
void TCP_Established(void);
void TCP_Close_Wait(void);
void TCP_Last_Ack(void);
void DoNetworkStuff(void);
void TCPActiveTxData(void);
void RTL8019ActiveOpen(void);
void Prepare_ICMP_Answer(void);
void Prepare_TCP_Frame(Uint16 TCPCode);
void CopyFrameFromBE(Uint16 Offset,Uint16 Size);
void ProcessEthBroadcastFrame(void);

//========================== end ==========================

⌨️ 快捷键说明

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