Subversion Repositories FlightCtrl

Rev

Rev 1424 | Rev 1438 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1424 Rev 1435
1
#ifndef _MAIN_H
1
#ifndef _MAIN_H
2
 #define _MAIN_H
2
 #define _MAIN_H
3
 
3
 
4
#define QUADRO
4
#define QUADRO
5
 
-
 
6
//Hier die Quarz Frequenz einstellen
-
 
7
#if defined (__AVR_ATmega32__)
-
 
8
#define SYSCLK  20000000L       //Quarz Frequenz in Hz
-
 
9
#endif
-
 
10
 
-
 
11
#if defined (__AVR_ATmega644__)
-
 
12
#define SYSCLK  20000000L       //Quarz Frequenz in Hz
-
 
13
#endif
-
 
14
 
-
 
15
#if defined (__AVR_ATmega644P__)
-
 
16
#define SYSCLK  20000000L       //Quarz Frequenz in Hz
-
 
17
#endif
-
 
18
 
5
 
19
// neue Hardware
6
// neue Hardware
20
#define ROT_OFF   {if((PlatinenVersion == 10)||(PlatinenVersion == 20)) PORTB &=~0x01; else  PORTB |= 0x01;}
7
#define ROT_OFF   {if((PlatinenVersion == 10)||(PlatinenVersion == 20)) PORTB &=~0x01; else  PORTB |= 0x01;}
21
#define ROT_ON    {if((PlatinenVersion == 10)||(PlatinenVersion == 20)) PORTB |= 0x01; else  PORTB &=~0x01;}
8
#define ROT_ON    {if((PlatinenVersion == 10)||(PlatinenVersion == 20)) PORTB |= 0x01; else  PORTB &=~0x01;}
22
#define ROT_FLASH PORTB ^= 0x01
9
#define ROT_FLASH PORTB ^= 0x01
23
#define GRN_OFF   {if((PlatinenVersion < 12)) PORTB &=~0x02; else PORTB |= 0x02;}
10
#define GRN_OFF   {if((PlatinenVersion < 12)) PORTB &=~0x02; else PORTB |= 0x02;}
24
#define GRN_ON    {if((PlatinenVersion < 12)) PORTB |= 0x02; else PORTB &=~0x02;}
11
#define GRN_ON    {if((PlatinenVersion < 12)) PORTB |= 0x02; else PORTB &=~0x02;}
25
#define GRN_FLASH PORTB ^= 0x02
12
#define GRN_FLASH PORTB ^= 0x02
26
 
13
 
27
#define F_CPU SYSCLK
-
 
28
//#ifndef F_CPU
-
 
29
//#error ################## F_CPU nicht definiert oder ungültig #############
14
#define SYSCLK F_CPU
30
//#endif
15
 
31
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
16
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32
#define EE_DATENREVISION 82 // Parameter fürs Koptertool; wird angepasst, wenn sich die EEPROM-Daten geändert haben
17
#define EE_DATENREVISION 82 // Parameter fürs Koptertool; wird angepasst, wenn sich die EEPROM-Daten geändert haben
33
#define MIXER_REVISION    1 // wird angepasst, wenn sich die Mixer-Daten geändert haben
18
#define MIXER_REVISION    1 // wird angepasst, wenn sich die Mixer-Daten geändert haben
34
 
19
 
35
#define EEPROM_ADR_VALID            1
20
#define EEPROM_ADR_VALID            1
36
#define EEPROM_ADR_ACTIVE_SET       2
21
#define EEPROM_ADR_ACTIVE_SET       2
37
#define EEPROM_ADR_LAST_OFFSET      3
22
#define EEPROM_ADR_LAST_OFFSET      3
38
 
23
 
39
#define EEPROM_ADR_ACC_NICK         4
24
#define EEPROM_ADR_ACC_NICK         4
40
#define EEPROM_ADR_ACC_ROLL         6
25
#define EEPROM_ADR_ACC_ROLL         6
41
#define EEPROM_ADR_ACC_Z            8
26
#define EEPROM_ADR_ACC_Z            8
42
#define EEPROM_ADR_MINUTES         10
27
#define EEPROM_ADR_MINUTES         10
43
#define EEPROM_ADR_MINUTES2        14
28
#define EEPROM_ADR_MINUTES2        14
44
 
29
 
45
#define EEPROM_ADR_CHANNELS          80
30
#define EEPROM_ADR_CHANNELS          80
46
 
31
 
47
#define EEPROM_ADR_PARAM_LENGTH      98
32
#define EEPROM_ADR_PARAM_LENGTH      98
48
#define EEPROM_ADR_PARAM_BEGIN      100
33
#define EEPROM_ADR_PARAM_BEGIN      100
49
 
34
 
50
#define EEPROM_ADR_MIXER_TABLE     1000 // 1001 - 1100
35
#define EEPROM_ADR_MIXER_TABLE     1000 // 1001 - 1100
51
 
36
 
52
#define CFG_HOEHENREGELUNG       0x01
37
#define CFG_HOEHENREGELUNG       0x01
53
#define CFG_HOEHEN_SCHALTER      0x02
38
#define CFG_HOEHEN_SCHALTER      0x02
54
#define CFG_HEADING_HOLD         0x04
39
#define CFG_HEADING_HOLD         0x04
55
#define CFG_KOMPASS_AKTIV        0x08
40
#define CFG_KOMPASS_AKTIV        0x08
56
#define CFG_KOMPASS_FIX          0x10
41
#define CFG_KOMPASS_FIX          0x10
57
#define CFG_GPS_AKTIV            0x20
42
#define CFG_GPS_AKTIV            0x20
58
#define CFG_ACHSENKOPPLUNG_AKTIV 0x40
43
#define CFG_ACHSENKOPPLUNG_AKTIV 0x40
59
#define CFG_DREHRATEN_BEGRENZER  0x80
44
#define CFG_DREHRATEN_BEGRENZER  0x80
60
 
45
 
61
#define CFG_LOOP_OBEN            0x01
46
#define CFG_LOOP_OBEN            0x01
62
#define CFG_LOOP_UNTEN           0x02
47
#define CFG_LOOP_UNTEN           0x02
63
#define CFG_LOOP_LINKS           0x04
48
#define CFG_LOOP_LINKS           0x04
64
#define CFG_LOOP_RECHTS          0x08
49
#define CFG_LOOP_RECHTS          0x08
65
#define CFG_MOTOR_BLINK          0x10
50
#define CFG_MOTOR_BLINK          0x10
66
#define CFG_MOTOR_OFF_LED1       0x20
51
#define CFG_MOTOR_OFF_LED1       0x20
67
#define CFG_MOTOR_OFF_LED2       0x40
52
#define CFG_MOTOR_OFF_LED2       0x40
68
#define CFG_RES4                         0x80
53
#define CFG_RES4                         0x80
69
 
54
 
70
#define CFG2_HEIGHT_LIMIT        0x01
55
#define CFG2_HEIGHT_LIMIT        0x01
71
#define CFG2_VARIO_BEEP          0x02
56
#define CFG2_VARIO_BEEP          0x02
72
#define CFG_SENSITIVE_RC         0x04
57
#define CFG_SENSITIVE_RC         0x04
73
 
58
 
74
#define J3High    PORTD |= 0x20
59
#define J3High    PORTD |= 0x20
75
#define J3Low     PORTD &= ~0x20
60
#define J3Low     PORTD &= ~0x20
76
#define J4High    PORTD |= 0x10
61
#define J4High    PORTD |= 0x10
77
#define J4Low     PORTD &= ~0x10
62
#define J4Low     PORTD &= ~0x10
78
#define J5High    PORTD |= 0x08
63
#define J5High    PORTD |= 0x08
79
#define J5Low     PORTD &= ~0x08
64
#define J5Low     PORTD &= ~0x08
80
 
-
 
81
 
-
 
82
//#define  SYSCLK
-
 
83
//extern unsigned long SYSCLK;
65
 
84
extern volatile unsigned char SenderOkay;
66
extern volatile unsigned char SenderOkay;
85
extern unsigned char BattLowVoltageWarning;
67
extern unsigned char BattLowVoltageWarning;
86
extern unsigned char CosinusNickWinkel, CosinusRollWinkel;
68
extern unsigned char CosinusNickWinkel, CosinusRollWinkel;
87
extern unsigned char PlatinenVersion;
69
extern unsigned char PlatinenVersion;
88
extern unsigned char SendVersionToNavi;
70
extern unsigned char SendVersionToNavi;
89
void ReadParameterSet (unsigned char number, unsigned char *buffer, unsigned char length);
71
void ReadParameterSet (unsigned char number, unsigned char *buffer, unsigned char length);
90
void WriteParameterSet(unsigned char number, unsigned char *buffer, unsigned char length);
72
void WriteParameterSet(unsigned char number, unsigned char *buffer, unsigned char length);
91
extern unsigned char GetActiveParamSetNumber(void);
73
extern unsigned char GetActiveParamSetNumber(void);
92
void SetActiveParamSetNumber(unsigned char number);
74
void SetActiveParamSetNumber(unsigned char number);
93
void LipoDetection(unsigned char print);
75
void LipoDetection(unsigned char print);
94
extern unsigned char EEPromArray[];
76
extern unsigned char EEPromArray[];
95
extern unsigned int FlugMinuten,FlugMinutenGesamt;
77
extern unsigned int FlugMinuten,FlugMinutenGesamt;
96
 
78
 
97
#include <stdlib.h>
79
#include <stdlib.h>
98
#include <string.h>
80
#include <string.h>
99
#include <avr/io.h>
81
#include <avr/io.h>
100
#include <avr/pgmspace.h>
82
#include <avr/pgmspace.h>
101
#include <avr/interrupt.h>
83
#include <avr/interrupt.h>
102
#include <avr/eeprom.h>
84
#include <avr/eeprom.h>
103
#include <avr/boot.h>
85
#include <avr/boot.h>
104
#include <avr/wdt.h>
86
#include <avr/wdt.h>
105
 
87
 
106
#include "old_macros.h"
88
#include "old_macros.h"
107
 
89
 
108
#include "_Settings.h"
90
#include "_Settings.h"
109
#include "printf_P.h"
91
#include "printf_P.h"
110
#include "timer0.h"
92
#include "timer0.h"
111
#include "uart.h"
93
#include "uart.h"
112
#include "analog.h"
94
#include "analog.h"
113
#include "twimaster.h"
95
#include "twimaster.h"
114
#include "menu.h"
96
#include "menu.h"
115
#include "rc.h"
97
#include "rc.h"
116
#include "fc.h"
98
#include "fc.h"
117
#include "gps.h"
99
#include "gps.h"
118
#include "spi.h"
100
#include "spi.h"
119
#include "led.h"
101
#include "led.h"
120
#include "spektrum.h"
102
#include "spektrum.h"
121
#include "libfcinit.h"
103
#include "libfc.h"
122
 
104
 
123
 
105
 
124
#ifndef EEMEM
106
#ifndef EEMEM
125
#define EEMEM __attribute__ ((section (".eeprom")))
107
#define EEMEM __attribute__ ((section (".eeprom")))
126
#endif
108
#endif
127
 
109
 
128
#define DEBUG_DISPLAY_INTERVALL  123 // in ms
110
#define DEBUG_DISPLAY_INTERVALL  123 // in ms
129
 
111
 
130
 
112
 
131
#define DELAY_US(x)     ((unsigned int)( (x) * 1e-6 * F_CPU ))
113
#define DELAY_US(x)     ((unsigned int)( (x) * 1e-6 * F_CPU ))
132
 
114
 
133
#endif //_MAIN_H
115
#endif //_MAIN_H
134
 
116
 
135
 
117
 
136
 
118
 
137
 
119
 
138
 
120
 
139
 
121
 
140
 
122