📄 gps1602.lst
字号:
C51 COMPILER V7.09 GPS1602 03/26/2008 13:55:09 PAGE 1
C51 COMPILER V7.09, COMPILATION OF MODULE GPS1602
OBJECT MODULE PLACED IN gps1602.OBJ
COMPILER INVOKED BY: C:\Program Files\keil c51\C51\BIN\C51.EXE gps1602.C BROWSE DEBUG OBJECTEXTEND
line level source
1 /******************************************************************************
2 Copyright 2007
3 All rights reserved.
4
5 文件名 :gps1602.c
6 模块名称:
7 功能概要:
8
9 取代版本:0.0.1
10 修改人 :pulan
11 完成日期:2007.07.27
12 升级说明:create
13 cpu:stc89c58 晶振频率:11.0592Mhz
14 硬件连接:
15 ---------------------------------------------------------------
16 |DB0-----P0.0 | DB4-----P0.4 | WR-------P2.2 | A0--------P2.1 |
17 |DB1-----P0.1 | DB5-----P0.5 | RD-------P2.4 | Vo悬空 |
18 |DB2-----P0.2 | DB6-----P0.6 | CS-------P2.5 |
19 |DB3-----P0.3 | DB7-----P0.7 | RST-------P2.3 |
20 ---------------------------------------------------------------
21 ******************************************************************************/
22
23 #include <reg52.h>
24 #include <string.h>
25
26 #define LCM_Data P0
27 #define Busy 0x80 //用于检测LCM状态字中的Busy标识
28 sbit LCM_RW = P2^2; //1602定义引脚
29 sbit LCM_RS = P2^1;
30 sbit LCM_E = P2^5;
31
32 //sbit GPS_SPD=P1^2;
33 //sbit SPD_TYPE=P1^3;
34 sbit KEY1=P1^1;
35
36
37 char code TIME_AREA= 8; //时区
38
39 //GPS数据存储数组
40 unsigned char JD[10]; //经度
41 unsigned char JD_a; //经度方向
42 unsigned char WD[9]; //纬度
43 unsigned char WD_a; //纬度方向
44 unsigned char time[6]; //时间
45 unsigned char speed[5]; //速度
46 unsigned char high[6]; //高度
47 unsigned char angle[5]; //方位角
48 unsigned char use_sat[2]; //使用的卫星数
49 unsigned char total_sat[2]; //天空中总卫星数
50 unsigned char lock; //定位状态
51
52 //串口中断需要的变量
53 unsigned char seg_count; //逗号计数器
54 unsigned char dot_count; //小数点计数器
55 unsigned char byte_count; //位数计数器
C51 COMPILER V7.09 GPS1602 03/26/2008 13:55:09 PAGE 2
56 unsigned char cmd_number; //命令类型
57 unsigned char mode; //0:结束模式,1:命令模式,2:数据模式
58 unsigned char buf_full; //1:整句接收完成,相应数据有效。0:缓存数据无效。
59 unsigned char cmd[5]; //命令类型存储数组
60
61 //显示需要的变量
62 unsigned int dsp_count; //刷新次数计数器
63 unsigned char time_count;
64 bit page;
65 bit spd_type;
66
67 void sys_init(void);
68 bit chk_key(void);
69
70 void WriteDataLCM(unsigned char WDLCM);
71 void WriteCommandLCM(unsigned char WCLCM,BuysC);
72 unsigned char ReadDataLCM(void);
73 unsigned char ReadStatusLCM(void);
74 void LCMInit(void);
75 void LCD_cls(void);
76 void DisplayOneChar(unsigned char X, unsigned char Y, unsigned char DData);
77 void DisplayListChar(unsigned char X, unsigned char Y, unsigned char code *DData);
78 void Delay5Ms(void);
79 void Delay400Ms(void);
80 /******************************************************************************************
81 * 函数名称 :
82 * 功能描述 :
83 * 参数 : 参数名称: 输入/输出? 类型 描述
84 *
85 * 返回值 :
86 * 作者 :
87 * 创建日期 :2006-12-19
88 * 全局变量 :
89 * 全局静态变量:
90 * 局部静态变量:
91 *----------------------------------------修改历史------------------------------------------
92 * 当前版本 : 修改人: 修改日期:
93 * 修改说明 :
94 ******************************************************************************************/
95 main()
96 {
97 1 unsigned char i;
98 1 char Bhour;
99 1 unsigned int Knots;
100 1 sys_init();
101 1
102 1 while(1)
103 1 {
104 2 if(buf_full==0) //无GPS信号时
105 2 {
106 3 dsp_count++;
107 3 if(dsp_count>=65000)
108 3 {
109 4 LCD_cls(); //清屏
110 4 DisplayListChar(0,0,"No GPS connect..");
111 4 while(buf_full==0);
112 4 LCD_cls();
113 4 dsp_count=0;
114 4 }
115 3 }
116 2 else
117 2 { //有GPS信号时
C51 COMPILER V7.09 GPS1602 03/26/2008 13:55:09 PAGE 3
118 3 if(chk_key())
119 3 { //检测到按键切换显示
120 4 page=!page;
121 4 LCD_cls();
122 4 }
123 3
124 3 if(!page)
125 3 { //页面1
126 4 if(buf_full|0x01)
127 4 { //GGA语句
128 5 if(lock=='0')
129 5 { //如果未定位
130 6 DisplayListChar(0,0,"*---.--.---- ");
131 6 DisplayListChar(0,1,"* --.--.---- ");
132 6 }
133 5 else
134 5 { //如果已定位
135 6 DisplayOneChar(0,0,JD_a); //显示经度
136 6 for(i=0;i<3;i++)
137 6 {
138 7 DisplayOneChar(i+1,0,JD[i]);
139 7 }
140 6 DisplayOneChar(4,0,'.');
141 6 for(i=3;i<10;i++)
142 6 {
143 7 DisplayOneChar(i+2,0,JD[i]);
144 7 }
145 6
146 6 DisplayOneChar(0,1,WD_a); //显示纬度
147 6 DisplayOneChar(1,1,' ');
148 6 for(i=0;i<2;i++)
149 6 {
150 7 DisplayOneChar(i+2,1,WD[i]);
151 7 }
152 6 DisplayOneChar(4,1,'.');
153 6 for(i=2;i<9;i++)
154 6 {
155 7 DisplayOneChar(i+3,1,WD[i]);
156 7 }
157 6 }
158 5 DisplayOneChar(14,0,use_sat[0]); //显示接收卫星数
159 5 DisplayOneChar(15,0,use_sat[1]);
160 5 buf_full&=~0x01;
161 5 dsp_count=0;
162 5 }
163 4 if(buf_full|0x02){ //GSV语句
164 5 DisplayOneChar(14,1,total_sat[0]);
165 5 DisplayOneChar(15,1,total_sat[1]);
166 5 buf_full&=~0x02;
167 5 dsp_count=0;
168 5 }
169 4 if(buf_full|0x04)
170 4 {
171 5 buf_full&=~0x04;
172 5 dsp_count=0;
173 5 }
174 4 }
175 3 else
176 3 { //页面2
177 4 if(buf_full|0x01)
178 4 { //GGA语句
179 5 buf_full&=~0x01;
C51 COMPILER V7.09 GPS1602 03/26/2008 13:55:09 PAGE 4
180 5 dsp_count=0;
181 5 }
182 4 if(buf_full|0x02)
183 4 {
184 5 buf_full&=~0x02;
185 5 dsp_count=0;
186 5 }
187 4 if(buf_full|0x04)
188 4 { //RMC语句
189 5 Bhour=((time[0]-0x30)*10+time[1]-0x30)+TIME_AREA;
190 5 if(Bhour>=24)
191 5 {
192 6 Bhour-=24;
193 6 }
194 5 else if(Bhour<0)
195 5 {
196 6 Bhour+=24;
197 6 }
198 5 DisplayListChar(2,1,"BJT ");
199 5 DisplayOneChar(6,1,Bhour/10+0x30);
200 5 DisplayOneChar(7,1,Bhour%10+0x30);
201 5 DisplayOneChar(8,1,':');
202 5 DisplayOneChar(9,1,time[2]);
203 5 DisplayOneChar(10,1,time[3]);
204 5 DisplayOneChar(11,1,':');
205 5 DisplayOneChar(12,1,time[4]);
206 5 DisplayOneChar(13,1,time[5]);
207 5 if(spd_type)
208 5 {
209 6 DisplayListChar(5,0,"km/h A");
210 6 }
211 5 else
212 5 {
213 6 DisplayListChar(5,0,"knot A");
214 6 }
215 5 if(lock=='0')
216 5 { //如果未定位
217 6 DisplayListChar(0,0,"---.-");
218 6 DisplayListChar(11,0,"---.-");
219 6 }
220 5 else
221 5 { //已经定位
222 6 if(spd_type)
223 6 { //km/h显示
224 7 for(i=0;i<5;i++)
225 7 {
226 8 DisplayOneChar(i,0,speed[i]);
227 8 }
228 7 }
229 6 else
230 6 { //knot显示
231 7 Knots= (((speed[0]-0x30)*1000
232 7 +(speed[1]-0x30)*100
233 7 +(speed[2]-0x30)*10
234 7 +(speed[4]-0x30))*1000)/1852;
235 7 DisplayOneChar(0,0,Knots/1000+0x30);
236 7 DisplayOneChar(1,0,(Knots%1000)/100+0x30);
237 7 DisplayOneChar(2,0,(Knots%100)/10+0x30);
238 7 DisplayOneChar(3,0,'.');
239 7 DisplayOneChar(4,0,Knots%10+0x30);
240 7 }
241 6 for(i=0;i<5;i++)
C51 COMPILER V7.09 GPS1602 03/26/2008 13:55:09 PAGE 5
242 6 {
243 7 DisplayOneChar(11+i,0,angle[i]);
244 7 }
245 6 }
246 5 buf_full&=~0x04;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -