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

📄 test_rs232.c

📁 Taiwan sunplus develop spce3200, it is a test program ----- testboard source code
💻 C
字号:
//====================================================================================
//File Name:	Test_RS232.c
//Description:	Serial port test
//Update:		V1.0 by wangtao <wangtao@sunnorth.com.cn>
//====================================================================================
#include "SystemHeader.h"

short Test_RS232(void)
{
	short x, y;
	short Ret = 0;
	int i;
	STR_IMAGE Pic_RS232 = {112, 128, RES_RS232_BIN};
	
	
	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_SetColor(COLOR_BLUE);
	TFT_SetWindow(50, 45, 165, 189);
	TFT_SetTextPos(0, 0);
	TFT_Print("Please toggle 5 and 6 of the toggle switch SW3 to ON, short the second and third pins of COM port, click any position on the screen to continue.");
	TFT_SetWindow(166, 50, 277, 183);
	TFT_PutImage(0, 0, &Pic_RS232);
	while(1)
	{
		Touch_Get(&x, &y);
		if(x!=-1) break;
	}
	for(i=0; i<1000000; i++);
	
	TFT_SetBGColor(COLOR_WHITE);
	TFT_SetWindow(40, 40, 279, 199);
	TFT_SetColor(COLOR_RED);
	TFT_Rectangle(0, 0, 239, 159, PAINT_HOLLOW);
	TFT_SetColor(COLOR_BLUE);
	TFT_SetWindow(70, 100, 259, 189);
	TFT_SetTextPos(0, 0);
	TFT_Print("RS232 interface test...");

	UART_Initial(BAUD_RATE_115200);
	for(i=0; i<128; i++)
	{
		UART_SendChar(i);
		if(UART_GetChar()!=i)break;
	}
	if(i==128)
	{
		TFT_Print("Successful!");
		Ret = 1;
	}
	else
	{
		TFT_SetColor(COLOR_RED);
		TFT_Print("Failed!");
		Ret = 0;
	}
	TFT_SetTextPos(0, 60);
	TFT_SetColor(COLOR_BLUE);
	TFT_Print("Click any position on the screen to return");
	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 + -