Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1184 | pangu | 1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 | // + Copyright (c) 04.2007 Holger Buss |
||
3 | // + only for non-profit use |
||
4 | // + www.MikroKopter.com |
||
5 | // + see the File "License.txt" for further Informations |
||
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
7 | #include <stdarg.h> |
||
8 | #include <string.h> |
||
9 | #include "main.h" |
||
10 | #include "uart.h" |
||
11 | |||
12 | |||
13 | #define FC_ADDRESS 1 |
||
14 | #define NC_ADDRESS 2 |
||
15 | #define MK3MAG_ADDRESS 3 |
||
16 | |||
17 | unsigned char GetExternalControl = 0,DebugDisplayAnforderung1 = 0, DebugDisplayAnforderung = 0,DebugDataAnforderung = 0,GetVersionAnforderung = 0, GetPPMChannelAnforderung = 0; |
||
18 | unsigned char DisplayLine = 0; |
||
19 | unsigned volatile char SioTmp = 0; |
||
20 | unsigned volatile char SendeBuffer[MAX_SENDE_BUFF]; |
||
21 | unsigned volatile char RxdBuffer[MAX_EMPFANGS_BUFF]; |
||
22 | unsigned volatile char NMEABuffer[MAX_EMPFANGS_BUFF]; |
||
23 | unsigned volatile char NeuerDatensatzEmpfangen = 0; |
||
24 | unsigned volatile char NeueKoordinateEmpfangen = 0; |
||
25 | unsigned volatile char UebertragungAbgeschlossen = 1; |
||
26 | unsigned volatile char CntCrcError = 0; |
||
27 | unsigned volatile char AnzahlEmpfangsBytes = 0; |
||
28 | unsigned char *pRxData = 0; |
||
29 | unsigned char RxDataLen = 0; |
||
30 | unsigned volatile char PC_DebugTimeout = 0; |
||
31 | |||
32 | unsigned char DebugTextAnforderung = 255; |
||
33 | unsigned char PcZugriff = 100; |
||
34 | unsigned char MotorTest[4] = {0,0,0,0}; |
||
35 | unsigned char MeineSlaveAdresse = 1; // Flight-Ctrl |
||
36 | unsigned char ConfirmFrame; |
||
37 | struct str_DebugOut DebugOut; |
||
38 | struct str_ExternControl ExternControl; |
||
39 | struct str_VersionInfo VersionInfo; |
||
40 | struct str_WinkelOut WinkelOut; |
||
41 | struct str_Data3D Data3D; |
||
42 | |||
43 | int Debug_Timer,Kompass_Timer,Timer3D; |
||
44 | unsigned int DebugDataIntervall = 200, Intervall3D = 0; |
||
45 | |||
46 | const unsigned char ANALOG_TEXT[32][16] = |
||
47 | { |
||
48 | //1234567890123456 |
||
49 | "AngleNick ", //0 |
||
50 | "AngleRoll ", |
||
51 | "AccNick ", |
||
52 | "AccRoll ", |
||
53 | "GyroGier ", |
||
54 | "Hight Value ", //5 |
||
55 | "AccZ ", |
||
56 | "Gas ", |
||
57 | "Compass Value ", |
||
58 | "Voltage ", |
||
59 | "Empfang ", //10 |
||
60 | "Gyro Kompass ", |
||
61 | "Motor Front ", |
||
62 | "Motor Rear ", |
||
63 | "Motor Left ", |
||
64 | "Motor Right ", //15 |
||
65 | " ", |
||
66 | " ", |
||
67 | " ", |
||
68 | "MK3Mag CalState ", |
||
69 | "Servo ", //20 |
||
70 | " ", |
||
71 | " ", |
||
72 | " ", |
||
73 | " ", |
||
74 | " ", //25 |
||
75 | " ", |
||
76 | "Kalman_MaxDrift ", |
||
77 | " ", |
||
78 | " ", |
||
79 | "GPS_Nick ", //30 |
||
80 | "GPS_Roll " |
||
81 | }; |
||
82 | |||
83 | |||
84 | |||
85 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
86 | //++ Sende-Part der Datenübertragung |
||
87 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
88 | SIGNAL(INT_VEC_TX) |
||
89 | { |
||
90 | static unsigned int ptr = 0; |
||
91 | unsigned char tmp_tx; |
||
92 | if(!UebertragungAbgeschlossen) |
||
93 | { |
||
94 | ptr++; // die [0] wurde schon gesendet |
||
95 | tmp_tx = SendeBuffer[ptr]; |
||
96 | if((tmp_tx == '\r') || (ptr == MAX_SENDE_BUFF)) |
||
97 | { |
||
98 | ptr = 0; |
||
99 | UebertragungAbgeschlossen = 1; |
||
100 | } |
||
101 | UDR = tmp_tx; |
||
102 | } |
||
103 | else ptr = 0; |
||
104 | } |
||
105 | |||
106 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
107 | //++ Empfangs-Part der Datenübertragung, incl. CRC-Auswertung |
||
108 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
109 | SIGNAL(INT_VEC_RX) |
||
110 | { |
||
111 | static unsigned int crc; |
||
112 | static unsigned char crc1,crc2,buf_ptr; |
||
113 | static unsigned char UartState = 0; |
||
114 | unsigned char CrcOkay = 0; |
||
115 | |||
116 | SioTmp = UDR; |
||
117 | if(buf_ptr >= MAX_EMPFANGS_BUFF) UartState = 0; |
||
118 | if(SioTmp == '\r' && UartState == 2) |
||
119 | { |
||
120 | UartState = 0; |
||
121 | crc -= RxdBuffer[buf_ptr-2]; |
||
122 | crc -= RxdBuffer[buf_ptr-1]; |
||
123 | crc %= 4096; |
||
124 | crc1 = '=' + crc / 64; |
||
125 | crc2 = '=' + crc % 64; |
||
126 | CrcOkay = 0; |
||
127 | if((crc1 == RxdBuffer[buf_ptr-2]) && (crc2 == RxdBuffer[buf_ptr-1])) CrcOkay = 1; else { CrcOkay = 0; CntCrcError++;}; |
||
128 | if(!NeuerDatensatzEmpfangen && CrcOkay) // Datensatz schon verarbeitet |
||
129 | { |
||
130 | NeuerDatensatzEmpfangen = 1; |
||
131 | AnzahlEmpfangsBytes = buf_ptr + 1; |
||
132 | RxdBuffer[buf_ptr] = '\r'; |
||
133 | if(RxdBuffer[2] == 'R') wdt_enable(WDTO_250MS); // Reset-Commando |
||
134 | } |
||
135 | } |
||
136 | else |
||
137 | switch(UartState) |
||
138 | { |
||
139 | case 0: |
||
140 | if(SioTmp == '#' && !NeuerDatensatzEmpfangen) UartState = 1; // Startzeichen und Daten schon verarbeitet |
||
141 | buf_ptr = 0; |
||
142 | RxdBuffer[buf_ptr++] = SioTmp; |
||
143 | crc = SioTmp; |
||
144 | break; |
||
145 | case 1: // Adresse auswerten |
||
146 | UartState++; |
||
147 | RxdBuffer[buf_ptr++] = SioTmp; |
||
148 | crc += SioTmp; |
||
149 | break; |
||
150 | case 2: // Eingangsdaten sammeln |
||
151 | RxdBuffer[buf_ptr] = SioTmp; |
||
152 | if(buf_ptr < MAX_EMPFANGS_BUFF) buf_ptr++; |
||
153 | else UartState = 0; |
||
154 | crc += SioTmp; |
||
155 | break; |
||
156 | default: |
||
157 | UartState = 0; |
||
158 | break; |
||
159 | } |
||
160 | } |
||
161 | |||
162 | |||
163 | // -------------------------------------------------------------------------- |
||
164 | void AddCRC(unsigned int wieviele) |
||
165 | { |
||
166 | unsigned int tmpCRC = 0,i; |
||
167 | for(i = 0; i < wieviele;i++) |
||
168 | { |
||
169 | tmpCRC += SendeBuffer[i]; |
||
170 | } |
||
171 | tmpCRC %= 4096; |
||
172 | SendeBuffer[i++] = '=' + tmpCRC / 64; |
||
173 | SendeBuffer[i++] = '=' + tmpCRC % 64; |
||
174 | SendeBuffer[i++] = '\r'; |
||
175 | UebertragungAbgeschlossen = 0; |
||
176 | UDR = SendeBuffer[0]; |
||
177 | } |
||
178 | |||
179 | |||
180 | |||
181 | // -------------------------------------------------------------------------- |
||
182 | void SendOutData(unsigned char cmd,unsigned char address, unsigned char BufferAnzahl, ...) //unsigned char *snd, unsigned char len) |
||
183 | { |
||
184 | va_list ap; |
||
185 | unsigned int pt = 0; |
||
186 | unsigned char a,b,c; |
||
187 | unsigned char ptr = 0; |
||
188 | |||
189 | unsigned char *snd = 0; |
||
190 | int len = 0; |
||
191 | |||
192 | SendeBuffer[pt++] = '#'; // Startzeichen |
||
193 | SendeBuffer[pt++] = 'a' + address; // Adresse (a=0; b=1,...) |
||
194 | SendeBuffer[pt++] = cmd; // Commando |
||
195 | |||
196 | va_start(ap, BufferAnzahl); |
||
197 | if(BufferAnzahl) |
||
198 | { |
||
199 | snd = va_arg(ap, unsigned char*); |
||
200 | len = va_arg(ap, int); |
||
201 | ptr = 0; |
||
202 | BufferAnzahl--; |
||
203 | } |
||
204 | while(len) |
||
205 | { |
||
206 | if(len) |
||
207 | { |
||
208 | a = snd[ptr++]; |
||
209 | len--; |
||
210 | if((!len) && BufferAnzahl) |
||
211 | { |
||
212 | snd = va_arg(ap, unsigned char*); |
||
213 | len = va_arg(ap, int); |
||
214 | ptr = 0; |
||
215 | BufferAnzahl--; |
||
216 | } |
||
217 | } |
||
218 | else a = 0; |
||
219 | if(len) |
||
220 | { |
||
221 | b = snd[ptr++]; |
||
222 | len--; |
||
223 | if((!len) && BufferAnzahl) |
||
224 | { |
||
225 | snd = va_arg(ap, unsigned char*); |
||
226 | len = va_arg(ap, int); |
||
227 | ptr = 0; |
||
228 | BufferAnzahl--; |
||
229 | } |
||
230 | } |
||
231 | else b = 0; |
||
232 | if(len) |
||
233 | { |
||
234 | c = snd[ptr++]; |
||
235 | len--; |
||
236 | if((!len) && BufferAnzahl) |
||
237 | { |
||
238 | snd = va_arg(ap, unsigned char*); |
||
239 | len = va_arg(ap, int); |
||
240 | ptr = 0; |
||
241 | BufferAnzahl--; |
||
242 | } |
||
243 | } |
||
244 | else c = 0; |
||
245 | SendeBuffer[pt++] = '=' + (a >> 2); |
||
246 | SendeBuffer[pt++] = '=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4)); |
||
247 | SendeBuffer[pt++] = '=' + (((b & 0x0f) << 2) | ((c & 0xc0) >> 6)); |
||
248 | SendeBuffer[pt++] = '=' + ( c & 0x3f); |
||
249 | } |
||
250 | va_end(ap); |
||
251 | AddCRC(pt); |
||
252 | } |
||
253 | |||
254 | |||
255 | // -------------------------------------------------------------------------- |
||
256 | void Decode64(void) // die daten werden im rx buffer dekodiert, das geht nur, weil aus 4 byte immer 3 gemacht werden. |
||
257 | { |
||
258 | unsigned char a,b,c,d; |
||
259 | unsigned char x,y,z; |
||
260 | unsigned char ptrIn = 3; // start at begin of data block |
||
261 | unsigned char ptrOut = 3; |
||
262 | unsigned char len = AnzahlEmpfangsBytes - 6; // von der Gesamtbytezahl eines Frames gehen 3 Bytes des Headers ('#',Addr, Cmd) und 3 Bytes des Footers (CRC1, CRC2, '\r') ab. |
||
263 | |||
264 | while(len) |
||
265 | { |
||
266 | a = RxdBuffer[ptrIn++] - '='; |
||
267 | b = RxdBuffer[ptrIn++] - '='; |
||
268 | c = RxdBuffer[ptrIn++] - '='; |
||
269 | d = RxdBuffer[ptrIn++] - '='; |
||
270 | |||
271 | x = (a << 2) | (b >> 4); |
||
272 | y = ((b & 0x0f) << 4) | (c >> 2); |
||
273 | z = ((c & 0x03) << 6) | d; |
||
274 | |||
275 | if(len--) RxdBuffer[ptrOut++] = x; else break; |
||
276 | if(len--) RxdBuffer[ptrOut++] = y; else break; |
||
277 | if(len--) RxdBuffer[ptrOut++] = z; else break; |
||
278 | } |
||
279 | pRxData = (unsigned char*)&RxdBuffer[3]; // decodierte Daten beginnen beim 4. Byte |
||
280 | RxDataLen = ptrOut - 3; // wie viele Bytes wurden dekodiert? |
||
281 | |||
282 | } |
||
283 | |||
284 | // -------------------------------------------------------------------------- |
||
285 | void BearbeiteRxDaten(void) |
||
286 | { |
||
287 | if(!NeuerDatensatzEmpfangen) return; |
||
288 | |||
289 | unsigned char tempchar1, tempchar2; |
||
290 | Decode64(); // dekodiere datenblock im Empfangsbuffer |
||
291 | switch(RxdBuffer[1]-'a') // check for Slave Address |
||
292 | { |
||
293 | case FC_ADDRESS: // FC special commands |
||
294 | |||
295 | switch(RxdBuffer[2]) |
||
296 | { |
||
297 | case 'K':// Kompasswert |
||
298 | memcpy((unsigned char *)&KompassValue , (unsigned char *)pRxData, sizeof(KompassValue)); |
||
299 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
||
300 | break; |
||
301 | |||
302 | case 't':// Motortest |
||
303 | memcpy(&MotorTest[0], (unsigned char *)pRxData, sizeof(MotorTest)); |
||
304 | //while(!UebertragungAbgeschlossen); |
||
305 | //SendOutData('T', MeineSlaveAdresse, 0); |
||
306 | PcZugriff = 255; |
||
307 | break; |
||
308 | |||
309 | case 'p': // get PPM Channels |
||
310 | GetPPMChannelAnforderung = 1; |
||
311 | break; |
||
312 | |||
313 | case 'q':// "Get"-Anforderung für Settings |
||
314 | // Bei Get werden die vom PC einstellbaren Werte vom PC zurückgelesen |
||
315 | if(pRxData[0] == 0xFF) |
||
316 | { |
||
317 | pRxData[0] = GetActiveParamSetNumber(); |
||
318 | } |
||
319 | // limit settings range |
||
320 | if(pRxData[0] < 1) pRxData[0] = 1; // limit to 5 |
||
321 | else if(pRxData[0] > 5) pRxData[0] = 5; // limit to 5 |
||
322 | // load requested parameter set |
||
323 | ReadParameterSet(pRxData[0], (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
||
324 | |||
325 | while(!UebertragungAbgeschlossen); |
||
326 | tempchar1 = pRxData[0]; |
||
327 | tempchar2 = EE_DATENREVISION; |
||
328 | SendOutData('Q', FC_ADDRESS, 3, &tempchar1, sizeof(tempchar1), &tempchar2, sizeof(tempchar2), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
||
329 | break; |
||
330 | |||
331 | case 's': // Parametersatz speichern |
||
332 | if((1 <= pRxData[0]) && (pRxData[0] <= 5) && (pRxData[1] == EE_DATENREVISION)) // check for setting to be in range |
||
333 | { |
||
334 | memcpy((unsigned char *) &EE_Parameter.Kanalbelegung[0], (unsigned char *)&pRxData[2], STRUCT_PARAM_LAENGE); |
||
335 | WriteParameterSet(pRxData[0], (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
||
336 | Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L; |
||
337 | Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L; |
||
338 | SetActiveParamSetNumber(pRxData[0]); |
||
339 | tempchar1 = GetActiveParamSetNumber(); |
||
340 | Piep(tempchar1); |
||
341 | } |
||
342 | else |
||
343 | { |
||
344 | tempchar1 = 0; // mark in response an invlid setting |
||
345 | } |
||
346 | while(!UebertragungAbgeschlossen); |
||
347 | SendOutData('S', FC_ADDRESS, 1, &tempchar1, sizeof(tempchar1)); |
||
348 | break; |
||
349 | |||
350 | } // case FC_ADDRESS: |
||
351 | |||
352 | default: // any Slave Address |
||
353 | |||
354 | switch(RxdBuffer[2]) |
||
355 | { |
||
356 | // 't' comand placed here only for compatibility to BL |
||
357 | case 't':// Motortest |
||
358 | memcpy(&MotorTest[0], (unsigned char *)pRxData, sizeof(MotorTest)); |
||
359 | while(!UebertragungAbgeschlossen); |
||
360 | SendOutData('T', MeineSlaveAdresse, 0); |
||
361 | PcZugriff = 255; |
||
362 | break; |
||
363 | // 'K' comand placed here only for compatibility to old MK3MAG software, that does not send the right Slave Address |
||
364 | case 'K':// Kompasswert |
||
365 | memcpy((unsigned char *)&KompassValue , (unsigned char *)pRxData, sizeof(KompassValue)); |
||
366 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
||
367 | break; |
||
368 | case 'a':// Texte der Analogwerte |
||
369 | DebugTextAnforderung = pRxData[0]; |
||
370 | if (DebugTextAnforderung > 31) DebugTextAnforderung = 31; |
||
371 | PcZugriff = 255; |
||
372 | break; |
||
373 | case 'b': |
||
374 | memcpy((unsigned char *)&ExternControl, (unsigned char *)pRxData, sizeof(ExternControl)); |
||
375 | ConfirmFrame = ExternControl.Frame; |
||
376 | PcZugriff = 255; |
||
377 | break; |
||
378 | case 'c': // Poll the 3D-Data |
||
379 | if(!Intervall3D) { if(pRxData[0]) Timer3D = SetDelay(pRxData[0] * 10);} |
||
380 | Intervall3D = pRxData[0] * 10; |
||
381 | break; |
||
382 | case 'd': // Poll the debug data |
||
383 | DebugDataIntervall = pRxData[0] * 10; |
||
384 | if(DebugDataIntervall > 0) DebugDataAnforderung = 1; |
||
385 | break; |
||
386 | |||
387 | case 'h':// x-1 Displayzeilen |
||
388 | PcZugriff = 255; |
||
389 | RemoteKeys |= pRxData[0]; |
||
390 | if(RemoteKeys) DisplayLine = 0; |
||
391 | DebugDisplayAnforderung = 1; |
||
392 | break; |
||
393 | |||
394 | case 'l':// x-1 Displayzeilen |
||
395 | PcZugriff = 255; |
||
396 | MenuePunkt = pRxData[0]; |
||
397 | DebugDisplayAnforderung1 = 1; |
||
398 | break; |
||
399 | case 'v': // Version-Anforderung und Ausbaustufe |
||
400 | GetVersionAnforderung = 1; |
||
401 | break; |
||
402 | |||
403 | case 'g':// |
||
404 | GetExternalControl = 1; |
||
405 | break; |
||
406 | } |
||
407 | break; // default: |
||
408 | } |
||
409 | NeuerDatensatzEmpfangen = 0; |
||
410 | pRxData = 0; |
||
411 | RxDataLen = 0; |
||
412 | } |
||
413 | |||
414 | //############################################################################ |
||
415 | //Routine für die Serielle Ausgabe |
||
416 | int uart_putchar (char c) |
||
417 | //############################################################################ |
||
418 | { |
||
419 | if (c == '\n') |
||
420 | uart_putchar('\r'); |
||
421 | //Warten solange bis Zeichen gesendet wurde |
||
422 | loop_until_bit_is_set(USR, UDRE); |
||
423 | //Ausgabe des Zeichens |
||
424 | UDR = c; |
||
425 | |||
426 | return (0); |
||
427 | } |
||
428 | |||
429 | // -------------------------------------------------------------------------- |
||
430 | void WriteProgramData(unsigned int pos, unsigned char wert) |
||
431 | { |
||
432 | //if (ProgramLocation == IN_RAM) Buffer[pos] = wert; |
||
433 | // else eeprom_write_byte(&EE_Buffer[pos], wert); |
||
434 | // Buffer[pos] = wert; |
||
435 | } |
||
436 | |||
437 | //############################################################################ |
||
438 | //INstallation der Seriellen Schnittstelle |
||
439 | void UART_Init (void) |
||
440 | //############################################################################ |
||
441 | { |
||
442 | //Enable TXEN im Register UCR TX-Data Enable & RX Enable |
||
443 | |||
444 | UCR=(1 << TXEN) | (1 << RXEN); |
||
445 | // UART Double Speed (U2X) |
||
446 | USR |= (1<<U2X); |
||
447 | // RX-Interrupt Freigabe |
||
448 | UCSRB |= (1<<RXCIE); |
||
449 | // TX-Interrupt Freigabe |
||
450 | UCSRB |= (1<<TXCIE); |
||
451 | |||
452 | //Teiler wird gesetzt |
||
453 | UBRR=(SYSCLK / (BAUD_RATE * 8L) - 1); |
||
454 | //UBRR = 33; |
||
455 | //öffnet einen Kanal für printf (STDOUT) |
||
456 | //fdevopen (uart_putchar, 0); |
||
457 | //sbi(PORTD,4); |
||
458 | Debug_Timer = SetDelay(DebugDataIntervall); |
||
459 | Kompass_Timer = SetDelay(220); |
||
460 | |||
461 | VersionInfo.SWMajor = VERSION_MAJOR; |
||
462 | VersionInfo.SWMinor = VERSION_MINOR; |
||
463 | VersionInfo.SWPatch = VERSION_PATCH; |
||
464 | VersionInfo.ProtoMajor = VERSION_SERIAL_MAJOR; |
||
465 | VersionInfo.ProtoMinor = VERSION_SERIAL_MINOR; |
||
466 | |||
467 | pRxData = 0; |
||
468 | RxDataLen = 0; |
||
469 | } |
||
470 | |||
471 | //--------------------------------------------------------------------------------------------- |
||
472 | void DatenUebertragung(void) |
||
473 | { |
||
474 | if(!UebertragungAbgeschlossen) return; |
||
475 | |||
476 | if(DebugDisplayAnforderung && UebertragungAbgeschlossen) |
||
477 | { |
||
478 | Menu(); |
||
479 | SendOutData('H', FC_ADDRESS, 2, &DisplayLine, sizeof(DisplayLine), &DisplayBuff[DisplayLine * 20], 20); |
||
480 | DisplayLine++; |
||
481 | if(DisplayLine >= 4) DisplayLine = 0; |
||
482 | DebugDisplayAnforderung = 0; |
||
483 | } |
||
484 | if(DebugDisplayAnforderung1 && UebertragungAbgeschlossen) |
||
485 | { |
||
486 | Menu(); |
||
487 | SendOutData('L', FC_ADDRESS, 3, &MenuePunkt, sizeof(MenuePunkt), &MaxMenue, sizeof(MaxMenue), DisplayBuff, sizeof(DisplayBuff)); |
||
488 | DebugDisplayAnforderung1 = 0; |
||
489 | } |
||
490 | if(GetVersionAnforderung && UebertragungAbgeschlossen) |
||
491 | { |
||
492 | SendOutData('V', FC_ADDRESS, 1, (unsigned char *) &VersionInfo, sizeof(VersionInfo)); |
||
493 | GetVersionAnforderung = 0; |
||
494 | } |
||
495 | |||
496 | if(GetExternalControl && UebertragungAbgeschlossen) // Bei Get werden die vom PC einstellbaren Werte vom PC zurückgelesen |
||
497 | { |
||
498 | SendOutData('G',MeineSlaveAdresse, 1, (unsigned char *) &ExternControl, sizeof(ExternControl)); |
||
499 | GetExternalControl = 0; |
||
500 | } |
||
501 | if((CheckDelay(Kompass_Timer)) && UebertragungAbgeschlossen) |
||
502 | { |
||
503 | WinkelOut.Winkel[0] = (int) (IntegralNick / (EE_Parameter.GyroAccFaktor * 4)); // etwa in 0.1 Grad |
||
504 | WinkelOut.Winkel[1] = (int) (IntegralRoll / (EE_Parameter.GyroAccFaktor * 4)); // etwa in 0.1 Grad |
||
505 | WinkelOut.UserParameter[0] = Parameter_UserParam1; |
||
506 | WinkelOut.UserParameter[1] = Parameter_UserParam2; |
||
507 | SendOutData('w', MK3MAG_ADDRESS, 1, (unsigned char *) &WinkelOut,sizeof(WinkelOut)); |
||
508 | if(WinkelOut.CalcState > 4) WinkelOut.CalcState = 6; // wird dann in SPI auf Null gesetzt |
||
509 | Kompass_Timer = SetDelay(99); |
||
510 | } |
||
511 | if(((DebugDataIntervall>0 && CheckDelay(Debug_Timer)) || DebugDataAnforderung) && UebertragungAbgeschlossen) |
||
512 | { |
||
513 | SendOutData('D', FC_ADDRESS, 1, (unsigned char *) &DebugOut,sizeof(DebugOut)); |
||
514 | DebugDataAnforderung = 0; |
||
515 | if(DebugDataIntervall>0) Debug_Timer = SetDelay(DebugDataIntervall); |
||
516 | } |
||
517 | if(Intervall3D > 0 && CheckDelay(Timer3D) && UebertragungAbgeschlossen) |
||
518 | { |
||
519 | Data3D.Winkel[0] = (int) (IntegralNick / (EE_Parameter.GyroAccFaktor * 4)); // etwa in 0.1 Grad |
||
520 | Data3D.Winkel[1] = (int) (IntegralRoll / (EE_Parameter.GyroAccFaktor * 4)); // etwa in 0.1 Grad |
||
521 | Data3D.Winkel[2] = (int) ((10 * ErsatzKompass) / GIER_GRAD_FAKTOR); |
||
522 | SendOutData('C', FC_ADDRESS, 1, (unsigned char *) &Data3D,sizeof(Data3D)); |
||
523 | Timer3D = SetDelay(Intervall3D); |
||
524 | } |
||
525 | if(DebugTextAnforderung != 255) // Texte für die Analogdaten |
||
526 | { |
||
527 | SendOutData('A', FC_ADDRESS, 2, (unsigned char *)&DebugTextAnforderung, sizeof(DebugTextAnforderung),(unsigned char *) ANALOG_TEXT[DebugTextAnforderung], 16); |
||
528 | DebugTextAnforderung = 255; |
||
529 | } |
||
530 | if(ConfirmFrame && UebertragungAbgeschlossen) // Datensatz bestätigen |
||
531 | { |
||
532 | SendOutData('B', FC_ADDRESS, 1, (uint8_t*)&ConfirmFrame, sizeof(ConfirmFrame)); |
||
533 | ConfirmFrame = 0; |
||
534 | } |
||
535 | |||
536 | if(GetPPMChannelAnforderung && UebertragungAbgeschlossen) |
||
537 | { |
||
538 | SendOutData('P', FC_ADDRESS, 1, (unsigned char *) &PPM_in, sizeof(PPM_in)); |
||
539 | GetPPMChannelAnforderung = 0; |
||
540 | } |
||
541 | |||
542 | } |
||
543 |