⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hostif_test.c

📁 s3c6400 ADS下官方测试程序
💻 C
字号:
/**
 * HOSTIF_TEST.C
 *
 * @author	SONG JAE GEUN
 * @version         1.0
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>

#include "system.h"
#include "option.h"
#include "library.h"
#include "intc.h"
#include "sysc.h"

#include "nand.h"
#include "hostif.h"
#include "timer.h"
#include "modemif.h"

extern NAND_oInform NAND_Inform[NAND_CONNUM];

void Test_HOSTIF_AP_Int(void)
{
	HOSTIF_AP_Init();

	while(!Getc());
	
	INTC_Disable(NUM_HOSTIF);
}

void Test_HOSTIF_MODEM_Int(void)
{	
	HOSTIF_MODEM_Init();

	while(!Getc());
	
	INTC_Disable(NUM_EINT1);
}

void Test_Single_ReadWrite(void)
{
	u32 addr, data, temp;

	HOSTIF_MODEM_Init();
	
	printf("\nInput HOST I/F SingleWrite Address : ");
	addr = GetIntNum();

	printf("\nInput HOST I/F SingleWrite DATA : ");
	data = GetIntNum();
	
	HOSTIF_SingleWrite(addr, data);
	temp = HOSTIF_SingleRead(addr);
	printf("\ntemp = 0x%x\n", temp);

	if (data == temp) 
		printf("\nHOST I/F Single Read/Write test completed!!!\n");
	else
		printf("HOST I/F Single Read/Write test error!!!\n");		
	
}

void Test_Burst_ReadWrite(void)
{
	u32 addr, data, size;
	//u32* pSrcaddr;

	printf("\nInput HOST I/F BurstWrite Address : ");
	addr = GetIntNum();

	printf("\nInput HOST I/F BurstWrite DataAddress : ");
	data = GetIntNum();

	printf("\nInput HOST I/F BurstWrite DataSize : ");
	size = GetIntNum();

	HOSTIF_BurstWrite(addr, (u32 *)data, size);
	
	printf("\nInput HOST I/F BurstRead Address : ");
	addr = GetIntNum();

	printf("\nInput HOST I/F BurstRead DataAddress : ");
	data = GetIntNum();

	printf("\nInput HOST I/F BurstWrite DataSize : ");
	size = GetIntNum();

	HOSTIF_BurstRead(addr, (u16 *)data, size);

}

void Test_RepeatedBurst_Write(void)
{
	u32 addr, data, size;
	//u32* pSrcaddr;

	printf("\nInput HOST I/F RepeatedBurstWrite Address : ");
	addr = GetIntNum();

	printf("\nInput HOST I/F RepeatedBurstWrite DataAddress : ");
	data = GetIntNum();

	printf("\nInput HOST I/F RepeatedBurstWrite DataSize : ");
	size = GetIntNum();

	HOSTIF_RepeatedBurstWrite(addr, (u32 *) data, size);
}

void Test_InMailBox(void)
{
	HOSTIF_InMailBox(0x1234ABCD);
}

void Test_OutMailBox(void)
{
	//HOSTIF_AP_Init();
	HOSTIF_OutMailBox(0xcdef1234);
}

void Test_MODEM_Booting(void)
{
#if 0
	u32 i, data, lengh;
	u32 maxlengh = 0x1000;

	NAND_eERROR eError;

	// MODEM I/F GPIO Setting
	MODEMIF_Set_Modem_Booting_Port();
	Delay(1000);
	
	// MODEM Booting AP Reset
	MODEMIF_AP_Reset();

	// SROM BUS 16bit setting
	SYSC_16bitBUS();

	// MODEM bootloader copy to DPSRAM
	NAND_Inform[0].uNandType = NAND_Normal8bit;
	NAND_Inform[0].uAddrCycle = 4;
	NAND_Inform[0].uBlockNum = 4096;
	NAND_Inform[0].uPageNum = 32;
	NAND_Inform[0].uPageSize = NAND_PAGE_512;
	NAND_Inform[0].uSpareSize = NAND_SPARE_16;
	NAND_Inform[0].uECCtest = 0;
	NAND_Inform[0].uTacls = 0;
	NAND_Inform[0].uTwrph0 = 35+10;	//Pad delay : about 10ns
	NAND_Inform[0].uTwrph1 = 15+5;	//tWH : 15ns
	
	NAND_Init(0);
	NAND_ReadMultiPage(0, 1, 0, (u8 *)0x55000000, 0x1000);

	SetHostMode(&hostCfg, BLEN(1)|RBURST_DISABLE|DEST_LOWER|TRANS_WR);

	for (lengh = 0 ; lengh <= maxlengh ; lengh+=4)
	{
		data = Inp32(0x55000000 + lengh);
		SWrite(&hostCfg, 0x0c000000+lengh, data);
	}

	SetHostMode(&hostCfg, BLEN(1)|RBURST_DISABLE|DEST_LOWER|TRANS_RD);
	
	for (lengh = 0 ; lengh <= maxlengh ; lengh+=4)
	{
		SRead(&hostCfg, 0x0c000000+lengh);

	}
	HOSTIF_MODEM_To_AP_Reset();

	printf("Press any key and BOOT CODE(0x0c000000) start!!!\n");
	Getc();
#else
	u32 data, lengh;
	u32 maxlengh = 0x1000;

	// MODEM I/F GPIO Setting
	MODEMIF_Set_Modem_Booting_Port();
	Delay(1000);
	
	// MODEM Booting AP Reset
	MODEMIF_AP_Reset();

	// SROM BUS 16bit setting
	SYSC_16bitBUS();

	// MODEM bootloader copy to DPSRAM
	NAND_Inform[0].uNandType = NAND_Normal8bit;
	NAND_Inform[0].uAddrCycle = 4;
	NAND_Inform[0].uBlockNum = 4096;
	NAND_Inform[0].uPageNum = 32;
	NAND_Inform[0].uPageSize = NAND_PAGE_512;
	NAND_Inform[0].uSpareSize = NAND_SPARE_16;
	NAND_Inform[0].uECCtest = 0;
	NAND_Inform[0].uTacls = 0;
	NAND_Inform[0].uTwrph0 = 35+10;	//Pad delay : about 10ns
	NAND_Inform[0].uTwrph1 = 15+5;	//tWH : 15ns
	
	NAND_Init(0);
	NAND_ReadMultiPage(0, 10, 0, (u8 *)0x55000000, 0x1000);

	for (lengh = 0 ; lengh <= maxlengh ; lengh+=4)
	{
		data = Inp32(0x55000000 + lengh);
		HOSTIF_SingleWrite(0x0c000000+lengh, data);
	}

	for (lengh = 0 ; lengh <= maxlengh ; lengh+=4)
		HOSTIF_SingleRead(0x0c000000+lengh);

	HOSTIF_MODEM_To_AP_Reset();

	printf("Press any key and BOOT CODE(0x0c000000) start!!!\n");
	Getc();

#endif
}

void Test_HOSTIF_Performance(void)
{
	u16 temp;
	u32 lengh;

	HOSTIF_MODEM_Init();

	// SingleWrite	
	StartTimer(0);
	for (lengh = 0 ; lengh < 0x1000 ; lengh+=4)
		HOSTIF_SingleWrite(0x52000000+lengh, lengh);
	temp = StopTimer(0);
	printf("4Kb SingleWrite time = %dus\n",temp);
	Getc();

	//SingleRead
	StartTimer(0);
	for (lengh = 0 ; lengh < 0x1000 ; lengh+=4)
		HOSTIF_SingleRead(0x52000000+lengh);
	temp = StopTimer(0);
	printf("4Kb SingleRead time = %dus\n",temp);
	Getc();
	
	// BurstWrite
	StartTimer(0);
	HOSTIF_BurstWrite(0x52000000, (u32 *)0x74100000, 1024);
	temp = StopTimer(0);
	printf("4Kb BurstWrite time = %dus\n",temp);
	Getc();
	
	//BurstRead
	StartTimer(0);
	HOSTIF_BurstRead(0x74100000, (u16 *)0x52000000, 1024);	
	temp = StopTimer(0);
	printf("4Kb BurstRead time = %dus\n",temp);
	Getc();


	//RepeatedBurstWrite
	StartTimer(0);
	HOSTIF_RepeatedBurstWrite(0x52000000, (u32 *)0x74100000, 1024);
	temp = StopTimer(0);
	printf("4Kb RepeatedBurstWrite time = %dus\n",temp);
	Getc();
	
	printf("\nHOST I/F Performance test end\n");

}

void Test_HSTIF_Debug(void)
{
	HOSTIF_TestProtoReg();
}	

void HOSTIF_Test(void)
{
	int i, sel;

	//FUNC_MENU menu[]=
	const testFuncMenu menu[]=
	{
		0,                  		                	"Exit",
		Test_HOSTIF_MODEM_Int,	"HOST I/F MODEM Interrupt Init	",
		Test_HOSTIF_AP_Int,		"HOST I/F AP Interrupt Init		",

		Test_Single_ReadWrite,		"Single Write/Read		",
		Test_Burst_ReadWrite,		"Burst Write/Read		",
		Test_RepeatedBurst_Write,	"Repeated Burst Write	",

		Test_InMailBox,				"In-MailBox		",
		Test_OutMailBox,			"Out-MailBox		",

		Test_MODEM_Booting,		"MODEM Booting Test	",
		Test_HOSTIF_Performance,	"HOST I/F Performance		",

		Test_HSTIF_Debug,			"HOST I/F Debugging		",
		0,0
	};

	while(1)
	{
		printf("\n");
		for (i=0; (int)(menu[i].desc)!=0; i++) {
			printf("%2d: %s\n", i, menu[i].desc);
		}

		printf("\nSelect the function to test : ");
		sel = GetIntNum();
		printf("\n");

		if (sel == 0)
			break;
		else if (sel>0 && sel<(sizeof(menu)/8-1))
			(menu[sel].func) ();
	}
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -