Rev 130 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 130 | Rev 243 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 | // + Copyright (c) 04.2007 Holger Buss |
2 | // + Copyright (c) 04.2007 Holger Buss |
3 | // + only for non-profit use |
3 | // + only for non-profit use |
4 | // + www.MikroKopter.com |
4 | // + www.MikroKopter.com |
5 | // + see the File "License.txt" for further Informations |
5 | // + see the File "License.txt" for further Informations |
6 | // + |
- | |
7 | // + GPS read out: |
- | |
8 | // + modified Version of the Pitschu Brushless Ufo - (c) Peter Schulten, Mülheim, Germany |
- | |
9 | // + only for non-profit use |
- | |
10 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Line 11... | Line 7... | ||
11 | 7 | ||
12 | #include "main.h" |
8 | #include "main.h" |
Line 40... | Line 36... | ||
40 | #define GPS_LEN2 5 |
36 | #define GPS_LEN2 5 |
41 | #define GPS_FILLING 6 |
37 | #define GPS_FILLING 6 |
42 | #define GPS_CKA 7 |
38 | #define GPS_CKA 7 |
43 | #define GPS_CKB 8 |
39 | #define GPS_CKB 8 |
Line 44... | Line -... | ||
44 | - | ||
45 | //gpsInfo_t gpsPoints[5]; // stored position to fly to (currently only 1 target supported) |
- | |
46 | //gpsInfo_t *gpsTarget; // points to one of the targets |
40 | |
Line 47... | Line 41... | ||
47 | gpsInfo_t actualPos; // measured position (last gps record) |
41 | gpsInfo_t actualPos; // measured position (last gps record) |
48 | 42 | ||
Line 49... | Line 43... | ||
49 | #define SYNC_CHAR1 0xb5 |
43 | #define SYNC_CHAR1 0xb5 |
50 | #define SYNC_CHAR2 0x62 |
- | |
51 | 44 | #define SYNC_CHAR2 0x62 |
|
52 | #define CLASS_NAV 0x01 |
- | |
53 | #define MSGID_POSECEF 0x01 |
- | |
54 | #define MSGID_STATUS 0x03 |
45 | |
55 | //#define MSGID_POSLLH 0x02 |
46 | #define CLASS_NAV 0x01 |
Line 56... | Line 47... | ||
56 | #define MSGID_VELECEF 0x11 |
47 | #define MSGID_STATUS 0x03 |
57 | //#define MSGID_POSUTM 0x08 |
48 | #define MSGID_POSUTM 0x08 |
Line 68... | Line 59... | ||
68 | unsigned long TTFF; // Time to first fix (millisecond time tag) |
59 | unsigned long TTFF; // Time to first fix (millisecond time tag) |
69 | unsigned long MSSS; // Milliseconds since Startup / Reset |
60 | unsigned long MSSS; // Milliseconds since Startup / Reset |
70 | uint8_t packetStatus; |
61 | uint8_t packetStatus; |
71 | } NAV_STATUS_t; |
62 | } NAV_STATUS_t; |
Line 72... | Line -... | ||
72 | - | ||
73 | /* |
- | |
74 | typedef struct { |
- | |
75 | unsigned long ITOW; // time of week |
- | |
76 | long LON; // longitude in 1e-07 deg |
- | |
77 | long LAT; // lattitude |
- | |
78 | long HEIGHT; // height in mm |
- | |
79 | long HMSL; // height above mean sea level im mm |
- | |
80 | unsigned long Hacc; // horizontal accuracy in mm |
- | |
81 | unsigned long Vacc; // vertical accuracy in mm |
- | |
82 | uint8_t packetStatus; |
- | |
83 | } NAV_POSLLH_t; |
- | |
Line 84... | Line 63... | ||
84 | 63 | ||
85 | 64 | ||
86 | typedef struct { |
65 | typedef struct { |
87 | unsigned long ITOW; // time of week |
66 | unsigned long ITOW; // time of week |
Line 104... | Line 83... | ||
104 | long Heading; // deg (1e-05) Heading 2-D |
83 | long Heading; // deg (1e-05) Heading 2-D |
105 | unsigned long SAcc; // cm/s Speed Accuracy Estimate |
84 | unsigned long SAcc; // cm/s Speed Accuracy Estimate |
106 | unsigned long CAcc; // deg Course / Heading Accuracy Estimate |
85 | unsigned long CAcc; // deg Course / Heading Accuracy Estimate |
107 | uint8_t packetStatus; |
86 | uint8_t packetStatus; |
108 | } NAV_VELNED_t; |
87 | } NAV_VELNED_t; |
109 | */ |
- | |
110 | - | ||
111 | typedef struct { |
- | |
112 | unsigned long ITOW; // ms GPS Millisecond Time of Week |
- | |
113 | long ECEF_X; // ecef x / cm |
- | |
114 | long ECEF_Y; // ecef y / cm |
- | |
115 | long ECEF_Z; // ecef z / cm |
- | |
116 | unsigned long Pacc; // Abweichung |
- | |
117 | uint8_t packetStatus; |
- | |
118 | } NAV_POSECEF_t ; |
- | |
119 | - | ||
120 | typedef struct { |
- | |
121 | unsigned long ITOW; // ms GPS Millisecond Time of Week |
- | |
122 | long ECEFVX; // ecef x velocity cm/s |
- | |
123 | long ECEFVY; // ecef y velocity cm/s |
- | |
124 | long ECEFVZ; // ecef z velocity cm/s |
- | |
125 | unsigned long SAcc; // Abweichung |
- | |
126 | uint8_t packetStatus; |
- | |
127 | } NAV_VELECEF_t; |
- | |
128 | - | ||
Line 129... | Line 88... | ||
129 | 88 | ||
130 | NAV_STATUS_t navStatus; |
- | |
131 | NAV_POSECEF_t navPosECEF; |
- | |
132 | NAV_VELECEF_t navVelECEF; |
- | |
133 | - | ||
134 | //NAV_POSLLH_t navPosLlh; |
89 | NAV_STATUS_t navStatus; |
135 | //NAV_POSUTM_t navPosUtm; |
90 | NAV_POSUTM_t navPosUtm; |
Line 136... | Line 91... | ||
136 | //NAV_VELECEF avVelNed; |
91 | NAV_VELNED_t navVelNed; |
137 | 92 | ||
138 | volatile char *ubxP, *ubxEp, *ubxSp; // pointers to packet currently transfered |
93 | volatile char *ubxP, *ubxEp, *ubxSp; // pointers to packet currently transfered |
139 | volatile uint8_t CK_A, CK_B; // UBX checksum bytes |
94 | volatile uint8_t CK_A, CK_B; // UBX checksum bytes |
Line 179... | Line 134... | ||
179 | 134 | ||
180 | void GPSscanData (void) |
135 | void GPSscanData (void) |
Line 181... | Line -... | ||
181 | { |
- | |
182 | - | ||
183 | - | ||
184 | if (navPosECEF.packetStatus == 1) // valid packet |
- | |
185 | { |
- | |
186 | actualPos.x = navPosECEF.ECEF_X; //ECEF X in cm |
- | |
187 | actualPos.y = navPosECEF.ECEF_Y; //ECEF Y in cm |
- | |
188 | actualPos.z = navPosECEF.ECEF_Z; //ECEF Z in cm |
- | |
Line 189... | Line 136... | ||
189 | navPosECEF.packetStatus = 0; |
136 | { |
190 | } |
137 | |
191 | 138 | ||
192 | 139 | ||
193 | if (navStatus.packetStatus == 1) // valid packet |
140 | if (navStatus.packetStatus == 1) // valid packet |
194 | { |
141 | { |
195 | actualPos.state = navStatus.GPSfix; |
- | |
196 | navStatus.packetStatus = 0; |
- | |
197 | } |
- | |
198 | - | ||
199 | if (navVelECEF.packetStatus == 1) // valid packet |
- | |
200 | { |
- | |
201 | actualPos.vx = navVelECEF.ECEFVX; //ECEF VEL X in cm/s |
- | |
202 | actualPos.vy = navVelECEF.ECEFVY; //ECEF VEL Y in cm/s |
- | |
203 | actualPos.vz = navVelECEF.ECEFVZ; //ECEF VEL Z in cm/s |
142 | actualPos.state = navStatus.GPSfix; |
204 | navVelECEF.packetStatus = 0; |
143 | navStatus.packetStatus = 0; |
205 | } |
144 | } |
206 | /* |
145 | |
207 | if (navPosUtm.packetStatus == 1) // valid packet |
146 | if (navPosUtm.packetStatus == 1) // valid packet |
208 | { |
147 | { |
209 | actualPos.northing = navPosUtm.NORTH; ///10; // in 10cm; |
148 | actualPos.northing = navPosUtm.NORTH; ///10; |
Line 210... | Line -... | ||
210 | actualPos.easting = navPosUtm.EAST; //10; |
- | |
211 | actualPos.altitude = navPosUtm.ALT; //10; |
- | |
212 | navPosUtm.packetStatus = 0; |
- | |
213 | } |
- | |
214 | 149 | actualPos.easting = navPosUtm.EAST; //10; |
|
215 | 150 | actualPos.altitude = navPosUtm.ALT; //10; |
|
216 | if (navPosLlh.packetStatus == 1) |
151 | navPosUtm.packetStatus = 0; |
- | 152 | } |
|
217 | navPosLlh.packetStatus = 0; |
153 | |
Line 218... | Line 154... | ||
218 | |
154 | if (navVelNed.packetStatus == 1){ |
219 | if (navVelNed.packetStatus == 1){ |
- | |
220 | actualPos.velNorth = navVelNed.VEL_N; |
- | |
221 | actualPos.velEast = navVelNed.VEL_E; |
155 | actualPos.velNorth = navVelNed.VEL_N; |
222 | navVelNed.packetStatus = 0;} |
- | |
223 | 156 | actualPos.velEast = navVelNed.VEL_E; |
|
Line 224... | Line 157... | ||
224 | navPosLlh and navVelNed currently not used |
157 | actualPos.velDown = navVelNed.VEL_D; |
225 | */ |
158 | navVelNed.packetStatus = 0;} |
226 | 159 | ||
227 | if (actualPos.state != 0){ROT_ON;} //-> Rot blinkt mit 4Hz wenn GPS Signal brauchbar |
160 | if (actualPos.state == 2){ROT_ON; gps_new=1;} //-> Rot blinkt mit 4Hz wenn GPS 2D-Fix |
Line 238... | Line 171... | ||
238 | static unsigned char UartState = 0; |
171 | static unsigned char UartState = 0; |
239 | unsigned char CrcOkay = 0; |
172 | unsigned char CrcOkay = 0; |
Line 240... | Line 173... | ||
240 | 173 | ||
Line 241... | Line -... | ||
241 | SioTmp = UDR; |
- | |
242 | - | ||
243 | - | ||
244 | 174 | SioTmp = UDR; |
|
245 | 175 | ||
Line 246... | Line 176... | ||
246 | uint8_t c; |
176 | uint8_t c; |
247 | uint8_t re; |
177 | uint8_t re; |
Line 294... | Line 224... | ||
294 | ubxP = (char*)&navStatus; |
224 | ubxP = (char*)&navStatus; |
295 | ubxEp = (char*)(&navStatus + sizeof(NAV_STATUS_t)); |
225 | ubxEp = (char*)(&navStatus + sizeof(NAV_STATUS_t)); |
296 | ubxSp = (char*)&navStatus.packetStatus; |
226 | ubxSp = (char*)&navStatus.packetStatus; |
297 | ignorePacket = navStatus.packetStatus; |
227 | ignorePacket = navStatus.packetStatus; |
298 | break; |
228 | break; |
299 | case MSGID_POSECEF: |
- | |
300 | ubxP = (char*)&navPosECEF; |
- | |
301 | ubxEp = (char*)(&navPosECEF + sizeof(NAV_POSECEF_t)); |
- | |
302 | ubxSp = (char*)&navPosECEF.packetStatus; |
- | |
303 | ignorePacket = navPosECEF.packetStatus; |
- | |
304 | break; |
- | |
305 | case MSGID_VELECEF: |
- | |
306 | ubxP = (char*)&navVelECEF; |
- | |
307 | ubxEp = (char*)(&navVelECEF + sizeof(NAV_VELECEF_t)); |
- | |
308 | ubxSp = (char*)&navVelECEF.packetStatus; |
- | |
309 | ignorePacket = navVelECEF.packetStatus; |
- | |
310 | break; |
- | |
311 | - | ||
312 | /* |
- | |
313 | case MSGID_POSLLH: |
- | |
314 | ubxP = (char*)&navPosLlh; |
- | |
315 | ubxEp = (char*)(&navPosLlh + sizeof(NAV_POSLLH_t)); |
- | |
316 | ubxSp = (char*)&navPosLlh.packetStatus; |
- | |
317 | ignorePacket = navPosLlh.packetStatus; |
- | |
318 | break; |
- | |
319 | case MSGID_POSUTM: |
229 | case MSGID_POSUTM: |
320 | ubxP = (char*)&navPosUtm; |
230 | ubxP = (char*)&navPosUtm; |
321 | ubxEp = (char*)(&navPosUtm + sizeof(NAV_POSUTM_t)); |
231 | ubxEp = (char*)(&navPosUtm + sizeof(NAV_POSUTM_t)); |
322 | ubxSp = (char*)&navPosUtm.packetStatus; |
232 | ubxSp = (char*)&navPosUtm.packetStatus; |
323 | ignorePacket = navPosUtm.packetStatus; |
233 | ignorePacket = navPosUtm.packetStatus; |
Line 326... | Line 236... | ||
326 | ubxP = (char*)&navVelNed; |
236 | ubxP = (char*)&navVelNed; |
327 | ubxEp = (char*)(&navVelNed + sizeof(NAV_VELNED_t)); |
237 | ubxEp = (char*)(&navVelNed + sizeof(NAV_VELNED_t)); |
328 | ubxSp = (char*)&navVelNed.packetStatus; |
238 | ubxSp = (char*)&navVelNed.packetStatus; |
329 | ignorePacket = navVelNed.packetStatus; |
239 | ignorePacket = navVelNed.packetStatus; |
330 | break; |
240 | break; |
331 | */ |
241 | |
Line 332... | Line 242... | ||
332 | 242 | ||
333 | default: |
243 | default: |
334 | ignorePacket = 1; |
244 | ignorePacket = 1; |
335 | ubxSp = (char*)0; |
245 | ubxSp = (char*)0; |
Line 377... | Line 287... | ||
377 | { |
287 | { |
378 | gpsState = GPS_EMPTY; |
288 | gpsState = GPS_EMPTY; |
379 | GPSscanData (); //Test kann ggf. wieder gelöscht werden! |
289 | GPSscanData (); //Test kann ggf. wieder gelöscht werden! |
380 | } |
290 | } |
381 | GPSscanData (); |
291 | GPSscanData (); |
382 | - | ||
383 | 292 | ||
384 | - | ||
385 | - | ||
386 | - | ||
387 | - | ||
Line 388... | Line 293... | ||
388 | 293 | ||
389 | if(buf_ptr >= MAX_EMPFANGS_BUFF) UartState = 0; |
294 | if(buf_ptr >= MAX_EMPFANGS_BUFF) UartState = 0; |
390 | if(SioTmp == '\r' && UartState == 2) |
295 | if(SioTmp == '\r' && UartState == 2) |
391 | { |
296 | { |
Line 400... | Line 305... | ||
400 | if(!NeuerDatensatzEmpfangen && CrcOkay) // Datensatz schon verarbeitet |
305 | if(!NeuerDatensatzEmpfangen && CrcOkay) // Datensatz schon verarbeitet |
401 | { |
306 | { |
402 | NeuerDatensatzEmpfangen = 1; |
307 | NeuerDatensatzEmpfangen = 1; |
403 | AnzahlEmpfangsBytes = buf_ptr; |
308 | AnzahlEmpfangsBytes = buf_ptr; |
404 | RxdBuffer[buf_ptr] = '\r'; |
309 | RxdBuffer[buf_ptr] = '\r'; |
405 | if(/*(RxdBuffer[1] == MeineSlaveAdresse || (RxdBuffer[1] == 'a')) && */(RxdBuffer[2] == 'R')) wdt_enable(WDTO_250MS); // Reset-Commando |
310 | if(RxdBuffer[2] == 'R') wdt_enable(WDTO_250MS); // Reset-Commando |
406 | } |
311 | } |
407 | } |
312 | } |
408 | else |
313 | else |
409 | switch(UartState) |
314 | switch(UartState) |
410 | { |
315 | { |
Line 447... | Line 352... | ||
447 | UebertragungAbgeschlossen = 0; |
352 | UebertragungAbgeschlossen = 0; |
448 | UDR = SendeBuffer[0]; |
353 | UDR = SendeBuffer[0]; |
449 | } |
354 | } |
Line -... | Line 355... | ||
- | 355 | ||
450 | 356 | ||
451 | 357 | ||
452 | // -------------------------------------------------------------------------- |
358 | // -------------------------------------------------------------------------- |
453 | void SendOutData(unsigned char cmd,unsigned char modul, unsigned char *snd, unsigned char len) |
359 | void SendOutData(unsigned char cmd,unsigned char modul, unsigned char *snd, unsigned char len) |
454 | { |
360 | { |
Line 519... | Line 425... | ||
519 | /* for(unsigned char i=0; i<4;i++) |
425 | /* for(unsigned char i=0; i<4;i++) |
520 | { |
426 | { |
521 | EE_CheckAndWrite(&EE_Buffer[EE_DEBUGWERTE + i*2], DebugIn.Analog[i]); |
427 | EE_CheckAndWrite(&EE_Buffer[EE_DEBUGWERTE + i*2], DebugIn.Analog[i]); |
522 | EE_CheckAndWrite(&EE_Buffer[EE_DEBUGWERTE + i*2 + 1], DebugIn.Analog[i] >> 8); |
428 | EE_CheckAndWrite(&EE_Buffer[EE_DEBUGWERTE + i*2 + 1], DebugIn.Analog[i] >> 8); |
523 | }*/ |
429 | }*/ |
524 | RemoteTasten |= DebugIn.RemoteTasten; |
430 | //RemoteTasten |= DebugIn.RemoteTasten; |
525 | DebugDataAnforderung = 1; |
431 | DebugDataAnforderung = 1; |
526 | break; |
432 | break; |
Line 527... | Line 433... | ||
527 | 433 | ||
528 | case 'h':// x-1 Displayzeilen |
434 | case 'h':// x-1 Displayzeilen |
Line 614... | Line 520... | ||
614 | //UBRR = 33; |
520 | //UBRR = 33; |
615 | //öffnet einen Kanal für printf (STDOUT) |
521 | //öffnet einen Kanal für printf (STDOUT) |
616 | //fdevopen (uart_putchar, 0); |
522 | //fdevopen (uart_putchar, 0); |
617 | //sbi(PORTD,4); |
523 | //sbi(PORTD,4); |
618 | Debug_Timer = SetDelay(200); |
524 | Debug_Timer = SetDelay(200); |
619 | - | ||
620 | gpsState = GPS_EMPTY; |
- | |
621 | } |
525 | } |
Line 622... | Line 526... | ||
622 | 526 | ||
623 | //--------------------------------------------------------------------------------------------- |
527 | //--------------------------------------------------------------------------------------------- |
624 | void DatenUebertragung(void) |
528 | void DatenUebertragung(void) |
Line 641... | Line 545... | ||
641 | 545 | ||
642 | if(DebugDisplayAnforderung && UebertragungAbgeschlossen) |
546 | if(DebugDisplayAnforderung && UebertragungAbgeschlossen) |
643 | { |
547 | { |
644 | Menu(); |
548 | Menu(); |
645 | DebugDisplayAnforderung = 0; |
549 | DebugDisplayAnforderung = 0; |
- | 550 | if(++dis_zeile == 4) |
|
- | 551 | { |
|
- | 552 | SendOutData('4',0,&PPM_in,sizeof(PPM_in)); // DisplayZeile übertragen |
|
- | 553 | dis_zeile = -1; |
|
646 | if(++dis_zeile == 4) dis_zeile = 0; |
554 | } |
647 | SendOutData('0' + dis_zeile,0,&DisplayBuff[20 * dis_zeile],20); // DisplayZeile übertragen |
555 | else SendOutData('0' + dis_zeile,0,&DisplayBuff[20 * dis_zeile],20); // DisplayZeile übertragen |
648 | } |
556 | } |
649 | if(GetVersionAnforderung && UebertragungAbgeschlossen) |
557 | if(GetVersionAnforderung && UebertragungAbgeschlossen) |
650 | { |
558 | { |
651 | SendOutData('V',MeineSlaveAdresse,(unsigned char *) &VersionInfo,sizeof(VersionInfo)); |
559 | SendOutData('V',MeineSlaveAdresse,(unsigned char *) &VersionInfo,sizeof(VersionInfo)); |