📄 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;
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!");
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.");
}
else
{
Uart_Printf("\nKM29U128T is not found.");
}
Beep(0x0);
Uart_Select(0); //Select UART0//
SerialNo=SerialNo1+SerialNo2;
{
long j;
rINTMSK=~BIT_GLOBAL;
rNCACHBE0=( (0x2000000>>12)<<16 )|(0>>12); //flash area must be non-cachable area.
rSYSCFG=rSYSCFG&(~0x8); //write buffer has to be off for proper timing.
ProgramSST39LF160();
for(;;);
}
}
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//
}
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 + -