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