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