?? test_basic.c
字號:
//====================================================================================
//File Name: Test_Basic.c
//Description: Basic test
//Update: V1.0 by wangtao <wangtao@sunnorth.com.cn>
//====================================================================================
#include "SystemHeader.h"
short Test_SDRam(void)
{
unsigned int Temp0, Temp1, Temp2, Temp3;
short Ret = 1;
Temp0 = *(unsigned int *)0xA0555550;
Temp1 = *(unsigned int *)0xA1005550;
Temp2 = *(unsigned int *)0xA0AAAAA0;
Temp3 = *(unsigned int *)0xA100AAA0;
*(unsigned int *)0xA0555550 = 0xAAAAAAAA;
*(unsigned int *)0xA1005550 = 0x55555555;
*(unsigned int *)0xA0AAAAA0 = 0xFFFFFFFF;
*(unsigned int *)0xA100AAA0 = 0x00000000;
if(*(unsigned int *)0xA0555550 != 0xAAAAAAAA)
Ret = 0;
if(*(unsigned int *)0xA1005550 != 0x55555555)
Ret = 0;
if(*(unsigned int *)0xA0AAAAA0 != 0xFFFFFFFF)
Ret = 0;
if(*(unsigned int *)0xA100AAA0 != 0x00000000)
Ret = 0;
*(unsigned int *)0xA0555550 = 0x00000000;
*(unsigned int *)0xA1005550 = 0x55555555;
*(unsigned int *)0xA0AAAAA0 = 0xAAAAAAAA;
*(unsigned int *)0xA100AAA0 = 0xFFFFFFFF;
if(*(unsigned int *)0xA0555550 != 0x00000000)
Ret = 0;
if(*(unsigned int *)0xA1005550 != 0x55555555)
Ret = 0;
if(*(unsigned int *)0xA0AAAAA0 != 0xAAAAAAAA)
Ret = 0;
if(*(unsigned int *)0xA100AAA0 != 0xFFFFFFFF)
Ret = 0;
*(unsigned int *)0xA0555550 = Temp0;
*(unsigned int *)0xA1005550 = Temp1;
*(unsigned int *)0xA0AAAAA0 = Temp2;
*(unsigned int *)0xA100AAA0 = Temp3;
return Ret;
}
short Test_NorFlash(void)
{
unsigned int TempData;
*P_NOR_COMMAND_CTRL = 1;
*(unsigned char *)0x9e055550 = 0xAA;
*(unsigned char *)0x9e02AAA0 = 0x55;
*(unsigned char *)0x9e055550 = 0x90;
TempData = *(unsigned int *)0x9e000000;
*P_NOR_COMMAND_CTRL = 0;
if((TempData & 0xFFFF) != 0x00BF)
return 0;
else
return 1;
}
short Test_NandFlash(void)
{
unsigned int TempData;
short Ret = 1;
int i;
*P_GPIO_CLK_CONF = C_GPIO_CLK_EN + C_GPIO_RST_DIS; // Enable SFTCFG clk and not reset SFTCFG module.
*P_NAND_CLK_CONF = C_NAND_CLK_EN + C_NAND_RST_DIS; // Enable NAND clk and not reset NAND module.
*P_NAND_INTERFACE_SEL = C_NAND_PORT_SEL; // Enable NAND module.
*P_NAND_MODE_CTRL = C_NAND_PORT_EN|C_NAND_CEN_LOW|C_NAND_WPN_HIGH|C_NAND_CMD_READ|C_NAND_ALE_FALL|C_NAND_ALE_1CYCLE|C_NAND_WENLOW_2CYCLE|C_NAND_WENHIGH_1CYCLE|C_NAND_RENLOW_2CYCLE|C_NAND_RENHIGH_1CYCLE|0x00030000;
*P_NAND_CLE_COMMAND = 0x90; // Don't check controller's BUSY flag.
i = 0;
while ((*P_NAND_INT_STATUS & C_NAND_CTRL_BUSY) != 0) // Polling status of controller.
{
i++;
if(i==100000)
{
Ret = 0;
break;
}
}
*P_NAND_ALE_ADDR = 0x00000000;
while ((*P_NAND_INT_STATUS & C_NAND_CTRL_BUSY) != 0) // Polling status of controller.
{
i++;
if(i==100000)
{
Ret = 0;
break;
}
}
TempData = *P_NAND_RX_DATA; // Get 32-bit ID.
if((TempData & 0xFF)!=0xEC)
Ret = 0;
*P_NAND_MODE_CTRL = 0x00000000 | C_NAND_PORT_EN | C_NAND_CEN_HIGH | C_NAND_WPN_HIGH | C_NAND_RD_RESV; // CEn=1
return Ret;
}
short Test_Ethernet(void)
{
extern void InitSPI(void);
InitSPI();
if(MACInit()==0)
return 0;
return 1;
}
short Test_Basic(void)
{
short x, y;
short Ret = 1;
int i;
TFT_SetBGColor(0x0001);
TFT_SetWindow(0, 0, TFT_WIDTH-1, TFT_HEIGHT-1);
TFT_SetBGColor(COLOR_WHITE);
TFT_SetWindow(40, 40, 279, 199);
TFT_SetColor(COLOR_RED);
TFT_Rectangle(0, 0, 239, 159, PAINT_HOLLOW);
TFT_SetBGColor(COLOR_BLACK);
TFT_SetWindow(50, 50, 269, 189);
TFT_SetColor(COLOR_BLUE);
TFT_SetTextPos(0, 0);
TFT_Print("DRAM test...");
if(Test_SDRam())
TFT_Print("Successful!\n");
else
{
TFT_SetColor(COLOR_RED);
TFT_Print("Failed!\n");
TFT_SetColor(COLOR_BLUE);
Ret = 0;
}
TFT_Print("Nand Flash test...");
if(Test_NandFlash())
TFT_Print("Successful!\n");
else
{
TFT_SetColor(COLOR_RED);
TFT_Print("Failed!\n");
TFT_SetColor(COLOR_BLUE);
Ret = 0;
}
TFT_Print("Nor Flash test...");
if(Test_NorFlash())
TFT_Print("Successful!\n");
else
{
TFT_SetColor(COLOR_RED);
TFT_Print("Failed!\n");
TFT_SetColor(COLOR_BLUE);
Ret = 0;
}
TFT_Print("Ethernet controller test...");
if(Test_Ethernet())
TFT_Print("Successful!\n");
else
{
TFT_SetColor(COLOR_RED);
TFT_Print("Failed!\n");
TFT_SetColor(COLOR_BLUE);
Ret = 0;
}
TFT_SetTextPos(20, 110);
TFT_Print("Click any position on the screen to continue");
while(1)
{
Touch_Get(&x, &y);
if(x!=-1) break;
}
for(i=0; i<1000000; i++);
TFT_SetBGColor(0x0001);
TFT_SetWindow(0, 0, TFT_WIDTH-1, TFT_HEIGHT-1);
return Ret;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -