Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
12 | hbuss | 1 | /*####################################################################################### |
2 | MK3Mag 3D-Magnet sensor |
||
3 | !!! THIS IS NOT FREE SOFTWARE !!! |
||
4 | #######################################################################################*/ |
||
5 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
6 | // + Copyright (c) 05.2008 Holger Buss |
||
7 | // + Thanks to Ilja Fähnrich (P_Latzhalter) |
||
1 | ingob | 8 | // + Nur für den privaten Gebrauch |
12 | hbuss | 9 | // + www.MikroKopter.com |
10 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
11 | // + Die Portierung der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
||
12 | // + mit unserer Zustimmung zulässig |
||
13 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
14 | // + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
||
15 | // + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist. |
||
16 | // + AUSNAHME: Ein bei www.mikrokopter.de erworbener vorbestückter MK3Mag darf als Baugruppe auch in kommerziellen Systemen verbaut werden |
||
17 | // + Im Zweifelsfall bitte anfragen bei: info@mikrokopter.de |
||
18 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
19 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
||
20 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
||
21 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
22 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
||
23 | // + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
||
24 | // + eindeutig als Ursprung verlinkt werden |
||
25 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
26 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
||
27 | // + Benutzung auf eigene Gefahr |
||
28 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
||
29 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
30 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
||
31 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
32 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
||
33 | // + this list of conditions and the following disclaimer. |
||
34 | // + * PORTING this software (or parts of it) to systems (other than hardware from www.mikrokopter.de) is NOT allowed |
||
35 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
||
36 | // + from this software without specific prior written permission. |
||
37 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permittet |
||
38 | // + for non-commercial use (directly or indirectly) |
||
39 | // + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
||
40 | // + with our written permission |
||
41 | // + Exception: A preassembled MK3Mag, purchased from www.mikrokopter.de may be used as a part of commercial systems |
||
42 | // + In case of doubt please contact: info@MikroKopter.de |
||
43 | // + * If sources or documentations are redistributet on other webpages, our webpage (http://www.MikroKopter.de) must be |
||
44 | // + clearly linked as origin |
||
45 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
46 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
47 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||
48 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
||
49 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||
50 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||
51 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||
52 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||
53 | // + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||
54 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||
55 | // + POSSIBILITY OF SUCH DAMAGE. |
||
56 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
1 | ingob | 57 | |
58 | #include "main.h" |
||
59 | #include "uart.h" |
||
60 | |||
61 | #define MAX_SENDE_BUFF 100 |
||
62 | #define MAX_EMPFANGS_BUFF 100 |
||
63 | |||
64 | unsigned volatile char SIO_Sollwert = 0; |
||
65 | unsigned volatile char SioTmp = 0; |
||
66 | unsigned volatile char SendeBuffer[MAX_SENDE_BUFF]; |
||
67 | unsigned volatile char RxdBuffer[MAX_EMPFANGS_BUFF]; |
||
68 | unsigned volatile char NeuerDatensatzEmpfangen = 0; |
||
69 | unsigned volatile char UebertragungAbgeschlossen = 1; |
||
70 | unsigned char GetVersionAnforderung = 0,DebugTextAnforderung = 0,DebugGetAnforderung = 0, KompassAntwort = 0; |
||
71 | unsigned char MeineSlaveAdresse; |
||
72 | unsigned char MotorTest[4] = {0,0,0,0}; |
||
73 | unsigned volatile char AnzahlEmpfangsBytes = 0; |
||
74 | unsigned char PcZugriff; |
||
75 | |||
76 | struct str_DebugOut DebugOut; |
||
7 | hbuss | 77 | struct str_ExternData ExternData; |
1 | ingob | 78 | struct str_ExternControl ExternControl; |
79 | struct str_VersionInfo VersionInfo; |
||
80 | |||
81 | |||
3 | ingob | 82 | |
1 | ingob | 83 | int Debug_Timer; |
84 | |||
85 | const unsigned char ANALOG_TEXT[32][16] = |
||
86 | { |
||
7 | hbuss | 87 | //1234567890123456 |
1 | ingob | 88 | "Magnet N ", //0 |
89 | "Magnet R ", |
||
7 | hbuss | 90 | "Magnet Z ", |
91 | "Raw N ", |
||
92 | "Raw R ", |
||
93 | "Raw Z ", //5 |
||
1 | ingob | 94 | "Lage N ", |
95 | "Lage R ", |
||
7 | hbuss | 96 | "Xmin ", |
97 | "Xmax ", |
||
98 | "Ymin ", //10 |
||
99 | "Ymax ", |
||
100 | "Zmin ", |
||
101 | "ZMax ", |
||
102 | "Calstate ", |
||
103 | "Kompass ", //15 |
||
5 | hbuss | 104 | "User0 ", |
105 | "User1 ", |
||
7 | hbuss | 106 | "Analog18 ", |
107 | "Analog19 ", |
||
108 | "Analog20 ", //20 |
||
109 | "Analog21 ", |
||
110 | "Analog22 ", |
||
111 | "Analog23 ", |
||
112 | "Analog24 ", |
||
113 | "Analog25 ", //25 |
||
1 | ingob | 114 | "Analog26 ", |
7 | hbuss | 115 | "Analog27 ", |
116 | "Analog28 ", |
||
117 | "Analog29 ", |
||
118 | "Analog30 ", //30 |
||
119 | "Analog31 " |
||
1 | ingob | 120 | }; |
121 | |||
122 | |||
7 | hbuss | 123 | |
1 | ingob | 124 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
125 | //++ Sende-Part der Datenübertragung |
||
126 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
127 | SIGNAL(INT_VEC_TX) |
||
128 | { |
||
129 | static unsigned int ptr = 0; |
||
130 | unsigned char tmp_tx; |
||
131 | if(!UebertragungAbgeschlossen) |
||
132 | { |
||
133 | ptr++; // die [0] wurde schon gesendet |
||
134 | tmp_tx = SendeBuffer[ptr]; |
||
135 | if((tmp_tx == '\r') || (ptr == MAX_SENDE_BUFF)) |
||
136 | { |
||
137 | ptr = 0; |
||
138 | UebertragungAbgeschlossen = 1; |
||
139 | } |
||
140 | UDR = tmp_tx; |
||
141 | } |
||
142 | else ptr = 0; |
||
143 | } |
||
144 | |||
145 | void SendUart(void) |
||
146 | { |
||
147 | static unsigned int ptr = 0; |
||
148 | unsigned char tmp_tx; |
||
149 | if(!(USR & 0x40)) return; |
||
150 | if(!UebertragungAbgeschlossen) |
||
151 | { |
||
152 | ptr++; // die [0] wurde schon gesendet |
||
153 | tmp_tx = SendeBuffer[ptr]; |
||
154 | if((tmp_tx == '\r') || (ptr == MAX_SENDE_BUFF)) |
||
155 | { |
||
156 | ptr = 0; |
||
157 | UebertragungAbgeschlossen = 1; |
||
158 | } |
||
159 | USR |= (1<TXC0); |
||
160 | UDR = tmp_tx; |
||
161 | } |
||
162 | else ptr = 0; |
||
163 | } |
||
164 | |||
165 | // -------------------------------------------------------------------------- |
||
166 | void Decode64(unsigned char *ptrOut, unsigned char len, unsigned char ptrIn,unsigned char max) // Wohin mit den Daten; Wie lang; Wo im RxdBuffer |
||
167 | { |
||
168 | unsigned char a,b,c,d; |
||
169 | unsigned char ptr = 0; |
||
170 | unsigned char x,y,z; |
||
171 | while(len) |
||
172 | { |
||
173 | a = RxdBuffer[ptrIn++] - '='; |
||
174 | b = RxdBuffer[ptrIn++] - '='; |
||
175 | c = RxdBuffer[ptrIn++] - '='; |
||
176 | d = RxdBuffer[ptrIn++] - '='; |
||
177 | if(ptrIn > max - 2) break; // nicht mehr Daten verarbeiten, als empfangen wurden |
||
178 | |||
179 | x = (a << 2) | (b >> 4); |
||
180 | y = ((b & 0x0f) << 4) | (c >> 2); |
||
181 | z = ((c & 0x03) << 6) | d; |
||
182 | |||
183 | if(len--) ptrOut[ptr++] = x; else break; |
||
184 | if(len--) ptrOut[ptr++] = y; else break; |
||
185 | if(len--) ptrOut[ptr++] = z; else break; |
||
186 | } |
||
187 | |||
188 | } |
||
189 | |||
190 | |||
191 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
192 | //++ Empfangs-Part der Datenübertragung |
||
193 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
194 | SIGNAL(INT_VEC_RX) |
||
195 | { |
||
196 | static unsigned int crc; |
||
197 | static unsigned char crc1,crc2,buf_ptr; |
||
198 | static unsigned char UartState = 0; |
||
199 | unsigned char CrcOkay = 0; |
||
200 | |||
201 | SioTmp = UDR; |
||
202 | if(buf_ptr >= MAX_EMPFANGS_BUFF) UartState = 0; |
||
203 | if(SioTmp == '\r' && UartState == 2) |
||
204 | { |
||
205 | UartState = 0; |
||
206 | crc -= RxdBuffer[buf_ptr-2]; |
||
207 | crc -= RxdBuffer[buf_ptr-1]; |
||
208 | crc %= 4096; |
||
209 | crc1 = '=' + crc / 64; |
||
210 | crc2 = '=' + crc % 64; |
||
211 | CrcOkay = 0; |
||
212 | if((crc1 == RxdBuffer[buf_ptr-2]) && (crc2 == RxdBuffer[buf_ptr-1])) CrcOkay = 1; else { CrcOkay = 0; }; |
||
213 | if(CrcOkay) // Datensatz schon verarbeitet |
||
214 | { |
||
215 | NeuerDatensatzEmpfangen = 1; |
||
216 | AnzahlEmpfangsBytes = buf_ptr; |
||
217 | RxdBuffer[buf_ptr] = '\r'; |
||
218 | if((RxdBuffer[2] == 'R')) wdt_enable(WDTO_250MS); // Reset-Commando |
||
219 | // uart_putchar(RxdBuffer[2]); |
||
220 | } |
||
221 | } |
||
222 | else |
||
223 | switch(UartState) |
||
224 | { |
||
225 | case 0: |
||
226 | if(SioTmp == '#' && !NeuerDatensatzEmpfangen) UartState = 1; // Startzeichen und Daten schon verarbeitet |
||
227 | buf_ptr = 0; |
||
228 | RxdBuffer[buf_ptr++] = SioTmp; |
||
229 | crc = SioTmp; |
||
230 | break; |
||
231 | case 1: // Adresse auswerten |
||
232 | UartState++; |
||
233 | RxdBuffer[buf_ptr++] = SioTmp; |
||
234 | crc += SioTmp; |
||
235 | break; |
||
236 | case 2: // Eingangsdaten sammeln |
||
237 | RxdBuffer[buf_ptr] = SioTmp; |
||
238 | if(buf_ptr < MAX_EMPFANGS_BUFF) buf_ptr++; |
||
239 | else UartState = 0; |
||
240 | crc += SioTmp; |
||
241 | break; |
||
242 | default: |
||
243 | UartState = 0; |
||
244 | break; |
||
245 | } |
||
246 | |||
247 | }; |
||
248 | |||
249 | |||
250 | // -------------------------------------------------------------------------- |
||
251 | void AddCRC(unsigned int wieviele) |
||
252 | { |
||
253 | unsigned int tmpCRC = 0,i; |
||
254 | for(i = 0; i < wieviele;i++) |
||
255 | { |
||
256 | tmpCRC += SendeBuffer[i]; |
||
257 | } |
||
258 | tmpCRC %= 4096; |
||
259 | SendeBuffer[i++] = '=' + tmpCRC / 64; |
||
260 | SendeBuffer[i++] = '=' + tmpCRC % 64; |
||
261 | SendeBuffer[i++] = '\r'; |
||
262 | UebertragungAbgeschlossen = 0; |
||
263 | UDR = SendeBuffer[0]; |
||
264 | } |
||
265 | |||
266 | |||
267 | // -------------------------------------------------------------------------- |
||
268 | void SendOutData(unsigned char cmd,unsigned char modul, unsigned char *snd, unsigned char len) |
||
269 | { |
||
270 | unsigned int pt = 0; |
||
271 | unsigned char a,b,c; |
||
272 | unsigned char ptr = 0; |
||
273 | |||
274 | SendeBuffer[pt++] = '#'; // Startzeichen |
||
275 | SendeBuffer[pt++] = modul; // Adresse (a=0; b=1,...) |
||
276 | SendeBuffer[pt++] = cmd; // Commando |
||
277 | |||
278 | while(len) |
||
279 | { |
||
280 | if(len) { a = snd[ptr++]; len--;} else a = 0; |
||
281 | if(len) { b = snd[ptr++]; len--;} else b = 0; |
||
282 | if(len) { c = snd[ptr++]; len--;} else c = 0; |
||
283 | SendeBuffer[pt++] = '=' + (a >> 2); |
||
284 | SendeBuffer[pt++] = '=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4)); |
||
285 | SendeBuffer[pt++] = '=' + (((b & 0x0f) << 2) | ((c & 0xc0) >> 6)); |
||
286 | SendeBuffer[pt++] = '=' + ( c & 0x3f); |
||
287 | } |
||
288 | AddCRC(pt); |
||
289 | } |
||
290 | |||
291 | |||
292 | |||
293 | //############################################################################ |
||
294 | //Routine für die Serielle Ausgabe |
||
295 | int uart_putchar (char c) |
||
296 | //############################################################################ |
||
297 | { |
||
7 | hbuss | 298 | if(!(UCR & (1 << TXEN))) return (0); |
1 | ingob | 299 | if (c == '\n') |
300 | uart_putchar('\r'); |
||
301 | //Warten solange bis Zeichen gesendet wurde |
||
302 | loop_until_bit_is_set(USR, UDRE); |
||
303 | //Ausgabe des Zeichens |
||
304 | UDR = c; |
||
305 | |||
306 | return (0); |
||
307 | } |
||
308 | |||
309 | // -------------------------------------------------------------------------- |
||
310 | void WriteProgramData(unsigned int pos, unsigned char wert) |
||
311 | { |
||
312 | } |
||
313 | |||
314 | //############################################################################ |
||
315 | //INstallation der Seriellen Schnittstelle |
||
316 | void UART_Init (void) |
||
317 | //############################################################################ |
||
318 | { |
||
319 | //Enable TXEN im Register UCR TX-Data Enable & RX Enable |
||
320 | |||
321 | UCR=(1 << TXEN) | (1 << RXEN); |
||
322 | // UART Double Speed (U2X) |
||
323 | USR |= (1<<U2X); |
||
324 | // RX-Interrupt Freigabe |
||
325 | |||
326 | UCSRB |= (1<<RXCIE); // serieller Empfangsinterrupt |
||
327 | |||
328 | // TX-Interrupt Freigabe |
||
329 | UCSRB |= (1<<TXCIE); |
||
330 | |||
331 | //Teiler wird gesetzt |
||
332 | UBRR= (SYSCLK / (BAUD_RATE * 8L) -1 ); |
||
333 | //öffnet einen Kanal für printf (STDOUT) |
||
334 | // fdevopen (uart_putchar, NULL); |
||
335 | Debug_Timer = SetDelay(200); |
||
336 | // Version beim Start ausgeben (nicht schön, aber geht... ) |
||
337 | uart_putchar ('\n');uart_putchar ('C');uart_putchar ('P');uart_putchar (':'); |
||
338 | uart_putchar ('V');uart_putchar (0x30 + VERSION_HAUPTVERSION);uart_putchar ('.');uart_putchar (0x30 + VERSION_NEBENVERSION/10); uart_putchar (0x30 + VERSION_NEBENVERSION%10); |
||
339 | uart_putchar ('\n'); |
||
340 | } |
||
341 | |||
342 | |||
343 | void BearbeiteRxDaten(void) |
||
344 | { |
||
345 | if(!NeuerDatensatzEmpfangen) return; |
||
346 | // unsigned int tmp_int_arr1[1]; |
||
347 | // unsigned int tmp_int_arr2[2]; |
||
348 | // unsigned int tmp_int_arr3[3]; |
||
349 | unsigned char tmp_char_arr2[2]; |
||
350 | // unsigned char tmp_char_arr3[3]; |
||
351 | // unsigned char tmp_char_arr4[4]; |
||
352 | //if(!MotorenEin) |
||
353 | PcZugriff = 255; |
||
354 | |||
355 | switch(RxdBuffer[2]) |
||
356 | { |
||
357 | case 'w':// Lagewinkel |
||
7 | hbuss | 358 | Decode64((unsigned char *) &ExternData,sizeof(ExternData),3,AnzahlEmpfangsBytes); |
1 | ingob | 359 | DebugOut.Analog[15]++; |
360 | KompassAntwort = 1; |
||
361 | break; |
||
362 | case 'c': |
||
363 | case 'b': |
||
364 | Decode64((unsigned char *) &ExternControl,sizeof(ExternControl),3,AnzahlEmpfangsBytes); |
||
7 | hbuss | 365 | ExternData.Winkel[0] = ExternControl.Par1; |
366 | ExternData.Winkel[1] = ExternControl.Par2; |
||
1 | ingob | 367 | break; |
368 | case 'v': // Version-Anforderung und Ausbaustufe |
||
369 | GetVersionAnforderung = 1; |
||
370 | PC_Connected = 255; |
||
371 | break; |
||
372 | |||
373 | case 'a':// Texte der Analogwerte |
||
374 | Decode64((unsigned char *) &tmp_char_arr2[0],sizeof(tmp_char_arr2),3,AnzahlEmpfangsBytes); |
||
375 | DebugTextAnforderung = tmp_char_arr2[0]; |
||
376 | PC_Connected = 255; |
||
377 | break; |
||
378 | case 'g':// "Get"-Anforderung für Debug-Daten |
||
379 | // Bei Get werden die vom PC einstellbaren Werte vom PC zurückgelesen |
||
380 | PC_Connected = 255; |
||
381 | DebugGetAnforderung = 1; |
||
382 | break; |
||
383 | case 'h':// x-1 Displayzeilen |
||
384 | PC_Connected = 255; |
||
385 | break; |
||
386 | /* |
||
387 | case 'b': |
||
388 | Decode64((unsigned char *) &ExternControl,sizeof(ExternControl),3,AnzahlEmpfangsBytes); |
||
389 | RemoteTasten |= ExternControl.RemoteTasten; |
||
390 | ConfirmFrame = ExternControl.Frame; |
||
391 | break; |
||
392 | case 'c': |
||
393 | Decode64((unsigned char *) &ExternControl,sizeof(ExternControl),3,AnzahlEmpfangsBytes); |
||
394 | RemoteTasten |= ExternControl.RemoteTasten; |
||
395 | ConfirmFrame = ExternControl.Frame; |
||
396 | DebugDataAnforderung = 1; |
||
397 | break; |
||
398 | case 'h':// x-1 Displayzeilen |
||
399 | Decode64((unsigned char *) &tmp_char_arr2[0],sizeof(tmp_char_arr2),3,AnzahlEmpfangsBytes); |
||
400 | RemoteTasten |= tmp_char_arr2[0]; |
||
401 | if(tmp_char_arr2[1] == 255) NurKanalAnforderung = 1; else NurKanalAnforderung = 0; // keine Displaydaten |
||
402 | DebugDisplayAnforderung = 1; |
||
403 | break; |
||
404 | case 't':// Motortest |
||
405 | Decode64((unsigned char *) &MotorTest[0],sizeof(MotorTest),3,AnzahlEmpfangsBytes); |
||
406 | break; |
||
407 | case 'k':// Keys von DubWise |
||
408 | Decode64((unsigned char *) &DubWiseKeys[0],sizeof(DubWiseKeys),3,AnzahlEmpfangsBytes); |
||
409 | ConfirmFrame = DubWiseKeys[3]; |
||
410 | break; |
||
411 | case 'q':// "Get"-Anforderung für Settings |
||
412 | // Bei Get werden die vom PC einstellbaren Werte vom PC zurückgelesen |
||
413 | Decode64((unsigned char *) &tmp_char_arr2[0],sizeof(tmp_char_arr2),3,AnzahlEmpfangsBytes); |
||
414 | if(tmp_char_arr2[0] != 0xff) |
||
415 | { |
||
416 | if(tmp_char_arr2[0] > 5) tmp_char_arr2[0] = 5; |
||
417 | ReadParameterSet(tmp_char_arr2[0], (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
||
418 | SendOutData('L' + tmp_char_arr2[0] -1,MeineSlaveAdresse,(unsigned char *) &EE_Parameter.Kanalbelegung[0],STRUCT_PARAM_LAENGE); |
||
419 | } |
||
420 | else |
||
421 | SendOutData('L' + GetActiveParamSetNumber()-1,MeineSlaveAdresse,(unsigned char *) &EE_Parameter.Kanalbelegung[0],STRUCT_PARAM_LAENGE); |
||
422 | |||
423 | break; |
||
424 | |||
425 | case 'l': |
||
426 | case 'm': |
||
427 | case 'n': |
||
428 | case 'o': |
||
429 | case 'p': // Parametersatz speichern |
||
430 | Decode64((unsigned char *) &EE_Parameter.Kanalbelegung[0],STRUCT_PARAM_LAENGE,3,AnzahlEmpfangsBytes); |
||
431 | WriteParameterSet(RxdBuffer[2] - 'l' + 1, (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
||
432 | eeprom_write_byte(&EEPromArray[EEPROM_ADR_ACTIVE_SET], RxdBuffer[2] - 'l' + 1); // aktiven Datensatz merken |
||
433 | Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L; |
||
434 | Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L; |
||
435 | Piep(GetActiveParamSetNumber()); |
||
436 | break; |
||
437 | */ |
||
438 | |||
439 | } |
||
440 | // DebugOut.AnzahlZyklen = Debug_Timer_Intervall; |
||
441 | NeuerDatensatzEmpfangen = 0; |
||
442 | } |
||
443 | |||
444 | |||
445 | //--------------------------------------------------------------------------------------------- |
||
446 | void DatenUebertragung(void) |
||
447 | { |
||
448 | if((CheckDelay(Debug_Timer) && UebertragungAbgeschlossen)) // im Singlestep-Betrieb in jedem Schtitt senden |
||
449 | { |
||
7 | hbuss | 450 | SetDebugValues(); |
1 | ingob | 451 | SendOutData('D',MeineSlaveAdresse,(unsigned char *) &DebugOut,sizeof(DebugOut)); |
452 | Debug_Timer = SetDelay(250); // Sendeintervall |
||
453 | } |
||
454 | if(GetVersionAnforderung && UebertragungAbgeschlossen) |
||
455 | { |
||
456 | SendOutData('V',MeineSlaveAdresse,(unsigned char *) &VersionInfo,sizeof(VersionInfo)); |
||
457 | GetVersionAnforderung = 0; |
||
458 | } |
||
459 | if(DebugTextAnforderung != 255) // Texte für die Analogdaten |
||
460 | { |
||
461 | SendOutData('A',DebugTextAnforderung + '0',(unsigned char *) ANALOG_TEXT[DebugTextAnforderung],16); |
||
462 | DebugTextAnforderung = 255; |
||
463 | } |
||
464 | if(DebugGetAnforderung && UebertragungAbgeschlossen) // Bei Get werden die vom PC einstellbaren Werte vom PC zurückgelesen |
||
465 | { |
||
466 | SendOutData('G',MeineSlaveAdresse,(unsigned char *) &ExternControl,sizeof(ExternControl)); |
||
467 | DebugGetAnforderung = 0; |
||
468 | } |
||
469 | if(KompassAntwort && UebertragungAbgeschlossen) // Bei Get werden die vom PC einstellbaren Werte vom PC zurückgelesen |
||
470 | { |
||
3 | ingob | 471 | SendOutData('K',MeineSlaveAdresse,(unsigned char *) &I2C_Heading,sizeof(I2C_Heading)); |
1 | ingob | 472 | KompassAntwort = 0; |
473 | } |
||
474 | } |
||
475 |