1 Star 0 Fork 0

仁矜羽/C52

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
GPS.lst 8.59 KB
一键复制 编辑 原始数据 按行查看 历史
仁矜羽 提交于 2021-04-24 20:20 . 2.0电子指南针定版
C51 COMPILER V9.60.0.0 GPS 04/24/2021 20:03:49 PAGE 1
C51 COMPILER V9.60.0.0, COMPILATION OF MODULE GPS
OBJECT MODULE PLACED IN GPS.obj
COMPILER INVOKED BY: E:\Keil_v5\C51\C51\BIN\C51.EXE SRC\GPS.c LARGE OPTIMIZE(8,SPEED) BROWSE INCDIR(.\SRC) DEBUG OBJECTE
-XTEND PRINT(.\GPS.lst) TABS(2) OBJECT(GPS.obj)
line level source
1
2 #include "GPS.h"
3 #include "uart.h"
4 #include "oled.h"
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8
9
10 void errorLog(int num)
11 {
12 1
13 1
14 1 }
*** WARNING C280 IN LINE 10 OF SRC\GPS.c: 'num': unreferenced local variable
15
16 void parseGpsBuffer()
17 {
18 1 char *subString;
19 1 char *subStringNext;
20 1 char i = 0;
21 1 if (Save_Data.isGetData)
22 1 {
23 2 Save_Data.isGetData = false;
24 2 //UartPrintf("**************\r\n");
25 2 //UartPrintf(Save_Data.GPS_Buffer);
26 2
27 2
28 2 for (i = 0 ; i <= 6 ; i++)
29 2 {
30 3 if (i == 0)
31 3 {
32 4 if ((subString = strstr(Save_Data.GPS_Buffer, ",")) == NULL)
33 4 errorLog(1); //解析错误
34 4 }
35 3 else
36 3 {
37 4 subString++;
38 4 if ((subStringNext = strstr(subString, ",")) != NULL)
39 4 {
40 5 char usefullBuffer[2];
41 5 switch(i)
42 5 {
43 6 case 1:memcpy(Save_Data.UTCTime, subString, subStringNext - subString);break; //获取UTC时间
44 6 case 2:memcpy(usefullBuffer, subString, subStringNext - subString);break; //获取UTC时间
45 6 case 3:memcpy(Save_Data.latitude, subString, subStringNext - subString);break; //获取纬度信息
46 6 case 4:memcpy(Save_Data.N_S, subString, subStringNext - subString);break; //获取N/S
47 6 case 5:memcpy(Save_Data.longitude, subString, subStringNext - subString);break; //获取经度信息
48 6 case 6:memcpy(Save_Data.E_W, subString, subStringNext - subString);break; //获取E/W
49 6
50 6 default:break;
51 6 }
52 5
53 5 subString = subStringNext;
C51 COMPILER V9.60.0.0 GPS 04/24/2021 20:03:49 PAGE 2
54 5 Save_Data.isParseData = true;
55 5 if(usefullBuffer[0] == 'A')
56 5 Save_Data.isUsefull = true;
57 5 else if(usefullBuffer[0] == 'V')
58 5 Save_Data.isUsefull = false;
59 5
60 5 }
61 4 else
62 4 {
63 5 errorLog(2); //解析错误
64 5 }
65 4 }
66 3
67 3
68 3 }
69 2 }
70 1 }
71
72 extern void usartSendstr(char *s);
73 extern bit UPINFO;
74 void printGpsBuffer()
75 {
76 1 double temp;
77 1 int rev;
78 1 char bf0[10] = {'\0'};
79 1 char bf1[10] = {'\0'};
80 1 unsigned char showbuf[16]={'\0'};
81 1 if (Save_Data.isParseData)
82 1 {
83 2 Save_Data.isParseData = false;
84 2
85 2
86 2
87 2 if(Save_Data.isUsefull)
88 2 {
89 3 Save_Data.isUsefull = false;
90 3 #if 0
if(UPINFO)
{
UartPrintf("Save_Data.latitude = ");
UartPrintf(Save_Data.latitude);
UartPrintf("\r\n");
UartPrintf("Save_Data.N_S = ");
UartPrintf(Save_Data.N_S);
UartPrintf("\r\n");
UartPrintf("Save_Data.longitude = ");
UartPrintf(Save_Data.longitude);
UartPrintf("\r\n");
UartPrintf("Save_Data.E_W = ");
UartPrintf(Save_Data.E_W);
UartPrintf("\r\n");
UartPrintf("Save_Data.UTCTime = ");
UartPrintf(Save_Data.UTCTime);
UartPrintf("\r\n");
}
#endif
115 3 temp = atof(Save_Data.longitude);
C51 COMPILER V9.60.0.0 GPS 04/24/2021 20:03:49 PAGE 3
116 3 rev = (int)((temp-(int)temp)*60);
117 3 //sprintf(showbuf,"rev0 %d\r\n",rev );
118 3 //UartPrintf(showbuf);
119 3 //memset(showbuf, '\0', sizeof(showbuf));
120 3 bf0[0] = Save_Data.longitude[0];
121 3 bf0[1] = Save_Data.longitude[1];
122 3 bf0[2] = Save_Data.longitude[2];
123 3 bf0[3] = '.';
124 3 bf0[4] = Save_Data.longitude[3];
125 3 bf0[5] = Save_Data.longitude[4];
126 3 bf0[6] = '.';
127 3 bf0[7] = '0'+rev/10;
128 3 bf0[8] = '0'+rev%10;
129 3
130 3 temp = atof(Save_Data.latitude);
131 3 rev = (int)((temp-(int)temp)*60);
132 3 //sprintf(showbuf,"rev1 %d\r\n",rev );
133 3 //UartPrintf(showbuf);
134 3 //memset(showbuf, '\0', sizeof(showbuf));
135 3
136 3 bf1[0] = Save_Data.latitude[0];
137 3 bf1[1] = Save_Data.latitude[1];
138 3 bf1[2] = '.';
139 3 bf1[3] = Save_Data.latitude[2];
140 3 bf1[4] = Save_Data.latitude[3];
141 3 bf1[5] = '.';
142 3 bf1[6] = '0'+rev/10;
143 3 bf1[7] = '0'+rev%10;
144 3 OLED_ShowString(0,4,Save_Data.N_S,16);
145 3 OLED_ShowString(20,4,bf1,16);
146 3
147 3
148 3 OLED_ShowString(0,6,Save_Data.E_W,16);
149 3 OLED_ShowString(20,6,bf0,16);
150 3
151 3 rev = Save_Data.UTCTime[1]-'0'+(Save_Data.UTCTime[0]-'0')*10+8;
152 3 if(rev>24)
153 3 rev-=24;
154 3 sprintf(showbuf, "Time %d:%c%c:%c%c", rev,Save_Data.UTCTime[2],Save_Data.UTCTime[3],Save_Data.UTCTime[4
-],Save_Data.UTCTime[5]);
155 3 //Save_Data.UTCTime[1] += 8;
156 3 OLED_ShowString(0,2,showbuf,16);
157 3 if(UPINFO)
158 3 {
159 4 usartSendstr(bf0);
160 4 usartSendstr(bf1);
161 4 usartSendstr(showbuf);
162 4 }
163 3
164 3
165 3
166 3
167 3 }
168 2 else
169 2 {
170 3 //UartPrintf("GPS DATA is not usefull!\r\n");
171 3 }
172 2
173 2 }
174 1 }
175
176 //****************************************************
C51 COMPILER V9.60.0.0 GPS 04/24/2021 20:03:49 PAGE 4
177 //MS延时函数
178 //****************************************************
179 void Delay_nms(unsigned int n)
180 {
181 1 unsigned int i,j;
182 1 for(i=0;i<n;i++)
183 1 for(j=0;j<123;j++);
184 1 }
185
186
187 void GPS_Init(void)
188 {
189 1 Uart_Init();
190 1 Delay_nms(10);
191 1
192 1 clrStruct(); //清空缓存数组
193 1 }
194
195 void GPS_Read(void)
196 {
197 1 parseGpsBuffer();
198 1 printGpsBuffer();
199 1 }
200
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1181 ----
CONSTANT SIZE = 56 ----
XDATA SIZE = ---- 53
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 1 WARNING(S), 0 ERROR(S)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yjr_ty/C52.git
git@gitee.com:yjr_ty/C52.git
yjr_ty
C52
C52
master

搜索帮助