Subversion Repositories Projects

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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