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

📄 2410test.c

📁 优龙的ARM9 FS2410开发板原码
💻 C
字号:
#include "def.h"
#include "2410addr.h"
#include "2410lib.h"
#include "2410slib.h"
#include "mmu.h"
#include "uart.h"
#include "timer.h"
#include "rtcapi.h"

/************************************************************/
extern U32 downloadAddress, downloadFileSize;
U8 USB_OR_UART_Download_OK = 0 ;

extern void UsbMain(void);
extern void comdownload(void);
extern void Lcd_Tft_240X320_Init( void ) ;
extern void Test_Lcd_Tft_240X320( void );
extern void SDI_test(void);
extern void PlayMusicTest(void);
extern void RecordTest(void);
extern void RtcTest(void);
extern void DmaTest(void);
extern void Test_IrDA_Tx(void);
extern void Touch_Screen_Init(void);
extern void Test_Adc(void) ;
extern void Uart2_Test( void ) ;
extern void BUZZER_PWM_Test( void ) ;
extern void Key_Scan_Test( void ) ;
extern void Test_Iic(void) ;
extern void  call_linux(U32 a0, U32 a1, U32 a2);

//======================================================
void HaltUndef(void)
{
    printf("Undefined instruction exception!!!\n");
    while(1);
}

void HaltSwi(void)
{
    printf("SWI exception!!!\n");
    while(1);
}

void HaltPabort(void)
{
    printf("Pabort exception!!!\n");
    while(1);
}

void HaltDabort(void)
{
    printf("Dabort exception!!!\n");
    while(1);
}

void Isr_Init(void)
{
    pISR_UNDEF  = (U32)HaltUndef;
    pISR_SWI    = (U32)HaltSwi;
    pISR_PABORT = (U32)HaltPabort;
    pISR_DABORT = (U32)HaltDabort;
    rINTMOD = 0x0;	  // All=IRQ mode
    rINTMSK = BIT_ALLMSK;	  // All interrupt is masked.        
}

void run_prog(void)
{
	call_linux(0, 193, downloadAddress);
}

void Temp_function() { puts("\nPlease input 1-14 to select test!!!\n"); }

struct {
	void (*fun)(void);
	char *tip;
}CmdTip[] = {
				{ Temp_function, "Please input 1-14 to select test"},
				//{ UsbMain, "Download file from PC via USB port"},
				//{ comdownload, "Download file from PC via COM port"},
				{ RTC_Display, "Real time clock display" },
				{ Key_Scan_Test, "8*2 key array test"},
				{ BUZZER_PWM_Test, "Buzzer test"},
				{ Test_Adc, "ADC test" },
				{ Test_Iic, "IIC EEPROM test" },
				{ Touch_Screen_Init, "Touchpanel test" },
				{ Test_Lcd_Tft_240X320, "3.5# TFT LCD 240*320 test"},
				{ PlayMusicTest, "UDA1341 play audio test"},
				{ RecordTest, "UDA1341 record audio test"},
				{ Test_IrDA_Tx, "IRDA test"},
				{ SDI_test, "SD Card write and read test"},
				{ Uart2_Test, "COM port ( UART2 ) test"},
				{ 0, 0}						
			};


static void Led1Flash(U32 i)
{	
	static cnt = 30;
	
	if(!--cnt) {
		ReleaseBiosTimerEvent(i);
//		ChangeSlowMode(CLKSLOW_PLL_ON);		
//		Uart_Init(0, UART_BAUD);
	}
	rGPFDAT ^= 0x80;
}
static void Led2Flash(U32 i)
{	
	rGPFDAT ^= 0x40;	
}
static void Led3Flash(U32 i)
{	
	rGPFDAT ^= 0x20;	
}
static void Led4Flash(U32 i)
{		
	rGPFDAT ^= 0x10;	
}

/************************************************************/
void KeyScanInit(void);

int Main()
{
	int i;	
	
#if 0			//bank0 modified to RO_START  
    MMU_Init();	//MMU should be reconfigured or turned off for the debugger, 
    //After downloading, MMU should be turned off for the MMU based program,such as WinCE.	
#else
    MMU_EnableICache();      
#endif	
	
//	ChangeClockDivider(1, 1);    // 1:2:4        
//	ChangeMPllValue(192, 4, 1);    //FCLK=180.0Mhz                  
	SetClockDivider(1, 1);
	SetSysFclk(DFT_FCLK_VAL);
	Delay( 0 ) ;
    
	Port_Init();
	Isr_Init();
	
	Uart_Select(0);
	Uart_Init(0, UART_BAUD);
	
	RequestBiosTimerEvent(10, Led1Flash);	//when request, auto open bios timer
	RequestBiosTimerEvent(20, Led2Flash);
	RequestBiosTimerEvent(50, Led3Flash);
	RequestBiosTimerEvent(100, Led4Flash);
		
	//GPIO,UART0,PWM TIMER,NAND FLASH
//	DisableModuleClock(CLOCK_ALL);
	EnableModuleClock(CLOCK_UART0|CLOCK_TIMER|CLOCK_GPIO|CLOCK_NAND|CLOCK_LCD);

	Lcd_Tft_240X320_Init();
	Beep( 2000, 2000 ) ;

	putch('\n');
	puts("***********************************\n");
	puts("*                                 *\n");
	puts("*    FS2410 board demo program    *\n");
	puts("*    Version: 2.1   2005/06/21    *\n");
	puts("*     Http://www.uCdragon.com     *\n");
	puts("*                                 *\n");	
	puts("***********************************\n");

	RTC_Time_Set() ;
	
	{	
		U16 year ;
		U8 month, day ;		// week
		U8 hour, minute, second ;

		rRTCCON = 1 ;		//RTC read and write enable

		year = 0x2000+rBCDYEAR  ;		//年
	    month = rBCDMON  ;		//月
	    day = rBCDDATE  ;		//日	
//		week = rBCDDAY  ;		//星期
		hour = rBCDHOUR  ;		//小时
	    minute = rBCDMIN  ;		//分
	    second = rBCDSEC  ;		//秒
		
		rRTCCON &= ~1 ;		//RTC read and write disable

	    Uart_Printf( "RTC time : %04x-%02x-%02x %02x:%02x:%02x\n", year, month, day, hour, minute, second );
	}
	
	while(1)
	{
		U8 idx=0;
	
		puts("\nPlease select function : \n");	
		for(i=0; CmdTip[i].fun!=0; i++)
			printf("%2d : %s\n", i, CmdTip[i].tip);
		idx = Uart_GetIntNum_GJ() ;
		//idx=getch();
		//idx-='0';	
		if(idx<i)
		{
			(*CmdTip[idx].fun)();
//			ChangeMPllValue(192, 4, 1);    //FCLK=180.0Mhz
			//Delay(2000);
			//SetSysFclk(DFT_FCLK_VAL);			
			//Uart_Init(0, UART_BAUD);
		}	
	}	  	
	
	while(1)
	{
		Led_Display(0xf);
		Delay(10000);
		Led_Display(0);
		Delay(10000);
		putch('@');
	}
	
	return 0;
}

⌨️ 快捷键说明

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