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

📄 main.c

📁 arm7s3c44b0x0里ps2口和lcd口驱动编程实例
💻 C
字号:
/*=========================================================================*/
/*		Project:		Teaching Box									   */
/*		Version:    	1.0												   */
/*      Date From:      10,Dec,2005										   */
/*		Description:	The software based on ARM7 is for 				   */
/*						teaching box of arc welding robot				   */
/*		Author:         LSG												   */
/*=========================================================================*/

/*=========================================================================*/
/*      Include the .h files											   */
/*=========================================================================*/
#include "\inc\define.h"
#include "\inc\drives.h"
#include "\inc\extint.h"
#include "\inc\sysinit.h"
#include "\inc\timerinit.h"
#include "\inc\NandFlashInit.h"
#include "\inc\TBlib.h"

extern OSTimeDly_sys;
extern OSTimeDly_user[6];


/*=========================================================================*/
/*    				The main function of system							   */
/*=========================================================================*/
void Main(void)
{
    int i = 0;    
    TIME_STRUC Time2Set, Time2Alarm, TimeCurrent;
    unsigned char ReadBuffer[528], WriteBuffer[528];     
    unsigned int ID=0x0;
	DisableInt();	           //Disable interrupt	
	
	BoardInitStart();	
	SystemClockInit();
	TimerInit(TIMER_FREQ);
    MemCfgInit();
	PortInit();
	SerialChgBaud(115200);	
	ISRInit();
	BoardInitEnd();		

	CacheFlush();
	CacheEnable();	
	
	LedSet(0xf);
	Beep(2000, 100);	
	puts("\n----------------------------------------------------------------");				
	puts("\n                  焊接机器人ARM示教盒开发中...                  ");
	puts("\n                   Powered by LSG & ZFS                         ");
	puts("\n                  Start on 08, Dec, 2005                        ");
	puts("\n----------------------------------------------------------------");			
	LedSet(0x0);		
	
	rPDATE = 0x0f;
	
	
	/*================================================*/
	//Test the Nand Flash
	/*================================================*/
	puts("\n开始NandFlash测试\n");
	for(i=0; i<528; i++)
	{
		WriteBuffer[i] = i%256;		
		ReadBuffer[i] = i%256 + 10;
	}
	rPDATE = 0xff;
	NandInit();	
	if((ID = NandReadID()) != 0x0)
	{	
		Uart_Printf("\nID Number is:0x%x   Read Nand Flash ID Finished\n", ID);		
	}
	else
	{
		puts("\nReand Nand Flash ID Failure");
	}
	if(NandEraseBlock(1000))
	{
		puts("\nErase Finished");
	}
	else
	{
		puts("\nErase Failure");
	}
	if(NandWritePage(1000, 0, WriteBuffer))
	{
		puts("\nWrite Finished");
	}
	else
	{
		puts("\nWrite Failure");		
	}
	if(NandReadPage(1000,0,ReadBuffer))
	{
		puts("\nRead Finished\n");		
	}
	else
	{
		puts("\nReadFailure\n");
	}
	for(i=0; i<256; i++)
	{
		Uart_Printf("%d ", WriteBuffer[i]);		
		Uart_Printf("%d ", ReadBuffer[i]);		
		if(ReadBuffer[i] == WriteBuffer[i])
		{			
			puts("ok\n");
		}
		Delay(50);
	}
	puts("\nNand Flash测试完毕\n");	
	
	
	/*============================================*/
	//Test the Interrupt
	/*============================================*/
	puts("\n开始中断测试");
	IntInit();
	Timer0Init();
	Timer1Init();
	Timer2Init();
	Timer3Init();
	Timer4Init();
	Timer5Init();
		
	Time2Set.year = 0x2005;
	Time2Set.month = 0x12;
	Time2Set.day = 0x14;
	Time2Set.weekday = 0x03;
	Time2Set.hour = 0x19;
	Time2Set.min = 0x50;
	Time2Set.sec = 0x30;
	
	Time2Alarm.year = 0x2005;
	Time2Alarm.month = 0x12;
	Time2Alarm.day = 0x14;
	Time2Alarm.weekday = 0x03;
	Time2Alarm.hour = 0x19;
	Time2Alarm.min = 0x50;
	Time2Alarm.sec = 0x40;
	
	RTCInit(Time2Set, Time2Alarm);			
	
	ExtIntInit();
	EnableInt();
	    
	while(1)
	{		 
		if(OSTimeDly_user[0] >= 10)
		{
		    OSTimeDly_user[0] = 0;
			rPDATE ^= SETBIT7;	
		}  	
		if(OSTimeDly_user[1] >= 10)
		{
		    OSTimeDly_user[1] = 0;
			rPDATE ^= SETBIT6;	
		}  	
		if(OSTimeDly_user[2] >= 4)
		{
		    OSTimeDly_user[2] = 0;
			rPDATE ^= SETBIT5;	
		}  	
		if(OSTimeDly_user[3] >= 4)
		{
			rPDATE ^= SETBIT3;	
		    OSTimeDly_user[3] = 0;		     
		    rPDATE ^= SETBIT3;				
		}  	
		if(OSTimeDly_user[4] >= 2)
		{
		    OSTimeDly_user[4] = 0;
			rPDATE ^= SETBIT4;	
		}  	
		if(OSTimeDly_user[5] >= 100)
		{
		    OSTimeDly_user[5] = 0;
		    TimeCurrent = RTCRead();
		    //puts(TimeStruct.sec);
			puts("a second\n");	
		}  			
			
		ExtIntRpt();
		if(OSTimeDly_sys >= 6000)			
		{
			DisableInt();
			puts("\n中断测试完毕");
			break;
		}
		
   }
   
   /*============================================================*/
}

⌨️ 快捷键说明

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