Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1515 | - | 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" |
||
1526 | - | 41 | #include "lipo.h" |
1515 | - | 42 | |
43 | #if defined HWVERSION1_3W || defined HWVERSION3_9 |
||
44 | //-------------------------------------------------------------- |
||
45 | void Change_Output(uint8_t UartMode) // Schaltet die Rx/Tx Richtungen |
||
46 | { |
||
47 | // hiermit werden die 74HTC125 (IC5) Gatter geschaltet |
||
48 | clr_USB2FC(); // PC2 aus |
||
49 | clr_USB2Wi(); // PB0 aus |
||
50 | clr_Uart02FC(); // PC6 aus |
||
51 | clr_Uart02Wi(); // PC5 aus |
||
52 | |||
53 | |||
54 | switch (UartMode) |
||
55 | { |
||
56 | case USB2FC: |
||
57 | UCSR1B &= ~(1<<RXEN1); |
||
58 | UCSR1B &= ~(1<<TXEN1); |
||
59 | UCSR1B &= ~(1<<RXCIE1); |
||
60 | |||
61 | DDRD &= ~(1<<DDD2); // Pins auf Eingang setzen |
||
62 | DDRD &= ~(1<<DDD3); |
||
63 | PORTD &= ~(1<<PD2); // Pullup aus |
||
64 | PORTD &= ~(1<<PD3); |
||
65 | |||
66 | set_USB2FC(); |
||
67 | break; |
||
68 | |||
69 | case Uart02Wi: |
||
70 | set_Uart02Wi(); |
||
71 | break; |
||
72 | |||
73 | case Uart02FC: |
||
74 | set_Uart02FC(); |
||
75 | break; |
||
76 | |||
77 | case USB2Wi: |
||
78 | UCSR1B &= ~(1<<RXEN1); |
||
79 | UCSR1B &= ~(1<<TXEN1); |
||
80 | UCSR1B &= ~(1<<RXCIE1); |
||
81 | |||
82 | DDRD &= ~(1<<DDD2); // Pins auf Eingang setzen |
||
83 | DDRD &= ~(1<<DDD3); |
||
84 | PORTD &= ~(1<<PD2); // Pullup aus |
||
85 | PORTD &= ~(1<<PD3); |
||
86 | |||
87 | set_USB2Wi(); |
||
88 | break; |
||
89 | } |
||
90 | |||
91 | } |
||
92 | |||
93 | |||
94 | //-------------------------------------------------------------- |
||
95 | // Function: BT2FC() |
||
96 | // Purpose: Connect BT direct to FC-Kabel (SV2 as MKUSB) |
||
97 | // Returns: |
||
98 | //-------------------------------------------------------------- |
||
99 | void Port_BT2FC(void) |
||
100 | { |
||
101 | lcd_cls (); |
||
102 | |||
103 | if(UseBT == true) |
||
104 | { |
||
105 | // lcd_printp_at (0, 0, PSTR(" MK-USB Funktion "), 2); |
||
106 | lcd_puts_at(0, 0, strGet(CONNECT14), 2); |
||
107 | // lcd_printp_at (0, 1, PSTR(" BT --> Kabel an FC "), 2); |
||
108 | lcd_puts_at(0, 1, strGet(CONNECT15), 0); |
||
109 | // lcd_printp_at (0, 3, PSTR("PC mit BT verb."), 0); |
||
110 | lcd_puts_at(0, 3, strGet(CONNECT16), 0); |
||
111 | // lcd_printp_at (0, 4, PSTR("PKT-Kabel an FC"), 0); |
||
112 | lcd_puts_at(0, 4, strGet(CONNECT17), 0); |
||
113 | // lcd_printp_at (0, 5, PSTR("MK-Tool starten"), 0); |
||
114 | // lcd_printp_at (12, 7, PSTR("Esc"), 0); |
||
115 | lcd_puts_at(0, 5, strGet(CONNECT23), 0); |
||
116 | lcd_puts_at(12, 7, strGet(ESC), 0); |
||
117 | set_BTOn(); |
||
118 | |||
119 | Change_Output(USB2FC); |
||
1526 | - | 120 | do |
121 | { |
||
122 | show_Lipo(); |
||
123 | } |
||
1515 | - | 124 | while(!get_key_press (1 << KEY_ESC)); |
125 | |||
126 | get_key_press(KEY_ALL); |
||
127 | if (U02SV2 == 1) |
||
128 | Change_Output(Uart02FC); |
||
129 | else |
||
130 | Change_Output(Uart02Wi); |
||
131 | |||
132 | set_USBOn(); |
||
133 | return; |
||
134 | } |
||
135 | else |
||
136 | { |
||
137 | // lcd_printp_at (0, 0, PSTR("Es ist kein BTM-222 "), 0); |
||
138 | // lcd_printp_at (0, 1, PSTR("Modul eingebaut! "), 0); |
||
139 | // lcd_printp_at (0, 3, PSTR("Wenn doch, dann bitte"), 0); |
||
140 | // lcd_printp_at (0, 4, PSTR("das Modul zuerst im "), 0); |
||
141 | // lcd_printp_at (0, 5, PSTR("Setupmenü aktivieren."), 0); |
||
142 | lcd_puts_at(0, 1, strGet(CONNECT12), 0); |
||
143 | lcd_puts_at(0, 1, strGet(CONNECT13), 0); |
||
144 | lcd_puts_at(0, 2, strGet(CONNECT7), 0); |
||
145 | lcd_puts_at(0, 3, strGet(CONNECT8), 0); |
||
146 | lcd_puts_at(0, 4, strGet(CONNECT9), 0); |
||
147 | lcd_puts_at(12, 7, strGet(ENDE), 0); |
||
148 | // lcd_printp_at (12, 7, PSTR("Ende"), 0); |
||
149 | |||
150 | while(!get_key_press (1 << KEY_ESC)); |
||
151 | |||
152 | get_key_press(KEY_ALL); |
||
153 | return; |
||
154 | } |
||
155 | } |
||
156 | |||
157 | |||
158 | //-------------------------------------------------------------- |
||
159 | // Function: BT2Wi() |
||
160 | // Purpose: Connect BT direct to Wi.232 |
||
161 | // Returns: |
||
162 | //-------------------------------------------------------------- |
||
163 | void Port_BT2Wi(void) |
||
164 | { |
||
165 | |||
166 | lcd_cls (); |
||
167 | |||
168 | // if((UseBT == true) && (UseWi == true))6.1.2012 CB Abfrage entfernt, damit die Funktion auch ohne Module geht |
||
169 | { |
||
170 | // lcd_printp_at (0, 0, PSTR(" MK-USB Funktion "), 2); |
||
171 | lcd_puts_at(0, 0, strGet(CONNECT14), 2); |
||
172 | // lcd_printp_at (0, 1, PSTR(" BT --> Wi.232 "), 2); |
||
173 | lcd_puts_at(0, 1, strGet(CONNECT18), 2); |
||
174 | // lcd_printp_at (0, 3, PSTR("PC mit BT verbinden "), 0); |
||
175 | lcd_puts_at(0, 3, strGet(CONNECT16), 0); |
||
176 | // lcd_printp_at (0, 4, PSTR("Wi.232 an FC "), 0); |
||
177 | lcd_puts_at(0, 4, strGet(CONNECT19), 0); |
||
178 | // lcd_printp_at (0, 5, PSTR("MK-Tool starten "), 0); |
||
179 | lcd_puts_at(0, 5, strGet(CONNECT23), 0); |
||
180 | |||
181 | // lcd_printp_at (12, 7, PSTR("Esc"), 0); |
||
182 | lcd_puts_at(12, 7, strGet(ESC), 0); |
||
183 | set_BTOn(); |
||
184 | |||
185 | Change_Output(USB2Wi); |
||
1526 | - | 186 | do |
187 | { |
||
188 | show_Lipo(); |
||
189 | } |
||
1515 | - | 190 | while(!get_key_press (1 << KEY_ESC)); |
191 | |||
192 | get_key_press(KEY_ALL); |
||
193 | if (U02SV2 == 1) |
||
194 | Change_Output(Uart02FC); |
||
195 | else |
||
196 | Change_Output(Uart02Wi); |
||
197 | |||
198 | set_USBOn(); |
||
199 | return; |
||
200 | } |
||
201 | // else |
||
202 | // { |
||
203 | //// lcd_printp_at (0, 0, PSTR("Es ist kein BTM-222 "), 0); |
||
204 | //// lcd_printp_at (0, 1, PSTR("Modul eingebaut! "), 0); |
||
205 | //// lcd_printp_at (0, 3, PSTR("Wenn doch, dann bitte"), 0); |
||
206 | //// lcd_printp_at (0, 4, PSTR("das Modul zuerst im "), 0); |
||
207 | //// lcd_printp_at (0, 5, PSTR("Setupmenü aktivieren."), 0); |
||
208 | // |
||
209 | // lcd_puts_at(0, 0, strGet(CONNECT12), 0); |
||
210 | // lcd_puts_at(0, 1, strGet(CONNECT13), 0); |
||
211 | // lcd_puts_at(0, 2, strGet(CONNECT7), 0); |
||
212 | // lcd_puts_at(0, 3, strGet(CONNECT8), 0); |
||
213 | // lcd_puts_at(0, 4, strGet(CONNECT9), 0); |
||
214 | // lcd_puts_at(12, 7, strGet(ENDE), 0); |
||
215 | //// lcd_printp_at (12, 7, PSTR("Ende"), 0); |
||
216 | // |
||
217 | // while(!get_key_press (1 << KEY_ESC)); |
||
218 | // get_key_press(KEY_ALL); |
||
219 | // |
||
220 | // return; |
||
221 | // } |
||
222 | } |
||
223 | |||
224 | |||
225 | //-------------------------------------------------------------- |
||
226 | // Function: FC2CFG_BT() |
||
227 | // Purpose: Connect FC (Tx1 Pin3, Rx1 Pin4) direct to BT |
||
228 | // Returns: |
||
229 | //-------------------------------------------------------------- |
||
230 | void Port_FC2CFG_BT(void) |
||
231 | { |
||
232 | |||
233 | lcd_cls (); |
||
234 | lcd_printp_at (0, 0, PSTR("BTM-222 Konfigurieren"), 2); |
||
235 | lcd_printp_at (0, 1, PSTR("FC > MK-USB > BTM-222"), 2); |
||
236 | lcd_printp_at (0, 3, PSTR("MK-USB an PC anschl. "), 0); |
||
237 | lcd_printp_at (0, 4, PSTR("Zwischen MK-USB und "), 0); |
||
238 | lcd_printp_at (0, 5, PSTR("PKT ein gekreuztes "), 0); |
||
239 | lcd_printp_at (0, 6, PSTR("Kabel anschliessen. "), 0); |
||
240 | lcd_puts_at(12, 7, strGet(ESC), 0); |
||
241 | // lcd_printp_at (12, 7, PSTR("Esc"), 0); |
||
242 | |||
243 | set_BTOn(); |
||
244 | Change_Output(USB2FC); |
||
245 | |||
246 | while(!get_key_press (1 << KEY_ESC)); |
||
247 | |||
248 | get_key_press(KEY_ALL); |
||
249 | if (U02SV2 == 1) |
||
250 | Change_Output(Uart02FC); |
||
251 | else |
||
252 | Change_Output(Uart02Wi); |
||
253 | |||
254 | set_USBOn(); |
||
255 | return; |
||
256 | } |
||
257 | |||
258 | |||
259 | //-------------------------------------------------------------- |
||
260 | // Function: USB2FC() |
||
261 | // Purpose: Connect USB direct to FC-Kabel (SV2 as MKUSB) |
||
262 | // Returns: |
||
263 | //-------------------------------------------------------------- |
||
264 | void Port_USB2FC(void) |
||
265 | { |
||
266 | lcd_cls (); |
||
267 | // lcd_printp_at (0, 0, PSTR(" MK-USB Funktion "), 2); |
||
268 | lcd_puts_at(0, 0, strGet(CONNECT14), 2); |
||
269 | // lcd_printp_at (0, 1, PSTR(" USB --> Kabel an FC "), 2); |
||
270 | lcd_puts_at(0, 1, strGet(CONNECT20), 0); |
||
271 | // lcd_printp_at (0, 3, PSTR("PC mit USB verbinden "), 0); |
||
272 | lcd_puts_at(0, 3, strGet(CONNECT21), 0); |
||
273 | // lcd_printp_at (0, 4, PSTR("PKT-Kabel an FC "), 0); |
||
274 | lcd_puts_at(0, 4, strGet(CONNECT17), 0); |
||
275 | // lcd_printp_at (0, 5, PSTR("MK-Tool starten "), 0); |
||
276 | // lcd_printp_at (12, 7, PSTR("Esc"), 0); |
||
277 | lcd_puts_at(0, 5, strGet(CONNECT23), 0); |
||
278 | lcd_puts_at(12, 7, strGet(ESC), 0); |
||
279 | Change_Output(USB2FC); |
||
1526 | - | 280 | do |
281 | { |
||
282 | show_Lipo(); |
||
283 | } |
||
1515 | - | 284 | while(!get_key_press (1 << KEY_ESC)); |
285 | |||
286 | get_key_press(KEY_ALL); |
||
287 | if (U02SV2 == 1) |
||
288 | Change_Output(Uart02FC); |
||
289 | else |
||
290 | Change_Output(Uart02Wi); |
||
291 | |||
292 | return; |
||
293 | } |
||
294 | |||
295 | //-------------------------------------------------------------- |
||
296 | // Function: USB2Wi() |
||
297 | // Purpose: Connect USB direct to Wi.232 |
||
298 | // Returns: |
||
299 | //-------------------------------------------------------------- |
||
300 | void Port_USB2Wi(void) |
||
301 | { |
||
302 | |||
303 | lcd_cls (); |
||
304 | // if(UseWi == true) // 6.1.2012 CB Abfrage entfernt, damit die Funktion auch ohne Module geht |
||
305 | { |
||
306 | // lcd_printp_at (0, 0, PSTR(" MK-USB Funktion "), 2); |
||
307 | lcd_puts_at(0, 0, strGet(CONNECT14), 2); |
||
308 | // lcd_printp_at (0, 1, PSTR(" USB --> Wi.232 "), 2); |
||
309 | lcd_puts_at(0, 1, strGet(CONNECT22), 2); |
||
310 | // lcd_printp_at (0, 3, PSTR("PC mit USB verbinden "), 0); |
||
311 | lcd_puts_at(0, 3, strGet(CONNECT21), 0); |
||
312 | // lcd_printp_at (0, 4, PSTR("Wi.232 an FC "), 0); |
||
313 | lcd_puts_at(0, 4, strGet(CONNECT19), 0); |
||
314 | // lcd_printp_at (0, 5, PSTR("MK-Tool starten "), 0); |
||
315 | lcd_puts_at(0, 5, strGet(CONNECT23), 0); |
||
316 | lcd_puts_at(12, 7, strGet(ESC), 0); |
||
317 | // lcd_printp_at (12, 7, PSTR("Esc"), 0); |
||
318 | |||
319 | Change_Output(USB2Wi); |
||
1526 | - | 320 | do |
321 | { |
||
322 | show_Lipo(); |
||
323 | } |
||
1515 | - | 324 | while(!get_key_press (1 << KEY_ESC)); |
325 | |||
326 | get_key_press(KEY_ALL); |
||
327 | if (U02SV2 == 1) |
||
328 | Change_Output(Uart02FC); |
||
329 | else |
||
330 | Change_Output(Uart02Wi); |
||
331 | |||
332 | return; |
||
333 | } |
||
334 | // else |
||
335 | // { |
||
336 | //// lcd_printp_at (0, 0, PSTR("Es ist kein Wi.232 "), 0); |
||
337 | //// lcd_printp_at (0, 1, PSTR("Modul eingebaut! "), 0); |
||
338 | //// lcd_printp_at (0, 3, PSTR("Wenn doch, dann bitte"), 0); |
||
339 | //// lcd_printp_at (0, 4, PSTR("das Modul zuerst im "), 0); |
||
340 | //// lcd_printp_at (0, 5, PSTR("Setupmenü aktivieren."), 0); |
||
341 | //// lcd_printp_at (12, 7, PSTR("Ende"), 0); |
||
342 | // lcd_puts_at(0, 0, strGet(CONNECT5), 0); |
||
343 | // lcd_puts_at(0, 1, strGet(CONNECT6), 0); |
||
344 | // lcd_puts_at(0, 2, strGet(CONNECT7), 0); |
||
345 | // lcd_puts_at(0, 3, strGet(CONNECT8), 0); |
||
346 | // lcd_puts_at(0, 4, strGet(CONNECT9), 0); |
||
347 | // lcd_puts_at(12, 7, strGet(ENDE), 0); |
||
348 | // while(!get_key_press (1 << KEY_ESC)); |
||
349 | // get_key_press(KEY_ALL); |
||
350 | // |
||
351 | // return; |
||
352 | // } |
||
353 | } |
||
354 | |||
355 | //-------------------------------------------------------------- |
||
356 | // Function: USB2CFG_Wi() |
||
357 | // Purpose: Connect USB direct to Wi.232 in Progmode |
||
358 | // Returns: |
||
359 | //-------------------------------------------------------------- |
||
360 | void Port_USB2CFG_Wi(void) |
||
361 | { |
||
362 | |||
363 | lcd_cls (); |
||
364 | // lcd_printp_at (0, 0, PSTR(" Wi.232 Konfigurieren"), 2); |
||
365 | lcd_puts_at(0, 0, strGet(CONNECT24), 2); |
||
366 | // lcd_printp_at (0, 1, PSTR(" USB --> Wi.232 "), 2); |
||
367 | lcd_puts_at(0, 1, strGet(CONNECT22), 2); |
||
368 | // lcd_printp_at (0, 3, PSTR("PC mit USB verbinden."), 0); |
||
369 | lcd_puts_at(0, 3, strGet(CONNECT21), 0); |
||
370 | lcd_printp_at (0, 4, PSTR("Radiotronix Wi.232DTS"), 0); |
||
371 | lcd_printp_at (0, 5, PSTR("Evaluation (868MHz) "), 0); |
||
372 | // lcd_printp_at (0, 6, PSTR("Programm starten. "), 0); |
||
373 | lcd_puts_at(0, 6, strGet(CONNECT25), 0); |
||
374 | lcd_puts_at(12, 7, strGet(ESC), 0); |
||
375 | // lcd_printp_at (12, 7, PSTR("Esc"), 0); |
||
376 | |||
377 | Change_Output(USB2Wi); |
||
378 | |||
379 | set_WI232CMD(); // Port D6 = CMD |
||
380 | |||
381 | while(!get_key_press (1 << KEY_ESC)); |
||
382 | |||
383 | get_key_press(KEY_ALL); |
||
384 | clr_WI232CMD(); // Port D6 = CMD |
||
385 | |||
386 | if (U02SV2 == 1) |
||
387 | Change_Output(Uart02FC); |
||
388 | else |
||
389 | Change_Output(Uart02Wi); |
||
390 | |||
391 | return; |
||
392 | } |
||
393 | |||
394 | #endif |