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

📄 uart_test.c

📁 s3c6400 ADS下官方测试程序
💻 C
📖 第 1 页 / 共 3 页
字号:
{
	s32 sCh;
	s32 sBrate;
	u8 ucTxCnt = 0;
	u8 ucCnt = 0;
	u32 ucCnt2 = 0;
	
	RxBufferClear();

	
	printf("Which channel do you want to check?\n");
	printf("[0 ~ 3] :");
	sCh = GetIntNum();
	if (sCh == -1)
		sCh = 1;
	else if (sCh == 0)
	{
	printf("Debug Channel will be channel 1\n");
	UART_InitDebugCh(1,115200);
	Delay(1000);
	}	

	printf("\n");


	printf("How much BaudRate do you want to use as a Tx?\n");
	printf("BaudRate (ex 9600, 115200[D], 921600) : ");
	sBrate = GetIntNum();
	if (sBrate == -1)
		sBrate = 115200;
	printf("\n");


		
	UART_SetConfig(sCh,2,1,1,4,3,1,1,sBrate,1,3,1,1);    
	UART_Open2(sCh);
	Delay(10000);

	printf("Press any key when you ready to Start/n");
	UART_Getc();



/*	
	Txdone = 1;
	Rxdone = 1;
	while(Txdone|Rxdone)
		{
		if(Txdone)
			{
				if(UART_RdUTRSTAT(sCh)&0x4) 
				{
				UART_WrUtxh(sCh,*pTestLBString);

					if(*pTestLBString == '\r') 
					Txdone = 0;

				pTestLBString++;
				}
			}

		if(Rxdone)
			{

				if(UART_RdUTRSTAT(sCh)&0x1) 
				{

				*pUartRxStr = UART_RdUrxh(sCh);


					if(*pUartRxStr == '\r')
						Rxdone = 0;

					
					pUartRxStr++;
				}
			}

		}


	pUartRxStr =(u8 *)(UART_BUF+0x200000);
	
	while(1) 
		{
			printf("%c",*pUartRxStr);
			if(*pUartRxStr == '\r')
				break;
			
			pUartRxStr++;
		}

*/
	UART_RxEmpty(sCh);


	while(!UART_GetKey())
		{
		
//				if(!(UART_RdUFSTAT(sCh)&0x4000)) 		//if TX Fifo is not Full
//				if(UART_RdUTRSTAT(sCh)&0x4) 				//if TX Fifo empty

			while(!(UART_RdUFSTAT(sCh)&0x4000))
				{
					UART_WrUtxh(sCh,ucTxCnt);
					//printf("%d\b\b",ucCnt);
					//Delay(100);
					ucTxCnt++;
					if(ucTxCnt == 0xf)
						ucTxCnt=0;
				}

//			if((UART_RdUFSTAT(sCh)&0x40)) 		//if Rx Fifo is Full
			if(UART_RdUTRSTAT(sCh)&0x1) 				//receive buffer has data
			{

				if(ucCnt == UART_RdUrxh(sCh))	
					{
					//printf("%d\b\b",ucCnt);
					ucCnt++;
						if(ucCnt == 0xf)
							{
							ucCnt=0;
							ucCnt2++;
							}
					}
				
				else
					{
					printf("Test is failed!!!\n");
					printf("Cnt = %d\n",ucCnt);
					printf("Cnt2 = %d",ucCnt2*15);
					break;
					}

			}
		}



	
	UART_Close(sCh);
	Delay(10000);
	UART_InitDebugCh(0,115200);	

}



// File Name : Uart_TxAgingTest
// File Description : for Uart Pending bit problem validation
// Input : NONE
// Output : NONE
// Version : 0.1
void Uart_TxAgingTest(void)
{
	u8 ch;
	static u8 acTestString[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz0123456789\r";
//	static u8 acTestString[]="UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU!!!!\r ";
//	static u8 acTestString[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz0123456789 ";

	ch = UART_Config();	
	if( UART_Open2(ch) == SENDBREAK ) 
	{
		printf("\n\nSend Break Signal has been transfered\n");
		return; 	
	} 	

	UART_EnModemINT(ch,1);
	Delay(10000);	
	// UART Tx test with interrupt	
	printf("\n[Uart channel %d Tx Test]\n",ch);	
	while(!UART_GetKey())
		{
	UART_TxString(ch, acTestString);
		}
	printf("\nTx Done~ \n");	
}


// File Name : Uart_RTS
// File Description : Check Uart RTS/CTS manually (non AFC)
// Input : NONE
// Output : NONE
// Version : 0.1
void Uart_RTS(void)
{
	volatile u8 *pUartRxStr;
	s8 sCh;

	printf("Which channel do you want to check?\n");
	printf("[0 or 1] :");
	sCh = GetIntNum();
	
	if (sCh == 0)
	{
		printf("Debug Channel will be channel 1\n");
		printf("\n");
		printf("change debug port cable to channel 1 and Press any key to ready RTS\n");

		UART_InitDebugCh(1,115200);
		Delay(1000);
	}	
	else
	{
		printf("Press any key to start RTS\n");
		sCh = 1;
	}
	printf("\n");
	

	
	UART_SetConfig(sCh,0,1,1,4,1,2,1,115200,1,5,1,1);
	UART_Open2(sCh);
	Delay(1000);
	pUartRxStr=(u8 *)(UART_BUF+0x200000);
	RxBufferClear();

	UART_Getc();	
	
	UART_WrRTS(sCh,RTS_inAct);
	printf("Start up Tx(CTS) on the other B'd and then press any key, it will start Rx(RTS)\n");
	UART_Getc();

	
	while(1) 
		{

			if(UART_RdUFSTAT(sCh)&0x3f)
				{
				UART_WrRTS(sCh,RTS_inAct);					//disable RTS
					if(UART_RdUTRSTAT(sCh)&0x1) 
						{
						
						*pUartRxStr = UART_RdUrxh(sCh);
	
							if(*pUartRxStr == '\r')
								break;

							
							pUartRxStr++;
						}
					}
			UART_WrRTS(sCh,RTS_Act);						//enbale RTS

		}

	pUartRxStr =(u8 *)(UART_BUF+0x200000);

	printf("##Rx :  ");
	while(1) 
		{
			printf("%c",*pUartRxStr);
			if(*pUartRxStr == '\r')
				break;
			
			pUartRxStr++;
		}
	if(sCh == 0)
		{
		printf("\n\nPress any key when you ready to change debug port as 0\n");
		printf("Change debug port cable to channel 0!\n");
		}
	else
		printf("Press any key when you end test\n");
	UART_Getc();

	UART_Close(sCh);
	Delay(10000);
	UART_InitDebugCh(0,115200);

}


// File Name : Uart_CTS
// File Description : Check Uart RTS/CTS manually (non AFC)
// Input : NONE
// Output : NONE
// Version : 0.1
void Uart_CTS(void)
{
	u8* pUartTxStr;
//	u8 acTestPString[]="\r";
	u8 acTestPString[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890->UART Tx CTS test is good!!!!ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890->UART Tx CTS test is good!!!!\r";
//	static u8* acTestPString="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890->UART Tx Polling test is good!!!!\r";
	s8 sCh;

	printf("Which channel do you want to check?\n");
	printf("[0 or 1] :");
	sCh = GetIntNum();
	
	if (sCh == 0)
	{
		printf("Debug Channel will be channel 1\n");

		printf("\n");
		printf("Change Debug port cable to channel 1 and Press any key to start CTS\n");

		UART_InitDebugCh(1,115200);
		Delay(1000);
	}	
	else
	{
		printf("Press any key to start CTS\n");
		sCh = 1;
	}


		
	UART_SetConfig(sCh,0,1,1,4,1,2,1,115200,1,5,1,1);
	UART_Open2(sCh);
	Delay(1000);
	UART_Getc();
	printf("### CTS started ###\n");
	

	pUartTxStr = acTestPString;

	while(1) {

				if(UART_RdUMSTAT(sCh)&0x1)			// check CTS signal
					{
						if(UART_RdUTRSTAT(sCh)&0x4) 
						{
							UART_WrUtxh(sCh,*pUartTxStr);

							if(*pUartTxStr == '\r') 
								break;

							pUartTxStr++;
						}
					}
		}


	if(sCh == 0)
	printf("\n\nPress Enter when you complete to check Rx and then change Debug port cable to channel 0\n");
	else
	printf("\n\nPress Enter when you complete to check Rx\n");
	
	UART_Getc();

	UART_Close(sCh);
	Delay(10000);	
	
	
	UART_InitDebugCh(0,115200);	

}



// File Name : Uart_ModemInt
// File Description : Check Uart Modem Interrupt by RTS/CTS check 
// Input : NONE
// Output : NONE
// Version : 0.1
void Uart_ModemInt(void)
{
	u8* pUartTxStr;
//	u8 acTestPString[]="\r";
	u8 acTestPString[]="0123456789\r";
//	static u8* acTestPString="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890->UART Tx Polling test is good!!!!\r";
	s8 sCh;

	printf("\n\n     ########################################################\n");
	printf("     This is the Modem Interrupt check test which is using manual mode of CTS function   \n");
	printf("     This check should be operate with UART_RTS test on the other Board!\n");
	printf("     At first, Set up UART_RTS test on the other connected Board n Press Any Key to start\n");
	printf("     ########################################################\n");	
	UART_Getc();



	printf("Which channel do you want to check?\n");
	printf("[0 or 1] :");
	sCh = GetIntNum();
	
	if (sCh == 0)
	{
		printf("Debug Channel will be channel 1\n");

		printf("\n");
		printf("Change Debug port cable to channel 1 and Press any key to start CTS\n");

		UART_InitDebugCh(1,115200);
		Delay(1000);
	}	
	else
	{
		printf("Press any key to start CTS\n");
		sCh = 1;
	}

	UART_Getc();
	
	printf("\n");

	printf("\n### CTS Started ###\n");
		
	UART_SetConfig(sCh,0,1,1,4,1,2,1,115200,1,5,1,1);
	UART_Open2(sCh);
	UART_EnModemINT(sCh,1);	
	Delay(1000);	
	UART_OpenModem(sCh) ;

	

	pUartTxStr = acTestPString;

	while(1) {

				if(UART_RdUMSTAT(sCh)&0x1)			// check CTS signal
					{
						if(UART_RdUTRSTAT(sCh)&0x4) 
						{
							UART_WrUtxh(sCh,*pUartTxStr);

							if(*pUartTxStr == '\r') 
								break;

							pUartTxStr++;
						}
					}

		}




	if(sCh == 0)
	printf("\n\nPress Enter when you complete to check Rx and then change Debug port cable to channel 0\n");
	else
	printf("\n\nPress Enter when you complete to check Rx\n");
	
	UART_Getc();

	UART_Close(sCh);
	Delay(10000);	
	
	
	UART_InitDebugCh(0,115200);		

	UART_Getc();
}


⌨️ 快捷键说明

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