?? gps1602.lst
字號:
C51 COMPILER V7.50 GPS1602 10/27/2008 14:06:52 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE GPS1602
OBJECT MODULE PLACED IN gps1602.OBJ
COMPILER INVOKED BY: D:\Program Files\Keil\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.50 GPS1602 10/27/2008 14:06:52 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.50 GPS1602 10/27/2008 14:06:52 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.50 GPS1602 10/27/2008 14:06:52 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.50 GPS1602 10/27/2008 14:06:52 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 + -