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

📄 main.c

📁 ADC图形图像例子
💻 C
字号:
/********************************************************************
 * File: MAIN.c
 * 
 * Copyright: Peak Microtech Corporation
 *
 *******************************************************************/


#include "net_cfg.h"


void Logo(void)
{
	UartPrintfCh1("\r\n");
	UartPrintfCh1("\r\n***************************************");
	UartPrintfCh1("\r\n  Welcome to Amazon V4 Board !");
	UartPrintfCh1("\r\n***************************************\r\n");
	UartPrintfCh1("\r\n  Net 8019 Driver !");
	UartPrintfCh1("\r\n***************************************\r\n");
}


int main()
{
	U8 i;

	// initialize for DebugPrintf
	UartConfigCh1(DATABIT8, BPS115200);

	Logo();

	// Set PCS4# as 16bit bus	
	writel(REG_CS3CON, 0x0884);

	// Net reset
	NetReset();

	// Set IP address,Geteway IP address, Mask IP Address
	My_Ip_Address.dwords = IP_SETTING; 
	Gateway_Ip_Address.dwords = GATEWAY_SETTING; 
	Mask_Ip_Address.dwords = IP_MARK_SETTING; //255.255.255.0	

	// Initialize system
	initial_system();

	// Display some IP address
	UartPrintfCh1("\r\nLocalHost IP = ");
	Printf_IPStr(My_Ip_Address);
	UartPrintfCh1("\r\nGateWay IP = ");
	Printf_IPStr(Gateway_Ip_Address);
	UartPrintfCh1("\r\nSubNet Mask= ");
	Printf_IPStr(Mask_Ip_Address);
	UartPrintfCh1("\r\n");

	while (1)
	{
		// Deal with TCP tiemout
		// if(Tcp_Timeout)Process_Tcp_Timeout();	

		// command inputing
		if (UartIsRxCh1() == TRUE)
		{
			// Get input command to Command_Buf
			UartRxStringCh1(Command_Buf);
			Command_Len = strlen(Command_Buf);
			if (Command_Len > 0)
			{
				Command_Len--;
			}
			else
			{
				Command_Len = 0;
			}
			process_command();
			Process_Ping();
			Process_Udp_Command(); 
			// Gateway_Arp_Request();	// Parse getaway
		}

		// 2s call once (Interrup control)
		if (BiSecond)
		{
			BiSecond = 0;
			// if(TCP1024.State==0)	
			// 		process_command();	
			Process_Ping();
			Process_Udp_Command(); //
			// Gateway_Arp_Request();	// Parse getaway
		}

		for (i = 0; i < 5; i++)
		{	
			// Check if recive new packet
			if (Rec_NewPacket())
			{				
				if (RxdNetBuff.EtherFrame.NextProtocal == 0x0608)
				// 0x0608 ARP protocol ID
				{
					if (RxdNetBuff.ArpFrame.Operation == 0x0100)
					// 0x0100: recive a arp request
					{
						Arp_Answer();
					} 
					else if (RxdNetBuff.ArpFrame.Operation == 0x0200)
					// 0x0200: recive a arp answer
					{
						Arp_Process();
					} 
				}
				else if (RxdNetBuff.EtherFrame.NextProtocal == 0x0008)
				//IP protocol ID
					if ((RxdNetBuff.IpFrame.VerandIphLen &0xf0) == 0x40)	// IP V4			
						if (VerifyIpHeadCrc())	// Check IP header CRC				
				{					
					switch (RxdNetBuff.IpFrame.NextProtocal)
					{
						case 1:
							// ICMP type
							if (RxdNetBuff.IcmpFrame.type == 8)
							// type==8: recive a ping request
							{
								Ping_Answer();
							}							
							else if (RxdNetBuff.IcmpFrame.type == 0)
							// tpye==0: recive a ping answer
							{
								Ping_Echo();
							}							
							break;
						case 6:
							// 6: TCP type
							// Process_Tcp();		// Don't support TCP
							break;
						case 0x11:
							// 0x11: udp type
							Process_Udp();
							break;
						default:
							;
					}
				}
			}
		}
	}
	return 0;
}

⌨️ 快捷键说明

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