Subversion Repositories Projects

Rev

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

Rev Author Line No. Line
2136 - 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
//# HISTORY  main.c
36
//#
37
//# 14.05.2014 OG
38
//# - chg: include "mk/mksettings.h" geaendert auf "mksettings/mksettings.h"
39
//#
40
//# 29.03.2014 OG
41
//# - chg: MK_Show_LastGPS_Position() ersetzt durch OSDDATA_ShowLastGPSPosition()
42
//#
43
//# 28.03.2014 OG
44
//# - chg: mk_last_position() ersetzt durch MK_Show_LastGPS_Position() (mkbase.c)
45
//# - del: mk_last_position()
46
//#
47
//# 21.02.2014 OG
48
//# - chg: mk_show_lastposition() auf PKT_TitlePKTVersion() angepasst
49
//#
50
//# 19.02.2014 OG
51
//# - chg: main() hinzugefuegt: MKSettings_TMP_Init0()
52
//# - add: #include "mk/mksettings.h"
53
//#
54
//# 12.02.2014 OG
55
//# - del: die includes zu den alten parameter... entfernt
56
//#
57
//# 11.02.2014 OG
58
//# - chg: main() Aufruf von searchMK() bzgl. Parametern angepasst
59
//#
60
//# 03.02.2014 OG
61
//# - chg: Titelanzeige in searchMK() umgestellt auf PKT_ShowTitlePKTVersion()
62
//#
63
//# 02.02.2014 OG
64
//# - chg: Screen-Layout von der Anzeige der letzten MK-Position und
65
//#        Ausgliederung davon in mk_show_lastposition()
66
//#
67
//# 29.01.2014 OG
68
//# - del: #include "display.h"
69
//# - chg: verschoben: MK_load_setting() und searchMK() nach mk/mkbase.c
70
//# - add: #include "mk/mkbase.h"
71
//#
72
//# 25.01.2014 OG
73
//# - chg: searchMK(): kuerzerer Fehlerbeep bei falscher FC-Revision und
74
//#        automatisches beenden des Fehlerscreens nach 4 Sekunden
75
//#
76
//# 24.01.2014 OG
77
//# - fix: searchMK(): wenn MK_load_setting() keine Daten liefert wird keine
78
//#        falsche RC-Settings-Revisionsnummer mehr angezeigt sondern "ERR!"
79
//# - chg: searchMK(): Bestaetigung Fehleranzeige bei falscher FC-Revision
80
//#        geaendert von KEY_ESC nach KEY_ENTER - Grund: das PKT behandelt
81
//#        dieses Problem nun flexibler und z.B. OSD (und anderes) geht noch
82
//# - chg: searchMK(): beschleunigte Erkennung inkompatibler FC-Settings-Revisionen
83
//# - chg: timings in MK_load_setting()
84
//#
85
//# 07.1.2016 Cebra
86
//# - chg: setzen globale Variable für Abfrage WrongFCVersion etwas verändert
87
//#
88
//# 26.06.2013 OG
89
//# - del: searchMK() Layout und Code-Struktur
90
//# - fix: searchMK() laden der MK-Settings
91
//# - add: MK_load_setting() - wird ggf. spaeter zu einer bessern Stelle verschoben
92
//# - del: Code zu USE_PKT_STARTINFO
93
//#
94
//# 20.05.2013 OG
95
//# - chg: searchMK() Code fuer KEY_ESC geaendert
96
//#
97
//# 19.05.2013 OG
98
//# - del: PKT_Update(), PKT_CheckUpdate(), PKT_Info(), PKT_SwitchOff()
99
//#        -> verschoben nach pkt/pkt.c
100
//# - chg: Aufruf von main_menu() geaendert zu Menu_Main()
101
//#
102
//# 19.05.2013 OG
103
//# - add: PKT_Update(), PKT_CheckUpdate(), PKT_Info(), PKT_SwitchOff()
104
//#
105
//# 16.05.2013 Cebra
106
//# - chg: Startinfo wird nur noch komplett angezeigt wenn im Setup auf JA
107
//#
108
//# 15.05.2013 OG
109
//# - chg: define USE_PKT_STARTINFO ergaenzt (siehe main.h)
110
//#
111
//# 07.05.2013 Cebra
112
//# - chg: wenn NC vorhanden wird die Version der NC in NCversion gespeichert
113
//#        sonst die FC-Version in FCversion
114
//#
115
//# 27.04.2013 OG
116
//# - chg: GPS-Positionsausgabe umgestellt auf writex_gpspos()
117
//# - chg: einige clear-lines auf lcd_frect() umgestellt um Speicher zu sparen
118
//############################################################################
119
 
120
 
121
#include "cpu.h"
122
#include <avr/io.h>
123
#include <inttypes.h>
124
#include <stdlib.h>
125
#include <avr/pgmspace.h>
126
#include <avr/wdt.h>
127
#include <util/delay.h>
128
#include <avr/eeprom.h>
129
 
130
 
131
//************************************************************************************
132
// Watchdog integrieren und abschalten, wird für Bootloader benötigt
133
// !!muss hier stehen bleiben!!
134
 
135
//--------------------------------------------------------------
136
void wdt_init(void) __attribute__((naked)) __attribute__((section(".init1")));
137
 
138
//--------------------------------------------------------------
139
void wdt_init(void)
140
{
141
    MCUSR = 0;
142
    wdt_disable();
143
    return;
144
}
145
 
146
//************************************************************************************
147
// erst ab hier weitere #includes
148
 
149
 
150
#include "main.h"
151
#include "lcd/lcd.h"
152
#include "uart/usart.h"
153
#include "mk-data-structs.h"
154
#include "menu.h"
155
#include "timer/timer.h"
156
#include "eeprom/eeprom.h"
157
#include "wi232/Wi232.h"
158
#include "motortest/twimaster.h"
159
#include "messages.h"
160
#include "utils/scrollbox.h"
161
#include "pkt/pkt.h"
162
#include "lipo/lipo.h"
163
#include "mk/mkbase.h"
164
#include "mksettings/mksettings.h"
165
#include "osd/osddata.h"
166
 
167
 
168
 
169
//----------------------------------------------------------------------------
170
// Anmerkung: 29.01.2014 OG
171
// - muss spaeter an geeignete Stelle verschoben werden (ggf. mkbase.c/usart.c)
172
//----------------------------------------------------------------------------
173
volatile uint8_t mode = 0;
174
uint8_t hardware = 0;
175
uint8_t current_hardware = 0;
176
 
177
 
178
 
179
//--------------------------------------------------------------
180
//--------------------------------------------------------------
181
int main(void)
182
{
183
    InitHWPorts();                      // Hardwareanhängige Ports konfigurieren
184
                                        // dafür wird je nach Hardware die HAL_HWxxx verwendet
185
                                        // Define dazu in der main.h
186
    hardware = NO;
187
    current_hardware = 0;
188
 
189
    MKSettings_TMP_Init0();             // TMP-Setting initialisieren
190
 
191
    if( Config.LastLongitude>0x00000000 && Config.LastLatitude>0x00000000 )
192
    {
193
        OSDDATA_ShowLastGPSPosition();  // letzte MK GPS-Position zeigen
194
    }
195
 
196
    searchMK(true);                     // MK suchen (true = MK_Info() anzeigen)
197
 
198
    while(true)
199
    {
200
        Menu_Main();
201
    }
202
}