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

📄 main.c

📁 运行于嵌入式系统的uCLinux的bios源码
💻 C
字号:
/*
;************************************************************************************************************
;*				        				北京精仪达盛科技有限公司
;*                                     	     研    发    部
;*
;*                                 	     http://www.techshine.com
;*
;*--------------------------------------------- 文件信息 ----------------------------------------------------                                      
;*
;* 文件名称 : Main.c	
;* 文件功能 : 该文件为S3C44B0硬件平台的主函数。
;* 补充说明 : 
;*-------------------------------------------- 最新版本信息 -------------------------------------------------
;* 修改作者 : ARM7开发小组
;* 修改日期 : 2004/04/25
;* 版本声明 : V1.0.1
;*-------------------------------------------- 历史版本信息 -------------------------------------------------
;* 文件作者 : ARM7开发小组
;* 创建日期 : 2004/04/20
;* 版本声明 : v1.0.0
;*-----------------------------------------------------------------------------------------------------------
;*-----------------------------------------------------------------------------------------------------------
;************************************************************************************************************
;*/

#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include "../inc/option.h"
#include "../inc/44b.h"
#include "../inc/44blib.h"
#include "../inc/def.h"
#include "../inc/rtc.h"
#include "../net/armnet.h"
#include "../inc/shell.h"
#include "../inc/flash.h"

volatile char which_int=0;
unsigned char default_mac[MACLEN] = {0x12,0x34,0x56,0x78,0x90,0xab};
NODE locnode;
unsigned int SERIAL_BAUD = 115200;
ETHERFRAME etherframe;
TIME_STRUC SysTime;
unsigned int IP_ADDRESS;
unsigned int download_addr;
unsigned int download_begin;
unsigned int download_end;
unsigned int download_len;
/*
*************************************************************************************************************
- 函数名称 : void NetSever(void)
- 函数说明 : 网络服务函数
- 输入参数 : 无
- 输出参数 : 无
*************************************************************************************************************
*/
void NetSever(void)
{	
	unsigned short rxlen,ip_len;
	unsigned char net_isr;
	ARPKT *arp;
	ETHERFRAME *efp;
	IPKT *ip;
	efp = &etherframe;

	net_isr = EN_ISR;
	
	if(net_isr & ENISR_RX)
	{
		DEBUGF(DEMO_DEBUG,("Rtl8019 Interrupted RX\n"));
		EN_ISR |= ENISR_RX;

		memset((unsigned char *)efp, 0, sizeof(ETHERFRAME));
		rxlen = GetEthernet(efp);
		SwapEther(efp);
		
		if(IsArp(efp, rxlen))
		{
			arp = (ARPKT *)(efp->edata);
			if(READ_PACKED(arp->dip)==locnode.ip &&(arp->op==ARPREQ || arp->op==ARPRESP))
			{
				DEBUGF(ARP_DEBUG,("Get ARP\n"));
				ArpRcvPacket(efp);
			}
		}
		else
		{
			ip_len = IsIp(efp, rxlen);
			if(ip_len)
			{
				ip = (IPKT *)(efp->edata);
				DEBUGF(DEMO_DEBUG,("Get IP\n"));
				if(IsIcmp(ip, ip_len))
				{
					DEBUGF(ICMP_DEBUG,("Get ICMP\n"));
					IcmpRcvPacket(efp);
				}
				else if(IsUdp(ip, ip_len))
				{
					DEBUGF(DEMO_DEBUG,("Get UDP\n"));
					UdpRcvPacket(efp);
				}
			}
		}
	}
	
	if(net_isr & ENISR_RX_ERR)
	{
		DEBUGF(DEMO_DEBUG,("Rtl8019 Interrupted RX_ERR\n"));
		EN_ISR |= ENISR_RX_ERR;
	}
	
	if(net_isr & ENISR_TX)
	{
		DEBUGF(DEMO_DEBUG,("Rtl8019 Interrupted TX\n"));
		EN_ISR |= ENISR_TX;
	}
	
	if(net_isr & ENISR_TX_ERR)
	{
		DEBUGF(DEMO_DEBUG,("Rtl8019 Interrupted TX_ERR\n"));
		EN_ISR |= ENISR_TX_ERR;
	}		
}
/*
*************************************************************************************************************
- 函数名称 : void NodeInit(void)
- 函数说明 : 本开发板所使用的节点的初始化函数
- 输入参数 : 无
- 输出参数 : 无
*************************************************************************************************************
*/
void NodeInit(void)
{
	IP_ADDRESS = IP4_ADDR(192,168,0,100);
	locnode.ip = IP_ADDRESS;
	locnode.mask = IP4_ADDR(255,255,255,0);
	locnode.gate = IP4_ADDR(192,168,0,10);
	memcpy(locnode.mac,default_mac,6);
	locnode.port = 9000;
}
/*
*************************************************************************************************************
- 函数名称 : void NetIntPreInit(void)
- 函数说明 : RTL8019所使用的中断的初始化,使用中断3
- 输入参数 : 无
- 输出参数 : 无
*************************************************************************************************************
*/
void NetIntPreInit(void)
{
	rPCONG = rPCONG | 0x00c0;
	rPUPG = rPUPG & 0xf7;
	rEXTINT |= 0x4000;
}
/*
*************************************************************************************************************
- 函数名称 : void Main(void)
- 函数说明 : 主函数
- 输入参数 : 无
- 输出参数 : 无
*************************************************************************************************************
*/
void Main(void)
{	

    rSYSCFG=SYSCFG_8KB;															    	  //使用8K字节的指令缓存
	rNCACHBE0=((unsigned int)(Non_Cache_End>>12)<<16)|(Non_Cache_Start>>12); 
    																			  //在上面的数据区域不使用高速缓存

	Port_Init();		//IO端口功能、方向设定
	rPDATE=rPDATE|0x10;
	ChangePllValue(52,2,1);		
	Uart_Init(0,SERIAL_BAUD);		//异步串行口初始化,设置波特率为115200
	Delay(0);
	NodeInit();
	NetIntPreInit();
	ArpInit();	
	Uart_Printf("\n\n");
	Uart_Printf("*******************************\n");
	Uart_Printf("欢迎您使用北京精仪达盛的ARMII实验系统\n");
	Uart_Printf("该实验系统的IP地址是:IP: %u.%u.%u.%u\n", (IP_ADDRESS>>24)&0xff, (IP_ADDRESS>>16)&0xff, (IP_ADDRESS>>8)&0xff, IP_ADDRESS&0xff);
	Uart_Printf("*******************************\n");
	Uart_Printf("\n");

	ShellIn();
}
/*
*************************************************************************************************************
*-                            				结束文件													   -*
*************************************************************************************************************
*/

⌨️ 快捷键说明

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