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

📄 main.c

📁 S3C2410上GPS模块的驱动代码.ADS1.2编译工程,附文档.
💻 C
字号:
#include <stdio.h>
#include "gps.h"
#include "2410lib.h"
#include "def.h"
#include "lcdlib.h"
#include "INT.h"
#include "UartLib.h"
#include "touch.h"

void rpt_packet(TSIPPKT *rpt,char *obuf);
void tsip_input_proc(TSIPPKT *rpt,char inbyte);
void WIN_GPS(void);
void GpsUartSet(int Uart);
void GspOutput(int formWidth, int formHeight);
void DrawGpsForm(void);

TSIPPKT gRpt;
POSITION Pos;
VELOCITY Vel;
int GpsUart = UART1;


int main(void)
{
	int formWidth = 220;
	int formHeight = 90;
	char Gpsdata;

	ChangeClockDivider(1,1);			// 1:2:4
	ChangeMPllValue(0xa1,0x3,0x1);		// FCLK=202.8MHz
	Port_Init();
	__vInitHaltHandlers();

	LCD_Init();
	GpsUartSet(GpsUart);
	WIN_GPS();
	
	Rewriteletter((g_xMax-112)/2,(g_yMax)/2-60,"等待GPS数据...",1,0,RGB(255,255,0),RGB(130,130,240));
	
	while (SUB_RUN)
	{
		if (RxUartS(&Gpsdata,GpsUart))				// UART receive data
		{
			tsip_input_proc(&gRpt,Gpsdata);			// analyse
			if (gRpt.status == TSIP_PARSED_FULL)	// receive complete
			{
				rpt_packet(&gRpt,outbuf);			// output reports
				GspOutput(formWidth, formHeight);
				gRpt.status=TSIP_PARSED_EMPTY;		// prepare for next
			}
		}
	}
}


void WIN_GPS(void)
{
	WIN_WaterTek("GPS卫星定位实验");
	drawletter((g_xMax-64)/2,(g_yMax)/2+70,"数据窗口",1,0,RGB(255,255,0));
	DrawGpsForm();
}

void GpsUartSet(int Uart)
{
	UartInterrupt(FALSE,Uart);
	SetBaudrate(9600,Uart);
	UartDefaultInit(Uart);
}

void GspOutput(int formWidth, int formHeight)
{
	int p1_x = (g_xMax - formWidth) / 2 + 64 + 12;
	int p1_y = g_yMax / 2 - formHeight / 2 + 48;
	int p2_x = (g_xMax - formWidth) / 2 + 138;
	int p3_y = g_yMax / 2 + 48 - formHeight * 5 / 6;
	char info[5];
	COLOR txtColor = RGB(255,255,0);
	COLOR bgColor = RGB(130,130,240);
	
	sprintf(info,"%c",Pos.latdir);
	Rewriteletter(p1_x, p1_y, info, 1, 0, txtColor, bgColor);

	Pos.lat[10] = 0;
	Rewriteletter(p2_x, p1_y, Pos.lat, 1, 0, txtColor, bgColor);
	
	sprintf(info,"%c",Pos.londir);
	Rewriteletter(p1_x ,p3_y, info, 1, 0, txtColor, bgColor);
	
	Pos.lon[10] = 0;
	Rewriteletter(p2_x, p3_y, Pos.lon, 1, 0, txtColor, bgColor);
	
	if (Pos.latdir > 0 && Pos.londir > 0)
		Rewriteletter((g_xMax-112)/2,(g_yMax)/2-60,"分析GPS数据...",1,0,RGB(255,255,0),RGB(130,130,240));
}

void DrawGpsForm(void)
{
	int x;						// 表的位置X坐标
	int y;						// 表的位置Y坐标
	int width	= 220;			// 表的高度
	int height	= 90;			// 表的长度
	int subH	= height / 3;	// 行高
	int subW_1	= 40;			// 第一列宽度
	int subW_2	= 80;			// 第二列宽度
	int subW_3	= 100;			// 第三列宽度
	COLOR color = RGB(255,255,0);
	
	x = (g_xMax - width) / 2;
	y = g_yMax / 2 - height + 40;
	
	DrawFrame(x, y, x+width, y+height, 1, color);
	DrawFrame(x, y+subH, x+width, y+height-subH, 1, color);
	
	line(x+subW_1, y, x+subW_1, y+height, color);
	line(x+subW_1+subW_2, y, x+subW_1+subW_2, y+height, color);
	
	drawletter(x+(subW_1-32)/2, y+height-(subH-16)/2, "类别", 1, 0, color);
	drawletter(x+subW_1+(subW_2-32)/2, y+height-(subH-16)/2, "方向", 1, 0, color);
	drawletter(x+subW_1+subW_2+(subW_3-64)/2, y+height-(subH-16)/2, "数值(度)", 1, 0, color);
	
	drawletter(x+(subW_1-32)/2, y+subH*2-(subH-16)/2, "纬度", 1, 0, color);
	drawletter(x+(subW_1-32)/2, y+subH-(subH-16)/2, "经度", 1, 0, color);
}

⌨️ 快捷键说明

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