Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1734 | - | 1 | /***************************************************************************** |
2 | * Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
||
3 | * Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
||
4 | * Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net * |
||
5 | * Copyright (C) 2011 Harald Bongartz * |
||
6 | * * |
||
7 | * This program is free software; you can redistribute it and/or modify * |
||
8 | * it under the terms of the GNU General Public License as published by * |
||
9 | * the Free Software Foundation; either version 2 of the License. * |
||
10 | * * |
||
11 | * This program is distributed in the hope that it will be useful, * |
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
14 | * GNU General Public License for more details. * |
||
15 | * * |
||
16 | * You should have received a copy of the GNU General Public License * |
||
17 | * along with this program; if not, write to the * |
||
18 | * Free Software Foundation, Inc., * |
||
19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
20 | * * |
||
21 | * * |
||
22 | * Credits to: * |
||
23 | * Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN * |
||
24 | * http://www.mikrokopter.de * |
||
25 | * Gregor "killagreg" Stobrawa for his version of the MK code * |
||
26 | * Thomas Kaiser "thkais" for the original project. See * |
||
27 | * http://www.ft-fanpage.de/mikrokopter/ * |
||
28 | * http://forum.mikrokopter.de/topic-4061-1.html * |
||
29 | * Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code * |
||
30 | * http://www.mylifesucks.de/oss/c-osd/ * |
||
31 | * Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility* |
||
32 | *****************************************************************************/ |
||
33 | |||
34 | |||
35 | #include "cpu.h" |
||
36 | #include <avr/pgmspace.h> |
||
37 | #include "lcd.h" |
||
38 | #include "timer.h" |
||
39 | #include "eeprom.h" |
||
40 | #include "messages.h" |
||
41 | #include "lipo.h" |
||
42 | #include "main.h" |
||
43 | |||
44 | #if defined HWVERSION3_9 |
||
45 | //-------------------------------------------------------------- |
||
46 | void Change_Output(uint8_t UartMode) // Schaltet die Rx/Tx Richtungen |
||
47 | { |
||
48 | // hiermit werden die 74HTC125 (IC5) Gatter geschaltet |
||
49 | clr_USB2FC(); // PC2 aus |
||
50 | clr_USB2Wi(); // PB0 aus |
||
51 | clr_Uart02FC(); // PC6 aus |
||
52 | clr_Uart02Wi(); // PC5 aus |
||
53 | |||
54 | |||
55 | switch (UartMode) |
||
56 | { |
||
57 | case USB2FC: |
||
58 | UCSR1B &= ~(1<<RXEN1); |
||
59 | UCSR1B &= ~(1<<TXEN1); |
||
60 | UCSR1B &= ~(1<<RXCIE1); |
||
61 | |||
62 | DDRD &= ~(1<<DDD2); // Pins auf Eingang setzen |
||
63 | DDRD &= ~(1<<DDD3); |
||
64 | PORTD &= ~(1<<PIND2); // Pullup aus // MartinR: von PD auf PIND geändert |
||
65 | PORTD &= ~(1<<PIND3); // MartinR: von PD auf PIND geändert |
||
66 | |||
67 | set_USB2FC(); |
||
68 | break; |
||
69 | |||
70 | case Uart02Wi: |
||
71 | set_Uart02Wi(); |
||
72 | break; |
||
73 | |||
74 | case Uart02FC: |
||
75 | set_Uart02FC(); |
||
76 | break; |
||
77 | |||
78 | case USB2Wi: |
||
79 | UCSR1B &= ~(1<<RXEN1); |
||
80 | UCSR1B &= ~(1<<TXEN1); |
||
81 | UCSR1B &= ~(1<<RXCIE1); |
||
82 | |||
83 | DDRD &= ~(1<<DDD2); // Pins auf Eingang setzen |
||
84 | DDRD &= ~(1<<DDD3); |
||
85 | PORTD &= ~(1<<PIND2); // Pullup aus // MartinR: von PD auf PIND geändert |
||
86 | PORTD &= ~(1<<PIND3); // MartinR: von PD auf PIND geändert |
||
87 | |||
88 | set_USB2Wi(); |
||
89 | break; |
||
90 | } |
||
91 | |||
92 | } |
||
93 | |||
94 | |||
95 | //-------------------------------------------------------------- |
||
96 | // Function: BT2FC() |
||
97 | // Purpose: Connect BT direct to FC-Kabel (SV2 as MKUSB) |
||
98 | // Returns: |
||
99 | //-------------------------------------------------------------- |
||
100 | void Port_BT2FC(void) |
||
101 | { |
||
102 | lcd_cls (); |
||
103 | |||
104 | if(UseBT == true) |
||
105 | { |
||
106 | // lcd_printp_at (0, 0, PSTR(" MK-USB Funktion "), 2); |
||
107 | lcd_puts_at(0, 0, strGet(CONNECT14), 2); |
||
108 | // lcd_printp_at (0, 1, PSTR(" BT --> Kabel an FC "), 2); |
||
109 | lcd_puts_at(0, 1, strGet(CONNECT15), 0); |
||
110 | // lcd_printp_at (0, 3, PSTR("PC mit BT verb."), 0); |
||
111 | lcd_puts_at(0, 3, strGet(CONNECT16), 0); |
||
112 | // lcd_printp_at (0, 4, PSTR("PKT-Kabel an FC"), 0); |
||
113 | lcd_puts_at(0, 4, strGet(CONNECT17), 0); |
||
114 | // lcd_printp_at (0, 5, PSTR("MK-Tool starten"), 0); |
||
115 | // lcd_printp_at (12, 7, PSTR("Esc"), 0); |
||
116 | lcd_puts_at(0, 5, strGet(CONNECT23), 0); |
||
117 | lcd_puts_at(12, 7, strGet(ESC), 0); |
||
118 | set_BTOn(); |
||
119 | |||
120 | Change_Output(USB2FC); |
||
121 | do |
||
122 | { |
||
123 | #ifndef ohne_Lipo // MartinR |
||
124 | show_Lipo(); |
||
125 | #endif |
||
126 | } |
||
127 | while(!get_key_press (1 << KEY_ESC)); |
||
128 | |||
129 | get_key_press(KEY_ALL); |
||
130 | if (U02SV2 == 1) |
||
131 | Change_Output(Uart02FC); |
||
132 | else |
||
133 | Change_Output(Uart02Wi); |
||
134 | |||
135 | set_BTOff(); |
||
136 | return; |
||
137 | } |
||
138 | else |
||
139 | { |
||
140 | // lcd_printp_at (0, 0, PSTR("Es ist kein BTM-222 "), 0); |
||
141 | // lcd_printp_at (0, 1, PSTR("Modul eingebaut! "), 0); |
||
142 | // lcd_printp_at (0, 3, PSTR("Wenn doch, dann bitte"), 0); |
||
143 | // lcd_printp_at (0, 4, PSTR("das Modul zuerst im "), 0); |
||
144 | // lcd_printp_at (0, 5, PSTR("Setupmenü aktivieren."), 0); |
||
145 | lcd_puts_at(0, 1, strGet(CONNECT12), 0); |
||
146 | lcd_puts_at(0, 1, strGet(CONNECT13), 0); |
||
147 | lcd_puts_at(0, 2, strGet(CONNECT7), 0); |
||
148 | lcd_puts_at(0, 3, strGet(CONNECT8), 0); |
||
149 | lcd_puts_at(0, 4, strGet(CONNECT9), 0); |
||
150 | lcd_puts_at(12, 7, strGet(ENDE), 0); |
||
151 | // lcd_printp_at (12, 7, PSTR("Ende"), 0); |
||
152 | |||
153 | while(!get_key_press (1 << KEY_ESC)); |
||
154 | |||
155 | get_key_press(KEY_ALL); |
||
156 | return; |
||
157 | } |
||
158 | } |
||
159 | |||
160 | |||
161 | //-------------------------------------------------------------- |
||
162 | // Function: BT2Wi() |
||
163 | // Purpose: Connect BT direct to Wi.232 |
||
164 | // Returns: |
||
165 | //-------------------------------------------------------------- |
||
166 | void Port_BT2Wi(void) |
||
167 | { |
||
168 | |||
169 | lcd_cls (); |
||
170 | |||
171 | // if((UseBT == true) && (UseWi == true))6.1.2012 CB Abfrage entfernt, damit die Funktion auch ohne Module geht |
||
172 | { |
||
173 | // lcd_printp_at (0, 0, PSTR(" MK-USB Funktion "), 2); |
||
174 | lcd_puts_at(0, 0, strGet(CONNECT14), 2); |
||
175 | // lcd_printp_at (0, 1, PSTR(" BT --> Wi.232 "), 2); |
||
176 | lcd_puts_at(0, 1, strGet(CONNECT18), 2); |
||
177 | // lcd_printp_at (0, 3, PSTR("PC mit BT verbinden "), 0); |
||
178 | lcd_puts_at(0, 3, strGet(CONNECT16), 0); |
||
179 | // lcd_printp_at (0, 4, PSTR("Wi.232 an FC "), 0); |
||
180 | lcd_puts_at(0, 4, strGet(CONNECT19), 0); |
||
181 | // lcd_printp_at (0, 5, PSTR("MK-Tool starten "), 0); |
||
182 | lcd_puts_at(0, 5, strGet(CONNECT23), 0); |
||
183 | |||
184 | // lcd_printp_at (12, 7, PSTR("Esc"), 0); |
||
185 | lcd_puts_at(12, 7, strGet(ESC), 0); |
||
186 | set_BTOn(); |
||
187 | |||
188 | Change_Output(USB2Wi); |
||
189 | do |
||
190 | { |
||
191 | #ifndef ohne_Lipo // MartinR |
||
192 | show_Lipo(); |
||
193 | #endif |
||
194 | } |
||
195 | while(!get_key_press (1 << KEY_ESC)); |
||
196 | |||
197 | get_key_press(KEY_ALL); |
||
198 | if (U02SV2 == 1) |
||
199 | Change_Output(Uart02FC); |
||
200 | else |
||
201 | Change_Output(Uart02Wi); |
||
202 | |||
203 | set_BTOff(); |
||
204 | return; |
||
205 | } |
||
206 | // else |
||
207 | // { |
||
208 | //// lcd_printp_at (0, 0, PSTR("Es ist kein BTM-222 "), 0); |
||
209 | //// lcd_printp_at (0, 1, PSTR("Modul eingebaut! "), 0); |
||
210 | //// lcd_printp_at (0, 3, PSTR("Wenn doch, dann bitte"), 0); |
||
211 | //// lcd_printp_at (0, 4, PSTR("das Modul zuerst im "), 0); |
||
212 | //// lcd_printp_at (0, 5, PSTR("Setupmenü aktivieren."), 0); |
||
213 | // |
||
214 | // lcd_puts_at(0, 0, strGet(CONNECT12), 0); |
||
215 | // lcd_puts_at(0, 1, strGet(CONNECT13), 0); |
||
216 | // lcd_puts_at(0, 2, strGet(CONNECT7), 0); |
||
217 | // lcd_puts_at(0, 3, strGet(CONNECT8), 0); |
||
218 | // lcd_puts_at(0, 4, strGet(CONNECT9), 0); |
||
219 | // lcd_puts_at(12, 7, strGet(ENDE), 0); |
||
220 | //// lcd_printp_at (12, 7, PSTR("Ende"), 0); |
||
221 | // |
||
222 | // while(!get_key_press (1 << KEY_ESC)); |
||
223 | // get_key_press(KEY_ALL); |
||
224 | // |
||
225 | // return; |
||
226 | // } |
||
227 | } |
||
228 | |||
229 | |||
230 | //-------------------------------------------------------------- |
||
231 | // Function: FC2CFG_BT() |
||
232 | // Purpose: Connect FC (Tx1 Pin3, Rx1 Pin4) direct to BT |
||
233 | // Returns: |
||
234 | //-------------------------------------------------------------- |
||
235 | void Port_FC2CFG_BT(void) |
||
236 | { |
||
237 | |||
238 | lcd_cls (); |
||
239 | lcd_printp_at (0, 0, PSTR("BTM-222 Konfigurieren"), 2); |
||
240 | lcd_printp_at (0, 1, PSTR("FC > MK-USB > BTM-222"), 2); |
||
241 | lcd_printp_at (0, 3, PSTR("MK-USB an PC anschl. "), 0); |
||
242 | lcd_printp_at (0, 4, PSTR("Zwischen MK-USB und "), 0); |
||
243 | lcd_printp_at (0, 5, PSTR("PKT ein gekreuztes "), 0); |
||
244 | lcd_printp_at (0, 6, PSTR("Kabel anschliessen. "), 0); |
||
245 | lcd_puts_at(12, 7, strGet(ESC), 0); |
||
246 | // lcd_printp_at (12, 7, PSTR("Esc"), 0); |
||
247 | |||
248 | set_BTOn(); |
||
249 | Change_Output(USB2FC); |
||
250 | |||
251 | while(!get_key_press (1 << KEY_ESC)); |
||
252 | |||
253 | get_key_press(KEY_ALL); |
||
254 | if (U02SV2 == 1) |
||
255 | Change_Output(Uart02FC); |
||
256 | else |
||
257 | Change_Output(Uart02Wi); |
||
258 | |||
259 | set_BTOff(); |
||
260 | return; |
||
261 | } |
||
262 | |||
263 | |||
264 | //-------------------------------------------------------------- |
||
265 | // Function: USB2FC() |
||
266 | // Purpose: Connect USB direct to FC-Kabel (SV2 as MKUSB) |
||
267 | // Returns: |
||
268 | //-------------------------------------------------------------- |
||
269 | void Port_USB2FC(void) |
||
270 | { |
||
271 | lcd_cls (); |
||
272 | // lcd_printp_at (0, 0, PSTR(" MK-USB Funktion "), 2); |
||
273 | lcd_puts_at(0, 0, strGet(CONNECT14), 2); |
||
274 | // lcd_printp_at (0, 1, PSTR(" USB --> Kabel an FC "), 2); |
||
275 | lcd_puts_at(0, 1, strGet(CONNECT20), 0); |
||
276 | // lcd_printp_at (0, 3, PSTR("PC mit USB verbinden "), 0); |
||
277 | lcd_puts_at(0, 3, strGet(CONNECT21), 0); |
||
278 | // lcd_printp_at (0, 4, PSTR("PKT-Kabel an FC "), 0); |
||
279 | lcd_puts_at(0, 4, strGet(CONNECT17), 0); |
||
280 | // lcd_printp_at (0, 5, PSTR("MK-Tool starten "), 0); |
||
281 | // lcd_printp_at (12, 7, PSTR("Esc"), 0); |
||
282 | lcd_puts_at(0, 5, strGet(CONNECT23), 0); |
||
283 | lcd_puts_at(12, 7, strGet(ESC), 0); |
||
284 | Change_Output(USB2FC); |
||
285 | do |
||
286 | { |
||
287 | #ifndef ohne_Lipo // MartinR |
||
288 | show_Lipo(); |
||
289 | #endif |
||
290 | } |
||
291 | while(!get_key_press (1 << KEY_ESC)); |
||
292 | |||
293 | get_key_press(KEY_ALL); |
||
294 | if (U02SV2 == 1) |
||
295 | Change_Output(Uart02FC); |
||
296 | else |
||
297 | Change_Output(Uart02Wi); |
||
298 | |||
299 | return; |
||
300 | } |
||
301 | |||
302 | //-------------------------------------------------------------- |
||
303 | // Function: USB2Wi() |
||
304 | // Purpose: Connect USB direct to Wi.232 |
||
305 | // Returns: |
||
306 | //-------------------------------------------------------------- |
||
307 | void Port_USB2Wi(void) |
||
308 | { |
||
309 | |||
310 | lcd_cls (); |
||
311 | // if(UseWi == true) // 6.1.2012 CB Abfrage entfernt, damit die Funktion auch ohne Module geht |
||
312 | { |
||
313 | // lcd_printp_at (0, 0, PSTR(" MK-USB Funktion "), 2); |
||
314 | lcd_puts_at(0, 0, strGet(CONNECT14), 2); |
||
315 | // lcd_printp_at (0, 1, PSTR(" USB --> Wi.232 "), 2); |
||
316 | lcd_puts_at(0, 1, strGet(CONNECT22), 2); |
||
317 | // lcd_printp_at (0, 3, PSTR("PC mit USB verbinden "), 0); |
||
318 | lcd_puts_at(0, 3, strGet(CONNECT21), 0); |
||
319 | // lcd_printp_at (0, 4, PSTR("Wi.232 an FC "), 0); |
||
320 | lcd_puts_at(0, 4, strGet(CONNECT19), 0); |
||
321 | // lcd_printp_at (0, 5, PSTR("MK-Tool starten "), 0); |
||
322 | lcd_puts_at(0, 5, strGet(CONNECT23), 0); |
||
323 | lcd_puts_at(12, 7, strGet(ESC), 0); |
||
324 | // lcd_printp_at (12, 7, PSTR("Esc"), 0); |
||
325 | |||
326 | Change_Output(USB2Wi); |
||
327 | do |
||
328 | { |
||
329 | #ifndef ohne_Lipo // MartinR |
||
330 | show_Lipo(); |
||
331 | #endif |
||
332 | } |
||
333 | while(!get_key_press (1 << KEY_ESC)); |
||
334 | |||
335 | get_key_press(KEY_ALL); |
||
336 | if (U02SV2 == 1) |
||
337 | Change_Output(Uart02FC); |
||
338 | else |
||
339 | Change_Output(Uart02Wi); |
||
340 | |||
341 | return; |
||
342 | } |
||
343 | // else |
||
344 | // { |
||
345 | //// lcd_printp_at (0, 0, PSTR("Es ist kein Wi.232 "), 0); |
||
346 | //// lcd_printp_at (0, 1, PSTR("Modul eingebaut! "), 0); |
||
347 | //// lcd_printp_at (0, 3, PSTR("Wenn doch, dann bitte"), 0); |
||
348 | //// lcd_printp_at (0, 4, PSTR("das Modul zuerst im "), 0); |
||
349 | //// lcd_printp_at (0, 5, PSTR("Setupmenü aktivieren."), 0); |
||
350 | //// lcd_printp_at (12, 7, PSTR("Ende"), 0); |
||
351 | // lcd_puts_at(0, 0, strGet(CONNECT5), 0); |
||
352 | // lcd_puts_at(0, 1, strGet(CONNECT6), 0); |
||
353 | // lcd_puts_at(0, 2, strGet(CONNECT7), 0); |
||
354 | // lcd_puts_at(0, 3, strGet(CONNECT8), 0); |
||
355 | // lcd_puts_at(0, 4, strGet(CONNECT9), 0); |
||
356 | // lcd_puts_at(12, 7, strGet(ENDE), 0); |
||
357 | // while(!get_key_press (1 << KEY_ESC)); |
||
358 | // get_key_press(KEY_ALL); |
||
359 | // |
||
360 | // return; |
||
361 | // } |
||
362 | } |
||
363 | |||
364 | //-------------------------------------------------------------- |
||
365 | // Function: USB2CFG_Wi() |
||
366 | // Purpose: Connect USB direct to Wi.232 in Progmode |
||
367 | // Returns: |
||
368 | //-------------------------------------------------------------- |
||
369 | void Port_USB2CFG_Wi(void) |
||
370 | { |
||
371 | |||
372 | lcd_cls (); |
||
373 | // lcd_printp_at (0, 0, PSTR(" Wi.232 Konfigurieren"), 2); |
||
374 | lcd_puts_at(0, 0, strGet(CONNECT24), 2); |
||
375 | // lcd_printp_at (0, 1, PSTR(" USB --> Wi.232 "), 2); |
||
376 | lcd_puts_at(0, 1, strGet(CONNECT22), 2); |
||
377 | // lcd_printp_at (0, 3, PSTR("PC mit USB verbinden."), 0); |
||
378 | lcd_puts_at(0, 3, strGet(CONNECT21), 0); |
||
379 | lcd_printp_at (0, 4, PSTR("Radiotronix Wi.232DTS"), 0); |
||
380 | lcd_printp_at (0, 5, PSTR("Evaluation (868MHz) "), 0); |
||
381 | // lcd_printp_at (0, 6, PSTR("Programm starten. "), 0); |
||
382 | lcd_puts_at(0, 6, strGet(CONNECT25), 0); |
||
383 | lcd_puts_at(12, 7, strGet(ESC), 0); |
||
384 | // lcd_printp_at (12, 7, PSTR("Esc"), 0); |
||
385 | |||
386 | Change_Output(USB2Wi); |
||
387 | |||
388 | set_WI232CMD(); // Port D6 = CMD |
||
389 | |||
390 | while(!get_key_press (1 << KEY_ESC)); |
||
391 | |||
392 | get_key_press(KEY_ALL); |
||
393 | clr_WI232CMD(); // Port D6 = CMD |
||
394 | |||
395 | if (U02SV2 == 1) |
||
396 | Change_Output(Uart02FC); |
||
397 | else |
||
398 | Change_Output(Uart02Wi); |
||
399 | |||
400 | return; |
||
401 | } |
||
402 | |||
403 | #endif |