📄 2460test.cpp
字号:
#include <stdio.h>
#include <stdlib.h>
#include "2460addr.h"
#include "2460lib.h"
#include "2460slib.h"
#include "Console.h"
#include "mmu.h"
#include "PLL.h"
#include "DRAM.h"
#include "TeakDSP.h"
#include "BurdenTest.h"
#include "memtest.h"
#include "VFP9.h"
#include "dma.h"
#include "flash.h"
#include "am29f800.h"
#include "strata16.h"
#include "nand.h"
#include "LCD.h"
#include "LCDlib.h"
#include "Camif.h"
#include "IrDA.h"
#include "Post.h"
#include "IIC.h"
#include "Mobile_Demo.h"
#include "spi01.h"
#include "AC97.h"
#include "pcm.h"
#include "iis.h"
#include "keypad.h"
#include "sdi.h"
#include "mstick.h"
#include "RTC.h"
#include "watchdog.h"
#include "timer.h"
#include "eint.h"
#include "power.h"
#include "adcts.h"
#include "modemif.h"
#include "uart.h"
#include "cs8900.h"
#include "cd_rom.h"
#include "type.h"
void VFP9(void);
#ifdef __cplusplus
extern "C" {
#endif
void Dhry_Run(void);
#ifdef __cplusplus
}
#endif
#define mSDRAM 0
#define mDDR 1
uint8 WhichDRAM(void)
{
#if (WHICH_PORT==2)
if((rP2BANKCFG_DDR&(3<<21))==(1<<21))
return mSDRAM;
else if((rP2BANKCFG_DDR&(3<<21))==(3<<21))
return mDDR;
else
return 2;
#else //400 or 496PKG
if((rP1BANKCFG_DDR&(3<<21))==(1<<21))
return mSDRAM;
else if((rP1BANKCFG_DDR&(3<<21))==(3<<21))
return mDDR;
else
return 2;
#endif
}
#if 0 //khs(tmp.050825)
void DRAM_Test(void)
{
volatile uint32 *pt,data;
uint8 memory_type, memory_error=0;
printf("DRAM Test Start....\n\n");
/* mSDRAM mDDR */
MMU_SetMTT(0x10000000,0x10f00000,0x10000000,RW_CB); //SDRAM System Group S0-1
MMU_SetMTT(0x11000000,0x11e00000,0x11000000,RW_NCNB); //SDRAM System Group S0-2
MMU_SetMTT(0x11f00000,0x11f00000,0x11f00000,RW_CB); //SDRAM System Group S0-3
/* mSDRAM mDDR */
MMU_SetMTT(0x20000000,0x21f00000,0x20000000,RW_CB); //SDRAM Image Subsystem Group I0
memory_type = WhichDRAM();
while(Uart_GetKey()!='x')
{
if(memory_type==mSDRAM) ;
else if (memory_type==mDDR)
{
uint8 DQS_delay=0,DQS_set_type=0,i;
printf("\nEnter DQS delay value(0~7):");
DQS_delay = GetIntNum();
rP1BANKCON_DDR = (rP1BANKCON_DDR & ~(0xf00) | (DQS_delay<<8));
rP2BANKCON_DDR = (rP2BANKCON_DDR & ~(0xf00) | (DQS_delay<<8));
}
else
printf("else memory type(not mSDRAM/mDDR)\n\n");
printf("\nrP1BANKCFG_DDR = 0x%08x,\trP2BANKCFG_DDR = 0x%08x",rP1BANKCFG_DDR,rP2BANKCFG_DDR);
printf("\nrP1BANKCON_DDR = 0x%04x,\trP2BANKCON_DDR = 0x%04x\n\n",rP1BANKCON_DDR,rP2BANKCON_DDR);
Delay(100); //10ms delay
SetCLKDIV( Startup_ARMCLKdiv, Startup_HCLKdiv, Startup_PCLKdiv);
SetMPLL( 125, 4, 0); //266MHz
GlobalCLK();
ChangeSDRAMParameter(HCLK);
Init_LogicalConsole();
printf("\nMPLL=%.2fMHz, ARMCLK=%.2fMHz (%d:%d:%d), HCLK=%.2fMHz, PCLK=%.2fMHz\n\n",
(float)MPLL/1000000,(float)ARMCLK/1000000,ARMCLKdiv+1,(ARMCLKdiv+1)*(HCLKdiv+1),(ARMCLKdiv+1)*(HCLKdiv+1)*(PCLKdiv+1),(float)HCLK/1000000,(float)PCLK/1000000);
Delay(100); //10ms delay
/* pPort Test */
pt=(unsigned int *)((_ISR_STARTADDRESS&0xffff0000) + 0x10000);
printf("Memory Test(0x%08x-0x%08xh)\n",pt,0x10200000);
printf("Writing....\n");
TmpStartDmaMem2Mem();
while((uint32)pt<0x10200000)
{
*pt = (uint32)pt;
pt++;
}
printf("Reading....\n");
TmpStartDmaMem2Mem();
while((uint32)pt<0x10200000)
{
data = *pt;
if(data!=(unsigned int)pt)
{
printf("\b\bFAIL:0x%08x=0x%08x\n",pt,data);
memory_error = TRUE;
break;
}
pt++;
}
/* dPort Test */
pt=(unsigned int *)0x20000000;
printf("Memory Test(0x%08x-0x%08xh)\n",pt,0x20200000);
printf("Writing....\n");
TmpStartDmaMem2Mem();
while((uint32)pt<0x20200000)
{
*pt = (uint32)pt;
pt++;
}
printf("Reading....\n");
TmpStartDmaMem2Mem();
while((uint32)pt<0x20200000)
{
data = *pt;
if(data!=(unsigned int)pt)
{
printf("\b\bFAIL:0x%08x=0x%08x\n",pt,data);
memory_error = TRUE;
break;
}
pt++;
}
if(memory_error == FALSE)
printf("\n**Memory Test O.K.**\n\n");
}
return;
}
#endif
void *function[][2]=
{ //
#if 1
// "123456789012345678901"
(void *) VFP9, "VFP9 ",
(void *) TeakDSP, "Teak DSP ",
(void *) System_Burden_Test, "System burden Test ",
(void *) Mem_Test, "Memory Test ",
(void *) Ch9_DMA, "DMA ",
(void *) Ch3_Power_Test, "Power mode Test ",
(void *) Ch4_NAND_FLASH_CONTROLLER, "NAND FLASH ",
(void *) Ch6_INTERRUPT_CONTROLLER, "Interrupt Con. ",
(void *) Ch28_LCD, "LCD ",
(void *) Ch21_CAMERA, "Camera ",
(void *) Ch12_IrDA, "IrDA ",
(void *) Ch27_POST, "Post processor ",
(void *) Ch13_Iic_Test, "IIC ",
(void *) Ch22_mpeg4_test, "MPEG4 demo ",
(void *) ProgramFlash, "NOR Flash ",
(void *) Ch15_SPI, "spi test ",
(void *) Ch3_Pll_Test, "Pll test ",
(void *) AC97_Test, "AC97 ",
(void *) PCM_Test, "PCM ",
(void *) IIS_Test, "IIS ",
(void *) Ch33_KEYPAD, "Keypad test ",
(void *) Ch28_SD_MMC, "SD/MMC test ",
(void *) Ch29_MEMORY_STICK, "Memory stick ",
(void *) Ch12_RTC, "RTC timer ",
(void *) Ch11_WDT_Test, "Watch dog ",
(void *) Ch10_PwmTimer_test, "Timer test ",
(void *) Ch34_CS8900_Test, "CS8900 test ",
(void *) Ch30_ADC, "ADC&Touch Screen ",
(void *) Ch27_MODEM, "Modem test ",
(void *) Uart_Test, "UART ",
(void *) CD_ROM_Test, "CD-ROM test ",
#else //temp
(void *) Ch4_NAND_FLASH_CONTROLLER, "NAND FLASH ",
(void *) ProgramFlash, "NOR Flash ",
#endif
0,0
};
void Isr_Init(void)
{
pISR_UNDEF = (unsigned)HaltUndef;
pISR_SWI = (unsigned)HaltSwi;
pISR_PABORT = (unsigned)HaltPabort;
pISR_DABORT = (unsigned)HaltDabort;
pISR_IRQ = (unsigned)IsrIRQ;
rINTMOD = 0x0; //All=IRQ mode
rINTMSK = BIT_ALLMSK; //All interrupt is masked.
rINTSUBMSK = BIT_SUB_ALLMSK1; //All sub-interrupt is masked.
rINTSUBMSK2 = BIT_SUB_ALLMSK2; //All sub-interrupt is masked.
rEINTCON0 = 0x22222222; //EINT2~0
rEINTCON1 = 0x22222222; //EINT10~3
CLR_IF();
}
int main( void)
{
int i;
//To make margin
PreChangeSDRAMParameter();
#if 1 //original
SetCLKDIV( Startup_ARMCLKdiv, Startup_HCLKdiv, Startup_PCLKdiv);
SetMPLL( Startup_MDIV, Startup_PDIV, Startup_SDIV);
#else //temp
SetCLKDIV( Startup_ARMCLKdiv, Startup_HCLKdiv, Startup_PCLKdiv);
//SetMPLL( 68, 4, 0); //152MHz
//SetMPLL( 40, 1, 0); //192MHz
SetMPLL( 72, 2, 0); //240MHz
//SetMPLL( 125, 4, 0); //266MHz
//SetMPLL( 82, 2, 0); //270MHz
//SetMPLL( 84, 2, 0); //276MHz
//SetMPLL( 86, 2, 0); //282
//SetMPLL( 88, 2, 0); //288
//SetMPLL( 90, 2, 0); //294
//SetMPLL( 92, 2, 0); //300
Delay(0);
#endif
GlobalCLK();
ChangeSDRAMParameter(HCLK);
Isr_Init();
MMU_Init();
Delay(0); //calibrate Delay()
// CamDemoDisplay(); // camera demo
// Mpeg4_camera_image(); // MPEG&Camif demo
EnableCLKOUT();
rCLKOUTCON=(4<<12)|(0<<8)|(0<<4)|(0<<1)|(1<<0);
// SetCLKOUT(4);
//--------------------------------------------------------------------------------------------
while(1)
{
GlobalCLK();
Init_LogicalConsole();
Init_LED();
Led_Display(0xf);//all on
printf("\n\n+--------------------------------------------------------------------------------+\n");
printf("SMDK2460 Test Program Ver 0.1 (20040715)\n");
printf("MPLL=%.2fMHz, ARMCLK=%.2fMHz (%d:%d:%d), HCLK=%.2fMHz, PCLK=%.2fMHz\n",
(float)MPLL/1000000,(float)ARMCLK/1000000,ARMCLKdiv+1,(ARMCLKdiv+1)*(HCLKdiv+1),(ARMCLKdiv+1)*(HCLKdiv+1)*(PCLKdiv+1),(float)HCLK/1000000,(float)PCLK/1000000);
printf("+--------------------------------------------------------------------------------+\n\n");
i = 0;
while(1)
{ //display menu
printf("%2d:%s",i,function[i][1]);
i++;
if((int)(function[i][0])==0)
{
printf("\n");
break;
}
if((i%4)==0) printf("\n");
}
printf("\nSelect the function to test : ");
i = GetIntNum();
printf("\n");
if( i>=0 && (i<sizeof(function)/8-1) )
( (void (*)(void)) (function[i][0]) )();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -