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