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