📄 main.c
字号:
#include <string.h>
#include "..\inc\option.h"
#include "..\inc\def.h"
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\flash.h"
#include "..\inc\download.h"
#include "..\inc\usb.h"
#include "..\inc\cache.h"
#include "..\inc\lcd.h"
#include "..\inc\ata.h"
#include <stdio.h>
//following is CPU test functions include
#include "..\inc\cputest\adc.h"
#include "..\inc\cputest\etc.h"
#include "..\inc\cputest\dma.h"
#include "..\inc\cputest\eint.h"
#include "..\inc\cputest\extdma.h"
#include "..\inc\cputest\idle.h"
#include "..\inc\cputest\iic.h"
#include "..\inc\cputest\iis.h"
#include "..\inc\cputest\nwait.h"
#include "..\inc\cputest\power.h"
#include "..\inc\cputest\rtc.h"
#include "..\inc\cputest\sio.h"
#include "..\inc\cputest\stop.h"
#include "..\inc\cputest\timer.h"
#include "..\inc\cputest\uart.h"
#include "..\inc\usb\def9603.h"
//*******************************
volatile unsigned int err=0;
extern unsigned char *downPt;
extern unsigned int fileSize;
void Isr_Init(void);
void __irq Uerror(void);
extern int Image$$RO$$Limit;
extern int Image$$RW$$Base;
//////////////////////////////////////////////
// S3C44BOX(ARM7 TDMI Core) 开发板演示工具 //
// 日期:2001 May //
// 作者:戎海峰 Crazy Seadragon //
// Email:hardmcu@263.net //
// 版本:0.99 //
// 系统配置: //
// Bank0:System Monitor(SST29EE010) //
// Bank1:扩展内存空间 //
// Bank2:16MB Nand-Flash(KM29U128) //
// Bank3:USB(USBN9603) //
// Bank4:IDE //
// Bank5~6:保留 //
// Bank7:8MB SDRAM //
///////////////////////////////////////////////
//Please use "Courier New" font when you open it with UE//
static void (*run)(void)=(void (*)(void))DOWNLOAD_ADDRESS;
void * function[][2]=
{
(void *)Test_SLIdleMode, "SL_IDLE Mode ",
(void *)Test_SLIdleMode20, "SL_IDLE Mode20 ",
(void *)Test_IdleMode, "IDLE Mode ",
(void *)Test_IdleModeHard, "IDLE(hard) ",
(void *)Test_WaitPin, "nWAIT pin ",
(void *)Test_ZDma0Xdreq, "nXDREQ0 ",
(void *)Test_Adc, "Adc 0,1,2,3 ",
(void *)Test_DMA_Adc, "Adc with DMA ",
(void *)Test_Uart0, "UART 0 ",
(void *)Test_Uart0Fifo, "UART 0 FIFO ",
(void *)Test_Uart1, "UART 1 ",
(void *)Test_Uart1Fifo, "UART 1 FIFO ",
(void *)Test_SlowMode, "SLOW Mode ",
(void *)Test_HoldMode, "HOLD Mode ",
(void *)Test_StopMode, "STOP Mode ",
(void *)Test_Zdma0, "Zdma0 ",
(void *)Test_Zdma1, "Zdma1 ",
(void *)Test_Sio, "SIO Tx/Rx ",
(void *)Test_SIOTX_BDMA0, "SIO Tx BDMA0 ",
(void *)Test_SIORX_BDMA1, "SIO Rx BDMA1 ",
(void *)Test_WDTimer, "WDTimer ",
(void *)Display_Rtc, "RTC(display) ",
(void *)Test_Rtc_Alarm, "RTC(Test) ",
(void *)Test_Rtc_Tick, "RTC Tick ",
(void *)Test_Iic, "IIC(AT24LCxx) ",
(void *)Test_Iis, "IIS(uda1341) ",
(void *)Iis_Tx, "IIS Tx(Slave) ",
(void *)Iis_Rx, "IIS Rx(Master) ",
(void *)Test_TimerInt, "Timer Int ",
(void *)Test_Timer, "Tout test ",
(void *)Test_Eint, "Ext. Int ",
(void *)Etc, "Etc... ",
(void *)Test_UartAFC_Tx, "Test AFC(Tx) ",
(void *)Test_UartAFC_Rx, "Test AFC(Rx) ",
0,0
};
void Main(void)
{
unsigned int SerialNo;
/*SerialNo=0x104A7F=1067647=123802+943845*/
unsigned int SerialNo1=123802;
unsigned int SerialNo2=943845;
int i,j,memError=0;
char aa;
rSYSCFG=CACHECFG; // Using 8KB Cache//
Port_Init();
Isr_Init();
Uart_Init(0,115200);
Led_Display(0xf);
Delay(0);
downPt=(unsigned char *)DOWNLOAD_ADDRESS;
/*******************************/
/* Cache test */
/*******************************/
if(Test_Cache())
Uart_Printf("\nCache Test:OK!");
else
Uart_Printf("\nCache Test:FAIL!");
/* Uart_Printf("\nMemory Test(%xh-%xh):WR",_RAM_STARTADDRESS,(_ISR_STARTADDRESS&0xfff0000));
for(i=_RAM_STARTADDRESS;i<(0x0c400000);i+=4)
{
*((volatile unsigned *)i)=i;
}
Uart_Printf("\b\bRD");
for(i=_RAM_STARTADDRESS;i<(0x0c400000);i+=4)
{
j=*((volatile unsigned *)i);
if(j!=i)
memError=1;
}*/
Beep(0x1);
if(memError==0)
Uart_Printf("\b\bO.K.\n");
else
Uart_Printf("\b\bFAIL\n");
Flash_Reset();
if(Check_Flash_Id()==KM29U128_ID)
{
Uart_Printf("\nKM29U128T is found.");
LOAD_HZK();
}
else
{
Uart_Printf("\nKM29U128T is not found.");
}
Beep(0x0);
Uart_Select(0); //Select UART0//
SerialNo=SerialNo1+SerialNo2;
Uart_Printf("\n*************************************************************************");
Uart_Printf("\n* Hard & Soft Mcu Studio *");
Uart_Printf("\n* SamArmDvkVer2 Boot Rom Date:May.2001 *");
Uart_Printf("\n* Crazy Seadragon and Cowboy Version 2.00 *");
Uart_Printf("\n* Email:hardmcu@263.net ; softmcu@263.net *");
Uart_Printf("\n* SerialNo:0x%8x *");
Uart_Printf("\n* COM:115.2kbps,8Bit,NP,UART0 *");
Uart_Printf("\n RO_Limit=0x%8x",Image$$RO$$Limit);
Uart_Printf("\n RW_BASE =0x%8x",Image$$RW$$Base);
Uart_Printf("\n*-----------------------------------------------------------------------*");
Uart_Printf("\n*----------------Use USB? (Y/N)-----------------------------------------*");
Led_Display(0x0);
aa= Uart_Getch();
if((aa=='Y')||(aa=='y'))
init_usb();
else
Uart_Printf("\n USB is inactive!");
while(1)
{
Uart_Printf("\n* You had selected Monitor Tools *");
Uart_Printf("\n* F(f)>>Flash Rom Tools *");
Uart_Printf("\n* R(r)>>Run USB Download Code *");
Uart_Printf("\n* L(l)>>LCD routine *");
Uart_Printf("\n* A(a)>>ATA routine *");
Uart_Printf("\n* 1 >>Run Demo1.bin *");
Uart_Printf("\n* 2 >>Run Demo2.bin *");
Uart_Printf("\n* 3 >>Run Demo3.bin *");
Uart_Printf("\n* C(c)>>CPU Functions Test *");
Uart_Printf("\n*-----------------------------------------------------------------------*");
aa= Uart_Getch();
switch(aa)
{
case 'a':
case 'A':
ATA_Test();
case 'f':
case 'F':
Flash_Tools();
break;
case 'r':
case 'R':
/*对USBN9603进行一次软件复位*/
write_usb(MCNTRL,SRST); /*写 0x01 到 MCNTRL*/
/*INTOC(1-0)=00 :禁止中断输出 */
/*NAT=0 :禁止被USB总线检测 */
/*VEG=0 :禁止内部3.3V稳压 */
/*SRST=1 :进行软件复位 */
Delay(30000);//it should be delay a long time for pc software stable
run();
break;
case 'l':
case 'L':
Uart_Printf("\nPlease look at LCD.");
LCD_Init();
CLS();
LCD_Printf(1,"Hello.");
LCD_Printf(2,"This is EricRong");
LCD_Printf(3," and Cowboy.");
LCD_Printf(4,"Please wait.....");
LCD_Printf(5, "Then show U BMP");
Delay(35000);
Show_BMP(Welcome_BMP);
break;
case '1':
LOAD_DEMO1_CODE();
break;
case '2':
LOAD_DEMO2_CODE();
break;
case '3':
LOAD_DEMO3_CODE();
break;
case 'c':
case 'C':
Uart_Printf("\nWhen you use this test tool,usb interface will be invalid!");
/*对USBN9603进行一次软件复位*/
write_usb(MCNTRL,SRST); /*写 0x01 到 MCNTRL*/
/*INTOC(1-0)=00 :禁止中断输出 */
/*NAT=0 :禁止被USB总线检测 */
/*VEG=0 :禁止内部3.3V稳压 */
/*SRST=1 :进行软件复位 */
Delay(30000);//it should be delay a long time for pc software stable
//CPU Functions test
while(1)
{
i=0;
Uart_Printf("\n\nSamArmDvkVer2's CPU Test Program. rSYSCFG=0x%x MCLK=%d\n\n",rSYSCFG,MCLK);
while(1)
{ //display menu
Uart_Printf("%2d:%s",i,function[i][1]);
i++;
if((int)(function[i][0])==0)
{
Uart_Printf("\n");
break;
}
if((i%4)==0)
Uart_Printf("\n");
}
Uart_Printf("\nSelect the function to test?");
i=Uart_GetIntNum();
Uart_Printf("\n");
if(i>=0 && (i<(sizeof(function)/8)) )
( (void (*)(void)) (function[i][0]) )();
}
break;
}
}
}
void Isr_Init(void)
{
rINTCON=0x5; //Non-vectored,IRQ enable,FIQ disable //
rINTMOD=0x0; //All=IRQ mode//
rINTMSK=~(BIT_EINT0 | BIT_GLOBAL); //Default value=0x7ffffff//
//pISR_FIQ,pISR_IRQ must be initialized//
pISR_EINT0=(unsigned)usb_isr;
}
void __irq Uerror(void)
{
rI_ISPC=BIT_UERR01 ; //clear pending bits,Default value=0x0000000//
err++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -