📄 401test.c
字号:
#include <string.h>
#include "..\include\option.h"
#include "..\include\k401.h"
#include "..\include\k401lib.h"
#include "..\include\def.h"
#include "..\include\adc.h"
#include "..\include\cache.h"
#include "..\include\dma.h"
#include "..\include\rtc.h"
#include "..\include\power.h"
#include "..\include\timer.h"
#include "..\include\sio.h"
#include "..\include\memory.h"
#include "..\include\extra.h"
#include "..\include\flash.h"
#include "..\include\uart.h"
void AutoTest(void);
void Isr_Init(void);
void HaltUndef(void);
void HaltSwi(void);
void HaltPabort(void);
void HaltDabort(void);
/***************************************************************
* KS17C40100 developer's notes *
***************************************************************
***************************************************************/
void *function[][2]=
{
(void *)Test_Adc, "ADC [7:0] ",
(void *)Test_Cache, "Cache ",
(void *)Test_ISRAM, "ISRAM Test ",
(void *)Test_DMA, "DMA Test ",
(void *)Test_ExtDMA, "Ext. DMA Test ",
(void *)Test_Rtc, "RTC Test ",
(void *)Display_Rtc, "Display RTC ",
(void *)Test_RtcAlarm, "Alarm Int Test ",
(void *)Test_StopMode, "Stop Mode Test ",
(void *)Test_IdleMode, "Idle Mode Test ",
(void *)Test_Timer, "Timer Test ",
(void *)Test_Sio, "SIO Test ",
(void *)Test_SIO0_DMA_Tx, "SIO Tx DMA Test ",
(void *)Test_SIO0_DMA_Rx, "SIO Rx DMA Test ",
(void *)Test_Sram, "SRAM Test ",
(void *)Test_Sdram, "SDRAM Test ",
(void *)Test_Extra, "Extra Dev. Test ",
(void *)Test_LCD, "LCD Test ",
(void *)ProgramFlash, "Programing Flash ",
(void *)Test_UartFifo, "Uart FIFO Test ",
0,0
};
void Main(void)
{
int i;
Isr_Init();
Uart_Init(115200);
Delay(0); //calibrate Delay()
rPCON7|=0x1;
rPDAT7=0x1;
while(1)
{
i=0;
Uart_Printf("\n\nKS17C40100 Test Program Ver 0.0 rSYSCFG=%x MCLK=%d rSYSCON=%x\n",rSYSCFG,MCLK,rSYSCON);
Uart_Printf("=============================================================================\n");
while(1)
{ //display menu
Uart_Printf("%c: %s",'a'+i,function[i][1]);
i++;
if((int)(function[i][0])==0){Uart_Printf("\n");break;}
if((i%4)==0)Uart_Printf("\n");
}
Uart_Printf("=============================================================================\n");
Uart_Printf("Select the function to test?");
i=Uart_Getch()-'a';
Uart_Printf(" : %c\n",'a'+i);
if(i>=0 && (i<(sizeof(function)/8)) )
( (void (*)(void)) (function[i][0]) )();
}
}
/*void AutoTest(void)
{
int i=0;
int error=0;
void *testFunction[][3]=
{
(void *)Test_Lcd, "LCD ",0,
0,0,0
};
for(i=0;testFunction[i][0]!=0;i++)
{
testFunction[i][2]=(void *) ( ( (int (*)(void)) (testFunction[i][0]) )() );
Uart_Printf("==============================================================\n");
}
for(i=0;testFunction[i][0]!=0;i++)
{
if(testFunction[i][2]==0)
{Uart_Printf("%s is out of order!!!\n",testFunction[i][1]);error++;}
else
Uart_Printf("%s is O.K.\n",(char *)testFunction[i][1]);
}
}*/
void Isr_Init(void)
{
pISR_UNDEF=(unsigned)HaltUndef;
pISR_SWI =(unsigned)HaltSwi;
pISR_PABORT=(unsigned)HaltPabort;
pISR_DABORT=(unsigned)HaltDabort;
rINTMOD=0x0; // All=IRQ mode
rSYSCON=(rSYSCON & (~ BIT_GLOBAL)); // Grobal interrupt is masked.
}
void HaltUndef(void){
Uart_Printf("Undefined instruction exception!!!\n");
while(1);
}
void HaltSwi(void){
Uart_Printf("SWI exception!!!\n");
while(1);
}
void HaltPabort(void){
Uart_Printf("Pabort exception!!!\n");
while(1);
}
void HaltDabort(void){
Uart_Printf("Dabort exception!!!\n");
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -