Rev 1515 |
Blame |
Last modification |
View Log
| RSS feed
/*****************************************************************************
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de *
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net *
* Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net *
* Copyright (C) 2011 Harald Bongartz *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
* *
* Credits to: *
* Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN *
* http://www.mikrokopter.de *
* Gregor "killagreg" Stobrawa for his version of the MK code *
* Thomas Kaiser "thkais" for the original project. See *
* http://www.ft-fanpage.de/mikrokopter/ *
* http://forum.mikrokopter.de/topic-4061-1.html *
* Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code *
* http://www.mylifesucks.de/oss/c-osd/ *
* Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility*
*****************************************************************************/
#include "cpu.h"
#include <avr/pgmspace.h>
#include "lcd.h"
#include "timer.h"
#include "eeprom.h"
#include "messages.h"
#include "lipo.h"
#if defined HWVERSION1_3W || defined HWVERSION3_9
//--------------------------------------------------------------
void Change_Output(uint8_t UartMode) // Schaltet die Rx/Tx Richtungen
{
// hiermit werden die 74HTC125 (IC5) Gatter geschaltet
clr_USB2FC(); // PC2 aus
clr_USB2Wi(); // PB0 aus
clr_Uart02FC(); // PC6 aus
clr_Uart02Wi(); // PC5 aus
switch (UartMode)
{
case USB2FC:
UCSR1B &= ~(1<<RXEN1);
UCSR1B &= ~(1<<TXEN1);
UCSR1B &= ~(1<<RXCIE1);
DDRD &= ~(1<<DDD2); // Pins auf Eingang setzen
DDRD &= ~(1<<DDD3);
PORTD &= ~(1<<PD2); // Pullup aus
PORTD &= ~(1<<PD3);
set_USB2FC();
break;
case Uart02Wi:
set_Uart02Wi();
break;
case Uart02FC:
set_Uart02FC();
break;
case USB2Wi:
UCSR1B &= ~(1<<RXEN1);
UCSR1B &= ~(1<<TXEN1);
UCSR1B &= ~(1<<RXCIE1);
DDRD &= ~(1<<DDD2); // Pins auf Eingang setzen
DDRD &= ~(1<<DDD3);
PORTD &= ~(1<<PD2); // Pullup aus
PORTD &= ~(1<<PD3);
set_USB2Wi();
break;
}
}
//--------------------------------------------------------------
// Function: BT2FC()
// Purpose: Connect BT direct to FC-Kabel (SV2 as MKUSB)
// Returns:
//--------------------------------------------------------------
void Port_BT2FC(void)
{
lcd_cls ();
if(UseBT == true)
{
// lcd_printp_at (0, 0, PSTR(" MK-USB Funktion "), 2);
lcd_puts_at(0, 0, strGet(CONNECT14), 2);
// lcd_printp_at (0, 1, PSTR(" BT --> Kabel an FC "), 2);
lcd_puts_at(0, 1, strGet(CONNECT15), 0);
// lcd_printp_at (0, 3, PSTR("PC mit BT verb."), 0);
lcd_puts_at(0, 3, strGet(CONNECT16), 0);
// lcd_printp_at (0, 4, PSTR("PKT-Kabel an FC"), 0);
lcd_puts_at(0, 4, strGet(CONNECT17), 0);
// lcd_printp_at (0, 5, PSTR("MK-Tool starten"), 0);
// lcd_printp_at (12, 7, PSTR("Esc"), 0);
lcd_puts_at(0, 5, strGet(CONNECT23), 0);
lcd_puts_at(12, 7, strGet(ESC), 0);
set_BTOn();
Change_Output(USB2FC);
do
{
show_Lipo();
}
while(!get_key_press (1 << KEY_ESC));
get_key_press(KEY_ALL);
if (U02SV2 == 1)
Change_Output(Uart02FC);
else
Change_Output(Uart02Wi);
set_USBOn();
return;
}
else
{
// lcd_printp_at (0, 0, PSTR("Es ist kein BTM-222 "), 0);
// lcd_printp_at (0, 1, PSTR("Modul eingebaut! "), 0);
// lcd_printp_at (0, 3, PSTR("Wenn doch, dann bitte"), 0);
// lcd_printp_at (0, 4, PSTR("das Modul zuerst im "), 0);
// lcd_printp_at (0, 5, PSTR("Setupmenü aktivieren."), 0);
lcd_puts_at(0, 1, strGet(CONNECT12), 0);
lcd_puts_at(0, 1, strGet(CONNECT13), 0);
lcd_puts_at(0, 2, strGet(CONNECT7), 0);
lcd_puts_at(0, 3, strGet(CONNECT8), 0);
lcd_puts_at(0, 4, strGet(CONNECT9), 0);
lcd_puts_at(12, 7, strGet(ENDE), 0);
// lcd_printp_at (12, 7, PSTR("Ende"), 0);
while(!get_key_press (1 << KEY_ESC));
get_key_press(KEY_ALL);
return;
}
}
//--------------------------------------------------------------
// Function: BT2Wi()
// Purpose: Connect BT direct to Wi.232
// Returns:
//--------------------------------------------------------------
void Port_BT2Wi(void)
{
lcd_cls ();
// if((UseBT == true) && (UseWi == true))6.1.2012 CB Abfrage entfernt, damit die Funktion auch ohne Module geht
{
// lcd_printp_at (0, 0, PSTR(" MK-USB Funktion "), 2);
lcd_puts_at(0, 0, strGet(CONNECT14), 2);
// lcd_printp_at (0, 1, PSTR(" BT --> Wi.232 "), 2);
lcd_puts_at(0, 1, strGet(CONNECT18), 2);
// lcd_printp_at (0, 3, PSTR("PC mit BT verbinden "), 0);
lcd_puts_at(0, 3, strGet(CONNECT16), 0);
// lcd_printp_at (0, 4, PSTR("Wi.232 an FC "), 0);
lcd_puts_at(0, 4, strGet(CONNECT19), 0);
// lcd_printp_at (0, 5, PSTR("MK-Tool starten "), 0);
lcd_puts_at(0, 5, strGet(CONNECT23), 0);
// lcd_printp_at (12, 7, PSTR("Esc"), 0);
lcd_puts_at(12, 7, strGet(ESC), 0);
set_BTOn();
Change_Output(USB2Wi);
do
{
show_Lipo();
}
while(!get_key_press (1 << KEY_ESC));
get_key_press(KEY_ALL);
if (U02SV2 == 1)
Change_Output(Uart02FC);
else
Change_Output(Uart02Wi);
set_USBOn();
return;
}
// else
// {
//// lcd_printp_at (0, 0, PSTR("Es ist kein BTM-222 "), 0);
//// lcd_printp_at (0, 1, PSTR("Modul eingebaut! "), 0);
//// lcd_printp_at (0, 3, PSTR("Wenn doch, dann bitte"), 0);
//// lcd_printp_at (0, 4, PSTR("das Modul zuerst im "), 0);
//// lcd_printp_at (0, 5, PSTR("Setupmenü aktivieren."), 0);
//
// lcd_puts_at(0, 0, strGet(CONNECT12), 0);
// lcd_puts_at(0, 1, strGet(CONNECT13), 0);
// lcd_puts_at(0, 2, strGet(CONNECT7), 0);
// lcd_puts_at(0, 3, strGet(CONNECT8), 0);
// lcd_puts_at(0, 4, strGet(CONNECT9), 0);
// lcd_puts_at(12, 7, strGet(ENDE), 0);
//// lcd_printp_at (12, 7, PSTR("Ende"), 0);
//
// while(!get_key_press (1 << KEY_ESC));
// get_key_press(KEY_ALL);
//
// return;
// }
}
//--------------------------------------------------------------
// Function: FC2CFG_BT()
// Purpose: Connect FC (Tx1 Pin3, Rx1 Pin4) direct to BT
// Returns:
//--------------------------------------------------------------
void Port_FC2CFG_BT(void)
{
lcd_cls ();
lcd_printp_at (0, 0, PSTR("BTM-222 Konfigurieren"), 2);
lcd_printp_at (0, 1, PSTR("FC > MK-USB > BTM-222"), 2);
lcd_printp_at (0, 3, PSTR("MK-USB an PC anschl. "), 0);
lcd_printp_at (0, 4, PSTR("Zwischen MK-USB und "), 0);
lcd_printp_at (0, 5, PSTR("PKT ein gekreuztes "), 0);
lcd_printp_at (0, 6, PSTR("Kabel anschliessen. "), 0);
lcd_puts_at(12, 7, strGet(ESC), 0);
// lcd_printp_at (12, 7, PSTR("Esc"), 0);
set_BTOn();
Change_Output(USB2FC);
while(!get_key_press (1 << KEY_ESC));
get_key_press(KEY_ALL);
if (U02SV2 == 1)
Change_Output(Uart02FC);
else
Change_Output(Uart02Wi);
set_USBOn();
return;
}
//--------------------------------------------------------------
// Function: USB2FC()
// Purpose: Connect USB direct to FC-Kabel (SV2 as MKUSB)
// Returns:
//--------------------------------------------------------------
void Port_USB2FC(void)
{
lcd_cls ();
// lcd_printp_at (0, 0, PSTR(" MK-USB Funktion "), 2);
lcd_puts_at(0, 0, strGet(CONNECT14), 2);
// lcd_printp_at (0, 1, PSTR(" USB --> Kabel an FC "), 2);
lcd_puts_at(0, 1, strGet(CONNECT20), 0);
// lcd_printp_at (0, 3, PSTR("PC mit USB verbinden "), 0);
lcd_puts_at(0, 3, strGet(CONNECT21), 0);
// lcd_printp_at (0, 4, PSTR("PKT-Kabel an FC "), 0);
lcd_puts_at(0, 4, strGet(CONNECT17), 0);
// lcd_printp_at (0, 5, PSTR("MK-Tool starten "), 0);
// lcd_printp_at (12, 7, PSTR("Esc"), 0);
lcd_puts_at(0, 5, strGet(CONNECT23), 0);
lcd_puts_at(12, 7, strGet(ESC), 0);
Change_Output(USB2FC);
do
{
show_Lipo();
}
while(!get_key_press (1 << KEY_ESC));
get_key_press(KEY_ALL);
if (U02SV2 == 1)
Change_Output(Uart02FC);
else
Change_Output(Uart02Wi);
return;
}
//--------------------------------------------------------------
// Function: USB2Wi()
// Purpose: Connect USB direct to Wi.232
// Returns:
//--------------------------------------------------------------
void Port_USB2Wi(void)
{
lcd_cls ();
// if(UseWi == true) // 6.1.2012 CB Abfrage entfernt, damit die Funktion auch ohne Module geht
{
// lcd_printp_at (0, 0, PSTR(" MK-USB Funktion "), 2);
lcd_puts_at(0, 0, strGet(CONNECT14), 2);
// lcd_printp_at (0, 1, PSTR(" USB --> Wi.232 "), 2);
lcd_puts_at(0, 1, strGet(CONNECT22), 2);
// lcd_printp_at (0, 3, PSTR("PC mit USB verbinden "), 0);
lcd_puts_at(0, 3, strGet(CONNECT21), 0);
// lcd_printp_at (0, 4, PSTR("Wi.232 an FC "), 0);
lcd_puts_at(0, 4, strGet(CONNECT19), 0);
// lcd_printp_at (0, 5, PSTR("MK-Tool starten "), 0);
lcd_puts_at(0, 5, strGet(CONNECT23), 0);
lcd_puts_at(12, 7, strGet(ESC), 0);
// lcd_printp_at (12, 7, PSTR("Esc"), 0);
Change_Output(USB2Wi);
do
{
show_Lipo();
}
while(!get_key_press (1 << KEY_ESC));
get_key_press(KEY_ALL);
if (U02SV2 == 1)
Change_Output(Uart02FC);
else
Change_Output(Uart02Wi);
return;
}
// else
// {
//// lcd_printp_at (0, 0, PSTR("Es ist kein Wi.232 "), 0);
//// lcd_printp_at (0, 1, PSTR("Modul eingebaut! "), 0);
//// lcd_printp_at (0, 3, PSTR("Wenn doch, dann bitte"), 0);
//// lcd_printp_at (0, 4, PSTR("das Modul zuerst im "), 0);
//// lcd_printp_at (0, 5, PSTR("Setupmenü aktivieren."), 0);
//// lcd_printp_at (12, 7, PSTR("Ende"), 0);
// lcd_puts_at(0, 0, strGet(CONNECT5), 0);
// lcd_puts_at(0, 1, strGet(CONNECT6), 0);
// lcd_puts_at(0, 2, strGet(CONNECT7), 0);
// lcd_puts_at(0, 3, strGet(CONNECT8), 0);
// lcd_puts_at(0, 4, strGet(CONNECT9), 0);
// lcd_puts_at(12, 7, strGet(ENDE), 0);
// while(!get_key_press (1 << KEY_ESC));
// get_key_press(KEY_ALL);
//
// return;
// }
}
//--------------------------------------------------------------
// Function: USB2CFG_Wi()
// Purpose: Connect USB direct to Wi.232 in Progmode
// Returns:
//--------------------------------------------------------------
void Port_USB2CFG_Wi(void)
{
lcd_cls ();
// lcd_printp_at (0, 0, PSTR(" Wi.232 Konfigurieren"), 2);
lcd_puts_at(0, 0, strGet(CONNECT24), 2);
// lcd_printp_at (0, 1, PSTR(" USB --> Wi.232 "), 2);
lcd_puts_at(0, 1, strGet(CONNECT22), 2);
// lcd_printp_at (0, 3, PSTR("PC mit USB verbinden."), 0);
lcd_puts_at(0, 3, strGet(CONNECT21), 0);
lcd_printp_at (0, 4, PSTR("Radiotronix Wi.232DTS"), 0);
lcd_printp_at (0, 5, PSTR("Evaluation (868MHz) "), 0);
// lcd_printp_at (0, 6, PSTR("Programm starten. "), 0);
lcd_puts_at(0, 6, strGet(CONNECT25), 0);
lcd_puts_at(12, 7, strGet(ESC), 0);
// lcd_printp_at (12, 7, PSTR("Esc"), 0);
Change_Output(USB2Wi);
set_WI232CMD(); // Port D6 = CMD
while(!get_key_press (1 << KEY_ESC));
get_key_press(KEY_ALL);
clr_WI232CMD(); // Port D6 = CMD
if (U02SV2 == 1)
Change_Output(Uart02FC);
else
Change_Output(Uart02Wi);
return;
}
#endif