📄 main.lst
字号:
C51 COMPILER V7.06 MAIN 01/12/2006 13:06:29 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 //-------------------------------------------------------------
2 // filename: main.C
3 // This file is programed for the Micro Auto Pilot System of the Wisewell Inc.
4 // Programer: wangr
5 //-------------------------------------------------------------
6
7
8 //------------------------ NOTES -------------------
9
10 //------------------------------------------------
11 /*********************************************************************************/
12 /*************************** ************************************/
13 /*************************** include section ************************************/
14 /*************************** ************************************/
15 /*********************************************************************************/
16 //#include <C8051F020.h>
17 #include <GPS_F023.c>
18 #include <intrins.h>
19 #include <ABSACC.H>
20 #include <math.h>
21 #include <stdio.h>
22 #include <string.h>
23
24 #define uchar unsigned char
25 #define uint unsigned int
26
27 sbit LED1 = P1^1;
28 sbit LED2 = P1^2;
29 sbit LED3 = P1^3;
30 sbit LED4 = P1^4;
31 sbit LED5 = P1^5;
32 sbit LED6 = P1^6;
33 sbit LED7 = P1^7;
34
35 bit LED_flag;
36
37 //uchar xdata r_buf[100];
38 //uchar xdata r_in;
39 bit GPS_received_data_OK, GPS_received_data_OK1, gps_en;
40
41 uint xdata main_count;
42
43 /************************************************/
44 /************* GPS recieve ****************/
45 #define PI 3.14
46
47 #define ILEN 85
48 #define OS_ENTER_CRITICAL() EA = 0
49 #define OS_EXIT_CRITICAL() EA = 1
50 #define VAH_Gain 10
51
52 //typedef unsigned char uchar ;
53
54 #define OS_GPS_LAT_EN 1
55 #define OS_GPS_LONG_EN 1
C51 COMPILER V7.06 MAIN 01/12/2006 13:06:29 PAGE 2
56
57 /* serial port 0 exchange data between gps and pc */
58 /*************************************************************/
59 /* GPS buffer */
60 /*************************************************************/
61 //uchar idata r_buf[]="$GPGGA,034745.94,3537.8333,N,11619.5870,E,1,06,2.2,-143.5,M,-12.6,M,000,000*7F,111"
-;
62 // uchar xdata s_buf[]="$GPGGA,034745.94,3537.8333,N,11619.5870,E,0,06,2.2,-143.5,M,-12.6,M,000,000*7F,";
63 uchar idata r_buf[ILEN]="$GPRMC,022309.34,V,3537.8333,N,13944.6667,E,004.0,002.0,030222,,*02";
64 // uchar idata r_buf[ILEN];
65 /*
66 $GPGGA,022237.00,3537.8333,N,13944.6667,E,0,00,99.9,0100,M,,M,000,0000*7E
67 $GPGLL,3537.8333,N,13944.6667,E,022237,V*38
68 $GPRMC,022237,V,3537.8333,N,13944.6667,E,000.0,000.0,030222,,*0E
69 $GPZDA,022237,03,02,2022,,*4D
70 */
71
72 /****************************************************************************/
73 /* 500m DBSAE = 120
74 /* 1km DBSAE = 60
75 /* 2km DBSAE = 30
76 /* 3km DBSAE = 20
77 /* 4km DBSAE = 15
78 /* 5km DBSAE = 12
79 /* 6km DBSAE = 10
80 /* 7km DBSAE = 9
81 /* 8km DBSAE = 8
82 /* 9km DBSAE = 7
83 /* 10km DBSAE = 6
84 /*
85 /****************************************************************************/
86
87 unsigned char code DBSAE_Table[]={60,30,15,10,7,6,5,4,4,3,3};
88 uchar idata r_in;
89
90
91
92
93
94 bit measure_detect;
95 bit Data_Request;
96 bit GPS_received_data_OK,GPS_received_data_OK1;
97 bit second_flag;
98 bit GPGGA_flag;
99 bit GPRMC_flag;
100 bit send_flag_OK;
101 bit gps_flag = 0;
102 bit TimeCorrect_flag;
103 bit Int0Send_flag;
104
105 // GPS data //
106 bit gps_en; /* control the GPS receiver status */
107 idata int L_X = 0;
108 idata int L_Y = 0;
109
110 typedef struct {
111 // utc time
112 union { double utc_time;
113 struct {uchar hour;
114 uchar min;
115 uchar sec;
116 uchar date;
C51 COMPILER V7.06 MAIN 01/12/2006 13:06:29 PAGE 3
117 uchar month;
118 uchar year_low;uchar year_high;} times;
119 } OS_UTC;
120 // latitude WGS-84.
121 #ifdef OS_GPS_LAT_EN
122 union { unsigned long latitude;
123 struct {uchar latitude_deg;
124 uchar latitude_min;
125 uint latitude_sec;} latitudes;
126 } OS_Latitude;
127 float f_latitude;
128 uchar latitude_deg;
129 float f_latitude_min;
130 #else
float f_latitude;
uchar latitude_deg;
float f_latitude_min;
#endif
135
136 uchar latitude_N_S;
137
138 // longitude WGS-84.
139 #ifdef OS_GPS_LONG_EN
140 union { unsigned long longitude;
141 struct {uchar longitude_deg;
142 uchar longitude_min;
143 uint longitude_sec;} longitudes;
144 } OS_Longitude;
145 float f_longitude;
146 uchar longitude_deg;
147 float f_longitude_min;
148 #else
float f_longitude;
uchar longitude_deg;
float f_longitude_min;
#endif
153 uchar longitude_E_W;
154 // orientation
155 uchar orientation;
156 // star number
157 uchar star_number;
158 // HDOP
159 float HDOP;
160 // altitude Altitude with respect to mean sea level.
161 float f_altitude; //海拔高度
162 // Geoidal Separationthe difference between the WGS-84 earth ellipsoid and mean-sea-level (geoid).
163 float f_separation; // - means that mean-sea-level below ellipsoid.
164 // speed
165 float f_speed;
166 // heading
167 float f_heading;
168 // megnitude angle
169 float f_magval;
170 char f_magsig;
171 // megnitude angle direction
172 } OS_GPS;
173
174 typedef struct os_point{
175 float Ex;
176 float Ny;
177 float Sz;
178 uchar G;
C51 COMPILER V7.06 MAIN 01/12/2006 13:06:29 PAGE 4
179 uint Heading;
180 uint Speed;
181 uint Distance;
182 } POINT;
183
184 idata OS_GPS gps_point;
185 xdata POINT OS_PTbl[2];
186
187 xdata POINT xdata *Start_Point;
188 xdata POINT xdata *Any_Point;
189
190 void delay(uchar x);
191 void delay20();
192 //void InitTimer0(void);
193 void serialGPS_init();
194 void putbyte(uchar c);
195 uchar Read_GPS_GPGGA_B();
196 uchar Read_GPS_GPRMC_B();
197 uchar Read_GPS_GPRMC_C();
198 void trans_data(uchar ch);
199 void send_data();
200 void sys_ini();
201 void Process_GPS();
202 void Init_Device(void);
203
204 uchar xdata ReportTime_buf[8] = {0x12};
205 uchar xdata ReportTimetoMach[30] = {0xAA, 0xBB, 0xFF, 0xFF, 0x12};
206 uchar xdata com_receive_data[20]={0x00,0x00,0x00,0x00,0x00};
207 uchar xdata com_receive_subf=5;
208 bit idata buff_flag=0;
209 uchar idata buff_count,buff_number;
210 bit com_receive_f=0;
211 bit com_send_f=0;
212
213 uint xdata day_count;
214 uchar xdata year_count,day_count_temp1, day_count_temp2;
215
216 /*********************************************************************************?
217 /******************* Function declare *******************************************/
218 /*********************************************************************************/
219 void config (void);
220 void MCU_init(void);
221 void delay(uchar m);
222
223 /*********************************************************************************/
224 /*************************** ************************************/
225 /*************************** main ************************************/
226 /*************************** ************************************/
227 /*********************************************************************************/
228 void main(void)
229 {
230 1
231 1 /*********************************************************************/
232 1 /*data and system Initialized
233 1 /*********************************************************************/
234 1 uchar idata GPS_Count = 0;
235 1 //float idata start_temp = 0;
236 1 // uchar idata i;
237 1 float idata any_temp = 0;
238 1
239 1 config();
240 1 MCU_init();
C51 COMPILER V7.06 MAIN 01/12/2006 13:06:29 PAGE 5
241 1 LED_flag = 0;
242 1 LED1 = 0;
243 1
244 1 /* main_flag = 1;
245 1 height_flag = 0;
246 1 do{
247 1 ADC0CN |= 0x90; // A/D trans enabled
248 1 delay(10);
249 1 height = AD_buf[0]*256 + AD_buf[1];
250 1 if(height>0x0010)
251 1 {
252 1 potentiometer_data--;
253 1 SPI0_Init(potentiometer_data);
254 1 }
255 1 else if(height<1)
256 1 {
257 1 potentiometer_data++;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -