Subversion Repositories FlightCtrl

Rev

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

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